]> git.proxmox.com Git - mirror_edk2.git/blame - DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
DynamicTablesPkg: Add AmlCodeGenMethodRetInteger function
[mirror_edk2.git] / DynamicTablesPkg / Include / Library / AmlLib / AmlLib.h
CommitLineData
c85ac524
PG
1/** @file\r
2 AML Lib.\r
3\r
691c5f77 4 Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.<BR>\r
c85ac524
PG
5\r
6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
7**/\r
8\r
9#ifndef AML_LIB_H_\r
10#define AML_LIB_H_\r
11\r
12/**\r
13 @mainpage Dynamic AML Generation\r
14 @{\r
15 @par Summary\r
16 @{\r
17 ACPI tables are categorized as data tables and definition block\r
18 tables. Dynamic Tables Framework currently supports generation of ACPI\r
19 data tables. Generation of definition block tables is difficult as these\r
20 tables are encoded in ACPI Machine Language (AML), which has a complex\r
21 grammar.\r
22\r
23 Dynamic AML Generation is an extension to the Dynamic tables Framework.\r
24 One of the techniques used to simplify definition block generation is to\r
25 fixup a template SSDT table.\r
26\r
27 Dynamic AML aims to provide a framework that allows fixing up of an ACPI\r
28 SSDT template with appropriate information about the hardware.\r
29\r
30 This framework consists of an:\r
31 - AMLLib core that implements a rich set of interfaces to parse, traverse\r
32 and update AML data.\r
33 - AMLLib library APIs that provides interfaces to search and updates nodes\r
34 in the AML namespace.\r
35 @}\r
36 @}\r
37*/\r
38\r
39#include <IndustryStandard/Acpi.h>\r
40\r
41#ifndef AML_HANDLE\r
42\r
43/** Node handle.\r
44*/\r
731c67e1 45typedef void *AML_NODE_HANDLE;\r
c85ac524
PG
46\r
47/** Root Node handle.\r
48*/\r
731c67e1 49typedef void *AML_ROOT_NODE_HANDLE;\r
c85ac524
PG
50\r
51/** Object Node handle.\r
52*/\r
731c67e1 53typedef void *AML_OBJECT_NODE_HANDLE;\r
c85ac524
PG
54\r
55/** Data Node handle.\r
56*/\r
731c67e1 57typedef void *AML_DATA_NODE_HANDLE;\r
c85ac524
PG
58\r
59#endif // AML_HANDLE\r
60\r
61/** Parse the definition block.\r
62\r
63 The function parses the whole AML blob. It starts with the ACPI DSDT/SSDT\r
64 header and then parses the AML bytestream.\r
65 A tree structure is returned via the RootPtr.\r
66 The tree must be deleted with the AmlDeleteTree function.\r
67\r
68 @ingroup UserApis\r
69\r
70 @param [in] DefinitionBlock Pointer to the definition block.\r
71 @param [out] RootPtr Pointer to the root node of the AML tree.\r
72\r
73 @retval EFI_SUCCESS The function completed successfully.\r
74 @retval EFI_BUFFER_TOO_SMALL No space left in the buffer.\r
75 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
76 @retval EFI_OUT_OF_RESOURCES Could not allocate memory.\r
77**/\r
78EFI_STATUS\r
79EFIAPI\r
80AmlParseDefinitionBlock (\r
731c67e1
MK
81 IN CONST EFI_ACPI_DESCRIPTION_HEADER *DefinitionBlock,\r
82 OUT AML_ROOT_NODE_HANDLE *RootPtr\r
c85ac524
PG
83 );\r
84\r
85/** Serialize an AML definition block.\r
86\r
87 This functions allocates memory with the "AllocateZeroPool ()"\r
88 function. This memory is used to serialize the AML tree and is\r
89 returned in the Table.\r
90\r
91 @ingroup UserApis\r
92\r
93 @param [in] RootNode Root node of the tree.\r
94 @param [out] Table On return, hold the serialized\r
95 definition block.\r
96\r
97 @retval EFI_SUCCESS The function completed successfully.\r
98 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
99 @retval EFI_OUT_OF_RESOURCES Could not allocate memory.\r
100**/\r
101EFI_STATUS\r
102EFIAPI\r
103AmlSerializeDefinitionBlock (\r
731c67e1
MK
104 IN AML_ROOT_NODE_HANDLE RootNode,\r
105 OUT EFI_ACPI_DESCRIPTION_HEADER **Table\r
c85ac524
PG
106 );\r
107\r
108/** Clone a node and its children (clone a tree branch).\r
109\r
110 The cloned branch returned is not attached to any tree.\r
111\r
112 @ingroup UserApis\r
113\r
114 @param [in] Node Pointer to a node.\r
115 Node is the head of the branch to clone.\r
116 @param [out] ClonedNode Pointer holding the head of the created cloned\r
117 branch.\r
118\r
119 @retval EFI_SUCCESS The function completed successfully.\r
120 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
121 @retval EFI_OUT_OF_RESOURCES Could not allocate memory.\r
122**/\r
123EFI_STATUS\r
124EFIAPI\r
125AmlCloneTree (\r
731c67e1
MK
126 IN AML_NODE_HANDLE Node,\r
127 OUT AML_NODE_HANDLE *ClonedNode\r
c85ac524
PG
128 );\r
129\r
130/** Delete a Node and its children.\r
131\r
132 The Node must be removed from the tree first,\r
133 or must be the root node.\r
134\r
135 @ingroup UserApis\r
136\r
137 @param [in] Node Pointer to the node to delete.\r
138\r
139 @retval EFI_SUCCESS The function completed successfully.\r
140 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
141**/\r
142EFI_STATUS\r
143EFIAPI\r
144AmlDeleteTree (\r
731c67e1 145 IN AML_NODE_HANDLE Node\r
c85ac524
PG
146 );\r
147\r
148/** Detach the Node from the tree.\r
149\r
150 The function will fail if the Node is in its parent's fixed\r
151 argument list.\r
152 The Node is not deleted. The deletion is done separately\r
153 from the removal.\r
154\r
155 @ingroup UserApis\r
156\r
157 @param [in] Node Pointer to a Node.\r
158 Must be a data node or an object node.\r
159\r
160 @retval EFI_SUCCESS The function completed successfully.\r
161 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
162**/\r
163EFI_STATUS\r
164EFIAPI\r
165AmlDetachNode (\r
731c67e1 166 IN AML_NODE_HANDLE Node\r
c85ac524
PG
167 );\r
168\r
69ddfee1
PG
169/** Attach a node in an AML tree.\r
170\r
171 The node will be added as the last statement of the ParentNode.\r
172 E.g.:\r
173 ASL code corresponding to NewNode:\r
174 Name (_UID, 0)\r
175\r
176 ASL code corresponding to ParentNode:\r
177 Device (PCI0) {\r
178 Name(_HID, EISAID("PNP0A08"))\r
179 }\r
180\r
181 "AmlAttachNode (ParentNode, NewNode)" will result in:\r
182 ASL code:\r
183 Device (PCI0) {\r
184 Name(_HID, EISAID("PNP0A08"))\r
185 Name (_UID, 0)\r
186 }\r
187\r
188 @param [in] ParentNode Pointer to the parent node.\r
189 Must be a root or an object node.\r
190 @param [in] NewNode Pointer to the node to add.\r
191\r
192 @retval EFI_SUCCESS The function completed successfully.\r
193 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
194**/\r
195EFI_STATUS\r
196EFIAPI\r
197AmlAttachNode (\r
198 IN AML_NODE_HANDLE ParentNode,\r
199 IN AML_NODE_HANDLE NewNode\r
200 );\r
201\r
c85ac524
PG
202/** Find a node in the AML namespace, given an ASL path and a reference Node.\r
203\r
204 - The AslPath can be an absolute path, or a relative path from the\r
205 reference Node;\r
206 - Node must be a root node or a namespace node;\r
207 - A root node is expected to be at the top of the tree.\r
208\r
209 E.g.:\r
210 For the following AML namespace, with the ReferenceNode being the node with\r
211 the name "AAAA":\r
212 - the node with the name "BBBB" can be found by looking for the ASL\r
213 path "BBBB";\r
214 - the root node can be found by looking for the ASL relative path "^",\r
215 or the absolute path "\\".\r
216\r
217 AML namespace:\r
218 \\r
219 \-AAAA <- ReferenceNode\r
220 \-BBBB\r
221\r
222 @ingroup NameSpaceApis\r
223\r
224 @param [in] ReferenceNode Reference node.\r
225 If a relative path is given, the\r
226 search is done from this node. If\r
227 an absolute path is given, the\r
228 search is done from the root node.\r
229 Must be a root node or an object\r
230 node which is part of the\r
231 namespace.\r
232 @param [in] AslPath ASL path to the searched node in\r
233 the namespace. An ASL path name is\r
234 NULL terminated. Can be a relative\r
235 or absolute path.\r
236 E.g.: "\\_SB.CLU0.CPU0" or "^CPU0"\r
237 @param [out] OutNode Pointer to the found node.\r
238 Contains NULL if not found.\r
239\r
240 @retval EFI_SUCCESS The function completed successfully.\r
241 @retval EFI_BUFFER_TOO_SMALL No space left in the buffer.\r
242 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
243 @retval EFI_OUT_OF_RESOURCES Out of memory.\r
244**/\r
245EFI_STATUS\r
246EFIAPI\r
247AmlFindNode (\r
731c67e1
MK
248 IN AML_NODE_HANDLE ReferenceNode,\r
249 IN CHAR8 *AslPath,\r
250 OUT AML_NODE_HANDLE *OutNode\r
c85ac524
PG
251 );\r
252\r
253/**\r
254 @defgroup UserApis User APIs\r
255 @{\r
256 User APIs are implemented to ease most common actions that might be done\r
257 using the AmlLib. They allow to find specific objects like "_UID" or\r
258 "_CRS" and to update their value. It also shows what can be done using\r
259 AmlLib functions.\r
260 @}\r
261*/\r
262\r
263/** Update the name of a DeviceOp object node.\r
264\r
265 @ingroup UserApis\r
266\r
267 @param [in] DeviceOpNode Object node representing a Device.\r
268 Must have an OpCode=AML_NAME_OP, SubOpCode=0.\r
269 OpCode/SubOpCode.\r
270 DeviceOp object nodes are defined in ASL\r
271 using the "Device ()" function.\r
272 @param [in] NewNameString The new Device's name.\r
273 Must be a NULL-terminated ASL NameString\r
274 e.g.: "DEV0", "DV15.DEV0", etc.\r
275 The input string is copied.\r
276\r
277 @retval EFI_SUCCESS The function completed successfully.\r
278 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
279**/\r
280EFI_STATUS\r
281EFIAPI\r
282AmlDeviceOpUpdateName (\r
731c67e1
MK
283 IN AML_OBJECT_NODE_HANDLE DeviceOpNode,\r
284 IN CHAR8 *NewNameString\r
c85ac524
PG
285 );\r
286\r
287/** Update an integer value defined by a NameOp object node.\r
288\r
289 For compatibility reasons, the NameOpNode must initially\r
290 contain an integer.\r
291\r
292 @ingroup UserApis\r
293\r
294 @param [in] NameOpNode NameOp object node.\r
295 Must have an OpCode=AML_NAME_OP, SubOpCode=0.\r
296 NameOp object nodes are defined in ASL\r
297 using the "Name ()" function.\r
298 @param [in] NewInt New Integer value to assign.\r
299 Must be a UINT64.\r
300\r
301 @retval EFI_SUCCESS The function completed successfully.\r
302 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
303**/\r
304EFI_STATUS\r
305EFIAPI\r
306AmlNameOpUpdateInteger (\r
307 IN AML_OBJECT_NODE_HANDLE NameOpNode,\r
308 IN UINT64 NewInt\r
309 );\r
310\r
311/** Update a string value defined by a NameOp object node.\r
312\r
313 The NameOpNode must initially contain a string.\r
314 The EISAID ASL macro converts a string to an integer. This, it is\r
315 not accepted.\r
316\r
317 @ingroup UserApis\r
318\r
319 @param [in] NameOpNode NameOp object node.\r
320 Must have an OpCode=AML_NAME_OP, SubOpCode=0.\r
321 NameOp object nodes are defined in ASL\r
322 using the "Name ()" function.\r
323 @param [in] NewName New NULL terminated string to assign to\r
324 the NameOpNode.\r
325 The input string is copied.\r
326\r
327 @retval EFI_SUCCESS The function completed successfully.\r
328 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
329**/\r
330EFI_STATUS\r
331EFIAPI\r
332AmlNameOpUpdateString (\r
731c67e1
MK
333 IN AML_OBJECT_NODE_HANDLE NameOpNode,\r
334 IN CONST CHAR8 *NewName\r
c85ac524
PG
335 );\r
336\r
691c5f77 337/** Get the first Resource Data element contained in a named object.\r
c85ac524
PG
338\r
339 In the following ASL code, the function will return the Resource Data\r
340 node corresponding to the "QWordMemory ()" ASL macro.\r
341 Name (_CRS, ResourceTemplate() {\r
342 QWordMemory (...) {...},\r
343 Interrupt (...) {...}\r
344 }\r
345 )\r
346\r
347 Note:\r
691c5f77
PG
348 "_CRS" names defined as methods are not handled by this function.\r
349 They must be defined as names, using the "Name ()" statement.\r
c85ac524
PG
350\r
351 @ingroup UserApis\r
352\r
691c5f77
PG
353 @param [in] NameOpNode NameOp object node defining a named object.\r
354 Must have an OpCode=AML_NAME_OP, SubOpCode=0.\r
355 NameOp object nodes are defined in ASL\r
356 using the "Name ()" function.\r
357 @param [out] OutRdNode Pointer to the first Resource Data element of\r
358 the named object. A Resource Data element\r
359 is stored in a data node.\r
c85ac524
PG
360\r
361 @retval EFI_SUCCESS The function completed successfully.\r
362 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
363**/\r
364EFI_STATUS\r
365EFIAPI\r
691c5f77 366AmlNameOpGetFirstRdNode (\r
731c67e1
MK
367 IN AML_OBJECT_NODE_HANDLE NameOpNode,\r
368 OUT AML_DATA_NODE_HANDLE *OutRdNode\r
c85ac524
PG
369 );\r
370\r
371/** Get the Resource Data element following the CurrRdNode Resource Data.\r
372\r
373 In the following ASL code, if CurrRdNode corresponds to the first\r
374 "QWordMemory ()" ASL macro, the function will return the Resource Data\r
375 node corresponding to the "Interrupt ()" ASL macro.\r
376 Name (_CRS, ResourceTemplate() {\r
377 QwordMemory (...) {...},\r
378 Interrupt (...) {...}\r
379 }\r
380 )\r
381\r
691c5f77
PG
382 Note:\r
383 "_CRS" names defined as methods are not handled by this function.\r
384 They must be defined as names, using the "Name ()" statement.\r
c85ac524
PG
385\r
386 @ingroup UserApis\r
387\r
388 @param [in] CurrRdNode Pointer to the current Resource Data element of\r
691c5f77 389 the named object.\r
c85ac524
PG
390 @param [out] OutRdNode Pointer to the Resource Data element following\r
391 the CurrRdNode.\r
392 Contain a NULL pointer if CurrRdNode is the\r
393 last Resource Data element in the list.\r
394 The "End Tag" is not considered as a resource\r
395 data element and is not returned.\r
396\r
397 @retval EFI_SUCCESS The function completed successfully.\r
398 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
399**/\r
400EFI_STATUS\r
401EFIAPI\r
691c5f77 402AmlNameOpGetNextRdNode (\r
731c67e1
MK
403 IN AML_DATA_NODE_HANDLE CurrRdNode,\r
404 OUT AML_DATA_NODE_HANDLE *OutRdNode\r
c85ac524
PG
405 );\r
406\r
407/** Update the first interrupt of an Interrupt resource data node.\r
408\r
409 The flags of the Interrupt resource data are left unchanged.\r
410\r
411 The InterruptRdNode corresponds to the Resource Data created by the\r
412 "Interrupt ()" ASL macro. It is an Extended Interrupt Resource Data.\r
413 See ACPI 6.3 specification, s6.4.3.6 "Extended Interrupt Descriptor"\r
414 for more information about Extended Interrupt Resource Data.\r
415\r
416 @ingroup UserApis\r
417\r
418 @param [in] InterruptRdNode Pointer to the an extended interrupt\r
419 resource data node.\r
420 @param [in] Irq Interrupt value to update.\r
421\r
422 @retval EFI_SUCCESS The function completed successfully.\r
423 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
424 @retval EFI_OUT_OF_RESOURCES Out of resources.\r
425**/\r
426EFI_STATUS\r
427EFIAPI\r
428AmlUpdateRdInterrupt (\r
731c67e1
MK
429 IN AML_DATA_NODE_HANDLE InterruptRdNode,\r
430 IN UINT32 Irq\r
c85ac524
PG
431 );\r
432\r
433/** Update the base address and length of a QWord resource data node.\r
434\r
435 @ingroup UserApis\r
436\r
437 @param [in] QWordRdNode Pointer a QWord resource data\r
438 node.\r
439 @param [in] BaseAddress Base address.\r
440 @param [in] BaseAddressLength Base address length.\r
441\r
442 @retval EFI_SUCCESS The function completed successfully.\r
443 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
444 @retval EFI_OUT_OF_RESOURCES Out of resources.\r
445**/\r
446EFI_STATUS\r
447EFIAPI\r
448AmlUpdateRdQWord (\r
449 IN AML_DATA_NODE_HANDLE QWordRdNode,\r
450 IN UINT64 BaseAddress,\r
451 IN UINT64 BaseAddressLength\r
452 );\r
453\r
7f1861be
PG
454/** Code generation for the "DWordIO ()" ASL function.\r
455\r
456 The Resource Data effectively created is a DWord Address Space Resource\r
457 Data. Cf ACPI 6.4:\r
458 - s6.4.3.5.2 "DWord Address Space Descriptor".\r
459 - s19.6.34 "DWordIO".\r
460\r
461 The created resource data node can be:\r
462 - appended to the list of resource data elements of the NameOpNode.\r
463 In such case NameOpNode must be defined by a the "Name ()" ASL statement\r
464 and initially contain a "ResourceTemplate ()".\r
465 - returned through the NewRdNode parameter.\r
466\r
467 See ACPI 6.4 spec, s19.6.34 for more.\r
468\r
469 @param [in] IsResourceConsumer ResourceUsage parameter.\r
470 @param [in] IsMinFixed Minimum address is fixed.\r
471 @param [in] IsMaxFixed Maximum address is fixed.\r
472 @param [in] IsPosDecode Decode parameter\r
473 @param [in] IsaRanges Possible values are:\r
474 0-Reserved\r
475 1-NonISAOnly\r
476 2-ISAOnly\r
477 3-EntireRange\r
478 @param [in] AddressGranularity Address granularity.\r
479 @param [in] AddressMinimum Minimum address.\r
480 @param [in] AddressMaximum Maximum address.\r
481 @param [in] AddressTranslation Address translation.\r
482 @param [in] RangeLength Range length.\r
483 @param [in] ResourceSourceIndex Resource Source index.\r
484 Not supported. Must be 0.\r
485 @param [in] ResourceSource Resource Source.\r
486 Not supported. Must be NULL.\r
487 @param [in] IsDenseTranslation TranslationDensity parameter.\r
488 @param [in] IsTypeStatic TranslationType parameter.\r
489 @param [in] NameOpNode NameOp object node defining a named object.\r
490 If provided, append the new resource data\r
491 node to the list of resource data elements\r
492 of this node.\r
493 @param [out] NewRdNode If provided and success,\r
494 contain the created node.\r
495\r
496 @retval EFI_SUCCESS The function completed successfully.\r
497 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
498 @retval EFI_OUT_OF_RESOURCES Could not allocate memory.\r
499**/\r
500EFI_STATUS\r
501EFIAPI\r
502AmlCodeGenRdDWordIo (\r
503 IN BOOLEAN IsResourceConsumer,\r
504 IN BOOLEAN IsMinFixed,\r
505 IN BOOLEAN IsMaxFixed,\r
506 IN BOOLEAN IsPosDecode,\r
507 IN UINT8 IsaRanges,\r
508 IN UINT32 AddressGranularity,\r
509 IN UINT32 AddressMinimum,\r
510 IN UINT32 AddressMaximum,\r
511 IN UINT32 AddressTranslation,\r
512 IN UINT32 RangeLength,\r
513 IN UINT8 ResourceSourceIndex,\r
514 IN CONST CHAR8 *ResourceSource,\r
515 IN BOOLEAN IsDenseTranslation,\r
516 IN BOOLEAN IsTypeStatic,\r
517 IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL\r
518 OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL\r
519 );\r
520\r
521/** Code generation for the "DWordMemory ()" ASL function.\r
522\r
523 The Resource Data effectively created is a DWord Address Space Resource\r
524 Data. Cf ACPI 6.4:\r
525 - s6.4.3.5.2 "DWord Address Space Descriptor".\r
526 - s19.6.35 "DWordMemory".\r
527\r
528 The created resource data node can be:\r
529 - appended to the list of resource data elements of the NameOpNode.\r
530 In such case NameOpNode must be defined by a the "Name ()" ASL statement\r
531 and initially contain a "ResourceTemplate ()".\r
532 - returned through the NewRdNode parameter.\r
533\r
534 See ACPI 6.4 spec, s19.6.35 for more.\r
535\r
536 @param [in] IsResourceConsumer ResourceUsage parameter.\r
537 @param [in] IsPosDecode Decode parameter\r
538 @param [in] IsMinFixed Minimum address is fixed.\r
539 @param [in] IsMaxFixed Maximum address is fixed.\r
540 @param [in] Cacheable Possible values are:\r
541 0-The memory is non-cacheable\r
542 1-The memory is cacheable\r
543 2-The memory is cacheable and supports\r
544 write combining\r
545 3-The memory is cacheable and prefetchable\r
546 @param [in] IsReadWrite ReadAndWrite parameter.\r
547 @param [in] AddressGranularity Address granularity.\r
548 @param [in] AddressMinimum Minimum address.\r
549 @param [in] AddressMaximum Maximum address.\r
550 @param [in] AddressTranslation Address translation.\r
551 @param [in] RangeLength Range length.\r
552 @param [in] ResourceSourceIndex Resource Source index.\r
553 Not supported. Must be 0.\r
554 @param [in] ResourceSource Resource Source.\r
555 Not supported. Must be NULL.\r
556 @param [in] MemoryRangeType Possible values are:\r
557 0-AddressRangeMemory\r
558 1-AddressRangeReserved\r
559 2-AddressRangeACPI\r
560 3-AddressRangeNVS\r
561 @param [in] IsTypeStatic TranslationType parameter.\r
562 @param [in] NameOpNode NameOp object node defining a named object.\r
563 If provided, append the new resource data\r
564 node to the list of resource data elements\r
565 of this node.\r
566 @param [out] NewRdNode If provided and success,\r
567 contain the created node.\r
568\r
569 @retval EFI_SUCCESS The function completed successfully.\r
570 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
571 @retval EFI_OUT_OF_RESOURCES Could not allocate memory.\r
572**/\r
573EFI_STATUS\r
574EFIAPI\r
575AmlCodeGenRdDWordMemory (\r
576 IN BOOLEAN IsResourceConsumer,\r
577 IN BOOLEAN IsPosDecode,\r
578 IN BOOLEAN IsMinFixed,\r
579 IN BOOLEAN IsMaxFixed,\r
580 IN UINT8 Cacheable,\r
581 IN BOOLEAN IsReadWrite,\r
582 IN UINT32 AddressGranularity,\r
583 IN UINT32 AddressMinimum,\r
584 IN UINT32 AddressMaximum,\r
585 IN UINT32 AddressTranslation,\r
586 IN UINT32 RangeLength,\r
587 IN UINT8 ResourceSourceIndex,\r
588 IN CONST CHAR8 *ResourceSource,\r
589 IN UINT8 MemoryRangeType,\r
590 IN BOOLEAN IsTypeStatic,\r
591 IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL\r
592 OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL\r
593 );\r
594\r
45b16126
RC
595/** Code generation for the "Memory32Fixed ()" ASL macro.\r
596\r
597 The Resource Data effectively created is a 32-bit Memory Resource\r
598 Data. Cf ACPI 6.4:\r
599 - s19.6.83 "Memory Resource Descriptor Macro".\r
600 - s19.2.8 "Memory32FixedTerm".\r
601\r
602 See ACPI 6.4 spec, s19.2.8 for more.\r
603\r
604 @param [in] IsReadWrite ReadAndWrite parameter.\r
605 @param [in] Address AddressBase parameter.\r
606 @param [in] RangeLength Range length.\r
607 @param [in] NameOpNode NameOp object node defining a named object.\r
608 If provided, append the new resource data\r
609 node to the list of resource data elements\r
610 of this node.\r
611 @param [out] NewMemNode If provided and success,\r
612 contain the created node.\r
613\r
614 @retval EFI_SUCCESS The function completed successfully.\r
615 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
616 @retval EFI_OUT_OF_RESOURCES Could not allocate memory.\r
617**/\r
618EFI_STATUS\r
619EFIAPI\r
620AmlCodeGenRdMemory32Fixed (\r
621 BOOLEAN IsReadWrite,\r
622 UINT32 Address,\r
623 UINT32 RangeLength,\r
624 AML_OBJECT_NODE_HANDLE NameOpNode,\r
625 AML_DATA_NODE_HANDLE *NewMemNode\r
626 );\r
627\r
7f1861be
PG
628/** Code generation for the "WordBusNumber ()" ASL function.\r
629\r
630 The Resource Data effectively created is a Word Address Space Resource\r
631 Data. Cf ACPI 6.4:\r
632 - s6.4.3.5.3 "Word Address Space Descriptor".\r
633 - s19.6.149 "WordBusNumber".\r
634\r
635 The created resource data node can be:\r
636 - appended to the list of resource data elements of the NameOpNode.\r
637 In such case NameOpNode must be defined by a the "Name ()" ASL statement\r
638 and initially contain a "ResourceTemplate ()".\r
639 - returned through the NewRdNode parameter.\r
640\r
641 See ACPI 6.4 spec, s19.6.149 for more.\r
642\r
643 @param [in] IsResourceConsumer ResourceUsage parameter.\r
644 @param [in] IsMinFixed Minimum address is fixed.\r
645 @param [in] IsMaxFixed Maximum address is fixed.\r
646 @param [in] IsPosDecode Decode parameter\r
647 @param [in] AddressGranularity Address granularity.\r
648 @param [in] AddressMinimum Minimum address.\r
649 @param [in] AddressMaximum Maximum address.\r
650 @param [in] AddressTranslation Address translation.\r
651 @param [in] RangeLength Range length.\r
652 @param [in] ResourceSourceIndex Resource Source index.\r
653 Not supported. Must be 0.\r
654 @param [in] ResourceSource Resource Source.\r
655 Not supported. Must be NULL.\r
656 @param [in] NameOpNode NameOp object node defining a named object.\r
657 If provided, append the new resource data\r
658 node to the list of resource data elements\r
659 of this node.\r
660 @param [out] NewRdNode If provided and success,\r
661 contain the created node.\r
662\r
663 @retval EFI_SUCCESS The function completed successfully.\r
664 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
665 @retval EFI_OUT_OF_RESOURCES Could not allocate memory.\r
666**/\r
667EFI_STATUS\r
668EFIAPI\r
669AmlCodeGenRdWordBusNumber (\r
670 IN BOOLEAN IsResourceConsumer,\r
671 IN BOOLEAN IsMinFixed,\r
672 IN BOOLEAN IsMaxFixed,\r
673 IN BOOLEAN IsPosDecode,\r
674 IN UINT32 AddressGranularity,\r
675 IN UINT32 AddressMinimum,\r
676 IN UINT32 AddressMaximum,\r
677 IN UINT32 AddressTranslation,\r
678 IN UINT32 RangeLength,\r
679 IN UINT8 ResourceSourceIndex,\r
680 IN CONST CHAR8 *ResourceSource,\r
681 IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL\r
682 OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL\r
683 );\r
684\r
685/** Code generation for the "QWordMemory ()" ASL function.\r
686\r
687 The Resource Data effectively created is a QWord Address Space Resource\r
688 Data. Cf ACPI 6.4:\r
689 - s6.4.3.5.1 "QWord Address Space Descriptor".\r
690 - s19.6.110 "QWordMemory".\r
691\r
692 The created resource data node can be:\r
693 - appended to the list of resource data elements of the NameOpNode.\r
694 In such case NameOpNode must be defined by a the "Name ()" ASL statement\r
695 and initially contain a "ResourceTemplate ()".\r
696 - returned through the NewRdNode parameter.\r
697\r
698 See ACPI 6.4 spec, s19.6.110 for more.\r
699\r
700 @param [in] IsResourceConsumer ResourceUsage parameter.\r
701 @param [in] IsPosDecode Decode parameter.\r
702 @param [in] IsMinFixed Minimum address is fixed.\r
703 @param [in] IsMaxFixed Maximum address is fixed.\r
704 @param [in] Cacheable Possible values are:\r
705 0-The memory is non-cacheable\r
706 1-The memory is cacheable\r
707 2-The memory is cacheable and supports\r
708 write combining\r
709 3-The memory is cacheable and prefetchable\r
710 @param [in] IsReadWrite ReadAndWrite parameter.\r
711 @param [in] AddressGranularity Address granularity.\r
712 @param [in] AddressMinimum Minimum address.\r
713 @param [in] AddressMaximum Maximum address.\r
714 @param [in] AddressTranslation Address translation.\r
715 @param [in] RangeLength Range length.\r
716 @param [in] ResourceSourceIndex Resource Source index.\r
717 Not supported. Must be 0.\r
718 @param [in] ResourceSource Resource Source.\r
719 Not supported. Must be NULL.\r
720 @param [in] MemoryRangeType Possible values are:\r
721 0-AddressRangeMemory\r
722 1-AddressRangeReserved\r
723 2-AddressRangeACPI\r
724 3-AddressRangeNVS\r
725 @param [in] IsTypeStatic TranslationType parameter.\r
726 @param [in] NameOpNode NameOp object node defining a named object.\r
727 If provided, append the new resource data\r
728 node to the list of resource data elements\r
729 of this node.\r
730 @param [out] NewRdNode If provided and success,\r
731 contain the created node.\r
732\r
733 @retval EFI_SUCCESS The function completed successfully.\r
734 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
735 @retval EFI_OUT_OF_RESOURCES Could not allocate memory.\r
736**/\r
737EFI_STATUS\r
738EFIAPI\r
739AmlCodeGenRdQWordMemory (\r
740 IN BOOLEAN IsResourceConsumer,\r
741 IN BOOLEAN IsPosDecode,\r
742 IN BOOLEAN IsMinFixed,\r
743 IN BOOLEAN IsMaxFixed,\r
744 IN UINT8 Cacheable,\r
745 IN BOOLEAN IsReadWrite,\r
746 IN UINT64 AddressGranularity,\r
747 IN UINT64 AddressMinimum,\r
748 IN UINT64 AddressMaximum,\r
749 IN UINT64 AddressTranslation,\r
750 IN UINT64 RangeLength,\r
751 IN UINT8 ResourceSourceIndex,\r
752 IN CONST CHAR8 *ResourceSource,\r
753 IN UINT8 MemoryRangeType,\r
754 IN BOOLEAN IsTypeStatic,\r
755 IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL\r
756 OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL\r
757 );\r
758\r
22873f58 759/** Code generation for the "Interrupt ()" ASL function.\r
c85ac524
PG
760\r
761 The Resource Data effectively created is an Extended Interrupt Resource\r
22873f58
PG
762 Data. Cf ACPI 6.4:\r
763 - s6.4.3.6 "Extended Interrupt Descriptor"\r
764 - s19.6.64 "Interrupt (Interrupt Resource Descriptor Macro)"\r
c85ac524 765\r
22873f58
PG
766 The created resource data node can be:\r
767 - appended to the list of resource data elements of the NameOpNode.\r
768 In such case NameOpNode must be defined by a the "Name ()" ASL statement\r
769 and initially contain a "ResourceTemplate ()".\r
770 - returned through the NewRdNode parameter.\r
c85ac524 771\r
691c5f77 772 @ingroup CodeGenApis\r
c85ac524 773\r
c85ac524
PG
774 @param [in] ResourceConsumer The device consumes the specified interrupt\r
775 or produces it for use by a child device.\r
776 @param [in] EdgeTriggered The interrupt is edge triggered or\r
777 level triggered.\r
778 @param [in] ActiveLow The interrupt is active-high or active-low.\r
779 @param [in] Shared The interrupt can be shared with other\r
780 devices or not (Exclusive).\r
781 @param [in] IrqList Interrupt list. Must be non-NULL.\r
782 @param [in] IrqCount Interrupt count. Must be non-zero.\r
22873f58
PG
783 @param [in] NameOpNode NameOp object node defining a named object.\r
784 If provided, append the new resource data node\r
785 to the list of resource data elements of this\r
786 node.\r
787 @param [out] NewRdNode If provided and success,\r
788 contain the created node.\r
c85ac524
PG
789\r
790 @retval EFI_SUCCESS The function completed successfully.\r
791 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
792 @retval EFI_OUT_OF_RESOURCES Could not allocate memory.\r
793**/\r
794EFI_STATUS\r
795EFIAPI\r
22873f58 796AmlCodeGenRdInterrupt (\r
c85ac524
PG
797 IN BOOLEAN ResourceConsumer,\r
798 IN BOOLEAN EdgeTriggered,\r
799 IN BOOLEAN ActiveLow,\r
800 IN BOOLEAN Shared,\r
22873f58
PG
801 IN UINT32 *IrqList,\r
802 IN UINT8 IrqCount,\r
fe2d8189 803 IN AML_OBJECT_NODE_HANDLE NameOpNode OPTIONAL,\r
22873f58 804 OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL\r
c85ac524
PG
805 );\r
806\r
807/** AML code generation for DefinitionBlock.\r
808\r
809 Create a Root Node handle.\r
810 It is the caller's responsibility to free the allocated memory\r
811 with the AmlDeleteTree function.\r
812\r
813 AmlCodeGenDefinitionBlock (TableSignature, OemId, TableID, OEMRevision) is\r
814 equivalent to the following ASL code:\r
815 DefinitionBlock (AMLFileName, TableSignature, ComplianceRevision,\r
816 OemId, TableID, OEMRevision) {}\r
817 with the ComplianceRevision set to 2 and the AMLFileName is ignored.\r
818\r
819 @ingroup CodeGenApis\r
820\r
821 @param[in] TableSignature 4-character ACPI signature.\r
822 Must be 'DSDT' or 'SSDT'.\r
823 @param[in] OemId 6-character string OEM identifier.\r
824 @param[in] OemTableId 8-character string OEM table identifier.\r
825 @param[in] OemRevision OEM revision number.\r
826 @param[out] DefinitionBlockTerm The ASL Term handle representing a\r
827 Definition Block.\r
828\r
829 @retval EFI_SUCCESS Success.\r
830 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
831 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
832**/\r
833EFI_STATUS\r
834EFIAPI\r
835AmlCodeGenDefinitionBlock (\r
731c67e1
MK
836 IN CONST CHAR8 *TableSignature,\r
837 IN CONST CHAR8 *OemId,\r
838 IN CONST CHAR8 *OemTableId,\r
839 IN UINT32 OemRevision,\r
840 OUT AML_ROOT_NODE_HANDLE *NewRootNode\r
c85ac524
PG
841 );\r
842\r
843/** AML code generation for a Name object node, containing a String.\r
844\r
845 AmlCodeGenNameString ("_HID", "HID0000", ParentNode, NewObjectNode) is\r
846 equivalent of the following ASL code:\r
847 Name(_HID, "HID0000")\r
848\r
849 @ingroup CodeGenApis\r
850\r
851 @param [in] NameString The new variable name.\r
852 Must be a NULL-terminated ASL NameString\r
853 e.g.: "DEV0", "DV15.DEV0", etc.\r
854 The input string is copied.\r
855 @param [in] String NULL terminated String to associate to the\r
856 NameString.\r
857 @param [in] ParentNode If provided, set ParentNode as the parent\r
858 of the node created.\r
859 @param [out] NewObjectNode If success, contains the created node.\r
860\r
861 @retval EFI_SUCCESS Success.\r
862 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
863 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
864**/\r
865EFI_STATUS\r
866EFIAPI\r
867AmlCodeGenNameString (\r
731c67e1
MK
868 IN CONST CHAR8 *NameString,\r
869 IN CHAR8 *String,\r
870 IN AML_NODE_HANDLE ParentNode OPTIONAL,\r
871 OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL\r
c85ac524
PG
872 );\r
873\r
874/** AML code generation for a Name object node, containing an Integer.\r
875\r
876 AmlCodeGenNameInteger ("_UID", 1, ParentNode, NewObjectNode) is\r
877 equivalent of the following ASL code:\r
878 Name(_UID, One)\r
879\r
880 @ingroup CodeGenApis\r
881\r
882 @param [in] NameString The new variable name.\r
883 Must be a NULL-terminated ASL NameString\r
884 e.g.: "DEV0", "DV15.DEV0", etc.\r
885 The input string is copied.\r
886 @param [in] Integer Integer to associate to the NameString.\r
887 @param [in] ParentNode If provided, set ParentNode as the parent\r
888 of the node created.\r
889 @param [out] NewObjectNode If success, contains the created node.\r
890\r
891 @retval EFI_SUCCESS Success.\r
892 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
893 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
894**/\r
895EFI_STATUS\r
896EFIAPI\r
897AmlCodeGenNameInteger (\r
731c67e1
MK
898 IN CONST CHAR8 *NameString,\r
899 IN UINT64 Integer,\r
900 IN AML_NODE_HANDLE ParentNode OPTIONAL,\r
901 OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL\r
c85ac524
PG
902 );\r
903\r
0e7147fe
PG
904/** AML code generation for a Name object node, containing a Package.\r
905\r
906 AmlCodeGenNamePackage ("PKG0", ParentNode, NewObjectNode) is\r
907 equivalent of the following ASL code:\r
908 Name(PKG0, Package () {})\r
909\r
910 @ingroup CodeGenApis\r
911\r
912 @param [in] NameString The new variable name.\r
913 Must be a NULL-terminated ASL NameString\r
914 e.g.: "DEV0", "DV15.DEV0", etc.\r
915 The input string is copied.\r
916 @param [in] ParentNode If provided, set ParentNode as the parent\r
917 of the node created.\r
918 @param [out] NewObjectNode If success, contains the created node.\r
919\r
920 @retval EFI_SUCCESS Success.\r
921 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
922 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
923**/\r
924EFI_STATUS\r
925EFIAPI\r
926AmlCodeGenNamePackage (\r
927 IN CONST CHAR8 *NameString,\r
928 IN AML_NODE_HANDLE ParentNode, OPTIONAL\r
929 OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL\r
930 );\r
931\r
fd5fc4bb
PG
932/** AML code generation for a Name object node, containing a ResourceTemplate.\r
933\r
934 AmlCodeGenNameResourceTemplate ("PRS0", ParentNode, NewObjectNode) is\r
935 equivalent of the following ASL code:\r
936 Name(PRS0, ResourceTemplate () {})\r
937\r
938 @ingroup CodeGenApis\r
939\r
940 @param [in] NameString The new variable name.\r
941 Must be a NULL-terminated ASL NameString\r
942 e.g.: "DEV0", "DV15.DEV0", etc.\r
943 The input string is copied.\r
944 @param [in] ParentNode If provided, set ParentNode as the parent\r
945 of the node created.\r
946 @param [out] NewObjectNode If success, contains the created node.\r
947\r
948 @retval EFI_SUCCESS Success.\r
949 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
950 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
951**/\r
952EFI_STATUS\r
953EFIAPI\r
954AmlCodeGenNameResourceTemplate (\r
955 IN CONST CHAR8 *NameString,\r
956 IN AML_NODE_HANDLE ParentNode, OPTIONAL\r
957 OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL\r
958 );\r
959\r
b2b8def4
PG
960/** Add a _PRT entry.\r
961\r
962 AmlCodeGenPrtEntry (0x0FFFF, 0, "LNKA", 0, PrtNameNode) is\r
963 equivalent of the following ASL code:\r
964 Package (4) {\r
965 0x0FFFF, // Address: Device address (([Device Id] << 16) | 0xFFFF).\r
966 0, // Pin: PCI pin number of the device (0-INTA, ...).\r
967 LNKA // Source: Name of the device that allocates the interrupt\r
968 // to which the above pin is connected.\r
969 0 // Source Index: Source is assumed to only describe one\r
970 // interrupt, so let it to index 0.\r
971 }\r
972\r
973 The package is added at the tail of the list of the input _PRT node\r
974 name:\r
975 Name (_PRT, Package () {\r
976 [Pre-existing _PRT entries],\r
977 [Newly created _PRT entry]\r
978 })\r
979\r
980 Cf. ACPI 6.4, s6.2.13 "_PRT (PCI Routing Table)"\r
981\r
982 @ingroup CodeGenApis\r
983\r
984 @param [in] Address Address. Cf ACPI 6.4 specification, Table 6.2:\r
985 "ADR Object Address Encodings":\r
986 High word-Device #, Low word-Function #. (for\r
987 example, device 3, function 2 is 0x00030002).\r
988 To refer to all the functions on a device #,\r
989 use a function number of FFFF).\r
990 @param [in] Pin PCI pin number of the device (0-INTA ... 3-INTD).\r
991 Must be between 0-3.\r
992 @param [in] LinkName Link Name, i.e. device in the AML NameSpace\r
993 describing the interrupt used.\r
994 The input string is copied.\r
995 @param [in] SourceIndex Source index or GSIV.\r
996 @param [in] PrtNameNode Prt Named node to add the object to ....\r
997\r
998 @retval EFI_SUCCESS Success.\r
999 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
1000 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
1001**/\r
1002EFI_STATUS\r
1003EFIAPI\r
1004AmlAddPrtEntry (\r
1005 IN UINT32 Address,\r
1006 IN UINT8 Pin,\r
1007 IN CONST CHAR8 *LinkName,\r
1008 IN UINT32 SourceIndex,\r
1009 IN AML_OBJECT_NODE_HANDLE PrtNameNode\r
1010 );\r
1011\r
c85ac524
PG
1012/** AML code generation for a Device object node.\r
1013\r
1014 AmlCodeGenDevice ("COM0", ParentNode, NewObjectNode) is\r
1015 equivalent of the following ASL code:\r
1016 Device(COM0) {}\r
1017\r
1018 @ingroup CodeGenApis\r
1019\r
1020 @param [in] NameString The new Device's name.\r
1021 Must be a NULL-terminated ASL NameString\r
1022 e.g.: "DEV0", "DV15.DEV0", etc.\r
1023 The input string is copied.\r
1024 @param [in] ParentNode If provided, set ParentNode as the parent\r
1025 of the node created.\r
1026 @param [out] NewObjectNode If success, contains the created node.\r
1027\r
1028 @retval EFI_SUCCESS Success.\r
1029 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
1030 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
1031**/\r
1032EFI_STATUS\r
1033EFIAPI\r
1034AmlCodeGenDevice (\r
731c67e1
MK
1035 IN CONST CHAR8 *NameString,\r
1036 IN AML_NODE_HANDLE ParentNode OPTIONAL,\r
1037 OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL\r
c85ac524
PG
1038 );\r
1039\r
1040/** AML code generation for a Scope object node.\r
1041\r
1042 AmlCodeGenScope ("_SB", ParentNode, NewObjectNode) is\r
1043 equivalent of the following ASL code:\r
1044 Scope(_SB) {}\r
1045\r
1046 @ingroup CodeGenApis\r
1047\r
1048 @param [in] NameString The new Scope's name.\r
1049 Must be a NULL-terminated ASL NameString\r
1050 e.g.: "DEV0", "DV15.DEV0", etc.\r
1051 The input string is copied.\r
1052 @param [in] ParentNode If provided, set ParentNode as the parent\r
1053 of the node created.\r
1054 @param [out] NewObjectNode If success, contains the created node.\r
1055\r
1056 @retval EFI_SUCCESS Success.\r
1057 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
1058 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
1059**/\r
1060EFI_STATUS\r
1061EFIAPI\r
1062AmlCodeGenScope (\r
731c67e1
MK
1063 IN CONST CHAR8 *NameString,\r
1064 IN AML_NODE_HANDLE ParentNode OPTIONAL,\r
1065 OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL\r
c85ac524
PG
1066 );\r
1067\r
3e958e93
PG
1068/** AML code generation for a method returning a NameString.\r
1069\r
1070 AmlCodeGenMethodRetNameString (\r
1071 "MET0", "_CRS", 1, TRUE, 3, ParentNode, NewObjectNode\r
1072 );\r
1073 is equivalent of the following ASL code:\r
1074 Method(MET0, 1, Serialized, 3) {\r
1075 Return (_CRS)\r
1076 }\r
1077\r
1078 The ASL parameters "ReturnType" and "ParameterTypes" are not asked\r
1079 in this function. They are optional parameters in ASL.\r
1080\r
1081 @ingroup CodeGenApis\r
1082\r
1083 @param [in] MethodNameString The new Method's name.\r
1084 Must be a NULL-terminated ASL NameString\r
1085 e.g.: "MET0", "_SB.MET0", etc.\r
1086 The input string is copied.\r
1087 @param [in] ReturnedNameString The name of the object returned by the\r
1088 method. Optional parameter, can be:\r
1089 - NULL (ignored).\r
1090 - A NULL-terminated ASL NameString.\r
1091 e.g.: "MET0", "_SB.MET0", etc.\r
1092 The input string is copied.\r
1093 @param [in] NumArgs Number of arguments.\r
1094 Must be 0 <= NumArgs <= 6.\r
1095 @param [in] IsSerialized TRUE is equivalent to Serialized.\r
1096 FALSE is equivalent to NotSerialized.\r
1097 Default is NotSerialized in ASL spec.\r
1098 @param [in] SyncLevel Synchronization level for the method.\r
1099 Must be 0 <= SyncLevel <= 15.\r
1100 Default is 0 in ASL.\r
1101 @param [in] ParentNode If provided, set ParentNode as the parent\r
1102 of the node created.\r
1103 @param [out] NewObjectNode If success, contains the created node.\r
1104\r
1105 @retval EFI_SUCCESS Success.\r
1106 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
1107 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
1108**/\r
1109EFI_STATUS\r
1110EFIAPI\r
1111AmlCodeGenMethodRetNameString (\r
731c67e1
MK
1112 IN CONST CHAR8 *MethodNameString,\r
1113 IN CONST CHAR8 *ReturnedNameString OPTIONAL,\r
1114 IN UINT8 NumArgs,\r
1115 IN BOOLEAN IsSerialized,\r
1116 IN UINT8 SyncLevel,\r
1117 IN AML_NODE_HANDLE ParentNode OPTIONAL,\r
1118 OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL\r
3e958e93
PG
1119 );\r
1120\r
33189f05
RC
1121/** AML code generation for a method returning an Integer.\r
1122\r
1123 AmlCodeGenMethodRetInteger (\r
1124 "_CBA", 0, 1, TRUE, 3, ParentNode, NewObjectNode\r
1125 );\r
1126 is equivalent of the following ASL code:\r
1127 Method(_CBA, 1, Serialized, 3) {\r
1128 Return (0)\r
1129 }\r
1130\r
1131 The ASL parameters "ReturnType" and "ParameterTypes" are not asked\r
1132 in this function. They are optional parameters in ASL.\r
1133\r
1134 @param [in] MethodNameString The new Method's name.\r
1135 Must be a NULL-terminated ASL NameString\r
1136 e.g.: "MET0", "_SB.MET0", etc.\r
1137 The input string is copied.\r
1138 @param [in] ReturnedInteger The value of the integer returned by the\r
1139 method.\r
1140 @param [in] NumArgs Number of arguments.\r
1141 Must be 0 <= NumArgs <= 6.\r
1142 @param [in] IsSerialized TRUE is equivalent to Serialized.\r
1143 FALSE is equivalent to NotSerialized.\r
1144 Default is NotSerialized in ASL spec.\r
1145 @param [in] SyncLevel Synchronization level for the method.\r
1146 Must be 0 <= SyncLevel <= 15.\r
1147 Default is 0 in ASL.\r
1148 @param [in] ParentNode If provided, set ParentNode as the parent\r
1149 of the node created.\r
1150 @param [out] NewObjectNode If success, contains the created node.\r
1151\r
1152 @retval EFI_SUCCESS Success.\r
1153 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
1154 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
1155**/\r
1156EFI_STATUS\r
1157EFIAPI\r
1158AmlCodeGenMethodRetInteger (\r
1159 IN CONST CHAR8 *MethodNameString,\r
1160 IN UINT64 ReturnedInteger,\r
1161 IN UINT8 NumArgs,\r
1162 IN BOOLEAN IsSerialized,\r
1163 IN UINT8 SyncLevel,\r
1164 IN AML_NODE_HANDLE ParentNode OPTIONAL,\r
1165 OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL\r
1166 );\r
1167\r
018a962d
PG
1168/** Create a _LPI name.\r
1169\r
1170 AmlCreateLpiNode ("_LPI", 0, 1, ParentNode, &LpiNode) is\r
1171 equivalent of the following ASL code:\r
1172 Name (_LPI, Package (\r
1173 0, // Revision\r
1174 1, // LevelId\r
1175 0 // Count\r
1176 ))\r
1177\r
1178 This function doesn't define any LPI state. As shown above, the count\r
1179 of _LPI state is set to 0.\r
1180 The AmlAddLpiState () function must be used to add LPI states.\r
1181\r
1182 Cf ACPI 6.3 specification, s8.4.4 "Lower Power Idle States".\r
1183\r
1184 @ingroup CodeGenApis\r
1185\r
1186 @param [in] LpiNameString The new LPI 's object name.\r
1187 Must be a NULL-terminated ASL NameString\r
1188 e.g.: "_LPI", "DEV0.PLPI", etc.\r
1189 The input string is copied.\r
1190 @param [in] Revision Revision number of the _LPI states.\r
1191 @param [in] LevelId A platform defined number that identifies the\r
1192 level of hierarchy of the processor node to\r
1193 which the LPI states apply.\r
1194 @param [in] ParentNode If provided, set ParentNode as the parent\r
1195 of the node created.\r
1196 @param [out] NewLpiNode If success, contains the created node.\r
1197\r
1198 @retval EFI_SUCCESS The function completed successfully.\r
1199 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
1200 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
1201**/\r
1202EFI_STATUS\r
1203EFIAPI\r
1204AmlCreateLpiNode (\r
731c67e1
MK
1205 IN CONST CHAR8 *LpiNameString,\r
1206 IN UINT16 Revision,\r
1207 IN UINT64 LevelId,\r
1208 IN AML_NODE_HANDLE ParentNode OPTIONAL,\r
1209 OUT AML_OBJECT_NODE_HANDLE *NewLpiNode OPTIONAL\r
018a962d
PG
1210 );\r
1211\r
a5e36ad9
PG
1212/** Add an _LPI state to a LPI node created using AmlCreateLpiNode ().\r
1213\r
1214 AmlAddLpiState () increments the Count of LPI states in the LPI node by one,\r
1215 and adds the following package:\r
1216 Package() {\r
1217 MinResidency,\r
1218 WorstCaseWakeLatency,\r
1219 Flags,\r
1220 ArchFlags,\r
1221 ResCntFreq,\r
1222 EnableParentState,\r
1223 (GenericRegisterDescriptor != NULL) ? // Entry method. If a\r
1224 ResourceTemplate(GenericRegisterDescriptor) : // Register is given,\r
1225 Integer, // use it. Use the\r
1226 // Integer otherwise.\r
1227 ResourceTemplate() { // NULL Residency Counter\r
1228 Register (SystemMemory, 0, 0, 0, 0)\r
1229 },\r
1230 ResourceTemplate() { // NULL Usage Counter\r
1231 Register (SystemMemory, 0, 0, 0, 0)\r
1232 },\r
1233 "" // NULL State Name\r
1234 },\r
1235\r
1236 Cf ACPI 6.3 specification, s8.4.4 "Lower Power Idle States".\r
1237\r
1238 @ingroup CodeGenApis\r
1239\r
1240 @param [in] MinResidency Minimum Residency.\r
1241 @param [in] WorstCaseWakeLatency Worst case wake-up latency.\r
1242 @param [in] Flags Flags.\r
1243 @param [in] ArchFlags Architectural flags.\r
1244 @param [in] ResCntFreq Residency Counter Frequency.\r
1245 @param [in] EnableParentState Enabled Parent State.\r
1246 @param [in] GenericRegisterDescriptor Entry Method.\r
1247 If not NULL, use this Register to\r
1248 describe the entry method address.\r
1249 @param [in] Integer Entry Method.\r
1250 If GenericRegisterDescriptor is NULL,\r
1251 take this value.\r
1252 @param [in] ResidencyCounterRegister If not NULL, use it to populate the\r
1253 residency counter register.\r
1254 @param [in] UsageCounterRegister If not NULL, use it to populate the\r
1255 usage counter register.\r
1256 @param [in] StateName If not NULL, use it to populate the\r
1257 state name.\r
1258 @param [in] LpiNode Lpi node created with the function\r
1259 AmlCreateLpiNode to which the new LPI\r
1260 state is appended.\r
1261\r
1262 @retval EFI_SUCCESS The function completed successfully.\r
1263 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
1264 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
1265**/\r
1266EFI_STATUS\r
1267EFIAPI\r
1268AmlAddLpiState (\r
731c67e1
MK
1269 IN UINT32 MinResidency,\r
1270 IN UINT32 WorstCaseWakeLatency,\r
1271 IN UINT32 Flags,\r
1272 IN UINT32 ArchFlags,\r
1273 IN UINT32 ResCntFreq,\r
1274 IN UINT32 EnableParentState,\r
1275 IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE *GenericRegisterDescriptor OPTIONAL,\r
1276 IN UINT64 Integer OPTIONAL,\r
1277 IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE *ResidencyCounterRegister OPTIONAL,\r
1278 IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE *UsageCounterRegister OPTIONAL,\r
1279 IN CHAR8 *StateName OPTIONAL,\r
1280 IN AML_OBJECT_NODE_HANDLE LpiNode\r
a5e36ad9
PG
1281 );\r
1282\r
691c5f77
PG
1283// DEPRECATED APIS\r
1284#ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
1285\r
1286/** DEPRECATED API\r
1287\r
1288 Get the first Resource Data element contained in a "_CRS" object.\r
1289\r
1290 In the following ASL code, the function will return the Resource Data\r
1291 node corresponding to the "QWordMemory ()" ASL macro.\r
1292 Name (_CRS, ResourceTemplate() {\r
1293 QWordMemory (...) {...},\r
1294 Interrupt (...) {...}\r
1295 }\r
1296 )\r
1297\r
1298 Note:\r
1299 - The "_CRS" object must be declared using ASL "Name (Declare Named Object)".\r
1300 - "_CRS" declared using ASL "Method (Declare Control Method)" is not\r
1301 supported.\r
1302\r
1303 @ingroup UserApis\r
1304\r
1305 @param [in] NameOpCrsNode NameOp object node defining a "_CRS" object.\r
1306 Must have an OpCode=AML_NAME_OP, SubOpCode=0.\r
1307 NameOp object nodes are defined in ASL\r
1308 using the "Name ()" function.\r
1309 @param [out] OutRdNode Pointer to the first Resource Data element of\r
1310 the "_CRS" object. A Resource Data element\r
1311 is stored in a data node.\r
1312\r
1313 @retval EFI_SUCCESS The function completed successfully.\r
1314 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
1315**/\r
1316EFI_STATUS\r
1317EFIAPI\r
1318AmlNameOpCrsGetFirstRdNode (\r
731c67e1
MK
1319 IN AML_OBJECT_NODE_HANDLE NameOpCrsNode,\r
1320 OUT AML_DATA_NODE_HANDLE *OutRdNode\r
691c5f77
PG
1321 );\r
1322\r
1323/** DEPRECATED API\r
1324\r
1325 Get the Resource Data element following the CurrRdNode Resource Data.\r
1326\r
1327 In the following ASL code, if CurrRdNode corresponds to the first\r
1328 "QWordMemory ()" ASL macro, the function will return the Resource Data\r
1329 node corresponding to the "Interrupt ()" ASL macro.\r
1330 Name (_CRS, ResourceTemplate() {\r
1331 QwordMemory (...) {...},\r
1332 Interrupt (...) {...}\r
1333 }\r
1334 )\r
1335\r
1336 The CurrRdNode Resource Data node must be defined in an object named "_CRS"\r
1337 and defined by a "Name ()" ASL function.\r
1338\r
1339 @ingroup UserApis\r
1340\r
1341 @param [in] CurrRdNode Pointer to the current Resource Data element of\r
1342 the "_CRS" variable.\r
1343 @param [out] OutRdNode Pointer to the Resource Data element following\r
1344 the CurrRdNode.\r
1345 Contain a NULL pointer if CurrRdNode is the\r
1346 last Resource Data element in the list.\r
1347 The "End Tag" is not considered as a resource\r
1348 data element and is not returned.\r
1349\r
1350 @retval EFI_SUCCESS The function completed successfully.\r
1351 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
1352**/\r
1353EFI_STATUS\r
1354EFIAPI\r
1355AmlNameOpCrsGetNextRdNode (\r
731c67e1
MK
1356 IN AML_DATA_NODE_HANDLE CurrRdNode,\r
1357 OUT AML_DATA_NODE_HANDLE *OutRdNode\r
691c5f77
PG
1358 );\r
1359\r
1360/** DEPRECATED API\r
1361\r
1362 Add an Interrupt Resource Data node.\r
1363\r
1364 This function creates a Resource Data element corresponding to the\r
1365 "Interrupt ()" ASL function, stores it in an AML Data Node.\r
1366\r
1367 It then adds it after the input CurrRdNode in the list of resource data\r
1368 element.\r
1369\r
1370 The Resource Data effectively created is an Extended Interrupt Resource\r
1371 Data. See ACPI 6.3 specification, s6.4.3.6 "Extended Interrupt Descriptor"\r
1372 for more information about Extended Interrupt Resource Data.\r
1373\r
1374 The Extended Interrupt contains one single interrupt.\r
1375\r
1376 This function allocates memory to create a data node. It is the caller's\r
1377 responsibility to either:\r
1378 - attach this node to an AML tree;\r
1379 - delete this node.\r
1380\r
1381 Note: The _CRS node must be defined using the ASL Name () function.\r
1382 e.g. Name (_CRS, ResourceTemplate () {\r
1383 ...\r
1384 }\r
1385\r
1386 @ingroup CodeGenApis\r
1387\r
1388 @param [in] NameOpCrsNode NameOp object node defining a "_CRS" object.\r
1389 Must have an OpCode=AML_NAME_OP, SubOpCode=0.\r
1390 NameOp object nodes are defined in ASL\r
1391 using the "Name ()" function.\r
1392 @param [in] ResourceConsumer The device consumes the specified interrupt\r
1393 or produces it for use by a child device.\r
1394 @param [in] EdgeTriggered The interrupt is edge triggered or\r
1395 level triggered.\r
1396 @param [in] ActiveLow The interrupt is active-high or active-low.\r
1397 @param [in] Shared The interrupt can be shared with other\r
1398 devices or not (Exclusive).\r
1399 @param [in] IrqList Interrupt list. Must be non-NULL.\r
1400 @param [in] IrqCount Interrupt count. Must be non-zero.\r
1401\r
1402\r
1403 @retval EFI_SUCCESS The function completed successfully.\r
1404 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
1405 @retval EFI_OUT_OF_RESOURCES Could not allocate memory.\r
1406**/\r
1407EFI_STATUS\r
1408EFIAPI\r
1409AmlCodeGenCrsAddRdInterrupt (\r
1410 IN AML_OBJECT_NODE_HANDLE NameOpCrsNode,\r
1411 IN BOOLEAN ResourceConsumer,\r
1412 IN BOOLEAN EdgeTriggered,\r
1413 IN BOOLEAN ActiveLow,\r
1414 IN BOOLEAN Shared,\r
731c67e1 1415 IN UINT32 *IrqList,\r
691c5f77
PG
1416 IN UINT8 IrqCount\r
1417 );\r
1418\r
1419#endif // DISABLE_NEW_DEPRECATED_INTERFACES\r
1420\r
c85ac524 1421#endif // AML_LIB_H_\r