xref: /netbsd-src/sys/external/bsd/acpica/dist/compiler/aslhelpers.y (revision 046a29855e04359424fd074e8313af6b6be8cfb6)
1 NoEcho('
2 /******************************************************************************
3  *
4  * Module Name: aslhelpers.y - helper and option terms
5  *
6  *****************************************************************************/
7 
8 /*
9  * Copyright (C) 2000 - 2023, Intel Corp.
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions, and the following disclaimer,
17  *    without modification.
18  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19  *    substantially similar to the "NO WARRANTY" disclaimer below
20  *    ("Disclaimer") and any redistribution must be conditioned upon
21  *    including a substantially similar Disclaimer requirement for further
22  *    binary redistribution.
23  * 3. Neither the names of the above-listed copyright holders nor the names
24  *    of any contributors may be used to endorse or promote products derived
25  *    from this software without specific prior written permission.
26  *
27  * Alternatively, this software may be distributed under the terms of the
28  * GNU General Public License ("GPL") version 2 as published by the Free
29  * Software Foundation.
30  *
31  * NO WARRANTY
32  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
35  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42  * POSSIBILITY OF SUCH DAMAGES.
43  */
44 
45 ')
46 
47 
48 /*******************************************************************************
49  *
50  * ASL Helper Terms
51  *
52  ******************************************************************************/
53 
54 OptionalBusMasterKeyword
55     : ','                                   {$$ = TrCreateLeafOp (
56                                                 PARSEOP_BUSMASTERTYPE_MASTER);}
57     | ',' PARSEOP_BUSMASTERTYPE_MASTER      {$$ = TrCreateLeafOp (
58                                                 PARSEOP_BUSMASTERTYPE_MASTER);}
59     | ',' PARSEOP_BUSMASTERTYPE_NOTMASTER   {$$ = TrCreateLeafOp (
60                                                 PARSEOP_BUSMASTERTYPE_NOTMASTER);}
61     ;
62 
63 OptionalAccessAttribTerm
64     :                               {$$ = NULL;}
65     | ','                           {$$ = NULL;}
66     | ',' ByteConstExpr             {$$ = $2;}
67     | ',' AccessAttribKeyword       {$$ = $2;}
68     ;
69 
70 OptionalAccessSize
71     :                               {$$ = TrCreateValuedLeafOp (
72                                         PARSEOP_BYTECONST, 0);}
73     | ','                           {$$ = TrCreateValuedLeafOp (
74                                         PARSEOP_BYTECONST, 0);}
75     | ',' ByteConstExpr             {$$ = $2;}
76     ;
77 
78 OptionalAccessTypeKeyword   /* Default: AnyAcc */
79     :                               {$$ = TrCreateLeafOp (
80                                         PARSEOP_ACCESSTYPE_ANY);}
81     | ','                           {$$ = TrCreateLeafOp (
82                                         PARSEOP_ACCESSTYPE_ANY);}
83     | ',' AccessTypeKeyword         {$$ = $2;}
84     ;
85 
86 OptionalAddressingMode
87     : ','                           {$$ = NULL;}
88     | ',' AddressingModeKeyword     {$$ = $2;}
89     ;
90 
91 OptionalAddressRange
92     :                               {$$ = NULL;}
93     | ','                           {$$ = NULL;}
94     | ',' AddressKeyword            {$$ = $2;}
95     ;
96 
97 OptionalBitsPerByte
98     : ','                           {$$ = NULL;}
99     | ',' BitsPerByteKeyword        {$$ = $2;}
100     ;
101 
102 OptionalBuffer_Last
103     :                               {$$ = NULL;}
104     | ','                           {$$ = NULL;}
105     | ',' RawDataBufferTerm         {$$ = $2;}
106     ;
107 
108 OptionalByteConstExpr
109     :                               {$$ = NULL;}
110     | ','                           {$$ = NULL;}
111     | ',' ByteConstExpr             {$$ = $2;}
112     ;
113 
114 OptionalDecodeType
115     : ','                           {$$ = NULL;}
116     | ',' DecodeKeyword             {$$ = $2;}
117     ;
118 
119 OptionalDevicePolarity
120     : ','                           {$$ = NULL;}
121     | ',' DevicePolarityKeyword     {$$ = $2;}
122     ;
123 
124 OptionalDWordConstExpr
125     :                               {$$ = NULL;}
126     | ','                           {$$ = NULL;}
127     | ',' DWordConstExpr            {$$ = $2;}
128     ;
129 
130 OptionalEndian
131     : ','                           {$$ = NULL;}
132     | ',' EndianKeyword             {$$ = $2;}
133     ;
134 
135 OptionalFlowControl
136     : ','                           {$$ = NULL;}
137     | ',' FlowControlKeyword        {$$ = $2;}
138     ;
139 
140 OptionalIoRestriction
141     : ','                           {$$ = NULL;}
142     | ',' IoRestrictionKeyword      {$$ = $2;}
143     ;
144 
145 OptionalListString
146     :                               {$$ = TrCreateValuedLeafOp (
147                                         PARSEOP_STRING_LITERAL,
148                                         ACPI_TO_INTEGER (""));}   /* Placeholder is a NULL string */
149     | ','                           {$$ = TrCreateValuedLeafOp (
150                                         PARSEOP_STRING_LITERAL,
151                                         ACPI_TO_INTEGER (""));}   /* Placeholder is a NULL string */
152     | ',' TermArg                   {$$ = $2;}
153     ;
154 
155 OptionalLockRuleKeyword     /* Default: NoLock */
156     :                               {$$ = TrCreateLeafOp (
157                                         PARSEOP_LOCKRULE_NOLOCK);}
158     | ','                           {$$ = TrCreateLeafOp (
159                                         PARSEOP_LOCKRULE_NOLOCK);}
160     | ',' LockRuleKeyword           {$$ = $2;}
161     ;
162 
163 OptionalMaxType
164     : ','                           {$$ = NULL;}
165     | ',' MaxKeyword                {$$ = $2;}
166     ;
167 
168 OptionalMemType
169     : ','                           {$$ = NULL;}
170     | ',' MemTypeKeyword            {$$ = $2;}
171     ;
172 
173 OptionalMinType
174     : ','                           {$$ = NULL;}
175     | ',' MinKeyword                {$$ = $2;}
176     ;
177 
178 OptionalNameString
179     :                               {$$ = NULL;}
180     | ','                           {$$ = NULL;}
181     | ',' NameString                {$$ = $2;}
182     ;
183 
184 OptionalNameString_Last
185     :                               {$$ = NULL;}
186     | ','                           {$$ = NULL;}
187     | ',' NameString                {$$ = $2;}
188     ;
189 
190 OptionalNameString_First
191     :                               {$$ = TrCreateLeafOp (
192                                         PARSEOP_ZERO);}
193     | NameString                    {$$ = $1;}
194     ;
195 
196 OptionalObjectTypeKeyword
197     :                               {$$ = TrCreateLeafOp (
198                                         PARSEOP_OBJECTTYPE_UNK);}
199     | ',' ObjectTypeKeyword         {$$ = $2;}
200     ;
201 
202 OptionalParityType
203     : ','                           {$$ = NULL;}
204     | ',' ParityTypeKeyword         {$$ = $2;}
205     ;
206 
207 OptionalQWordConstExpr
208     :                               {$$ = NULL;}
209     | ','                           {$$ = NULL;}
210     | ',' QWordConstExpr            {$$ = $2;}
211     ;
212 
213 OptionalRangeType
214     : ','                           {$$ = NULL;}
215     | ',' RangeTypeKeyword          {$$ = $2;}
216     ;
217 
218 OptionalReadWriteKeyword
219     :                                   {$$ = TrCreateLeafOp (
220                                             PARSEOP_READWRITETYPE_BOTH);}
221     | PARSEOP_READWRITETYPE_BOTH        {$$ = TrCreateLeafOp (
222                                             PARSEOP_READWRITETYPE_BOTH);}
223     | PARSEOP_READWRITETYPE_READONLY    {$$ = TrCreateLeafOp (
224                                             PARSEOP_READWRITETYPE_READONLY);}
225     ;
226 
227 OptionalResourceType_First
228     :                               {$$ = TrCreateLeafOp (
229                                         PARSEOP_RESOURCETYPE_CONSUMER);}
230     | ResourceTypeKeyword           {$$ = $1;}
231     ;
232 
233 OptionalResourceType
234     :                               {$$ = TrCreateLeafOp (
235                                         PARSEOP_RESOURCETYPE_CONSUMER);}
236     | ','                           {$$ = TrCreateLeafOp (
237                                         PARSEOP_RESOURCETYPE_CONSUMER);}
238     | ',' ResourceTypeKeyword       {$$ = $2;}
239     ;
240 
241 /* Same as above except default is producer */
242 OptionalProducerResourceType
243     :                               {$$ = TrCreateLeafOp (
244                                         PARSEOP_RESOURCETYPE_PRODUCER);}
245     | ','                           {$$ = TrCreateLeafOp (
246                                         PARSEOP_RESOURCETYPE_PRODUCER);}
247     | ',' ResourceTypeKeyword       {$$ = $2;}
248     ;
249 
250 OptionalSlaveMode
251     : ','                           {$$ = NULL;}
252     | ',' SlaveModeKeyword          {$$ = $2;}
253     ;
254 
255 OptionalSlaveMode_First
256     :                               {$$ = NULL;}
257     | SlaveModeKeyword              {$$ = $1;}
258     ;
259 
260 OptionalShareType
261     :                               {$$ = NULL;}
262     | ','                           {$$ = NULL;}
263     | ',' ShareTypeKeyword          {$$ = $2;}
264     ;
265 
266 OptionalShareType_First
267     :                               {$$ = NULL;}
268     | ShareTypeKeyword              {$$ = $1;}
269     ;
270 
271 OptionalStopBits
272     : ','                           {$$ = NULL;}
273     | ',' StopBitsKeyword           {$$ = $2;}
274     ;
275 
276 OptionalStringData
277     :                               {$$ = NULL;}
278     | ','                           {$$ = NULL;}
279     | ',' StringData                {$$ = $2;}
280     ;
281 
282 OptionalSyncLevel           /* Default: 0 */
283     :                               {$$ = TrCreateValuedLeafOp (
284                                         PARSEOP_BYTECONST, 0);}
285     | ','                           {$$ = TrCreateValuedLeafOp (
286                                         PARSEOP_BYTECONST, 0);}
287     | ',' ByteConstExpr             {$$ = $2;}
288     ;
289 
290 OptionalTranslationType_Last
291     :                               {$$ = NULL;}
292     | ','                           {$$ = NULL;}
293     | ',' TranslationKeyword        {$$ = $2;}
294     ;
295 
296 OptionalType
297     :                               {$$ = NULL;}
298     | ','                           {$$ = NULL;}
299     | ',' TypeKeyword               {$$ = $2;}
300     ;
301 
302 OptionalType_Last
303     :                               {$$ = NULL;}
304     | ','                           {$$ = NULL;}
305     | ',' TypeKeyword               {$$ = $2;}
306     ;
307 
308 OptionalUpdateRuleKeyword   /* Default: Preserve */
309     :                               {$$ = TrCreateLeafOp (
310                                         PARSEOP_UPDATERULE_PRESERVE);}
311     | ','                           {$$ = TrCreateLeafOp (
312                                         PARSEOP_UPDATERULE_PRESERVE);}
313     | ',' UpdateRuleKeyword         {$$ = $2;}
314     ;
315 
316 OptionalWireMode
317     : ','                           {$$ = NULL;}
318     | ',' WireModeKeyword           {$$ = $2;}
319     ;
320 
321 OptionalWordConstExpr
322     : ','                           {$$ = NULL;}
323     | ',' WordConstExpr             {$$ = $2;}
324     ;
325 
326 OptionalXferSize
327     :                               {$$ = TrCreateValuedLeafOp (
328                                         PARSEOP_XFERSIZE_32, 2);}
329     | ','                           {$$ = TrCreateValuedLeafOp (
330                                         PARSEOP_XFERSIZE_32, 2);}
331     | ',' XferSizeKeyword           {$$ = $2;}
332     ;
333