Exemplo n.º 1
0
/**
  TODO: Add function description

  @param  Event                 TODO: add argument description
  @param  Context               TODO: add argument description

  @return TODO: add return values

**/
VOID
EFIAPI
WinNtGopSimpleTextInWaitForKey (
  IN EFI_EVENT          Event,
  IN VOID               *Context
  )
{
  GOP_PRIVATE_DATA  *Private;
  EFI_STATUS        Status;
  EFI_TPL           OldTpl;
  EFI_KEY_DATA      KeyData;

  Private = (GOP_PRIVATE_DATA *) Context;

  //
  // Enter critical section
  //
  OldTpl  = gBS->RaiseTPL (TPL_NOTIFY);

  //
  // Call hot key callback before telling caller there is a key available
  //
  WinNtGopSimpleTextInTimerHandler (NULL, Private);
  
  //
  // WaitforKey doesn't suppor the partial key.
  // Considering if the partial keystroke is enabled, there maybe a partial
  // keystroke in the queue, so here skip the partial keystroke and get the
  // next key from the queue
  //
  while (1) {
    Status  = GopPrivateCheckQ (&Private->QueueForRead);
    if (!EFI_ERROR (Status)) {
      //
      // If a there is a key in the queue and it is not partial keystroke,  signal event.
      //
      if (Private->QueueForRead.Q[Private->QueueForRead.Front].Key.ScanCode == SCAN_NULL &&
        Private->QueueForRead.Q[Private->QueueForRead.Front].Key.UnicodeChar == CHAR_NULL) {
        GopPrivateDeleteQ (Private,&Private->QueueForRead,&KeyData);
        continue;
      }
      gBS->SignalEvent (Event);
    } else {
      //
      // We need to sleep or NT will schedule this thread with such high
      // priority that WinProc thread will never run and we will not see
      // keyboard input. This Sleep makes the syste run 10x faster, so don't
      // remove it.
      //
      Private->WinNtThunk->Sleep (1);
    }
    break;
  }

  //
  // Leave critical section and return
  //
  gBS->RestoreTPL (OldTpl);
}
Exemplo n.º 2
0
VOID
WinNtGopSimpleTextInTimerHandler (
  IN EFI_EVENT  Event,
  IN VOID       *Context
  )
{
  GOP_PRIVATE_DATA  *Private;
  EFI_KEY_DATA      KeyData;

  Private = (GOP_PRIVATE_DATA *)Context;
  while (GopPrivateDeleteQ (Private, &Private->QueueForNotify, &KeyData) == EFI_SUCCESS) {
    GopPrivateInvokeRegisteredFunction (Private, &KeyData);
  }
}
Exemplo n.º 3
0
STATIC
EFI_STATUS
GopPrivateReadKeyStrokeWorker (
  IN GOP_PRIVATE_DATA                   *Private,
  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:
    Private    - The private structure of WinNt Gop device.
    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;
  EFI_TPL                         OldTpl;  

  if (KeyData == NULL) {
    return EFI_INVALID_PARAMETER;
  }

  //
  // Enter critical section
  //
  OldTpl  = gBS->RaiseTPL (EFI_TPL_NOTIFY);

  Status  = GopPrivateCheckQ (Private);
  if (!EFI_ERROR (Status)) {
    //
    // If a Key press exists try and read it.
    //
    Status = GopPrivateDeleteQ (Private, &KeyData->Key);
#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)     
    if (!EFI_ERROR (Status)) {
      //
      // Record Key shift state and toggle state
      //      
      if (Private->LeftCtrl) {
        Private->KeyState.KeyShiftState  |= EFI_LEFT_CONTROL_PRESSED;
      }                                    
      if (Private->RightCtrl) {
        Private->KeyState.KeyShiftState  |= EFI_RIGHT_CONTROL_PRESSED;
      }                                    
      if (Private->LeftAlt) {                
        Private->KeyState.KeyShiftState  |= EFI_LEFT_ALT_PRESSED;
      }                                    
      if (Private->RightAlt) {                
        Private->KeyState.KeyShiftState  |= EFI_RIGHT_ALT_PRESSED;
      }                                      
      if (Private->LeftShift) {          
        Private->KeyState.KeyShiftState  |= EFI_LEFT_SHIFT_PRESSED;
      }                                    
      if (Private->RightShift) {         
        Private->KeyState.KeyShiftState  |= EFI_RIGHT_SHIFT_PRESSED;
      }                                    
      if (Private->LeftLogo) {           
        Private->KeyState.KeyShiftState  |= EFI_LEFT_LOGO_PRESSED;
      }                                    
      if (Private->RightLogo) {          
        Private->KeyState.KeyShiftState  |= EFI_RIGHT_LOGO_PRESSED;
      }                                    
      if (Private->Menu) {               
        Private->KeyState.KeyShiftState  |= EFI_MENU_KEY_PRESSED;
      }                                    
      if (Private->SysReq) {             
        Private->KeyState.KeyShiftState  |= EFI_SYS_REQ_PRESSED;
      }  
      if (Private->CapsLock) {
        Private->KeyState.KeyToggleState |= EFI_CAPS_LOCK_ACTIVE;
      }
      if (Private->NumLock) {
        Private->KeyState.KeyToggleState |= EFI_NUM_LOCK_ACTIVE;
      }
      if (Private->ScrollLock) {
        Private->KeyState.KeyToggleState |= EFI_SCROLL_LOCK_ACTIVE;
      }
      
      KeyData->KeyState.KeyShiftState  = Private->KeyState.KeyShiftState;
      KeyData->KeyState.KeyToggleState = Private->KeyState.KeyToggleState;
      
      Private->KeyState.KeyShiftState  = EFI_SHIFT_STATE_VALID;
      Private->KeyState.KeyToggleState = EFI_TOGGLE_STATE_VALID;
  
      //
      // Leave critical section and return
      //
      gBS->RestoreTPL (OldTpl);
      
      GopPrivateInvokeRegisteredFunction (Private, KeyData);
      
      return EFI_SUCCESS;
    }
#endif    
  }

  //
  // Leave critical section and return
  //
  gBS->RestoreTPL (OldTpl);

  return Status;

}
Exemplo n.º 4
0
STATIC
EFI_STATUS
GopPrivateResetWorker (
  IN GOP_PRIVATE_DATA                     *Private
  )
