📄 psargs.c
字号:
* 3) NotFound while building a Package is ok at this point, we * may flag as an error later if slack mode is not enabled. * (Some ASL code depends on allowing this behavior) */ else if ((Arg->Common.Parent) && ((Arg->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || (Arg->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))) { Status = AE_OK; } } /* Final exception check (may have been changed from code above) */ if (ACPI_FAILURE (Status)) { ACPI_ERROR_NAMESPACE (Path, Status); if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) { /* Report a control method execution error */ Status = AcpiDsMethodError (Status, WalkState); } } /* Save the namepath */ Arg->Common.Value.Name = Path; return_ACPI_STATUS (Status);}/******************************************************************************* * * FUNCTION: AcpiPsGetNextSimpleArg * * PARAMETERS: ParserState - Current parser state object * ArgType - The argument type (AML_*_ARG) * Arg - Where the argument is returned * * RETURN: None * * DESCRIPTION: Get the next simple argument (constant, string, or namestring) * ******************************************************************************/voidAcpiPsGetNextSimpleArg ( ACPI_PARSE_STATE *ParserState, UINT32 ArgType, ACPI_PARSE_OBJECT *Arg){ UINT32 Length; UINT16 Opcode; UINT8 *Aml = ParserState->Aml; ACPI_FUNCTION_TRACE_U32 (PsGetNextSimpleArg, ArgType); switch (ArgType) { case ARGP_BYTEDATA: /* Get 1 byte from the AML stream */ Opcode = AML_BYTE_OP; Arg->Common.Value.Integer = (ACPI_INTEGER) *Aml; Length = 1; break; case ARGP_WORDDATA: /* Get 2 bytes from the AML stream */ Opcode = AML_WORD_OP; ACPI_MOVE_16_TO_64 (&Arg->Common.Value.Integer, Aml); Length = 2; break; case ARGP_DWORDDATA: /* Get 4 bytes from the AML stream */ Opcode = AML_DWORD_OP; ACPI_MOVE_32_TO_64 (&Arg->Common.Value.Integer, Aml); Length = 4; break; case ARGP_QWORDDATA: /* Get 8 bytes from the AML stream */ Opcode = AML_QWORD_OP; ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, Aml); Length = 8; break; case ARGP_CHARLIST: /* Get a pointer to the string, point past the string */ Opcode = AML_STRING_OP; Arg->Common.Value.String = ACPI_CAST_PTR (char, Aml); /* Find the null terminator */ Length = 0; while (Aml[Length]) { Length++; } Length++; break; case ARGP_NAME: case ARGP_NAMESTRING: AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState); return_VOID; default: ACPI_ERROR ((AE_INFO, "Invalid ArgType %X", ArgType)); return_VOID; } AcpiPsInitOp (Arg, Opcode); ParserState->Aml += Length; return_VOID;}/******************************************************************************* * * FUNCTION: AcpiPsGetNextField * * PARAMETERS: ParserState - Current parser state object * * RETURN: A newly allocated FIELD op * * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField) * ******************************************************************************/static ACPI_PARSE_OBJECT *AcpiPsGetNextField ( ACPI_PARSE_STATE *ParserState){ UINT32 AmlOffset = (UINT32) ACPI_PTR_DIFF (ParserState->Aml, ParserState->AmlStart); ACPI_PARSE_OBJECT *Field; UINT16 Opcode; UINT32 Name; ACPI_FUNCTION_TRACE (PsGetNextField); /* Determine field type */ switch (ACPI_GET8 (ParserState->Aml)) { default: Opcode = AML_INT_NAMEDFIELD_OP; break; case 0x00: Opcode = AML_INT_RESERVEDFIELD_OP; ParserState->Aml++; break; case 0x01: Opcode = AML_INT_ACCESSFIELD_OP; ParserState->Aml++; break; } /* Allocate a new field op */ Field = AcpiPsAllocOp (Opcode); if (!Field) { return_PTR (NULL); } Field->Common.AmlOffset = AmlOffset; /* Decode the field type */ switch (Opcode) { case AML_INT_NAMEDFIELD_OP: /* Get the 4-character name */ ACPI_MOVE_32_TO_32 (&Name, ParserState->Aml); AcpiPsSetName (Field, Name); ParserState->Aml += ACPI_NAME_SIZE; /* Get the length which is encoded as a package length */ Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState); break; case AML_INT_RESERVEDFIELD_OP: /* Get the length which is encoded as a package length */ Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState); break; case AML_INT_ACCESSFIELD_OP: /* * Get AccessType and AccessAttrib and merge into the field Op * AccessType is first operand, AccessAttribute is second */ Field->Common.Value.Integer = (((UINT32) ACPI_GET8 (ParserState->Aml) << 8)); ParserState->Aml++; Field->Common.Value.Integer |= ACPI_GET8 (ParserState->Aml); ParserState->Aml++; break; default: /* Opcode was set in previous switch */ break; } return_PTR (Field);}/******************************************************************************* * * FUNCTION: AcpiPsGetNextArg * * PARAMETERS: WalkState - Current state * ParserState - Current parser state object * ArgType - The argument type (AML_*_ARG) * ReturnArg - Where the next arg is returned * * 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_STATUSAcpiPsGetNextArg ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_STATE *ParserState, UINT32 ArgType, 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); switch (ArgType) { case ARGP_BYTEDATA: case ARGP_WORDDATA: case ARGP_DWORDDATA: case ARGP_CHARLIST: case ARGP_NAME: case ARGP_NAMESTRING: /* Constants, strings, and namestrings are all the same size */ Arg = AcpiPsAllocOp (AML_BYTE_OP); if (!Arg) { return_ACPI_STATUS (AE_NO_MEMORY); } AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg); break; case ARGP_PKGLENGTH: /* Package length, nothing returned */ ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState); break; case ARGP_FIELDLIST: if (ParserState->Aml < ParserState->PkgEnd) { /* Non-empty list */ while (ParserState->Aml < ParserState->PkgEnd) { Field = AcpiPsGetNextField (ParserState); if (!Field) { return_ACPI_STATUS (AE_NO_MEMORY); } if (Prev) { Prev->Common.Next = Field; } else { Arg = Field; } Prev = Field; } /* Skip to End of byte data */ ParserState->Aml = ParserState->PkgEnd; } break; case ARGP_BYTELIST: if (ParserState->Aml < ParserState->PkgEnd) { /* Non-empty list */ Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP); if (!Arg) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Fill in bytelist data */ Arg->Common.Value.Size = (UINT32) ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml); Arg->Named.Data = ParserState->Aml; /* Skip to End of byte data */ ParserState->Aml = ParserState->PkgEnd; } break; case ARGP_TARGET: case ARGP_SUPERNAME: case ARGP_SIMPLENAME: Subop = AcpiPsPeekOpcode (ParserState); if (Subop == 0 || AcpiPsIsLeadingChar (Subop) || AcpiPsIsPrefixChar (Subop)) { /* NullName or NameString */ Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); if (!Arg) { return_ACPI_STATUS (AE_NO_MEMORY); } /* To support SuperName arg of Unload */ if (WalkState->Op->Common.AmlOpcode == AML_UNLOAD_OP) { Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 1); /* * If the SuperName arg of Unload is a method call, * we have restored the AML pointer, just free this Arg */ if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP) { AcpiPsFreeOp (Arg); Arg = NULL; } } else { Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0); } } else { /* Single complex argument, nothing returned */ WalkState->ArgCount = 1; } break; case ARGP_DATAOBJ: case ARGP_TERMARG: /* Single complex argument, nothing returned */ WalkState->ArgCount = 1; break; case ARGP_DATAOBJLIST: case ARGP_TERMLIST: case ARGP_OBJLIST: if (ParserState->Aml < ParserState->PkgEnd) { /* Non-empty list of variable arguments, nothing returned */ WalkState->ArgCount = ACPI_VAR_ARGS; } break; default: ACPI_ERROR ((AE_INFO, "Invalid ArgType: %X", ArgType)); Status = AE_AML_OPERAND_TYPE; break; } *ReturnArg = Arg; return_ACPI_STATUS (Status);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -