Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
acpi.h File Reference
#include <acpica/source/include/acpi.h>
#include <zephyr/drivers/pcie/pcie.h>

Go to the source code of this file.

Data Structures

struct  acpi_dev
 
union  acpi_dmar_id
 
struct  acpi_mcfg
 
struct  acpi_irq_resource
 
struct  acpi_reg_base
 
struct  acpi_mmio_resource
 

Macros

#define ACPI_RES_INVALID   ACPI_RESOURCE_TYPE_MAX
 
#define ACPI_DRHD_FLAG_INCLUDE_PCI_ALL   BIT(0)
 
#define ACPI_DMAR_FLAG_INTR_REMAP   BIT(0)
 
#define ACPI_DMAR_FLAG_X2APIC_OPT_OUT   BIT(1)
 
#define ACPI_DMAR_FLAG_DMA_CTRL_PLATFORM_OPT_IN   BIT(2)
 
#define ACPI_MMIO_GET(res)
 
#define ACPI_IO_GET(res)
 
#define ACPI_RESOURCE_SIZE_GET(res)
 
#define ACPI_RESOURCE_TYPE_GET(res)
 
#define ACPI_MULTI_MMIO_GET(res, idx)
 
#define ACPI_MULTI_IO_GET(res, idx)
 
#define ACPI_MULTI_RESOURCE_SIZE_GET(res, idx)
 
#define ACPI_MULTI_RESOURCE_TYPE_GET(res, idx)
 
#define ACPI_RESOURCE_COUNT_GET(res)
 
#define ACPI_DT_HID(node_id)
 Get the ACPI HID for a node.
 
#define ACPI_DT_UID(node_id)
 Get the ACPI UID for a node if one exist.
 
#define ACPI_DT_HAS_HID(node_id)
 check whether the node has ACPI HID property or not
 
#define ACPI_DT_HAS_UID(node_id)
 check whether the node has ACPI UID property or not
 

Typedefs

typedef void(* dmar_foreach_subtable_func_t) (ACPI_DMAR_HEADER *subtable, void *arg)
 
typedef void(* dmar_foreach_devscope_func_t) (ACPI_DMAR_DEVICE_SCOPE *devscope, void *arg)
 

Enumerations

enum  acpi_res_type { ACPI_RES_TYPE_IO , ACPI_RES_TYPE_MEM , ACPI_RES_TYPE_UNKNOWN }
 

Functions

int acpi_legacy_irq_init (const char *hid, const char *uid)
 Init legacy interrupt routing table information from ACPI.
 
uint32_t acpi_legacy_irq_get (pcie_bdf_t bdf)
 Retrieve a legacy interrupt number for a PCI device.
 
int acpi_current_resource_get (char *dev_name, ACPI_RESOURCE **res)
 Retrieve the current resource settings of a device.
 
int acpi_possible_resource_get (char *dev_name, ACPI_RESOURCE **res)
 Retrieve possible resource settings of a device.
 
int acpi_current_resource_free (ACPI_RESOURCE *res)
 Free current resource list memory which is retrieved by acpi_current_resource_get().
 
ACPI_RESOURCE * acpi_resource_parse (ACPI_RESOURCE *res, int res_type)
 Parse resource table for a given resource type.
 
struct acpi_devacpi_device_get (const char *hid, const char *uid)
 Retrieve ACPI device info for given hardware id and unique id.
 
struct acpi_devacpi_device_by_index_get (int index)
 Retrieve acpi device info from the index.
 
static ACPI_RESOURCE_IRQ * acpi_irq_res_get (ACPI_RESOURCE *res_lst)
 Parse resource table for irq info.
 
int acpi_device_irq_get (struct acpi_dev *child_dev, struct acpi_irq_resource *irq_res)
 Parse resource table for irq info.
 
int acpi_device_mmio_get (struct acpi_dev *child_dev, struct acpi_mmio_resource *mmio_res)
 Parse resource table for MMIO info.
 
int acpi_device_type_get (ACPI_RESOURCE *res)
 Parse resource table for identify resource type.
 
void * acpi_table_get (char *signature, int inst)
 Retrieve acpi table for the given signature.
 
