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 "acevents.h"
47#include "acnamesp.h"
48#include "acinterp.h"
49
50#define _COMPONENT ACPI_EVENTS
51ACPI_MODULE_NAME("evregion")
52
53
54static u8
55acpi_ev_has_default_handler(struct acpi_namespace_node *node,
56 acpi_adr_space_type space_id);
57
58static void acpi_ev_orphan_ec_reg_method(void);
59
60static acpi_status
61acpi_ev_reg_run(acpi_handle obj_handle,
62 u32 level, void *context, void **return_value);
63
64static acpi_status
65acpi_ev_install_handler(acpi_handle obj_handle,
66 u32 level, void *context, void **return_value);
67
68
69
70#define ACPI_NUM_DEFAULT_SPACES 4
71
72static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = {
73 ACPI_ADR_SPACE_SYSTEM_MEMORY,
74 ACPI_ADR_SPACE_SYSTEM_IO,
75 ACPI_ADR_SPACE_PCI_CONFIG,
76 ACPI_ADR_SPACE_DATA_TABLE
77};
78
79
80
81
82
83
84
85
86
87
88
89
90
91acpi_status acpi_ev_install_region_handlers(void)
92{
93 acpi_status status;
94 u32 i;
95
96 ACPI_FUNCTION_TRACE(ev_install_region_handlers);
97
98 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
99 if (ACPI_FAILURE(status)) {
100 return_ACPI_STATUS(status);
101 }
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
123 status = acpi_ev_install_space_handler(acpi_gbl_root_node,
124 acpi_gbl_default_address_spaces
125 [i],
126 ACPI_DEFAULT_HANDLER,
127 NULL, NULL);
128 switch (status) {
129 case AE_OK:
130 case AE_SAME_HANDLER:
131 case AE_ALREADY_EXISTS:
132
133
134
135 status = AE_OK;
136 break;
137
138 default:
139
140 goto unlock_and_exit;
141 }
142 }
143
144 unlock_and_exit:
145 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
146 return_ACPI_STATUS(status);
147}
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163static u8
164acpi_ev_has_default_handler(struct acpi_namespace_node *node,
165 acpi_adr_space_type space_id)
166{
167 union acpi_operand_object *obj_desc;
168 union acpi_operand_object *handler_obj;
169
170
171
172 obj_desc = acpi_ns_get_attached_object(node);
173 if (obj_desc) {
174 handler_obj = obj_desc->device.handler;
175
176
177
178 while (handler_obj) {
179 if (handler_obj->address_space.space_id == space_id) {
180 if (handler_obj->address_space.handler_flags &
181 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) {
182 return (TRUE);
183 }
184 }
185
186 handler_obj = handler_obj->address_space.next;
187 }
188 }
189
190 return (FALSE);
191}
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206acpi_status acpi_ev_initialize_op_regions(void)
207{
208 acpi_status status;
209 u32 i;
210
211 ACPI_FUNCTION_TRACE(ev_initialize_op_regions);
212
213 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
214 if (ACPI_FAILURE(status)) {
215 return_ACPI_STATUS(status);
216 }
217
218
219
220 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
221
222
223
224
225
226 if (acpi_ev_has_default_handler(acpi_gbl_root_node,
227 acpi_gbl_default_address_spaces
228 [i])) {
229 status =
230 acpi_ev_execute_reg_methods(acpi_gbl_root_node,
231 acpi_gbl_default_address_spaces
232 [i]);
233 }
234 }
235
236 acpi_gbl_reg_methods_executed = TRUE;
237
238 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
239 return_ACPI_STATUS(status);
240}
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255acpi_status
256acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
257{
258 struct acpi_evaluate_info *info;
259 union acpi_operand_object *args[3];
260 union acpi_operand_object *region_obj2;
261 acpi_status status;
262
263 ACPI_FUNCTION_TRACE(ev_execute_reg_method);
264
265 region_obj2 = acpi_ns_get_secondary_object(region_obj);
266 if (!region_obj2) {
267 return_ACPI_STATUS(AE_NOT_EXIST);
268 }
269
270 if (region_obj2->extra.method_REG == NULL) {
271 return_ACPI_STATUS(AE_OK);
272 }
273
274
275
276 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
277 if (!info) {
278 return_ACPI_STATUS(AE_NO_MEMORY);
279 }
280
281 info->prefix_node = region_obj2->extra.method_REG;
282 info->pathname = NULL;
283 info->parameters = args;
284 info->flags = ACPI_IGNORE_RETURN_VALUE;
285
286
287
288
289
290
291
292
293
294
295
296 args[0] =
297 acpi_ut_create_integer_object((u64) region_obj->region.space_id);
298 if (!args[0]) {
299 status = AE_NO_MEMORY;
300 goto cleanup1;
301 }
302
303 args[1] = acpi_ut_create_integer_object((u64) function);
304 if (!args[1]) {
305 status = AE_NO_MEMORY;
306 goto cleanup2;
307 }
308
309 args[2] = NULL;
310
311
312
313 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
314 (ACPI_TYPE_METHOD, info->prefix_node, NULL));
315
316 status = acpi_ns_evaluate(info);
317 acpi_ut_remove_reference(args[1]);
318
319 cleanup2:
320 acpi_ut_remove_reference(args[0]);
321
322 cleanup1:
323 ACPI_FREE(info);
324 return_ACPI_STATUS(status);
325}
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346acpi_status
347acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
348 union acpi_operand_object *field_obj,
349 u32 function,
350 u32 region_offset, u32 bit_width, u64 *value)
351{
352 acpi_status status;
353 acpi_adr_space_handler handler;
354 acpi_adr_space_setup region_setup;
355 union acpi_operand_object *handler_desc;
356 union acpi_operand_object *region_obj2;
357 void *region_context = NULL;
358 struct acpi_connection_info *context;
359
360 ACPI_FUNCTION_TRACE(ev_address_space_dispatch);
361
362 region_obj2 = acpi_ns_get_secondary_object(region_obj);
363 if (!region_obj2) {
364 return_ACPI_STATUS(AE_NOT_EXIST);
365 }
366
367
368
369 handler_desc = region_obj->region.handler;
370 if (!handler_desc) {
371 ACPI_ERROR((AE_INFO,
372 "No handler for Region [%4.4s] (%p) [%s]",
373 acpi_ut_get_node_name(region_obj->region.node),
374 region_obj,
375 acpi_ut_get_region_name(region_obj->region.
376 space_id)));
377
378 return_ACPI_STATUS(AE_NOT_EXIST);
379 }
380
381 context = handler_desc->address_space.context;
382
383
384
385
386
387 if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) {
388
389
390
391 region_setup = handler_desc->address_space.setup;
392 if (!region_setup) {
393
394
395
396 ACPI_ERROR((AE_INFO,
397 "No init routine for region(%p) [%s]",
398 region_obj,
399 acpi_ut_get_region_name(region_obj->region.
400 space_id)));
401 return_ACPI_STATUS(AE_NOT_EXIST);
402 }
403
404
405
406
407
408
409 acpi_ex_exit_interpreter();
410
411 status = region_setup(region_obj, ACPI_REGION_ACTIVATE,
412 context, ®ion_context);
413
414
415
416 acpi_ex_enter_interpreter();
417
418
419
420 if (ACPI_FAILURE(status)) {
421 ACPI_EXCEPTION((AE_INFO, status,
422 "During region initialization: [%s]",
423 acpi_ut_get_region_name(region_obj->
424 region.
425 space_id)));
426 return_ACPI_STATUS(status);
427 }
428
429
430
431 if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) {
432 region_obj->region.flags |= AOPOBJ_SETUP_COMPLETE;
433
434 if (region_obj2->extra.region_context) {
435
436
437
438 ACPI_FREE(region_context);
439 } else {
440
441
442
443
444 region_obj2->extra.region_context =
445 region_context;
446 }
447 }
448 }
449
450
451
452 handler = handler_desc->address_space.handler;
453
454 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
455 "Handler %p (@%p) Address %8.8X%8.8X [%s]\n",
456 ®ion_obj->region.handler->address_space, handler,
457 ACPI_FORMAT_NATIVE_UINT(region_obj->region.address +
458 region_offset),
459 acpi_ut_get_region_name(region_obj->region.
460 space_id)));
461
462
463
464
465
466
467
468
469
470 if (((region_obj->region.space_id == ACPI_ADR_SPACE_GSBUS) ||
471 (region_obj->region.space_id == ACPI_ADR_SPACE_GPIO)) &&
472 context && field_obj) {
473
474
475
476 context->connection = field_obj->field.resource_buffer;
477 context->length = field_obj->field.resource_length;
478 context->access_length = field_obj->field.access_length;
479 }
480
481 if (!(handler_desc->address_space.handler_flags &
482 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
483
484
485
486
487
488 acpi_ex_exit_interpreter();
489 }
490
491
492
493 status = handler(function,
494 (region_obj->region.address + region_offset),
495 bit_width, value, context,
496 region_obj2->extra.region_context);
497
498 if (ACPI_FAILURE(status)) {
499 ACPI_EXCEPTION((AE_INFO, status, "Returned by Handler for [%s]",
500 acpi_ut_get_region_name(region_obj->region.
501 space_id)));
502 }
503
504 if (!(handler_desc->address_space.handler_flags &
505 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
506
507
508
509
510 acpi_ex_enter_interpreter();
511 }
512
513 return_ACPI_STATUS(status);
514}
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530void
531acpi_ev_detach_region(union acpi_operand_object *region_obj,
532 u8 acpi_ns_is_locked)
533{
534 union acpi_operand_object *handler_obj;
535 union acpi_operand_object *obj_desc;
536 union acpi_operand_object **last_obj_ptr;
537 acpi_adr_space_setup region_setup;
538 void **region_context;
539 union acpi_operand_object *region_obj2;
540 acpi_status status;
541
542 ACPI_FUNCTION_TRACE(ev_detach_region);
543
544 region_obj2 = acpi_ns_get_secondary_object(region_obj);
545 if (!region_obj2) {
546 return_VOID;
547 }
548 region_context = ®ion_obj2->extra.region_context;
549
550
551
552 handler_obj = region_obj->region.handler;
553 if (!handler_obj) {
554
555
556
557 return_VOID;
558 }
559
560
561
562 obj_desc = handler_obj->address_space.region_list;
563 last_obj_ptr = &handler_obj->address_space.region_list;
564
565 while (obj_desc) {
566
567
568
569 if (obj_desc == region_obj) {
570 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
571 "Removing Region %p from address handler %p\n",
572 region_obj, handler_obj));
573
574
575
576 *last_obj_ptr = obj_desc->region.next;
577 obj_desc->region.next = NULL;
578
579 if (acpi_ns_is_locked) {
580 status =
581 acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
582 if (ACPI_FAILURE(status)) {
583 return_VOID;
584 }
585 }
586
587
588
589 status =
590 acpi_ev_execute_reg_method(region_obj,
591 ACPI_REG_DISCONNECT);
592 if (ACPI_FAILURE(status)) {
593 ACPI_EXCEPTION((AE_INFO, status,
594 "from region _REG, [%s]",
595 acpi_ut_get_region_name
596 (region_obj->region.space_id)));
597 }
598
599 if (acpi_ns_is_locked) {
600 status =
601 acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
602 if (ACPI_FAILURE(status)) {
603 return_VOID;
604 }
605 }
606
607
608
609
610
611 if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) {
612 region_setup = handler_obj->address_space.setup;
613 status =
614 region_setup(region_obj,
615 ACPI_REGION_DEACTIVATE,
616 handler_obj->address_space.
617 context, region_context);
618
619
620
621 if (ACPI_FAILURE(status)) {
622 ACPI_EXCEPTION((AE_INFO, status,
623 "from region handler - deactivate, [%s]",
624 acpi_ut_get_region_name
625 (region_obj->region.
626 space_id)));
627 }
628
629 region_obj->region.flags &=
630 ~(AOPOBJ_SETUP_COMPLETE);
631 }
632
633
634
635
636
637
638
639
640
641
642 region_obj->region.handler = NULL;
643 acpi_ut_remove_reference(handler_obj);
644
645 return_VOID;
646 }
647
648
649
650 last_obj_ptr = &obj_desc->region.next;
651 obj_desc = obj_desc->region.next;
652 }
653
654
655
656 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
657 "Cannot remove region %p from address handler %p\n",
658 region_obj, handler_obj));
659
660 return_VOID;
661}
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678acpi_status
679acpi_ev_attach_region(union acpi_operand_object *handler_obj,
680 union acpi_operand_object *region_obj,
681 u8 acpi_ns_is_locked)
682{
683
684 ACPI_FUNCTION_TRACE(ev_attach_region);
685
686 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
687 "Adding Region [%4.4s] %p to address handler %p [%s]\n",
688 acpi_ut_get_node_name(region_obj->region.node),
689 region_obj, handler_obj,
690 acpi_ut_get_region_name(region_obj->region.
691 space_id)));
692
693
694
695 region_obj->region.next = handler_obj->address_space.region_list;
696 handler_obj->address_space.region_list = region_obj;
697
698
699
700 if (region_obj->region.handler) {
701 return_ACPI_STATUS(AE_ALREADY_EXISTS);
702 }
703
704 region_obj->region.handler = handler_obj;
705 acpi_ut_add_reference(handler_obj);
706
707 return_ACPI_STATUS(AE_OK);
708}
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727static acpi_status
728acpi_ev_install_handler(acpi_handle obj_handle,
729 u32 level, void *context, void **return_value)
730{
731 union acpi_operand_object *handler_obj;
732 union acpi_operand_object *next_handler_obj;
733 union acpi_operand_object *obj_desc;
734 struct acpi_namespace_node *node;
735 acpi_status status;
736
737 ACPI_FUNCTION_NAME(ev_install_handler);
738
739 handler_obj = (union acpi_operand_object *)context;
740
741
742
743 if (!handler_obj) {
744 return (AE_OK);
745 }
746
747
748
749 node = acpi_ns_validate_handle(obj_handle);
750 if (!node) {
751 return (AE_BAD_PARAMETER);
752 }
753
754
755
756
757
758 if ((node->type != ACPI_TYPE_DEVICE) &&
759 (node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) {
760 return (AE_OK);
761 }
762
763
764
765 obj_desc = acpi_ns_get_attached_object(node);
766 if (!obj_desc) {
767
768
769
770 return (AE_OK);
771 }
772
773
774
775 if (obj_desc->common.type == ACPI_TYPE_DEVICE) {
776
777
778
779 next_handler_obj = obj_desc->device.handler;
780 while (next_handler_obj) {
781
782
783
784 if (next_handler_obj->address_space.space_id ==
785 handler_obj->address_space.space_id) {
786 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
787 "Found handler for region [%s] in device %p(%p) "
788 "handler %p\n",
789 acpi_ut_get_region_name
790 (handler_obj->address_space.
791 space_id), obj_desc,
792 next_handler_obj,
793 handler_obj));
794
795
796
797
798
799
800
801
802 return (AE_CTRL_DEPTH);
803 }
804
805
806
807 next_handler_obj = next_handler_obj->address_space.next;
808 }
809
810
811
812
813
814 return (AE_OK);
815 }
816
817
818
819 if (obj_desc->region.space_id != handler_obj->address_space.space_id) {
820
821
822
823 return (AE_OK);
824 }
825
826
827
828
829
830
831 acpi_ev_detach_region(obj_desc, FALSE);
832
833
834
835 status = acpi_ev_attach_region(handler_obj, obj_desc, FALSE);
836 return (status);
837}
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856acpi_status
857acpi_ev_install_space_handler(struct acpi_namespace_node * node,
858 acpi_adr_space_type space_id,
859 acpi_adr_space_handler handler,
860 acpi_adr_space_setup setup, void *context)
861{
862 union acpi_operand_object *obj_desc;
863 union acpi_operand_object *handler_obj;
864 acpi_status status;
865 acpi_object_type type;
866 u8 flags = 0;
867
868 ACPI_FUNCTION_TRACE(ev_install_space_handler);
869
870
871
872
873
874 if ((node->type != ACPI_TYPE_DEVICE) &&
875 (node->type != ACPI_TYPE_PROCESSOR) &&
876 (node->type != ACPI_TYPE_THERMAL) && (node != acpi_gbl_root_node)) {
877 status = AE_BAD_PARAMETER;
878 goto unlock_and_exit;
879 }
880
881 if (handler == ACPI_DEFAULT_HANDLER) {
882 flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED;
883
884 switch (space_id) {
885 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
886 handler = acpi_ex_system_memory_space_handler;
887 setup = acpi_ev_system_memory_region_setup;
888 break;
889
890 case ACPI_ADR_SPACE_SYSTEM_IO:
891 handler = acpi_ex_system_io_space_handler;
892 setup = acpi_ev_io_space_region_setup;
893 break;
894
895 case ACPI_ADR_SPACE_PCI_CONFIG:
896 handler = acpi_ex_pci_config_space_handler;
897 setup = acpi_ev_pci_config_region_setup;
898 break;
899
900 case ACPI_ADR_SPACE_CMOS:
901 handler = acpi_ex_cmos_space_handler;
902 setup = acpi_ev_cmos_region_setup;
903 break;
904
905 case ACPI_ADR_SPACE_PCI_BAR_TARGET:
906 handler = acpi_ex_pci_bar_space_handler;
907 setup = acpi_ev_pci_bar_region_setup;
908 break;
909
910 case ACPI_ADR_SPACE_DATA_TABLE:
911 handler = acpi_ex_data_table_space_handler;
912 setup = NULL;
913 break;
914
915 default:
916 status = AE_BAD_PARAMETER;
917 goto unlock_and_exit;
918 }
919 }
920
921
922
923 if (!setup) {
924 setup = acpi_ev_default_region_setup;
925 }
926
927
928
929 obj_desc = acpi_ns_get_attached_object(node);
930 if (obj_desc) {
931
932
933
934
935 handler_obj = obj_desc->device.handler;
936
937
938
939 while (handler_obj) {
940
941
942
943 if (handler_obj->address_space.space_id == space_id) {
944 if (handler_obj->address_space.handler ==
945 handler) {
946
947
948
949
950
951 status = AE_SAME_HANDLER;
952 goto unlock_and_exit;
953 } else {
954
955
956 status = AE_ALREADY_EXISTS;
957 }
958 goto unlock_and_exit;
959 }
960
961
962
963 handler_obj = handler_obj->address_space.next;
964 }
965 } else {
966 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
967 "Creating object on Device %p while installing handler\n",
968 node));
969
970
971
972 if (node->type == ACPI_TYPE_ANY) {
973 type = ACPI_TYPE_DEVICE;
974 } else {
975 type = node->type;
976 }
977
978 obj_desc = acpi_ut_create_internal_object(type);
979 if (!obj_desc) {
980 status = AE_NO_MEMORY;
981 goto unlock_and_exit;
982 }
983
984
985
986 obj_desc->common.type = (u8) type;
987
988
989
990 status = acpi_ns_attach_object(node, obj_desc, type);
991
992
993
994 acpi_ut_remove_reference(obj_desc);
995
996 if (ACPI_FAILURE(status)) {
997 goto unlock_and_exit;
998 }
999 }
1000
1001 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
1002 "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n",
1003 acpi_ut_get_region_name(space_id), space_id,
1004 acpi_ut_get_node_name(node), node, obj_desc));
1005
1006
1007
1008
1009
1010
1011
1012 handler_obj =
1013 acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER);
1014 if (!handler_obj) {
1015 status = AE_NO_MEMORY;
1016 goto unlock_and_exit;
1017 }
1018
1019
1020
1021 handler_obj->address_space.space_id = (u8) space_id;
1022 handler_obj->address_space.handler_flags = flags;
1023 handler_obj->address_space.region_list = NULL;
1024 handler_obj->address_space.node = node;
1025 handler_obj->address_space.handler = handler;
1026 handler_obj->address_space.context = context;
1027 handler_obj->address_space.setup = setup;
1028
1029
1030
1031 handler_obj->address_space.next = obj_desc->device.handler;
1032
1033
1034
1035
1036
1037 obj_desc->device.handler = handler_obj;
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
1052 ACPI_NS_WALK_UNLOCK,
1053 acpi_ev_install_handler, NULL,
1054 handler_obj, NULL);
1055
1056 unlock_and_exit:
1057 return_ACPI_STATUS(status);
1058}
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074acpi_status
1075acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
1076 acpi_adr_space_type space_id)
1077{
1078 acpi_status status;
1079
1080 ACPI_FUNCTION_TRACE(ev_execute_reg_methods);
1081
1082
1083
1084
1085
1086
1087
1088 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
1089 ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run,
1090 NULL, &space_id, NULL);
1091
1092
1093
1094 if (space_id == ACPI_ADR_SPACE_EC) {
1095 acpi_ev_orphan_ec_reg_method();
1096 }
1097
1098 return_ACPI_STATUS(status);
1099}
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111static acpi_status
1112acpi_ev_reg_run(acpi_handle obj_handle,
1113 u32 level, void *context, void **return_value)
1114{
1115 union acpi_operand_object *obj_desc;
1116 struct acpi_namespace_node *node;
1117 acpi_adr_space_type space_id;
1118 acpi_status status;
1119
1120 space_id = *ACPI_CAST_PTR(acpi_adr_space_type, context);
1121
1122
1123
1124 node = acpi_ns_validate_handle(obj_handle);
1125 if (!node) {
1126 return (AE_BAD_PARAMETER);
1127 }
1128
1129
1130
1131
1132
1133 if ((node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) {
1134 return (AE_OK);
1135 }
1136
1137
1138
1139 obj_desc = acpi_ns_get_attached_object(node);
1140 if (!obj_desc) {
1141
1142
1143
1144 return (AE_OK);
1145 }
1146
1147
1148
1149 if (obj_desc->region.space_id != space_id) {
1150
1151
1152
1153 return (AE_OK);
1154 }
1155
1156 status = acpi_ev_execute_reg_method(obj_desc, ACPI_REG_CONNECT);
1157 return (status);
1158}
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183static void acpi_ev_orphan_ec_reg_method(void)
1184{
1185 struct acpi_table_ecdt *table;
1186 acpi_status status;
1187 struct acpi_object_list args;
1188 union acpi_object objects[2];
1189 struct acpi_namespace_node *ec_device_node;
1190 struct acpi_namespace_node *reg_method;
1191 struct acpi_namespace_node *next_node;
1192
1193 ACPI_FUNCTION_TRACE(ev_orphan_ec_reg_method);
1194
1195
1196
1197 status = acpi_get_table(ACPI_SIG_ECDT, 0,
1198 ACPI_CAST_INDIRECT_PTR(struct acpi_table_header,
1199 &table));
1200 if (ACPI_FAILURE(status)) {
1201 return_VOID;
1202 }
1203
1204
1205
1206 if (!(*table->id)) {
1207 return_VOID;
1208 }
1209
1210
1211
1212 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
1213
1214
1215
1216 status = acpi_get_handle(NULL,
1217 ACPI_CAST_PTR(char, table->id),
1218 ACPI_CAST_PTR(acpi_handle, &ec_device_node));
1219 if (ACPI_FAILURE(status)) {
1220 goto exit;
1221 }
1222
1223
1224
1225 status = acpi_get_handle(ec_device_node,
1226 METHOD_NAME__REG, ACPI_CAST_PTR(acpi_handle,
1227 ®_method));
1228 if (ACPI_FAILURE(status)) {
1229 goto exit;
1230 }
1231
1232
1233
1234
1235
1236
1237
1238
1239 next_node = acpi_ns_get_next_node(ec_device_node, NULL);
1240 while (next_node) {
1241 if ((next_node->type == ACPI_TYPE_REGION) &&
1242 (next_node->object) &&
1243 (next_node->object->region.space_id == ACPI_ADR_SPACE_EC)) {
1244 goto exit;
1245 }
1246 next_node = acpi_ns_get_next_node(ec_device_node, next_node);
1247 }
1248
1249
1250
1251 args.count = 2;
1252 args.pointer = objects;
1253 objects[0].type = ACPI_TYPE_INTEGER;
1254 objects[0].integer.value = ACPI_ADR_SPACE_EC;
1255 objects[1].type = ACPI_TYPE_INTEGER;
1256 objects[1].integer.value = ACPI_REG_CONNECT;
1257
1258 status = acpi_evaluate_object(reg_method, NULL, &args, NULL);
1259
1260 exit:
1261
1262
1263 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
1264 return_VOID;
1265}
1266