This source file includes following definitions.
- ACPI_MODULE_NAME
- acpi_ds_method_data_delete_all
- acpi_ds_method_data_init_args
- acpi_ds_method_data_get_node
- acpi_ds_method_data_set_value
- acpi_ds_method_data_get_value
- acpi_ds_method_data_delete_value
- acpi_ds_store_object_to_local
- acpi_ds_method_data_get_type
1
2
3
4
5
6
7
8 #include <acpi/acpi.h>
9 #include "accommon.h"
10 #include "acdispat.h"
11 #include "acnamesp.h"
12 #include "acinterp.h"
13
14 #define _COMPONENT ACPI_DISPATCHER
15 ACPI_MODULE_NAME("dsmthdat")
16
17
18 static void
19 acpi_ds_method_data_delete_value(u8 type,
20 u32 index, struct acpi_walk_state *walk_state);
21
22 static acpi_status
23 acpi_ds_method_data_set_value(u8 type,
24 u32 index,
25 union acpi_operand_object *object,
26 struct acpi_walk_state *walk_state);
27
28 #ifdef ACPI_OBSOLETE_FUNCTIONS
29 acpi_object_type
30 acpi_ds_method_data_get_type(u16 opcode,
31 u32 index, struct acpi_walk_state *walk_state);
32 #endif
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 void acpi_ds_method_data_init(struct acpi_walk_state *walk_state)
56 {
57 u32 i;
58
59 ACPI_FUNCTION_TRACE(ds_method_data_init);
60
61
62
63 for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) {
64 ACPI_MOVE_32_TO_32(&walk_state->arguments[i].name,
65 NAMEOF_ARG_NTE);
66
67 walk_state->arguments[i].name.integer |= (i << 24);
68 walk_state->arguments[i].descriptor_type = ACPI_DESC_TYPE_NAMED;
69 walk_state->arguments[i].type = ACPI_TYPE_ANY;
70 walk_state->arguments[i].flags = ANOBJ_METHOD_ARG;
71 }
72
73
74
75 for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) {
76 ACPI_MOVE_32_TO_32(&walk_state->local_variables[i].name,
77 NAMEOF_LOCAL_NTE);
78
79 walk_state->local_variables[i].name.integer |= (i << 24);
80 walk_state->local_variables[i].descriptor_type =
81 ACPI_DESC_TYPE_NAMED;
82 walk_state->local_variables[i].type = ACPI_TYPE_ANY;
83 walk_state->local_variables[i].flags = ANOBJ_METHOD_LOCAL;
84 }
85
86 return_VOID;
87 }
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102 void acpi_ds_method_data_delete_all(struct acpi_walk_state *walk_state)
103 {
104 u32 index;
105
106 ACPI_FUNCTION_TRACE(ds_method_data_delete_all);
107
108
109
110 for (index = 0; index < ACPI_METHOD_NUM_LOCALS; index++) {
111 if (walk_state->local_variables[index].object) {
112 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Local%u=%p\n",
113 index,
114 walk_state->local_variables[index].
115 object));
116
117
118
119 acpi_ns_detach_object(&walk_state->
120 local_variables[index]);
121 }
122 }
123
124
125
126 for (index = 0; index < ACPI_METHOD_NUM_ARGS; index++) {
127 if (walk_state->arguments[index].object) {
128 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Arg%u=%p\n",
129 index,
130 walk_state->arguments[index].object));
131
132
133
134 acpi_ns_detach_object(&walk_state->arguments[index]);
135 }
136 }
137
138 return_VOID;
139 }
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157 acpi_status
158 acpi_ds_method_data_init_args(union acpi_operand_object **params,
159 u32 max_param_count,
160 struct acpi_walk_state *walk_state)
161 {
162 acpi_status status;
163 u32 index = 0;
164
165 ACPI_FUNCTION_TRACE_PTR(ds_method_data_init_args, params);
166
167 if (!params) {
168 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
169 "No parameter list passed to method\n"));
170 return_ACPI_STATUS(AE_OK);
171 }
172
173
174
175 while ((index < ACPI_METHOD_NUM_ARGS) &&
176 (index < max_param_count) && params[index]) {
177
178
179
180
181
182 status =
183 acpi_ds_method_data_set_value(ACPI_REFCLASS_ARG, index,
184 params[index], walk_state);
185 if (ACPI_FAILURE(status)) {
186 return_ACPI_STATUS(status);
187 }
188
189 index++;
190 }
191
192 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%u args passed to method\n", index));
193 return_ACPI_STATUS(AE_OK);
194 }
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212 acpi_status
213 acpi_ds_method_data_get_node(u8 type,
214 u32 index,
215 struct acpi_walk_state *walk_state,
216 struct acpi_namespace_node **node)
217 {
218 ACPI_FUNCTION_TRACE(ds_method_data_get_node);
219
220
221
222
223 switch (type) {
224 case ACPI_REFCLASS_LOCAL:
225
226 if (index > ACPI_METHOD_MAX_LOCAL) {
227 ACPI_ERROR((AE_INFO,
228 "Local index %u is invalid (max %u)",
229 index, ACPI_METHOD_MAX_LOCAL));
230 return_ACPI_STATUS(AE_AML_INVALID_INDEX);
231 }
232
233
234
235 *node = &walk_state->local_variables[index];
236 break;
237
238 case ACPI_REFCLASS_ARG:
239
240 if (index > ACPI_METHOD_MAX_ARG) {
241 ACPI_ERROR((AE_INFO,
242 "Arg index %u is invalid (max %u)",
243 index, ACPI_METHOD_MAX_ARG));
244 return_ACPI_STATUS(AE_AML_INVALID_INDEX);
245 }
246
247
248
249 *node = &walk_state->arguments[index];
250 break;
251
252 default:
253
254 ACPI_ERROR((AE_INFO, "Type %u is invalid", type));
255 return_ACPI_STATUS(AE_TYPE);
256 }
257
258 return_ACPI_STATUS(AE_OK);
259 }
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278 static acpi_status
279 acpi_ds_method_data_set_value(u8 type,
280 u32 index,
281 union acpi_operand_object *object,
282 struct acpi_walk_state *walk_state)
283 {
284 acpi_status status;
285 struct acpi_namespace_node *node;
286
287 ACPI_FUNCTION_TRACE(ds_method_data_set_value);
288
289 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
290 "NewObj %p Type %2.2X, Refs=%u [%s]\n", object,
291 type, object->common.reference_count,
292 acpi_ut_get_type_name(object->common.type)));
293
294
295
296 status = acpi_ds_method_data_get_node(type, index, walk_state, &node);
297 if (ACPI_FAILURE(status)) {
298 return_ACPI_STATUS(status);
299 }
300
301
302
303
304
305
306
307 acpi_ut_add_reference(object);
308
309
310
311 node->object = object;
312 return_ACPI_STATUS(status);
313 }
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332 acpi_status
333 acpi_ds_method_data_get_value(u8 type,
334 u32 index,
335 struct acpi_walk_state *walk_state,
336 union acpi_operand_object **dest_desc)
337 {
338 acpi_status status;
339 struct acpi_namespace_node *node;
340 union acpi_operand_object *object;
341
342 ACPI_FUNCTION_TRACE(ds_method_data_get_value);
343
344
345
346 if (!dest_desc) {
347 ACPI_ERROR((AE_INFO, "Null object descriptor pointer"));
348 return_ACPI_STATUS(AE_BAD_PARAMETER);
349 }
350
351
352
353 status = acpi_ds_method_data_get_node(type, index, walk_state, &node);
354 if (ACPI_FAILURE(status)) {
355 return_ACPI_STATUS(status);
356 }
357
358
359
360 object = node->object;
361
362
363
364 if (!object) {
365
366
367
368
369
370
371
372
373
374
375 if (acpi_gbl_enable_interpreter_slack) {
376 object = acpi_ut_create_integer_object((u64) 0);
377 if (!object) {
378 return_ACPI_STATUS(AE_NO_MEMORY);
379 }
380
381 node->object = object;
382 }
383
384
385
386 else
387 switch (type) {
388 case ACPI_REFCLASS_ARG:
389
390 ACPI_ERROR((AE_INFO,
391 "Uninitialized Arg[%u] at node %p",
392 index, node));
393
394 return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG);
395
396 case ACPI_REFCLASS_LOCAL:
397
398
399
400
401 return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL);
402
403 default:
404
405 ACPI_ERROR((AE_INFO,
406 "Not a Arg/Local opcode: 0x%X",
407 type));
408 return_ACPI_STATUS(AE_AML_INTERNAL);
409 }
410 }
411
412
413
414
415
416 *dest_desc = object;
417 acpi_ut_add_reference(object);
418
419 return_ACPI_STATUS(AE_OK);
420 }
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438 static void
439 acpi_ds_method_data_delete_value(u8 type,
440 u32 index, struct acpi_walk_state *walk_state)
441 {
442 acpi_status status;
443 struct acpi_namespace_node *node;
444 union acpi_operand_object *object;
445
446 ACPI_FUNCTION_TRACE(ds_method_data_delete_value);
447
448
449
450 status = acpi_ds_method_data_get_node(type, index, walk_state, &node);
451 if (ACPI_FAILURE(status)) {
452 return_VOID;
453 }
454
455
456
457 object = acpi_ns_get_attached_object(node);
458
459
460
461
462
463
464 node->object = NULL;
465
466 if ((object) &&
467 (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_OPERAND)) {
468
469
470
471
472
473 acpi_ut_remove_reference(object);
474 }
475
476 return_VOID;
477 }
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497 acpi_status
498 acpi_ds_store_object_to_local(u8 type,
499 u32 index,
500 union acpi_operand_object *obj_desc,
501 struct acpi_walk_state *walk_state)
502 {
503 acpi_status status;
504 struct acpi_namespace_node *node;
505 union acpi_operand_object *current_obj_desc;
506 union acpi_operand_object *new_obj_desc;
507
508 ACPI_FUNCTION_TRACE(ds_store_object_to_local);
509 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Type=%2.2X Index=%u Obj=%p\n",
510 type, index, obj_desc));
511
512
513
514 if (!obj_desc) {
515 return_ACPI_STATUS(AE_BAD_PARAMETER);
516 }
517
518
519
520 status = acpi_ds_method_data_get_node(type, index, walk_state, &node);
521 if (ACPI_FAILURE(status)) {
522 return_ACPI_STATUS(status);
523 }
524
525 current_obj_desc = acpi_ns_get_attached_object(node);
526 if (current_obj_desc == obj_desc) {
527 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p already installed!\n",
528 obj_desc));
529 return_ACPI_STATUS(status);
530 }
531
532
533
534
535
536
537
538
539 new_obj_desc = obj_desc;
540 if (obj_desc->common.reference_count > 1) {
541 status =
542 acpi_ut_copy_iobject_to_iobject(obj_desc, &new_obj_desc,
543 walk_state);
544 if (ACPI_FAILURE(status)) {
545 return_ACPI_STATUS(status);
546 }
547 }
548
549
550
551
552
553
554
555 if (current_obj_desc) {
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572 if (type == ACPI_REFCLASS_ARG) {
573
574
575
576
577 if ((ACPI_GET_DESCRIPTOR_TYPE(current_obj_desc) ==
578 ACPI_DESC_TYPE_OPERAND) &&
579 (current_obj_desc->common.type ==
580 ACPI_TYPE_LOCAL_REFERENCE) &&
581 (current_obj_desc->reference.class ==
582 ACPI_REFCLASS_REFOF)) {
583 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
584 "Arg (%p) is an ObjRef(Node), storing in node %p\n",
585 new_obj_desc,
586 current_obj_desc));
587
588
589
590
591
592
593 status =
594 acpi_ex_store_object_to_node(new_obj_desc,
595 current_obj_desc->
596 reference.
597 object,
598 walk_state,
599 ACPI_NO_IMPLICIT_CONVERSION);
600
601
602
603 if (new_obj_desc != obj_desc) {
604 acpi_ut_remove_reference(new_obj_desc);
605 }
606
607 return_ACPI_STATUS(status);
608 }
609 }
610
611
612
613 acpi_ds_method_data_delete_value(type, index, walk_state);
614 }
615
616
617
618
619
620
621 status =
622 acpi_ds_method_data_set_value(type, index, new_obj_desc,
623 walk_state);
624
625
626
627 if (new_obj_desc != obj_desc) {
628 acpi_ut_remove_reference(new_obj_desc);
629 }
630
631 return_ACPI_STATUS(status);
632 }
633
634 #ifdef ACPI_OBSOLETE_FUNCTIONS
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650 acpi_object_type
651 acpi_ds_method_data_get_type(u16 opcode,
652 u32 index, struct acpi_walk_state *walk_state)
653 {
654 acpi_status status;
655 struct acpi_namespace_node *node;
656 union acpi_operand_object *object;
657
658 ACPI_FUNCTION_TRACE(ds_method_data_get_type);
659
660
661
662 status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
663 if (ACPI_FAILURE(status)) {
664 return_VALUE((ACPI_TYPE_NOT_FOUND));
665 }
666
667
668
669 object = acpi_ns_get_attached_object(node);
670 if (!object) {
671
672
673
674 return_VALUE(ACPI_TYPE_ANY);
675 }
676
677
678
679 return_VALUE(object->type);
680 }
681 #endif