int acpi_madt_entry_get (int type, ACPI_SUBTABLE_HEADER **tables, int *num_inst)
 retrieve acpi MAD table for the given type.
 
int acpi_dmar_entry_get (enum AcpiDmarType type, ACPI_SUBTABLE_HEADER **tables)
 retrieve DMA remapping structure for the given type.
 
int acpi_drhd_get (enum AcpiDmarScopeType scope, ACPI_DMAR_DEVICE_SCOPE *dev_scope, union acpi_dmar_id *dmar_id, int *num_inst, int max_inst)
 retrieve acpi DRHD info for the given scope.
 
void acpi_dmar_foreach_subtable (ACPI_TABLE_DMAR *dmar, dmar_foreach_subtable_func_t func, void *arg)
 
void acpi_dmar_foreach_devscope (ACPI_DMAR_HARDWARE_UNIT *hu, dmar_foreach_devscope_func_t func, void *arg)
 
int acpi_dmar_ioapic_get (uint16_t *ioapic_id)
 Retrieve IOAPIC id.
 
ACPI_MADT_LOCAL_APIC * acpi_local_apic_get (int cpu_num)
 Retrieve the 'n'th enabled local apic info.
 
int acpi_invoke_method (char *path, ACPI_OBJECT_LIST *arg_list, ACPI_OBJECT *ret_obj)
 invoke an ACPI method and return the result.
 

Macro Definition Documentation

◆ ACPI_DMAR_FLAG_DMA_CTRL_PLATFORM_OPT_IN

#define ACPI_DMAR_FLAG_DMA_CTRL_PLATFORM_OPT_IN   BIT(2)

◆ ACPI_DMAR_FLAG_INTR_REMAP

#define ACPI_DMAR_FLAG_INTR_REMAP   BIT(0)

◆ ACPI_DMAR_FLAG_X2APIC_OPT_OUT

#define ACPI_DMAR_FLAG_X2APIC_OPT_OUT   BIT(1)

◆ ACPI_DRHD_FLAG_INCLUDE_PCI_ALL

#define ACPI_DRHD_FLAG_INCLUDE_PCI_ALL   BIT(0)

◆ ACPI_DT_HAS_HID

#define ACPI_DT_HAS_HID ( node_id)
Value:
DT_NODE_HAS_PROP(node_id, acpi_hid)
#define DT_NODE_HAS_PROP(node_id, prop)
Does a devicetree node have a property?
Definition devicetree.h:3677

check whether the node has ACPI HID property or not

Parameters
node_idDTS node identifier
Returns
1 if the node has the HID, 0 otherwise.

◆ ACPI_DT_HAS_UID

#define ACPI_DT_HAS_UID ( node_id)
Value:
DT_NODE_HAS_PROP(node_id, acpi_uid)

check whether the node has ACPI UID property or not

Parameters
node_idDTS node identifier
Returns
1 if the node has the UID, 0 otherwise.

◆ ACPI_DT_HID

#define ACPI_DT_HID ( node_id)
Value:
DT_PROP(node_id, acpi_hid)
#define DT_PROP(node_id, prop)
Get a devicetree property value.
Definition devicetree.h:745

Get the ACPI HID for a node.

Parameters
node_idDTS node identifier
Returns
The HID of the ACPI node

◆ ACPI_DT_UID

#define ACPI_DT_UID ( node_id)
Value:
DT_PROP_OR(node_id, acpi_uid, NULL)
#define DT_PROP_OR(node_id, prop, default_value)
Like DT_PROP(), but with a fallback to default_value.
Definition devicetree.h:907

Get the ACPI UID for a node if one exist.

Parameters
node_idDTS node identifier
Returns
The UID of the ACPI node else NULL if does not exist

◆ ACPI_IO_GET

#define ACPI_IO_GET ( res)
Value:
(res)->reg_base[0].port

◆ ACPI_MMIO_GET

#define ACPI_MMIO_GET ( res)
Value:
(res)->reg_base[0].mmio

◆ ACPI_MULTI_IO_GET

#define ACPI_MULTI_IO_GET ( res,
idx )
Value:
(res)->reg_base[idx].port

