dsobject.c
来自「是关于linux2.5.1的完全源码」· C语言 代码 · 共 710 行 · 第 1/2 页
C
710 行
acpi_ds_build_internal_object ( acpi_walk_state *walk_state, acpi_parse_object *op, acpi_operand_object **obj_desc_ptr){ acpi_operand_object *obj_desc; acpi_status status; char *name; ACPI_FUNCTION_TRACE ("Ds_build_internal_object"); if (op->opcode == AML_INT_NAMEPATH_OP) { /* * This is an object reference. If this name was * previously looked up in the namespace, it was stored in this op. * Otherwise, go ahead and look it up now */ if (!op->node) { status = acpi_ns_lookup (walk_state->scope_info, op->value.string, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, (acpi_namespace_node **) &(op->node)); if (ACPI_FAILURE (status)) { if (status == AE_NOT_FOUND) { name = NULL; acpi_ns_externalize_name (ACPI_UINT32_MAX, op->value.string, NULL, &name); if (name) { ACPI_REPORT_WARNING (("Reference %s at AML %X not found\n", name, op->aml_offset)); ACPI_MEM_FREE (name); } else { ACPI_REPORT_WARNING (("Reference %s at AML %X not found\n", op->value.string, op->aml_offset)); } *obj_desc_ptr = NULL; } else { return_ACPI_STATUS (status); } } } } /* Create and init the internal ACPI object */ obj_desc = acpi_ut_create_internal_object ((acpi_ps_get_opcode_info (op->opcode))->object_type); if (!obj_desc) { return_ACPI_STATUS (AE_NO_MEMORY); } status = acpi_ds_init_object_from_op (walk_state, op, op->opcode, &obj_desc); if (ACPI_FAILURE (status)) { acpi_ut_remove_reference (obj_desc); return_ACPI_STATUS (status); } *obj_desc_ptr = obj_desc; return_ACPI_STATUS (AE_OK);}/***************************************************************************** * * FUNCTION: Acpi_ds_build_internal_buffer_obj * * PARAMETERS: Op - Parser object to be translated * Obj_desc_ptr - Where the ACPI internal object is returned * * RETURN: Status * * DESCRIPTION: Translate a parser Op package object to the equivalent * namespace object * ****************************************************************************/acpi_statusacpi_ds_build_internal_buffer_obj ( acpi_walk_state *walk_state, acpi_parse_object *op, u32 buffer_length, acpi_operand_object **obj_desc_ptr){ acpi_parse_object *arg; acpi_operand_object *obj_desc; acpi_parse2_object *byte_list; u32 byte_list_length = 0; ACPI_FUNCTION_TRACE ("Ds_build_internal_buffer_obj"); obj_desc = *obj_desc_ptr; if (obj_desc) { /* * We are evaluating a Named buffer object "Name (xxxx, Buffer)". * The buffer object already exists (from the NS node) */ } else { /* Create a new buffer object */ obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); *obj_desc_ptr = obj_desc; if (!obj_desc) { return_ACPI_STATUS (AE_NO_MEMORY); } } /* * Second arg is the buffer data (optional) Byte_list can be either * individual bytes or a string initializer. In either case, a * Byte_list appears in the AML. */ arg = op->value.arg; /* skip first arg */ byte_list = (acpi_parse2_object *) arg->next; if (byte_list) { if (byte_list->opcode != AML_INT_BYTELIST_OP) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Expecting bytelist, got AML opcode %X in op %p\n", byte_list->opcode, byte_list)); acpi_ut_remove_reference (obj_desc); return (AE_TYPE); } byte_list_length = byte_list->value.integer32; } /* * The buffer length (number of bytes) will be the larger of: * 1) The specified buffer length and * 2) The length of the initializer byte list */ obj_desc->buffer.length = buffer_length; if (byte_list_length > buffer_length) { obj_desc->buffer.length = byte_list_length; } /* Allocate the buffer */ if (obj_desc->buffer.length == 0) { obj_desc->buffer.pointer = NULL; ACPI_REPORT_WARNING (("Buffer created with zero length in AML\n")); return_ACPI_STATUS (AE_OK); } obj_desc->buffer.pointer = ACPI_MEM_CALLOCATE ( obj_desc->buffer.length); if (!obj_desc->buffer.pointer) { acpi_ut_delete_object_desc (obj_desc); return_ACPI_STATUS (AE_NO_MEMORY); } /* Initialize buffer from the Byte_list (if present) */ if (byte_list) { ACPI_MEMCPY (obj_desc->buffer.pointer, byte_list->data, byte_list_length); } obj_desc->buffer.flags |= AOPOBJ_DATA_VALID; op->node = (acpi_namespace_node *) obj_desc; return_ACPI_STATUS (AE_OK);}/***************************************************************************** * * FUNCTION: Acpi_ds_build_internal_package_obj * * PARAMETERS: Op - Parser object to be translated * Obj_desc_ptr - Where the ACPI internal object is returned * * RETURN: Status * * DESCRIPTION: Translate a parser Op package object to the equivalent * namespace object * ****************************************************************************/acpi_statusacpi_ds_build_internal_package_obj ( acpi_walk_state *walk_state, acpi_parse_object *op, u32 package_length, acpi_operand_object **obj_desc_ptr){ acpi_parse_object *arg; acpi_parse_object *parent; acpi_operand_object *obj_desc = NULL; u32 package_list_length; acpi_status status = AE_OK; u32 i; ACPI_FUNCTION_TRACE ("Ds_build_internal_package_obj"); /* Find the parent of a possibly nested package */ parent = op->parent; while ((parent->opcode == AML_PACKAGE_OP) || (parent->opcode == AML_VAR_PACKAGE_OP)) { parent = parent->parent; } obj_desc = *obj_desc_ptr; if (obj_desc) { /* * We are evaluating a Named package object "Name (xxxx, Package)". * Get the existing package object from the NS node */ } else { obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_PACKAGE); *obj_desc_ptr = obj_desc; if (!obj_desc) { return_ACPI_STATUS (AE_NO_MEMORY); } obj_desc->package.node = parent->node; } obj_desc->package.count = package_length; /* Count the number of items in the package list */ package_list_length = 0; arg = op->value.arg; arg = arg->next; while (arg) { package_list_length++; arg = arg->next; } /* * The package length (number of elements) will be the greater * of the specified length and the length of the initializer list */ if (package_list_length > package_length) { obj_desc->package.count = package_list_length; } /* * Allocate the pointer array (array of pointers to the * individual objects). Add an extra pointer slot so * that the list is always null terminated. */ obj_desc->package.elements = ACPI_MEM_CALLOCATE ( (obj_desc->package.count + 1) * sizeof (void *)); if (!obj_desc->package.elements) { acpi_ut_delete_object_desc (obj_desc); return_ACPI_STATUS (AE_NO_MEMORY); } /* * Now init the elements of the package */ i = 0; arg = op->value.arg; arg = arg->next; while (arg) { if (arg->opcode == AML_INT_RETURN_VALUE_OP) { /* Object (package or buffer) is already built */ obj_desc->package.elements[i] = (acpi_operand_object *) arg->node; } else { status = acpi_ds_build_internal_object (walk_state, arg, &obj_desc->package.elements[i]); } i++; arg = arg->next; } obj_desc->package.flags |= AOPOBJ_DATA_VALID; op->node = (acpi_namespace_node *) obj_desc; return_ACPI_STATUS (status);}/***************************************************************************** * * FUNCTION: Acpi_ds_create_node * * PARAMETERS: Op - Parser object to be translated * Obj_desc_ptr - Where the ACPI internal object is returned * * RETURN: Status * * DESCRIPTION: * ****************************************************************************/acpi_statusacpi_ds_create_node ( acpi_walk_state *walk_state, acpi_namespace_node *node, acpi_parse_object *op){ acpi_status status; acpi_operand_object *obj_desc; ACPI_FUNCTION_TRACE_PTR ("Ds_create_node", op); /* * Because of the execution pass through the non-control-method * parts of the table, we can arrive here twice. Only init * the named object node the first time through */ if (acpi_ns_get_attached_object (node)) { return_ACPI_STATUS (AE_OK); } if (!op->value.arg) { /* No arguments, there is nothing to do */ return_ACPI_STATUS (AE_OK); } /* Build an internal object for the argument(s) */ status = acpi_ds_build_internal_object (walk_state, op->value.arg, &obj_desc); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } /* Re-type the object according to it's argument */ node->type = obj_desc->common.type; /* Attach obj to node */ status = acpi_ns_attach_object (node, obj_desc, node->type); /* Remove local reference to the object */ acpi_ut_remove_reference (obj_desc); return_ACPI_STATUS (status);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?