ACPI_STATUS AtInstallGpeHandlerCommon( 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); } 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 == 1) { /* Make Device handle invalid by unloading SSDT table*/ if (ACPI_FAILURE(Status = AtAuxiliarySsdt(AT_UNLOAD))) { return (Status); } } else if (CheckAction == 5) { if (ExpectedStatus != AE_ALREADY_EXISTS) { TestErrors++; printf ("Test Error: ExpectedStatus %s != AE_ALREADY_EXISTS\n", AcpiFormatException(ExpectedStatus)); return (AE_ERROR); } ExpectedStatus = AE_OK; } GpeHandlerCounter = 0; 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; } GpeHandlerContext[i] = 0; Status = AcpiInstallGpeHandler(GpeDevice, Gpe, EolType, EventHandler, &GpeHandlerContext[i]); if (Status != ExpectedStatus) { AapiErrors++; printf ("Api Error: AcpiInstallGpeHandler(%d, 0x%x, 0x%p)" " returned %s, expected %s\n", Gpe, EolType, EventHandler, AcpiFormatException(Status), AcpiFormatException(ExpectedStatus)); if (Status != AE_OK) { return (Status); } else { return (AE_ERROR); } } } if (CheckAction == 5) { for (i = 0; i < AT_NUM_GPE_EVENTS; i++) { Gpe = GpeNumber[i]; EolType = GpeEolType[i]; EventHandler = GpeHandlers[(i + 1) % AT_NUM_GPE_EVENTS]; Status = AcpiInstallGpeHandler(GpeDevice, Gpe, EolType, EventHandler, &GpeHandlerContext[i]); if (Status != AE_ALREADY_EXISTS) { AapiErrors++; printf ("Error: AcpiInstallGpeHandler(%d, 0x%x, 0x%p) returned %s," " expected %s\n", Gpe, EolType, EventHandler, AcpiFormatException(Status), AcpiFormatException(AE_ALREADY_EXISTS)); 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)); }
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)); }
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)); }
ACPI_STATUS AtInstallGpeBlockExceptionTest( ACPI_OSXF OsxfNum, AT_ACTD_FLAG ActFlag, UINT32 ActCode, UINT32 TFst, ACPI_STATUS Benchmark) { ACPI_STATUS Status; ACPI_OSXF OsxfNumAct; UINT32 Continue_Cond = 1; UINT32 TMax = 10000; UINT32 i; ACPI_STRING Pathname = "\\DGPE"; ACPI_HANDLE GpeDevice; for (i = TFst; (i < TMax) && Continue_Cond; i++) { printf ("AtWalkNamespaceExceptionTest: i = %d\n", i); Status = AtSubsystemInit( AAPITS_INI_DEF, AAPITS_EN_FLAGS, AAPITS_OI_FLAGS, AtAMLcodeFileName); if (ACPI_FAILURE(Status)) { return (Status); } Status = AcpiGetHandle (NULL, Pathname, &GpeDevice); if (ACPI_FAILURE(Status)) { AapiErrors++; printf ("Api Error: AcpiGetHandle(%s) returned %s\n", Pathname, AcpiFormatException(Status)); return (Status); } Status = OsxfCtrlSet(OsxfNum, i, ActFlag, ActCode); if (ACPI_FAILURE(Status)) { TestErrors++; printf ("Test error: OsxfCtrlSet returned %s\n", AcpiFormatException(Status)); return (Status); } Status = AcpiInstallGpeBlock (GpeDevice, &GpeBlockAddress, RegisterCount, InterruptNumber); if (!(OsxfNumAct = OsxfCtrlGetActOsxf(OsxfNum, 1))) { if (i == TFst) { TestSkipped++; printf ("Test note: test action hasn't occur\n"); } TestPass++; Continue_Cond = 0; } else { if (Status != Benchmark) { AapiErrors++; printf ("API Error: AcpiInstallGpeBlock returned %s,\n" " expected to return %s\n", AcpiFormatException(Status), AcpiFormatException(Benchmark)); return (AE_ERROR); } } Status = AtTerminateCtrlCheck(AE_OK, ALL_STAT); if (ACPI_FAILURE(Status)) { return (Status); } } if (i >= TMax) { TestErrors++; printf ("Test error: there are test cases remained\n"); return (AE_ERROR); } return (AE_OK); }
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)); }
ACPI_STATUS AtFixedEventsCommon( UINT32 ApiCall, UINT32 CheckAction, ACPI_STATUS ExpectedStatus) { ACPI_STATUS Status; UINT32 Event, Flags = 0; UINT32 i; char *ApiCallName; ACPI_EVENT_STATUS EventStatus, *EventStatusPointer = &EventStatus; Status = AtSubsystemInit( AAPITS_INI_DEF, AAPITS_EN_FLAGS, AAPITS_OI_FLAGS, NULL); if (ACPI_FAILURE(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; default: TestErrors++; printf ("Test Error: the number of Fixed Events (%d) too big (should be 5)\n", ACPI_NUM_FIXED_EVENTS); return (AE_ERROR); } if (CheckAction == 1) { Event += ACPI_NUM_FIXED_EVENTS; } else if (CheckAction == 2) { EventStatusPointer = NULL; } switch (ApiCall) { case 0: ApiCallName = "AcpiEnableEvent"; Status = AcpiEnableEvent(Event, Flags); break; case 1: ApiCallName = "AcpiDisableEvent"; Status = AcpiDisableEvent(Event, Flags); break; case 2: ApiCallName = "AcpiClearEvent"; Status = AcpiClearEvent(Event); break; case 3: ApiCallName = "AcpiGetEventStatus"; Status = AcpiGetEventStatus(Event, EventStatusPointer); break; default: TestErrors++; printf ("Test Error: the ApiCall number (%d) should be in range 0-3\n", ApiCall); return (AE_ERROR); } if (Status != ExpectedStatus) { AapiErrors++; printf ("Api Error: %s(%d) returned %s, expected %s\n", ApiCallName, Event, AcpiFormatException(Status), AcpiFormatException(ExpectedStatus)); if (Status != AE_OK) { return (Status); } else { return (AE_ERROR); } } } return (AtTerminateCtrlCheck(AE_OK, ALL_STAT)); }