Ejemplo n.º 1
0
ACPI_STATUS
AtGpeCommon(
    ACPI_STRING             Pathname,
    UINT32                  GpeNumber[],
    UINT8                   GpeType[],
    UINT32                  GpeCount,
    UINT32                  ApiCall,
    UINT32                  CheckAction,
    ACPI_STATUS             ExpectedStatus)
{
    ACPI_STATUS             Status;
    ACPI_HANDLE             GpeDevice = NULL;
    UINT32                  Gpe;
    UINT32                  i;
    char                    *ApiCallName;
    ACPI_EVENT_STATUS       GpeStatus, *GpeStatusPointer = &GpeStatus;

    if (ACPI_FAILURE(Status = AtAMLcodeFileNameSet("gpev0000.aml")))
    {
        return (Status);
    }

    Status = AtSubsystemInit(
        AAPITS_INI_DEF,
        AAPITS_EN_FLAGS, AAPITS_OI_FLAGS, AtAMLcodeFileName);
    if (ACPI_FAILURE(Status))
    {
        return (Status);
    }

    if (CheckAction == 1)
    {
        if (ACPI_FAILURE(Status = AtAuxiliarySsdt(AT_LOAD)))
        {
            return (Status);
        }
        Pathname = "\\AUX2.DEV0";
    }

    if (Pathname)
    {
        Status = AcpiGetHandle (NULL, Pathname, &GpeDevice);
        if (ACPI_FAILURE(Status))
        {
            AapiErrors++;
            printf ("Api Error: AcpiGetHandle(%s) returned %s\n",
                Pathname, AcpiFormatException(Status));
            return (Status);
        }

        if (CheckAction != 2)
        {
            Status = AcpiInstallGpeBlock (GpeDevice, &GpeBlockAddress,
                RegisterCount, InterruptNumber);
            if (ACPI_FAILURE(Status))
            {
                AapiErrors++;
                printf ("Api Error: AcpiInstallGpeBlock(%s) returned %s\n",
                    Pathname, AcpiFormatException(Status));
                return (Status);
            }
        }
    }

#if 0
/* OBSOLETE interface, AcpiSetGpeType */

    if (CheckAction != 2 && ApiCall != 0)
    {
        for (i = 0; i < GpeCount; i++)
        {
            Gpe = GpeNumber[i];
            Type = GpeType[i];

            Status = AcpiSetGpeType(GpeDevice, Gpe, Type);
            if (ACPI_FAILURE(Status))
            {
                AapiErrors++;
                printf ("API Error: AcpiSetGpeType(0x%x, 0x%x) returned %s\n",
                    Gpe, (UINT32)Type, AcpiFormatException(Status));
                return (Status);
            }
        }
    }
#endif


    if (CheckAction == 1)
    {
        /* Make Device handle invalid by unloading SSDT table*/
        if (ACPI_FAILURE(Status = AtAuxiliarySsdt(AT_UNLOAD)))
        {
            return (Status);
        }
    }

    for (i = 0; i < GpeCount; i++)
    {
        Gpe = GpeNumber[i];

        if (CheckAction == 3)
        {
            Gpe += 256;
        }
        else if (CheckAction == 5)
        {
            GpeStatusPointer = NULL;
        }

        switch (ApiCall)
        {
        case 0:
            ApiCallName = "AcpiSetGpeType";
#if 0
/* OBSOLETE INTERFACE */
            Status = AcpiSetGpeType(GpeDevice, Gpe, Type);
#endif
            Status = AE_OK;
            break;
        case 1:
            ApiCallName = "AcpiEnableGpe";
            Status = AcpiEnableGpe(GpeDevice, Gpe);
            break;
        case 2:
            ApiCallName = "AcpiClearGpe";
            Status = AcpiClearGpe(GpeDevice, Gpe);
            break;
        case 3:
            ApiCallName = "AcpiGetGpeStatus";
            Status = AcpiGetGpeStatus(GpeDevice, Gpe, GpeStatusPointer);
            break;
        case 4:
            ApiCallName = "AcpiDisableGpe";
            Status = AcpiDisableGpe(GpeDevice, Gpe);
            break;
        default:
            TestErrors++;
            printf ("Test Error: the ApiCall number (%d) should be in range 0-4\n",
                ApiCall);
            return (AE_ERROR);
        }

        if (Status != ExpectedStatus)
        {
            AapiErrors++;
            printf ("Api Error: %s(%d) returned %s, expected %s\n",
                ApiCallName, Gpe, AcpiFormatException(Status),
                AcpiFormatException(ExpectedStatus));
            if (Status != AE_OK)
            {
                return (Status);
            }
            else
            {
                return (AE_ERROR);
            }
        }
    }

    return (AtTerminateCtrlCheck(AE_OK, ALL_STAT));
}
Ejemplo n.º 2
0
ACPI_STATUS
AtRemoveGpeHandlerCommon(
    UINT32                  CheckAction,
    ACPI_STATUS             ExpectedStatus)
{
    ACPI_STATUS             Status;
    ACPI_STRING             Pathname = "\\DGPE";
    ACPI_HANDLE             GpeDevice = NULL;
    UINT32                  Gpe;
    UINT8                   EolType;
    ACPI_GPE_HANDLER        EventHandler;
    UINT32                  i;
    UINT32                  InitStages = AAPITS_INI_DEF & ~AAPITS_INSTALL_HS;

    if (ACPI_FAILURE(Status = AtAMLcodeFileNameSet("gpev0000.aml")))
    {
        return Status;
    }

    if (CheckAction == 1)
    {
        InitStages |= AAPITS_INSTALL_HS;
    }

    Status = AtSubsystemInit(
        InitStages,
        AAPITS_EN_FLAGS, AAPITS_OI_FLAGS, AtAMLcodeFileName);
    if (ACPI_FAILURE(Status))
    {
        return Status;
    }

    if (CheckAction == 1)
    {
        if (ACPI_FAILURE(Status = AtAuxiliarySsdt(AT_LOAD)))
        {
            return Status;
        }
        Pathname = "\\AUX2.DEV0";
    }

    Status = AcpiGetHandle (NULL, Pathname, &GpeDevice);
    if (ACPI_FAILURE(Status))
    {
        AapiErrors++;
        printf ("Api Error: AcpiGetHandle(%s) returned %s\n",
            Pathname, AcpiFormatException(Status));
        return Status;
    }

    GpeHandlerCounter = 0;

    if (CheckAction != 2)
    {
        Status = AcpiInstallGpeBlock (GpeDevice, &GpeBlockAddress,
            RegisterCount, InterruptNumber);
        if (ACPI_FAILURE(Status))
        {
            AapiErrors++;
            printf ("Api Error: AcpiInstallGpeBlock(%s) returned %s\n",
                Pathname, AcpiFormatException(Status));
            return Status;
        }

        if (CheckAction != 6)
        {
            for (i = 0; i < AT_NUM_GPE_EVENTS; i++)
            {
                Gpe = GpeNumber[i];
                EolType = GpeEolType[i];
                EventHandler = GpeHandlers[i];
                GpeHandlerContext[i] = 0;

                Status = AcpiInstallGpeHandler(GpeDevice, Gpe, EolType,
                    EventHandler, &GpeHandlerContext[i]);
                if (ACPI_FAILURE(Status))
                {
                    AapiErrors++;
                    printf ("Error: AcpiInstallGpeHandler(%d, 0x%x, 0x%p) returned %s\n",
                        Gpe, EolType, EventHandler, AcpiFormatException(Status));
                    return Status;
                }
            }
        }
    }

    if (CheckAction == 1)
    {
        /* Make Device handle invalid by unloading SSDT table*/
        if (ACPI_FAILURE(Status = AtAuxiliarySsdt(AT_UNLOAD)))
        {
            return Status;
        }
    }

    for (i = 0; i < AT_NUM_GPE_EVENTS; i++)
    {
        Gpe = GpeNumber[i];
        EolType = GpeEolType[i];
        EventHandler = GpeHandlers[i];

        if (CheckAction == 3)
        {
            Gpe += 256;
        }
        else if (CheckAction == 4)
        {
            EventHandler = NULL;
        }
        else if (CheckAction == 5)
        {
            EventHandler = GpeHandlers[(i + 2) % AT_NUM_GPE_EVENTS];
        }

        Status = AcpiRemoveGpeHandler(GpeDevice, Gpe, EventHandler);

        if (Status != ExpectedStatus)
        {
            AapiErrors++;
            printf ("Api Error: AcpiRemoveGpeHandler(%d, 0x%p)"
                " returned %s, expected %s\n",
                Gpe, EventHandler, AcpiFormatException(Status),
                AcpiFormatException(ExpectedStatus));
            if (Status != AE_OK)
            {
                return Status;
            }
            else
            {
                return AE_ERROR;
            }
        }
    }

    if (GpeHandlerCounter != 0)
    {
        AapiErrors++;
        printf ("Api Error: Gpe Handler invoked %d times\n",
            GpeHandlerCounter);
        return AE_ERROR;
    }

    return AtTerminateCtrlCheck(AE_OK, ALL_STAT);
}
Ejemplo n.º 3
0
ACPI_STATUS
AtRemoveGpeBlockCommon(
    UINT32                  CheckAction,
    ACPI_STATUS             ExpectedStatus)
{
    ACPI_STATUS             Status;
    ACPI_STRING             Pathname = "\\DGPE";
    ACPI_HANDLE             GpeDevice;

    if (ACPI_FAILURE(Status = AtAMLcodeFileNameSet("gpev0000.aml")))
    {
        return (Status);
    }

    Status = AtSubsystemInit(
        AAPITS_INI_DEF,
        AAPITS_EN_FLAGS, AAPITS_OI_FLAGS, AtAMLcodeFileName);
    if (ACPI_FAILURE(Status))
    {
        return (Status);
    }

    if (CheckAction == 1)
    {
        if (ACPI_FAILURE(Status = AtAuxiliarySsdt(AT_LOAD)))
        {
            return (Status);
        }
        Pathname = "\\AUX2.DEV0";
    }

    Status = AcpiGetHandle (NULL, Pathname, &GpeDevice);
    if (ACPI_FAILURE(Status))
    {
        AapiErrors++;
        printf ("Api Error: AcpiGetHandle(%s) returned %s\n",
            Pathname, AcpiFormatException(Status));
        return (Status);
    }

    Status = AcpiInstallGpeBlock (GpeDevice, &GpeBlockAddress,
        RegisterCount, InterruptNumber);
    if (ACPI_FAILURE(Status))
    {
        AapiErrors++;
        printf ("Api Error: AcpiInstallGpeBlock(%s) returned %s\n",
            Pathname, AcpiFormatException(Status));
        return (Status);
    }

    if (CheckAction == 1)
    {
        /* Make Device handle invalid by unloading SSDT table*/
        if (ACPI_FAILURE(Status = AtAuxiliarySsdt(AT_UNLOAD)))
        {
            return (Status);
        }
    }
    else if (CheckAction == 2)
    {
        Pathname = "\\NGPE";
    }

    Status = AcpiRemoveGpeBlock (GpeDevice);
    if (Status != ExpectedStatus)
    {
        AapiErrors++;
        printf ("Api Error: AcpiInstallGpeBlock(%s) returned %s, expected %s\n",
            Pathname, AcpiFormatException(Status),
            AcpiFormatException(ExpectedStatus));
        if (Status != AE_OK)
        {
            return (Status);
        }
        else
        {
            return (AE_ERROR);
        }
    }

    return (AtTerminateCtrlCheck(AE_OK, ALL_STAT));
}