hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/acpi/acpica/dbtest.c
....@@ -10,6 +10,7 @@
1010 #include "acdebug.h"
1111 #include "acnamesp.h"
1212 #include "acpredef.h"
13
+#include "acinterp.h"
1314
1415 #define _COMPONENT ACPI_CA_DEBUGGER
1516 ACPI_MODULE_NAME("dbtest")
....@@ -31,6 +32,9 @@
3132 acpi_db_test_string_type(struct acpi_namespace_node *node, u32 byte_length);
3233
3334 static acpi_status acpi_db_test_package_type(struct acpi_namespace_node *node);
35
+
36
+static acpi_status
37
+acpi_db_test_field_unit_type(union acpi_operand_object *obj_desc);
3438
3539 static acpi_status
3640 acpi_db_read_from_object(struct acpi_namespace_node *node,
....@@ -74,7 +78,7 @@
7478 static acpi_handle read_handle = NULL;
7579 static acpi_handle write_handle = NULL;
7680
77
-/* ASL Definitions of the debugger read/write control methods */
81
+/* ASL Definitions of the debugger read/write control methods. AML below. */
7882
7983 #if 0
8084 definition_block("ssdt.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001)
....@@ -227,10 +231,8 @@
227231 * RETURN: Status
228232 *
229233 * DESCRIPTION: Test one namespace object. Supported types are Integer,
230
- * String, Buffer, buffer_field, and field_unit. All other object
231
- * types are simply ignored.
232
- *
233
- * Note: Support for Packages is not implemented.
234
+ * String, Buffer, Package, buffer_field, and field_unit.
235
+ * All other object types are simply ignored.
234236 *
235237 ******************************************************************************/
236238
....@@ -240,7 +242,6 @@
240242 {
241243 struct acpi_namespace_node *node;
242244 union acpi_operand_object *obj_desc;
243
- union acpi_operand_object *region_obj;
244245 acpi_object_type local_type;
245246 u32 bit_length = 0;
246247 u32 byte_length = 0;
....@@ -281,18 +282,21 @@
281282 break;
282283
283284 case ACPI_TYPE_FIELD_UNIT:
284
- case ACPI_TYPE_BUFFER_FIELD:
285285 case ACPI_TYPE_LOCAL_REGION_FIELD:
286286 case ACPI_TYPE_LOCAL_INDEX_FIELD:
287287 case ACPI_TYPE_LOCAL_BANK_FIELD:
288288
289
+ local_type = ACPI_TYPE_FIELD_UNIT;
290
+ break;
291
+
292
+ case ACPI_TYPE_BUFFER_FIELD:
293
+ /*
294
+ * The returned object will be a Buffer if the field length
295
+ * is larger than the size of an Integer (32 or 64 bits
296
+ * depending on the DSDT version).
297
+ */
289298 local_type = ACPI_TYPE_INTEGER;
290299 if (obj_desc) {
291
- /*
292
- * Returned object will be a Buffer if the field length
293
- * is larger than the size of an Integer (32 or 64 bits
294
- * depending on the DSDT version).
295
- */
296300 bit_length = obj_desc->common_field.bit_length;
297301 byte_length = ACPI_ROUND_BITS_UP_TO_BYTES(bit_length);
298302 if (bit_length > acpi_gbl_integer_bit_width) {
....@@ -303,7 +307,7 @@
303307
304308 default:
305309
306
- /* Ignore all other types */
310
+ /* Ignore all non-data types - Methods, Devices, Scopes, etc. */
307311
308312 return (AE_OK);
309313 }
....@@ -314,38 +318,8 @@
314318 acpi_ut_get_type_name(node->type), node->name.ascii);
315319
316320 if (!obj_desc) {
317
- acpi_os_printf(" Ignoring, no attached object\n");
321
+ acpi_os_printf(" No attached sub-object, ignoring\n");
318322 return (AE_OK);
319
- }
320
-
321
- /*
322
- * Check for unsupported region types. Note: acpi_exec simulates
323
- * access to system_memory, system_IO, PCI_Config, and EC.
324
- */
325
- switch (node->type) {
326
- case ACPI_TYPE_LOCAL_REGION_FIELD:
327
-
328
- region_obj = obj_desc->field.region_obj;
329
- switch (region_obj->region.space_id) {
330
- case ACPI_ADR_SPACE_SYSTEM_MEMORY:
331
- case ACPI_ADR_SPACE_SYSTEM_IO:
332
- case ACPI_ADR_SPACE_PCI_CONFIG:
333
-
334
- break;
335
-
336
- default:
337
-
338
- acpi_os_printf
339
- (" %s space is not supported in this command [%4.4s]\n",
340
- acpi_ut_get_region_name(region_obj->region.
341
- space_id),
342
- region_obj->region.node->name.ascii);
343
- return (AE_OK);
344
- }
345
- break;
346
-
347
- default:
348
- break;
349323 }
350324
351325 /* At this point, we have resolved the object to one of the major types */
....@@ -371,6 +345,11 @@
371345 status = acpi_db_test_package_type(node);
372346 break;
373347
348
+ case ACPI_TYPE_FIELD_UNIT:
349
+
350
+ status = acpi_db_test_field_unit_type(obj_desc);
351
+ break;
352
+
374353 default:
375354
376355 acpi_os_printf(" Ignoring, type not implemented (%2.2X)",
....@@ -382,24 +361,8 @@
382361
383362 if (ACPI_FAILURE(status)) {
384363 status = AE_OK;
385
- goto exit;
386364 }
387365
388
- switch (node->type) {
389
- case ACPI_TYPE_LOCAL_REGION_FIELD:
390
-
391
- region_obj = obj_desc->field.region_obj;
392
- acpi_os_printf(" (%s)",
393
- acpi_ut_get_region_name(region_obj->region.
394
- space_id));
395
-
396
- break;
397
-
398
- default:
399
- break;
400
- }
401
-
402
-exit:
403366 acpi_os_printf("\n");
404367 return (status);
405368 }
....@@ -444,7 +407,7 @@
444407 return (status);
445408 }
446409
447
- acpi_os_printf(" (%4.4X/%3.3X) %8.8X%8.8X",
410
+ acpi_os_printf(ACPI_DEBUG_LENGTH_FORMAT " %8.8X%8.8X",
448411 bit_length, ACPI_ROUND_BITS_UP_TO_BYTES(bit_length),
449412 ACPI_FORMAT_UINT64(temp1->integer.value));
450413
....@@ -558,8 +521,9 @@
558521
559522 /* Emit a few bytes of the buffer */
560523
561
- acpi_os_printf(" (%4.4X/%3.3X)", bit_length, temp1->buffer.length);
562
- for (i = 0; ((i < 4) && (i < byte_length)); i++) {
524
+ acpi_os_printf(ACPI_DEBUG_LENGTH_FORMAT, bit_length,
525
+ temp1->buffer.length);
526
+ for (i = 0; ((i < 8) && (i < byte_length)); i++) {
563527 acpi_os_printf(" %2.2X", temp1->buffer.pointer[i]);
564528 }
565529 acpi_os_printf("... ");
....@@ -665,8 +629,9 @@
665629 return (status);
666630 }
667631
668
- acpi_os_printf(" (%4.4X/%3.3X) \"%s\"", (temp1->string.length * 8),
669
- temp1->string.length, temp1->string.pointer);
632
+ acpi_os_printf(ACPI_DEBUG_LENGTH_FORMAT " \"%s\"",
633
+ (temp1->string.length * 8), temp1->string.length,
634
+ temp1->string.pointer);
670635
671636 /* Write a new value */
672637
....@@ -750,13 +715,80 @@
750715 return (status);
751716 }
752717
753
- acpi_os_printf(" %8.8X Elements", temp1->package.count);
718
+ acpi_os_printf(" %.2X Elements", temp1->package.count);
754719 acpi_os_free(temp1);
755720 return (status);
756721 }
757722
758723 /*******************************************************************************
759724 *
725
+ * FUNCTION: acpi_db_test_field_unit_type
726
+ *
727
+ * PARAMETERS: obj_desc - A field unit object
728
+ *
729
+ * RETURN: Status
730
+ *
731
+ * DESCRIPTION: Test read/write on a named field unit.
732
+ *
733
+ ******************************************************************************/
734
+
735
+static acpi_status
736
+acpi_db_test_field_unit_type(union acpi_operand_object *obj_desc)
737
+{
738
+ union acpi_operand_object *region_obj;
739
+ u32 bit_length = 0;
740
+ u32 byte_length = 0;
741
+ acpi_status status = AE_OK;
742
+ union acpi_operand_object *ret_buffer_desc;
743
+
744
+ /* Supported spaces are memory/io/pci_config */
745
+
746
+ region_obj = obj_desc->field.region_obj;
747
+ switch (region_obj->region.space_id) {
748
+ case ACPI_ADR_SPACE_SYSTEM_MEMORY:
749
+ case ACPI_ADR_SPACE_SYSTEM_IO:
750
+ case ACPI_ADR_SPACE_PCI_CONFIG:
751
+
752
+ /* Need the interpreter to execute */
753
+
754
+ acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
755
+ acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
756
+
757
+ /* Exercise read-then-write */
758
+
759
+ status =
760
+ acpi_ex_read_data_from_field(NULL, obj_desc,
761
+ &ret_buffer_desc);
762
+ if (status == AE_OK) {
763
+ acpi_ex_write_data_to_field(ret_buffer_desc, obj_desc,
764
+ NULL);
765
+ acpi_ut_remove_reference(ret_buffer_desc);
766
+ }
767
+
768
+ acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
769
+ acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
770
+
771
+ bit_length = obj_desc->common_field.bit_length;
772
+ byte_length = ACPI_ROUND_BITS_UP_TO_BYTES(bit_length);
773
+
774
+ acpi_os_printf(ACPI_DEBUG_LENGTH_FORMAT " [%s]", bit_length,
775
+ byte_length,
776
+ acpi_ut_get_region_name(region_obj->region.
777
+ space_id));
778
+ return (status);
779
+
780
+ default:
781
+
782
+ acpi_os_printf
783
+ (" %s address space is not supported in this command [%4.4s]",
784
+ acpi_ut_get_region_name(region_obj->region.space_id),
785
+ region_obj->region.node->name.ascii);
786
+ return (AE_OK);
787
+ }
788
+}
789
+
790
+/*******************************************************************************
791
+ *
760792 * FUNCTION: acpi_db_read_from_object
761793 *
762794 * PARAMETERS: node - Parent NS node for the object