Add WinNtConsole driver into Nt32Pkg.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2779 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2 2007-06-27 06:23:37 +00:00
parent d8a43975d9
commit af4d71fcda
9 changed files with 2342 additions and 1 deletions

View File

@ -20,6 +20,8 @@ Abstract:
#ifndef __WIN_NT_IO_H__ #ifndef __WIN_NT_IO_H__
#define __WIN_NT_IO_H__ #define __WIN_NT_IO_H__
#include <Protocol/WinNtThunk.h>
#define EFI_WIN_NT_IO_PROTOCOL_GUID \ #define EFI_WIN_NT_IO_PROTOCOL_GUID \
{ 0x96eb4ad6, 0xa32a, 0x11d4, { 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } } { 0x96eb4ad6, 0xa32a, 0x11d4, { 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } }

View File

@ -406,3 +406,4 @@
$(WORKSPACE)\Nt32Pkg\WinNtAutoScanPeim\WinNtAutoScan.inf $(WORKSPACE)\Nt32Pkg\WinNtAutoScanPeim\WinNtAutoScan.inf
$(WORKSPACE)\Nt32Pkg\WinNtBlockIoDxe\WinNtBlockIo.inf $(WORKSPACE)\Nt32Pkg\WinNtBlockIoDxe\WinNtBlockIo.inf
$(WORKSPACE)\Nt32Pkg\WinNtBusDriverDxe\WinNtBusDriver.inf $(WORKSPACE)\Nt32Pkg\WinNtBusDriverDxe\WinNtBusDriver.inf
$(WORKSPACE)\Nt32Pkg\WinNtConsoleDxe\WinNtConsole.inf

View File

