xref: /illumos-gate/usr/src/cmd/acpi/iasl/aslpld.c (revision 66582b606a8194f7f3ba5b3a3a6dca5b0d346361)
1 /******************************************************************************
2  *
3  * Module Name: aslpld - Implementation of ASL ToPLD macro
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2018, 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 "aslcompiler.h"
153 #include "aslcompiler.y.h"
154 #include "amlcode.h"
155 
156 #define _COMPONENT          ACPI_COMPILER
157         ACPI_MODULE_NAME    ("aslpld")
158 
159 
160 /* Local prototypes */
161 
162 static UINT8 *
163 OpcEncodePldBuffer (
164     ACPI_PLD_INFO           *PldInfo);
165 
166 static BOOLEAN
167 OpcFindName (
168     const char              **List,
169     char                    *Name,
170     UINT32                  *Index);
171 
172 
173 /*******************************************************************************
174  *
175  * FUNCTION:    OpcDoPld
176  *
177  * PARAMETERS:  Op                  - Current parse node
178  *
179  * RETURN:      None
180  *
181  * DESCRIPTION: Convert ToPLD macro to 20-byte buffer
182  *
183  * The ToPLD parse tree looks like this:
184  *
185  *      TOPLD
186  *          PLD_REVISION
187  *              INTEGER
188  *          PLD_IGNORECOLOR
189  *              INTEGER
190  *          ...
191  *          etc.
192  *
193  ******************************************************************************/
194 
195 void
196 OpcDoPld (
197     ACPI_PARSE_OBJECT       *Op)
198 {
199     ACPI_PLD_INFO           PldInfo;
200     UINT8                   *Buffer;
201     ACPI_PARSE_OBJECT       *ThisOp;
202     ACPI_PARSE_OBJECT       *NewOp;
203     UINT16                  ParseOpcode;
204     UINT32                  Value;
205 
206 
207     if (!Op)
208     {
209         AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, NULL);
210         return;
211     }
212 
213     if (Op->Asl.ParseOpcode != PARSEOP_TOPLD)
214     {
215         AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, Op, NULL);
216         return;
217     }
218 
219     memset (&PldInfo, 0, sizeof (ACPI_PLD_INFO));
220 
221     /* Traverse the list of PLD Ops (one per PLD field) */
222 
223     ThisOp = Op->Asl.Child;
224     while (ThisOp)
225     {
226         /* Get child values */
227 
228         ParseOpcode = ThisOp->Asl.Child->Asl.ParseOpcode;
229         Value = (UINT32) ThisOp->Asl.Child->Asl.Value.Integer;
230 
231         switch (ThisOp->Asl.ParseOpcode)
232         {
233         case PARSEOP_PLD_REVISION:
234 
235             if (ParseOpcode != PARSEOP_INTEGER)
236             {
237                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
238                 break;
239             }
240 
241             if (Value > 127)
242             {
243                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
244                 break;
245             }
246 
247             PldInfo.Revision = (UINT8) Value;
248             break;
249 
250         case PARSEOP_PLD_IGNORECOLOR:
251 
252             if (ParseOpcode != PARSEOP_INTEGER)
253             {
254                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
255                 break;
256             }
257 
258             if (Value > 1)
259             {
260                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
261                 break;
262             }
263 
264             PldInfo.IgnoreColor = (UINT8) Value;
265             break;
266 
267         case PARSEOP_PLD_RED:
268         case PARSEOP_PLD_GREEN:
269         case PARSEOP_PLD_BLUE:
270 
271             if (ParseOpcode != PARSEOP_INTEGER)
272             {
273                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
274                 break;
275             }
276 
277             if (Value > 255)
278             {
279                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
280                 break;
281             }
282 
283             if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_RED)
284             {
285                 PldInfo.Red = (UINT8) Value;
286             }
287             else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_GREEN)
288             {
289                 PldInfo.Green = (UINT8) Value;
290             }
291             else /* PARSEOP_PLD_BLUE */
292             {
293                 PldInfo.Blue = (UINT8) Value;
294             }
295             break;
296 
297         case PARSEOP_PLD_WIDTH:
298         case PARSEOP_PLD_HEIGHT:
299 
300             if (ParseOpcode != PARSEOP_INTEGER)
301             {
302                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
303                 break;
304             }
305 
306             if (Value > 65535)
307             {
308                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
309                 break;
310             }
311 
312             if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_WIDTH)
313             {
314                 PldInfo.Width = (UINT16) Value;
315             }
316             else /* PARSEOP_PLD_HEIGHT */
317             {
318                 PldInfo.Height = (UINT16) Value;
319             }
320 
321             break;
322 
323         case PARSEOP_PLD_USERVISIBLE:
324         case PARSEOP_PLD_DOCK:
325         case PARSEOP_PLD_LID:
326 
327             if (ParseOpcode != PARSEOP_INTEGER)
328             {
329                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
330                 break;
331             }
332 
333             if (Value > 1)
334             {
335                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
336                 break;
337             }
338 
339             if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_USERVISIBLE)
340             {
341                 PldInfo.UserVisible = (UINT8) Value;
342             }
343             else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_DOCK)
344             {
345                 PldInfo.Dock = (UINT8) Value;
346             }
347             else
348             {
349                 PldInfo.Lid = (UINT8) Value;
350             }
351 
352             break;
353 
354         case PARSEOP_PLD_PANEL:
355 
356             if (ParseOpcode == PARSEOP_INTEGER)
357             {
358                 if (Value > 6)
359                 {
360                     AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
361                     break;
362                 }
363             }
364             else /* PARSEOP_STRING */
365             {
366                 if (!OpcFindName (AcpiGbl_PldPanelList,
367                     ThisOp->Asl.Child->Asl.Value.String,
368                     &Value))
369                 {
370                     AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL);
371                     break;
372                 }
373             }
374 
375             PldInfo.Panel = (UINT8) Value;
376             break;
377 
378         case PARSEOP_PLD_VERTICALPOSITION:
379 
380             if (ParseOpcode == PARSEOP_INTEGER)
381             {
382                 if (Value > 2)
383                 {
384                     AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
385                     break;
386                 }
387             }
388             else /* PARSEOP_STRING */
389             {
390                 if (!OpcFindName (AcpiGbl_PldVerticalPositionList,
391                     ThisOp->Asl.Child->Asl.Value.String,
392                     &Value))
393                 {
394                     AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL);
395                     break;
396                 }
397             }
398 
399             PldInfo.VerticalPosition = (UINT8) Value;
400             break;
401 
402         case PARSEOP_PLD_HORIZONTALPOSITION:
403 
404             if (ParseOpcode == PARSEOP_INTEGER)
405             {
406                 if (Value > 2)
407                 {
408                     AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
409                     break;
410                 }
411             }
412             else /* PARSEOP_STRING */
413             {
414                 if (!OpcFindName (AcpiGbl_PldHorizontalPositionList,
415                     ThisOp->Asl.Child->Asl.Value.String,
416                     &Value))
417                 {
418                     AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL);
419                     break;
420                 }
421             }
422 
423             PldInfo.HorizontalPosition = (UINT8) Value;
424             break;
425 
426         case PARSEOP_PLD_SHAPE:
427 
428             if (ParseOpcode == PARSEOP_INTEGER)
429             {
430                 if (Value > 8)
431                 {
432                     AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
433                     break;
434                 }
435             }
436             else /* PARSEOP_STRING */
437             {
438                 if (!OpcFindName (AcpiGbl_PldShapeList,
439                     ThisOp->Asl.Child->Asl.Value.String,
440                     &Value))
441                 {
442                     AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL);
443                     break;
444                 }
445             }
446 
447             PldInfo.Shape = (UINT8) Value;
448             break;
449 
450         case PARSEOP_PLD_GROUPORIENTATION:
451 
452             if (ParseOpcode != PARSEOP_INTEGER)
453             {
454                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
455                 break;
456             }
457 
458             if (Value > 1)
459             {
460                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
461                 break;
462             }
463 
464             PldInfo.GroupOrientation = (UINT8) Value;
465             break;
466 
467         case PARSEOP_PLD_GROUPTOKEN:
468         case PARSEOP_PLD_GROUPPOSITION:
469 
470             if (ParseOpcode != PARSEOP_INTEGER)
471             {
472                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
473                 break;
474             }
475 
476             if (Value > 255)
477             {
478                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
479                 break;
480             }
481 
482             if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_GROUPTOKEN)
483             {
484                 PldInfo.GroupToken = (UINT8) Value;
485             }
486             else /* PARSEOP_PLD_GROUPPOSITION */
487             {
488                 PldInfo.GroupPosition = (UINT8) Value;
489             }
490 
491             break;
492 
493         case PARSEOP_PLD_BAY:
494         case PARSEOP_PLD_EJECTABLE:
495         case PARSEOP_PLD_EJECTREQUIRED:
496 
497             if (ParseOpcode != PARSEOP_INTEGER)
498             {
499                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
500                 break;
501             }
502 
503             if (Value > 1)
504             {
505                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
506                 break;
507             }
508 
509             if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_BAY)
510             {
511                 PldInfo.Bay = (UINT8) Value;
512             }
513             else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_EJECTABLE)
514             {
515                 PldInfo.Ejectable = (UINT8) Value;
516             }
517             else /* PARSEOP_PLD_EJECTREQUIRED */
518             {
519                 PldInfo.OspmEjectRequired = (UINT8) Value;
520             }
521 
522             break;
523 
524         case PARSEOP_PLD_CABINETNUMBER:
525         case PARSEOP_PLD_CARDCAGENUMBER:
526 
527             if (ParseOpcode != PARSEOP_INTEGER)
528             {
529                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
530                 break;
531             }
532 
533             if (Value > 255)
534             {
535                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
536                 break;
537             }
538 
539             if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_CABINETNUMBER)
540             {
541                 PldInfo.CabinetNumber = (UINT8) Value;
542             }
543             else /* PARSEOP_PLD_CARDCAGENUMBER */
544             {
545                 PldInfo.CardCageNumber = (UINT8) Value;
546             }
547 
548             break;
549 
550         case PARSEOP_PLD_REFERENCE:
551 
552             if (ParseOpcode != PARSEOP_INTEGER)
553             {
554                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
555                 break;
556             }
557 
558             if (Value > 1)
559             {
560                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
561                 break;
562             }
563 
564             PldInfo.Reference = (UINT8) Value;
565             break;
566 
567         case PARSEOP_PLD_ROTATION:
568 
569             if (ParseOpcode != PARSEOP_INTEGER)
570             {
571                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
572                 break;
573             }
574 
575             if (Value > 7)
576             {
577                 switch (Value)
578                 {
579                 case 45:
580 
581                     Value = 1;
582                     break;
583 
584                 case 90:
585 
586                     Value = 2;
587                     break;
588 
589                 case 135:
590 
591                     Value = 3;
592                     break;
593 
594                 case 180:
595 
596                     Value = 4;
597                     break;
598 
599                 case 225:
600 
601                     Value = 5;
602                     break;
603 
604                 case 270:
605 
606                     Value = 6;
607                     break;
608 
609                 case 315:
610 
611                     Value = 7;
612                     break;
613 
614                 default:
615 
616                     AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
617                     break;
618                 }
619             }
620 
621             PldInfo.Rotation = (UINT8) Value;
622             break;
623 
624         case PARSEOP_PLD_ORDER:
625 
626             if (ParseOpcode != PARSEOP_INTEGER)
627             {
628                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
629                 break;
630             }
631 
632             if (Value > 31)
633             {
634                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
635                 break;
636             }
637 
638             PldInfo.Order = (UINT8) Value;
639             break;
640 
641         case PARSEOP_PLD_VERTICALOFFSET:
642         case PARSEOP_PLD_HORIZONTALOFFSET:
643 
644             if (ParseOpcode != PARSEOP_INTEGER)
645             {
646                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
647                 break;
648             }
649 
650             if (Value > 65535)
651             {
652                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
653                 break;
654             }
655 
656             if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_VERTICALOFFSET)
657             {
658                 PldInfo.VerticalOffset = (UINT16) Value;
659             }
660             else /* PARSEOP_PLD_HORIZONTALOFFSET */
661             {
662                 PldInfo.HorizontalOffset = (UINT16) Value;
663             }
664 
665             break;
666 
667         default:
668 
669             AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
670             break;
671         }
672 
673         ThisOp = ThisOp->Asl.Next;
674     }
675 
676     Buffer = OpcEncodePldBuffer (&PldInfo);
677 
678     /* Change Op to a Buffer */
679 
680     Op->Asl.ParseOpcode = PARSEOP_BUFFER;
681     Op->Common.AmlOpcode = AML_BUFFER_OP;
682 
683     /* Disable further optimization */
684 
685     Op->Asl.CompileFlags &= ~OP_COMPILE_TIME_CONST;
686     UtSetParseOpName (Op);
687 
688     /* Child node is the buffer length */
689 
690     NewOp = TrAllocateOp (PARSEOP_INTEGER);
691 
692     NewOp->Asl.AmlOpcode = AML_BYTE_OP;
693     NewOp->Asl.Value.Integer = 20;
694     NewOp->Asl.Parent = Op;
695 
696     Op->Asl.Child = NewOp;
697     Op = NewOp;
698 
699     /* Peer to the child is the raw buffer data */
700 
701     NewOp = TrAllocateOp (PARSEOP_RAW_DATA);
702     NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
703     NewOp->Asl.AmlLength = 20;
704     NewOp->Asl.Value.String = ACPI_CAST_PTR (char, Buffer);
705     NewOp->Asl.Parent = Op->Asl.Parent;
706 
707     Op->Asl.Next = NewOp;
708 }
709 
710 
711 /*******************************************************************************
712  *
713  * FUNCTION:    OpcEncodePldBuffer
714  *
715  * PARAMETERS:  PldInfo             - _PLD buffer struct (Using local struct)
716  *
717  * RETURN:      Encode _PLD buffer suitable for return value from _PLD
718  *
719  * DESCRIPTION: Bit-packs a _PLD buffer struct.
720  *
721  ******************************************************************************/
722 
723 static UINT8 *
724 OpcEncodePldBuffer (
725     ACPI_PLD_INFO           *PldInfo)
726 {
727     UINT32                  *Buffer;
728     UINT32                  Dword;
729 
730 
731     Buffer = ACPI_ALLOCATE_ZEROED (ACPI_PLD_BUFFER_SIZE);
732     if (!Buffer)
733     {
734         return (NULL);
735     }
736 
737     /* First 32 bits */
738 
739     Dword = 0;
740     ACPI_PLD_SET_REVISION       (&Dword, PldInfo->Revision);
741     ACPI_PLD_SET_IGNORE_COLOR   (&Dword, PldInfo->IgnoreColor);
742     ACPI_PLD_SET_RED            (&Dword, PldInfo->Red);
743     ACPI_PLD_SET_GREEN          (&Dword, PldInfo->Green);
744     ACPI_PLD_SET_BLUE           (&Dword, PldInfo->Blue);
745     ACPI_MOVE_32_TO_32          (&Buffer[0], &Dword);
746 
747     /* Second 32 bits */
748 
749     Dword = 0;
750     ACPI_PLD_SET_WIDTH          (&Dword, PldInfo->Width);
751     ACPI_PLD_SET_HEIGHT         (&Dword, PldInfo->Height);
752     ACPI_MOVE_32_TO_32          (&Buffer[1], &Dword);
753 
754     /* Third 32 bits */
755 
756     Dword = 0;
757     ACPI_PLD_SET_USER_VISIBLE   (&Dword, PldInfo->UserVisible);
758     ACPI_PLD_SET_DOCK           (&Dword, PldInfo->Dock);
759     ACPI_PLD_SET_LID            (&Dword, PldInfo->Lid);
760     ACPI_PLD_SET_PANEL          (&Dword, PldInfo->Panel);
761     ACPI_PLD_SET_VERTICAL       (&Dword, PldInfo->VerticalPosition);
762     ACPI_PLD_SET_HORIZONTAL     (&Dword, PldInfo->HorizontalPosition);
763     ACPI_PLD_SET_SHAPE          (&Dword, PldInfo->Shape);
764     ACPI_PLD_SET_ORIENTATION    (&Dword, PldInfo->GroupOrientation);
765     ACPI_PLD_SET_TOKEN          (&Dword, PldInfo->GroupToken);
766     ACPI_PLD_SET_POSITION       (&Dword, PldInfo->GroupPosition);
767     ACPI_PLD_SET_BAY            (&Dword, PldInfo->Bay);
768     ACPI_MOVE_32_TO_32          (&Buffer[2], &Dword);
769 
770     /* Fourth 32 bits */
771 
772     Dword = 0;
773     ACPI_PLD_SET_EJECTABLE      (&Dword, PldInfo->Ejectable);
774     ACPI_PLD_SET_OSPM_EJECT     (&Dword, PldInfo->OspmEjectRequired);
775     ACPI_PLD_SET_CABINET        (&Dword, PldInfo->CabinetNumber);
776     ACPI_PLD_SET_CARD_CAGE      (&Dword, PldInfo->CardCageNumber);
777     ACPI_PLD_SET_REFERENCE      (&Dword, PldInfo->Reference);
778     ACPI_PLD_SET_ROTATION       (&Dword, PldInfo->Rotation);
779     ACPI_PLD_SET_ORDER          (&Dword, PldInfo->Order);
780     ACPI_MOVE_32_TO_32          (&Buffer[3], &Dword);
781 
782     /* Revision 2 adds an additional DWORD */
783 
784     if (PldInfo->Revision >= 2)
785     {
786         /* Fifth 32 bits */
787 
788         Dword = 0;
789         ACPI_PLD_SET_VERT_OFFSET    (&Dword, PldInfo->VerticalOffset);
790         ACPI_PLD_SET_HORIZ_OFFSET   (&Dword, PldInfo->HorizontalOffset);
791         ACPI_MOVE_32_TO_32          (&Buffer[4], &Dword);
792     }
793 
794     return (ACPI_CAST_PTR (UINT8, Buffer));
795 }
796 
797 
798 /*******************************************************************************
799  *
800  * FUNCTION:    OpcFindName
801  *
802  * PARAMETERS:  List                - Array of char strings to be searched
803  *              Name                - Char string to string for
804  *              Index               - Index value to set if found
805  *
806  * RETURN:      TRUE if any names matched, FALSE otherwise
807  *
808  * DESCRIPTION: Match PLD name to value in lookup table. Sets Value to
809  *              equivalent parameter value.
810  *
811  ******************************************************************************/
812 
813 static BOOLEAN
814 OpcFindName (
815     const char              **List,
816     char                    *Name,
817     UINT32                  *Index)
818 {
819     const char              *NameString;
820     UINT32                  i;
821 
822 
823     AcpiUtStrupr (Name);
824 
825     for (i = 0, NameString = List[0];
826             NameString;
827             i++, NameString = List[i])
828     {
829         if (!(strncmp (NameString, Name, strlen (Name))))
830         {
831             *Index = i;
832             return (TRUE);
833         }
834     }
835 
836     return (FALSE);
837 }
838