mirror of https://github.com/acidanthera/audk.git
Add WinNtGop driver into Nt32Pkg
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2784 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
8879d432af
commit
c9fc89a313
|
@ -411,3 +411,4 @@
|
||||||
$(WORKSPACE)\Nt32Pkg\WinNtBusDriverDxe\WinNtBusDriver.inf
|
$(WORKSPACE)\Nt32Pkg\WinNtBusDriverDxe\WinNtBusDriver.inf
|
||||||
$(WORKSPACE)\Nt32Pkg\WinNtConsoleDxe\WinNtConsole.inf
|
$(WORKSPACE)\Nt32Pkg\WinNtConsoleDxe\WinNtConsole.inf
|
||||||
$(WORKSPACE)\Nt32Pkg\WinNtSimpleFileSystemDxe\WinNtSimpleFileSystem.inf
|
$(WORKSPACE)\Nt32Pkg\WinNtSimpleFileSystemDxe\WinNtSimpleFileSystem.inf
|
||||||
|
$(WORKSPACE)\Nt32Pkg\WinNtGopDxe\WinNtGop.inf
|
||||||
|
|
|
@ -0,0 +1,224 @@
|
||||||
|
/** @file
|
||||||
|
|
||||||
|
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 <Guid/EventGroup.h>
|
||||||
|
#include <Protocol/WinNtIo.h>
|
||||||
|
#include <Protocol/ComponentName.h>
|
||||||
|
#include <Protocol/SimpleTextIn.h>
|
||||||
|
#include <Protocol/DriverBinding.h>
|
||||||
|
#include <Protocol/GraphicsOutput.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 "WinNtGop.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// EFI Component Name Functions
|
||||||
|
//
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
WinNtGopComponentNameGetDriverName (
|
||||||
|
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||||
|
IN CHAR8 *Language,
|
||||||
|
OUT CHAR16 **DriverName
|
||||||
|
);
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
WinNtGopComponentNameGetControllerName (
|
||||||
|
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 gWinNtGopComponentName = {
|
||||||
|
WinNtGopComponentNameGetDriverName,
|
||||||
|
WinNtGopComponentNameGetControllerName,
|
||||||
|
"eng"
|
||||||
|
};
|
||||||
|
|
||||||
|
static EFI_UNICODE_STRING_TABLE mWinNtGopDriverNameTable[] = {
|
||||||
|
{ "eng", L"Windows GOP Driver" },
|
||||||
|
{ NULL , NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Retrieves a Unicode string that is the user readable name of the EFI Driver.
|
||||||
|
|
||||||
|
@param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL
|
||||||
|
instance.
|
||||||
|
@param 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.
|
||||||
|
@param 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.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The Unicode string for the Driver specified by
|
||||||
|
This and the language specified by Language was
|
||||||
|
returned in DriverName.
|
||||||
|
@retval EFI_INVALID_PARAMETER Language is NULL.
|
||||||
|
@retval EFI_INVALID_PARAMETER DriverName is NULL.
|
||||||
|
@retval EFI_UNSUPPORTED The driver specified by This does not support the
|
||||||
|
language specified by Language.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
WinNtGopComponentNameGetDriverName (
|
||||||
|
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||||
|
IN CHAR8 *Language,
|
||||||
|
OUT CHAR16 **DriverName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return LookupUnicodeString (
|
||||||
|
Language,
|
||||||
|
gWinNtGopComponentName.SupportedLanguages,
|
||||||
|
mWinNtGopDriverNameTable,
|
||||||
|
DriverName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Retrieves a Unicode string that is the user readable name of the controller
|
||||||
|
that is being managed by an EFI Driver.
|
||||||
|
|
||||||
|
@param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL
|
||||||
|
instance.
|
||||||
|
@param 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.
|
||||||
|
@param 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.
|
||||||
|
@param 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.
|
||||||
|
@param 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.
|
||||||
|
|
||||||
|
@retval 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.
|
||||||
|
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
|
||||||
|
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
|
||||||
|
EFI_HANDLE.
|
||||||
|
@retval EFI_INVALID_PARAMETER Language is NULL.
|
||||||
|
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
|
||||||
|
@retval EFI_UNSUPPORTED The driver specified by This is not currently
|
||||||
|
managing the controller specified by
|
||||||
|
ControllerHandle and ChildHandle.
|
||||||
|
@retval EFI_UNSUPPORTED The driver specified by This does not support the
|
||||||
|
language specified by Language.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
WinNtGopComponentNameGetControllerName (
|
||||||
|
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||||
|
IN EFI_HANDLE ControllerHandle,
|
||||||
|
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||||
|
IN CHAR8 *Language,
|
||||||
|
OUT CHAR16 **ControllerName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
|
||||||
|
GOP_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,
|
||||||
|
gWinNtGopDriverBinding.DriverBindingHandle,
|
||||||
|
&gEfiWinNtIoProtocolGuid
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Get our context back
|
||||||
|
//
|
||||||
|
Status = gBS->OpenProtocol (
|
||||||
|
ControllerHandle,
|
||||||
|
&gEfiGraphicsOutputProtocolGuid,
|
||||||
|
&GraphicsOutput,
|
||||||
|
gWinNtGopDriverBinding.DriverBindingHandle,
|
||||||
|
ControllerHandle,
|
||||||
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Private = GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput);
|
||||||
|
|
||||||
|
return LookupUnicodeString (
|
||||||
|
Language,
|
||||||
|
gWinNtGopComponentName.SupportedLanguages,
|
||||||
|
Private->ControllerNameTable,
|
||||||
|
ControllerName
|
||||||
|
);
|
||||||
|
}
|
|
@ -0,0 +1,326 @@
|
||||||
|
/** @file
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
WinNtGop.h
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
Private data for the Gop driver that is bound to the WinNt Thunk protocol
|
||||||
|
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _WIN_NT_GOP_H_
|
||||||
|
#define _WIN_NT_GOP_H_
|
||||||
|
|
||||||
|
//
|
||||||
|
// Include common header file for this module.
|
||||||
|
//
|
||||||
|
#include "CommonHeader.h"
|
||||||
|
|
||||||
|
//@MT:#include "EfiWinNT.h"
|
||||||
|
//@MT:#include "Tiano.h"
|
||||||
|
//@MT:#include "EfiDriverLib.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Driver Consumed Protocols
|
||||||
|
//
|
||||||
|
//@MT:#include EFI_PROTOCOL_DEFINITION (DevicePath)
|
||||||
|
//@MT:#include EFI_PROTOCOL_DEFINITION (WinNtIo)
|
||||||
|
|
||||||
|
//
|
||||||
|
// Driver Produced Protocols
|
||||||
|
//
|
||||||
|
//@MT:#include EFI_PROTOCOL_DEFINITION (DriverBinding)
|
||||||
|
//@MT:#include EFI_PROTOCOL_DEFINITION (ComponentName)
|
||||||
|
//@MT:#include EFI_PROTOCOL_DEFINITION (GraphicsOutput)
|
||||||
|
//@MT:#include "LinkedList.h"
|
||||||
|
|
||||||
|
#define MAX_Q 256
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINTN Front;
|
||||||
|
UINTN Rear;
|
||||||
|
UINTN Count;
|
||||||
|
EFI_INPUT_KEY Q[MAX_Q];
|
||||||
|
} GOP_QUEUE_FIXED;
|
||||||
|
|
||||||
|
#define WIN_NT_GOP_CLASS_NAME L"WinNtGopWindow"
|
||||||
|
|
||||||
|
#define GOP_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('S', 'g', 'o', 'N')
|
||||||
|
|
||||||
|
#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINT32 HorizontalResolution;
|
||||||
|
UINT32 VerticalResolution;
|
||||||
|
UINT32 ColorDepth;
|
||||||
|
UINT32 RefreshRate;
|
||||||
|
} GOP_MODE_DATA;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINT64 Signature;
|
||||||
|
|
||||||
|
EFI_HANDLE Handle;
|
||||||
|
EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;
|
||||||
|
EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
|
||||||
|
|
||||||
|
EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;
|
||||||
|
|
||||||
|
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
|
||||||
|
|
||||||
|
//
|
||||||
|
// GOP Private Data for QueryMode ()
|
||||||
|
//
|
||||||
|
GOP_MODE_DATA *ModeData;
|
||||||
|
|
||||||
|
//
|
||||||
|
// GOP Private Data knowing when to start hardware
|
||||||
|
//
|
||||||
|
BOOLEAN HardwareNeedsStarting;
|
||||||
|
|
||||||
|
CHAR16 *WindowName;
|
||||||
|
CHAR16 Buffer[160];
|
||||||
|
|
||||||
|
HANDLE ThreadInited; // Semaphore
|
||||||
|
HANDLE ThreadHandle; // Thread
|
||||||
|
DWORD ThreadId;
|
||||||
|
|
||||||
|
HWND WindowHandle;
|
||||||
|
WNDCLASSEX WindowsClass;
|
||||||
|
|
||||||
|
//
|
||||||
|
// This screen is used to redraw the scree when windows events happen. It's
|
||||||
|
// updated in the main thread and displayed in the windows thread.
|
||||||
|
//
|
||||||
|
BITMAPV4HEADER *VirtualScreenInfo;
|
||||||
|
RGBQUAD *VirtualScreen;
|
||||||
|
|
||||||
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *FillLine;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Keyboard Queue used by Simple Text In. WinProc thread adds, and main
|
||||||
|
// thread removes.
|
||||||
|
//
|
||||||
|
CRITICAL_SECTION QCriticalSection;
|
||||||
|
GOP_QUEUE_FIXED Queue;
|
||||||
|
|
||||||
|
} GOP_PRIVATE_DATA;
|
||||||
|
|
||||||
|
#define GOP_PRIVATE_DATA_FROM_THIS(a) \
|
||||||
|
CR(a, GOP_PRIVATE_DATA, GraphicsOutput, GOP_PRIVATE_DATA_SIGNATURE)
|
||||||
|
|
||||||
|
#define GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS(a) \
|
||||||
|
CR(a, GOP_PRIVATE_DATA, SimpleTextIn, GOP_PRIVATE_DATA_SIGNATURE)
|
||||||
|
|
||||||
|
//
|
||||||
|
// Global Protocol Variables
|
||||||
|
//
|
||||||
|
extern EFI_DRIVER_BINDING_PROTOCOL gWinNtGopDriverBinding;
|
||||||
|
extern EFI_COMPONENT_NAME_PROTOCOL gWinNtGopComponentName;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Gop Hardware abstraction internal worker functions
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param WinNtIo TODO: add argument description
|
||||||
|
|
||||||
|
@return TODO: add return values
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
WinNtGopSupported (
|
||||||
|
IN EFI_WIN_NT_IO_PROTOCOL *WinNtIo
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param Private TODO: add argument description
|
||||||
|
|
||||||
|
@return TODO: add return values
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
WinNtGopConstructor (
|
||||||
|
IN GOP_PRIVATE_DATA *Private
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param Private TODO: add argument description
|
||||||
|
|
||||||
|
@return TODO: add return values
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
WinNtGopDestructor (
|
||||||
|
IN GOP_PRIVATE_DATA *Private
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// EFI 1.1 driver model prototypes for Win NT GOP
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param ImageHandle TODO: add argument description
|
||||||
|
@param SystemTable TODO: add argument description
|
||||||
|
|
||||||
|
@return TODO: add return values
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
WinNtGopInitialize (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param This TODO: add argument description
|
||||||
|
@param Handle TODO: add argument description
|
||||||
|
@param RemainingDevicePath TODO: add argument description
|
||||||
|
|
||||||
|
@return TODO: add return values
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
WinNtGopDriverBindingSupported (
|
||||||
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||||
|
IN EFI_HANDLE Handle,
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param This TODO: add argument description
|
||||||
|
@param Handle TODO: add argument description
|
||||||
|
@param RemainingDevicePath TODO: add argument description
|
||||||
|
|
||||||
|
@return TODO: add return values
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
WinNtGopDriverBindingStart (
|
||||||
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||||
|
IN EFI_HANDLE Handle,
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param This TODO: add argument description
|
||||||
|
@param Handle TODO: add argument description
|
||||||
|
@param NumberOfChildren TODO: add argument description
|
||||||
|
@param ChildHandleBuffer TODO: add argument description
|
||||||
|
|
||||||
|
@return TODO: add return values
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
WinNtGopDriverBindingStop (
|
||||||
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||||
|
IN EFI_HANDLE Handle,
|
||||||
|
IN UINTN NumberOfChildren,
|
||||||
|
IN EFI_HANDLE *ChildHandleBuffer
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param Private TODO: add argument description
|
||||||
|
@param Key TODO: add argument description
|
||||||
|
|
||||||
|
@return TODO: add return values
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
GopPrivateAddQ (
|
||||||
|
IN GOP_PRIVATE_DATA *Private,
|
||||||
|
IN EFI_INPUT_KEY Key
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param Private TODO: add argument description
|
||||||
|
|
||||||
|
@return TODO: add return values
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
WinNtGopInitializeSimpleTextInForWindow (
|
||||||
|
IN GOP_PRIVATE_DATA *Private
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param Private TODO: add argument description
|
||||||
|
|
||||||
|
@return TODO: add return values
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
WinNtGopDestroySimpleTextInForWindow (
|
||||||
|
IN GOP_PRIVATE_DATA *Private
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param String TODO: add argument description
|
||||||
|
|
||||||
|
@return TODO: add return values
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINTN
|
||||||
|
Atoi (
|
||||||
|
IN CHAR16 *String
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,119 @@
|
||||||
|
#/** @file
|
||||||
|
# Gop Driver
|
||||||
|
#
|
||||||
|
# GOP is short hand for UEFI Graphics Output protocol.
|
||||||
|
# This file is a verision of GopIo the uses WinNtThunk system calls as an IO
|
||||||
|
# abstraction. For a PCI device WinNtIo would be replaced with
|
||||||
|
# a PCI IO abstraction that abstracted a specific PCI device.
|
||||||
|
# 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 = WinNtGop
|
||||||
|
FILE_GUID = 29b3c4c6-e5aa-49e4-8ce0-2772f782ddc2
|
||||||
|
MODULE_TYPE = UEFI_DRIVER
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
EDK_RELEASE_VERSION = 0x00020000
|
||||||
|
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||||
|
|
||||||
|
ENTRY_POINT = InitializeWinNtGop
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32
|
||||||
|
#
|
||||||
|
# DRIVER_BINDING = gWinNtGopDriverBinding
|
||||||
|
# COMPONENT_NAME = gWinNtGopComponentName
|
||||||
|
#
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Sources Section - list of files that are required for the build to succeed.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[Sources.common]
|
||||||
|
WinNtGopDriver.c
|
||||||
|
ComponentName.c
|
||||||
|
WinNtGop.h
|
||||||
|
WinNtGopInput.c
|
||||||
|
WinNtGopScreen.c
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# 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]
|
||||||
|
gEfiEventExitBootServicesGuid # SOMETIMES_CONSUMED Create Event: EVENT_GROUP_GUID
|
||||||
|
gEfiWinNtGopGuid # ALWAYS_CONSUMED
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Protocol C Name Section - list of Protocol and Protocol Notify C Names
|
||||||
|
# that this module uses or produces.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiGraphicsOutputProtocolGuid # PROTOCOL BY_START
|
||||||
|
gEfiSimpleTextInProtocolGuid # PROTOCOL BY_START
|
||||||
|
gEfiWinNtIoProtocolGuid # PROTOCOL TO_START
|
||||||
|
|
|
@ -0,0 +1,378 @@
|
||||||
|
/** @file
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
WinNtGopDriver.c
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
This file implements the UEFI Device Driver model requirements for GOP
|
||||||
|
|
||||||
|
GOP is short hand for Graphics Output 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 <Guid/EventGroup.h>
|
||||||
|
#include <Protocol/WinNtIo.h>
|
||||||
|
#include <Protocol/ComponentName.h>
|
||||||
|
#include <Protocol/SimpleTextIn.h>
|
||||||
|
#include <Protocol/DriverBinding.h>
|
||||||
|
#include <Protocol/GraphicsOutput.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 "WinNtGop.h"
|
||||||
|
|
||||||
|
EFI_DRIVER_BINDING_PROTOCOL gWinNtGopDriverBinding = {
|
||||||
|
WinNtGopDriverBindingSupported,
|
||||||
|
WinNtGopDriverBindingStart,
|
||||||
|
WinNtGopDriverBindingStop,
|
||||||
|
0xa,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
The user Entry Point for module WinNtGop. 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
|
||||||
|
InitializeWinNtGop(
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Install driver model protocol(s).
|
||||||
|
//
|
||||||
|
Status = EfiLibInstallAllDriverProtocols (
|
||||||
|
ImageHandle,
|
||||||
|
SystemTable,
|
||||||
|
&gWinNtGopDriverBinding,
|
||||||
|
ImageHandle,
|
||||||
|
&gWinNtGopComponentName,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
|
||||||
|
@return 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
|
||||||
|
EFIAPI
|
||||||
|
WinNtGopDriverBindingSupported (
|
||||||
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||||
|
IN EFI_HANDLE Handle,
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||||
|
)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = WinNtGopSupported (WinNtIo);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Close the I/O Abstraction(s) used to perform the supported test
|
||||||
|
//
|
||||||
|
gBS->CloseProtocol (
|
||||||
|
Handle,
|
||||||
|
&gEfiWinNtIoProtocolGuid,
|
||||||
|
This->DriverBindingHandle,
|
||||||
|
Handle
|
||||||
|
);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
|
||||||
|
@return 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
|
||||||
|
// TODO: EFI_UNSUPPORTED - add return value to function comment
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
WinNtGopDriverBindingStart (
|
||||||
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||||
|
IN EFI_HANDLE Handle,
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_WIN_NT_IO_PROTOCOL *WinNtIo;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
GOP_PRIVATE_DATA *Private;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Grab the protocols we need
|
||||||
|
//
|
||||||
|
Status = gBS->OpenProtocol (
|
||||||
|
Handle,
|
||||||
|
&gEfiWinNtIoProtocolGuid,
|
||||||
|
&WinNtIo,
|
||||||
|
This->DriverBindingHandle,
|
||||||
|
Handle,
|
||||||
|
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Allocate Private context data for SGO inteface.
|
||||||
|
//
|
||||||
|
Private = NULL;
|
||||||
|
Private = AllocatePool (sizeof (GOP_PRIVATE_DATA));
|
||||||
|
if (Private == NULL) {
|
||||||
|
goto Done;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Set up context record
|
||||||
|
//
|
||||||
|
Private->Signature = GOP_PRIVATE_DATA_SIGNATURE;
|
||||||
|
Private->Handle = Handle;
|
||||||
|
Private->WinNtThunk = WinNtIo->WinNtThunk;
|
||||||
|
|
||||||
|
Private->ControllerNameTable = NULL;
|
||||||
|
|
||||||
|
AddUnicodeString (
|
||||||
|
"eng",
|
||||||
|
gWinNtGopComponentName.SupportedLanguages,
|
||||||
|
&Private->ControllerNameTable,
|
||||||
|
WinNtIo->EnvString
|
||||||
|
);
|
||||||
|
|
||||||
|
Private->WindowName = WinNtIo->EnvString;
|
||||||
|
|
||||||
|
Status = WinNtGopConstructor (Private);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
goto Done;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Publish the Gop interface to the world
|
||||||
|
//
|
||||||
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||||
|
&Private->Handle,
|
||||||
|
&gEfiGraphicsOutputProtocolGuid,
|
||||||
|
&Private->GraphicsOutput,
|
||||||
|
&gEfiSimpleTextInProtocolGuid,
|
||||||
|
&Private->SimpleTextIn,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
Done:
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
|
||||||
|
gBS->CloseProtocol (
|
||||||
|
Handle,
|
||||||
|
&gEfiWinNtIoProtocolGuid,
|
||||||
|
This->DriverBindingHandle,
|
||||||
|
Handle
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Private != NULL) {
|
||||||
|
//
|
||||||
|
// On Error Free back private data
|
||||||
|
//
|
||||||
|
if (Private->ControllerNameTable != NULL) {
|
||||||
|
FreeUnicodeStringTable (Private->ControllerNameTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
FreePool (Private);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
|
||||||
|
@return None
|
||||||
|
|
||||||
|
**/
|
||||||
|
// TODO: This - add argument and description to function comment
|
||||||
|
// TODO: Handle - add argument and description to function comment
|
||||||
|
// TODO: NumberOfChildren - add argument and description to function comment
|
||||||
|
// TODO: ChildHandleBuffer - add argument and description to function comment
|
||||||
|
// TODO: EFI_NOT_STARTED - add return value to function comment
|
||||||
|
// TODO: EFI_DEVICE_ERROR - add return value to function comment
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
WinNtGopDriverBindingStop (
|
||||||
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||||
|
IN EFI_HANDLE Handle,
|
||||||
|
IN UINTN NumberOfChildren,
|
||||||
|
IN EFI_HANDLE *ChildHandleBuffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
GOP_PRIVATE_DATA *Private;
|
||||||
|
|
||||||
|
Status = gBS->OpenProtocol (
|
||||||
|
Handle,
|
||||||
|
&gEfiGraphicsOutputProtocolGuid,
|
||||||
|
&GraphicsOutput,
|
||||||
|
This->DriverBindingHandle,
|
||||||
|
Handle,
|
||||||
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
//
|
||||||
|
// If the GOP interface does not exist the driver is not started
|
||||||
|
//
|
||||||
|
return EFI_NOT_STARTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get our private context information
|
||||||
|
//
|
||||||
|
Private = GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Remove the SGO interface from the system
|
||||||
|
//
|
||||||
|
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||||
|
Private->Handle,
|
||||||
|
&gEfiGraphicsOutputProtocolGuid,
|
||||||
|
&Private->GraphicsOutput,
|
||||||
|
&gEfiSimpleTextInProtocolGuid,
|
||||||
|
&Private->SimpleTextIn,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
//
|
||||||
|
// Shutdown the hardware
|
||||||
|
//
|
||||||
|
Status = WinNtGopDestructor (Private);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
gBS->CloseProtocol (
|
||||||
|
Handle,
|
||||||
|
&gEfiWinNtIoProtocolGuid,
|
||||||
|
This->DriverBindingHandle,
|
||||||
|
Handle
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Free our instance data
|
||||||
|
//
|
||||||
|
FreeUnicodeStringTable (Private->ControllerNameTable);
|
||||||
|
|
||||||
|
FreePool (Private);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert a unicode string to a UINTN
|
||||||
|
|
||||||
|
@param String Unicode string.
|
||||||
|
|
||||||
|
@return UINTN of the number represented by String.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINTN
|
||||||
|
Atoi (
|
||||||
|
CHAR16 *String
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINTN Number;
|
||||||
|
CHAR16 *Str;
|
||||||
|
|
||||||
|
//
|
||||||
|
// skip preceeding white space
|
||||||
|
//
|
||||||
|
Str = String;
|
||||||
|
while ((*Str) && (*Str == ' ' || *Str == '"')) {
|
||||||
|
Str++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Convert ot a Number
|
||||||
|
//
|
||||||
|
Number = 0;
|
||||||
|
while (*Str != '\0') {
|
||||||
|
if ((*Str >= '0') && (*Str <= '9')) {
|
||||||
|
Number = (Number * 10) +*Str - '0';
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Str++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Number;
|
||||||
|
}
|
|
@ -0,0 +1,377 @@
|
||||||
|
/** @file
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
WinNtGopInput.c
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
This file produces the Simple Text In for an Gop window.
|
||||||
|
|
||||||
|
This stuff is linked at the hip to the Window, since the window
|
||||||
|
processing is done in a thread kicked off in WinNtGopImplementation.c
|
||||||
|
|
||||||
|
Since the window information is processed in an other thread we need
|
||||||
|
a keyboard Queue to pass data about. The Simple Text In code just
|
||||||
|
takes data off the Queue. The WinProc message loop takes keyboard input
|
||||||
|
and places it in the Queue.
|
||||||
|
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
//
|
||||||
|
// The package level header files this module uses
|
||||||
|
//
|
||||||
|
#include <Uefi.h>
|
||||||
|
#include <WinNtDxe.h>
|
||||||
|
//
|
||||||
|
// The protocols, PPI and GUID defintions for this module
|
||||||
|
//
|
||||||
|
#include <Guid/EventGroup.h>
|
||||||
|
#include <Protocol/WinNtIo.h>
|
||||||
|
#include <Protocol/ComponentName.h>
|
||||||
|
#include <Protocol/SimpleTextIn.h>
|
||||||
|
#include <Protocol/DriverBinding.h>
|
||||||
|
#include <Protocol/GraphicsOutput.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 "WinNtGop.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param Private TODO: add argument description
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS TODO: Add description for return value
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
GopPrivateCreateQ (
|
||||||
|
IN GOP_PRIVATE_DATA *Private
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Private->WinNtThunk->InitializeCriticalSection (&Private->QCriticalSection);
|
||||||
|
|
||||||
|
Private->Queue.Front = 0;
|
||||||
|
Private->Queue.Rear = MAX_Q - 1;
|
||||||
|
Private->Queue.Count = 0;
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param Private TODO: add argument description
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS TODO: Add description for return value
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
GopPrivateDestroyQ (
|
||||||
|
IN GOP_PRIVATE_DATA *Private
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Private->Queue.Count = 0;
|
||||||
|
Private->WinNtThunk->DeleteCriticalSection (&Private->QCriticalSection);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param Private TODO: add argument description
|
||||||
|
@param Key TODO: add argument description
|
||||||
|
|
||||||
|
@retval EFI_NOT_READY TODO: Add description for return value
|
||||||
|
@retval EFI_SUCCESS TODO: Add description for return value
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
GopPrivateAddQ (
|
||||||
|
IN GOP_PRIVATE_DATA *Private,
|
||||||
|
IN EFI_INPUT_KEY Key
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Private->WinNtThunk->EnterCriticalSection (&Private->QCriticalSection);
|
||||||
|
|
||||||
|
if (Private->Queue.Count == MAX_Q) {
|
||||||
|
Private->WinNtThunk->LeaveCriticalSection (&Private->QCriticalSection);
|
||||||
|
return EFI_NOT_READY;
|
||||||
|
}
|
||||||
|
|
||||||
|
Private->Queue.Rear = (Private->Queue.Rear + 1) % MAX_Q;
|
||||||
|
Private->Queue.Q[Private->Queue.Rear] = Key;
|
||||||
|
Private->Queue.Count++;
|
||||||
|
|
||||||
|
Private->WinNtThunk->LeaveCriticalSection (&Private->QCriticalSection);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param Private TODO: add argument description
|
||||||
|
@param Key TODO: add argument description
|
||||||
|
|
||||||
|
@retval EFI_NOT_READY TODO: Add description for return value
|
||||||
|
@retval EFI_SUCCESS TODO: Add description for return value
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
GopPrivateDeleteQ (
|
||||||
|
IN GOP_PRIVATE_DATA *Private,
|
||||||
|
OUT EFI_INPUT_KEY *Key
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Private->WinNtThunk->EnterCriticalSection (&Private->QCriticalSection);
|
||||||
|
|
||||||
|
if (Private->Queue.Count == 0) {
|
||||||
|
Private->WinNtThunk->LeaveCriticalSection (&Private->QCriticalSection);
|
||||||
|
return EFI_NOT_READY;
|
||||||
|
}
|
||||||
|
|
||||||
|
*Key = Private->Queue.Q[Private->Queue.Front];
|
||||||
|
Private->Queue.Front = (Private->Queue.Front + 1) % MAX_Q;
|
||||||
|
Private->Queue.Count--;
|
||||||
|
|
||||||
|
Private->WinNtThunk->LeaveCriticalSection (&Private->QCriticalSection);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param Private TODO: add argument description
|
||||||
|
|
||||||
|
@retval EFI_NOT_READY TODO: Add description for return value
|
||||||
|
@retval EFI_SUCCESS TODO: Add description for return value
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
GopPrivateCheckQ (
|
||||||
|
IN GOP_PRIVATE_DATA *Private
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (Private->Queue.Count == 0) {
|
||||||
|
return EFI_NOT_READY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Simple Text In implementation.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param This TODO: add argument description
|
||||||
|
@param ExtendedVerification TODO: add argument description
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS TODO: Add description for return value
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
WinNtGopSimpleTextInReset (
|
||||||
|
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
|
||||||
|
IN BOOLEAN ExtendedVerification
|
||||||
|
)
|
||||||
|
{
|
||||||
|
GOP_PRIVATE_DATA *Private;
|
||||||
|
EFI_INPUT_KEY Key;
|
||||||
|
EFI_TPL OldTpl;
|
||||||
|
|
||||||
|
Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Enter critical section
|
||||||
|
//
|
||||||
|
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
|
||||||
|
|
||||||
|
//
|
||||||
|
// A reset is draining the Queue
|
||||||
|
//
|
||||||
|
while (GopPrivateDeleteQ (Private, &Key) == EFI_SUCCESS)
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Leave critical section and return
|
||||||
|
//
|
||||||
|
gBS->RestoreTPL (OldTpl);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param This TODO: add argument description
|
||||||
|
@param Key TODO: add argument description
|
||||||
|
|
||||||
|
@return TODO: add return values
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
WinNtGopSimpleTextInReadKeyStroke (
|
||||||
|
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
|
||||||
|
OUT EFI_INPUT_KEY *Key
|
||||||
|
)
|
||||||
|
{
|
||||||
|
GOP_PRIVATE_DATA *Private;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_TPL OldTpl;
|
||||||
|
|
||||||
|
Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Enter critical section
|
||||||
|
//
|
||||||
|
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
|
||||||
|
|
||||||
|
Status = GopPrivateCheckQ (Private);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
//
|
||||||
|
// If a Key press exists try and read it.
|
||||||
|
//
|
||||||
|
Status = GopPrivateDeleteQ (Private, Key);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Leave critical section and return
|
||||||
|
//
|
||||||
|
gBS->RestoreTPL (OldTpl);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param Event TODO: add argument description
|
||||||
|
@param Context TODO: add argument description
|
||||||
|
|
||||||
|
@return TODO: add return values
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
WinNtGopSimpleTextInWaitForKey (
|
||||||
|
IN EFI_EVENT Event,
|
||||||
|
IN VOID *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
GOP_PRIVATE_DATA *Private;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_TPL OldTpl;
|
||||||
|
|
||||||
|
Private = (GOP_PRIVATE_DATA *) Context;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Enter critical section
|
||||||
|
//
|
||||||
|
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
|
||||||
|
|
||||||
|
Status = GopPrivateCheckQ (Private);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
//
|
||||||
|
// If a there is a key in the queue signal our event.
|
||||||
|
//
|
||||||
|
gBS->SignalEvent (Event);
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// We need to sleep or NT will schedule this thread with such high
|
||||||
|
// priority that WinProc thread will never run and we will not see
|
||||||
|
// keyboard input. This Sleep makes the syste run 10x faster, so don't
|
||||||
|
// remove it.
|
||||||
|
//
|
||||||
|
Private->WinNtThunk->Sleep (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Leave critical section and return
|
||||||
|
//
|
||||||
|
gBS->RestoreTPL (OldTpl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param Private TODO: add argument description
|
||||||
|
|
||||||
|
@return TODO: add return values
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
WinNtGopInitializeSimpleTextInForWindow (
|
||||||
|
IN GOP_PRIVATE_DATA *Private
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
GopPrivateCreateQ (Private);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize Simple Text In protoocol
|
||||||
|
//
|
||||||
|
Private->SimpleTextIn.Reset = WinNtGopSimpleTextInReset;
|
||||||
|
Private->SimpleTextIn.ReadKeyStroke = WinNtGopSimpleTextInReadKeyStroke;
|
||||||
|
|
||||||
|
Status = gBS->CreateEvent (
|
||||||
|
EVT_NOTIFY_WAIT,
|
||||||
|
TPL_NOTIFY,
|
||||||
|
WinNtGopSimpleTextInWaitForKey,
|
||||||
|
Private,
|
||||||
|
&Private->SimpleTextIn.WaitForKey
|
||||||
|
);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
@param Private TODO: add argument description
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS TODO: Add description for return value
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
WinNtGopDestroySimpleTextInForWindow (
|
||||||
|
IN GOP_PRIVATE_DATA *Private
|
||||||
|
)
|
||||||
|
{
|
||||||
|
GopPrivateDestroyQ (Private);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue