/* Timer event handler: read a series of scancodes from 8042 and put them into memory scancode buffer. it read as much scancodes to either fill the memory buffer or empty the keyboard buffer. It is registered as running under TPL_NOTIFY */
VOID EFIAPI KeyboardTimerHandler(IN EFI_EVENT Event, IN VOID *Context)
/* Timer event handler: read a series of scancodes from 8042 and put them into memory scancode buffer. it read as much scancodes to either fill the memory buffer or empty the keyboard buffer. It is registered as running under TPL_NOTIFY */
VOID EFIAPI KeyboardTimerHandler(IN EFI_EVENT Event, IN VOID *Context)
{
  UINT8                    Data;
  EFI_TPL                  OldTpl;
  KEYBOARD_CONSOLE_IN_DEV  *ConsoleIn;
  ConsoleIn = (KEYBOARD_CONSOLE_IN_DEV *)Context;
  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
  if (((KEYBOARD_CONSOLE_IN_DEV *)Context)->KeyboardErr) {
    gBS->RestoreTPL (OldTpl);
    return;
  }
  while ((KeyReadStatusRegister (ConsoleIn) & (KEYBOARD_STATUS_REGISTER_TRANSMIT_TIMEOUT|KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA)) ==
         KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA
         )
  {
    Data = KeyReadDataRegister (ConsoleIn);
    PushScancodeBufTail (&ConsoleIn->ScancodeQueue, Data);
  }
  KeyGetchar (ConsoleIn);
  gBS->RestoreTPL (OldTpl);
}