/*++\r
\r
-Copyright (c) 2006, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
Module Name:\r
\r
Keyboard.c\r
- \r
+\r
Abstract:\r
\r
Helper functions for USB Keyboard Driver\r
{ SCAN_NULL, 0x00, 0x00 }, // 0x39 CapsLock\r
{ SCAN_F1, 0x00, 0x00 }, // 0x3A\r
{ SCAN_F2, 0x00, 0x00 }, // 0x3B\r
- { SCAN_F3, 0x00, 0x00 }, // 0x3C \r
- { SCAN_F4, 0x00, 0x00 }, // 0x3D \r
+ { SCAN_F3, 0x00, 0x00 }, // 0x3C\r
+ { SCAN_F4, 0x00, 0x00 }, // 0x3D\r
{ SCAN_F5, 0x00, 0x00 }, // 0x3E\r
{ SCAN_F6, 0x00, 0x00 }, // 0x3F\r
{ SCAN_F7, 0x00, 0x00 }, // 0x40\r
};\r
\r
STATIC KB_MODIFIER KB_Mod[8] = {\r
- { MOD_CONTROL_L, 0xe0 }, // 11100000 \r
- { MOD_CONTROL_R, 0xe4 }, // 11100100 \r
- { MOD_SHIFT_L, 0xe1 }, // 11100001 \r
- { MOD_SHIFT_R, 0xe5 }, // 11100101 \r
- { MOD_ALT_L, 0xe2 }, // 11100010 \r
- { MOD_ALT_R, 0xe6 }, // 11100110 \r
- { MOD_WIN_L, 0xe3 }, // 11100011 \r
- { MOD_WIN_R, 0xe7 } // 11100111 \r
+ { MOD_CONTROL_L, 0xe0 }, // 11100000\r
+ { MOD_CONTROL_R, 0xe4 }, // 11100100\r
+ { MOD_SHIFT_L, 0xe1 }, // 11100001\r
+ { MOD_SHIFT_R, 0xe5 }, // 11100101\r
+ { MOD_ALT_L, 0xe2 }, // 11100010\r
+ { MOD_ALT_R, 0xe6 }, // 11100110\r
+ { MOD_WIN_L, 0xe3 }, // 11100011\r
+ { MOD_WIN_R, 0xe7 } // 11100111\r
};\r
\r
\r
IN EFI_USB_IO_PROTOCOL *UsbIo\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
Uses USB I/O to check whether the device is a USB Keyboard device.\r
- \r
+\r
Arguments:\r
UsbIo: Points to a USB I/O protocol instance.\r
- \r
+\r
Returns:\r
- \r
---*/ \r
+\r
+--*/\r
{\r
EFI_STATUS Status;\r
EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;\r
IN USB_KB_DEV *UsbKeyboardDevice\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
Initialize USB Keyboard device and all private data structures.\r
- \r
+\r
Arguments:\r
UsbKeyboardDevice The USB_KB_DEV instance.\r
- \r
+\r
Returns:\r
EFI_SUCCESS - Success\r
EFI_DEVICE_ERROR - Hardware Error\r
UsbKeyboardDevice->ShiftOn = 0;\r
UsbKeyboardDevice->NumLockOn = 0;\r
UsbKeyboardDevice->CapsOn = 0;\r
- UsbKeyboardDevice->ScrollOn = 0; \r
+ UsbKeyboardDevice->ScrollOn = 0;\r
ZeroMem (UsbKeyboardDevice->LastKeyCodeArray, sizeof (UINT8) * 8);\r
\r
//\r
}\r
\r
Status = gBS->CreateEvent (\r
- EFI_EVENT_TIMER | EFI_EVENT_NOTIFY_SIGNAL,\r
- EFI_TPL_NOTIFY,\r
+ EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
+ TPL_NOTIFY,\r
USBKeyboardRepeatHandler,\r
UsbKeyboardDevice,\r
&UsbKeyboardDevice->RepeatTimer\r
}\r
\r
Status = gBS->CreateEvent (\r
- EFI_EVENT_TIMER | EFI_EVENT_NOTIFY_SIGNAL,\r
- EFI_TPL_NOTIFY,\r
+ EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
+ TPL_NOTIFY,\r
USBKeyboardRecoveryHandler,\r
UsbKeyboardDevice,\r
&UsbKeyboardDevice->DelayedRecoveryEvent\r
IN UINT32 Result\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
Handler function for USB Keyboard's asynchronous interrupt transfer.\r
- \r
+\r
Arguments:\r
Data A pointer to a buffer that is filled with key data which is\r
retrieved via asynchronous interrupt transfer.\r
DataLength Indicates the size of the data buffer.\r
Context Pointing to USB_KB_DEV instance.\r
Result Indicates the result of the asynchronous interrupt transfer.\r
- \r
+\r
Returns:\r
EFI_SUCCESS - Success\r
EFI_DEVICE_ERROR - Hardware Error\r
---*/ \r
+--*/\r
{\r
USB_KB_DEV *UsbKeyboardDevice;\r
EFI_USB_IO_PROTOCOL *UsbIo;\r
&UsbStatus\r
);\r
}\r
- \r
+\r
//\r
// Delete & Submit this interrupt again\r
//\r
- \r
+\r
UsbIo->UsbAsyncInterruptTransfer (\r
UsbIo,\r
UsbKeyboardDevice->IntEndpointDescriptor.EndpointAddress,\r
if (Index == 8) {\r
return EFI_SUCCESS;\r
}\r
- \r
+\r
//\r
// Parse the modifier key\r
//\r
InsertKeyCode (&(UsbKeyboardDevice->KeyboardBuffer), KB_Mod[Index].Key, Down);\r
}\r
}\r
- \r
+\r
//\r
// handle normal key's releasing situation\r
//\r
}\r
}\r
}\r
- \r
+\r
//\r
// original repeat key is released, cancel the repeat timer\r
//\r
USBKBD_REPEAT_RATE\r
);\r
}\r
- \r
+\r
//\r
// handle normal key's pressing situation\r
//\r
}\r
}\r
}\r
- \r
+\r
//\r
// Update LastKeycodeArray[] buffer in the\r
// Usb Keyboard Device data structure.\r
for (Index = 0; Index < 8; Index++) {\r
UsbKeyboardDevice->LastKeyCodeArray[Index] = CurKeyCodeBuffer[Index];\r
}\r
- \r
+\r
//\r
// pre-process KeyboardBuffer, pop out the ctrl,alt,del key in sequence\r
// and judge whether it will invoke reset event.\r
default:\r
break;\r
}\r
- \r
+\r
//\r
// insert the key back to the buffer.\r
// so the key sequence will not be destroyed.\r
OUT UINT8 *KeyChar\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
Retrieves a key character after parsing the raw data in keyboard buffer.\r
- \r
+\r
Arguments:\r
UsbKeyboardDevice The USB_KB_DEV instance.\r
KeyChar Points to the Key character after key parsing.\r
- \r
+\r
Returns:\r
EFI_SUCCESS - Success\r
- EFI_NOT_READY - Device is not ready \r
---*/ \r
+ EFI_NOT_READY - Device is not ready\r
+--*/\r
{\r
USB_KEY UsbKey;\r
\r
\r
continue;\r
}\r
- \r
+\r
//\r
// Analyzes key pressing situation\r
//\r
UsbKeyboardDevice->ScrollOn ^= 1;\r
SetKeyLED (UsbKeyboardDevice);\r
continue;\r
- break; \r
+ break;\r
case 0x48:\r
//\r
// fall through\r
default:\r
break;\r
}\r
- \r
+\r
//\r
// When encountered Del Key...\r
//\r
OUT EFI_INPUT_KEY *Key\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
Converts USB Keyboard code to EFI Scan Code.\r
- \r
- Arguments: \r
+\r
+ Arguments:\r
UsbKeyboardDevice The USB_KB_DEV instance.\r
- KeyChar Indicates the key code that will be interpreted. \r
- Key A pointer to a buffer that is filled in with \r
- the keystroke information for the key that \r
+ KeyChar Indicates the key code that will be interpreted.\r
+ Key A pointer to a buffer that is filled in with\r
+ the keystroke information for the key that\r
was pressed.\r
Returns:\r
EFI_NOT_READY - Device is not ready\r
if (!USBKBD_VALID_KEYCODE (KeyChar)) {\r
return EFI_NOT_READY;\r
}\r
- \r
+\r
//\r
// valid USB Key Code starts from 4\r
//\r
IN OUT USB_KB_BUFFER *KeyboardBuffer\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
Resets USB Keyboard Buffer.\r
- \r
+\r
Arguments:\r
KeyboardBuffer - Points to the USB Keyboard Buffer.\r
- \r
+\r
Returns:\r
EFI_SUCCESS - Success\r
---*/ \r
+--*/\r
{\r
ZeroMem (KeyboardBuffer, sizeof (USB_KB_BUFFER));\r
\r
IN USB_KB_BUFFER *KeyboardBuffer\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
Check whether USB Keyboard buffer is empty.\r
- \r
+\r
Arguments:\r
KeyboardBuffer - USB Keyboard Buffer.\r
- \r
+\r
Returns:\r
- \r
+\r
--*/\r
{\r
//\r
IN USB_KB_BUFFER *KeyboardBuffer\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
Check whether USB Keyboard buffer is full.\r
- \r
+\r
Arguments:\r
KeyboardBuffer - USB Keyboard Buffer.\r
- \r
+\r
Returns:\r
- \r
+\r
--*/\r
{\r
- return (BOOLEAN)(((KeyboardBuffer->bTail + 1) % (MAX_KEY_ALLOWED + 1)) == \r
+ return (BOOLEAN)(((KeyboardBuffer->bTail + 1) % (MAX_KEY_ALLOWED + 1)) ==\r
KeyboardBuffer->bHead);\r
}\r
\r
IN UINT8 Down\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
Inserts a key code into keyboard buffer.\r
- \r
+\r
Arguments:\r
KeyboardBuffer - Points to the USB Keyboard Buffer.\r
Key - Key code\r
OUT USB_KEY *UsbKey\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
Pops a key code off from keyboard buffer.\r
- \r
+\r
Arguments:\r
KeyboardBuffer - Points to the USB Keyboard Buffer.\r
UsbKey - Points to the buffer that contains a usb key code.\r
- \r
+\r
Returns:\r
EFI_SUCCESS - Success\r
EFI_DEVICE_ERROR - Hardware Error\r
---*/ \r
+--*/\r
{\r
if (IsUSBKeyboardBufferEmpty (KeyboardBuffer)) {\r
return EFI_DEVICE_ERROR;\r
IN USB_KB_DEV *UsbKeyboardDevice\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
Sets USB Keyboard LED state.\r
- \r
+\r
Arguments:\r
UsbKeyboardDevice - The USB_KB_DEV instance.\r
- \r
+\r
Returns:\r
EFI_SUCCESS - Success\r
---*/ \r
+--*/\r
{\r
LED_MAP Led;\r
UINT8 ReportId;\r
//\r
Led.NumLock = (UINT8) UsbKeyboardDevice->NumLockOn;\r
Led.CapsLock = (UINT8) UsbKeyboardDevice->CapsOn;\r
- Led.ScrollLock = (UINT8) UsbKeyboardDevice->ScrollOn; \r
+ Led.ScrollLock = (UINT8) UsbKeyboardDevice->ScrollOn;\r
Led.Resrvd = 0;\r
\r
ReportId = 0;\r
IN VOID *Context\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
Timer handler for Repeat Key timer.\r
- \r
+\r
Arguments:\r
Event - The Repeat Key event.\r
Context - Points to the USB_KB_DEV instance.\r
- \r
+\r
Returns:\r
- \r
---*/ \r
+\r
+--*/\r
{\r
USB_KB_DEV *UsbKeyboardDevice;\r
\r
IN VOID *Context\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
Timer handler for Delayed Recovery timer.\r
- \r
+\r
Arguments:\r
Event - The Delayed Recovery event.\r
Context - Points to the USB_KB_DEV instance.\r
- \r
+\r
Returns:\r
- \r
---*/ \r
+\r
+--*/\r
{\r
\r
USB_KB_DEV *UsbKeyboardDevice;\r