ConsoleWrappers.c revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/** @file
Function definitions for shell simple text in and out on top of file handles.
Copyright (c) 2010 - 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 <Uefi.h>
#include <ShellBase.h>
#include "ConsoleWrappers.h"
#include "Shell.h"
typedef struct {
typedef struct {
/**
Event notification function for EFI_SIMPLE_TEXT_INPUT_PROTOCOL.WaitForKey event
Signal the event if there is key available
@param Event Indicates the event that invoke this function.
@param Context Indicates the calling context.
**/
)
{
//
// Someone is waiting on the keystroke event, if there's
// a key pending, signal the event
//
// Context is the pointer to EFI_SIMPLE_TEXT_INPUT_PROTOCOL
//
ShellInfoObject.NewEfiShellProtocol->GetFilePosition(((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)Context)->FileHandle, &Position);
ShellInfoObject.NewEfiShellProtocol->GetFileSize (((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)Context)->FileHandle, &Size );
}
}
/**
Reset function for the fake simple text input.
@param[in] This A pointer to the SimpleTextIn structure.
@param[in] ExtendedVerification TRUE for extra validation, FALSE otherwise.
@retval EFI_SUCCESS The reset was successful.
**/
)
{
return (EFI_SUCCESS);
}
/**
ReadKeyStroke function for the fake simple text input.
@param[in] This A pointer to the SimpleTextIn structure.
@param[in, out] Key A pointer to the Key structure to fill.
@retval EFI_SUCCESS The read was successful.
**/
)
{
return (EFI_INVALID_PARAMETER);
}
&Size,
&Key->UnicodeChar));
}
/**
Function to create a EFI_SIMPLE_TEXT_INPUT_PROTOCOL on top of a
SHELL_FILE_HANDLE to support redirecting input from a file.
@param[in] FileHandleToUse The pointer to the SHELL_FILE_HANDLE to use.
@param[in] HandleLocation The pointer of a location to copy handle with protocol to.
@retval NULL There was insufficient memory available.
@return A pointer to the allocated protocol structure;
**/
)
{
return (NULL);
}
if (ProtocolToReturn == NULL) {
return (NULL);
}
);
return (NULL);
}
///@todo possibly also install SimpleTextInputEx on the handle at this point.
&(ProtocolToReturn->SimpleTextIn));
return ((EFI_SIMPLE_TEXT_INPUT_PROTOCOL*)ProtocolToReturn);
} else {
return (NULL);
}
}
/**
Function to close a EFI_SIMPLE_TEXT_INPUT_PROTOCOL on top of a
SHELL_FILE_HANDLE to support redirecting input from a file.
@param[in] SimpleTextIn The pointer to the SimpleTextIn to close.
@retval EFI_SUCCESS The object was closed.
**/
)
{
if (SimpleTextIn == NULL) {
return (EFI_INVALID_PARAMETER);
}
Status = gBS->CloseEvent(((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)SimpleTextIn)->SimpleTextIn.WaitForKey);
return (Status1);
} else {
return (Status);
}
}
/**
Reset the text output device hardware and optionaly run diagnostics.
@param This pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
@param ExtendedVerification Indicates that a more extensive test may be performed
@retval EFI_SUCCESS The text output device was reset.
**/
)
{
return (EFI_SUCCESS);
}
/**
Verifies that all characters in a Unicode string can be output to the
target device.
@param[in] This Protocol instance pointer.
@param[in] WString The NULL-terminated Unicode string to be examined.
@retval EFI_SUCCESS The device(s) are capable of rendering the output string.
**/
)
{
return (EFI_SUCCESS);
}
/**
Returns information for an available text mode that the output device(s)
supports.
@param[in] This Protocol instance pointer.
@param[in] ModeNumber The mode number to return information on.
@param[out] Columns Upon return, the number of columns in the selected geometry
@param[out] Rows Upon return, the number of rows in the selected geometry
@retval EFI_UNSUPPORTED The mode number was not valid.
**/
)
{
return (EFI_UNSUPPORTED);
}
/**
Sets the output device(s) to a specified mode.
@param[in] This Protocol instance pointer.
@param[in] ModeNumber The mode number to set.
@retval EFI_UNSUPPORTED The mode number was not valid.
**/
)
{
return (EFI_UNSUPPORTED);
}
/**
Sets the background and foreground colors for the OutputString () and
ClearScreen () functions.
@param[in] This Protocol instance pointer.
@param[in] Attribute The attribute to set. Bits 0..3 are the foreground color, and
bits 4..6 are the background color. All other bits are undefined
and must be zero. The valid Attributes are defined in this file.
@retval EFI_SUCCESS The attribute was set.
**/
)
{
return (EFI_SUCCESS);
}
/**
Clears the output device(s) display to the currently selected background
color.
@param[in] This Protocol instance pointer.
@retval EFI_UNSUPPORTED The output device is not in a valid text mode.
**/
)
{
return (EFI_SUCCESS);
}
/**
Sets the current coordinates of the cursor position
@param[in] This Protocol instance pointer.
@param[in] Column Column to put the cursor in. Must be between zero and Column returned from QueryMode
@param[in] Row Row to put the cursor in. Must be between zero and Row returned from QueryMode
@retval EFI_SUCCESS The operation completed successfully.
**/
)
{
return (EFI_SUCCESS);
}
/**
Makes the cursor visible or invisible
@param[in] This Protocol instance pointer.
@param[in] Visible If TRUE, the cursor is set to be visible. If FALSE, the cursor is
set to be invisible.
@retval EFI_SUCCESS The operation completed successfully.
**/
)
{
return (EFI_SUCCESS);
}
/**
Write a Unicode string to the output device.
@param[in] This Protocol instance pointer.
@param[in] WString The NULL-terminated Unicode string to be displayed on the output
device(s). All output devices must also support the Unicode
drawing defined in this file.
@retval EFI_SUCCESS The string was output to the device.
@retval EFI_DEVICE_ERROR The device reported an error while attempting to output
the text.
@retval EFI_UNSUPPORTED The output device's mode is not currently in a
defined text mode.
@retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
characters in the Unicode string could not be
rendered and were skipped.
**/
)
{
&Size,
WString));
}
/**
Function to create a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a
SHELL_FILE_HANDLE to support redirecting output from a file.
@param[in] FileHandleToUse The pointer to the SHELL_FILE_HANDLE to use.
@param[in] HandleLocation The pointer of a location to copy handle with protocol to.
@retval NULL There was insufficient memory available.
@return A pointer to the allocated protocol structure;
**/
)
{
return (NULL);
}
if (ProtocolToReturn == NULL) {
return (NULL);
}
return (NULL);
}
return ((EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)ProtocolToReturn);
} else {
return (NULL);
}
}
/**
Function to close a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a
SHELL_FILE_HANDLE to support redirecting output from a file.
@param[in] SimpleTextOut The pointer to the SimpleTextOUT to close.
@retval EFI_SUCCESS The object was closed.
**/
)
{
if (SimpleTextOut == NULL) {
return (EFI_INVALID_PARAMETER);
}
return (Status);
}