◆ ACPI_MULTI_MMIO_GET

#define ACPI_MULTI_MMIO_GET ( res,
idx )
Value:
(res)->reg_base[idx].mmio

◆ ACPI_MULTI_RESOURCE_SIZE_GET

#define ACPI_MULTI_RESOURCE_SIZE_GET ( res,
idx )
Value:
(res)->reg_base[idx].length

◆ ACPI_MULTI_RESOURCE_TYPE_GET

#define ACPI_MULTI_RESOURCE_TYPE_GET ( res,
idx )
Value:
(res)->reg_base[idx].type

◆ ACPI_RES_INVALID

#define ACPI_RES_INVALID   ACPI_RESOURCE_TYPE_MAX

◆ ACPI_RESOURCE_COUNT_GET

#define ACPI_RESOURCE_COUNT_GET ( res)
Value:
(res)->mmio_max

◆ ACPI_RESOURCE_SIZE_GET

#define ACPI_RESOURCE_SIZE_GET ( res)
Value:
(res)->reg_base[0].length

◆ ACPI_RESOURCE_TYPE_GET

#define ACPI_RESOURCE_TYPE_GET ( res)
Value:
(res)->reg_base[0].type

Typedef Documentation

◆ dmar_foreach_devscope_func_t

typedef void(* dmar_foreach_devscope_func_t) (ACPI_DMAR_DEVICE_SCOPE *devscope, void *arg)

◆ dmar_foreach_subtable_func_t

typedef void(* dmar_foreach_subtable_func_t) (ACPI_DMAR_HEADER *subtable, void *arg)

Enumeration Type Documentation

◆ acpi_res_type

Enumerator
ACPI_RES_TYPE_IO 

IO mapped Resource type.

ACPI_RES_TYPE_MEM 

Memory mapped Resource type.

ACPI_RES_TYPE_UNKNOWN 

Unknown Resource type.

Function Documentation

◆ acpi_current_resource_free()

int acpi_current_resource_free ( ACPI_RESOURCE * res)

Free current resource list memory which is retrieved by acpi_current_resource_get().

Parameters
resthe list of acpi resource list
Returns
return 0 on success or error code

◆ acpi_current_resource_get()

int acpi_current_resource_get ( char * dev_name,
ACPI_RESOURCE ** res )

Retrieve the current resource settings of a device.

Parameters
dev_namethe name of the device
resthe list of acpi resource list
Returns
return 0 on success or error code

◆ acpi_device_by_index_get()

struct acpi_dev * acpi_device_by_index_get ( int index)

Retrieve acpi device info from the index.

Parameters
indexthe device index of an acpi child device
Returns
acpi child device info on success or NULL

◆ acpi_device_get()

struct acpi_dev * acpi_device_get ( const char * hid,
const char * uid )

Retrieve ACPI device info for given hardware id and unique id.

Parameters
hidthe hardware id of the ACPI child device
uidthe unique id of the ACPI child device. The uid can be NULL if only one device with given HID present in the platform.
Returns
ACPI child device info on success or NULL

◆ acpi_device_irq_get()

int acpi_device_irq_get ( struct acpi_dev * child_dev,
struct acpi_irq_resource * irq_res )

Parse resource table for irq info.

Parameters
child_devthe device object of the ACPI node
irq_resirq resource info
Returns
return 0 on success or error code

◆ acpi_device_mmio_get()

int acpi_device_mmio_get ( struct acpi_dev * child_dev,
struct acpi_mmio_resource * mmio_res )

Parse resource table for MMIO info.

Parameters
child_devthe device object of the ACPI node
mmio_resMMIO resource info
Returns
return 0 on success or error code

◆ acpi_device_type_get()

int acpi_device_type_get ( ACPI_RESOURCE * res)

Parse resource table for identify resource type.

Parameters
resthe list of acpi resource list
Returns
resource type on success or invalid resource type

◆ acpi_dmar_entry_get()

int acpi_dmar_entry_get ( enum AcpiDmarType type,
ACPI_SUBTABLE_HEADER ** tables )

retrieve DMA remapping structure for the given type.

Parameters
typetype of remapping structure
tablespointer to the dmar id structure
Returns
return 0 on success or error code

