BOOLEAN AnLastStatementIsReturn ( ACPI_PARSE_OBJECT *Op) { ACPI_PARSE_OBJECT *Next; /* Check if last statement is a return */ Next = ASL_GET_CHILD_NODE (Op); while (Next) { if ((!Next->Asl.Next) && (Next->Asl.ParseOpcode == PARSEOP_RETURN)) { return (TRUE); } Next = ASL_GET_PEER_NODE (Next); } return (FALSE); }
static ACPI_STATUS LdLoadResourceElements ( ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState) { ACPI_PARSE_OBJECT *InitializerOp = NULL; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; /* * Enter the resource name into the namespace. Name must not already exist. * This opens a scope, so later field names are guaranteed to be new/unique. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Asl.Namepath, ACPI_TYPE_LOCAL_RESOURCE, ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH | ACPI_NS_ERROR_IF_FOUND, WalkState, &Node); if (ACPI_FAILURE (Status)) { if (Status == AE_ALREADY_EXISTS) { /* Actual node causing the error was saved in ParentMethod */ AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, (ACPI_PARSE_OBJECT *) Op->Asl.ParentMethod, Op->Asl.Namepath); return (AE_OK); } return (Status); } Node->Value = (UINT32) Op->Asl.Value.Integer; Node->Op = Op; Op->Asl.Node = Node; /* * Now enter the predefined fields, for easy lookup when referenced * by the source ASL */ InitializerOp = ASL_GET_CHILD_NODE (Op); while (InitializerOp) { if (InitializerOp->Asl.ExternalName) { Status = AcpiNsLookup (WalkState->ScopeInfo, InitializerOp->Asl.ExternalName, ACPI_TYPE_LOCAL_RESOURCE_FIELD, ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); if (ACPI_FAILURE (Status)) { return (Status); } /* * Store the field offset and length in the namespace node * so it can be used when the field is referenced */ Node->Value = InitializerOp->Asl.Value.Tag.BitOffset; Node->Length = InitializerOp->Asl.Value.Tag.BitLength; InitializerOp->Asl.Node = Node; Node->Op = InitializerOp; } InitializerOp = ASL_GET_PEER_NODE (InitializerOp); } return (AE_OK); }
void RsDoResourceTemplate ( ACPI_PARSE_OBJECT *Op) { ACPI_PARSE_OBJECT *BufferLengthOp; ACPI_PARSE_OBJECT *BufferOp; ACPI_PARSE_OBJECT *DescriptorTypeOp; ACPI_PARSE_OBJECT *LastOp = NULL; UINT32 CurrentByteOffset = 0; ASL_RESOURCE_NODE HeadRnode; ASL_RESOURCE_NODE *PreviousRnode; ASL_RESOURCE_NODE *Rnode; UINT8 State; /* Mark parent as containing a resource template */ if (Op->Asl.Parent) { Op->Asl.Parent->Asl.CompileFlags |= NODE_IS_RESOURCE_DESC; } /* ResourceTemplate Opcode is first (Op) */ /* Buffer Length node is first child */ BufferLengthOp = ASL_GET_CHILD_NODE (Op); /* Buffer Op is first peer */ BufferOp = ASL_GET_PEER_NODE (BufferLengthOp); /* First Descriptor type is next */ DescriptorTypeOp = ASL_GET_PEER_NODE (BufferOp); /* * Process all resource descriptors in the list * Note: It is assumed that the EndTag node has been automatically * inserted at the end of the template by the parser. */ State = ACPI_RSTATE_NORMAL; PreviousRnode = &HeadRnode; while (DescriptorTypeOp) { DescriptorTypeOp->Asl.CompileFlags |= NODE_IS_RESOURCE_DESC; Rnode = RsDoOneResourceDescriptor (DescriptorTypeOp, CurrentByteOffset, &State); /* * Update current byte offset to indicate the number of bytes from the * start of the buffer. Buffer can include multiple descriptors, we * must keep track of the offset of not only each descriptor, but each * element (field) within each descriptor as well. */ CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, Rnode); /* Get the next descriptor in the list */ LastOp = DescriptorTypeOp; DescriptorTypeOp = ASL_GET_PEER_NODE (DescriptorTypeOp); } if (State == ACPI_RSTATE_DEPENDENT_LIST) { if (LastOp) { LastOp = LastOp->Asl.Parent; } AslError (ASL_ERROR, ASL_MSG_MISSING_ENDDEPENDENT, LastOp, NULL); } /* * Transform the nodes into the following * * Op -> AML_BUFFER_OP * First Child -> BufferLength * Second Child -> Descriptor Buffer (raw byte data) */ Op->Asl.ParseOpcode = PARSEOP_BUFFER; Op->Asl.AmlOpcode = AML_BUFFER_OP; Op->Asl.CompileFlags = NODE_AML_PACKAGE | NODE_IS_RESOURCE_DESC; BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; BufferLengthOp->Asl.Value.Integer = CurrentByteOffset; (void) OpcSetOptimalIntegerSize (BufferLengthOp); BufferOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; BufferOp->Asl.AmlOpcode = AML_RAW_DATA_CHAIN; BufferOp->Asl.AmlOpcodeLength = 0; BufferOp->Asl.AmlLength = CurrentByteOffset; BufferOp->Asl.Value.Buffer = (UINT8 *) HeadRnode.Next; BufferOp->Asl.CompileFlags |= NODE_IS_RESOURCE_DATA; return; }
void RsDoResourceTemplate ( ACPI_PARSE_OBJECT *Op) { ACPI_PARSE_OBJECT *BufferLengthOp; ACPI_PARSE_OBJECT *BufferOp; ACPI_PARSE_OBJECT *DescriptorTypeOp; ACPI_PARSE_OBJECT *LastOp = NULL; ASL_RESOURCE_DESC *Descriptor; UINT32 CurrentByteOffset = 0; ASL_RESOURCE_NODE HeadRnode; ASL_RESOURCE_NODE *PreviousRnode; ASL_RESOURCE_NODE *Rnode; UINT8 State; /* ResourceTemplate Opcode is first (Op) */ /* Buffer Length node is first child */ BufferLengthOp = ASL_GET_CHILD_NODE (Op); /* Buffer Op is first peer */ BufferOp = ASL_GET_PEER_NODE (BufferLengthOp); /* First Descriptor type is next */ DescriptorTypeOp = ASL_GET_PEER_NODE (BufferOp); /* Process all resource descriptors in the list */ State = ACPI_RSTATE_NORMAL; PreviousRnode = &HeadRnode; while (DescriptorTypeOp) { Rnode = RsDoOneResourceDescriptor (DescriptorTypeOp, CurrentByteOffset, &State); /* * Update current byte offset to indicate the number of bytes from the * start of the buffer. Buffer can include multiple descriptors, we * must keep track of the offset of not only each descriptor, but each * element (field) within each descriptor as well. */ CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, Rnode); /* Get the next descriptor in the list */ LastOp = DescriptorTypeOp; DescriptorTypeOp = ASL_GET_PEER_NODE (DescriptorTypeOp); } if (State == ACPI_RSTATE_DEPENDENT_LIST) { if (LastOp) { LastOp = LastOp->Asl.Parent; } AslError (ASL_ERROR, ASL_MSG_MISSING_ENDDEPENDENT, LastOp, NULL); } /* * Insert the EndTag descriptor after all other descriptors have been processed */ Rnode = RsAllocateResourceNode (sizeof (ASL_END_TAG_DESC)); Descriptor = Rnode->Buffer; Descriptor->Et.DescriptorType = ACPI_RDESC_TYPE_END_TAG | ASL_RDESC_END_TAG_SIZE; Descriptor->Et.Checksum = 0; CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, Rnode); /* * Transform the nodes into the following * * Op -> AML_BUFFER_OP * First Child -> BufferLength * Second Child -> Descriptor Buffer (raw byte data) */ Op->Asl.ParseOpcode = PARSEOP_BUFFER; Op->Asl.AmlOpcode = AML_BUFFER_OP; Op->Asl.CompileFlags = NODE_AML_PACKAGE; BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; BufferLengthOp->Asl.Value.Integer = CurrentByteOffset; (void) OpcSetOptimalIntegerSize (BufferLengthOp); BufferOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; BufferOp->Asl.AmlOpcode = AML_RAW_DATA_CHAIN; BufferOp->Asl.AmlOpcodeLength = 0; BufferOp->Asl.AmlLength = CurrentByteOffset; BufferOp->Asl.Value.Buffer = (UINT8 *) HeadRnode.Next; return; }