Check in following modules,
DxeIpl ConPlatform ConSplitter GraphicsConsole Terminal DevicePath git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3069 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
51
MdeModulePkg/Universal/Console/TerminalDxe/CommonHeader.h
Normal file
51
MdeModulePkg/Universal/Console/TerminalDxe/CommonHeader.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/**@file
|
||||
Common header file shared by all source files.
|
||||
|
||||
This file includes package header files, library classes and protocol, PPI & GUID definitions.
|
||||
|
||||
Copyright (c) 2006 - 2007, Intel Corporation
|
||||
All rights reserved. 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
**/
|
||||
|
||||
#ifndef __COMMON_HEADER_H_
|
||||
#define __COMMON_HEADER_H_
|
||||
|
||||
|
||||
//
|
||||
// The package level header files this module uses
|
||||
//
|
||||
#include <PiDxe.h>
|
||||
//
|
||||
// The protocols, PPI and GUID defintions for this module
|
||||
//
|
||||
#include <Protocol/SimpleTextOut.h>
|
||||
#include <Protocol/SerialIo.h>
|
||||
#include <Guid/GlobalVariable.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
#include <Protocol/SimpleTextIn.h>
|
||||
#include <Guid/HotPlugDevice.h>
|
||||
#include <Guid/PcAnsi.h>
|
||||
//
|
||||
// The Library classes this module consumes
|
||||
//
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/UefiDriverEntryPoint.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/ReportStatusCodeLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
//
|
||||
// Driver Binding Externs
|
||||
//
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL gTerminalDriverBinding;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gTerminalComponentName;
|
||||
|
||||
#endif
|
200
MdeModulePkg/Universal/Console/TerminalDxe/ComponentName.c
Normal file
200
MdeModulePkg/Universal/Console/TerminalDxe/ComponentName.c
Normal file
@@ -0,0 +1,200 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
All rights reserved. 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
ComponentName.c
|
||||
|
||||
Abstract:
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
//
|
||||
// Include common header file for this module.
|
||||
//
|
||||
#include "CommonHeader.h"
|
||||
|
||||
#include "Terminal.h"
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
EFI_COMPONENT_NAME_PROTOCOL gTerminalComponentName = {
|
||||
TerminalComponentNameGetDriverName,
|
||||
TerminalComponentNameGetControllerName,
|
||||
"eng"
|
||||
};
|
||||
|
||||
static EFI_UNICODE_STRING_TABLE mTerminalDriverNameTable[] = {
|
||||
{
|
||||
"eng",
|
||||
(CHAR16 *) L"Serial Terminal Driver"
|
||||
},
|
||||
{
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalComponentNameGetDriverName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **DriverName
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Retrieves a Unicode string that is the user readable name of the EFI Driver.
|
||||
|
||||
Arguments:
|
||||
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
Language - A pointer to a three character ISO 639-2 language identifier.
|
||||
This is the language of the driver name that that the caller
|
||||
is requesting, and it must match one of the languages specified
|
||||
in SupportedLanguages. The number of languages supported by a
|
||||
driver is up to the driver writer.
|
||||
DriverName - A pointer to the Unicode string to return. This Unicode string
|
||||
is the name of the driver specified by This in the language
|
||||
specified by Language.
|
||||
|
||||
Returns:
|
||||
EFI_SUCCESS - The Unicode string for the Driver specified by This
|
||||
and the language specified by Language was returned
|
||||
in DriverName.
|
||||
EFI_INVALID_PARAMETER - Language is NULL.
|
||||
EFI_INVALID_PARAMETER - DriverName is NULL.
|
||||
EFI_UNSUPPORTED - The driver specified by This does not support the
|
||||
language specified by Language.
|
||||
|
||||
--*/
|
||||
{
|
||||
return LookupUnicodeString (
|
||||
Language,
|
||||
gTerminalComponentName.SupportedLanguages,
|
||||
mTerminalDriverNameTable,
|
||||
DriverName
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by an EFI Driver.
|
||||
|
||||
Arguments:
|
||||
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
ControllerHandle - The handle of a controller that the driver specified by
|
||||
This is managing. This handle specifies the controller
|
||||
whose name is to be returned.
|
||||
ChildHandle - The handle of the child controller to retrieve the name
|
||||
of. This is an optional parameter that may be NULL. It
|
||||
will be NULL for device drivers. It will also be NULL
|
||||
for a bus drivers that wish to retrieve the name of the
|
||||
bus controller. It will not be NULL for a bus driver
|
||||
that wishes to retrieve the name of a child controller.
|
||||
Language - A pointer to a three character ISO 639-2 language
|
||||
identifier. This is the language of the controller name
|
||||
that that the caller is requesting, and it must match one
|
||||
of the languages specified in SupportedLanguages. The
|
||||
number of languages supported by a driver is up to the
|
||||
driver writer.
|
||||
ControllerName - A pointer to the Unicode string to return. This Unicode
|
||||
string is the name of the controller specified by
|
||||
ControllerHandle and ChildHandle in the language
|
||||
specified by Language from the point of view of the
|
||||
driver specified by This.
|
||||
|
||||
Returns:
|
||||
EFI_SUCCESS - The Unicode string for the user readable name in the
|
||||
language specified by Language for the driver
|
||||
specified by This was returned in DriverName.
|
||||
EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
|
||||
EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
|
||||
EFI_HANDLE.
|
||||
EFI_INVALID_PARAMETER - Language is NULL.
|
||||
EFI_INVALID_PARAMETER - ControllerName is NULL.
|
||||
EFI_UNSUPPORTED - The driver specified by This is not currently
|
||||
managing the controller specified by
|
||||
ControllerHandle and ChildHandle.
|
||||
EFI_UNSUPPORTED - The driver specified by This does not support the
|
||||
language specified by Language.
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOutput;
|
||||
TERMINAL_DEV *TerminalDevice;
|
||||
|
||||
//
|
||||
// Make sure this driver is currently managing ControllHandle
|
||||
//
|
||||
Status = EfiTestManagedDevice (
|
||||
ControllerHandle,
|
||||
gTerminalDriverBinding.DriverBindingHandle,
|
||||
&gEfiSerialIoProtocolGuid
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// This is a bus driver, so ChildHandle can not be NULL.
|
||||
//
|
||||
if (ChildHandle == NULL) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Status = EfiTestChildHandle (
|
||||
ControllerHandle,
|
||||
ChildHandle,
|
||||
&gEfiSerialIoProtocolGuid
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get our context back
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiSimpleTextOutProtocolGuid,
|
||||
(VOID **) &SimpleTextOutput,
|
||||
gTerminalDriverBinding.DriverBindingHandle,
|
||||
ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (SimpleTextOutput);
|
||||
|
||||
return LookupUnicodeString (
|
||||
Language,
|
||||
gTerminalComponentName.SupportedLanguages,
|
||||
TerminalDevice->ControllerNameTable,
|
||||
ControllerName
|
||||
);
|
||||
}
|
56
MdeModulePkg/Universal/Console/TerminalDxe/EntryPoint.c
Normal file
56
MdeModulePkg/Universal/Console/TerminalDxe/EntryPoint.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/**@file
|
||||
Entry Point Source file.
|
||||
|
||||
This file contains the user entry point
|
||||
|
||||
Copyright (c) 2006 - 2007, Intel Corporation
|
||||
All rights reserved. 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
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 common header file for this module.
|
||||
//
|
||||
#include "CommonHeader.h"
|
||||
|
||||
/**
|
||||
The user Entry Point for module Terminal. The user code starts with this function.
|
||||
|
||||
@param[in] ImageHandle The firmware allocated handle for the EFI image.
|
||||
@param[in] SystemTable A pointer to the EFI System Table.
|
||||
|
||||
@retval EFI_SUCCESS The entry point is executed successfully.
|
||||
@retval other Some error occurs when executing this entry point.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeTerminal(
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Install driver model protocol(s).
|
||||
//
|
||||
Status = EfiLibInstallAllDriverProtocols (
|
||||
ImageHandle,
|
||||
SystemTable,
|
||||
&gTerminalDriverBinding,
|
||||
ImageHandle,
|
||||
&gTerminalComponentName,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
return Status;
|
||||
}
|
1194
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
Normal file
1194
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
Normal file
File diff suppressed because it is too large
Load Diff
554
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
Normal file
554
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
Normal file
@@ -0,0 +1,554 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
All rights reserved. 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
terminal.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _TERMINAL_H
|
||||
#define _TERMINAL_H
|
||||
|
||||
//
|
||||
// Include common header file for this module.
|
||||
//
|
||||
#include "CommonHeader.h"
|
||||
|
||||
#define RAW_FIFO_MAX_NUMBER 256
|
||||
#define FIFO_MAX_NUMBER 128
|
||||
|
||||
typedef struct {
|
||||
UINT8 Head;
|
||||
UINT8 Tail;
|
||||
UINT8 Data[RAW_FIFO_MAX_NUMBER + 1];
|
||||
} RAW_DATA_FIFO;
|
||||
|
||||
typedef struct {
|
||||
UINT8 Head;
|
||||
UINT8 Tail;
|
||||
UINT16 Data[FIFO_MAX_NUMBER + 1];
|
||||
} UNICODE_FIFO;
|
||||
|
||||
typedef struct {
|
||||
UINT8 Head;
|
||||
UINT8 Tail;
|
||||
EFI_INPUT_KEY Data[FIFO_MAX_NUMBER + 1];
|
||||
} EFI_KEY_FIFO;
|
||||
|
||||
#define TERMINAL_DEV_SIGNATURE EFI_SIGNATURE_32 ('t', 'm', 'n', 'l')
|
||||
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
EFI_HANDLE Handle;
|
||||
UINT8 TerminalType;
|
||||
EFI_SERIAL_IO_PROTOCOL *SerialIo;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
VENDOR_DEVICE_PATH Node;
|
||||
EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput;
|
||||
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;
|
||||
EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;
|
||||
UINTN SerialInTimeOut;
|
||||
RAW_DATA_FIFO RawFiFo;
|
||||
UNICODE_FIFO UnicodeFiFo;
|
||||
EFI_KEY_FIFO EfiKeyFiFo;
|
||||
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
|
||||
EFI_EVENT TwoSecondTimeOut;
|
||||
UINT32 InputState;
|
||||
UINT32 ResetState;
|
||||
|
||||
//
|
||||
// Esc could not be output to the screen by user,
|
||||
// but the terminal driver need to output it to
|
||||
// the terminal emulation software to send control sequence.
|
||||
// This boolean is used by the terminal driver only
|
||||
// to indicate whether the Esc could be sent or not.
|
||||
//
|
||||
BOOLEAN OutputEscChar;
|
||||
} TERMINAL_DEV;
|
||||
|
||||
#define INPUT_STATE_DEFAULT 0x00
|
||||
#define INPUT_STATE_ESC 0x01
|
||||
#define INPUT_STATE_CSI 0x02
|
||||
#define INPUT_STATE_LEFTOPENBRACKET 0x04
|
||||
#define INPUT_STATE_O 0x08
|
||||
#define INPUT_STATE_2 0x10
|
||||
|
||||
#define RESET_STATE_DEFAULT 0x00
|
||||
#define RESET_STATE_ESC_R 0x01
|
||||
#define RESET_STATE_ESC_R_ESC_r 0x02
|
||||
|
||||
#define TERMINAL_CON_IN_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleInput, TERMINAL_DEV_SIGNATURE)
|
||||
#define TERMINAL_CON_OUT_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleTextOutput, TERMINAL_DEV_SIGNATURE)
|
||||
|
||||
typedef union {
|
||||
UINT8 Utf8_1;
|
||||
UINT8 Utf8_2[2];
|
||||
UINT8 Utf8_3[3];
|
||||
} UTF8_CHAR;
|
||||
|
||||
#define PcAnsiType 0
|
||||
#define VT100Type 1
|
||||
#define VT100PlusType 2
|
||||
#define VTUTF8Type 3
|
||||
|
||||
#define LEFTOPENBRACKET 0x5b // '['
|
||||
#define ACAP 0x41
|
||||
#define BCAP 0x42
|
||||
#define CCAP 0x43
|
||||
#define DCAP 0x44
|
||||
|
||||
#define MODE0_COLUMN_COUNT 80
|
||||
#define MODE0_ROW_COUNT 25
|
||||
|
||||
#define BACKSPACE 8
|
||||
#define ESC 27
|
||||
#define CSI 0x9B
|
||||
#define DEL 127
|
||||
#define BRIGHT_CONTROL_OFFSET 2
|
||||
#define FOREGROUND_CONTROL_OFFSET 6
|
||||
#define BACKGROUND_CONTROL_OFFSET 11
|
||||
#define ROW_OFFSET 2
|
||||
#define COLUMN_OFFSET 5
|
||||
|
||||
typedef struct {
|
||||
UINT16 Unicode;
|
||||
CHAR8 PcAnsi;
|
||||
CHAR8 Ascii;
|
||||
} UNICODE_TO_CHAR;
|
||||
|
||||
#define VarConsoleInpDev L"ConInDev"
|
||||
#define VarConsoleOutDev L"ConOutDev"
|
||||
#define VarErrorOutDev L"ErrOutDev"
|
||||
|
||||
//
|
||||
// Global Variables
|
||||
//
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL gTerminalDriverBinding;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gTerminalComponentName;
|
||||
|
||||
//
|
||||
// Prototypes
|
||||
//
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeTerminal (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalConInReset (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalConInReadKeyStroke (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
|
||||
OUT EFI_INPUT_KEY *Key
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
TerminalConInWaitForKey (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalConOutReset (
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalConOutOutputString (
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
||||
IN CHAR16 *WString
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalConOutTestString (
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
||||
IN CHAR16 *WString
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalConOutQueryMode (
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
||||
IN UINTN ModeNumber,
|
||||
OUT UINTN *Columns,
|
||||
OUT UINTN *Rows
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalConOutSetMode (
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
||||
IN UINTN ModeNumber
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalConOutSetAttribute (
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
||||
IN UINTN Attribute
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalConOutClearScreen (
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalConOutSetCursorPosition (
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
||||
IN UINTN Column,
|
||||
IN UINTN Row
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalConOutEnableCursor (
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
||||
IN BOOLEAN Visible
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalDriverBindingSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalDriverBindingStart (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalDriverBindingStop (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN UINTN NumberOfChildren,
|
||||
IN EFI_HANDLE *ChildHandleBuffer
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalComponentNameGetDriverName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TerminalComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
//
|
||||
// internal functions
|
||||
//
|
||||
EFI_STATUS
|
||||
TerminalConInCheckForKey (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
TerminalUpdateConsoleDevVariable (
|
||||
IN CHAR16 *VariableName,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
TerminalRemoveConsoleDevVariable (
|
||||
IN CHAR16 *VariableName,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath
|
||||
)
|
||||
;
|
||||
|
||||
VOID *
|
||||
TerminalGetVariableAndSize (
|
||||
IN CHAR16 *Name,
|
||||
IN EFI_GUID *VendorGuid,
|
||||
OUT UINTN *VariableSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SetTerminalDevicePath (
|
||||
IN UINT8 TerminalType,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
|
||||
OUT EFI_DEVICE_PATH_PROTOCOL **TerminalDevicePath
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
InitializeRawFiFo (
|
||||
IN TERMINAL_DEV *TerminalDevice
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
InitializeUnicodeFiFo (
|
||||
IN TERMINAL_DEV *TerminalDevice
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
InitializeEfiKeyFiFo (
|
||||
IN TERMINAL_DEV *TerminalDevice
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
GetOneKeyFromSerial (
|
||||
EFI_SERIAL_IO_PROTOCOL *SerialIo,
|
||||
UINT8 *Input
|
||||
)
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
RawFiFoInsertOneKey (
|
||||
TERMINAL_DEV *TerminalDevice,
|
||||
UINT8 Input
|
||||
)
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
RawFiFoRemoveOneKey (
|
||||
TERMINAL_DEV *TerminalDevice,
|
||||
UINT8 *Output
|
||||
)
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
IsRawFiFoEmpty (
|
||||
TERMINAL_DEV *TerminalDevice
|
||||
)
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
IsRawFiFoFull (
|
||||
TERMINAL_DEV *TerminalDevice
|
||||
)
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
EfiKeyFiFoInsertOneKey (
|
||||
TERMINAL_DEV *TerminalDevice,
|
||||
EFI_INPUT_KEY Key
|
||||
)
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
EfiKeyFiFoRemoveOneKey (
|
||||
TERMINAL_DEV *TerminalDevice,
|
||||
EFI_INPUT_KEY *Output
|
||||
)
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
IsEfiKeyFiFoEmpty (
|
||||
TERMINAL_DEV *TerminalDevice
|
||||
)
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
IsEfiKeyFiFoFull (
|
||||
TERMINAL_DEV *TerminalDevice
|
||||
)
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
UnicodeFiFoInsertOneKey (
|
||||
TERMINAL_DEV *TerminalDevice,
|
||||
UINT16 Input
|
||||
)
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
UnicodeFiFoRemoveOneKey (
|
||||
TERMINAL_DEV *TerminalDevice,
|
||||
UINT16 *Output
|
||||
)
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
IsUnicodeFiFoEmpty (
|
||||
TERMINAL_DEV *TerminalDevice
|
||||
)
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
IsUnicodeFiFoFull (
|
||||
TERMINAL_DEV *TerminalDevice
|
||||
)
|
||||
;
|
||||
|
||||
UINT8
|
||||
UnicodeFiFoGetKeyCount (
|
||||
TERMINAL_DEV *TerminalDevice
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
TranslateRawDataToEfiKey (
|
||||
IN TERMINAL_DEV *TerminalDevice
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// internal functions for PC ANSI
|
||||
//
|
||||
VOID
|
||||
AnsiRawDataToUnicode (
|
||||
IN TERMINAL_DEV *PcAnsiDevice
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
UnicodeToEfiKey (
|
||||
IN TERMINAL_DEV *PcAnsiDevice
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
AnsiTestString (
|
||||
IN TERMINAL_DEV *TerminalDevice,
|
||||
IN CHAR16 *WString
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// internal functions for VT100
|
||||
//
|
||||
EFI_STATUS
|
||||
VT100TestString (
|
||||
IN TERMINAL_DEV *VT100Device,
|
||||
IN CHAR16 *WString
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// internal functions for VT100Plus
|
||||
//
|
||||
EFI_STATUS
|
||||
VT100PlusTestString (
|
||||
IN TERMINAL_DEV *TerminalDevice,
|
||||
IN CHAR16 *WString
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// internal functions for VTUTF8
|
||||
//
|
||||
VOID
|
||||
VTUTF8RawDataToUnicode (
|
||||
IN TERMINAL_DEV *VtUtf8Device
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
VTUTF8TestString (
|
||||
IN TERMINAL_DEV *TerminalDevice,
|
||||
IN CHAR16 *WString
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
UnicodeToUtf8 (
|
||||
IN CHAR16 Unicode,
|
||||
OUT UTF8_CHAR *Utf8Char,
|
||||
OUT UINT8 *ValidBytes
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
GetOneValidUtf8Char (
|
||||
IN TERMINAL_DEV *Utf8Device,
|
||||
OUT UTF8_CHAR *Utf8Char,
|
||||
OUT UINT8 *ValidBytes
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
Utf8ToUnicode (
|
||||
IN UTF8_CHAR Utf8Char,
|
||||
IN UINT8 ValidBytes,
|
||||
OUT CHAR16 *UnicodeChar
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// functions for boxdraw unicode
|
||||
//
|
||||
BOOLEAN
|
||||
TerminalIsValidTextGraphics (
|
||||
IN CHAR16 Graphic,
|
||||
OUT CHAR8 *PcAnsi, OPTIONAL
|
||||
OUT CHAR8 *Ascii OPTIONAL
|
||||
)
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
TerminalIsValidAscii (
|
||||
IN CHAR16 Ascii
|
||||
)
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
TerminalIsValidEfiCntlChar (
|
||||
IN CHAR16 CharC
|
||||
)
|
||||
;
|
||||
|
||||
#endif
|
117
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.inf
Normal file
117
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.inf
Normal file
@@ -0,0 +1,117 @@
|
||||
#/** @file
|
||||
# Component description file for Terminal module.
|
||||
#
|
||||
# This driver installs Simple Text In/Out protocol for terminal devices (serial devices or hotplug devices).
|
||||
# Copyright (c) 2006 - 2007, Intel Corporation
|
||||
#
|
||||
# All rights reserved. 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#
|
||||
#**/
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Defines Section - statements that will be processed to create a Makefile.
|
||||
#
|
||||
################################################################################
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = Terminal
|
||||
FILE_GUID = 9E863906-A40F-4875-977F-5B93FF237FC6
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
EDK_RELEASE_VERSION = 0x00020000
|
||||
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||
|
||||
ENTRY_POINT = InitializeTerminal
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
# DRIVER_BINDING = gTerminalDriverBinding
|
||||
# COMPONENT_NAME = gTerminalComponentName
|
||||
#
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Sources Section - list of files that are required for the build to succeed.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[Sources.common]
|
||||
ComponentName.c
|
||||
vtutf8.c
|
||||
ansi.c
|
||||
TerminalConOut.c
|
||||
TerminalConIn.c
|
||||
Terminal.c
|
||||
Terminal.h
|
||||
CommonHeader.h
|
||||
EntryPoint.c
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Package Dependency Section - list of Package files that are required for
|
||||
# this module.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
IntelFrameworkPkg/IntelFrameworkPkg.dec
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Library Class Section - list of Library Classes that are required for
|
||||
# this module.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[LibraryClasses]
|
||||
DevicePathLib
|
||||
UefiRuntimeServicesTableLib
|
||||
UefiBootServicesTableLib
|
||||
MemoryAllocationLib
|
||||
BaseMemoryLib
|
||||
ReportStatusCodeLib
|
||||
UefiLib
|
||||
UefiDriverEntryPoint
|
||||
DebugLib
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Guid C Name Section - list of Guids that this module uses or produces.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[Guids]
|
||||
gEfiGlobalVariableGuid # SOMETIMES_CONSUMED L"ErrOutDev"
|
||||
gEfiVTUTF8Guid # SOMETIMES_CONSUMED
|
||||
gEfiVT100Guid # SOMETIMES_CONSUMED
|
||||
gEfiVT100PlusGuid # SOMETIMES_CONSUMED
|
||||
gEfiPcAnsiGuid # SOMETIMES_CONSUMED
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Protocol C Name Section - list of Protocol and Protocol Notify C Names
|
||||
# that this module uses or produces.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[Protocols]
|
||||
gEfiHotPlugDeviceGuid # PROTOCOL SOMETIMES_CONSUMED
|
||||
gEfiSerialIoProtocolGuid # PROTOCOL TO_START
|
||||
gEfiDevicePathProtocolGuid # PROTOCOL TO_START
|
||||
gEfiSimpleTextInProtocolGuid # PROTOCOL BY_START
|
||||
gEfiSimpleTextOutProtocolGuid # PROTOCOL BY_START
|
||||
|
129
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.msa
Normal file
129
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.msa
Normal file
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
|
||||
<MsaHeader>
|
||||
<ModuleName>Terminal</ModuleName>
|
||||
<ModuleType>DXE_DRIVER</ModuleType>
|
||||
<GuidValue>9E863906-A40F-4875-977F-5B93FF237FC6</GuidValue>
|
||||
<Version>1.0</Version>
|
||||
<Abstract>Component description file for Terminal module.</Abstract>
|
||||
<Description>This driver installs Simple Text In/Out protocol for terminal devices (serial devices or hotplug devices).</Description>
|
||||
<Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>
|
||||
<License>All rights reserved. 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
|
||||
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
||||
</MsaHeader>
|
||||
<ModuleDefinitions>
|
||||
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
|
||||
<BinaryModule>false</BinaryModule>
|
||||
<OutputFileBasename>Terminal</OutputFileBasename>
|
||||
</ModuleDefinitions>
|
||||
<LibraryClassDefinitions>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED" RecommendedInstanceGuid="bda39d3a-451b-4350-8266-81ab10fa0523">
|
||||
<Keyword>DebugLib</Keyword>
|
||||
<HelpText>Recommended libary Instance is PeiDxeDebugLibReportStatusCode instance in MdePkg.</HelpText>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiDriverModelLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiDriverEntryPoint</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>ReportStatusCodeLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>BaseMemoryLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>MemoryAllocationLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiBootServicesTableLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiRuntimeServicesTableLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>DevicePathLib</Keyword>
|
||||
</LibraryClass>
|
||||
</LibraryClassDefinitions>
|
||||
<SourceFiles>
|
||||
<Filename>Terminal.h</Filename>
|
||||
<Filename>Terminal.c</Filename>
|
||||
<Filename>TerminalConIn.c</Filename>
|
||||
<Filename>TerminalConOut.c</Filename>
|
||||
<Filename>ansi.c</Filename>
|
||||
<Filename>vtutf8.c</Filename>
|
||||
<Filename>ComponentName.c</Filename>
|
||||
</SourceFiles>
|
||||
<PackageDependencies>
|
||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
|
||||
</PackageDependencies>
|
||||
<Protocols>
|
||||
<Protocol Usage="BY_START">
|
||||
<ProtocolCName>gEfiSimpleTextOutProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="BY_START">
|
||||
<ProtocolCName>gEfiSimpleTextInProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="TO_START">
|
||||
<ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="TO_START">
|
||||
<ProtocolCName>gEfiSerialIoProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="SOMETIMES_CONSUMED">
|
||||
<ProtocolCName>gEfiHotPlugDeviceGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
</Protocols>
|
||||
<Variables>
|
||||
<Variable Usage="SOMETIMES_CONSUMED">
|
||||
<VariableName>0x0043 0x006F 0x006E 0x0049 0x006E 0x0044 0x0065 0x0076</VariableName>
|
||||
<GuidC_Name>gEfiGlobalVariableGuid</GuidC_Name>
|
||||
<HelpText>L"ConInDev" global variable will be updated if the serial device is not a hot plug device.</HelpText>
|
||||
</Variable>
|
||||
<Variable Usage="SOMETIMES_CONSUMED">
|
||||
<VariableName>0x0043 0x006F 0x006E 0x004F 0x0075 0x0074 0x0044 0x0065 0x0076</VariableName>
|
||||
<GuidC_Name>gEfiGlobalVariableGuid</GuidC_Name>
|
||||
<HelpText>L"ConOutDev" global variable will be updated if the serial device is not a hot plug device.</HelpText>
|
||||
</Variable>
|
||||
<Variable Usage="SOMETIMES_CONSUMED">
|
||||
<VariableName>0x0045 0x0072 0x0072 0x004F 0x0075 0x0074 0x0044 0x0065 0x0076</VariableName>
|
||||
<GuidC_Name>gEfiGlobalVariableGuid</GuidC_Name>
|
||||
<HelpText>L"ErrOutDev" global variable will be updated if the serial device is not a hot plug device.</HelpText>
|
||||
</Variable>
|
||||
</Variables>
|
||||
<Guids>
|
||||
<GuidCNames Usage="SOMETIMES_CONSUMED">
|
||||
<GuidCName>gEfiGlobalVariableGuid</GuidCName>
|
||||
</GuidCNames>
|
||||
<GuidCNames Usage="SOMETIMES_CONSUMED">
|
||||
<GuidCName>gEfiPcAnsiGuid</GuidCName>
|
||||
</GuidCNames>
|
||||
<GuidCNames Usage="SOMETIMES_CONSUMED">
|
||||
<GuidCName>gEfiVT100PlusGuid</GuidCName>
|
||||
</GuidCNames>
|
||||
<GuidCNames Usage="SOMETIMES_CONSUMED">
|
||||
<GuidCName>gEfiVT100Guid</GuidCName>
|
||||
</GuidCNames>
|
||||
<GuidCNames Usage="SOMETIMES_CONSUMED">
|
||||
<GuidCName>gEfiVTUTF8Guid</GuidCName>
|
||||
</GuidCNames>
|
||||
</Guids>
|
||||
<Externs>
|
||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||
<Extern>
|
||||
<DriverBinding>gTerminalDriverBinding</DriverBinding>
|
||||
<ComponentName>gTerminalComponentName</ComponentName>
|
||||
</Extern>
|
||||
</Externs>
|
||||
</ModuleSurfaceArea>
|
1184
MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
Normal file
1184
MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
Normal file
File diff suppressed because it is too large
Load Diff
1002
MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
Normal file
1002
MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
Normal file
File diff suppressed because it is too large
Load Diff
73
MdeModulePkg/Universal/Console/TerminalDxe/ansi.c
Normal file
73
MdeModulePkg/Universal/Console/TerminalDxe/ansi.c
Normal file
@@ -0,0 +1,73 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
All rights reserved. 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
ansi.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
Revision History
|
||||
--*/
|
||||
|
||||
|
||||
//
|
||||
// Include common header file for this module.
|
||||
//
|
||||
#include "CommonHeader.h"
|
||||
|
||||
#include "Terminal.h"
|
||||
|
||||
VOID
|
||||
AnsiRawDataToUnicode (
|
||||
IN TERMINAL_DEV *TerminalDevice
|
||||
)
|
||||
{
|
||||
UINT8 RawData;
|
||||
|
||||
//
|
||||
// pop the raw data out from the raw fifo,
|
||||
// and translate it into unicode, then push
|
||||
// the unicode into unicode fifo, until the raw fifo is empty.
|
||||
//
|
||||
while (!IsRawFiFoEmpty (TerminalDevice)) {
|
||||
|
||||
RawFiFoRemoveOneKey (TerminalDevice, &RawData);
|
||||
|
||||
UnicodeFiFoInsertOneKey (TerminalDevice, (UINT16) RawData);
|
||||
}
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
AnsiTestString (
|
||||
IN TERMINAL_DEV *TerminalDevice,
|
||||
IN CHAR16 *WString
|
||||
)
|
||||
{
|
||||
CHAR8 GraphicChar;
|
||||
|
||||
//
|
||||
// support three kind of character:
|
||||
// valid ascii, valid efi control char, valid text graphics.
|
||||
//
|
||||
for (; *WString != CHAR_NULL; WString++) {
|
||||
|
||||
if ( !(TerminalIsValidAscii (*WString) ||
|
||||
TerminalIsValidEfiCntlChar (*WString) ||
|
||||
TerminalIsValidTextGraphics (*WString, &GraphicChar, NULL) )) {
|
||||
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
275
MdeModulePkg/Universal/Console/TerminalDxe/vtutf8.c
Normal file
275
MdeModulePkg/Universal/Console/TerminalDxe/vtutf8.c
Normal file
@@ -0,0 +1,275 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
All rights reserved. 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
vtutf8.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
Revision History
|
||||
--*/
|
||||
|
||||
|
||||
//
|
||||
// Include common header file for this module.
|
||||
//
|
||||
#include "CommonHeader.h"
|
||||
|
||||
#include "Terminal.h"
|
||||
|
||||
VOID
|
||||
VTUTF8RawDataToUnicode (
|
||||
IN TERMINAL_DEV *TerminalDevice
|
||||
)
|
||||
{
|
||||
UTF8_CHAR Utf8Char;
|
||||
UINT8 ValidBytes;
|
||||
UINT16 UnicodeChar;
|
||||
|
||||
ValidBytes = 0;
|
||||
//
|
||||
// pop the raw data out from the raw fifo,
|
||||
// and translate it into unicode, then push
|
||||
// the unicode into unicode fifo, until the raw fifo is empty.
|
||||
//
|
||||
while (!IsRawFiFoEmpty (TerminalDevice)) {
|
||||
|
||||
GetOneValidUtf8Char (TerminalDevice, &Utf8Char, &ValidBytes);
|
||||
|
||||
if (ValidBytes < 1 || ValidBytes > 3) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Utf8ToUnicode (Utf8Char, ValidBytes, (CHAR16 *) &UnicodeChar);
|
||||
|
||||
UnicodeFiFoInsertOneKey (TerminalDevice, UnicodeChar);
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
GetOneValidUtf8Char (
|
||||
IN TERMINAL_DEV *Utf8Device,
|
||||
OUT UTF8_CHAR *Utf8Char,
|
||||
OUT UINT8 *ValidBytes
|
||||
)
|
||||
{
|
||||
UINT8 Temp;
|
||||
UINT8 Index;
|
||||
BOOLEAN FetchFlag;
|
||||
|
||||
Temp = 0;
|
||||
Index = 0;
|
||||
FetchFlag = TRUE;
|
||||
|
||||
//
|
||||
// if no valid Utf8 char is found in the RawFiFo,
|
||||
// then *ValidBytes will be zero.
|
||||
//
|
||||
*ValidBytes = 0;
|
||||
|
||||
while (!IsRawFiFoEmpty (Utf8Device)) {
|
||||
|
||||
RawFiFoRemoveOneKey (Utf8Device, &Temp);
|
||||
|
||||
switch (*ValidBytes) {
|
||||
|
||||
case 0:
|
||||
if ((Temp & 0x80) == 0) {
|
||||
//
|
||||
// one-byte utf8 char
|
||||
//
|
||||
*ValidBytes = 1;
|
||||
|
||||
Utf8Char->Utf8_1 = Temp;
|
||||
|
||||
FetchFlag = FALSE;
|
||||
|
||||
} else if ((Temp & 0xe0) == 0xc0) {
|
||||
//
|
||||
// two-byte utf8 char
|
||||
//
|
||||
*ValidBytes = 2;
|
||||
|
||||
Utf8Char->Utf8_2[1] = Temp;
|
||||
|
||||
} else if ((Temp & 0xf0) == 0xe0) {
|
||||
//
|
||||
// three-byte utf8 char
|
||||
//
|
||||
*ValidBytes = 3;
|
||||
|
||||
Utf8Char->Utf8_3[2] = Temp;
|
||||
|
||||
Index++;
|
||||
|
||||
} else {
|
||||
//
|
||||
// reset *ValidBytes to zero, let valid utf8 char search restart
|
||||
//
|
||||
*ValidBytes = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ((Temp & 0xc0) == 0x80) {
|
||||
|
||||
Utf8Char->Utf8_2[0] = Temp;
|
||||
|
||||
FetchFlag = FALSE;
|
||||
|
||||
} else {
|
||||
|
||||
*ValidBytes = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if ((Temp & 0xc0) == 0x80) {
|
||||
|
||||
Utf8Char->Utf8_3[2 - Index] = Temp;
|
||||
Index++;
|
||||
if (Index == 3) {
|
||||
FetchFlag = FALSE;
|
||||
}
|
||||
} else {
|
||||
|
||||
*ValidBytes = 0;
|
||||
Index = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!FetchFlag) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
VOID
|
||||
Utf8ToUnicode (
|
||||
IN UTF8_CHAR Utf8Char,
|
||||
IN UINT8 ValidBytes,
|
||||
OUT CHAR16 *UnicodeChar
|
||||
)
|
||||
{
|
||||
UINT8 UnicodeByte0;
|
||||
UINT8 UnicodeByte1;
|
||||
UINT8 Byte0;
|
||||
UINT8 Byte1;
|
||||
UINT8 Byte2;
|
||||
|
||||
*UnicodeChar = 0;
|
||||
|
||||
//
|
||||
// translate utf8 code to unicode, in terminal standard,
|
||||
// up to 3 bytes utf8 code is supported.
|
||||
//
|
||||
switch (ValidBytes) {
|
||||
case 1:
|
||||
//
|
||||
// one-byte utf8 code
|
||||
//
|
||||
*UnicodeChar = (UINT16) Utf8Char.Utf8_1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
//
|
||||
// two-byte utf8 code
|
||||
//
|
||||
Byte0 = Utf8Char.Utf8_2[0];
|
||||
Byte1 = Utf8Char.Utf8_2[1];
|
||||
|
||||
UnicodeByte0 = (UINT8) ((Byte1 << 6) | (Byte0 & 0x3f));
|
||||
UnicodeByte1 = (UINT8) ((Byte1 >> 2) & 0x07);
|
||||
*UnicodeChar = (UINT16) (UnicodeByte0 | (UnicodeByte1 << 8));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
//
|
||||
// three-byte utf8 code
|
||||
//
|
||||
Byte0 = Utf8Char.Utf8_3[0];
|
||||
Byte1 = Utf8Char.Utf8_3[1];
|
||||
Byte2 = Utf8Char.Utf8_3[2];
|
||||
|
||||
UnicodeByte0 = (UINT8) ((Byte1 << 6) | (Byte0 & 0x3f));
|
||||
UnicodeByte1 = (UINT8) ((Byte2 << 4) | ((Byte1 >> 2) & 0x0f));
|
||||
*UnicodeChar = (UINT16) (UnicodeByte0 | (UnicodeByte1 << 8));
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
VOID
|
||||
UnicodeToUtf8 (
|
||||
IN CHAR16 Unicode,
|
||||
OUT UTF8_CHAR *Utf8Char,
|
||||
OUT UINT8 *ValidBytes
|
||||
)
|
||||
{
|
||||
UINT8 UnicodeByte0;
|
||||
UINT8 UnicodeByte1;
|
||||
//
|
||||
// translate unicode to utf8 code
|
||||
//
|
||||
UnicodeByte0 = (UINT8) Unicode;
|
||||
UnicodeByte1 = (UINT8) (Unicode >> 8);
|
||||
|
||||
if (Unicode < 0x0080) {
|
||||
|
||||
Utf8Char->Utf8_1 = (UINT8) (UnicodeByte0 & 0x7f);
|
||||
*ValidBytes = 1;
|
||||
|
||||
} else if (Unicode < 0x0800) {
|
||||
//
|
||||
// byte sequence: high -> low
|
||||
// Utf8_2[0], Utf8_2[1]
|
||||
//
|
||||
Utf8Char->Utf8_2[1] = (UINT8) ((UnicodeByte0 & 0x3f) + 0x80);
|
||||
Utf8Char->Utf8_2[0] = (UINT8) ((((UnicodeByte1 << 2) + (UnicodeByte0 >> 6)) & 0x1f) + 0xc0);
|
||||
|
||||
*ValidBytes = 2;
|
||||
|
||||
} else {
|
||||
//
|
||||
// byte sequence: high -> low
|
||||
// Utf8_3[0], Utf8_3[1], Utf8_3[2]
|
||||
//
|
||||
Utf8Char->Utf8_3[2] = (UINT8) ((UnicodeByte0 & 0x3f) + 0x80);
|
||||
Utf8Char->Utf8_3[1] = (UINT8) ((((UnicodeByte1 << 2) + (UnicodeByte0 >> 6)) & 0x3f) + 0x80);
|
||||
Utf8Char->Utf8_3[0] = (UINT8) (((UnicodeByte1 >> 4) & 0x0f) + 0xe0);
|
||||
|
||||
*ValidBytes = 3;
|
||||
}
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
VTUTF8TestString (
|
||||
IN TERMINAL_DEV *TerminalDevice,
|
||||
IN CHAR16 *WString
|
||||
)
|
||||
{
|
||||
//
|
||||
// to utf8, all kind of characters are supported.
|
||||
//
|
||||
return EFI_SUCCESS;
|
||||
}
|
Reference in New Issue
Block a user