@ -0,0 +1,220 @@
/*++
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:
--*/
//
// The package level header files this module uses
//
#include <Uefi.h>
#include <WinNtDxe.h>
//
// The protocols, PPI and GUID defintions for this module
//
#include <Protocol/SimpleTextIn.h>
#include <Protocol/WinNtIo.h>
#include <Protocol/SimpleTextOut.h>
#include <Protocol/ComponentName.h>
#include <Protocol/DriverBinding.h>
//
// The Library classes this module consumes
//
#include <Library/DebugLib.h>
#include <Library/BaseLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include "Console.h"
//
// EFI Component Name Functions
//
EFI_STATUS
EFIAPI
WinNtConsoleComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
);
EFI_STATUS
EFIAPI
WinNtConsoleComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
);
//
// EFI Component Name Protocol
//
EFI_COMPONENT_NAME_PROTOCOL gWinNtConsoleComponentName = {
WinNtConsoleComponentNameGetDriverName,
WinNtConsoleComponentNameGetControllerName,
"eng"
};
static EFI_UNICODE_STRING_TABLE mWinNtConsoleDriverNameTable[] = {
{ "eng", L"Windows Text Console Driver" },
{ NULL , NULL }
};
EFI_STATUS
EFIAPI
WinNtConsoleComponentNameGetDriverName (
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,
gWinNtConsoleComponentName.SupportedLanguages,
mWinNtConsoleDriverNameTable,
DriverName
);
}
EFI_STATUS
EFIAPI
WinNtConsoleComponentNameGetControllerName (
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 *SimpleTextOut;
WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private;
//
// This is a device driver, so ChildHandle must be NULL.
//
if (ChildHandle != NULL) {
return EFI_UNSUPPORTED;
}
//
// Make sure this driver is currently managing ControllerHandle
//
Status = EfiTestManagedDevice (
ControllerHandle,
gWinNtConsoleDriverBinding.DriverBindingHandle,
&gEfiWinNtIoProtocolGuid
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
//
// Get out context back
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiSimpleTextOutProtocolGuid,
&SimpleTextOut,
gWinNtConsoleDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
Private = WIN_NT_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (SimpleTextOut);
return LookupUnicodeString (
Language,
gWinNtConsoleComponentName.SupportedLanguages,
Private->ControllerNameTable,
ControllerName
);
}

View File

@ -0,0 +1,364 @@
/*++
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.
Module Name:
Console.c
Abstract:
Console based on Win32 APIs.
--*/
//
// The package level header files this module uses
//
#include <Uefi.h>
#include <WinNtDxe.h>
//
// The protocols, PPI and GUID defintions for this module
//
#include <Protocol/SimpleTextIn.h>
#include <Protocol/WinNtIo.h>
#include <Protocol/SimpleTextOut.h>
#include <Protocol/ComponentName.h>
#include <Protocol/DriverBinding.h>
//
// The Library classes this module consumes
//
#include <Library/DebugLib.h>
#include <Library/BaseLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include "Console.h"
EFI_STATUS
EFIAPI
WinNtConsoleDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
EFI_STATUS
EFIAPI
WinNtConsoleDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
EFI_STATUS
EFIAPI
WinNtConsoleDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
);
EFI_DRIVER_BINDING_PROTOCOL gWinNtConsoleDriverBinding = {
WinNtConsoleDriverBindingSupported,
WinNtConsoleDriverBindingStart,
WinNtConsoleDriverBindingStop,
0xa,
NULL,
NULL
};
/**
The user Entry Point for module WinNtConsole. 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
InitializeWinNtConsole(
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
//
// Install driver model protocol(s).
//
Status = EfiLibInstallAllDriverProtocols (
ImageHandle,
SystemTable,
&gWinNtConsoleDriverBinding,
ImageHandle,
&gWinNtConsoleComponentName,
NULL,
NULL
);
ASSERT_EFI_ERROR (Status);
return Status;
}
EFI_STATUS
EFIAPI
WinNtConsoleDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
// TODO: This - add argument and description to function comment
// TODO: Handle - add argument and description to function comment
// TODO: RemainingDevicePath - add argument and description to function comment
{
EFI_STATUS Status;
EFI_WIN_NT_IO_PROTOCOL *WinNtIo;
//
// Open the IO Abstraction(s) needed to perform the supported test
//
Status = gBS->OpenProtocol (
Handle,
&gEfiWinNtIoProtocolGuid,
&WinNtIo,
This->DriverBindingHandle,
Handle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Make sure that the WinNt Thunk Protocol is valid
//
Status = EFI_UNSUPPORTED;
if (WinNtIo->WinNtThunk->Signature == EFI_WIN_NT_THUNK_PROTOCOL_SIGNATURE) {
//
// Check the GUID to see if this is a handle type the driver supports
//
if (CompareGuid (WinNtIo->TypeGuid, &gEfiWinNtConsoleGuid)) {
Status = EFI_SUCCESS;
}
}
//
// Close the I/O Abstraction(s) used to perform the supported test
//
gBS->CloseProtocol (
Handle,
&gEfiWinNtIoProtocolGuid,
This->DriverBindingHandle,
Handle
);
return Status;
}
EFI_STATUS
EFIAPI
WinNtConsoleDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
// TODO: This - add argument and description to function comment
// TODO: Handle - add argument and description to function comment
// TODO: RemainingDevicePath - add argument and description to function comment
{
EFI_STATUS Status;
EFI_WIN_NT_IO_PROTOCOL *WinNtIo;
WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private;
//
// Grab the IO abstraction we need to get any work done
//
Status = gBS->OpenProtocol (
Handle,
&gEfiWinNtIoProtocolGuid,
&WinNtIo,
This->DriverBindingHandle,
Handle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
return Status;
}
Private = AllocatePool (sizeof (WIN_NT_SIMPLE_TEXT_PRIVATE_DATA));
if (Private == NULL) {
goto Done;
}
ZeroMem (Private, sizeof (WIN_NT_SIMPLE_TEXT_PRIVATE_DATA));
Private->Signature = WIN_NT_SIMPLE_TEXT_PRIVATE_DATA_SIGNATURE;
Private->Handle = Handle;
Private->WinNtIo = WinNtIo;
Private->WinNtThunk = WinNtIo->WinNtThunk;
WinNtSimpleTextOutOpenWindow (Private);
WinNtSimpleTextInAttachToWindow (Private);
Status = gBS->InstallMultipleProtocolInterfaces (
&Handle,
&gEfiSimpleTextOutProtocolGuid,
&Private->SimpleTextOut,
&gEfiSimpleTextInProtocolGuid,
&Private->SimpleTextIn,
NULL
);
if (!EFI_ERROR (Status)) {
return Status;
}
Done:
gBS->CloseProtocol (
Handle,
&gEfiWinNtIoProtocolGuid,
This->DriverBindingHandle,
Handle
);
if (Private != NULL) {
FreeUnicodeStringTable (Private->ControllerNameTable);
if (Private->NtOutHandle != NULL) {
Private->WinNtThunk->CloseHandle (Private->NtOutHandle);
}
if (Private->SimpleTextIn.WaitForKey != NULL) {
gBS->CloseEvent (Private->SimpleTextIn.WaitForKey);
}
FreePool (Private);
}
return Status;
}
EFI_STATUS
EFIAPI
WinNtConsoleDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Handle - TODO: add argument description
NumberOfChildren - TODO: add argument description
ChildHandleBuffer - TODO: add argument description
Returns:
EFI_UNSUPPORTED - TODO: Add description for return value
--*/
{
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
EFI_STATUS Status;
WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private;
//
// Kick people off our interface???
//
Status = gBS->OpenProtocol (
Handle,
&gEfiSimpleTextOutProtocolGuid,
&SimpleTextOut,
This->DriverBindingHandle,
Handle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
Private = WIN_NT_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (SimpleTextOut);
ASSERT (Private->Handle == Handle);
Status = gBS->UninstallMultipleProtocolInterfaces (
Handle,
&gEfiSimpleTextOutProtocolGuid,
&Private->SimpleTextOut,
&gEfiSimpleTextInProtocolGuid,
&Private->SimpleTextIn,
NULL
);
if (!EFI_ERROR (Status)) {
//
// Shut down our device
//
Status = gBS->CloseProtocol (
Handle,
&gEfiWinNtIoProtocolGuid,
This->DriverBindingHandle,
Handle
);
Status = gBS->CloseEvent (Private->SimpleTextIn.WaitForKey);
ASSERT_EFI_ERROR (Status);
Private->WinNtThunk->CloseHandle (Private->NtOutHandle);
//
// DO NOT close Private->NtInHandle. It points to StdIn and not
// the Private->NtOutHandle is StdIn and should not be closed!
//
FreeUnicodeStringTable (Private->ControllerNameTable);
FreePool (Private);
}
return Status;
}

View File

@ -0,0 +1,511 @@
/*++
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:
Console.h
Abstract:
Console based on Win32 APIs.
This file attaches a SimpleTextIn protocol to a previously open window.
The constructor for this protocol depends on an open window. Currently
the SimpleTextOut protocol creates a window when it's constructor is called.
Thus this code must run after the constructor for the SimpleTextOut
protocol
--*/
#ifndef _CONSOLE_H_
#define _CONSOLE_H_
#define WIN_NT_SIMPLE_TEXT_PRIVATE_DATA_SIGNATURE \
EFI_SIGNATURE_32('N','T','s','c')
typedef struct {
UINT64 Signature;
EFI_HANDLE Handle;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOut;
EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutMode;
EFI_WIN_NT_IO_PROTOCOL *WinNtIo;
EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;
//
// SimpleTextOut Private Data including Win32 types.
//
HANDLE NtOutHandle;
HANDLE NtInHandle;
COORD MaxScreenSize;
COORD Possition;
WORD Attribute;
BOOLEAN CursorEnable;
EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
} WIN_NT_SIMPLE_TEXT_PRIVATE_DATA;
#define WIN_NT_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS(a) \
CR(a, WIN_NT_SIMPLE_TEXT_PRIVATE_DATA, SimpleTextOut, WIN_NT_SIMPLE_TEXT_PRIVATE_DATA_SIGNATURE)
#define WIN_NT_SIMPLE_TEXT_IN_PRIVATE_DATA_FROM_THIS(a) \
CR(a, WIN_NT_SIMPLE_TEXT_PRIVATE_DATA, SimpleTextIn, WIN_NT_SIMPLE_TEXT_PRIVATE_DATA_SIGNATURE)
//
// Console Globale Variables
//
extern EFI_DRIVER_BINDING_PROTOCOL gWinNtConsoleDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gWinNtConsoleComponentName;
typedef struct {
UINTN ColumnsX;
UINTN RowsY;
} WIN_NT_SIMPLE_TEXT_OUT_MODE;
//
// Simple Text Out protocol member functions
//
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutReset (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
ExtendedVerification - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutOutputString (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN CHAR16 *String
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
String - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutTestString (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN CHAR16 *String
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
String - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutQueryMode (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN ModeNumber,
OUT UINTN *Columns,
OUT UINTN *Rows
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
ModeNumber - TODO: add argument description
Columns - TODO: add argument description
Rows - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutSetMode (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN ModeNumber
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
ModeNumber - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutSetAttribute (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN Attribute
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Attribute - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutClearScreen (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutSetCursorPosition (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN Column,
IN UINTN Row
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Column - TODO: add argument description
Row - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutEnableCursor (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN BOOLEAN Enable
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Enable - TODO: add argument description
Returns:
TODO: add return values
--*/
;
//
// Simple Text Out constructor and destructor.
//
EFI_STATUS
WinNtSimpleTextOutOpenWindow (
IN OUT WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
WinNtSimpleTextOutCloseWindow (
IN OUT WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Console
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Console - TODO: add argument description
Returns:
TODO: add return values
--*/
;
//
// Simple Text In protocol member functions.
//
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextInReset (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
ExtendedVerification - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextInReadKeyStroke (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
OUT EFI_INPUT_KEY *Key
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Key - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
VOID
EFIAPI
WinNtSimpleTextInWaitForKey (
IN EFI_EVENT Event,
IN VOID *Context
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Event - TODO: add argument description
Context - TODO: add argument description
Returns:
TODO: add return values
--*/
;
//
// Simple Text In constructor
//
EFI_STATUS
WinNtSimpleTextInAttachToWindow (
IN WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
;
//
// Main Entry Point
//
EFI_STATUS
EFIAPI
InitializeWinNtConsole (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
TODO: Add function description
Arguments:
ImageHandle - TODO: add argument description
SystemTable - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
AppendDevicePathInstanceToVar (
IN CHAR16 *VariableName,
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
)
/*++
Routine Description:
TODO: Add function description
Arguments:
VariableName - TODO: add argument description
DevicePathInstance - TODO: add argument description
Returns:
TODO: add return values
--*/
;
#endif

View File

@ -0,0 +1,379 @@
/*++
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.
Module Name:
ConsoleIn.c
Abstract:
Console based on Win32 APIs.
This file attaches a SimpleTextIn protocol to a previously open window.
The constructor for this protocol depends on an open window. Currently
the SimpleTextOut protocol creates a window when it's constructor is called.
Thus this code must run after the constructor for the SimpleTextOut
protocol
--*/
//
// The package level header files this module uses
//
#include <Uefi.h>
#include <WinNtDxe.h>
//
// The protocols, PPI and GUID defintions for this module
//
#include <Protocol/SimpleTextIn.h>
#include <Protocol/WinNtIo.h>
#include <Protocol/SimpleTextOut.h>
#include <Protocol/ComponentName.h>
#include <Protocol/DriverBinding.h>
//
// The Library classes this module consumes
//
#include <Library/DebugLib.h>
#include <Library/BaseLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include "Console.h"
//
// Private worker functions
//
STATIC
EFI_STATUS
WinNtSimpleTextInCheckKey (
WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private
);
EFI_STATUS
EFIAPI
WinNtSimpleTextInReset (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
ExtendedVerification - TODO: add argument description
Returns:
EFI_SUCCESS - TODO: Add description for return value
--*/
{
WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private;
Private = WIN_NT_SIMPLE_TEXT_IN_PRIVATE_DATA_FROM_THIS (This);
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
WinNtConvertInputRecordToEfiKey (
IN INPUT_RECORD *InputRecord,
OUT EFI_INPUT_KEY *Key
)
/*++
Routine Description:
TODO: Add function description
Arguments:
InputRecord - TODO: add argument description
Key - TODO: add argument description
Returns:
EFI_NOT_READY - TODO: Add description for return value
EFI_NOT_READY - TODO: Add description for return value
EFI_NOT_READY - TODO: Add description for return value
EFI_SUCCESS - TODO: Add description for return value
--*/
{
//
// Make sure InputRecord is an event that represents a keypress
//
if (InputRecord->EventType == KEY_EVENT) {
if (!InputRecord->Event.KeyEvent.bKeyDown) {
return EFI_NOT_READY;
}
} else {
return EFI_NOT_READY;
}
//
// Check to see if we should return a scan code in place of Unicode character.
//
Key->ScanCode = 0;
Key->UnicodeChar = 0;
if ((InputRecord->Event.KeyEvent.dwControlKeyState & (NUMLOCK_ON | ENHANCED_KEY)) != NUMLOCK_ON) {
//
// Only check these scan codes if num lock is off.
//
switch (InputRecord->Event.KeyEvent.wVirtualScanCode) {
case 0x48: Key->ScanCode = SCAN_UP; break;
case 0x50: Key->ScanCode = SCAN_DOWN; break;
case 0x4d: Key->ScanCode = SCAN_RIGHT; break;
case 0x4b: Key->ScanCode = SCAN_LEFT; break;
case 0x47: Key->ScanCode = SCAN_HOME; break;
case 0x4F: Key->ScanCode = SCAN_END; break;
case 0x52: Key->ScanCode = SCAN_INSERT; break;
case 0x53: Key->ScanCode = SCAN_DELETE; break;
case 0x49: Key->ScanCode = SCAN_PAGE_UP; break;
case 0x51: Key->ScanCode = SCAN_PAGE_DOWN; break;
}
}
switch (InputRecord->Event.KeyEvent.wVirtualScanCode) {
case 0x3b: Key->ScanCode = SCAN_F1; break;
case 0x3c: Key->ScanCode = SCAN_F2; break;
case 0x3d: Key->ScanCode = SCAN_F3; break;
case 0x3e: Key->ScanCode = SCAN_F4; break;
case 0x3f: Key->ScanCode = SCAN_F5; break;
case 0x40: Key->ScanCode = SCAN_F6; break;
case 0x41: Key->ScanCode = SCAN_F7; break;
case 0x42: Key->ScanCode = SCAN_F8; break;
case 0x43: Key->ScanCode = SCAN_F9; break;
case 0x44: Key->ScanCode = SCAN_F10; break;
case 0x01: Key->ScanCode = SCAN_ESC; break;
}
//
// If there's a scan code pass it, and don't pass the char code
//
if (Key->ScanCode == 0) {
Key->UnicodeChar = InputRecord->Event.KeyEvent.uChar.UnicodeChar;
if (Key->UnicodeChar == 0) {
return EFI_NOT_READY;
}
}
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextInReadKeyStroke (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
OUT EFI_INPUT_KEY *Key
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Key - TODO: add argument description
Returns:
EFI_DEVICE_ERROR - TODO: Add description for return value
EFI_NOT_READY - TODO: Add description for return value
--*/
{
EFI_STATUS Status;
WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private;
INPUT_RECORD InputRecord;
DWORD NtEventCount;
Private = WIN_NT_SIMPLE_TEXT_IN_PRIVATE_DATA_FROM_THIS (This);
Status = WinNtSimpleTextInCheckKey (Private);
if (EFI_ERROR (Status)) {
return Status;
}
do {
if (!Private->WinNtThunk->ReadConsoleInput (Private->NtInHandle, &InputRecord, 1, &NtEventCount)) {
return EFI_DEVICE_ERROR;
}
if (NtEventCount == 0) {
return EFI_NOT_READY;
}
//
// Convert the Input Record to an EFI Keystroke.
//
Status = WinNtConvertInputRecordToEfiKey (&InputRecord, Key);
} while (EFI_ERROR (Status));
return Status;
}
STATIC
VOID
EFIAPI
WinNtSimpleTextInWaitForKey (
IN EFI_EVENT Event,
IN VOID *Context
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Event - TODO: add argument description
Context - TODO: add argument description
Returns:
TODO: add return values
--*/
{
WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private;
EFI_STATUS Status;
Private = (WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *) Context;
Status = WinNtSimpleTextInCheckKey (Private);
if (!EFI_ERROR (Status)) {
gBS->SignalEvent (Event);
}
}
STATIC
EFI_STATUS
WinNtSimpleTextInCheckKey (
WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
{
INPUT_RECORD *InputRecord;
DWORD NtEventCount;
DWORD ActualNtEventCount;
EFI_STATUS Status;
BOOLEAN Success;
UINTN Index;
EFI_INPUT_KEY Key;
InputRecord = NULL;
NtEventCount = 0;
Private->WinNtThunk->GetNumberOfConsoleInputEvents (Private->NtInHandle, &NtEventCount);
if (NtEventCount == 0) {
Status = EFI_NOT_READY;
goto Done;
}
InputRecord = AllocatePool (sizeof (INPUT_RECORD) * NtEventCount);
if (InputRecord == NULL) {
Status = EFI_NOT_READY;
goto Done;
}
Success = (BOOLEAN) Private->WinNtThunk->PeekConsoleInput (
Private->NtInHandle,
InputRecord,
NtEventCount,
&ActualNtEventCount
);
if (!Success) {
Status = EFI_NOT_READY;
goto Done;
}
Status = EFI_NOT_READY;
for (Index = 0; Index < (UINTN) ActualNtEventCount; Index++) {
//
// Convert the Input Record to an EFI Keystroke.
//
Status = WinNtConvertInputRecordToEfiKey (&InputRecord[Index], &Key);
if (!EFI_ERROR (Status)) {
Status = EFI_SUCCESS;
goto Done;
}
}
Done:
if (InputRecord != NULL) {
FreePool (InputRecord);
}
return Status;
}
EFI_STATUS
WinNtSimpleTextInAttachToWindow (
IN WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
{
EFI_STATUS Status;
Private->NtInHandle = Private->WinNtThunk->GetStdHandle (STD_INPUT_HANDLE);
Private->SimpleTextIn.Reset = WinNtSimpleTextInReset;
Private->SimpleTextIn.ReadKeyStroke = WinNtSimpleTextInReadKeyStroke;
Status = gBS->CreateEvent (
EVT_NOTIFY_WAIT,
TPL_NOTIFY,
WinNtSimpleTextInWaitForKey,
Private,
&Private->SimpleTextIn.WaitForKey
);
ASSERT_EFI_ERROR (Status);
return Status;
}

View File

@ -0,0 +1,663 @@
/*++
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:
ConsoleOut.c
Abstract:
Console based on Win32 APIs.
This file creates an Win32 window and attaches a SimpleTextOut protocol.
--*/
//
// The package level header files this module uses
//
#include <Uefi.h>
#include <WinNtDxe.h>
//
// The protocols, PPI and GUID defintions for this module
//
#include <Protocol/SimpleTextIn.h>
#include <Protocol/WinNtIo.h>
#include <Protocol/SimpleTextOut.h>
#include <Protocol/ComponentName.h>
#include <Protocol/DriverBinding.h>
//
// The Library classes this module consumes
//
#include <Library/DebugLib.h>
#include <Library/BaseLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include "Console.h"
//
// Private worker functions.
//
STATIC
VOID
WinNtSimpleTextOutScrollScreen (
IN OUT WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Console
);
STATIC
VOID
WinNtSimpleTextOutPutChar (
IN OUT WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Console,
IN CHAR16 Char
);
//
// Modeule Global for Simple Text Out Mode.
//
#define MAX_SIMPLE_TEXT_OUT_MODE \
(sizeof(mWinNtSimpleTextOutSupportedModes)/sizeof(WIN_NT_SIMPLE_TEXT_OUT_MODE))
STATIC WIN_NT_SIMPLE_TEXT_OUT_MODE mWinNtSimpleTextOutSupportedModes[] = {
{ 80, 25 },
{ 80, 50 },
{ 80, 43 },
{ 100, 100 },
{ 100, 999 }
};
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutReset (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
ExtendedVerification - TODO: add argument description
Returns:
EFI_SUCCESS - TODO: Add description for return value
--*/
{
WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private;
Private = WIN_NT_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);
WinNtSimpleTextOutSetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK));
WinNtSimpleTextOutSetMode (This, 0);
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutOutputString (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN CHAR16 *String
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
String - TODO: add argument description
Returns:
EFI_SUCCESS - TODO: Add description for return value
--*/
{
WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private;
CHAR16 *Str;
Private = WIN_NT_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);
for (Str = String; *Str != '\0'; Str++) {
switch (*Str) {
case '\n':
if (Private->Possition.Y == (Private->MaxScreenSize.Y - 1)) {
WinNtSimpleTextOutScrollScreen (Private);
}
if (Private->Possition.Y < (Private->MaxScreenSize.Y - 1)) {
Private->Possition.Y++;
This->Mode->CursorRow++;
}
break;
case '\r':
Private->Possition.X = 0;
This->Mode->CursorColumn = 0;
break;
case '\b':
if (Private->Possition.X > 0) {
Private->Possition.X--;
This->Mode->CursorColumn--;
}
break;
default:
WinNtSimpleTextOutPutChar (Private, *Str);
}
}
return EFI_SUCCESS;
}
STATIC
VOID
WinNtSimpleTextOutPutChar (
IN OUT WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Console,
IN CHAR16 Char
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Console - TODO: add argument description
Char - TODO: add argument description
Returns:
TODO: add return values
--*/
{
SMALL_RECT Region;
COORD StrCoordinate;
COORD StrSize;
CHAR_INFO CharInfo;
BOOL Flag;
CharInfo.Char.UnicodeChar = Char;
CharInfo.Attributes = Console->Attribute;
StrSize.X = 1;
StrSize.Y = 1;
StrCoordinate.X = 0;
StrCoordinate.Y = 0;
Region.Left = (INT16) Console->Possition.X;
Region.Top = (INT16) Console->Possition.Y;
Region.Right = (INT16) (Console->Possition.X + 1);
Region.Bottom = (INT16) Console->Possition.Y;
Console->WinNtThunk->WriteConsoleOutput (
Console->NtOutHandle,
&CharInfo,
StrSize,
StrCoordinate,
&Region
);
if (Console->Possition.X >= (Console->MaxScreenSize.X - 1)) {
//
// If you print off the end wrap around
//
Console->SimpleTextOut.OutputString (&Console->SimpleTextOut, L"\n\r");
} else {
Console->Possition.X++;
Console->SimpleTextOut.Mode->CursorColumn++;
}
Flag = Console->WinNtThunk->SetConsoleCursorPosition (Console->NtOutHandle, Console->Possition);
}
STATIC
VOID
WinNtSimpleTextOutScrollScreen (
IN OUT WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Console
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Console - TODO: add argument description
Returns:
TODO: add return values
--*/
{
SMALL_RECT Scroll;
CHAR_INFO CharInfo;
COORD Origin;
CharInfo.Char.UnicodeChar = ' ';
CharInfo.Attributes = Console->Attribute;
Origin.X = 0;
Origin.Y = 0;
Scroll.Top = 1;
Scroll.Left = 0;
Scroll.Right = (INT16) Console->MaxScreenSize.X;
Scroll.Bottom = (INT16) Console->MaxScreenSize.Y;
Console->WinNtThunk->ScrollConsoleScreenBuffer (
Console->NtOutHandle,
&Scroll,
NULL,
Origin,
&CharInfo
);
}
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutTestString (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN CHAR16 *String
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
String - TODO: add argument description
Returns:
EFI_SUCCESS - TODO: Add description for return value
--*/
{
WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private;
Private = WIN_NT_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);
//
// BugBug: The correct answer would be a function of what code pages
// are currently loaded? For now we will just return success.
//
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutQueryMode (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN ModeNumber,
OUT UINTN *Columns,
OUT UINTN *Rows
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
ModeNumber - TODO: add argument description
Columns - TODO: add argument description
Rows - TODO: add argument description
Returns:
EFI_INVALID_PARAMETER - TODO: Add description for return value
EFI_SUCCESS - TODO: Add description for return value
--*/
{
WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private;
Private = WIN_NT_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);
if (ModeNumber > MAX_SIMPLE_TEXT_OUT_MODE) {
return EFI_INVALID_PARAMETER;
}
*Columns = mWinNtSimpleTextOutSupportedModes[ModeNumber].ColumnsX;
*Rows = mWinNtSimpleTextOutSupportedModes[ModeNumber].RowsY;
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutSetMode (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN ModeNumber
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
ModeNumber - TODO: add argument description
Returns:
EFI_INVALID_PARAMETER - TODO: Add description for return value
EFI_SUCCESS - TODO: Add description for return value
--*/
{
WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private;
Private = WIN_NT_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);
if (ModeNumber > MAX_SIMPLE_TEXT_OUT_MODE) {
return EFI_INVALID_PARAMETER;
}
Private->MaxScreenSize.X = (WORD) mWinNtSimpleTextOutSupportedModes[ModeNumber].ColumnsX;
Private->MaxScreenSize.Y = (WORD) mWinNtSimpleTextOutSupportedModes[ModeNumber].RowsY;
Private->WinNtThunk->SetConsoleScreenBufferSize (Private->NtOutHandle, Private->MaxScreenSize);
Private->WinNtThunk->SetConsoleActiveScreenBuffer (Private->NtOutHandle);
This->Mode->Mode = (INT32) ModeNumber;
This->EnableCursor (This, TRUE);
This->ClearScreen (This);
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutSetAttribute (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN Attribute
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Attribute - TODO: add argument description
Returns:
EFI_SUCCESS - TODO: Add description for return value
--*/
{
WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private;
Private = WIN_NT_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);
Private->Attribute = (WORD) Attribute;
This->Mode->Attribute = (INT32) Attribute;
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutClearScreen (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Returns:
EFI_SUCCESS - TODO: Add description for return value
--*/
{
WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private;
DWORD ConsoleWindow;
Private = WIN_NT_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);
This->SetCursorPosition (This, 0, 0);
Private->WinNtThunk->FillConsoleOutputCharacter (
Private->NtOutHandle,
' ',
Private->MaxScreenSize.X * Private->MaxScreenSize.Y,
Private->Possition,
&ConsoleWindow
);
Private->WinNtThunk->FillConsoleOutputAttribute (
Private->NtOutHandle,
Private->Attribute,
Private->MaxScreenSize.X * Private->MaxScreenSize.Y,
Private->Possition,
&ConsoleWindow
);
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutSetCursorPosition (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN Column,
IN UINTN Row
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Column - TODO: add argument description
Row - TODO: add argument description
Returns:
EFI_SUCCESS - TODO: Add description for return value
--*/
{
WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private;
Private = WIN_NT_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);
Private->Possition.X = (WORD) Column;
This->Mode->CursorColumn = (INT32) Column;
Private->Possition.Y = (WORD) Row;
This->Mode->CursorRow = (INT32) Row;
Private->WinNtThunk->SetConsoleCursorPosition (Private->NtOutHandle, Private->Possition);
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
EFIAPI
WinNtSimpleTextOutEnableCursor (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN BOOLEAN Enable
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Enable - TODO: add argument description
Returns:
EFI_SUCCESS - TODO: Add description for return value
--*/
{
WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private;
CONSOLE_CURSOR_INFO Info;
Private = WIN_NT_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);
Private->CursorEnable = Enable;
This->Mode->CursorVisible = Enable;
Private->WinNtThunk->GetConsoleCursorInfo (Private->NtOutHandle, &Info);
Info.bVisible = Enable;
Private->WinNtThunk->SetConsoleCursorInfo (Private->NtOutHandle, &Info);
return EFI_SUCCESS;
}
EFI_STATUS
WinNtSimpleTextOutOpenWindow (
IN OUT WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
{
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
CHAR16 *WindowName;
WindowName = Private->WinNtIo->EnvString;
Private->Attribute = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
if (*WindowName == '?') {
Private->Attribute = BACKGROUND_RED | FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN;
WindowName = L"EFI Emulator Error Console";
}
AddUnicodeString (
"eng",
gWinNtConsoleComponentName.SupportedLanguages,
&Private->ControllerNameTable,
WindowName
);
//
// Fill in protocol member functions
//
SimpleTextOut = &Private->SimpleTextOut;
SimpleTextOut->Reset = WinNtSimpleTextOutReset;
SimpleTextOut->OutputString = WinNtSimpleTextOutOutputString;
SimpleTextOut->TestString = WinNtSimpleTextOutTestString;
SimpleTextOut->QueryMode = WinNtSimpleTextOutQueryMode;
SimpleTextOut->SetMode = WinNtSimpleTextOutSetMode;
SimpleTextOut->SetAttribute = WinNtSimpleTextOutSetAttribute;
SimpleTextOut->ClearScreen = WinNtSimpleTextOutClearScreen;
SimpleTextOut->SetCursorPosition = WinNtSimpleTextOutSetCursorPosition;
SimpleTextOut->EnableCursor = WinNtSimpleTextOutEnableCursor;
//
// Initialize SimpleTextOut protocol mode structure
//
SimpleTextOut->Mode = &Private->SimpleTextOutMode;
SimpleTextOut->Mode->MaxMode = MAX_SIMPLE_TEXT_OUT_MODE;
SimpleTextOut->Mode->Attribute = (INT32) Private->Attribute;
//
// Open the window an initialize it!
//
Private->NtOutHandle = Private->WinNtThunk->CreateConsoleScreenBuffer (
GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_WRITE | FILE_SHARE_READ,
NULL,
CONSOLE_TEXTMODE_BUFFER,
NULL
);
Private->WinNtThunk->SetConsoleTitle (WindowName);
return SimpleTextOut->SetMode (SimpleTextOut, 0);
}
EFI_STATUS
WinNtSimpleTextOutCloseWindow (
IN OUT WIN_NT_SIMPLE_TEXT_PRIVATE_DATA *Console
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Console - TODO: add argument description
Returns:
EFI_SUCCESS - TODO: Add description for return value
--*/
{
Console->WinNtThunk->CloseHandle (Console->NtOutHandle);
return EFI_SUCCESS;
}

View File

@ -0,0 +1,116 @@
#/** @file
# Console Dxe driver
#
# Simulate console with WinAPI
# 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 = WinNtConsole
FILE_GUID = 263631d7-5836-4b74-be48-ee22e92ce5d3
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
ENTRY_POINT = InitializeWinNtConsole
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32
#
# DRIVER_BINDING = gWinNtConsoleDriverBinding
# COMPONENT_NAME = gWinNtConsoleComponentName
#
################################################################################
#
# Sources Section - list of files that are required for the build to succeed.
#
################################################################################
[Sources.common]
ComponentName.c
ConsoleOut.c
ConsoleIn.c
Console.c
Console.h
################################################################################
#
# Includes Section - list of Include locations that are required for
# this module.
#
################################################################################
[Includes]
$(WORKSPACE)/MdePkg/Include/Library
################################################################################
#
# Package Dependency Section - list of Package files that are required for
# this module.
#
################################################################################
[Packages]
Nt32Pkg/Nt32Pkg.dec
MdePkg/MdePkg.dec
################################################################################
#
# Library Class Section - list of Library Classes that are required for
# this module.
#
################################################################################
[LibraryClasses]
MemoryAllocationLib
UefiBootServicesTableLib
BaseMemoryLib
UefiLib
UefiDriverEntryPoint
BaseLib
DebugLib
################################################################################
#
# Guid C Name Section - list of Guids that this module uses or produces.
#
################################################################################
[Guids]
gEfiWinNtConsoleGuid # ALWAYS_CONSUMED
################################################################################
#
# Protocol C Name Section - list of Protocol and Protocol Notify C Names
# that this module uses or produces.
#
################################################################################
[Protocols]
gEfiSimpleTextInProtocolGuid # PROTOCOL BY_START
gEfiSimpleTextOutProtocolGuid # PROTOCOL BY_START
gEfiWinNtIoProtocolGuid # PROTOCOL TO_START

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MsaHeader>
<ModuleName>WinNtConsole</ModuleName>
<ModuleType>UEFI_DRIVER</ModuleType>
<GuidValue>263631d7-5836-4b74-be48-ee22e92ce5d3</GuidValue>
<Version>1.0</Version>
<Abstract>Console Dxe driver</Abstract>
<Description>Simulate console with WinAPI</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</SupportedArchitectures>
<BinaryModule>false</BinaryModule>
<OutputFileBasename>WinNtConsole</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DebugLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseLib</Keyword>
</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>BaseMemoryLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiBootServicesTableLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>MemoryAllocationLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>Console.h</Filename>
<Filename>Console.c</Filename>
<Filename>ConsoleIn.c</Filename>
<Filename>ConsoleOut.c</Filename>
<Filename>ComponentName.c</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Package PackageGuid="0fb2aa2d-10d5-40a5-a9dc-060c12a4a3f3"/>
</PackageDependencies>
<Protocols>
<Protocol Usage="TO_START">
<ProtocolCName>gEfiWinNtIoProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="BY_START">
<ProtocolCName>gEfiSimpleTextOutProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="BY_START">
<ProtocolCName>gEfiSimpleTextInProtocolGuid</ProtocolCName>
</Protocol>
</Protocols>
<Guids>
<GuidCNames Usage="ALWAYS_CONSUMED">
<GuidCName>gEfiWinNtConsoleGuid</GuidCName>
</GuidCNames>
</Guids>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
<Extern>
<DriverBinding>gWinNtConsoleDriverBinding</DriverBinding>
<ComponentName>gWinNtConsoleComponentName</ComponentName>
</Extern>
</Externs>
</ModuleSurfaceArea>