mirror of
https://github.com/ipxe/ipxe
synced 2026-02-28 03:11:18 +03:00
[acpi] Add acpi_ioremap() to map an ACPI-described address
An ACPI Generic Address Structure (GAS) may be used to describe the location of a peripheral such as an early boot console. Add the relevant definitions and provide acpi_ioremap() as a helper function to map a region described using this structure. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -27,6 +27,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <byteswap.h>
|
#include <byteswap.h>
|
||||||
#include <ipxe/uaccess.h>
|
#include <ipxe/uaccess.h>
|
||||||
|
#include <ipxe/iomap.h>
|
||||||
#include <ipxe/acpi.h>
|
#include <ipxe/acpi.h>
|
||||||
#include <ipxe/interface.h>
|
#include <ipxe/interface.h>
|
||||||
|
|
||||||
@@ -258,6 +259,24 @@ int acpi_extract ( uint32_t signature, void *data,
|
|||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map an ACPI generic address
|
||||||
|
*
|
||||||
|
* @v address Generic address
|
||||||
|
* @v len Length of region
|
||||||
|
* @ret io_addr I/O address, or NULL on error
|
||||||
|
*/
|
||||||
|
void * acpi_ioremap ( struct acpi_address *address, size_t len ) {
|
||||||
|
physaddr_t base = le64_to_cpu ( address->address );
|
||||||
|
|
||||||
|
switch ( address->type ) {
|
||||||
|
case ACPI_ADDRESS_TYPE_MEM:
|
||||||
|
return ioremap ( base, len );
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
*
|
*
|
||||||
* Descriptors
|
* Descriptors
|
||||||
|
|||||||
@@ -18,6 +18,29 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
#include <ipxe/api.h>
|
#include <ipxe/api.h>
|
||||||
#include <config/general.h>
|
#include <config/general.h>
|
||||||
|
|
||||||
|
/** An ACPI generic address structure */
|
||||||
|
struct acpi_address {
|
||||||
|
/** Address space type */
|
||||||
|
uint8_t type;
|
||||||
|
/** Register bit width */
|
||||||
|
uint8_t width;
|
||||||
|
/** Register bit offset */
|
||||||
|
uint8_t offset;
|
||||||
|
/** Access size */
|
||||||
|
uint8_t access;
|
||||||
|
/** Address */
|
||||||
|
uint64_t address;
|
||||||
|
} __attribute__ (( packed ));
|
||||||
|
|
||||||
|
/** A memory address space type */
|
||||||
|
#define ACPI_ADDRESS_TYPE_MEM 0x00
|
||||||
|
|
||||||
|
/** An I/O address space type */
|
||||||
|
#define ACPI_ADDRESS_TYPE_IO 0x01
|
||||||
|
|
||||||
|
/** A bus number address space type */
|
||||||
|
#define ACPI_ADDRESS_TYPE_BUS 0x02
|
||||||
|
|
||||||
/** An ACPI small resource descriptor header */
|
/** An ACPI small resource descriptor header */
|
||||||
struct acpi_small_resource {
|
struct acpi_small_resource {
|
||||||
/** Tag byte */
|
/** Tag byte */
|
||||||
@@ -74,12 +97,6 @@ struct acpi_qword_address_space_resource {
|
|||||||
uint64_t len;
|
uint64_t len;
|
||||||
} __attribute__ (( packed ));
|
} __attribute__ (( packed ));
|
||||||
|
|
||||||
/** A memory address space type */
|
|
||||||
#define ACPI_ADDRESS_TYPE_MEM 0x00
|
|
||||||
|
|
||||||
/** A bus number address space type */
|
|
||||||
#define ACPI_ADDRESS_TYPE_BUS 0x02
|
|
||||||
|
|
||||||
/** An ACPI resource descriptor */
|
/** An ACPI resource descriptor */
|
||||||
union acpi_resource {
|
union acpi_resource {
|
||||||
/** Tag byte */
|
/** Tag byte */
|
||||||
@@ -397,6 +414,7 @@ extern int acpi_extract ( uint32_t signature, void *data,
|
|||||||
int ( * extract ) ( const struct acpi_header *zsdt,
|
int ( * extract ) ( const struct acpi_header *zsdt,
|
||||||
size_t len, size_t offset,
|
size_t len, size_t offset,
|
||||||
void *data ) );
|
void *data ) );
|
||||||
|
extern void * acpi_ioremap ( struct acpi_address *address, size_t len );
|
||||||
extern void acpi_add ( struct acpi_descriptor *desc );
|
extern void acpi_add ( struct acpi_descriptor *desc );
|
||||||
extern void acpi_del ( struct acpi_descriptor *desc );
|
extern void acpi_del ( struct acpi_descriptor *desc );
|
||||||
extern int acpi_install ( int ( * install ) ( struct acpi_header *acpi ) );
|
extern int acpi_install ( int ( * install ) ( struct acpi_header *acpi ) );
|
||||||
|
|||||||
Reference in New Issue
Block a user