◆ acpi_dmar_foreach_devscope()

void acpi_dmar_foreach_devscope ( ACPI_DMAR_HARDWARE_UNIT * hu,
dmar_foreach_devscope_func_t func,
void * arg )

◆ acpi_dmar_foreach_subtable()

void acpi_dmar_foreach_subtable ( ACPI_TABLE_DMAR * dmar,
dmar_foreach_subtable_func_t func,
void * arg )

◆ acpi_dmar_ioapic_get()

int acpi_dmar_ioapic_get ( uint16_t * ioapic_id)

Retrieve IOAPIC id.

Parameters
ioapic_idIOAPIC id
Returns
return 0 on success or error code

◆ acpi_drhd_get()

int acpi_drhd_get ( enum AcpiDmarScopeType scope,
ACPI_DMAR_DEVICE_SCOPE * dev_scope,
union acpi_dmar_id * dmar_id,
int * num_inst,
int max_inst )

retrieve acpi DRHD info for the given scope.

Parameters
scopescope of requested DHRD table
dev_scopepointer to the sub table (optional)
dmar_idpointer to the DHRD info
num_instnumber of instance for the requested table
max_instmaximum number of entry for the given dmar_id buffer
Returns
return 0 on success or error code

◆ acpi_invoke_method()

int acpi_invoke_method ( char * path,
ACPI_OBJECT_LIST * arg_list,
ACPI_OBJECT * ret_obj )

invoke an ACPI method and return the result.

Parameters
paththe path name of the ACPI object
arg_listthe list of arguments to be pass down
ret_objthe ACPI result to be return
Returns
return 0 on success or error code

◆ acpi_irq_res_get()

static ACPI_RESOURCE_IRQ * acpi_irq_res_get ( ACPI_RESOURCE * res_lst)
inlinestatic

Parse resource table for irq info.

Parameters
res_lstthe list of acpi resource list
Returns
irq resource list on success or NULL

◆ acpi_legacy_irq_get()

uint32_t acpi_legacy_irq_get ( pcie_bdf_t bdf)

Retrieve a legacy interrupt number for a PCI device.

Parameters
bdfthe BDF of endpoint/PCI device
Returns
return IRQ number or UINT_MAX if not found

◆ acpi_legacy_irq_init()

int acpi_legacy_irq_init ( const char * hid,
const char * uid )

Init legacy interrupt routing table information from ACPI.

Currently assume platform have only one PCI bus.

Parameters
hidthe hardware id of the ACPI child device
uidthe unique id of the ACPI child device. The uid can be NULL if only one device with given hid present in the platform.
Returns
return 0 on success or error code

◆ acpi_local_apic_get()

ACPI_MADT_LOCAL_APIC * acpi_local_apic_get ( int cpu_num)

Retrieve the 'n'th enabled local apic info.

Parameters
cpu_numthe cpu number
Returns
local apic info on success or NULL otherwise

◆ acpi_madt_entry_get()

int acpi_madt_entry_get ( int type,
ACPI_SUBTABLE_HEADER ** tables,
int * num_inst )

retrieve acpi MAD table for the given type.

Parameters
typetype of requested MAD table
tablespointer to the MAD table
num_instnumber of instance for the requested table
Returns
return 0 on success or error code

◆ acpi_possible_resource_get()

int acpi_possible_resource_get ( char * dev_name,
ACPI_RESOURCE ** res )

Retrieve possible resource settings of a device.

Parameters
dev_namethe name of the device
resthe list of acpi resource list
Returns
return 0 on success or error code

◆ acpi_resource_parse()

ACPI_RESOURCE * acpi_resource_parse ( ACPI_RESOURCE * res,
int res_type )

Parse resource table for a given resource type.

Parameters
resthe list of acpi resource list
res_typethe acpi resource type
Returns
resource list for the given type on success or NULL

◆ acpi_table_get()

void * acpi_table_get ( char * signature,
int inst )

Retrieve acpi table for the given signature.

Parameters
signaturepointer to the 4-character ACPI signature for the requested table
instinstance number for the requested table
Returns
acpi_table pointer to the acpi table on success else return NULL