/*++

Routine Description:

  This function is a worker function for SimpleTextIn/SimpleTextInEx.Reset().

Arguments:

  Private     - WinNT GOP private structure

Returns:

  EFI_SUCCESS - Reset successfully

--*/
{
  EFI_INPUT_KEY     Key;
  EFI_TPL           OldTpl;

  //
  // Enter critical section
  //
  OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY);

  //
  // A reset is draining the Queue
  //
  while (GopPrivateDeleteQ (Private, &Key) == EFI_SUCCESS)
    ;

#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
  Private->LeftShift               = FALSE;
  Private->RightShift              = FALSE;
  Private->LeftAlt                 = FALSE;
  Private->RightAlt                = FALSE;
  Private->LeftCtrl                = FALSE;
  Private->RightCtrl               = FALSE;
  Private->LeftLogo                = FALSE;
  Private->RightLogo               = FALSE;
  Private->Menu                    = FALSE;
  Private->SysReq                  = FALSE;
  
  Private->CapsLock                = FALSE;
  Private->NumLock                 = FALSE;
  Private->ScrollLock              = FALSE;
  
  Private->KeyState.KeyShiftState  = EFI_SHIFT_STATE_VALID;
  Private->KeyState.KeyToggleState = EFI_TOGGLE_STATE_VALID;
#endif

  //
  // Leave critical section and return
  //
  gBS->RestoreTPL (OldTpl);

  return EFI_SUCCESS;
}
Exemplo n.º 5
0
EFI_STATUS
GopPrivateReadKeyStrokeWorker (
  IN GOP_PRIVATE_DATA                   *Private,
  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:
    Private    - The private structure of WinNt Gop device.
    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;
  EFI_TPL                         OldTpl;

  if (KeyData == NULL) {
    return EFI_INVALID_PARAMETER;
  }

  //
  // Enter critical section
  //
  OldTpl  = gBS->RaiseTPL (TPL_NOTIFY);

  //
  // Call hot key callback before telling caller there is a key available
  //
  WinNtGopSimpleTextInTimerHandler (NULL, Private);

  ZeroMem (&KeyData->Key, sizeof (KeyData->Key));
  InitializeKeyState (Private, &KeyData->KeyState);

  Status  = GopPrivateCheckQ (&Private->QueueForRead);
  if (!EFI_ERROR (Status)) {
    //
    // If a Key press exists try and read it.
    //
    Status = GopPrivateDeleteQ (Private, &Private->QueueForRead, KeyData);
    if (!EFI_ERROR (Status)) {
      //
      // If partial keystroke is not enabled, check whether it is value key. If not return
      // EFI_NOT_READY.
      //
      if (!Private->IsPartialKeySupport) {
        if (KeyData->Key.ScanCode == SCAN_NULL && KeyData->Key.UnicodeChar == CHAR_NULL) {
          Status = EFI_NOT_READY;
        }
      }
    }
  }

  //
  // Leave critical section and return
  //
  gBS->RestoreTPL (OldTpl);

  return Status;

}
Exemplo n.º 6
0
EFI_STATUS
GopPrivateResetWorker (
  IN GOP_PRIVATE_DATA                     *Private
  )
/*++

Routine Description:

  This function is a worker function for SimpleTextIn/SimpleTextInEx.Reset().

Arguments:

  Private     - WinNT GOP private structure

Returns:

  EFI_SUCCESS - Reset successfully

--*/
{
  EFI_KEY_DATA      KeyData;
  EFI_TPL           OldTpl;

  //
  // Enter critical section
  //
  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);

  //
  // A reset is draining the Queue
  //
  while (GopPrivateDeleteQ (Private, &Private->QueueForRead, &KeyData) == EFI_SUCCESS)
    ;
  while (GopPrivateDeleteQ (Private, &Private->QueueForNotify, &KeyData) == EFI_SUCCESS)
    ;

  Private->LeftShift               = FALSE;
  Private->RightShift              = FALSE;
  Private->LeftAlt                 = FALSE;
  Private->RightAlt                = FALSE;
  Private->LeftCtrl                = FALSE;
  Private->RightCtrl               = FALSE;
  Private->LeftLogo                = FALSE;
  Private->RightLogo               = FALSE;
  Private->Menu                    = FALSE;
  Private->SysReq                  = FALSE;

  Private->CapsLock                = FALSE;
  Private->NumLock                 = FALSE;
  Private->ScrollLock              = FALSE;
  Private->IsPartialKeySupport     = FALSE;

  Private->KeyState.KeyShiftState  = EFI_SHIFT_STATE_VALID;
  Private->KeyState.KeyToggleState = EFI_TOGGLE_STATE_VALID;

  //
  // Leave critical section and return
  //
  gBS->RestoreTPL (OldTpl);

  return EFI_SUCCESS;
}