Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
18struct acpi_dev {
19 ACPI_HANDLE handle;
20 char *path;
21 char hid[CONFIG_ACPI_HID_LEN_MAX];
22 ACPI_RESOURCE *res_lst;
24 ACPI_DEVICE_INFO *dev_info;
25};
26
28 struct {
33
35};
36
37struct acpi_mcfg {
38 struct acpi_table_header header;
39 uint64_t _reserved;
40 struct acpi_mcfg_allocation pci_segs[];
41} __packed;
42
50
58int acpi_current_resource_get(char *dev_name, ACPI_RESOURCE **res);
59
67int acpi_possible_resource_get(char *dev_name, ACPI_RESOURCE **res);
68
76int acpi_current_resource_free(ACPI_RESOURCE *res);
77
86int acpi_get_irq_routing_table(char *bus_name, ACPI_PCI_ROUTING_TABLE *rt_table, size_t rt_size);
87
95ACPI_RESOURCE *acpi_resource_parse(ACPI_RESOURCE *res, int res_type);
96
104struct acpi_dev *acpi_device_get(char *hid, int inst);
105
113
120static inline ACPI_RESOURCE_IRQ *acpi_irq_res_get(ACPI_RESOURCE *res_lst)
121{
122 ACPI_RESOURCE *res = acpi_resource_parse(res_lst, ACPI_RESOURCE_TYPE_IRQ);
123
124 return res ? &res->Data.Irq : NULL;
125}
126
133int acpi_device_type_get(ACPI_RESOURCE *res);
134
142void *acpi_table_get(char *signature, int inst);
143
152int acpi_madt_entry_get(int type, struct acpi_subtable_header **tables, int *num_inst);
153
161int acpi_dmar_entry_get(enum AcpiDmarType type,
162 struct acpi_subtable_header **tables);
163
174int acpi_drhd_get(enum AcpiDmarScopeType scope, struct acpi_dmar_device_scope *dev_scope,
175 union acpi_dmar_id *dmar_id, int *num_inst, int max_inst);
176
183struct acpi_madt_local_apic *acpi_local_apic_get(uint32_t cpu_num);
184#endif
uint32_t acpi_legacy_irq_get(pcie_bdf_t bdf)
Retrieve a legacy interrupt number for a PCI device.
int acpi_madt_entry_get(int type, struct acpi_subtable_header **tables, int *num_inst)
retrieve acpi MAD table 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:120
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.
int acpi_get_irq_routing_table(char *bus_name, ACPI_PCI_ROUTING_TABLE *rt_table, size_t rt_size)
Retrieve IRQ routing table of a bus.
struct acpi_dev * acpi_device_by_index_get(int index)
Retrieve acpi device info from the index.
struct acpi_dev * acpi_device_get(char *hid, int inst)
Retrieve acpi device info for given hardware id and unique id.
int acpi_current_resource_free(ACPI_RESOURCE *res)
Free current resource list memory which is retrieved by acpi_current_resource_get().
int acpi_dmar_entry_get(enum AcpiDmarType type, struct acpi_subtable_header **tables)
retrieve DMA remapping structure for the given type.
struct acpi_madt_local_apic * acpi_local_apic_get(uint32_t cpu_num)
Retrieve lapic info for a specific cpu.
ACPI_RESOURCE * acpi_resource_parse(ACPI_RESOURCE *res, int res_type)
Parse resource table for a given resource type.
void * acpi_table_get(char *signature, int inst)
Retrieve acpi table for the given signature.
int acpi_drhd_get(enum AcpiDmarScopeType scope, struct 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.
int acpi_current_resource_get(char *dev_name, ACPI_RESOURCE **res)
Retrieve the current resource settings of a device.
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
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Definition: acpi.h:18
char * path
Definition: acpi.h:20
ACPI_DEVICE_INFO * dev_info
Definition: acpi.h:24
ACPI_RESOURCE * res_lst
Definition: acpi.h:22
char hid[CONFIG_ACPI_HID_LEN_MAX]
Definition: acpi.h:21
int res_type
Definition: acpi.h:23
ACPI_HANDLE handle
Definition: acpi.h:19
Definition: acpi.h:37
struct acpi_table_header header
Definition: acpi.h:38
struct acpi_mcfg_allocation pci_segs[]
Definition: acpi.h:40
Definition: acpi.h:27
uint16_t device
Definition: acpi.h:30
struct acpi_dmar_id::@0 bits
uint16_t bus
Definition: acpi.h:31
uint16_t raw
Definition: acpi.h:34
uint16_t function
Definition: acpi.h:29