diff options
author | iwasaki <iwasaki@FreeBSD.org> | 2002-08-29 01:51:24 +0000 |
---|---|---|
committer | iwasaki <iwasaki@FreeBSD.org> | 2002-08-29 01:51:24 +0000 |
commit | 1824f192010fc0c0826e9889892e534075b58793 (patch) | |
tree | bbc04a2733724f3f0ab5cecb259948ac9a9723d7 /sys/contrib/dev/acpica/psargs.c | |
parent | 3f86517f16a9cf970e93e483e90066da6eb323dd (diff) | |
download | FreeBSD-src-1824f192010fc0c0826e9889892e534075b58793.zip FreeBSD-src-1824f192010fc0c0826e9889892e534075b58793.tar.gz |
Vendor import of the Intel ACPI CA 20020815 drop.
Diffstat (limited to 'sys/contrib/dev/acpica/psargs.c')
-rw-r--r-- | sys/contrib/dev/acpica/psargs.c | 297 |
1 files changed, 99 insertions, 198 deletions
diff --git a/sys/contrib/dev/acpica/psargs.c b/sys/contrib/dev/acpica/psargs.c index 4034788..e1e5346 100644 --- a/sys/contrib/dev/acpica/psargs.c +++ b/sys/contrib/dev/acpica/psargs.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psargs - Parse AML opcode arguments - * $Revision: 62 $ + * $Revision: 64 $ * *****************************************************************************/ @@ -256,7 +256,7 @@ AcpiPsGetNextNamestring ( while (AcpiPsIsPrefixChar (ACPI_GET8 (End))) { - /* include prefix '\\' or '^' */ + /* Include prefix '\\' or '^' */ End++; } @@ -314,20 +314,17 @@ AcpiPsGetNextNamestring ( * MethodCall - Whether the namepath can be the start * of a method call * - * RETURN: None + * RETURN: Status * - * DESCRIPTION: Get next name (if method call, push appropriate # args). Names - * are looked up in either the parsed or internal namespace to - * determine if the name represents a control method. If a method + * DESCRIPTION: Get next name (if method call, return # of required args). + * Names are looked up in the internal namespace to determine + * if the name represents a control method. If a method * is found, the number of arguments to the method is returned. * This information is critical for parsing to continue correctly. * ******************************************************************************/ - -#ifdef PARSER_ONLY - -void +ACPI_STATUS AcpiPsGetNextNamepath ( ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT *Arg, @@ -336,69 +333,77 @@ AcpiPsGetNextNamepath ( { NATIVE_CHAR *Path; ACPI_PARSE_OBJECT *NameOp; - ACPI_PARSE_OBJECT *Op; - ACPI_PARSE_OBJECT *Count; + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *MethodDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_GENERIC_STATE ScopeInfo; ACPI_FUNCTION_TRACE ("PsGetNextNamepath"); Path = AcpiPsGetNextNamestring (ParserState); - if (!Path || !MethodCall) - { - /* Null name case, create a null namepath object */ - - AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); - Arg->Common.Value.Name = Path; - return_VOID; - } + /* Null path case is allowed */ - if (AcpiGbl_ParsedNamespaceRoot) + if (Path) { /* - * Lookup the name in the parsed namespace + * Lookup the name in the internal namespace */ - Op = NULL; - if (MethodCall) + ScopeInfo.Scope.Node = NULL; + Node = ParserState->StartNode; + if (Node) { - Op = AcpiPsFind (AcpiPsGetParentScope (ParserState), - Path, AML_METHOD_OP, 0); + ScopeInfo.Scope.Node = Node; } - if (Op) + /* + * 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 = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, + &Node); + if (ACPI_SUCCESS (Status) && MethodCall) { - if (Op->Common.AmlOpcode == AML_METHOD_OP) + if (Node->Type == ACPI_TYPE_METHOD) { - /* - * 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 = AcpiPsGetArg (Op, 0); - if (Count && Count->Common.AmlOpcode == AML_BYTE_OP) + MethodDesc = AcpiNsGetAttachedObject (Node); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Control Method - %p Desc %p Path=%p\n", + Node, MethodDesc, Path)); + + NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); + if (!NameOp) { - NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); - if (NameOp) - { - /* Change arg into a METHOD CALL and attach the name */ + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Change arg into a METHOD CALL and attach name to it */ - AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP); + AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP); - NameOp->Common.Value.Name = Path; + NameOp->Common.Value.Name = Path; - /* Point METHODCALL/NAME to the METHOD Node */ + /* Point METHODCALL/NAME to the METHOD Node */ - NameOp->Common.Node = (ACPI_NAMESPACE_NODE *) Op; - AcpiPsAppendArg (Arg, NameOp); + NameOp->Common.Node = Node; + AcpiPsAppendArg (Arg, NameOp); - *ArgCount = (UINT32) Count->Common.Value.Integer & - METHOD_FLAGS_ARG_COUNT; - } + if (!MethodDesc) + { + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Control Method - %p has no attached object\n", + Node)); + return_ACPI_STATUS (AE_AML_INTERNAL); } - return_VOID; + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Control Method - %p Args %X\n", + Node, MethodDesc->Method.ParamCount)); + + *ArgCount = MethodDesc->Method.ParamCount; + return_ACPI_STATUS (AE_OK); } /* @@ -410,127 +415,15 @@ AcpiPsGetNextNamepath ( } /* - * 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 - */ - AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); - Arg->Common.Value.Name = Path; - - - return_VOID; -} - - -#else - - -void -AcpiPsGetNextNamepath ( - ACPI_PARSE_STATE *ParserState, - ACPI_PARSE_OBJECT *Arg, - UINT32 *ArgCount, - BOOLEAN MethodCall) -{ - NATIVE_CHAR *Path; - ACPI_PARSE_OBJECT *NameOp; - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *MethodDesc; - ACPI_NAMESPACE_NODE *Node; - ACPI_GENERIC_STATE ScopeInfo; - - - ACPI_FUNCTION_TRACE ("PsGetNextNamepath"); - - - Path = AcpiPsGetNextNamestring (ParserState); - if (!Path || !MethodCall) - { - /* Null name case, create a null namepath object */ - - AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); - Arg->Common.Value.Name = Path; - return_VOID; - } - - /* - * Lookup the name in the internal namespace - */ - ScopeInfo.Scope.Node = NULL; - Node = ParserState->StartNode; - if (Node) - { - ScopeInfo.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 = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, - &Node); - if (ACPI_SUCCESS (Status)) - { - if (Node->Type == ACPI_TYPE_METHOD) - { - MethodDesc = AcpiNsGetAttachedObject (Node); - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Control Method - %p Desc %p Path=%p\n", - Node, MethodDesc, Path)); - - NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); - if (!NameOp) - { - return_VOID; - } - - /* Change arg into a METHOD CALL and attach name to it */ - - AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP); - - NameOp->Common.Value.Name = Path; - - /* Point METHODCALL/NAME to the METHOD Node */ - - NameOp->Common.Node = Node; - AcpiPsAppendArg (Arg, NameOp); - - if (!MethodDesc) - { - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Control Method - %p has no attached object\n", - Node)); - return_VOID; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Control Method - %p Args %X\n", - Node, MethodDesc->Method.ParamCount)); - - *ArgCount = MethodDesc->Method.ParamCount; - return_VOID; - } - - /* - * 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. + * Regardless of success/failure above, + * Just initialize the Op with the pathname. */ AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); Arg->Common.Value.Name = Path; - - return_VOID; + return_ACPI_STATUS (Status); } -#endif /******************************************************************************* * @@ -744,23 +637,25 @@ AcpiPsGetNextField ( * ArgCount - If the argument points to a control method * the method's argument is returned here. * - * RETURN: An op object containing the next argument. + * RETURN: Status, and an op object containing the next argument. * * DESCRIPTION: Get next argument (including complex list arguments that require * pushing the parser stack) * ******************************************************************************/ -ACPI_PARSE_OBJECT * +ACPI_STATUS AcpiPsGetNextArg ( ACPI_PARSE_STATE *ParserState, UINT32 ArgType, - UINT32 *ArgCount) + UINT32 *ArgCount, + ACPI_PARSE_OBJECT **ReturnArg) { ACPI_PARSE_OBJECT *Arg = NULL; ACPI_PARSE_OBJECT *Prev = NULL; ACPI_PARSE_OBJECT *Field; UINT32 Subop; + ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE_PTR ("PsGetNextArg", ParserState); @@ -778,16 +673,17 @@ AcpiPsGetNextArg ( /* constants, strings, and namestrings are all the same size */ Arg = AcpiPsAllocOp (AML_BYTE_OP); - if (Arg) + if (!Arg) { - AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg); + return_ACPI_STATUS (AE_NO_MEMORY); } + AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg); break; case ARGP_PKGLENGTH: - /* package length, nothing returned */ + /* Package length, nothing returned */ ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState); break; @@ -797,21 +693,20 @@ AcpiPsGetNextArg ( if (ParserState->Aml < ParserState->PkgEnd) { - /* non-empty list */ + /* Non-empty list */ while (ParserState->Aml < ParserState->PkgEnd) { Field = AcpiPsGetNextField (ParserState); if (!Field) { - break; + return_ACPI_STATUS (AE_NO_MEMORY); } if (Prev) { Prev->Common.Next = Field; } - else { Arg = Field; @@ -820,7 +715,7 @@ AcpiPsGetNextArg ( Prev = Field; } - /* skip to End of byte data */ + /* Skip to End of byte data */ ParserState->Aml = ParserState->PkgEnd; } @@ -831,18 +726,20 @@ AcpiPsGetNextArg ( if (ParserState->Aml < ParserState->PkgEnd) { - /* non-empty list */ + /* Non-empty list */ Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP); - if (Arg) + if (!Arg) { - /* fill in bytelist data */ - - Arg->Common.Value.Size = ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml); - Arg->Named.Data = ParserState->Aml; + return_ACPI_STATUS (AE_NO_MEMORY); } - /* skip to End of byte data */ + /* Fill in bytelist data */ + + Arg->Common.Value.Size = ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml); + Arg->Named.Data = ParserState->Aml; + + /* Skip to End of byte data */ ParserState->Aml = ParserState->PkgEnd; } @@ -852,27 +749,27 @@ AcpiPsGetNextArg ( case ARGP_TARGET: case ARGP_SUPERNAME: case ARGP_SIMPLENAME: + + Subop = AcpiPsPeekOpcode (ParserState); + if (Subop == 0 || + AcpiPsIsLeadingChar (Subop) || + AcpiPsIsPrefixChar (Subop)) { - Subop = AcpiPsPeekOpcode (ParserState); - if (Subop == 0 || - AcpiPsIsLeadingChar (Subop) || - AcpiPsIsPrefixChar (Subop)) - { - /* NullName or NameString */ + /* NullName or NameString */ - Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); - if (Arg) - { - AcpiPsGetNextNamepath (ParserState, Arg, ArgCount, 0); - } + Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); + if (!Arg) + { + return_ACPI_STATUS (AE_NO_MEMORY); } - else - { - /* single complex argument, nothing returned */ + Status = AcpiPsGetNextNamepath (ParserState, Arg, ArgCount, 0); + } + else + { + /* single complex argument, nothing returned */ - *ArgCount = 1; - } + *ArgCount = 1; } break; @@ -898,10 +795,14 @@ AcpiPsGetNextArg ( } break; + default: + ACPI_REPORT_ERROR (("Invalid ArgType: %X\n", ArgType)); + Status = AE_AML_OPERAND_TYPE; break; } - return_PTR (Arg); + *ReturnArg = Arg; + return_ACPI_STATUS (Status); } |