utids.c revision 1.1.1.13 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.1.1.6 christos * Module Name: utids - support for device IDs - HID, UID, CID, SUB, CLS
4 1.1 jruoho *
5 1.1 jruoho *****************************************************************************/
6 1.1 jruoho
7 1.1.1.2 jruoho /*
8 1.1.1.13 christos * Copyright (C) 2000 - 2021, Intel Corp.
9 1.1 jruoho * All rights reserved.
10 1.1 jruoho *
11 1.1.1.2 jruoho * Redistribution and use in source and binary forms, with or without
12 1.1.1.2 jruoho * modification, are permitted provided that the following conditions
13 1.1.1.2 jruoho * are met:
14 1.1.1.2 jruoho * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2 jruoho * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2 jruoho * without modification.
17 1.1.1.2 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2 jruoho * including a substantially similar Disclaimer requirement for further
21 1.1.1.2 jruoho * binary redistribution.
22 1.1.1.2 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2 jruoho * of any contributors may be used to endorse or promote products derived
24 1.1.1.2 jruoho * from this software without specific prior written permission.
25 1.1.1.2 jruoho *
26 1.1.1.2 jruoho * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2 jruoho * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2 jruoho * Software Foundation.
29 1.1.1.2 jruoho *
30 1.1.1.2 jruoho * NO WARRANTY
31 1.1.1.2 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.13 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34 1.1.1.2 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2 jruoho * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2 jruoho * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2 jruoho * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2 jruoho * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2 jruoho * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2 jruoho * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2 jruoho * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2 jruoho */
43 1.1 jruoho
44 1.1 jruoho #include "acpi.h"
45 1.1 jruoho #include "accommon.h"
46 1.1 jruoho #include "acinterp.h"
47 1.1 jruoho
48 1.1 jruoho
49 1.1 jruoho #define _COMPONENT ACPI_UTILITIES
50 1.1 jruoho ACPI_MODULE_NAME ("utids")
51 1.1 jruoho
52 1.1 jruoho
53 1.1 jruoho /*******************************************************************************
54 1.1 jruoho *
55 1.1 jruoho * FUNCTION: AcpiUtExecute_HID
56 1.1 jruoho *
57 1.1 jruoho * PARAMETERS: DeviceNode - Node for the device
58 1.1 jruoho * ReturnId - Where the string HID is returned
59 1.1 jruoho *
60 1.1 jruoho * RETURN: Status
61 1.1 jruoho *
62 1.1 jruoho * DESCRIPTION: Executes the _HID control method that returns the hardware
63 1.1 jruoho * ID of the device. The HID is either an 32-bit encoded EISAID
64 1.1 jruoho * Integer or a String. A string is always returned. An EISAID
65 1.1 jruoho * is converted to a string.
66 1.1 jruoho *
67 1.1 jruoho * NOTE: Internal function, no parameter validation
68 1.1 jruoho *
69 1.1 jruoho ******************************************************************************/
70 1.1 jruoho
71 1.1 jruoho ACPI_STATUS
72 1.1 jruoho AcpiUtExecute_HID (
73 1.1 jruoho ACPI_NAMESPACE_NODE *DeviceNode,
74 1.1.1.3 christos ACPI_PNP_DEVICE_ID **ReturnId)
75 1.1 jruoho {
76 1.1 jruoho ACPI_OPERAND_OBJECT *ObjDesc;
77 1.1.1.3 christos ACPI_PNP_DEVICE_ID *Hid;
78 1.1 jruoho UINT32 Length;
79 1.1 jruoho ACPI_STATUS Status;
80 1.1 jruoho
81 1.1 jruoho
82 1.1 jruoho ACPI_FUNCTION_TRACE (UtExecute_HID);
83 1.1 jruoho
84 1.1 jruoho
85 1.1 jruoho Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID,
86 1.1.1.7 christos ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
87 1.1 jruoho if (ACPI_FAILURE (Status))
88 1.1 jruoho {
89 1.1 jruoho return_ACPI_STATUS (Status);
90 1.1 jruoho }
91 1.1 jruoho
92 1.1 jruoho /* Get the size of the String to be returned, includes null terminator */
93 1.1 jruoho
94 1.1 jruoho if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
95 1.1 jruoho {
96 1.1 jruoho Length = ACPI_EISAID_STRING_SIZE;
97 1.1 jruoho }
98 1.1 jruoho else
99 1.1 jruoho {
100 1.1 jruoho Length = ObjDesc->String.Length + 1;
101 1.1 jruoho }
102 1.1 jruoho
103 1.1 jruoho /* Allocate a buffer for the HID */
104 1.1 jruoho
105 1.1.1.7 christos Hid = ACPI_ALLOCATE_ZEROED (
106 1.1.1.7 christos sizeof (ACPI_PNP_DEVICE_ID) + (ACPI_SIZE) Length);
107 1.1 jruoho if (!Hid)
108 1.1 jruoho {
109 1.1 jruoho Status = AE_NO_MEMORY;
110 1.1 jruoho goto Cleanup;
111 1.1 jruoho }
112 1.1 jruoho
113 1.1.1.3 christos /* Area for the string starts after PNP_DEVICE_ID struct */
114 1.1 jruoho
115 1.1.1.3 christos Hid->String = ACPI_ADD_PTR (char, Hid, sizeof (ACPI_PNP_DEVICE_ID));
116 1.1 jruoho
117 1.1 jruoho /* Convert EISAID to a string or simply copy existing string */
118 1.1 jruoho
119 1.1 jruoho if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
120 1.1 jruoho {
121 1.1 jruoho AcpiExEisaIdToString (Hid->String, ObjDesc->Integer.Value);
122 1.1 jruoho }
123 1.1 jruoho else
124 1.1 jruoho {
125 1.1.1.6 christos strcpy (Hid->String, ObjDesc->String.Pointer);
126 1.1 jruoho }
127 1.1 jruoho
128 1.1 jruoho Hid->Length = Length;
129 1.1 jruoho *ReturnId = Hid;
130 1.1 jruoho
131 1.1 jruoho
132 1.1 jruoho Cleanup:
133 1.1 jruoho
134 1.1 jruoho /* On exit, we must delete the return object */
135 1.1 jruoho
136 1.1 jruoho AcpiUtRemoveReference (ObjDesc);
137 1.1 jruoho return_ACPI_STATUS (Status);
138 1.1 jruoho }
139 1.1 jruoho
140 1.1 jruoho
141 1.1 jruoho /*******************************************************************************
142 1.1 jruoho *
143 1.1 jruoho * FUNCTION: AcpiUtExecute_UID
144 1.1 jruoho *
145 1.1 jruoho * PARAMETERS: DeviceNode - Node for the device
146 1.1 jruoho * ReturnId - Where the string UID is returned
147 1.1 jruoho *
148 1.1 jruoho * RETURN: Status
149 1.1 jruoho *
150 1.1 jruoho * DESCRIPTION: Executes the _UID control method that returns the unique
151 1.1 jruoho * ID of the device. The UID is either a 64-bit Integer (NOT an
152 1.1 jruoho * EISAID) or a string. Always returns a string. A 64-bit integer
153 1.1 jruoho * is converted to a decimal string.
154 1.1 jruoho *
155 1.1 jruoho * NOTE: Internal function, no parameter validation
156 1.1 jruoho *
157 1.1 jruoho ******************************************************************************/
158 1.1 jruoho
159 1.1 jruoho ACPI_STATUS
160 1.1 jruoho AcpiUtExecute_UID (
161 1.1 jruoho ACPI_NAMESPACE_NODE *DeviceNode,
162 1.1.1.3 christos ACPI_PNP_DEVICE_ID **ReturnId)
163 1.1 jruoho {
164 1.1 jruoho ACPI_OPERAND_OBJECT *ObjDesc;
165 1.1.1.3 christos ACPI_PNP_DEVICE_ID *Uid;
166 1.1 jruoho UINT32 Length;
167 1.1 jruoho ACPI_STATUS Status;
168 1.1 jruoho
169 1.1 jruoho
170 1.1 jruoho ACPI_FUNCTION_TRACE (UtExecute_UID);
171 1.1 jruoho
172 1.1 jruoho
173 1.1 jruoho Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID,
174 1.1.1.7 christos ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
175 1.1 jruoho if (ACPI_FAILURE (Status))
176 1.1 jruoho {
177 1.1 jruoho return_ACPI_STATUS (Status);
178 1.1 jruoho }
179 1.1 jruoho
180 1.1 jruoho /* Get the size of the String to be returned, includes null terminator */
181 1.1 jruoho
182 1.1 jruoho if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
183 1.1 jruoho {
184 1.1 jruoho Length = ACPI_MAX64_DECIMAL_DIGITS + 1;
185 1.1 jruoho }
186 1.1 jruoho else
187 1.1 jruoho {
188 1.1 jruoho Length = ObjDesc->String.Length + 1;
189 1.1 jruoho }
190 1.1 jruoho
191 1.1 jruoho /* Allocate a buffer for the UID */
192 1.1 jruoho
193 1.1.1.7 christos Uid = ACPI_ALLOCATE_ZEROED (
194 1.1.1.7 christos sizeof (ACPI_PNP_DEVICE_ID) + (ACPI_SIZE) Length);
195 1.1 jruoho if (!Uid)
196 1.1 jruoho {
197 1.1 jruoho Status = AE_NO_MEMORY;
198 1.1 jruoho goto Cleanup;
199 1.1 jruoho }
200 1.1 jruoho
201 1.1.1.3 christos /* Area for the string starts after PNP_DEVICE_ID struct */
202 1.1 jruoho
203 1.1.1.3 christos Uid->String = ACPI_ADD_PTR (char, Uid, sizeof (ACPI_PNP_DEVICE_ID));
204 1.1 jruoho
205 1.1 jruoho /* Convert an Integer to string, or just copy an existing string */
206 1.1 jruoho
207 1.1 jruoho if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
208 1.1 jruoho {
209 1.1 jruoho AcpiExIntegerToString (Uid->String, ObjDesc->Integer.Value);
210 1.1 jruoho }
211 1.1 jruoho else
212 1.1 jruoho {
213 1.1.1.6 christos strcpy (Uid->String, ObjDesc->String.Pointer);
214 1.1 jruoho }
215 1.1 jruoho
216 1.1 jruoho Uid->Length = Length;
217 1.1 jruoho *ReturnId = Uid;
218 1.1 jruoho
219 1.1 jruoho
220 1.1 jruoho Cleanup:
221 1.1 jruoho
222 1.1 jruoho /* On exit, we must delete the return object */
223 1.1 jruoho
224 1.1 jruoho AcpiUtRemoveReference (ObjDesc);
225 1.1 jruoho return_ACPI_STATUS (Status);
226 1.1 jruoho }
227 1.1 jruoho
228 1.1 jruoho
229 1.1 jruoho /*******************************************************************************
230 1.1 jruoho *
231 1.1 jruoho * FUNCTION: AcpiUtExecute_CID
232 1.1 jruoho *
233 1.1 jruoho * PARAMETERS: DeviceNode - Node for the device
234 1.1 jruoho * ReturnCidList - Where the CID list is returned
235 1.1 jruoho *
236 1.1 jruoho * RETURN: Status, list of CID strings
237 1.1 jruoho *
238 1.1 jruoho * DESCRIPTION: Executes the _CID control method that returns one or more
239 1.1 jruoho * compatible hardware IDs for the device.
240 1.1 jruoho *
241 1.1 jruoho * NOTE: Internal function, no parameter validation
242 1.1 jruoho *
243 1.1 jruoho * A _CID method can return either a single compatible ID or a package of
244 1.1 jruoho * compatible IDs. Each compatible ID can be one of the following:
245 1.1 jruoho * 1) Integer (32 bit compressed EISA ID) or
246 1.1 jruoho * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss")
247 1.1 jruoho *
248 1.1 jruoho * The Integer CIDs are converted to string format by this function.
249 1.1 jruoho *
250 1.1 jruoho ******************************************************************************/
251 1.1 jruoho
252 1.1 jruoho ACPI_STATUS
253 1.1 jruoho AcpiUtExecute_CID (
254 1.1 jruoho ACPI_NAMESPACE_NODE *DeviceNode,
255 1.1.1.3 christos ACPI_PNP_DEVICE_ID_LIST **ReturnCidList)
256 1.1 jruoho {
257 1.1 jruoho ACPI_OPERAND_OBJECT **CidObjects;
258 1.1 jruoho ACPI_OPERAND_OBJECT *ObjDesc;
259 1.1.1.3 christos ACPI_PNP_DEVICE_ID_LIST *CidList;
260 1.1 jruoho char *NextIdString;
261 1.1 jruoho UINT32 StringAreaSize;
262 1.1 jruoho UINT32 Length;
263 1.1 jruoho UINT32 CidListSize;
264 1.1 jruoho ACPI_STATUS Status;
265 1.1 jruoho UINT32 Count;
266 1.1 jruoho UINT32 i;
267 1.1 jruoho
268 1.1 jruoho
269 1.1 jruoho ACPI_FUNCTION_TRACE (UtExecute_CID);
270 1.1 jruoho
271 1.1 jruoho
272 1.1 jruoho /* Evaluate the _CID method for this device */
273 1.1 jruoho
274 1.1 jruoho Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID,
275 1.1.1.7 christos ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE,
276 1.1.1.7 christos &ObjDesc);
277 1.1 jruoho if (ACPI_FAILURE (Status))
278 1.1 jruoho {
279 1.1 jruoho return_ACPI_STATUS (Status);
280 1.1 jruoho }
281 1.1 jruoho
282 1.1 jruoho /*
283 1.1 jruoho * Get the count and size of the returned _CIDs. _CID can return either
284 1.1 jruoho * a Package of Integers/Strings or a single Integer or String.
285 1.1 jruoho * Note: This section also validates that all CID elements are of the
286 1.1 jruoho * correct type (Integer or String).
287 1.1 jruoho */
288 1.1 jruoho if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE)
289 1.1 jruoho {
290 1.1 jruoho Count = ObjDesc->Package.Count;
291 1.1 jruoho CidObjects = ObjDesc->Package.Elements;
292 1.1 jruoho }
293 1.1 jruoho else /* Single Integer or String CID */
294 1.1 jruoho {
295 1.1 jruoho Count = 1;
296 1.1 jruoho CidObjects = &ObjDesc;
297 1.1 jruoho }
298 1.1 jruoho
299 1.1 jruoho StringAreaSize = 0;
300 1.1 jruoho for (i = 0; i < Count; i++)
301 1.1 jruoho {
302 1.1 jruoho /* String lengths include null terminator */
303 1.1 jruoho
304 1.1 jruoho switch (CidObjects[i]->Common.Type)
305 1.1 jruoho {
306 1.1 jruoho case ACPI_TYPE_INTEGER:
307 1.1.1.3 christos
308 1.1 jruoho StringAreaSize += ACPI_EISAID_STRING_SIZE;
309 1.1 jruoho break;
310 1.1 jruoho
311 1.1 jruoho case ACPI_TYPE_STRING:
312 1.1.1.3 christos
313 1.1 jruoho StringAreaSize += CidObjects[i]->String.Length + 1;
314 1.1 jruoho break;
315 1.1 jruoho
316 1.1 jruoho default:
317 1.1.1.3 christos
318 1.1 jruoho Status = AE_TYPE;
319 1.1 jruoho goto Cleanup;
320 1.1 jruoho }
321 1.1 jruoho }
322 1.1 jruoho
323 1.1 jruoho /*
324 1.1 jruoho * Now that we know the length of the CIDs, allocate return buffer:
325 1.1 jruoho * 1) Size of the base structure +
326 1.1.1.3 christos * 2) Size of the CID PNP_DEVICE_ID array +
327 1.1 jruoho * 3) Size of the actual CID strings
328 1.1 jruoho */
329 1.1.1.3 christos CidListSize = sizeof (ACPI_PNP_DEVICE_ID_LIST) +
330 1.1.1.12 christos (Count * sizeof (ACPI_PNP_DEVICE_ID)) +
331 1.1 jruoho StringAreaSize;
332 1.1 jruoho
333 1.1 jruoho CidList = ACPI_ALLOCATE_ZEROED (CidListSize);
334 1.1 jruoho if (!CidList)
335 1.1 jruoho {
336 1.1 jruoho Status = AE_NO_MEMORY;
337 1.1 jruoho goto Cleanup;
338 1.1 jruoho }
339 1.1 jruoho
340 1.1.1.3 christos /* Area for CID strings starts after the CID PNP_DEVICE_ID array */
341 1.1 jruoho
342 1.1 jruoho NextIdString = ACPI_CAST_PTR (char, CidList->Ids) +
343 1.1.1.3 christos ((ACPI_SIZE) Count * sizeof (ACPI_PNP_DEVICE_ID));
344 1.1 jruoho
345 1.1 jruoho /* Copy/convert the CIDs to the return buffer */
346 1.1 jruoho
347 1.1 jruoho for (i = 0; i < Count; i++)
348 1.1 jruoho {
349 1.1 jruoho if (CidObjects[i]->Common.Type == ACPI_TYPE_INTEGER)
350 1.1 jruoho {
351 1.1 jruoho /* Convert the Integer (EISAID) CID to a string */
352 1.1 jruoho
353 1.1.1.7 christos AcpiExEisaIdToString (
354 1.1.1.7 christos NextIdString, CidObjects[i]->Integer.Value);
355 1.1 jruoho Length = ACPI_EISAID_STRING_SIZE;
356 1.1 jruoho }
357 1.1 jruoho else /* ACPI_TYPE_STRING */
358 1.1 jruoho {
359 1.1 jruoho /* Copy the String CID from the returned object */
360 1.1 jruoho
361 1.1.1.6 christos strcpy (NextIdString, CidObjects[i]->String.Pointer);
362 1.1 jruoho Length = CidObjects[i]->String.Length + 1;
363 1.1 jruoho }
364 1.1 jruoho
365 1.1 jruoho CidList->Ids[i].String = NextIdString;
366 1.1 jruoho CidList->Ids[i].Length = Length;
367 1.1 jruoho NextIdString += Length;
368 1.1 jruoho }
369 1.1 jruoho
370 1.1 jruoho /* Finish the CID list */
371 1.1 jruoho
372 1.1 jruoho CidList->Count = Count;
373 1.1 jruoho CidList->ListSize = CidListSize;
374 1.1 jruoho *ReturnCidList = CidList;
375 1.1 jruoho
376 1.1 jruoho
377 1.1 jruoho Cleanup:
378 1.1 jruoho
379 1.1 jruoho /* On exit, we must delete the _CID return object */
380 1.1 jruoho
381 1.1 jruoho AcpiUtRemoveReference (ObjDesc);
382 1.1 jruoho return_ACPI_STATUS (Status);
383 1.1 jruoho }
384 1.1.1.6 christos
385 1.1.1.6 christos
386 1.1.1.6 christos /*******************************************************************************
387 1.1.1.6 christos *
388 1.1.1.6 christos * FUNCTION: AcpiUtExecute_CLS
389 1.1.1.6 christos *
390 1.1.1.6 christos * PARAMETERS: DeviceNode - Node for the device
391 1.1.1.6 christos * ReturnId - Where the _CLS is returned
392 1.1.1.6 christos *
393 1.1.1.6 christos * RETURN: Status
394 1.1.1.6 christos *
395 1.1.1.6 christos * DESCRIPTION: Executes the _CLS control method that returns PCI-defined
396 1.1.1.6 christos * class code of the device. The _CLS value is always a package
397 1.1.1.6 christos * containing PCI class information as a list of integers.
398 1.1.1.6 christos * The returned string has format "BBSSPP", where:
399 1.1.1.6 christos * BB = Base-class code
400 1.1.1.6 christos * SS = Sub-class code
401 1.1.1.6 christos * PP = Programming Interface code
402 1.1.1.6 christos *
403 1.1.1.6 christos ******************************************************************************/
404 1.1.1.6 christos
405 1.1.1.6 christos ACPI_STATUS
406 1.1.1.6 christos AcpiUtExecute_CLS (
407 1.1.1.6 christos ACPI_NAMESPACE_NODE *DeviceNode,
408 1.1.1.6 christos ACPI_PNP_DEVICE_ID **ReturnId)
409 1.1.1.6 christos {
410 1.1.1.6 christos ACPI_OPERAND_OBJECT *ObjDesc;
411 1.1.1.6 christos ACPI_OPERAND_OBJECT **ClsObjects;
412 1.1.1.6 christos UINT32 Count;
413 1.1.1.6 christos ACPI_PNP_DEVICE_ID *Cls;
414 1.1.1.6 christos UINT32 Length;
415 1.1.1.6 christos ACPI_STATUS Status;
416 1.1.1.6 christos UINT8 ClassCode[3] = {0, 0, 0};
417 1.1.1.6 christos
418 1.1.1.6 christos
419 1.1.1.6 christos ACPI_FUNCTION_TRACE (UtExecute_CLS);
420 1.1.1.6 christos
421 1.1.1.6 christos
422 1.1.1.6 christos Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CLS,
423 1.1.1.7 christos ACPI_BTYPE_PACKAGE, &ObjDesc);
424 1.1.1.6 christos if (ACPI_FAILURE (Status))
425 1.1.1.6 christos {
426 1.1.1.6 christos return_ACPI_STATUS (Status);
427 1.1.1.6 christos }
428 1.1.1.6 christos
429 1.1.1.6 christos /* Get the size of the String to be returned, includes null terminator */
430 1.1.1.6 christos
431 1.1.1.6 christos Length = ACPI_PCICLS_STRING_SIZE;
432 1.1.1.6 christos ClsObjects = ObjDesc->Package.Elements;
433 1.1.1.6 christos Count = ObjDesc->Package.Count;
434 1.1.1.6 christos
435 1.1.1.6 christos if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE)
436 1.1.1.6 christos {
437 1.1.1.6 christos if (Count > 0 && ClsObjects[0]->Common.Type == ACPI_TYPE_INTEGER)
438 1.1.1.6 christos {
439 1.1.1.6 christos ClassCode[0] = (UINT8) ClsObjects[0]->Integer.Value;
440 1.1.1.6 christos }
441 1.1.1.6 christos if (Count > 1 && ClsObjects[1]->Common.Type == ACPI_TYPE_INTEGER)
442 1.1.1.6 christos {
443 1.1.1.6 christos ClassCode[1] = (UINT8) ClsObjects[1]->Integer.Value;
444 1.1.1.6 christos }
445 1.1.1.6 christos if (Count > 2 && ClsObjects[2]->Common.Type == ACPI_TYPE_INTEGER)
446 1.1.1.6 christos {
447 1.1.1.6 christos ClassCode[2] = (UINT8) ClsObjects[2]->Integer.Value;
448 1.1.1.6 christos }
449 1.1.1.6 christos }
450 1.1.1.6 christos
451 1.1.1.6 christos /* Allocate a buffer for the CLS */
452 1.1.1.6 christos
453 1.1.1.7 christos Cls = ACPI_ALLOCATE_ZEROED (
454 1.1.1.7 christos sizeof (ACPI_PNP_DEVICE_ID) + (ACPI_SIZE) Length);
455 1.1.1.6 christos if (!Cls)
456 1.1.1.6 christos {
457 1.1.1.6 christos Status = AE_NO_MEMORY;
458 1.1.1.6 christos goto Cleanup;
459 1.1.1.6 christos }
460 1.1.1.6 christos
461 1.1.1.6 christos /* Area for the string starts after PNP_DEVICE_ID struct */
462 1.1.1.6 christos
463 1.1.1.6 christos Cls->String = ACPI_ADD_PTR (char, Cls, sizeof (ACPI_PNP_DEVICE_ID));
464 1.1.1.6 christos
465 1.1.1.6 christos /* Simply copy existing string */
466 1.1.1.6 christos
467 1.1.1.6 christos AcpiExPciClsToString (Cls->String, ClassCode);
468 1.1.1.6 christos Cls->Length = Length;
469 1.1.1.6 christos *ReturnId = Cls;
470 1.1.1.6 christos
471 1.1.1.6 christos
472 1.1.1.6 christos Cleanup:
473 1.1.1.6 christos
474 1.1.1.6 christos /* On exit, we must delete the return object */
475 1.1.1.6 christos
476 1.1.1.6 christos AcpiUtRemoveReference (ObjDesc);
477 1.1.1.6 christos return_ACPI_STATUS (Status);
478 1.1.1.6 christos }
479