1bc36eafdSMike Gerdts /******************************************************************************
2bc36eafdSMike Gerdts  *
3bc36eafdSMike Gerdts  * Module Name: aslrestype2s - Serial Large resource descriptors
4bc36eafdSMike Gerdts  *
5bc36eafdSMike Gerdts  *****************************************************************************/
6bc36eafdSMike Gerdts 
7*35786f68SRobert Mustacchi /******************************************************************************
8*35786f68SRobert Mustacchi  *
9*35786f68SRobert Mustacchi  * 1. Copyright Notice
10*35786f68SRobert Mustacchi  *
11*35786f68SRobert Mustacchi  * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12bc36eafdSMike Gerdts  * All rights reserved.
13bc36eafdSMike Gerdts  *
14*35786f68SRobert Mustacchi  * 2. License
15*35786f68SRobert Mustacchi  *
16*35786f68SRobert Mustacchi  * 2.1. This is your license from Intel Corp. under its intellectual property
17*35786f68SRobert Mustacchi  * rights. You may have additional license terms from the party that provided
18*35786f68SRobert Mustacchi  * you this software, covering your right to use that party's intellectual
19*35786f68SRobert Mustacchi  * property rights.
20*35786f68SRobert Mustacchi  *
21*35786f68SRobert Mustacchi  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22*35786f68SRobert Mustacchi  * copy of the source code appearing in this file ("Covered Code") an
23*35786f68SRobert Mustacchi  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24*35786f68SRobert Mustacchi  * base code distributed originally by Intel ("Original Intel Code") to copy,
25*35786f68SRobert Mustacchi  * make derivatives, distribute, use and display any portion of the Covered
26*35786f68SRobert Mustacchi  * Code in any form, with the right to sublicense such rights; and
27*35786f68SRobert Mustacchi  *
28*35786f68SRobert Mustacchi  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29*35786f68SRobert Mustacchi  * license (with the right to sublicense), under only those claims of Intel
30*35786f68SRobert Mustacchi  * patents that are infringed by the Original Intel Code, to make, use, sell,
31*35786f68SRobert Mustacchi  * offer to sell, and import the Covered Code and derivative works thereof
32*35786f68SRobert Mustacchi  * solely to the minimum extent necessary to exercise the above copyright
33*35786f68SRobert Mustacchi  * license, and in no event shall the patent license extend to any additions
34*35786f68SRobert Mustacchi  * to or modifications of the Original Intel Code. No other license or right
35*35786f68SRobert Mustacchi  * is granted directly or by implication, estoppel or otherwise;
36*35786f68SRobert Mustacchi  *
37*35786f68SRobert Mustacchi  * The above copyright and patent license is granted only if the following
38*35786f68SRobert Mustacchi  * conditions are met:
39*35786f68SRobert Mustacchi  *
40*35786f68SRobert Mustacchi  * 3. Conditions
41*35786f68SRobert Mustacchi  *
42*35786f68SRobert Mustacchi  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43*35786f68SRobert Mustacchi  * Redistribution of source code of any substantial portion of the Covered
44*35786f68SRobert Mustacchi  * Code or modification with rights to further distribute source must include
45*35786f68SRobert Mustacchi  * the above Copyright Notice, the above License, this list of Conditions,
46*35786f68SRobert Mustacchi  * and the following Disclaimer and Export Compliance provision. In addition,
47*35786f68SRobert Mustacchi  * Licensee must cause all Covered Code to which Licensee contributes to
48*35786f68SRobert Mustacchi  * contain a file documenting the changes Licensee made to create that Covered
49*35786f68SRobert Mustacchi  * Code and the date of any change. Licensee must include in that file the
50*35786f68SRobert Mustacchi  * documentation of any changes made by any predecessor Licensee. Licensee
51*35786f68SRobert Mustacchi  * must include a prominent statement that the modification is derived,
52*35786f68SRobert Mustacchi  * directly or indirectly, from Original Intel Code.
53*35786f68SRobert Mustacchi  *
54*35786f68SRobert Mustacchi  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55*35786f68SRobert Mustacchi  * Redistribution of source code of any substantial portion of the Covered
56*35786f68SRobert Mustacchi  * Code or modification without rights to further distribute source must
57*35786f68SRobert Mustacchi  * include the following Disclaimer and Export Compliance provision in the
58*35786f68SRobert Mustacchi  * documentation and/or other materials provided with distribution. In
59*35786f68SRobert Mustacchi  * addition, Licensee may not authorize further sublicense of source of any
60*35786f68SRobert Mustacchi  * portion of the Covered Code, and must include terms to the effect that the
61*35786f68SRobert Mustacchi  * license from Licensee to its licensee is limited to the intellectual
62*35786f68SRobert Mustacchi  * property embodied in the software Licensee provides to its licensee, and
63*35786f68SRobert Mustacchi  * not to intellectual property embodied in modifications its licensee may
64*35786f68SRobert Mustacchi  * make.
65*35786f68SRobert Mustacchi  *
66*35786f68SRobert Mustacchi  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67*35786f68SRobert Mustacchi  * substantial portion of the Covered Code or modification must reproduce the
68*35786f68SRobert Mustacchi  * above Copyright Notice, and the following Disclaimer and Export Compliance
69*35786f68SRobert Mustacchi  * provision in the documentation and/or other materials provided with the
70*35786f68SRobert Mustacchi  * distribution.
71*35786f68SRobert Mustacchi  *
72*35786f68SRobert Mustacchi  * 3.4. Intel retains all right, title, and interest in and to the Original
73*35786f68SRobert Mustacchi  * Intel Code.
74*35786f68SRobert Mustacchi  *
75*35786f68SRobert Mustacchi  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76*35786f68SRobert Mustacchi  * Intel shall be used in advertising or otherwise to promote the sale, use or
77*35786f68SRobert Mustacchi  * other dealings in products derived from or relating to the Covered Code
78*35786f68SRobert Mustacchi  * without prior written authorization from Intel.
79*35786f68SRobert Mustacchi  *
80*35786f68SRobert Mustacchi  * 4. Disclaimer and Export Compliance
81*35786f68SRobert Mustacchi  *
82*35786f68SRobert Mustacchi  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83*35786f68SRobert Mustacchi  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84*35786f68SRobert Mustacchi  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85*35786f68SRobert Mustacchi  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86*35786f68SRobert Mustacchi  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87*35786f68SRobert Mustacchi  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88*35786f68SRobert Mustacchi  * PARTICULAR PURPOSE.
89*35786f68SRobert Mustacchi  *
90*35786f68SRobert Mustacchi  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91*35786f68SRobert Mustacchi  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92*35786f68SRobert Mustacchi  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93*35786f68SRobert Mustacchi  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94*35786f68SRobert Mustacchi  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95*35786f68SRobert Mustacchi  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96*35786f68SRobert Mustacchi  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97*35786f68SRobert Mustacchi  * LIMITED REMEDY.
98*35786f68SRobert Mustacchi  *
99*35786f68SRobert Mustacchi  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100*35786f68SRobert Mustacchi  * software or system incorporating such software without first obtaining any
101*35786f68SRobert Mustacchi  * required license or other approval from the U. S. Department of Commerce or
102*35786f68SRobert Mustacchi  * any other agency or department of the United States Government. In the
103*35786f68SRobert Mustacchi  * event Licensee exports any such software from the United States or
104*35786f68SRobert Mustacchi  * re-exports any such software from a foreign destination, Licensee shall
105*35786f68SRobert Mustacchi  * ensure that the distribution and export/re-export of the software is in
106*35786f68SRobert Mustacchi  * compliance with all laws, regulations, orders, or other restrictions of the
107*35786f68SRobert Mustacchi  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108*35786f68SRobert Mustacchi  * any of its subsidiaries will export/re-export any technical data, process,
109*35786f68SRobert Mustacchi  * software, or service, directly or indirectly, to any country for which the
110*35786f68SRobert Mustacchi  * United States government or any agency thereof requires an export license,
111*35786f68SRobert Mustacchi  * other governmental approval, or letter of assurance, without first obtaining
112*35786f68SRobert Mustacchi  * such license, approval or letter.
113*35786f68SRobert Mustacchi  *
114*35786f68SRobert Mustacchi  *****************************************************************************
115*35786f68SRobert Mustacchi  *
116*35786f68SRobert Mustacchi  * Alternatively, you may choose to be licensed under the terms of the
117*35786f68SRobert Mustacchi  * following license:
118*35786f68SRobert Mustacchi  *
119bc36eafdSMike Gerdts  * Redistribution and use in source and binary forms, with or without
120bc36eafdSMike Gerdts  * modification, are permitted provided that the following conditions
121bc36eafdSMike Gerdts  * are met:
122bc36eafdSMike Gerdts  * 1. Redistributions of source code must retain the above copyright
123bc36eafdSMike Gerdts  *    notice, this list of conditions, and the following disclaimer,
124bc36eafdSMike Gerdts  *    without modification.
125bc36eafdSMike Gerdts  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126bc36eafdSMike Gerdts  *    substantially similar to the "NO WARRANTY" disclaimer below
127bc36eafdSMike Gerdts  *    ("Disclaimer") and any redistribution must be conditioned upon
128bc36eafdSMike Gerdts  *    including a substantially similar Disclaimer requirement for further
129bc36eafdSMike Gerdts  *    binary redistribution.
130bc36eafdSMike Gerdts  * 3. Neither the names of the above-listed copyright holders nor the names
131bc36eafdSMike Gerdts  *    of any contributors may be used to endorse or promote products derived
132bc36eafdSMike Gerdts  *    from this software without specific prior written permission.
133bc36eafdSMike Gerdts  *
134bc36eafdSMike Gerdts  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135bc36eafdSMike Gerdts  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136*35786f68SRobert Mustacchi  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137bc36eafdSMike Gerdts  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138*35786f68SRobert Mustacchi  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139*35786f68SRobert Mustacchi  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140*35786f68SRobert Mustacchi  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141*35786f68SRobert Mustacchi  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142*35786f68SRobert Mustacchi  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143*35786f68SRobert Mustacchi  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144*35786f68SRobert Mustacchi  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145*35786f68SRobert Mustacchi  *
146*35786f68SRobert Mustacchi  * Alternatively, you may choose to be licensed under the terms of the
147*35786f68SRobert Mustacchi  * GNU General Public License ("GPL") version 2 as published by the Free
148*35786f68SRobert Mustacchi  * Software Foundation.
149*35786f68SRobert Mustacchi  *
150*35786f68SRobert Mustacchi  *****************************************************************************/
151bc36eafdSMike Gerdts 
152bc36eafdSMike Gerdts #include "aslcompiler.h"
153bc36eafdSMike Gerdts #include "aslcompiler.y.h"
154bc36eafdSMike Gerdts #include "amlcode.h"
155bc36eafdSMike Gerdts 
156bc36eafdSMike Gerdts #define _COMPONENT          ACPI_COMPILER
157bc36eafdSMike Gerdts         ACPI_MODULE_NAME    ("aslrestype2s")
158bc36eafdSMike Gerdts 
159bc36eafdSMike Gerdts 
160bc36eafdSMike Gerdts static UINT16
161bc36eafdSMike Gerdts RsGetBufferDataLength (
162bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *InitializerOp);
163bc36eafdSMike Gerdts 
164bc36eafdSMike Gerdts static UINT16
165bc36eafdSMike Gerdts RsGetInterruptDataLength (
166*35786f68SRobert Mustacchi     ACPI_PARSE_OBJECT       *InitializerOp,
167*35786f68SRobert Mustacchi     UINT32                  StartIndex);
168bc36eafdSMike Gerdts 
169bc36eafdSMike Gerdts static BOOLEAN
170bc36eafdSMike Gerdts RsGetVendorData (
171bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *InitializerOp,
172bc36eafdSMike Gerdts     UINT8                   *VendorData,
173bc36eafdSMike Gerdts     ACPI_SIZE               DescriptorOffset);
174bc36eafdSMike Gerdts 
175*35786f68SRobert Mustacchi static UINT16
176*35786f68SRobert Mustacchi RsGetStringDataLengthAt (
177*35786f68SRobert Mustacchi     ACPI_PARSE_OBJECT       *InitializerOp,
178*35786f68SRobert Mustacchi     UINT32                  StartIndex);
179*35786f68SRobert Mustacchi 
180bc36eafdSMike Gerdts /*
181bc36eafdSMike Gerdts  * This module contains descriptors for serial buses and GPIO:
182bc36eafdSMike Gerdts  *
183bc36eafdSMike Gerdts  * GpioInt
184bc36eafdSMike Gerdts  * GpioIo
185bc36eafdSMike Gerdts  * I2cSerialBus
186bc36eafdSMike Gerdts  * SpiSerialBus
187bc36eafdSMike Gerdts  * UartSerialBus
188*35786f68SRobert Mustacchi  * PinFunction
189*35786f68SRobert Mustacchi  * PinConfig
190*35786f68SRobert Mustacchi  * PinGroup
191*35786f68SRobert Mustacchi  * PinGroupFunction
192*35786f68SRobert Mustacchi  * PinGroupConfig
193bc36eafdSMike Gerdts  */
194bc36eafdSMike Gerdts 
195bc36eafdSMike Gerdts 
196bc36eafdSMike Gerdts /*******************************************************************************
197bc36eafdSMike Gerdts  *
198bc36eafdSMike Gerdts  * FUNCTION:    RsGetBufferDataLength
199bc36eafdSMike Gerdts  *
200bc36eafdSMike Gerdts  * PARAMETERS:  InitializerOp       - Current parse op, start of the resource
201bc36eafdSMike Gerdts  *                                    descriptor
202bc36eafdSMike Gerdts  *
203bc36eafdSMike Gerdts  * RETURN:      Length of the data buffer
204bc36eafdSMike Gerdts  *
205bc36eafdSMike Gerdts  * DESCRIPTION: Get the length of a RawDataBuffer, used for vendor data.
206bc36eafdSMike Gerdts  *
207bc36eafdSMike Gerdts  ******************************************************************************/
208bc36eafdSMike Gerdts 
209bc36eafdSMike Gerdts static UINT16
RsGetBufferDataLength(ACPI_PARSE_OBJECT * InitializerOp)210bc36eafdSMike Gerdts RsGetBufferDataLength (
211bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *InitializerOp)
212bc36eafdSMike Gerdts {
213bc36eafdSMike Gerdts     UINT16                  ExtraDataSize = 0;
214bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *DataList;
215bc36eafdSMike Gerdts 
216bc36eafdSMike Gerdts 
217bc36eafdSMike Gerdts     /* Find the byte-initializer list */
218bc36eafdSMike Gerdts 
219bc36eafdSMike Gerdts     while (InitializerOp)
220bc36eafdSMike Gerdts     {
221bc36eafdSMike Gerdts         if (InitializerOp->Asl.ParseOpcode == PARSEOP_DATABUFFER)
222bc36eafdSMike Gerdts         {
223bc36eafdSMike Gerdts             /* First child is the optional length (ignore it here) */
224bc36eafdSMike Gerdts 
225bc36eafdSMike Gerdts             DataList = InitializerOp->Asl.Child;
226bc36eafdSMike Gerdts             DataList = ASL_GET_PEER_NODE (DataList);
227bc36eafdSMike Gerdts 
228bc36eafdSMike Gerdts             /* Count the data items (each one is a byte of data) */
229bc36eafdSMike Gerdts 
230bc36eafdSMike Gerdts             while (DataList)
231bc36eafdSMike Gerdts             {
232bc36eafdSMike Gerdts                 ExtraDataSize++;
233bc36eafdSMike Gerdts                 DataList = ASL_GET_PEER_NODE (DataList);
234bc36eafdSMike Gerdts             }
235bc36eafdSMike Gerdts 
236bc36eafdSMike Gerdts             return (ExtraDataSize);
237bc36eafdSMike Gerdts         }
238bc36eafdSMike Gerdts 
239bc36eafdSMike Gerdts         InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
240bc36eafdSMike Gerdts     }
241bc36eafdSMike Gerdts 
242bc36eafdSMike Gerdts     return (ExtraDataSize);
243bc36eafdSMike Gerdts }
244bc36eafdSMike Gerdts 
245bc36eafdSMike Gerdts 
246bc36eafdSMike Gerdts /*******************************************************************************
247bc36eafdSMike Gerdts  *
248bc36eafdSMike Gerdts  * FUNCTION:    RsGetInterruptDataLength
249bc36eafdSMike Gerdts  *
250bc36eafdSMike Gerdts  * PARAMETERS:  InitializerOp       - Current parse op, start of the resource
251bc36eafdSMike Gerdts  *                                    descriptor
252*35786f68SRobert Mustacchi  *              StartIndex          - Start index of interrupt/pin list
253bc36eafdSMike Gerdts  *
254bc36eafdSMike Gerdts  * RETURN:      Length of the interrupt data list
255bc36eafdSMike Gerdts  *
256bc36eafdSMike Gerdts  * DESCRIPTION: Get the length of a list of interrupt DWORDs for the GPIO
257bc36eafdSMike Gerdts  *              descriptors.
258bc36eafdSMike Gerdts  *
259bc36eafdSMike Gerdts  ******************************************************************************/
260bc36eafdSMike Gerdts 
261bc36eafdSMike Gerdts static UINT16
RsGetInterruptDataLength(ACPI_PARSE_OBJECT * InitializerOp,UINT32 StartIndex)262bc36eafdSMike Gerdts RsGetInterruptDataLength (
263*35786f68SRobert Mustacchi     ACPI_PARSE_OBJECT       *InitializerOp,
264*35786f68SRobert Mustacchi     UINT32                  StartIndex)
265bc36eafdSMike Gerdts {
266bc36eafdSMike Gerdts     UINT16                  InterruptLength;
267bc36eafdSMike Gerdts     UINT32                  i;
268bc36eafdSMike Gerdts 
269bc36eafdSMike Gerdts 
270bc36eafdSMike Gerdts     /* Count the interrupt numbers */
271bc36eafdSMike Gerdts 
272bc36eafdSMike Gerdts     InterruptLength = 0;
273bc36eafdSMike Gerdts     for (i = 0; InitializerOp; i++)
274bc36eafdSMike Gerdts     {
275bc36eafdSMike Gerdts         InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
276bc36eafdSMike Gerdts 
277*35786f68SRobert Mustacchi         /* Interrupt list starts at offset StartIndex (Gpio descriptors) */
278bc36eafdSMike Gerdts 
279*35786f68SRobert Mustacchi         if (i >= StartIndex)
280bc36eafdSMike Gerdts         {
281bc36eafdSMike Gerdts             InterruptLength += 2;
282bc36eafdSMike Gerdts         }
283bc36eafdSMike Gerdts     }
284bc36eafdSMike Gerdts 
285bc36eafdSMike Gerdts     return (InterruptLength);
286bc36eafdSMike Gerdts }
287bc36eafdSMike Gerdts 
288bc36eafdSMike Gerdts 
289bc36eafdSMike Gerdts /*******************************************************************************
290bc36eafdSMike Gerdts  *
291bc36eafdSMike Gerdts  * FUNCTION:    RsGetVendorData
292bc36eafdSMike Gerdts  *
293bc36eafdSMike Gerdts  * PARAMETERS:  InitializerOp       - Current parse op, start of the resource
294bc36eafdSMike Gerdts  *                                    descriptor.
295bc36eafdSMike Gerdts  *              VendorData          - Where the vendor data is returned
296bc36eafdSMike Gerdts  *              DescriptorOffset    - Where vendor data begins in descriptor
297bc36eafdSMike Gerdts  *
298bc36eafdSMike Gerdts  * RETURN:      TRUE if valid vendor data was returned, FALSE otherwise.
299bc36eafdSMike Gerdts  *
300bc36eafdSMike Gerdts  * DESCRIPTION: Extract the vendor data and construct a vendor data buffer.
301bc36eafdSMike Gerdts  *
302bc36eafdSMike Gerdts  ******************************************************************************/
303bc36eafdSMike Gerdts 
304bc36eafdSMike Gerdts static BOOLEAN
RsGetVendorData(ACPI_PARSE_OBJECT * InitializerOp,UINT8 * VendorData,ACPI_SIZE DescriptorOffset)305bc36eafdSMike Gerdts RsGetVendorData (
306bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *InitializerOp,
307bc36eafdSMike Gerdts     UINT8                   *VendorData,
308bc36eafdSMike Gerdts     ACPI_SIZE               DescriptorOffset)
309bc36eafdSMike Gerdts {
310bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *BufferOp;
311bc36eafdSMike Gerdts     UINT32                  SpecifiedLength = ACPI_UINT32_MAX;
312bc36eafdSMike Gerdts     UINT16                  ActualLength = 0;
313bc36eafdSMike Gerdts 
314bc36eafdSMike Gerdts 
315bc36eafdSMike Gerdts     /* Vendor Data field is always optional */
316bc36eafdSMike Gerdts 
317bc36eafdSMike Gerdts     if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
318bc36eafdSMike Gerdts     {
319bc36eafdSMike Gerdts         return (FALSE);
320bc36eafdSMike Gerdts     }
321bc36eafdSMike Gerdts 
322bc36eafdSMike Gerdts     BufferOp = InitializerOp->Asl.Child;
323bc36eafdSMike Gerdts     if (!BufferOp)
324bc36eafdSMike Gerdts     {
325bc36eafdSMike Gerdts         AslError (ASL_ERROR, ASL_MSG_SYNTAX, InitializerOp, "");
326bc36eafdSMike Gerdts         return (FALSE);
327bc36eafdSMike Gerdts     }
328bc36eafdSMike Gerdts 
329bc36eafdSMike Gerdts     /* First child is the optional buffer length (WORD) */
330bc36eafdSMike Gerdts 
331bc36eafdSMike Gerdts     if (BufferOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
332bc36eafdSMike Gerdts     {
333bc36eafdSMike Gerdts         SpecifiedLength = (UINT16) BufferOp->Asl.Value.Integer;
334bc36eafdSMike Gerdts     }
335bc36eafdSMike Gerdts 
336bc36eafdSMike Gerdts     /* Insert field tag _VEN */
337bc36eafdSMike Gerdts 
338bc36eafdSMike Gerdts     RsCreateByteField (InitializerOp, ACPI_RESTAG_VENDORDATA,
339bc36eafdSMike Gerdts         (UINT16) DescriptorOffset);
340bc36eafdSMike Gerdts 
341bc36eafdSMike Gerdts     /* Walk the list of buffer initializers (each is one byte) */
342bc36eafdSMike Gerdts 
343bc36eafdSMike Gerdts     BufferOp = RsCompleteNodeAndGetNext (BufferOp);
344bc36eafdSMike Gerdts     if (BufferOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
345bc36eafdSMike Gerdts     {
346bc36eafdSMike Gerdts         while (BufferOp)
347bc36eafdSMike Gerdts         {
348bc36eafdSMike Gerdts             *VendorData = (UINT8) BufferOp->Asl.Value.Integer;
349bc36eafdSMike Gerdts             VendorData++;
350bc36eafdSMike Gerdts             ActualLength++;
351bc36eafdSMike Gerdts             BufferOp = RsCompleteNodeAndGetNext (BufferOp);
352bc36eafdSMike Gerdts         }
353bc36eafdSMike Gerdts     }
354bc36eafdSMike Gerdts 
355bc36eafdSMike Gerdts     /* Length validation. Buffer cannot be of zero length */
356bc36eafdSMike Gerdts 
357bc36eafdSMike Gerdts     if ((SpecifiedLength == 0) ||
358bc36eafdSMike Gerdts         ((SpecifiedLength == ACPI_UINT32_MAX) && (ActualLength == 0)))
359bc36eafdSMike Gerdts     {
360bc36eafdSMike Gerdts         AslError (ASL_ERROR, ASL_MSG_BUFFER_LENGTH, InitializerOp, NULL);
361bc36eafdSMike Gerdts         return (FALSE);
362bc36eafdSMike Gerdts     }
363bc36eafdSMike Gerdts 
364bc36eafdSMike Gerdts     if (SpecifiedLength != ACPI_UINT32_MAX)
365bc36eafdSMike Gerdts     {
366bc36eafdSMike Gerdts         /* ActualLength > SpecifiedLength -> error */
367bc36eafdSMike Gerdts 
368bc36eafdSMike Gerdts         if (ActualLength > SpecifiedLength)
369bc36eafdSMike Gerdts         {
370bc36eafdSMike Gerdts             AslError (ASL_ERROR, ASL_MSG_LIST_LENGTH_LONG, InitializerOp, NULL);
371bc36eafdSMike Gerdts             return (FALSE);
372bc36eafdSMike Gerdts         }
373bc36eafdSMike Gerdts 
374bc36eafdSMike Gerdts         /* ActualLength < SpecifiedLength -> remark */
375bc36eafdSMike Gerdts 
376bc36eafdSMike Gerdts         else if (ActualLength < SpecifiedLength)
377bc36eafdSMike Gerdts         {
378bc36eafdSMike Gerdts             AslError (ASL_REMARK, ASL_MSG_LIST_LENGTH_SHORT, InitializerOp, NULL);
379bc36eafdSMike Gerdts             return (FALSE);
380bc36eafdSMike Gerdts         }
381bc36eafdSMike Gerdts     }
382bc36eafdSMike Gerdts 
383bc36eafdSMike Gerdts     return (TRUE);
384bc36eafdSMike Gerdts }
385bc36eafdSMike Gerdts 
386bc36eafdSMike Gerdts 
387*35786f68SRobert Mustacchi /*******************************************************************************
388*35786f68SRobert Mustacchi  *
389*35786f68SRobert Mustacchi  * FUNCTION:    RsGetStringDataLengthAt
390*35786f68SRobert Mustacchi  *
391*35786f68SRobert Mustacchi  * PARAMETERS:  InitializerOp     - Start of a subtree of init nodes
392*35786f68SRobert Mustacchi  *              StartIndex        - Starting index of the string node
393*35786f68SRobert Mustacchi  *
394*35786f68SRobert Mustacchi  * RETURN:      Valid string length if a string node is found at given
395*35786f68SRobert Mustacchi  *               StartIndex or 0 otherwise.
396*35786f68SRobert Mustacchi  *
397*35786f68SRobert Mustacchi  * DESCRIPTION: In a list of peer nodes, find the first one at given index
398*35786f68SRobert Mustacchi  *              that contains a string and return length.
399*35786f68SRobert Mustacchi  *
400*35786f68SRobert Mustacchi  ******************************************************************************/
401*35786f68SRobert Mustacchi 
402*35786f68SRobert Mustacchi static UINT16
RsGetStringDataLengthAt(ACPI_PARSE_OBJECT * InitializerOp,UINT32 StartIndex)403*35786f68SRobert Mustacchi RsGetStringDataLengthAt (
404*35786f68SRobert Mustacchi     ACPI_PARSE_OBJECT       *InitializerOp,
405*35786f68SRobert Mustacchi     UINT32                  StartIndex)
406*35786f68SRobert Mustacchi {
407*35786f68SRobert Mustacchi     UINT32 i;
408*35786f68SRobert Mustacchi 
409*35786f68SRobert Mustacchi     for (i = 0; InitializerOp; i++)
410*35786f68SRobert Mustacchi     {
411*35786f68SRobert Mustacchi         if (i == StartIndex &&
412*35786f68SRobert Mustacchi             InitializerOp->Asl.ParseOpcode == PARSEOP_STRING_LITERAL)
413*35786f68SRobert Mustacchi         {
414*35786f68SRobert Mustacchi             return ((UINT16) (strlen (InitializerOp->Asl.Value.String) + 1));
415*35786f68SRobert Mustacchi         }
416*35786f68SRobert Mustacchi 
417*35786f68SRobert Mustacchi         InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
418*35786f68SRobert Mustacchi     }
419*35786f68SRobert Mustacchi 
420*35786f68SRobert Mustacchi     return (0);
421*35786f68SRobert Mustacchi }
422*35786f68SRobert Mustacchi 
423*35786f68SRobert Mustacchi 
424bc36eafdSMike Gerdts /*******************************************************************************
425bc36eafdSMike Gerdts  *
426bc36eafdSMike Gerdts  * FUNCTION:    RsDoGpioIntDescriptor
427bc36eafdSMike Gerdts  *
428bc36eafdSMike Gerdts  * PARAMETERS:  Info                - Parse Op and resource template offset
429bc36eafdSMike Gerdts  *
430bc36eafdSMike Gerdts  * RETURN:      Completed resource node
431bc36eafdSMike Gerdts  *
432bc36eafdSMike Gerdts  * DESCRIPTION: Construct a long "GpioInt" descriptor
433bc36eafdSMike Gerdts  *
434bc36eafdSMike Gerdts  ******************************************************************************/
435bc36eafdSMike Gerdts 
436bc36eafdSMike Gerdts ASL_RESOURCE_NODE *
RsDoGpioIntDescriptor(ASL_RESOURCE_INFO * Info)437bc36eafdSMike Gerdts RsDoGpioIntDescriptor (
438bc36eafdSMike Gerdts     ASL_RESOURCE_INFO       *Info)
439bc36eafdSMike Gerdts {
440bc36eafdSMike Gerdts     AML_RESOURCE            *Descriptor;
441bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *InitializerOp;
442bc36eafdSMike Gerdts     ASL_RESOURCE_NODE       *Rnode;
443bc36eafdSMike Gerdts     char                    *ResourceSource = NULL;
444bc36eafdSMike Gerdts     UINT8                   *VendorData = NULL;
445bc36eafdSMike Gerdts     UINT16                  *InterruptList = NULL;
446bc36eafdSMike Gerdts     UINT16                  *PinList = NULL;
447bc36eafdSMike Gerdts     UINT16                  ResSourceLength;
448bc36eafdSMike Gerdts     UINT16                  VendorLength;
449bc36eafdSMike Gerdts     UINT16                  InterruptLength;
450bc36eafdSMike Gerdts     UINT16                  DescriptorSize;
451bc36eafdSMike Gerdts     UINT32                  CurrentByteOffset;
452bc36eafdSMike Gerdts     UINT32                  PinCount = 0;
453bc36eafdSMike Gerdts     UINT32                  i;
454bc36eafdSMike Gerdts 
455bc36eafdSMike Gerdts 
456bc36eafdSMike Gerdts     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
457bc36eafdSMike Gerdts     CurrentByteOffset = Info->CurrentByteOffset;
458bc36eafdSMike Gerdts 
459bc36eafdSMike Gerdts     /*
460bc36eafdSMike Gerdts      * Calculate lengths for fields that have variable length:
461bc36eafdSMike Gerdts      * 1) Resource Source string
462bc36eafdSMike Gerdts      * 2) Vendor Data buffer
463bc36eafdSMike Gerdts      * 3) PIN (interrupt) list
464bc36eafdSMike Gerdts      */
465bc36eafdSMike Gerdts     ResSourceLength = RsGetStringDataLength (InitializerOp);
466bc36eafdSMike Gerdts     VendorLength = RsGetBufferDataLength (InitializerOp);
467*35786f68SRobert Mustacchi     InterruptLength = RsGetInterruptDataLength (InitializerOp, 10);
468bc36eafdSMike Gerdts 
469bc36eafdSMike Gerdts     DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_GPIO) +
470bc36eafdSMike Gerdts         ResSourceLength + VendorLength + InterruptLength;
471bc36eafdSMike Gerdts 
472bc36eafdSMike Gerdts     /* Allocate the local resource node and initialize */
473bc36eafdSMike Gerdts 
474bc36eafdSMike Gerdts     Rnode = RsAllocateResourceNode (DescriptorSize +
475bc36eafdSMike Gerdts         sizeof (AML_RESOURCE_LARGE_HEADER));
476bc36eafdSMike Gerdts 
477bc36eafdSMike Gerdts     Descriptor = Rnode->Buffer;
478bc36eafdSMike Gerdts     Descriptor->Gpio.ResourceLength = DescriptorSize;
479bc36eafdSMike Gerdts     Descriptor->Gpio.DescriptorType = ACPI_RESOURCE_NAME_GPIO;
480bc36eafdSMike Gerdts     Descriptor->Gpio.RevisionId = AML_RESOURCE_GPIO_REVISION;
481bc36eafdSMike Gerdts     Descriptor->Gpio.ConnectionType = AML_RESOURCE_GPIO_TYPE_INT;
482bc36eafdSMike Gerdts 
483bc36eafdSMike Gerdts     /* Build pointers to optional areas */
484bc36eafdSMike Gerdts 
485bc36eafdSMike Gerdts     InterruptList = ACPI_ADD_PTR (UINT16, Descriptor,
486bc36eafdSMike Gerdts         sizeof (AML_RESOURCE_GPIO));
487bc36eafdSMike Gerdts     PinList = InterruptList;
488bc36eafdSMike Gerdts     ResourceSource = ACPI_ADD_PTR (char, InterruptList, InterruptLength);
489bc36eafdSMike Gerdts     VendorData = ACPI_ADD_PTR (UINT8, ResourceSource, ResSourceLength);
490bc36eafdSMike Gerdts 
491bc36eafdSMike Gerdts     /* Setup offsets within the descriptor */
492bc36eafdSMike Gerdts 
493bc36eafdSMike Gerdts     Descriptor->Gpio.PinTableOffset = (UINT16)
494bc36eafdSMike Gerdts         ACPI_PTR_DIFF (InterruptList, Descriptor);
495bc36eafdSMike Gerdts 
496bc36eafdSMike Gerdts     Descriptor->Gpio.ResSourceOffset = (UINT16)
497bc36eafdSMike Gerdts         ACPI_PTR_DIFF (ResourceSource, Descriptor);
498bc36eafdSMike Gerdts 
499bc36eafdSMike Gerdts     /* Process all child initialization nodes */
500bc36eafdSMike Gerdts 
501bc36eafdSMike Gerdts     for (i = 0; InitializerOp; i++)
502bc36eafdSMike Gerdts     {
503bc36eafdSMike Gerdts         switch (i)
504bc36eafdSMike Gerdts         {
505bc36eafdSMike Gerdts         case 0: /* Interrupt Mode - edge/level [Flag] (_MOD) */
506bc36eafdSMike Gerdts 
507bc36eafdSMike Gerdts             RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 0, 0);
508bc36eafdSMike Gerdts             RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE,
509bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 0);
510bc36eafdSMike Gerdts             break;
511bc36eafdSMike Gerdts 
512bc36eafdSMike Gerdts         case 1: /* Interrupt Polarity - Active high/low [Flags] (_POL) */
513bc36eafdSMike Gerdts 
514bc36eafdSMike Gerdts             RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 1, 0);
515bc36eafdSMike Gerdts             RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_POLARITY,
516bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 1, 2);
517bc36eafdSMike Gerdts             break;
518bc36eafdSMike Gerdts 
519bc36eafdSMike Gerdts         case 2: /* Share Type - Default: exclusive (0) [Flags] (_SHR) */
520bc36eafdSMike Gerdts 
521bc36eafdSMike Gerdts             RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 3, 0);
522bc36eafdSMike Gerdts             RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
523bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 3, 2);
524bc36eafdSMike Gerdts             break;
525bc36eafdSMike Gerdts 
526bc36eafdSMike Gerdts         case 3: /* Pin Config [BYTE] (_PPI) */
527bc36eafdSMike Gerdts 
528bc36eafdSMike Gerdts             Descriptor->Gpio.PinConfig = (UINT8) InitializerOp->Asl.Value.Integer;
529bc36eafdSMike Gerdts             RsCreateByteField (InitializerOp, ACPI_RESTAG_PINCONFIG,
530bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.PinConfig));
531bc36eafdSMike Gerdts             break;
532bc36eafdSMike Gerdts 
533bc36eafdSMike Gerdts         case 4: /* Debounce Timeout [WORD] (_DBT) */
534bc36eafdSMike Gerdts 
535bc36eafdSMike Gerdts             Descriptor->Gpio.DebounceTimeout = (UINT16) InitializerOp->Asl.Value.Integer;
536bc36eafdSMike Gerdts             RsCreateWordField (InitializerOp, ACPI_RESTAG_DEBOUNCETIME,
537bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.DebounceTimeout));
538bc36eafdSMike Gerdts             break;
539bc36eafdSMike Gerdts 
540bc36eafdSMike Gerdts         case 5: /* ResSource [Optional Field - STRING] */
541bc36eafdSMike Gerdts 
542bc36eafdSMike Gerdts             if (ResSourceLength)
543bc36eafdSMike Gerdts             {
544bc36eafdSMike Gerdts                 /* Copy string to the descriptor */
545bc36eafdSMike Gerdts 
546bc36eafdSMike Gerdts                 strcpy (ResourceSource,
547bc36eafdSMike Gerdts                     InitializerOp->Asl.Value.String);
548bc36eafdSMike Gerdts             }
549bc36eafdSMike Gerdts             break;
550bc36eafdSMike Gerdts 
551bc36eafdSMike Gerdts         case 6: /* Resource Index */
552bc36eafdSMike Gerdts 
553bc36eafdSMike Gerdts             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
554bc36eafdSMike Gerdts             {
555bc36eafdSMike Gerdts                 Descriptor->Gpio.ResSourceIndex =
556bc36eafdSMike Gerdts                     (UINT8) InitializerOp->Asl.Value.Integer;
557bc36eafdSMike Gerdts             }
558bc36eafdSMike Gerdts             break;
559bc36eafdSMike Gerdts 
560bc36eafdSMike Gerdts         case 7: /* Resource Usage (consumer/producer) */
561bc36eafdSMike Gerdts 
562bc36eafdSMike Gerdts             RsSetFlagBits16 (&Descriptor->Gpio.Flags, InitializerOp, 0, 1);
563bc36eafdSMike Gerdts             break;
564bc36eafdSMike Gerdts 
565bc36eafdSMike Gerdts         case 8: /* Resource Tag (Descriptor Name) */
566bc36eafdSMike Gerdts 
567bc36eafdSMike Gerdts             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
568bc36eafdSMike Gerdts             break;
569bc36eafdSMike Gerdts 
570bc36eafdSMike Gerdts         case 9: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */
571bc36eafdSMike Gerdts 
572bc36eafdSMike Gerdts             /*
573bc36eafdSMike Gerdts              * Always set the VendorOffset even if there is no Vendor Data.
574bc36eafdSMike Gerdts              * This field is required in order to calculate the length
575bc36eafdSMike Gerdts              * of the ResourceSource at runtime.
576bc36eafdSMike Gerdts              */
577bc36eafdSMike Gerdts             Descriptor->Gpio.VendorOffset = (UINT16)
578bc36eafdSMike Gerdts                 ACPI_PTR_DIFF (VendorData, Descriptor);
579bc36eafdSMike Gerdts 
580bc36eafdSMike Gerdts             if (RsGetVendorData (InitializerOp, VendorData,
581bc36eafdSMike Gerdts                 (CurrentByteOffset +  Descriptor->Gpio.VendorOffset)))
582bc36eafdSMike Gerdts             {
583bc36eafdSMike Gerdts                 Descriptor->Gpio.VendorLength = VendorLength;
584bc36eafdSMike Gerdts             }
585bc36eafdSMike Gerdts             break;
586bc36eafdSMike Gerdts 
587bc36eafdSMike Gerdts         default:
588bc36eafdSMike Gerdts             /*
589bc36eafdSMike Gerdts              * PINs come through here, repeatedly. Each PIN must be a WORD.
590bc36eafdSMike Gerdts              * NOTE: there is no "length" field for this, so from ACPI spec:
591bc36eafdSMike Gerdts              *  The number of pins in the table can be calculated from:
592bc36eafdSMike Gerdts              *  PinCount = (Resource Source Name Offset - Pin Table Offset) / 2
593bc36eafdSMike Gerdts              *  (implies resource source must immediately follow the pin list.)
594bc36eafdSMike Gerdts              *  Name: _PIN
595bc36eafdSMike Gerdts              */
596bc36eafdSMike Gerdts             *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer;
597bc36eafdSMike Gerdts             InterruptList++;
598bc36eafdSMike Gerdts             PinCount++;
599bc36eafdSMike Gerdts 
600bc36eafdSMike Gerdts             /* Case 10: First interrupt number in list */
601bc36eafdSMike Gerdts 
602bc36eafdSMike Gerdts             if (i == 10)
603bc36eafdSMike Gerdts             {
604bc36eafdSMike Gerdts                 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
605bc36eafdSMike Gerdts                 {
606bc36eafdSMike Gerdts                     /* Must be at least one interrupt */
607bc36eafdSMike Gerdts 
608bc36eafdSMike Gerdts                     AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_LIST_MIN,
609bc36eafdSMike Gerdts                         InitializerOp, NULL);
610bc36eafdSMike Gerdts                 }
611bc36eafdSMike Gerdts 
612bc36eafdSMike Gerdts                 /* Check now for duplicates in list */
613bc36eafdSMike Gerdts 
614bc36eafdSMike Gerdts                 RsCheckListForDuplicates (InitializerOp);
615bc36eafdSMike Gerdts 
616bc36eafdSMike Gerdts                 /* Create a named field at the start of the list */
617bc36eafdSMike Gerdts 
618bc36eafdSMike Gerdts                 RsCreateWordField (InitializerOp, ACPI_RESTAG_PIN,
619bc36eafdSMike Gerdts                     CurrentByteOffset + Descriptor->Gpio.PinTableOffset);
620bc36eafdSMike Gerdts             }
621bc36eafdSMike Gerdts             break;
622bc36eafdSMike Gerdts         }
623bc36eafdSMike Gerdts 
624bc36eafdSMike Gerdts         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
625bc36eafdSMike Gerdts     }
626bc36eafdSMike Gerdts 
627bc36eafdSMike Gerdts     MpSaveGpioInfo (Info->MappingOp, Descriptor,
628bc36eafdSMike Gerdts         PinCount, PinList, ResourceSource);
629bc36eafdSMike Gerdts     return (Rnode);
630bc36eafdSMike Gerdts }
631bc36eafdSMike Gerdts 
632bc36eafdSMike Gerdts 
633bc36eafdSMike Gerdts /*******************************************************************************
634bc36eafdSMike Gerdts  *
635bc36eafdSMike Gerdts  * FUNCTION:    RsDoGpioIoDescriptor
636bc36eafdSMike Gerdts  *
637bc36eafdSMike Gerdts  * PARAMETERS:  Info                - Parse Op and resource template offset
638bc36eafdSMike Gerdts  *
639bc36eafdSMike Gerdts  * RETURN:      Completed resource node
640bc36eafdSMike Gerdts  *
641bc36eafdSMike Gerdts  * DESCRIPTION: Construct a long "GpioIo" descriptor
642bc36eafdSMike Gerdts  *
643bc36eafdSMike Gerdts  ******************************************************************************/
644bc36eafdSMike Gerdts 
645bc36eafdSMike Gerdts ASL_RESOURCE_NODE *
RsDoGpioIoDescriptor(ASL_RESOURCE_INFO * Info)646bc36eafdSMike Gerdts RsDoGpioIoDescriptor (
647bc36eafdSMike Gerdts     ASL_RESOURCE_INFO       *Info)
648bc36eafdSMike Gerdts {
649bc36eafdSMike Gerdts     AML_RESOURCE            *Descriptor;
650bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *InitializerOp;
651bc36eafdSMike Gerdts     ASL_RESOURCE_NODE       *Rnode;
652bc36eafdSMike Gerdts     char                    *ResourceSource = NULL;
653bc36eafdSMike Gerdts     UINT8                   *VendorData = NULL;
654bc36eafdSMike Gerdts     UINT16                  *InterruptList = NULL;
655bc36eafdSMike Gerdts     UINT16                  *PinList = NULL;
656bc36eafdSMike Gerdts     UINT16                  ResSourceLength;
657bc36eafdSMike Gerdts     UINT16                  VendorLength;
658bc36eafdSMike Gerdts     UINT16                  InterruptLength;
659bc36eafdSMike Gerdts     UINT16                  DescriptorSize;
660bc36eafdSMike Gerdts     UINT32                  CurrentByteOffset;
661bc36eafdSMike Gerdts     UINT32                  PinCount = 0;
662bc36eafdSMike Gerdts     UINT32                  i;
663bc36eafdSMike Gerdts 
664bc36eafdSMike Gerdts 
665bc36eafdSMike Gerdts     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
666bc36eafdSMike Gerdts     CurrentByteOffset = Info->CurrentByteOffset;
667bc36eafdSMike Gerdts 
668bc36eafdSMike Gerdts     /*
669bc36eafdSMike Gerdts      * Calculate lengths for fields that have variable length:
670bc36eafdSMike Gerdts      * 1) Resource Source string
671bc36eafdSMike Gerdts      * 2) Vendor Data buffer
672bc36eafdSMike Gerdts      * 3) PIN (interrupt) list
673bc36eafdSMike Gerdts      */
674bc36eafdSMike Gerdts     ResSourceLength = RsGetStringDataLength (InitializerOp);
675bc36eafdSMike Gerdts     VendorLength = RsGetBufferDataLength (InitializerOp);
676*35786f68SRobert Mustacchi     InterruptLength = RsGetInterruptDataLength (InitializerOp, 10);
677bc36eafdSMike Gerdts     PinList = InterruptList;
678bc36eafdSMike Gerdts 
679bc36eafdSMike Gerdts     DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_GPIO) +
680bc36eafdSMike Gerdts         ResSourceLength + VendorLength + InterruptLength;
681bc36eafdSMike Gerdts 
682bc36eafdSMike Gerdts     /* Allocate the local resource node and initialize */
683bc36eafdSMike Gerdts 
684bc36eafdSMike Gerdts     Rnode = RsAllocateResourceNode (DescriptorSize +
685bc36eafdSMike Gerdts         sizeof (AML_RESOURCE_LARGE_HEADER));
686bc36eafdSMike Gerdts 
687bc36eafdSMike Gerdts     Descriptor = Rnode->Buffer;
688bc36eafdSMike Gerdts     Descriptor->Gpio.ResourceLength = DescriptorSize;
689bc36eafdSMike Gerdts     Descriptor->Gpio.DescriptorType = ACPI_RESOURCE_NAME_GPIO;
690bc36eafdSMike Gerdts     Descriptor->Gpio.RevisionId = AML_RESOURCE_GPIO_REVISION;
691bc36eafdSMike Gerdts     Descriptor->Gpio.ConnectionType = AML_RESOURCE_GPIO_TYPE_IO;
692bc36eafdSMike Gerdts 
693bc36eafdSMike Gerdts     /* Build pointers to optional areas */
694bc36eafdSMike Gerdts 
695bc36eafdSMike Gerdts     InterruptList = ACPI_ADD_PTR (UINT16, Descriptor, sizeof (AML_RESOURCE_GPIO));
696bc36eafdSMike Gerdts     PinList = InterruptList;
697bc36eafdSMike Gerdts     ResourceSource = ACPI_ADD_PTR (char, InterruptList, InterruptLength);
698bc36eafdSMike Gerdts     VendorData = ACPI_ADD_PTR (UINT8, ResourceSource, ResSourceLength);
699bc36eafdSMike Gerdts 
700bc36eafdSMike Gerdts     /* Setup offsets within the descriptor */
701bc36eafdSMike Gerdts 
702bc36eafdSMike Gerdts     Descriptor->Gpio.PinTableOffset = (UINT16)
703bc36eafdSMike Gerdts         ACPI_PTR_DIFF (InterruptList, Descriptor);
704bc36eafdSMike Gerdts 
705bc36eafdSMike Gerdts     Descriptor->Gpio.ResSourceOffset = (UINT16)
706bc36eafdSMike Gerdts         ACPI_PTR_DIFF (ResourceSource, Descriptor);
707bc36eafdSMike Gerdts 
708bc36eafdSMike Gerdts     /* Process all child initialization nodes */
709bc36eafdSMike Gerdts 
710bc36eafdSMike Gerdts     for (i = 0; InitializerOp; i++)
711bc36eafdSMike Gerdts     {
712bc36eafdSMike Gerdts         switch (i)
713bc36eafdSMike Gerdts         {
714bc36eafdSMike Gerdts         case 0: /* Share Type [Flags] (_SHR) */
715bc36eafdSMike Gerdts 
716bc36eafdSMike Gerdts             RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 3, 0);
717bc36eafdSMike Gerdts             RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
718bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 3);
719bc36eafdSMike Gerdts             break;
720bc36eafdSMike Gerdts 
721bc36eafdSMike Gerdts         case 1: /* Pin Config [BYTE] (_PPI) */
722bc36eafdSMike Gerdts 
723bc36eafdSMike Gerdts             Descriptor->Gpio.PinConfig = (UINT8) InitializerOp->Asl.Value.Integer;
724bc36eafdSMike Gerdts             RsCreateByteField (InitializerOp, ACPI_RESTAG_PINCONFIG,
725bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.PinConfig));
726bc36eafdSMike Gerdts             break;
727bc36eafdSMike Gerdts 
728bc36eafdSMike Gerdts         case 2: /* Debounce Timeout [WORD] (_DBT) */
729bc36eafdSMike Gerdts 
730bc36eafdSMike Gerdts             Descriptor->Gpio.DebounceTimeout = (UINT16) InitializerOp->Asl.Value.Integer;
731bc36eafdSMike Gerdts             RsCreateWordField (InitializerOp, ACPI_RESTAG_DEBOUNCETIME,
732bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.DebounceTimeout));
733bc36eafdSMike Gerdts             break;
734bc36eafdSMike Gerdts 
735bc36eafdSMike Gerdts         case 3: /* Drive Strength [WORD] (_DRS) */
736bc36eafdSMike Gerdts 
737bc36eafdSMike Gerdts             Descriptor->Gpio.DriveStrength = (UINT16) InitializerOp->Asl.Value.Integer;
738bc36eafdSMike Gerdts             RsCreateWordField (InitializerOp, ACPI_RESTAG_DRIVESTRENGTH,
739bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.DriveStrength));
740bc36eafdSMike Gerdts             break;
741bc36eafdSMike Gerdts 
742bc36eafdSMike Gerdts         case 4: /* I/O Restriction [Flag] (_IOR) */
743bc36eafdSMike Gerdts 
744bc36eafdSMike Gerdts             RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 0, 0);
745bc36eafdSMike Gerdts             RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_IORESTRICTION,
746bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 0, 2);
747bc36eafdSMike Gerdts             break;
748bc36eafdSMike Gerdts 
749bc36eafdSMike Gerdts         case 5: /* ResSource [Optional Field - STRING] */
750bc36eafdSMike Gerdts 
751bc36eafdSMike Gerdts             if (ResSourceLength)
752bc36eafdSMike Gerdts             {
753bc36eafdSMike Gerdts                 /* Copy string to the descriptor */
754bc36eafdSMike Gerdts 
755bc36eafdSMike Gerdts                 strcpy (ResourceSource,
756bc36eafdSMike Gerdts                     InitializerOp->Asl.Value.String);
757bc36eafdSMike Gerdts             }
758bc36eafdSMike Gerdts             break;
759bc36eafdSMike Gerdts 
760bc36eafdSMike Gerdts         case 6: /* Resource Index */
761bc36eafdSMike Gerdts 
762bc36eafdSMike Gerdts             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
763bc36eafdSMike Gerdts             {
764bc36eafdSMike Gerdts                 Descriptor->Gpio.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer;
765bc36eafdSMike Gerdts             }
766bc36eafdSMike Gerdts             break;
767bc36eafdSMike Gerdts 
768bc36eafdSMike Gerdts         case 7: /* Resource Usage (consumer/producer) */
769bc36eafdSMike Gerdts 
770bc36eafdSMike Gerdts             RsSetFlagBits16 (&Descriptor->Gpio.Flags, InitializerOp, 0, 1);
771bc36eafdSMike Gerdts             break;
772bc36eafdSMike Gerdts 
773bc36eafdSMike Gerdts         case 8: /* Resource Tag (Descriptor Name) */
774bc36eafdSMike Gerdts 
775bc36eafdSMike Gerdts             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
776bc36eafdSMike Gerdts             break;
777bc36eafdSMike Gerdts 
778bc36eafdSMike Gerdts         case 9: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */
779bc36eafdSMike Gerdts             /*
780bc36eafdSMike Gerdts              * Always set the VendorOffset even if there is no Vendor Data.
781bc36eafdSMike Gerdts              * This field is required in order to calculate the length
782bc36eafdSMike Gerdts              * of the ResourceSource at runtime.
783bc36eafdSMike Gerdts              */
784bc36eafdSMike Gerdts             Descriptor->Gpio.VendorOffset = (UINT16)
785bc36eafdSMike Gerdts                 ACPI_PTR_DIFF (VendorData, Descriptor);
786bc36eafdSMike Gerdts 
787bc36eafdSMike Gerdts             if (RsGetVendorData (InitializerOp, VendorData,
788bc36eafdSMike Gerdts                 (CurrentByteOffset + Descriptor->Gpio.VendorOffset)))
789bc36eafdSMike Gerdts             {
790bc36eafdSMike Gerdts                 Descriptor->Gpio.VendorLength = VendorLength;
791bc36eafdSMike Gerdts             }
792bc36eafdSMike Gerdts             break;
793bc36eafdSMike Gerdts 
794bc36eafdSMike Gerdts         default:
795bc36eafdSMike Gerdts             /*
796bc36eafdSMike Gerdts              * PINs come through here, repeatedly. Each PIN must be a WORD.
797bc36eafdSMike Gerdts              * NOTE: there is no "length" field for this, so from ACPI spec:
798bc36eafdSMike Gerdts              *  The number of pins in the table can be calculated from:
799bc36eafdSMike Gerdts              *  PinCount = (Resource Source Name Offset - Pin Table Offset) / 2
800bc36eafdSMike Gerdts              *  (implies resource source must immediately follow the pin list.)
801bc36eafdSMike Gerdts              *  Name: _PIN
802bc36eafdSMike Gerdts              */
803bc36eafdSMike Gerdts             *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer;
804bc36eafdSMike Gerdts             InterruptList++;
805bc36eafdSMike Gerdts             PinCount++;
806bc36eafdSMike Gerdts 
807bc36eafdSMike Gerdts             /* Case 10: First interrupt number in list */
808bc36eafdSMike Gerdts 
809bc36eafdSMike Gerdts             if (i == 10)
810bc36eafdSMike Gerdts             {
811bc36eafdSMike Gerdts                 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
812bc36eafdSMike Gerdts                 {
813bc36eafdSMike Gerdts                     /* Must be at least one interrupt */
814bc36eafdSMike Gerdts 
815bc36eafdSMike Gerdts                     AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_LIST_MIN,
816bc36eafdSMike Gerdts                         InitializerOp, NULL);
817bc36eafdSMike Gerdts                 }
818bc36eafdSMike Gerdts 
819bc36eafdSMike Gerdts                 /* Check now for duplicates in list */
820bc36eafdSMike Gerdts 
821bc36eafdSMike Gerdts                 RsCheckListForDuplicates (InitializerOp);
822bc36eafdSMike Gerdts 
823bc36eafdSMike Gerdts                 /* Create a named field at the start of the list */
824bc36eafdSMike Gerdts 
825bc36eafdSMike Gerdts                 RsCreateWordField (InitializerOp, ACPI_RESTAG_PIN,
826bc36eafdSMike Gerdts                     CurrentByteOffset + Descriptor->Gpio.PinTableOffset);
827bc36eafdSMike Gerdts             }
828bc36eafdSMike Gerdts             break;
829bc36eafdSMike Gerdts         }
830bc36eafdSMike Gerdts 
831bc36eafdSMike Gerdts         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
832bc36eafdSMike Gerdts     }
833bc36eafdSMike Gerdts 
834bc36eafdSMike Gerdts     MpSaveGpioInfo (Info->MappingOp, Descriptor,
835bc36eafdSMike Gerdts         PinCount, PinList, ResourceSource);
836bc36eafdSMike Gerdts     return (Rnode);
837bc36eafdSMike Gerdts }
838bc36eafdSMike Gerdts 
839bc36eafdSMike Gerdts 
840bc36eafdSMike Gerdts /*******************************************************************************
841bc36eafdSMike Gerdts  *
842bc36eafdSMike Gerdts  * FUNCTION:    RsDoI2cSerialBusDescriptor
843bc36eafdSMike Gerdts  *
844bc36eafdSMike Gerdts  * PARAMETERS:  Info                - Parse Op and resource template offset
845bc36eafdSMike Gerdts  *
846bc36eafdSMike Gerdts  * RETURN:      Completed resource node
847bc36eafdSMike Gerdts  *
848bc36eafdSMike Gerdts  * DESCRIPTION: Construct a long "I2cSerialBus" descriptor
849bc36eafdSMike Gerdts  *
850bc36eafdSMike Gerdts  ******************************************************************************/
851bc36eafdSMike Gerdts 
852bc36eafdSMike Gerdts ASL_RESOURCE_NODE *
RsDoI2cSerialBusDescriptor(ASL_RESOURCE_INFO * Info)853bc36eafdSMike Gerdts RsDoI2cSerialBusDescriptor (
854bc36eafdSMike Gerdts     ASL_RESOURCE_INFO       *Info)
855bc36eafdSMike Gerdts {
856bc36eafdSMike Gerdts     AML_RESOURCE            *Descriptor;
857bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *InitializerOp;
858bc36eafdSMike Gerdts     ASL_RESOURCE_NODE       *Rnode;
859bc36eafdSMike Gerdts     char                    *ResourceSource = NULL;
860bc36eafdSMike Gerdts     UINT8                   *VendorData = NULL;
861bc36eafdSMike Gerdts     UINT16                  ResSourceLength;
862bc36eafdSMike Gerdts     UINT16                  VendorLength;
863bc36eafdSMike Gerdts     UINT16                  DescriptorSize;
864bc36eafdSMike Gerdts     UINT32                  CurrentByteOffset;
865bc36eafdSMike Gerdts     UINT32                  i;
866bc36eafdSMike Gerdts 
867bc36eafdSMike Gerdts 
868bc36eafdSMike Gerdts     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
869bc36eafdSMike Gerdts     CurrentByteOffset = Info->CurrentByteOffset;
870bc36eafdSMike Gerdts 
871bc36eafdSMike Gerdts     /*
872bc36eafdSMike Gerdts      * Calculate lengths for fields that have variable length:
873bc36eafdSMike Gerdts      * 1) Resource Source string
874bc36eafdSMike Gerdts      * 2) Vendor Data buffer
875bc36eafdSMike Gerdts      */
876bc36eafdSMike Gerdts     ResSourceLength = RsGetStringDataLength (InitializerOp);
877bc36eafdSMike Gerdts     VendorLength = RsGetBufferDataLength (InitializerOp);
878bc36eafdSMike Gerdts 
879bc36eafdSMike Gerdts     DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_I2C_SERIALBUS) +
880bc36eafdSMike Gerdts         ResSourceLength + VendorLength;
881bc36eafdSMike Gerdts 
882bc36eafdSMike Gerdts     /* Allocate the local resource node and initialize */
883bc36eafdSMike Gerdts 
884bc36eafdSMike Gerdts     Rnode = RsAllocateResourceNode (DescriptorSize +
885bc36eafdSMike Gerdts         sizeof (AML_RESOURCE_LARGE_HEADER));
886bc36eafdSMike Gerdts 
887bc36eafdSMike Gerdts     Descriptor = Rnode->Buffer;
888bc36eafdSMike Gerdts     Descriptor->I2cSerialBus.ResourceLength = DescriptorSize;
889bc36eafdSMike Gerdts     Descriptor->I2cSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS;
890bc36eafdSMike Gerdts     Descriptor->I2cSerialBus.RevisionId = AML_RESOURCE_I2C_REVISION;
891bc36eafdSMike Gerdts     Descriptor->I2cSerialBus.TypeRevisionId = AML_RESOURCE_I2C_TYPE_REVISION;
892bc36eafdSMike Gerdts     Descriptor->I2cSerialBus.Type = AML_RESOURCE_I2C_SERIALBUSTYPE;
893bc36eafdSMike Gerdts     Descriptor->I2cSerialBus.TypeDataLength = AML_RESOURCE_I2C_MIN_DATA_LEN + VendorLength;
894bc36eafdSMike Gerdts 
895bc36eafdSMike Gerdts     if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_I2C_SERIALBUS_V2)
896bc36eafdSMike Gerdts     {
897bc36eafdSMike Gerdts         Descriptor->I2cSerialBus.RevisionId = 2;
898bc36eafdSMike Gerdts     }
899bc36eafdSMike Gerdts 
900bc36eafdSMike Gerdts     /* Build pointers to optional areas */
901bc36eafdSMike Gerdts 
902bc36eafdSMike Gerdts     VendorData = ACPI_ADD_PTR (UINT8, Descriptor, sizeof (AML_RESOURCE_I2C_SERIALBUS));
903bc36eafdSMike Gerdts     ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength);
904bc36eafdSMike Gerdts 
905bc36eafdSMike Gerdts     /* Process all child initialization nodes */
906bc36eafdSMike Gerdts 
907bc36eafdSMike Gerdts     for (i = 0; InitializerOp; i++)
908bc36eafdSMike Gerdts     {
909bc36eafdSMike Gerdts         switch (i)
910bc36eafdSMike Gerdts         {
911bc36eafdSMike Gerdts         case 0: /* Slave Address [WORD] (_ADR) */
912bc36eafdSMike Gerdts 
913bc36eafdSMike Gerdts             Descriptor->I2cSerialBus.SlaveAddress = (UINT16) InitializerOp->Asl.Value.Integer;
914bc36eafdSMike Gerdts             RsCreateWordField (InitializerOp, ACPI_RESTAG_ADDRESS,
915bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.SlaveAddress));
916bc36eafdSMike Gerdts             break;
917bc36eafdSMike Gerdts 
918bc36eafdSMike Gerdts         case 1: /* Slave Mode [Flag] (_SLV) */
919bc36eafdSMike Gerdts 
920bc36eafdSMike Gerdts             RsSetFlagBits (&Descriptor->I2cSerialBus.Flags, InitializerOp, 0, 0);
921bc36eafdSMike Gerdts             RsCreateBitField (InitializerOp, ACPI_RESTAG_SLAVEMODE,
922bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.Flags), 0);
923bc36eafdSMike Gerdts             break;
924bc36eafdSMike Gerdts 
925bc36eafdSMike Gerdts         case 2: /* Connection Speed [DWORD] (_SPE) */
926bc36eafdSMike Gerdts 
927bc36eafdSMike Gerdts             Descriptor->I2cSerialBus.ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer;
928bc36eafdSMike Gerdts             RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
929bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.ConnectionSpeed));
930bc36eafdSMike Gerdts             break;
931bc36eafdSMike Gerdts 
932bc36eafdSMike Gerdts         case 3: /* Addressing Mode [Flag] (_MOD) */
933bc36eafdSMike Gerdts 
934bc36eafdSMike Gerdts             RsSetFlagBits16 (&Descriptor->I2cSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
935bc36eafdSMike Gerdts             RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE,
936bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.TypeSpecificFlags), 0);
937bc36eafdSMike Gerdts             break;
938bc36eafdSMike Gerdts 
939bc36eafdSMike Gerdts         case 4: /* ResSource [Optional Field - STRING] */
940bc36eafdSMike Gerdts 
941bc36eafdSMike Gerdts             if (ResSourceLength)
942bc36eafdSMike Gerdts             {
943bc36eafdSMike Gerdts                 /* Copy string to the descriptor */
944bc36eafdSMike Gerdts 
945bc36eafdSMike Gerdts                 strcpy (ResourceSource,
946bc36eafdSMike Gerdts                     InitializerOp->Asl.Value.String);
947bc36eafdSMike Gerdts             }
948bc36eafdSMike Gerdts             break;
949bc36eafdSMike Gerdts 
950bc36eafdSMike Gerdts         case 5: /* Resource Index */
951bc36eafdSMike Gerdts 
952bc36eafdSMike Gerdts             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
953bc36eafdSMike Gerdts             {
954bc36eafdSMike Gerdts                 Descriptor->I2cSerialBus.ResSourceIndex =
955bc36eafdSMike Gerdts                     (UINT8) InitializerOp->Asl.Value.Integer;
956bc36eafdSMike Gerdts             }
957bc36eafdSMike Gerdts             break;
958bc36eafdSMike Gerdts 
959bc36eafdSMike Gerdts         case 6: /* Resource Usage (consumer/producer) */
960bc36eafdSMike Gerdts 
961bc36eafdSMike Gerdts             RsSetFlagBits (&Descriptor->I2cSerialBus.Flags, InitializerOp, 1, 1);
962bc36eafdSMike Gerdts             break;
963bc36eafdSMike Gerdts 
964bc36eafdSMike Gerdts         case 7: /* Resource Tag (Descriptor Name) */
965bc36eafdSMike Gerdts 
966bc36eafdSMike Gerdts             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
967bc36eafdSMike Gerdts             break;
968bc36eafdSMike Gerdts 
969bc36eafdSMike Gerdts         case 8:
970bc36eafdSMike Gerdts             /*
971bc36eafdSMike Gerdts              * Connection Share - Added for V2 (ACPI 6.0) version of the descriptor
972bc36eafdSMike Gerdts              * Note: For V1, the share bit will be zero (Op is DEFAULT_ARG from
973bc36eafdSMike Gerdts              * the ASL parser)
974bc36eafdSMike Gerdts              */
975bc36eafdSMike Gerdts             RsSetFlagBits (&Descriptor->I2cSerialBus.Flags, InitializerOp, 2, 0);
976bc36eafdSMike Gerdts             RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
977bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.Flags), 2);
978bc36eafdSMike Gerdts             break;
979bc36eafdSMike Gerdts 
980bc36eafdSMike Gerdts         case 9: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */
981bc36eafdSMike Gerdts 
982bc36eafdSMike Gerdts             RsGetVendorData (InitializerOp, VendorData,
983bc36eafdSMike Gerdts                 CurrentByteOffset + sizeof (AML_RESOURCE_I2C_SERIALBUS));
984bc36eafdSMike Gerdts             break;
985bc36eafdSMike Gerdts 
986bc36eafdSMike Gerdts         default:    /* Ignore any extra nodes */
987bc36eafdSMike Gerdts 
988bc36eafdSMike Gerdts             break;
989bc36eafdSMike Gerdts         }
990bc36eafdSMike Gerdts 
991bc36eafdSMike Gerdts         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
992bc36eafdSMike Gerdts     }
993bc36eafdSMike Gerdts 
994bc36eafdSMike Gerdts     MpSaveSerialInfo (Info->MappingOp, Descriptor, ResourceSource);
995bc36eafdSMike Gerdts     return (Rnode);
996bc36eafdSMike Gerdts }
997bc36eafdSMike Gerdts 
998bc36eafdSMike Gerdts 
999bc36eafdSMike Gerdts /*******************************************************************************
1000bc36eafdSMike Gerdts  *
1001bc36eafdSMike Gerdts  * FUNCTION:    RsDoSpiSerialBusDescriptor
1002bc36eafdSMike Gerdts  *
1003bc36eafdSMike Gerdts  * PARAMETERS:  Info                - Parse Op and resource template offset
1004bc36eafdSMike Gerdts  *
1005bc36eafdSMike Gerdts  * RETURN:      Completed resource node
1006bc36eafdSMike Gerdts  *
1007bc36eafdSMike Gerdts  * DESCRIPTION: Construct a long "SPI Serial Bus" descriptor
1008bc36eafdSMike Gerdts  *
1009bc36eafdSMike Gerdts  ******************************************************************************/
1010bc36eafdSMike Gerdts 
1011bc36eafdSMike Gerdts ASL_RESOURCE_NODE *
RsDoSpiSerialBusDescriptor(ASL_RESOURCE_INFO * Info)1012bc36eafdSMike Gerdts RsDoSpiSerialBusDescriptor (
1013bc36eafdSMike Gerdts     ASL_RESOURCE_INFO       *Info)
1014bc36eafdSMike Gerdts {
1015bc36eafdSMike Gerdts     AML_RESOURCE            *Descriptor;
1016bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *InitializerOp;
1017bc36eafdSMike Gerdts     ASL_RESOURCE_NODE       *Rnode;
1018bc36eafdSMike Gerdts     char                    *ResourceSource = NULL;
1019bc36eafdSMike Gerdts     UINT8                   *VendorData = NULL;
1020bc36eafdSMike Gerdts     UINT16                  ResSourceLength;
1021bc36eafdSMike Gerdts     UINT16                  VendorLength;
1022bc36eafdSMike Gerdts     UINT16                  DescriptorSize;
1023bc36eafdSMike Gerdts     UINT32                  CurrentByteOffset;
1024bc36eafdSMike Gerdts     UINT32                  i;
1025bc36eafdSMike Gerdts 
1026bc36eafdSMike Gerdts 
1027bc36eafdSMike Gerdts     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
1028bc36eafdSMike Gerdts     CurrentByteOffset = Info->CurrentByteOffset;
1029bc36eafdSMike Gerdts 
1030bc36eafdSMike Gerdts     /*
1031bc36eafdSMike Gerdts      * Calculate lengths for fields that have variable length:
1032bc36eafdSMike Gerdts      * 1) Resource Source string
1033bc36eafdSMike Gerdts      * 2) Vendor Data buffer
1034bc36eafdSMike Gerdts      */
1035bc36eafdSMike Gerdts     ResSourceLength = RsGetStringDataLength (InitializerOp);
1036bc36eafdSMike Gerdts     VendorLength = RsGetBufferDataLength (InitializerOp);
1037bc36eafdSMike Gerdts 
1038bc36eafdSMike Gerdts     DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_SPI_SERIALBUS) +
1039bc36eafdSMike Gerdts         ResSourceLength + VendorLength;
1040bc36eafdSMike Gerdts 
1041bc36eafdSMike Gerdts     /* Allocate the local resource node and initialize */
1042bc36eafdSMike Gerdts 
1043bc36eafdSMike Gerdts     Rnode = RsAllocateResourceNode (DescriptorSize +
1044bc36eafdSMike Gerdts         sizeof (AML_RESOURCE_LARGE_HEADER));
1045bc36eafdSMike Gerdts 
1046bc36eafdSMike Gerdts     Descriptor = Rnode->Buffer;
1047bc36eafdSMike Gerdts     Descriptor->SpiSerialBus.ResourceLength = DescriptorSize;
1048bc36eafdSMike Gerdts     Descriptor->SpiSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS;
1049bc36eafdSMike Gerdts     Descriptor->SpiSerialBus.RevisionId = AML_RESOURCE_SPI_REVISION;
1050bc36eafdSMike Gerdts     Descriptor->SpiSerialBus.TypeRevisionId = AML_RESOURCE_SPI_TYPE_REVISION;
1051bc36eafdSMike Gerdts     Descriptor->SpiSerialBus.Type = AML_RESOURCE_SPI_SERIALBUSTYPE;
1052bc36eafdSMike Gerdts     Descriptor->SpiSerialBus.TypeDataLength = AML_RESOURCE_SPI_MIN_DATA_LEN + VendorLength;
1053bc36eafdSMike Gerdts 
1054bc36eafdSMike Gerdts     if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_SPI_SERIALBUS_V2)
1055bc36eafdSMike Gerdts     {
1056bc36eafdSMike Gerdts         Descriptor->I2cSerialBus.RevisionId = 2;
1057bc36eafdSMike Gerdts     }
1058bc36eafdSMike Gerdts 
1059bc36eafdSMike Gerdts     /* Build pointers to optional areas */
1060bc36eafdSMike Gerdts 
1061bc36eafdSMike Gerdts     VendorData = ACPI_ADD_PTR (UINT8, Descriptor,
1062bc36eafdSMike Gerdts         sizeof (AML_RESOURCE_SPI_SERIALBUS));
1063bc36eafdSMike Gerdts     ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength);
1064bc36eafdSMike Gerdts 
1065bc36eafdSMike Gerdts     /* Process all child initialization nodes */
1066bc36eafdSMike Gerdts 
1067bc36eafdSMike Gerdts     for (i = 0; InitializerOp; i++)
1068bc36eafdSMike Gerdts     {
1069bc36eafdSMike Gerdts         switch (i)
1070bc36eafdSMike Gerdts         {
1071bc36eafdSMike Gerdts         case 0: /* Device Selection [WORD] (_ADR) */
1072bc36eafdSMike Gerdts 
1073bc36eafdSMike Gerdts             Descriptor->SpiSerialBus.DeviceSelection = (UINT16) InitializerOp->Asl.Value.Integer;
1074bc36eafdSMike Gerdts             RsCreateWordField (InitializerOp, ACPI_RESTAG_ADDRESS,
1075bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.DeviceSelection));
1076bc36eafdSMike Gerdts             break;
1077bc36eafdSMike Gerdts 
1078bc36eafdSMike Gerdts         case 1: /* Device Polarity [Flag] (_DPL) */
1079bc36eafdSMike Gerdts 
1080bc36eafdSMike Gerdts             RsSetFlagBits16 (&Descriptor->SpiSerialBus.TypeSpecificFlags, InitializerOp, 1, 0);
1081bc36eafdSMike Gerdts             RsCreateBitField (InitializerOp, ACPI_RESTAG_DEVICEPOLARITY,
1082bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.TypeSpecificFlags), 1);
1083bc36eafdSMike Gerdts             break;
1084bc36eafdSMike Gerdts 
1085bc36eafdSMike Gerdts         case 2: /* Wire Mode [Flag] (_MOD) */
1086bc36eafdSMike Gerdts 
1087bc36eafdSMike Gerdts             RsSetFlagBits16 (&Descriptor->SpiSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
1088bc36eafdSMike Gerdts             RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE,
1089bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.TypeSpecificFlags), 0);
1090bc36eafdSMike Gerdts             break;
1091bc36eafdSMike Gerdts 
1092bc36eafdSMike Gerdts         case 3: /* Device Bit Length [BYTE] (_LEN) */
1093bc36eafdSMike Gerdts 
1094bc36eafdSMike Gerdts             Descriptor->SpiSerialBus.DataBitLength = (UINT8) InitializerOp->Asl.Value.Integer;
1095bc36eafdSMike Gerdts             RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
1096bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.DataBitLength));
1097bc36eafdSMike Gerdts             break;
1098bc36eafdSMike Gerdts 
1099bc36eafdSMike Gerdts         case 4: /* Slave Mode [Flag] (_SLV) */
1100bc36eafdSMike Gerdts 
1101bc36eafdSMike Gerdts             RsSetFlagBits (&Descriptor->SpiSerialBus.Flags, InitializerOp, 0, 0);
1102bc36eafdSMike Gerdts             RsCreateBitField (InitializerOp, ACPI_RESTAG_SLAVEMODE,
1103bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.Flags), 0);
1104bc36eafdSMike Gerdts             break;
1105bc36eafdSMike Gerdts 
1106bc36eafdSMike Gerdts         case 5: /* Connection Speed [DWORD] (_SPE) */
1107bc36eafdSMike Gerdts 
1108bc36eafdSMike Gerdts             Descriptor->SpiSerialBus.ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer;
1109bc36eafdSMike Gerdts             RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
1110bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.ConnectionSpeed));
1111bc36eafdSMike Gerdts             break;
1112bc36eafdSMike Gerdts 
1113bc36eafdSMike Gerdts         case 6: /* Clock Polarity [BYTE] (_POL) */
1114bc36eafdSMike Gerdts 
1115bc36eafdSMike Gerdts             Descriptor->SpiSerialBus.ClockPolarity = (UINT8) InitializerOp->Asl.Value.Integer;
1116bc36eafdSMike Gerdts             RsCreateByteField (InitializerOp, ACPI_RESTAG_POLARITY,
1117bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.ClockPolarity));
1118bc36eafdSMike Gerdts             break;
1119bc36eafdSMike Gerdts 
1120bc36eafdSMike Gerdts         case 7: /* Clock Phase [BYTE] (_PHA) */
1121bc36eafdSMike Gerdts 
1122bc36eafdSMike Gerdts             Descriptor->SpiSerialBus.ClockPhase = (UINT8) InitializerOp->Asl.Value.Integer;
1123bc36eafdSMike Gerdts             RsCreateByteField (InitializerOp, ACPI_RESTAG_PHASE,
1124bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.ClockPhase));
1125bc36eafdSMike Gerdts             break;
1126bc36eafdSMike Gerdts 
1127bc36eafdSMike Gerdts         case 8: /* ResSource [Optional Field - STRING] */
1128bc36eafdSMike Gerdts 
1129bc36eafdSMike Gerdts             if (ResSourceLength)
1130bc36eafdSMike Gerdts             {
1131bc36eafdSMike Gerdts                 /* Copy string to the descriptor */
1132bc36eafdSMike Gerdts 
1133bc36eafdSMike Gerdts                 strcpy (ResourceSource,
1134bc36eafdSMike Gerdts                     InitializerOp->Asl.Value.String);
1135bc36eafdSMike Gerdts             }
1136bc36eafdSMike Gerdts             break;
1137bc36eafdSMike Gerdts 
1138bc36eafdSMike Gerdts         case 9: /* Resource Index */
1139bc36eafdSMike Gerdts 
1140bc36eafdSMike Gerdts             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
1141bc36eafdSMike Gerdts             {
1142bc36eafdSMike Gerdts                 Descriptor->SpiSerialBus.ResSourceIndex =
1143bc36eafdSMike Gerdts                     (UINT8) InitializerOp->Asl.Value.Integer;
1144bc36eafdSMike Gerdts             }
1145bc36eafdSMike Gerdts             break;
1146bc36eafdSMike Gerdts 
1147bc36eafdSMike Gerdts         case 10: /* Resource Usage (consumer/producer) */
1148bc36eafdSMike Gerdts 
1149bc36eafdSMike Gerdts             RsSetFlagBits (&Descriptor->SpiSerialBus.Flags, InitializerOp, 1, 1);
1150bc36eafdSMike Gerdts             break;
1151bc36eafdSMike Gerdts 
1152bc36eafdSMike Gerdts         case 11: /* Resource Tag (Descriptor Name) */
1153bc36eafdSMike Gerdts 
1154bc36eafdSMike Gerdts             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
1155bc36eafdSMike Gerdts             break;
1156bc36eafdSMike Gerdts 
1157bc36eafdSMike Gerdts         case 12:
1158bc36eafdSMike Gerdts             /*
1159bc36eafdSMike Gerdts              * Connection Share - Added for V2 (ACPI 6.0) version of the descriptor
1160bc36eafdSMike Gerdts              * Note: For V1, the share bit will be zero (Op is DEFAULT_ARG from
1161bc36eafdSMike Gerdts              * the ASL parser)
1162bc36eafdSMike Gerdts              */
1163bc36eafdSMike Gerdts             RsSetFlagBits (&Descriptor->SpiSerialBus.Flags, InitializerOp, 2, 0);
1164bc36eafdSMike Gerdts             RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
1165bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.Flags), 2);
1166bc36eafdSMike Gerdts             break;
1167bc36eafdSMike Gerdts 
1168bc36eafdSMike Gerdts         case 13: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */
1169bc36eafdSMike Gerdts 
1170bc36eafdSMike Gerdts             RsGetVendorData (InitializerOp, VendorData,
1171bc36eafdSMike Gerdts                 CurrentByteOffset + sizeof (AML_RESOURCE_SPI_SERIALBUS));
1172bc36eafdSMike Gerdts             break;
1173bc36eafdSMike Gerdts 
1174bc36eafdSMike Gerdts         default:    /* Ignore any extra nodes */
1175bc36eafdSMike Gerdts 
1176bc36eafdSMike Gerdts             break;
1177bc36eafdSMike Gerdts         }
1178bc36eafdSMike Gerdts 
1179bc36eafdSMike Gerdts         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1180bc36eafdSMike Gerdts     }
1181bc36eafdSMike Gerdts 
1182bc36eafdSMike Gerdts     MpSaveSerialInfo (Info->MappingOp, Descriptor, ResourceSource);
1183bc36eafdSMike Gerdts     return (Rnode);
1184bc36eafdSMike Gerdts }
1185bc36eafdSMike Gerdts 
1186bc36eafdSMike Gerdts 
1187bc36eafdSMike Gerdts /*******************************************************************************
1188bc36eafdSMike Gerdts  *
1189bc36eafdSMike Gerdts  * FUNCTION:    RsDoUartSerialBusDescriptor
1190bc36eafdSMike Gerdts  *
1191bc36eafdSMike Gerdts  * PARAMETERS:  Info                - Parse Op and resource template offset
1192bc36eafdSMike Gerdts  *
1193bc36eafdSMike Gerdts  * RETURN:      Completed resource node
1194bc36eafdSMike Gerdts  *
1195bc36eafdSMike Gerdts  * DESCRIPTION: Construct a long "UART Serial Bus" descriptor
1196bc36eafdSMike Gerdts  *
1197bc36eafdSMike Gerdts  ******************************************************************************/
1198bc36eafdSMike Gerdts 
1199bc36eafdSMike Gerdts ASL_RESOURCE_NODE *
RsDoUartSerialBusDescriptor(ASL_RESOURCE_INFO * Info)1200bc36eafdSMike Gerdts RsDoUartSerialBusDescriptor (
1201bc36eafdSMike Gerdts     ASL_RESOURCE_INFO       *Info)
1202bc36eafdSMike Gerdts {
1203bc36eafdSMike Gerdts     AML_RESOURCE            *Descriptor;
1204bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *InitializerOp;
1205bc36eafdSMike Gerdts     ASL_RESOURCE_NODE       *Rnode;
1206bc36eafdSMike Gerdts     char                    *ResourceSource = NULL;
1207bc36eafdSMike Gerdts     UINT8                   *VendorData = NULL;
1208bc36eafdSMike Gerdts     UINT16                  ResSourceLength;
1209bc36eafdSMike Gerdts     UINT16                  VendorLength;
1210bc36eafdSMike Gerdts     UINT16                  DescriptorSize;
1211bc36eafdSMike Gerdts     UINT32                  CurrentByteOffset;
1212bc36eafdSMike Gerdts     UINT32                  i;
1213bc36eafdSMike Gerdts 
1214bc36eafdSMike Gerdts 
1215bc36eafdSMike Gerdts     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
1216bc36eafdSMike Gerdts     CurrentByteOffset = Info->CurrentByteOffset;
1217bc36eafdSMike Gerdts 
1218bc36eafdSMike Gerdts     /*
1219bc36eafdSMike Gerdts      * Calculate lengths for fields that have variable length:
1220bc36eafdSMike Gerdts      * 1) Resource Source string
1221bc36eafdSMike Gerdts      * 2) Vendor Data buffer
1222bc36eafdSMike Gerdts      */
1223bc36eafdSMike Gerdts     ResSourceLength = RsGetStringDataLength (InitializerOp);
1224bc36eafdSMike Gerdts     VendorLength = RsGetBufferDataLength (InitializerOp);
1225bc36eafdSMike Gerdts 
1226bc36eafdSMike Gerdts     DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_UART_SERIALBUS) +
1227bc36eafdSMike Gerdts         ResSourceLength + VendorLength;
1228bc36eafdSMike Gerdts 
1229bc36eafdSMike Gerdts     /* Allocate the local resource node and initialize */
1230bc36eafdSMike Gerdts 
1231bc36eafdSMike Gerdts     Rnode = RsAllocateResourceNode (DescriptorSize +
1232bc36eafdSMike Gerdts         sizeof (AML_RESOURCE_LARGE_HEADER));
1233bc36eafdSMike Gerdts 
1234bc36eafdSMike Gerdts     Descriptor = Rnode->Buffer;
1235bc36eafdSMike Gerdts     Descriptor->UartSerialBus.ResourceLength = DescriptorSize;
1236bc36eafdSMike Gerdts     Descriptor->UartSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS;
1237bc36eafdSMike Gerdts     Descriptor->UartSerialBus.RevisionId = AML_RESOURCE_UART_REVISION;
1238bc36eafdSMike Gerdts     Descriptor->UartSerialBus.TypeRevisionId = AML_RESOURCE_UART_TYPE_REVISION;
1239bc36eafdSMike Gerdts     Descriptor->UartSerialBus.Type = AML_RESOURCE_UART_SERIALBUSTYPE;
1240bc36eafdSMike Gerdts     Descriptor->UartSerialBus.TypeDataLength = AML_RESOURCE_UART_MIN_DATA_LEN + VendorLength;
1241bc36eafdSMike Gerdts 
1242bc36eafdSMike Gerdts     if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_UART_SERIALBUS_V2)
1243bc36eafdSMike Gerdts     {
1244bc36eafdSMike Gerdts         Descriptor->I2cSerialBus.RevisionId = 2;
1245bc36eafdSMike Gerdts     }
1246bc36eafdSMike Gerdts 
1247bc36eafdSMike Gerdts     /* Build pointers to optional areas */
1248bc36eafdSMike Gerdts 
1249bc36eafdSMike Gerdts     VendorData = ACPI_ADD_PTR (UINT8, Descriptor, sizeof (AML_RESOURCE_UART_SERIALBUS));
1250bc36eafdSMike Gerdts     ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength);
1251bc36eafdSMike Gerdts 
1252bc36eafdSMike Gerdts     /* Process all child initialization nodes */
1253bc36eafdSMike Gerdts 
1254bc36eafdSMike Gerdts     for (i = 0; InitializerOp; i++)
1255bc36eafdSMike Gerdts     {
1256bc36eafdSMike Gerdts         switch (i)
1257bc36eafdSMike Gerdts         {
1258bc36eafdSMike Gerdts         case 0: /* Connection Speed (Baud Rate) [DWORD] (_SPE) */
1259bc36eafdSMike Gerdts 
1260bc36eafdSMike Gerdts             Descriptor->UartSerialBus.DefaultBaudRate = (UINT32) InitializerOp->Asl.Value.Integer;
1261bc36eafdSMike Gerdts             RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
1262bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.DefaultBaudRate));
1263bc36eafdSMike Gerdts             break;
1264bc36eafdSMike Gerdts 
1265bc36eafdSMike Gerdts         case 1: /* Bits Per Byte [Flags] (_LEN) */
1266bc36eafdSMike Gerdts 
1267bc36eafdSMike Gerdts             RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 4, 3);
1268bc36eafdSMike Gerdts             RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_LENGTH,
1269bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 4, 3);
1270bc36eafdSMike Gerdts             break;
1271bc36eafdSMike Gerdts 
1272bc36eafdSMike Gerdts         case 2: /* Stop Bits [Flags] (_STB) */
1273bc36eafdSMike Gerdts 
1274bc36eafdSMike Gerdts             RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 2, 1);
1275bc36eafdSMike Gerdts             RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_STOPBITS,
1276bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 2, 2);
1277bc36eafdSMike Gerdts             break;
1278bc36eafdSMike Gerdts 
1279bc36eafdSMike Gerdts         case 3: /* Lines In Use [BYTE] (_LIN) */
1280bc36eafdSMike Gerdts 
1281bc36eafdSMike Gerdts             Descriptor->UartSerialBus.LinesEnabled = (UINT8) InitializerOp->Asl.Value.Integer;
1282bc36eafdSMike Gerdts             RsCreateByteField (InitializerOp, ACPI_RESTAG_LINE,
1283bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.LinesEnabled));
1284bc36eafdSMike Gerdts             break;
1285bc36eafdSMike Gerdts 
1286bc36eafdSMike Gerdts         case 4: /* Endianness [Flag] (_END) */
1287bc36eafdSMike Gerdts 
1288bc36eafdSMike Gerdts             RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 7, 0);
1289bc36eafdSMike Gerdts             RsCreateBitField (InitializerOp, ACPI_RESTAG_ENDIANNESS,
1290bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 7);
1291bc36eafdSMike Gerdts             break;
1292bc36eafdSMike Gerdts 
1293bc36eafdSMike Gerdts         case 5: /* Parity [BYTE] (_PAR) */
1294bc36eafdSMike Gerdts 
1295bc36eafdSMike Gerdts             Descriptor->UartSerialBus.Parity = (UINT8) InitializerOp->Asl.Value.Integer;
1296bc36eafdSMike Gerdts             RsCreateByteField (InitializerOp, ACPI_RESTAG_PARITY,
1297bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.Parity));
1298bc36eafdSMike Gerdts             break;
1299bc36eafdSMike Gerdts 
1300bc36eafdSMike Gerdts         case 6: /* Flow Control [Flags] (_FLC) */
1301bc36eafdSMike Gerdts 
1302bc36eafdSMike Gerdts             RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
1303bc36eafdSMike Gerdts             RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_FLOWCONTROL,
1304bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 0, 2);
1305bc36eafdSMike Gerdts             break;
1306bc36eafdSMike Gerdts 
1307bc36eafdSMike Gerdts         case 7: /* Rx Buffer Size [WORD] (_RXL) */
1308bc36eafdSMike Gerdts 
1309bc36eafdSMike Gerdts             Descriptor->UartSerialBus.RxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer;
1310bc36eafdSMike Gerdts             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH_RX,
1311bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.RxFifoSize));
1312bc36eafdSMike Gerdts             break;
1313bc36eafdSMike Gerdts 
1314bc36eafdSMike Gerdts         case 8: /* Tx Buffer Size [WORD] (_TXL) */
1315bc36eafdSMike Gerdts 
1316bc36eafdSMike Gerdts             Descriptor->UartSerialBus.TxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer;
1317bc36eafdSMike Gerdts             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH_TX,
1318bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TxFifoSize));
1319bc36eafdSMike Gerdts             break;
1320bc36eafdSMike Gerdts 
1321bc36eafdSMike Gerdts         case 9: /* ResSource [Optional Field - STRING] */
1322bc36eafdSMike Gerdts 
1323bc36eafdSMike Gerdts             if (ResSourceLength)
1324bc36eafdSMike Gerdts             {
1325bc36eafdSMike Gerdts                 /* Copy string to the descriptor */
1326bc36eafdSMike Gerdts 
1327bc36eafdSMike Gerdts                 strcpy (ResourceSource,
1328bc36eafdSMike Gerdts                     InitializerOp->Asl.Value.String);
1329bc36eafdSMike Gerdts             }
1330bc36eafdSMike Gerdts             break;
1331bc36eafdSMike Gerdts 
1332bc36eafdSMike Gerdts         case 10: /* Resource Index */
1333bc36eafdSMike Gerdts 
1334bc36eafdSMike Gerdts             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
1335bc36eafdSMike Gerdts             {
1336bc36eafdSMike Gerdts                 Descriptor->UartSerialBus.ResSourceIndex =
1337bc36eafdSMike Gerdts                     (UINT8) InitializerOp->Asl.Value.Integer;
1338bc36eafdSMike Gerdts             }
1339bc36eafdSMike Gerdts             break;
1340bc36eafdSMike Gerdts 
1341bc36eafdSMike Gerdts         case 11: /* Resource Usage (consumer/producer) */
1342bc36eafdSMike Gerdts 
1343bc36eafdSMike Gerdts             RsSetFlagBits (&Descriptor->UartSerialBus.Flags, InitializerOp, 1, 1);
1344bc36eafdSMike Gerdts 
1345bc36eafdSMike Gerdts             /*
1346bc36eafdSMike Gerdts              * Slave Mode [Flag] (_SLV)
1347bc36eafdSMike Gerdts              *
1348bc36eafdSMike Gerdts              * Note: There is no SlaveMode argument to the UartSerialBus macro, but
1349bc36eafdSMike Gerdts              * we add this name anyway to allow the flag to be set by ASL in the
1350bc36eafdSMike Gerdts              * rare case where there is a slave mode associated with the UART.
1351bc36eafdSMike Gerdts              */
1352bc36eafdSMike Gerdts             RsCreateBitField (InitializerOp, ACPI_RESTAG_SLAVEMODE,
1353bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.Flags), 0);
1354bc36eafdSMike Gerdts             break;
1355bc36eafdSMike Gerdts 
1356bc36eafdSMike Gerdts         case 12: /* Resource Tag (Descriptor Name) */
1357bc36eafdSMike Gerdts 
1358bc36eafdSMike Gerdts             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
1359bc36eafdSMike Gerdts             break;
1360bc36eafdSMike Gerdts 
1361bc36eafdSMike Gerdts         case 13:
1362bc36eafdSMike Gerdts             /*
1363bc36eafdSMike Gerdts              * Connection Share - Added for V2 (ACPI 6.0) version of the descriptor
1364bc36eafdSMike Gerdts              * Note: For V1, the share bit will be zero (Op is DEFAULT_ARG from
1365bc36eafdSMike Gerdts              * the ASL parser)
1366bc36eafdSMike Gerdts              */
1367bc36eafdSMike Gerdts             RsSetFlagBits (&Descriptor->UartSerialBus.Flags, InitializerOp, 2, 0);
1368bc36eafdSMike Gerdts             RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
1369bc36eafdSMike Gerdts                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.Flags), 2);
1370bc36eafdSMike Gerdts             break;
1371bc36eafdSMike Gerdts 
1372bc36eafdSMike Gerdts         case 14: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */
1373bc36eafdSMike Gerdts 
1374bc36eafdSMike Gerdts             RsGetVendorData (InitializerOp, VendorData,
1375bc36eafdSMike Gerdts                 CurrentByteOffset + sizeof (AML_RESOURCE_UART_SERIALBUS));
1376bc36eafdSMike Gerdts             break;
1377bc36eafdSMike Gerdts 
1378bc36eafdSMike Gerdts         default:    /* Ignore any extra nodes */
1379bc36eafdSMike Gerdts 
1380bc36eafdSMike Gerdts             break;
1381bc36eafdSMike Gerdts         }
1382bc36eafdSMike Gerdts 
1383bc36eafdSMike Gerdts         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1384bc36eafdSMike Gerdts     }
1385bc36eafdSMike Gerdts 
1386bc36eafdSMike Gerdts     MpSaveSerialInfo (Info->MappingOp, Descriptor, ResourceSource);
1387bc36eafdSMike Gerdts     return (Rnode);
1388bc36eafdSMike Gerdts }
1389*35786f68SRobert Mustacchi 
1390*35786f68SRobert Mustacchi 
1391*35786f68SRobert Mustacchi /*******************************************************************************
1392*35786f68SRobert Mustacchi  *
1393*35786f68SRobert Mustacchi  * FUNCTION:    RsDoPinFunctionDescriptor
1394*35786f68SRobert Mustacchi  *
1395*35786f68SRobert Mustacchi  * PARAMETERS:  Info                - Parse Op and resource template offset
1396*35786f68SRobert Mustacchi  *
1397*35786f68SRobert Mustacchi  * RETURN:      Completed resource node
1398*35786f68SRobert Mustacchi  *
1399*35786f68SRobert Mustacchi  * DESCRIPTION: Construct a long "PinFunction" descriptor
1400*35786f68SRobert Mustacchi  *
1401*35786f68SRobert Mustacchi  ******************************************************************************/
1402*35786f68SRobert Mustacchi 
1403*35786f68SRobert Mustacchi ASL_RESOURCE_NODE *
RsDoPinFunctionDescriptor(ASL_RESOURCE_INFO * Info)1404*35786f68SRobert Mustacchi RsDoPinFunctionDescriptor (
1405*35786f68SRobert Mustacchi     ASL_RESOURCE_INFO       *Info)
1406*35786f68SRobert Mustacchi {
1407*35786f68SRobert Mustacchi     AML_RESOURCE            *Descriptor;
1408*35786f68SRobert Mustacchi     ACPI_PARSE_OBJECT       *InitializerOp;
1409*35786f68SRobert Mustacchi     ASL_RESOURCE_NODE       *Rnode;
1410*35786f68SRobert Mustacchi     char                    *ResourceSource = NULL;
1411*35786f68SRobert Mustacchi     UINT8                   *VendorData = NULL;
1412*35786f68SRobert Mustacchi     UINT16                  *PinList = NULL;
1413*35786f68SRobert Mustacchi     UINT16                  ResSourceLength;
1414*35786f68SRobert Mustacchi     UINT16                  VendorLength;
1415*35786f68SRobert Mustacchi     UINT16                  PinListLength;
1416*35786f68SRobert Mustacchi     UINT16                  DescriptorSize;
1417*35786f68SRobert Mustacchi     UINT32                  CurrentByteOffset;
1418*35786f68SRobert Mustacchi     UINT32                  PinCount = 0;
1419*35786f68SRobert Mustacchi     UINT32                  i;
1420*35786f68SRobert Mustacchi 
1421*35786f68SRobert Mustacchi     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
1422*35786f68SRobert Mustacchi     CurrentByteOffset = Info->CurrentByteOffset;
1423*35786f68SRobert Mustacchi 
1424*35786f68SRobert Mustacchi     /*
1425*35786f68SRobert Mustacchi      * Calculate lengths for fields that have variable length:
1426*35786f68SRobert Mustacchi      * 1) Resource Source string
1427*35786f68SRobert Mustacchi      * 2) Vendor Data buffer
1428*35786f68SRobert Mustacchi      * 3) PIN (interrupt) list
1429*35786f68SRobert Mustacchi      */
1430*35786f68SRobert Mustacchi     ResSourceLength = RsGetStringDataLength (InitializerOp);
1431*35786f68SRobert Mustacchi     VendorLength = RsGetBufferDataLength (InitializerOp);
1432*35786f68SRobert Mustacchi     PinListLength = RsGetInterruptDataLength (InitializerOp, 8);
1433*35786f68SRobert Mustacchi 
1434*35786f68SRobert Mustacchi     DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_PIN_FUNCTION) +
1435*35786f68SRobert Mustacchi         ResSourceLength + VendorLength + PinListLength;
1436*35786f68SRobert Mustacchi 
1437*35786f68SRobert Mustacchi     /* Allocate the local resource node and initialize */
1438*35786f68SRobert Mustacchi 
1439*35786f68SRobert Mustacchi     Rnode = RsAllocateResourceNode (DescriptorSize +
1440*35786f68SRobert Mustacchi         sizeof (AML_RESOURCE_LARGE_HEADER));
1441*35786f68SRobert Mustacchi 
1442*35786f68SRobert Mustacchi     Descriptor = Rnode->Buffer;
1443*35786f68SRobert Mustacchi     Descriptor->PinFunction.ResourceLength = DescriptorSize;
1444*35786f68SRobert Mustacchi     Descriptor->PinFunction.DescriptorType = ACPI_RESOURCE_NAME_PIN_FUNCTION;
1445*35786f68SRobert Mustacchi     Descriptor->PinFunction.RevisionId = AML_RESOURCE_PIN_FUNCTION_REVISION;
1446*35786f68SRobert Mustacchi 
1447*35786f68SRobert Mustacchi     /* Build pointers to optional areas */
1448*35786f68SRobert Mustacchi 
1449*35786f68SRobert Mustacchi     PinList = ACPI_ADD_PTR (UINT16, Descriptor, sizeof (AML_RESOURCE_PIN_FUNCTION));
1450*35786f68SRobert Mustacchi     ResourceSource = ACPI_ADD_PTR (char, PinList, PinListLength);
1451*35786f68SRobert Mustacchi     VendorData = ACPI_ADD_PTR (UINT8, ResourceSource, ResSourceLength);
1452*35786f68SRobert Mustacchi 
1453*35786f68SRobert Mustacchi     /* Setup offsets within the descriptor */
1454*35786f68SRobert Mustacchi 
1455*35786f68SRobert Mustacchi     Descriptor->PinFunction.PinTableOffset = (UINT16)
1456*35786f68SRobert Mustacchi         ACPI_PTR_DIFF (PinList, Descriptor);
1457*35786f68SRobert Mustacchi 
1458*35786f68SRobert Mustacchi     Descriptor->PinFunction.ResSourceOffset = (UINT16)
1459*35786f68SRobert Mustacchi         ACPI_PTR_DIFF (ResourceSource, Descriptor);
1460*35786f68SRobert Mustacchi 
1461*35786f68SRobert Mustacchi     /* Process all child initialization nodes */
1462*35786f68SRobert Mustacchi 
1463*35786f68SRobert Mustacchi     for (i = 0; InitializerOp; i++)
1464*35786f68SRobert Mustacchi     {
1465*35786f68SRobert Mustacchi         switch (i)
1466*35786f68SRobert Mustacchi         {
1467*35786f68SRobert Mustacchi         case 0: /* Share Type [Flags] (_SHR) */
1468*35786f68SRobert Mustacchi 
1469*35786f68SRobert Mustacchi             RsSetFlagBits16 (&Descriptor->PinFunction.Flags, InitializerOp, 0, 0);
1470*35786f68SRobert Mustacchi             RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
1471*35786f68SRobert Mustacchi                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinFunction.Flags), 0);
1472*35786f68SRobert Mustacchi             break;
1473*35786f68SRobert Mustacchi 
1474*35786f68SRobert Mustacchi         case 1: /* Pin Config [BYTE] (_PPI) */
1475*35786f68SRobert Mustacchi 
1476*35786f68SRobert Mustacchi             Descriptor->PinFunction.PinConfig = (UINT8) InitializerOp->Asl.Value.Integer;
1477*35786f68SRobert Mustacchi             RsCreateByteField (InitializerOp, ACPI_RESTAG_PINCONFIG,
1478*35786f68SRobert Mustacchi                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinFunction.PinConfig));
1479*35786f68SRobert Mustacchi             break;
1480*35786f68SRobert Mustacchi 
1481*35786f68SRobert Mustacchi         case 2: /* Function Number [WORD] (_FUN) */
1482*35786f68SRobert Mustacchi 
1483*35786f68SRobert Mustacchi             Descriptor->PinFunction.FunctionNumber = (UINT16) InitializerOp->Asl.Value.Integer;
1484*35786f68SRobert Mustacchi             RsCreateDwordField (InitializerOp, ACPI_RESTAG_FUNCTION,
1485*35786f68SRobert Mustacchi                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinFunction.FunctionNumber));
1486*35786f68SRobert Mustacchi             break;
1487*35786f68SRobert Mustacchi 
1488*35786f68SRobert Mustacchi         case 3: /* ResSource [Optional Field - STRING] */
1489*35786f68SRobert Mustacchi 
1490*35786f68SRobert Mustacchi             if (ResSourceLength)
1491*35786f68SRobert Mustacchi             {
1492*35786f68SRobert Mustacchi                 /* Copy string to the descriptor */
1493*35786f68SRobert Mustacchi 
1494*35786f68SRobert Mustacchi                 strcpy (ResourceSource, InitializerOp->Asl.Value.String);
1495*35786f68SRobert Mustacchi             }
1496*35786f68SRobert Mustacchi             break;
1497*35786f68SRobert Mustacchi 
1498*35786f68SRobert Mustacchi         case 4: /* Resource Index */
1499*35786f68SRobert Mustacchi 
1500*35786f68SRobert Mustacchi             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
1501*35786f68SRobert Mustacchi             {
1502*35786f68SRobert Mustacchi                 Descriptor->PinFunction.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer;
1503*35786f68SRobert Mustacchi             }
1504*35786f68SRobert Mustacchi             break;
1505*35786f68SRobert Mustacchi 
1506*35786f68SRobert Mustacchi         case 5: /* Resource Usage (consumer/producer) */
1507*35786f68SRobert Mustacchi 
1508*35786f68SRobert Mustacchi             /* Assumed to be consumer */
1509*35786f68SRobert Mustacchi 
1510*35786f68SRobert Mustacchi             break;
1511*35786f68SRobert Mustacchi 
1512*35786f68SRobert Mustacchi         case 6: /* Resource Tag (Descriptor Name) */
1513*35786f68SRobert Mustacchi 
1514*35786f68SRobert Mustacchi             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
1515*35786f68SRobert Mustacchi             break;
1516*35786f68SRobert Mustacchi 
1517*35786f68SRobert Mustacchi         case 7: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */
1518*35786f68SRobert Mustacchi             /*
1519*35786f68SRobert Mustacchi              * Always set the VendorOffset even if there is no Vendor Data.
1520*35786f68SRobert Mustacchi              * This field is required in order to calculate the length
1521*35786f68SRobert Mustacchi              * of the ResourceSource at runtime.
1522*35786f68SRobert Mustacchi              */
1523*35786f68SRobert Mustacchi             Descriptor->PinFunction.VendorOffset = (UINT16)
1524*35786f68SRobert Mustacchi                 ACPI_PTR_DIFF (VendorData, Descriptor);
1525*35786f68SRobert Mustacchi 
1526*35786f68SRobert Mustacchi             if (RsGetVendorData (InitializerOp, VendorData,
1527*35786f68SRobert Mustacchi                 (CurrentByteOffset + Descriptor->PinFunction.VendorOffset)))
1528*35786f68SRobert Mustacchi             {
1529*35786f68SRobert Mustacchi                 Descriptor->PinFunction.VendorLength = VendorLength;
1530*35786f68SRobert Mustacchi             }
1531*35786f68SRobert Mustacchi             break;
1532*35786f68SRobert Mustacchi 
1533*35786f68SRobert Mustacchi         default:
1534*35786f68SRobert Mustacchi             /*
1535*35786f68SRobert Mustacchi              * PINs come through here, repeatedly. Each PIN must be a WORD.
1536*35786f68SRobert Mustacchi              * NOTE: there is no "length" field for this, so from ACPI spec:
1537*35786f68SRobert Mustacchi              *  The number of pins in the table can be calculated from:
1538*35786f68SRobert Mustacchi              *  PinCount = (Resource Source Name Offset - Pin Table Offset) / 2
1539*35786f68SRobert Mustacchi              *  (implies resource source must immediately follow the pin list.)
1540*35786f68SRobert Mustacchi              *  Name: _PIN
1541*35786f68SRobert Mustacchi              */
1542*35786f68SRobert Mustacchi             *PinList = (UINT16) InitializerOp->Asl.Value.Integer;
1543*35786f68SRobert Mustacchi             PinList++;
1544*35786f68SRobert Mustacchi             PinCount++;
1545*35786f68SRobert Mustacchi 
1546*35786f68SRobert Mustacchi             /* Case 8: First pin number in list */
1547*35786f68SRobert Mustacchi 
1548*35786f68SRobert Mustacchi             if (i == 8)
1549*35786f68SRobert Mustacchi             {
1550*35786f68SRobert Mustacchi                 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
1551*35786f68SRobert Mustacchi                 {
1552*35786f68SRobert Mustacchi                     /* Must be at least one interrupt */
1553*35786f68SRobert Mustacchi 
1554*35786f68SRobert Mustacchi                     AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_LIST_MIN,
1555*35786f68SRobert Mustacchi                         InitializerOp, NULL);
1556*35786f68SRobert Mustacchi                 }
1557*35786f68SRobert Mustacchi 
1558*35786f68SRobert Mustacchi                 /* Check now for duplicates in list */
1559*35786f68SRobert Mustacchi 
1560*35786f68SRobert Mustacchi                 RsCheckListForDuplicates (InitializerOp);
1561*35786f68SRobert Mustacchi 
1562*35786f68SRobert Mustacchi                 /* Create a named field at the start of the list */
1563*35786f68SRobert Mustacchi 
1564*35786f68SRobert Mustacchi                 RsCreateWordField (InitializerOp, ACPI_RESTAG_PIN,
1565*35786f68SRobert Mustacchi                     CurrentByteOffset + Descriptor->PinFunction.PinTableOffset);
1566*35786f68SRobert Mustacchi             }
1567*35786f68SRobert Mustacchi             break;
1568*35786f68SRobert Mustacchi         }
1569*35786f68SRobert Mustacchi 
1570*35786f68SRobert Mustacchi         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1571*35786f68SRobert Mustacchi     }
1572*35786f68SRobert Mustacchi 
1573*35786f68SRobert Mustacchi     return (Rnode);
1574*35786f68SRobert Mustacchi }
1575*35786f68SRobert Mustacchi 
1576*35786f68SRobert Mustacchi 
1577*35786f68SRobert Mustacchi /*******************************************************************************
1578*35786f68SRobert Mustacchi  *
1579*35786f68SRobert Mustacchi  * FUNCTION:    RsDoPinConfigDescriptor
1580*35786f68SRobert Mustacchi  *
1581*35786f68SRobert Mustacchi  * PARAMETERS:  Info                - Parse Op and resource template offset
1582*35786f68SRobert Mustacchi  *
1583*35786f68SRobert Mustacchi  * RETURN:      Completed resource node
1584*35786f68SRobert Mustacchi  *
1585*35786f68SRobert Mustacchi  * DESCRIPTION: Construct a long "PinConfig" descriptor
1586*35786f68SRobert Mustacchi  *
1587*35786f68SRobert Mustacchi  ******************************************************************************/
1588*35786f68SRobert Mustacchi 
1589*35786f68SRobert Mustacchi ASL_RESOURCE_NODE *
RsDoPinConfigDescriptor(ASL_RESOURCE_INFO * Info)1590*35786f68SRobert Mustacchi RsDoPinConfigDescriptor (
1591*35786f68SRobert Mustacchi     ASL_RESOURCE_INFO       *Info)
1592*35786f68SRobert Mustacchi {
1593*35786f68SRobert Mustacchi     AML_RESOURCE            *Descriptor;
1594*35786f68SRobert Mustacchi     ACPI_PARSE_OBJECT       *InitializerOp;
1595*35786f68SRobert Mustacchi     ASL_RESOURCE_NODE       *Rnode;
1596*35786f68SRobert Mustacchi     char                    *ResourceSource = NULL;
1597*35786f68SRobert Mustacchi     UINT8                   *VendorData = NULL;
1598*35786f68SRobert Mustacchi     UINT16                  *PinList = NULL;
1599*35786f68SRobert Mustacchi     UINT16                  ResSourceLength;
1600*35786f68SRobert Mustacchi     UINT16                  VendorLength;
1601*35786f68SRobert Mustacchi     UINT16                  PinListLength;
1602*35786f68SRobert Mustacchi     UINT16                  DescriptorSize;
1603*35786f68SRobert Mustacchi     UINT32                  CurrentByteOffset;
1604*35786f68SRobert Mustacchi     UINT32                  PinCount = 0;
1605*35786f68SRobert Mustacchi     UINT32                  i;
1606*35786f68SRobert Mustacchi 
1607*35786f68SRobert Mustacchi     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
1608*35786f68SRobert Mustacchi     CurrentByteOffset = Info->CurrentByteOffset;
1609*35786f68SRobert Mustacchi 
1610*35786f68SRobert Mustacchi     /*
1611*35786f68SRobert Mustacchi      * Calculate lengths for fields that have variable length:
1612*35786f68SRobert Mustacchi      * 1) Resource Source string
1613*35786f68SRobert Mustacchi      * 2) Vendor Data buffer
1614*35786f68SRobert Mustacchi      * 3) PIN (interrupt) list
1615*35786f68SRobert Mustacchi      */
1616*35786f68SRobert Mustacchi     ResSourceLength = RsGetStringDataLength (InitializerOp);
1617*35786f68SRobert Mustacchi     VendorLength = RsGetBufferDataLength (InitializerOp);
1618*35786f68SRobert Mustacchi     PinListLength = RsGetInterruptDataLength (InitializerOp, 8);
1619*35786f68SRobert Mustacchi 
1620*35786f68SRobert Mustacchi     DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_PIN_CONFIG) +
1621*35786f68SRobert Mustacchi         ResSourceLength + VendorLength + PinListLength;
1622*35786f68SRobert Mustacchi 
1623*35786f68SRobert Mustacchi     /* Allocate the local resource node and initialize */
1624*35786f68SRobert Mustacchi 
1625*35786f68SRobert Mustacchi     Rnode = RsAllocateResourceNode (DescriptorSize +
1626*35786f68SRobert Mustacchi         sizeof (AML_RESOURCE_LARGE_HEADER));
1627*35786f68SRobert Mustacchi 
1628*35786f68SRobert Mustacchi     Descriptor = Rnode->Buffer;
1629*35786f68SRobert Mustacchi     Descriptor->PinConfig.ResourceLength = DescriptorSize;
1630*35786f68SRobert Mustacchi     Descriptor->PinConfig.DescriptorType = ACPI_RESOURCE_NAME_PIN_CONFIG;
1631*35786f68SRobert Mustacchi     Descriptor->PinConfig.RevisionId = AML_RESOURCE_PIN_CONFIG_REVISION;
1632*35786f68SRobert Mustacchi 
1633*35786f68SRobert Mustacchi     /* Build pointers to optional areas */
1634*35786f68SRobert Mustacchi 
1635*35786f68SRobert Mustacchi     PinList = ACPI_ADD_PTR (UINT16, Descriptor, sizeof (AML_RESOURCE_PIN_CONFIG));
1636*35786f68SRobert Mustacchi     ResourceSource = ACPI_ADD_PTR (char, PinList, PinListLength);
1637*35786f68SRobert Mustacchi     VendorData = ACPI_ADD_PTR (UINT8, ResourceSource, ResSourceLength);
1638*35786f68SRobert Mustacchi 
1639*35786f68SRobert Mustacchi     /* Setup offsets within the descriptor */
1640*35786f68SRobert Mustacchi 
1641*35786f68SRobert Mustacchi     Descriptor->PinConfig.PinTableOffset = (UINT16)
1642*35786f68SRobert Mustacchi         ACPI_PTR_DIFF (PinList, Descriptor);
1643*35786f68SRobert Mustacchi 
1644*35786f68SRobert Mustacchi     Descriptor->PinConfig.ResSourceOffset = (UINT16)
1645*35786f68SRobert Mustacchi         ACPI_PTR_DIFF (ResourceSource, Descriptor);
1646*35786f68SRobert Mustacchi 
1647*35786f68SRobert Mustacchi     /* Process all child initialization nodes */
1648*35786f68SRobert Mustacchi 
1649*35786f68SRobert Mustacchi     for (i = 0; InitializerOp; i++)
1650*35786f68SRobert Mustacchi     {
1651*35786f68SRobert Mustacchi         BOOLEAN isValid;
1652*35786f68SRobert Mustacchi 
1653*35786f68SRobert Mustacchi         switch (i)
1654*35786f68SRobert Mustacchi         {
1655*35786f68SRobert Mustacchi         case 0: /* Share Type [Flags] (_SHR) */
1656*35786f68SRobert Mustacchi 
1657*35786f68SRobert Mustacchi             RsSetFlagBits16 (&Descriptor->PinConfig.Flags, InitializerOp, 0, 0);
1658*35786f68SRobert Mustacchi             RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
1659*35786f68SRobert Mustacchi                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinConfig.Flags), 0);
1660*35786f68SRobert Mustacchi             break;
1661*35786f68SRobert Mustacchi 
1662*35786f68SRobert Mustacchi         case 1: /* Pin Config Type [BYTE] (_TYP) */
1663*35786f68SRobert Mustacchi 
1664*35786f68SRobert Mustacchi             isValid = InitializerOp->Asl.Value.Integer <= 0x0d;
1665*35786f68SRobert Mustacchi             if (!isValid)
1666*35786f68SRobert Mustacchi             {
1667*35786f68SRobert Mustacchi                 isValid = InitializerOp->Asl.Value.Integer >= 0x80 &&
1668*35786f68SRobert Mustacchi                           InitializerOp->Asl.Value.Integer <= 0xff;
1669*35786f68SRobert Mustacchi             }
1670*35786f68SRobert Mustacchi             if (!isValid)
1671*35786f68SRobert Mustacchi             {
1672*35786f68SRobert Mustacchi                     AslError (ASL_ERROR, ASL_MSG_RANGE, InitializerOp, NULL);
1673*35786f68SRobert Mustacchi             }
1674*35786f68SRobert Mustacchi 
1675*35786f68SRobert Mustacchi             Descriptor->PinConfig.PinConfigType = (UINT8) InitializerOp->Asl.Value.Integer;
1676*35786f68SRobert Mustacchi             RsCreateByteField (InitializerOp, ACPI_RESTAG_PINCONFIG_TYPE,
1677*35786f68SRobert Mustacchi                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinConfig.PinConfigType));
1678*35786f68SRobert Mustacchi 
1679*35786f68SRobert Mustacchi             break;
1680*35786f68SRobert Mustacchi 
1681*35786f68SRobert Mustacchi         case 2: /* Pin Config Value [DWORD] (_VAL) */
1682*35786f68SRobert Mustacchi 
1683*35786f68SRobert Mustacchi             Descriptor->PinConfig.PinConfigValue = (UINT32) InitializerOp->Asl.Value.Integer;
1684*35786f68SRobert Mustacchi             RsCreateDwordField (InitializerOp, ACPI_RESTAG_PINCONFIG_VALUE,
1685*35786f68SRobert Mustacchi                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinConfig.PinConfigValue));
1686*35786f68SRobert Mustacchi             break;
1687*35786f68SRobert Mustacchi 
1688*35786f68SRobert Mustacchi         case 3: /* ResSource [Optional Field - STRING] */
1689*35786f68SRobert Mustacchi 
1690*35786f68SRobert Mustacchi             if (ResSourceLength)
1691*35786f68SRobert Mustacchi             {
1692*35786f68SRobert Mustacchi                 /* Copy string to the descriptor */
1693*35786f68SRobert Mustacchi 
1694*35786f68SRobert Mustacchi                 strcpy (ResourceSource, InitializerOp->Asl.Value.String);
1695*35786f68SRobert Mustacchi             }
1696*35786f68SRobert Mustacchi             break;
1697*35786f68SRobert Mustacchi 
1698*35786f68SRobert Mustacchi         case 4: /* Resource Index */
1699*35786f68SRobert Mustacchi 
1700*35786f68SRobert Mustacchi             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
1701*35786f68SRobert Mustacchi             {
1702*35786f68SRobert Mustacchi                 Descriptor->PinConfig.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer;
1703*35786f68SRobert Mustacchi             }
1704*35786f68SRobert Mustacchi             break;
1705*35786f68SRobert Mustacchi 
1706*35786f68SRobert Mustacchi         case 5: /* Resource Usage (consumer/producer) */
1707*35786f68SRobert Mustacchi 
1708*35786f68SRobert Mustacchi             RsSetFlagBits16 (&Descriptor->PinConfig.Flags, InitializerOp, 1, 1);
1709*35786f68SRobert Mustacchi 
1710*35786f68SRobert Mustacchi             break;
1711*35786f68SRobert Mustacchi 
1712*35786f68SRobert Mustacchi         case 6: /* Resource Tag (Descriptor Name) */
1713*35786f68SRobert Mustacchi 
1714*35786f68SRobert Mustacchi             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
1715*35786f68SRobert Mustacchi             break;
1716*35786f68SRobert Mustacchi 
1717*35786f68SRobert Mustacchi         case 7: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */
1718*35786f68SRobert Mustacchi             /*
1719*35786f68SRobert Mustacchi              * Always set the VendorOffset even if there is no Vendor Data.
1720*35786f68SRobert Mustacchi              * This field is required in order to calculate the length
1721*35786f68SRobert Mustacchi              * of the ResourceSource at runtime.
1722*35786f68SRobert Mustacchi              */
1723*35786f68SRobert Mustacchi             Descriptor->PinConfig.VendorOffset = (UINT16)
1724*35786f68SRobert Mustacchi                 ACPI_PTR_DIFF (VendorData, Descriptor);
1725*35786f68SRobert Mustacchi 
1726*35786f68SRobert Mustacchi             if (RsGetVendorData (InitializerOp, VendorData,
1727*35786f68SRobert Mustacchi                 (CurrentByteOffset + Descriptor->PinConfig.VendorOffset)))
1728*35786f68SRobert Mustacchi             {
1729*35786f68SRobert Mustacchi                 Descriptor->PinConfig.VendorLength = VendorLength;
1730*35786f68SRobert Mustacchi             }
1731*35786f68SRobert Mustacchi             break;
1732*35786f68SRobert Mustacchi 
1733*35786f68SRobert Mustacchi         default:
1734*35786f68SRobert Mustacchi             /*
1735*35786f68SRobert Mustacchi              * PINs come through here, repeatedly. Each PIN must be a WORD.
1736*35786f68SRobert Mustacchi              * NOTE: there is no "length" field for this, so from ACPI spec:
1737*35786f68SRobert Mustacchi              *  The number of pins in the table can be calculated from:
1738*35786f68SRobert Mustacchi              *  PinCount = (Resource Source Name Offset - Pin Table Offset) / 2
1739*35786f68SRobert Mustacchi              *  (implies resource source must immediately follow the pin list.)
1740*35786f68SRobert Mustacchi              *  Name: _PIN
1741*35786f68SRobert Mustacchi              */
1742*35786f68SRobert Mustacchi             *PinList = (UINT16) InitializerOp->Asl.Value.Integer;
1743*35786f68SRobert Mustacchi             PinList++;
1744*35786f68SRobert Mustacchi             PinCount++;
1745*35786f68SRobert Mustacchi 
1746*35786f68SRobert Mustacchi             /* Case 8: First pin number in list */
1747*35786f68SRobert Mustacchi 
1748*35786f68SRobert Mustacchi             if (i == 8)
1749*35786f68SRobert Mustacchi             {
1750*35786f68SRobert Mustacchi                 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
1751*35786f68SRobert Mustacchi                 {
1752*35786f68SRobert Mustacchi                     /* Must be at least one interrupt */
1753*35786f68SRobert Mustacchi 
1754*35786f68SRobert Mustacchi                     AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_LIST_MIN,
1755*35786f68SRobert Mustacchi                         InitializerOp, NULL);
1756*35786f68SRobert Mustacchi                 }
1757*35786f68SRobert Mustacchi 
1758*35786f68SRobert Mustacchi                 /* Check now for duplicates in list */
1759*35786f68SRobert Mustacchi 
1760*35786f68SRobert Mustacchi                 RsCheckListForDuplicates (InitializerOp);
1761*35786f68SRobert Mustacchi 
1762*35786f68SRobert Mustacchi                 /* Create a named field at the start of the list */
1763*35786f68SRobert Mustacchi 
1764*35786f68SRobert Mustacchi                 RsCreateWordField (InitializerOp, ACPI_RESTAG_PIN,
1765*35786f68SRobert Mustacchi                     CurrentByteOffset + Descriptor->PinConfig.PinTableOffset);
1766*35786f68SRobert Mustacchi             }
1767*35786f68SRobert Mustacchi             break;
1768*35786f68SRobert Mustacchi         }
1769*35786f68SRobert Mustacchi 
1770*35786f68SRobert Mustacchi         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1771*35786f68SRobert Mustacchi     }
1772*35786f68SRobert Mustacchi 
1773*35786f68SRobert Mustacchi     return (Rnode);
1774*35786f68SRobert Mustacchi }
1775*35786f68SRobert Mustacchi 
1776*35786f68SRobert Mustacchi 
1777*35786f68SRobert Mustacchi /*******************************************************************************
1778*35786f68SRobert Mustacchi  *
1779*35786f68SRobert Mustacchi  * FUNCTION:    RsDoPinGroupDescriptor
1780*35786f68SRobert Mustacchi  *
1781*35786f68SRobert Mustacchi  * PARAMETERS:  Info                - Parse Op and resource template offset
1782*35786f68SRobert Mustacchi  *
1783*35786f68SRobert Mustacchi  * RETURN:      Completed resource node
1784*35786f68SRobert Mustacchi  *
1785*35786f68SRobert Mustacchi  * DESCRIPTION: Construct a long "PinGroup" descriptor
1786*35786f68SRobert Mustacchi  *
1787*35786f68SRobert Mustacchi  ******************************************************************************/
1788*35786f68SRobert Mustacchi 
1789*35786f68SRobert Mustacchi ASL_RESOURCE_NODE *
RsDoPinGroupDescriptor(ASL_RESOURCE_INFO * Info)1790*35786f68SRobert Mustacchi RsDoPinGroupDescriptor (
1791*35786f68SRobert Mustacchi     ASL_RESOURCE_INFO       *Info)
1792*35786f68SRobert Mustacchi {
1793*35786f68SRobert Mustacchi     AML_RESOURCE            *Descriptor;
1794*35786f68SRobert Mustacchi     ACPI_PARSE_OBJECT       *InitializerOp;
1795*35786f68SRobert Mustacchi     ASL_RESOURCE_NODE       *Rnode;
1796*35786f68SRobert Mustacchi     UINT8                   *VendorData = NULL;
1797*35786f68SRobert Mustacchi     UINT16                  *PinList = NULL;
1798*35786f68SRobert Mustacchi     char                    *Label = NULL;
1799*35786f68SRobert Mustacchi     UINT16                  LabelLength;
1800*35786f68SRobert Mustacchi     UINT16                  VendorLength;
1801*35786f68SRobert Mustacchi     UINT16                  PinListLength;
1802*35786f68SRobert Mustacchi     UINT16                  DescriptorSize;
1803*35786f68SRobert Mustacchi     UINT32                  CurrentByteOffset;
1804*35786f68SRobert Mustacchi     UINT32                  PinCount = 0;
1805*35786f68SRobert Mustacchi     UINT32                  i;
1806*35786f68SRobert Mustacchi 
1807*35786f68SRobert Mustacchi     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
1808*35786f68SRobert Mustacchi     CurrentByteOffset = Info->CurrentByteOffset;
1809*35786f68SRobert Mustacchi 
1810*35786f68SRobert Mustacchi     /*
1811*35786f68SRobert Mustacchi      * Calculate lengths for fields that have variable length:
1812*35786f68SRobert Mustacchi      * 1) Label
1813*35786f68SRobert Mustacchi      * 2) Vendor Data buffer
1814*35786f68SRobert Mustacchi      * 3) PIN (interrupt) list
1815*35786f68SRobert Mustacchi      */
1816*35786f68SRobert Mustacchi     LabelLength = RsGetStringDataLength (InitializerOp);
1817*35786f68SRobert Mustacchi     VendorLength = RsGetBufferDataLength (InitializerOp);
1818*35786f68SRobert Mustacchi     PinListLength = RsGetInterruptDataLength (InitializerOp, 4);
1819*35786f68SRobert Mustacchi 
1820*35786f68SRobert Mustacchi     DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_PIN_GROUP) +
1821*35786f68SRobert Mustacchi         LabelLength + VendorLength + PinListLength;
1822*35786f68SRobert Mustacchi 
1823*35786f68SRobert Mustacchi     /* Allocate the local resource node and initialize */
1824*35786f68SRobert Mustacchi 
1825*35786f68SRobert Mustacchi     Rnode = RsAllocateResourceNode (DescriptorSize +
1826*35786f68SRobert Mustacchi         sizeof (AML_RESOURCE_LARGE_HEADER));
1827*35786f68SRobert Mustacchi 
1828*35786f68SRobert Mustacchi     Descriptor = Rnode->Buffer;
1829*35786f68SRobert Mustacchi     Descriptor->PinGroup.ResourceLength = DescriptorSize;
1830*35786f68SRobert Mustacchi     Descriptor->PinGroup.DescriptorType = ACPI_RESOURCE_NAME_PIN_GROUP;
1831*35786f68SRobert Mustacchi     Descriptor->PinGroup.RevisionId = AML_RESOURCE_PIN_GROUP_REVISION;
1832*35786f68SRobert Mustacchi 
1833*35786f68SRobert Mustacchi     /* Build pointers to optional areas */
1834*35786f68SRobert Mustacchi 
1835*35786f68SRobert Mustacchi     PinList = ACPI_ADD_PTR (UINT16, Descriptor, sizeof (AML_RESOURCE_PIN_GROUP));
1836*35786f68SRobert Mustacchi     Label = ACPI_ADD_PTR (char, PinList, PinListLength);
1837*35786f68SRobert Mustacchi     VendorData = ACPI_ADD_PTR (UINT8, Label, LabelLength);
1838*35786f68SRobert Mustacchi 
1839*35786f68SRobert Mustacchi     /* Setup offsets within the descriptor */
1840*35786f68SRobert Mustacchi 
1841*35786f68SRobert Mustacchi     Descriptor->PinGroup.PinTableOffset = (UINT16) ACPI_PTR_DIFF (PinList, Descriptor);
1842*35786f68SRobert Mustacchi     Descriptor->PinGroup.LabelOffset = (UINT16) ACPI_PTR_DIFF (Label, Descriptor);
1843*35786f68SRobert Mustacchi 
1844*35786f68SRobert Mustacchi     /* Process all child initialization nodes */
1845*35786f68SRobert Mustacchi 
1846*35786f68SRobert Mustacchi     for (i = 0; InitializerOp; i++)
1847*35786f68SRobert Mustacchi     {
1848*35786f68SRobert Mustacchi         switch (i)
1849*35786f68SRobert Mustacchi         {
1850*35786f68SRobert Mustacchi         case 0: /* Resource Label */
1851*35786f68SRobert Mustacchi 
1852*35786f68SRobert Mustacchi             if (LabelLength < 2)
1853*35786f68SRobert Mustacchi             {
1854*35786f68SRobert Mustacchi                 AslError(ASL_WARNING, ASL_MSG_NULL_STRING, InitializerOp, NULL);
1855*35786f68SRobert Mustacchi             }
1856*35786f68SRobert Mustacchi             strcpy (Label, InitializerOp->Asl.Value.String);
1857*35786f68SRobert Mustacchi 
1858*35786f68SRobert Mustacchi             break;
1859*35786f68SRobert Mustacchi 
1860*35786f68SRobert Mustacchi         case 1: /* Resource Usage (consumer/producer) */
1861*35786f68SRobert Mustacchi 
1862*35786f68SRobert Mustacchi             RsSetFlagBits16 (&Descriptor->PinGroup.Flags, InitializerOp, 0, 0);
1863*35786f68SRobert Mustacchi 
1864*35786f68SRobert Mustacchi             break;
1865*35786f68SRobert Mustacchi 
1866*35786f68SRobert Mustacchi         case 2: /* Resource Tag (Descriptor Name) */
1867*35786f68SRobert Mustacchi 
1868*35786f68SRobert Mustacchi             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
1869*35786f68SRobert Mustacchi             break;
1870*35786f68SRobert Mustacchi 
1871*35786f68SRobert Mustacchi         case 3: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */
1872*35786f68SRobert Mustacchi             /*
1873*35786f68SRobert Mustacchi              * Always set the VendorOffset even if there is no Vendor Data.
1874*35786f68SRobert Mustacchi              * This field is required in order to calculate the length
1875*35786f68SRobert Mustacchi              * of the ResourceSource at runtime.
1876*35786f68SRobert Mustacchi              */
1877*35786f68SRobert Mustacchi             Descriptor->PinGroup.VendorOffset = (UINT16)
1878*35786f68SRobert Mustacchi                 ACPI_PTR_DIFF (VendorData, Descriptor);
1879*35786f68SRobert Mustacchi 
1880*35786f68SRobert Mustacchi             if (RsGetVendorData (InitializerOp, VendorData,
1881*35786f68SRobert Mustacchi                 (CurrentByteOffset + Descriptor->PinGroup.VendorOffset)))
1882*35786f68SRobert Mustacchi             {
1883*35786f68SRobert Mustacchi                 Descriptor->PinGroup.VendorLength = VendorLength;
1884*35786f68SRobert Mustacchi             }
1885*35786f68SRobert Mustacchi             break;
1886*35786f68SRobert Mustacchi 
1887*35786f68SRobert Mustacchi         default:
1888*35786f68SRobert Mustacchi             /*
1889*35786f68SRobert Mustacchi              * PINs come through here, repeatedly. Each PIN must be a WORD.
1890*35786f68SRobert Mustacchi              * NOTE: there is no "length" field for this, so from ACPI spec:
1891*35786f68SRobert Mustacchi              *  The number of pins in the table can be calculated from:
1892*35786f68SRobert Mustacchi              *  PinCount = (Resource Source Name Offset - Pin Table Offset) / 2
1893*35786f68SRobert Mustacchi              *  (implies resource source must immediately follow the pin list.)
1894*35786f68SRobert Mustacchi              *  Name: _PIN
1895*35786f68SRobert Mustacchi              */
1896*35786f68SRobert Mustacchi             *PinList = (UINT16) InitializerOp->Asl.Value.Integer;
1897*35786f68SRobert Mustacchi             PinList++;
1898*35786f68SRobert Mustacchi             PinCount++;
1899*35786f68SRobert Mustacchi 
1900*35786f68SRobert Mustacchi             /* Case 3: First pin number in list */
1901*35786f68SRobert Mustacchi 
1902*35786f68SRobert Mustacchi             if (i == 4)
1903*35786f68SRobert Mustacchi             {
1904*35786f68SRobert Mustacchi                 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
1905*35786f68SRobert Mustacchi                 {
1906*35786f68SRobert Mustacchi                     /* Must be at least one interrupt */
1907*35786f68SRobert Mustacchi 
1908*35786f68SRobert Mustacchi                     AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_LIST_MIN,
1909*35786f68SRobert Mustacchi                         InitializerOp, NULL);
1910*35786f68SRobert Mustacchi                 }
1911*35786f68SRobert Mustacchi 
1912*35786f68SRobert Mustacchi                 /* Check now for duplicates in list */
1913*35786f68SRobert Mustacchi 
1914*35786f68SRobert Mustacchi                 RsCheckListForDuplicates (InitializerOp);
1915*35786f68SRobert Mustacchi 
1916*35786f68SRobert Mustacchi                 /* Create a named field at the start of the list */
1917*35786f68SRobert Mustacchi 
1918*35786f68SRobert Mustacchi                 RsCreateWordField (InitializerOp, ACPI_RESTAG_PIN,
1919*35786f68SRobert Mustacchi                     CurrentByteOffset + Descriptor->PinGroup.PinTableOffset);
1920*35786f68SRobert Mustacchi             }
1921*35786f68SRobert Mustacchi             break;
1922*35786f68SRobert Mustacchi         }
1923*35786f68SRobert Mustacchi 
1924*35786f68SRobert Mustacchi         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1925*35786f68SRobert Mustacchi     }
1926*35786f68SRobert Mustacchi 
1927*35786f68SRobert Mustacchi     return (Rnode);
1928*35786f68SRobert Mustacchi }
1929*35786f68SRobert Mustacchi 
1930*35786f68SRobert Mustacchi 
1931*35786f68SRobert Mustacchi /*******************************************************************************
1932*35786f68SRobert Mustacchi  *
1933*35786f68SRobert Mustacchi  * FUNCTION:    RsDoPinGroupFunctionDescriptor
1934*35786f68SRobert Mustacchi  *
1935*35786f68SRobert Mustacchi  * PARAMETERS:  Info                - Parse Op and resource template offset
1936*35786f68SRobert Mustacchi  *
1937*35786f68SRobert Mustacchi  * RETURN:      Completed resource node
1938*35786f68SRobert Mustacchi  *
1939*35786f68SRobert Mustacchi  * DESCRIPTION: Construct a long "PinGroupFunction" descriptor
1940*35786f68SRobert Mustacchi  *
1941*35786f68SRobert Mustacchi  ******************************************************************************/
1942*35786f68SRobert Mustacchi 
1943*35786f68SRobert Mustacchi ASL_RESOURCE_NODE *
RsDoPinGroupFunctionDescriptor(ASL_RESOURCE_INFO * Info)1944*35786f68SRobert Mustacchi RsDoPinGroupFunctionDescriptor (
1945*35786f68SRobert Mustacchi     ASL_RESOURCE_INFO       *Info)
1946*35786f68SRobert Mustacchi {
1947*35786f68SRobert Mustacchi     AML_RESOURCE            *Descriptor;
1948*35786f68SRobert Mustacchi     ACPI_PARSE_OBJECT       *InitializerOp;
1949*35786f68SRobert Mustacchi     ASL_RESOURCE_NODE       *Rnode;
1950*35786f68SRobert Mustacchi     char                    *ResourceSource = NULL;
1951*35786f68SRobert Mustacchi     char                    *ResourceSourceLabel = NULL;
1952*35786f68SRobert Mustacchi     UINT8                   *VendorData = NULL;
1953*35786f68SRobert Mustacchi     UINT16                  ResSourceLength;
1954*35786f68SRobert Mustacchi     UINT16                  ResSourceLabelLength;
1955*35786f68SRobert Mustacchi     UINT16                  VendorLength;
1956*35786f68SRobert Mustacchi     UINT16                  DescriptorSize;
1957*35786f68SRobert Mustacchi     UINT32                  CurrentByteOffset;
1958*35786f68SRobert Mustacchi     UINT32                  i;
1959*35786f68SRobert Mustacchi 
1960*35786f68SRobert Mustacchi     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
1961*35786f68SRobert Mustacchi     CurrentByteOffset = Info->CurrentByteOffset;
1962*35786f68SRobert Mustacchi 
1963*35786f68SRobert Mustacchi     /*
1964*35786f68SRobert Mustacchi      * Calculate lengths for fields that have variable length:
1965*35786f68SRobert Mustacchi      * 1) Resource Source string
1966*35786f68SRobert Mustacchi      * 2) Resource Source Label string
1967*35786f68SRobert Mustacchi      * 3) Vendor Data buffer
1968*35786f68SRobert Mustacchi      */
1969*35786f68SRobert Mustacchi     ResSourceLength = RsGetStringDataLengthAt (InitializerOp, 2);
1970*35786f68SRobert Mustacchi     ResSourceLabelLength = RsGetStringDataLengthAt (InitializerOp, 4);
1971*35786f68SRobert Mustacchi     VendorLength = RsGetBufferDataLength (InitializerOp);
1972*35786f68SRobert Mustacchi 
1973*35786f68SRobert Mustacchi     DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_PIN_GROUP_FUNCTION) +
1974*35786f68SRobert Mustacchi         ResSourceLength + ResSourceLabelLength + VendorLength;
1975*35786f68SRobert Mustacchi 
1976*35786f68SRobert Mustacchi     /* Allocate the local resource node and initialize */
1977*35786f68SRobert Mustacchi 
1978*35786f68SRobert Mustacchi     Rnode = RsAllocateResourceNode (DescriptorSize +
1979*35786f68SRobert Mustacchi         sizeof (AML_RESOURCE_LARGE_HEADER));
1980*35786f68SRobert Mustacchi 
1981*35786f68SRobert Mustacchi     Descriptor = Rnode->Buffer;
1982*35786f68SRobert Mustacchi     Descriptor->PinGroupFunction.ResourceLength = DescriptorSize;
1983*35786f68SRobert Mustacchi     Descriptor->PinGroupFunction.DescriptorType = ACPI_RESOURCE_NAME_PIN_GROUP_FUNCTION;
1984*35786f68SRobert Mustacchi     Descriptor->PinGroupFunction.RevisionId = AML_RESOURCE_PIN_GROUP_FUNCTION_REVISION;
1985*35786f68SRobert Mustacchi 
1986*35786f68SRobert Mustacchi     /* Build pointers to optional areas */
1987*35786f68SRobert Mustacchi 
1988*35786f68SRobert Mustacchi     ResourceSource = ACPI_ADD_PTR (char, Descriptor, sizeof (AML_RESOURCE_PIN_GROUP_FUNCTION));
1989*35786f68SRobert Mustacchi     ResourceSourceLabel = ACPI_ADD_PTR (char, ResourceSource, ResSourceLength);
1990*35786f68SRobert Mustacchi     VendorData = ACPI_ADD_PTR (UINT8, ResourceSourceLabel, ResSourceLabelLength);
1991*35786f68SRobert Mustacchi 
1992*35786f68SRobert Mustacchi     /* Setup offsets within the descriptor */
1993*35786f68SRobert Mustacchi 
1994*35786f68SRobert Mustacchi     Descriptor->PinGroupFunction.ResSourceOffset = (UINT16)
1995*35786f68SRobert Mustacchi         ACPI_PTR_DIFF (ResourceSource, Descriptor);
1996*35786f68SRobert Mustacchi     Descriptor->PinGroupFunction.ResSourceLabelOffset = (UINT16)
1997*35786f68SRobert Mustacchi         ACPI_PTR_DIFF (ResourceSourceLabel, Descriptor);
1998*35786f68SRobert Mustacchi 
1999*35786f68SRobert Mustacchi     /* Process all child initialization nodes */
2000*35786f68SRobert Mustacchi 
2001*35786f68SRobert Mustacchi     for (i = 0; InitializerOp; i++)
2002*35786f68SRobert Mustacchi     {
2003*35786f68SRobert Mustacchi         switch (i)
2004*35786f68SRobert Mustacchi         {
2005*35786f68SRobert Mustacchi         case 0: /* Share Type [Flags] (_SHR) */
2006*35786f68SRobert Mustacchi 
2007*35786f68SRobert Mustacchi             RsSetFlagBits16 (&Descriptor->PinGroupFunction.Flags, InitializerOp, 0, 0);
2008*35786f68SRobert Mustacchi             RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
2009*35786f68SRobert Mustacchi                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinGroupFunction.Flags), 0);
2010*35786f68SRobert Mustacchi             break;
2011*35786f68SRobert Mustacchi 
2012*35786f68SRobert Mustacchi         case 1: /* Function Number [WORD] */
2013*35786f68SRobert Mustacchi 
2014*35786f68SRobert Mustacchi             Descriptor->PinGroupFunction.FunctionNumber = (UINT16) InitializerOp->Asl.Value.Integer;
2015*35786f68SRobert Mustacchi             RsCreateDwordField (InitializerOp, ACPI_RESTAG_FUNCTION,
2016*35786f68SRobert Mustacchi                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinGroupFunction.FunctionNumber));
2017*35786f68SRobert Mustacchi             break;
2018*35786f68SRobert Mustacchi 
2019*35786f68SRobert Mustacchi         case 2: /* ResourceSource [STRING] */
2020*35786f68SRobert Mustacchi 
2021*35786f68SRobert Mustacchi             strcpy (ResourceSource, InitializerOp->Asl.Value.String);
2022*35786f68SRobert Mustacchi             break;
2023*35786f68SRobert Mustacchi 
2024*35786f68SRobert Mustacchi         case 3: /* Resource Index */
2025*35786f68SRobert Mustacchi 
2026*35786f68SRobert Mustacchi             Descriptor->PinGroupFunction.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer;
2027*35786f68SRobert Mustacchi             break;
2028*35786f68SRobert Mustacchi 
2029*35786f68SRobert Mustacchi         case 4: /* ResourceSourceLabel [STRING] */
2030*35786f68SRobert Mustacchi 
2031*35786f68SRobert Mustacchi             if (ResSourceLabelLength < 2)
2032*35786f68SRobert Mustacchi             {
2033*35786f68SRobert Mustacchi                 AslError(ASL_WARNING, ASL_MSG_NULL_STRING, InitializerOp, NULL);
2034*35786f68SRobert Mustacchi             }
2035*35786f68SRobert Mustacchi 
2036*35786f68SRobert Mustacchi             strcpy (ResourceSourceLabel, InitializerOp->Asl.Value.String);
2037*35786f68SRobert Mustacchi             break;
2038*35786f68SRobert Mustacchi 
2039*35786f68SRobert Mustacchi         case 5: /* Resource Usage (consumer/producer) */
2040*35786f68SRobert Mustacchi 
2041*35786f68SRobert Mustacchi             RsSetFlagBits16 (&Descriptor->PinGroupFunction.Flags, InitializerOp, 1, 1);
2042*35786f68SRobert Mustacchi 
2043*35786f68SRobert Mustacchi             break;
2044*35786f68SRobert Mustacchi 
2045*35786f68SRobert Mustacchi         case 6: /* Resource Tag (Descriptor Name) */
2046*35786f68SRobert Mustacchi 
2047*35786f68SRobert Mustacchi             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
2048*35786f68SRobert Mustacchi             break;
2049*35786f68SRobert Mustacchi 
2050*35786f68SRobert Mustacchi         case 7: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */
2051*35786f68SRobert Mustacchi             /*
2052*35786f68SRobert Mustacchi              * Always set the VendorOffset even if there is no Vendor Data.
2053*35786f68SRobert Mustacchi              * This field is required in order to calculate the length
2054*35786f68SRobert Mustacchi              * of the ResourceSource at runtime.
2055*35786f68SRobert Mustacchi              */
2056*35786f68SRobert Mustacchi             Descriptor->PinGroupFunction.VendorOffset = (UINT16)
2057*35786f68SRobert Mustacchi                 ACPI_PTR_DIFF (VendorData, Descriptor);
2058*35786f68SRobert Mustacchi 
2059*35786f68SRobert Mustacchi             if (RsGetVendorData (InitializerOp, VendorData,
2060*35786f68SRobert Mustacchi                 (CurrentByteOffset + Descriptor->PinGroupFunction.VendorOffset)))
2061*35786f68SRobert Mustacchi             {
2062*35786f68SRobert Mustacchi                 Descriptor->PinGroupFunction.VendorLength = VendorLength;
2063*35786f68SRobert Mustacchi             }
2064*35786f68SRobert Mustacchi             break;
2065*35786f68SRobert Mustacchi 
2066*35786f68SRobert Mustacchi         default:
2067*35786f68SRobert Mustacchi             break;
2068*35786f68SRobert Mustacchi         }
2069*35786f68SRobert Mustacchi 
2070*35786f68SRobert Mustacchi         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
2071*35786f68SRobert Mustacchi     }
2072*35786f68SRobert Mustacchi 
2073*35786f68SRobert Mustacchi     return (Rnode);
2074*35786f68SRobert Mustacchi }
2075*35786f68SRobert Mustacchi 
2076*35786f68SRobert Mustacchi 
2077*35786f68SRobert Mustacchi /*******************************************************************************
2078*35786f68SRobert Mustacchi  *
2079*35786f68SRobert Mustacchi  * FUNCTION:    RsDoPinGroupConfigDescriptor
2080*35786f68SRobert Mustacchi  *
2081*35786f68SRobert Mustacchi  * PARAMETERS:  Info                - Parse Op and resource template offset
2082*35786f68SRobert Mustacchi  *
2083*35786f68SRobert Mustacchi  * RETURN:      Completed resource node
2084*35786f68SRobert Mustacchi  *
2085*35786f68SRobert Mustacchi  * DESCRIPTION: Construct a long "PinGroupConfig" descriptor
2086*35786f68SRobert Mustacchi  *
2087*35786f68SRobert Mustacchi  ******************************************************************************/
2088*35786f68SRobert Mustacchi 
2089*35786f68SRobert Mustacchi ASL_RESOURCE_NODE *
RsDoPinGroupConfigDescriptor(ASL_RESOURCE_INFO * Info)2090*35786f68SRobert Mustacchi RsDoPinGroupConfigDescriptor (
2091*35786f68SRobert Mustacchi     ASL_RESOURCE_INFO       *Info)
2092*35786f68SRobert Mustacchi {
2093*35786f68SRobert Mustacchi     AML_RESOURCE            *Descriptor;
2094*35786f68SRobert Mustacchi     ACPI_PARSE_OBJECT       *InitializerOp;
2095*35786f68SRobert Mustacchi     ASL_RESOURCE_NODE       *Rnode;
2096*35786f68SRobert Mustacchi     char                    *ResourceSource = NULL;
2097*35786f68SRobert Mustacchi     char                    *ResourceSourceLabel = NULL;
2098*35786f68SRobert Mustacchi     UINT8                   *VendorData = NULL;
2099*35786f68SRobert Mustacchi     UINT16                  ResSourceLength;
2100*35786f68SRobert Mustacchi     UINT16                  ResSourceLabelLength;
2101*35786f68SRobert Mustacchi     UINT16                  VendorLength;
2102*35786f68SRobert Mustacchi     UINT16                  DescriptorSize;
2103*35786f68SRobert Mustacchi     UINT32                  CurrentByteOffset;
2104*35786f68SRobert Mustacchi     UINT32                  i;
2105*35786f68SRobert Mustacchi 
2106*35786f68SRobert Mustacchi     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
2107*35786f68SRobert Mustacchi     CurrentByteOffset = Info->CurrentByteOffset;
2108*35786f68SRobert Mustacchi 
2109*35786f68SRobert Mustacchi     /*
2110*35786f68SRobert Mustacchi      * Calculate lengths for fields that have variable length:
2111*35786f68SRobert Mustacchi      * 1) Resource Source string
2112*35786f68SRobert Mustacchi      * 2) Resource Source Label string
2113*35786f68SRobert Mustacchi      * 3) Vendor Data buffer
2114*35786f68SRobert Mustacchi      */
2115*35786f68SRobert Mustacchi     ResSourceLength = RsGetStringDataLengthAt (InitializerOp, 3);
2116*35786f68SRobert Mustacchi     ResSourceLabelLength = RsGetStringDataLengthAt (InitializerOp, 5);
2117*35786f68SRobert Mustacchi     VendorLength = RsGetBufferDataLength (InitializerOp);
2118*35786f68SRobert Mustacchi 
2119*35786f68SRobert Mustacchi     DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_PIN_GROUP_CONFIG) +
2120*35786f68SRobert Mustacchi         ResSourceLength + ResSourceLabelLength + VendorLength;
2121*35786f68SRobert Mustacchi 
2122*35786f68SRobert Mustacchi     /* Allocate the local resource node and initialize */
2123*35786f68SRobert Mustacchi 
2124*35786f68SRobert Mustacchi     Rnode = RsAllocateResourceNode (DescriptorSize +
2125*35786f68SRobert Mustacchi         sizeof (AML_RESOURCE_LARGE_HEADER));
2126*35786f68SRobert Mustacchi 
2127*35786f68SRobert Mustacchi     Descriptor = Rnode->Buffer;
2128*35786f68SRobert Mustacchi     Descriptor->PinGroupConfig.ResourceLength = DescriptorSize;
2129*35786f68SRobert Mustacchi     Descriptor->PinGroupConfig.DescriptorType = ACPI_RESOURCE_NAME_PIN_GROUP_CONFIG;
2130*35786f68SRobert Mustacchi     Descriptor->PinGroupConfig.RevisionId = AML_RESOURCE_PIN_GROUP_CONFIG_REVISION;
2131*35786f68SRobert Mustacchi 
2132*35786f68SRobert Mustacchi     /* Build pointers to optional areas */
2133*35786f68SRobert Mustacchi 
2134*35786f68SRobert Mustacchi     ResourceSource = ACPI_ADD_PTR (char, Descriptor, sizeof (AML_RESOURCE_PIN_GROUP_CONFIG));
2135*35786f68SRobert Mustacchi     ResourceSourceLabel = ACPI_ADD_PTR (char, ResourceSource, ResSourceLength);
2136*35786f68SRobert Mustacchi     VendorData = ACPI_ADD_PTR (UINT8, ResourceSourceLabel, ResSourceLabelLength);
2137*35786f68SRobert Mustacchi 
2138*35786f68SRobert Mustacchi     /* Setup offsets within the descriptor */
2139*35786f68SRobert Mustacchi 
2140*35786f68SRobert Mustacchi     Descriptor->PinGroupConfig.ResSourceOffset = (UINT16)
2141*35786f68SRobert Mustacchi         ACPI_PTR_DIFF (ResourceSource, Descriptor);
2142*35786f68SRobert Mustacchi     Descriptor->PinGroupConfig.ResSourceLabelOffset = (UINT16)
2143*35786f68SRobert Mustacchi         ACPI_PTR_DIFF (ResourceSourceLabel, Descriptor);
2144*35786f68SRobert Mustacchi 
2145*35786f68SRobert Mustacchi     /* Process all child initialization nodes */
2146*35786f68SRobert Mustacchi 
2147*35786f68SRobert Mustacchi     for (i = 0; InitializerOp; i++)
2148*35786f68SRobert Mustacchi     {
2149*35786f68SRobert Mustacchi         BOOLEAN isValid;
2150*35786f68SRobert Mustacchi 
2151*35786f68SRobert Mustacchi         switch (i)
2152*35786f68SRobert Mustacchi         {
2153*35786f68SRobert Mustacchi         case 0: /* Share Type [Flags] (_SHR) */
2154*35786f68SRobert Mustacchi 
2155*35786f68SRobert Mustacchi             RsSetFlagBits16 (&Descriptor->PinGroupConfig.Flags, InitializerOp, 0, 0);
2156*35786f68SRobert Mustacchi             RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
2157*35786f68SRobert Mustacchi                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinGroupConfig.Flags), 0);
2158*35786f68SRobert Mustacchi             break;
2159*35786f68SRobert Mustacchi 
2160*35786f68SRobert Mustacchi         case 1: /* Pin Config Type [BYTE] (_TYP) */
2161*35786f68SRobert Mustacchi 
2162*35786f68SRobert Mustacchi             isValid = InitializerOp->Asl.Value.Integer <= 0x0d;
2163*35786f68SRobert Mustacchi             if (!isValid)
2164*35786f68SRobert Mustacchi             {
2165*35786f68SRobert Mustacchi                 isValid = InitializerOp->Asl.Value.Integer >= 0x80 &&
2166*35786f68SRobert Mustacchi                           InitializerOp->Asl.Value.Integer <= 0xff;
2167*35786f68SRobert Mustacchi             }
2168*35786f68SRobert Mustacchi             if (!isValid)
2169*35786f68SRobert Mustacchi             {
2170*35786f68SRobert Mustacchi                     AslError (ASL_ERROR, ASL_MSG_RANGE, InitializerOp, NULL);
2171*35786f68SRobert Mustacchi             }
2172*35786f68SRobert Mustacchi 
2173*35786f68SRobert Mustacchi             Descriptor->PinGroupConfig.PinConfigType = (UINT8) InitializerOp->Asl.Value.Integer;
2174*35786f68SRobert Mustacchi             RsCreateByteField (InitializerOp, ACPI_RESTAG_PINCONFIG_TYPE,
2175*35786f68SRobert Mustacchi                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinGroupConfig.PinConfigType));
2176*35786f68SRobert Mustacchi 
2177*35786f68SRobert Mustacchi             break;
2178*35786f68SRobert Mustacchi 
2179*35786f68SRobert Mustacchi         case 2: /* Pin Config Value [DWORD] (_VAL) */
2180*35786f68SRobert Mustacchi 
2181*35786f68SRobert Mustacchi             Descriptor->PinGroupConfig.PinConfigValue = (UINT32) InitializerOp->Asl.Value.Integer;
2182*35786f68SRobert Mustacchi             RsCreateDwordField (InitializerOp, ACPI_RESTAG_PINCONFIG_VALUE,
2183*35786f68SRobert Mustacchi                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinGroupConfig.PinConfigValue));
2184*35786f68SRobert Mustacchi             break;
2185*35786f68SRobert Mustacchi 
2186*35786f68SRobert Mustacchi         case 3: /* ResourceSource [STRING] */
2187*35786f68SRobert Mustacchi 
2188*35786f68SRobert Mustacchi             /* Copy string to the descriptor */
2189*35786f68SRobert Mustacchi 
2190*35786f68SRobert Mustacchi             strcpy (ResourceSource, InitializerOp->Asl.Value.String);
2191*35786f68SRobert Mustacchi             break;
2192*35786f68SRobert Mustacchi 
2193*35786f68SRobert Mustacchi         case 4: /* Resource Index */
2194*35786f68SRobert Mustacchi 
2195*35786f68SRobert Mustacchi             Descriptor->PinGroupConfig.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer;
2196*35786f68SRobert Mustacchi             break;
2197*35786f68SRobert Mustacchi 
2198*35786f68SRobert Mustacchi         case 5: /* ResourceSourceLabel [STRING] */
2199*35786f68SRobert Mustacchi 
2200*35786f68SRobert Mustacchi             if (ResSourceLabelLength < 2)
2201*35786f68SRobert Mustacchi             {
2202*35786f68SRobert Mustacchi                 AslError(ASL_WARNING, ASL_MSG_NULL_STRING, InitializerOp, NULL);
2203*35786f68SRobert Mustacchi             }
2204*35786f68SRobert Mustacchi 
2205*35786f68SRobert Mustacchi             strcpy (ResourceSourceLabel, InitializerOp->Asl.Value.String);
2206*35786f68SRobert Mustacchi             break;
2207*35786f68SRobert Mustacchi 
2208*35786f68SRobert Mustacchi         case 6: /* Resource Usage (consumer/producer) */
2209*35786f68SRobert Mustacchi 
2210*35786f68SRobert Mustacchi             RsSetFlagBits16 (&Descriptor->PinGroupConfig.Flags, InitializerOp, 1, 1);
2211*35786f68SRobert Mustacchi 
2212*35786f68SRobert Mustacchi             break;
2213*35786f68SRobert Mustacchi 
2214*35786f68SRobert Mustacchi         case 7: /* Resource Tag (Descriptor Name) */
2215*35786f68SRobert Mustacchi 
2216*35786f68SRobert Mustacchi             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
2217*35786f68SRobert Mustacchi             break;
2218*35786f68SRobert Mustacchi 
2219*35786f68SRobert Mustacchi         case 8: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */
2220*35786f68SRobert Mustacchi             /*
2221*35786f68SRobert Mustacchi              * Always set the VendorOffset even if there is no Vendor Data.
2222*35786f68SRobert Mustacchi              * This field is required in order to calculate the length
2223*35786f68SRobert Mustacchi              * of the ResourceSource at runtime.
2224*35786f68SRobert Mustacchi              */
2225*35786f68SRobert Mustacchi             Descriptor->PinGroupConfig.VendorOffset = (UINT16)
2226*35786f68SRobert Mustacchi                 ACPI_PTR_DIFF (VendorData, Descriptor);
2227*35786f68SRobert Mustacchi 
2228*35786f68SRobert Mustacchi             if (RsGetVendorData (InitializerOp, VendorData,
2229*35786f68SRobert Mustacchi                 (CurrentByteOffset + Descriptor->PinGroupConfig.VendorOffset)))
2230*35786f68SRobert Mustacchi             {
2231*35786f68SRobert Mustacchi                 Descriptor->PinGroupConfig.VendorLength = VendorLength;
2232*35786f68SRobert Mustacchi             }
2233*35786f68SRobert Mustacchi             break;
2234*35786f68SRobert Mustacchi 
2235*35786f68SRobert Mustacchi         default:
2236*35786f68SRobert Mustacchi             break;
2237*35786f68SRobert Mustacchi         }
2238*35786f68SRobert Mustacchi 
2239*35786f68SRobert Mustacchi         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
2240*35786f68SRobert Mustacchi     }
2241*35786f68SRobert Mustacchi 
2242*35786f68SRobert Mustacchi     return (Rnode);
2243*35786f68SRobert Mustacchi }
2244