hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/acpi/acpica/dbmethod.c
....@@ -21,6 +21,8 @@
2121 acpi_db_walk_for_execute(acpi_handle obj_handle,
2222 u32 nesting_level, void *context, void **return_value);
2323
24
+static acpi_status acpi_db_evaluate_object(struct acpi_namespace_node *node);
25
+
2426 /*******************************************************************************
2527 *
2628 * FUNCTION: acpi_db_set_method_breakpoint
....@@ -302,6 +304,10 @@
302304 }
303305
304306 status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
307
+ if (ACPI_FAILURE(status)) {
308
+ return (status);
309
+ }
310
+
305311 walk_state->owner_id = obj_desc->method.owner_id;
306312
307313 /* Push start scope on scope stack and make it current */
....@@ -317,6 +323,10 @@
317323 walk_state->parse_flags |= ACPI_PARSE_DISASSEMBLE;
318324
319325 status = acpi_ps_parse_aml(walk_state);
326
+ if (ACPI_FAILURE(status)) {
327
+ return (status);
328
+ }
329
+
320330 (void)acpi_dm_parse_deferred_ops(op);
321331
322332 /* Now we can disassemble the method */
....@@ -338,42 +348,26 @@
338348
339349 /*******************************************************************************
340350 *
341
- * FUNCTION: acpi_db_walk_for_execute
351
+ * FUNCTION: acpi_db_evaluate_object
342352 *
343
- * PARAMETERS: Callback from walk_namespace
353
+ * PARAMETERS: node - Namespace node for the object
344354 *
345355 * RETURN: Status
346356 *
347
- * DESCRIPTION: Batch execution module. Currently only executes predefined
348
- * ACPI names.
357
+ * DESCRIPTION: Main execution function for the Evaluate/Execute/All debugger
358
+ * commands.
349359 *
350360 ******************************************************************************/
351361
352
-static acpi_status
353
-acpi_db_walk_for_execute(acpi_handle obj_handle,
354
- u32 nesting_level, void *context, void **return_value)
362
+static acpi_status acpi_db_evaluate_object(struct acpi_namespace_node *node)
355363 {
356
- struct acpi_namespace_node *node =
357
- (struct acpi_namespace_node *)obj_handle;
358
- struct acpi_db_execute_walk *info =
359
- (struct acpi_db_execute_walk *)context;
360
- struct acpi_buffer return_obj;
361
- acpi_status status;
362364 char *pathname;
363365 u32 i;
364366 struct acpi_device_info *obj_info;
365367 struct acpi_object_list param_objects;
366368 union acpi_object params[ACPI_METHOD_NUM_ARGS];
367
- const union acpi_predefined_info *predefined;
368
-
369
- predefined = acpi_ut_match_predefined_method(node->name.ascii);
370
- if (!predefined) {
371
- return (AE_OK);
372
- }
373
-
374
- if (node->type == ACPI_TYPE_LOCAL_SCOPE) {
375
- return (AE_OK);
376
- }
369
+ struct acpi_buffer return_obj;
370
+ acpi_status status;
377371
378372 pathname = acpi_ns_get_external_pathname(node);
379373 if (!pathname) {
....@@ -382,7 +376,7 @@
382376
383377 /* Get the object info for number of method parameters */
384378
385
- status = acpi_get_object_info(obj_handle, &obj_info);
379
+ status = acpi_get_object_info(node, &obj_info);
386380 if (ACPI_FAILURE(status)) {
387381 ACPI_FREE(pathname);
388382 return (status);
....@@ -413,13 +407,66 @@
413407 acpi_gbl_method_executing = TRUE;
414408
415409 status = acpi_evaluate_object(node, NULL, &param_objects, &return_obj);
410
+ acpi_gbl_method_executing = FALSE;
416411
417412 acpi_os_printf("%-32s returned %s\n", pathname,
418413 acpi_format_exception(status));
419
- acpi_gbl_method_executing = FALSE;
414
+ if (return_obj.length) {
415
+ acpi_os_printf("Evaluation of %s returned object %p, "
416
+ "external buffer length %X\n",
417
+ pathname, return_obj.pointer,
418
+ (u32)return_obj.length);
419
+
420
+ acpi_db_dump_external_object(return_obj.pointer, 1);
421
+ acpi_os_printf("\n");
422
+ }
423
+
420424 ACPI_FREE(pathname);
421425
422426 /* Ignore status from method execution */
427
+
428
+ return (AE_OK);
429
+
430
+ /* Update count, check if we have executed enough methods */
431
+
432
+}
433
+
434
+/*******************************************************************************
435
+ *
436
+ * FUNCTION: acpi_db_walk_for_execute
437
+ *
438
+ * PARAMETERS: Callback from walk_namespace
439
+ *
440
+ * RETURN: Status
441
+ *
442
+ * DESCRIPTION: Batch execution function. Evaluates all "predefined" objects --
443
+ * the nameseg begins with an underscore.
444
+ *
445
+ ******************************************************************************/
446
+
447
+static acpi_status
448
+acpi_db_walk_for_execute(acpi_handle obj_handle,
449
+ u32 nesting_level, void *context, void **return_value)
450
+{
451
+ struct acpi_namespace_node *node =
452
+ (struct acpi_namespace_node *)obj_handle;
453
+ struct acpi_db_execute_walk *info =
454
+ (struct acpi_db_execute_walk *)context;
455
+ acpi_status status;
456
+ const union acpi_predefined_info *predefined;
457
+
458
+ predefined = acpi_ut_match_predefined_method(node->name.ascii);
459
+ if (!predefined) {
460
+ return (AE_OK);
461
+ }
462
+
463
+ if (node->type == ACPI_TYPE_LOCAL_SCOPE) {
464
+ return (AE_OK);
465
+ }
466
+
467
+ acpi_db_evaluate_object(node);
468
+
469
+ /* Ignore status from object evaluation */
423470
424471 status = AE_OK;
425472
....@@ -430,6 +477,52 @@
430477 status = AE_CTRL_TERMINATE;
431478 }
432479
480
+ return (status);
481
+}
482
+
483
+/*******************************************************************************
484
+ *
485
+ * FUNCTION: acpi_db_walk_for_execute_all
486
+ *
487
+ * PARAMETERS: Callback from walk_namespace
488
+ *
489
+ * RETURN: Status
490
+ *
491
+ * DESCRIPTION: Batch execution function. Evaluates all objects whose path ends
492
+ * with the nameseg "Info->NameSeg". Used for the "ALL" command.
493
+ *
494
+ ******************************************************************************/
495
+
496
+static acpi_status
497
+acpi_db_walk_for_execute_all(acpi_handle obj_handle,
498
+ u32 nesting_level,
499
+ void *context, void **return_value)
500
+{
501
+ struct acpi_namespace_node *node =
502
+ (struct acpi_namespace_node *)obj_handle;
503
+ struct acpi_db_execute_walk *info =
504
+ (struct acpi_db_execute_walk *)context;
505
+ acpi_status status;
506
+
507
+ if (!ACPI_COMPARE_NAMESEG(node->name.ascii, info->name_seg)) {
508
+ return (AE_OK);
509
+ }
510
+
511
+ if (node->type == ACPI_TYPE_LOCAL_SCOPE) {
512
+ return (AE_OK);
513
+ }
514
+
515
+ /* Now evaluate the input object (node) */
516
+
517
+ acpi_db_evaluate_object(node);
518
+
519
+ /* Ignore status from method execution */
520
+
521
+ status = AE_OK;
522
+
523
+ /* Update count of executed methods/objects */
524
+
525
+ info->count++;
433526 return (status);
434527 }
435528
....@@ -462,3 +555,35 @@
462555 acpi_os_printf("Evaluated %u predefined names in the namespace\n",
463556 info.count);
464557 }
558
+
559
+/*******************************************************************************
560
+ *
561
+ * FUNCTION: acpi_db_evaluate_all
562
+ *
563
+ * PARAMETERS: none_acpi_gbl_db_method_info
564
+ *
565
+ * RETURN: None
566
+ *
567
+ * DESCRIPTION: Namespace batch execution. Implements the "ALL" command.
568
+ * Execute all namepaths whose final nameseg matches the
569
+ * input nameseg.
570
+ *
571
+ ******************************************************************************/
572
+
573
+void acpi_db_evaluate_all(char *name_seg)
574
+{
575
+ struct acpi_db_execute_walk info;
576
+
577
+ info.count = 0;
578
+ info.max_count = ACPI_UINT32_MAX;
579
+ ACPI_COPY_NAMESEG(info.name_seg, name_seg);
580
+ info.name_seg[ACPI_NAMESEG_SIZE] = 0;
581
+
582
+ /* Search all nodes in namespace */
583
+
584
+ (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
585
+ ACPI_UINT32_MAX, acpi_db_walk_for_execute_all,
586
+ NULL, (void *)&info, NULL);
587
+
588
+ acpi_os_printf("Evaluated %u names in the namespace\n", info.count);
589
+}