@@ -21,6 +21,8 @@ static acpi_status
2121acpi_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
@@ -346,42 +348,26 @@ acpi_status acpi_db_disassemble_method(char *name)
346348
347349/*******************************************************************************
348350 *
349- * FUNCTION: acpi_db_walk_for_execute
351+ * FUNCTION: acpi_db_evaluate_object
350352 *
351- * PARAMETERS: Callback from walk_namespace
353+ * PARAMETERS: node - Namespace node for the object
352354 *
353355 * RETURN: Status
354356 *
355- * DESCRIPTION: Batch execution module. Currently only executes predefined
356- * ACPI names .
357+ * DESCRIPTION: Main execution function for the Evaluate/Execute/All debugger
358+ * commands .
357359 *
358360 ******************************************************************************/
359361
360- static acpi_status
361- acpi_db_walk_for_execute (acpi_handle obj_handle ,
362- u32 nesting_level , void * context , void * * return_value )
362+ static acpi_status acpi_db_evaluate_object (struct acpi_namespace_node * node )
363363{
364- struct acpi_namespace_node * node =
365- (struct acpi_namespace_node * )obj_handle ;
366- struct acpi_db_execute_walk * info =
367- (struct acpi_db_execute_walk * )context ;
368- struct acpi_buffer return_obj ;
369- acpi_status status ;
370364 char * pathname ;
371365 u32 i ;
372366 struct acpi_device_info * obj_info ;
373367 struct acpi_object_list param_objects ;
374368 union acpi_object params [ACPI_METHOD_NUM_ARGS ];
375- const union acpi_predefined_info * predefined ;
376-
377- predefined = acpi_ut_match_predefined_method (node -> name .ascii );
378- if (!predefined ) {
379- return (AE_OK );
380- }
381-
382- if (node -> type == ACPI_TYPE_LOCAL_SCOPE ) {
383- return (AE_OK );
384- }
369+ struct acpi_buffer return_obj ;
370+ acpi_status status ;
385371
386372 pathname = acpi_ns_get_external_pathname (node );
387373 if (!pathname ) {
@@ -390,7 +376,7 @@ acpi_db_walk_for_execute(acpi_handle obj_handle,
390376
391377 /* Get the object info for number of method parameters */
392378
393- status = acpi_get_object_info (obj_handle , & obj_info );
379+ status = acpi_get_object_info (node , & obj_info );
394380 if (ACPI_FAILURE (status )) {
395381 ACPI_FREE (pathname );
396382 return (status );
@@ -421,14 +407,67 @@ acpi_db_walk_for_execute(acpi_handle obj_handle,
421407 acpi_gbl_method_executing = TRUE;
422408
423409 status = acpi_evaluate_object (node , NULL , & param_objects , & return_obj );
410+ acpi_gbl_method_executing = FALSE;
424411
425412 acpi_os_printf ("%-32s returned %s\n" , pathname ,
426413 acpi_format_exception (status ));
427- 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+
428424 ACPI_FREE (pathname );
429425
430426 /* Ignore status from method execution */
431427
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 */
470+
432471 status = AE_OK ;
433472
434473 /* Update count, check if we have executed enough methods */
@@ -441,6 +480,52 @@ acpi_db_walk_for_execute(acpi_handle obj_handle,
441480 return (status );
442481}
443482
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 ++ ;
526+ return (status );
527+ }
528+
444529/*******************************************************************************
445530 *
446531 * FUNCTION: acpi_db_evaluate_predefined_names
@@ -470,3 +555,35 @@ void acpi_db_evaluate_predefined_names(void)
470555 acpi_os_printf ("Evaluated %u predefined names in the namespace\n" ,
471556 info .count );
472557}
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+ }
0 commit comments