From a7022cec4e8b46d7f2bfc1ee84333cf6e71e633b Mon Sep 17 00:00:00 2001 From: eric_tian Date: Wed, 23 Jul 2008 06:29:46 +0000 Subject: [PATCH] modify coding style to pass ecc tool git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5551 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Bus/Usb/UsbKbDxe/ComponentName.c | 13 +- .../Bus/Usb/UsbKbDxe/{efikey.c => EfiKey.c} | 500 ++++++++++-------- .../Bus/Usb/UsbKbDxe/{efikey.h => EfiKey.h} | 177 +++---- .../Usb/UsbKbDxe/{keyboard.c => KeyBoard.c} | 277 +++++----- MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h | 260 +++++++++ MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf | 8 +- MdeModulePkg/Bus/Usb/UsbKbDxe/keyboard.h | 118 ----- 7 files changed, 747 insertions(+), 606 deletions(-) rename MdeModulePkg/Bus/Usb/UsbKbDxe/{efikey.c => EfiKey.c} (71%) rename MdeModulePkg/Bus/Usb/UsbKbDxe/{efikey.h => EfiKey.h} (63%) rename MdeModulePkg/Bus/Usb/UsbKbDxe/{keyboard.c => KeyBoard.c} (90%) create mode 100644 MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h delete mode 100644 MdeModulePkg/Bus/Usb/UsbKbDxe/keyboard.h diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/ComponentName.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/ComponentName.c index b95b703350..e40a79b9f3 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/ComponentName.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/ComponentName.c @@ -1,6 +1,8 @@ /** @file -Copyright (c) 2004 - 2007, Intel Corporation + UEFI Component Name(2) protocol implementation for Usb Keyboard driver. + +Copyright (c) 2004 - 2008, Intel Corporation All rights reserved. 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 @@ -9,17 +11,10 @@ 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. -Module Name: - - ComponentName.c - -Abstract: - - **/ -#include "keyboard.h" +#include "KeyBoard.h" // // EFI Component Name Functions diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/efikey.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c similarity index 71% rename from MdeModulePkg/Bus/Usb/UsbKbDxe/efikey.c rename to MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c index 50413bd500..b971903a2d 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/efikey.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c @@ -1,5 +1,7 @@ /** @file + USB Keyboard Driver that includes the implementation of interface. + Copyright (c) 2004 - 2008, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -9,26 +11,21 @@ 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. -Module Name: - - EfiKey.c - -Abstract: - - USB Keyboard Driver - -Revision History - - **/ -#include "efikey.h" -#include "keyboard.h" +#include "EfiKey.h" +#include "KeyBoard.h" -// -// Prototypes -// Driver model protocol interface -// +/** + The Usb Keyboard Driver Entry Point. + + @param ImageHandle The driver image handle. + @param SystemTable The system table. + + @return EFI_SUCCESS The component name protocol is installed. + @return Others Failed to install. + +**/ EFI_STATUS EFIAPI USBKeyboardDriverBindingEntryPoint ( @@ -36,6 +33,16 @@ USBKeyboardDriverBindingEntryPoint ( IN EFI_SYSTEM_TABLE *SystemTable ); +/** + Check whether USB keyboard driver support 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 EFI_UNSUPPORTED This device isn't supported. +**/ EFI_STATUS EFIAPI USBKeyboardDriverBindingSupported ( @@ -44,6 +51,17 @@ USBKeyboardDriverBindingSupported ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ); +/** + Start running driver on the controller. + + @param This The USB keyboard driver binding instance. + @param Controller The controller to check. + @param RemainingDevicePath The remaining device patch. + + @retval EFI_SUCCESS The controller is controlled by the usb keyboard driver. + @return Other The keyboard driver doesn't support this controller. + +**/ EFI_STATUS EFIAPI USBKeyboardDriverBindingStart ( @@ -52,6 +70,18 @@ USBKeyboardDriverBindingStart ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ); +/** + Stop handle the controller by this USB keyboard 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 controller or children are stopped. + @retval EFI_DEVICE_ERROR Failed to stop the driver. + +**/ EFI_STATUS EFIAPI USBKeyboardDriverBindingStop ( @@ -61,10 +91,16 @@ USBKeyboardDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer ); -// -// Simple Text In Protocol Interface -// -STATIC +/** + Reset Usb Keyboard. + + @param This The protocol instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL. + @param ExtendedVerification Whether completely reset keyboard or not. + + @retval EFI_SUCCESS Reset keyboard successfully. + @retval EFI_DEVICE_ERROR Reset keyboard failed. + +**/ EFI_STATUS EFIAPI USBKeyboardReset ( @@ -72,7 +108,17 @@ USBKeyboardReset ( IN BOOLEAN ExtendedVerification ); -STATIC +/** + Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke() function. + + @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 Read key stroke successfully. + @retval Other Read key stroke failed. + +**/ EFI_STATUS EFIAPI USBKeyboardReadKeyStroke ( @@ -80,7 +126,14 @@ USBKeyboardReadKeyStroke ( OUT EFI_INPUT_KEY *Key ); -STATIC +/** + Handler function for WaitForKey event. + + @param Event Event to be signaled when a key is pressed. + @param Context Points to USB_KB_DEV instance. + + @return None. +**/ VOID EFIAPI USBKeyboardWaitForKey ( @@ -88,11 +141,17 @@ USBKeyboardWaitForKey ( IN VOID *Context ); -// -// Helper functions -// -STATIC +/** + Check whether there is key pending. + + @param UsbKeyboardDevice The USB_KB_DEV instance. + + @retval EFI_SUCCESS Have key pending to read. + @retval Other Parse key failed. + +**/ EFI_STATUS +EFIAPI USBKeyboardCheckForKey ( IN USB_KB_DEV *UsbKeyboardDevice ); @@ -100,13 +159,36 @@ USBKeyboardCheckForKey ( EFI_GUID gEfiUsbKeyboardDriverGuid = { 0xa05f5f78, 0xfb3, 0x4d10, {0x90, 0x90, 0xac, 0x4, 0x6e, 0xeb, 0x7c, 0x3c} }; -STATIC + +/** + Free keyboard notify list. + + @param ListHead The list head. + + @retval EFI_SUCCESS Free the notify list successfully. + @retval EFI_INVALID_PARAMETER ListHead is invalid. + +**/ EFI_STATUS +EFIAPI KbdFreeNotifyList ( IN OUT LIST_ENTRY *ListHead ); -STATIC + +/** + Whether the pressed key matches a registered key or not. + + @param RegsiteredData A pointer to a buffer that is filled in with the keystroke + state data for the key that was registered. + @param InputData A pointer to a buffer that is filled in with the keystroke + state data for the key that was pressed. + + @retval TRUE Key pressed matches a registered key. + @retval FLASE Match failed. + +**/ BOOLEAN +EFIAPI IsKeyRegistered ( IN EFI_KEY_DATA *RegsiteredData, IN EFI_KEY_DATA *InputData @@ -125,24 +207,22 @@ EFI_DRIVER_BINDING_PROTOCOL gUsbKeyboardDriverBinding = { NULL }; +/** + The Usb Keyboard Driver Entry Point. + + @param ImageHandle The driver image handle. + @param SystemTable The system table. + + @return EFI_SUCCESS The component name protocol is installed. + @return Others Failed to install. + +**/ EFI_STATUS EFIAPI USBKeyboardDriverBindingEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) -/*++ - - Routine Description: - Driver Entry Point. - - Arguments: - ImageHandle - EFI_HANDLE - SystemTable - EFI_SYSTEM_TABLE - Returns: - EFI_STATUS - ---*/ { return EfiLibInstallDriverBindingComponentName2 ( ImageHandle, @@ -154,16 +234,15 @@ USBKeyboardDriverBindingEntryPoint ( ); } - - /** - Supported. + Check whether USB keyboard driver support this device. - @param This EFI_DRIVER_BINDING_PROTOCOL - @param Controller Controller handle - @param RemainingDevicePath EFI_DEVICE_PATH_PROTOCOL - EFI_STATUS + @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 EFI_UNSUPPORTED This device isn't supported. **/ EFI_STATUS EFIAPI @@ -212,17 +291,15 @@ USBKeyboardDriverBindingSupported ( return Status; } - /** - Start. + Start running driver on the controller. - @param This EFI_DRIVER_BINDING_PROTOCOL - @param Controller Controller handle - @param RemainingDevicePath EFI_DEVICE_PATH_PROTOCOL + @param This The USB keyboard driver binding instance. + @param Controller The controller to check. + @param RemainingDevicePath The remaining device patch. - @retval EFI_SUCCESS Success - @retval EFI_OUT_OF_RESOURCES Can't allocate memory - @retval EFI_UNSUPPORTED The Start routine fail + @retval EFI_SUCCESS The controller is controlled by the usb keyboard driver. + @return Other The keyboard driver doesn't support this controller. **/ EFI_STATUS @@ -546,17 +623,16 @@ ErrorExit: } - /** - Stop. + Stop handle the controller by this USB keyboard driver. - @param This EFI_DRIVER_BINDING_PROTOCOL - @param Controller Controller handle - @param NumberOfChildren Child handle number - @param ChildHandleBuffer Child handle buffer + @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 Success - @retval EFI_UNSUPPORTED Can't support + @retval EFI_SUCCESS The controller or children are stopped. + @retval EFI_DEVICE_ERROR Failed to stop the driver. **/ EFI_STATUS @@ -668,31 +744,27 @@ USBKeyboardDriverBindingStop ( } -STATIC +/** + Reads the next keystroke from the input device. The WaitForKey Event can + be used to test for existance of a keystroke via WaitForEvent () call. + + @param UsbKeyboardDevice Usb keyboard's private structure. + @param KeyData A pointer to a buffer that is filled in with the keystroke + state data for the key that was pressed. + + @return EFI_SUCCESS The keystroke information was returned. + @return EFI_NOT_READY There was no keystroke data availiable. + @return EFI_DEVICE_ERROR The keystroke information was not returned due to + hardware errors. + @return EFI_INVALID_PARAMETER KeyData is NULL. + +**/ EFI_STATUS +EFIAPI USBKeyboardReadKeyStrokeWorker ( IN USB_KB_DEV *UsbKeyboardDevice, OUT EFI_KEY_DATA *KeyData ) -/*++ - - Routine Description: - Reads the next keystroke from the input device. The WaitForKey Event can - be used to test for existance of a keystroke via WaitForEvent () call. - - Arguments: - UsbKeyboardDevice - Usb keyboard private structure. - KeyData - A pointer to a buffer that is filled in with the keystroke - state data for the key that was pressed. - - Returns: - EFI_SUCCESS - The keystroke information was returned. - EFI_NOT_READY - There was no keystroke data availiable. - EFI_DEVICE_ERROR - The keystroke information was not returned due to - hardware errors. - EFI_INVALID_PARAMETER - KeyData is NULL. - ---*/ { EFI_STATUS Status; @@ -741,9 +813,9 @@ USBKeyboardReadKeyStrokeWorker ( // their corresponding control value (ctrl-a = 0x0001 through ctrl-Z = 0x001A), here switch them back for notification function. // CopyMem (&OriginalKeyData, KeyData, sizeof (EFI_KEY_DATA)); - if (UsbKeyboardDevice->CtrlOn) { + if (UsbKeyboardDevice->CtrlOn != 0) { if (OriginalKeyData.Key.UnicodeChar >= 0x01 && OriginalKeyData.Key.UnicodeChar <= 0x1A) { - if (UsbKeyboardDevice->CapsOn) { + if (UsbKeyboardDevice->CapsOn != 0) { OriginalKeyData.Key.UnicodeChar = (CHAR16)(OriginalKeyData.Key.UnicodeChar + 'A' - 1); } else { OriginalKeyData.Key.UnicodeChar = (CHAR16)(OriginalKeyData.Key.UnicodeChar + 'a' - 1); @@ -769,6 +841,17 @@ USBKeyboardReadKeyStrokeWorker ( return EFI_SUCCESS; } + +/** + Reset Usb Keyboard. + + @param This The protocol instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL. + @param ExtendedVerification Whether completely reset keyboard or not. + + @retval EFI_SUCCESS Reset keyboard successfully. + @retval EFI_DEVICE_ERROR Reset keyboard failed. + +**/ EFI_STATUS EFIAPI USBKeyboardReset ( @@ -822,14 +905,14 @@ USBKeyboardReset ( /** Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke() function. - This The EFI_SIMPLE_TEXT_INPUT_PROTOCOL instance. - Key A pointer to a buffer that is filled in with the keystroke - information for the key that was pressed. + @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 Success + @retval EFI_SUCCESS Read key stroke successfully. + @retval Other Read key stroke failed. **/ -STATIC EFI_STATUS EFIAPI USBKeyboardReadKeyStroke ( @@ -858,13 +941,11 @@ USBKeyboardReadKeyStroke ( /** Handler function for WaitForKey event. - Event Event to be signaled when a key is pressed. - Context Points to USB_KB_DEV instance. - - @return VOID + @param Event Event to be signaled when a key is pressed. + @param Context Points to USB_KB_DEV instance. + @return None. **/ -STATIC VOID EFIAPI USBKeyboardWaitForKey ( @@ -889,17 +970,17 @@ USBKeyboardWaitForKey ( } - /** Check whether there is key pending. - UsbKeyboardDevice The USB_KB_DEV instance. + @param UsbKeyboardDevice The USB_KB_DEV instance. - @retval EFI_SUCCESS Success + @retval EFI_SUCCESS Have key pending to read. + @retval Other Parse key failed. **/ -STATIC EFI_STATUS +EFIAPI USBKeyboardCheckForKey ( IN USB_KB_DEV *UsbKeyboardDevice ) @@ -920,18 +1001,18 @@ USBKeyboardCheckForKey ( return EFI_SUCCESS; } - /** - Report Status Code in Usb Bot Driver + Report Status Code in Usb Keyboard Driver. - @param DevicePath Use this to get Device Path - @param CodeType Status Code Type - @param CodeValue Status Code Value + @param DevicePath Use this to get Device Path. + @param CodeType Status Code Type. + @param CodeValue Status Code Value. - @return None + @return None. **/ VOID +EFIAPI KbdReportStatusCode ( IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN EFI_STATUS_CODE_TYPE CodeType, @@ -945,25 +1026,21 @@ KbdReportStatusCode ( DevicePath ); } -STATIC + +/** + Free keyboard notify list. + + @param ListHead The list head. + + @retval EFI_SUCCESS Free the notify list successfully. + @retval EFI_INVALID_PARAMETER ListHead is invalid. + +**/ EFI_STATUS +EFIAPI KbdFreeNotifyList ( IN OUT LIST_ENTRY *ListHead ) -/*++ - -Routine Description: - -Arguments: - - ListHead - The list head - -Returns: - - EFI_SUCCESS - Free the notify list successfully - EFI_INVALID_PARAMETER - ListHead is invalid. - ---*/ { KEYBOARD_CONSOLE_IN_EX_NOTIFY *NotifyNode; @@ -984,28 +1061,24 @@ Returns: return EFI_SUCCESS; } -STATIC +/** + Whether the pressed key matches a registered key or not. + + @param RegsiteredData A pointer to a buffer that is filled in with the keystroke + state data for the key that was registered. + @param InputData A pointer to a buffer that is filled in with the keystroke + state data for the key that was pressed. + + @retval TRUE Key pressed matches a registered key. + @retval FLASE Match failed. + +**/ BOOLEAN +EFIAPI IsKeyRegistered ( IN EFI_KEY_DATA *RegsiteredData, IN EFI_KEY_DATA *InputData ) -/*++ - -Routine Description: - -Arguments: - - RegsiteredData - A pointer to a buffer that is filled in with the keystroke - state data for the key that was registered. - InputData - A pointer to a buffer that is filled in with the keystroke - state data for the key that was pressed. - -Returns: - TRUE - Key be pressed matches a registered key. - FLASE - Match failed. - ---*/ { ASSERT (RegsiteredData != NULL && InputData != NULL); @@ -1033,27 +1106,23 @@ Returns: // // Simple Text Input Ex protocol functions // +/** + The extension routine to reset the input device. + + @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 USBKeyboardResetEx ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN BOOLEAN ExtendedVerification ) -/*++ - - Routine Description: - Reset the input device and optionaly run diagnostics - - Arguments: - This - Protocol instance pointer. - ExtendedVerification - Driver may perform diagnostics on reset. - - Returns: - EFI_SUCCESS - The device was reset. - EFI_DEVICE_ERROR - The device is not functioning properly and could - not be reset. - ---*/ { EFI_STATUS Status; USB_KB_DEV *UsbKeyboardDevice; @@ -1076,31 +1145,25 @@ USBKeyboardResetEx ( } +/** + Reads the next keystroke from the input device. The WaitForKey Event can + be used to test for existance of a keystroke via WaitForEvent () call. + + @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. + + @return EFI_SUCCESS The keystroke information was returned successfully. + @retval EFI_INVALID_PARAMETER KeyData is NULL. + @retval Other Read key stroke information failed. + +**/ EFI_STATUS EFIAPI USBKeyboardReadKeyStrokeEx ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, OUT EFI_KEY_DATA *KeyData ) -/*++ - - Routine Description: - Reads the next keystroke from the input device. The WaitForKey Event can - be used to test for existance of a keystroke via WaitForEvent () call. - - Arguments: - This - Protocol instance pointer. - KeyData - A pointer to a buffer that is filled in with the keystroke - state data for the key that was pressed. - - Returns: - EFI_SUCCESS - The keystroke information was returned. - EFI_NOT_READY - There was no keystroke data availiable. - EFI_DEVICE_ERROR - The keystroke information was not returned due to - hardware errors. - EFI_INVALID_PARAMETER - KeyData is NULL. - ---*/ { USB_KB_DEV *UsbKeyboardDevice; @@ -1114,30 +1177,24 @@ USBKeyboardReadKeyStrokeEx ( } +/** + 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 successfully. + @retval EFI_UNSUPPORTED The device does not have the ability to set its state. + @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 ) -/*++ - - Routine Description: - Set certain state for the input device. - - Arguments: - This - Protocol instance pointer. - KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the - state for the input device. - - Returns: - EFI_SUCCESS - The device state was set successfully. - EFI_DEVICE_ERROR - The device is not functioning correctly and could - not have the setting adjusted. - EFI_UNSUPPORTED - The device does not have the ability to set its state. - EFI_INVALID_PARAMETER - KeyToggleState is NULL. - ---*/ { USB_KB_DEV *UsbKeyboardDevice; @@ -1178,33 +1235,29 @@ USBKeyboardSetState ( } +/** + 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 data for the key that was pressed. + @param KeyNotificationFunction Points to the function to be called when the key + sequence is typed specified by KeyData. + @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 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 EFI_HANDLE *NotifyHandle + OUT EFI_HANDLE *NotifyHandle ) -/*++ - - Routine Description: - Register a notification function for a particular keystroke for the input device. - - Arguments: - This - Protocol instance pointer. - KeyData - A pointer to a buffer that is filled in with the keystroke - information data for the key that was pressed. - KeyNotificationFunction - Points to the function to be called when the key - sequence is typed specified by KeyData. - NotifyHandle - Points to the unique handle assigned to the registered notification. - - Returns: - EFI_SUCCESS - The notification function was registered successfully. - EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures. - EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL. - ---*/ { USB_KB_DEV *UsbKeyboardDevice; EFI_STATUS Status; @@ -1266,27 +1319,24 @@ USBKeyboardRegisterKeyNotify ( } +/** + 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 or opening gSimpleTextInExNotifyGuid + on NotificationHandle fails. + @retval EFI_NOT_FOUND Can not find the matching entry in database. + +**/ EFI_STATUS EFIAPI USBKeyboardUnregisterKeyNotify ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_HANDLE NotificationHandle ) -/*++ - - Routine Description: - Remove a registered notification function from a particular keystroke. - - Arguments: - This - Protocol instance pointer. - NotificationHandle - The handle of the notification function being unregistered. - - Returns: - EFI_SUCCESS - The notification function was unregistered successfully. - EFI_INVALID_PARAMETER - The NotificationHandle is invalid. - EFI_NOT_FOUND - Can not find the matching entry in database. - ---*/ { USB_KB_DEV *UsbKeyboardDevice; EFI_STATUS Status; diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/efikey.h b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h similarity index 63% rename from MdeModulePkg/Bus/Usb/UsbKbDxe/efikey.h rename to MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h index 19443949e9..b933201cc9 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/efikey.h +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h @@ -1,4 +1,7 @@ /** @file + + Header file for USB Keyboard Driver's Data Structures. + Copyright (c) 2004 - 2008, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -8,19 +11,9 @@ 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. -Module Name: - - EfiKey.h - -Abstract: - - Header file for USB Keyboard Driver's Data Structures - -Revision History - **/ -#ifndef _USB_KB_H -#define _USB_KB_H +#ifndef _EFI_USB_KB_H_ +#define _EFI_USB_KB_H_ #include @@ -164,7 +157,18 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gUsbKeyboardComponentName2; extern EFI_GUID gEfiUsbKeyboardDriverGuid; extern EFI_GUID gSimpleTextInExNotifyGuid; +/** + Report Status Code in Usb Keyboard Driver. + + @param DevicePath Use this to get Device Path. + @param CodeType Status Code Type. + @param CodeValue Status Code Value. + + @return None. + +**/ VOID +EFIAPI KbdReportStatusCode ( IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN EFI_STATUS_CODE_TYPE CodeType, @@ -205,82 +209,81 @@ typedef struct { // // Simple Text Input Ex protocol functions // +/** + The extension routine to reset the input device. + + @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 USBKeyboardResetEx ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN BOOLEAN ExtendedVerification ) -/*++ - - Routine Description: - Reset the input device and optionaly run diagnostics - - Arguments: - This - Protocol instance pointer. - ExtendedVerification - Driver may perform diagnostics on reset. - - Returns: - EFI_SUCCESS - The device was reset. - EFI_DEVICE_ERROR - The device is not functioning properly and could - not be reset. - ---*/ ; +/** + Reads the next keystroke from the input device. The WaitForKey Event can + be used to test for existance of a keystroke via WaitForEvent () call. + + @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. + + @return EFI_SUCCESS The keystroke information was returned successfully. + @retval EFI_INVALID_PARAMETER KeyData is NULL. + @retval Other Read key stroke information failed. + +**/ EFI_STATUS EFIAPI USBKeyboardReadKeyStrokeEx ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, OUT EFI_KEY_DATA *KeyData ) -/*++ - - Routine Description: - Reads the next keystroke from the input device. The WaitForKey Event can - be used to test for existance of a keystroke via WaitForEvent () call. - - Arguments: - This - Protocol instance pointer. - KeyData - A pointer to a buffer that is filled in with the keystroke - state data for the key that was pressed. - - Returns: - EFI_SUCCESS - The keystroke information was returned. - EFI_NOT_READY - There was no keystroke data availiable. - EFI_DEVICE_ERROR - The keystroke information was not returned due to - hardware errors. - EFI_INVALID_PARAMETER - KeyData is NULL. - ---*/ ; +/** + 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 successfully. + @retval EFI_UNSUPPORTED The device does not have the ability to set its state. + @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 ) -/*++ - - Routine Description: - Set certain state for the input device. - - Arguments: - This - Protocol instance pointer. - KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the - state for the input device. - - Returns: - EFI_SUCCESS - The device state was set successfully. - EFI_DEVICE_ERROR - The device is not functioning correctly and could - not have the setting adjusted. - EFI_UNSUPPORTED - The device does not have the ability to set its state. - EFI_INVALID_PARAMETER - KeyToggleState is NULL. - ---*/ ; +/** + 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 data for the key that was pressed. + @param KeyNotificationFunction Points to the function to be called when the key + sequence is typed specified by KeyData. + @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 is NULL. + +**/ EFI_STATUS EFIAPI USBKeyboardRegisterKeyNotify ( @@ -289,48 +292,26 @@ USBKeyboardRegisterKeyNotify ( IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction, OUT EFI_HANDLE *NotifyHandle ) -/*++ - - Routine Description: - Register a notification function for a particular keystroke for the input device. - - Arguments: - This - Protocol instance pointer. - KeyData - A pointer to a buffer that is filled in with the keystroke - information data for the key that was pressed. - KeyNotificationFunction - Points to the function to be called when the key - sequence is typed specified by KeyData. - NotifyHandle - Points to the unique handle assigned to the registered notification. - - Returns: - EFI_SUCCESS - The notification function was registered successfully. - EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures. - EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL. - ---*/ ; +/** + 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 or opening gSimpleTextInExNotifyGuid + on NotificationHandle fails. + @retval EFI_NOT_FOUND Can not find the matching entry in database. + +**/ EFI_STATUS EFIAPI USBKeyboardUnregisterKeyNotify ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_HANDLE NotificationHandle ) -/*++ - - Routine Description: - Remove a registered notification function from a particular keystroke. - - Arguments: - This - Protocol instance pointer. - NotificationHandle - The handle of the notification function being unregistered. - - Returns: - EFI_SUCCESS - The notification function was unregistered successfully. - EFI_INVALID_PARAMETER - The NotificationHandle is invalid. - EFI_NOT_FOUND - Can not find the matching entry in database. - ---*/ ; #endif diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/keyboard.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c similarity index 90% rename from MdeModulePkg/Bus/Usb/UsbKbDxe/keyboard.c rename to MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c index b7cd8c1199..489ec5c61b 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/keyboard.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c @@ -1,5 +1,7 @@ /** @file + Helper functions for USB Keyboard Driver. + Copyright (c) 2004 - 2008, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -9,20 +11,9 @@ 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. -Module Name: - - Keyboard.c - -Abstract: - - Helper functions for USB Keyboard Driver - -Revision History - - **/ -#include "keyboard.h" +#include "KeyBoard.h" #include // @@ -140,22 +131,18 @@ UINT8 KeyboardLayoutTable[USB_KEYCODE_MAX_MAKE + 8][5] = { {EfiKeyA3, 0, 0, EFI_RIGHT_LOGO_MODIFIER, 0}, // 0xe7 }; +/** + Initialize KeyConvertionTable by using default keyboard layout. + + @param UsbKeyboardDevice The USB_KB_DEV instance. + @retval None. + +**/ VOID +EFIAPI LoadDefaultKeyboardLayout ( IN USB_KB_DEV *UsbKeyboardDevice ) -/*++ - - Routine Description: - Initialize KeyConvertionTable by using default keyboard layout. - - Arguments: - UsbKeyboardDevice The USB_KB_DEV instance. - - Returns: - None. - ---*/ { UINTN Index; EFI_KEY_DESCRIPTOR *KeyDescriptor; @@ -350,11 +337,12 @@ STATIC KB_MODIFIER KB_Mod[8] = { /** Uses USB I/O to check whether the device is a USB Keyboard device. - UsbIo: Points to a USB I/O protocol instance. - + @param UsbIo Points to a USB I/O protocol instance. + @retval None **/ BOOLEAN +EFIAPI IsUSBKeyboard ( IN EFI_USB_IO_PROTOCOL *UsbIo ) @@ -386,23 +374,17 @@ IsUSBKeyboard ( return FALSE; } +/** + Get current keyboard layout from HII database. + @retval Pointer to EFI_HII_KEYBOARD_LAYOUT. + +**/ EFI_HII_KEYBOARD_LAYOUT * +EFIAPI GetCurrentKeyboardLayout ( VOID ) -/*++ - - Routine Description: - Get current keyboard layout from HII database. - - Arguments: - None. - - Returns: - Pointer to EFI_HII_KEYBOARD_LAYOUT. - ---*/ { EFI_STATUS Status; EFI_HII_DATABASE_PROTOCOL *HiiDatabase; @@ -451,24 +433,21 @@ GetCurrentKeyboardLayout ( return KeyboardLayout; } +/** + Find Key Descriptor in KeyConvertionTable given its scan code. + + @param UsbKeyboardDevice The USB_KB_DEV instance. + @param ScanCode USB scan code. + + @return The Key descriptor in KeyConvertionTable. + +**/ EFI_KEY_DESCRIPTOR * +EFIAPI GetKeyDescriptor ( IN USB_KB_DEV *UsbKeyboardDevice, IN UINT8 ScanCode ) -/*++ - - Routine Description: - Find Key Descriptor in KeyConvertionTable given its scan code. - - Arguments: - UsbKeyboardDevice - The USB_KB_DEV instance. - ScanCode - USB scan code. - - Returns: - The Key descriptor in KeyConvertionTable. - ---*/ { UINT8 Index; @@ -485,24 +464,22 @@ GetKeyDescriptor ( return &UsbKeyboardDevice->KeyConvertionTable[Index]; } +/** + Find Non-Spacing key for given KeyDescriptor. + + @param UsbKeyboardDevice The USB_KB_DEV instance. + @param KeyDescriptor Key descriptor. + + @retval NULL Key list is empty. + @return Other The Non-Spacing key. + +**/ USB_NS_KEY * +EFIAPI FindUsbNsKey ( IN USB_KB_DEV *UsbKeyboardDevice, IN EFI_KEY_DESCRIPTOR *KeyDescriptor ) -/*++ - - Routine Description: - Find Non-Spacing key for given KeyDescriptor. - - Arguments: - UsbKeyboardDevice - The USB_KB_DEV instance. - KeyDescriptor - Key descriptor. - - Returns: - The Non-Spacing key. - ---*/ { LIST_ENTRY *Link; USB_NS_KEY *UsbNsKey; @@ -521,24 +498,21 @@ FindUsbNsKey ( return NULL; } +/** + Find physical key definition for a given Key stroke. + + @param UsbNsKey The Non-Spacing key information. + @param KeyDescriptor The key stroke. + + @return The physical key definition. + +**/ EFI_KEY_DESCRIPTOR * +EFIAPI FindPhysicalKey ( IN USB_NS_KEY *UsbNsKey, IN EFI_KEY_DESCRIPTOR *KeyDescriptor ) -/*++ - - Routine Description: - Find physical key definition for a given Key stroke. - - Arguments: - UsbNsKey - The Non-Spacing key information. - KeyDescriptor - The key stroke. - - Returns: - The physical key definition. - ---*/ { UINTN Index; EFI_KEY_DESCRIPTOR *PhysicalKey; @@ -558,22 +532,19 @@ FindPhysicalKey ( return KeyDescriptor; } +/** + The notification function for SET_KEYBOARD_LAYOUT_EVENT. + + @param Event The instance of EFI_EVENT. + @param Context passing parameter. + +**/ VOID EFIAPI SetKeyboardLayoutEvent ( EFI_EVENT Event, VOID *Context ) -/*++ - - Routine Description: - The notification function for SET_KEYBOARD_LAYOUT_EVENT. - - Arguments: - - Returns: - ---*/ { USB_KB_DEV *UsbKeyboardDevice; EFI_HII_KEYBOARD_LAYOUT *KeyboardLayout; @@ -668,22 +639,17 @@ SetKeyboardLayoutEvent ( gBS->FreePool (KeyboardLayout); } +/** + Destroy resources for Keyboard layout. + + @param UsbKeyboardDevice The USB_KB_DEV instance. + +**/ VOID +EFIAPI ReleaseKeyboardLayoutResources ( IN USB_KB_DEV *UsbKeyboardDevice ) -/*++ - - Routine Description: - Destroy resources for Keyboard layout. - - Arguments: - UsbKeyboardDevice - The USB_KB_DEV instance. - - Returns: - None. - ---*/ { USB_NS_KEY *UsbNsKey; LIST_ENTRY *Link; @@ -701,22 +667,20 @@ ReleaseKeyboardLayoutResources ( } } +/** + Initialize USB Keyboard layout. + + @param UsbKeyboardDevice The USB_KB_DEV instance. + + @retval EFI_SUCCESS Initialization Success. + @retval Other Keyboard layout initial failed. + +**/ EFI_STATUS +EFIAPI InitKeyboardLayout ( IN USB_KB_DEV *UsbKeyboardDevice ) -/*++ - - Routine Description: - Initialize USB Keyboard layout. - - Arguments: - UsbKeyboardDevice The USB_KB_DEV instance. - - Returns: - EFI_SUCCESS - Success - Other - Keyboard layout initial failed. ---*/ { EFI_HII_KEYBOARD_LAYOUT *KeyboardLayout; EFI_STATUS Status; @@ -772,13 +736,14 @@ InitKeyboardLayout ( /** Initialize USB Keyboard device and all private data structures. - UsbKeyboardDevice The USB_KB_DEV instance. + @param UsbKeyboardDevice The USB_KB_DEV instance. - @retval EFI_SUCCESS Success - @retval EFI_DEVICE_ERROR Hardware Error + @retval EFI_SUCCESS Initialization is successful. + @retval EFI_DEVICE_ERROR Configure hardware failed. **/ EFI_STATUS +EFIAPI InitUSBKeyboard ( IN USB_KB_DEV *UsbKeyboardDevice ) @@ -895,7 +860,7 @@ InitUSBKeyboard ( // // Set a timer for repeat keys' generation. // - if (UsbKeyboardDevice->RepeatTimer) { + if (UsbKeyboardDevice->RepeatTimer != NULL) { gBS->CloseEvent (UsbKeyboardDevice->RepeatTimer); UsbKeyboardDevice->RepeatTimer = 0; } @@ -908,7 +873,7 @@ InitUSBKeyboard ( &UsbKeyboardDevice->RepeatTimer ); - if (UsbKeyboardDevice->DelayedRecoveryEvent) { + if (UsbKeyboardDevice->DelayedRecoveryEvent != NULL) { gBS->CloseEvent (UsbKeyboardDevice->DelayedRecoveryEvent); UsbKeyboardDevice->DelayedRecoveryEvent = 0; } @@ -928,14 +893,14 @@ InitUSBKeyboard ( /** Handler function for USB Keyboard's asynchronous interrupt transfer. - Data A pointer to a buffer that is filled with key data which is - retrieved via asynchronous interrupt transfer. - DataLength Indicates the size of the data buffer. - Context Pointing to USB_KB_DEV instance. - Result Indicates the result of the asynchronous interrupt transfer. + @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 Success - @retval EFI_DEVICE_ERROR Hardware Error + @retval EFI_SUCCESS Handler is successful. + @retval EFI_DEVICE_ERROR Hardware Error **/ EFI_STATUS @@ -1182,7 +1147,7 @@ KeyboardHandler ( case EFI_LEFT_CONTROL_MODIFIER: case EFI_RIGHT_CONTROL_MODIFIER: - if (UsbKey.Down) { + if (UsbKey.Down != 0) { UsbKeyboardDevice->CtrlOn = 1; } else { UsbKeyboardDevice->CtrlOn = 0; @@ -1191,7 +1156,7 @@ KeyboardHandler ( case EFI_LEFT_ALT_MODIFIER: case EFI_RIGHT_ALT_MODIFIER: - if (UsbKey.Down) { + if (UsbKey.Down != 0) { UsbKeyboardDevice->AltOn = 1; } else { UsbKeyboardDevice->AltOn = 0; @@ -1199,7 +1164,7 @@ KeyboardHandler ( break; case EFI_ALT_GR_MODIFIER: - if (UsbKey.Down) { + if (UsbKey.Down != 0) { UsbKeyboardDevice->AltGrOn = 1; } else { UsbKeyboardDevice->AltGrOn = 0; @@ -1210,8 +1175,8 @@ KeyboardHandler ( // Del Key Code // case EFI_DELETE_MODIFIER: - if (UsbKey.Down) { - if (UsbKeyboardDevice->CtrlOn && UsbKeyboardDevice->AltOn) { + if (UsbKey.Down != 0) { + if ((UsbKeyboardDevice->CtrlOn != 0) && (UsbKeyboardDevice->AltOn != 0)) { gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL); } } @@ -1258,14 +1223,15 @@ KeyboardHandler ( /** Retrieves a key character after parsing the raw data in keyboard buffer. - UsbKeyboardDevice The USB_KB_DEV instance. - KeyChar Points to the Key character after key parsing. + @param UsbKeyboardDevice The USB_KB_DEV instance. + @param KeyChar Points to the Key character after key parsing. - @retval EFI_SUCCESS Success - @retval EFI_NOT_READY Device is not ready + @retval EFI_SUCCESS Parse key is successful. + @retval EFI_NOT_READY Device is not ready. **/ EFI_STATUS +EFIAPI USBParseKey ( IN OUT USB_KB_DEV *UsbKeyboardDevice, OUT UINT8 *KeyChar @@ -1283,7 +1249,7 @@ USBParseKey ( RemoveKeyCode (&(UsbKeyboardDevice->KeyboardBuffer), &UsbKey); KeyDescriptor = GetKeyDescriptor (UsbKeyboardDevice, UsbKey.KeyCode); - if (!UsbKey.Down) { + if (UsbKey.Down == 0) { switch (KeyDescriptor->Modifier) { // @@ -1498,7 +1464,7 @@ USBParseKey ( // When encountered Del Key... // if (KeyDescriptor->Modifier == EFI_DELETE_MODIFIER) { - if (UsbKeyboardDevice->CtrlOn && UsbKeyboardDevice->AltOn) { + if ((UsbKeyboardDevice->CtrlOn != 0) && (UsbKeyboardDevice->AltOn != 0)) { gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL); } } @@ -1511,21 +1477,21 @@ USBParseKey ( } - /** Converts USB Keyboard code to EFI Scan Code. - UsbKeyboardDevice The USB_KB_DEV instance. - KeyChar Indicates the key code that will be interpreted. - Key A pointer to a buffer that is filled in with - the keystroke information for the key that - was pressed. + @param UsbKeyboardDevice The USB_KB_DEV instance. + @param KeyChar Indicates the key code that will be interpreted. + @param Key A pointer to a buffer that is filled in with + the keystroke information for the key that + was pressed. - @retval EFI_NOT_READY Device is not ready - @retval EFI_SUCCESS Success + @retval EFI_NOT_READY Device is not ready + @retval EFI_SUCCESS Success. **/ EFI_STATUS +EFIAPI USBKeyCodeToEFIScanCode ( IN USB_KB_DEV *UsbKeyboardDevice, IN UINT8 KeyChar, @@ -1570,7 +1536,7 @@ USBKeyCodeToEFIScanCode ( Key->UnicodeChar = KeyDescriptor->Unicode; if (KeyDescriptor->AffectedAttribute & EFI_AFFECTED_BY_STANDARD_SHIFT) { - if (UsbKeyboardDevice->ShiftOn) { + if (UsbKeyboardDevice->ShiftOn != 0) { Key->UnicodeChar = KeyDescriptor->ShiftedUnicode; // @@ -1582,7 +1548,7 @@ USBKeyCodeToEFIScanCode ( UsbKeyboardDevice->RightShiftOn = 0; } - if (UsbKeyboardDevice->AltGrOn) { + if (UsbKeyboardDevice->AltGrOn != 0) { Key->UnicodeChar = KeyDescriptor->ShiftedAltGrUnicode; } } else { @@ -1591,14 +1557,14 @@ USBKeyCodeToEFIScanCode ( // Key->UnicodeChar = KeyDescriptor->Unicode; - if (UsbKeyboardDevice->AltGrOn) { + if (UsbKeyboardDevice->AltGrOn != 0) { Key->UnicodeChar = KeyDescriptor->AltGrUnicode; } } } if (KeyDescriptor->AffectedAttribute & EFI_AFFECTED_BY_CAPS_LOCK) { - if (UsbKeyboardDevice->CapsOn) { + if (UsbKeyboardDevice->CapsOn != 0) { if (Key->UnicodeChar == KeyDescriptor->Unicode) { @@ -1615,7 +1581,7 @@ USBKeyCodeToEFIScanCode ( // // Translate the CTRL-Alpha characters to their corresponding control value (ctrl-a = 0x0001 through ctrl-Z = 0x001A) // - if (UsbKeyboardDevice->CtrlOn) { + if (UsbKeyboardDevice->CtrlOn != 0) { if (Key->UnicodeChar >= 'a' && Key->UnicodeChar <= 'z') { Key->UnicodeChar = (UINT8) (Key->UnicodeChar - 'a' + 1); } else if (Key->UnicodeChar >= 'A' && Key->UnicodeChar <= 'Z') { @@ -1625,7 +1591,7 @@ USBKeyCodeToEFIScanCode ( if (KeyDescriptor->AffectedAttribute & EFI_AFFECTED_BY_NUM_LOCK) { - if (UsbKeyboardDevice->NumLockOn && !UsbKeyboardDevice->ShiftOn) { + if ((UsbKeyboardDevice->NumLockOn != 0) && (UsbKeyboardDevice->ShiftOn == 0)) { Key->ScanCode = SCAN_NULL; @@ -1696,16 +1662,16 @@ USBKeyCodeToEFIScanCode ( } - /** Resets USB Keyboard Buffer. @param KeyboardBuffer Points to the USB Keyboard Buffer. - @retval EFI_SUCCESS Success + @retval EFI_SUCCESS Init key buffer successfully. **/ EFI_STATUS +EFIAPI InitUSBKeyBuffer ( IN OUT USB_KB_BUFFER *KeyboardBuffer ) @@ -1723,9 +1689,12 @@ InitUSBKeyBuffer ( @param KeyboardBuffer USB Keyboard Buffer. + @retval TRUE Key buffer is empty. + @retval FALSE Key buffer is not empty. **/ BOOLEAN +EFIAPI IsUSBKeyboardBufferEmpty ( IN USB_KB_BUFFER *KeyboardBuffer ) @@ -1737,15 +1706,17 @@ IsUSBKeyboardBufferEmpty ( } - /** Check whether USB Keyboard buffer is full. @param KeyboardBuffer USB Keyboard Buffer. + @retval TRUE Key buffer is full. + @retval FALSE Key buffer is not full. **/ BOOLEAN +EFIAPI IsUSBKeyboardBufferFull ( IN USB_KB_BUFFER *KeyboardBuffer ) @@ -1755,7 +1726,6 @@ IsUSBKeyboardBufferFull ( } - /** Inserts a key code into keyboard buffer. @@ -1767,6 +1737,7 @@ IsUSBKeyboardBufferFull ( **/ EFI_STATUS +EFIAPI InsertKeyCode ( IN OUT USB_KB_BUFFER *KeyboardBuffer, IN UINT8 Key, @@ -1806,6 +1777,7 @@ InsertKeyCode ( **/ EFI_STATUS +EFIAPI RemoveKeyCode ( IN OUT USB_KB_BUFFER *KeyboardBuffer, OUT USB_KEY *UsbKey @@ -1836,6 +1808,7 @@ RemoveKeyCode ( **/ EFI_STATUS +EFIAPI SetKeyLED ( IN USB_KB_DEV *UsbKeyboardDevice ) diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h new file mode 100644 index 0000000000..22aaf21271 --- /dev/null +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h @@ -0,0 +1,260 @@ +/** @file + + Function prototype for USB Keyboard Driver. + +Copyright (c) 2004 - 2008, Intel Corporation +All rights reserved. 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 _EFI_KEYBOARD_H_ +#define _EFI_KEYBOARD_H_ + + +#include "EfiKey.h" + +/** + Uses USB I/O to check whether the device is a USB Keyboard device. + + @param UsbIo Points to a USB I/O protocol instance. + @retval None + +**/ +BOOLEAN +EFIAPI +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 Configure hardware failed. + +**/ +EFI_STATUS +EFIAPI +InitUSBKeyboard ( + IN USB_KB_DEV *UsbKeyboardDevice + ); + +/** + Initialize USB Keyboard layout. + + @param UsbKeyboardDevice The USB_KB_DEV instance. + + @retval EFI_SUCCESS Initialization Success. + @retval Other Keyboard layout initial failed. + +**/ +EFI_STATUS +EFIAPI +InitKeyboardLayout ( + IN USB_KB_DEV *UsbKeyboardDevice + ); + +/** + Destroy resources for Keyboard layout. + + @param UsbKeyboardDevice The USB_KB_DEV instance. + +**/ +VOID +EFIAPI +ReleaseKeyboardLayoutResources ( + IN USB_KB_DEV *UsbKeyboardDevice + ); + +/** + Handler function for USB Keyboard's asynchronous interrupt transfer. + + @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 Handler is successful. + @retval EFI_DEVICE_ERROR Hardware Error + +**/ +EFI_STATUS +EFIAPI +KeyboardHandler ( + IN VOID *Data, + IN UINTN DataLength, + IN VOID *Context, + IN UINT32 Result + ); + +/** + Timer handler for Delayed Recovery timer. + + @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 key character after parsing the raw data in keyboard buffer. + + @param UsbKeyboardDevice The USB_KB_DEV instance. + @param KeyChar Points to the Key character after key parsing. + + @retval EFI_SUCCESS Parse key is successful. + @retval EFI_NOT_READY Device is not ready. + +**/ +EFI_STATUS +EFIAPI +USBParseKey ( + IN OUT USB_KB_DEV *UsbKeyboardDevice, + OUT UINT8 *KeyChar + ); + +/** + Converts USB Keyboard code to EFI Scan Code. + + @param UsbKeyboardDevice The USB_KB_DEV instance. + @param KeyChar Indicates the key code that will be interpreted. + @param Key A pointer to a buffer that is filled in with + the keystroke information for the key that + was pressed. + + @retval EFI_NOT_READY Device is not ready + @retval EFI_SUCCESS Success. + +**/ +EFI_STATUS +EFIAPI +USBKeyCodeToEFIScanCode ( + IN USB_KB_DEV *UsbKeyboardDevice, + IN UINT8 KeyChar, + OUT EFI_INPUT_KEY *Key + ); + +/** + Resets USB Keyboard Buffer. + + @param KeyboardBuffer Points to the USB Keyboard Buffer. + + @retval EFI_SUCCESS Init key buffer successfully. + +**/ +EFI_STATUS +EFIAPI +InitUSBKeyBuffer ( + IN OUT USB_KB_BUFFER *KeyboardBuffer + ); + +/** + Check whether USB Keyboard buffer is empty. + + @param KeyboardBuffer USB Keyboard Buffer. + + @retval TRUE Key buffer is empty. + @retval FALSE Key buffer is not empty. + +**/ +BOOLEAN +EFIAPI +IsUSBKeyboardBufferEmpty ( + IN USB_KB_BUFFER *KeyboardBuffer + ); + +/** + Check whether USB Keyboard buffer is full. + + @param KeyboardBuffer USB Keyboard Buffer. + + @retval TRUE Key buffer is full. + @retval FALSE Key buffer is not full. + +**/ +BOOLEAN +EFIAPI +IsUSBKeyboardBufferFull ( + IN USB_KB_BUFFER *KeyboardBuffer + ); + +/** + Inserts a key code into keyboard buffer. + + @param KeyboardBuffer Points to the USB Keyboard Buffer. + @param Key Key code + @param Down Special key + + @retval EFI_SUCCESS Success + +**/ +EFI_STATUS +EFIAPI +InsertKeyCode ( + IN OUT USB_KB_BUFFER *KeyboardBuffer, + IN UINT8 Key, + IN UINT8 Down + ); + +/** + Pops a key code off from keyboard buffer. + + @param KeyboardBuffer Points to the USB Keyboard Buffer. + @param UsbKey Points to the buffer that contains a usb key code. + + @retval EFI_SUCCESS Success + @retval EFI_DEVICE_ERROR Hardware Error + +**/ +EFI_STATUS +EFIAPI +RemoveKeyCode ( + IN OUT USB_KB_BUFFER *KeyboardBuffer, + OUT USB_KEY *UsbKey + ); + +/** + Timer handler for Repeat Key timer. + + @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. + + @retval EFI_SUCCESS Success + +**/ +EFI_STATUS +EFIAPI +SetKeyLED ( + IN USB_KB_DEV *UsbKeyboardDevice + ); + +#endif diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf b/MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf index 0a50c277c5..5098a8b9ce 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf @@ -33,11 +33,11 @@ # [Sources.common] - efikey.c - efikey.h - keyboard.c + EfiKey.c + EfiKey.h + KeyBoard.c ComponentName.c - keyboard.h + KeyBoard.h [Packages] MdePkg/MdePkg.dec diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/keyboard.h b/MdeModulePkg/Bus/Usb/UsbKbDxe/keyboard.h deleted file mode 100644 index 2e7ccf7888..0000000000 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/keyboard.h +++ /dev/null @@ -1,118 +0,0 @@ -/** @file -Copyright (c) 2004 - 2005, Intel Corporation -All rights reserved. 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. - -Module Name: - - Keyboard.h - -Abstract: - - Function prototype for USB Keyboard Driver - -Revision History - -**/ - -#ifndef _KEYBOARD_H -#define _KEYBOARD_H - - -#include "efikey.h" - -BOOLEAN -IsUSBKeyboard ( - IN EFI_USB_IO_PROTOCOL *UsbIo - ); - -EFI_STATUS -InitUSBKeyboard ( - IN USB_KB_DEV *UsbKeyboardDevice - ); - -EFI_STATUS -InitKeyboardLayout ( - IN USB_KB_DEV *UsbKeyboardDevice - ); - -VOID -ReleaseKeyboardLayoutResources ( - USB_KB_DEV *UsbKeyboardDevice - ); - -EFI_STATUS -EFIAPI -KeyboardHandler ( - IN VOID *Data, - IN UINTN DataLength, - IN VOID *Context, - IN UINT32 Result - ); - -VOID -EFIAPI -USBKeyboardRecoveryHandler ( - IN EFI_EVENT Event, - IN VOID *Context - ); - -EFI_STATUS -USBParseKey ( - IN OUT USB_KB_DEV *UsbKeyboardDevice, - OUT UINT8 *KeyChar - ); - -EFI_STATUS -USBKeyCodeToEFIScanCode ( - IN USB_KB_DEV *UsbKeyboardDevice, - IN UINT8 KeyChar, - OUT EFI_INPUT_KEY *Key - ); - -EFI_STATUS -InitUSBKeyBuffer ( - IN OUT USB_KB_BUFFER *KeyboardBuffer - ); - -BOOLEAN -IsUSBKeyboardBufferEmpty ( - IN USB_KB_BUFFER *KeyboardBuffer - ); - -BOOLEAN -IsUSBKeyboardBufferFull ( - IN USB_KB_BUFFER *KeyboardBuffer - ); - -EFI_STATUS -InsertKeyCode ( - IN OUT USB_KB_BUFFER *KeyboardBuffer, - IN UINT8 Key, - IN UINT8 Down - ); - -EFI_STATUS -RemoveKeyCode ( - IN OUT USB_KB_BUFFER *KeyboardBuffer, - OUT USB_KEY *UsbKey - ); - -VOID -EFIAPI -USBKeyboardRepeatHandler ( - IN EFI_EVENT Event, - IN VOID *Context - ); - -EFI_STATUS -SetKeyLED ( - IN USB_KB_DEV *UsbKeyboardDevice - ); - -#endif