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