acpi_parse_object* acpi_ps_alloc_op ( u16 opcode) { acpi_parse_object *op = NULL; u32 size; u8 flags; const acpi_opcode_info *op_info; FUNCTION_ENTRY (); op_info = acpi_ps_get_opcode_info (opcode); /* Allocate the minimum required size object */ if (op_info->flags & AML_DEFER) { size = sizeof (acpi_parse2_object); flags = PARSEOP_DEFERRED; } else if (op_info->flags & AML_NAMED) { size = sizeof (acpi_parse2_object); flags = PARSEOP_NAMED; } else if (opcode == AML_INT_BYTELIST_OP) { size = sizeof (acpi_parse2_object); flags = PARSEOP_BYTELIST; } else { size = sizeof (acpi_parse_object); flags = PARSEOP_GENERIC; } if (size == sizeof (acpi_parse_object)) { /* * The generic op is by far the most common (16 to 1) */ op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE); } else { op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE_EXT); } /* Initialize the Op */ if (op) { acpi_ps_init_op (op, opcode); op->flags = flags; } return (op); }
union acpi_parse_object *acpi_ps_alloc_op(u16 opcode, u8 *aml) { union acpi_parse_object *op; const struct acpi_opcode_info *op_info; u8 flags = ACPI_PARSEOP_GENERIC; ACPI_FUNCTION_ENTRY(); op_info = acpi_ps_get_opcode_info(opcode); /* Determine type of parse_op required */ if (op_info->flags & AML_DEFER) { flags = ACPI_PARSEOP_DEFERRED; } else if (op_info->flags & AML_NAMED) { flags = ACPI_PARSEOP_NAMED_OBJECT; } else if (opcode == AML_INT_BYTELIST_OP) { flags = ACPI_PARSEOP_BYTELIST; } /* Allocate the minimum required size object */ if (flags == ACPI_PARSEOP_GENERIC) { /* The generic op (default) is by far the most common (16 to 1) */ op = acpi_os_acquire_object(acpi_gbl_ps_node_cache); } else { /* Extended parseop */ op = acpi_os_acquire_object(acpi_gbl_ps_node_ext_cache); } /* Initialize the Op */ if (op) { acpi_ps_init_op(op, opcode); op->common.aml = aml; op->common.flags = flags; } return (op); }
union acpi_parse_object *acpi_ps_alloc_op(u16 opcode) { union acpi_parse_object *op; const struct acpi_opcode_info *op_info; u8 flags = ACPI_PARSEOP_GENERIC; ACPI_FUNCTION_ENTRY(); op_info = acpi_ps_get_opcode_info(opcode); if (op_info->flags & AML_DEFER) { flags = ACPI_PARSEOP_DEFERRED; } else if (op_info->flags & AML_NAMED) { flags = ACPI_PARSEOP_NAMED; } else if (opcode == AML_INT_BYTELIST_OP) { flags = ACPI_PARSEOP_BYTELIST; } if (flags == ACPI_PARSEOP_GENERIC) { op = acpi_os_acquire_object(acpi_gbl_ps_node_cache); } else { op = acpi_os_acquire_object(acpi_gbl_ps_node_ext_cache); } if (op) { acpi_ps_init_op(op, opcode); op->common.flags = flags; } return (op); }
void acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state, u32 arg_type, union acpi_parse_object *arg) { ACPI_FUNCTION_TRACE_U32("ps_get_next_simple_arg", arg_type); switch (arg_type) { case ARGP_BYTEDATA: acpi_ps_init_op(arg, AML_BYTE_OP); arg->common.value.integer = (u32) ACPI_GET8(parser_state->aml); parser_state->aml++; break; case ARGP_WORDDATA: acpi_ps_init_op(arg, AML_WORD_OP); /* Get 2 bytes from the AML stream */ ACPI_MOVE_16_TO_32(&arg->common.value.integer, parser_state->aml); parser_state->aml += 2; break; case ARGP_DWORDDATA: acpi_ps_init_op(arg, AML_DWORD_OP); /* Get 4 bytes from the AML stream */ ACPI_MOVE_32_TO_32(&arg->common.value.integer, parser_state->aml); parser_state->aml += 4; break; case ARGP_QWORDDATA: acpi_ps_init_op(arg, AML_QWORD_OP); /* Get 8 bytes from the AML stream */ ACPI_MOVE_64_TO_64(&arg->common.value.integer, parser_state->aml); parser_state->aml += 8; break; case ARGP_CHARLIST: acpi_ps_init_op(arg, AML_STRING_OP); arg->common.value.string = (char *)parser_state->aml; while (ACPI_GET8(parser_state->aml) != '\0') { parser_state->aml++; } parser_state->aml++; break; case ARGP_NAME: case ARGP_NAMESTRING: acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP); arg->common.value.name = acpi_ps_get_next_namestring(parser_state); break; default: ACPI_REPORT_ERROR(("Invalid arg_type %X\n", arg_type)); break; } return_VOID; }
acpi_status acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state, struct acpi_parse_state *parser_state, union acpi_parse_object *arg, u8 method_call) { char *path; union acpi_parse_object *name_op; acpi_status status = AE_OK; union acpi_operand_object *method_desc; struct acpi_namespace_node *node; union acpi_generic_state scope_info; ACPI_FUNCTION_TRACE("ps_get_next_namepath"); path = acpi_ps_get_next_namestring(parser_state); /* Null path case is allowed */ if (path) { /* * Lookup the name in the internal namespace */ scope_info.scope.node = NULL; node = parser_state->start_node; if (node) { scope_info.scope.node = node; } /* * Lookup object. We don't want to add anything new to the namespace * here, however. So we use MODE_EXECUTE. Allow searching of the * parent tree, but don't open a new scope -- we just want to lookup the * object (MUST BE mode EXECUTE to perform upsearch) */ status = acpi_ns_lookup(&scope_info, path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &node); if (ACPI_SUCCESS(status) && method_call) { if (node->type == ACPI_TYPE_METHOD) { /* This name is actually a control method invocation */ method_desc = acpi_ns_get_attached_object(node); ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Control Method - %p Desc %p Path=%p\n", node, method_desc, path)); name_op = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP); if (!name_op) { return_ACPI_STATUS(AE_NO_MEMORY); } /* Change arg into a METHOD CALL and attach name to it */ acpi_ps_init_op(arg, AML_INT_METHODCALL_OP); name_op->common.value.name = path; /* Point METHODCALL/NAME to the METHOD Node */ name_op->common.node = node; acpi_ps_append_arg(arg, name_op); if (!method_desc) { ACPI_REPORT_ERROR(("ps_get_next_namepath: Control Method %p has no attached object\n", node)); return_ACPI_STATUS(AE_AML_INTERNAL); } ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Control Method - %p Args %X\n", node, method_desc->method. param_count)); /* Get the number of arguments to expect */ walk_state->arg_count = method_desc->method.param_count; return_ACPI_STATUS(AE_OK); } /* * Else this is normal named object reference. * Just init the NAMEPATH object with the pathname. * (See code below) */ } if (ACPI_FAILURE(status)) { /* * 1) Any error other than NOT_FOUND is always severe * 2) NOT_FOUND is only important if we are executing a method. * 3) If executing a cond_ref_of opcode, NOT_FOUND is ok. */ if ((((walk_state-> parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) && (status == AE_NOT_FOUND) && (walk_state->op->common.aml_opcode != AML_COND_REF_OF_OP)) || (status != AE_NOT_FOUND)) { ACPI_REPORT_NSERROR(path, status); acpi_os_printf ("search_node %p start_node %p return_node %p\n", scope_info.scope.node, parser_state->start_node, node); } else { /* * We got a NOT_FOUND during table load or we encountered * a cond_ref_of(x) where the target does not exist. * Either case is ok */ status = AE_OK; } } } /* * Regardless of success/failure above, * Just initialize the Op with the pathname. */ acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP); arg->common.value.name = path; return_ACPI_STATUS(status); }
void acpi_ps_get_next_simple_arg ( ACPI_PARSE_STATE *parser_state, u32 arg_type, ACPI_PARSE_OBJECT *arg) { switch (arg_type) { case ARGP_BYTEDATA: acpi_ps_init_op (arg, AML_BYTE_OP); arg->value.integer = (u32) GET8 (parser_state->aml); parser_state->aml++; break; case ARGP_WORDDATA: acpi_ps_init_op (arg, AML_WORD_OP); /* Get 2 bytes from the AML stream */ MOVE_UNALIGNED16_TO_32 (&arg->value.integer, parser_state->aml); parser_state->aml += 2; break; case ARGP_DWORDDATA: acpi_ps_init_op (arg, AML_DWORD_OP); /* Get 4 bytes from the AML stream */ MOVE_UNALIGNED32_TO_32 (&arg->value.integer, parser_state->aml); parser_state->aml += 4; break; case ARGP_CHARLIST: acpi_ps_init_op (arg, AML_STRING_OP); arg->value.string = (char*) parser_state->aml; while (GET8 (parser_state->aml) != '\0') { parser_state->aml++; } parser_state->aml++; break; case ARGP_NAME: case ARGP_NAMESTRING: acpi_ps_init_op (arg, AML_NAMEPATH_OP); arg->value.name = acpi_ps_get_next_namestring (parser_state); break; } return; }
void acpi_ps_get_next_namepath ( ACPI_PARSE_STATE *parser_state, ACPI_PARSE_OBJECT *arg, u32 *arg_count, u8 method_call) { NATIVE_CHAR *path; ACPI_PARSE_OBJECT *name_op; ACPI_STATUS status; ACPI_NAMESPACE_NODE *method_node = NULL; ACPI_NAMESPACE_NODE *node; ACPI_GENERIC_STATE scope_info; path = acpi_ps_get_next_namestring (parser_state); if (!path || !method_call) { /* Null name case, create a null namepath object */ acpi_ps_init_op (arg, AML_NAMEPATH_OP); arg->value.name = path; return; } if (method_call) { /* * Lookup the name in the internal namespace */ scope_info.scope.node = NULL; node = parser_state->start_node; if (node) { scope_info.scope.node = node; } /* * Lookup object. We don't want to add anything new to the namespace * here, however. So we use MODE_EXECUTE. Allow searching of the * parent tree, but don't open a new scope -- we just want to lookup the * object (MUST BE mode EXECUTE to perform upsearch) */ status = acpi_ns_lookup (&scope_info, path, ACPI_TYPE_ANY, IMODE_EXECUTE, NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, NULL, &node); if (ACPI_SUCCESS (status)) { if (node->type == ACPI_TYPE_METHOD) { method_node = node; name_op = acpi_ps_alloc_op (AML_NAMEPATH_OP); if (name_op) { /* Change arg into a METHOD CALL and attach name to it */ acpi_ps_init_op (arg, AML_METHODCALL_OP); name_op->value.name = path; /* Point METHODCALL/NAME to the METHOD Node */ name_op->node = method_node; acpi_ps_append_arg (arg, name_op); if (!(ACPI_OPERAND_OBJECT *) method_node->object) { return; } *arg_count = ((ACPI_OPERAND_OBJECT *) method_node->object)->method.param_count; } return; } /* * Else this is normal named object reference. * Just init the NAMEPATH object with the pathname. * (See code below) */ } } /* * Either we didn't find the object in the namespace, or the object is * something other than a control method. Just initialize the Op with the * pathname. */ acpi_ps_init_op (arg, AML_NAMEPATH_OP); arg->value.name = path; return; }
void acpi_ps_get_next_namepath ( ACPI_PARSE_STATE *parser_state, ACPI_PARSE_OBJECT *arg, u32 *arg_count, u8 method_call) { NATIVE_CHAR *path; ACPI_PARSE_OBJECT *name_op; ACPI_PARSE_OBJECT *op; ACPI_PARSE_OBJECT *count; path = acpi_ps_get_next_namestring (parser_state); if (!path || !method_call) { /* Null name case, create a null namepath object */ acpi_ps_init_op (arg, AML_NAMEPATH_OP); arg->value.name = path; return; } if (acpi_gbl_parsed_namespace_root) { /* * Lookup the name in the parsed namespace */ op = NULL; if (method_call) { op = acpi_ps_find (acpi_ps_get_parent_scope (parser_state), path, AML_METHOD_OP, 0); } if (op) { if (op->opcode == AML_METHOD_OP) { /* * The name refers to a control method, so this namepath is a * method invocation. We need to 1) Get the number of arguments * associated with this method, and 2) Change the NAMEPATH * object into a METHODCALL object. */ count = acpi_ps_get_arg (op, 0); if (count && count->opcode == AML_BYTE_OP) { name_op = acpi_ps_alloc_op (AML_NAMEPATH_OP); if (name_op) { /* Change arg into a METHOD CALL and attach the name */ acpi_ps_init_op (arg, AML_METHODCALL_OP); name_op->value.name = path; /* Point METHODCALL/NAME to the METHOD Node */ name_op->node = (ACPI_NAMESPACE_NODE *) op; acpi_ps_append_arg (arg, name_op); *arg_count = count->value.integer & METHOD_FLAGS_ARG_COUNT; } } return; } /* * Else this is normal named object reference. * Just init the NAMEPATH object with the pathname. * (See code below) */ } } /* * Either we didn't find the object in the namespace, or the object is * something other than a control method. Just initialize the Op with the * pathname */ acpi_ps_init_op (arg, AML_NAMEPATH_OP); arg->value.name = path; return; }