mirror of
https://github.com/acidanthera/OpenCorePkg.git
synced 2026-02-01 15:59:39 +00:00
AppleUsbKbDxe: Import from AppleSupportPkg
This commit is contained in:
parent
ebe0764499
commit
597df1c724
@ -55,8 +55,7 @@
|
||||
|
||||
## Include/Protocol/AmiPointer.h
|
||||
gAmiEfiPointerProtocolGuid = { 0x15A10CE7, 0xEAB5, 0x43BF, { 0x90, 0x42, 0x74, 0x43, 0x2E, 0x69, 0x63, 0x77 } }
|
||||
|
||||
|
||||
|
||||
## Include/Protocol/AmiKeycode.h
|
||||
gAmiEfiKeycodeProtocolGuid = { 0x0ADFB62D, 0xFF74, 0x484C, { 0x89, 0x44, 0xF8, 0x5C, 0x4B, 0xEA, 0x87, 0xA8 } }
|
||||
|
||||
@ -73,6 +72,27 @@
|
||||
# @Prompt Register a protocol installation notify for Apple KeyMap Database when not found initially.
|
||||
gOcSupportPkgTokenSpaceGuid.PcNvramInitDevicePropertyDatabase|FALSE|BOOLEAN|0x00000001
|
||||
|
||||
## Indicates if USB KeyBoard Driver disconnects itself when the Exit Boot
|
||||
## Services event is triggered.<BR><BR>
|
||||
# TRUE - USB KeyBoard Driver will disconnect itself.<BR>
|
||||
# FALSE - USB KeyBoard Driver will not disconnect itself.<BR>
|
||||
# @Prompt Disconnect the USB KeyBoard Driver when exitting Boot Services.
|
||||
gOcSupportPkgTokenSpaceGuid.PcdEnableDisconnectOnExitBootServicesInUsbKbDriver|TRUE|BOOLEAN|0x00000002
|
||||
|
||||
## Indicates if USB KeyBoard Driver registers a Apple KeyMap Database protocol installation notify.
|
||||
## Services event is triggered.<BR><BR>
|
||||
# TRUE - USB KeyBoard Driver will registers a protocol installation notify.<BR>
|
||||
# FALSE - USB KeyBoard Driver will registers a protocol installation notify.<BR>
|
||||
# @Prompt Register a protocol installation notify for Apple KeyMap Database when not found initially.
|
||||
gOcSupportPkgTokenSpaceGuid.PcdNotifyAppleKeyMapDbInUsbKbDriver|TRUE|BOOLEAN|0x00000003
|
||||
|
||||
## Indicates if USB KeyBoard Driver disconnects other drivers to take precedence.
|
||||
## Services event is triggered.<BR><BR>
|
||||
# TRUE - USB KeyBoard Driver will disconnect other drivers.<BR>
|
||||
# FALSE - USB KeyBoard Driver will not disconnect other drivers.<BR>
|
||||
# @Prompt Disconnect other drivers for the USB KeyBoard Driver to take precedence over them.
|
||||
gOcSupportPkgTokenSpaceGuid.PcdUsbKbDriverTakePrecedence|TRUE|BOOLEAN|0x00000004
|
||||
|
||||
[PcdsFixedAtBuild]
|
||||
## Defines the Console Control initialization mode set on entry.<BR><BR>
|
||||
# 0 - EfiConsoleControlScreenText<BR>
|
||||
|
||||
@ -25,41 +25,27 @@
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
|
||||
BaseRngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
|
||||
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
|
||||
BaseRngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
|
||||
CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
|
||||
DebugLib|OcSupportPkg/Library/OcDebugLogLib/OcDebugLogLib.inf
|
||||
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
|
||||
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
|
||||
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
|
||||
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
|
||||
HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
|
||||
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
|
||||
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
|
||||
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
|
||||
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
|
||||
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
|
||||
UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
|
||||
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
|
||||
UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
|
||||
PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
|
||||
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
|
||||
PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
|
||||
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
|
||||
SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
|
||||
PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf
|
||||
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
|
||||
FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
|
||||
HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
|
||||
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
|
||||
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
|
||||
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
|
||||
OcAcpiLib|OcSupportPkg/Library/OcAcpiLib/OcAcpiLib.inf
|
||||
OcAppleBootCompatLib|OcSupportPkg/Library/OcAppleBootCompatLib/OcAppleBootCompatLib.inf
|
||||
OcAppleBootPolicyLib|OcSupportPkg/Library/OcAppleBootPolicyLib/OcAppleBootPolicyLib.inf
|
||||
OcAppleChunklistLib|OcSupportPkg/Library/OcAppleChunklistLib/OcAppleChunklistLib.inf
|
||||
OcAppleImg4Lib|OcSupportPkg/Library/OcAppleImg4Lib/OcAppleImg4Lib.inf
|
||||
OcAppleDiskImageLib|OcSupportPkg/Library/OcAppleDiskImageLib/OcAppleDiskImageLib.inf
|
||||
OcAppleEventLib|OcSupportPkg/Library/OcAppleEventLib/OcAppleEventLib.inf
|
||||
OcInputLib|OcSupportPkg/Library/OcInputLib/OcInputLib.inf
|
||||
OcAppleImageConversionLib|OcSupportPkg/Library/OcAppleImageConversionLib/OcAppleImageConversionLib.inf
|
||||
OcAppleImageVerificationLib|OcSupportPkg/Library/OcAppleImageVerificationLib/OcAppleImageVerificationLib.inf
|
||||
OcAppleImg4Lib|OcSupportPkg/Library/OcAppleImg4Lib/OcAppleImg4Lib.inf
|
||||
OcAppleKernelLib|OcSupportPkg/Library/OcAppleKernelLib/OcAppleKernelLib.inf
|
||||
OcAppleKeyMapLib|OcSupportPkg/Library/OcAppleKeyMapLib/OcAppleKeyMapLib.inf
|
||||
OcAppleKeysLib|OcSupportPkg/Library/OcAppleKeysLib/OcAppleKeysLib.inf
|
||||
@ -67,11 +53,11 @@
|
||||
OcAppleSecureBootLib|OcSupportPkg/Library/OcAppleSecureBootLib/OcAppleSecureBootLib.inf
|
||||
OcAppleUserInterfaceThemeLib|OcSupportPkg/Library/OcAppleUserInterfaceThemeLib/OcAppleUserInterfaceThemeLib.inf
|
||||
OcBootManagementLib|OcSupportPkg/Library/OcBootManagementLib/OcBootManagementLib.inf
|
||||
OcConsoleLib|OcSupportPkg/Library/OcConsoleLib/OcConsoleLib.inf
|
||||
OcCompressionLib|OcSupportPkg/Library/OcCompressionLib/OcCompressionLib.inf
|
||||
OcConsoleControlEntryModeLib|OcSupportPkg/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.inf
|
||||
OcConsoleLib|OcSupportPkg/Library/OcConsoleLib/OcConsoleLib.inf
|
||||
OcCpuLib|OcSupportPkg/Library/OcCpuLib/OcCpuLib.inf
|
||||
OcCryptoLib|OcSupportPkg/Library/OcCryptoLib/OcCryptoLib.inf
|
||||
OcCompressionLib|OcSupportPkg/Library/OcCompressionLib/OcCompressionLib.inf
|
||||
OcDataHubLib|OcSupportPkg/Library/OcDataHubLib/OcDataHubLib.inf
|
||||
OcDebugLogLib|OcSupportPkg/Library/OcDebugLogLib/OcDebugLogLib.inf
|
||||
OcDevicePathLib|OcSupportPkg/Library/OcDevicePathLib/OcDevicePathLib.inf
|
||||
@ -81,6 +67,7 @@
|
||||
OcFirmwareVolumeLib|OcSupportPkg/Library/OcFirmwareVolumeLib/OcFirmwareVolumeLib.inf
|
||||
OcGuardLib|OcSupportPkg/Library/OcGuardLib/OcGuardLib.inf
|
||||
OcHashServicesLib|OcSupportPkg/Library/OcHashServicesLib/OcHashServicesLib.inf
|
||||
OcInputLib|OcSupportPkg/Library/OcInputLib/OcInputLib.inf
|
||||
OcMachoLib|OcSupportPkg/Library/OcMachoLib/OcMachoLib.inf
|
||||
OcMemoryLib|OcSupportPkg/Library/OcMemoryLib/OcMemoryLib.inf
|
||||
OcMiscLib|OcSupportPkg/Library/OcMiscLib/OcMiscLib.inf
|
||||
@ -97,32 +84,46 @@
|
||||
OcUnicodeCollationEngLib|OcSupportPkg/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLib.inf
|
||||
OcVirtualFsLib|OcSupportPkg/Library/OcVirtualFsLib/OcVirtualFsLib.inf
|
||||
OcXmlLib|OcSupportPkg/Library/OcXmlLib/OcXmlLib.inf
|
||||
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
|
||||
PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
|
||||
PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
|
||||
PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf
|
||||
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
|
||||
ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
|
||||
SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
|
||||
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
|
||||
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
|
||||
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
|
||||
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
|
||||
UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
|
||||
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
|
||||
UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
|
||||
|
||||
[Components]
|
||||
OcSupportPkg/Application/CleanNvram/CleanNvram.inf
|
||||
OcSupportPkg/Application/VerifyMsrE2/VerifyMsrE2.inf
|
||||
OcSupportPkg/Debug/GdbSyms/GdbSyms.inf
|
||||
OcSupportPkg/Library/OcAcpiLib/OcAcpiLib.inf
|
||||
OcSupportPkg/Library/OcAppleBootCompatLib/OcAppleBootCompatLib.inf
|
||||
OcSupportPkg/Library/OcAppleBootPolicyLib/OcAppleBootPolicyLib.inf
|
||||
OcSupportPkg/Library/OcAppleChunklistLib/OcAppleChunklistLib.inf
|
||||
OcSupportPkg/Library/OcAppleImg4Lib/OcAppleImg4Lib.inf
|
||||
OcSupportPkg/Library/OcAppleDiskImageLib/OcAppleDiskImageLib.inf
|
||||
OcSupportPkg/Library/OcAppleEventLib/OcAppleEventLib.inf
|
||||
OcSupportPkg/Library/OcInputLib/OcInputLib.inf
|
||||
OcSupportPkg/Library/OcAppleImageConversionLib/OcAppleImageConversionLib.inf
|
||||
OcSupportPkg/Library/OcAppleImageVerificationLib/OcAppleImageVerificationLib.inf
|
||||
OcSupportPkg/Library/OcAppleImg4Lib/OcAppleImg4Lib.inf
|
||||
OcSupportPkg/Library/OcAppleKernelLib/OcAppleKernelLib.inf
|
||||
OcSupportPkg/Library/OcAppleKeyMapLib/OcAppleKeyMapLib.inf
|
||||
OcSupportPkg/Library/OcAppleRamDiskLib/OcAppleRamDiskLib.inf
|
||||
OcSupportPkg/Library/OcAppleSecureBootLib/OcAppleSecureBootLib.inf
|
||||
OcSupportPkg/Library/OcAppleUserInterfaceThemeLib/OcAppleUserInterfaceThemeLib.inf
|
||||
OcSupportPkg/Library/OcBootManagementLib/OcBootManagementLib.inf
|
||||
OcSupportPkg/Library/OcCompressionLib/OcCompressionLib.inf
|
||||
OcSupportPkg/Library/OcConfigurationLib/OcConfigurationLib.inf
|
||||
OcSupportPkg/Library/OcConsoleLib/OcConsoleLib.inf
|
||||
OcSupportPkg/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.inf
|
||||
OcSupportPkg/Library/OcConsoleLib/OcConsoleLib.inf
|
||||
OcSupportPkg/Library/OcCpuLib/OcCpuLib.inf
|
||||
OcSupportPkg/Library/OcCryptoLib/OcCryptoLib.inf
|
||||
OcSupportPkg/Library/OcCompressionLib/OcCompressionLib.inf
|
||||
OcSupportPkg/Library/OcDataHubLib/OcDataHubLib.inf
|
||||
OcSupportPkg/Library/OcDebugLogLib/OcDebugLogLib.inf
|
||||
OcSupportPkg/Library/OcDevicePathLib/OcDevicePathLib.inf
|
||||
@ -133,6 +134,7 @@
|
||||
OcSupportPkg/Library/OcFirmwareVolumeLib/OcFirmwareVolumeLib.inf
|
||||
OcSupportPkg/Library/OcGuardLib/OcGuardLib.inf
|
||||
OcSupportPkg/Library/OcHashServicesLib/OcHashServicesLib.inf
|
||||
OcSupportPkg/Library/OcInputLib/OcInputLib.inf
|
||||
OcSupportPkg/Library/OcMachoLib/OcMachoLib.inf
|
||||
OcSupportPkg/Library/OcMemoryLib/OcMemoryLib.inf
|
||||
OcSupportPkg/Library/OcMiscLib/OcMiscLib.inf
|
||||
@ -149,14 +151,14 @@
|
||||
OcSupportPkg/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLib.inf
|
||||
OcSupportPkg/Library/OcVirtualFsLib/OcVirtualFsLib.inf
|
||||
OcSupportPkg/Library/OcXmlLib/OcXmlLib.inf
|
||||
OcSupportPkg/Debug/GdbSyms/GdbSyms.inf
|
||||
OcSupportPkg/Platform/AppleUsbKbDxe/UsbKbDxe.inf
|
||||
OcSupportPkg/Platform/FwRuntimeServices/FwRuntimeServices.inf
|
||||
OcSupportPkg/Tests/CryptoTest/CryptoTest.inf
|
||||
OcSupportPkg/Tests/CryptoTest/CryptoTestApp.inf
|
||||
OcSupportPkg/Tests/AcpiTest/AcpiTest.inf
|
||||
OcSupportPkg/Tests/AcpiTest/AcpiTestApp.inf
|
||||
OcSupportPkg/Tests/BlessTest/BlessTest.inf
|
||||
OcSupportPkg/Tests/BlessTest/BlessTestApp.inf
|
||||
OcSupportPkg/Tests/CryptoTest/CryptoTest.inf
|
||||
OcSupportPkg/Tests/CryptoTest/CryptoTestApp.inf
|
||||
OcSupportPkg/Tests/DataHubTest/DataHubTest.inf
|
||||
OcSupportPkg/Tests/DataHubTest/DataHubTestApp.inf
|
||||
OcSupportPkg/Tests/ExternalUi/ExternalUi.inf
|
||||
|
||||
145
Platform/AppleUsbKbDxe/AppleKey.c
Normal file
145
Platform/AppleUsbKbDxe/AppleKey.c
Normal file
@ -0,0 +1,145 @@
|
||||
/** @file
|
||||
Produces Keyboard Info Protocol.
|
||||
|
||||
Copyright (c) 2016 - 2018, Download-Fritz. All rights reserved.<BR>
|
||||
This program and the accompanying materials are licensed and made available
|
||||
under the terms and conditions of the BSD License which accompanies this
|
||||
distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include "EfiKey.h"
|
||||
#include "AppleKey.h"
|
||||
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
|
||||
#define ASSERT_USB_KB_DEV_VALID(UsbKbDev) \
|
||||
do { \
|
||||
ASSERT ((UsbKbDev) != NULL); \
|
||||
ASSERT ((UsbKbDev)->Signature == USB_KB_DEV_SIGNATURE); \
|
||||
} while (FALSE)
|
||||
|
||||
STATIC VOID *mAppleKeyMapDbRegistration = NULL;
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
UsbKbSetAppleKeyMapDb (
|
||||
IN USB_KB_DEV *UsbKeyboardDevice,
|
||||
IN APPLE_KEY_MAP_DATABASE_PROTOCOL *KeyMapDb
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT_USB_KB_DEV_VALID (UsbKeyboardDevice);
|
||||
ASSERT (KeyMapDb != NULL);
|
||||
|
||||
Status = KeyMapDb->CreateKeyStrokesBuffer (
|
||||
KeyMapDb,
|
||||
6,
|
||||
&UsbKeyboardDevice->KeyMapDbIndex
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
UsbKeyboardDevice->KeyMapDb = KeyMapDb;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Protocol installation notify for Apple KeyMap Database.
|
||||
|
||||
@param[in] Event Indicates the event that invoke this function.
|
||||
@param[in] Context Indicates the calling context.
|
||||
|
||||
**/
|
||||
STATIC
|
||||
VOID
|
||||
EFIAPI
|
||||
UsbKbAppleKeyMapDbInstallNotify (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
APPLE_KEY_MAP_DATABASE_PROTOCOL *KeyMapDb;
|
||||
USB_KB_DEV *UsbKeyboardDevice;
|
||||
|
||||
ASSERT (Event != NULL);
|
||||
ASSERT_USB_KB_DEV_VALID ((USB_KB_DEV *)Context);
|
||||
ASSERT (((USB_KB_DEV *)Context)->KeyMapInstallNotifyEvent == Event);
|
||||
|
||||
Status = gBS->LocateProtocol (
|
||||
&gAppleKeyMapDatabaseProtocolGuid,
|
||||
mAppleKeyMapDbRegistration,
|
||||
(VOID **)&KeyMapDb
|
||||
);
|
||||
ASSERT (Status != EFI_NOT_FOUND);
|
||||
|
||||
UsbKeyboardDevice = (USB_KB_DEV *)Context;
|
||||
UsbKbSetAppleKeyMapDb (UsbKeyboardDevice, KeyMapDb);
|
||||
|
||||
gBS->CloseEvent (UsbKeyboardDevice->KeyMapInstallNotifyEvent);
|
||||
UsbKeyboardDevice->KeyMapInstallNotifyEvent = NULL;
|
||||
}
|
||||
|
||||
VOID
|
||||
UsbKbLocateAppleKeyMapDb (
|
||||
IN USB_KB_DEV *UsbKeyboardDevice
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
APPLE_KEY_MAP_DATABASE_PROTOCOL *KeyMapDb;
|
||||
|
||||
ASSERT_USB_KB_DEV_VALID (UsbKeyboardDevice);
|
||||
|
||||
Status = gBS->LocateProtocol (
|
||||
&gAppleKeyMapDatabaseProtocolGuid,
|
||||
NULL,
|
||||
(VOID **)&KeyMapDb
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
UsbKbSetAppleKeyMapDb (UsbKeyboardDevice, KeyMapDb);
|
||||
} else if (PcdGetBool (PcdNotifyAppleKeyMapDbInUsbKbDriver)) {
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
TPL_NOTIFY,
|
||||
UsbKbAppleKeyMapDbInstallNotify,
|
||||
(VOID *)UsbKeyboardDevice,
|
||||
&UsbKeyboardDevice->KeyMapInstallNotifyEvent
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = gBS->RegisterProtocolNotify (
|
||||
&gAppleKeyMapDatabaseProtocolGuid,
|
||||
UsbKeyboardDevice->KeyMapInstallNotifyEvent,
|
||||
&mAppleKeyMapDbRegistration
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
UsbKbFreeAppleKeyMapDb (
|
||||
IN USB_KB_DEV *UsbKeyboardDevice
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT_USB_KB_DEV_VALID (UsbKeyboardDevice);
|
||||
|
||||
if (UsbKeyboardDevice->KeyMapDb != NULL) {
|
||||
Status = UsbKeyboardDevice->KeyMapDb->RemoveKeyStrokesBuffer (
|
||||
UsbKeyboardDevice->KeyMapDb,
|
||||
UsbKeyboardDevice->KeyMapDbIndex
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
} else if (UsbKeyboardDevice->KeyMapInstallNotifyEvent != NULL) {
|
||||
Status = gBS->CloseEvent (UsbKeyboardDevice->KeyMapInstallNotifyEvent);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
UsbKeyboardDevice->KeyMapInstallNotifyEvent = NULL;
|
||||
}
|
||||
}
|
||||
40
Platform/AppleUsbKbDxe/AppleKey.h
Normal file
40
Platform/AppleUsbKbDxe/AppleKey.h
Normal file
@ -0,0 +1,40 @@
|
||||
/** @file
|
||||
Header file for Apple-specific USB Keyboard Driver's Data Structures.
|
||||
|
||||
Copyright (c) 2016 - 2018, Download-Fritz. All rights reserved.<BR>
|
||||
This program and the accompanying materials are licensed and made available
|
||||
under the terms and conditions of the BSD License which accompanies this
|
||||
distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
#ifndef APPLE_USB_KB_H_
|
||||
#define APPLE_USB_KB_H_
|
||||
|
||||
#include "EfiKey.h"
|
||||
|
||||
#include <Guid/ApplePlatformInfo.h>
|
||||
|
||||
#include <Protocol/AppleKeyMapDatabase.h>
|
||||
#include <Protocol/ApplePlatformInfoDatabase.h>
|
||||
#include <Protocol/KeyboardInfo.h>
|
||||
#include <Protocol/UsbIo.h>
|
||||
|
||||
//
|
||||
// Functions of Keyboard Info Protocol
|
||||
//
|
||||
VOID
|
||||
UsbKbLocateAppleKeyMapDb (
|
||||
IN USB_KB_DEV *UsbKeyboardDevice
|
||||
);
|
||||
|
||||
VOID
|
||||
UsbKbFreeAppleKeyMapDb (
|
||||
IN USB_KB_DEV *UsbKeyboardDevice
|
||||
);
|
||||
|
||||
#endif // APPLE_USB_KB_H_
|
||||
|
||||
217
Platform/AppleUsbKbDxe/ComponentName.c
Normal file
217
Platform/AppleUsbKbDxe/ComponentName.c
Normal file
@ -0,0 +1,217 @@
|
||||
/** @file
|
||||
UEFI Component Name(2) protocol implementation for USB Keyboard driver.
|
||||
|
||||
Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include "KeyBoard.h"
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUsbKeyboardComponentName = {
|
||||
UsbKeyboardComponentNameGetDriverName,
|
||||
UsbKeyboardComponentNameGetControllerName,
|
||||
"eng"
|
||||
};
|
||||
|
||||
//
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbKeyboardComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UsbKeyboardComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UsbKeyboardComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbKeyboardDriverNameTable[] = {
|
||||
{ "eng;en", L"Usb Keyboard Driver" },
|
||||
{ NULL , NULL }
|
||||
};
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
|
||||
This function retrieves the user readable name of a driver in the form of a
|
||||
Unicode string. If the driver specified by This has a user readable name in
|
||||
the language specified by Language, then a pointer to the driver name is
|
||||
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
|
||||
by This does not support the language specified by Language,
|
||||
then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
@param Language A pointer to a Null-terminated ASCII string
|
||||
array indicating the language. This is the
|
||||
language of the driver name that the caller is
|
||||
requesting, and it must match one of the
|
||||
languages specified in SupportedLanguages. The
|
||||
number of languages supported by a driver is up
|
||||
to the driver writer. Language is specified
|
||||
in RFC 4646 or ISO 639-2 language code format.
|
||||
@param DriverName A pointer to the Unicode string to return.
|
||||
This Unicode string is the name of the
|
||||
driver specified by This in the language
|
||||
specified by Language.
|
||||
|
||||
@retval EFI_SUCCESS The Unicode string for the Driver specified by
|
||||
This and the language specified by Language was
|
||||
returned in DriverName.
|
||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
||||
@retval EFI_INVALID_PARAMETER DriverName is NULL.
|
||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
||||
the language specified by Language.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbKeyboardComponentNameGetDriverName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **DriverName
|
||||
)
|
||||
{
|
||||
return LookupUnicodeString2 (
|
||||
Language,
|
||||
This->SupportedLanguages,
|
||||
mUsbKeyboardDriverNameTable,
|
||||
DriverName,
|
||||
(BOOLEAN)(This == &gUsbKeyboardComponentName)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
|
||||
This function retrieves the user readable name of the controller specified by
|
||||
ControllerHandle and ChildHandle in the form of a Unicode string. If the
|
||||
driver specified by This has a user readable name in the language specified by
|
||||
Language, then a pointer to the controller name is returned in ControllerName,
|
||||
and EFI_SUCCESS is returned. If the driver specified by This is not currently
|
||||
managing the controller specified by ControllerHandle and ChildHandle,
|
||||
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
|
||||
support the language specified by Language, then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
@param ControllerHandle The handle of a controller that the driver
|
||||
specified by This is managing. This handle
|
||||
specifies the controller whose name is to be
|
||||
returned.
|
||||
@param ChildHandle The handle of the child controller to retrieve
|
||||
the name of. This is an optional parameter that
|
||||
may be NULL. It will be NULL for device
|
||||
drivers. It will also be NULL for a bus drivers
|
||||
that wish to retrieve the name of the bus
|
||||
controller. It will not be NULL for a bus
|
||||
driver that wishes to retrieve the name of a
|
||||
child controller.
|
||||
@param Language A pointer to a Null-terminated ASCII string
|
||||
array indicating the language. This is the
|
||||
language of the driver name that the caller is
|
||||
requesting, and it must match one of the
|
||||
languages specified in SupportedLanguages. The
|
||||
number of languages supported by a driver is up
|
||||
to the driver writer. Language is specified in
|
||||
RFC 4646 or ISO 639-2 language code format.
|
||||
@param ControllerName A pointer to the Unicode string to return.
|
||||
This Unicode string is the name of the
|
||||
controller specified by ControllerHandle and
|
||||
ChildHandle in the language specified by
|
||||
Language from the point of view of the driver
|
||||
specified by This.
|
||||
|
||||
@retval EFI_SUCCESS The Unicode string for the user readable name in
|
||||
the language specified by Language for the
|
||||
driver specified by This was returned in
|
||||
DriverName.
|
||||
@retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
|
||||
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
|
||||
EFI_HANDLE.
|
||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
||||
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
|
||||
@retval EFI_UNSUPPORTED The driver specified by This is not currently
|
||||
managing the controller specified by
|
||||
ControllerHandle and ChildHandle.
|
||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
||||
the language specified by Language.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbKeyboardComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
USB_KB_DEV *UsbKbDev;
|
||||
EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTxtIn;
|
||||
EFI_USB_IO_PROTOCOL *UsbIoProtocol;
|
||||
//
|
||||
// This is a device driver, so ChildHandle must be NULL.
|
||||
//
|
||||
if (ChildHandle != NULL) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Controller's handle
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiUsbIoProtocolGuid,
|
||||
(VOID **) &UsbIoProtocol,
|
||||
gUsbKeyboardDriverBinding.DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
gBS->CloseProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiUsbIoProtocolGuid,
|
||||
gUsbKeyboardDriverBinding.DriverBindingHandle,
|
||||
ControllerHandle
|
||||
);
|
||||
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (Status != EFI_ALREADY_STARTED) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
//
|
||||
// Get the device context
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiSimpleTextInProtocolGuid,
|
||||
(VOID **) &SimpleTxtIn,
|
||||
gUsbKeyboardDriverBinding.DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
UsbKbDev = USB_KB_DEV_FROM_THIS (SimpleTxtIn);
|
||||
|
||||
return LookupUnicodeString2 (
|
||||
Language,
|
||||
This->SupportedLanguages,
|
||||
UsbKbDev->ControllerNameTable,
|
||||
ControllerName,
|
||||
(BOOLEAN)(This == &gUsbKeyboardComponentName)
|
||||
);
|
||||
|
||||
}
|
||||
1317
Platform/AppleUsbKbDxe/EfiKey.c
Normal file
1317
Platform/AppleUsbKbDxe/EfiKey.c
Normal file
File diff suppressed because it is too large
Load Diff
635
Platform/AppleUsbKbDxe/EfiKey.h
Normal file
635
Platform/AppleUsbKbDxe/EfiKey.h
Normal file
@ -0,0 +1,635 @@
|
||||
/** @file
|
||||
Header file for USB Keyboard Driver's Data Structures.
|
||||
|
||||
Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
#ifndef _EFI_USB_KB_H_
|
||||
#define _EFI_USB_KB_H_
|
||||
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
#include <IndustryStandard/AppleHid.h>
|
||||
|
||||
#include <Protocol/SimpleTextIn.h>
|
||||
#include <Protocol/SimpleTextInEx.h>
|
||||
#include <Protocol/HiiDatabase.h>
|
||||
#include <Protocol/UsbIo.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
#include <Protocol/AppleKeyMapDatabase.h>
|
||||
#include <Protocol/ApplePlatformInfoDatabase.h>
|
||||
|
||||
#include <Guid/HiiKeyBoardLayout.h>
|
||||
#include <Guid/UsbKeyBoardLayout.h>
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/ReportStatusCodeLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/UefiDriverEntryPoint.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/UefiUsbLib.h>
|
||||
#include <Library/HiiLib.h>
|
||||
|
||||
#include <IndustryStandard/Usb.h>
|
||||
|
||||
#define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s
|
||||
|
||||
#define MAX_KEY_ALLOWED 32
|
||||
|
||||
#define HZ 1000 * 1000 * 10
|
||||
#define USBKBD_REPEAT_DELAY ((HZ) / 2)
|
||||
#define USBKBD_REPEAT_RATE ((HZ) / 50)
|
||||
|
||||
#define CLASS_HID 3
|
||||
#define SUBCLASS_BOOT 1
|
||||
#define PROTOCOL_KEYBOARD 1
|
||||
|
||||
#define BOOT_PROTOCOL 0
|
||||
#define REPORT_PROTOCOL 1
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN Down;
|
||||
UINT8 KeyCode;
|
||||
} USB_KEY;
|
||||
|
||||
typedef struct {
|
||||
VOID *Buffer[MAX_KEY_ALLOWED + 1];
|
||||
UINTN Head;
|
||||
UINTN Tail;
|
||||
UINTN ItemSize;
|
||||
} USB_SIMPLE_QUEUE;
|
||||
|
||||
#define USB_KB_DEV_SIGNATURE SIGNATURE_32 ('u', 'k', 'b', 'd')
|
||||
#define USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('u', 'k', 'b', 'x')
|
||||
|
||||
typedef struct _KEYBOARD_CONSOLE_IN_EX_NOTIFY {
|
||||
UINTN Signature;
|
||||
EFI_KEY_DATA KeyData;
|
||||
EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
|
||||
LIST_ENTRY NotifyEntry;
|
||||
} KEYBOARD_CONSOLE_IN_EX_NOTIFY;
|
||||
|
||||
#define USB_NS_KEY_SIGNATURE SIGNATURE_32 ('u', 'n', 's', 'k')
|
||||
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link;
|
||||
|
||||
//
|
||||
// The number of EFI_NS_KEY_MODIFIER children definitions
|
||||
//
|
||||
UINTN KeyCount;
|
||||
|
||||
//
|
||||
// NsKey[0] : Non-spacing key
|
||||
// NsKey[1] ~ NsKey[KeyCount] : Physical keys
|
||||
//
|
||||
EFI_KEY_DESCRIPTOR *NsKey;
|
||||
} USB_NS_KEY;
|
||||
|
||||
#define USB_NS_KEY_FORM_FROM_LINK(a) CR (a, USB_NS_KEY, Link, USB_NS_KEY_SIGNATURE)
|
||||
|
||||
///
|
||||
/// Structure to describe USB keyboard device
|
||||
///
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
EFI_HANDLE ControllerHandle;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
EFI_EVENT DelayedRecoveryEvent;
|
||||
EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput;
|
||||
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleInputEx;
|
||||
EFI_USB_IO_PROTOCOL *UsbIo;
|
||||
|
||||
EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
|
||||
EFI_USB_ENDPOINT_DESCRIPTOR IntEndpointDescriptor;
|
||||
|
||||
USB_SIMPLE_QUEUE UsbKeyQueue;
|
||||
USB_SIMPLE_QUEUE EfiKeyQueue;
|
||||
USB_SIMPLE_QUEUE EfiKeyQueueForNotify;
|
||||
BOOLEAN CtrlOn;
|
||||
BOOLEAN AltOn;
|
||||
BOOLEAN ShiftOn;
|
||||
BOOLEAN NumLockOn;
|
||||
BOOLEAN CapsOn;
|
||||
BOOLEAN ScrollOn;
|
||||
UINT8 LastKeyCodeArray[8];
|
||||
UINT8 CurKeyCode;
|
||||
|
||||
EFI_EVENT TimerEvent;
|
||||
|
||||
UINT8 RepeatKey;
|
||||
EFI_EVENT RepeatTimer;
|
||||
|
||||
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
|
||||
|
||||
BOOLEAN LeftCtrlOn;
|
||||
BOOLEAN LeftAltOn;
|
||||
BOOLEAN LeftShiftOn;
|
||||
BOOLEAN LeftLogoOn;
|
||||
BOOLEAN RightCtrlOn;
|
||||
BOOLEAN RightAltOn;
|
||||
BOOLEAN RightShiftOn;
|
||||
BOOLEAN RightLogoOn;
|
||||
BOOLEAN MenuKeyOn;
|
||||
BOOLEAN SysReqOn;
|
||||
BOOLEAN AltGrOn;
|
||||
|
||||
BOOLEAN IsSupportPartialKey;
|
||||
|
||||
EFI_KEY_STATE KeyState;
|
||||
//
|
||||
// Notification function list
|
||||
//
|
||||
LIST_ENTRY NotifyList;
|
||||
EFI_EVENT KeyNotifyProcessEvent;
|
||||
|
||||
//
|
||||
// Non-spacing key list
|
||||
//
|
||||
LIST_ENTRY NsKeyList;
|
||||
USB_NS_KEY *CurrentNsKey;
|
||||
EFI_KEY_DESCRIPTOR *KeyConvertionTable;
|
||||
EFI_EVENT KeyboardLayoutEvent;
|
||||
|
||||
APPLE_KEY_MAP_DATABASE_PROTOCOL *KeyMapDb;
|
||||
UINTN KeyMapDbIndex;
|
||||
|
||||
EFI_EVENT KeyMapInstallNotifyEvent;
|
||||
|
||||
EFI_EVENT ExitBootServicesEvent;
|
||||
} USB_KB_DEV;
|
||||
|
||||
//
|
||||
// Global Variables
|
||||
//
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL gUsbKeyboardDriverBinding;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gUsbKeyboardComponentName;
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gUsbKeyboardComponentName2;
|
||||
|
||||
#define USB_KB_DEV_FROM_THIS(a) \
|
||||
CR(a, USB_KB_DEV, SimpleInput, USB_KB_DEV_SIGNATURE)
|
||||
#define TEXT_INPUT_EX_USB_KB_DEV_FROM_THIS(a) \
|
||||
CR(a, USB_KB_DEV, SimpleInputEx, USB_KB_DEV_SIGNATURE)
|
||||
|
||||
//
|
||||
// According to Universal Serial Bus HID Usage Tables document ver 1.12,
|
||||
// a Boot Keyboard should support the keycode range from 0x0 to 0x65 and 0xE0 to 0xE7.
|
||||
// 0xE0 to 0xE7 are for modifier keys, and 0x0 to 0x3 are reserved for typical
|
||||
// keyboard status or keyboard errors.
|
||||
// So the number of valid non-modifier USB keycodes is 0x62, and the number of
|
||||
// valid keycodes is 0x6A.
|
||||
//
|
||||
#define NUMBER_OF_VALID_NON_MODIFIER_USB_KEYCODE 0x62
|
||||
#define NUMBER_OF_VALID_USB_KEYCODE 0x6A
|
||||
//
|
||||
// 0x0 to 0x3 are reserved for typical keyboard status or keyboard errors.
|
||||
//
|
||||
#define USBKBD_VALID_KEYCODE(Key) ((UINT8) (Key) > 3)
|
||||
|
||||
typedef struct {
|
||||
UINT8 NumLock : 1;
|
||||
UINT8 CapsLock : 1;
|
||||
UINT8 ScrollLock : 1;
|
||||
UINT8 Resrvd : 5;
|
||||
} LED_MAP;
|
||||
|
||||
//
|
||||
// Functions of Driver Binding Protocol
|
||||
//
|
||||
/**
|
||||
Check whether USB keyboard driver supports this device.
|
||||
|
||||
@param This The USB keyboard driver binding protocol.
|
||||
@param Controller The controller handle to check.
|
||||
@param RemainingDevicePath The remaining device path.
|
||||
|
||||
@retval EFI_SUCCESS The driver supports this controller.
|
||||
@retval other This device isn't supported.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
USBKeyboardDriverBindingSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
);
|
||||
|
||||
/**
|
||||
Starts the keyboard device with this driver.
|
||||
|
||||
This function produces Simple Text Input Protocol and Simple Text Input Ex Protocol,
|
||||
initializes the keyboard device, and submit Asynchronous Interrupt Transfer to manage
|
||||
this keyboard device.
|
||||
|
||||
@param This The USB keyboard driver binding instance.
|
||||
@param Controller Handle of device to bind driver to.
|
||||
@param RemainingDevicePath Optional parameter use to pick a specific child
|
||||
device to start.
|
||||
|
||||
@retval EFI_SUCCESS The controller is controlled by the usb keyboard driver.
|
||||
@retval EFI_UNSUPPORTED No interrupt endpoint can be found.
|
||||
@retval Other This controller cannot be started.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
USBKeyboardDriverBindingStart (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
);
|
||||
|
||||
/**
|
||||
Stop the USB keyboard device handled by this driver.
|
||||
|
||||
@param This The USB keyboard driver binding protocol.
|
||||
@param Controller The controller to release.
|
||||
@param NumberOfChildren The number of handles in ChildHandleBuffer.
|
||||
@param ChildHandleBuffer The array of child handle.
|
||||
|
||||
@retval EFI_SUCCESS The device was stopped.
|
||||
@retval EFI_UNSUPPORTED Simple Text In Protocol or Simple Text In Ex Protocol
|
||||
is not installed on Controller.
|
||||
@retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
|
||||
@retval Others Fail to uninstall protocols attached on the device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
USBKeyboardDriverBindingStop (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN UINTN NumberOfChildren,
|
||||
IN EFI_HANDLE *ChildHandleBuffer
|
||||
);
|
||||
|
||||
//
|
||||
// EFI Component Name Functions
|
||||
//
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
|
||||
This function retrieves the user readable name of a driver in the form of a
|
||||
Unicode string. If the driver specified by This has a user readable name in
|
||||
the language specified by Language, then a pointer to the driver name is
|
||||
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
|
||||
by This does not support the language specified by Language,
|
||||
then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
@param Language A pointer to a Null-terminated ASCII string
|
||||
array indicating the language. This is the
|
||||
language of the driver name that the caller is
|
||||
requesting, and it must match one of the
|
||||
languages specified in SupportedLanguages. The
|
||||
number of languages supported by a driver is up
|
||||
to the driver writer. Language is specified
|
||||
in RFC 4646 or ISO 639-2 language code format.
|
||||
@param DriverName A pointer to the Unicode string to return.
|
||||
This Unicode string is the name of the
|
||||
driver specified by This in the language
|
||||
specified by Language.
|
||||
|
||||
@retval EFI_SUCCESS The Unicode string for the Driver specified by
|
||||
This and the language specified by Language was
|
||||
returned in DriverName.
|
||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
||||
@retval EFI_INVALID_PARAMETER DriverName is NULL.
|
||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
||||
the language specified by Language.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbKeyboardComponentNameGetDriverName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
|
||||
This function retrieves the user readable name of the controller specified by
|
||||
ControllerHandle and ChildHandle in the form of a Unicode string. If the
|
||||
driver specified by This has a user readable name in the language specified by
|
||||
Language, then a pointer to the controller name is returned in ControllerName,
|
||||
and EFI_SUCCESS is returned. If the driver specified by This is not currently
|
||||
managing the controller specified by ControllerHandle and ChildHandle,
|
||||
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
|
||||
support the language specified by Language, then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
@param ControllerHandle The handle of a controller that the driver
|
||||
specified by This is managing. This handle
|
||||
specifies the controller whose name is to be
|
||||
returned.
|
||||
@param ChildHandle The handle of the child controller to retrieve
|
||||
the name of. This is an optional parameter that
|
||||
may be NULL. It will be NULL for device
|
||||
drivers. It will also be NULL for a bus drivers
|
||||
that wish to retrieve the name of the bus
|
||||
controller. It will not be NULL for a bus
|
||||
driver that wishes to retrieve the name of a
|
||||
child controller.
|
||||
@param Language A pointer to a Null-terminated ASCII string
|
||||
array indicating the language. This is the
|
||||
language of the driver name that the caller is
|
||||
requesting, and it must match one of the
|
||||
languages specified in SupportedLanguages. The
|
||||
number of languages supported by a driver is up
|
||||
to the driver writer. Language is specified in
|
||||
RFC 4646 or ISO 639-2 language code format.
|
||||
@param ControllerName A pointer to the Unicode string to return.
|
||||
This Unicode string is the name of the
|
||||
controller specified by ControllerHandle and
|
||||
ChildHandle in the language specified by
|
||||
Language from the point of view of the driver
|
||||
specified by This.
|
||||
|
||||
@retval EFI_SUCCESS The Unicode string for the user readable name in
|
||||
the language specified by Language for the
|
||||
driver specified by This was returned in
|
||||
DriverName.
|
||||
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
|
||||
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
|
||||
EFI_HANDLE.
|
||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
||||
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
|
||||
@retval EFI_UNSUPPORTED The driver specified by This is not currently
|
||||
managing the controller specified by
|
||||
ControllerHandle and ChildHandle.
|
||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
||||
the language specified by Language.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbKeyboardComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
//
|
||||
// Functions of Simple Text Input Protocol
|
||||
//
|
||||
/**
|
||||
Reset the input device and optionaly run diagnostics
|
||||
|
||||
There are 2 types of reset for USB keyboard.
|
||||
For non-exhaustive reset, only keyboard buffer is cleared.
|
||||
For exhaustive reset, in addition to clearance of keyboard buffer, the hardware status
|
||||
is also re-initialized.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param ExtendedVerification Driver may perform diagnostics on reset.
|
||||
|
||||
@retval EFI_SUCCESS The device was reset.
|
||||
@retval EFI_DEVICE_ERROR The device is not functioning properly and could not be reset.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
USBKeyboardReset (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
);
|
||||
|
||||
/**
|
||||
Reads the next keystroke from the input device.
|
||||
|
||||
@param This The EFI_SIMPLE_TEXT_INPUT_PROTOCOL instance.
|
||||
@param Key A pointer to a buffer that is filled in with the keystroke
|
||||
information for the key that was pressed.
|
||||
|
||||
@retval EFI_SUCCESS The keystroke information was returned.
|
||||
@retval EFI_NOT_READY There was no keystroke data availiable.
|
||||
@retval EFI_DEVICE_ERROR The keydtroke information was not returned due to
|
||||
hardware errors.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
USBKeyboardReadKeyStroke (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
|
||||
OUT EFI_INPUT_KEY *Key
|
||||
);
|
||||
|
||||
//
|
||||
// Simple Text Input Ex protocol functions
|
||||
//
|
||||
/**
|
||||
Resets the input device hardware.
|
||||
|
||||
The Reset() function resets the input device hardware. As part
|
||||
of initialization process, the firmware/device will make a quick
|
||||
but reasonable attempt to verify that the device is functioning.
|
||||
If the ExtendedVerification flag is TRUE the firmware may take
|
||||
an extended amount of time to verify the device is operating on
|
||||
reset. Otherwise the reset operation is to occur as quickly as
|
||||
possible. The hardware verification process is not defined by
|
||||
this specification and is left up to the platform firmware or
|
||||
driver to implement.
|
||||
|
||||
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
|
||||
|
||||
@param ExtendedVerification Indicates that the driver may perform a more exhaustive
|
||||
verification operation of the device during reset.
|
||||
|
||||
@retval EFI_SUCCESS The device was reset.
|
||||
@retval EFI_DEVICE_ERROR The device is not functioning correctly and could not be reset.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
USBKeyboardResetEx (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
);
|
||||
|
||||
/**
|
||||
Reads the next keystroke from the input device.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param KeyData A pointer to a buffer that is filled in with the keystroke
|
||||
state data for the key that was pressed.
|
||||
|
||||
@retval EFI_SUCCESS The keystroke information was returned.
|
||||
@retval EFI_NOT_READY There was no keystroke data available.
|
||||
@retval EFI_DEVICE_ERROR The keystroke information was not returned due to
|
||||
hardware errors.
|
||||
@retval EFI_INVALID_PARAMETER KeyData is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
USBKeyboardReadKeyStrokeEx (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
OUT EFI_KEY_DATA *KeyData
|
||||
);
|
||||
|
||||
/**
|
||||
Set certain state for the input device.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
|
||||
state for the input device.
|
||||
|
||||
@retval EFI_SUCCESS The device state was set appropriately.
|
||||
@retval EFI_DEVICE_ERROR The device is not functioning correctly and could
|
||||
not have the setting adjusted.
|
||||
@retval EFI_UNSUPPORTED The device does not support the ability to have its state set.
|
||||
@retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
USBKeyboardSetState (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
IN EFI_KEY_TOGGLE_STATE *KeyToggleState
|
||||
);
|
||||
|
||||
/**
|
||||
Register a notification function for a particular keystroke for the input device.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param KeyData A pointer to a buffer that is filled in with
|
||||
the keystroke information for the key that was
|
||||
pressed. If KeyData.Key, KeyData.KeyState.KeyToggleState
|
||||
and KeyData.KeyState.KeyShiftState are 0, then any incomplete
|
||||
keystroke will trigger a notification of the KeyNotificationFunction.
|
||||
@param KeyNotificationFunction Points to the function to be called when the key
|
||||
sequence is typed specified by KeyData. This notification function
|
||||
should be called at <=TPL_CALLBACK.
|
||||
@param NotifyHandle Points to the unique handle assigned to the registered notification.
|
||||
|
||||
@retval EFI_SUCCESS The notification function was registered successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data structures.
|
||||
@retval EFI_INVALID_PARAMETER KeyData or NotifyHandle or KeyNotificationFunction is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
USBKeyboardRegisterKeyNotify (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
IN EFI_KEY_DATA *KeyData,
|
||||
IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,
|
||||
OUT VOID **NotifyHandle
|
||||
);
|
||||
|
||||
/**
|
||||
Remove a registered notification function from a particular keystroke.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param NotificationHandle The handle of the notification function being unregistered.
|
||||
|
||||
@retval EFI_SUCCESS The notification function was unregistered successfully.
|
||||
@retval EFI_INVALID_PARAMETER The NotificationHandle is invalid
|
||||
@retval EFI_NOT_FOUND Cannot find the matching entry in database.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
USBKeyboardUnregisterKeyNotify (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
IN VOID *NotificationHandle
|
||||
);
|
||||
|
||||
/**
|
||||
Event notification function registered for EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx
|
||||
and EFI_SIMPLE_TEXT_INPUT_PROTOCOL.WaitForKey.
|
||||
|
||||
@param Event Event to be signaled when a key is pressed.
|
||||
@param Context Points to USB_KB_DEV instance.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
USBKeyboardWaitForKey (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
Free keyboard notify list.
|
||||
|
||||
@param NotifyList The keyboard notify list to free.
|
||||
|
||||
@retval EFI_SUCCESS Free the notify list successfully.
|
||||
@retval EFI_INVALID_PARAMETER NotifyList is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
KbdFreeNotifyList (
|
||||
IN OUT LIST_ENTRY *NotifyList
|
||||
);
|
||||
|
||||
/**
|
||||
Check whether the pressed key matches a registered key or not.
|
||||
|
||||
@param RegsiteredData A pointer to keystroke data for the key that was registered.
|
||||
@param InputData A pointer to keystroke data for the key that was pressed.
|
||||
|
||||
@retval TRUE Key pressed matches a registered key.
|
||||
@retval FLASE Key pressed does not matche a registered key.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
IsKeyRegistered (
|
||||
IN EFI_KEY_DATA *RegsiteredData,
|
||||
IN EFI_KEY_DATA *InputData
|
||||
);
|
||||
|
||||
/**
|
||||
Timer handler to convert the key from USB.
|
||||
|
||||
@param Event Indicates the event that invoke this function.
|
||||
@param Context Indicates the calling context.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
USBKeyboardTimerHandler (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
ExitBootServices handler to disconnect from the device.
|
||||
|
||||
@param Event Indicates the event that invoke this function.
|
||||
@param Context Indicates the calling context.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
USBKeyboardExitBootServices (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
Process key notify.
|
||||
@param Event Indicates the event that invoke this function.
|
||||
@param Context Indicates the calling context.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
KeyNotifyProcessHandler (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
#endif
|
||||
2015
Platform/AppleUsbKbDxe/KeyBoard.c
Normal file
2015
Platform/AppleUsbKbDxe/KeyBoard.c
Normal file
File diff suppressed because it is too large
Load Diff
326
Platform/AppleUsbKbDxe/KeyBoard.h
Normal file
326
Platform/AppleUsbKbDxe/KeyBoard.h
Normal file
@ -0,0 +1,326 @@
|
||||
/** @file
|
||||
Function prototype for USB Keyboard Driver.
|
||||
|
||||
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _EFI_KEYBOARD_H_
|
||||
#define _EFI_KEYBOARD_H_
|
||||
|
||||
|
||||
#include "EfiKey.h"
|
||||
|
||||
#define USB_KEYBOARD_KEY_COUNT 105
|
||||
|
||||
#define USB_KEYBOARD_LANGUAGE_STR_LEN 5 // RFC4646 Language Code: "en-US"
|
||||
#define USB_KEYBOARD_DESCRIPTION_STR_LEN (16 + 1) // Description: "English Keyboard"
|
||||
|
||||
#pragma pack (1)
|
||||
typedef struct {
|
||||
//
|
||||
// This 4-bytes total array length is required by PreparePackageList()
|
||||
//
|
||||
UINT32 Length;
|
||||
|
||||
//
|
||||
// Keyboard Layout package definition
|
||||
//
|
||||
EFI_HII_PACKAGE_HEADER PackageHeader;
|
||||
UINT16 LayoutCount;
|
||||
|
||||
//
|
||||
// EFI_HII_KEYBOARD_LAYOUT
|
||||
//
|
||||
UINT16 LayoutLength;
|
||||
EFI_GUID Guid;
|
||||
UINT32 LayoutDescriptorStringOffset;
|
||||
UINT8 DescriptorCount;
|
||||
EFI_KEY_DESCRIPTOR KeyDescriptor[USB_KEYBOARD_KEY_COUNT];
|
||||
UINT16 DescriptionCount;
|
||||
CHAR16 Language[USB_KEYBOARD_LANGUAGE_STR_LEN];
|
||||
CHAR16 Space;
|
||||
CHAR16 DescriptionString[USB_KEYBOARD_DESCRIPTION_STR_LEN];
|
||||
} USB_KEYBOARD_LAYOUT_PACK_BIN;
|
||||
#pragma pack()
|
||||
/**
|
||||
Uses USB I/O to check whether the device is a USB keyboard device.
|
||||
|
||||
@param UsbIo Pointer to a USB I/O protocol instance.
|
||||
|
||||
@retval TRUE Device is a USB keyboard device.
|
||||
@retval FALSE Device is a not USB keyboard device.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
IsUSBKeyboard (
|
||||
IN EFI_USB_IO_PROTOCOL *UsbIo
|
||||
);
|
||||
|
||||
/**
|
||||
Initialize USB keyboard device and all private data structures.
|
||||
|
||||
@param UsbKeyboardDevice The USB_KB_DEV instance.
|
||||
|
||||
@retval EFI_SUCCESS Initialization is successful.
|
||||
@retval EFI_DEVICE_ERROR Keyboard initialization failed.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
InitUSBKeyboard (
|
||||
IN OUT USB_KB_DEV *UsbKeyboardDevice
|
||||
);
|
||||
|
||||
/**
|
||||
Initialize USB keyboard layout.
|
||||
|
||||
This function initializes Key Convertion Table for the USB keyboard device.
|
||||
It first tries to retrieve layout from HII database. If failed and default
|
||||
layout is enabled, then it just uses the default layout.
|
||||
|
||||
@param UsbKeyboardDevice The USB_KB_DEV instance.
|
||||
|
||||
@retval EFI_SUCCESS Initialization succeeded.
|
||||
@retval EFI_NOT_READY Keyboard layout cannot be retrieve from HII
|
||||
database, and default layout is disabled.
|
||||
@retval Other Fail to register event to EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
InitKeyboardLayout (
|
||||
OUT USB_KB_DEV *UsbKeyboardDevice
|
||||
);
|
||||
|
||||
/**
|
||||
Destroy resources for keyboard layout.
|
||||
|
||||
@param UsbKeyboardDevice The USB_KB_DEV instance.
|
||||
|
||||
**/
|
||||
VOID
|
||||
ReleaseKeyboardLayoutResources (
|
||||
IN OUT USB_KB_DEV *UsbKeyboardDevice
|
||||
);
|
||||
|
||||
/**
|
||||
Handler function for USB keyboard's asynchronous interrupt transfer.
|
||||
|
||||
This function is the handler function for USB keyboard's asynchronous interrupt transfer
|
||||
to manage the keyboard. It parses the USB keyboard input report, and inserts data to
|
||||
keyboard buffer according to state of modifer keys and normal keys. Timer for repeat key
|
||||
is also set accordingly.
|
||||
|
||||
@param Data A pointer to a buffer that is filled with key data which is
|
||||
retrieved via asynchronous interrupt transfer.
|
||||
@param DataLength Indicates the size of the data buffer.
|
||||
@param Context Pointing to USB_KB_DEV instance.
|
||||
@param Result Indicates the result of the asynchronous interrupt transfer.
|
||||
|
||||
@retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.
|
||||
@retval EFI_DEVICE_ERROR Hardware error occurs.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
KeyboardHandler (
|
||||
IN VOID *Data,
|
||||
IN UINTN DataLength,
|
||||
IN VOID *Context,
|
||||
IN UINT32 Result
|
||||
);
|
||||
|
||||
/**
|
||||
Handler for Delayed Recovery event.
|
||||
|
||||
This function is the handler for Delayed Recovery event triggered
|
||||
by timer.
|
||||
After a device error occurs, the event would be triggered
|
||||
with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY
|
||||
is defined in USB standard for error handling.
|
||||
|
||||
@param Event The Delayed Recovery event.
|
||||
@param Context Points to the USB_KB_DEV instance.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
USBKeyboardRecoveryHandler (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
Retrieves a USB keycode after parsing the raw data in keyboard buffer.
|
||||
|
||||
This function parses keyboard buffer. It updates state of modifier key for
|
||||
USB_KB_DEV instancem, and returns keycode for output.
|
||||
|
||||
@param UsbKeyboardDevice The USB_KB_DEV instance.
|
||||
@param KeyCode Pointer to the USB keycode for output.
|
||||
|
||||
@retval EFI_SUCCESS Keycode successfully parsed.
|
||||
@retval EFI_NOT_READY Keyboard buffer is not ready for a valid keycode
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
USBParseKey (
|
||||
IN OUT USB_KB_DEV *UsbKeyboardDevice,
|
||||
OUT UINT8 *KeyCode
|
||||
);
|
||||
|
||||
/**
|
||||
Converts USB Keycode ranging from 0x4 to 0x65 to EFI_INPUT_KEY.
|
||||
|
||||
@param UsbKeyboardDevice The USB_KB_DEV instance.
|
||||
@param KeyCode Indicates the key code that will be interpreted.
|
||||
@param KeyData A pointer to a buffer that is filled in with
|
||||
the keystroke information for the key that
|
||||
was pressed.
|
||||
|
||||
@retval EFI_SUCCESS Success.
|
||||
@retval EFI_INVALID_PARAMETER KeyCode is not in the range of 0x4 to 0x65.
|
||||
@retval EFI_INVALID_PARAMETER Translated EFI_INPUT_KEY has zero for both ScanCode and UnicodeChar.
|
||||
@retval EFI_NOT_READY KeyCode represents a dead key with EFI_NS_KEY_MODIFIER
|
||||
@retval EFI_DEVICE_ERROR Keyboard layout is invalid.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbKeyCodeToEfiInputKey (
|
||||
IN USB_KB_DEV *UsbKeyboardDevice,
|
||||
IN UINT8 KeyCode,
|
||||
OUT EFI_KEY_DATA *KeyData
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Create the queue.
|
||||
|
||||
@param Queue Points to the queue.
|
||||
@param ItemSize Size of the single item.
|
||||
|
||||
**/
|
||||
VOID
|
||||
InitQueue (
|
||||
IN OUT USB_SIMPLE_QUEUE *Queue,
|
||||
IN UINTN ItemSize
|
||||
);
|
||||
|
||||
/**
|
||||
Destroy the queue
|
||||
|
||||
@param Queue Points to the queue.
|
||||
**/
|
||||
VOID
|
||||
DestroyQueue (
|
||||
IN OUT USB_SIMPLE_QUEUE *Queue
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Check whether the queue is empty.
|
||||
|
||||
@param Queue Points to the queue.
|
||||
|
||||
@retval TRUE Queue is empty.
|
||||
@retval FALSE Queue is not empty.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
IsQueueEmpty (
|
||||
IN USB_SIMPLE_QUEUE *Queue
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Check whether the queue is full.
|
||||
|
||||
@param Queue Points to the queue.
|
||||
|
||||
@retval TRUE Queue is full.
|
||||
@retval FALSE Queue is not full.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
IsQueueFull (
|
||||
IN USB_SIMPLE_QUEUE *Queue
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Enqueue the item to the queue.
|
||||
|
||||
@param Queue Points to the queue.
|
||||
@param Item Points to the item to be enqueued.
|
||||
@param ItemSize Size of the item.
|
||||
**/
|
||||
VOID
|
||||
Enqueue (
|
||||
IN OUT USB_SIMPLE_QUEUE *Queue,
|
||||
IN VOID *Item,
|
||||
IN UINTN ItemSize
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Dequeue a item from the queue.
|
||||
|
||||
@param Queue Points to the queue.
|
||||
@param Item Receives the item.
|
||||
@param ItemSize Size of the item.
|
||||
|
||||
@retval EFI_SUCCESS Item was successfully dequeued.
|
||||
@retval EFI_DEVICE_ERROR The queue is empty.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
Dequeue (
|
||||
IN OUT USB_SIMPLE_QUEUE *Queue,
|
||||
OUT VOID *Item,
|
||||
IN UINTN ItemSize
|
||||
);
|
||||
|
||||
/**
|
||||
Handler for Repeat Key event.
|
||||
|
||||
This function is the handler for Repeat Key event triggered
|
||||
by timer.
|
||||
After a repeatable key is pressed, the event would be triggered
|
||||
with interval of USBKBD_REPEAT_DELAY. Once the event is triggered,
|
||||
following trigger will come with interval of USBKBD_REPEAT_RATE.
|
||||
|
||||
@param Event The Repeat Key event.
|
||||
@param Context Points to the USB_KB_DEV instance.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
USBKeyboardRepeatHandler (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
Sets USB keyboard LED state.
|
||||
|
||||
@param UsbKeyboardDevice The USB_KB_DEV instance.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SetKeyLED (
|
||||
IN USB_KB_DEV *UsbKeyboardDevice
|
||||
);
|
||||
|
||||
/**
|
||||
Initialize the key state.
|
||||
|
||||
@param UsbKeyboardDevice The USB_KB_DEV instance.
|
||||
@param KeyState A pointer to receive the key state information.
|
||||
**/
|
||||
VOID
|
||||
InitializeKeyState (
|
||||
IN USB_KB_DEV *UsbKeyboardDevice,
|
||||
OUT EFI_KEY_STATE *KeyState
|
||||
);
|
||||
|
||||
#endif
|
||||
106
Platform/AppleUsbKbDxe/UsbKbDxe.inf
Normal file
106
Platform/AppleUsbKbDxe/UsbKbDxe.inf
Normal file
@ -0,0 +1,106 @@
|
||||
## @file
|
||||
# USB Keyboard Driver that manages USB keyboard and produces Simple Text Input(Ex) Protocol.
|
||||
#
|
||||
# USB Keyboard Driver consumes USB I/O Protocol and Device Path Protocol, and produces
|
||||
# Simple Text Input Protocol and Simple Text Input Ex Protocol on USB keyboard devices.
|
||||
# It initializes the keyboard layout according to info retrieved from HII database.
|
||||
# If HII cannot provide the info, this module uses its carried default one if PCD allows.
|
||||
# It manages the USB keyboard device via Asynchronous Interrupt Transfer of USB I/O Protocol,
|
||||
# and parses the data according to USB HID documents.
|
||||
# This module refers to following specifications:
|
||||
# 1. Universal Serial Bus HID Firmware Specification, ver 1.11
|
||||
# 2. Universal Serial Bus HID Usage Tables, ver 1.12
|
||||
# 3. UEFI Specification, v2.1
|
||||
#
|
||||
# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
# Portions Copyright (C) 2016 - 2018, Download-Fritz. All rights reserved.<BR>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = AppleUsbKbDxe
|
||||
MODULE_UNI_FILE = UsbKbDxe.uni
|
||||
FILE_GUID = D1A1230D-1288-4443-B381-8CC85FA69949
|
||||
MODULE_TYPE = UEFI_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
ENTRY_POINT = USBKeyboardDriverBindingEntryPoint
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 EBC ARM AARCH64
|
||||
#
|
||||
# DRIVER_BINDING = gUsbKeyboardDriverBinding
|
||||
# COMPONENT_NAME = gUsbKeyboardComponentName
|
||||
# COMPONENT_NAME2 = gUsbKeyboardComponentName2
|
||||
#
|
||||
|
||||
[Sources]
|
||||
EfiKey.c
|
||||
EfiKey.h
|
||||
AppleKey.c
|
||||
AppleKey.h
|
||||
KeyBoard.c
|
||||
ComponentName.c
|
||||
KeyBoard.h
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
EfiPkg/EfiPkg.dec
|
||||
OcSupportPkg/OcSupportPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
MemoryAllocationLib
|
||||
UefiLib
|
||||
UefiBootServicesTableLib
|
||||
UefiDriverEntryPoint
|
||||
UefiRuntimeServicesTableLib
|
||||
BaseMemoryLib
|
||||
ReportStatusCodeLib
|
||||
DebugLib
|
||||
PcdLib
|
||||
UefiUsbLib
|
||||
HiiLib
|
||||
OcGuardLib
|
||||
|
||||
[Guids]
|
||||
#
|
||||
# Event registered to EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group,
|
||||
# which will be triggered by EFI_HII_DATABASE_PROTOCOL.SetKeyboardLayout().
|
||||
#
|
||||
gEfiHiiKeyBoardLayoutGuid ## SOMETIMES_CONSUMES ## Event
|
||||
gUsbKeyboardLayoutPackageGuid ## SOMETIMES_CONSUMES ## HII
|
||||
gUsbKeyboardLayoutKeyGuid ## SOMETIMES_PRODUCES ## UNDEFINED
|
||||
gAppleKeyboardPlatformInfoGuid ## SOMETIMES_CONSUMES
|
||||
|
||||
[Protocols]
|
||||
gEfiUsbIoProtocolGuid ## TO_START
|
||||
gEfiDevicePathProtocolGuid ## TO_START
|
||||
gEfiSimpleTextInProtocolGuid ## BY_START
|
||||
gEfiSimpleTextInputExProtocolGuid ## BY_START
|
||||
#
|
||||
# If HII Database Protocol exists, then keyboard layout from HII database is used.
|
||||
# Otherwise, USB keyboard module tries to use its carried default layout.
|
||||
#
|
||||
gEfiHiiDatabaseProtocolGuid ## SOMETIMES_CONSUMES
|
||||
gAppleKeyMapDatabaseProtocolGuid ## SOMETIMES_CONSUMES
|
||||
gApplePlatformInfoDatabaseProtocolGuid ## SOMETMES_CONSUMES
|
||||
gEfiKeyboardInfoProtocolGuid ## SOMETIMES_PRODUCES
|
||||
|
||||
[FeaturePcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdDisableDefaultKeyboardLayoutInUsbKbDriver ## CONSUMES
|
||||
gOcSupportPkgTokenSpaceGuid.PcdEnableDisconnectOnExitBootServicesInUsbKbDriver ## CONSUMES
|
||||
gOcSupportPkgTokenSpaceGuid.PcdNotifyAppleKeyMapDbInUsbKbDriver ## CONSUMES
|
||||
gOcSupportPkgTokenSpaceGuid.PcdUsbKbDriverTakePrecedence ## CONSUMES
|
||||
|
||||
# [Event]
|
||||
# EVENT_TYPE_RELATIVE_TIMER ## CONSUMES
|
||||
#
|
||||
|
||||
[UserExtensions.TianoCore."ExtraFiles"]
|
||||
UsbKbDxeExtra.uni
|
||||
29
Platform/AppleUsbKbDxe/UsbKbDxe.uni
Normal file
29
Platform/AppleUsbKbDxe/UsbKbDxe.uni
Normal file
@ -0,0 +1,29 @@
|
||||
// /** @file
|
||||
// USB Keyboard Driver that manages USB keyboard and produces Simple Text Input(Ex) Protocol.
|
||||
//
|
||||
// USB Keyboard Driver consumes USB I/O Protocol and Device Path Protocol, and produces
|
||||
// Simple Text Input Protocol and Simple Text Input Ex Protocol on USB keyboard devices.
|
||||
// It initializes the keyboard layout according to info retrieved from HII database.
|
||||
// If HII cannot provide the info, this module uses its carried default one if PCD allows.
|
||||
// It manages the USB keyboard device via Asynchronous Interrupt Transfer of USB I/O Protocol,
|
||||
// and parses the data according to USB HID documents.
|
||||
// This module refers to following specifications:
|
||||
// 1. Universal Serial Bus HID Firmware Specification, ver 1.11
|
||||
// 2. Universal Serial Bus HID Usage Tables, ver 1.12
|
||||
// 3. UEFI Specification, v2.1
|
||||
//
|
||||
// Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// **/
|
||||
|
||||
|
||||
#string STR_MODULE_ABSTRACT #language en-US "Manages USB keyboard and produces Simple Text Input(Ex) Protocol"
|
||||
|
||||
#string STR_MODULE_DESCRIPTION #language en-US "USB Keyboard Driver consumes USB I/O Protocol and Device Path Protocol, and produces Simple Text Input Protocol and Simple Text Input Ex Protocol on USB keyboard devices. It initializes the keyboard layout according to information retrieved from the HII database. If HII cannot provide the information, this module uses its carried default one if PCD allows. It manages the USB keyboard device via Asynchronous Interrupt Transfer of USB I/O Protocol, and parses the data according to USB HID documents.<BR><BR>\n"
|
||||
"This module refers to following specifications:<BR>\n"
|
||||
"1. Universal Serial Bus HID Firmware Specification, ver 1.11<BR>\n"
|
||||
"2. Universal Serial Bus HID Usage Tables, ver 1.12<BR>\n"
|
||||
"3. UEFI Specification, v2.1<BR>"
|
||||
|
||||
14
Platform/AppleUsbKbDxe/UsbKbDxeExtra.uni
Normal file
14
Platform/AppleUsbKbDxe/UsbKbDxeExtra.uni
Normal file
@ -0,0 +1,14 @@
|
||||
// /** @file
|
||||
// UsbKbDxe Localized Strings and Content
|
||||
//
|
||||
// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// **/
|
||||
|
||||
#string STR_PROPERTIES_MODULE_NAME
|
||||
#language en-US
|
||||
"USB Keyboard DXE Driver"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user