]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.h
MdeModulePkg: Add support for weakly aligned FVs.
[mirror_edk2.git] / MdeModulePkg / Universal / Acpi / AcpiTableDxe / AcpiSdt.h
CommitLineData
3dc8585e
JY
1/** @file\r
2 ACPI Sdt Protocol Driver\r
3\r
4 Copyright (c) 2010, Intel Corporation. All rights reserved. <BR>\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef _ACPI_SDT_H_\r
16#define _ACPI_SDT_H_\r
17\r
3dc8585e
JY
18//\r
19// Privacy data structure\r
20//\r
21\r
22//\r
23// ACPI Notify Linked List Signature.\r
24//\r
25#define EFI_ACPI_NOTIFY_LIST_SIGNATURE SIGNATURE_32 ('E', 'A', 'N', 'L')\r
26\r
27//\r
28// ACPI Notify List Entry definition.\r
29//\r
30// Signature must be set to EFI_ACPI_NOTIFY_LIST_SIGNATURE\r
31// Link is the linked list data.\r
32// Notification is the callback function.\r
33//\r
34typedef struct {\r
35 UINT32 Signature;\r
36 LIST_ENTRY Link;\r
37 EFI_ACPI_NOTIFICATION_FN Notification;\r
38} EFI_ACPI_NOTIFY_LIST;\r
39\r
40//\r
41// Containment record for ACPI Notify linked list.\r
42//\r
43#define EFI_ACPI_NOTIFY_LIST_FROM_LINK(_link) CR (_link, EFI_ACPI_NOTIFY_LIST, Link, EFI_ACPI_NOTIFY_LIST_SIGNATURE)\r
44\r
45typedef struct _AML_BYTE_ENCODING AML_BYTE_ENCODING;\r
46typedef struct _EFI_AML_NODE_LIST EFI_AML_NODE_LIST;\r
47\r
48//\r
49// AML Node Linked List Signature.\r
50//\r
51#define EFI_AML_NODE_LIST_SIGNATURE SIGNATURE_32 ('E', 'A', 'M', 'L')\r
52\r
53//\r
54// AML Node Linked List Entry definition.\r
55//\r
56// Signature must be set to EFI_AML_NODE_LIST_SIGNATURE\r
57// Link is the linked list data.\r
58// Name is the ACPI node name.\r
59// This is listed for PATH finding.\r
60// Buffer is the ACPI node buffer pointer, the first/second bytes are opcode.\r
61// This buffer should not be freed.\r
62// Size is the total size of this ACPI node buffer.\r
63// Children is the children linked list of this node.\r
64//\r
65#define AML_NAME_SEG_SIZE 4\r
66\r
67struct _EFI_AML_NODE_LIST {\r
68 UINT32 Signature;\r
69 UINT8 Name[AML_NAME_SEG_SIZE];\r
70 UINT8 *Buffer;\r
71 UINTN Size;\r
72 LIST_ENTRY Link;\r
73 LIST_ENTRY Children;\r
74 EFI_AML_NODE_LIST *Parent;\r
75 AML_BYTE_ENCODING *AmlByteEncoding;\r
76};\r
77\r
78//\r
79// Containment record for AML Node linked list.\r
80//\r
81#define EFI_AML_NODE_LIST_FROM_LINK(_link) CR (_link, EFI_AML_NODE_LIST, Link, EFI_AML_NODE_LIST_SIGNATURE)\r
82\r
83//\r
84// AML Handle Signature.\r
85//\r
86#define EFI_AML_HANDLE_SIGNATURE SIGNATURE_32 ('E', 'A', 'H', 'S')\r
87#define EFI_AML_ROOT_HANDLE_SIGNATURE SIGNATURE_32 ('E', 'A', 'R', 'H')\r
88\r
89//\r
90// AML Handle Entry definition.\r
91//\r
92// Signature must be set to EFI_AML_HANDLE_SIGNATURE or EFI_AML_ROOT_HANDLE_SIGNATURE\r
93// Buffer is the ACPI node buffer pointer, the first/second bytes are opcode.\r
94// This buffer should not be freed.\r
95// Size is the total size of this ACPI node buffer.\r
96//\r
97typedef struct {\r
98 UINT32 Signature;\r
99 UINT8 *Buffer;\r
100 UINTN Size;\r
101 AML_BYTE_ENCODING *AmlByteEncoding;\r
102 BOOLEAN Modified;\r
103} EFI_AML_HANDLE;\r
104\r
105typedef UINT32 AML_OP_PARSE_INDEX;\r
106\r
107#define AML_OP_PARSE_INDEX_GET_OPCODE 0\r
108#define AML_OP_PARSE_INDEX_GET_TERM1 1\r
109#define AML_OP_PARSE_INDEX_GET_TERM2 2\r
110#define AML_OP_PARSE_INDEX_GET_TERM3 3\r
111#define AML_OP_PARSE_INDEX_GET_TERM4 4\r
112#define AML_OP_PARSE_INDEX_GET_TERM5 5\r
113#define AML_OP_PARSE_INDEX_GET_TERM6 6\r
114#define AML_OP_PARSE_INDEX_GET_SIZE (AML_OP_PARSE_INDEX)-1\r
115\r
116typedef UINT32 AML_OP_PARSE_FORMAT;\r
117#define AML_NONE 0\r
118#define AML_OPCODE 1\r
119#define AML_UINT8 2\r
120#define AML_UINT16 3\r
121#define AML_UINT32 4\r
122#define AML_UINT64 5\r
123#define AML_NAME 6\r
124#define AML_STRING 7\r
125#define AML_OBJECT 8\r
126\r
127typedef UINT32 AML_OP_ATTRIBUTE;\r
128#define AML_HAS_PKG_LENGTH 0x1 // It is ACPI attribute - if OpCode has PkgLength\r
129#define AML_IS_NAME_CHAR 0x2 // It is ACPI attribute - if this is NameChar\r
130#define AML_HAS_CHILD_OBJ 0x4 // it is ACPI attribute - if OpCode has Child Object.\r
131#define AML_IN_NAMESPACE 0x10000 // It is UEFI SDT attribute - if OpCode will be in NameSpace\r
132 // NOTE; Not all OBJECT will be in NameSpace\r
133 // For example, BankField | CreateBitField | CreateByteField | CreateDWordField | \r
134 // CreateField | CreateQWordField | CreateWordField | Field | IndexField.\r
135\r
136struct _AML_BYTE_ENCODING {\r
137 UINT8 OpCode;\r
138 UINT8 SubOpCode;\r
139 AML_OP_PARSE_INDEX MaxIndex;\r
140 AML_OP_PARSE_FORMAT Format[6];\r
141 AML_OP_ATTRIBUTE Attribute;\r
142};\r
143\r
144//\r
145// AcpiSdt protocol declaration\r
146//\r
147\r
148/**\r
149 Returns a requested ACPI table.\r
150 \r
151 The GetAcpiTable() function returns a pointer to a buffer containing the ACPI table associated\r
152 with the Index that was input. The following structures are not considered elements in the list of\r
153 ACPI tables:\r
154 - Root System Description Pointer (RSD_PTR)\r
155 - Root System Description Table (RSDT)\r
156 - Extended System Description Table (XSDT)\r
157 Version is updated with a bit map containing all the versions of ACPI of which the table is a\r
158 member.\r
159 \r
160 @param[in] Index The zero-based index of the table to retrieve.\r
161 @param[out] Table Pointer for returning the table buffer.\r
162 @param[out] Version On return, updated with the ACPI versions to which this table belongs. Type\r
163 EFI_ACPI_TABLE_VERSION is defined in "Related Definitions" in the\r
164 EFI_ACPI_SDT_PROTOCOL. \r
165 @param[out] TableKey On return, points to the table key for the specified ACPI system definition table. This\r
166 is identical to the table key used in the EFI_ACPI_TABLE_PROTOCOL. \r
167 \r
168 @retval EFI_SUCCESS The function completed successfully.\r
169 @retval EFI_NOT_FOUND The requested index is too large and a table was not found. \r
170**/ \r
171EFI_STATUS\r
172EFIAPI\r
173GetAcpiTable2 (\r
174 IN UINTN Index,\r
175 OUT EFI_ACPI_SDT_HEADER **Table,\r
176 OUT EFI_ACPI_TABLE_VERSION *Version,\r
177 OUT UINTN *TableKey\r
178 );\r
179\r
180/**\r
181 Register or unregister a callback when an ACPI table is installed.\r
182 \r
183 This function registers or unregisters a function which will be called whenever a new ACPI table is\r
184 installed.\r
185 \r
186 @param[in] Register If TRUE, then the specified function will be registered. If FALSE, then the specified\r
187 function will be unregistered.\r
188 @param[in] Notification Points to the callback function to be registered or unregistered.\r
189 \r
190 @retval EFI_SUCCESS Callback successfully registered or unregistered.\r
191 @retval EFI_INVALID_PARAMETER Notification is NULL\r
192 @retval EFI_INVALID_PARAMETER Register is FALSE and Notification does not match a known registration function. \r
193**/\r
194EFI_STATUS\r
195EFIAPI\r
196RegisterNotify (\r
197 IN BOOLEAN Register,\r
198 IN EFI_ACPI_NOTIFICATION_FN Notification\r
199 );\r
200\r
201/**\r
202 Create a handle for the first ACPI opcode in an ACPI system description table.\r
203 \r
204 @param[in] TableKey The table key for the ACPI table, as returned by GetTable().\r
205 @param[out] Handle On return, points to the newly created ACPI handle.\r
206\r
207 @retval EFI_SUCCESS Handle created successfully.\r
208 @retval EFI_NOT_FOUND TableKey does not refer to a valid ACPI table. \r
209**/\r
210EFI_STATUS\r
211EFIAPI\r
212OpenSdt (\r
213 IN UINTN TableKey,\r
214 OUT EFI_ACPI_HANDLE *Handle\r
215 );\r
216\r
217/**\r
218 Create a handle from an ACPI opcode\r
219 \r
220 @param[in] Buffer Points to the ACPI opcode.\r
221 @param[out] Handle Upon return, holds the handle.\r
222 \r
223 @retval EFI_SUCCESS Success\r
224 @retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an\r
225 invalid opcode.\r
226 \r
227**/\r
228EFI_STATUS\r
229EFIAPI\r
230Open (\r
231 IN VOID *Buffer,\r
232 OUT EFI_ACPI_HANDLE *Handle \r
233 );\r
234\r
235/**\r
236 Close an ACPI handle.\r
237 \r
238 @param[in] Handle Returns the handle.\r
239 \r
240 @retval EFI_SUCCESS Success\r
241 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object. \r
242**/\r
243EFI_STATUS\r
244EFIAPI\r
245Close (\r
246 IN EFI_ACPI_HANDLE Handle\r
247 );\r
248\r
249/**\r
250 Retrieve information about an ACPI object.\r
251 \r
252 @param[in] Handle ACPI object handle.\r
253 @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right\r
254 in the ACPI encoding, with index 0 always being the ACPI opcode.\r
255 @param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists\r
256 for the specified index.\r
257 @param[out] Data Upon return, points to the pointer to the data.\r
258 @param[out] DataSize Upon return, points to the size of Data.\r
259 \r
260 @retval EFI_SUCCESS Success.\r
261 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.\r
262**/\r
263EFI_STATUS\r
264EFIAPI\r
265GetOption (\r
266 IN EFI_ACPI_HANDLE Handle,\r
267 IN UINTN Index,\r
268 OUT EFI_ACPI_DATA_TYPE *DataType,\r
269 OUT CONST VOID **Data,\r
270 OUT UINTN *DataSize\r
271 );\r
272\r
273/**\r
274 Change information about an ACPI object.\r
275 \r
276 @param[in] Handle ACPI object handle.\r
277 @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right\r
278 in the ACPI encoding, with index 0 always being the ACPI opcode.\r
279 @param[in] Data Points to the data.\r
280 @param[in] DataSize The size of the Data.\r
281\r
282 @retval EFI_SUCCESS Success\r
283 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.\r
284 @retval EFI_BAD_BUFFER_SIZE Data cannot be accommodated in the space occupied by\r
285 the option.\r
286\r
287**/\r
288EFI_STATUS\r
289EFIAPI\r
290SetOption (\r
291 IN EFI_ACPI_HANDLE Handle,\r
292 IN UINTN Index,\r
293 IN CONST VOID *Data,\r
294 IN UINTN DataSize\r
295 );\r
296\r
297/**\r
298 Return the child ACPI objects.\r
299 \r
300 @param[in] ParentHandle Parent handle.\r
301 @param[in, out] Handle On entry, points to the previously returned handle or NULL to start with the first\r
302 handle. On return, points to the next returned ACPI handle or NULL if there are no\r
303 child objects.\r
304\r
305 @retval EFI_SUCCESS Success\r
306 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object. \r
307**/\r
308EFI_STATUS\r
309EFIAPI\r
310GetChild (\r
311 IN EFI_ACPI_HANDLE ParentHandle,\r
312 IN OUT EFI_ACPI_HANDLE *Handle\r
313 );\r
314\r
315/**\r
316 Returns the handle of the ACPI object representing the specified ACPI path\r
317 \r
318 @param[in] HandleIn Points to the handle of the object representing the starting point for the path search.\r
319 @param[in] AcpiPath Points to the ACPI path, which conforms to the ACPI encoded path format.\r
320 @param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to\r
321 HandleIn.\r
322 \r
323 @retval EFI_SUCCESS Success\r
324 @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object. \r
325**/\r
326EFI_STATUS\r
327EFIAPI\r
328FindPath (\r
329 IN EFI_ACPI_HANDLE HandleIn,\r
330 IN VOID *AcpiPath,\r
331 OUT EFI_ACPI_HANDLE *HandleOut\r
332 );\r
333\r
334//\r
335// ACPI SDT function\r
336//\r
337\r
338/**\r
339 Create a handle from an ACPI opcode\r
340 \r
341 @param[in] Buffer Points to the ACPI opcode.\r
342 @param[in] BufferSize Max buffer size.\r
343 @param[out] Handle Upon return, holds the handle.\r
344 \r
345 @retval EFI_SUCCESS Success\r
346 @retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an\r
347 invalid opcode.\r
348 \r
349**/\r
350EFI_STATUS\r
351SdtOpenEx (\r
352 IN VOID *Buffer,\r
353 IN UINTN BufferSize,\r
354 OUT EFI_ACPI_HANDLE *Handle \r
355 );\r
356\r
357//\r
358// AML support function\r
359//\r
360\r
361/**\r
362 Get AML NameString size.\r
363\r
364 @param[in] Buffer AML NameString.\r
365 @param[out] BufferSize AML NameString size \r
366 \r
367 @retval EFI_SUCCESS Success.\r
368 @retval EFI_INVALID_PARAMETER Buffer does not refer to a valid AML NameString.\r
369**/\r
370EFI_STATUS\r
371AmlGetNameStringSize (\r
372 IN UINT8 *Buffer,\r
373 OUT UINTN *BufferSize\r
374 );\r
375\r
376/**\r
377 This function retuns package length from the buffer.\r
378\r
379 @param[in] Buffer AML buffer\r
380 @param[out] PkgLength The total length of package.\r
381\r
382 @return The byte data count to present the package length.\r
383**/\r
384UINTN\r
385AmlGetPkgLength (\r
386 IN UINT8 *Buffer,\r
387 OUT UINTN *PkgLength\r
388 );\r
389\r
390/**\r
391 This function returns AcpiDataType according to AmlType.\r
392\r
393 @param[in] AmlType AML Type.\r
394\r
395 @return AcpiDataType\r
396**/\r
397EFI_ACPI_DATA_TYPE\r
398AmlTypeToAcpiType (\r
399 IN AML_OP_PARSE_FORMAT AmlType\r
400 );\r
401\r
402/**\r
403 This function returns AmlByteEncoding according to OpCode Byte.\r
404\r
405 @param[in] OpByteBuffer OpCode byte buffer.\r
406\r
407 @return AmlByteEncoding\r
408**/\r
409AML_BYTE_ENCODING *\r
410AmlSearchByOpByte (\r
411 IN UINT8 *OpByteBuffer\r
412 );\r
413\r
414/**\r
415 Return object size.\r
416 \r
417 @param[in] AmlByteEncoding AML Byte Encoding.\r
418 @param[in] Buffer AML object buffer.\r
419 @param[in] MaxBufferSize AML object buffer MAX size. The parser can not parse any data exceed this region.\r
420 \r
421 @return Size of the object.\r
422**/\r
423UINTN\r
424AmlGetObjectSize (\r
425 IN AML_BYTE_ENCODING *AmlByteEncoding,\r
426 IN UINT8 *Buffer,\r
427 IN UINTN MaxBufferSize\r
428 );\r
429\r
430/**\r
431 Return object name.\r
432 \r
433 @param[in] AmlHandle AML handle.\r
434 \r
435 @return Name of the object.\r
436**/\r
437CHAR8 *\r
438AmlGetObjectName (\r
439 IN EFI_AML_HANDLE *AmlHandle\r
440 );\r
441\r
442/**\r
443 Retrieve information according to AmlHandle\r
444 \r
445 @param[in] AmlHandle AML handle.\r
446 @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right\r
447 in the ACPI encoding, with index 0 always being the ACPI opcode.\r
448 @param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists\r
449 for the specified index.\r
450 @param[out] Data Upon return, points to the pointer to the data.\r
451 @param[out] DataSize Upon return, points to the size of Data.\r
452 \r
453 @retval EFI_SUCCESS Success.\r
454 @retval EFI_INVALID_PARAMETER AmlHandle does not refer to a valid ACPI object.\r
455**/\r
456EFI_STATUS\r
457AmlParseOptionHandleCommon (\r
458 IN EFI_AML_HANDLE *AmlHandle,\r
459 IN AML_OP_PARSE_INDEX Index,\r
460 OUT EFI_ACPI_DATA_TYPE *DataType,\r
461 OUT VOID **Data,\r
462 OUT UINTN *DataSize\r
463 );\r
464\r
465/**\r
466 Return offset of last option.\r
467 \r
468 @param[in] AmlHandle AML Handle.\r
469 @param[out] Buffer Upon return, points to the offset after last option.\r
470 \r
471 @retval EFI_SUCCESS Success.\r
472 @retval EFI_INVALID_PARAMETER AmlHandle does not refer to a valid ACPI object.\r
473**/\r
474EFI_STATUS\r
475AmlGetOffsetAfterLastOption (\r
476 IN EFI_AML_HANDLE *AmlHandle,\r
477 OUT UINT8 **Buffer\r
478 );\r
479\r
480/**\r
481 Return the child ACPI objects from Root Handle.\r
482 \r
483 @param[in] AmlParentHandle Parent handle. It is Root Handle.\r
484 @param[in] AmlHandle The previously returned handle or NULL to start with the first handle.\r
485 @param[out] Buffer On return, points to the next returned ACPI handle or NULL if there are no\r
486 child objects.\r
487\r
488 @retval EFI_SUCCESS Success\r
489 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object. \r
490**/\r
491EFI_STATUS\r
492AmlGetChildFromRoot (\r
493 IN EFI_AML_HANDLE *AmlParentHandle,\r
494 IN EFI_AML_HANDLE *AmlHandle,\r
495 OUT VOID **Buffer\r
496 );\r
497\r
498/**\r
499 Return the child ACPI objects from Non-Root Handle.\r
500 \r
501 @param[in] AmlParentHandle Parent handle. It is Non-Root Handle.\r
502 @param[in] AmlHandle The previously returned handle or NULL to start with the first handle.\r
503 @param[out] Buffer On return, points to the next returned ACPI handle or NULL if there are no\r
504 child objects.\r
505\r
506 @retval EFI_SUCCESS Success\r
507 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object. \r
508**/\r
509EFI_STATUS\r
510AmlGetChildFromNonRoot (\r
511 IN EFI_AML_HANDLE *AmlParentHandle,\r
512 IN EFI_AML_HANDLE *AmlHandle,\r
513 OUT VOID **Buffer\r
514 );\r
515\r
516/**\r
517 Return AML name according to ASL name.\r
518 The caller need free the AmlName returned.\r
519\r
520 @param[in] AslPath ASL name.\r
521\r
522 @return AmlName\r
523**/\r
524UINT8 *\r
525AmlNameFromAslName (\r
526 IN UINT8 *AslPath\r
527 );\r
528\r
529/**\r
530 Returns the handle of the ACPI object representing the specified ACPI AML path\r
531 \r
532 @param[in] AmlHandle Points to the handle of the object representing the starting point for the path search.\r
533 @param[in] AmlPath Points to the ACPI AML path.\r
534 @param[out] Buffer On return, points to the ACPI object which represents AcpiPath, relative to\r
535 HandleIn.\r
536 @param[in] FromRoot TRUE means to find AML path from \ (Root) Node.\r
537 FALSE means to find AML path from this Node (The HandleIn).\r
538 \r
539 @retval EFI_SUCCESS Success\r
540 @retval EFI_INVALID_PARAMETER HandleIn does not refer to a valid ACPI object. \r
541**/\r
542EFI_STATUS\r
543AmlFindPath (\r
544 IN EFI_AML_HANDLE *AmlHandle,\r
545 IN UINT8 *AmlPath,\r
546 OUT VOID **Buffer,\r
547 IN BOOLEAN FromRoot\r
548 );\r
549\r
550/**\r
551 Print AML NameString.\r
552\r
553 @param[in] Buffer AML NameString.\r
554**/\r
555VOID\r
556AmlPrintNameString (\r
557 IN UINT8 *Buffer\r
558 );\r
559\r
560/**\r
561 Print AML NameSeg.\r
562\r
563 @param[in] Buffer AML NameSeg.\r
564**/\r
565VOID\r
566AmlPrintNameSeg (\r
567 IN UINT8 *Buffer\r
568 );\r
569\r
570/**\r
571 Check if it is AML Root name\r
572\r
573 @param[in] Buffer AML path.\r
574 \r
575 @retval TRUE AML path is root.\r
576 @retval FALSE AML path is not root.\r
577**/\r
578BOOLEAN\r
579AmlIsRootPath (\r
580 IN UINT8 *Buffer\r
581 );\r
582\r
583#endif\r