Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
acpi.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef ZEPHYR_INCLUDE_DRIVERS_ACPI_H_
7#define ZEPHYR_INCLUDE_DRIVERS_ACPI_H_
8#include <acpica/source/include/acpi.h>
10
11#define ACPI_RES_INVALID ACPI_RESOURCE_TYPE_MAX
12
13#define ACPI_DRHD_FLAG_INCLUDE_PCI_ALL BIT(0)
14#define ACPI_DMAR_FLAG_INTR_REMAP BIT(0)
15#define ACPI_DMAR_FLAG_X2APIC_OPT_OUT BIT(1)
16#define ACPI_DMAR_FLAG_DMA_CTRL_PLATFORM_OPT_IN BIT(2)
17
18#define ACPI_MMIO_GET(res) (res)->reg_base[0].mmio
19#define ACPI_IO_GET(res) (res)->reg_base[0].port
20#define ACPI_RESOURCE_SIZE_GET(res) (res)->reg_base[0].length
21#define ACPI_RESOURCE_TYPE_GET(res) (res)->reg_base[0].type
22
23#define ACPI_MULTI_MMIO_GET(res, idx) (res)->reg_base[idx].mmio
24#define ACPI_MULTI_IO_GET(res, idx) (res)->reg_base[idx].port
25#define ACPI_MULTI_RESOURCE_SIZE_GET(res, idx) (res)->reg_base[idx].length
26#define ACPI_MULTI_RESOURCE_TYPE_GET(res, idx) (res)->reg_base[idx].type
27
28#define ACPI_RESOURCE_COUNT_GET(res) (res)->mmio_max
29
38
39struct acpi_dev {
40 ACPI_HANDLE handle;
41 char *path;
42 ACPI_RESOURCE *res_lst;
44 ACPI_DEVICE_INFO *dev_info;
45};
46
56
57struct acpi_mcfg {
58 ACPI_TABLE_HEADER header;
59 uint64_t _reserved;
60 ACPI_MCFG_ALLOCATION pci_segs[];
61} __packed;
62
68
77
82
89#define ACPI_DT_HID(node_id) DT_PROP(node_id, acpi_hid)
90
97#define ACPI_DT_UID(node_id) DT_PROP_OR(node_id, acpi_uid, NULL)
98
105#define ACPI_DT_HAS_HID(node_id) DT_NODE_HAS_PROP(node_id, acpi_hid)
106
113#define ACPI_DT_HAS_UID(node_id) DT_NODE_HAS_PROP(node_id, acpi_uid)
114
124int acpi_legacy_irq_init(const char *hid, const char *uid);
125
133
141int acpi_current_resource_get(char *dev_name, ACPI_RESOURCE **res);
142
150int acpi_possible_resource_get(char *dev_name, ACPI_RESOURCE **res);
151
159int acpi_current_resource_free(ACPI_RESOURCE *res);
160
168ACPI_RESOURCE *acpi_resource_parse(ACPI_RESOURCE *res, int res_type);
169
178struct acpi_dev *acpi_device_get(const char *hid, const char *uid);
179
187
194static inline ACPI_RESOURCE_IRQ *acpi_irq_res_get(ACPI_RESOURCE *res_lst)
195{
196 ACPI_RESOURCE *res = acpi_resource_parse(res_lst, ACPI_RESOURCE_TYPE_IRQ);
197
198 return res ? &res->Data.Irq : NULL;
199}
200
208int acpi_device_irq_get(struct acpi_dev *child_dev, struct acpi_irq_resource *irq_res);
209
217int acpi_device_mmio_get(struct acpi_dev *child_dev, struct acpi_mmio_resource *mmio_res);
218
225int acpi_device_type_get(ACPI_RESOURCE *res);
226
234void *acpi_table_get(char *signature, int inst);
235
244int acpi_madt_entry_get(int type, ACPI_SUBTABLE_HEADER **tables, int *num_inst);
245
253int acpi_dmar_entry_get(enum AcpiDmarType type, ACPI_SUBTABLE_HEADER **tables);
254
265int acpi_drhd_get(enum AcpiDmarScopeType scope, ACPI_DMAR_DEVICE_SCOPE *dev_scope,
266 union acpi_dmar_id *dmar_id, int *num_inst, int max_inst);
267
268typedef void (*dmar_foreach_subtable_func_t)(ACPI_DMAR_HEADER *subtable, void *arg);
269typedef void (*dmar_foreach_devscope_func_t)(ACPI_DMAR_DEVICE_SCOPE *devscope, void *arg);
270
272 void *arg);
273void acpi_dmar_foreach_devscope(ACPI_DMAR_HARDWARE_UNIT *hu,
274 dmar_foreach_devscope_func_t func, void *arg);
275
283
290ACPI_MADT_LOCAL_APIC *acpi_local_apic_get(int cpu_num);
291
300int acpi_invoke_method(char *path, ACPI_OBJECT_LIST *arg_list, ACPI_OBJECT *ret_obj);
301
302#endif
uint32_t acpi_legacy_irq_get(pcie_bdf_t bdf)
Retrieve a legacy interrupt number for a PCI device.
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.
acpi_res_type
Definition acpi.h:30
@ ACPI_RES_TYPE_MEM
Memory mapped Resource type.
Definition acpi.h:34
@ ACPI_RES_TYPE_UNKNOWN
Unknown Resource type.
Definition acpi.h:36
@ ACPI_RES_TYPE_IO
IO mapped Resource type.
Definition acpi.h:32
int acpi_dmar_entry_get(enum AcpiDmarType type, ACPI_SUBTABLE_HEADER **tables)
retrieve DMA remapping structure for the given type.
static ACPI_RESOURCE_IRQ * acpi_irq_res_get(ACPI_RESOURCE *res_lst)
Parse resource table for irq info.
Definition acpi.h:194
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.
int acpi_possible_resource_get(char *dev_name, ACPI_RESOURCE **res)
Retrieve possible resource settings of a device.
struct acpi_dev * acpi_device_by_index_get(int index)
Retrieve acpi device info from the index.
struct acpi_dev * acpi_device_get(const char *hid, const char *uid)
Retrieve ACPI device info for given hardware id and unique id.
void(* dmar_foreach_devscope_func_t)(ACPI_DMAR_DEVICE_SCOPE *devscope, void *arg)
Definition acpi.h:269
int acpi_current_resource_free(ACPI_RESOURCE *res)
Free current resource list memory which is retrieved by acpi_current_resource_get().
ACPI_MADT_LOCAL_APIC * acpi_local_apic_get(int cpu_num)
Retrieve the 'n'th enabled local apic info.
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_RESOURCE * acpi_resource_parse(ACPI_RESOURCE *res, int res_type)
Parse resource table for a given resource type.
int acpi_invoke_method(char *path, ACPI_OBJECT_LIST *arg_list, ACPI_OBJECT *ret_obj)
invoke an ACPI method and return the result.
void * acpi_table_get(char *signature, int inst)
Retrieve acpi table for the given signature.
int acpi_device_irq_get(struct acpi_dev *child_dev, struct acpi_irq_resource *irq_res)
Parse resource table for irq info.
int acpi_madt_entry_get(int type, ACPI_SUBTABLE_HEADER **tables, int *num_inst)
retrieve acpi MAD table for the given type.
int acpi_legacy_irq_init(const char *hid, const char *uid)
Init legacy interrupt routing table information from ACPI.
int acpi_current_resource_get(char *dev_name, ACPI_RESOURCE **res)
Retrieve the current resource settings of a device.
void acpi_dmar_foreach_subtable(ACPI_TABLE_DMAR *dmar, dmar_foreach_subtable_func_t func, void *arg)
void(* dmar_foreach_subtable_func_t)(ACPI_DMAR_HEADER *subtable, void *arg)
Definition acpi.h:268
uint32_t pcie_bdf_t
A unique PCI(e) endpoint (bus, device, function).
Definition pcie.h:37
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINTPTR_TYPE__ uintptr_t
Definition stdint.h:105
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Definition acpi.h:39
char * path
Definition acpi.h:41
ACPI_DEVICE_INFO * dev_info
Definition acpi.h:44
ACPI_RESOURCE * res_lst
Definition acpi.h:42
int res_type
Definition acpi.h:43
ACPI_HANDLE handle
Definition acpi.h:40
Definition acpi.h:63
uint16_t * irqs
Definition acpi.h:66
uint8_t irq_vector_max
Definition acpi.h:65
uint32_t flags
Definition acpi.h:64
Definition acpi.h:57
ACPI_MCFG_ALLOCATION pci_segs[]
Definition acpi.h:60
ACPI_TABLE_HEADER header
Definition acpi.h:58
Definition acpi.h:78
uint8_t mmio_max
Definition acpi.h:79
struct acpi_reg_base * reg_base
Definition acpi.h:80
Definition acpi.h:69
enum acpi_res_type type
Definition acpi.h:70
uint32_t length
Definition acpi.h:75
uintptr_t port
Definition acpi.h:73
uintptr_t mmio
Definition acpi.h:72
Definition acpi.h:47
uint16_t device
Definition acpi.h:50
struct acpi_dmar_id::@0 bits
uint16_t bus
Definition acpi.h:51
uint16_t raw
Definition acpi.h:54
uint16_t function
Definition acpi.h:49