void acpi_ns_print_node_pathname(struct acpi_namespace_node *node, const char *message) { struct acpi_buffer buffer; acpi_status status; if (!node) { acpi_os_printf("[NULL NAME]"); return; } /* Convert handle to full pathname and print it (with supplied message) */ buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; status = acpi_ns_handle_to_pathname(node, &buffer); if (ACPI_SUCCESS(status)) { if (message) { acpi_os_printf("%s ", message); } acpi_os_printf("[%s] (Node %p)", (char *)buffer.pointer, node); ACPI_FREE(buffer.pointer); } }
static acpi_status acpi_db_walk_for_specific_objects(acpi_handle obj_handle, u32 nesting_level, void *context, void **return_value) { struct acpi_walk_info *info = (struct acpi_walk_info *)context; struct acpi_buffer buffer; acpi_status status; info->count++; /* Get and display the full pathname to this object */ buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE); if (ACPI_FAILURE(status)) { acpi_os_printf("Could Not get pathname for object %p\n", obj_handle); return (AE_OK); } acpi_os_printf("%32s", (char *)buffer.pointer); ACPI_FREE(buffer.pointer); /* Dump short info about the object */ (void)acpi_ns_dump_one_object(obj_handle, nesting_level, info, NULL); return (AE_OK); }
static void acpi_ds_print_node_pathname(struct acpi_namespace_node *node, const char *message) { struct acpi_buffer buffer; acpi_status status; ACPI_FUNCTION_TRACE(ds_print_node_pathname); if (!node) { ACPI_DEBUG_PRINT_RAW((ACPI_DB_DISPATCH, "[NULL NAME]")); return_VOID; } /* Convert handle to full pathname and print it (with supplied message) */ buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; status = acpi_ns_handle_to_pathname(node, &buffer, TRUE); if (ACPI_SUCCESS(status)) { if (message) { ACPI_DEBUG_PRINT_RAW((ACPI_DB_DISPATCH, "%s ", message)); } ACPI_DEBUG_PRINT_RAW((ACPI_DB_DISPATCH, "[%s] (Node %p)", (char *)buffer.pointer, node)); ACPI_FREE(buffer.pointer); } return_VOID; }
/****************************************************************************** * * FUNCTION: acpi_get_name * * PARAMETERS: Handle - Handle to be converted to a pathname * name_type - Full pathname or single segment * Buffer - Buffer for returned path * * RETURN: Pointer to a string containing the fully qualified Name. * * DESCRIPTION: This routine returns the fully qualified name associated with * the Handle parameter. This and the acpi_pathname_to_handle are * complementary functions. * ******************************************************************************/ acpi_status acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer) { acpi_status status; struct acpi_namespace_node *node; /* Parameter validation */ if (name_type > ACPI_NAME_TYPE_MAX) { return (AE_BAD_PARAMETER); } status = acpi_ut_validate_buffer(buffer); if (ACPI_FAILURE(status)) { return (status); } if (name_type == ACPI_FULL_PATHNAME) { /* Get the full pathname (From the namespace root) */ status = acpi_ns_handle_to_pathname(handle, buffer); return (status); } /* * Wants the single segment ACPI name. * Validate handle and convert to a namespace Node */ status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { return (status); } node = acpi_ns_map_handle_to_node(handle); if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } /* Validate/Allocate/Clear caller buffer */ status = acpi_ut_initialize_buffer(buffer, ACPI_PATH_SEGMENT_LENGTH); if (ACPI_FAILURE(status)) { goto unlock_and_exit; } /* Just copy the ACPI name from the Node and zero terminate it */ ACPI_STRNCPY(buffer->pointer, acpi_ut_get_node_name(node), ACPI_NAME_SIZE); ((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0; status = AE_OK; unlock_and_exit: (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); return (status); }
acpi_status acpi_ps_display_object_pathname ( acpi_walk_state *walk_state, acpi_parse_object *op) { acpi_status status; acpi_namespace_node *node; NATIVE_CHAR buffer[MAX_SHOW_ENTRY]; u32 buffer_size = MAX_SHOW_ENTRY; u32 debug_level; /* Save current debug level so we don't get extraneous debug output */ debug_level = acpi_dbg_level; acpi_dbg_level = 0; /* Just get the Node out of the Op object */ node = op->node; if (!node) { /* Node not defined in this scope, look it up */ status = acpi_ns_lookup (walk_state->scope_info, op->value.string, ACPI_TYPE_ANY, IMODE_EXECUTE, NS_SEARCH_PARENT, walk_state, &(node)); if (ACPI_FAILURE (status)) { /* * We can't get the pathname since the object * is not in the namespace. This can happen during single * stepping where a dynamic named object is *about* to be created. */ acpi_os_printf (" [Path not found]"); goto exit; } /* Save it for next time. */ op->node = node; } /* Convert Named_desc/handle to a full pathname */ status = acpi_ns_handle_to_pathname (node, &buffer_size, buffer); if (ACPI_FAILURE (status)) { acpi_os_printf ("****Could not get pathname****)"); goto exit; } acpi_os_printf (" (Path %s)", buffer); exit: /* Restore the debug level */ acpi_dbg_level = debug_level; return (status); }
void acpi_ut_display_init_pathname ( u8 type, struct acpi_namespace_node *obj_handle, char *path) { acpi_status status; struct acpi_buffer buffer; ACPI_FUNCTION_ENTRY (); /* Only print the path if the appropriate debug level is enabled */ if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { return; } /* Get the full pathname to the node */ buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; status = acpi_ns_handle_to_pathname (obj_handle, &buffer); if (ACPI_FAILURE (status)) { return; } /* Print what we're doing */ switch (type) { case ACPI_TYPE_METHOD: acpi_os_printf ("Executing "); break; default: acpi_os_printf ("Initializing "); break; } /* Print the object type and pathname */ acpi_os_printf ("%-12s %s", acpi_ut_get_type_name (type), (char *) buffer.pointer); /* Extra path is used to append names like _STA, _INI, etc. */ if (path) { acpi_os_printf (".%s", path); } acpi_os_printf ("\n"); ACPI_MEM_FREE (buffer.pointer); }
static acpi_status acpi_db_walk_and_match_name(acpi_handle obj_handle, u32 nesting_level, void *context, void **return_value) { acpi_status status; char *requested_name = (char *)context; u32 i; struct acpi_buffer buffer; struct acpi_walk_info info; /* Check for a name match */ for (i = 0; i < 4; i++) { /* Wildcard support */ if ((requested_name[i] != '?') && (requested_name[i] != ((struct acpi_namespace_node *) obj_handle)->name.ascii[i])) { /* No match, just exit */ return (AE_OK); } } /* Get the full pathname to this object */ buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE); if (ACPI_FAILURE(status)) { acpi_os_printf("Could Not get pathname for object %p\n", obj_handle); } else { info.owner_id = ACPI_OWNER_ID_MAX; info.debug_level = ACPI_UINT32_MAX; info.display_type = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT; acpi_os_printf("%32s", (char *)buffer.pointer); (void)acpi_ns_dump_one_object(obj_handle, nesting_level, &info, NULL); ACPI_FREE(buffer.pointer); } return (AE_OK); }
acpi_status acpi_db_walk_and_match_name ( acpi_handle obj_handle, u32 nesting_level, void *context, void **return_value) { acpi_status status; NATIVE_CHAR *requested_name = (NATIVE_CHAR *) context; u32 i; u32 buf_size; NATIVE_CHAR buffer[96]; /* Check for a name match */ for (i = 0; i < 4; i++) { /* Wildcard support */ if ((requested_name[i] != '?') && (requested_name[i] != ((NATIVE_CHAR *) (&((acpi_namespace_node *) obj_handle)->name))[i])) { /* No match, just exit */ return (AE_OK); } } /* Get the full pathname to this object */ buf_size = sizeof (buffer) / sizeof (*buffer); status = acpi_ns_handle_to_pathname (obj_handle, &buf_size, buffer); if (ACPI_FAILURE (status)) { acpi_os_printf ("Could Not get pathname for object %p\n", obj_handle); } else { acpi_os_printf ("%32s (%p) - %s\n", buffer, obj_handle, acpi_ut_get_type_name (((acpi_namespace_node *) obj_handle)->type)); } return (AE_OK); }
void acpi_ut_display_init_pathname ( acpi_handle obj_handle, char *path) { acpi_status status; u32 length = 128; char buffer[128]; PROC_NAME ("Ut_display_init_pathname"); status = acpi_ns_handle_to_pathname (obj_handle, &length, buffer); if (ACPI_SUCCESS (status)) { if (path) { ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "%s.%s\n", buffer, path)); } else { ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "%s\n", buffer)); } } }
static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc) { struct acpi_buffer ret_buf; acpi_status status; ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER; if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) { acpi_os_printf("Named Object %p ", obj_desc->reference.node); status = acpi_ns_handle_to_pathname(obj_desc->reference.node, &ret_buf); if (ACPI_FAILURE(status)) { acpi_os_printf("Could not convert name to pathname\n"); } else { acpi_os_printf("%s\n", (char *)ret_buf.pointer); ACPI_FREE(ret_buf.pointer); } } else if (obj_desc->reference.object) { acpi_os_printf("\nReferenced Object: %p\n", obj_desc->reference.object); } }
static acpi_status acpi_db_bus_walk(acpi_handle obj_handle, u32 nesting_level, void *context, void **return_value) { struct acpi_namespace_node *node = (struct acpi_namespace_node *)obj_handle; acpi_status status; struct acpi_buffer buffer; struct acpi_namespace_node *temp_node; struct acpi_device_info *info; u32 i; if ((node->type != ACPI_TYPE_DEVICE) && (node->type != ACPI_TYPE_PROCESSOR)) { return (AE_OK); } /* Exit if there is no _PRT under this device */ status = acpi_get_handle(node, METHOD_NAME__PRT, ACPI_CAST_PTR(acpi_handle, &temp_node)); if (ACPI_FAILURE(status)) { return (AE_OK); } /* Get the full path to this device object */ buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE); if (ACPI_FAILURE(status)) { acpi_os_printf("Could Not get pathname for object %p\n", obj_handle); return (AE_OK); } status = acpi_get_object_info(obj_handle, &info); if (ACPI_FAILURE(status)) { return (AE_OK); } /* Display the full path */ acpi_os_printf("%-32s Type %X", (char *)buffer.pointer, node->type); ACPI_FREE(buffer.pointer); if (info->flags & ACPI_PCI_ROOT_BRIDGE) { acpi_os_printf(" - Is PCI Root Bridge"); } acpi_os_printf("\n"); /* _PRT info */ acpi_os_printf("_PRT: %p\n", temp_node); /* Dump _ADR, _HID, _UID, _CID */ if (info->valid & ACPI_VALID_ADR) { acpi_os_printf("_ADR: %8.8X%8.8X\n", ACPI_FORMAT_UINT64(info->address)); } else { acpi_os_printf("_ADR: <Not Present>\n"); } if (info->valid & ACPI_VALID_HID) { acpi_os_printf("_HID: %s\n", info->hardware_id.string); } else { acpi_os_printf("_HID: <Not Present>\n"); } if (info->valid & ACPI_VALID_UID) { acpi_os_printf("_UID: %s\n", info->unique_id.string); } else { acpi_os_printf("_UID: <Not Present>\n"); } if (info->valid & ACPI_VALID_CID) { for (i = 0; i < info->compatible_id_list.count; i++) { acpi_os_printf("_CID: %s\n", info->compatible_id_list.ids[i].string); } } else { acpi_os_printf("_CID: <Not Present>\n"); } ACPI_FREE(info); return (AE_OK); }
acpi_status acpi_get_name ( acpi_handle handle, u32 name_type, acpi_buffer *ret_path_ptr) { acpi_status status; acpi_namespace_node *node; /* Buffer pointer must be valid always */ if (!ret_path_ptr || (name_type > ACPI_NAME_TYPE_MAX)) { return (AE_BAD_PARAMETER); } /* Allow length to be zero and ignore the pointer */ if ((ret_path_ptr->length) && (!ret_path_ptr->pointer)) { return (AE_BAD_PARAMETER); } if (name_type == ACPI_FULL_PATHNAME) { /* Get the full pathname (From the namespace root) */ status = acpi_ns_handle_to_pathname (handle, &ret_path_ptr->length, ret_path_ptr->pointer); return (status); } /* * Wants the single segment ACPI name. * Validate handle and convert to an Node */ acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); node = acpi_ns_map_handle_to_node (handle); if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } /* Check if name will fit in buffer */ if (ret_path_ptr->length < PATH_SEGMENT_LENGTH) { ret_path_ptr->length = PATH_SEGMENT_LENGTH; status = AE_BUFFER_OVERFLOW; goto unlock_and_exit; } /* Just copy the ACPI name from the Node and zero terminate it */ STRNCPY (ret_path_ptr->pointer, (NATIVE_CHAR *) &node->name, ACPI_NAME_SIZE); ((NATIVE_CHAR *) ret_path_ptr->pointer) [ACPI_NAME_SIZE] = 0; status = AE_OK; unlock_and_exit: acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); return (status); }
acpi_status acpi_db_walk_for_specific_objects ( acpi_handle obj_handle, u32 nesting_level, void *context, void **return_value) { acpi_operand_object *obj_desc; acpi_status status; u32 buf_size; NATIVE_CHAR buffer[64]; obj_desc = ((acpi_namespace_node *)obj_handle)->object; buf_size = sizeof (buffer) / sizeof (*buffer); /* Get and display the full pathname to this object */ status = acpi_ns_handle_to_pathname (obj_handle, &buf_size, buffer); if (ACPI_FAILURE (status)) { acpi_os_printf ("Could Not get pathname for object %p\n", obj_handle); return (AE_OK); } acpi_os_printf ("%32s", buffer); /* Display short information about the object */ if (obj_desc) { switch (obj_desc->common.type) { case ACPI_TYPE_METHOD: acpi_os_printf (" #Args %d Concurrency %X", obj_desc->method.param_count, obj_desc->method.concurrency); break; case ACPI_TYPE_INTEGER: acpi_os_printf (" Value %X", obj_desc->integer.value); break; case ACPI_TYPE_STRING: acpi_os_printf (" \"%s\"", obj_desc->string.pointer); break; case ACPI_TYPE_REGION: acpi_os_printf (" Space_id %X Address %X Length %X", obj_desc->region.space_id, obj_desc->region.address, obj_desc->region.length); break; case ACPI_TYPE_PACKAGE: acpi_os_printf (" #Elements %X", obj_desc->package.count); break; case ACPI_TYPE_BUFFER: acpi_os_printf (" Length %X", obj_desc->buffer.length); break; } } acpi_os_printf ("\n"); return (AE_OK); }
acpi_status acpi_rs_create_pci_routing_table ( acpi_operand_object *package_object, u8 *output_buffer, u32 *output_buffer_length) { u8 *buffer = output_buffer; acpi_operand_object **top_object_list = NULL; acpi_operand_object **sub_object_list = NULL; acpi_operand_object *package_element = NULL; u32 buffer_size_needed = 0; u32 number_of_elements = 0; u32 index = 0; pci_routing_table *user_prt = NULL; acpi_namespace_node *node; acpi_status status; FUNCTION_TRACE ("Rs_create_pci_routing_table"); /* * Params already validated, so we don't re-validate here */ status = acpi_rs_calculate_pci_routing_table_length (package_object, &buffer_size_needed); if (!ACPI_SUCCESS(status)) { return_ACPI_STATUS (status); } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Buffer_size_needed = %X\n", buffer_size_needed)); /* * If the data will fit into the available buffer * call to fill in the list */ if (buffer_size_needed <= *output_buffer_length) { /* * Zero out the return buffer before proceeding */ MEMSET (output_buffer, 0x00, *output_buffer_length); /* * Loop through the ACPI_INTERNAL_OBJECTS - Each object should * contain a u32 Address, a u8 Pin, a Name and a u8 * Source_index. */ top_object_list = package_object->package.elements; number_of_elements = package_object->package.count; user_prt = (pci_routing_table *) buffer; buffer = ROUND_PTR_UP_TO_8 (buffer, u8); for (index = 0; index < number_of_elements; index++) { /* * Point User_prt past this current structure * * NOTE: On the first iteration, User_prt->Length will * be zero because we cleared the return buffer earlier */ buffer += user_prt->length; user_prt = (pci_routing_table *) buffer; /* * Fill in the Length field with the information we * have at this point. * The minus four is to subtract the size of the * u8 Source[4] member because it is added below. */ user_prt->length = (sizeof (pci_routing_table) -4); /* * 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; /* * 1) First subobject: Dereference the Address */ if (ACPI_TYPE_INTEGER == (*sub_object_list)->common.type) { user_prt->address = (*sub_object_list)->integer.value; } else { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n", acpi_ut_get_type_name ((*sub_object_list)->common.type))); return_ACPI_STATUS (AE_BAD_DATA); } /* * 2) Second subobject: Dereference the Pin */ sub_object_list++; if (ACPI_TYPE_INTEGER == (*sub_object_list)->common.type) { user_prt->pin = (u32) (*sub_object_list)->integer.value; } else { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n", acpi_ut_get_type_name ((*sub_object_list)->common.type))); return_ACPI_STATUS (AE_BAD_DATA); } /* * 3) Third subobject: Dereference the Source Name */ sub_object_list++; switch ((*sub_object_list)->common.type) { case INTERNAL_TYPE_REFERENCE: if ((*sub_object_list)->reference.opcode != AML_INT_NAMEPATH_OP) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need name, found reference op %X\n", (*sub_object_list)->reference.opcode)); return_ACPI_STATUS (AE_BAD_DATA); } node = (*sub_object_list)->reference.node; /* TBD: use *remaining* length of the buffer! */ status = acpi_ns_handle_to_pathname ((acpi_handle *) node, output_buffer_length, user_prt->source); user_prt->length += STRLEN (user_prt->source) + 1; /* include null terminator */ break; case ACPI_TYPE_STRING: STRCPY (user_prt->source, (*sub_object_list)->string.pointer); /* * Add to the Length field the length of the string */ user_prt->length += (*sub_object_list)->string.length; break; case ACPI_TYPE_INTEGER: /* * If this is a number, then the Source Name * is NULL, since the entire buffer was zeroed * out, we can leave this alone. */ /* * Add to the Length field the length of * the u32 NULL */ user_prt->length += sizeof (u32); break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n", acpi_ut_get_type_name ((*sub_object_list)->common.type))); return_ACPI_STATUS (AE_BAD_DATA); break; } /* Now align the current length */ user_prt->length = ROUND_UP_TO_64_bITS (user_prt->length); /* * 4) Fourth subobject: Dereference the Source Index */ sub_object_list++; if (ACPI_TYPE_INTEGER == (*sub_object_list)->common.type) { user_prt->source_index = (u32) (*sub_object_list)->integer.value; } else { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n", acpi_ut_get_type_name ((*sub_object_list)->common.type))); return_ACPI_STATUS (AE_BAD_DATA); } /* * Point to the next acpi_operand_object */ top_object_list++; } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Output_buffer = %p\n", output_buffer)); } else { *output_buffer_length = buffer_size_needed; return_ACPI_STATUS (AE_BUFFER_OVERFLOW); } /* * Report the amount of buffer used */ *output_buffer_length = buffer_size_needed; return_ACPI_STATUS (AE_OK); }
acpi_status acpi_rs_create_pci_routing_table ( union acpi_operand_object *package_object, struct acpi_buffer *output_buffer) { u8 *buffer; union acpi_operand_object **top_object_list; union acpi_operand_object **sub_object_list; union acpi_operand_object *obj_desc; acpi_size buffer_size_needed = 0; u32 number_of_elements; u32 index; struct acpi_pci_routing_table *user_prt; struct acpi_namespace_node *node; acpi_status status; struct acpi_buffer path_buffer; ACPI_FUNCTION_TRACE ("rs_create_pci_routing_table"); /* Params already validated, so we don't re-validate here */ /* Get the required buffer length */ status = acpi_rs_get_pci_routing_table_length (package_object, &buffer_size_needed); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "buffer_size_needed = %X\n", (u32) buffer_size_needed)); /* Validate/Allocate/Clear caller buffer */ status = acpi_ut_initialize_buffer (output_buffer, buffer_size_needed); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } /* * Loop through the ACPI_INTERNAL_OBJECTS - Each object * should be a package that in turn contains an * acpi_integer Address, a u8 Pin, a Name and a u8 source_index. */ top_object_list = package_object->package.elements; number_of_elements = package_object->package.count; buffer = output_buffer->pointer; user_prt = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer); for (index = 0; index < number_of_elements; index++) { /* * Point user_prt past this current structure * * NOTE: On the first iteration, user_prt->Length will * be zero because we cleared the return buffer earlier */ buffer += user_prt->length; user_prt = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer); /* * Fill in the Length field with the information we have at this point. * The minus four is to subtract the size of the u8 Source[4] member * because it is added below. */ user_prt->length = (sizeof (struct acpi_pci_routing_table) - 4); /* Each element of the top-level package must also be a package */ if (ACPI_GET_OBJECT_TYPE (*top_object_list) != ACPI_TYPE_PACKAGE) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(PRT[%X]) Need sub-package, found %s\n", index, acpi_ut_get_object_type_name (*top_object_list))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } /* Each sub-package must be of length 4 */ if ((*top_object_list)->package.count != 4) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(PRT[%X]) Need package of length 4, found length %d\n", index, (*top_object_list)->package.count)); return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT); } /* * Dereference the sub-package. * The sub_object_list will now point to an array of the four IRQ * elements: [Address, Pin, Source, source_index] */ sub_object_list = (*top_object_list)->package.elements; /* 1) First subobject: Dereference the PRT.Address */ obj_desc = sub_object_list[0]; if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { user_prt->address = obj_desc->integer.value; } else { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(PRT[%X].Address) Need Integer, found %s\n", index, acpi_ut_get_object_type_name (obj_desc))); return_ACPI_STATUS (AE_BAD_DATA); } /* 2) Second subobject: Dereference the PRT.Pin */ obj_desc = sub_object_list[1]; if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { user_prt->pin = (u32) obj_desc->integer.value; } else { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(PRT[%X].Pin) Need Integer, found %s\n", index, acpi_ut_get_object_type_name (obj_desc))); return_ACPI_STATUS (AE_BAD_DATA); } /* 3) Third subobject: Dereference the PRT.source_name */ obj_desc = sub_object_list[2]; switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { case ACPI_TYPE_LOCAL_REFERENCE: if (obj_desc->reference.opcode != AML_INT_NAMEPATH_OP) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(PRT[%X].Source) Need name, found reference op %X\n", index, obj_desc->reference.opcode)); return_ACPI_STATUS (AE_BAD_DATA); } node = obj_desc->reference.node; /* Use *remaining* length of the buffer as max for pathname */ path_buffer.length = output_buffer->length - (u32) ((u8 *) user_prt->source - (u8 *) output_buffer->pointer); path_buffer.pointer = user_prt->source; status = acpi_ns_handle_to_pathname ((acpi_handle) node, &path_buffer); /* +1 to include null terminator */ user_prt->length += (u32) ACPI_STRLEN (user_prt->source) + 1; break; case ACPI_TYPE_STRING: ACPI_STRCPY (user_prt->source, obj_desc->string.pointer); /* * Add to the Length field the length of the string * (add 1 for terminator) */ user_prt->length += obj_desc->string.length + 1; break; case ACPI_TYPE_INTEGER: /* * If this is a number, then the Source Name is NULL, since the * entire buffer was zeroed out, we can leave this alone. * * Add to the Length field the length of the u32 NULL */ user_prt->length += sizeof (u32); break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(PRT[%X].Source) Need Ref/String/Integer, found %s\n", index, acpi_ut_get_object_type_name (obj_desc))); return_ACPI_STATUS (AE_BAD_DATA); } /* Now align the current length */ user_prt->length = (u32) ACPI_ROUND_UP_to_64_bITS (user_prt->length); /* 4) Fourth subobject: Dereference the PRT.source_index */ obj_desc = sub_object_list[3]; if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { user_prt->source_index = (u32) obj_desc->integer.value; } else { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(PRT[%X].source_index) Need Integer, found %s\n", index, acpi_ut_get_object_type_name (obj_desc))); return_ACPI_STATUS (AE_BAD_DATA); } /* Point to the next union acpi_operand_object in the top level package */ top_object_list++; } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "output_buffer %p Length %X\n", output_buffer->pointer, (u32) output_buffer->length)); return_ACPI_STATUS (AE_OK); }
static acpi_status acpi_ut_copy_isimple_to_esimple ( acpi_operand_object *internal_object, acpi_object *external_object, u8 *data_space, u32 *buffer_space_used) { u32 length = 0; acpi_status status = AE_OK; FUNCTION_TRACE ("Ut_copy_isimple_to_esimple"); /* * Check for NULL object case (could be an uninitialized * package element */ if (!internal_object) { *buffer_space_used = 0; return_ACPI_STATUS (AE_OK); } /* Always clear the external object */ MEMSET (external_object, 0, sizeof (acpi_object)); /* * In general, the external object will be the same type as * the internal object */ external_object->type = internal_object->common.type; /* However, only a limited number of external types are supported */ switch (internal_object->common.type) { case ACPI_TYPE_STRING: length = internal_object->string.length + 1; external_object->string.length = internal_object->string.length; external_object->string.pointer = (NATIVE_CHAR *) data_space; MEMCPY ((void *) data_space, (void *) internal_object->string.pointer, length); break; case ACPI_TYPE_BUFFER: length = internal_object->buffer.length; external_object->buffer.length = internal_object->buffer.length; external_object->buffer.pointer = data_space; MEMCPY ((void *) data_space, (void *) internal_object->buffer.pointer, length); break; case ACPI_TYPE_INTEGER: external_object->integer.value= internal_object->integer.value; break; case INTERNAL_TYPE_REFERENCE: /* * This is an object reference. Attempt to dereference it. */ switch (internal_object->reference.opcode) { case AML_ZERO_OP: external_object->type = ACPI_TYPE_INTEGER; external_object->integer.value = 0; break; case AML_ONE_OP: external_object->type = ACPI_TYPE_INTEGER; external_object->integer.value = 1; break; case AML_ONES_OP: external_object->type = ACPI_TYPE_INTEGER; external_object->integer.value = ACPI_INTEGER_MAX; break; case AML_REVISION_OP: external_object->type = ACPI_TYPE_INTEGER; external_object->integer.value = ACPI_CA_SUPPORT_LEVEL; break; case AML_INT_NAMEPATH_OP: /* * This is a named reference, get the string. We already know that * we have room for it, use max length */ length = MAX_STRING_LENGTH; external_object->type = ACPI_TYPE_STRING; external_object->string.pointer = (NATIVE_CHAR *) data_space; status = acpi_ns_handle_to_pathname ((acpi_handle *) internal_object->reference.node, &length, (char *) data_space); /* Converted (external) string length is returned from above */ external_object->string.length = length; break; default: /* * Use the object type of "Any" to indicate a reference * to object containing a handle to an ACPI named object. */ external_object->type = ACPI_TYPE_ANY; external_object->reference.handle = internal_object->reference.node; break; } break; case ACPI_TYPE_PROCESSOR: external_object->processor.proc_id = internal_object->processor.proc_id; external_object->processor.pblk_address = internal_object->processor.address; external_object->processor.pblk_length = internal_object->processor.length; break; case ACPI_TYPE_POWER: external_object->power_resource.system_level = internal_object->power_resource.system_level; external_object->power_resource.resource_order = internal_object->power_resource.resource_order; break; default: /* * There is no corresponding external object type */ return_ACPI_STATUS (AE_SUPPORT); break; } *buffer_space_used = (u32) ROUND_UP_TO_NATIVE_WORD (length); return_ACPI_STATUS (status); }