/** @file
Routines implements SIMPLE_TEXT_IN protocol's interfaces based on 8042 interfaces
provided by Ps2KbdCtrller.c.
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
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
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "Ps2Keyboard.h"
/**
Check whether the EFI key buffer is empty.
@param Queue Pointer to instance of EFI_KEY_QUEUE.
@retval TRUE The EFI key buffer is empty.
@retval FALSE The EFI key buffer isn't empty.
**/
)
{
}
/**
Read & remove one key data from the EFI key buffer.
@param Queue Pointer to instance of EFI_KEY_QUEUE.
@param KeyData Receive the key data.
@retval EFI_SUCCESS The key data is popped successfully.
@retval EFI_NOT_READY There is no key data available.
**/
)
{
if (IsEfikeyBufEmpty (Queue)) {
return EFI_NOT_READY;
}
//
// Retrieve and remove the values
//
}
return EFI_SUCCESS;
}
/**
Push one key data to the EFI key buffer.
@param Queue Pointer to instance of EFI_KEY_QUEUE.
@param KeyData The key data to push.
**/
)
{
//
// If Queue is full, pop the one from head.
//
}
}
/**
Judge whether is a registed key
@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 be pressed matches a registered key.
@retval FLASE Match failed.
**/
)
{
return FALSE;
}
//
// Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
//
return FALSE;
}
return FALSE;
}
return TRUE;
}
/**
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 ConsoleInDev Ps2 Keyboard private structure
@param KeyData A pointer to a buffer that is filled in with the keystroke
state data for the key that was pressed.
@retval EFI_SUCCESS The keystroke information was returned.
@retval EFI_NOT_READY There was no keystroke data availiable.
@retval EFI_DEVICE_ERROR The keystroke information was not returned due to
hardware errors.
@retval EFI_INVALID_PARAMETER KeyData is NULL.
**/
)
{
return EFI_INVALID_PARAMETER;
}
//
// Enter critical section
//
if (ConsoleInDev->KeyboardErr) {
} else {
}
return Status;
}
/**
Perform 8042 controller and keyboard initialization which implement SIMPLE_TEXT_IN.Reset()
@param This Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL
@param ExtendedVerification Indicate that the driver may perform a more
exhaustive verification operation of the device during
reset, now this par is ignored in this driver
**/
)
{
if (ConsoleIn->KeyboardErr) {
return EFI_DEVICE_ERROR;
}
);
//
// Enter critical section
//
//
// Call InitKeyboard to initialize the keyboard
//
//
// Leave critical section and return
//
return EFI_DEVICE_ERROR;
}
//
// Leave critical section and return
//
//
// Report the status If a stuck key was detected
//
);
}
//
// Report the status If keyboard is locked
//
);
}
return EFI_SUCCESS;
}
/**
Retrieve key values for driver user which implement SIMPLE_TEXT_IN.ReadKeyStroke().
@param This Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL
@param Key The output buffer for key value
@retval EFI_SUCCESS success to read key stroke
**/
)
{
//
// 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) {
//
// If there is no pending key, then return.
//
return Status;
}
//
// If it is partial keystroke, skip it.
//
continue;
}
//
// Translate the CTRL-Alpha characters to their corresponding control value
// (ctrl-a = 0x0001 through ctrl-Z = 0x001A)
//
if ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) {
}
}
return EFI_SUCCESS;
}
}
/**
Event notification function for SIMPLE_TEXT_IN.WaitForKey event
Signal the event if there is key available
@param Event the event object
@param Context waitting context
**/
)
{
//
// Enter critical section
//
if (!ConsoleIn->KeyboardErr) {
//
// 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
//
CopyMem (
&KeyData,
sizeof (EFI_KEY_DATA)
);
continue;
}
//
// if there is pending value key, signal the event.
//
break;
}
}
//
// Leave critical section and return
//
}
/**
Event notification function for SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event
Signal the event if there is key available
@param Event event object
@param Context waiting context
**/
)
{
}
/**
Reset the input device and optionaly run diagnostics
@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.
**/
)
{
);
}
/**
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.
@retval EFI_SUCCESS The keystroke information was returned.
@retval EFI_NOT_READY There was no keystroke data availiable.
@retval EFI_DEVICE_ERROR The keystroke information was not returned due to
hardware errors.
@retval EFI_INVALID_PARAMETER KeyData is NULL.
**/
)
{
return EFI_INVALID_PARAMETER;
}
}
/**
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_DEVICE_ERROR The device is not functioning correctly and could
not have the setting adjusted.
@retval EFI_UNSUPPORTED The device does not have the ability to set its state.
@retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
**/
)
{
if (KeyToggleState == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Enter critical section
//
if (ConsoleInDev->KeyboardErr) {
goto Exit;
}
goto Exit;
}
//
// Update the status light
//
}
}
}
}
}
Exit:
//
// Leave critical section and return
//
return Status;
}
/**
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 or KeyNotificationFunction is NULL.
**/
)
{
return EFI_INVALID_PARAMETER;
}
//
// Enter critical section
//
//
// Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
//
for (Link = ConsoleInDev->NotifyList.ForwardLink; Link != &ConsoleInDev->NotifyList; Link = Link->ForwardLink) {
CurrentNotify = CR (
Link,
);
goto Exit;
}
}
}
//
// Allocate resource to save the notification function
//
NewNotify = (KEYBOARD_CONSOLE_IN_EX_NOTIFY *) AllocateZeroPool (sizeof (KEYBOARD_CONSOLE_IN_EX_NOTIFY));
goto Exit;
}
Exit:
//
// Leave critical section and return
//
return Status;
}
/**
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.
**/
)
{
if (NotificationHandle == NULL) {
return EFI_INVALID_PARAMETER;
}
if (((KEYBOARD_CONSOLE_IN_EX_NOTIFY *) NotificationHandle)->Signature != KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE) {
return EFI_INVALID_PARAMETER;
}
//
// Enter critical section
//
for (Link = ConsoleInDev->NotifyList.ForwardLink; Link != &ConsoleInDev->NotifyList; Link = Link->ForwardLink) {
CurrentNotify = CR (
Link,
);
//
// Remove the notification function from NotifyList and free resources
//
goto Exit;
}
}
//
// Can not find the specified Notification Handle
//
Exit:
//
// Leave critical section and return
//
return Status;
}