Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
acpi.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Intel Corporation
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6#ifndef ZEPHYR_INCLUDE_ARCH_X86_ACPI_H
7#define ZEPHYR_INCLUDE_ARCH_X86_ACPI_H
8
9#ifndef _ASMLANGUAGE
10
11#define ACPI_RSDP_SIGNATURE 0x2052545020445352 /* == "RSD PTR " */
12
13/* Root System Description Pointer */
14struct acpi_rsdp {
15 char signature[8];
17 char oem_id[6];
23 uint8_t _reserved[3];
24} __packed;
25
26/* Standard table header */
27struct acpi_sdt {
32 char oem_id[6];
33 char oem_table_id[8];
37} __packed;
38
39/* Root System Description Table */
40struct acpi_rsdt {
41 struct acpi_sdt sdt;
43} __packed;
44
45/* eXtended System Descriptor Table */
46struct acpi_xsdt {
47 struct acpi_sdt sdt;
49} __packed;
50
51/* MCFG table storing MMIO addresses for PCI configuration space */
52
53#define ACPI_MCFG_SIGNATURE 0x4746434d /* 'MCFG' */
54
55struct acpi_mcfg {
56 struct acpi_sdt sdt;
57 uint64_t _reserved;
58 struct {
64} __packed;
65
66/* MADT table storing IO-APIC and multiprocessor configuration */
67
68#define ACPI_MADT_SIGNATURE 0x43495041 /* 'APIC' */
69
71 uint8_t type; /* See ACPI_MADT_ENTRY_* below */
73} __packed;
74
75#define ACPI_MADT_ENTRY_CPU 0
76
77struct acpi_madt {
78 struct acpi_sdt sdt;
79 uint32_t loapic; /* local APIC MMIO address */
80 uint32_t flags; /* see ACPI_MADT_FLAGS_* below */
82} __packed;
83
84#define ACPI_MADT_FLAGS_PICS 0x01 /* legacy 8259s installed */
85
86struct acpi_cpu {
89 uint8_t apic_id; /* local APIC ID */
90 uint8_t flags; /* see ACPI_CPU_FLAGS_* below */
91} __packed;
92
93#define ACPI_CPU_FLAGS_ENABLED 0x01
94
95/* Generic DMA Remapping entry structure part */
97 uint16_t type; /* See ACPI_DMAR_TYPE_* below */
99} __packed;
100
101#define ACPI_DMAR_TYPE_DRHD 0 /* DMA Remapping Hardware Unit Definition */
102#define ACPI_DMAR_TYPE_RMRR 1 /* Do not care atm (legacy usage) */
103#define ACPI_DMAR_TYPE_ATSR 2 /* Do not care atm (PCIE ATS support) */
104#define ACPI_DMAR_TYPE_RHSA 3 /* Do not care atm (NUMA specific ) */
105#define ACPI_DMAR_TYPE_ANDD 4 /* Do not care atm (ACPI DSDT related) */
106#define ACPI_DMAR_TYPE_SACT 5 /* Do not care atm */
107
108/* PCI Device/Function Pair (forming the BDF, with start_bus_num below) */
112} __packed;
113
114#define ACPI_DMAR_DEV_PATH_SIZE 2
115
116/* DMA Remapping Device Scope */
118 uint8_t type; /* See ACPI_DRHD_DEV_SCOPE_* below */
119 uint8_t length; /* 6 + X where X is Path attribute size */
120 uint16_t _reserved;
122 uint8_t start_bus_num; /* PCI bus, forming BDF with each Path below */
123 struct acpi_dmar_dev_path path[]; /* One is at least always found */
124} __packed;
125
126#define ACPI_DMAR_DEV_SCOPE_MIN_SIZE 6
127
128#define ACPI_DRHD_DEV_SCOPE_PCI_EPD 0x01
129#define ACPI_DRHD_DEV_SCOPE_PCI_SUB_H 0x02
130#define ACPI_DRHD_DEV_SCOPE_IOAPIC 0x03
131#define ACPI_DRHD_DEV_SCOPE_MSI_CAP_HPET 0x04
132#define ACPI_DRHD_DEV_SCOPE_NAMESPACE_DEV 0x05
133
134struct acpi_drhd {
136 uint8_t flags; /* See ACPI_DRHD_FLAG_* below */
137 uint8_t _reserved;
138 uint16_t segment_num; /* Associated PCI segment */
139 uint64_t base_address; /* Base address of the remapping hw */
141} __packed;
142
143#define ACPI_DRHD_MIN_SIZE 16
144
145#define ACPI_DRHD_FLAG_INCLUDE_PCI_ALL BIT(0)
146
147#define ACPI_DMAR_SIGNATURE 0x52414D44 /* 'DMAR' */
148
149#define ACPI_DMAR_FLAG_INTR_REMAP BIT(0)
150#define ACPI_DMAR_FLAG_X2APIC_OPT_OUT BIT(1)
151#define ACPI_DMAR_FLAG_DMA_CTRL_PLATFORM_OPT_IN BIT(2)
152
153/* DMA Remapping reporting structure */
154struct acpi_dmar {
155 struct acpi_sdt sdt;
158 uint8_t _reserved[10];
160} __packed;
161
162#if defined(CONFIG_ACPI)
163
164void *z_acpi_find_table(uint32_t signature);
165
166struct acpi_cpu *z_acpi_get_cpu(int n);
167
168struct acpi_dmar *z_acpi_find_dmar(void);
169
170struct acpi_drhd *z_acpi_find_drhds(int *n);
171
172struct acpi_dmar_dev_scope *z_acpi_get_drhd_dev_scopes(struct acpi_drhd *drhd,
173 int *n);
174
175struct acpi_dmar_dev_path *
176z_acpi_get_dev_scope_paths(struct acpi_dmar_dev_scope *dev_scope, int *n);
177
178#else /* CONFIG_ACPI */
179
180#define z_acpi_find_table(...) NULL
181#define z_acpi_get_cpu(...) NULL
182#define z_acpi_find_dmar(...) NULL
183#define z_acpi_find_drhds(...) NULL
184#define z_acpi_get_drhd_dev_scopes(...) NULL
185#define z_acpi_get_dev_scope_paths(...) NULL
186
187#endif /* CONFIG_ACPI */
188
189#endif /* _ASMLANGUAGE */
190
191#endif /* ZEPHYR_INCLUDE_ARCH_X86_ACPI_H */
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT64_TYPE__ uint64_t
Definition: stdint.h:61
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
__UINT16_TYPE__ uint16_t
Definition: stdint.h:59
Definition: acpi.h:86
uint8_t apic_id
Definition: acpi.h:89
uint8_t acpi_id
Definition: acpi.h:88
struct acpi_madt_entry entry
Definition: acpi.h:87
uint8_t flags
Definition: acpi.h:90
Definition: acpi.h:109
uint8_t function
Definition: acpi.h:111
uint8_t device
Definition: acpi.h:110
Definition: acpi.h:117
uint8_t type
Definition: acpi.h:118
uint8_t start_bus_num
Definition: acpi.h:122
uint8_t length
Definition: acpi.h:119
uint8_t enumeration_id
Definition: acpi.h:121
struct acpi_dmar_dev_path path[]
Definition: acpi.h:123
Definition: acpi.h:96
uint16_t type
Definition: acpi.h:97
uint16_t length
Definition: acpi.h:98
Definition: acpi.h:154
uint8_t host_addr_width
Definition: acpi.h:156
struct acpi_dmar_entry remap_entries[]
Definition: acpi.h:159
uint8_t flags
Definition: acpi.h:157
struct acpi_sdt sdt
Definition: acpi.h:155
Definition: acpi.h:134
uint64_t base_address
Definition: acpi.h:139
struct acpi_dmar_dev_scope device_scope[]
Definition: acpi.h:140
uint16_t segment_num
Definition: acpi.h:138
struct acpi_dmar_entry entry
Definition: acpi.h:135
uint8_t flags
Definition: acpi.h:136
Definition: acpi.h:70
uint8_t length
Definition: acpi.h:72
uint8_t type
Definition: acpi.h:71
Definition: acpi.h:77
uint32_t flags
Definition: acpi.h:80
struct acpi_madt_entry entries[]
Definition: acpi.h:81
struct acpi_sdt sdt
Definition: acpi.h:78
uint32_t loapic
Definition: acpi.h:79
Definition: acpi.h:55
struct acpi_sdt sdt
Definition: acpi.h:56
struct acpi_mcfg::@14 pci_segs[]
uint64_t base_addr
Definition: acpi.h:59
uint16_t seg_group_num
Definition: acpi.h:60
uint8_t start_bus
Definition: acpi.h:61
uint8_t end_bus
Definition: acpi.h:62
Definition: acpi.h:14
char signature[8]
Definition: acpi.h:15
uint8_t chksum
Definition: acpi.h:16
uint64_t xsdt_ptr
Definition: acpi.h:21
uint32_t rsdt_ptr
Definition: acpi.h:19
uint32_t length
Definition: acpi.h:20
char oem_id[6]
Definition: acpi.h:17
uint8_t revision
Definition: acpi.h:18
uint8_t ext_chksum
Definition: acpi.h:22
Definition: acpi.h:40
uint32_t table_ptrs[]
Definition: acpi.h:42
struct acpi_sdt sdt
Definition: acpi.h:41
Definition: acpi.h:27
char oem_id[6]
Definition: acpi.h:32
uint32_t creator_id
Definition: acpi.h:35
uint8_t revision
Definition: acpi.h:30
char oem_table_id[8]
Definition: acpi.h:33
uint32_t oem_revision
Definition: acpi.h:34
uint32_t creator_revision
Definition: acpi.h:36
uint32_t length
Definition: acpi.h:29
uint8_t chksum
Definition: acpi.h:31
uint32_t signature
Definition: acpi.h:28
Definition: acpi.h:46
struct acpi_sdt sdt
Definition: acpi.h:47
uint64_t table_ptrs[]
Definition: acpi.h:48