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
145acpi_status
146acpi_ut_execute_SUB(struct acpi_namespace_node *device_node,
147 struct acpi_pnp_device_id **return_id)
148{
149 union acpi_operand_object *obj_desc;
150 struct acpi_pnp_device_id *sub;
151 u32 length;
152 acpi_status status;
153
154 ACPI_FUNCTION_TRACE(ut_execute_SUB);
155
156 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__SUB,
157 ACPI_BTYPE_STRING, &obj_desc);
158 if (ACPI_FAILURE(status)) {
159 return_ACPI_STATUS(status);
160 }
161
162
163
164 length = obj_desc->string.length + 1;
165
166
167
168 sub =
169 ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) +
170 (acpi_size) length);
171 if (!sub) {
172 status = AE_NO_MEMORY;
173 goto cleanup;
174 }
175
176
177
178 sub->string =
179 ACPI_ADD_PTR(char, sub, sizeof(struct acpi_pnp_device_id));
180
181
182
183 strcpy(sub->string, obj_desc->string.pointer);
184 sub->length = length;
185 *return_id = sub;
186
187 cleanup:
188
189
190
191 acpi_ut_remove_reference(obj_desc);
192 return_ACPI_STATUS(status);
193}
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213acpi_status
214acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
215 struct acpi_pnp_device_id **return_id)
216{
217 union acpi_operand_object *obj_desc;
218 struct acpi_pnp_device_id *uid;
219 u32 length;
220 acpi_status status;
221
222 ACPI_FUNCTION_TRACE(ut_execute_UID);
223
224 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__UID,
225 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
226 &obj_desc);
227 if (ACPI_FAILURE(status)) {
228 return_ACPI_STATUS(status);
229 }
230
231
232
233 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
234 length = ACPI_MAX64_DECIMAL_DIGITS + 1;
235 } else {
236 length = obj_desc->string.length + 1;
237 }
238
239
240
241 uid =
242 ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) +
243 (acpi_size) length);
244 if (!uid) {
245 status = AE_NO_MEMORY;
246 goto cleanup;
247 }
248
249
250
251 uid->string =
252 ACPI_ADD_PTR(char, uid, sizeof(struct acpi_pnp_device_id));
253
254
255
256 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
257 acpi_ex_integer_to_string(uid->string, obj_desc->integer.value);
258 } else {
259 strcpy(uid->string, obj_desc->string.pointer);
260 }
261
262 uid->length = length;
263 *return_id = uid;
264
265cleanup:
266
267
268
269 acpi_ut_remove_reference(obj_desc);
270 return_ACPI_STATUS(status);
271}
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296acpi_status
297acpi_ut_execute_CID(struct acpi_namespace_node *device_node,
298 struct acpi_pnp_device_id_list **return_cid_list)
299{
300 union acpi_operand_object **cid_objects;
301 union acpi_operand_object *obj_desc;
302 struct acpi_pnp_device_id_list *cid_list;
303 char *next_id_string;
304 u32 string_area_size;
305 u32 length;
306 u32 cid_list_size;
307 acpi_status status;
308 u32 count;
309 u32 i;
310
311 ACPI_FUNCTION_TRACE(ut_execute_CID);
312
313
314
315 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CID,
316 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING
317 | ACPI_BTYPE_PACKAGE, &obj_desc);
318 if (ACPI_FAILURE(status)) {
319 return_ACPI_STATUS(status);
320 }
321
322
323
324
325
326
327
328 if (obj_desc->common.type == ACPI_TYPE_PACKAGE) {
329 count = obj_desc->package.count;
330 cid_objects = obj_desc->package.elements;
331 } else {
332
333 count = 1;
334 cid_objects = &obj_desc;
335 }
336
337 string_area_size = 0;
338 for (i = 0; i < count; i++) {
339
340
341
342 switch (cid_objects[i]->common.type) {
343 case ACPI_TYPE_INTEGER:
344
345 string_area_size += ACPI_EISAID_STRING_SIZE;
346 break;
347
348 case ACPI_TYPE_STRING:
349
350 string_area_size += cid_objects[i]->string.length + 1;
351 break;
352
353 default:
354
355 status = AE_TYPE;
356 goto cleanup;
357 }
358 }
359
360
361
362
363
364
365
366 cid_list_size = sizeof(struct acpi_pnp_device_id_list) +
367 ((count - 1) * sizeof(struct acpi_pnp_device_id)) +
368 string_area_size;
369
370 cid_list = ACPI_ALLOCATE_ZEROED(cid_list_size);
371 if (!cid_list) {
372 status = AE_NO_MEMORY;
373 goto cleanup;
374 }
375
376
377
378 next_id_string = ACPI_CAST_PTR(char, cid_list->ids) +
379 ((acpi_size) count * sizeof(struct acpi_pnp_device_id));
380
381
382
383 for (i = 0; i < count; i++) {
384 if (cid_objects[i]->common.type == ACPI_TYPE_INTEGER) {
385
386
387
388 acpi_ex_eisa_id_to_string(next_id_string,
389 cid_objects[i]->integer.
390 value);
391 length = ACPI_EISAID_STRING_SIZE;
392 } else {
393
394
395
396 strcpy(next_id_string, cid_objects[i]->string.pointer);
397 length = cid_objects[i]->string.length + 1;
398 }
399
400 cid_list->ids[i].string = next_id_string;
401 cid_list->ids[i].length = length;
402 next_id_string += length;
403 }
404
405
406
407 cid_list->count = count;
408 cid_list->list_size = cid_list_size;
409 *return_cid_list = cid_list;
410
411cleanup:
412
413
414
415 acpi_ut_remove_reference(obj_desc);
416 return_ACPI_STATUS(status);
417}
418