diff options
Diffstat (limited to 'Board/EM/MeWrapper/AmtWrapper/AmtLockKBD')
7 files changed, 1006 insertions, 0 deletions
diff --git a/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtInt9.asm b/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtInt9.asm new file mode 100644 index 0000000..a40f50e --- /dev/null +++ b/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtInt9.asm @@ -0,0 +1,277 @@ + + TITLE AMTINT9.ASM -- OEM INTERRUPT IMPLEMENTATION + +;************************************************************************* +;************************************************************************* +;** ** +;** (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/AmtWrapper/AmtLockKBD/AmtInt9.asm 1 2/08/12 1:10a Klzhan $ +; +; $Date: 2/08/12 1:10a $ +; +;**************************************************************************** +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/ME/AmtWrapper/AmtLockKBD/AmtInt9.asm $ +; +; 1 2/08/12 1:10a Klzhan +; Initial Check in +; +; 2 7/13/11 4:03a Klzhan +; Fix Lock KBD can't work without SOL enable. +; +; 1 2/25/11 1:45a Klzhan +; Initial Check-in +; +; 1 12/03/10 5:11a Klzhan +; Initial Check-in. +; +; +;**************************************************************************** +;<AMI_FHDR_START> +; +; Name: AMTInt9.asm +; +; Description: Hook Int 9 for Legacy Serial Redirection. +; +;<AMI_FHDR_END> +;**************************************************************************** + +;---------------------------------------------------------------------------- +; INCLUDE FILES +;---------------------------------------------------------------------------- +include token.equ +;---------------------------------------------------------------------------- +; EQUATES & STRUCTURES +;---------------------------------------------------------------------------- +refresh_port equ 61h +kb_data_port equ 60h ; keyboard data port +kb_stat_port equ 64h ; keyboard status port +kbcCMDPort EQU 64h ; Keyboard controller command port +enKeyboardCMD EQU 0aeh ; Enable keyboard command +diKeyboardCMD EQU 0adh ; Disable keyboard command +IBFTimeoutCount EQU 0f000h ; Check keyboart input buffer count +kbcIBF EQU 00000010b; Keyboard input buffer full +;---------------------------------------------------------------------------- +; EXTERNS USED +;---------------------------------------------------------------------------- + +;---------------------------------------------------------------------------- +; CSMOEM_CSEG S E G M E N T STARTS +;---------------------------------------------------------------------------- +CSMOEM_CSEG SEGMENT PARA PUBLIC 'CODE' USE16 + ASSUME cs:CSMOEM_CSEG, ds:CSMOEM_CSEG +.386p +;---------------------------------------------------------------------------- + +OldIntHandler LABEL DWORD + IntSegSav dw 0 + IntOfsSav dw 0 + +;<AMI_PHDR_START> +;---------------------------------------------------------------------------- +; +; Procedure: AMTINT09Proc +; +; Description: +; +; Input: +; +; Output: +; +; Modified: +; +;---------------------------------------------------------------------------- +;<AMI_PHDR_END> +AMTINT09Proc PROC NEAR PUBLIC + pushf + cmp cs:dSredirInterruptPtr, 0 + jnz lock_local_keyboard + popf + jmp DWORD PTR cs:[OldIntHandler] +lock_local_keyboard: + push ds + push si + ; DS:SI = *dSredirInterruptPtr + lds si, DWORD PTR cs:dSredirInterruptPtr +; cmp WORD PTR ds:[si], 0 ; does interrutp come from redirection ? + test BYTE PTR ds:[si], 1 ; does interrutp come from redirection ? + jz not_serial_redirection_interrupt ; br not redirection interrupt + ; jmp to original Int 9 vector to service redirection interrupt + pushf + push cs + push OFFSET returnFromInt9 + push DWORD PTR cs:OldIntHandler + retf +returnFromInt9: +; mov WORD PTR ds:[si], 0 ; clear redirection interrupt flag + mov BYTE PTR ds:[si], 0 ; clear redirection interrupt flag + jmp redirection_return_to_caller +not_serial_redirection_interrupt: + ; do nothing and return to caller. + push ax + call disable_keyboard + call enable_keyboard + ; clear EOI + mov al, 20h ; end of INT code + out 20h, al ; out to INT CONTROLLER port + pop ax +redirection_return_to_caller: + pop si + pop ds + popf + retf 2 + +AMTINT09Proc ENDP +;<AMI_PHDR_START> +;---------------------------------------------------------------------------- +; Procedure: CheckKBCController +; +; Description: Check KBC controller present. +; +; Input: None. +; +; Output: None. +; +; Modified: ZF = 0 KBC controller present. +; = 1 No KBC controller. +; +; Referrals: +; +;---------------------------------------------------------------------------- +;<AMI_PHDR_END> +CheckKBCController PROC NEAR + push ax + in al, kb_stat_port + cmp al, 0ffh + pop ax + ret +CheckKBCController ENDP +;<AMI_PHDR_START> +;---------------------------------------------------------------------------- +; Procedure: enable_keyboard +; +; Description: Enables KBD interface. Also CPU interrupt will be enabled +; here. +; +; Input: None. +; +; Output: None. +; +; Modified: AL. +; +; Referrals: ib_free. +; +;---------------------------------------------------------------------------- +;<AMI_PHDR_END> + +enable_keyboard PROC NEAR PUBLIC + + call CheckKBCController + jz short Enable_keyboardExit + call ib_free ; Wait for input buffer free. + mov al, enKeyboardCMD ; CMD to enable KBD interface. + out kbcCMDPort, al ; Write command to KBC. + call ib_free ; Wait for input buffer free. +Enable_keyboardExit: ;(BUG4128+) + sti + ret + +enable_keyboard ENDP +;<AMI_PHDR_START> +;---------------------------------------------------------------------------- +; Procedure: disable_keyboard +; +; Description: Disables KBD interface and reads the data from KBC data port. +; +; Input: None. +; +; Output: AL - Data read from KBC data port. +; +; Modified: AL. +; +; Referrals: ib_free. +; +;---------------------------------------------------------------------------- +;<AMI_PHDR_END> + +disable_keyboard PROC NEAR PUBLIC + call CheckKBCController + jz short Disable_keyboardExit + call ib_free ; Wait for input buffer free. + mov al, diKeyboardCMD ; CMD to disable KBD interface. + out kbcCMDPort, al ; Write command to KBC. + call ib_free ; Wait for input buffer free. + in al, kb_data_port ; Read the data.(BUG2673+) +Disable_keyboardExit: ; + ret + +disable_keyboard ENDP +;<AMI_PHDR_START> +;---------------------------------------------------------------------------- +; Procedure: ib_free +; +; Description: This routine waits until the KBC input buffer is free. +; +; Input: None. +; +; Output: None. +; +; Modified: AL. +; +; Referrals: None. +; +; Notes: DO NOT USE STACK. This routine may be called with RET_SP +; macro. +; +;---------------------------------------------------------------------------- +;<AMI_PHDR_END> +ib_free PROC NEAR PUBLIC + push cx + mov cx, IBFTimeoutCount +IbFreeLp: + in al, kb_stat_port + call CheckKBCController + jz short IbFreeExit + out 0ebh, al + out 0ebh, al + out 0ebh, al + test al, kbcIBF + loopnz IbFreeLp +IbFreeExit: + pop cx + ret +ib_free ENDP + +;---------------------------------------------------------------------------- +LockKeyBoardSignature DB '$LKb' +dSredirInterruptPtr DD 0 +dLockKBD DD 0 +;---------------------------------------------------------------------------- +; CSMOEM_CSEG S E G M E N T ENDS +;---------------------------------------------------------------------------- +CSMOEM_CSEG ENDS +END +;**************************************************************************** +;**************************************************************************** +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone (770)-246-8600 ** +;** ** +;**************************************************************************** +;****************************************************************************
\ No newline at end of file diff --git a/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.c b/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.c new file mode 100644 index 0000000..aea8c99 --- /dev/null +++ b/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.c @@ -0,0 +1,507 @@ +//************************************************************************* +//************************************************************************* +//** ** +//** (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/AmtWrapper/AmtLockKBD/AmtLockKBD.c 4 4/30/13 3:35a Tristinchou $ +// +// $Revision: 4 $ +// +// $Date: 4/30/13 3:35a $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/ME/AmtWrapper/AmtLockKBD/AmtLockKBD.c $ +// +// 4 4/30/13 3:35a Tristinchou +// [TAG] EIP119188 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] Lock keyboard will be no function +// [Solution] Lock keyboard directly +// [Files] AmtLockKBD.c +// +// 3 12/11/12 2:40a Klzhan +// Fix exception error when Secure Boot Enabled. +// +// 2 4/24/12 12:45a Klzhan +// Update module to latest +// +// 1 2/08/12 1:10a Klzhan +// Initial Check in +// +// 4 7/24/11 10:12a Klzhan +// Remove un-used debug message. +// +// 3 7/13/11 4:03a Klzhan +// Fix Lock KBD can't work without SOL enable. +// +// 2 6/28/11 7:32a Klzhan +// Enable Legacy SreDir before getting signature. +// +// 1 2/25/11 1:45a Klzhan +// Initial Check-in +// +// 1 12/03/10 5:11a Klzhan +// Initial Check-in. +// +//********************************************************************** + +//<AMI_FHDR_START> +//--------------------------------------------------------------------------- +// Name: AMTLockKBD.c +// +// Description: AMT Lock KeyBoard Functions. +// +//--------------------------------------------------------------------------- +//<AMI_FHDR_END> +#include <token.h> +#include <EFI.h> +#include <DXE.h> +#include <AmiDxeLib.h> +#include <..\Include\Protocol\ConsoleControl.h> +#if (defined(CSM_SUPPORT) && (CSM_SUPPORT != 0)) +#include "..\core\em\csm\csm.h" +#endif +#include "..\Include\Protocol\DevicePath.h" +#include "..\Include\Protocol\DataHub.h" +#include "..\Include\Protocol\SimpleTextIn.h" +#include "..\Include\Protocol\SimpleTextInEx.h" +#include <ReferenceCode\ME\Protocol\AlertStandardFormat\AlertStandardFormat.h> +#include "Protocol\LegacySredir.h" +#include <Protocol\SmmPowerButtonDispatch.h> + +//============================================================================ +// Local defines for transaction types +//============================================================================ +#define EFI_SIGNATURE_16(A,B) ((A) | ((B)<<8)) +#define EFI_SIGNATURE_32(A,B,C,D) \ + (EFI_SIGNATURE_16((A),(B)) | (EFI_SIGNATURE_16((C),(D)) << 16)) + +#define AMT_INT9_SIGNATURE EFI_SIGNATURE_32 ('$', 'L', 'K', 'b') +#define SREDIR_FLAG_SIGNATURE EFI_SIGNATURE_32 ('$', 'S', 'r', 'F') + +#define BDS_ALL_DRIVERS_CONNECTED_PROTOCOL_GUID \ + { 0xdbc9fd21, 0xfad8, 0x45b0, 0x9e, 0x78, 0x27, 0x15, 0x88, 0x67, 0xcc, 0x93 } +EFI_GUID gBdsAllDriversConnectedProtocolGuid = \ + BDS_ALL_DRIVERS_CONNECTED_PROTOCOL_GUID; +EFI_GUID gEfiSimpleTextInExProtocolGuid = \ + EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID; +EFI_GUID gEfiSimpleTextInProtocolGuid = EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID; +EFI_GUID ConInStartedProtocolGuid = CONSOLE_IN_DEVICES_STARTED_PROTOCOL_GUID; + +#define BDS_CONNECT_DRIVERS_PROTOCOL_GUID \ + { 0x3aa83745, 0x9454, 0x4f7a, 0xa7, 0xc0, 0x90, 0xdb, 0xd0, 0x2f, 0xab, 0x8e } +EFI_GUID gEfiSmmPowerButtonDispatchProtocolGuid = \ + EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL_GUID; +EFI_GUID gBdsConnectDriversProtocolGuid = \ + BDS_CONNECT_DRIVERS_PROTOCOL_GUID; +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: ClearPowerButtonSmi +// +// Description: This routine disables Power Button SMI if Lock Power Button +// bit of Boot Option BitMask is set. +// +// Input: None. +// +// Output: None. +// +// Notes: None. +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID +ClearPowerButtonSmi (VOID) +{ + UINT32 dPwrMgValue; + + // Read PM_1 Status/Enable Register + dPwrMgValue = IoRead32(PM_BASE_ADDRESS); + dPwrMgValue |= BIT08; // clear Power Button Status + dPwrMgValue &= ~BIT24; // clear Power Button Enable + IoWrite32 ( PM_BASE_ADDRESS, dPwrMgValue ); +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: DisablePowerButtonSmiEvent +// +// Description: This routine disables Power Button SMI if Lock Power Button +// bit of Boot Option BitMask is set. +// +// Input: EFI_EVENT - Event +// VOID* - Context +// +// Output: EFI_STATUS +// +// Notes: None. +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS +DisablePowerButtonSmiEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL *PowerButton; + + Status = pBS->LocateProtocol ( &gEfiSmmPowerButtonDispatchProtocolGuid, \ + NULL, \ + &PowerButton ); + if(EFI_ERROR( Status )) return Status; + + ClearPowerButtonSmi(); + + pBS->CloseEvent(Event); + + return EFI_SUCCESS; +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: ASFRegisterPowerButtonCallBack +// +// Description: This routine register a Protocol Callback for Lock Power Button +// if Lock Power Button bit of Boot Option BitMask is set. +// +// Input: None. +// +// Output: None. +// +// Notes: None. +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID +ASFRegisterPowerButtonCallBack (VOID) +{ + EFI_STATUS Status = EFI_SUCCESS; + EFI_EVENT EvtASFSmmPwrBtn, EvtASFBdsConnectDrivers; + VOID *RgnASFSmmPwrBtn, *RgnASFBdsConnectDrivers; + + // Clear Power Button Status before Power Button SMI is registered. + Status = RegisterProtocolCallback ( \ + &gEfiSmmPowerButtonDispatchProtocolGuid, \ + DisablePowerButtonSmiEvent, \ + NULL, \ + &EvtASFSmmPwrBtn, \ + &RgnASFSmmPwrBtn ); + + DisablePowerButtonSmiEvent ( EvtASFSmmPwrBtn, NULL ); + + Status = RegisterProtocolCallback ( \ + &gBdsConnectDriversProtocolGuid, \ + DisablePowerButtonSmiEvent, \ + NULL, \ + &EvtASFBdsConnectDrivers, \ + &RgnASFBdsConnectDrivers ); + return ; +} +#if (defined(CSM_SUPPORT) && (CSM_SUPPORT != 0)) + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: GetLegacyDriverSignaturePtr +// +// Description: Aux roution to find the Signature in Legacy Reagon +// +// Input: +// +// Output: +// +// Notes: +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT32 +GetLegacyDriverSignaturePtr ( + IN UINT32 dStartAddress, + IN UINT32 dSize, + IN UINT32 dSignature +) +{ + UINT8 *pStartAddr = (UINT8 *)(UINTN)dStartAddress; + + for ( ;(UINTN)pStartAddr < (UINTN)(dStartAddress + dSize); pStartAddr++ ) + if ( *(UINT32 *)pStartAddr == dSignature ) return ((UINT32)pStartAddr); + return FALSE; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: LegacyBiosLockLocalKeyboard +// +// Description: Sub-roution lock keyboard. +// +// Input: +// +// Output: +// +// Notes: +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID +LegacyBiosLockLocalKeyboard (VOID) +{ + + EFI_STATUS Status; + UINT32 dAMTInt9Ptr = 0, dSRedirFlagPtr = 0; + EFI_LEGACY_BIOS_PROTOCOL *LegacyBios; + BIOS_INFO *Private; + + // Get AMT Int 9h signature pointer. + dAMTInt9Ptr = GetLegacyDriverSignaturePtr ( \ + 0xe0000, 0x20000, AMT_INT9_SIGNATURE ); + // Get Legacy Serial Redirection Flag signature pointer. + dSRedirFlagPtr = GetLegacyDriverSignaturePtr ( \ + 0x90000, 0x10000, SREDIR_FLAG_SIGNATURE ); + if ( !dAMTInt9Ptr ) return ; + // Locate Legacy Bios Protocol for lock/unlock shadow ram. + Status = pBS->LocateProtocol ( &gEfiLegacyBiosProtocolGuid, \ + NULL, \ + &LegacyBios ); + if ( EFI_ERROR( Status ) ) return; + Private = (BIOS_INFO *) LegacyBios; + // Unlock Shadow ram. + Private->iRegion->UnLock ( Private->iRegion, 0xE0000, 0x20000, NULL ); + // Update Legacy Serial Redirection Flag pointer to AMT Int 9h. + if(!dSRedirFlagPtr) + dSRedirFlagPtr = (dAMTInt9Ptr + 4); + *(UINT32*)(dAMTInt9Ptr + 4) = (UINT32)(((UINTN)dSRedirFlagPtr & 0xFFFF) + \ + (((UINTN)dSRedirFlagPtr & 0xF0000) << 12) + \ + sizeof ( SREDIR_FLAG_SIGNATURE )); + // Lock Shadow ram. + Private->iRegion->Lock ( Private->iRegion, 0xE0000, 0x20000, NULL ); + +} +#endif +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: EventAllConsoleDevicesStarted +// +// Description: Sub-Roution to check if need disable keyboard or not +// from IntelAMT extersion ASF Boot Option Message. +// +// Input: +// +// Output: +// +// Notes: +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID +EventAllConsoleDevicesStarted +( + IN EFI_EVENT Event, + IN VOID *Context +) +{ + EFI_STATUS Status; + EFI_HANDLE *SimpleTextInHandle; + UINTN HandleNum, Index; + EFI_DEVICE_PATH_PROTOCOL *DevicePathNode; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTextIn; + EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *SimpleTextInEx; + PCI_DEVICE_PATH *PciDevicePath; + EFI_GUID gEfiAlertStandardFormatProtocolGuid = EFI_ALERT_STANDARD_FORMAT_PROTOCOL_GUID; + EFI_ALERT_STANDARD_FORMAT_PROTOCOL *Asf; + EFI_ASF_BOOT_OPTIONS *mAsfBootOptions; + + Status = pBS->LocateProtocol ( + &gEfiAlertStandardFormatProtocolGuid, + NULL, + &Asf + ); + + if (EFI_ERROR (Status)) { + return; + } + + Status = Asf->GetBootOptions (Asf, &mAsfBootOptions); + // If not Lock keyboard, return !! + if(!((mAsfBootOptions->BootOptions) & 0x20)) + return; + + // 2. Uninstall all the console spliter drivers except SOL. + // Locate Simple Text Input Protocol Handle Buffer. + Status = pBS->LocateHandleBuffer ( ByProtocol, \ + &gEfiSimpleTextInProtocolGuid, \ + NULL, \ + &HandleNum, \ + &SimpleTextInHandle ); + if ( EFI_ERROR ( Status ) ) return ; + + // Search USB keyboard and Generic PS2 Keyboard Device Path. + for ( Index = 0; Index < HandleNum; Index++ ) { + + // Locate Simple Text Input Protocol. + Status = pBS->HandleProtocol ( SimpleTextInHandle[Index], \ + &gEfiDevicePathProtocolGuid, \ + (VOID *)&DevicePath ); + if ( EFI_ERROR ( Status ) ) continue; + + DevicePathNode = DevicePath; + while ( !isEndNode ( DevicePathNode ) ) { + PciDevicePath = (PCI_DEVICE_PATH *) DevicePathNode; + // Is USB Device Path or Generic SIO Device Path (SouthBridge)? + if ((( DevicePathNode->Type == MESSAGING_DEVICE_PATH ) && \ + ( DevicePathNode->SubType == MSG_USB_DP )) || \ + (( DevicePathNode->Type == HARDWARE_DEVICE_PATH ) && \ + ( DevicePathNode->SubType == HW_PCI_DP ) && \ + ( PciDevicePath->Device == 0x1f ) && \ + ( PciDevicePath->Function == 0 ))) { + + // Locate Simple Text Input Protocol. + Status = pBS->HandleProtocol ( SimpleTextInHandle[Index], \ + &gEfiSimpleTextInProtocolGuid, \ + (VOID **)&SimpleTextIn ); + if ( EFI_ERROR ( Status ) ) break; + + // Uninstall Simple Text Input Protocol for stopping keyboard. + Status = pBS->UninstallProtocolInterface ( \ + SimpleTextInHandle[Index], \ + &gEfiSimpleTextInProtocolGuid, \ + SimpleTextIn ); + if ( EFI_ERROR ( Status ) ) break; + + // Locate Simple Text Input EX Protocol. + Status = pBS->HandleProtocol ( \ + SimpleTextInHandle[Index], \ + &gEfiSimpleTextInExProtocolGuid, \ + (VOID **)&SimpleTextInEx ); + if ( EFI_ERROR ( Status ) ) break; + + // Uninstall Simple Text Input EX Protocol for stopping + // SIO keyboard. + Status = pBS->UninstallProtocolInterface ( \ + SimpleTextInHandle[Index], \ + &gEfiSimpleTextInExProtocolGuid, \ + SimpleTextInEx ); + break; + } + DevicePathNode = NEXT_NODE ( DevicePathNode ); + } + } +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: LockLegacyKBD +// +// Description: Sub-Roution to check if need disable keyboard or not +// from IntelAMT extersion ASF Boot Option Message. +// +// Input: +// +// Output: +// +// Notes: +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID +LockLegacyKBD +( + IN EFI_EVENT Event, + IN VOID *Context +) +{ + // 1. Hook Int 9h for locking local keyboard but keep the Legacy SOL + // working in CSM and Legacy OS. +#if (defined(CSM_SUPPORT) && (CSM_SUPPORT != 0)) + LegacyBiosLockLocalKeyboard (); +#endif +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: AMTLOCKKBDEntryPoint +// +// Description: Lock keyboard Entrypoint. +// +// Input: +// +// Output: +// +// Notes: +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS AMTLOCKKBDEntryPoint( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable +) +{ + EFI_STATUS Status; + EFI_EVENT ConInConnectEvt; + VOID *ConInNotifyReg; + EFI_EVENT ConInExConnectEvt; + VOID *ConInExNotifyReg; + EFI_EVENT AllDriverConnectEvt; + VOID *AllDriverExNotifyReg; + + EFI_GUID gEfiAlertStandardFormatProtocolGuid = EFI_ALERT_STANDARD_FORMAT_PROTOCOL_GUID; + EFI_ALERT_STANDARD_FORMAT_PROTOCOL *Asf; + EFI_ASF_BOOT_OPTIONS *mAsfBootOptions; + + InitAmiLib(ImageHandle, SystemTable); + Status = pBS->LocateProtocol (&gEfiAlertStandardFormatProtocolGuid, \ + NULL, &Asf ); + if (EFI_ERROR (Status)) return Status; + + Status = Asf->GetBootOptions (Asf, &mAsfBootOptions); + if (EFI_ERROR (Status)) return Status; + + // If not Lock keyboard, return !! + if (mAsfBootOptions->BootOptions & 0x20) { + + Status = RegisterProtocolCallback( + &gEfiSimpleTextInExProtocolGuid, + EventAllConsoleDevicesStarted, + NULL, + &ConInExConnectEvt, + &ConInExNotifyReg); + + Status = RegisterProtocolCallback( + &gEfiSimpleTextInProtocolGuid, + EventAllConsoleDevicesStarted, + NULL, + &ConInConnectEvt, + &ConInNotifyReg); + + Status = RegisterProtocolCallback( + &gBdsAllDriversConnectedProtocolGuid, + LockLegacyKBD, + NULL, + &AllDriverConnectEvt, + &AllDriverExNotifyReg); + + } + if (mAsfBootOptions->BootOptions & 0x2) ASFRegisterPowerButtonCallBack (); + return EFI_SUCCESS; +} +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//*************************************************************************
\ No newline at end of file diff --git a/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.cif b/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.cif new file mode 100644 index 0000000..33e5afa --- /dev/null +++ b/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.cif @@ -0,0 +1,13 @@ +<component> + name = "AmtLockKBD" + category = ModulePart + LocalRoot = "Board\EM\MeWrapper\AmtWrapper\AmtLockKBD\" + RefName = "AmtLockKBD" +[files] +"AmtLockKBD.sdl" +"AmtLockKBD.mak" +"AmtLockKBD.c" +"AmtLockKBD.h" +"AmtLockKBD.dxs" +"AmtInt9.asm" +<endComponent> diff --git a/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.dxs b/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.dxs new file mode 100644 index 0000000..87b05c8 --- /dev/null +++ b/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.dxs @@ -0,0 +1,6 @@ +#include <ReferenceCode\ME\Protocol\AlertStandardFormat\AlertStandardFormat.h> + +DEPENDENCY_START + EFI_ALERT_STANDARD_FORMAT_PROTOCOL_GUID +DEPENDENCY_END + diff --git a/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.h b/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.h new file mode 100644 index 0000000..6e23ec6 --- /dev/null +++ b/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.h @@ -0,0 +1,77 @@ +//************************************************************************* +//************************************************************************* +//** ** +//** (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/AmtWrapper/AmtLockKBD/AmtLockKBD.h 1 2/08/12 1:10a Klzhan $ +// +// $Revision: 1 $ +// +// $Date: 2/08/12 1:10a $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/ME/AmtWrapper/AmtLockKBD/AmtLockKBD.h $ +// +// 1 2/08/12 1:10a Klzhan +// Initial Check in +// +// 1 2/25/11 1:45a Klzhan +// Initial Check-in +// +// 1 12/03/10 5:11a Klzhan +// Initial Check-in. +// +//********************************************************************** + +//<AMI_FHDR_START> +//--------------------------------------------------------------------------- +// Name: AMTLockKBD.h +// +// Description: AMT Lock KeyBoard Includes. +// +//--------------------------------------------------------------------------- +//<AMI_FHDR_END> +#ifndef _AMT_INT16_H +#define _AMT_INT16_H + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include "Protocol\AmtWrapper\AmtWrapper.h" + +#include EFI_PROTOCOL_CONSUMER (AmtWrapper) +#include EFI_PROTOCOL_CONSUMER (LegacyBios) + +#define AMT_INT16_CSM_GUID \ + {0x6046e678, 0x24ef, 0x4005, 0xba, 0x39, 0xbd, 0xa1, 0x1f, 0x6d, 0x55, 0x5d} + +EFI_GUID gEfiFirmwareVolumeProtocolGuid = EFI_FIRMWARE_VOLUME_PROTOCOL_GUID; +EFI_GUID gAmtInt16CsmGuid = AMT_INT16_CSM_GUID; +EFI_GUID gLegacyBiosProtocolGuid = EFI_LEGACY_BIOS_PROTOCOL_GUID; +EFI_GUID gEfiAmtWrapperProtocolGuid = EFI_AMT_WRAPPER_PROTOCOL_GUID; +EFI_GUID gEfiEventReadyToBootGuid = EFI_EVENT_GROUP_READY_TO_BOOT; + +#endif +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//*************************************************************************
\ No newline at end of file diff --git a/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.mak b/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.mak new file mode 100644 index 0000000..0680ae3 --- /dev/null +++ b/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.mak @@ -0,0 +1,88 @@ +#************************************************************************* +#************************************************************************* +#** ** +#** (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/AmtWrapper/AmtLockKBD/AmtLockKBD.mak 1 2/08/12 1:10a Klzhan $ +# +# $Revision: 1 $ +# +# $Date: 2/08/12 1:10a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/ME/AmtWrapper/AmtLockKBD/AmtLockKBD.mak $ +# +# 1 2/08/12 1:10a Klzhan +# Initial Check in +# +# 1 2/25/11 1:45a Klzhan +# Initial Check-in +# +# 1 12/03/10 5:11a Klzhan +# Initial Check-in. +# +#********************************************************************** + +#<AMI_FHDR_START> +#--------------------------------------------------------------------------- +# Name: AMTLockKBD.mak +# +# Description: AMT Lock KeyBoard. +# +#--------------------------------------------------------------------------- +#<AMI_FHDR_END> +all : AMTLOCKKBD $(BUILD_DIR)\AmtInt9.obj + +AMT_LOCKKBD_BUILD_DIR = $(BUILD_DIR)\$(AmtLockKBD_DIR) + +#--------------------------------------------------------------------------- +# Generic AMT dependencies +#--------------------------------------------------------------------------- +$(BUILD_DIR)\AmtLockKBD.mak : $(AmtLockKBD_DIR)\AmtLockKBD.cif $(BUILD_RULES) + $(CIF2MAK) $(AmtLockKBD_DIR)\AmtLockKBD.cif $(CIF2MAK_DEFAULTS) + +$(BUILD_DIR)\AmtInt9.obj: $(AmtLockKBD_DIR)\AmtInt9.asm + $(ASM16) /c /nologo /Fo$(BUILD_DIR)\ $(AmtLockKBD_DIR)\AmtInt9.asm + +#--------------------------------------------------------------------------- + +AMT_LOCKKBD_OBJECTS = \ +$(BUILD_DIR)\$(AmtLockKBD_DIR)\AmtLockKBD.obj + +#--------------------------------------------------------------------------- +# Create ASF Verbosity DXE Component +#--------------------------------------------------------------------------- +AMTLOCKKBD: $(BUILD_DIR)\AmtLockKBD.mak AMTLOCKKBDBin + +AMTLOCKKBDBin : $(AMIDXELIB) + $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\ + /f $(BUILD_DIR)\AmtLockKBD.mak all\ + MAKEFILE=$(BUILD_DIR)\AmtLockKBD.mak \ + OBJECTS="$(AMT_LOCKKBD_OBJECTS)" \ + GUID=5507247A-846B-4f22-B55F-72B4049435EF \ + ENTRY_POINT=AMTLOCKKBDEntryPoint \ + 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 ** +#** ** +#************************************************************************* +#*************************************************************************
\ No newline at end of file diff --git a/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.sdl b/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.sdl new file mode 100644 index 0000000..ad810bd --- /dev/null +++ b/Board/EM/MeWrapper/AmtWrapper/AmtLockKBD/AmtLockKBD.sdl @@ -0,0 +1,38 @@ +TOKEN + Name = "AmtLockKBD_SUPPORT" + Value = "1" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes + Help = "Main switch to enable AmtInt16 support in Project" +End + +MODULE + Help = "Includes AmtInt16.mak to Project" + File = "AmtLockKBD.mak" +End + +PATH + Name = "AmtLockKBD_DIR" +End + +ELINK + Name = "AMTINT09Proc" + Parent = "CsmOemInterrupts" + ProcID = 09h + SrcFile = "Board\EM\MEWrapper\AmtWrapper\Dxe\AmtInt9.asm" + InvokeOrder = AfterParent +End + +ELINK + Name = "$(BUILD_DIR)\AmtInt9.obj" + Parent = "CSM_OEMINT_OBJS" + InvokeOrder = AfterParent +End + +ELINK + Name = "$(BUILD_DIR)\AmtLockKBD.ffs" + Parent = "FV_MAIN" + InvokeOrder = AfterParent +End
\ No newline at end of file |