static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle) { acpi_status status; acpi_handle child_handle; acpi_handle parent_handle; acpi_handle next_child_handle; acpi_handle dummy; u32 level; ACPI_FUNCTION_TRACE(ns_delete_subtree); parent_handle = start_handle; child_handle = NULL; level = 1; while (level > 0) { status = acpi_get_next_object(ACPI_TYPE_ANY, parent_handle, child_handle, &next_child_handle); child_handle = next_child_handle; if (ACPI_SUCCESS(status)) { if (ACPI_SUCCESS (acpi_get_next_object (ACPI_TYPE_ANY, child_handle, NULL, &dummy))) { level++; parent_handle = child_handle; child_handle = NULL; } } else { level--; acpi_ns_delete_children(child_handle); child_handle = parent_handle; status = acpi_get_parent(parent_handle, &parent_handle); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } } } acpi_ns_remove_node(child_handle); return_ACPI_STATUS(AE_OK); }
/** \brief get peer device in ACPI namespace * \param handle acpi handle * \return acpi handle for peer device */ KCL_ACPI_DevHandle ATI_API_CALL KCL_ACPI_GetPeerDevice(KCL_ACPI_DevHandle handle) { KCL_ACPI_DevHandle peer_handle; acpi_status status = acpi_get_next_object (ACPI_TYPE_ANY, NULL, handle, &peer_handle); if (ACPI_SUCCESS(status)) { return peer_handle; } else { return NULL; } }
/** \brief get child device in ACPI namespace * \param handle acpi handle for parent device * \return acpi handle for child device */ KCL_ACPI_DevHandle ATI_API_CALL KCL_ACPI_GetChildDevice(KCL_ACPI_DevHandle handle) { KCL_ACPI_DevHandle child_handle; acpi_status status = acpi_get_next_object (ACPI_TYPE_ANY, handle, NULL, &child_handle); if (ACPI_SUCCESS(status)) { return child_handle; } else { return NULL; } }
static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle) { acpi_status status; acpi_handle child_handle; acpi_handle parent_handle; acpi_handle next_child_handle; acpi_handle dummy; u32 level; ACPI_FUNCTION_TRACE(ns_delete_subtree); parent_handle = start_handle; child_handle = NULL; level = 1; /* * Traverse the tree of objects until we bubble back up * to where we started. */ while (level > 0) { /* Attempt to get the next object in this scope */ status = acpi_get_next_object(ACPI_TYPE_ANY, parent_handle, child_handle, &next_child_handle); child_handle = next_child_handle; /* Did we get a new object? */ if (ACPI_SUCCESS(status)) { /* Check if this object has any children */ if (ACPI_SUCCESS (acpi_get_next_object (ACPI_TYPE_ANY, child_handle, NULL, &dummy))) { /* * There is at least one child of this object, * visit the object */ level++; parent_handle = child_handle; child_handle = NULL; } } else { /* * No more children in this object, go back up to * the object's parent */ level--; /* Delete all children now */ acpi_ns_delete_children(child_handle); child_handle = parent_handle; status = acpi_get_parent(parent_handle, &parent_handle); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } } } /* Now delete the starting object, and we are done */ acpi_ns_delete_node(child_handle); return_ACPI_STATUS(AE_OK); }
acpi_status bm_enumerate_namespace (void) { acpi_status status = AE_OK; acpi_handle parent_handle = ACPI_ROOT_OBJECT; acpi_handle child_handle = NULL; BM_NODE *parent = NULL; BM_NODE *child = NULL; acpi_object_type acpi_type = 0; u32 level = 1; FUNCTION_TRACE("bm_enumerate_namespace"); parent = node_list.nodes[0]; /* * Enumerate ACPI Namespace: * ------------------------- * Parse through the ACPI namespace, identify all 'devices', * and create a new entry for each in our collection. */ while (level > 0) { /* * Get the next object at this level. */ status = acpi_get_next_object(ACPI_TYPE_ANY, parent_handle, child_handle, &child_handle); if (ACPI_SUCCESS(status)) { /* * TBD: This is a hack to get around the problem * identifying scope objects. Scopes * somehow need to be uniquely identified. */ status = acpi_get_type(child_handle, &acpi_type); if (ACPI_SUCCESS(status) && (acpi_type == ACPI_TYPE_ANY)) { status = acpi_get_next_object(ACPI_TYPE_ANY, child_handle, 0, NULL); if (ACPI_SUCCESS(status)) { acpi_type = INTERNAL_TYPE_SCOPE; } } /* * Device? * ------- * If this object is a 'device', insert into the * ACPI Bus Manager's local hierarchy and search * the object's scope for any child devices (a * depth-first search). */ switch (acpi_type) { case INTERNAL_TYPE_SCOPE: case ACPI_TYPE_DEVICE: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_THERMAL: case ACPI_TYPE_POWER: status = bm_add_namespace_device(child_handle, acpi_type, parent, &child); if (ACPI_SUCCESS(status)) { status = acpi_get_next_object(ACPI_TYPE_ANY, child_handle, 0, NULL); if (ACPI_SUCCESS(status)) { level++; parent_handle = child_handle; child_handle = 0; parent = child; } } break; } } /* * Scope Exhausted: * ---------------- * No more children in this object's scope, Go back up * in the namespace tree to the object's parent. */ else { level--; child_handle = parent_handle; acpi_get_parent(parent_handle, &parent_handle); if (parent) { parent = parent->parent; } else { return_ACPI_STATUS(AE_NULL_ENTRY); } } } return_ACPI_STATUS(AE_OK); }
void bm_print_object ( acpi_handle handle) { acpi_buffer buffer; acpi_handle parent; acpi_object_type type; buffer.length = 256; buffer.pointer = acpi_os_callocate(buffer.length); if (!buffer.pointer) { return; } acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); acpi_get_parent(handle, &parent); acpi_get_type(handle, &type); /* * TBD: Hack to get around scope identification problem. */ if (type == ACPI_TYPE_ANY) { if (ACPI_SUCCESS(acpi_get_next_object(ACPI_TYPE_ANY, handle, 0, NULL))) { type = INTERNAL_TYPE_SCOPE; } } switch (type) { case INTERNAL_TYPE_SCOPE: acpi_os_printf("SCOPE: "); break; case ACPI_TYPE_INTEGER: acpi_os_printf("SIMPLE (number): "); break; case ACPI_TYPE_STRING: acpi_os_printf("SIMPLE (string): "); break; case ACPI_TYPE_BUFFER: acpi_os_printf("SIMPLE (buffer): "); break; case ACPI_TYPE_PACKAGE: acpi_os_printf("SIMPLE (package): "); break; case ACPI_TYPE_FIELD_UNIT: acpi_os_printf("FIELD UNIT: "); break; case ACPI_TYPE_DEVICE: acpi_os_printf("DEVICE: "); break; case ACPI_TYPE_EVENT: acpi_os_printf("EVENT: "); break; case ACPI_TYPE_METHOD: acpi_os_printf("CONTROL METHOD: "); break; case ACPI_TYPE_MUTEX: acpi_os_printf("MUTEX: "); break; case ACPI_TYPE_REGION: acpi_os_printf("OPERATION REGION: "); break; case ACPI_TYPE_POWER: acpi_os_printf("POWER RESOURCE: "); break; case ACPI_TYPE_PROCESSOR: acpi_os_printf("PROCESSOR: "); break; case ACPI_TYPE_THERMAL: acpi_os_printf("THERMAL ZONE: "); break; case ACPI_TYPE_BUFFER_FIELD: acpi_os_printf("BUFFER FIELD: "); break; case ACPI_TYPE_DDB_HANDLE: acpi_os_printf("DDB HANDLE: "); break; default: acpi_os_printf("OTHER (%d): ", type); break; } acpi_os_printf("Object[%p][%s] parent[%p].\n", handle, (char*)buffer.pointer, parent); acpi_os_free(buffer.pointer); }