1 /******************************************************************************
2  *
3  * Module Name: ahgrammar - AML grammar items
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights. You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25  * make derivatives, distribute, use and display any portion of the Covered
26  * Code in any form, with the right to sublicense such rights; and
27  *
28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29  * license (with the right to sublicense), under only those claims of Intel
30  * patents that are infringed by the Original Intel Code, to make, use, sell,
31  * offer to sell, and import the Covered Code and derivative works thereof
32  * solely to the minimum extent necessary to exercise the above copyright
33  * license, and in no event shall the patent license extend to any additions
34  * to or modifications of the Original Intel Code. No other license or right
35  * is granted directly or by implication, estoppel or otherwise;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43  * Redistribution of source code of any substantial portion of the Covered
44  * Code or modification with rights to further distribute source must include
45  * the above Copyright Notice, the above License, this list of Conditions,
46  * and the following Disclaimer and Export Compliance provision. In addition,
47  * Licensee must cause all Covered Code to which Licensee contributes to
48  * contain a file documenting the changes Licensee made to create that Covered
49  * Code and the date of any change. Licensee must include in that file the
50  * documentation of any changes made by any predecessor Licensee. Licensee
51  * must include a prominent statement that the modification is derived,
52  * directly or indirectly, from Original Intel Code.
53  *
54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55  * Redistribution of source code of any substantial portion of the Covered
56  * Code or modification without rights to further distribute source must
57  * include the following Disclaimer and Export Compliance provision in the
58  * documentation and/or other materials provided with distribution. In
59  * addition, Licensee may not authorize further sublicense of source of any
60  * portion of the Covered Code, and must include terms to the effect that the
61  * license from Licensee to its licensee is limited to the intellectual
62  * property embodied in the software Licensee provides to its licensee, and
63  * not to intellectual property embodied in modifications its licensee may
64  * make.
65  *
66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67  * substantial portion of the Covered Code or modification must reproduce the
68  * above Copyright Notice, and the following Disclaimer and Export Compliance
69  * provision in the documentation and/or other materials provided with the
70  * distribution.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76  * Intel shall be used in advertising or otherwise to promote the sale, use or
77  * other dealings in products derived from or relating to the Covered Code
78  * without prior written authorization from Intel.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88  * PARTICULAR PURPOSE.
89  *
90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97  * LIMITED REMEDY.
98  *
99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100  * software or system incorporating such software without first obtaining any
101  * required license or other approval from the U. S. Department of Commerce or
102  * any other agency or department of the United States Government. In the
103  * event Licensee exports any such software from the United States or
104  * re-exports any such software from a foreign destination, Licensee shall
105  * ensure that the distribution and export/re-export of the software is in
106  * compliance with all laws, regulations, orders, or other restrictions of the
107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108  * any of its subsidiaries will export/re-export any technical data, process,
109  * software, or service, directly or indirectly, to any country for which the
110  * United States government or any agency thereof requires an export license,
111  * other governmental approval, or letter of assurance, without first obtaining
112  * such license, approval or letter.
113  *
114  *****************************************************************************
115  *
116  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
122  * 1. Redistributions of source code must retain the above copyright
123  *    notice, this list of conditions, and the following disclaimer,
124  *    without modification.
125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126  *    substantially similar to the "NO WARRANTY" disclaimer below
127  *    ("Disclaimer") and any redistribution must be conditioned upon
128  *    including a substantially similar Disclaimer requirement for further
129  *    binary redistribution.
130  * 3. Neither the names of the above-listed copyright holders nor the names
131  *    of any contributors may be used to endorse or promote products derived
132  *    from this software without specific prior written permission.
133  *
134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145  *
146  * Alternatively, you may choose to be licensed under the terms of the
147  * GNU General Public License ("GPL") version 2 as published by the Free
148  * Software Foundation.
149  *
150  *****************************************************************************/
151 
152 #include "acpihelp.h"
153 
154 const AH_AML_TYPE           Gbl_AmlTypesInfo[] =
155 {
156     {"ComputationalData",
157         "ComputationalData :=\n"
158         "ByteConst | WordConst | DWordConst | QWordConst |\n"
159         "String | ConstObj | RevisionOp | DefBuffer\n\n"
160         "DataObject := ComputationalData | DefPackage | DefVarPackage\n"
161         "DataRefObject := DataObject | ObjectReference | DDBHandle\n\n"
162 
163         "ByteConst := BytePrefix ByteData\n"
164         "BytePrefix := 0x0A\n"
165         "ByteList := Nothing | <ByteData ByteList>\n"
166         "ByteData := 0x00 - 0xFF\n\n"
167 
168         "WordConst := WordPrefix WordData\n"
169         "WordPrefix := 0x0B\n"
170         "WordData := 0x0000-0xFFFF\n\n"
171 
172         "DWordConst := DWordPrefix DWordData\n"
173         "DWordPrefix := 0x0C\n"
174         "DWordData := 0x00000000-0xFFFFFFFF\n\n"
175 
176         "QWordConst := QWordPrefix QWordData\n"
177         "QWordPrefix := 0x0E\n"
178         "QWordData := 0x0000000000000000-0xFFFFFFFFFFFFFFFF\n\n"
179 
180         "String := StringPrefix AsciiCharList NullChar\n"
181         "StringPrefix := 0x0D\n"
182         "AsciiCharList := Nothing | <AsciiChar AsciiCharList>\n"
183         "AsciiChar := 0x01 - 0x7F\n"
184         "NullChar := 0x00\n\n"
185 
186         "ConstObj := ZeroOp | OneOp | OnesOp\n\n"},
187 
188     {"DefinitionBlock",
189         "DefinitionBlockHeader :=\n"
190         "TableSignature TableLength SpecCompliance Checksum\n"
191         "OemID OemTableID OemRevision CreatorID CreatorRevision\n\n"
192 
193         "TableSignature := AsciiChar AsciiChar AsciiChar AsciiChar\n"
194         "TableLength := DWordData\n"
195         "// Length of the table in bytes including\n"
196         "// the block header.\n\n"
197 
198         "SpecCompliance := ByteData\n"
199         "// The revision of the structure\n\n"
200 
201         "CheckSum := ByteData\n"
202         "// Byte checksum of the entire table\n\n"
203 
204         "OemID := ByteData(6)\n"
205         "// OEM ID of up to 6 characters. If the OEM\n"
206         "// ID is shorter than 6 characters, it\n"
207         "// can be terminated with a NULL\n"
208         "// character.\n\n"
209 
210         "OemTableID := ByteData(8)\n"
211         "// OEM Table ID of up to 8 characters. If\n"
212         "// the OEM Table ID is shorter than 8\n"
213         "// characters, it can be terminated with\n"
214         "// a NULL character.\n"
215         "OemRevision := DWordData\n"
216         "// OEM Table Revision\n\n"
217         "CreatorID := DWordData\n"
218         "// Vendor ID of the ASL compiler\n"
219         "CreatorRevision := DWordData\n"
220         "// Revision of the ASL compiler\n"},
221 
222     {"FieldFlags",
223         "FieldFlags := ByteData\n"
224         "// bits 0-3: AccessType\n"
225         "//     0 AnyAcc\n"
226         "//     1 ByteAcc\n"
227         "//     2 WordAcc\n"
228         "//     3 DWordAcc\n"
229         "//     4 QWordAcc\n"
230         "//     5 BufferAcc\n"
231         "//     6 Reserved\n"
232         "//     7 Reserved\n"
233         "// bit 4: LockRule\n"
234         "//     0 NoLock\n"
235         "//     1 Lock\n"
236         "// bits 5-6: UpdateRule\n"
237         "//     0 Preserve\n"
238         "//     1 WriteAsOnes\n"
239         "//     2 WriteAsZeros\n"
240         "// bit 7:\n"
241         "//     0 Reserved (must be 0)\n"},
242 
243     {"FieldList",
244         "FieldList := Nothing | <FieldElement FieldList>\n\n"
245         "FieldElement := NamedField | ReservedField | AccessField |\n"
246         "    ExtendedAccessField | ConnectField\n\n"
247         "NamedField := NameSeg PkgLength\n"
248         "ReservedField := 0x00 PkgLength\n\n"
249 
250         "AccessField := 0x01 AccessType\n"
251         "AccessField := 0x01 AccessType AccessAttrib\n\n"
252 
253         "AccessType := ByteData\n"
254         "// Bits 0:3 - Same as AccessType bits of FieldFlags.\n"
255         "// Bits 4:5 - Reserved\n"
256         "// Bits 7:6 - 0 = AccessAttribute\n"
257         "//     Normal Access Attributes\n"
258         "//     1 = AttribBytes (x)\n"
259         "//     2 = AttribRawBytes (x)\n"
260         "//     3 = AttribRawProcessBytes (x)\n"
261         "//     Note: 'x' is encoded as bits 0:7 of the AccessAttrib byte.\n\n"
262 
263         "AccessAttrib := ByteData\n"
264         "// bits 0:7: Byte length\n"
265         "//\n"
266         "// If AccessType is BufferAcc for the SMB or\n"
267         "// GPIO OpRegions, AccessAttrib can be one of\n"
268         "// the following values:\n"
269         "// 0x02 AttribQuick\n"
270         "// 0x04 AttribSendReceive\n"
271         "// 0x06 AttribByte\n"
272         "// 0x08 AttribWord\n"
273         "// 0x0A AttribBlock\n"
274         "// 0x0C AttribProcessCall\n"
275         "// 0x0D AttribBlockProcessCall\n\n"
276 
277         "ExtendedAccessField := 0x03 AccessType ExtendedAccessAttrib AccessLength\n"
278         "ExtendedAccessAttrib := ByteData\n"
279         "// 0x0B AttribBytes\n"
280         "// 0x0E AttribRawBytes\n"
281         "// 0x0F AttribRawProcess\n\n"
282 
283         "ConnectField := 0x02 NameString> | <0x02 BufferData\n"},
284 
285     {"MatchOpcode",
286         "DefMatch := MatchOp SearchPkg MatchOpcode Operand MatchOpcode Operand StartIndex\n"
287         "MatchOp := 0x89\n"
288         "SearchPkg := TermArg => Package\n"
289         "MatchOpcode := ByteData\n"
290         "// 0 MTR\n"
291         "// 1 MEQ\n"
292         "// 2 MLE\n"
293         "// 3 MLT\n"
294         "// 4 MGE\n"
295         "// 5 MGT\n"},
296 
297    {"MethodFlags",
298         "DefMethod := MethodOp PkgLength NameString MethodFlags TermList\n"
299         "MethodOp := 0x14\n"
300         "MethodFlags := ByteData\n"
301         "// bit 0-2: ArgCount (0-7)\n"
302         "// bit 3: SerializeFlag\n"
303         "//   0 NotSerialized\n"
304         "//   1 Serialized\n"
305         "// bit 4-7: SyncLevel (0x00-0x0f)\n"},
306 
307     {"Miscellaneous",
308         "ZeroOp := 0x00\n"
309         "OneOp := 0x01\n"
310         "OnesOp := 0xFF\n"
311         "RevisionOp := ExtOpPrefix 0x30\n"
312         "ExtOpPrefix := 0x5B\n"},
313 
314     {"NameSeg",
315         "NameSeg := <LeadNameChar NameChar NameChar NameChar>\n"
316         "// Note: NameSegs shorter than 4 characters are filled with\n"
317         "// trailing underscores.\n\n"
318         "NameChar := DigitChar | LeadNameChar\n"
319         "LeadNameChar := 'A'-'Z' | '_' (0x41 - 0x5A) | (0x5F)\n"
320         "DigitChar := '0'-'9' (0x30 - 0x39)\n"},
321 
322     {"NameString",
323         "NameString := <RootChar NamePath> | <PrefixPath NamePath>\n"
324         "PrefixPath := Nothing | <ParentPrefixChar PrefixPath>\n"
325         "RootChar := '\\' (0x5C)\n"
326         "ParentPrefixChar := '^' (0x5E)\n"},
327 
328     {"NamePath",
329         "NamePath := NameSeg | DualNamePath | MultiNamePath | NullName\n"
330         "DualNamePath := DualNamePrefix NameSeg NameSeg\n"
331         "DualNamePrefix := 0x2E\n"
332         "MultiNamePath := MultiNamePrefix SegCount NameSeg(SegCount)\n"
333         "MultiNamePrefix := 0x2F\n"
334         "SegCount := ByteData\n"
335         "// Note: SegCount can be from 1 to 255. For example: MultiNamePrefix(35)\n"
336         "// is encoded as 0x2f 0x23 and followed by 35 NameSegs. So, the total\n"
337         "// encoding length will be 1 + 1 + (35 * 4) = 142. Notice that:\n"
338         "// DualNamePrefix NameSeg NameSeg has a smaller encoding than the\n"
339         "// encoding of: MultiNamePrefix(2) NameSeg NameSeg\n\n"
340 
341         "SimpleName := NameString | ArgObj | LocalObj\n"
342         "SuperName := SimpleName | DebugObj | Type6Opcode\n"
343         "NullName := 0x00\n"
344         "Target := SuperName | NullName\n"},
345 
346     {"PkgLength",
347         "PkgLength := PkgLeadByte |\n"
348         "<PkgLeadByte ByteData> |\n"
349         "<PkgLeadByte ByteData ByteData> |\n"
350         "<PkgLeadByte ByteData ByteData ByteData>\n\n"
351 
352         "PkgLeadByte :=\n"
353         "bit 7-6: Count of ByteData that follows (0-3)\n"
354         "bit 5-4: Only used if (PkgLength < 63)\n"
355         "bit 3-0: Least significant package length nybble\n"
356         "// Note: The high 2 bits of the first byte reveal how many follow bytes\n"
357         "// are in the PkgLength. If the PkgLength has only one byte, bit 0 through 5\n"
358         "// are used to encode the package length (in other words, values 0-63). If\n"
359         "// the package length value is more than 63, more than one byte must be\n"
360         "// used for the encoding in which case bit 4 and 5 of the PkgLeadByte are\n"
361         "// reserved and must be zero. If the multiple bytes encoding is used, bits\n"
362         "// 0-3 of the PkgLeadByte become the least significant 4 bits of the\n"
363         "// resulting package length value. The next ByteData will become the next\n"
364         "// least significant 8 bits of the resulting value and so on, up to 3\n"
365         "// ByteData bytes. Thus, the maximum package length is 2**28.\n"},
366 
367     {"RegionSpace",
368         "RegionSpace := ByteData\n"
369         "// 0x00 SystemMemory\n"
370         "// 0x01 SystemIO\n"
371         "// 0x02 PCI_Config\n"
372         "// 0x03 EmbeddedControl\n"
373         "// 0x04 SMBus\n"
374         "// 0x05 SystemCMOS\n"
375         "// 0x06 PciBarTarget\n"
376         "// 0x07 IPMI\n"
377         "// 0x08 GeneralPurposeIO\n"
378         "// 0x09 GenericSerialBus\n"
379         "// 0x0A Platform Communications Channel\n"
380         "// 0x0B-0x7E: Reserved\n"
381         "// 0x7F: Functional Fixed Hardware\n"
382         "// 0x80-0xBF: Reserved\n"
383         "// 0xC0-0xFF: OEM Defined\n"},
384 
385     {"TermObj",
386         "TermObj := NameSpaceModifierObj | NamedObj | Type1Opcode | Type2Opcode\n"
387         "TermList := Nothing | <TermObj TermList>\n\n"
388 
389         "MethodInvocation := NameString TermArgList\n"
390         "TermArgList := Nothing | <TermArg TermArgList>\n"
391         "TermArg := Type2Opcode | DataObject | ArgObj | LocalObj\n\n"
392 
393         "ObjectList := Nothing | <Object ObjectList>\n"
394         "Object := NameSpaceModifierObj | NamedObj\n"},
395 
396     {NULL, NULL}
397 };
398