forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/acpi/acpica/nsaccess.c
....@@ -36,6 +36,7 @@
3636 acpi_status status;
3737 const struct acpi_predefined_names *init_val = NULL;
3838 struct acpi_namespace_node *new_node;
39
+ struct acpi_namespace_node *prev_node = NULL;
3940 union acpi_operand_object *obj_desc;
4041 acpi_string val = NULL;
4142
....@@ -61,12 +62,28 @@
6162 */
6263 acpi_gbl_root_node = &acpi_gbl_root_node_struct;
6364
64
- /* Enter the pre-defined names in the name table */
65
+ /* Enter the predefined names in the name table */
6566
6667 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
6768 "Entering predefined entries into namespace\n"));
6869
70
+ /*
71
+ * Create the initial (default) namespace.
72
+ * This namespace looks like something similar to this:
73
+ *
74
+ * ACPI Namespace (from Namespace Root):
75
+ * 0 _GPE Scope 00203160 00
76
+ * 0 _PR_ Scope 002031D0 00
77
+ * 0 _SB_ Device 00203240 00 Notify Object: 0020ADD8
78
+ * 0 _SI_ Scope 002032B0 00
79
+ * 0 _TZ_ Device 00203320 00
80
+ * 0 _REV Integer 00203390 00 = 0000000000000002
81
+ * 0 _OS_ String 00203488 00 Len 14 "Microsoft Windows NT"
82
+ * 0 _GL_ Mutex 00203580 00 Object 002035F0
83
+ * 0 _OSI Method 00203678 00 Args 1 Len 0000 Aml 00000000
84
+ */
6985 for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) {
86
+ status = AE_OK;
7087
7188 /* _OSI is optional for now, will be permanent later */
7289
....@@ -75,16 +92,30 @@
7592 continue;
7693 }
7794
78
- status =
79
- acpi_ns_lookup(NULL, ACPI_CAST_PTR(char, init_val->name),
80
- init_val->type, ACPI_IMODE_LOAD_PASS2,
81
- ACPI_NS_NO_UPSEARCH, NULL, &new_node);
82
- if (ACPI_FAILURE(status)) {
83
- ACPI_EXCEPTION((AE_INFO, status,
84
- "Could not create predefined name %s",
85
- init_val->name));
86
- continue;
95
+ /*
96
+ * Create, init, and link the new predefined name
97
+ * Note: No need to use acpi_ns_lookup here because all the
98
+ * predefined names are at the root level. It is much easier to
99
+ * just create and link the new node(s) here.
100
+ */
101
+ new_node =
102
+ acpi_ns_create_node(*ACPI_CAST_PTR(u32, init_val->name));
103
+ if (!new_node) {
104
+ status = AE_NO_MEMORY;
105
+ goto unlock_and_exit;
87106 }
107
+
108
+ new_node->descriptor_type = ACPI_DESC_TYPE_NAMED;
109
+ new_node->type = init_val->type;
110
+
111
+ if (!prev_node) {
112
+ acpi_gbl_root_node_struct.child = new_node;
113
+ } else {
114
+ prev_node->peer = new_node;
115
+ }
116
+
117
+ new_node->parent = &acpi_gbl_root_node_struct;
118
+ prev_node = new_node;
88119
89120 /*
90121 * Name entered successfully. If entry in pre_defined_names[] specifies
....@@ -131,7 +162,7 @@
131162
132163 new_node->value = obj_desc->method.param_count;
133164 #else
134
- /* Mark this as a very SPECIAL method */
165
+ /* Mark this as a very SPECIAL method (_OSI) */
135166
136167 obj_desc->method.info_flags =
137168 ACPI_METHOD_INTERNAL_ONLY;
....@@ -267,6 +298,7 @@
267298 acpi_object_type this_search_type;
268299 u32 search_parent_flag = ACPI_NS_SEARCH_PARENT;
269300 u32 local_flags;
301
+ acpi_interpreter_mode local_interpreter_mode;
270302
271303 ACPI_FUNCTION_TRACE(ns_lookup);
272304
....@@ -506,6 +538,7 @@
506538 */
507539 this_search_type = ACPI_TYPE_ANY;
508540 current_node = this_node;
541
+
509542 while (num_segments && current_node) {
510543 num_segments--;
511544 if (!num_segments) {
....@@ -536,6 +569,16 @@
536569 }
537570 }
538571
572
+ /* Handle opcodes that create a new name_seg via a full name_path */
573
+
574
+ local_interpreter_mode = interpreter_mode;
575
+ if ((flags & ACPI_NS_PREFIX_MUST_EXIST) && (num_segments > 0)) {
576
+
577
+ /* Every element of the path must exist (except for the final name_seg) */
578
+
579
+ local_interpreter_mode = ACPI_IMODE_EXECUTE;
580
+ }
581
+
539582 /* Extract one ACPI name from the front of the pathname */
540583
541584 ACPI_MOVE_32_TO_32(&simple_name, path);
....@@ -544,12 +587,19 @@
544587
545588 status =
546589 acpi_ns_search_and_enter(simple_name, walk_state,
547
- current_node, interpreter_mode,
590
+ current_node,
591
+ local_interpreter_mode,
548592 this_search_type, local_flags,
549593 &this_node);
550594 if (ACPI_FAILURE(status)) {
551595 if (status == AE_NOT_FOUND) {
552
-
596
+#if !defined ACPI_ASL_COMPILER /* Note: iASL reports this error by itself, not needed here */
597
+ if (flags & ACPI_NS_PREFIX_MUST_EXIST) {
598
+ acpi_os_printf(ACPI_MSG_BIOS_ERROR
599
+ "Object does not exist: %4.4s\n",
600
+ (char *)&simple_name);
601
+ }
602
+#endif
553603 /* Name not found in ACPI namespace */
554604
555605 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
....@@ -664,7 +714,7 @@
664714
665715 /* Point to next name segment and make this node current */
666716
667
- path += ACPI_NAME_SIZE;
717
+ path += ACPI_NAMESEG_SIZE;
668718 current_node = this_node;
669719 }
670720