iPXE
acpi.h
Go to the documentation of this file.
1 #ifndef _IPXE_ACPI_H
2 #define _IPXE_ACPI_H
3 
4 /** @file
5  *
6  * ACPI data structures
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stdint.h>
13 #include <byteswap.h>
14 #include <ipxe/refcnt.h>
15 #include <ipxe/list.h>
16 #include <ipxe/interface.h>
17 #include <ipxe/uaccess.h>
18 #include <ipxe/tables.h>
19 #include <ipxe/api.h>
20 #include <config/general.h>
21 
22 /**
23  * An ACPI description header
24  *
25  * This is the structure common to the start of all ACPI system
26  * description tables.
27  */
28 struct acpi_header {
29  /** ACPI signature (4 ASCII characters) */
31  /** Length of table, in bytes, including header */
33  /** ACPI Specification minor version number */
35  /** To make sum of entire table == 0 */
37  /** OEM identification */
38  char oem_id[6];
39  /** OEM table identification */
40  char oem_table_id[8];
41  /** OEM revision number */
43  /** ASL compiler vendor ID */
44  char asl_compiler_id[4];
45  /** ASL compiler revision number */
47 } __attribute__ (( packed ));
48 
49 /**
50  * Transcribe ACPI table signature (for debugging)
51  *
52  * @v signature ACPI table signature
53  * @ret name ACPI table signature name
54  */
55 static inline const char * acpi_name ( uint32_t signature ) {
56  static union {
58  char name[5];
59  } u;
60 
61  u.signature = cpu_to_le32 ( signature );
62  return u.name;
63 }
64 
65 /**
66  * Build ACPI signature
67  *
68  * @v a First character of ACPI signature
69  * @v b Second character of ACPI signature
70  * @v c Third character of ACPI signature
71  * @v d Fourth character of ACPI signature
72  * @ret signature ACPI signature
73  */
74 #define ACPI_SIGNATURE( a, b, c, d ) \
75  ( ( (a) << 0 ) | ( (b) << 8 ) | ( (c) << 16 ) | ( (d) << 24 ) )
76 
77 /** Root System Description Pointer signature */
78 #define RSDP_SIGNATURE { 'R', 'S', 'D', ' ', 'P', 'T', 'R', ' ' }
79 
80 /** Root System Description Pointer */
81 struct acpi_rsdp {
82  /** Signature */
83  char signature[8];
84  /** To make sum of entire table == 0 */
86  /** OEM identification */
87  char oem_id[6];
88  /** Revision */
90  /** Physical address of RSDT */
92 } __attribute__ (( packed ));
93 
94 /** Root System Description Table (RSDT) signature */
95 #define RSDT_SIGNATURE ACPI_SIGNATURE ( 'R', 'S', 'D', 'T' )
96 
97 /** ACPI Root System Description Table (RSDT) */
98 struct acpi_rsdt {
99  /** ACPI header */
101  /** ACPI table entries */
103 } __attribute__ (( packed ));
104 
105 /** Fixed ACPI Description Table (FADT) signature */
106 #define FADT_SIGNATURE ACPI_SIGNATURE ( 'F', 'A', 'C', 'P' )
107 
108 /** Fixed ACPI Description Table (FADT) */
109 struct acpi_fadt {
110  /** ACPI header */
112  /** Physical address of FACS */
114  /** Physical address of DSDT */
116  /** Unused by iPXE */
118  /** PM1a Control Register Block */
120  /** PM1b Control Register Block */
122  /** PM2 Control Register Block */
124  /** PM Timer Control Register Block */
126 } __attribute__ (( packed ));
127 
128 /** ACPI PM1 Control Register (within PM1a_CNT_BLK or PM1A_CNT_BLK) */
129 #define ACPI_PM1_CNT 0
130 #define ACPI_PM1_CNT_SLP_TYP(x) ( (x) << 10 ) /**< Sleep type */
131 #define ACPI_PM1_CNT_SLP_EN ( 1 << 13 ) /**< Sleep enable */
132 
133 /** ACPI PM Timer Register (within PM_TMR_BLK) */
134 #define ACPI_PM_TMR 0
135 
136 /** Differentiated System Description Table (DSDT) signature */
137 #define DSDT_SIGNATURE ACPI_SIGNATURE ( 'D', 'S', 'D', 'T' )
138 
139 /** Secondary System Description Table (SSDT) signature */
140 #define SSDT_SIGNATURE ACPI_SIGNATURE ( 'S', 'S', 'D', 'T' )
141 
142 /** An ACPI descriptor (used to construct ACPI tables) */
144  /** Reference count of containing object */
145  struct refcnt *refcnt;
146  /** Table model */
147  struct acpi_model *model;
148  /** List of ACPI descriptors for this model */
149  struct list_head list;
150 };
151 
152 /**
153  * Initialise ACPI descriptor
154  *
155  * @v desc ACPI descriptor
156  * @v model Table model
157  * @v refcnt Reference count
158  */
159 static inline __attribute__ (( always_inline )) void
160 acpi_init ( struct acpi_descriptor *desc, struct acpi_model *model,
161  struct refcnt *refcnt ) {
162 
163  desc->refcnt = refcnt;
164  desc->model = model;
165  INIT_LIST_HEAD ( &desc->list );
166 }
167 
168 /** An ACPI table model */
169 struct acpi_model {
170  /** List of descriptors */
171  struct list_head descs;
172  /**
173  * Check if ACPI descriptor is complete
174  *
175  * @v desc ACPI descriptor
176  * @ret rc Return status code
177  */
178  int ( * complete ) ( struct acpi_descriptor *desc );
179  /**
180  * Install ACPI tables
181  *
182  * @v install Installation method
183  * @ret rc Return status code
184  */
185  int ( * install ) ( int ( * install ) ( struct acpi_header *acpi ) );
186 };
187 
188 /** ACPI models */
189 #define ACPI_MODELS __table ( struct acpi_model, "acpi_models" )
190 
191 /** Declare an ACPI model */
192 #define __acpi_model __table_entry ( ACPI_MODELS, 01 )
193 
194 /**
195  * Calculate static inline ACPI API function name
196  *
197  * @v _prefix Subsystem prefix
198  * @v _api_func API function
199  * @ret _subsys_func Subsystem API function
200  */
201 #define ACPI_INLINE( _subsys, _api_func ) \
202  SINGLE_API_INLINE ( ACPI_PREFIX_ ## _subsys, _api_func )
203 
204 /**
205  * Provide an ACPI API implementation
206  *
207  * @v _prefix Subsystem prefix
208  * @v _api_func API function
209  * @v _func Implementing function
210  */
211 #define PROVIDE_ACPI( _subsys, _api_func, _func ) \
212  PROVIDE_SINGLE_API ( ACPI_PREFIX_ ## _subsys, _api_func, _func )
213 
214 /**
215  * Provide a static inline ACPI API implementation
216  *
217  * @v _prefix Subsystem prefix
218  * @v _api_func API function
219  */
220 #define PROVIDE_ACPI_INLINE( _subsys, _api_func ) \
221  PROVIDE_SINGLE_API_INLINE ( ACPI_PREFIX_ ## _subsys, _api_func )
222 
223 /* Include all architecture-independent ACPI API headers */
224 #include <ipxe/null_acpi.h>
225 #include <ipxe/efi/efi_acpi.h>
226 
227 /* Include all architecture-dependent ACPI API headers */
228 #include <bits/acpi.h>
229 
230 /**
231  * Locate ACPI root system description table
232  *
233  * @ret rsdt ACPI root system description table, or UNULL
234  */
235 userptr_t acpi_find_rsdt ( void );
236 
237 extern struct acpi_descriptor *
238 acpi_describe ( struct interface *interface );
239 #define acpi_describe_TYPE( object_type ) \
240  typeof ( struct acpi_descriptor * ( object_type ) )
241 
242 extern void acpi_fix_checksum ( struct acpi_header *acpi );
243 extern userptr_t acpi_find ( uint32_t signature, unsigned int index );
244 extern int acpi_sx ( uint32_t signature );
245 extern void acpi_add ( struct acpi_descriptor *desc );
246 extern void acpi_del ( struct acpi_descriptor *desc );
247 extern int acpi_install ( int ( * install ) ( struct acpi_header *acpi ) );
248 
249 #endif /* _IPXE_ACPI_H */
#define __attribute__(x)
Definition: compiler.h:10
const char * name
Definition: ath9k_hw.c:1984
char oem_table_id[8]
OEM table identification.
Definition: acpi.h:40
iPXE internal APIs
uint8_t unused[20]
Unused by iPXE.
Definition: acpi.h:117
Standard do-nothing ACPI interface.
uint32_t pm2_cnt_blk
PM2 Control Register Block.
Definition: acpi.h:123
uint32_t signature
ACPI signature (4 ASCII characters)
Definition: acpi.h:30
struct list_head descs
List of descriptors.
Definition: acpi.h:171
uint8_t checksum
To make sum of entire table == 0.
Definition: acpi.h:85
char oem_id[6]
OEM identification.
Definition: acpi.h:87
uint32_t oem_revision
OEM revision number.
Definition: acpi.h:42
int(* install)(int(*install)(struct acpi_header *acpi))
Install ACPI tables.
Definition: acpi.h:185
ACPI Root System Description Table (RSDT)
Definition: acpi.h:98
static void(*) struct refcnt refcnt)
Definition: pool.h:62
uint32_t facs
Physical address of FACS.
Definition: acpi.h:113
x86-specific ACPI API implementations
Access to external ("user") memory.
A doubly-linked list entry (or list head)
Definition: list.h:18
A reference counter.
Definition: refcnt.h:26
struct acpi_model * model
Table model.
Definition: acpi.h:147
u8 signature
Definition: CIB_PRM.h:35
int acpi_install(int(*install)(struct acpi_header *acpi))
Install ACPI tables.
Definition: acpi.c:357
uint32_t pm_tmr_blk
PM Timer Control Register Block.
Definition: acpi.h:125
char oem_id[6]
OEM identification.
Definition: acpi.h:38
void acpi_del(struct acpi_descriptor *desc)
Remove ACPI descriptor.
Definition: acpi.c:320
void acpi_add(struct acpi_descriptor *desc)
Add ACPI descriptor.
Definition: acpi.c:308
An object interface.
Definition: interface.h:109
Fixed ACPI Description Table (FADT)
Definition: acpi.h:109
An ACPI table model.
Definition: acpi.h:169
uint32_t length
Length of table, in bytes, including header.
Definition: acpi.h:32
Object interfaces.
static EFI_ACPI_TABLE_PROTOCOL * acpi
ACPI table protocol protocol.
Definition: efi_block.c:61
struct list_head list
List of ACPI descriptors for this model.
Definition: acpi.h:149
char signature[8]
Signature.
Definition: acpi.h:83
uint32_t entry[0]
ACPI table entries.
Definition: acpi.h:102
void acpi_fix_checksum(struct acpi_header *acpi)
Fix up ACPI table checksum.
Definition: acpi.c:76
uint32_t pm1a_cnt_blk
PM1a Control Register Block.
Definition: acpi.h:119
userptr_t acpi_find(uint32_t signature, unsigned int index)
Locate ACPI table.
Definition: acpi.c:89
#define cpu_to_le32(value)
Definition: byteswap.h:107
Linked lists.
char asl_compiler_id[4]
ASL compiler vendor ID.
Definition: acpi.h:44
uint8_t checksum
To make sum of entire table == 0.
Definition: acpi.h:36
unsigned char uint8_t
Definition: stdint.h:10
userptr_t acpi_find_rsdt(void)
Locate ACPI root system description table.
An ACPI description header.
Definition: acpi.h:28
unsigned int uint32_t
Definition: stdint.h:12
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct acpi_header acpi
ACPI header.
Definition: acpi.h:100
int(* complete)(struct acpi_descriptor *desc)
Check if ACPI descriptor is complete.
Definition: acpi.h:178
iPXE ACPI API for EFI
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
An ACPI descriptor (used to construct ACPI tables)
Definition: acpi.h:143
uint32_t dsdt
Physical address of DSDT.
Definition: acpi.h:115
General configuration.
uint32_t pm1b_cnt_blk
PM1b Control Register Block.
Definition: acpi.h:121
uint32_t rsdt
Physical address of RSDT.
Definition: acpi.h:91
struct acpi_descriptor * acpi_describe(struct interface *interface)
Get object's ACPI descriptor.
Definition: acpi.c:334
static const char * acpi_name(uint32_t signature)
Transcribe ACPI table signature (for debugging)
Definition: acpi.h:55
Reference counting.
uint8_t revision
Revision.
Definition: acpi.h:89
Linker tables.
struct refcnt * refcnt
Reference count of containing object.
Definition: acpi.h:145
uint8_t revision
ACPI Specification minor version number.
Definition: acpi.h:34
Root System Description Pointer.
Definition: acpi.h:81
union @16 u
int acpi_sx(uint32_t signature)
Extract _Sx value from DSDT/SSDT.
Definition: acpi.c:257
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
struct acpi_header acpi
ACPI header.
Definition: acpi.h:111
uint32_t asl_compiler_revision
ASL compiler revision number.
Definition: acpi.h:46
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33
static void acpi_init(struct acpi_descriptor *desc, struct acpi_model *model, struct refcnt *refcnt)
Initialise ACPI descriptor.
Definition: acpi.h:160