ACPI_STATUS AnOtherSemanticAnalysisWalkBegin ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context) { ACPI_PARSE_OBJECT *ArgOp; ACPI_PARSE_OBJECT *PrevArgOp = NULL; const ACPI_OPCODE_INFO *OpInfo; ACPI_NAMESPACE_NODE *Node; OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); /* * Determine if an execution class operator actually does something by * checking if it has a target and/or the function return value is used. * (Target is optional, so a standalone statement can actually do nothing.) */ if ((OpInfo->Class == AML_CLASS_EXECUTE) && (OpInfo->Flags & AML_HAS_RETVAL) && (!AnIsResultUsed (Op))) { if (OpInfo->Flags & AML_HAS_TARGET) { /* * Find the target node, it is always the last child. If the target * is not specified in the ASL, a default node of type Zero was * created by the parser. */ ArgOp = Op->Asl.Child; while (ArgOp->Asl.Next) { PrevArgOp = ArgOp; ArgOp = ArgOp->Asl.Next; } /* Divide() is the only weird case, it has two targets */ if (Op->Asl.AmlOpcode == AML_DIVIDE_OP) { if ((ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) && (PrevArgOp) && (PrevArgOp->Asl.ParseOpcode == PARSEOP_ZERO)) { AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); } } else if (ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) { AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); } } else { /* * Has no target and the result is not used. Only a couple opcodes * can have this combination. */ switch (Op->Asl.ParseOpcode) { case PARSEOP_ACQUIRE: case PARSEOP_WAIT: case PARSEOP_LOADTABLE: break; default: AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); break; } } } /* * Semantic checks for individual ASL operators */ switch (Op->Asl.ParseOpcode) { case PARSEOP_STORE: if (Gbl_DoTypechecking) { AnAnalyzeStoreOperator (Op); } break; case PARSEOP_ACQUIRE: case PARSEOP_WAIT: /* * Emit a warning if the timeout parameter for these operators is not * ACPI_WAIT_FOREVER, and the result value from the operator is not * checked, meaning that a timeout could happen, but the code * would not know about it. */ /* First child is the namepath, 2nd child is timeout */ ArgOp = Op->Asl.Child; ArgOp = ArgOp->Asl.Next; /* * Check for the WAIT_FOREVER case - defined by the ACPI spec to be * 0xFFFF or greater */ if (((ArgOp->Asl.ParseOpcode == PARSEOP_WORDCONST) || (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER)) && (ArgOp->Asl.Value.Integer >= (UINT64) ACPI_WAIT_FOREVER)) { break; } /* * The operation could timeout. If the return value is not used * (indicates timeout occurred), issue a warning */ if (!AnIsResultUsed (Op)) { AslError (ASL_WARNING, ASL_MSG_TIMEOUT, ArgOp, Op->Asl.ExternalName); } break; case PARSEOP_CREATEFIELD: /* * Check for a zero Length (NumBits) operand. NumBits is the 3rd operand */ ArgOp = Op->Asl.Child; ArgOp = ArgOp->Asl.Next; ArgOp = ArgOp->Asl.Next; if ((ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) || ((ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) && (ArgOp->Asl.Value.Integer == 0))) { AslError (ASL_ERROR, ASL_MSG_NON_ZERO, ArgOp, NULL); } break; case PARSEOP_CONNECTION: /* * Ensure that the referenced operation region has the correct SPACE_ID. * From the grammar/parser, we know the parent is a FIELD definition. */ ArgOp = Op->Asl.Parent; /* Field definition */ ArgOp = ArgOp->Asl.Child; /* First child is the OpRegion Name */ Node = ArgOp->Asl.Node; /* OpRegion namespace node */ if (!Node) { break; } ArgOp = Node->Op; /* OpRegion definition */ ArgOp = ArgOp->Asl.Child; /* First child is the OpRegion Name */ ArgOp = ArgOp->Asl.Next; /* Next peer is the SPACE_ID (what we want) */ /* * The Connection() operator is only valid for the following operation * region SpaceIds: GeneralPurposeIo and GenericSerialBus. */ if ((ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GPIO) && (ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GSBUS)) { AslError (ASL_ERROR, ASL_MSG_CONNECTION_INVALID, Op, NULL); } break; case PARSEOP_FIELD: /* * Ensure that fields for GeneralPurposeIo and GenericSerialBus * contain at least one Connection() operator */ ArgOp = Op->Asl.Child; /* 1st child is the OpRegion Name */ Node = ArgOp->Asl.Node; /* OpRegion namespace node */ if (!Node) { break; } ArgOp = Node->Op; /* OpRegion definition */ ArgOp = ArgOp->Asl.Child; /* First child is the OpRegion Name */ ArgOp = ArgOp->Asl.Next; /* Next peer is the SPACE_ID (what we want) */ /* We are only interested in GeneralPurposeIo and GenericSerialBus */ if ((ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GPIO) && (ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GSBUS)) { break; } ArgOp = Op->Asl.Child; /* 1st child is the OpRegion Name */ ArgOp = ArgOp->Asl.Next; /* AccessType */ ArgOp = ArgOp->Asl.Next; /* LockRule */ ArgOp = ArgOp->Asl.Next; /* UpdateRule */ ArgOp = ArgOp->Asl.Next; /* Start of FieldUnitList */ /* Walk the FieldUnitList */ while (ArgOp) { if (ArgOp->Asl.ParseOpcode == PARSEOP_CONNECTION) { break; } else if (ArgOp->Asl.ParseOpcode == PARSEOP_NAMESEG) { AslError (ASL_ERROR, ASL_MSG_CONNECTION_MISSING, ArgOp, NULL); break; } ArgOp = ArgOp->Asl.Next; } break; default: break; } return (AE_OK); }
ACPI_STATUS AnOtherSemanticAnalysisWalkBegin ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context) { ACPI_PARSE_OBJECT *ArgNode; ACPI_PARSE_OBJECT *PrevArgNode = NULL; const ACPI_OPCODE_INFO *OpInfo; OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); /* * Determine if an execution class operator actually does something by * checking if it has a target and/or the function return value is used. * (Target is optional, so a standalone statement can actually do nothing.) */ if ((OpInfo->Class == AML_CLASS_EXECUTE) && (OpInfo->Flags & AML_HAS_RETVAL) && (!AnIsResultUsed (Op))) { if (OpInfo->Flags & AML_HAS_TARGET) { /* * Find the target node, it is always the last child. If the traget * is not specified in the ASL, a default node of type Zero was * created by the parser. */ ArgNode = Op->Asl.Child; while (ArgNode->Asl.Next) { PrevArgNode = ArgNode; ArgNode = ArgNode->Asl.Next; } /* Divide() is the only weird case, it has two targets */ if (Op->Asl.AmlOpcode == AML_DIVIDE_OP) { if ((ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) && (PrevArgNode) && (PrevArgNode->Asl.ParseOpcode == PARSEOP_ZERO)) { AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); } } else if (ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) { AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); } } else { /* * Has no target and the result is not used. Only a couple opcodes * can have this combination. */ switch (Op->Asl.ParseOpcode) { case PARSEOP_ACQUIRE: case PARSEOP_WAIT: case PARSEOP_LOADTABLE: break; default: AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); break; } } } /* * Semantic checks for individual ASL operators */ switch (Op->Asl.ParseOpcode) { case PARSEOP_ACQUIRE: case PARSEOP_WAIT: /* * Emit a warning if the timeout parameter for these operators is not * ACPI_WAIT_FOREVER, and the result value from the operator is not * checked, meaning that a timeout could happen, but the code * would not know about it. */ /* First child is the namepath, 2nd child is timeout */ ArgNode = Op->Asl.Child; ArgNode = ArgNode->Asl.Next; /* * Check for the WAIT_FOREVER case - defined by the ACPI spec to be * 0xFFFF or greater */ if (((ArgNode->Asl.ParseOpcode == PARSEOP_WORDCONST) || (ArgNode->Asl.ParseOpcode == PARSEOP_INTEGER)) && (ArgNode->Asl.Value.Integer >= (UINT64) ACPI_WAIT_FOREVER)) { break; } /* * The operation could timeout. If the return value is not used * (indicates timeout occurred), issue a warning */ if (!AnIsResultUsed (Op)) { AslError (ASL_WARNING, ASL_MSG_TIMEOUT, ArgNode, Op->Asl.ExternalName); } break; case PARSEOP_CREATEFIELD: /* * Check for a zero Length (NumBits) operand. NumBits is the 3rd operand */ ArgNode = Op->Asl.Child; ArgNode = ArgNode->Asl.Next; ArgNode = ArgNode->Asl.Next; if ((ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) || ((ArgNode->Asl.ParseOpcode == PARSEOP_INTEGER) && (ArgNode->Asl.Value.Integer == 0))) { AslError (ASL_ERROR, ASL_MSG_NON_ZERO, ArgNode, NULL); } break; default: break; } return (AE_OK); }