forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/acpi/acpica/tbxfload.c
....@@ -3,7 +3,7 @@
33 *
44 * Module Name: tbxfload - Table load/unload external interfaces
55 *
6
- * Copyright (C) 2000 - 2018, Intel Corp.
6
+ * Copyright (C) 2000 - 2020, Intel Corp.
77 *
88 *****************************************************************************/
99
....@@ -69,24 +69,18 @@
6969 "While loading namespace from ACPI tables"));
7070 }
7171
72
- if (acpi_gbl_execute_tables_as_methods
73
- || !acpi_gbl_group_module_level_code) {
74
- /*
75
- * If the module-level code support is enabled, initialize the objects
76
- * in the namespace that remain uninitialized. This runs the executable
77
- * AML that may be part of the declaration of these name objects:
78
- * operation_regions, buffer_fields, Buffers, and Packages.
79
- *
80
- * Note: The module-level code is optional at this time, but will
81
- * become the default in the future.
82
- */
83
- status = acpi_ns_initialize_objects();
84
- if (ACPI_FAILURE(status)) {
85
- return_ACPI_STATUS(status);
86
- }
72
+ /*
73
+ * Initialize the objects in the namespace that remain uninitialized.
74
+ * This runs the executable AML that may be part of the declaration of
75
+ * these name objects:
76
+ * operation_regions, buffer_fields, Buffers, and Packages.
77
+ *
78
+ */
79
+ status = acpi_ns_initialize_objects();
80
+ if (ACPI_SUCCESS(status)) {
81
+ acpi_gbl_namespace_initialized = TRUE;
8782 }
8883
89
- acpi_gbl_namespace_initialized = TRUE;
9084 return_ACPI_STATUS(status);
9185 }
9286
....@@ -124,7 +118,7 @@
124118 table = &acpi_gbl_root_table_list.tables[acpi_gbl_dsdt_index];
125119
126120 if (!acpi_gbl_root_table_list.current_table_count ||
127
- !ACPI_COMPARE_NAME(table->signature.ascii, ACPI_SIG_DSDT) ||
121
+ !ACPI_COMPARE_NAMESEG(table->signature.ascii, ACPI_SIG_DSDT) ||
128122 ACPI_FAILURE(acpi_tb_validate_table(table))) {
129123 status = AE_NO_ACPI_TABLES;
130124 goto unlock_and_exit;
....@@ -176,11 +170,12 @@
176170 table = &acpi_gbl_root_table_list.tables[i];
177171
178172 if (!table->address ||
179
- (!ACPI_COMPARE_NAME(table->signature.ascii, ACPI_SIG_SSDT)
180
- && !ACPI_COMPARE_NAME(table->signature.ascii,
181
- ACPI_SIG_PSDT)
182
- && !ACPI_COMPARE_NAME(table->signature.ascii,
183
- ACPI_SIG_OSDT))
173
+ (!ACPI_COMPARE_NAMESEG
174
+ (table->signature.ascii, ACPI_SIG_SSDT)
175
+ && !ACPI_COMPARE_NAMESEG(table->signature.ascii,
176
+ ACPI_SIG_PSDT)
177
+ && !ACPI_COMPARE_NAMESEG(table->signature.ascii,
178
+ ACPI_SIG_OSDT))
184179 || ACPI_FAILURE(acpi_tb_validate_table(table))) {
185180 continue;
186181 }
....@@ -273,6 +268,8 @@
273268 *
274269 * PARAMETERS: table - Pointer to a buffer containing the ACPI
275270 * table to be loaded.
271
+ * table_idx - Pointer to a u32 for storing the table
272
+ * index, might be NULL
276273 *
277274 * RETURN: Status
278275 *
....@@ -283,7 +280,7 @@
283280 * to ensure that the table is not deleted or unmapped.
284281 *
285282 ******************************************************************************/
286
-acpi_status acpi_load_table(struct acpi_table_header *table)
283
+acpi_status acpi_load_table(struct acpi_table_header *table, u32 *table_idx)
287284 {
288285 acpi_status status;
289286 u32 table_index;
....@@ -302,6 +299,17 @@
302299 status = acpi_tb_install_and_load_table(ACPI_PTR_TO_PHYSADDR(table),
303300 ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL,
304301 FALSE, &table_index);
302
+ if (table_idx) {
303
+ *table_idx = table_index;
304
+ }
305
+
306
+ if (ACPI_SUCCESS(status)) {
307
+
308
+ /* Complete the initialization/resolution of new objects */
309
+
310
+ acpi_ns_initialize_objects();
311
+ }
312
+
305313 return_ACPI_STATUS(status);
306314 }
307315
....@@ -370,7 +378,7 @@
370378 * only these types can contain AML and thus are the only types
371379 * that can create namespace objects.
372380 */
373
- if (ACPI_COMPARE_NAME
381
+ if (ACPI_COMPARE_NAMESEG
374382 (acpi_gbl_root_table_list.tables[i].signature.ascii,
375383 ACPI_SIG_DSDT)) {
376384 status = AE_TYPE;
....@@ -388,3 +396,35 @@
388396 }
389397
390398 ACPI_EXPORT_SYMBOL(acpi_unload_parent_table)
399
+/*******************************************************************************
400
+ *
401
+ * FUNCTION: acpi_unload_table
402
+ *
403
+ * PARAMETERS: table_index - Index as returned by acpi_load_table
404
+ *
405
+ * RETURN: Status
406
+ *
407
+ * DESCRIPTION: Via the table_index representing an SSDT or OEMx table, unloads
408
+ * the table and deletes all namespace objects associated with
409
+ * that table. Unloading of the DSDT is not allowed.
410
+ * Note: Mainly intended to support hotplug removal of SSDTs.
411
+ *
412
+ ******************************************************************************/
413
+acpi_status acpi_unload_table(u32 table_index)
414
+{
415
+ acpi_status status;
416
+
417
+ ACPI_FUNCTION_TRACE(acpi_unload_table);
418
+
419
+ if (table_index == 1) {
420
+
421
+ /* table_index==1 means DSDT is the owner. DSDT cannot be unloaded */
422
+
423
+ return_ACPI_STATUS(AE_TYPE);
424
+ }
425
+
426
+ status = acpi_tb_unload_table(table_index);
427
+ return_ACPI_STATUS(status);
428
+}
429
+
430
+ACPI_EXPORT_SYMBOL(acpi_unload_table)