Example #1
0
/*
 * ASSERTION 0005:
 */
ACPI_STATUS
AtGpeTest0005(void)
{
    ACPI_STATUS             Status;

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

    /*
     * AcpiOsAllocate returns NULL permanently since the specified call
     */

    Status = AtInstallGpeBlockExceptionTest(
        OSXF_NUM(AcpiOsAllocate),
        AtActD_Permanent, AtActRet_NULL, 1,
        AE_NO_MEMORY);
    if (ACPI_FAILURE(Status))
    {
        return (Status);
    }

    /*
     * AcpiOsAllocate returns NULL one time on the specified call
     */

    Status = AtInstallGpeBlockExceptionTest(
        OSXF_NUM(AcpiOsAllocate),
        AtActD_OneTime, AtActRet_NULL, 1,
        AE_NO_MEMORY);
    if (ACPI_FAILURE(Status))
    {
        return (Status);
    }

    return (AE_OK);
}
Example #2
0
/*
 * Initialize AcpiOS* interfaces test control data.
 *
 */
ACPI_STATUS
OsxfCtrlInit(
    void)
{
    UINT32                  i;

    for (i = 0; i < AcpiOsAllC; i++)
    {
        OsxfCtrl[i].CallsCount = 0;
        OsxfCtrl[i].SuccessCount = 0;
        OsxfCtrl[i].CtrlAct.CallsCount = 0;
    }

    InitOsxfCtrl = OsxfCtrl[OSXF_NUM(AcpiOsInitialize)];

    return (AE_OK);
}
Example #3
0
/*
 * Check specified conditions on AcpiOsInitialize test control data.
 *
 */
ACPI_STATUS
InitOsxfCtrlCheck(
    ACPI_STATUS             Check_Status)
{
    ACPI_OSXF_CONTROL       Ctrl = InitOsxfCtrl;

    InitOsxfCtrl = OsxfCtrl[OSXF_NUM(AcpiOsInitialize)];

    if ((InitOsxfCtrl.CallsCount != Ctrl.CallsCount + 1) ||
        (InitOsxfCtrl.SuccessCount != Ctrl.SuccessCount +
            (Check_Status == AE_OK)))
    {
        printf("API error: invalid AcpiOsInitialize call conditions"
            " on Status %s\n", AcpiFormatException(Check_Status));
        return (AE_ERROR);
    }
    return (AE_OK);
}
Example #4
0
/*
 * Calculate AcpiOS* interfaces calls.
 *
 */
