static ACPI_STATUS AcpiNsCheckObjectType ( ACPI_PREDEFINED_DATA *Data, ACPI_OPERAND_OBJECT **ReturnObjectPtr, UINT32 ExpectedBtypes, UINT32 PackageIndex) { ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; ACPI_STATUS Status = AE_OK; UINT32 ReturnBtype; char TypeBuffer[48]; /* Room for 5 types */ /* * If we get a NULL ReturnObject here, it is a NULL package element. * Since all extraneous NULL package elements were removed earlier by a * call to AcpiNsRemoveNullElements, this is an unexpected NULL element. * We will attempt to repair it. */ if (!ReturnObject) { Status = AcpiNsRepairNullElement (Data, ExpectedBtypes, PackageIndex, ReturnObjectPtr); if (ACPI_SUCCESS (Status)) { return (AE_OK); /* Repair was successful */ } goto TypeErrorExit; } /* A Namespace node should not get here, but make sure */ if (ACPI_GET_DESCRIPTOR_TYPE (ReturnObject) == ACPI_DESC_TYPE_NAMED) { ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, "Invalid return type - Found a Namespace node [%4.4s] type %s", ReturnObject->Node.Name.Ascii, AcpiUtGetTypeName (ReturnObject->Node.Type))); return (AE_AML_OPERAND_TYPE); } /* * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type. * The bitmapped type allows multiple possible return types. * * Note, the cases below must handle all of the possible types returned * from all of the predefined names (including elements of returned * packages) */ switch (ReturnObject->Common.Type) { case ACPI_TYPE_INTEGER: ReturnBtype = ACPI_RTYPE_INTEGER; break; case ACPI_TYPE_BUFFER: ReturnBtype = ACPI_RTYPE_BUFFER; break; case ACPI_TYPE_STRING: ReturnBtype = ACPI_RTYPE_STRING; break; case ACPI_TYPE_PACKAGE: ReturnBtype = ACPI_RTYPE_PACKAGE; break; case ACPI_TYPE_LOCAL_REFERENCE: ReturnBtype = ACPI_RTYPE_REFERENCE; break; default: /* Not one of the supported objects, must be incorrect */ goto TypeErrorExit; } /* Is the object one of the expected types? */ if (ReturnBtype & ExpectedBtypes) { /* For reference objects, check that the reference type is correct */ if (ReturnObject->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) { Status = AcpiNsCheckReference (Data, ReturnObject); } return (Status); } /* Type mismatch -- attempt repair of the returned object */ Status = AcpiNsRepairObject (Data, ExpectedBtypes, PackageIndex, ReturnObjectPtr); if (ACPI_SUCCESS (Status)) { return (AE_OK); /* Repair was successful */ } TypeErrorExit: /* Create a string with all expected types for this predefined object */ AcpiNsGetExpectedTypes (TypeBuffer, ExpectedBtypes); if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT) { ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, "Return type mismatch - found %s, expected %s", AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); } else { ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, "Return Package type mismatch at index %u - " "found %s, expected %s", PackageIndex, AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); } return (AE_AML_OPERAND_TYPE); }
ACPI_STATUS AcpiNsCheckObjectType ( ACPI_PREDEFINED_DATA *Data, ACPI_OPERAND_OBJECT **ReturnObjectPtr, UINT32 ExpectedBtypes, UINT32 PackageIndex) { ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; ACPI_STATUS Status = AE_OK; char TypeBuffer[48]; /* Room for 5 types */ /* A Namespace node should not get here, but make sure */ if (ReturnObject && ACPI_GET_DESCRIPTOR_TYPE (ReturnObject) == ACPI_DESC_TYPE_NAMED) { ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, "Invalid return type - Found a Namespace node [%4.4s] type %s", ReturnObject->Node.Name.Ascii, AcpiUtGetTypeName (ReturnObject->Node.Type))); return (AE_AML_OPERAND_TYPE); } /* * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type. * The bitmapped type allows multiple possible return types. * * Note, the cases below must handle all of the possible types returned * from all of the predefined names (including elements of returned * packages) */ Data->ReturnBtype = AcpiNsGetBitmappedType (ReturnObject); if (Data->ReturnBtype == ACPI_RTYPE_ANY) { /* Not one of the supported objects, must be incorrect */ goto TypeErrorExit; } /* For reference objects, check that the reference type is correct */ if ((Data->ReturnBtype & ExpectedBtypes) == ACPI_RTYPE_REFERENCE) { Status = AcpiNsCheckReference (Data, ReturnObject); return (Status); } /* Attempt simple repair of the returned object if necessary */ Status = AcpiNsSimpleRepair (Data, ExpectedBtypes, PackageIndex, ReturnObjectPtr); return (Status); TypeErrorExit: /* Create a string with all expected types for this predefined object */ AcpiUtGetExpectedReturnTypes (TypeBuffer, ExpectedBtypes); if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT) { ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, "Return type mismatch - found %s, expected %s", AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); } else { ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, "Return Package type mismatch at index %u - " "found %s, expected %s", PackageIndex, AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); } return (AE_AML_OPERAND_TYPE); }