1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "acinterp.h"
47
48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utids")
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68acpi_status
69acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
70 struct acpi_pnp_device_id **return_id)
71{
72 union acpi_operand_object *obj_desc;
73 struct acpi_pnp_device_id *hid;
74 u32 length;
75 acpi_status status;
76
77 ACPI_FUNCTION_TRACE(ut_execute_HID);
78
79 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__HID,
80 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
81 &obj_desc);
82 if (ACPI_FAILURE(status)) {
83 return_ACPI_STATUS(status);
84 }
85
86
87
88 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
89 length = ACPI_EISAID_STRING_SIZE;
90 } else {
91 length = obj_desc->string.length + 1;
92 }
93
94
95
96 hid =
97 ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) +
98 (acpi_size)length);
99 if (!hid) {
100 status = AE_NO_MEMORY;
101 goto cleanup;
102 }
103
104
105
106 hid->string =
107 ACPI_ADD_PTR(char, hid, sizeof(struct acpi_pnp_device_id));
108
109
110
111 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
112 acpi_ex_eisa_id_to_string(hid->string, obj_desc->integer.value);
113 } else {
114 strcpy(hid->string, obj_desc->string.pointer);
115 }
116
117 hid->length = length;
118 *return_id = hid;
119
120cleanup:
121
122
123
124 acpi_ut_remove_reference(obj_desc);
125 return_ACPI_STATUS(status);
126}
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146acpi_status
147acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
148 struct acpi_pnp_device_id **return_id)
149{
150 union acpi_operand_object *obj_desc;
151 struct acpi_pnp_device_id *uid;
152 u32 length;
153 acpi_status status;
154
155 ACPI_FUNCTION_TRACE(ut_execute_UID);
156
157 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__UID,
158 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
159 &obj_desc);
160 if (ACPI_FAILURE(status)) {
161 return_ACPI_STATUS(status);
162 }
163
164
165
166 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
167 length = ACPI_MAX64_DECIMAL_DIGITS + 1;
168 } else {
169 length = obj_desc->string.length + 1;
170 }
171
172
173
174 uid =
175 ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) +
176 (acpi_size)length);
177 if (!uid) {
178 status = AE_NO_MEMORY;
179 goto cleanup;
180 }
181
182
183
184 uid->string =
185 ACPI_ADD_PTR(char, uid, sizeof(struct acpi_pnp_device_id));
186
187
188
189 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
190 acpi_ex_integer_to_string(uid->string, obj_desc->integer.value);
191 } else {
192 strcpy(uid->string, obj_desc->string.pointer);
193 }
194
195 uid->length = length;
196 *return_id = uid;
197
198cleanup:
199
200
201
202 acpi_ut_remove_reference(obj_desc);
203 return_ACPI_STATUS(status);
204}
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229acpi_status
230acpi_ut_execute_CID(struct acpi_namespace_node *device_node,
231 struct acpi_pnp_device_id_list **return_cid_list)
232{
233 union acpi_operand_object **cid_objects;
234 union acpi_operand_object *obj_desc;
235 struct acpi_pnp_device_id_list *cid_list;
236 char *next_id_string;
237 u32 string_area_size;
238 u32 length;
239 u32 cid_list_size;
240 acpi_status status;
241 u32 count;
242 u32 i;
243
244 ACPI_FUNCTION_TRACE(ut_execute_CID);
245
246
247
248 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CID,
249 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING
250 | ACPI_BTYPE_PACKAGE, &obj_desc);
251 if (ACPI_FAILURE(status)) {
252 return_ACPI_STATUS(status);
253 }
254
255
256
257
258
259
260
261 if (obj_desc->common.type == ACPI_TYPE_PACKAGE) {
262 count = obj_desc->package.count;
263 cid_objects = obj_desc->package.elements;
264 } else {
265
266 count = 1;
267 cid_objects = &obj_desc;
268 }
269
270 string_area_size = 0;
271 for (i = 0; i < count; i++) {
272
273
274
275 switch (cid_objects[i]->common.type) {
276 case ACPI_TYPE_INTEGER:
277
278 string_area_size += ACPI_EISAID_STRING_SIZE;
279 break;
280
281 case ACPI_TYPE_STRING:
282
283 string_area_size += cid_objects[i]->string.length + 1;
284 break;
285
286 default:
287
288 status = AE_TYPE;
289 goto cleanup;
290 }
291 }
292
293
294
295
296
297
298
299 cid_list_size = sizeof(struct acpi_pnp_device_id_list) +
300 ((count - 1) * sizeof(struct acpi_pnp_device_id)) +
301 string_area_size;
302
303 cid_list = ACPI_ALLOCATE_ZEROED(cid_list_size);
304 if (!cid_list) {
305 status = AE_NO_MEMORY;
306 goto cleanup;
307 }
308
309
310
311 next_id_string = ACPI_CAST_PTR(char, cid_list->ids) +
312 ((acpi_size)count * sizeof(struct acpi_pnp_device_id));
313
314
315
316 for (i = 0; i < count; i++) {
317 if (cid_objects[i]->common.type == ACPI_TYPE_INTEGER) {
318
319
320
321 acpi_ex_eisa_id_to_string(next_id_string,
322 cid_objects[i]->integer.
323 value);
324 length = ACPI_EISAID_STRING_SIZE;
325 } else {
326
327
328
329 strcpy(next_id_string, cid_objects[i]->string.pointer);
330 length = cid_objects[i]->string.length + 1;
331 }
332
333 cid_list->ids[i].string = next_id_string;
334 cid_list->ids[i].length = length;
335 next_id_string += length;
336 }
337
338
339
340 cid_list->count = count;
341 cid_list->list_size = cid_list_size;
342 *return_cid_list = cid_list;
343
344cleanup:
345
346
347
348 acpi_ut_remove_reference(obj_desc);
349 return_ACPI_STATUS(status);
350}
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371acpi_status
372acpi_ut_execute_CLS(struct acpi_namespace_node *device_node,
373 struct acpi_pnp_device_id **return_id)
374{
375 union acpi_operand_object *obj_desc;
376 union acpi_operand_object **cls_objects;
377 u32 count;
378 struct acpi_pnp_device_id *cls;
379 u32 length;
380 acpi_status status;
381 u8 class_code[3] = { 0, 0, 0 };
382
383 ACPI_FUNCTION_TRACE(ut_execute_CLS);
384
385 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CLS,
386 ACPI_BTYPE_PACKAGE, &obj_desc);
387 if (ACPI_FAILURE(status)) {
388 return_ACPI_STATUS(status);
389 }
390
391
392
393 length = ACPI_PCICLS_STRING_SIZE;
394 cls_objects = obj_desc->package.elements;
395 count = obj_desc->package.count;
396
397 if (obj_desc->common.type == ACPI_TYPE_PACKAGE) {
398 if (count > 0
399 && cls_objects[0]->common.type == ACPI_TYPE_INTEGER) {
400 class_code[0] = (u8)cls_objects[0]->integer.value;
401 }
402 if (count > 1
403 && cls_objects[1]->common.type == ACPI_TYPE_INTEGER) {
404 class_code[1] = (u8)cls_objects[1]->integer.value;
405 }
406 if (count > 2
407 && cls_objects[2]->common.type == ACPI_TYPE_INTEGER) {
408 class_code[2] = (u8)cls_objects[2]->integer.value;
409 }
410 }
411
412
413
414 cls =
415 ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) +
416 (acpi_size)length);
417 if (!cls) {
418 status = AE_NO_MEMORY;
419 goto cleanup;
420 }
421
422
423
424 cls->string =
425 ACPI_ADD_PTR(char, cls, sizeof(struct acpi_pnp_device_id));
426
427
428
429 acpi_ex_pci_cls_to_string(cls->string, class_code);
430 cls->length = length;
431 *return_id = cls;
432
433cleanup:
434
435
436
437 acpi_ut_remove_reference(obj_desc);
438 return_ACPI_STATUS(status);
439}
440