diff options
author | raywu <raywu0301@gmail.com> | 2018-06-15 00:00:50 +0800 |
---|---|---|
committer | raywu <raywu0301@gmail.com> | 2018-06-15 00:00:50 +0800 |
commit | b7c51c9cf4864df6aabb99a1ae843becd577237c (patch) | |
tree | eebe9b0d0ca03062955223097e57da84dd618b9a /Board/EM/MeWrapper/AtAmUi | |
download | zprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz |
Diffstat (limited to 'Board/EM/MeWrapper/AtAmUi')
-rw-r--r-- | Board/EM/MeWrapper/AtAmUi/AtAmUi.c | 1120 | ||||
-rw-r--r-- | Board/EM/MeWrapper/AtAmUi/AtAmUi.cif | 14 | ||||
-rw-r--r-- | Board/EM/MeWrapper/AtAmUi/AtAmUi.dxs | 42 | ||||
-rw-r--r-- | Board/EM/MeWrapper/AtAmUi/AtAmUi.h | 150 | ||||
-rw-r--r-- | Board/EM/MeWrapper/AtAmUi/AtAmUi.mak | 148 | ||||
-rw-r--r-- | Board/EM/MeWrapper/AtAmUi/AtAmUi.sdl | 27 | ||||
-rw-r--r-- | Board/EM/MeWrapper/AtAmUi/AtAmUiString.c | 242 | ||||
-rw-r--r-- | Board/EM/MeWrapper/AtAmUi/AtAmUiString.h | 208 |
8 files changed, 1951 insertions, 0 deletions
diff --git a/Board/EM/MeWrapper/AtAmUi/AtAmUi.c b/Board/EM/MeWrapper/AtAmUi/AtAmUi.c new file mode 100644 index 0000000..8a2cffe --- /dev/null +++ b/Board/EM/MeWrapper/AtAmUi/AtAmUi.c @@ -0,0 +1,1120 @@ +/** @file + This file contines rouines responsible for handling the UI. + +@copyright + Copyright (c) 2012 - 2013 Intel Corporation. All rights reserved + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation. + + This file contains a 'Sample Driver' and is licensed as such + under the terms of your license agreement with Intel or your + vendor. This file may be modified by the user, subject to + the additional terms of the license agreement + +**/ +#include "AtAmUi.h" +#include EFI_PROTOCOL_CONSUMER (ConsoleControl) +#include EFI_PROTOCOL_CONSUMER (GraphicsOutput) +DXE_AT_POLICY_PROTOCOL *mDxePlatformAtPolicy; +EFI_GUID gAlertAtHandlerGuid = ME_ALERT_AT_HANDLER_GUID; +EFI_GUID gEfiAtAmProtocolGuid = EFI_ATAM_PROTOCOL_GUID; +EFI_EVENT gAlertAtHandlerEvent; +EFI_ATAM_PROTOCOL *mAtAm = NULL; + +// +// Driver entry point +// +EFI_DRIVER_ENTRY_POINT (AtAmUiEntryPoint); + +/** + ATAM UI driver entry point. + + @param[in] ImageHandle Handle for this drivers loaded image protocol. + @param[in] SystemTable EFI system table. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_UNSUPPORTED The function is unsupported by this driver +**/ +EFI_STATUS +AtAmUiEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + EfiInitializeDriverLib (ImageHandle, SystemTable); + Status = gBS->LocateProtocol ( + &gDxePlatformAtPolicyGuid, + NULL, + &mDxePlatformAtPolicy + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: No AT Platform Policy Protocol available")); + return Status; + } + ASSERT_EFI_ERROR (Status); + + if (mDxePlatformAtPolicy->At.AtAmBypass == 1) { + return EFI_SUCCESS; + } + + if (mAtAm == NULL) { + Status = gBS->LocateProtocol ( + &gEfiAtAmProtocolGuid, + NULL, + (VOID **) &mAtAm + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: ATAM Protocol failed, Status = %r\n", Status)); + return Status; + } else { + DEBUG ((EFI_D_ERROR, "ATAM: ATAM Protocol success, Status = %r\n", Status)); + } + } + + Status = gBS->CreateEventEx ( + EFI_EVENT_NOTIFY_SIGNAL, + EFI_TPL_CALLBACK, + AtAmUiCallback, + NULL, + &gAlertAtHandlerGuid, + &gAlertAtHandlerEvent + ); + + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: AT - Error Creating Event to Process Suspend Mode\n")); + } + + return Status; +} +EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl; +EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; +EFI_CONSOLE_CONTROL_SCREEN_MODE ScreenMode; +EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GraphicsModeInfo; +UINTN UgaBltSize = 0; +EFI_UGA_PIXEL *UgaBlt = NULL; +INT32 TextMode; +UINTN StyleGetTextMode(); + +VOID +GraphicsSave +( + VOID +) +{ + UINTN SizeOfGraphicsModeInfo; + + EFI_STATUS + Status = gBS->LocateProtocol( &gEfiConsoleControlProtocolGuid, NULL, &ConsoleControl); + + if(EFI_ERROR(Status)) + { + ConsoleControl = NULL; + return; + } + + Status = ConsoleControl->GetMode(ConsoleControl, &ScreenMode, NULL, NULL); + if(ScreenMode == EfiConsoleControlScreenText) + { + ConsoleControl = NULL; + return; + } + + Status = gBS->LocateProtocol( &gEfiGraphicsOutputProtocolGuid, NULL, &GraphicsOutput); + if(EFI_ERROR(Status)) + { + GraphicsOutput = NULL; + return; + } + + Status = GraphicsOutput->QueryMode( GraphicsOutput, GraphicsOutput->Mode->Mode, + &SizeOfGraphicsModeInfo ,&GraphicsModeInfo); + if(EFI_ERROR(Status)) + { + GraphicsModeInfo = NULL; + return; + } + + UgaBltSize = GraphicsModeInfo->HorizontalResolution * + GraphicsModeInfo->VerticalResolution * + sizeof(EFI_UGA_PIXEL); + + UgaBlt = AllocateZeroPool (UgaBltSize); + if( UgaBlt == NULL ) + return; + + Status = GraphicsOutput->Blt( + GraphicsOutput, + UgaBlt, + EfiBltVideoToBltBuffer, + 0, 0, + 0, 0, + GraphicsModeInfo->HorizontalResolution, + GraphicsModeInfo->VerticalResolution, + 0); + + Status = ConsoleControl->SetMode( ConsoleControl, EfiConsoleControlScreenText ); + TextMode = gST->ConOut->Mode->Mode; + gST->ConOut->SetMode(gST->ConOut, StyleGetTextMode()); +} + +VOID +GraphicsRestore +( + VOID +) +{ + if(!ConsoleControl) + return; + + gST->ConOut->SetMode(gST->ConOut, TextMode); + ConsoleControl->SetMode( ConsoleControl, EfiConsoleControlScreenGraphics ); + + if(!GraphicsOutput) + return; + + if(!UgaBlt || !GraphicsModeInfo) + return; + + GraphicsOutput->Blt( + GraphicsOutput, + UgaBlt, + EfiBltBufferToVideo, + 0, 0, + 0, 0, + GraphicsModeInfo->HorizontalResolution, + GraphicsModeInfo->VerticalResolution, + 0); + + ZeroMem(UgaBlt, UgaBltSize); + FreePool(UgaBlt); +} +/** + ATAM UI callback. + + @param[in] Event The event registered + @param[in] Context Event context. Not used in this event handler. + + @retval None +**/ +VOID +EFIAPI +AtAmUiCallback ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + DXE_AT_POLICY_PROTOCOL *pAtPlatformPolicy; + AT_STATE_INFO AtStateInfo; + EFI_TPL TplBackup; + + pAtPlatformPolicy = NULL; + + DEBUG ((EFI_D_ERROR, "ATAM: AtAmUiCallback \n")); + // + // change TPL to APPLICATION as required by ConIn to function + // + TplBackup = gBS->RaiseTPL (TPL_HIGH_LEVEL); + gBS->RestoreTPL (TplBackup); + if (TplBackup != TPL_APPLICATION) { + gBS->RestoreTPL(TPL_APPLICATION); + } + + Status = gBS->LocateProtocol ( + &gDxePlatformAtPolicyGuid, + NULL, + (VOID **) &pAtPlatformPolicy + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: ATAM LocateProtocol failed. \n")); + } + + if (mAtAm == NULL) { + Status = gBS->LocateProtocol ( + &gEfiAtAmProtocolGuid, + NULL, + (VOID **) &mAtAm + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: ATAM Protocol failed, Status = %r\n", Status)); + } + } + + mAtAm->AtAmGetAtStateInfo (mAtAm, &AtStateInfo); + + if (AtStateInfo.State == AT_STATE_STOLEN && pAtPlatformPolicy->At.AtPba == 1 && pAtPlatformPolicy->At.AtSupported == 0) { + AtAmUiTheftNotification (); + + } else if (AtStateInfo.State == AT_STATE_STOLEN && AtStateInfo.flags.LockState == 1 && AtStateInfo.flags.AuthenticateModule == AT_AM_SELECTION_ATAM) { + GraphicsSave(); + AtAmUiRecovery (); + GraphicsRestore(); + } else if (AtStateInfo.State == AT_STATE_SUSPEND) { + GraphicsSave(); + AtAmUiExitSuspendState (); + GraphicsRestore(); + } else if (AtStateInfo.State == AT_STATE_ACTIVE) { + if (pAtPlatformPolicy->At.AtEnterSuspendState) { + GraphicsSave(); + AtAmUiEnterSuspendState (); + GraphicsRestore(); + } + } + + // + // Restore TPL + // + if (TplBackup != TPL_APPLICATION) { + gBS->RaiseTPL(TplBackup); + } + + + return; +} + +/** + Function handling entering suspend mode. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary data structures. +**/ +EFI_STATUS +AtAmUiEnterSuspendState ( + VOID + ) +{ + EFI_STATUS Status; + UINT8 *PasswordASCII; + CHAR16 *PasswordUNICODE; + CHAR16 *UniCodeNonceStr; + UINT32 NumOfAttempts; + UINT8 NonceStr[STR_NONCE_LENGTH]; + UINT32 CRow; + UINT32 CCol; + UINT8 *IsvString; + UINT32 IsvId; + AT_BIOS_RECOVERY_CONFIG RecoveryConfig; + + Status = EFI_SUCCESS; + NumOfAttempts = ATAMUI_SUSPEND_ATTEMPTS; + + UniCodeNonceStr = AllocateZeroPool ((STR_NONCE_LENGTH + 1) * sizeof (CHAR16)); + PasswordASCII = AllocateZeroPool ((ATAM_SETUP_PASSWORD_LENGTH + 1) * sizeof (UINT8)); + PasswordUNICODE = AllocateZeroPool ((ATAM_SETUP_PASSWORD_LENGTH + 1) * sizeof (CHAR16)); + IsvString = AllocateZeroPool ((RECOVERY_STRING_LENGTH + 1) * sizeof (UINT8)); + + if (PasswordASCII == NULL || PasswordUNICODE == NULL || UniCodeNonceStr == NULL || IsvString == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + if (mAtAm == NULL) { + Status = gBS->LocateProtocol ( + &gEfiAtAmProtocolGuid, + NULL, + (VOID **) &mAtAm + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: ATAM Protocol failed, Status = %r\n", Status)); + } + } + + AtAmUiStrGetCursor (&CRow, &CCol); + + do { + AtAmUiStrClearScreen (); + + RecoveryConfig.IsvPlatformId[0] = L'\0'; + Status = mAtAm->AtAmGetRecoveryConfig (mAtAm, &RecoveryConfig); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: AtAmGetRecoveryConfig command failed, Status = %r\n", Status)); + } + if (RecoveryConfig.IsvPlatformId[0] != L'\0') { + AtAmUiStrSetCursor(4, 13); + AtAmUiStrDisplayFix (STR_ATAMUI_PLATFORM_ID, FALSE); + AtAmUiStrDisplay ((CHAR16 *) RecoveryConfig.IsvPlatformId); + } + + AtAmUiStrSetCursor(4, 14); + Status = mAtAm->AtAmGetIsvId (mAtAm, IsvString, &IsvId); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: AtAmGetIsvId command failed, Status = %r\n", Status)); + } + AtAmUiStrDisplay ((CHAR16 *) IsvString); + + AtAmUiStrEnableCursor (FALSE); + + AtAmUiStrDisplayFix (STR_ATAMUI_SUS_ENTER_INFO, TRUE); + + AtAmUiStrSetCursor (4, 2); + AtAmUiStrDisplayFix (STR_ATAMUI_SUS_REFER, FALSE); + Status = mAtAm->AtAmGetNonce (mAtAm, NonceStr); + if (Status == EFI_SUCCESS) { + Uint8ToUnicode (NonceStr, UniCodeNonceStr); + AtAmUiStrDisplay ((UINT16 *) UniCodeNonceStr); + } else { + AtAmUiStrDisplayFix (STR_ATAMUI_SUS_NONCE_FAILED, FALSE); + DEBUG ((EFI_D_ERROR, "ATAM: Get Nonce failed, Status = %r\n", Status)); + } + + AtAmUiStrDisplayFix (STR_ATAMUI_SUS_ENTER_TOKEN, TRUE); + AtAmUiStrEnableCursor (TRUE); + AtAmUiGetPassword (PasswordASCII, ATAM_SETUP_PASSWORD_LENGTH, PasswordUNICODE, 1); + AtAmUiStrEnableCursor (FALSE); + + Status = mAtAm->AtAmSetSuspendState (mAtAm, ATAM_ENTER_SUSPEND_STATE, PasswordASCII); + if (Status != EFI_SUCCESS) { + AtAmUiStrDisplayFix (STR_ATAMUI_SUS_ENTER_FAILED, TRUE); + AtAmUiDelay (2 * AT_AM_UI_1_SECOND); + } + + } while (--NumOfAttempts && (Status != EFI_SUCCESS)); + + if (Status == EFI_SUCCESS) { + AtAmUiStrDisplayFix (STR_ATAMUI_SUS_ENTER_SUCCESS, TRUE); + } else { + AtAmUiStrDisplayFix (STR_ATAMUI_SUS_ATTEMPT_EXC, TRUE); + } + + ZeroMem (UniCodeNonceStr, (STR_NONCE_LENGTH + 1) * sizeof (UINT16)); + ZeroMem (PasswordASCII, (ATAM_SETUP_PASSWORD_LENGTH + 1) * sizeof (CHAR8)); + ZeroMem (PasswordUNICODE, (ATAM_SETUP_PASSWORD_LENGTH + 1) * sizeof (CHAR16)); + + FreePool (UniCodeNonceStr); + FreePool (PasswordASCII); + FreePool (PasswordUNICODE); + + AtAmUiDelay (AT_AM_UI_1_SECOND); + + AtAmUiStrClearScreen (); + AtAmUiStrSetCursor (CCol, CRow); + + return Status; +} + +/** + Function handling exiting suspend mode. + + @param[in] None + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary data structures. +**/ +EFI_STATUS +AtAmUiExitSuspendState ( + VOID + ) +{ + EFI_STATUS Status; + UINT8 *PasswordASCII; + CHAR16 *PasswordUNICODE; + CHAR16 *UniCodeNonceStr; + UINT32 NumOfAttempts; + UINT8 NonceStr[STR_NONCE_LENGTH]; + EFI_INPUT_KEY Key; + UINT32 CRow; + UINT32 CCol; + UINT8 *IsvString; + UINT32 IsvId; + AT_BIOS_RECOVERY_CONFIG RecoveryConfig; + + Status = EFI_SUCCESS; + NumOfAttempts = 3; + + UniCodeNonceStr = AllocateZeroPool ((STR_NONCE_LENGTH + 1) * sizeof (CHAR16)); + PasswordASCII = AllocateZeroPool ((ATAM_SETUP_PASSWORD_LENGTH + 1) * sizeof (UINT8)); + PasswordUNICODE = AllocateZeroPool ((ATAM_SETUP_PASSWORD_LENGTH + 1) * sizeof (CHAR16)); + IsvString = AllocateZeroPool ((RECOVERY_STRING_LENGTH + 1) * sizeof (UINT8)); + + if (PasswordASCII == NULL || PasswordUNICODE == NULL || UniCodeNonceStr == NULL || IsvString == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + if (mAtAm == NULL) { + Status = gBS->LocateProtocol ( + &gEfiAtAmProtocolGuid, + NULL, + (VOID **) &mAtAm + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: ATAM Protocol failed, Status = %r\n", Status)); + } + } + + AtAmUiStrGetCursor (&CRow, &CCol); + + do { + AtAmUiStrClearScreen (); + AtAmUiStrDisplayFix (STR_ATAMUI_SUS_EXIT_QUESTION, TRUE); + + AtAmUiStrGetChar (&Key); + if (Key.UnicodeChar == L'y' || Key.UnicodeChar == L'Y' || Key.UnicodeChar == L'n' || Key.UnicodeChar == L'N') { + AtAmUiStrEnableCursor(FALSE); + break; + } + } while (1); + + if (Key.UnicodeChar == L'y' || Key.UnicodeChar == L'Y') { + do { + AtAmUiStrClearScreen (); + + RecoveryConfig.IsvPlatformId[0] = L'\0'; + Status = mAtAm->AtAmGetRecoveryConfig (mAtAm, &RecoveryConfig); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: AtAmGetRecoveryConfig command failed, Status = %r\n", Status)); + } + if (RecoveryConfig.IsvPlatformId[0] != L'\0') { + AtAmUiStrSetCursor(4, 13); + AtAmUiStrDisplayFix (STR_ATAMUI_PLATFORM_ID, FALSE); + AtAmUiStrDisplay ((CHAR16 *) RecoveryConfig.IsvPlatformId); + } + + AtAmUiStrSetCursor(4, 14); + Status = mAtAm->AtAmGetIsvId (mAtAm, IsvString, &IsvId); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: AtAmGetIsvId command failed, Status = %r\n", Status)); + } + AtAmUiStrDisplay ((CHAR16 *) IsvString); + + AtAmUiStrEnableCursor (FALSE); + + AtAmUiStrDisplayFix (STR_ATAMUI_SUS_EXIT_INFO, TRUE); + + AtAmUiStrSetCursor (4, 3); + AtAmUiStrDisplayFix (STR_ATAMUI_RES_REFER, FALSE); + mAtAm->AtAmGetNonce (mAtAm, NonceStr); + Uint8ToUnicode (NonceStr, UniCodeNonceStr); + AtAmUiStrDisplay ((UINT16 *) UniCodeNonceStr); + + AtAmUiStrSetCursor (4, 4); + AtAmUiStrDisplayFix (STR_ATAMUI_SUS_ENTER_TOKEN, FALSE); + + AtAmUiStrEnableCursor (TRUE); + AtAmUiGetPassword (PasswordASCII, ATAM_SETUP_PASSWORD_LENGTH, PasswordUNICODE, 1); + AtAmUiStrEnableCursor (FALSE); + + AtAmUiStrDisplayFix (STR_ATAMUI_CHECKING_AUTHENT, TRUE); + + Status = mAtAm->AtAmSetSuspendState (mAtAm, ATAM_EXIT_SUSPEND_STATE, PasswordASCII); + if (Status != EFI_SUCCESS) { + AtAmUiStrDisplayFix (STR_ATAMUI_SUS_AUTH_FAILED, FALSE); + AtAmUiDelay (AT_AM_UI_1_SECOND); + } + + AtAmUiDelay (AT_AM_UI_1_SECOND); + } while (--NumOfAttempts && (Status != EFI_SUCCESS)); + + if (Status == EFI_SUCCESS) { + AtAmUiStrDisplayFix (STR_ATAMUI_SUS_EXIT_SUCCESS, TRUE); + + } else { + AtAmUiStrDisplayFix (STR_ATAMUI_SUS_ATTEMPT_EXC, TRUE); + AtAmUiDelay (AT_AM_UI_1_SECOND); + } + } else if (Key.UnicodeChar == L'n' || Key.UnicodeChar == L'N') { + AtAmUiStrDisplayFix (STR_ATAMUI_SUS_STAY, TRUE); + AtAmUiDelay (2 *AT_AM_UI_1_SECOND); + } + + ZeroMem (UniCodeNonceStr, (STR_NONCE_LENGTH + 1) * sizeof (UINT16)); + ZeroMem (PasswordASCII, (ATAM_SETUP_PASSWORD_LENGTH + 1) * sizeof (CHAR8)); + ZeroMem (PasswordUNICODE, (ATAM_SETUP_PASSWORD_LENGTH + 1) * sizeof (CHAR16)); + + FreePool (UniCodeNonceStr); + FreePool (PasswordASCII); + FreePool (PasswordUNICODE); + + AtAmUiDelay (AT_AM_UI_1_SECOND); + + AtAmUiStrClearScreen (); + AtAmUiStrSetCursor (CCol, CRow); + + return Status; +} + +VOID +EFIAPI +ShowAtTimerCallback ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + UINT32 TimerLeft; + UINT32 TimerInterval; + static CHAR16 *TimeLeftStr = NULL; + EFI_STATUS Status; + UINT32 CRow; + UINT32 CCol; + + if(!TimeLeftStr) + TimeLeftStr = AllocateZeroPool ((ATAM_TIMER_STRING_LENGTH + 1) * sizeof (CHAR16)); + + AtAmUiStrGetCursor (&CRow, &CCol); + Status = mAtAm->AtAmGetTimer (mAtAm, &TimerLeft, &TimerInterval); + + if(EFI_ERROR(Status)) + return; + + UnicodeValueToString (TimeLeftStr, 0, TimerLeft, 0); + AtAmUiStrDisplayFix (STR_ATAMUI_TIME_LEFT, TRUE); + AtAmUiStrDisplay ((CHAR16 *) TimeLeftStr); + AtAmUiStrDisplayFix (STR_ATAMUI_TIME_LEFT_SEC,FALSE); + + AtAmUiStrSetCursor(CCol,CRow); +} +// Set the default TEXT MODE resolution the same with TSE +#define MAX_ROWS (UINT8)(31) +#define MAX_COLS (UINT8)(100) +UINTN StyleGetTextMode() +{ + EFI_STATUS Status; + INT32 i; + UINTN ModeRows, ModeCols; + + + // Default Implementation + for ( i = 0; i < gST->ConOut->Mode->MaxMode; i++ ) + { + Status = gST->ConOut->QueryMode( gST->ConOut, i, &ModeCols, &ModeRows ); + + if ( EFI_ERROR( Status ) ) + continue; + + if ( ( MAX_COLS <= ModeCols ) && ( MAX_ROWS <= ModeRows ) ) + return i; + } + + // return MaxMode if the mode wasn't found + return i; +} +/** + Function handling recovery proccess. + + @param[in] None + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary data structures. +**/ +EFI_STATUS +AtAmUiRecovery ( + VOID + ) +{ + EFI_STATUS Status; + EFI_INPUT_KEY Key; + UINT32 PassType; + UINT8 IsAuthenticated; + AT_STATE_INFO StateInfo; + UINT32 TimerLeft; + UINT32 TimerInterval; + UINT8 *PasswordASCII; + CHAR16 *PasswordUNICODE; + CHAR16 *TimeLeftStr; + UINT8 *IsvString; + UINT32 CRow; + UINT32 CCol; + UINT32 NumberOfAttempts; + UINT32 IsvId; + CHAR16 *UniCodeNonceStr; + UINT8 NonceStr[STR_NONCE_LENGTH]; + + IsAuthenticated = 0; + + PasswordASCII = AllocateZeroPool ((ATAM_SETUP_PASSWORD_LENGTH + 1) * sizeof (UINT8)); + PasswordUNICODE = AllocateZeroPool ((ATAM_SETUP_PASSWORD_LENGTH + 1) * sizeof (CHAR16)); + TimeLeftStr = AllocateZeroPool ((ATAM_TIMER_STRING_LENGTH + 1) * sizeof (CHAR16)); + IsvString = AllocateZeroPool ((RECOVERY_STRING_LENGTH + 1) * sizeof (UINT8)); + UniCodeNonceStr = AllocateZeroPool ((STR_NONCE_LENGTH + 1) * sizeof (CHAR16)); + + if (PasswordASCII == NULL || PasswordUNICODE == NULL || TimeLeftStr == NULL || IsvString == NULL || UniCodeNonceStr == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + if (mAtAm == NULL) { + Status = gBS->LocateProtocol ( + &gEfiAtAmProtocolGuid, + NULL, + (VOID **) &mAtAm + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: ATAM Protocol failed, Status = %r\n", Status)); + } + } + + AtAmUiStrGetCursor (&CRow, &CCol); + + NumberOfAttempts = 3; + + do { + AtAmUiStrClearScreen (); + AtAmUiDisplayIsvStrings (); + + do { + AtAmUiStrEnableCursor (FALSE); + + AtAmUiStrSetCursor(4, 20); + Status = mAtAm->AtAmGetIsvId (mAtAm, IsvString, &IsvId); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: AtAmGetIsvId command failed, Status = %r\n", Status)); + } + AtAmUiStrDisplay ((CHAR16 *) IsvString); + + mAtAm->AtAmGetAtStateInfo (mAtAm, &StateInfo); + AtAmUiStrDisplayFix (STR_ATAMUI_LOCK_DUE_TO, TRUE); + switch (StateInfo.LastTheftTrigger) { + case 1: + AtAmUiStrDisplayFix (STR_ATAMUI_LOCK_TIME, FALSE); + break; + + case 2: + AtAmUiStrDisplayFix (STR_ATAMUI_LOCK_STOLEN, FALSE); + break; + + case 3: + AtAmUiStrDisplayFix (STR_ATAMUI_LOCK_THRESHOLD, FALSE); + break; + + case 4: + AtAmUiStrDisplayFix (STR_ATAMUI_LOCK_ATTACK, FALSE); + + default: + break; + } + + mAtAm->AtAmGetTimer (mAtAm, &TimerLeft, &TimerInterval); + UnicodeValueToString (TimeLeftStr, 0, TimerLeft, 0); + + AtAmUiStrDisplayFix (STR_ATAMUI_TIME_LEFT, TRUE); + AtAmUiStrDisplay ((CHAR16 *) TimeLeftStr); + AtAmUiStrDisplayFix (STR_ATAMUI_TIME_LEFT_SEC,FALSE); + + AtAmUiStrDisplayFix (STR_ATAMUI_SELECT_PASS, TRUE); + + AtAmUiStrDisplayFix (STR_ATAMUI_SELECT_OPTION, TRUE); + + AtAmUiStrGetChar (&Key); + if (Key.UnicodeChar == L'1' || Key.UnicodeChar == L'2') { + break; + } + + AtAmUiStrDisplayFix (STR_ATAMUI_INVALID_SELECT, TRUE); + } while (1); + + AtAmUiStrClearScreen (); + AtAmUiDisplayIsvStrings (); + AtAmUiStrSetCursor(4, 20); + AtAmUiStrDisplay ((CHAR16 *) IsvString); + AtAmUiStrDisplayFix (STR_ATAMUI_LOCK_DUE_TO, TRUE); + switch (StateInfo.LastTheftTrigger) { + case 1: + AtAmUiStrDisplayFix (STR_ATAMUI_LOCK_TIME, FALSE); + break; + + case 2: + AtAmUiStrDisplayFix (STR_ATAMUI_LOCK_STOLEN, FALSE); + break; + + case 3: + AtAmUiStrDisplayFix (STR_ATAMUI_LOCK_THRESHOLD, FALSE); + break; + + case 4: + AtAmUiStrDisplayFix (STR_ATAMUI_LOCK_ATTACK, FALSE); + + default: + break; + } + mAtAm->AtAmGetTimer (mAtAm, &TimerLeft, &TimerInterval); + UnicodeValueToString (TimeLeftStr, 0, TimerLeft, 0); + AtAmUiStrDisplayFix (STR_ATAMUI_TIME_LEFT, TRUE); + AtAmUiStrDisplay ((CHAR16 *) TimeLeftStr); + AtAmUiStrDisplayFix (STR_ATAMUI_TIME_LEFT_SEC,FALSE); + + switch (Key.UnicodeChar) { + case L'1': + PassType = AT_CREDENTIAL_TYPE_USER_PASSPHRASE; + AtAmUiStrDisplayFix (STR_ATAMUI_USER_PASS, TRUE); + AtAmUiStrDisplayFix (STR_ATAMUI_RECO_ENTER_PASS, TRUE); + AtAmUiStrEnableCursor (TRUE); + AtAmUiGetPassword (PasswordASCII, ATAM_SETUP_PASSWORD_LENGTH, PasswordUNICODE, 0); + AtAmUiStrEnableCursor (FALSE); + AtAmUiStrDisplayFix (STR_ATAMUI_CHECKING_PASS, TRUE); + AtAmUiDelay (AT_AM_UI_1_SECOND); + Status = mAtAm->AtAmVerifyPassword (mAtAm, PasswordASCII, PassType, &IsAuthenticated); + DEBUG ((EFI_D_ERROR, "ATAM: IsAuthenticated %x\n", IsAuthenticated)); + + break; + + case L'2': + AtAmUiStrDisplayFix (STR_ATAMUI_RECO_REFER, TRUE); + Status = mAtAm->AtAmGetNonce (mAtAm, NonceStr); + if (Status == EFI_SUCCESS) { + Uint8ToUnicode (NonceStr, UniCodeNonceStr); + AtAmUiStrDisplay ((UINT16 *) UniCodeNonceStr); + } else { + AtAmUiStrDisplayFix (STR_ATAMUI_SUS_NONCE_FAILED, FALSE); + DEBUG ((EFI_D_ERROR, "ATAM: Get Nonce failed, Status = %r\n", Status)); + } + AtAmUiStrDisplayFix (STR_ATAMUI_SERV_BASED_RECOV, TRUE); + AtAmUiStrSetCursor(4, 6); + AtAmUiStrDisplayFix (STR_ATAMUI_RECO_SEC_TOKEN, FALSE); + + PassType = AT_CREDENTIAL_TYPE_SRTK; + + AtAmUiStrEnableCursor (TRUE); + AtAmUiGetPassword (PasswordASCII, ATAM_SETUP_PASSWORD_LENGTH, PasswordUNICODE, 1); + AtAmUiStrEnableCursor (FALSE); + + AtAmUiStrDisplayFix (STR_ATAMUI_CHECKING_PASS, TRUE); + AtAmUiDelay (AT_AM_UI_1_SECOND); + Status = mAtAm->AtAmVerifyPassword (mAtAm, PasswordASCII, PassType, &IsAuthenticated); + DEBUG ((EFI_D_ERROR, "ATAM: IsAuthenticated %x\n", IsAuthenticated)); + + break; + + default: + DEBUG ((EFI_D_ERROR, "ATAM: Option not supported. \n")); + + break; + } + + ZeroMem (PasswordASCII, (ATAM_SETUP_PASSWORD_LENGTH + 1) * sizeof (UINT8)); + ZeroMem (PasswordUNICODE, (ATAM_SETUP_PASSWORD_LENGTH + 1) * sizeof (CHAR16)); + + NumberOfAttempts--; + + if (NumberOfAttempts && IsAuthenticated == 0) { + AtAmUiStrDisplayFix (STR_ATAMUI_RECO_TRY_AGAIN, TRUE); + AtAmUiDelay (AT_AM_UI_1_SECOND); + } + + } while (NumberOfAttempts && (IsAuthenticated == 0)); + + FreePool (TimeLeftStr); + FreePool (PasswordASCII); + FreePool (PasswordUNICODE); + FreePool (IsvString); + FreePool (UniCodeNonceStr); + + if (IsAuthenticated == 1) { + AtAmUiStrDisplayFix (STR_ATAMUI_RECO_SUCCESS, TRUE); + AtAmUiDelay (2 * AT_AM_UI_1_SECOND); + } else { + AtAmUiStrDisplayFix (STR_ATAMUI_RECO_FAILED, TRUE); + AtAmUiDelay (2 * AT_AM_UI_1_SECOND); + gRT->ResetSystem (EfiResetShutdown, EFI_SUCCESS, 0, NULL); + } + + AtAmUiDelay (AT_AM_UI_1_SECOND); + AtAmUiStrClearScreen (); + AtAmUiStrSetCursor(CCol, CRow); + + return Status; +} + +/** + Function displaing Ivs strings. + + @param[in] None + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary data structures. +**/ +EFI_STATUS +AtAmUiDisplayIsvStrings ( + VOID + ) +{ + EFI_STATUS Status; + CHAR16 *IsvIdString; + AT_BIOS_RECOVERY_CONFIG RecoveryConfig; + UINT8 *IsvString; + UINT32 IsvId; + UINT32 CRow; + UINT32 CCol; + + IsvId = 0; + + DEBUG ((EFI_D_ERROR, "ATAM: AtAmUiDisplayIsvStrings. \n")); + + IsvIdString = AllocateZeroPool (ISV_PLATFORM_ID_LENGTH * sizeof (CHAR16)); + IsvString = AllocateZeroPool ((RECOVERY_STRING_LENGTH + 1) * sizeof (UINT8)); + if (IsvIdString == NULL || IsvString == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + if (mAtAm == NULL) { + Status = gBS->LocateProtocol ( + &gEfiAtAmProtocolGuid, + NULL, + (VOID **) &mAtAm + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: ATAM Protocol failed, Status = %r\n", Status)); + } + } + + AtAmUiStrGetCursor (&CRow, &CCol); + + Status = mAtAm->AtAmGetIsvId (mAtAm, IsvString, &IsvId); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: AtAmGetIsvId command failed, Status = %r\n", Status)); + } + + RecoveryConfig.IsvPlatformId[0] = L'\0'; + Status = mAtAm->AtAmGetRecoveryConfig (mAtAm, &RecoveryConfig); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: AtAmGetRecoveryConfig command failed, Status = %r\n", Status)); + } + + if (RecoveryConfig.IsvPlatformId[0] != L'\0') { + AtAmUiStrDisplayFix (STR_ATAMUI_PLATFORM_ID, TRUE); + AtAmUiStrDisplay ((CHAR16 *) RecoveryConfig.IsvPlatformId); + } + + if (IsvId != 0) { + UnicodeValueToString (IsvIdString, 0, (UINT32) IsvId, 0); + AtAmUiStrDisplayFix (STR_ATAMUI_PROVIDER_ID, TRUE); + AtAmUiStrDisplay (IsvIdString); + } + + FreePool (IsvString); + FreePool (IsvIdString); + + return Status; +} + +/** + This GetRecoveryPassword() process the AT recovery password user input. + + @param[out] PasswordASCII Pointer to an array of ASCII user input + @param[in] MaxPasswordLength Integer value for max password length + @param[out] PasswordUNICODE Pointer to an array of UNICODE user input + @param[in] ShowPassword TRUE - password is shown, FALSE - pasword is hidden by * + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_OUT_OF_RESOURCES Do not have enough resources to allocate memory or password too long. +**/ +EFI_STATUS +AtAmUiGetPassword ( + OUT UINT8 *PasswordASCII, + IN INTN MaxPasswordLength, + OUT CHAR16 *PasswordUNICODE, + IN UINT8 ShowPassword + ) +{ + INTN StrIndex; + EFI_INPUT_KEY Key = { 0, 0 }; + CHAR16 StarChar[2] = { L' ', L'\0' }; + + DEBUG ((EFI_D_ERROR, "ATAM: AtAmUiGetRecoveryPassword \n")); + + PasswordASCII[0] = L'\0'; + PasswordUNICODE[0] = L'\0'; + + Key.UnicodeChar = 0; + Key.ScanCode = 0; + StrIndex = 0; + + DEBUG ((EFI_D_ERROR, "ATAM: Wait for Key \n")); + + AtAmUiStrEnableCursor (TRUE); + do { + Key.ScanCode = 0; + Key.UnicodeChar = 0; + AtAmUiStrGetChar (&Key); + DEBUG ((EFI_D_ERROR, "ATAM: PasswordUNICODE: %s\n", PasswordUNICODE)); + + switch (Key.UnicodeChar) { + case CHAR_NULL: + /// + /// Non-printable characters handling: do not print caps/numlock, pgup/dn, Fx, cursors etc. + /// When escape pressed, return with empty password and ask for password again + /// + if (Key.ScanCode == SCAN_ESC) { + PasswordASCII[0] = L'\0'; + PasswordUNICODE[0] = L'\0'; + StrIndex = 0; + return EFI_SUCCESS; + } + break; + + case CHAR_CARRIAGE_RETURN: + /// + /// Enter handling: when enter pressed, return with the password + /// + StrIndex = 0; + + DEBUG ((EFI_D_ERROR, "ATAM: Passphrase Entered: %s\n", PasswordUNICODE)); + return EFI_SUCCESS; + + case CHAR_BACKSPACE: + /// + /// Backspace handling + /// + if (StrIndex > 0) { + StrIndex--; + PasswordASCII[StrIndex] = L'\0'; + PasswordUNICODE[StrIndex] = L'\0'; + /// + /// Backspace printing on screen + /// + AtAmUiStrDisplay (L"\b \b"); + } + break; + + default: + /// + /// Normal (printable) characters handling + /// Do not hide password on screen for Server Token Password recovery (usrRsp=2) + /// Hide password with '*' for User Password recovery (usrRsp=1) + /// + StarChar[0] = (ShowPassword == 1) ? Key.UnicodeChar : L'*'; + + if (StrIndex >= 0 && StrIndex < MaxPasswordLength) { + /// + /// Index in range + /// + PasswordASCII[StrIndex] = (UINT8) Key.UnicodeChar; + PasswordUNICODE[StrIndex] = Key.UnicodeChar; + StrIndex++; + /// + /// Print hidden (*) or unhidden password character + /// + AtAmUiStrDisplay (StarChar); + } else if (StrIndex < 0) { + /// + /// Index out of range: StrIndex < 0 - should never go here + /// + AtAmUiStrEnableCursor (FALSE); + StrIndex = 0; + } else { + /// + /// Index out of range: StrIndex >= ATAM_SETUP_PASSWORD_LENGTH - max password length (49 chars) exceeded, + /// only backspace, enter or escape will be accepted + /// + DEBUG ((EFI_D_ERROR, "ATAM: Password Length Exceeded\n")); + } + break; + } + + } while (1); + + AtAmUiStrEnableCursor (FALSE); + + return EFI_TIMEOUT; +} + +/** + Function displaing Ivs strings. + + @param[in] None + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary data structures. +**/ +EFI_STATUS +AtAmUiTheftNotification ( + VOID + ) +{ + EFI_STATUS Status; + AT_STATE_INFO StateInfo; + UINT32 TimerLeft; + UINT32 TimerInterval; + UINT8 *IsvString; + UINT32 IsvId; + CHAR16 *TimeLeftStr; + UINT8 PbaFailedExceeded; + UINT16 PbaFailedAttempts; + UINT16 PbaFailedThreshold; + + DEBUG ((EFI_D_ERROR, "ATAM: AtAmUiTheftNotification\n")); + + Status = EFI_SUCCESS; + PbaFailedExceeded = FALSE; + + Status = gBS->LocateProtocol ( + &gEfiAtAmProtocolGuid, + NULL, + (VOID **) &mAtAm + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: ATAM failed = %r\n", Status)); + return Status; + } + + Status = mAtAm->AtAmGetPbaCounter(&PbaFailedExceeded, &PbaFailedAttempts, &PbaFailedThreshold); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: AtAmGetIsvId = %r\n", Status)); + return Status; + } + + if (PbaFailedThreshold >= PbaFailedAttempts) { + return EFI_SUCCESS; + } else { + + IsvString = AllocateZeroPool ((RECOVERY_STRING_LENGTH + 1) * sizeof (UINT8)); + TimeLeftStr = AllocateZeroPool ((ATAM_TIMER_STRING_LENGTH + 1) * sizeof (CHAR16)); + + if (IsvString == NULL || TimeLeftStr == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + AtAmUiStrClearScreen (); + + AtAmUiDisplayIsvStrings (); + + AtAmUiStrEnableCursor (FALSE); + + AtAmUiStrSetCursor(4, 20); + Status = mAtAm->AtAmGetIsvId (mAtAm, IsvString, &IsvId); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "ATAM: AtAmGetIsvId, Status = %r\n", Status)); + } + + AtAmUiStrDisplay ((CHAR16 *) IsvString); + + mAtAm->AtAmGetAtStateInfo (mAtAm, &StateInfo); + AtAmUiStrDisplayFix (STR_ATAMUI_LOCK_DUE_TO, TRUE); + switch (StateInfo.LastTheftTrigger) { + case 1: + AtAmUiStrDisplayFix (STR_ATAMUI_LOCK_TIME, FALSE); + break; + + case 2: + AtAmUiStrDisplayFix (STR_ATAMUI_LOCK_STOLEN, FALSE); + break; + + case 3: + AtAmUiStrDisplayFix (STR_ATAMUI_LOCK_THRESHOLD, FALSE); + break; + + case 4: + AtAmUiStrDisplayFix (STR_ATAMUI_LOCK_ATTACK, FALSE); + + default: + break; + } + + mAtAm->AtAmGetTimer (mAtAm, &TimerLeft, &TimerInterval); + UnicodeValueToString (TimeLeftStr, 0, TimerLeft, 0); + + AtAmUiStrDisplayFix (STR_ATAMUI_TIME_LEFT, TRUE); + AtAmUiStrDisplay ((CHAR16 *) TimeLeftStr); + AtAmUiStrDisplayFix (STR_ATAMUI_TIME_LEFT_SEC,FALSE); + + AtAmUiDelay ((PbaFailedAttempts - PbaFailedThreshold) * 10 * AT_AM_UI_1_SECOND); + + AtAmUiStrClearScreen (); + + return Status; + } +} + diff --git a/Board/EM/MeWrapper/AtAmUi/AtAmUi.cif b/Board/EM/MeWrapper/AtAmUi/AtAmUi.cif new file mode 100644 index 0000000..f59551d --- /dev/null +++ b/Board/EM/MeWrapper/AtAmUi/AtAmUi.cif @@ -0,0 +1,14 @@ +<component> + name = "AtAmUi" + category = ModulePart + LocalRoot = "Board\EM\MeWrapper\AtAmUi\" + RefName = "AtAmUi" +[files] +"AtAmUi.dxs" +"AtAmUi.mak" +"AtAmUi.sdl" +"AtAmUi.c" +"AtAmUi.h" +"AtAmUiString.c" +"AtAmUiString.h" +<endComponent> diff --git a/Board/EM/MeWrapper/AtAmUi/AtAmUi.dxs b/Board/EM/MeWrapper/AtAmUi/AtAmUi.dxs new file mode 100644 index 0000000..7a69567 --- /dev/null +++ b/Board/EM/MeWrapper/AtAmUi/AtAmUi.dxs @@ -0,0 +1,42 @@ +/** @file + Dependency expression file for AtAmUi Invocation Driver. + +@copyright + Copyright (c) 2012 Intel Corporation. All rights reserved + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation. + + This file contains an 'Intel Peripheral Driver' and uniquely + identified as "Intel Reference Module" and is + licensed for Intel CPUs and chipsets under the terms of your + license agreement with Intel or your vendor. This file may + be modified by the user, subject to additional terms of the + license agreement + +**/ + + +#include "AutoGen.h" +#include "DxeDepex.h" + +#if defined (BUILD_WITH_GLUELIB) || defined (BUILD_WITH_EDKII_GLUE_LIB) +#include "EfiDepex.h" +#include EFI_PROTOCOL_DEPENDENCY (MeBiosPayloadData) +#include EFI_PROTOCOL_DEFINITION (Heci) +#include EFI_PROTOCOL_DEFINITION (At) +#include EFI_PROTOCOL_DEFINITION (AtAm) +#include EFI_PROTOCOL_DEFINITION (AtPlatformPolicy) +#endif + +DEPENDENCY_START + EFI_AT_PROTOCOL_GUID AND + DXE_PLATFORM_AT_POLICY_GUID AND + EFI_HECI_PROTOCOL_GUID AND + ME_BIOS_PAYLOAD_DATA_PROTOCOL_GUID AND + EFI_ATAM_PROTOCOL_GUID +DEPENDENCY_END diff --git a/Board/EM/MeWrapper/AtAmUi/AtAmUi.h b/Board/EM/MeWrapper/AtAmUi/AtAmUi.h new file mode 100644 index 0000000..04e356f --- /dev/null +++ b/Board/EM/MeWrapper/AtAmUi/AtAmUi.h @@ -0,0 +1,150 @@ +/** @file + Header file. + +@copyright + Copyright (c) 2013 Intel Corporation. All rights reserved + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation. + + This file contains a 'Sample Driver' and is licensed as such + under the terms of your license agreement with Intel or your + vendor. This file may be modified by the user, subject to + the additional terms of the license agreement +**/ +#ifndef _ATAMUI_H_ +#define _ATAMUI_H_ + +#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000) +#include "EdkIIGlueDxe.h" +#include "AtAmUiString.h" +#include "AtAm.h" +#include "AtHi.h" +#include "AtAmHelper.h" +#endif + +#include EFI_PROTOCOL_CONSUMER (AtAm) +#include EFI_PROTOCOL_CONSUMER (AtPlatformPolicy) + +/// +/// Intel ME Alert AT Handler Event GUID +/// The event is used to execute AtAmUiCallback () when the system is ready to launch ATAM UI +/// The event is signaled after consoles are ready in BDS phase. +/// +#define ME_ALERT_AT_HANDLER_GUID \ + { \ + 0xb441df87, 0x8d94, 0x4811, 0x85, 0xf7, 0xf, 0x9a, 0x7b, 0xf8, 0x9d, 0x2a \ + } + +#define ATAMUI_SUSPEND_ATTEMPTS 3 + +/** + ATAM UI callback. + + @param[in] Event The event registered + @param[in] Context Event context. Not used in this event handler. + + @retval None +**/ +VOID +EFIAPI +AtAmUiCallback ( + IN EFI_EVENT Event, + IN VOID *Context + ) +; + +/** + Function handling entering suspend mode. + + @param[in] None + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary data structures. +**/ +EFI_STATUS +AtAmUiTheftNotification ( + VOID + ) +; + +/** + Function handling displaing theft notification. + + @param[in] None + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary data structures. +**/ +EFI_STATUS +AtAmUiEnterSuspendState ( + VOID + ) +; + +/** + Function handling exiting suspend mode. + + @param[in] None + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary data structures. +**/ +EFI_STATUS +AtAmUiExitSuspendState ( + VOID + ) +; + +/** + Function handling recovery proccess. + + @param[in] None + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary data structures. +**/ +EFI_STATUS +AtAmUiRecovery ( + VOID + ) +; + +/** + Function displaing Ivs strings. + + @param[in] None + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary data structures. +**/ +EFI_STATUS +AtAmUiDisplayIsvStrings ( + VOID + ) +; + +/** + This GetRecoveryPassword() process the AT recovery password user input. + + @param[out] PasswordASCII Pointer to an array of ASCII user input + @param[in] MaxPasswordLength Integer value for max password length + @param[out] PasswordUNICODE Pointer to an array of UNICODE user input + @param[in] ShowPassword TRUE - password is shown, FALSE - pasword is hidden by * + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_OUT_OF_RESOURCES Do not have enough resources to allocate memory or password too long. +**/ +EFI_STATUS +AtAmUiGetPassword ( + OUT UINT8 *PasswordASCII, + IN INTN MaxPasswordLength, + OUT CHAR16 *PasswordUNICODE, + IN UINT8 ShowPassword + ) +; +#endif diff --git a/Board/EM/MeWrapper/AtAmUi/AtAmUi.mak b/Board/EM/MeWrapper/AtAmUi/AtAmUi.mak new file mode 100644 index 0000000..958ee72 --- /dev/null +++ b/Board/EM/MeWrapper/AtAmUi/AtAmUi.mak @@ -0,0 +1,148 @@ +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2010, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* +#********************************************************************** +# +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/ME/MeWrapper/ATAMUI/AtAmUi.mak 1 8/29/12 3:02a Klzhan $ +# +# $Revision: 1 $ +# +# $Date: 8/29/12 3:02a $ +# +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/ME/MeWrapper/ATAMUI/AtAmUi.mak $ +# +# 1 8/29/12 3:02a Klzhan +# [TAG] EIPNone +# [Category] Spec Update +# [Severity] Important +# [Description] Support AT5 +# [Files] AtAmUi.cif +# AtAmUi.dxs +# AtAmUi.mak +# AtAmUi.sdl +# AtAmUi.c +# AtAmUi.h +# AtAmUiString.c +# AtAmUiString.h +# +# 2 2/23/12 8:58a Klzhan +# Support New EDK +# +# 1 2/08/12 1:08a Klzhan +# Initial Check in +# +# 2 9/15/11 2:12a Klzhan +# Remove AMI Lib. +# +# 1 2/25/11 1:43a Klzhan +# Initial Check-in +# +# 1 12/03/10 5:10a Klzhan +# Initial Check-in. +# +# +#********************************************************************** +# +#<AMI_FHDR_START> +#---------------------------------------------------------------------------- +# +# Name: AmtWrapperDxe.mak +# +# Description: Makfile for Amt Wrapper Dxe module +# +#---------------------------------------------------------------------------- +#<AMI_FHDR_END> +EDK : AtAmUi + +AtAmUi : $(BUILD_DIR)\AtAmUi.mak AtAmUiBin + +$(BUILD_DIR)\AtAmUi.mak : $(AtAmUi_DIR)\AtAmUi.mak $(BUILD_RULES) + $(CIF2MAK) $(AtAmUi_DIR)\AtAmUi.cif $(CIF2MAK_DEFAULTS) + +AtAmUi_INCLUDES=\ + $(EDK_INCLUDES)\ + $(MISCFRAMEWORK_INCLUDES)\ + $(ME_INCLUDES)\ + $(INTEL_MCH_INCLUDES)\ + $(INTEL_PCH_INCLUDES)\ + $(IndustryStandard_INCLUDES)\ + $(EdkIIGlueLib_INCLUDES)\ + /IInclude\ + $(NB_INCLUDES)\ + /I$(AtAmDxe_DIR)\ + /I$(AtDxeLib_DIR)\ + +AtAmUi_LIBS=\ + $(EFISCRIPTLIB)\ + $(EFIDRIVERLIB)\ + $(EFICOMMONLIB)\ + $(PRINTLIB)\ + $(EDKFRAMEWORKPROTOCOLLIB)\ + $(EFIGUIDLIB)\ + $(AmtProtocolLib_LIB)\ + $(AmtLibDxe_LIB)\ + $(MeLibDxe_LIB)\ + $(AmtGuidLib_LIB)\ + $(EdkIIGlueDxeReportStatusCodeLib_LIB)\ + $(EdkIIGlueDxeDebugLibReportStatusCode_LIB)\ + $(EdkIIGlueBaseLib_LIB)\ +!IF "$(x64_BUILD)"=="1" + $(EdkIIGlueBaseLibX64_LIB)\ +!ELSE + $(EdkIIGlueBaseLibIA32_LIB)\ +!ENDIF + $(EdkIIGlueDxeServicesTableLib_LIB)\ + $(EdkIIGlueBasePrintLib_LIB) \ + $(AtDxeLib_LIB)\ + +AtAmUi_DEFINES = $(MY_DEFINES)\ + /D"__EDKII_GLUE_MODULE_ENTRY_POINT__=AtAmUiEntryPoint"\ + /D __EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__ \ + /D __EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__ \ + /D __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\ + /D __EDKII_GLUE_BASE_PCI_LIB_PCI_EXPRESS__ \ + /D __EDKII_GLUE_BASE_LIB__ \ + /D __EDKII_GLUE_BASE_MEMORY_LIB__ \ + /D __EDKII_GLUE_UEFI_DEVICE_PATH_LIB__ \ + /D __EDKII_GLUE_UEFI_LIB__\ + /D __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ \ + + +AtAmUiBin : $(AtAmUi_LIBS) + $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\ + /f $(BUILD_DIR)\AtAmUi.mak all\ + GUID=D2BC3092-92BB-4B21-A26B-CE6f7C3E9857\ + "MY_INCLUDES=$(AtAmUi_INCLUDES)" \ + "MY_DEFINES=$(AtAmUi_DEFINES)"\ + ENTRY_POINT=AtAmUiEntryPoint\ + DEPEX1=$(AtAmUi_DIR)\AtAmUi.dxs\ + DEPEX1_TYPE=EFI_SECTION_DXE_DEPEX\ + TYPE=BS_DRIVER\ + COMPRESS=1 + +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2010, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* diff --git a/Board/EM/MeWrapper/AtAmUi/AtAmUi.sdl b/Board/EM/MeWrapper/AtAmUi/AtAmUi.sdl new file mode 100644 index 0000000..ce0ff64 --- /dev/null +++ b/Board/EM/MeWrapper/AtAmUi/AtAmUi.sdl @@ -0,0 +1,27 @@ +TOKEN + Name = "AtAMUI_SUPPORT" + Value = "1" + Help = "Main switch to enable TdtWrapper support in Project" + TokenType = Boolean + TargetMAK = Yes + TargetH = Yes + Master = Yes + Token = "AT_SUPPORT" "=" "1" +End + + +PATH + Name = "AtAmUi_DIR" +End + +MODULE + Help = "Includes TdtWrapper.mak to Project" + File = "AtAmUi.mak" +End + +ELINK + Name = "$(BUILD_DIR)\AtAmUi.ffs" + Parent = "FV_MAIN" + InvokeOrder = AfterParent +End + diff --git a/Board/EM/MeWrapper/AtAmUi/AtAmUiString.c b/Board/EM/MeWrapper/AtAmUi/AtAmUiString.c new file mode 100644 index 0000000..021844b --- /dev/null +++ b/Board/EM/MeWrapper/AtAmUi/AtAmUiString.c @@ -0,0 +1,242 @@ +/** @file + This file contines function used for handling strings. + +@copyright + Copyright (c) 2012 - 2013 Intel Corporation. All rights reserved + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation. + + This file contains a 'Sample Driver' and is licensed as such + under the terms of your license agreement with Intel or your + vendor. This file may be modified by the user, subject to + the additional terms of the license agreement +**/ + +#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000) +#include "EdkIIGlueDxe.h" +#include "AtAmUiString.h" +#endif + +AT_AM_UI_STRING AtAmUiUSStringIDTab[] = { + {STR_ATAMUI_LOCKED_TEXT, 4, 20, L"This device has been locked and may have been lost.\r\n If found, Please use the following information to return the device\r\n "}, + {STR_ATAMUI_PLATFORM_ID, 4, 23, L"Platform ID: "}, + {STR_ATAMUI_PROVIDER_ID, 4, 24, L"Intel(R) Anti-Theft Technology service provider Id: "}, + {STR_ATAMUI_LOCK_DUE_TO, 4, 2, L"This computer has been disabled using Intel(R) Anti-Theft Technology due to: "}, + {STR_ATAMUI_SELECT_PASS, 4, 5, L"Please select one of the following for platform recovery:\r\n 1 - Passphrase\r\n 2 - Server Recovery Token"}, + {STR_ATAMUI_TIME_LEFT, 4, 4, L"Time Left to enter Passphrase: "}, + {STR_ATAMUI_USER_PASS, 4, 5, L"System Recovery"}, + {STR_ATAMUI_RECO_ENTER_PASS, 4, 6, L"Enter Passphrase: "}, + {STR_ATAMUI_SERV_BASED_RECOV, 4, 6, L"Server Based Recovery"}, + {STR_ATAMUI_INVALID_SELECT, 4, 10, L"Invalid Selection, Press 1 or 2 "}, + {STR_ATAMUI_LOCK_TIME, 4, 0, L"Disable Timer expired"}, + {STR_ATAMUI_LOCK_STOLEN, 4, 0, L"Stolen Message received"}, + {STR_ATAMUI_LOCK_THRESHOLD, 4, 0, L"Logon Threshold exceeded"}, + {STR_ATAMUI_LOCK_ATTACK, 4, 0, L"Platform Attack detected"}, + {STR_ATAMUI_CHECKING_PASS, 4, 8, L"Checking Recovery Password..."}, + {STR_ATAMUI_RECO_TRY_AGAIN, 4, 10, L"Recovery Failed. Please try again ..."}, + {STR_ATAMUI_RECO_FAILED, 4, 11, L"Intel(R) Anti-Theft Technology Recovery Failed.\r\n System will shutdown..."}, + {STR_ATAMUI_RECO_SUCCESS, 4, 11, L"Intel(R) Anti-Theft Technology Recovery Successful.\r\n System Boot Continue ....."}, + {STR_ATAMUI_SUS_ENTER_INFO, 4, 1, L"User Has Requested To Enter Intel(R) Anti-Theft Technology Suspend Mode....."}, + {STR_ATAMUI_RES_REFER, 4, 5, L"Refer the following Platform Resume ID to IT: "}, + {STR_ATAMUI_RECO_REFER, 4, 5, L"Refer the following Platform Recovery ID to IT: "}, + {STR_ATAMUI_SUS_REFER, 4, 5, L"Refer the following Platform Suspend ID to IT: "}, + {STR_ATAMUI_SUS_ENTER_TOKEN, 4, 4, L"Enter Suspend Token: "}, + {STR_ATAMUI_SUS_ATTEMPT_EXC, 4, 9, L"Exceeded Max Attempts - Exiting .... "}, + {STR_ATAMUI_SUS_ENTER_SUCCESS,4, 5, L"Successfully Put Platform in Suspended Mode"}, + {STR_ATAMUI_SUS_ENTER_FAILED, 4, 5, L"Failed to Put Platform into Suspended Mode"}, + {STR_ATAMUI_SUS_AUTH_FAILED, 4, 5, L"Failed to Authenticate "}, + {STR_ATAMUI_SUS_EXIT_QUESTION,4, 1, L"Intel(R) Anti-Theft Technology in Suspended State: Exit? (y/n)?"}, + {STR_ATAMUI_SUS_EXIT_INFO, 4, 2, L"Exit Intel(R) Anti-Theft Technology Suspend Mode....."}, + {STR_ATAMUI_SUS_EXIT_SUCCESS, 4, 7, L"Successfully Exited Suspend Mode"}, + {STR_ATAMUI_SUS_STAY, 4, 7, L"Stay in Suspend Mode...."}, + {STR_ATAMUI_SUS_NONCE_FAILED, 0, 0, L"NONCE unknown"}, + {STR_ATAMUI_TIME_LEFT_SEC, 0, 0, L" seconds "}, + {STR_ATAMUI_SELECT_OPTION, 4, 9, L"Select one of the above options to proceed ..."}, + {STR_ATAMUI_CHECKING_AUTHENT, 4, 6, L"Checking Authentication .."}, + {STR_ATAMUI_RECO_SEC_TOKEN, 4, 6, L"Server Recovery Token: "} +}; + +UINTN AtAmUiUSStringIDTabEntries = sizeof (AtAmUiUSStringIDTab) / sizeof (AT_AM_UI_STRING); + +/** + This function gets character inputted. + + @param[out] Key Pointer to buffer for keystroke. + + @retval EFI_SUCCESS The function completed successfully. +**/ +EFI_STATUS +AtAmUiStrGetChar ( + OUT EFI_INPUT_KEY *Key + ) +{ + EFI_STATUS Status; + UINTN Delay = 300000; + Status = EFI_SUCCESS; + + Key->UnicodeChar = L'\0'; + Key->ScanCode = 0; + while (Delay) { + Status = gST->ConIn->ReadKeyStroke (gST->ConIn, Key); + if (!(EFI_ERROR (Status))) { + break; + } + Delay --; + } + + return Status; +} + +/** + This routine displays the string out to the screen based on defined strings. + It uses X and Y to calculate the start location of string where it will be displayed. Function + uses string ID to indicate which strings are going to be shown by AtAmUiDisplay(). There will + be UseXY flag to indicate if there will be used coordinates from Strings library or not. If + not, the cursor will be moved behind last printed sign. It will be used to print e.g. '*' sign + during password entering. In graphic mode it is overridden by requirement. In graphic mode, X + and Y can be calculated the start location of string. + + @param[in] StringID Unique string ID crated as enum type of AT_AM_UI_STRING_ID + @param[in] UseXY Set the current cursor position for the displayed string if it is TRUE + FALSE - don't use coordinates from String library. Cursor is moved behind + last printed sign. + TRUE - Use coordinates from String library. + + @retval EFI_SUCCESS The function completed successfully. +**/ +EFI_STATUS +AtAmUiStrDisplayFix ( + IN UINT32 StringID, + IN BOOLEAN UseXY + ) +{ + EFI_STATUS Status; + UINTN i; + + for (i = 0; i < AtAmUiUSStringIDTabEntries; i++) { + if (AtAmUiUSStringIDTab[i].StrID == StringID) { + if (UseXY) { + Status = AtAmUiStrSetCursor (AtAmUiUSStringIDTab[i].X, AtAmUiUSStringIDTab[i].Y); + } + + Status = AtAmUiStrDisplay (AtAmUiUSStringIDTab[i].String); + return Status; + } + } + + return EFI_NOT_FOUND; +} + +/** + This routine displays the string out to the screen. + For multi-language support, a language table is expected to be selected by customization here. For example, + the default language table is US-English in AtAmUiUSStringTab[], a second language table is created by + customization in AtAmUiSECStringTab[]. + + @param[in] String The NULL-terminated Unicode string to be displayed on the output device(s) + + @retval EFI_SUCCESS The function completed successfully. +**/ +EFI_STATUS +AtAmUiStrDisplay ( + IN CHAR16 *String + ) +{ + + return gST->ConOut->OutputString (gST->ConOut, String); +} + +/** + This routine clears the screen. + In graphic mode it is overridden by requirement. + + @retval EFI_SUCCESS The function completed successfully. +**/ +EFI_STATUS +AtAmUiStrClearScreen ( + VOID + ) +{ + + return gST->ConOut->ClearScreen (gST->ConOut); +} + +/** + In text mode it is used to set the place of cursor row and cursor column. + In graphic mode it is overridden by requirement. + + @param[in] CCol The column position to set the cursor to + @param[in] CRow The row position to set the cursor to + + @retval EFI_SUCCESS The function completed successfully. +**/ +EFI_STATUS +AtAmUiStrSetCursor ( + IN UINT32 CCol, + IN UINT32 CRow + ) +{ + + return gST->ConOut->SetCursorPosition (gST->ConOut, CCol, CRow); +} + +/** + This function enables or disables cursor. + In graphic mode it is overridden by requirement. + + @param[in] Enabled If TRUE, the cursor is set to be visible. If FALSE, the cursor is set to be invisible. + + @retval EFI_SUCCESS The function completed successfully. +**/ +EFI_STATUS +AtAmUiStrEnableCursor ( + IN BOOLEAN Enabled + ) +{ + + return gST->ConOut->EnableCursor (gST->ConOut, Enabled); +} + +/** + In text mode it returns the place of cursor row and cursor column. + In graphic mode it is overridden by requirement. + + @param[out] CRow The pointer to return current cursor row + @param[out] CCol The pointer to return current cursor column + + @retval EFI_SUCCESS The function completed successfully. +**/ +EFI_STATUS +AtAmUiStrGetCursor ( + OUT UINT32 *CRow, + OUT UINT32 *CCol + ) +{ + *CRow = gST->ConOut->Mode->CursorRow; + *CCol = gST->ConOut->Mode->CursorColumn; + + return EFI_SUCCESS; +} + +/** + Function handling delay code. + In graphic mode it is overridden by requirement. + + @param[in] delay The number of microseconds to stall execution. + + @retval EFI_SUCCESS The function completed successfully. +**/ +EFI_STATUS +AtAmUiDelay ( + IN UINT32 delay + ) +{ + + return gBS->Stall (delay);; +} + diff --git a/Board/EM/MeWrapper/AtAmUi/AtAmUiString.h b/Board/EM/MeWrapper/AtAmUi/AtAmUiString.h new file mode 100644 index 0000000..0331127 --- /dev/null +++ b/Board/EM/MeWrapper/AtAmUi/AtAmUiString.h @@ -0,0 +1,208 @@ +/** @file + Heder file. + +@copyright + Copyright (c) 2012 Intel Corporation. All rights reserved + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation. + + This file contains a 'Sample Driver' and is licensed as such + under the terms of your license agreement with Intel or your + vendor. This file may be modified by the user, subject to + the additional terms of the license agreement +**/ + +#ifndef _ATAMUISTRING_H_ +#define _ATAMUISTRING_H_ + +typedef enum _AT_AM_UI_STRING_ID { + STR_ATAMUI_LOCKED_TEXT, + STR_ATAMUI_PLATFORM_ID, + STR_ATAMUI_PROVIDER_ID, + STR_ATAMUI_LOCK_DUE_TO, + STR_ATAMUI_SELECT_PASS, + STR_ATAMUI_TIME_LEFT, + STR_ATAMUI_USER_PASS, + STR_ATAMUI_SERV_BASED_RECOV, + STR_ATAMUI_INVALID_SELECT, + STR_ATAMUI_LOCK_TIME, + STR_ATAMUI_LOCK_STOLEN, + STR_ATAMUI_LOCK_THRESHOLD, + STR_ATAMUI_LOCK_ATTACK, + STR_ATAMUI_CHECKING_PASS, + STR_ATAMUI_RECO_TRY_AGAIN, + STR_ATAMUI_RECO_FAILED, + STR_ATAMUI_RECO_SUCCESS, + STR_ATAMUI_SUS_ENTER_INFO, + STR_ATAMUI_RES_REFER, + STR_ATAMUI_RECO_REFER, + STR_ATAMUI_SUS_REFER, + STR_ATAMUI_SUS_ENTER_TOKEN, + STR_ATAMUI_SUS_ATTEMPT_EXC, + STR_ATAMUI_SUS_ENTER_SUCCESS, + STR_ATAMUI_SUS_ENTER_FAILED, + STR_ATAMUI_SUS_AUTH_FAILED, + STR_ATAMUI_SUS_EXIT_QUESTION, + STR_ATAMUI_SUS_EXIT_INFO, + STR_ATAMUI_SUS_EXIT_SUCCESS, + STR_ATAMUI_SUS_STAY, + STR_ATAMUI_SUS_NONCE_FAILED, + STR_ATAMUI_RECO_ENTER_PASS, + STR_ATAMUI_TIME_LEFT_SEC, + STR_ATAMUI_SELECT_OPTION, + STR_ATAMUI_CHECKING_AUTHENT, + STR_ATAMUI_FAILED_TO_AUTHENT, + STR_ATAMUI_RECO_SEC_TOKEN, + + // + // this has to be a last element of this enum + // + STR_ATAMUI_END_OF_TAB +} AT_AM_UI_STRING_ID; + +/// +/// Strings will be kept in array. There can be created many tables with strings in various +/// languages. A language table can be selected within AtAmUiStrDisplay () to display string in +/// targeted language with the unique string ID. The same unique string ID is applied to all +/// language tables +/// +typedef struct _AT_AM_UI_STRING { + UINTN StrID; ///< Unique string ID crated as enum type AT_AM_UI_STRING_ID + UINT8 X; ///< The place of cursor row to be display + UINT8 Y; ///< The place of cursor column to be display + CHAR16 *String; ///< Pointer to the string +} AT_AM_UI_STRING; + +#define AT_AM_UI_1_SECOND 1000000 + +/** + This function gets character inputted. + + @param[out] Key Pointer to buffer for keystroke. + + @retval EFI_SUCCESS The function completed successfully. +**/ +EFI_STATUS +AtAmUiStrGetChar ( + OUT EFI_INPUT_KEY *Key + ) +; + +/** + This routine displays the string out to the screen based on defined strings. + It uses X and Y to calculate the start location of string where it will be displayed. Function + uses string ID to indicate which strings are going to be shown by AtAmUiDisplay(). There will + be UseXY flag to indicate if there will be used coordinates from Strings library or not. If + not, the cursor will be moved behind last printed sign. It will be used to print e.g. '*' sign + during password entering. In graphic mode it is overridden by requirement. In graphic mode, X + and Y can be calculated the start location of string. + + @param[in] StringID Unique string ID crated as enum type of AT_AM_UI_STRING_ID + @param[in] UseXY Set the current cursor position for the displayed string if it is TRUE + FALSE - don't use coordinates from String library. Cursor is moved behind + last printed sign. + TRUE - Use coordinates from String library. + + @retval EFI_SUCCESS The function completed successfully. +**/ +EFI_STATUS +AtAmUiStrDisplayFix ( + IN UINT32 StringID, + IN BOOLEAN UseXY + ) +; + +/** + This routine displays the string out to the screen. + For multi-language support, a language table is expected to be selected by customization here. For example, + the default language table is US-English in AtAmUiUSStringTab[], a second language table is created by + customization in AtAmUiSECStringTab[]. + + @param[in] String The NULL-terminated Unicode string to be displayed on the output device(s) + + @retval EFI_SUCCESS The function completed successfully. +**/ +EFI_STATUS +AtAmUiStrDisplay ( + IN CHAR16 *String + ) +; + +/** + This routine clears the screen. + In graphic mode it is overridden by requirement. + + @retval EFI_SUCCESS The function completed successfully. +**/ +EFI_STATUS +AtAmUiStrClearScreen ( + VOID + ) +; + +/** + In text mode it is used to set the place of cursor row and cursor column. + In graphic mode it is overridden by requirement. + + @param[in] CCol The column position to set the cursor to be displayed + @param[in] CRow The row position to set the cursor to be displayed + + @retval EFI_SUCCESS The function completed successfully. +**/ +EFI_STATUS +AtAmUiStrSetCursor ( + IN UINT32 CCol, + IN UINT32 CRow + ) +; + +/** + This function enables or disables cursor. + In graphic mode it is overridden by requirement. + + @param[in] Enabled If TRUE, the cursor is set to be visible. If FALSE, the cursor is set to be invisible. + + @retval EFI_SUCCESS The function completed successfully. +**/ +EFI_STATUS +AtAmUiStrEnableCursor ( + IN BOOLEAN Enabled + ) +; + +/** + In text mode it returns the place of cursor row and cursor column. + In graphic mode it is overridden by requirement. + + @param[out] CRow The pointer to return current cursor row + @param[out] CCol The pointer to return current cursor column + + @retval EFI_SUCCESS The function completed successfully. +**/ +EFI_STATUS +AtAmUiStrGetCursor ( + OUT UINT32 *CRow, + OUT UINT32 *CCol + ) +; + +/** + Function handling delay code. + In graphic mode it is overridden by requirement. + + @param[in] delay The number of microseconds to stall execution. + + @retval EFI_SUCCESS The function completed successfully. +**/ +EFI_STATUS +AtAmUiDelay ( + IN UINT32 delay + ) +; + +#endif |