void UtAttachNamepathToOwner ( ACPI_PARSE_OBJECT *Op, ACPI_PARSE_OBJECT *NameOp) { ACPI_STATUS Status; /* Full external path */ Op->Asl.ExternalName = NameOp->Asl.Value.String; /* Save the NameOp for possible error reporting later */ Op->Asl.ParentMethod = (void *) NameOp; /* Last nameseg of the path */ UtAttachNameseg (Op, Op->Asl.ExternalName); /* Create internalized path */ Status = UtInternalizeName (NameOp->Asl.Value.String, &Op->Asl.Namepath); if (ACPI_FAILURE (Status)) { /* TBD: abort on no memory */ } }
void CgGenerateAmlLengths ( ACPI_PARSE_OBJECT *Op) { char *Buffer; ACPI_STATUS Status; switch (Op->Asl.AmlOpcode) { case AML_RAW_DATA_BYTE: Op->Asl.AmlOpcodeLength = 0; Op->Asl.AmlLength = 1; return; case AML_RAW_DATA_WORD: Op->Asl.AmlOpcodeLength = 0; Op->Asl.AmlLength = 2; return; case AML_RAW_DATA_DWORD: Op->Asl.AmlOpcodeLength = 0; Op->Asl.AmlLength = 4; return; case AML_RAW_DATA_QWORD: Op->Asl.AmlOpcodeLength = 0; Op->Asl.AmlLength = 8; return; case AML_RAW_DATA_BUFFER: /* Aml length is/was set by creator */ Op->Asl.AmlOpcodeLength = 0; return; case AML_RAW_DATA_CHAIN: /* Aml length is/was set by creator */ Op->Asl.AmlOpcodeLength = 0; return; default: break; } switch (Op->Asl.ParseOpcode) { case PARSEOP_DEFINITIONBLOCK: Gbl_TableLength = sizeof (ACPI_TABLE_HEADER) + Op->Asl.AmlSubtreeLength; break; case PARSEOP_NAMESEG: Op->Asl.AmlOpcodeLength = 0; Op->Asl.AmlLength = 4; Op->Asl.ExternalName = Op->Asl.Value.String; break; case PARSEOP_NAMESTRING: case PARSEOP_METHODCALL: if (Op->Asl.CompileFlags & NODE_NAME_INTERNALIZED) { break; } Op->Asl.AmlOpcodeLength = 0; Status = UtInternalizeName (Op->Asl.Value.String, &Buffer); if (ACPI_FAILURE (Status)) { DbgPrint (ASL_DEBUG_OUTPUT, "Failure from internalize name %X\n", Status); break; } Op->Asl.ExternalName = Op->Asl.Value.String; Op->Asl.Value.String = Buffer; Op->Asl.CompileFlags |= NODE_NAME_INTERNALIZED; Op->Asl.AmlLength = strlen (Buffer); /* * Check for single backslash reference to root, * make it a null terminated string in the AML */ if (Op->Asl.AmlLength == 1) { Op->Asl.AmlLength = 2; } break; case PARSEOP_STRING_LITERAL: Op->Asl.AmlOpcodeLength = 1; /* Get null terminator */ Op->Asl.AmlLength = strlen (Op->Asl.Value.String) + 1; break; case PARSEOP_PACKAGE_LENGTH: Op->Asl.AmlOpcodeLength = 0; Op->Asl.AmlPkgLenBytes = CgGetPackageLenByteCount (Op, (UINT32) Op->Asl.Value.Integer); break; case PARSEOP_RAW_DATA: Op->Asl.AmlOpcodeLength = 0; break; case PARSEOP_DEFAULT_ARG: case PARSEOP_EXTERNAL: case PARSEOP_INCLUDE: case PARSEOP_INCLUDE_END: /* Ignore the "default arg" nodes, they are extraneous at this point */ break; default: CgGenerateAmlOpcodeLength (Op); break; } }
static ACPI_STATUS LdNamespace2Begin ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context) { ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; ACPI_OBJECT_TYPE ObjectType; BOOLEAN ForceNewScope = FALSE; ACPI_PARSE_OBJECT *Arg; char *Path; ACPI_NAMESPACE_NODE *TargetNode; ACPI_FUNCTION_NAME (LdNamespace2Begin); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n", Op, Op->Asl.ParseOpName)); /* Ignore Ops with no namespace node */ Node = Op->Asl.Node; if (!Node) { return (AE_OK); } /* Get the type to determine if we should push the scope */ if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) && (Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC)) { ObjectType = ACPI_TYPE_LOCAL_RESOURCE; } else { ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); } /* Push scope for Resource Templates */ if (Op->Asl.ParseOpcode == PARSEOP_NAME) { if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC) { ForceNewScope = TRUE; } } /* Push the scope stack */ if (ForceNewScope || AcpiNsOpensScope (ObjectType)) { Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } if (Op->Asl.ParseOpcode == PARSEOP_ALIAS) { /* Complete the alias node by getting and saving the target node */ /* First child is the alias target */ Arg = Op->Asl.Child; /* Get the target pathname */ Path = Arg->Asl.Namepath; if (!Path) { Status = UtInternalizeName (Arg->Asl.ExternalName, &Path); if (ACPI_FAILURE (Status)) { return (Status); } } /* Get the NS node associated with the target. It must exist. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, WalkState, &TargetNode); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) { AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, Op->Asl.ExternalName); /* * The name was not found, go ahead and create it. * This prevents more errors later. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH, WalkState, &(Node)); return (AE_OK); } AslCoreSubsystemError (Op, Status, "Failure from namespace lookup", FALSE); return (AE_OK); } /* Save the target node within the alias node */ Node->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); } return (AE_OK); }
static void ExMoveExternals ( ACPI_PARSE_OBJECT *DefinitionBlockOp) { ACPI_PARSE_OBJECT *ParentOp; ACPI_PARSE_OBJECT *ExternalOp; ACPI_PARSE_OBJECT *PredicateOp; ACPI_PARSE_OBJECT *NextOp; ACPI_PARSE_OBJECT *Prev; ACPI_PARSE_OBJECT *Next; char *ExternalName; ACPI_OBJECT_TYPE ObjType; ACPI_STATUS Status; UINT32 i; if (!AslGbl_ExternalsListHead) { return; } /* Remove the External nodes from the tree */ NextOp = AslGbl_ExternalsListHead; while (NextOp) { /* * The External is stored in child pointer of each node in the * list */ ExternalOp = NextOp->Asl.Child; /* Get/set the fully qualified name */ ExternalName = AcpiNsGetNormalizedPathname (ExternalOp->Asl.Node, TRUE); ExternalOp->Asl.ExternalName = ExternalName; ExternalOp->Asl.Namepath = ExternalName; /* Set line numbers (for listings, etc.) */ ExternalOp->Asl.LineNumber = 0; ExternalOp->Asl.LogicalLineNumber = 0; Next = ExternalOp->Asl.Child; Next->Asl.LineNumber = 0; Next->Asl.LogicalLineNumber = 0; if (Next->Asl.ParseOpcode == PARSEOP_NAMESEG) { Next->Asl.ParseOpcode = PARSEOP_NAMESTRING; } Next->Asl.ExternalName = ExternalName; Status = UtInternalizeName (ExternalName, &Next->Asl.Value.String); if (ACPI_FAILURE (Status)) { AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Next, "Could not internalize namestring"); return; } Next->Asl.AmlLength = strlen (Next->Asl.Value.String); Next = Next->Asl.Next; Next->Asl.LineNumber = 0; Next->Asl.LogicalLineNumber = 0; Next = Next->Asl.Next; Next->Asl.LineNumber = 0; Next->Asl.LogicalLineNumber = 0; Next = Next->Asl.Next; Next->Asl.LineNumber = 0; Next->Asl.LogicalLineNumber = 0; ParentOp = ExternalOp->Asl.Parent; Prev = Next = ParentOp->Asl.Child; /* Now find the External node's position in parse tree */ while (Next != ExternalOp) { Prev = Next; Next = Next->Asl.Next; } /* Remove the External from the parse tree */ if (Prev == ExternalOp) { /* External was the first child node */ ParentOp->Asl.Child = ExternalOp->Asl.Next; } Prev->Asl.Next = ExternalOp->Asl.Next; ExternalOp->Asl.Next = NULL; ExternalOp->Asl.Parent = AslGbl_ExternalsListHead; /* Point the External to the next in the list */ if (NextOp->Asl.Next) { ExternalOp->Asl.Next = NextOp->Asl.Next->Asl.Child; } NextOp = NextOp->Asl.Next; } /* * Loop again to remove MethodObj Externals for which * a MethodCall was not found (dead external reference) */ Prev = AslGbl_ExternalsListHead->Asl.Child; Next = Prev; while (Next) { ObjType = (ACPI_OBJECT_TYPE) Next->Asl.Child->Asl.Next->Asl.Value.Integer; if (ObjType == ACPI_TYPE_METHOD && !(Next->Asl.CompileFlags & OP_VISITED)) { if (Next == Prev) { AslGbl_ExternalsListHead->Asl.Child = Next->Asl.Next; Next->Asl.Next = NULL; Prev = AslGbl_ExternalsListHead->Asl.Child; Next = Prev; continue; } else { Prev->Asl.Next = Next->Asl.Next; Next->Asl.Next = NULL; Next = Prev->Asl.Next; continue; } } Prev = Next; Next = Next->Asl.Next; } /* If list is now empty, don't bother to make If (0) block */ if (!AslGbl_ExternalsListHead->Asl.Child) { return; } /* Convert Gbl_ExternalsListHead parent to If(). */ AslGbl_ExternalsListHead->Asl.ParseOpcode = PARSEOP_IF; AslGbl_ExternalsListHead->Asl.AmlOpcode = AML_IF_OP; AslGbl_ExternalsListHead->Asl.CompileFlags = OP_AML_PACKAGE; UtSetParseOpName (AslGbl_ExternalsListHead); /* Create a Zero op for the If predicate */ PredicateOp = TrAllocateOp (PARSEOP_ZERO); PredicateOp->Asl.AmlOpcode = AML_ZERO_OP; PredicateOp->Asl.Parent = AslGbl_ExternalsListHead; PredicateOp->Asl.Child = NULL; PredicateOp->Asl.Next = AslGbl_ExternalsListHead->Asl.Child; AslGbl_ExternalsListHead->Asl.Child = PredicateOp; /* Set line numbers (for listings, etc.) */ AslGbl_ExternalsListHead->Asl.LineNumber = 0; AslGbl_ExternalsListHead->Asl.LogicalLineNumber = 0; PredicateOp->Asl.LineNumber = 0; PredicateOp->Asl.LogicalLineNumber = 0; /* Insert block back in the list */ Prev = DefinitionBlockOp->Asl.Child; Next = Prev; /* Find last default arg */ for (i = 0; i < 6; i++) { Prev = Next; Next = Prev->Asl.Next; } if (Next) { /* Definition Block is not empty */ AslGbl_ExternalsListHead->Asl.Next = Next; } else { /* Definition Block is empty. */ AslGbl_ExternalsListHead->Asl.Next = NULL; } Prev->Asl.Next = AslGbl_ExternalsListHead; AslGbl_ExternalsListHead->Asl.Parent = Prev->Asl.Parent; }
static void ExInsertArgCount ( ACPI_PARSE_OBJECT *Op) { ACPI_PARSE_OBJECT *Next; ACPI_PARSE_OBJECT *NameOp; ACPI_PARSE_OBJECT *Child; ACPI_PARSE_OBJECT *ArgCountOp; char * ExternalName; char * CallName; UINT16 ArgCount = 0; ACPI_STATUS Status; CallName = AcpiNsGetNormalizedPathname (Op->Asl.Node, TRUE); Next = AslGbl_ExternalsListHead; while (Next) { ArgCount = 0; /* Skip if External node already handled */ if (Next->Asl.Child->Asl.CompileFlags & OP_VISITED) { Next = Next->Asl.Next; continue; } NameOp = Next->Asl.Child->Asl.Child; ExternalName = AcpiNsGetNormalizedPathname (NameOp->Asl.Node, TRUE); if (strcmp (CallName, ExternalName)) { ACPI_FREE (ExternalName); Next = Next->Asl.Next; continue; } Next->Asl.Child->Asl.CompileFlags |= OP_VISITED; /* * Since we will reposition Externals to the Root, set Namepath * to the fully qualified name and recalculate the aml length */ Status = UtInternalizeName (ExternalName, &NameOp->Asl.Value.String); ACPI_FREE (ExternalName); if (ACPI_FAILURE (Status)) { AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, NULL, "- Could not Internalize External"); break; } NameOp->Asl.AmlLength = strlen (NameOp->Asl.Value.String); /* Get argument count */ Child = Op->Asl.Child; while (Child) { ArgCount++; Child = Child->Asl.Next; } /* Setup ArgCount operand */ ArgCountOp = Next->Asl.Child->Asl.Child->Asl.Next->Asl.Next; ArgCountOp->Asl.Value.Integer = ArgCount; break; } ACPI_FREE (CallName); }