struct acpi_namespace_node *acpi_db_local_ns_lookup(char *name) { char *internal_path; acpi_status status; struct acpi_namespace_node *node = NULL; acpi_db_prep_namestring(name); /* Build an internal namestring */ status = acpi_ns_internalize_name(name, &internal_path); if (ACPI_FAILURE(status)) { acpi_os_printf("Invalid namestring: %s\n", name); return (NULL); } /* * Lookup the name. * (Uses root node as the search starting point) */ status = acpi_ns_lookup(NULL, internal_path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &node); if (ACPI_FAILURE(status)) { acpi_os_printf("Could not locate name: %s, %s\n", name, acpi_format_exception(status)); } ACPI_FREE(internal_path); return (node); }
acpi_status acpi_ns_evaluate_by_name ( NATIVE_CHAR *pathname, acpi_operand_object **params, acpi_operand_object **return_object) { acpi_status status; acpi_namespace_node *node = NULL; NATIVE_CHAR *internal_path = NULL; FUNCTION_TRACE ("Ns_evaluate_by_name"); /* Build an internal name string for the method */ status = acpi_ns_internalize_name (pathname, &internal_path); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); /* Lookup the name in the namespace */ status = acpi_ns_lookup (NULL, internal_path, ACPI_TYPE_ANY, IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, &node); acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (status)) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Object at [%s] was not found, status=%.4X\n", pathname, status)); goto cleanup; } /* * Now that we have a handle to the object, we can attempt * to evaluate it. */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s [%p] Value %p\n", pathname, node, node->object)); status = acpi_ns_evaluate_by_handle (node, params, return_object); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "*** Completed eval of object %s ***\n", pathname)); cleanup: /* Cleanup */ if (internal_path) { ACPI_MEM_FREE (internal_path); } return_ACPI_STATUS (status); }
acpi_status acpi_ns_get_node ( NATIVE_CHAR *pathname, acpi_namespace_node *start_node, acpi_namespace_node **return_node) { acpi_generic_state scope_info; acpi_status status; NATIVE_CHAR *internal_path = NULL; FUNCTION_TRACE_PTR ("Ns_get_node", pathname); /* Ensure that the namespace has been initialized */ if (!acpi_gbl_root_node) { return_ACPI_STATUS (AE_NO_NAMESPACE); } if (!pathname) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Convert path to internal representation */ status = acpi_ns_internalize_name (pathname, &internal_path); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); /* Setup lookup scope (search starting point) */ scope_info.scope.node = start_node; /* Lookup the name in the namespace */ status = acpi_ns_lookup (&scope_info, internal_path, ACPI_TYPE_ANY, IMODE_EXECUTE, NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, NULL, return_node); if (ACPI_FAILURE (status)) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s, %s\n", internal_path, acpi_format_exception (status))); } acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); /* Cleanup */ ACPI_MEM_FREE (internal_path); return_ACPI_STATUS (status); }
acpi_status acpi_ns_evaluate_by_name(char *pathname, struct acpi_parameter_info *info) { acpi_status status; char *internal_path = NULL; ACPI_FUNCTION_TRACE("ns_evaluate_by_name"); /* Build an internal name string for the method */ status = acpi_ns_internalize_name(pathname, &internal_path); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { goto cleanup; } /* Lookup the name in the namespace */ status = acpi_ns_lookup(NULL, internal_path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, &info->node); (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Object at [%s] was not found, status=%.4X\n", pathname, status)); goto cleanup; } /* * Now that we have a handle to the object, we can attempt to evaluate it. */ ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%s [%p] Value %p\n", pathname, info->node, acpi_ns_get_attached_object(info->node))); status = acpi_ns_evaluate_by_handle(info); ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", pathname)); cleanup: /* Cleanup */ if (internal_path) { ACPI_MEM_FREE(internal_path); } return_ACPI_STATUS(status); }
acpi_status acpi_ns_get_node_unlocked(struct acpi_namespace_node *prefix_node, const char *pathname, u32 flags, struct acpi_namespace_node **return_node) { union acpi_generic_state scope_info; acpi_status status; char *internal_path; ACPI_FUNCTION_TRACE_PTR(ns_get_node_unlocked, ACPI_CAST_PTR(char, pathname)); /* Simplest case is a null pathname */ if (!pathname) { *return_node = prefix_node; if (!prefix_node) { *return_node = acpi_gbl_root_node; } return_ACPI_STATUS(AE_OK); } /* Quick check for a reference to the root */ if (ACPI_IS_ROOT_PREFIX(pathname[0]) && (!pathname[1])) { *return_node = acpi_gbl_root_node; return_ACPI_STATUS(AE_OK); } /* Convert path to internal representation */ status = acpi_ns_internalize_name(pathname, &internal_path); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* Setup lookup scope (search starting point) */ scope_info.scope.node = prefix_node; /* Lookup the name in the namespace */ status = acpi_ns_lookup(&scope_info, internal_path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, (flags | ACPI_NS_DONT_OPEN_SCOPE), NULL, return_node); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s, %s\n", pathname, acpi_format_exception(status))); } ACPI_FREE(internal_path); return_ACPI_STATUS(status); }
acpi_status acpi_ns_get_node_by_path ( char *pathname, struct acpi_namespace_node *start_node, u32 flags, struct acpi_namespace_node **return_node) { union acpi_generic_state scope_info; acpi_status status; char *internal_path = NULL; ACPI_FUNCTION_TRACE_PTR ("ns_get_node_by_path", pathname); if (pathname) { /* Convert path to internal representation */ status = acpi_ns_internalize_name (pathname, &internal_path); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } } /* Must lock namespace during lookup */ status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (status)) { goto cleanup; } /* Setup lookup scope (search starting point) */ scope_info.scope.node = start_node; /* Lookup the name in the namespace */ status = acpi_ns_lookup (&scope_info, internal_path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, (flags | ACPI_NS_DONT_OPEN_SCOPE), NULL, return_node); if (ACPI_FAILURE (status)) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s, %s\n", internal_path, acpi_format_exception (status))); } (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); cleanup: /* Cleanup */ if (internal_path) { ACPI_MEM_FREE (internal_path); } return_ACPI_STATUS (status); }
ACPI_STATUS acpi_ns_evaluate_by_name ( NATIVE_CHAR *pathname, ACPI_OPERAND_OBJECT **params, ACPI_OPERAND_OBJECT **return_object) { ACPI_STATUS status; ACPI_NAMESPACE_NODE *node = NULL; NATIVE_CHAR *internal_path = NULL; /* Build an internal name string for the method */ status = acpi_ns_internalize_name (pathname, &internal_path); if (ACPI_FAILURE (status)) { return (status); } acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); /* Lookup the name in the namespace */ status = acpi_ns_lookup (NULL, internal_path, ACPI_TYPE_ANY, IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, &node); acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (status)) { goto cleanup; } /* * Now that we have a handle to the object, we can attempt * to evaluate it. */ status = acpi_ns_evaluate_by_handle (node, params, return_object); cleanup: /* Cleanup */ if (internal_path) { acpi_cm_free (internal_path); } return (status); }
acpi_namespace_node * acpi_db_local_ns_lookup ( NATIVE_CHAR *name) { NATIVE_CHAR *internal_path; acpi_status status; acpi_namespace_node *node = NULL; acpi_db_prep_namestring (name); /* Build an internal namestring */ status = acpi_ns_internalize_name (name, &internal_path); if (ACPI_FAILURE (status)) { acpi_os_printf ("Invalid namestring: %s\n", name); return (NULL); } /* Lookup the name */ /* TBD: [Investigate] what scope do we use? */ /* Use the root scope for the start of the search */ status = acpi_ns_lookup (NULL, internal_path, ACPI_TYPE_ANY, IMODE_EXECUTE, NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, NULL, &node); if (ACPI_FAILURE (status)) { acpi_os_printf ("Could not locate name: %s %s\n", name, acpi_format_exception (status)); } ACPI_MEM_FREE (internal_path); return (node); }
ACPI_STATUS acpi_ns_evaluate_relative ( ACPI_NAMESPACE_NODE *handle, NATIVE_CHAR *pathname, ACPI_OPERAND_OBJECT **params, ACPI_OPERAND_OBJECT **return_object) { ACPI_NAMESPACE_NODE *prefix_node; ACPI_STATUS status; ACPI_NAMESPACE_NODE *node = NULL; NATIVE_CHAR *internal_path = NULL; ACPI_GENERIC_STATE scope_info; /* * Must have a valid object handle */ if (!handle) { return (AE_BAD_PARAMETER); } /* Build an internal name string for the method */ status = acpi_ns_internalize_name (pathname, &internal_path); if (ACPI_FAILURE (status)) { return (status); } /* Get the prefix handle and Node */ acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); prefix_node = acpi_ns_convert_handle_to_entry (handle); if (!prefix_node) { acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); status = AE_BAD_PARAMETER; goto cleanup; } /* Lookup the name in the namespace */ scope_info.scope.node = prefix_node; status = acpi_ns_lookup (&scope_info, internal_path, ACPI_TYPE_ANY, IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, &node); acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (status)) { goto cleanup; } /* * Now that we have a handle to the object, we can attempt * to evaluate it. */ status = acpi_ns_evaluate_by_handle (node, params, return_object); cleanup: /* Cleanup */ acpi_cm_free (internal_path); return (status); }
acpi_status acpi_ns_evaluate_relative(char *pathname, struct acpi_parameter_info *info) { acpi_status status; struct acpi_namespace_node *node = NULL; union acpi_generic_state *scope_info; char *internal_path = NULL; ACPI_FUNCTION_TRACE("ns_evaluate_relative"); /* * Must have a valid object handle */ if (!info || !info->node) { return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Build an internal name string for the method */ status = acpi_ns_internalize_name(pathname, &internal_path); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } scope_info = acpi_ut_create_generic_state(); if (!scope_info) { goto cleanup1; } /* Get the prefix handle and Node */ status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { goto cleanup; } info->node = acpi_ns_map_handle_to_node(info->node); if (!info->node) { (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); status = AE_BAD_PARAMETER; goto cleanup; } /* Lookup the name in the namespace */ scope_info->scope.node = info->node; status = acpi_ns_lookup(scope_info, internal_path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, &node); (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Object [%s] not found [%s]\n", pathname, acpi_format_exception(status))); goto cleanup; } /* * Now that we have a handle to the object, we can attempt to evaluate it. */ ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%s [%p] Value %p\n", pathname, node, acpi_ns_get_attached_object(node))); info->node = node; status = acpi_ns_evaluate_by_handle(info); ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", pathname)); cleanup: acpi_ut_delete_generic_state(scope_info); cleanup1: ACPI_MEM_FREE(internal_path); return_ACPI_STATUS(status); }
acpi_status acpi_ns_evaluate_relative ( acpi_namespace_node *handle, NATIVE_CHAR *pathname, acpi_operand_object **params, acpi_operand_object **return_object) { acpi_namespace_node *prefix_node; acpi_status status; acpi_namespace_node *node = NULL; NATIVE_CHAR *internal_path = NULL; acpi_generic_state scope_info; FUNCTION_TRACE ("Ns_evaluate_relative"); /* * Must have a valid object handle */ if (!handle) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Build an internal name string for the method */ status = acpi_ns_internalize_name (pathname, &internal_path); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } /* Get the prefix handle and Node */ acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); prefix_node = acpi_ns_map_handle_to_node (handle); if (!prefix_node) { acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); status = AE_BAD_PARAMETER; goto cleanup; } /* Lookup the name in the namespace */ scope_info.scope.node = prefix_node; status = acpi_ns_lookup (&scope_info, internal_path, ACPI_TYPE_ANY, IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, &node); acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (status)) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Object [%s] not found [%s]\n", pathname, acpi_format_exception (status))); goto cleanup; } /* * Now that we have a handle to the object, we can attempt * to evaluate it. */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s [%p] Value %p\n", pathname, node, node->object)); status = acpi_ns_evaluate_by_handle (node, params, return_object); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "*** Completed eval of object %s ***\n", pathname)); cleanup: ACPI_MEM_FREE (internal_path); return_ACPI_STATUS (status); }