acpi_status acpi_ns_handle_to_pathname(acpi_handle target_handle, struct acpi_buffer * buffer) { acpi_status status; struct acpi_namespace_node *node; acpi_size required_size; ACPI_FUNCTION_TRACE_PTR(ns_handle_to_pathname, target_handle); node = acpi_ns_map_handle_to_node(target_handle); if (!node) { return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Determine size required for the caller buffer */ required_size = acpi_ns_get_pathname_length(node); /* Validate/Allocate/Clear caller buffer */ status = acpi_ut_initialize_buffer(buffer, required_size); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* Build the path in the caller buffer */ acpi_ns_build_external_path(node, required_size, buffer->pointer); ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X]\n", (char *)buffer->pointer, (u32) required_size)); return_ACPI_STATUS(AE_OK); }
char * acpi_ns_get_external_pathname ( struct acpi_namespace_node *node) { char *name_buffer; acpi_size size; ACPI_FUNCTION_TRACE_PTR ("ns_get_external_pathname", node); /* Calculate required buffer size based on depth below root */ size = acpi_ns_get_pathname_length (node); /* Allocate a buffer to be returned to caller */ name_buffer = ACPI_MEM_CALLOCATE (size); if (!name_buffer) { ACPI_REPORT_ERROR (("ns_get_table_pathname: allocation failure\n")); return_PTR (NULL); } /* Build the path in the allocated buffer */ acpi_ns_build_external_path (node, size, name_buffer); return_PTR (name_buffer); }
char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node) { acpi_status status; char *name_buffer; acpi_size size; ACPI_FUNCTION_TRACE_PTR(ns_get_external_pathname, node); /* Calculate required buffer size based on depth below root */ size = acpi_ns_get_pathname_length(node); if (!size) { return_PTR(NULL); } /* Allocate a buffer to be returned to caller */ name_buffer = ACPI_ALLOCATE_ZEROED(size); if (!name_buffer) { ACPI_ERROR((AE_INFO, "Could not allocate %u bytes", (u32)size)); return_PTR(NULL); } /* Build the path in the allocated buffer */ status = acpi_ns_build_external_path(node, size, name_buffer); if (ACPI_FAILURE(status)) { ACPI_FREE(name_buffer); return_PTR(NULL); } return_PTR(name_buffer); }
char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node) { acpi_status status; char *name_buffer; acpi_size size; ACPI_FUNCTION_TRACE_PTR(ns_get_external_pathname, node); size = acpi_ns_get_pathname_length(node); if (!size) { return_PTR(NULL); } name_buffer = ACPI_ALLOCATE_ZEROED(size); if (!name_buffer) { ACPI_ERROR((AE_INFO, "Could not allocate %u bytes", (u32)size)); return_PTR(NULL); } status = acpi_ns_build_external_path(node, size, name_buffer); if (ACPI_FAILURE(status)) { ACPI_FREE(name_buffer); return_PTR(NULL); } return_PTR(name_buffer); }
acpi_status acpi_ns_handle_to_pathname(acpi_handle target_handle, struct acpi_buffer * buffer) { acpi_status status; struct acpi_namespace_node *node; acpi_size required_size; ACPI_FUNCTION_TRACE_PTR(ns_handle_to_pathname, target_handle); node = acpi_ns_validate_handle(target_handle); if (!node) { return_ACPI_STATUS(AE_BAD_PARAMETER); } required_size = acpi_ns_get_pathname_length(node); if (!required_size) { return_ACPI_STATUS(AE_BAD_PARAMETER); } status = acpi_ut_initialize_buffer(buffer, required_size); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } status = acpi_ns_build_external_path(node, required_size, buffer->pointer); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X]\n", (char *)buffer->pointer, (u32) required_size)); return_ACPI_STATUS(AE_OK); }
static acpi_status acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, acpi_size * obj_length) { acpi_size length; acpi_size size; acpi_status status = AE_OK; ACPI_FUNCTION_TRACE_PTR(ut_get_simple_object_size, internal_object); if (!internal_object) { *obj_length = sizeof(union acpi_object); return_ACPI_STATUS(AE_OK); } length = sizeof(union acpi_object); if (ACPI_GET_DESCRIPTOR_TYPE(internal_object) == ACPI_DESC_TYPE_NAMED) { *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length); return_ACPI_STATUS(status); } switch (internal_object->common.type) { case ACPI_TYPE_STRING: length += (acpi_size) internal_object->string.length + 1; break; case ACPI_TYPE_BUFFER: length += (acpi_size) internal_object->buffer.length; break; case ACPI_TYPE_INTEGER: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_POWER: break; case ACPI_TYPE_LOCAL_REFERENCE: switch (internal_object->reference.class) { case ACPI_REFCLASS_NAME: size = acpi_ns_get_pathname_length(internal_object-> reference.node); if (!size) { return_ACPI_STATUS(AE_BAD_PARAMETER); } length += ACPI_ROUND_UP_TO_NATIVE_WORD(size); break; default: ACPI_ERROR((AE_INFO, "Cannot convert to external object - " "unsupported Reference Class [%s] %X in object %p", acpi_ut_get_reference_name(internal_object), internal_object->reference.class, internal_object)); status = AE_TYPE; break; } break; default: ACPI_ERROR((AE_INFO, "Cannot convert to external object - " "unsupported type [%s] %X in object %p", acpi_ut_get_object_type_name(internal_object), internal_object->common.type, internal_object)); status = AE_TYPE; break; } *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length); return_ACPI_STATUS(status); }
static acpi_status acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, acpi_size * obj_length) { acpi_size length; acpi_status status = AE_OK; ACPI_FUNCTION_TRACE_PTR(ut_get_simple_object_size, internal_object); /* * Handle a null object (Could be a uninitialized package * element -- which is legal) */ if (!internal_object) { *obj_length = sizeof(union acpi_object); return_ACPI_STATUS(AE_OK); } /* Start with the length of the Acpi object */ length = sizeof(union acpi_object); if (ACPI_GET_DESCRIPTOR_TYPE(internal_object) == ACPI_DESC_TYPE_NAMED) { /* Object is a named object (reference), just return the length */ *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length); return_ACPI_STATUS(status); } /* * The final length depends on the object type * Strings and Buffers are packed right up against the parent object and * must be accessed bytewise or there may be alignment problems on * certain processors */ switch (ACPI_GET_OBJECT_TYPE(internal_object)) { case ACPI_TYPE_STRING: length += (acpi_size) internal_object->string.length + 1; break; case ACPI_TYPE_BUFFER: length += (acpi_size) internal_object->buffer.length; break; case ACPI_TYPE_INTEGER: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_POWER: /* No extra data for these types */ break; case ACPI_TYPE_LOCAL_REFERENCE: switch (internal_object->reference.opcode) { case AML_INT_NAMEPATH_OP: /* * Get the actual length of the full pathname to this object. * The reference will be converted to the pathname to the object */ length += ACPI_ROUND_UP_TO_NATIVE_WORD (acpi_ns_get_pathname_length (internal_object->reference.node)); break; default: /* * No other reference opcodes are supported. * Notably, Locals and Args are not supported, but this may be * required eventually. */ ACPI_ERROR((AE_INFO, "Unsupported Reference opcode=%X in object %p", internal_object->reference.opcode, internal_object)); status = AE_TYPE; break; } break; default: ACPI_ERROR((AE_INFO, "Unsupported type=%X in object %p", ACPI_GET_OBJECT_TYPE(internal_object), internal_object)); status = AE_TYPE; break; } /* * Account for the space required by the object rounded up to the next * multiple of the machine word size. This keeps each object aligned * on a machine word boundary. (preventing alignment faults on some * machines.) */ *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length); return_ACPI_STATUS(status); }
acpi_status acpi_ns_handle_to_pathname ( acpi_handle target_handle, u32 *buf_size, NATIVE_CHAR *user_buffer) { acpi_status status = AE_OK; acpi_namespace_node *node; u32 path_length; u32 user_buf_size; acpi_name name; u32 size; FUNCTION_TRACE_PTR ("Ns_handle_to_pathname", target_handle); if (!acpi_gbl_root_node) { /* * If the name space has not been initialized, * this function should not have been called. */ return_ACPI_STATUS (AE_NO_NAMESPACE); } node = acpi_ns_map_handle_to_node (target_handle); if (!node) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Set return length to the required path length */ path_length = acpi_ns_get_pathname_length (node); size = path_length - 1; user_buf_size = *buf_size; *buf_size = path_length; /* Check if the user buffer is sufficiently large */ if (path_length > user_buf_size) { status = AE_BUFFER_OVERFLOW; goto exit; } /* Store null terminator */ user_buffer[size] = 0; size -= ACPI_NAME_SIZE; /* Put the original ACPI name at the end of the path */ MOVE_UNALIGNED32_TO_32 ((user_buffer + size), &node->name); user_buffer[--size] = PATH_SEPARATOR; /* Build name backwards, putting "." between segments */ while ((size > ACPI_NAME_SIZE) && node) { size -= ACPI_NAME_SIZE; name = acpi_ns_find_parent_name (node); MOVE_UNALIGNED32_TO_32 ((user_buffer + size), &name); user_buffer[--size] = PATH_SEPARATOR; node = acpi_ns_get_parent_object (node); } /* * Overlay the "." preceding the first segment with * the root name "\" */ user_buffer[size] = '\\'; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Len=%X, %s \n", path_length, user_buffer)); exit: return_ACPI_STATUS (status); }
acpi_status acpi_rs_calculate_pci_routing_table_length ( acpi_operand_object *package_object, u32 *buffer_size_needed) { u32 number_of_elements; u32 temp_size_needed = 0; acpi_operand_object **top_object_list; u32 index; acpi_operand_object *package_element; acpi_operand_object **sub_object_list; u8 name_found; u32 table_index; FUNCTION_TRACE ("Rs_calculate_pci_routing_table_length"); number_of_elements = package_object->package.count; /* * Calculate the size of the return buffer. * The base size is the number of elements * the sizes of the * structures. Additional space for the strings is added below. * The minus one is to subtract the size of the u8 Source[1] * member because it is added below. * * But each PRT_ENTRY structure has a pointer to a string and * the size of that string must be found. */ top_object_list = package_object->package.elements; for (index = 0; index < number_of_elements; index++) { /* * Dereference the sub-package */ package_element = *top_object_list; /* * The Sub_object_list will now point to an array of the * four IRQ elements: Address, Pin, Source and Source_index */ sub_object_list = package_element->package.elements; /* * Scan the Irq_table_elements for the Source Name String */ name_found = FALSE; for (table_index = 0; table_index < 4 && !name_found; table_index++) { if ((ACPI_TYPE_STRING == (*sub_object_list)->common.type) || ((INTERNAL_TYPE_REFERENCE == (*sub_object_list)->common.type) && ((*sub_object_list)->reference.opcode == AML_INT_NAMEPATH_OP))) { name_found = TRUE; } else { /* * Look at the next element */ sub_object_list++; } } temp_size_needed += (sizeof (pci_routing_table) - 4); /* * Was a String type found? */ if (TRUE == name_found) { if (ACPI_TYPE_STRING == (*sub_object_list)->common.type) { /* * The length String.Length field includes the * terminating NULL */ temp_size_needed += (*sub_object_list)->string.length; } else { temp_size_needed += acpi_ns_get_pathname_length ( (*sub_object_list)->reference.node); } } else { /* * If no name was found, then this is a NULL, which is * translated as a u32 zero. */ temp_size_needed += sizeof (u32); } /* Round up the size since each element must be aligned */ temp_size_needed = ROUND_UP_TO_64_bITS (temp_size_needed); /* * Point to the next acpi_operand_object */ top_object_list++; } /* * Adding an extra element to the end of the list, essentially a NULL terminator */ *buffer_size_needed = temp_size_needed + sizeof (pci_routing_table); return_ACPI_STATUS (AE_OK); }
acpi_status acpi_ut_get_simple_object_size ( acpi_operand_object *internal_object, u32 *obj_length) { u32 length; acpi_status status = AE_OK; FUNCTION_TRACE_PTR ("Ut_get_simple_object_size", internal_object); /* Handle a null object (Could be a uninitialized package element -- which is legal) */ if (!internal_object) { *obj_length = 0; return_ACPI_STATUS (AE_OK); } /* Start with the length of the Acpi object */ length = sizeof (acpi_object); if (VALID_DESCRIPTOR_TYPE (internal_object, ACPI_DESC_TYPE_NAMED)) { /* Object is a named object (reference), just return the length */ *obj_length = (u32) ROUND_UP_TO_NATIVE_WORD (length); return_ACPI_STATUS (status); } /* * The final length depends on the object type * Strings and Buffers are packed right up against the parent object and * must be accessed bytewise or there may be alignment problems on * certain processors */ switch (internal_object->common.type) { case ACPI_TYPE_STRING: length += internal_object->string.length + 1; break; case ACPI_TYPE_BUFFER: length += internal_object->buffer.length; break; case ACPI_TYPE_INTEGER: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_POWER: /* * No extra data for these types */ break; case INTERNAL_TYPE_REFERENCE: /* * The only type that should be here is internal opcode NAMEPATH_OP -- since * this means an object reference */ if (internal_object->reference.opcode != AML_INT_NAMEPATH_OP) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported Reference opcode=%X in object %p\n", internal_object->reference.opcode, internal_object)); status = AE_TYPE; } else { /* * Get the actual length of the full pathname to this object. * The reference will be converted to the pathname to the object */ length += ROUND_UP_TO_NATIVE_WORD (acpi_ns_get_pathname_length (internal_object->reference.node)); } break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported type=%X in object %p\n", internal_object->common.type, internal_object)); status = AE_TYPE; break; } /* * Account for the space required by the object rounded up to the next * multiple of the machine word size. This keeps each object aligned * on a machine word boundary. (preventing alignment faults on some * machines.) */ *obj_length = (u32) ROUND_UP_TO_NATIVE_WORD (length); return_ACPI_STATUS (status); }
static acpi_status acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, acpi_size * obj_length) { acpi_size length; acpi_size size; acpi_status status = AE_OK; ACPI_FUNCTION_TRACE_PTR(ut_get_simple_object_size, internal_object); /* Start with the length of the (external) Acpi object */ length = sizeof(union acpi_object); /* A NULL object is allowed, can be a legal uninitialized package element */ if (!internal_object) { /* * Object is NULL, just return the length of union acpi_object * (A NULL union acpi_object is an object of all zeroes.) */ *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length); return_ACPI_STATUS(AE_OK); } /* A Namespace Node should never appear here */ if (ACPI_GET_DESCRIPTOR_TYPE(internal_object) == ACPI_DESC_TYPE_NAMED) { /* A namespace node should never get here */ return_ACPI_STATUS(AE_AML_INTERNAL); } /* * The final length depends on the object type * Strings and Buffers are packed right up against the parent object and * must be accessed bytewise or there may be alignment problems on * certain processors */ switch (internal_object->common.type) { case ACPI_TYPE_STRING: length += (acpi_size) internal_object->string.length + 1; break; case ACPI_TYPE_BUFFER: length += (acpi_size) internal_object->buffer.length; break; case ACPI_TYPE_INTEGER: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_POWER: /* No extra data for these types */ break; case ACPI_TYPE_LOCAL_REFERENCE: switch (internal_object->reference.class) { case ACPI_REFCLASS_NAME: /* * Get the actual length of the full pathname to this object. * The reference will be converted to the pathname to the object */ size = acpi_ns_get_pathname_length(internal_object-> reference.node); if (!size) { return_ACPI_STATUS(AE_BAD_PARAMETER); } length += ACPI_ROUND_UP_TO_NATIVE_WORD(size); break; default: /* * No other reference opcodes are supported. * Notably, Locals and Args are not supported, but this may be * required eventually. */ ACPI_ERROR((AE_INFO, "Cannot convert to external object - " "unsupported Reference Class [%s] 0x%X in object %p", acpi_ut_get_reference_name(internal_object), internal_object->reference.class, internal_object)); status = AE_TYPE; break; } break; default: ACPI_ERROR((AE_INFO, "Cannot convert to external object - " "unsupported type [%s] 0x%X in object %p", acpi_ut_get_object_type_name(internal_object), internal_object->common.type, internal_object)); status = AE_TYPE; break; } /* * Account for the space required by the object rounded up to the next * multiple of the machine word size. This keeps each object aligned * on a machine word boundary. (preventing alignment faults on some * machines.) */ *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length); return_ACPI_STATUS(status); }