UINT64
OsxfCtrlTotalCalls(
    UINT32                  SuccessCountFlag)
{
    UINT64                  Count = 0;
    UINT32                  i;

    if (SuccessCountFlag)
    {
        for (i = AcpiOsInitializeC; i < AcpiOsAllC; i++)
        {
            Count += OsxfCtrl[i].SuccessCount;
        }
    }
    else
    {
        Count = OsxfCtrl[OSXF_NUM(AcpiOsTotal)].CallsCount;
    }

    return (Count);
}
Example #5
0
ACPI_STATUS
AtRemoveFixedEventHandlerCommon(
    UINT32                  CheckAction,
    ACPI_STATUS             ExpectedStatus)
{
    ACPI_STATUS             Status;
    UINT32                  Event = ACPI_NUM_FIXED_EVENTS;
    ACPI_EVENT_HANDLER      EventHandler;
    ACPI_OSXF               OsxfNumAct;
    UINT32                  i;

    Status = AtSubsystemInit(
        AAPITS_INI_DEF & ~AAPITS_INSTALL_HS,
        AAPITS_EN_FLAGS | ACPI_NO_HANDLER_INIT, AAPITS_OI_FLAGS, NULL);
    if (ACPI_FAILURE(Status))
    {
        return (Status);
    }

    FixedEventHandlerCounter = 0;
    for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
    {
        if (CheckAction == 5)
        {
            continue;
        }
        switch (i)
        {
        case 0:
            Event = ACPI_EVENT_PMTIMER;
            break;
        case 1:
            Event = ACPI_EVENT_GLOBAL;
            break;
        case 2:
            Event = ACPI_EVENT_POWER_BUTTON;
            break;
        case 3:
            Event = ACPI_EVENT_SLEEP_BUTTON;
            break;
        case 4:
            Event = ACPI_EVENT_RTC;
            break;
        default:
            TestErrors++;
            printf ("Test Error: the number of Fixed Events (%d) too big (should be 5)\n",
                ACPI_NUM_FIXED_EVENTS);
            return (AE_ERROR);
        }
        EventHandler = FixedEventHandlers[i];

        FixedEventHandlerContext[i] = 0;

        Status = AcpiInstallFixedEventHandler(Event,
            EventHandler, &FixedEventHandlerContext[i]);
        if (ACPI_FAILURE(Status))
        {
            AapiErrors++;
            printf ("Api Error: AcpiInstallFixedEventHandler(%d) returned %s\n",
                Event, AcpiFormatException(Status));
            return (Status);
        }
    }

    for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
    {
        switch (i)
        {
        case 0:
            Event = ACPI_EVENT_PMTIMER;
            break;
        case 1:
            Event = ACPI_EVENT_GLOBAL;
            break;
        case 2:
            Event = ACPI_EVENT_POWER_BUTTON;
            break;
        case 3:
            Event = ACPI_EVENT_SLEEP_BUTTON;
            break;
        case 4:
            Event = ACPI_EVENT_RTC;
            break;
        }
        EventHandler = FixedEventHandlers[i];

        if (CheckAction == 1)
        {
            Event += ACPI_NUM_FIXED_EVENTS;
        }
        else if (CheckAction == 2)
        {
            EventHandler = NULL;
        }
        else if (CheckAction == 3)
        {
            /*
             * initiate the situation when fixed event
             * enable register can not be written
             */
            Status = OsxfCtrlSet(OSXF_NUM(AcpiOsWritePort), 1,
                AtActD_OneTime, AtActRet_ERROR);
            if (ACPI_FAILURE(Status))
            {
                TestErrors++;
                printf ("Test error: OsxfCtrlSet returned %s\n",
                    AcpiFormatException(Status));
                return (Status);
            }
        }
        else if (CheckAction == 4)
        {
            EventHandler = FixedEventHandlers[(i + 2) % ACPI_NUM_FIXED_EVENTS];
        }

        Status = AcpiRemoveFixedEventHandler(Event, EventHandler);

        if (CheckAction == 3 &&
            !(OsxfNumAct = OsxfCtrlGetActOsxf(OSXF_NUM(AcpiOsWritePort), 1)))
        {
            TestSkipped++;
            printf ("Test note: test action hasn't occur\n");
            return (AE_ERROR);
        }
        TestPass++;

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

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

    return (AtTerminateCtrlCheck(AE_OK, ALL_STAT));
}
Example #6
0
/*
 * Check specified conditions on AcpiOS* interfaces test control data.
 *
 */
ACPI_STATUS
OsxfCtrlCheck(
    UINT32                  CondFlags,
    UINT32                  FreeCond)
{
    INT64                   Diff64;
    UINT32                  i;
    UINT32                  Diff_Flags = 0;
    UINT32                  Free_Flag = 0;
    UINT32                  OsxfNum1;

    if (CondFlags & FREE_STAT)
    {
        CondFlags &= ~FREE_STAT;
        Free_Flag = 1;
    }

    if (CondFlags & TOTAL_STAT)
    {
        CondFlags &= ~TOTAL_STAT;

        Diff64 = OsxfCtrlGetDiff(TOTAL_STAT);

        if (Diff64 < 0)
        {
            printf("Test error: invalid CallsCount calculation\n");
            return (AE_ERROR);
        }

        if ((Diff64 == 0 && (FreeCond == 0)) ||
                (Diff64 > 0 && (FreeCond != 0)))
        {
            printf("API error: contradictory %d AcpiOS* invocations"
                " on FreeCond %d\n", (UINT32)Diff64, FreeCond);
            return (AE_ERROR);
        }
    }

    if ((ALL_STAT & CondFlags) != CondFlags)
    {
        printf("Test error: unexpected CondFlags 0x%x\n",
            ~ALL_STAT & CondFlags);
        return (AE_ERROR);
    }
    if (!CondFlags)
    {
        return (AE_OK);
    }
    for (i = 0; i < 5; i++)
    {
        if (CondFlags & (1 << i))
        {
            Diff64 = OsxfCtrlGetDiff(1 << i);

            if (Diff64 < 0)
            {
                printf("%s API error: there were invalid"
                    " freeings, Diff = %d\n", stat_msg[i], (UINT32)Diff64);
                return (AE_ERROR);
            }

            if ((FreeCond == 0 && Diff64 == 0) ||
                    (FreeCond != 0 && Diff64 != 0))
            {
                Diff_Flags |= (1 << i);
            }
            if (Free_Flag)
            {
                switch (1 << i)
                {
                case OSINIT_STAT:
                    OsxfNum1 = OSXF_NUM(AcpiOsTerminate);
                    break;
                case MALLOC_STAT:
                    OsxfNum1 = OSXF_NUM(AcpiOsFree);
                    break;
                case MMAP_STAT:
                    OsxfNum1 = OSXF_NUM(AcpiOsUnmapMemory);
                    break;
                case SEMAPH_STAT:
                    OsxfNum1 = OSXF_NUM(AcpiOsDeleteSemaphore);
                    break;
                case LOCK_STAT:
                    OsxfNum1 = OSXF_NUM(AcpiOsDeleteLock);
                    break;
                default:
                    OsxfNum1 = OSXF_NUM(AcpiOsTotal);
                    break;
                }

                /* Check that all resource releasings resulted in success */
                Diff64 = OsxfCtrl[OsxfNum1].CallsCount - OsxfCtrl[OsxfNum1].SuccessCount;
                if (Diff64)
                {
                    printf("%s API error: there were unexpected"
                        " freeings, Diff = %d\n", stat_msg[i], (UINT32)Diff64);
                    return (AE_ERROR);
                }
            }
        }
    }
    if ((FreeCond == 0 && Diff_Flags == CondFlags) ||
            (FreeCond != 0 && Diff_Flags != 0))
    {
        printf("API error: unexpected free conditions,"
            " FreeCond %d, Diff_Flags = 0x%.2x\n", FreeCond, Diff_Flags);
        return (AE_ERROR);
    }

    return (AE_OK);
}
Example #7
0
/*
 * Get specified differencies on AcpiOS* allocation/releasing interfaces calls.
 *
 */
INT64
OsxfCtrlGetDiff(
    UINT32                  OsxfFlags)
{
    INT64                   Diff64 = -1;
    UINT32                  OsxfNum0, OsxfNum1;
    UINT64                  NewTotalCallsCount;

    if (OsxfFlags & TOTAL_STAT)
    {
        NewTotalCallsCount = OsxfCtrlTotalCalls(0);
        Diff64 = NewTotalCallsCount - TotalCallsCountMark;
        TotalCallsCountMark = NewTotalCallsCount;
    }
    else
    {
        switch (OsxfFlags)
        {
        case OSINIT_STAT:
            OsxfNum0 = OSXF_NUM(AcpiOsInitialize);
            OsxfNum1 = OSXF_NUM(AcpiOsTerminate);
            break;
        case MALLOC_STAT:
            OsxfNum0 = OSXF_NUM(AcpiOsAllocate);
            OsxfNum1 = OSXF_NUM(AcpiOsFree);
            break;
        case MMAP_STAT:
            OsxfNum0 = OSXF_NUM(AcpiOsMapMemory);
            OsxfNum1 = OSXF_NUM(AcpiOsUnmapMemory);
            break;
        case SEMAPH_STAT:
            OsxfNum0 = OSXF_NUM(AcpiOsCreateSemaphore);
            OsxfNum1 = OSXF_NUM(AcpiOsDeleteSemaphore);
            break;
        case LOCK_STAT:
            OsxfNum0 = OSXF_NUM(AcpiOsCreateLock);
            OsxfNum1 = OSXF_NUM(AcpiOsDeleteLock);
            break;
        default:
            OsxfNum0 = OSXF_NUM(AcpiOsTotal);
            OsxfNum1 = OSXF_NUM(AcpiOsTotal);
            break;
        }

        Diff64 = OsxfCtrl[OsxfNum0].SuccessCount - OsxfCtrl[OsxfNum1].SuccessCount;
    }

    return (Diff64);
}