Sync ACPICA with Intel's version 20180927:
[dragonfly.git] / sys / contrib / dev / acpica / source / compiler / aslpld.c
blobe9b49ac36781ef0a77dc1476a03b6090ef107ca2
1 /******************************************************************************
3 * Module Name: aslpld - Implementation of ASL ToPLD macro
5 *****************************************************************************/
7 /******************************************************************************
9 * 1. Copyright Notice
11 * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12 * All rights reserved.
14 * 2. License
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.
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
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;
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
40 * 3. Conditions
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.
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.
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.
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
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.
80 * 4. Disclaimer and Export Compliance
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.
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.
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.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
117 * following license:
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.
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.
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.
150 *****************************************************************************/
152 #include "aslcompiler.h"
153 #include "aslcompiler.y.h"
154 #include "amlcode.h"
156 #define _COMPONENT ACPI_COMPILER
157 ACPI_MODULE_NAME ("aslpld")
160 /* Local prototypes */
162 static UINT8 *
163 OpcEncodePldBuffer (
164 ACPI_PLD_INFO *PldInfo);
166 static BOOLEAN
167 OpcFindName (
168 const char **List,
169 char *Name,
170 UINT32 *Index);
173 /*******************************************************************************
175 * FUNCTION: OpcDoPld
177 * PARAMETERS: Op - Current parse node
179 * RETURN: None
181 * DESCRIPTION: Convert ToPLD macro to 20-byte buffer
183 * The ToPLD parse tree looks like this:
185 * TOPLD
186 * PLD_REVISION
187 * INTEGER
188 * PLD_IGNORECOLOR
189 * INTEGER
190 * ...
191 * etc.
193 ******************************************************************************/
195 void
196 OpcDoPld (
197 ACPI_PARSE_OBJECT *Op)
199 ACPI_PLD_INFO PldInfo;
200 UINT8 *Buffer;
201 ACPI_PARSE_OBJECT *ThisOp;
202 ACPI_PARSE_OBJECT *NewOp;
203 UINT16 ParseOpcode;
204 UINT32 Value;
207 if (!Op)
209 AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, NULL);
210 return;
213 if (Op->Asl.ParseOpcode != PARSEOP_TOPLD)
215 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, Op, NULL);
216 return;
219 memset (&PldInfo, 0, sizeof (ACPI_PLD_INFO));
221 /* Traverse the list of PLD Ops (one per PLD field) */
223 ThisOp = Op->Asl.Child;
224 while (ThisOp)
226 /* Get child values */
228 ParseOpcode = ThisOp->Asl.Child->Asl.ParseOpcode;
229 Value = (UINT32) ThisOp->Asl.Child->Asl.Value.Integer;
231 switch (ThisOp->Asl.ParseOpcode)
233 case PARSEOP_PLD_REVISION:
235 if (ParseOpcode != PARSEOP_INTEGER)
237 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
238 break;
241 if (Value > 127)
243 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
244 break;
247 PldInfo.Revision = (UINT8) Value;
248 break;
250 case PARSEOP_PLD_IGNORECOLOR:
252 if (ParseOpcode != PARSEOP_INTEGER)
254 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
255 break;
258 if (Value > 1)
260 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
261 break;
264 PldInfo.IgnoreColor = (UINT8) Value;
265 break;
267 case PARSEOP_PLD_RED:
268 case PARSEOP_PLD_GREEN:
269 case PARSEOP_PLD_BLUE:
271 if (ParseOpcode != PARSEOP_INTEGER)
273 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
274 break;
277 if (Value > 255)
279 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
280 break;
283 if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_RED)
285 PldInfo.Red = (UINT8) Value;
287 else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_GREEN)
289 PldInfo.Green = (UINT8) Value;
291 else /* PARSEOP_PLD_BLUE */
293 PldInfo.Blue = (UINT8) Value;
295 break;
297 case PARSEOP_PLD_WIDTH:
298 case PARSEOP_PLD_HEIGHT:
300 if (ParseOpcode != PARSEOP_INTEGER)
302 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
303 break;
306 if (Value > 65535)
308 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
309 break;
312 if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_WIDTH)
314 PldInfo.Width = (UINT16) Value;
316 else /* PARSEOP_PLD_HEIGHT */
318 PldInfo.Height = (UINT16) Value;
321 break;
323 case PARSEOP_PLD_USERVISIBLE:
324 case PARSEOP_PLD_DOCK:
325 case PARSEOP_PLD_LID:
327 if (ParseOpcode != PARSEOP_INTEGER)
329 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
330 break;
333 if (Value > 1)
335 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
336 break;
339 if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_USERVISIBLE)
341 PldInfo.UserVisible = (UINT8) Value;
343 else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_DOCK)
345 PldInfo.Dock = (UINT8) Value;
347 else
349 PldInfo.Lid = (UINT8) Value;
352 break;
354 case PARSEOP_PLD_PANEL:
356 if (ParseOpcode == PARSEOP_INTEGER)
358 if (Value > 6)
360 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
361 break;
364 else /* PARSEOP_STRING */
366 if (!OpcFindName (AcpiGbl_PldPanelList,
367 ThisOp->Asl.Child->Asl.Value.String,
368 &Value))
370 AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL);
371 break;
375 PldInfo.Panel = (UINT8) Value;
376 break;
378 case PARSEOP_PLD_VERTICALPOSITION:
380 if (ParseOpcode == PARSEOP_INTEGER)
382 if (Value > 2)
384 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
385 break;
388 else /* PARSEOP_STRING */
390 if (!OpcFindName (AcpiGbl_PldVerticalPositionList,
391 ThisOp->Asl.Child->Asl.Value.String,
392 &Value))
394 AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL);
395 break;
399 PldInfo.VerticalPosition = (UINT8) Value;
400 break;
402 case PARSEOP_PLD_HORIZONTALPOSITION:
404 if (ParseOpcode == PARSEOP_INTEGER)
406 if (Value > 2)
408 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
409 break;
412 else /* PARSEOP_STRING */
414 if (!OpcFindName (AcpiGbl_PldHorizontalPositionList,
415 ThisOp->Asl.Child->Asl.Value.String,
416 &Value))
418 AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL);
419 break;
423 PldInfo.HorizontalPosition = (UINT8) Value;
424 break;
426 case PARSEOP_PLD_SHAPE:
428 if (ParseOpcode == PARSEOP_INTEGER)
430 if (Value > 8)
432 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
433 break;
436 else /* PARSEOP_STRING */
438 if (!OpcFindName (AcpiGbl_PldShapeList,
439 ThisOp->Asl.Child->Asl.Value.String,
440 &Value))
442 AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL);
443 break;
447 PldInfo.Shape = (UINT8) Value;
448 break;
450 case PARSEOP_PLD_GROUPORIENTATION:
452 if (ParseOpcode != PARSEOP_INTEGER)
454 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
455 break;
458 if (Value > 1)
460 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
461 break;
464 PldInfo.GroupOrientation = (UINT8) Value;
465 break;
467 case PARSEOP_PLD_GROUPTOKEN:
468 case PARSEOP_PLD_GROUPPOSITION:
470 if (ParseOpcode != PARSEOP_INTEGER)
472 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
473 break;
476 if (Value > 255)
478 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
479 break;
482 if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_GROUPTOKEN)
484 PldInfo.GroupToken = (UINT8) Value;
486 else /* PARSEOP_PLD_GROUPPOSITION */
488 PldInfo.GroupPosition = (UINT8) Value;
491 break;
493 case PARSEOP_PLD_BAY:
494 case PARSEOP_PLD_EJECTABLE:
495 case PARSEOP_PLD_EJECTREQUIRED:
497 if (ParseOpcode != PARSEOP_INTEGER)
499 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
500 break;
503 if (Value > 1)
505 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
506 break;
509 if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_BAY)
511 PldInfo.Bay = (UINT8) Value;
513 else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_EJECTABLE)
515 PldInfo.Ejectable = (UINT8) Value;
517 else /* PARSEOP_PLD_EJECTREQUIRED */
519 PldInfo.OspmEjectRequired = (UINT8) Value;
522 break;
524 case PARSEOP_PLD_CABINETNUMBER:
525 case PARSEOP_PLD_CARDCAGENUMBER:
527 if (ParseOpcode != PARSEOP_INTEGER)
529 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
530 break;
533 if (Value > 255)
535 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
536 break;
539 if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_CABINETNUMBER)
541 PldInfo.CabinetNumber = (UINT8) Value;
543 else /* PARSEOP_PLD_CARDCAGENUMBER */
545 PldInfo.CardCageNumber = (UINT8) Value;
548 break;
550 case PARSEOP_PLD_REFERENCE:
552 if (ParseOpcode != PARSEOP_INTEGER)
554 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
555 break;
558 if (Value > 1)
560 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
561 break;
564 PldInfo.Reference = (UINT8) Value;
565 break;
567 case PARSEOP_PLD_ROTATION:
569 if (ParseOpcode != PARSEOP_INTEGER)
571 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
572 break;
575 if (Value > 7)
577 switch (Value)
579 case 45:
581 Value = 1;
582 break;
584 case 90:
586 Value = 2;
587 break;
589 case 135:
591 Value = 3;
592 break;
594 case 180:
596 Value = 4;
597 break;
599 case 225:
601 Value = 5;
602 break;
604 case 270:
606 Value = 6;
607 break;
609 case 315:
611 Value = 7;
612 break;
614 default:
616 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
617 break;
621 PldInfo.Rotation = (UINT8) Value;
622 break;
624 case PARSEOP_PLD_ORDER:
626 if (ParseOpcode != PARSEOP_INTEGER)
628 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
629 break;
632 if (Value > 31)
634 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
635 break;
638 PldInfo.Order = (UINT8) Value;
639 break;
641 case PARSEOP_PLD_VERTICALOFFSET:
642 case PARSEOP_PLD_HORIZONTALOFFSET:
644 if (ParseOpcode != PARSEOP_INTEGER)
646 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
647 break;
650 if (Value > 65535)
652 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
653 break;
656 if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_VERTICALOFFSET)
658 PldInfo.VerticalOffset = (UINT16) Value;
660 else /* PARSEOP_PLD_HORIZONTALOFFSET */
662 PldInfo.HorizontalOffset = (UINT16) Value;
665 break;
667 default:
669 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
670 break;
673 ThisOp = ThisOp->Asl.Next;
676 Buffer = OpcEncodePldBuffer (&PldInfo);
678 /* Change Op to a Buffer */
680 Op->Asl.ParseOpcode = PARSEOP_BUFFER;
681 Op->Common.AmlOpcode = AML_BUFFER_OP;
683 /* Disable further optimization */
685 Op->Asl.CompileFlags &= ~OP_COMPILE_TIME_CONST;
686 UtSetParseOpName (Op);
688 /* Child node is the buffer length */
690 NewOp = TrAllocateOp (PARSEOP_INTEGER);
692 NewOp->Asl.AmlOpcode = AML_BYTE_OP;
693 NewOp->Asl.Value.Integer = 20;
694 NewOp->Asl.Parent = Op;
696 Op->Asl.Child = NewOp;
697 Op = NewOp;
699 /* Peer to the child is the raw buffer data */
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;
707 Op->Asl.Next = NewOp;
711 /*******************************************************************************
713 * FUNCTION: OpcEncodePldBuffer
715 * PARAMETERS: PldInfo - _PLD buffer struct (Using local struct)
717 * RETURN: Encode _PLD buffer suitable for return value from _PLD
719 * DESCRIPTION: Bit-packs a _PLD buffer struct.
721 ******************************************************************************/
723 static UINT8 *
724 OpcEncodePldBuffer (
725 ACPI_PLD_INFO *PldInfo)
727 UINT32 *Buffer;
728 UINT32 Dword;
731 Buffer = ACPI_CAST_PTR (UINT32, UtLocalCacheCalloc (ACPI_PLD_BUFFER_SIZE));
733 /* First 32 bits */
735 Dword = 0;
736 ACPI_PLD_SET_REVISION (&Dword, PldInfo->Revision);
737 ACPI_PLD_SET_IGNORE_COLOR (&Dword, PldInfo->IgnoreColor);
738 ACPI_PLD_SET_RED (&Dword, PldInfo->Red);
739 ACPI_PLD_SET_GREEN (&Dword, PldInfo->Green);
740 ACPI_PLD_SET_BLUE (&Dword, PldInfo->Blue);
741 ACPI_MOVE_32_TO_32 (&Buffer[0], &Dword);
743 /* Second 32 bits */
745 Dword = 0;
746 ACPI_PLD_SET_WIDTH (&Dword, PldInfo->Width);
747 ACPI_PLD_SET_HEIGHT (&Dword, PldInfo->Height);
748 ACPI_MOVE_32_TO_32 (&Buffer[1], &Dword);
750 /* Third 32 bits */
752 Dword = 0;
753 ACPI_PLD_SET_USER_VISIBLE (&Dword, PldInfo->UserVisible);
754 ACPI_PLD_SET_DOCK (&Dword, PldInfo->Dock);
755 ACPI_PLD_SET_LID (&Dword, PldInfo->Lid);
756 ACPI_PLD_SET_PANEL (&Dword, PldInfo->Panel);
757 ACPI_PLD_SET_VERTICAL (&Dword, PldInfo->VerticalPosition);
758 ACPI_PLD_SET_HORIZONTAL (&Dword, PldInfo->HorizontalPosition);
759 ACPI_PLD_SET_SHAPE (&Dword, PldInfo->Shape);
760 ACPI_PLD_SET_ORIENTATION (&Dword, PldInfo->GroupOrientation);
761 ACPI_PLD_SET_TOKEN (&Dword, PldInfo->GroupToken);
762 ACPI_PLD_SET_POSITION (&Dword, PldInfo->GroupPosition);
763 ACPI_PLD_SET_BAY (&Dword, PldInfo->Bay);
764 ACPI_MOVE_32_TO_32 (&Buffer[2], &Dword);
766 /* Fourth 32 bits */
768 Dword = 0;
769 ACPI_PLD_SET_EJECTABLE (&Dword, PldInfo->Ejectable);
770 ACPI_PLD_SET_OSPM_EJECT (&Dword, PldInfo->OspmEjectRequired);
771 ACPI_PLD_SET_CABINET (&Dword, PldInfo->CabinetNumber);
772 ACPI_PLD_SET_CARD_CAGE (&Dword, PldInfo->CardCageNumber);
773 ACPI_PLD_SET_REFERENCE (&Dword, PldInfo->Reference);
774 ACPI_PLD_SET_ROTATION (&Dword, PldInfo->Rotation);
775 ACPI_PLD_SET_ORDER (&Dword, PldInfo->Order);
776 ACPI_MOVE_32_TO_32 (&Buffer[3], &Dword);
778 /* Revision 2 adds an additional DWORD */
780 if (PldInfo->Revision >= 2)
782 /* Fifth 32 bits */
784 Dword = 0;
785 ACPI_PLD_SET_VERT_OFFSET (&Dword, PldInfo->VerticalOffset);
786 ACPI_PLD_SET_HORIZ_OFFSET (&Dword, PldInfo->HorizontalOffset);
787 ACPI_MOVE_32_TO_32 (&Buffer[4], &Dword);
790 return (ACPI_CAST_PTR (UINT8, Buffer));
794 /*******************************************************************************
796 * FUNCTION: OpcFindName
798 * PARAMETERS: List - Array of char strings to be searched
799 * Name - Char string to string for
800 * Index - Index value to set if found
802 * RETURN: TRUE if any names matched, FALSE otherwise
804 * DESCRIPTION: Match PLD name to value in lookup table. Sets Value to
805 * equivalent parameter value.
807 ******************************************************************************/
809 static BOOLEAN
810 OpcFindName (
811 const char **List,
812 char *Name,
813 UINT32 *Index)
815 const char *NameString;
816 UINT32 i;
819 AcpiUtStrupr (Name);
821 for (i = 0, NameString = List[0];
822 NameString;
823 i++, NameString = List[i])
825 if (!(strncmp (NameString, Name, strlen (Name))))
827 *Index = i;
828 return (TRUE);
832 return (FALSE);