- gBS->RestoreTPL (OldTpl);\r
- return ;\r
- }\r
- //\r
- // To let KB driver support Hot plug, here should skip the 'resend' command for the case that\r
- // KB is not connected to system. If KB is not connected to system, driver will find there's something\r
- // error in the following code and wait for the input buffer empty, this waiting time shoulb be short enough since\r
- // this is a NOTIFY TPL period function, or the system performance will degrade hardly when KB is not connected.\r
- // Just skip the 'resend' process simply.\r
- //\r
-\r
- Data = 0;\r
-\r
- //\r
- // if there is no key present, just return\r
- //\r
- if ((KeyReadStatusRegister (Context) & 0x21) != 0x1) {\r
- //\r
- // Leave critical section and return\r
- //\r
- gBS->RestoreTPL (OldTpl);\r
-\r
- return ;\r
- }\r
- //\r
- // Read one byte of the scan code and store it into the memory buffer\r
- //\r
- if (ConsoleIn->ScancodeBufCount < KEYBOARD_BUFFER_MAX_COUNT) {\r
-\r
- Data = KeyReadDataRegister (Context);\r
- //\r
- // put the scancode into the memory scancode buffer\r
- //\r
- ConsoleIn->ScancodeBufCount++;\r
- ConsoleIn->ScancodeBufEndPos++;\r
- if (ConsoleIn->ScancodeBufEndPos >= KEYBOARD_BUFFER_MAX_COUNT) {\r
- ConsoleIn->ScancodeBufEndPos = 0;\r
- }\r
-\r
- ConsoleIn->ScancodeBuf[ConsoleIn->ScancodeBufEndPos] = Data;\r
-\r
- //\r
- // Handle Alt+Ctrl+Del Key combination\r
- //\r
- switch (Data) {\r
- case SCANCODE_CTRL_MAKE:\r
- ConsoleIn->Ctrled = TRUE;\r
- break;\r
-\r
- case SCANCODE_CTRL_BREAK:\r
- ConsoleIn->Ctrled = FALSE;\r
- break;\r
-\r
- case SCANCODE_ALT_MAKE:\r
- ConsoleIn->Alted = TRUE;\r
- break;\r
-\r
- case SCANCODE_ALT_BREAK:\r
- ConsoleIn->Alted = FALSE;\r
- break;\r
- }\r
- //\r
- // if Alt+Ctrl+Del, Reboot the System\r
- //\r
- if (ConsoleIn->Ctrled && ConsoleIn->Alted && Data == 0x53) {\r
- gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
- }\r
- }\r
- //\r
- // Leave critical section and return\r
- //\r
- gBS->RestoreTPL (OldTpl);\r
-\r
- return ;\r
-}\r
-\r
-/**\r
- Read several bytes from the scancode buffer without removing them.\r
- This function is called to see if there are enough bytes of scancode\r
- representing a single key.\r
-\r
- @param Count - Number of bytes to be read\r
- @param Buf - Store the results\r
-\r
- @retval EFI_SUCCESS success to scan the keyboard code\r
- @retval EFI_NOT_READY invalid parameter\r
-**/\r
-STATIC\r
-EFI_STATUS\r
-GetScancodeBufHead (\r
- KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,\r
- IN UINT32 Count,\r
- OUT UINT8 *Buf\r
- )\r
-{\r
- UINT32 Index;\r
- UINT32 Pos;\r
-\r
- Index = 0;\r
- Pos = 0;\r
-\r
- //\r
- // check the valid range of parameter 'Count'\r
- //\r
- if (Count <= 0 || ConsoleIn->ScancodeBufCount < Count) {\r
- return EFI_NOT_READY;\r
- }\r
- //\r
- // retrieve the values\r
- //\r
- for (Index = 0; Index < Count; Index++) {\r
-\r
- if (Index == 0) {\r
-\r
- Pos = ConsoleIn->ScancodeBufStartPos;\r
- } else {\r
-\r
- Pos = Pos + 1;\r
- if (Pos >= KEYBOARD_BUFFER_MAX_COUNT) {\r
- Pos = 0;\r
- }\r
- }\r
-\r
- Buf[Index] = ConsoleIn->ScancodeBuf[Pos];\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-\r
- Read & remove several bytes from the scancode buffer.\r
- This function is usually called after GetScancodeBufHead()\r
-\r
- @param Count - Number of bytes to be read\r
- @param Buf - Store the results\r
-\r
- @retval EFI_SUCCESS success to scan the keyboard code\r
- @retval EFI_NOT_READY invalid parameter\r
-**/\r
-STATIC\r
-EFI_STATUS\r
-PopScancodeBufHead (\r
- KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,\r
- IN UINT32 Count,\r
- OUT UINT8 *Buf\r
- )\r
-{\r
- UINT32 Index;\r
-\r
- Index = 0;\r
-\r
- //\r
- // Check the valid range of parameter 'Count'\r
- //\r
- if (Count <= 0 || ConsoleIn->ScancodeBufCount < Count) {\r
- return EFI_NOT_READY;\r
- }\r
- //\r
- // Retrieve and remove the values\r
- //\r
- for (Index = 0; Index < Count; Index++) {\r
-\r
- if (Index != 0) {\r
-\r
- ConsoleIn->ScancodeBufStartPos++;\r
- if (ConsoleIn->ScancodeBufStartPos >= KEYBOARD_BUFFER_MAX_COUNT) {\r
- ConsoleIn->ScancodeBufStartPos = 0;\r
- }\r
- }\r
-\r
- Buf[Index] = ConsoleIn->ScancodeBuf[ConsoleIn->ScancodeBufStartPos];\r
- ConsoleIn->ScancodeBufCount--;\r