]>
Commit | Line | Data |
---|---|---|
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 | |
45 | typedef void* AML_NODE_HANDLE;\r | |
46 | \r | |
47 | /** Root Node handle.\r | |
48 | */\r | |
49 | typedef void* AML_ROOT_NODE_HANDLE;\r | |
50 | \r | |
51 | /** Object Node handle.\r | |
52 | */\r | |
53 | typedef void* AML_OBJECT_NODE_HANDLE;\r | |
54 | \r | |
55 | /** Data Node handle.\r | |
56 | */\r | |
57 | typedef void* AML_DATA_NODE_HANDLE;\r | |
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 | |
78 | EFI_STATUS\r | |
79 | EFIAPI\r | |
80 | AmlParseDefinitionBlock (\r | |
81 | IN CONST EFI_ACPI_DESCRIPTION_HEADER * DefinitionBlock,\r | |
82 | OUT AML_ROOT_NODE_HANDLE * RootPtr\r | |
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 | |
101 | EFI_STATUS\r | |
102 | EFIAPI\r | |
103 | AmlSerializeDefinitionBlock (\r | |
104 | IN AML_ROOT_NODE_HANDLE RootNode,\r | |
105 | OUT EFI_ACPI_DESCRIPTION_HEADER ** Table\r | |
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 | |
123 | EFI_STATUS\r | |
124 | EFIAPI\r | |
125 | AmlCloneTree (\r | |
126 | IN AML_NODE_HANDLE Node,\r | |
127 | OUT AML_NODE_HANDLE * ClonedNode\r | |
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 | |
142 | EFI_STATUS\r | |
143 | EFIAPI\r | |
144 | AmlDeleteTree (\r | |
145 | IN AML_NODE_HANDLE Node\r | |
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 | |
163 | EFI_STATUS\r | |
164 | EFIAPI\r | |
165 | AmlDetachNode (\r | |
166 | IN AML_NODE_HANDLE Node\r | |
167 | );\r | |
168 | \r | |
169 | /** Find a node in the AML namespace, given an ASL path and a reference Node.\r | |
170 | \r | |
171 | - The AslPath can be an absolute path, or a relative path from the\r | |
172 | reference Node;\r | |
173 | - Node must be a root node or a namespace node;\r | |
174 | - A root node is expected to be at the top of the tree.\r | |
175 | \r | |
176 | E.g.:\r | |
177 | For the following AML namespace, with the ReferenceNode being the node with\r | |
178 | the name "AAAA":\r | |
179 | - the node with the name "BBBB" can be found by looking for the ASL\r | |
180 | path "BBBB";\r | |
181 | - the root node can be found by looking for the ASL relative path "^",\r | |
182 | or the absolute path "\\".\r | |
183 | \r | |
184 | AML namespace:\r | |
185 | \\r | |
186 | \-AAAA <- ReferenceNode\r | |
187 | \-BBBB\r | |
188 | \r | |
189 | @ingroup NameSpaceApis\r | |
190 | \r | |
191 | @param [in] ReferenceNode Reference node.\r | |
192 | If a relative path is given, the\r | |
193 | search is done from this node. If\r | |
194 | an absolute path is given, the\r | |
195 | search is done from the root node.\r | |
196 | Must be a root node or an object\r | |
197 | node which is part of the\r | |
198 | namespace.\r | |
199 | @param [in] AslPath ASL path to the searched node in\r | |
200 | the namespace. An ASL path name is\r | |
201 | NULL terminated. Can be a relative\r | |
202 | or absolute path.\r | |
203 | E.g.: "\\_SB.CLU0.CPU0" or "^CPU0"\r | |
204 | @param [out] OutNode Pointer to the found node.\r | |
205 | Contains NULL if not found.\r | |
206 | \r | |
207 | @retval EFI_SUCCESS The function completed successfully.\r | |
208 | @retval EFI_BUFFER_TOO_SMALL No space left in the buffer.\r | |
209 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
210 | @retval EFI_OUT_OF_RESOURCES Out of memory.\r | |
211 | **/\r | |
212 | EFI_STATUS\r | |
213 | EFIAPI\r | |
214 | AmlFindNode (\r | |
215 | IN AML_NODE_HANDLE ReferenceNode,\r | |
216 | IN CHAR8 * AslPath,\r | |
217 | OUT AML_NODE_HANDLE * OutNode\r | |
218 | );\r | |
219 | \r | |
220 | /**\r | |
221 | @defgroup UserApis User APIs\r | |
222 | @{\r | |
223 | User APIs are implemented to ease most common actions that might be done\r | |
224 | using the AmlLib. They allow to find specific objects like "_UID" or\r | |
225 | "_CRS" and to update their value. It also shows what can be done using\r | |
226 | AmlLib functions.\r | |
227 | @}\r | |
228 | */\r | |
229 | \r | |
230 | /** Update the name of a DeviceOp object node.\r | |
231 | \r | |
232 | @ingroup UserApis\r | |
233 | \r | |
234 | @param [in] DeviceOpNode Object node representing a Device.\r | |
235 | Must have an OpCode=AML_NAME_OP, SubOpCode=0.\r | |
236 | OpCode/SubOpCode.\r | |
237 | DeviceOp object nodes are defined in ASL\r | |
238 | using the "Device ()" function.\r | |
239 | @param [in] NewNameString The new Device's name.\r | |
240 | Must be a NULL-terminated ASL NameString\r | |
241 | e.g.: "DEV0", "DV15.DEV0", etc.\r | |
242 | The input string is copied.\r | |
243 | \r | |
244 | @retval EFI_SUCCESS The function completed successfully.\r | |
245 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
246 | **/\r | |
247 | EFI_STATUS\r | |
248 | EFIAPI\r | |
249 | AmlDeviceOpUpdateName (\r | |
250 | IN AML_OBJECT_NODE_HANDLE DeviceOpNode,\r | |
251 | IN CHAR8 * NewNameString\r | |
252 | );\r | |
253 | \r | |
254 | /** Update an integer value defined by a NameOp object node.\r | |
255 | \r | |
256 | For compatibility reasons, the NameOpNode must initially\r | |
257 | contain an integer.\r | |
258 | \r | |
259 | @ingroup UserApis\r | |
260 | \r | |
261 | @param [in] NameOpNode NameOp object node.\r | |
262 | Must have an OpCode=AML_NAME_OP, SubOpCode=0.\r | |
263 | NameOp object nodes are defined in ASL\r | |
264 | using the "Name ()" function.\r | |
265 | @param [in] NewInt New Integer value to assign.\r | |
266 | Must be a UINT64.\r | |
267 | \r | |
268 | @retval EFI_SUCCESS The function completed successfully.\r | |
269 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
270 | **/\r | |
271 | EFI_STATUS\r | |
272 | EFIAPI\r | |
273 | AmlNameOpUpdateInteger (\r | |
274 | IN AML_OBJECT_NODE_HANDLE NameOpNode,\r | |
275 | IN UINT64 NewInt\r | |
276 | );\r | |
277 | \r | |
278 | /** Update a string value defined by a NameOp object node.\r | |
279 | \r | |
280 | The NameOpNode must initially contain a string.\r | |
281 | The EISAID ASL macro converts a string to an integer. This, it is\r | |
282 | not accepted.\r | |
283 | \r | |
284 | @ingroup UserApis\r | |
285 | \r | |
286 | @param [in] NameOpNode NameOp object node.\r | |
287 | Must have an OpCode=AML_NAME_OP, SubOpCode=0.\r | |
288 | NameOp object nodes are defined in ASL\r | |
289 | using the "Name ()" function.\r | |
290 | @param [in] NewName New NULL terminated string to assign to\r | |
291 | the NameOpNode.\r | |
292 | The input string is copied.\r | |
293 | \r | |
294 | @retval EFI_SUCCESS The function completed successfully.\r | |
295 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
296 | **/\r | |
297 | EFI_STATUS\r | |
298 | EFIAPI\r | |
299 | AmlNameOpUpdateString (\r | |
300 | IN AML_OBJECT_NODE_HANDLE NameOpNode,\r | |
301 | IN CONST CHAR8 * NewName\r | |
302 | );\r | |
303 | \r | |
691c5f77 | 304 | /** Get the first Resource Data element contained in a named object.\r |
c85ac524 PG |
305 | \r |
306 | In the following ASL code, the function will return the Resource Data\r | |
307 | node corresponding to the "QWordMemory ()" ASL macro.\r | |
308 | Name (_CRS, ResourceTemplate() {\r | |
309 | QWordMemory (...) {...},\r | |
310 | Interrupt (...) {...}\r | |
311 | }\r | |
312 | )\r | |
313 | \r | |
314 | Note:\r | |
691c5f77 PG |
315 | "_CRS" names defined as methods are not handled by this function.\r |
316 | They must be defined as names, using the "Name ()" statement.\r | |
c85ac524 PG |
317 | \r |
318 | @ingroup UserApis\r | |
319 | \r | |
691c5f77 PG |
320 | @param [in] NameOpNode NameOp object node defining a named object.\r |
321 | Must have an OpCode=AML_NAME_OP, SubOpCode=0.\r | |
322 | NameOp object nodes are defined in ASL\r | |
323 | using the "Name ()" function.\r | |
324 | @param [out] OutRdNode Pointer to the first Resource Data element of\r | |
325 | the named object. A Resource Data element\r | |
326 | is stored in a data node.\r | |
c85ac524 PG |
327 | \r |
328 | @retval EFI_SUCCESS The function completed successfully.\r | |
329 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
330 | **/\r | |
331 | EFI_STATUS\r | |
332 | EFIAPI\r | |
691c5f77 PG |
333 | AmlNameOpGetFirstRdNode (\r |
334 | IN AML_OBJECT_NODE_HANDLE NameOpNode,\r | |
c85ac524 PG |
335 | OUT AML_DATA_NODE_HANDLE * OutRdNode\r |
336 | );\r | |
337 | \r | |
338 | /** Get the Resource Data element following the CurrRdNode Resource Data.\r | |
339 | \r | |
340 | In the following ASL code, if CurrRdNode corresponds to the first\r | |
341 | "QWordMemory ()" ASL macro, the function will return the Resource Data\r | |
342 | node corresponding to the "Interrupt ()" ASL macro.\r | |
343 | Name (_CRS, ResourceTemplate() {\r | |
344 | QwordMemory (...) {...},\r | |
345 | Interrupt (...) {...}\r | |
346 | }\r | |
347 | )\r | |
348 | \r | |
691c5f77 PG |
349 | Note:\r |
350 | "_CRS" names defined as methods are not handled by this function.\r | |
351 | They must be defined as names, using the "Name ()" statement.\r | |
c85ac524 PG |
352 | \r |
353 | @ingroup UserApis\r | |
354 | \r | |
355 | @param [in] CurrRdNode Pointer to the current Resource Data element of\r | |
691c5f77 | 356 | the named object.\r |
c85ac524 PG |
357 | @param [out] OutRdNode Pointer to the Resource Data element following\r |
358 | the CurrRdNode.\r | |
359 | Contain a NULL pointer if CurrRdNode is the\r | |
360 | last Resource Data element in the list.\r | |
361 | The "End Tag" is not considered as a resource\r | |
362 | data element and is not returned.\r | |
363 | \r | |
364 | @retval EFI_SUCCESS The function completed successfully.\r | |
365 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
366 | **/\r | |
367 | EFI_STATUS\r | |
368 | EFIAPI\r | |
691c5f77 | 369 | AmlNameOpGetNextRdNode (\r |
c85ac524 PG |
370 | IN AML_DATA_NODE_HANDLE CurrRdNode,\r |
371 | OUT AML_DATA_NODE_HANDLE * OutRdNode\r | |
372 | );\r | |
373 | \r | |
374 | /** Update the first interrupt of an Interrupt resource data node.\r | |
375 | \r | |
376 | The flags of the Interrupt resource data are left unchanged.\r | |
377 | \r | |
378 | The InterruptRdNode corresponds to the Resource Data created by the\r | |
379 | "Interrupt ()" ASL macro. It is an Extended Interrupt Resource Data.\r | |
380 | See ACPI 6.3 specification, s6.4.3.6 "Extended Interrupt Descriptor"\r | |
381 | for more information about Extended Interrupt Resource Data.\r | |
382 | \r | |
383 | @ingroup UserApis\r | |
384 | \r | |
385 | @param [in] InterruptRdNode Pointer to the an extended interrupt\r | |
386 | resource data node.\r | |
387 | @param [in] Irq Interrupt value to update.\r | |
388 | \r | |
389 | @retval EFI_SUCCESS The function completed successfully.\r | |
390 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
391 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
392 | **/\r | |
393 | EFI_STATUS\r | |
394 | EFIAPI\r | |
395 | AmlUpdateRdInterrupt (\r | |
396 | IN AML_DATA_NODE_HANDLE InterruptRdNode,\r | |
397 | IN UINT32 Irq\r | |
398 | );\r | |
399 | \r | |
400 | /** Update the base address and length of a QWord resource data node.\r | |
401 | \r | |
402 | @ingroup UserApis\r | |
403 | \r | |
404 | @param [in] QWordRdNode Pointer a QWord resource data\r | |
405 | node.\r | |
406 | @param [in] BaseAddress Base address.\r | |
407 | @param [in] BaseAddressLength Base address length.\r | |
408 | \r | |
409 | @retval EFI_SUCCESS The function completed successfully.\r | |
410 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
411 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
412 | **/\r | |
413 | EFI_STATUS\r | |
414 | EFIAPI\r | |
415 | AmlUpdateRdQWord (\r | |
416 | IN AML_DATA_NODE_HANDLE QWordRdNode,\r | |
417 | IN UINT64 BaseAddress,\r | |
418 | IN UINT64 BaseAddressLength\r | |
419 | );\r | |
420 | \r | |
22873f58 | 421 | /** Code generation for the "Interrupt ()" ASL function.\r |
c85ac524 PG |
422 | \r |
423 | The Resource Data effectively created is an Extended Interrupt Resource\r | |
22873f58 PG |
424 | Data. Cf ACPI 6.4:\r |
425 | - s6.4.3.6 "Extended Interrupt Descriptor"\r | |
426 | - s19.6.64 "Interrupt (Interrupt Resource Descriptor Macro)"\r | |
c85ac524 | 427 | \r |
22873f58 PG |
428 | The created resource data node can be:\r |
429 | - appended to the list of resource data elements of the NameOpNode.\r | |
430 | In such case NameOpNode must be defined by a the "Name ()" ASL statement\r | |
431 | and initially contain a "ResourceTemplate ()".\r | |
432 | - returned through the NewRdNode parameter.\r | |
c85ac524 | 433 | \r |
691c5f77 | 434 | @ingroup CodeGenApis\r |
c85ac524 | 435 | \r |
c85ac524 PG |
436 | @param [in] ResourceConsumer The device consumes the specified interrupt\r |
437 | or produces it for use by a child device.\r | |
438 | @param [in] EdgeTriggered The interrupt is edge triggered or\r | |
439 | level triggered.\r | |
440 | @param [in] ActiveLow The interrupt is active-high or active-low.\r | |
441 | @param [in] Shared The interrupt can be shared with other\r | |
442 | devices or not (Exclusive).\r | |
443 | @param [in] IrqList Interrupt list. Must be non-NULL.\r | |
444 | @param [in] IrqCount Interrupt count. Must be non-zero.\r | |
22873f58 PG |
445 | @param [in] NameOpNode NameOp object node defining a named object.\r |
446 | If provided, append the new resource data node\r | |
447 | to the list of resource data elements of this\r | |
448 | node.\r | |
449 | @param [out] NewRdNode If provided and success,\r | |
450 | contain the created node.\r | |
c85ac524 PG |
451 | \r |
452 | @retval EFI_SUCCESS The function completed successfully.\r | |
453 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
454 | @retval EFI_OUT_OF_RESOURCES Could not allocate memory.\r | |
455 | **/\r | |
456 | EFI_STATUS\r | |
457 | EFIAPI\r | |
22873f58 | 458 | AmlCodeGenRdInterrupt (\r |
c85ac524 PG |
459 | IN BOOLEAN ResourceConsumer,\r |
460 | IN BOOLEAN EdgeTriggered,\r | |
461 | IN BOOLEAN ActiveLow,\r | |
462 | IN BOOLEAN Shared,\r | |
22873f58 PG |
463 | IN UINT32 *IrqList,\r |
464 | IN UINT8 IrqCount,\r | |
fe2d8189 | 465 | IN AML_OBJECT_NODE_HANDLE NameOpNode OPTIONAL,\r |
22873f58 | 466 | OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL\r |
c85ac524 PG |
467 | );\r |
468 | \r | |
469 | /** AML code generation for DefinitionBlock.\r | |
470 | \r | |
471 | Create a Root Node handle.\r | |
472 | It is the caller's responsibility to free the allocated memory\r | |
473 | with the AmlDeleteTree function.\r | |
474 | \r | |
475 | AmlCodeGenDefinitionBlock (TableSignature, OemId, TableID, OEMRevision) is\r | |
476 | equivalent to the following ASL code:\r | |
477 | DefinitionBlock (AMLFileName, TableSignature, ComplianceRevision,\r | |
478 | OemId, TableID, OEMRevision) {}\r | |
479 | with the ComplianceRevision set to 2 and the AMLFileName is ignored.\r | |
480 | \r | |
481 | @ingroup CodeGenApis\r | |
482 | \r | |
483 | @param[in] TableSignature 4-character ACPI signature.\r | |
484 | Must be 'DSDT' or 'SSDT'.\r | |
485 | @param[in] OemId 6-character string OEM identifier.\r | |
486 | @param[in] OemTableId 8-character string OEM table identifier.\r | |
487 | @param[in] OemRevision OEM revision number.\r | |
488 | @param[out] DefinitionBlockTerm The ASL Term handle representing a\r | |
489 | Definition Block.\r | |
490 | \r | |
491 | @retval EFI_SUCCESS Success.\r | |
492 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
493 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
494 | **/\r | |
495 | EFI_STATUS\r | |
496 | EFIAPI\r | |
497 | AmlCodeGenDefinitionBlock (\r | |
498 | IN CONST CHAR8 * TableSignature,\r | |
499 | IN CONST CHAR8 * OemId,\r | |
500 | IN CONST CHAR8 * OemTableId,\r | |
501 | IN UINT32 OemRevision,\r | |
502 | OUT AML_ROOT_NODE_HANDLE * NewRootNode\r | |
503 | );\r | |
504 | \r | |
505 | /** AML code generation for a Name object node, containing a String.\r | |
506 | \r | |
507 | AmlCodeGenNameString ("_HID", "HID0000", ParentNode, NewObjectNode) is\r | |
508 | equivalent of the following ASL code:\r | |
509 | Name(_HID, "HID0000")\r | |
510 | \r | |
511 | @ingroup CodeGenApis\r | |
512 | \r | |
513 | @param [in] NameString The new variable name.\r | |
514 | Must be a NULL-terminated ASL NameString\r | |
515 | e.g.: "DEV0", "DV15.DEV0", etc.\r | |
516 | The input string is copied.\r | |
517 | @param [in] String NULL terminated String to associate to the\r | |
518 | NameString.\r | |
519 | @param [in] ParentNode If provided, set ParentNode as the parent\r | |
520 | of the node created.\r | |
521 | @param [out] NewObjectNode If success, contains the created node.\r | |
522 | \r | |
523 | @retval EFI_SUCCESS Success.\r | |
524 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
525 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
526 | **/\r | |
527 | EFI_STATUS\r | |
528 | EFIAPI\r | |
529 | AmlCodeGenNameString (\r | |
530 | IN CONST CHAR8 * NameString,\r | |
531 | IN CHAR8 * String,\r | |
fe2d8189 | 532 | IN AML_NODE_HANDLE ParentNode OPTIONAL,\r |
c85ac524 PG |
533 | OUT AML_OBJECT_NODE_HANDLE * NewObjectNode OPTIONAL\r |
534 | );\r | |
535 | \r | |
536 | /** AML code generation for a Name object node, containing an Integer.\r | |
537 | \r | |
538 | AmlCodeGenNameInteger ("_UID", 1, ParentNode, NewObjectNode) is\r | |
539 | equivalent of the following ASL code:\r | |
540 | Name(_UID, One)\r | |
541 | \r | |
542 | @ingroup CodeGenApis\r | |
543 | \r | |
544 | @param [in] NameString The new variable name.\r | |
545 | Must be a NULL-terminated ASL NameString\r | |
546 | e.g.: "DEV0", "DV15.DEV0", etc.\r | |
547 | The input string is copied.\r | |
548 | @param [in] Integer Integer to associate to the NameString.\r | |
549 | @param [in] ParentNode If provided, set ParentNode as the parent\r | |
550 | of the node created.\r | |
551 | @param [out] NewObjectNode If success, contains the created node.\r | |
552 | \r | |
553 | @retval EFI_SUCCESS Success.\r | |
554 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
555 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
556 | **/\r | |
557 | EFI_STATUS\r | |
558 | EFIAPI\r | |
559 | AmlCodeGenNameInteger (\r | |
560 | IN CONST CHAR8 * NameString,\r | |
561 | IN UINT64 Integer,\r | |
fe2d8189 | 562 | IN AML_NODE_HANDLE ParentNode OPTIONAL,\r |
c85ac524 PG |
563 | OUT AML_OBJECT_NODE_HANDLE * NewObjectNode OPTIONAL\r |
564 | );\r | |
565 | \r | |
566 | /** AML code generation for a Device object node.\r | |
567 | \r | |
568 | AmlCodeGenDevice ("COM0", ParentNode, NewObjectNode) is\r | |
569 | equivalent of the following ASL code:\r | |
570 | Device(COM0) {}\r | |
571 | \r | |
572 | @ingroup CodeGenApis\r | |
573 | \r | |
574 | @param [in] NameString The new Device's name.\r | |
575 | Must be a NULL-terminated ASL NameString\r | |
576 | e.g.: "DEV0", "DV15.DEV0", etc.\r | |
577 | The input string is copied.\r | |
578 | @param [in] ParentNode If provided, set ParentNode as the parent\r | |
579 | of the node created.\r | |
580 | @param [out] NewObjectNode If success, contains the created node.\r | |
581 | \r | |
582 | @retval EFI_SUCCESS Success.\r | |
583 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
584 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
585 | **/\r | |
586 | EFI_STATUS\r | |
587 | EFIAPI\r | |
588 | AmlCodeGenDevice (\r | |
589 | IN CONST CHAR8 * NameString,\r | |
fe2d8189 | 590 | IN AML_NODE_HANDLE ParentNode OPTIONAL,\r |
c85ac524 PG |
591 | OUT AML_OBJECT_NODE_HANDLE * NewObjectNode OPTIONAL\r |
592 | );\r | |
593 | \r | |
594 | /** AML code generation for a Scope object node.\r | |
595 | \r | |
596 | AmlCodeGenScope ("_SB", ParentNode, NewObjectNode) is\r | |
597 | equivalent of the following ASL code:\r | |
598 | Scope(_SB) {}\r | |
599 | \r | |
600 | @ingroup CodeGenApis\r | |
601 | \r | |
602 | @param [in] NameString The new Scope's name.\r | |
603 | Must be a NULL-terminated ASL NameString\r | |
604 | e.g.: "DEV0", "DV15.DEV0", etc.\r | |
605 | The input string is copied.\r | |
606 | @param [in] ParentNode If provided, set ParentNode as the parent\r | |
607 | of the node created.\r | |
608 | @param [out] NewObjectNode If success, contains the created node.\r | |
609 | \r | |
610 | @retval EFI_SUCCESS Success.\r | |
611 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
612 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
613 | **/\r | |
614 | EFI_STATUS\r | |
615 | EFIAPI\r | |
616 | AmlCodeGenScope (\r | |
617 | IN CONST CHAR8 * NameString,\r | |
fe2d8189 | 618 | IN AML_NODE_HANDLE ParentNode OPTIONAL,\r |
c85ac524 PG |
619 | OUT AML_OBJECT_NODE_HANDLE * NewObjectNode OPTIONAL\r |
620 | );\r | |
621 | \r | |
3e958e93 PG |
622 | /** AML code generation for a method returning a NameString.\r |
623 | \r | |
624 | AmlCodeGenMethodRetNameString (\r | |
625 | "MET0", "_CRS", 1, TRUE, 3, ParentNode, NewObjectNode\r | |
626 | );\r | |
627 | is equivalent of the following ASL code:\r | |
628 | Method(MET0, 1, Serialized, 3) {\r | |
629 | Return (_CRS)\r | |
630 | }\r | |
631 | \r | |
632 | The ASL parameters "ReturnType" and "ParameterTypes" are not asked\r | |
633 | in this function. They are optional parameters in ASL.\r | |
634 | \r | |
635 | @ingroup CodeGenApis\r | |
636 | \r | |
637 | @param [in] MethodNameString The new Method's name.\r | |
638 | Must be a NULL-terminated ASL NameString\r | |
639 | e.g.: "MET0", "_SB.MET0", etc.\r | |
640 | The input string is copied.\r | |
641 | @param [in] ReturnedNameString The name of the object returned by the\r | |
642 | method. Optional parameter, can be:\r | |
643 | - NULL (ignored).\r | |
644 | - A NULL-terminated ASL NameString.\r | |
645 | e.g.: "MET0", "_SB.MET0", etc.\r | |
646 | The input string is copied.\r | |
647 | @param [in] NumArgs Number of arguments.\r | |
648 | Must be 0 <= NumArgs <= 6.\r | |
649 | @param [in] IsSerialized TRUE is equivalent to Serialized.\r | |
650 | FALSE is equivalent to NotSerialized.\r | |
651 | Default is NotSerialized in ASL spec.\r | |
652 | @param [in] SyncLevel Synchronization level for the method.\r | |
653 | Must be 0 <= SyncLevel <= 15.\r | |
654 | Default is 0 in ASL.\r | |
655 | @param [in] ParentNode If provided, set ParentNode as the parent\r | |
656 | of the node created.\r | |
657 | @param [out] NewObjectNode If success, contains the created node.\r | |
658 | \r | |
659 | @retval EFI_SUCCESS Success.\r | |
660 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
661 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
662 | **/\r | |
663 | EFI_STATUS\r | |
664 | EFIAPI\r | |
665 | AmlCodeGenMethodRetNameString (\r | |
666 | IN CONST CHAR8 * MethodNameString,\r | |
fe2d8189 | 667 | IN CONST CHAR8 * ReturnedNameString OPTIONAL,\r |
3e958e93 PG |
668 | IN UINT8 NumArgs,\r |
669 | IN BOOLEAN IsSerialized,\r | |
670 | IN UINT8 SyncLevel,\r | |
fe2d8189 | 671 | IN AML_NODE_HANDLE ParentNode OPTIONAL,\r |
3e958e93 PG |
672 | OUT AML_OBJECT_NODE_HANDLE * NewObjectNode OPTIONAL\r |
673 | );\r | |
674 | \r | |
018a962d PG |
675 | /** Create a _LPI name.\r |
676 | \r | |
677 | AmlCreateLpiNode ("_LPI", 0, 1, ParentNode, &LpiNode) is\r | |
678 | equivalent of the following ASL code:\r | |
679 | Name (_LPI, Package (\r | |
680 | 0, // Revision\r | |
681 | 1, // LevelId\r | |
682 | 0 // Count\r | |
683 | ))\r | |
684 | \r | |
685 | This function doesn't define any LPI state. As shown above, the count\r | |
686 | of _LPI state is set to 0.\r | |
687 | The AmlAddLpiState () function must be used to add LPI states.\r | |
688 | \r | |
689 | Cf ACPI 6.3 specification, s8.4.4 "Lower Power Idle States".\r | |
690 | \r | |
691 | @ingroup CodeGenApis\r | |
692 | \r | |
693 | @param [in] LpiNameString The new LPI 's object name.\r | |
694 | Must be a NULL-terminated ASL NameString\r | |
695 | e.g.: "_LPI", "DEV0.PLPI", etc.\r | |
696 | The input string is copied.\r | |
697 | @param [in] Revision Revision number of the _LPI states.\r | |
698 | @param [in] LevelId A platform defined number that identifies the\r | |
699 | level of hierarchy of the processor node to\r | |
700 | which the LPI states apply.\r | |
701 | @param [in] ParentNode If provided, set ParentNode as the parent\r | |
702 | of the node created.\r | |
703 | @param [out] NewLpiNode If success, contains the created node.\r | |
704 | \r | |
705 | @retval EFI_SUCCESS The function completed successfully.\r | |
706 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
707 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
708 | **/\r | |
709 | EFI_STATUS\r | |
710 | EFIAPI\r | |
711 | AmlCreateLpiNode (\r | |
712 | IN CONST CHAR8 * LpiNameString,\r | |
713 | IN UINT16 Revision,\r | |
714 | IN UINT64 LevelId,\r | |
fe2d8189 | 715 | IN AML_NODE_HANDLE ParentNode OPTIONAL,\r |
018a962d PG |
716 | OUT AML_OBJECT_NODE_HANDLE * NewLpiNode OPTIONAL\r |
717 | );\r | |
718 | \r | |
a5e36ad9 PG |
719 | /** Add an _LPI state to a LPI node created using AmlCreateLpiNode ().\r |
720 | \r | |
721 | AmlAddLpiState () increments the Count of LPI states in the LPI node by one,\r | |
722 | and adds the following package:\r | |
723 | Package() {\r | |
724 | MinResidency,\r | |
725 | WorstCaseWakeLatency,\r | |
726 | Flags,\r | |
727 | ArchFlags,\r | |
728 | ResCntFreq,\r | |
729 | EnableParentState,\r | |
730 | (GenericRegisterDescriptor != NULL) ? // Entry method. If a\r | |
731 | ResourceTemplate(GenericRegisterDescriptor) : // Register is given,\r | |
732 | Integer, // use it. Use the\r | |
733 | // Integer otherwise.\r | |
734 | ResourceTemplate() { // NULL Residency Counter\r | |
735 | Register (SystemMemory, 0, 0, 0, 0)\r | |
736 | },\r | |
737 | ResourceTemplate() { // NULL Usage Counter\r | |
738 | Register (SystemMemory, 0, 0, 0, 0)\r | |
739 | },\r | |
740 | "" // NULL State Name\r | |
741 | },\r | |
742 | \r | |
743 | Cf ACPI 6.3 specification, s8.4.4 "Lower Power Idle States".\r | |
744 | \r | |
745 | @ingroup CodeGenApis\r | |
746 | \r | |
747 | @param [in] MinResidency Minimum Residency.\r | |
748 | @param [in] WorstCaseWakeLatency Worst case wake-up latency.\r | |
749 | @param [in] Flags Flags.\r | |
750 | @param [in] ArchFlags Architectural flags.\r | |
751 | @param [in] ResCntFreq Residency Counter Frequency.\r | |
752 | @param [in] EnableParentState Enabled Parent State.\r | |
753 | @param [in] GenericRegisterDescriptor Entry Method.\r | |
754 | If not NULL, use this Register to\r | |
755 | describe the entry method address.\r | |
756 | @param [in] Integer Entry Method.\r | |
757 | If GenericRegisterDescriptor is NULL,\r | |
758 | take this value.\r | |
759 | @param [in] ResidencyCounterRegister If not NULL, use it to populate the\r | |
760 | residency counter register.\r | |
761 | @param [in] UsageCounterRegister If not NULL, use it to populate the\r | |
762 | usage counter register.\r | |
763 | @param [in] StateName If not NULL, use it to populate the\r | |
764 | state name.\r | |
765 | @param [in] LpiNode Lpi node created with the function\r | |
766 | AmlCreateLpiNode to which the new LPI\r | |
767 | state is appended.\r | |
768 | \r | |
769 | @retval EFI_SUCCESS The function completed successfully.\r | |
770 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
771 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
772 | **/\r | |
773 | EFI_STATUS\r | |
774 | EFIAPI\r | |
775 | AmlAddLpiState (\r | |
776 | IN UINT32 MinResidency,\r | |
777 | IN UINT32 WorstCaseWakeLatency,\r | |
778 | IN UINT32 Flags,\r | |
779 | IN UINT32 ArchFlags,\r | |
780 | IN UINT32 ResCntFreq,\r | |
781 | IN UINT32 EnableParentState,\r | |
fe2d8189 MK |
782 | IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE * GenericRegisterDescriptor OPTIONAL,\r |
783 | IN UINT64 Integer OPTIONAL,\r | |
784 | IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE * ResidencyCounterRegister OPTIONAL,\r | |
785 | IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE * UsageCounterRegister OPTIONAL,\r | |
786 | IN CHAR8 * StateName OPTIONAL,\r | |
a5e36ad9 PG |
787 | IN AML_OBJECT_NODE_HANDLE LpiNode\r |
788 | );\r | |
789 | \r | |
691c5f77 PG |
790 | // DEPRECATED APIS\r |
791 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r | |
792 | \r | |
793 | /** DEPRECATED API\r | |
794 | \r | |
795 | Get the first Resource Data element contained in a "_CRS" object.\r | |
796 | \r | |
797 | In the following ASL code, the function will return the Resource Data\r | |
798 | node corresponding to the "QWordMemory ()" ASL macro.\r | |
799 | Name (_CRS, ResourceTemplate() {\r | |
800 | QWordMemory (...) {...},\r | |
801 | Interrupt (...) {...}\r | |
802 | }\r | |
803 | )\r | |
804 | \r | |
805 | Note:\r | |
806 | - The "_CRS" object must be declared using ASL "Name (Declare Named Object)".\r | |
807 | - "_CRS" declared using ASL "Method (Declare Control Method)" is not\r | |
808 | supported.\r | |
809 | \r | |
810 | @ingroup UserApis\r | |
811 | \r | |
812 | @param [in] NameOpCrsNode NameOp object node defining a "_CRS" object.\r | |
813 | Must have an OpCode=AML_NAME_OP, SubOpCode=0.\r | |
814 | NameOp object nodes are defined in ASL\r | |
815 | using the "Name ()" function.\r | |
816 | @param [out] OutRdNode Pointer to the first Resource Data element of\r | |
817 | the "_CRS" object. A Resource Data element\r | |
818 | is stored in a data node.\r | |
819 | \r | |
820 | @retval EFI_SUCCESS The function completed successfully.\r | |
821 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
822 | **/\r | |
823 | EFI_STATUS\r | |
824 | EFIAPI\r | |
825 | AmlNameOpCrsGetFirstRdNode (\r | |
826 | IN AML_OBJECT_NODE_HANDLE NameOpCrsNode,\r | |
827 | OUT AML_DATA_NODE_HANDLE * OutRdNode\r | |
828 | );\r | |
829 | \r | |
830 | /** DEPRECATED API\r | |
831 | \r | |
832 | Get the Resource Data element following the CurrRdNode Resource Data.\r | |
833 | \r | |
834 | In the following ASL code, if CurrRdNode corresponds to the first\r | |
835 | "QWordMemory ()" ASL macro, the function will return the Resource Data\r | |
836 | node corresponding to the "Interrupt ()" ASL macro.\r | |
837 | Name (_CRS, ResourceTemplate() {\r | |
838 | QwordMemory (...) {...},\r | |
839 | Interrupt (...) {...}\r | |
840 | }\r | |
841 | )\r | |
842 | \r | |
843 | The CurrRdNode Resource Data node must be defined in an object named "_CRS"\r | |
844 | and defined by a "Name ()" ASL function.\r | |
845 | \r | |
846 | @ingroup UserApis\r | |
847 | \r | |
848 | @param [in] CurrRdNode Pointer to the current Resource Data element of\r | |
849 | the "_CRS" variable.\r | |
850 | @param [out] OutRdNode Pointer to the Resource Data element following\r | |
851 | the CurrRdNode.\r | |
852 | Contain a NULL pointer if CurrRdNode is the\r | |
853 | last Resource Data element in the list.\r | |
854 | The "End Tag" is not considered as a resource\r | |
855 | data element and is not returned.\r | |
856 | \r | |
857 | @retval EFI_SUCCESS The function completed successfully.\r | |
858 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
859 | **/\r | |
860 | EFI_STATUS\r | |
861 | EFIAPI\r | |
862 | AmlNameOpCrsGetNextRdNode (\r | |
863 | IN AML_DATA_NODE_HANDLE CurrRdNode,\r | |
864 | OUT AML_DATA_NODE_HANDLE * OutRdNode\r | |
865 | );\r | |
866 | \r | |
867 | /** DEPRECATED API\r | |
868 | \r | |
869 | Add an Interrupt Resource Data node.\r | |
870 | \r | |
871 | This function creates a Resource Data element corresponding to the\r | |
872 | "Interrupt ()" ASL function, stores it in an AML Data Node.\r | |
873 | \r | |
874 | It then adds it after the input CurrRdNode in the list of resource data\r | |
875 | element.\r | |
876 | \r | |
877 | The Resource Data effectively created is an Extended Interrupt Resource\r | |
878 | Data. See ACPI 6.3 specification, s6.4.3.6 "Extended Interrupt Descriptor"\r | |
879 | for more information about Extended Interrupt Resource Data.\r | |
880 | \r | |
881 | The Extended Interrupt contains one single interrupt.\r | |
882 | \r | |
883 | This function allocates memory to create a data node. It is the caller's\r | |
884 | responsibility to either:\r | |
885 | - attach this node to an AML tree;\r | |
886 | - delete this node.\r | |
887 | \r | |
888 | Note: The _CRS node must be defined using the ASL Name () function.\r | |
889 | e.g. Name (_CRS, ResourceTemplate () {\r | |
890 | ...\r | |
891 | }\r | |
892 | \r | |
893 | @ingroup CodeGenApis\r | |
894 | \r | |
895 | @param [in] NameOpCrsNode NameOp object node defining a "_CRS" object.\r | |
896 | Must have an OpCode=AML_NAME_OP, SubOpCode=0.\r | |
897 | NameOp object nodes are defined in ASL\r | |
898 | using the "Name ()" function.\r | |
899 | @param [in] ResourceConsumer The device consumes the specified interrupt\r | |
900 | or produces it for use by a child device.\r | |
901 | @param [in] EdgeTriggered The interrupt is edge triggered or\r | |
902 | level triggered.\r | |
903 | @param [in] ActiveLow The interrupt is active-high or active-low.\r | |
904 | @param [in] Shared The interrupt can be shared with other\r | |
905 | devices or not (Exclusive).\r | |
906 | @param [in] IrqList Interrupt list. Must be non-NULL.\r | |
907 | @param [in] IrqCount Interrupt count. Must be non-zero.\r | |
908 | \r | |
909 | \r | |
910 | @retval EFI_SUCCESS The function completed successfully.\r | |
911 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
912 | @retval EFI_OUT_OF_RESOURCES Could not allocate memory.\r | |
913 | **/\r | |
914 | EFI_STATUS\r | |
915 | EFIAPI\r | |
916 | AmlCodeGenCrsAddRdInterrupt (\r | |
917 | IN AML_OBJECT_NODE_HANDLE NameOpCrsNode,\r | |
918 | IN BOOLEAN ResourceConsumer,\r | |
919 | IN BOOLEAN EdgeTriggered,\r | |
920 | IN BOOLEAN ActiveLow,\r | |
921 | IN BOOLEAN Shared,\r | |
922 | IN UINT32 * IrqList,\r | |
923 | IN UINT8 IrqCount\r | |
924 | );\r | |
925 | \r | |
926 | #endif // DISABLE_NEW_DEPRECATED_INTERFACES\r | |
927 | \r | |
c85ac524 | 928 | #endif // AML_LIB_H_\r |