Initial import.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
bbahnsen
2006-04-21 22:54:32 +00:00
commit 878ddf1fc3
2651 changed files with 624620 additions and 0 deletions

View File

@@ -0,0 +1,187 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
ComponentName.c
Abstract:
--*/
#include "WinNtBlockIo.h"
//
// EFI Component Name Functions
//
EFI_STATUS
EFIAPI
WinNtBlockIoComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
);
EFI_STATUS
EFIAPI
WinNtBlockIoComponentNameGetControllerName (
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 gWinNtBlockIoComponentName = {
WinNtBlockIoComponentNameGetDriverName,
WinNtBlockIoComponentNameGetControllerName,
"eng"
};
static EFI_UNICODE_STRING_TABLE mWinNtBlockIoDriverNameTable[] = {
{ "eng", L"Windows Block I/O Driver" },
{ NULL , NULL }
};
EFI_STATUS
EFIAPI
WinNtBlockIoComponentNameGetDriverName (
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,
gWinNtBlockIoComponentName.SupportedLanguages,
mWinNtBlockIoDriverNameTable,
DriverName
);
}
EFI_STATUS
EFIAPI
WinNtBlockIoComponentNameGetControllerName (
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_BLOCK_IO_PROTOCOL *BlockIo;
WIN_NT_BLOCK_IO_PRIVATE *Private;
//
// This is a device driver, so ChildHandle must be NULL.
//
if (ChildHandle != NULL) {
return EFI_UNSUPPORTED;
}
//
// Get our context back
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiBlockIoProtocolGuid,
&BlockIo,
gWinNtBlockIoDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (BlockIo);
return LookupUnicodeString (
Language,
gWinNtBlockIoComponentName.SupportedLanguages,
Private->ControllerNameTable,
ControllerName
);
}

View File

@@ -0,0 +1,338 @@
/*++
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:
DriverConfiguration.c
Abstract:
--*/
#include "WinNtBlockIo.h"
//
// EFI Driver Configuration Functions
//
EFI_STATUS
EFIAPI
WinNtBlockIoDriverConfigurationSetOptions (
IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
);
EFI_STATUS
EFIAPI
WinNtBlockIoDriverConfigurationOptionsValid (
IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL
);
EFI_STATUS
EFIAPI
WinNtBlockIoDriverConfigurationForceDefaults (
IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN UINT32 DefaultType,
OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
);
//
// EFI Driver Configuration Protocol
//
EFI_DRIVER_CONFIGURATION_PROTOCOL gWinNtBlockIoDriverConfiguration = {
WinNtBlockIoDriverConfigurationSetOptions,
WinNtBlockIoDriverConfigurationOptionsValid,
WinNtBlockIoDriverConfigurationForceDefaults,
LANGUAGESUPPORTED
};
EFI_STATUS
EFIAPI
WinNtBlockIoDriverConfigurationSetOptions (
IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
)
/*++
Routine Description:
Allows the user to set controller specific options for a controller that a
driver is currently managing.
Arguments:
This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
ControllerHandle - The handle of the controller to set options on.
ChildHandle - The handle of the child controller to set options on. This
is an optional parameter that may be NULL. It will be NULL
for device drivers, and for a bus drivers that wish to set
options for the bus controller. It will not be NULL for a
bus driver that wishes to set options for one of its child
controllers.
Language - A pointer to a three character ISO 639-2 language identifier.
This is the language of the user interface that should be
presented to the user, 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.
ActionRequired - A pointer to the action that the calling agent is required
to perform when this function returns. See "Related
Definitions" for a list of the actions that the calling
agent is required to perform prior to accessing
ControllerHandle again.
Returns:
EFI_SUCCESS - The driver specified by This successfully set the
configuration options for the controller specified
by ControllerHandle..
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 - ActionRequired is NULL.
EFI_UNSUPPORTED - The driver specified by This does not support setting
configuration options for the controller specified by
ControllerHandle and ChildHandle.
EFI_UNSUPPORTED - The driver specified by This does not support the
language specified by Language.
EFI_DEVICE_ERROR - A device error occurred while attempt to set the
configuration options for the controller specified
by ControllerHandle and ChildHandle.
EFI_OUT_RESOURCES - There are not enough resources available to set the
configuration options for the controller specified
by ControllerHandle and ChildHandle.
--*/
{
EFI_STATUS Status;
EFI_BLOCK_IO_PROTOCOL *BlockIo;
CHAR8 *SupportedLanguage;
SupportedLanguage = This->SupportedLanguages;
Status = EFI_UNSUPPORTED;
while (*SupportedLanguage != 0) {
if (AsciiStrnCmp (Language, SupportedLanguage, 3) == 0) {
Status = EFI_SUCCESS;
}
SupportedLanguage += 3;
}
if (EFI_ERROR (Status)) {
return Status;
}
if (ActionRequired == NULL || ControllerHandle == NULL) {
return EFI_INVALID_PARAMETER;
}
if (ChildHandle != NULL) {
return EFI_UNSUPPORTED;
}
//
// Validate controller handle
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiWinNtIoProtocolGuid,
&BlockIo,
gWinNtBlockIoDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (!EFI_ERROR (Status)) {
gBS->CloseProtocol (
ControllerHandle,
&gEfiWinNtIoProtocolGuid,
gWinNtBlockIoDriverBinding.DriverBindingHandle,
ControllerHandle
);
return EFI_UNSUPPORTED;
}
if (Status == EFI_UNSUPPORTED) {
return Status;
} else if (Status != EFI_ALREADY_STARTED) {
return EFI_INVALID_PARAMETER;
}
*ActionRequired = EfiDriverConfigurationActionNone;
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
WinNtBlockIoDriverConfigurationOptionsValid (
IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL
)
/*++
Routine Description:
Tests to see if a controller's current configuration options are valid.
Arguments:
This - A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance.
ControllerHandle - The handle of the controller to test if it's current
configuration options are valid.
ChildHandle - The handle of the child controller to test if it's current
configuration options are valid. 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 test the configuration options for the bus controller.
It will not be NULL for a bus driver that wishes to test
configuration options for one of its child controllers.
Returns:
EFI_SUCCESS - The controller specified by ControllerHandle and
ChildHandle that is being managed by the driver
specified by This has a valid set of configuration
options.
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_UNSUPPORTED - The driver specified by This is not currently
managing the controller specified by ControllerHandle
and ChildHandle.
EFI_DEVICE_ERROR - The controller specified by ControllerHandle and
ChildHandle that is being managed by the driver
specified by This has an invalid set of configuration
options.
--*/
{
EFI_STATUS Status;
EFI_BLOCK_IO_PROTOCOL *BlockIo;
if (ChildHandle != NULL) {
return EFI_UNSUPPORTED;
}
if (ControllerHandle == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Validate controller handle
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiWinNtIoProtocolGuid,
&BlockIo,
gWinNtBlockIoDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (!EFI_ERROR (Status)) {
gBS->CloseProtocol (
ControllerHandle,
&gEfiWinNtIoProtocolGuid,
gWinNtBlockIoDriverBinding.DriverBindingHandle,
ControllerHandle
);
return EFI_UNSUPPORTED;
}
if (Status == EFI_UNSUPPORTED) {
return Status;
} else if (Status != EFI_ALREADY_STARTED) {
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
WinNtBlockIoDriverConfigurationForceDefaults (
IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN UINT32 DefaultType,
OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
)
/*++
Routine Description:
Forces a driver to set the default configuration options for a controller.
Arguments:
This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
ControllerHandle - The handle of the controller to force default configuration options on.
ChildHandle - The handle of the child controller to force default configuration options on 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 force default configuration options for the bus controller. It will not be NULL for a bus driver that wishes to force default configuration options for one of its child controllers.
DefaultType - The type of default configuration options to force on the controller specified by ControllerHandle and ChildHandle. See Table 9-1 for legal values. A DefaultType of 0x00000000 must be supported by this protocol.
ActionRequired - A pointer to the action that the calling agent is required to perform when this function returns. See "Related Definitions" in Section 9.1for a list of the actions that the calling agent is required to perform prior to accessing ControllerHandle again.
Returns:
EFI_SUCCESS - The driver specified by This successfully forced the default configuration options on the controller specified by ControllerHandle and ChildHandle.
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 - ActionRequired is NULL.
EFI_UNSUPPORTED - The driver specified by This does not support forcing the default configuration options on the controller specified by ControllerHandle and ChildHandle.
EFI_UNSUPPORTED - The driver specified by This does not support the configuration type specified by DefaultType.
EFI_DEVICE_ERROR - A device error occurred while attempt to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.
EFI_OUT_RESOURCES - There are not enough resources available to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.
--*/
{
EFI_STATUS Status;
EFI_BLOCK_IO_PROTOCOL *BlockIo;
if (ChildHandle != NULL) {
return EFI_UNSUPPORTED;
}
if (ActionRequired == NULL || ControllerHandle == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Validate controller handle
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiWinNtIoProtocolGuid,
&BlockIo,
gWinNtBlockIoDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (!EFI_ERROR (Status)) {
gBS->CloseProtocol (
ControllerHandle,
&gEfiWinNtIoProtocolGuid,
gWinNtBlockIoDriverBinding.DriverBindingHandle,
ControllerHandle
);
return EFI_UNSUPPORTED;
}
if (Status == EFI_UNSUPPORTED) {
return Status;
} else if (Status != EFI_ALREADY_STARTED) {
return EFI_INVALID_PARAMETER;
}
*ActionRequired = EfiDriverConfigurationActionNone;
return EFI_SUCCESS;
}

View File

@@ -0,0 +1,186 @@
/*++
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:
DriverDiagnostics.c
Abstract:
--*/
#include "WinNtBlockIo.h"
//
// EFI Driver Diagnostics Functions
//
EFI_STATUS
EFIAPI
WinNtBlockIoDriverDiagnosticsRunDiagnostics (
IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
IN CHAR8 *Language,
OUT EFI_GUID **ErrorType,
OUT UINTN *BufferSize,
OUT CHAR16 **Buffer
);
//
// EFI Driver Diagnostics Protocol
//
EFI_DRIVER_DIAGNOSTICS_PROTOCOL gWinNtBlockIoDriverDiagnostics = {
WinNtBlockIoDriverDiagnosticsRunDiagnostics,
LANGUAGESUPPORTED
};
EFI_STATUS
EFIAPI
WinNtBlockIoDriverDiagnosticsRunDiagnostics (
IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
IN CHAR8 *Language,
OUT EFI_GUID **ErrorType,
OUT UINTN *BufferSize,
OUT CHAR16 **Buffer
)
/*++
Routine Description:
Runs diagnostics on a controller.
Arguments:
This - A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOL instance.
ControllerHandle - The handle of the controller to run diagnostics on.
ChildHandle - The handle of the child controller to run diagnostics on
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 run diagnostics on the bus
controller. It will not be NULL for a bus driver that
wishes to run diagnostics on one of its child controllers.
DiagnosticType - Indicates type of diagnostics to perform on the controller
specified by ControllerHandle and ChildHandle. See
"Related Definitions" for the list of supported types.
Language - A pointer to a three character ISO 639-2 language
identifier. This is the language in which the optional
error message should be returned in Buffer, 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.
ErrorType - A GUID that defines the format of the data returned in
Buffer.
BufferSize - The size, in bytes, of the data returned in Buffer.
Buffer - A buffer that contains a Null-terminated Unicode string
plus some additional data whose format is defined by
ErrorType. Buffer is allocated by this function with
AllocatePool(), and it is the caller's responsibility
to free it with a call to FreePool().
Returns:
EFI_SUCCESS - The controller specified by ControllerHandle and
ChildHandle passed the diagnostic.
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 - ErrorType is NULL.
EFI_INVALID_PARAMETER - BufferType is NULL.
EFI_INVALID_PARAMETER - Buffer is NULL.
EFI_UNSUPPORTED - The driver specified by This does not support
running diagnostics for the controller specified
by ControllerHandle and ChildHandle.
EFI_UNSUPPORTED - The driver specified by This does not support the
type of diagnostic specified by DiagnosticType.
EFI_UNSUPPORTED - The driver specified by This does not support the
language specified by Language.
EFI_OUT_OF_RESOURCES - There are not enough resources available to complete
the diagnostics.
EFI_OUT_OF_RESOURCES - There are not enough resources available to return
the status information in ErrorType, BufferSize,
and Buffer.
EFI_DEVICE_ERROR - The controller specified by ControllerHandle and
ChildHandle did not pass the diagnostic.
--*/
{
EFI_STATUS Status;
EFI_BLOCK_IO_PROTOCOL *BlockIo;
CHAR8 *SupportedLanguage;
if (Language == NULL ||
ErrorType == NULL ||
Buffer == NULL ||
ControllerHandle == NULL ||
BufferSize == NULL) {
return EFI_INVALID_PARAMETER;
}
SupportedLanguage = This->SupportedLanguages;
Status = EFI_UNSUPPORTED;
while (*SupportedLanguage != 0) {
if (AsciiStrnCmp (Language, SupportedLanguage, 3) == 0) {
Status = EFI_SUCCESS;
break;
}
SupportedLanguage += 3;
}
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
*ErrorType = NULL;
*BufferSize = 0;
if (DiagnosticType != EfiDriverDiagnosticTypeStandard) {
*ErrorType = &gEfiBlockIoProtocolGuid;
*BufferSize = 0x60;
gBS->AllocatePool (EfiBootServicesData, (UINTN) (*BufferSize), Buffer);
CopyMem (*Buffer, L"Windows Block I/O Driver Diagnostics Failed\n", *BufferSize);
return EFI_DEVICE_ERROR;
}
//
// Validate controller handle
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiWinNtIoProtocolGuid,
&BlockIo,
gWinNtBlockIoDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (!EFI_ERROR (Status)) {
gBS->CloseProtocol (
ControllerHandle,
&gEfiWinNtIoProtocolGuid,
gWinNtBlockIoDriverBinding.DriverBindingHandle,
ControllerHandle
);
return EFI_UNSUPPORTED;
}
if (Status == EFI_UNSUPPORTED) {
return Status;
} else if (Status != EFI_ALREADY_STARTED) {
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,471 @@
/*++
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:
WinNtBlockIo.h
Abstract:
Produce block IO abstractions for real devices on your PC using Win32 APIs.
The configuration of what devices to mount or emulate comes from NT
environment variables. The variables must be visible to the Microsoft*
Developer Studio for them to work.
* Other names and brands may be claimed as the property of others.
--*/
#ifndef _WIN_NT_BLOCK_IO_H_
#define _WIN_NT_BLOCK_IO_H_
#define FILENAME_BUFFER_SIZE 80
//
// Language supported for driverconfiguration protocol
//
#define LANGUAGESUPPORTED "eng"
typedef enum {
EfiWinNtVirtualDisks,
EfiWinNtPhysicalDisks,
EifWinNtMaxTypeDisks
} WIN_NT_RAW_DISK_DEVICE_TYPE;
#define WIN_NT_BLOCK_IO_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('N', 'T', 'b', 'k')
typedef struct {
UINTN Signature;
EFI_LOCK Lock;
CHAR16 Filename[FILENAME_BUFFER_SIZE];
UINTN ReadMode;
UINTN ShareMode;
UINTN OpenMode;
HANDLE NtHandle;
WIN_NT_RAW_DISK_DEVICE_TYPE DeviceType;
UINT64 LastBlock;
UINTN BlockSize;
UINT64 NumberOfBlocks;
EFI_HANDLE EfiHandle;
EFI_BLOCK_IO_PROTOCOL BlockIo;
EFI_BLOCK_IO_MEDIA Media;
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;
} WIN_NT_BLOCK_IO_PRIVATE;
#define WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS(a) \
CR(a, WIN_NT_BLOCK_IO_PRIVATE, BlockIo, WIN_NT_BLOCK_IO_PRIVATE_SIGNATURE)
#define LIST_BUFFER_SIZE 512
//
// Block I/O Global Variables
//
extern EFI_DRIVER_BINDING_PROTOCOL gWinNtBlockIoDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gWinNtBlockIoComponentName;
extern EFI_DRIVER_CONFIGURATION_PROTOCOL gWinNtBlockIoDriverConfiguration;
extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL gWinNtBlockIoDriverDiagnostics;
//
// EFI Driver Binding Functions
//
EFI_STATUS
EFIAPI
WinNtBlockIoDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Handle - TODO: add argument description
RemainingDevicePath - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
EFIAPI
WinNtBlockIoDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Handle - TODO: add argument description
RemainingDevicePath - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
EFIAPI
WinNtBlockIoDriverBindingStop (
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:
TODO: add return values
--*/
;
//
// Block IO protocol member functions
//
STATIC
EFI_STATUS
EFIAPI
WinNtBlockIoReadBlocks (
IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId,
IN EFI_LBA Lba,
IN UINTN BufferSize,
OUT VOID *Buffer
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
MediaId - TODO: add argument description
Lba - TODO: add argument description
BufferSize - TODO: add argument description
Buffer - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtBlockIoWriteBlocks (
IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId,
IN EFI_LBA Lba,
IN UINTN BufferSize,
IN VOID *Buffer
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
MediaId - TODO: add argument description
Lba - TODO: add argument description
BufferSize - TODO: add argument description
Buffer - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtBlockIoFlushBlocks (
IN EFI_BLOCK_IO_PROTOCOL *This
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtBlockIoResetBlock (
IN EFI_BLOCK_IO_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
--*/
;
//
// Private Worker functions
//
STATIC
EFI_STATUS
WinNtBlockIoCreateMapping (
IN EFI_WIN_NT_IO_PROTOCOL *WinNtIo,
IN EFI_HANDLE EfiDeviceHandle,
IN CHAR16 *Filename,
IN BOOLEAN ReadOnly,
IN BOOLEAN RemovableMedia,
IN UINTN NumberOfBlocks,
IN UINTN BlockSize,
IN WIN_NT_RAW_DISK_DEVICE_TYPE DeviceType
)
/*++
Routine Description:
TODO: Add function description
Arguments:
WinNtIo - TODO: add argument description
EfiDeviceHandle - TODO: add argument description
Filename - TODO: add argument description
ReadOnly - TODO: add argument description
RemovableMedia - TODO: add argument description
NumberOfBlocks - TODO: add argument description
BlockSize - TODO: add argument description
DeviceType - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
WinNtBlockIoReadWriteCommon (
IN WIN_NT_BLOCK_IO_PRIVATE *Private,
IN UINT32 MediaId,
IN EFI_LBA Lba,
IN UINTN BufferSize,
IN VOID *Buffer,
IN CHAR8 *CallerName
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
MediaId - TODO: add argument description
Lba - TODO: add argument description
BufferSize - TODO: add argument description
Buffer - TODO: add argument description
CallerName - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
WinNtBlockIoError (
IN WIN_NT_BLOCK_IO_PRIVATE *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
WinNtBlockIoOpenDevice (
WIN_NT_BLOCK_IO_PRIVATE *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
CHAR16 *
GetNextElementPastTerminator (
IN CHAR16 *EnvironmentVariable,
IN CHAR16 Terminator
)
/*++
Routine Description:
TODO: Add function description
Arguments:
EnvironmentVariable - TODO: add argument description
Terminator - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
SetFilePointer64 (
IN WIN_NT_BLOCK_IO_PRIVATE *Private,
IN INT64 DistanceToMove,
OUT UINT64 *NewFilePointer,
IN DWORD MoveMethod
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
DistanceToMove - TODO: add argument description
NewFilePointer - TODO: add argument description
MoveMethod - TODO: add argument description
Returns:
TODO: add return values
--*/
;
UINTN
Atoi (
CHAR16 *String
)
/*++
Routine Description:
TODO: Add function description
Arguments:
String - TODO: add argument description
Returns:
TODO: add return values
--*/
;
#endif

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MbdHeader>
<BaseName>WinNtBlockIo</BaseName>
<Guid>F479E147-A125-11d4-BCFC-0080C73C8881</Guid>
<Version>0</Version>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>
<Created>2006-03-14 17:04</Created>
<Modified>2006-03-19 15:17</Modified>
</MbdHeader>
<Libraries>
<Library>UefiBootServicesTableLib</Library>
<Library>BaseLib</Library>
<Library>UefiLib</Library>
<Library>UefiMemoryLib</Library>
<Library>UefiDriverEntryPoint</Library>
<Library>UefiDriverModelLib</Library>
<Library>UefiDebugLibStdErr</Library>
<Library>BasePrintLib</Library>
<Library>DxeMemoryAllocationLib</Library>
</Libraries>
</ModuleBuildDescription>

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MsaHeader>
<BaseName>WinNtBlockIo</BaseName>
<ModuleType>UEFI_DRIVER</ModuleType>
<ComponentType>BS_DRIVER</ComponentType>
<Guid>F479E147-A125-11d4-BCFC-0080C73C8881</Guid>
<Version>0</Version>
<Abstract>Component description file for WinNtBlockIo module.</Abstract>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>0</Specification>
<Created>2006-03-14 17:04</Created>
<Updated>2006-03-19 15:17</Updated>
</MsaHeader>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverModelLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverEntryPoint</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">MemoryAllocationLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>WinNtBlockIo.h</Filename>
<Filename>WinNtBlockIo.c</Filename>
<Filename>ComponentName.c</Filename>
<Filename>DriverConfiguration.c</Filename>
<Filename>DriverDiagnostics.c</Filename>
</SourceFiles>
<Includes>
<PackageName>MdePkg</PackageName>
<PackageName>EdkModulePkg</PackageName>
<PackageName>EdkNt32Pkg</PackageName>
</Includes>
<Protocols>
<Protocol Usage="TO_START">WinNtIo</Protocol>
<Protocol Usage="BY_START">BlockIo</Protocol>
</Protocols>
<Guids>
<GuidEntry Usage="ALWAYS_CONSUMED">
<C_Name>WinNtVirtualDisks</C_Name>
</GuidEntry>
<GuidEntry Usage="SOMETIMES_CONSUMED">
<C_Name>WinNtPhysicalDisks</C_Name>
</GuidEntry>
</Guids>
<Externs>
<Extern>
<ModuleEntryPoint></ModuleEntryPoint>
</Extern>
<Extern>
<DriverBinding>gWinNtBlockIoDriverBinding</DriverBinding>
<ComponentName>gWinNtBlockIoComponentName</ComponentName>
<DriverDiag>gWinNtBlockIoDriverDiagnostics</DriverDiag>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
<project basedir="." default="WinNtBlockIo"><!--Apply external ANT tasks-->
<taskdef resource="GenBuild.tasks"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property environment="env"/>
<property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
<import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
<property name="MODULE_RELATIVE_PATH" value="Dxe\WinNtThunk\Bus\BlockIo"/>
<property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
<property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
<target name="WinNtBlockIo">
<GenBuild baseName="WinNtBlockIo" mbdFilename="${MODULE_DIR}\WinNtBlockIo.mbd" msaFilename="${MODULE_DIR}\WinNtBlockIo.msa"/>
</target>
<target depends="WinNtBlockIo_clean" name="clean"/>
<target depends="WinNtBlockIo_cleanall" name="cleanall"/>
<target name="WinNtBlockIo_clean">
<OutputDirSetup baseName="WinNtBlockIo" mbdFilename="${MODULE_DIR}\WinNtBlockIo.mbd" msaFilename="${MODULE_DIR}\WinNtBlockIo.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\WinNtBlockIo_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\WinNtBlockIo_build.xml" target="clean"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
</target>
<target name="WinNtBlockIo_cleanall">
<OutputDirSetup baseName="WinNtBlockIo" mbdFilename="${MODULE_DIR}\WinNtBlockIo.mbd" msaFilename="${MODULE_DIR}\WinNtBlockIo.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\WinNtBlockIo_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\WinNtBlockIo_build.xml" target="cleanall"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}"/>
<delete dir="${DEST_DIR_DEBUG}"/>
<delete>
<fileset dir="${BIN_DIR}" includes="**WinNtBlockIo*"/>
</delete>
</target>
</project>

View File

@@ -0,0 +1,187 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
ComponentName.c
Abstract:
--*/
#include "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_OUT_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;
}
//
// 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,307 @@
/*++
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.c
Abstract:
Console based on Win32 APIs.
--*/
#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,
0x10,
NULL,
NULL
};
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;
}
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (WIN_NT_SIMPLE_TEXT_PRIVATE_DATA),
&Private
);
if (EFI_ERROR (Status)) {
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);
}
gBS->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_OUT_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);
gBS->FreePool (Private);
}
return Status;
}

View File

@@ -0,0 +1,512 @@
/*++
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_OUT_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_IN_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_OUT_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_OUT_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_OUT_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_OUT_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_OUT_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_OUT_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_OUT_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_OUT_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_OUT_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_IN_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_IN_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,361 @@
/*++
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:
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
--*/
#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_IN_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_IN_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;
}
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (INPUT_RECORD) * NtEventCount,
&InputRecord
);
if (EFI_ERROR (Status)) {
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) {
gBS->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 (
EFI_EVENT_NOTIFY_WAIT,
EFI_TPL_NOTIFY,
WinNtSimpleTextInWaitForKey,
Private,
&Private->SimpleTextIn.WaitForKey
);
ASSERT_EFI_ERROR (Status);
return Status;
}

View File

@@ -0,0 +1,638 @@
/*++
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.
--*/
#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_OUT_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_OUT_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_OUT_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_OUT_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_OUT_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_OUT_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_OUT_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_OUT_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_OUT_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_OUT_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,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MbdHeader>
<BaseName>WinNtConsole</BaseName>
<Guid>263631d7-5836-4b74-be48-ee22e92ce5d3</Guid>
<Version>0</Version>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>
<Created>2006-03-14 17:04</Created>
<Modified>2006-03-19 15:17</Modified>
</MbdHeader>
<Libraries>
<Library>UefiBootServicesTableLib</Library>
<Library>BaseLib</Library>
<Library>UefiLib</Library>
<Library>UefiMemoryLib</Library>
<Library>UefiDriverEntryPoint</Library>
<Library>UefiDriverModelLib</Library>
<Library>UefiDebugLibStdErr</Library>
<Library>BasePrintLib</Library>
<Library>DxeMemoryAllocationLib</Library>
</Libraries>
</ModuleBuildDescription>

View File

@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MsaHeader>
<BaseName>WinNtConsole</BaseName>
<ModuleType>UEFI_DRIVER</ModuleType>
<ComponentType>BS_DRIVER</ComponentType>
<Guid>263631d7-5836-4b74-be48-ee22e92ce5d3</Guid>
<Version>0</Version>
<Abstract>Component description file for WinNtConsole module.</Abstract>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>0</Specification>
<Created>2006-03-14 17:04</Created>
<Updated>2006-03-19 15:17</Updated>
</MsaHeader>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverModelLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverEntryPoint</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">MemoryAllocationLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>Console.h</Filename>
<Filename>Console.c</Filename>
<Filename>ConsoleIn.c</Filename>
<Filename>ConsoleOut.c</Filename>
<Filename>ComponentName.c</Filename>
</SourceFiles>
<Includes>
<PackageName>MdePkg</PackageName>
<PackageName>EdkModulePkg</PackageName>
<PackageName>EdkNt32Pkg</PackageName>
</Includes>
<Protocols>
<Protocol Usage="TO_START">WinNtIo</Protocol>
<Protocol Usage="BY_START">SimpleTextOut</Protocol>
<Protocol Usage="BY_START">SimpleTextIn</Protocol>
</Protocols>
<Guids>
<GuidEntry Usage="ALWAYS_CONSUMED">
<C_Name>WinNtConsole</C_Name>
</GuidEntry>
</Guids>
<Externs>
<Extern>
<ModuleEntryPoint></ModuleEntryPoint>
</Extern>
<Extern>
<DriverBinding>gWinNtConsoleDriverBinding</DriverBinding>
<ComponentName>gWinNtConsoleComponentName</ComponentName>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
<project basedir="." default="WinNtConsole"><!--Apply external ANT tasks-->
<taskdef resource="GenBuild.tasks"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property environment="env"/>
<property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
<import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
<property name="MODULE_RELATIVE_PATH" value="Dxe\WinNtThunk\Bus\Console"/>
<property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
<property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
<target name="WinNtConsole">
<GenBuild baseName="WinNtConsole" mbdFilename="${MODULE_DIR}\WinNtConsole.mbd" msaFilename="${MODULE_DIR}\WinNtConsole.msa"/>
</target>
<target depends="WinNtConsole_clean" name="clean"/>
<target depends="WinNtConsole_cleanall" name="cleanall"/>
<target name="WinNtConsole_clean">
<OutputDirSetup baseName="WinNtConsole" mbdFilename="${MODULE_DIR}\WinNtConsole.mbd" msaFilename="${MODULE_DIR}\WinNtConsole.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\WinNtConsole_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\WinNtConsole_build.xml" target="clean"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
</target>
<target name="WinNtConsole_cleanall">
<OutputDirSetup baseName="WinNtConsole" mbdFilename="${MODULE_DIR}\WinNtConsole.mbd" msaFilename="${MODULE_DIR}\WinNtConsole.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\WinNtConsole_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\WinNtConsole_build.xml" target="cleanall"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}"/>
<delete dir="${DEST_DIR_DEBUG}"/>
<delete>
<fileset dir="${BIN_DIR}" includes="**WinNtConsole*"/>
</delete>
</target>
</project>

View File

@@ -0,0 +1,187 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
ComponentName.c
Abstract:
--*/
#include "WinNtSerialIo.h"
//
// EFI Component Name Functions
//
EFI_STATUS
EFIAPI
WinNtSerialIoComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
);
EFI_STATUS
EFIAPI
WinNtSerialIoComponentNameGetControllerName (
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 gWinNtSerialIoComponentName = {
WinNtSerialIoComponentNameGetDriverName,
WinNtSerialIoComponentNameGetControllerName,
"eng"
};
static EFI_UNICODE_STRING_TABLE mWinNtSerialIoDriverNameTable[] = {
{ "eng", L"Windows Serial I/O Driver" },
{ NULL , NULL }
};
EFI_STATUS
EFIAPI
WinNtSerialIoComponentNameGetDriverName (
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,
gWinNtSerialIoComponentName.SupportedLanguages,
mWinNtSerialIoDriverNameTable,
DriverName
);
}
EFI_STATUS
EFIAPI
WinNtSerialIoComponentNameGetControllerName (
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_SERIAL_IO_PROTOCOL *SerialIo;
WIN_NT_SERIAL_IO_PRIVATE_DATA *Private;
//
// This is a bus driver, so ChildHandle must not be NULL.
//
if (ChildHandle == NULL) {
return EFI_UNSUPPORTED;
}
//
// Get our context back
//
Status = gBS->OpenProtocol (
ChildHandle,
&gEfiSerialIoProtocolGuid,
&SerialIo,
gWinNtSerialIoDriverBinding.DriverBindingHandle,
ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
Private = WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS (SerialIo);
return LookupUnicodeString (
Language,
gWinNtSerialIoComponentName.SupportedLanguages,
Private->ControllerNameTable,
ControllerName
);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,513 @@
/*++
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:
WinNtSerialIo.h
Abstract:
--*/
#ifndef _WIN_NT_SERIAL_IO_
#define _WIN_NT_SERIAL_IO_
#define SERIAL_MAX_BUFFER_SIZE 256
#define TIMEOUT_STALL_INTERVAL 10
typedef struct {
UINT32 First;
UINT32 Last;
UINT32 Surplus;
UINT8 Data[SERIAL_MAX_BUFFER_SIZE];
} SERIAL_DEV_FIFO;
#define WIN_NT_SERIAL_IO_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('N', 'T', 's', 'i')
typedef struct {
UINT64 Signature;
//
// Protocol data for the new handle we are going to add
//
EFI_HANDLE Handle;
EFI_SERIAL_IO_PROTOCOL SerialIo;
EFI_SERIAL_IO_MODE SerialIoMode;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
//
// Private Data
//
EFI_HANDLE ControllerHandle;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
UART_DEVICE_PATH UartDevicePath;
EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
//
// Private NT type Data;
//
HANDLE NtHandle;
DCB NtDCB;
DWORD NtError;
COMSTAT NtComStatus;
BOOLEAN SoftwareLoopbackEnable;
BOOLEAN HardwareFlowControl;
BOOLEAN HardwareLoopbackEnable;
SERIAL_DEV_FIFO Fifo;
} WIN_NT_SERIAL_IO_PRIVATE_DATA;
#define WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS(a) \
CR(a, WIN_NT_SERIAL_IO_PRIVATE_DATA, SerialIo, WIN_NT_SERIAL_IO_PRIVATE_DATA_SIGNATURE)
//
// Global Protocol Variables
//
extern EFI_DRIVER_BINDING_PROTOCOL gWinNtSerialIoDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gWinNtSerialIoComponentName;
//
// Macros to convert EFI serial types to NT serial types.
//
//
// one second
//
#define SERIAL_TIMEOUT_DEFAULT (1000 * 1000)
#define SERIAL_BAUD_DEFAULT 115200
#define SERIAL_FIFO_DEFAULT 14
#define SERIAL_DATABITS_DEFAULT 8
#define SERIAL_PARITY_DEFAULT DefaultParity
#define SERIAL_STOPBITS_DEFAULT DefaultStopBits
#define SERIAL_CONTROL_MASK (EFI_SERIAL_CLEAR_TO_SEND | \
EFI_SERIAL_DATA_SET_READY | \
EFI_SERIAL_RING_INDICATE | \
EFI_SERIAL_CARRIER_DETECT | \
EFI_SERIAL_REQUEST_TO_SEND | \
EFI_SERIAL_DATA_TERMINAL_READY | \
EFI_SERIAL_INPUT_BUFFER_EMPTY)
#define ConvertBaud2Nt(x) (DWORD) x
#define ConvertData2Nt(x) (BYTE) x
#define ConvertParity2Nt(x) \
(BYTE) ( \
x == DefaultParity ? NOPARITY : \
x == NoParity ? NOPARITY : \
x == EvenParity ? EVENPARITY : \
x == OddParity ? ODDPARITY : \
x == MarkParity ? MARKPARITY : \
x == SpaceParity ? SPACEPARITY : 0 \
)
#define ConvertStop2Nt(x) \
(BYTE) ( \
x == DefaultParity ? ONESTOPBIT : \
x == OneFiveStopBits ? ONE5STOPBITS : \
x == TwoStopBits ? TWOSTOPBITS : 0 \
)
#define ConvertTime2Nt(x) ((x) / 1000)
//
// 115400 baud with rounding errors
//
#define SERIAL_PORT_MAX_BAUD_RATE 115400
//
// Function Prototypes
//
EFI_STATUS
EFIAPI
InitializeWinNtSerialIo (
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
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSerialIoDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Handle - TODO: add argument description
RemainingDevicePath - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSerialIoDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Handle - TODO: add argument description
RemainingDevicePath - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSerialIoDriverBindingStop (
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:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSerialIoReset (
IN EFI_SERIAL_IO_PROTOCOL *This
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSerialIoSetAttributes (
IN EFI_SERIAL_IO_PROTOCOL *This,
IN UINT64 BaudRate,
IN UINT32 ReceiveFifoDepth,
IN UINT32 Timeout,
IN EFI_PARITY_TYPE Parity,
IN UINT8 DataBits,
IN EFI_STOP_BITS_TYPE StopBits
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
BaudRate - TODO: add argument description
ReceiveFifoDepth - TODO: add argument description
Timeout - TODO: add argument description
Parity - TODO: add argument description
DataBits - TODO: add argument description
StopBits - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSerialIoSetControl (
IN EFI_SERIAL_IO_PROTOCOL *This,
IN UINT32 Control
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Control - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSerialIoGetControl (
IN EFI_SERIAL_IO_PROTOCOL *This,
OUT UINT32 *Control
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Control - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSerialIoWrite (
IN EFI_SERIAL_IO_PROTOCOL *This,
IN OUT UINTN *BufferSize,
IN VOID *Buffer
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
BufferSize - TODO: add argument description
Buffer - TODO: add argument description
Returns:
TODO: add return values
--*/
;
STATIC
EFI_STATUS
EFIAPI
WinNtSerialIoRead (
IN EFI_SERIAL_IO_PROTOCOL *This,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
BufferSize - TODO: add argument description
Buffer - TODO: add argument description
Returns:
TODO: add return values
--*/
;
BOOLEAN
IsaSerialFifoFull (
IN SERIAL_DEV_FIFO *Fifo
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Fifo - TODO: add argument description
Returns:
TODO: add return values
--*/
;
BOOLEAN
IsaSerialFifoEmpty (
IN SERIAL_DEV_FIFO *Fifo
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Fifo - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
IsaSerialFifoAdd (
IN SERIAL_DEV_FIFO *Fifo,
IN UINT8 Data
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Fifo - TODO: add argument description
Data - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
IsaSerialFifoRemove (
IN SERIAL_DEV_FIFO *Fifo,
OUT UINT8 *Data
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Fifo - TODO: add argument description
Data - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
IsaSerialReceiveTransmit (
WIN_NT_SERIAL_IO_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
;
#endif

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MbdHeader>
<BaseName>WinNtSerialIo</BaseName>
<Guid>6B41B553-A649-11d4-BD02-0080C73C8881</Guid>
<Version>0</Version>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>
<Created>2006-03-13 17:02</Created>
<Modified>2006-03-19 15:17</Modified>
</MbdHeader>
<Libraries>
<Library>UefiBootServicesTableLib</Library>
<Library>BaseLib</Library>
<Library>UefiLib</Library>
<Library>UefiMemoryLib</Library>
<Library>UefiDriverEntryPoint</Library>
<Library>UefiDriverModelLib</Library>
<Library>UefiDebugLibStdErr</Library>
<Library>BasePrintLib</Library>
<Library>DxeMemoryAllocationLib</Library>
<Library>UefiDevicePathLib</Library>
</Libraries>
</ModuleBuildDescription>

View File

@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MsaHeader>
<BaseName>WinNtSerialIo</BaseName>
<ModuleType>UEFI_DRIVER</ModuleType>
<ComponentType>BS_DRIVER</ComponentType>
<Guid>6B41B553-A649-11d4-BD02-0080C73C8881</Guid>
<Version>0</Version>
<Abstract>Component description file for WinNtSerialIo module.</Abstract>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>0</Specification>
<Created>2006-03-13 17:02</Created>
<Updated>2006-03-19 15:17</Updated>
</MsaHeader>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverModelLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverEntryPoint</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">MemoryAllocationLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">DevicePathLib</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>WinNtSerialIo.h</Filename>
<Filename>WinNtSerialIo.c</Filename>
<Filename>ComponentName.c</Filename>
</SourceFiles>
<Includes>
<PackageName>MdePkg</PackageName>
<PackageName>EdkModulePkg</PackageName>
<PackageName>EdkNt32Pkg</PackageName>
</Includes>
<Protocols>
<Protocol Usage="TO_START">WinNtIo</Protocol>
<Protocol Usage="TO_START">DevicePath</Protocol>
<Protocol Usage="BY_START">SerialIo</Protocol>
</Protocols>
<Guids>
<GuidEntry Usage="ALWAYS_CONSUMED">
<C_Name>WinNtSerialPort</C_Name>
</GuidEntry>
</Guids>
<Externs>
<Extern>
<ModuleEntryPoint></ModuleEntryPoint>
</Extern>
<Extern>
<DriverBinding>gWinNtSerialIoDriverBinding</DriverBinding>
<ComponentName>gWinNtSerialIoComponentName</ComponentName>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
<project basedir="." default="WinNtSerialIo"><!--Apply external ANT tasks-->
<taskdef resource="GenBuild.tasks"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property environment="env"/>
<property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
<import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
<property name="MODULE_RELATIVE_PATH" value="Dxe\WinNtThunk\Bus\SerialIo"/>
<property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
<property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
<target name="WinNtSerialIo">
<GenBuild baseName="WinNtSerialIo" mbdFilename="${MODULE_DIR}\WinNtSerialIo.mbd" msaFilename="${MODULE_DIR}\WinNtSerialIo.msa"/>
</target>
<target depends="WinNtSerialIo_clean" name="clean"/>
<target depends="WinNtSerialIo_cleanall" name="cleanall"/>
<target name="WinNtSerialIo_clean">
<OutputDirSetup baseName="WinNtSerialIo" mbdFilename="${MODULE_DIR}\WinNtSerialIo.mbd" msaFilename="${MODULE_DIR}\WinNtSerialIo.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\WinNtSerialIo_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\WinNtSerialIo_build.xml" target="clean"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
</target>
<target name="WinNtSerialIo_cleanall">
<OutputDirSetup baseName="WinNtSerialIo" mbdFilename="${MODULE_DIR}\WinNtSerialIo.mbd" msaFilename="${MODULE_DIR}\WinNtSerialIo.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\WinNtSerialIo_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\WinNtSerialIo_build.xml" target="cleanall"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}"/>
<delete dir="${DEST_DIR_DEBUG}"/>
<delete>
<fileset dir="${BIN_DIR}" includes="**WinNtSerialIo*"/>
</delete>
</target>
</project>

View File

@@ -0,0 +1,193 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
ComponentName.c
Abstract:
--*/
#include "WinNtSimpleFileSystem.h"
//
// EFI Component Name Functions
//
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
);
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemComponentNameGetControllerName (
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 gWinNtSimpleFileSystemComponentName = {
WinNtSimpleFileSystemComponentNameGetDriverName,
WinNtSimpleFileSystemComponentNameGetControllerName,
"eng"
};
static EFI_UNICODE_STRING_TABLE mWinNtSimpleFileSystemDriverNameTable[] = {
{
"eng",
L"Windows Simple File System Driver"
},
{
NULL,
NULL
}
};
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemComponentNameGetDriverName (
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,
gWinNtSimpleFileSystemComponentName.SupportedLanguages,
mWinNtSimpleFileSystemDriverNameTable,
DriverName
);
}
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemComponentNameGetControllerName (
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_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
//
// This is a device driver, so ChildHandle must be NULL.
//
if (ChildHandle != NULL) {
return EFI_UNSUPPORTED;
}
//
// Get our context back
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiSimpleFileSystemProtocolGuid,
&SimpleFileSystem,
gWinNtSimpleFileSystemDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
Private = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem);
return LookupUnicodeString (
Language,
gWinNtSimpleFileSystemComponentName.SupportedLanguages,
Private->ControllerNameTable,
ControllerName
);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,587 @@
/*++
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:
WinNtSimpleFileSystem.h
Abstract:
Produce Simple File System abstractions for a directory on your PC using Win32 APIs.
The configuration of what devices to mount or emulate comes from NT
environment variables. The variables must be visible to the Microsoft*
Developer Studio for them to work.
* Other names and brands may be claimed as the property of others.
--*/
#ifndef _WIN_NT_SIMPLE_FILE_SYSTEM_H_
#define _WIN_NT_SIMPLE_FILE_SYSTEM_H_
#define WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('N', 'T', 'f', 's')
typedef struct {
UINTN Signature;
EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem;
CHAR16 *FilePath;
CHAR16 *VolumeLabel;
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
} WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE;
#define WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS(a) \
CR (a, \
WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE, \
SimpleFileSystem, \
WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \
)
#define WIN_NT_EFI_FILE_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('l', 'o', 'f', 's')
typedef struct {
UINTN Signature;
EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
EFI_FILE EfiFile;
HANDLE LHandle;
HANDLE DirHandle;
BOOLEAN IsRootDirectory;
BOOLEAN IsDirectoryPath;
BOOLEAN IsOpenedByRead;
CHAR16 *FilePath;
WCHAR *FileName;
BOOLEAN IsValidFindBuf;
WIN32_FIND_DATA FindBuf;
} WIN_NT_EFI_FILE_PRIVATE;
#define WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \
CR (a, \
WIN_NT_EFI_FILE_PRIVATE, \
EfiFile, \
WIN_NT_EFI_FILE_PRIVATE_SIGNATURE \
)
//
// Global Protocol Variables
//
extern EFI_DRIVER_BINDING_PROTOCOL gWinNtSimpleFileSystemDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gWinNtSimpleFileSystemComponentName;
//
// Driver Binding protocol member functions
//
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
/*++
Routine Description:
Check to see if the driver supports a given controller.
Arguments:
This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
ControllerHandle - EFI handle of the controller to test.
RemainingDevicePath - Pointer to remaining portion of a device path.
Returns:
EFI_SUCCESS - The device specified by ControllerHandle and RemainingDevicePath is supported by the driver
specified by This.
EFI_ALREADY_STARTED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by
the driver specified by This.
EFI_ACCESS_DENIED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by
a different driver or an application that requires exclusive access.
EFI_UNSUPPORTED - The device specified by ControllerHandle and RemainingDevicePath is not supported by the
driver specified by This.
--*/
;
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
/*++
Routine Description:
Starts a device controller or a bus controller.
Arguments:
This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
ControllerHandle - EFI handle of the controller to start.
RemainingDevicePath - Pointer to remaining portion of a device path.
Returns:
EFI_SUCCESS - The device or bus controller has been started.
EFI_DEVICE_ERROR - The device could not be started due to a device failure.
EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
--*/
;
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
ControllerHandle - A handle to the device to be stopped.
NumberOfChildren - The number of child device handles in ChildHandleBuffer.
ChildHandleBuffer - An array of child device handles to be freed.
Returns:
EFI_SUCCESS - The device has been stopped.
EFI_DEVICE_ERROR - The device could not be stopped due to a device failure.
--*/
;
//
// Simple File System protocol member functions
//
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemOpenVolume (
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
OUT EFI_FILE **Root
)
/*++
Routine Description:
Open the root directory on a volume.
Arguments:
This - A pointer to the volume to open.
Root - A pointer to storage for the returned opened file handle of the root directory.
Returns:
EFI_SUCCESS - The volume was opened.
EFI_UNSUPPORTED - The volume does not support the requested file system type.
EFI_NO_MEDIA - The device has no media.
EFI_DEVICE_ERROR - The device reported an error.
EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
EFI_ACCESS_DENIED - The service denied access to the file.
EFI_OUT_OF_RESOURCES - The file volume could not be opened due to lack of resources.
EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported.
--*/
;
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemOpen (
IN EFI_FILE *This,
OUT EFI_FILE **NewHandle,
IN CHAR16 *FileName,
IN UINT64 OpenMode,
IN UINT64 Attributes
)
/*++
Routine Description:
Open a file relative to the source file location.
Arguments:
This - A pointer to the source file location.
NewHandle - Pointer to storage for the new file handle.
FileName - Pointer to the file name to be opened.
OpenMode - File open mode information.
Attributes - File creation attributes.
Returns:
EFI_SUCCESS - The file was opened.
EFI_NOT_FOUND - The file could not be found in the volume.
EFI_NO_MEDIA - The device has no media.
EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported.
EFI_DEVICE_ERROR - The device reported an error.
EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
EFI_WRITE_PROTECTED - The volume or file is write protected.
EFI_ACCESS_DENIED - The service denied access to the file.
EFI_OUT_OF_RESOURCES - Not enough resources were available to open the file.
EFI_VOLUME_FULL - There is not enough space left to create the new file.
--*/
;
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemClose (
IN EFI_FILE *This
)
/*++
Routine Description:
Close the specified file handle.
Arguments:
This - Pointer to a returned opened file handle.
Returns:
EFI_SUCCESS - The file handle has been closed.
--*/
;
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemDelete (
IN EFI_FILE *This
)
/*++
Routine Description:
Close and delete a file.
Arguments:
This - Pointer to a returned opened file handle.
Returns:
EFI_SUCCESS - The file handle was closed and deleted.
EFI_WARN_DELETE_FAILURE - The handle was closed but could not be deleted.
--*/
;
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemRead (
IN EFI_FILE *This,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer
)
/*++
Routine Description:
Read data from a file.
Arguments:
This - Pointer to a returned open file handle.
BufferSize - On input, the size of the Buffer. On output, the number of bytes stored in the Buffer.
Buffer - Pointer to the first byte of the read Buffer.
Returns:
EFI_SUCCESS - The data was read.
EFI_NO_MEDIA - The device has no media.
EFI_DEVICE_ERROR - The device reported an error.
EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
EFI_BUFFER_TOO_SMALL - The supplied buffer size was too small to store the current directory entry.
*BufferSize has been updated with the size needed to complete the request.
--*/
;
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemWrite (
IN EFI_FILE *This,
IN OUT UINTN *BufferSize,
IN VOID *Buffer
)
/*++
Routine Description:
Write data to a file.
Arguments:
This - Pointer to an opened file handle.
BufferSize - On input, the number of bytes in the Buffer to write to the file. On output, the number of bytes
of data written to the file.
Buffer - Pointer to the first by of data in the buffer to write to the file.
Returns:
EFI_SUCCESS - The data was written to the file.
EFI_UNSUPPORTED - Writes to an open directory are not supported.
EFI_NO_MEDIA - The device has no media.
EFI_DEVICE_ERROR - The device reported an error.
EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
EFI_ACCESS_DENIED - The file was opened read-only.
EFI_VOLUME_FULL - The volume is full.
--*/
;
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemSetPosition (
IN EFI_FILE *This,
IN UINT64 Position
)
/*++
Routine Description:
Set a file's current position.
Arguments:
This - Pointer to an opened file handle.
Position - The byte position from the start of the file to set.
Returns:
EFI_SUCCESS - The file position has been changed.
EFI_UNSUPPORTED - The seek request for non-zero is not supported for directories.
--*/
;
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemGetPosition (
IN EFI_FILE *This,
OUT UINT64 *Position
)
/*++
Routine Description:
Get a file's current position.
Arguments:
This - Pointer to an opened file handle.
Position - Pointer to storage for the current position.
Returns:
EFI_SUCCESS - The file position has been reported.
EFI_UNSUPPORTED - Not valid for directories.
--*/
;
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemGetInfo (
IN EFI_FILE *This,
IN EFI_GUID *InformationType,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer
)
/*++
Routine Description:
Return information about a file or volume.
Arguments:
This - Pointer to an opened file handle.
InformationType - GUID describing the type of information to be returned.
BufferSize - On input, the size of the information buffer. On output, the number of bytes written to the
information buffer.
Buffer - Pointer to the first byte of the information buffer.
Returns:
EFI_SUCCESS - The requested information has been written into the buffer.
EFI_UNSUPPORTED - The InformationType is not known.
EFI_NO_MEDIA - The device has no media.
EFI_DEVICE_ERROR - The device reported an error.
EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
EFI_BUFFER_TOO_SMALL - The buffer size was too small to contain the requested information. The buffer size has
been updated with the size needed to complete the requested operation.
--*/
;
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemSetInfo (
IN EFI_FILE *This,
IN EFI_GUID *InformationType,
IN UINTN BufferSize,
IN VOID *Buffer
)
/*++
Routine Description:
Set information about a file or volume.
Arguments:
This - Pointer to an opened file handle.
InformationType - GUID identifying the type of information to set.
BufferSize - Number of bytes of data in the information buffer.
Buffer - Pointer to the first byte of data in the information buffer.
Returns:
EFI_SUCCESS - The file or volume information has been updated.
EFI_UNSUPPORTED - The information identifier is not recognised.
EFI_NO_MEDIA - The device has no media.
EFI_DEVICE_ERROR - The device reported an error.
EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
EFI_ACCESS_DENIED - The file was opened read-only.
EFI_VOLUME_FULL - The volume is full.
EFI_BAD_BUFFER_SIZE - The buffer size is smaller than the type indicated by InformationType.
--*/
;
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemFlush (
IN EFI_FILE *This
)
/*++
Routine Description:
Flush all modified data to the media.
Arguments:
This - Pointer to an opened file handle.
Returns:
EFI_SUCCESS - The data has been flushed.
EFI_NO_MEDIA - The device has no media.
EFI_DEVICE_ERROR - The device reported an error.
EFI_VOLUME_CORRUPTED - The file system structures have been corrupted.
EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
EFI_ACCESS_DENIED - The file was opened read-only.
EFI_VOLUME_FULL - The volume is full.
--*/
;
#endif /* _WIN_NT_SIMPLE_FILE_SYSTEM_H_ */
/* eof - WinNtSimpleFileSystem.h */

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MbdHeader>
<BaseName>WinNtSimpleFileSystem</BaseName>
<Guid>9C25E18B-76BA-43da-A132-DBB0997CEFEF</Guid>
<Version>0</Version>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>
<Created>2006-03-14 17:04</Created>
<Modified>2006-03-19 15:17</Modified>
</MbdHeader>
<Libraries>
<Library>UefiBootServicesTableLib</Library>
<Library>BaseLib</Library>
<Library>UefiLib</Library>
<Library>UefiMemoryLib</Library>
<Library>UefiDriverEntryPoint</Library>
<Library>UefiDriverModelLib</Library>
<Library>UefiDebugLibStdErr</Library>
<Library>BasePrintLib</Library>
<Library>DxeMemoryAllocationLib</Library>
</Libraries>
</ModuleBuildDescription>

View File

@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MsaHeader>
<BaseName>WinNtSimpleFileSystem</BaseName>
<ModuleType>UEFI_DRIVER</ModuleType>
<ComponentType>BS_DRIVER</ComponentType>
<Guid>9C25E18B-76BA-43da-A132-DBB0997CEFEF</Guid>
<Version>0</Version>
<Abstract>Component description file for WinNtSimpleFileSystem module.</Abstract>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>0</Specification>
<Created>2006-03-14 17:04</Created>
<Updated>2006-03-19 15:17</Updated>
</MsaHeader>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverModelLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverEntryPoint</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">MemoryAllocationLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>WinNtSimpleFileSystem.h</Filename>
<Filename>WinNtSimpleFileSystem.c</Filename>
<Filename>ComponentName.c</Filename>
</SourceFiles>
<Includes>
<PackageName>MdePkg</PackageName>
<PackageName>EdkModulePkg</PackageName>
<PackageName>EdkNt32Pkg</PackageName>
</Includes>
<Protocols>
<Protocol Usage="TO_START">WinNtIo</Protocol>
<Protocol Usage="BY_START">SimpleFileSystem</Protocol>
</Protocols>
<Guids>
<GuidEntry Usage="ALWAYS_CONSUMED">
<C_Name>WinNtFileSystem</C_Name>
</GuidEntry>
<GuidEntry Usage="SOMETIMES_CONSUMED">
<C_Name>FileSystemInfo</C_Name>
</GuidEntry>
<GuidEntry Usage="SOMETIMES_CONSUMED">
<C_Name>FileInfo</C_Name>
</GuidEntry>
<GuidEntry Usage="SOMETIMES_CONSUMED">
<C_Name>FileSystemVolumeLabelInfoId</C_Name>
</GuidEntry>
</Guids>
<Externs>
<Extern>
<ModuleEntryPoint></ModuleEntryPoint>
</Extern>
<Extern>
<DriverBinding>gWinNtSimpleFileSystemDriverBinding</DriverBinding>
<ComponentName>gWinNtSimpleFileSystemComponentName</ComponentName>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
<project basedir="." default="WinNtSimpleFileSystem"><!--Apply external ANT tasks-->
<taskdef resource="GenBuild.tasks"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property environment="env"/>
<property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
<import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
<property name="MODULE_RELATIVE_PATH" value="Dxe\WinNtThunk\Bus\SimpleFileSystem"/>
<property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
<property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
<target name="WinNtSimpleFileSystem">
<GenBuild baseName="WinNtSimpleFileSystem" mbdFilename="${MODULE_DIR}\WinNtSimpleFileSystem.mbd" msaFilename="${MODULE_DIR}\WinNtSimpleFileSystem.msa"/>
</target>
<target depends="WinNtSimpleFileSystem_clean" name="clean"/>
<target depends="WinNtSimpleFileSystem_cleanall" name="cleanall"/>
<target name="WinNtSimpleFileSystem_clean">
<OutputDirSetup baseName="WinNtSimpleFileSystem" mbdFilename="${MODULE_DIR}\WinNtSimpleFileSystem.mbd" msaFilename="${MODULE_DIR}\WinNtSimpleFileSystem.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\WinNtSimpleFileSystem_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\WinNtSimpleFileSystem_build.xml" target="clean"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
</target>
<target name="WinNtSimpleFileSystem_cleanall">
<OutputDirSetup baseName="WinNtSimpleFileSystem" mbdFilename="${MODULE_DIR}\WinNtSimpleFileSystem.mbd" msaFilename="${MODULE_DIR}\WinNtSimpleFileSystem.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\WinNtSimpleFileSystem_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\WinNtSimpleFileSystem_build.xml" target="cleanall"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}"/>
<delete dir="${DEST_DIR_DEBUG}"/>
<delete>
<fileset dir="${BIN_DIR}" includes="**WinNtSimpleFileSystem*"/>
</delete>
</target>
</project>

View File

@@ -0,0 +1,187 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
ComponentName.c
Abstract:
--*/
#include "WinNtUga.h"
//
// EFI Component Name Functions
//
EFI_STATUS
EFIAPI
WinNtUgaComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
);
EFI_STATUS
EFIAPI
WinNtUgaComponentNameGetControllerName (
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 gWinNtUgaComponentName = {
WinNtUgaComponentNameGetDriverName,
WinNtUgaComponentNameGetControllerName,
"eng"
};
static EFI_UNICODE_STRING_TABLE mWinNtUgaDriverNameTable[] = {
{ "eng", L"Windows Universal Graphics Adapter Driver" },
{ NULL , NULL }
};
EFI_STATUS
EFIAPI
WinNtUgaComponentNameGetDriverName (
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,
gWinNtUgaComponentName.SupportedLanguages,
mWinNtUgaDriverNameTable,
DriverName
);
}
EFI_STATUS
EFIAPI
WinNtUgaComponentNameGetControllerName (
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_UGA_DRAW_PROTOCOL *UgaDraw;
UGA_PRIVATE_DATA *Private;
//
// This is a device driver, so ChildHandle must be NULL.
//
if (ChildHandle != NULL) {
return EFI_UNSUPPORTED;
}
//
// Get our context back
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiUgaDrawProtocolGuid,
&UgaDraw,
gWinNtUgaDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
Private = UGA_DRAW_PRIVATE_DATA_FROM_THIS (UgaDraw);
return LookupUnicodeString (
Language,
gWinNtUgaComponentName.SupportedLanguages,
Private->ControllerNameTable,
ControllerName
);
}

View File

@@ -0,0 +1,363 @@
/*++
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:
WinNtUga.h
Abstract:
Private data for the Uga driver that is bound to the WinNt Thunk protocol
--*/
#ifndef _WIN_NT_UGA_H_
#define _WIN_NT_UGA_H_
#define MAX_Q 256
typedef struct {
UINTN Front;
UINTN Rear;
UINTN Count;
EFI_INPUT_KEY Q[MAX_Q];
} UGA_QUEUE_FIXED;
#define WIN_NT_UGA_CLASS_NAME L"WinNtUgaWindow"
#define UGA_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('S', 'g', 'o', 'N')
typedef struct {
UINT64 Signature;
EFI_HANDLE Handle;
EFI_UGA_DRAW_PROTOCOL UgaDraw;
EFI_SIMPLE_TEXT_IN_PROTOCOL SimpleTextIn;
EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
//
// UGA Private Data for GetMode ()
//
UINT32 HorizontalResolution;
UINT32 VerticalResolution;
UINT32 ColorDepth;
UINT32 RefreshRate;
//
// UGA 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_UGA_PIXEL *FillLine;
//
// Keyboard Queue used by Simple Text In. WinProc thread adds, and main
// thread removes.
//
CRITICAL_SECTION QCriticalSection;
UGA_QUEUE_FIXED Queue;
} UGA_PRIVATE_DATA;
#define UGA_DRAW_PRIVATE_DATA_FROM_THIS(a) \
CR(a, UGA_PRIVATE_DATA, UgaDraw, UGA_PRIVATE_DATA_SIGNATURE)
#define UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS(a) \
CR(a, UGA_PRIVATE_DATA, SimpleTextIn, UGA_PRIVATE_DATA_SIGNATURE)
//
// Global Protocol Variables
//
extern EFI_DRIVER_BINDING_PROTOCOL gWinNtUgaDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gWinNtUgaComponentName;
//
// Uga Hardware abstraction internal worker functions
//
EFI_STATUS
WinNtUgaSupported (
IN EFI_WIN_NT_IO_PROTOCOL *WinNtIo
)
/*++
Routine Description:
TODO: Add function description
Arguments:
WinNtIo - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
WinNtUgaConstructor (
IN UGA_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
WinNtUgaDestructor (
IN UGA_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
;
//
// EFI 1.1 driver model prototypes for Win NT UGA
//
EFI_STATUS
EFIAPI
WinNtUgaInitialize (
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
EFIAPI
WinNtUgaDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Handle - TODO: add argument description
RemainingDevicePath - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
EFIAPI
WinNtUgaDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Handle - TODO: add argument description
RemainingDevicePath - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
EFIAPI
WinNtUgaDriverBindingStop (
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:
TODO: add return values
--*/
;
EFI_STATUS
UgaPrivateAddQ (
IN UGA_PRIVATE_DATA *Private,
IN EFI_INPUT_KEY Key
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Key - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
WinNtUgaInitializeSimpleTextInForWindow (
IN UGA_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
WinNtUgaDestroySimpleTextInForWindow (
IN UGA_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
;
UINTN
Atoi (
IN CHAR16 *String
)
/*++
Routine Description:
TODO: Add function description
Arguments:
String - TODO: add argument description
Returns:
TODO: add return values
--*/
;
#endif

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MbdHeader>
<BaseName>WinNtUga</BaseName>
<Guid>AB248E8D-ABE1-11d4-BD0D-0080C73C8881</Guid>
<Version>0</Version>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>
<Created>2006-03-14 17:04</Created>
<Modified>2006-03-19 15:17</Modified>
</MbdHeader>
<Libraries>
<Library>UefiBootServicesTableLib</Library>
<Library>BaseLib</Library>
<Library>UefiLib</Library>
<Library>UefiMemoryLib</Library>
<Library>UefiDriverEntryPoint</Library>
<Library>UefiDriverModelLib</Library>
<Library>UefiDebugLibStdErr</Library>
<Library>BasePrintLib</Library>
<Library>DxeMemoryAllocationLib</Library>
</Libraries>
</ModuleBuildDescription>

View File

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MsaHeader>
<BaseName>WinNtUga</BaseName>
<ModuleType>UEFI_DRIVER</ModuleType>
<ComponentType>BS_DRIVER</ComponentType>
<Guid>AB248E8D-ABE1-11d4-BD0D-0080C73C8881</Guid>
<Version>0</Version>
<Abstract>Component description file for UGA module.</Abstract>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>0</Specification>
<Created>2006-03-14 17:04</Created>
<Updated>2006-03-19 15:17</Updated>
</MsaHeader>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverModelLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverEntryPoint</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">MemoryAllocationLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>WinNtUga.h</Filename>
<Filename>WinNtUgaInput.c</Filename>
<Filename>WinNtUgaDriver.c</Filename>
<Filename>WinNtUgaScreen.c</Filename>
<Filename>ComponentName.c</Filename>
</SourceFiles>
<Includes>
<PackageName>MdePkg</PackageName>
<PackageName>EdkModulePkg</PackageName>
<PackageName>EdkNt32Pkg</PackageName>
</Includes>
<Protocols>
<Protocol Usage="TO_START">WinNtIo</Protocol>
<Protocol Usage="BY_START">UgaDraw</Protocol>
<Protocol Usage="BY_START">SimpleTextIn</Protocol>
</Protocols>
<Events>
<CreateEvents>
<Event Usage="SOMETIMES_CONSUMED" EventGroup="EVENT_GROUP_EXIT_BOOT_SERVICES">
<C_Name>gEfiEventExitBootServicesGuid</C_Name>
<Guid>0x27abf055, 0xb1b8, 0x4c26, 0x80, 0x48, 0x74, 0x8f, 0x37, 0xba, 0xa2, 0xdf</Guid>
</Event>
</CreateEvents>
</Events>
<Guids>
<GuidEntry Usage="ALWAYS_CONSUMED">
<C_Name>WinNtUga</C_Name>
</GuidEntry>
</Guids>
<Externs>
<Extern>
<ModuleEntryPoint></ModuleEntryPoint>
</Extern>
<Extern>
<DriverBinding>gWinNtUgaDriverBinding</DriverBinding>
<ComponentName>gWinNtUgaComponentName</ComponentName>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@@ -0,0 +1,343 @@
/*++
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:
WinNtUgaDriver.c
Abstract:
This file implements the EFI 1.1 Device Driver model requirements for UGA
UGA is short hand for Universal Graphics Abstraction protocol.
This file is a verision of UgaIo 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.
--*/
#include "WinNtUga.h"
EFI_DRIVER_BINDING_PROTOCOL gWinNtUgaDriverBinding = {
WinNtUgaDriverBindingSupported,
WinNtUgaDriverBindingStart,
WinNtUgaDriverBindingStop,
0x10,
NULL,
NULL
};
EFI_STATUS
EFIAPI
WinNtUgaDriverBindingSupported (
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;
}
Status = WinNtUgaSupported (WinNtIo);
//
// Close the I/O Abstraction(s) used to perform the supported test
//
gBS->CloseProtocol (
Handle,
&gEfiWinNtIoProtocolGuid,
This->DriverBindingHandle,
Handle
);
return Status;
}
EFI_STATUS
EFIAPI
WinNtUgaDriverBindingStart (
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
// TODO: EFI_UNSUPPORTED - add return value to function comment
{
EFI_WIN_NT_IO_PROTOCOL *WinNtIo;
EFI_STATUS Status;
UGA_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;
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (UGA_PRIVATE_DATA),
&Private
);
if (EFI_ERROR (Status)) {
goto Done;
}
//
// Set up context record
//
Private->Signature = UGA_PRIVATE_DATA_SIGNATURE;
Private->Handle = Handle;
Private->WinNtThunk = WinNtIo->WinNtThunk;
Private->ControllerNameTable = NULL;
AddUnicodeString (
"eng",
gWinNtUgaComponentName.SupportedLanguages,
&Private->ControllerNameTable,
WinNtIo->EnvString
);
Private->WindowName = WinNtIo->EnvString;
Status = WinNtUgaConstructor (Private);
if (EFI_ERROR (Status)) {
goto Done;
}
//
// Publish the Uga interface to the world
//
Status = gBS->InstallMultipleProtocolInterfaces (
&Private->Handle,
&gEfiUgaDrawProtocolGuid,
&Private->UgaDraw,
&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);
}
gBS->FreePool (Private);
}
}
return Status;
}
EFI_STATUS
EFIAPI
WinNtUgaDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
)
/*++
Routine Description:
Arguments:
Returns:
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_UGA_DRAW_PROTOCOL *UgaDraw;
EFI_STATUS Status;
UGA_PRIVATE_DATA *Private;
Status = gBS->OpenProtocol (
Handle,
&gEfiUgaDrawProtocolGuid,
&UgaDraw,
This->DriverBindingHandle,
Handle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
//
// If the UGA interface does not exist the driver is not started
//
return EFI_NOT_STARTED;
}
//
// Get our private context information
//
Private = UGA_DRAW_PRIVATE_DATA_FROM_THIS (UgaDraw);
//
// Remove the SGO interface from the system
//
Status = gBS->UninstallMultipleProtocolInterfaces (
Private->Handle,
&gEfiUgaDrawProtocolGuid,
&Private->UgaDraw,
&gEfiSimpleTextInProtocolGuid,
&Private->SimpleTextIn,
NULL
);
if (!EFI_ERROR (Status)) {
//
// Shutdown the hardware
//
Status = WinNtUgaDestructor (Private);
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
gBS->CloseProtocol (
Handle,
&gEfiWinNtIoProtocolGuid,
This->DriverBindingHandle,
Handle
);
//
// Free our instance data
//
FreeUnicodeStringTable (Private->ControllerNameTable);
gBS->FreePool (Private);
}
return Status;
}
UINTN
Atoi (
CHAR16 *String
)
/*++
Routine Description:
Convert a unicode string to a UINTN
Arguments:
String - Unicode string.
Returns:
UINTN of the number represented by 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;
}

View File

@@ -0,0 +1,411 @@
/*++
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:
WinNtUgaInput.c
Abstract:
This file produces the Simple Text In for an Uga window.
This stuff is linked at the hip to the Window, since the window
processing is done in a thread kicked off in WinNtUgaImplementation.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.
--*/
#include "WinNtUga.h"
EFI_STATUS
UgaPrivateCreateQ (
IN UGA_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
EFI_SUCCESS - TODO: Add description for return value
--*/
{
Private->WinNtThunk->InitializeCriticalSection (&Private->QCriticalSection);
Private->Queue.Front = 0;
Private->Queue.Rear = MAX_Q - 1;
Private->Queue.Count = 0;
return EFI_SUCCESS;
}
EFI_STATUS
UgaPrivateDestroyQ (
IN UGA_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
EFI_SUCCESS - TODO: Add description for return value
--*/
{
Private->Queue.Count = 0;
Private->WinNtThunk->DeleteCriticalSection (&Private->QCriticalSection);
return EFI_SUCCESS;
}
EFI_STATUS
UgaPrivateAddQ (
IN UGA_PRIVATE_DATA *Private,
IN EFI_INPUT_KEY Key
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Key - TODO: add argument description
Returns:
EFI_NOT_READY - TODO: Add description for return value
EFI_SUCCESS - TODO: Add description for return value
--*/
{
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;
}
EFI_STATUS
UgaPrivateDeleteQ (
IN UGA_PRIVATE_DATA *Private,
OUT EFI_INPUT_KEY *Key
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Key - TODO: add argument description
Returns:
EFI_NOT_READY - TODO: Add description for return value
EFI_SUCCESS - TODO: Add description for return value
--*/
{
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;
}
EFI_STATUS
UgaPrivateCheckQ (
IN UGA_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
EFI_NOT_READY - TODO: Add description for return value
EFI_SUCCESS - TODO: Add description for return value
--*/
{
if (Private->Queue.Count == 0) {
return EFI_NOT_READY;
}
return EFI_SUCCESS;
}
//
// Simple Text In implementation.
//
EFI_STATUS
EFIAPI
WinNtUgaSimpleTextInReset (
IN EFI_SIMPLE_TEXT_IN_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
--*/
{
UGA_PRIVATE_DATA *Private;
EFI_INPUT_KEY Key;
EFI_TPL OldTpl;
Private = UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
//
// Enter critical section
//
OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY);
//
// A reset is draining the Queue
//
while (UgaPrivateDeleteQ (Private, &Key) == EFI_SUCCESS)
;
//
// Leave critical section and return
//
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
EFIAPI
WinNtUgaSimpleTextInReadKeyStroke (
IN EFI_SIMPLE_TEXT_IN_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
--*/
{
UGA_PRIVATE_DATA *Private;
EFI_STATUS Status;
EFI_TPL OldTpl;
Private = UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
//
// Enter critical section
//
OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY);
Status = UgaPrivateCheckQ (Private);
if (!EFI_ERROR (Status)) {
//
// If a Key press exists try and read it.
//
Status = UgaPrivateDeleteQ (Private, Key);
}
//
// Leave critical section and return
//
gBS->RestoreTPL (OldTpl);
return Status;
}
STATIC
VOID
EFIAPI
WinNtUgaSimpleTextInWaitForKey (
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
--*/
{
UGA_PRIVATE_DATA *Private;
EFI_STATUS Status;
EFI_TPL OldTpl;
Private = (UGA_PRIVATE_DATA *) Context;
//
// Enter critical section
//
OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY);
Status = UgaPrivateCheckQ (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);
}
EFI_STATUS
WinNtUgaInitializeSimpleTextInForWindow (
IN UGA_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
{
EFI_STATUS Status;
UgaPrivateCreateQ (Private);
//
// Initialize Simple Text In protoocol
//
Private->SimpleTextIn.Reset = WinNtUgaSimpleTextInReset;
Private->SimpleTextIn.ReadKeyStroke = WinNtUgaSimpleTextInReadKeyStroke;
Status = gBS->CreateEvent (
EFI_EVENT_NOTIFY_WAIT,
EFI_TPL_NOTIFY,
WinNtUgaSimpleTextInWaitForKey,
Private,
&Private->SimpleTextIn.WaitForKey
);
return Status;
}
EFI_STATUS
WinNtUgaDestroySimpleTextInForWindow (
IN UGA_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
EFI_SUCCESS - TODO: Add description for return value
--*/
{
UgaPrivateDestroyQ (Private);
return EFI_SUCCESS;
}

View File

@@ -0,0 +1,992 @@
/*++
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:
WinNtUgaScreen.c
Abstract:
This file produces the graphics abstration of UGA. It is called by
WinNtUgaDriver.c file which deals with the EFI 1.1 driver model.
This file just does graphics.
--*/
#include "WinNtUga.h"
EFI_WIN_NT_THUNK_PROTOCOL *mWinNt;
DWORD mTlsIndex = TLS_OUT_OF_INDEXES;
DWORD mTlsIndexUseCount = 0; // lets us know when we can free mTlsIndex.
static EFI_EVENT mUgaScreenExitBootServicesEvent;
EFI_STATUS
WinNtUgaStartWindow (
IN UGA_PRIVATE_DATA *Private,
IN UINT32 HorizontalResolution,
IN UINT32 VerticalResolution,
IN UINT32 ColorDepth,
IN UINT32 RefreshRate
);
STATIC
VOID
EFIAPI
KillNtUgaThread (
IN EFI_EVENT Event,
IN VOID *Context
);
//
// UGA Protocol Member Functions
//
EFI_STATUS
EFIAPI
WinNtUgaGetMode (
EFI_UGA_DRAW_PROTOCOL *This,
UINT32 *HorizontalResolution,
UINT32 *VerticalResolution,
UINT32 *ColorDepth,
UINT32 *RefreshRate
)
/*++
Routine Description:
Return the current video mode information.
Arguments:
This - Protocol instance pointer.
HorizontalResolution - Current video horizontal resolution in pixels
VerticalResolution - Current video Vertical resolution in pixels
ColorDepth - Current video color depth in bits per pixel
RefreshRate - Current video refresh rate in Hz.
Returns:
EFI_SUCCESS - Mode information returned.
EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()
EFI_INVALID_PARAMETER - One of the input args was NULL.
--*/
// TODO: ADD IN/OUT description here
{
UGA_PRIVATE_DATA *Private;
Private = UGA_DRAW_PRIVATE_DATA_FROM_THIS (This);
if (Private->HardwareNeedsStarting) {
return EFI_NOT_STARTED;
}
if ((HorizontalResolution == NULL) ||
(VerticalResolution == NULL) ||
(ColorDepth == NULL) ||
(RefreshRate == NULL)) {
return EFI_INVALID_PARAMETER;
}
*HorizontalResolution = Private->HorizontalResolution;
*VerticalResolution = Private->VerticalResolution;
*ColorDepth = Private->ColorDepth;
*RefreshRate = Private->RefreshRate;
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
WinNtUgaSetMode (
EFI_UGA_DRAW_PROTOCOL *This,
UINT32 HorizontalResolution,
UINT32 VerticalResolution,
UINT32 ColorDepth,
UINT32 RefreshRate
)
/*++
Routine Description:
Return the current video mode information.
Arguments:
This - Protocol instance pointer.
HorizontalResolution - Current video horizontal resolution in pixels
VerticalResolution - Current video Vertical resolution in pixels
ColorDepth - Current video color depth in bits per pixel
RefreshRate - Current video refresh rate in Hz.
Returns:
EFI_SUCCESS - Mode information returned.
EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()
EFI_INVALID_PARAMETER - One of the input args was NULL.
--*/
// TODO: EFI_DEVICE_ERROR - add return value to function comment
// TODO: EFI_DEVICE_ERROR - add return value to function comment
// TODO: ADD IN/OUT description here
{
EFI_STATUS Status;
UGA_PRIVATE_DATA *Private;
EFI_UGA_PIXEL Fill;
EFI_UGA_PIXEL *NewFillLine;
RECT Rect;
UINTN Size;
UINTN Width;
UINTN Height;
Private = UGA_DRAW_PRIVATE_DATA_FROM_THIS (This);
if (Private->HardwareNeedsStarting) {
Status = WinNtUgaStartWindow (
Private,
HorizontalResolution,
VerticalResolution,
ColorDepth,
RefreshRate
);
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
Private->HardwareNeedsStarting = FALSE;
} else {
//
// Change the resolution and resize of the window
//
//
// Free the old buffer. We do not save the content of the old buffer since the
// screen is to be cleared anyway. Clearing the screen is required by the EFI spec.
// See EFI spec chepter 10.5-EFI_UGA_DRAW_PROTOCOL.SetMode()
//
Private->WinNtThunk->HeapFree (Private->WinNtThunk->GetProcessHeap (), 0, Private->VirtualScreenInfo);
//
// Allocate DIB frame buffer directly from NT for performance enhancement
// This buffer is the virtual screen/frame buffer. This buffer is not the
// same a a frame buffer. The first row of this buffer will be the bottom
// line of the image. This is an artifact of the way we draw to the screen.
//
Size = HorizontalResolution * VerticalResolution * sizeof (RGBQUAD) + sizeof (BITMAPV4HEADER);
Private->VirtualScreenInfo = Private->WinNtThunk->HeapAlloc (
Private->WinNtThunk->GetProcessHeap (),
HEAP_ZERO_MEMORY,
Size
);
//
// Update the virtual screen info data structure
//
Private->VirtualScreenInfo->bV4Size = sizeof (BITMAPV4HEADER);
Private->VirtualScreenInfo->bV4Width = HorizontalResolution;
Private->VirtualScreenInfo->bV4Height = VerticalResolution;
Private->VirtualScreenInfo->bV4Planes = 1;
Private->VirtualScreenInfo->bV4BitCount = 32;
//
// uncompressed
//
Private->VirtualScreenInfo->bV4V4Compression = BI_RGB;
//
// The rest of the allocated memory block is the virtual screen buffer
//
Private->VirtualScreen = (RGBQUAD *) (Private->VirtualScreenInfo + 1);
//
// Use the AdjuctWindowRect fuction to calculate the real width and height
// of the new window including the border and caption
//
Rect.left = 0;
Rect.top = 0;
Rect.right = HorizontalResolution;
Rect.bottom = VerticalResolution;
Private->WinNtThunk->AdjustWindowRect (&Rect, WS_OVERLAPPEDWINDOW, 0);
Width = Rect.right - Rect.left;
Height = Rect.bottom - Rect.top;
//
// Retrieve the original window position information
//
Private->WinNtThunk->GetWindowRect (Private->WindowHandle, &Rect);
//
// Adjust the window size
//
Private->WinNtThunk->MoveWindow (Private->WindowHandle, Rect.left, Rect.top, Width, Height, TRUE);
}
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (EFI_UGA_PIXEL) * HorizontalResolution,
&NewFillLine
);
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
if (Private->FillLine != NULL) {
gBS->FreePool (Private->FillLine);
}
Private->FillLine = NewFillLine;
Private->HorizontalResolution = HorizontalResolution;
Private->VerticalResolution = VerticalResolution;
Private->ColorDepth = ColorDepth;
Private->RefreshRate = RefreshRate;
Fill.Red = 0x00;
Fill.Green = 0x00;
Fill.Blue = 0x00;
This->Blt (
This,
&Fill,
EfiUgaVideoFill,
0,
0,
0,
0,
HorizontalResolution,
VerticalResolution,
HorizontalResolution * sizeof (EFI_UGA_PIXEL)
);
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
WinNtUgaBlt (
IN EFI_UGA_DRAW_PROTOCOL *This,
IN EFI_UGA_PIXEL *BltBuffer, OPTIONAL
IN EFI_UGA_BLT_OPERATION BltOperation,
IN UINTN SourceX,
IN UINTN SourceY,
IN UINTN DestinationX,
IN UINTN DestinationY,
IN UINTN Width,
IN UINTN Height,
IN UINTN Delta OPTIONAL
)
/*++
Routine Description:
Blt pixels from the rectangle (Width X Height) formed by the BltBuffer
onto the graphics screen starting a location (X, Y). (0, 0) is defined as
the upper left hand side of the screen. (X, Y) can be outside of the
current screen geometry and the BltBuffer will be cliped when it is
displayed. X and Y can be negative or positive. If Width or Height is
bigger than the current video screen the image will be clipped.
Arguments:
This - Protocol instance pointer.
X - X location on graphics screen.
Y - Y location on the graphics screen.
Width - Width of BltBuffer.
Height - Hight of BltBuffer
BltOperation - Operation to perform on BltBuffer and video memory
BltBuffer - Buffer containing data to blt into video buffer. This
buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL)
SourceX - If the BltOperation is a EfiCopyBlt this is the source
of the copy. For other BLT operations this argument is not
used.
SourceX - If the BltOperation is a EfiCopyBlt this is the source
of the copy. For other BLT operations this argument is not
used.
Returns:
EFI_SUCCESS - The palette is updated with PaletteArray.
EFI_INVALID_PARAMETER - BltOperation is not valid.
EFI_DEVICE_ERROR - A hardware error occured writting to the video
buffer.
--*/
// TODO: SourceY - add argument and description to function comment
// TODO: DestinationX - add argument and description to function comment
// TODO: DestinationY - add argument and description to function comment
// TODO: Delta - add argument and description to function comment
{
UGA_PRIVATE_DATA *Private;
EFI_TPL OriginalTPL;
UINTN DstY;
UINTN SrcY;
RGBQUAD *VScreen;
RGBQUAD *VScreenSrc;
EFI_UGA_PIXEL *Blt;
UINTN Index;
RECT Rect;
EFI_UGA_PIXEL *FillPixel;
Private = UGA_DRAW_PRIVATE_DATA_FROM_THIS (This);
if ((BltOperation < 0) || (BltOperation >= EfiUgaBltMax)) {
return EFI_INVALID_PARAMETER;
}
if (Width == 0 || Height == 0) {
return EFI_INVALID_PARAMETER;
}
//
// If Delta is zero, then the entire BltBuffer is being used, so Delta
// is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,
// the number of bytes in each row can be computed.
//
if (Delta == 0) {
Delta = Width * sizeof (EFI_UGA_PIXEL);
}
//
// We need to fill the Virtual Screen buffer with the blt data.
// The virtual screen is upside down, as the first row is the bootom row of
// the image.
//
if (BltOperation == EfiUgaVideoToBltBuffer) {
//
// Video to BltBuffer: Source is Video, destination is BltBuffer
//
if (SourceY + Height > Private->VerticalResolution) {
return EFI_INVALID_PARAMETER;
}
if (SourceX + Width > Private->HorizontalResolution) {
return EFI_INVALID_PARAMETER;
}
//
// We have to raise to TPL Notify, so we make an atomic write the frame buffer.
// We would not want a timer based event (Cursor, ...) to come in while we are
// doing this operation.
//
OriginalTPL = gBS->RaiseTPL (EFI_TPL_NOTIFY);
for (SrcY = SourceY, DstY = DestinationY; DstY < (Height + DestinationY); SrcY++, DstY++) {
Blt = (EFI_UGA_PIXEL *) ((UINT8 *) BltBuffer + (DstY * Delta) + DestinationX * sizeof (EFI_UGA_PIXEL));
VScreen = &Private->VirtualScreen[(Private->VerticalResolution - SrcY - 1) * Private->HorizontalResolution + SourceX];
CopyMem (Blt, VScreen, sizeof (EFI_UGA_PIXEL) * Width);
}
} else {
//
// BltBuffer to Video: Source is BltBuffer, destination is Video
//
if (DestinationY + Height > Private->VerticalResolution) {
return EFI_INVALID_PARAMETER;
}
if (DestinationX + Width > Private->HorizontalResolution) {
return EFI_INVALID_PARAMETER;
}
//
// We have to raise to TPL Notify, so we make an atomic write the frame buffer.
// We would not want a timer based event (Cursor, ...) to come in while we are
// doing this operation.
//
OriginalTPL = gBS->RaiseTPL (EFI_TPL_NOTIFY);
if (BltOperation == EfiUgaVideoFill) {
FillPixel = BltBuffer;
for (Index = 0; Index < Width; Index++) {
Private->FillLine[Index] = *FillPixel;
}
}
for (Index = 0; Index < Height; Index++) {
if (DestinationY <= SourceY) {
SrcY = SourceY + Index;
DstY = DestinationY + Index;
} else {
SrcY = SourceY + Height - Index - 1;
DstY = DestinationY + Height - Index - 1;
}
VScreen = &Private->VirtualScreen[(Private->VerticalResolution - DstY - 1) * Private->HorizontalResolution + DestinationX];
switch (BltOperation) {
case EfiUgaBltBufferToVideo:
Blt = (EFI_UGA_PIXEL *) ((UINT8 *) BltBuffer + (SrcY * Delta) + SourceX * sizeof (EFI_UGA_PIXEL));
CopyMem (VScreen, Blt, Width * sizeof (EFI_UGA_PIXEL));
break;
case EfiUgaVideoToVideo:
VScreenSrc = &Private->VirtualScreen[(Private->VerticalResolution - SrcY - 1) * Private->HorizontalResolution + SourceX];
CopyMem (VScreen, VScreenSrc, Width * sizeof (EFI_UGA_PIXEL));
break;
case EfiUgaVideoFill:
CopyMem (VScreen, Private->FillLine, Width * sizeof (EFI_UGA_PIXEL));
break;
}
}
}
if (BltOperation != EfiUgaVideoToBltBuffer) {
//
// Mark the area we just blted as Invalid so WM_PAINT will update.
//
Rect.left = DestinationX;
Rect.top = DestinationY;
Rect.right = DestinationX + Width;
Rect.bottom = DestinationY + Height;
Private->WinNtThunk->InvalidateRect (Private->WindowHandle, &Rect, FALSE);
//
// Send the WM_PAINT message to the thread that is drawing the window. We
// are in the main thread and the window drawing is in a child thread.
// There is a child thread per window. We have no CriticalSection or Mutex
// since we write the data and the other thread displays the data. While
// we may miss some data for a short period of time this is no different than
// a write combining on writes to a frame buffer.
//
Private->WinNtThunk->UpdateWindow (Private->WindowHandle);
}
gBS->RestoreTPL (OriginalTPL);
return EFI_SUCCESS;
}
//
// Construction and Destruction functions
//
EFI_STATUS
WinNtUgaSupported (
IN EFI_WIN_NT_IO_PROTOCOL *WinNtIo
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
// TODO: WinNtIo - add argument and description to function comment
// TODO: EFI_UNSUPPORTED - add return value to function comment
// TODO: EFI_SUCCESS - add return value to function comment
{
//
// Check to see if the IO abstraction represents a device type we support.
//
// This would be replaced a check of PCI subsystem ID, etc.
//
if (!CompareGuid (WinNtIo->TypeGuid, &gEfiWinNtUgaGuid)) {
return EFI_UNSUPPORTED;
}
return EFI_SUCCESS;
}
LRESULT
CALLBACK
WinNtUgaThreadWindowProc (
IN HWND hwnd,
IN UINT iMsg,
IN WPARAM wParam,
IN LPARAM lParam
)
/*++
Routine Description:
Win32 Windows event handler.
Arguments:
See Win32 Book
Returns:
See Win32 Book
--*/
// TODO: hwnd - add argument and description to function comment
// TODO: iMsg - add argument and description to function comment
// TODO: wParam - add argument and description to function comment
// TODO: lParam - add argument and description to function comment
{
UGA_PRIVATE_DATA *Private;
UINTN Size;
HDC Handle;
PAINTSTRUCT PaintStruct;
LPARAM Index;
EFI_INPUT_KEY Key;
//
// BugBug - if there are two instances of this DLL in memory (such as is
// the case for ERM), the correct instance of this function may not be called.
// This also means that the address of the mTlsIndex value will be wrong, and
// the value may be wrong too.
//
//
// Use mTlsIndex global to get a Thread Local Storage version of Private.
// This works since each Uga protocol has a unique Private data instance and
// a unique thread.
//
Private = mWinNt->TlsGetValue (mTlsIndex);
ASSERT (NULL != Private);
switch (iMsg) {
case WM_CREATE:
Size = Private->HorizontalResolution * Private->VerticalResolution * sizeof (RGBQUAD);
//
// Allocate DIB frame buffer directly from NT for performance enhancement
// This buffer is the virtual screen/frame buffer. This buffer is not the
// same a a frame buffer. The first fow of this buffer will be the bottom
// line of the image. This is an artifact of the way we draw to the screen.
//
Private->VirtualScreenInfo = Private->WinNtThunk->HeapAlloc (
Private->WinNtThunk->GetProcessHeap (),
HEAP_ZERO_MEMORY,
Size
);
Private->VirtualScreenInfo->bV4Size = sizeof (BITMAPV4HEADER);
Private->VirtualScreenInfo->bV4Width = Private->HorizontalResolution;
Private->VirtualScreenInfo->bV4Height = Private->VerticalResolution;
Private->VirtualScreenInfo->bV4Planes = 1;
Private->VirtualScreenInfo->bV4BitCount = 32;
//
// uncompressed
//
Private->VirtualScreenInfo->bV4V4Compression = BI_RGB;
Private->VirtualScreen = (RGBQUAD *) (Private->VirtualScreenInfo + 1);
return 0;
case WM_PAINT:
//
// I have not found a way to convert hwnd into a Private context. So for
// now we use this API to convert hwnd to Private data.
//
Handle = mWinNt->BeginPaint (hwnd, &PaintStruct);
mWinNt->SetDIBitsToDevice (
Handle, // Destination Device Context
0, // Destination X - 0
0, // Destination Y - 0
Private->HorizontalResolution, // Width
Private->VerticalResolution, // Height
0, // Source X
0, // Source Y
0, // DIB Start Scan Line
Private->VerticalResolution, // Number of scan lines
Private->VirtualScreen, // Address of array of DIB bits
(BITMAPINFO *) Private->VirtualScreenInfo, // Address of structure with bitmap info
DIB_RGB_COLORS // RGB or palette indexes
);
mWinNt->EndPaint (hwnd, &PaintStruct);
return 0;
//
// F10 and the ALT key do not create a WM_KEYDOWN message, thus this special case
//
case WM_SYSKEYDOWN:
Key.ScanCode = 0;
switch (wParam) {
case VK_F10:
Key.ScanCode = SCAN_F10;
Key.UnicodeChar = 0;
UgaPrivateAddQ (Private, Key);
return 0;
}
break;
case WM_KEYDOWN:
Key.ScanCode = 0;
switch (wParam) {
case VK_HOME: Key.ScanCode = SCAN_HOME; break;
case VK_END: Key.ScanCode = SCAN_END; break;
case VK_LEFT: Key.ScanCode = SCAN_LEFT; break;
case VK_RIGHT: Key.ScanCode = SCAN_RIGHT; break;
case VK_UP: Key.ScanCode = SCAN_UP; break;
case VK_DOWN: Key.ScanCode = SCAN_DOWN; break;
case VK_DELETE: Key.ScanCode = SCAN_DELETE; break;
case VK_INSERT: Key.ScanCode = SCAN_INSERT; break;
case VK_PRIOR: Key.ScanCode = SCAN_PAGE_UP; break;
case VK_NEXT: Key.ScanCode = SCAN_PAGE_DOWN; break;
case VK_ESCAPE: Key.ScanCode = SCAN_ESC; break;
case VK_F1: Key.ScanCode = SCAN_F1; break;
case VK_F2: Key.ScanCode = SCAN_F2; break;
case VK_F3: Key.ScanCode = SCAN_F3; break;
case VK_F4: Key.ScanCode = SCAN_F4; break;
case VK_F5: Key.ScanCode = SCAN_F5; break;
case VK_F6: Key.ScanCode = SCAN_F6; break;
case VK_F7: Key.ScanCode = SCAN_F7; break;
case VK_F8: Key.ScanCode = SCAN_F8; break;
case VK_F9: Key.ScanCode = SCAN_F9; break;
}
if (Key.ScanCode != 0) {
Key.UnicodeChar = 0;
UgaPrivateAddQ (Private, Key);
}
return 0;
case WM_CHAR:
//
// The ESC key also generate WM_CHAR.
//
if (wParam == 0x1B) {
return 0;
}
for (Index = 0; Index < (lParam & 0xffff); Index++) {
if (wParam != 0) {
Key.UnicodeChar = (CHAR16) wParam;
Key.ScanCode = 0;
UgaPrivateAddQ (Private, Key);
}
}
return 0;
case WM_CLOSE:
//
// This close message is issued by user, core is not aware of this,
// so don't release the window display resource, just hide the window.
//
Private->WinNtThunk->ShowWindow (Private->WindowHandle, SW_HIDE);
return 0;
case WM_DESTROY:
mWinNt->DestroyWindow (hwnd);
mWinNt->PostQuitMessage (0);
mWinNt->HeapFree (Private->WinNtThunk->GetProcessHeap (), 0, Private->VirtualScreenInfo);
mWinNt->ExitThread (0);
return 0;
default:
break;
};
return mWinNt->DefWindowProc (hwnd, iMsg, wParam, lParam);
}
DWORD
WINAPI
WinNtUgaThreadWinMain (
LPVOID lpParameter
)
/*++
Routine Description:
This thread simulates the end of WinMain () aplication. Each Winow nededs
to process it's events. The messages are dispatched to
WinNtUgaThreadWindowProc ().
Be very careful sine WinNtUgaThreadWinMain () and WinNtUgaThreadWindowProc ()
are running in a seperate thread. We have to do this to process the events.
Arguments:
lpParameter - Handle of window to manage.
Returns:
if a WM_QUIT message is returned exit.
--*/
{
MSG Message;
UGA_PRIVATE_DATA *Private;
ATOM Atom;
RECT Rect;
Private = (UGA_PRIVATE_DATA *) lpParameter;
ASSERT (NULL != Private);
//
// Since each thread has unique private data, save the private data in Thread
// Local Storage slot. Then the shared global mTlsIndex can be used to get
// thread specific context.
//
Private->WinNtThunk->TlsSetValue (mTlsIndex, Private);
Private->ThreadId = Private->WinNtThunk->GetCurrentThreadId ();
Private->WindowsClass.cbSize = sizeof (WNDCLASSEX);
Private->WindowsClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
Private->WindowsClass.lpfnWndProc = WinNtUgaThreadWindowProc;
Private->WindowsClass.cbClsExtra = 0;
Private->WindowsClass.cbWndExtra = 0;
Private->WindowsClass.hInstance = NULL;
Private->WindowsClass.hIcon = Private->WinNtThunk->LoadIcon (NULL, IDI_APPLICATION);
Private->WindowsClass.hCursor = Private->WinNtThunk->LoadCursor (NULL, IDC_ARROW);
Private->WindowsClass.hbrBackground = (HBRUSH) COLOR_WINDOW;
Private->WindowsClass.lpszMenuName = NULL;
Private->WindowsClass.lpszClassName = WIN_NT_UGA_CLASS_NAME;
Private->WindowsClass.hIconSm = Private->WinNtThunk->LoadIcon (NULL, IDI_APPLICATION);
//
// This call will fail after the first time, but thats O.K. since we only need
// WIN_NT_UGA_CLASS_NAME to exist to create the window.
//
// Note: Multiple instances of this DLL will use the same instance of this
// Class, including the callback function, unless the Class is unregistered and
// successfully registered again.
//
Atom = Private->WinNtThunk->RegisterClassEx (&Private->WindowsClass);
//
// Setting Rect values to allow for the AdjustWindowRect to provide
// us the correct sizes for the client area when doing the CreateWindowEx
//
Rect.top = 0;
Rect.bottom = Private->VerticalResolution;
Rect.left = 0;
Rect.right = Private->HorizontalResolution;
Private->WinNtThunk->AdjustWindowRect (&Rect, WS_OVERLAPPEDWINDOW, 0);
Private->WindowHandle = Private->WinNtThunk->CreateWindowEx (
0,
WIN_NT_UGA_CLASS_NAME,
Private->WindowName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
Rect.right - Rect.left,
Rect.bottom - Rect.top,
NULL,
NULL,
NULL,
&Private
);
//
// The reset of this thread is the standard winows program. We need a sperate
// thread since we must process the message loop to make windows act like
// windows.
//
Private->WinNtThunk->ShowWindow (Private->WindowHandle, SW_SHOW);
Private->WinNtThunk->UpdateWindow (Private->WindowHandle);
//
// Let the main thread get some work done
//
Private->WinNtThunk->ReleaseSemaphore (Private->ThreadInited, 1, NULL);
//
// This is the message loop that all Windows programs need.
//
while (Private->WinNtThunk->GetMessage (&Message, Private->WindowHandle, 0, 0)) {
Private->WinNtThunk->TranslateMessage (&Message);
Private->WinNtThunk->DispatchMessage (&Message);
}
return Message.wParam;
}
EFI_STATUS
WinNtUgaStartWindow (
IN UGA_PRIVATE_DATA *Private,
IN UINT32 HorizontalResolution,
IN UINT32 VerticalResolution,
IN UINT32 ColorDepth,
IN UINT32 RefreshRate
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
HorizontalResolution - TODO: add argument description
VerticalResolution - TODO: add argument description
ColorDepth - TODO: add argument description
RefreshRate - TODO: add argument description
Returns:
TODO: add return values
--*/
{
EFI_STATUS Status;
DWORD NewThreadId;
mWinNt = Private->WinNtThunk;
//
// Initialize a Thread Local Storge variable slot. We use TLS to get the
// correct Private data instance into the windows thread.
//
if (mTlsIndex == TLS_OUT_OF_INDEXES) {
ASSERT (0 == mTlsIndexUseCount);
mTlsIndex = Private->WinNtThunk->TlsAlloc ();
}
//
// always increase the use count!
//
mTlsIndexUseCount++;
Private->HorizontalResolution = HorizontalResolution;
Private->VerticalResolution = VerticalResolution;
//
// Register to be notified on exit boot services so we can destroy the window.
//
Status = gBS->CreateEvent (
EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,
EFI_TPL_CALLBACK,
KillNtUgaThread,
Private,
&mUgaScreenExitBootServicesEvent
);
Private->ThreadInited = Private->WinNtThunk->CreateSemaphore (NULL, 0, 1, NULL);
Private->ThreadHandle = Private->WinNtThunk->CreateThread (
NULL,
0,
WinNtUgaThreadWinMain,
(VOID *) Private,
0,
&NewThreadId
);
//
// The other thread has entered the windows message loop so we can
// continue our initialization.
//
Private->WinNtThunk->WaitForSingleObject (Private->ThreadInited, INFINITE);
Private->WinNtThunk->CloseHandle (Private->ThreadInited);
return Status;
}
EFI_STATUS
WinNtUgaConstructor (
UGA_PRIVATE_DATA *Private
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
// TODO: Private - add argument and description to function comment
// TODO: EFI_SUCCESS - add return value to function comment
{
Private->UgaDraw.GetMode = WinNtUgaGetMode;
Private->UgaDraw.SetMode = WinNtUgaSetMode;
Private->UgaDraw.Blt = WinNtUgaBlt;
Private->HardwareNeedsStarting = TRUE;
Private->FillLine = NULL;
WinNtUgaInitializeSimpleTextInForWindow (Private);
return EFI_SUCCESS;
}
EFI_STATUS
WinNtUgaDestructor (
UGA_PRIVATE_DATA *Private
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
// TODO: Private - add argument and description to function comment
// TODO: EFI_SUCCESS - add return value to function comment
{
UINT32 UnregisterReturn;
if (!Private->HardwareNeedsStarting) {
//
// BugBug: Shutdown Uga Hardware and any child devices.
//
Private->WinNtThunk->SendMessage (Private->WindowHandle, WM_DESTROY, 0, 0);
Private->WinNtThunk->CloseHandle (Private->ThreadHandle);
mTlsIndexUseCount--;
//
// The callback function for another window could still be called,
// so we need to make sure there are no more users of mTlsIndex.
//
if (0 == mTlsIndexUseCount) {
ASSERT (TLS_OUT_OF_INDEXES != mTlsIndex);
Private->WinNtThunk->TlsFree (mTlsIndex);
mTlsIndex = TLS_OUT_OF_INDEXES;
UnregisterReturn = Private->WinNtThunk->UnregisterClass (
Private->WindowsClass.lpszClassName,
Private->WindowsClass.hInstance
);
}
WinNtUgaDestroySimpleTextInForWindow (Private);
}
return EFI_SUCCESS;
}
STATIC
VOID
EFIAPI
KillNtUgaThread (
IN EFI_EVENT Event,
IN VOID *Context
)
/*++
Routine Description:
This is the UGA screen's callback notification function for exit-boot-services.
All we do here is call WinNtUgaDestructor().
Arguments:
Event - not used
Context - pointer to the Private structure.
Returns:
None.
--*/
{
EFI_STATUS Status;
Status = WinNtUgaDestructor (Context);
}

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
<project basedir="." default="WinNtUga"><!--Apply external ANT tasks-->
<taskdef resource="GenBuild.tasks"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property environment="env"/>
<property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
<import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
<property name="MODULE_RELATIVE_PATH" value="Dxe\WinNtThunk\Bus\Uga"/>
<property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
<property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
<target name="WinNtUga">
<GenBuild baseName="WinNtUga" mbdFilename="${MODULE_DIR}\WinNtUga.mbd" msaFilename="${MODULE_DIR}\WinNtUga.msa"/>
</target>
<target depends="WinNtUga_clean" name="clean"/>
<target depends="WinNtUga_cleanall" name="cleanall"/>
<target name="WinNtUga_clean">
<OutputDirSetup baseName="WinNtUga" mbdFilename="${MODULE_DIR}\WinNtUga.mbd" msaFilename="${MODULE_DIR}\WinNtUga.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\WinNtUga_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\WinNtUga_build.xml" target="clean"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
</target>
<target name="WinNtUga_cleanall">
<OutputDirSetup baseName="WinNtUga" mbdFilename="${MODULE_DIR}\WinNtUga.mbd" msaFilename="${MODULE_DIR}\WinNtUga.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\WinNtUga_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\WinNtUga_build.xml" target="cleanall"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}"/>
<delete dir="${DEST_DIR_DEBUG}"/>
<delete>
<fileset dir="${BIN_DIR}" includes="**WinNtUga*"/>
</delete>
</target>
</project>

View File

@@ -0,0 +1,187 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
ComponentName.c
Abstract:
--*/
#include "WinNtBusDriver.h"
//
// EFI Component Name Functions
//
EFI_STATUS
EFIAPI
WinNtBusDriverComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
);
EFI_STATUS
EFIAPI
WinNtBusDriverComponentNameGetControllerName (
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 gWinNtBusDriverComponentName = {
WinNtBusDriverComponentNameGetDriverName,
WinNtBusDriverComponentNameGetControllerName,
"eng"
};
static EFI_UNICODE_STRING_TABLE mWinNtBusDriverNameTable[] = {
{ "eng", L"Windows Bus Driver" },
{ NULL , NULL }
};
EFI_STATUS
EFIAPI
WinNtBusDriverComponentNameGetDriverName (
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,
gWinNtBusDriverComponentName.SupportedLanguages,
mWinNtBusDriverNameTable,
DriverName
);
}
EFI_STATUS
EFIAPI
WinNtBusDriverComponentNameGetControllerName (
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_WIN_NT_IO_PROTOCOL *WinNtIo;
WIN_NT_IO_DEVICE *Private;
//
// This is a bus driver, so ChildHandle can not be NULL.
//
if (ChildHandle == NULL) {
return EFI_UNSUPPORTED;
}
//
// Get our context back
//
Status = gBS->OpenProtocol (
ChildHandle,
&gEfiWinNtIoProtocolGuid,
&WinNtIo,
gWinNtBusDriverBinding.DriverBindingHandle,
ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
Private = WIN_NT_IO_DEVICE_FROM_THIS (WinNtIo);
return LookupUnicodeString (
Language,
gWinNtBusDriverComponentName.SupportedLanguages,
Private->ControllerNameTable,
ControllerName
);
}

View File

@@ -0,0 +1,744 @@
/*+++
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:
WinNtBusDriver.c
Abstract:
This following section documents the envirnoment variables for the Win NT
build. These variables are used to define the (virtual) hardware
configuration of the NT environment
A ! can be used to seperate multiple instances in a variable. Each
instance represents a seperate hardware device.
EFI_WIN_NT_PHYSICAL_DISKS - maps to drives on your system
EFI_WIN_NT_VIRTUAL_DISKS - maps to a device emulated by a file
EFI_WIN_NT_FILE_SYSTEM - mouts a directory as a file system
EFI_WIN_NT_CONSOLE - make a logical comand line window (only one!)
EFI_WIN_NT_UGA - Builds UGA Windows of Width and Height
EFI_WIN_NT_SERIAL_PORT - maps physical serial ports
<F>ixed - Fixed disk like a hard drive.
<R>emovable - Removable media like a floppy or CD-ROM.
Read <O>nly - Write protected device.
Read <W>rite - Read write device.
<block count> - Decimal number of blocks a device supports.
<block size> - Decimal number of bytes per block.
NT envirnonment variable contents. '<' and '>' are not part of the variable,
they are just used to make this help more readable. There should be no
spaces between the ';'. Extra spaces will break the variable. A '!' is
used to seperate multiple devices in a variable.
EFI_WIN_NT_VIRTUAL_DISKS =
<F | R><O | W>;<block count>;<block size>[!...]
EFI_WIN_NT_PHYSICAL_DISKS =
<drive letter>:<F | R><O | W>;<block count>;<block size>[!...]
Virtual Disks: These devices use a file to emulate a hard disk or removable
media device.
Thus a 20 MB emulated hard drive would look like:
EFI_WIN_NT_VIRTUAL_DISKS=FW;40960;512
A 1.44MB emulated floppy with a block size of 1024 would look like:
EFI_WIN_NT_VIRTUAL_DISKS=RW;1440;1024
Physical Disks: These devices use NT to open a real device in your system
Thus a 120 MB floppy would look like:
EFI_WIN_NT_PHYSICAL_DISKS=B:RW;245760;512
Thus a standard CD-ROM floppy would look like:
EFI_WIN_NT_PHYSICAL_DISKS=Z:RO;307200;2048
EFI_WIN_NT_FILE_SYSTEM =
<directory path>[!...]
Mounting the two directories C:\FOO and C:\BAR would look like:
EFI_WIN_NT_FILE_SYSTEM=c:\foo!c:\bar
EFI_WIN_NT_CONSOLE =
<window title>
Declaring a text console window with the title "My EFI Console" woild look like:
EFI_WIN_NT_CONSOLE=My EFI Console
EFI_WIN_NT_UGA =
<width> <height>[!...]
Declaring a two UGA windows with resolutions of 800x600 and 1024x768 would look like:
Example : EFI_WIN_NT_UGA=800 600!1024 768
EFI_WIN_NT_SERIAL_PORT =
<port name>[!...]
Declaring two serial ports on COM1 and COM2 would look like:
Example : EFI_WIN_NT_SERIAL_PORT=COM1!COM2
EFI_WIN_NT_PASS_THROUGH =
<BaseAddress>;<Bus#>;<Device#>;<Function#>
Declaring a base address of 0xE0000000 (used for PCI Express devices)
and having NT32 talk to a device located at bus 0, device 1, function 0:
Example : EFI_WIN_NT_PASS_THROUGH=E000000;0;1;0
---*/
#include "WinNtBusDriver.h"
//#include "PciHostBridge.h"
//
// Define GUID for the WinNt Bus Driver
//
static EFI_GUID gWinNtBusDriverGuid = {
0x419f582, 0x625, 0x4531, 0x8a, 0x33, 0x85, 0xa9, 0x96, 0x5c, 0x95, 0xbc
};
//
// DriverBinding protocol global
//
EFI_DRIVER_BINDING_PROTOCOL gWinNtBusDriverBinding = {
WinNtBusDriverBindingSupported,
WinNtBusDriverBindingStart,
WinNtBusDriverBindingStop,
0x10,
NULL,
NULL
};
#define NT_PCD_ARRAY_SIZE (sizeof(mPcdEnvironment)/sizeof(NT_PCD_ENTRY))
//
// Table to map NT Environment variable to the GUID that should be in
// device path.
//
static NT_PCD_ENTRY mPcdEnvironment[] = {
PcdToken(PcdWinNtConsole), &gEfiWinNtConsoleGuid,
PcdToken(PcdWinNtUga), &gEfiWinNtUgaGuid,
PcdToken(PcdWinNtSerialPort), &gEfiWinNtSerialPortGuid,
PcdToken(PcdWinNtFileSystem), &gEfiWinNtFileSystemGuid,
PcdToken(PcdWinNtVirtualDisk), &gEfiWinNtVirtualDisksGuid,
PcdToken(PcdWinNtPhysicalDisk), &gEfiWinNtPhysicalDisksGuid,
PcdToken(PcdWinNtCpuModel), &gEfiWinNtCPUModelGuid,
PcdToken(PcdWinNtCpuSpeed), &gEfiWinNtCPUSpeedGuid,
PcdToken(PcdWinNtMemorySize), &gEfiWinNtMemoryGuid
};
VOID *
AllocateMemory (
IN UINTN Size
)
{
EFI_STATUS Status;
VOID *Buffer;
Status = gBS->AllocatePool (
EfiBootServicesData,
Size,
(VOID *)&Buffer
);
if (EFI_ERROR (Status)) {
ASSERT (FALSE);
return NULL;
}
return Buffer;
}
EFI_STATUS
EFIAPI
WinNtBusDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
// TODO: This - add argument and description to function comment
// TODO: ControllerHandle - 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
// TODO: EFI_UNSUPPORTED - add return value to function comment
// TODO: EFI_SUCCESS - add return value to function comment
// TODO: EFI_SUCCESS - add return value to function comment
{
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;
UINTN Index;
//
// Check the contents of the first Device Path Node of RemainingDevicePath to make sure
// it is a legal Device Path Node for this bus driver's children.
//
if (RemainingDevicePath != NULL) {
if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||
RemainingDevicePath->SubType != HW_VENDOR_DP ||
DevicePathNodeLength(RemainingDevicePath) != sizeof(WIN_NT_VENDOR_DEVICE_PATH_NODE)) {
return EFI_UNSUPPORTED;
}
for (Index = 0; Index < NT_PCD_ARRAY_SIZE; Index++) {
if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) {
break;
}
}
if (Index >= NT_PCD_ARRAY_SIZE) {
return EFI_UNSUPPORTED;
}
}
//
// Open the IO Abstraction(s) needed to perform the supported test
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
&ParentDevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (Status == EFI_ALREADY_STARTED) {
return EFI_SUCCESS;
}
if (EFI_ERROR (Status)) {
return Status;
}
gBS->CloseProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiWinNtThunkProtocolGuid,
&WinNtThunk,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (Status == EFI_ALREADY_STARTED) {
return EFI_SUCCESS;
}
if (EFI_ERROR (Status)) {
return Status;
}
//
// Since we call through WinNtThunk we need to make sure it's valid
//
Status = EFI_SUCCESS;
if (WinNtThunk->Signature != EFI_WIN_NT_THUNK_PROTOCOL_SIGNATURE) {
Status = EFI_UNSUPPORTED;
}
//
// Close the I/O Abstraction(s) used to perform the supported test
//
gBS->CloseProtocol (
ControllerHandle,
&gEfiWinNtThunkProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
return Status;
}
EFI_STATUS
EFIAPI
WinNtBusDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
// TODO: This - add argument and description to function comment
// TODO: ControllerHandle - add argument and description to function comment
// TODO: RemainingDevicePath - add argument and description to function comment
// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
// TODO: EFI_SUCCESS - add return value to function comment
{
EFI_STATUS Status;
EFI_STATUS InstallStatus;
EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
WIN_NT_BUS_DEVICE *WinNtBusDevice;
WIN_NT_IO_DEVICE *WinNtDevice;
UINTN Index;
CHAR16 *StartString;
CHAR16 *SubString;
UINT16 Count;
UINTN StringSize;
UINT16 ComponentName[MAX_NT_ENVIRNMENT_VARIABLE_LENGTH];
WIN_NT_VENDOR_DEVICE_PATH_NODE *Node;
BOOLEAN CreateDevice;
CHAR16 *TempStr;
CHAR16 *PcdTempStr;
UINTN TempStrSize;
//
// Test Feature Set and Binary Patchable Case
//
if (FeaturePcdGet (PcdWinNtFeatureFlag1)) {
TempStrSize = PatchPcdGet32(PcdWinNtBinaryPatch1) + PatchPcdGet32(PcdWinNtBinaryPatch2);
}
if (0) {
//
// Test Dynamic and DynamicEx
// (Please add PcdWinNtConsole in "WinNtBusDriver.inf" before enable this code!!!)
//
PcdTempStr = PcdGetPtr (PcdWinNtConsole);
}
//
// Test Dynamic Set and Dynamic Set Ex
//
PcdSet32 (PcdWinNtDynamicUINT32, 2006);
Status = EFI_UNSUPPORTED;
//
// Grab the protocols we need
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
&ParentDevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
return Status;
}
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiWinNtThunkProtocolGuid,
&WinNtThunk,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
return Status;
}
if (Status != EFI_ALREADY_STARTED) {
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (WIN_NT_BUS_DEVICE),
(VOID *) &WinNtBusDevice
);
if (EFI_ERROR (Status)) {
return Status;
}
WinNtBusDevice->Signature = WIN_NT_BUS_DEVICE_SIGNATURE;
WinNtBusDevice->ControllerNameTable = NULL;
AddUnicodeString (
"eng",
gWinNtBusDriverComponentName.SupportedLanguages,
&WinNtBusDevice->ControllerNameTable,
L"Windows Bus Controller"
);
Status = gBS->InstallMultipleProtocolInterfaces (
&ControllerHandle,
&gWinNtBusDriverGuid,
WinNtBusDevice,
NULL
);
if (EFI_ERROR (Status)) {
FreeUnicodeStringTable (WinNtBusDevice->ControllerNameTable);
gBS->FreePool (WinNtBusDevice);
return Status;
}
}
//
// Loop on the Variable list. Parse each variable to produce a set of handles that
// represent virtual hardware devices.
//
InstallStatus = EFI_NOT_FOUND;
for (Index = 0; Index < NT_PCD_ARRAY_SIZE; Index++) {
PcdTempStr = (VOID *)LibPcdGetPtr (mPcdEnvironment[Index].Token);
ASSERT (PcdTempStr != NULL);
TempStrSize = StrLen (PcdTempStr);
TempStr = AllocateMemory ((TempStrSize * sizeof (CHAR16)) + 1);
StrCpy (TempStr, PcdTempStr);
StartString = TempStr;
//
// Parse the envirnment variable into sub strings using '!' as a delimator.
// Each substring needs it's own handle to be added to the system. This code
// does not understand the sub string. Thats the device drivers job.
//
Count = 0;
while (*StartString != '\0') {
//
// Find the end of the sub string
//
SubString = StartString;
while (*SubString != '\0' && *SubString != '!') {
SubString++;
}
if (*SubString == '!') {
//
// Replace token with '\0' to make sub strings. If this is the end
// of the string SubString will already point to NULL.
//
*SubString = '\0';
SubString++;
}
CreateDevice = TRUE;
if (RemainingDevicePath != NULL) {
CreateDevice = FALSE;
Node = (WIN_NT_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;
if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&
Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&
DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE)
) {
if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) &&
Node->Instance == Count
) {
CreateDevice = TRUE;
}
}
}
if (CreateDevice) {
//
// Allocate instance structure, and fill in parent information.
//
WinNtDevice = AllocateMemory (sizeof (WIN_NT_IO_DEVICE));
if (WinNtDevice == NULL) {
return EFI_OUT_OF_RESOURCES;
}
WinNtDevice->Handle = NULL;
WinNtDevice->ControllerHandle = ControllerHandle;
WinNtDevice->ParentDevicePath = ParentDevicePath;
WinNtDevice->WinNtIo.WinNtThunk = WinNtThunk;
//
// Plus 2 to account for the NULL at the end of the Unicode string
//
StringSize = (UINTN) ((UINT8 *) SubString - (UINT8 *) StartString) + sizeof (CHAR16);
WinNtDevice->WinNtIo.EnvString = AllocateMemory (StringSize);
if (WinNtDevice->WinNtIo.EnvString != NULL) {
CopyMem (WinNtDevice->WinNtIo.EnvString, StartString, StringSize);
}
WinNtDevice->ControllerNameTable = NULL;
WinNtThunk->SPrintf (ComponentName, L"%s", WinNtDevice->WinNtIo.EnvString);
WinNtDevice->DevicePath = WinNtBusCreateDevicePath (
ParentDevicePath,
mPcdEnvironment[Index].DevicePathGuid,
Count
);
if (WinNtDevice->DevicePath == NULL) {
gBS->FreePool (WinNtDevice);
return EFI_OUT_OF_RESOURCES;
}
AddUnicodeString (
"eng",
gWinNtBusDriverComponentName.SupportedLanguages,
&WinNtDevice->ControllerNameTable,
ComponentName
);
WinNtDevice->WinNtIo.TypeGuid = mPcdEnvironment[Index].DevicePathGuid;
WinNtDevice->WinNtIo.InstanceNumber = Count;
WinNtDevice->Signature = WIN_NT_IO_DEVICE_SIGNATURE;
Status = gBS->InstallMultipleProtocolInterfaces (
&WinNtDevice->Handle,
&gEfiDevicePathProtocolGuid,
WinNtDevice->DevicePath,
&gEfiWinNtIoProtocolGuid,
&WinNtDevice->WinNtIo,
NULL
);
if (EFI_ERROR (Status)) {
FreeUnicodeStringTable (WinNtDevice->ControllerNameTable);
gBS->FreePool (WinNtDevice);
} else {
//
// Open For Child Device
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiWinNtThunkProtocolGuid,
&WinNtThunk,
This->DriverBindingHandle,
WinNtDevice->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
);
if (!EFI_ERROR (Status)) {
InstallStatus = EFI_SUCCESS;
}
}
}
//
// Parse Next sub string. This will point to '\0' if we are at the end.
//
Count++;
StartString = SubString;
}
gBS->FreePool (TempStr);
}
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
WinNtBusDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
// TODO: This - add argument and description to function comment
// TODO: ControllerHandle - 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_SUCCESS - add return value to function comment
// TODO: EFI_DEVICE_ERROR - add return value to function comment
// TODO: EFI_SUCCESS - add return value to function comment
{
EFI_STATUS Status;
UINTN Index;
BOOLEAN AllChildrenStopped;
EFI_WIN_NT_IO_PROTOCOL *WinNtIo;
WIN_NT_BUS_DEVICE *WinNtBusDevice;
WIN_NT_IO_DEVICE *WinNtDevice;
EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;
//
// Complete all outstanding transactions to Controller.
// Don't allow any new transaction to Controller to be started.
//
if (NumberOfChildren == 0) {
//
// Close the bus driver
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gWinNtBusDriverGuid,
&WinNtBusDevice,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return Status;
}
gBS->UninstallMultipleProtocolInterfaces (
ControllerHandle,
&gWinNtBusDriverGuid,
WinNtBusDevice,
NULL
);
FreeUnicodeStringTable (WinNtBusDevice->ControllerNameTable);
gBS->FreePool (WinNtBusDevice);
gBS->CloseProtocol (
ControllerHandle,
&gEfiWinNtThunkProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
gBS->CloseProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
return EFI_SUCCESS;
}
AllChildrenStopped = TRUE;
for (Index = 0; Index < NumberOfChildren; Index++) {
Status = gBS->OpenProtocol (
ChildHandleBuffer[Index],
&gEfiWinNtIoProtocolGuid,
&WinNtIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
WinNtDevice = WIN_NT_IO_DEVICE_FROM_THIS (WinNtIo);
Status = gBS->CloseProtocol (
ControllerHandle,
&gEfiWinNtThunkProtocolGuid,
This->DriverBindingHandle,
WinNtDevice->Handle
);
Status = gBS->UninstallMultipleProtocolInterfaces (
WinNtDevice->Handle,
&gEfiDevicePathProtocolGuid,
WinNtDevice->DevicePath,
&gEfiWinNtIoProtocolGuid,
&WinNtDevice->WinNtIo,
NULL
);
if (EFI_ERROR (Status)) {
gBS->OpenProtocol (
ControllerHandle,
&gEfiWinNtThunkProtocolGuid,
(VOID **) &WinNtThunk,
This->DriverBindingHandle,
WinNtDevice->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
);
} else {
//
// Close the child handle
//
FreeUnicodeStringTable (WinNtDevice->ControllerNameTable);
gBS->FreePool (WinNtDevice);
}
}
if (EFI_ERROR (Status)) {
AllChildrenStopped = FALSE;
}
}
if (!AllChildrenStopped) {
return EFI_DEVICE_ERROR;
}
return EFI_SUCCESS;
}
EFI_DEVICE_PATH_PROTOCOL *
WinNtBusCreateDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL *RootDevicePath,
IN EFI_GUID *Guid,
IN UINT16 InstanceNumber
)
/*++
Routine Description:
Create a device path node using Guid and InstanceNumber and append it to
the passed in RootDevicePath
Arguments:
RootDevicePath - Root of the device path to return.
Guid - GUID to use in vendor device path node.
InstanceNumber - Instance number to use in the vendor device path. This
argument is needed to make sure each device path is unique.
Returns:
EFI_DEVICE_PATH_PROTOCOL
--*/
{
WIN_NT_VENDOR_DEVICE_PATH_NODE DevicePath;
DevicePath.VendorDevicePath.Header.Type = HARDWARE_DEVICE_PATH;
DevicePath.VendorDevicePath.Header.SubType = HW_VENDOR_DP;
SetDevicePathNodeLength (&DevicePath.VendorDevicePath.Header, sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE));
//
// The GUID defines the Class
//
CopyMem (&DevicePath.VendorDevicePath.Guid, Guid, sizeof (EFI_GUID));
//
// Add an instance number so we can make sure there are no Device Path
// duplication.
//
DevicePath.Instance = InstanceNumber;
return AppendDevicePathNode (
RootDevicePath,
(EFI_DEVICE_PATH_PROTOCOL *) &DevicePath
);
}

View File

@@ -0,0 +1,297 @@
/*++
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:
WinNtBusDriver.h
Abstract:
This following section documents the envirnoment variables for the Win NT
build. These variables are used to define the (virtual) hardware
configuration of the NT environment
A ! can be used to seperate multiple instances in a variable. Each
instance represents a seperate hardware device.
EFI_WIN_NT_PHYSICAL_DISKS - maps to drives on your system
EFI_WIN_NT_VIRTUAL_DISKS - maps to a device emulated by a file
EFI_WIN_NT_FILE_SYSTEM - mouts a directory as a file system
EFI_WIN_NT_CONSOLE - make a logical comand line window (only one!)
EFI_WIN_NT_UGA - Builds UGA Windows of Width and Height
EFI_WIN_NT_SERIAL_PORT - maps physical serial ports
EFI_WIN_NT_PASS_THRU - associates a device with our PCI support
<F>ixed - Fixed disk like a hard drive.
<R>emovable - Removable media like a floppy or CD-ROM.
Read <O>nly - Write protected device.
Read <W>rite - Read write device.
<block count> - Decimal number of blocks a device supports.
<block size> - Decimal number of bytes per block.
NT envirnonment variable contents. '<' and '>' are not part of the variable,
they are just used to make this help more readable. There should be no
spaces between the ';'. Extra spaces will break the variable. A '!' is
used to seperate multiple devices in a variable.
EFI_WIN_NT_VIRTUAL_DISKS =
<F | R><O | W>;<block count>;<block size>[!...]
EFI_WIN_NT_PHYSICAL_DISKS =
<drive letter>:<F | R><O | W>;<block count>;<block size>[!...]
Virtual Disks: These devices use a file to emulate a hard disk or removable
media device.
Thus a 20 MB emulated hard drive would look like:
EFI_WIN_NT_VIRTUAL_DISKS=FW;40960;512
A 1.44MB emulated floppy with a block size of 1024 would look like:
EFI_WIN_NT_VIRTUAL_DISKS=RW;1440;1024
Physical Disks: These devices use NT to open a real device in your system
Thus a 120 MB floppy would look like:
EFI_WIN_NT_PHYSICAL_DISKS=B:RW;245760;512
Thus a standard CD-ROM floppy would look like:
EFI_WIN_NT_PHYSICAL_DISKS=Z:RO;307200;2048
EFI_WIN_NT_FILE_SYSTEM =
<directory path>[!...]
Mounting the two directories C:\FOO and C:\BAR would look like:
EFI_WIN_NT_FILE_SYSTEM=c:\foo!c:\bar
EFI_WIN_NT_CONSOLE =
<window title>
Declaring a text console window with the title "My EFI Console" woild look like:
EFI_WIN_NT_CONSOLE=My EFI Console
EFI_WIN_NT_UGA =
<width> <height>[!...]
Declaring a two UGA windows with resolutions of 800x600 and 1024x768 would look like:
Example : EFI_WIN_NT_UGA=800 600!1024 768
EFI_WIN_NT_SERIAL_PORT =
<port name>[!...]
Declaring two serial ports on COM1 and COM2 would look like:
Example : EFI_WIN_NT_SERIAL_PORT=COM1!COM2
EFI_WIN_NT_PASS_THROUGH =
<BaseAddress>;<Bus#>;<Device#>;<Function#>
Declaring a base address of 0xE0000000 (used for PCI Express devices)
and having NT32 talk to a device located at bus 0, device 1, function 0:
Example : EFI_WIN_NT_PASS_THROUGH=E000000;0;1;0
---*/
#ifndef __NT_BUS_DRIVER_H__
#define __NT_BUS_DRIVER_H__
//
// WinNt Bus Driver Global Variables
//
extern EFI_DRIVER_BINDING_PROTOCOL gWinNtBusDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gWinNtBusDriverComponentName;
//
// WinNt Bus Controller Structure
//
#define WIN_NT_BUS_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('N', 'T', 'B', 'D')
typedef struct {
UINT64 Signature;
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
} WIN_NT_BUS_DEVICE;
//
// WinNt Child Device Controller Structure
//
#define WIN_NT_IO_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('N', 'T', 'V', 'D')
typedef struct {
UINT64 Signature;
EFI_HANDLE Handle;
EFI_WIN_NT_IO_PROTOCOL WinNtIo;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
//
// Private data about the parent
//
EFI_HANDLE ControllerHandle;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
} WIN_NT_IO_DEVICE;
#define WIN_NT_IO_DEVICE_FROM_THIS(a) \
CR(a, WIN_NT_IO_DEVICE, WinNtIo, WIN_NT_IO_DEVICE_SIGNATURE)
//
// This is the largest env variable we can parse
//
#define MAX_NT_ENVIRNMENT_VARIABLE_LENGTH 512
typedef struct {
UINTN Token;
EFI_GUID *DevicePathGuid;
} NT_PCD_ENTRY;
typedef struct {
VENDOR_DEVICE_PATH VendorDevicePath;
UINT32 Instance;
} WIN_NT_VENDOR_DEVICE_PATH_NODE;
EFI_STATUS
EFIAPI
CpuIoInitialize (
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
--*/
;
//
// Driver Binding Protocol function prototypes
//
EFI_STATUS
EFIAPI
WinNtBusDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Handle - TODO: add argument description
RemainingDevicePath - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
EFIAPI
WinNtBusDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ParentHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
ParentHandle - TODO: add argument description
RemainingDevicePath - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
EFIAPI
WinNtBusDriverBindingStop (
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:
TODO: add return values
--*/
;
//
// WinNt Bus Driver private worker functions
//
EFI_DEVICE_PATH_PROTOCOL *
WinNtBusCreateDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL *RootDevicePath,
IN EFI_GUID *Guid,
IN UINT16 InstanceNumber
)
/*++
Routine Description:
TODO: Add function description
Arguments:
RootDevicePath - TODO: add argument description
Guid - TODO: add argument description
InstanceNumber - TODO: add argument description
Returns:
TODO: add return values
--*/
;
#endif

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MbdHeader>
<BaseName>WinNtBusDriver</BaseName>
<Guid>BD7E9A27-D6C5-416a-B245-5F507D95B2BD</Guid>
<Version>0</Version>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>
<Created>2006-03-13 17:02</Created>
<Modified>2006-03-19 15:17</Modified>
</MbdHeader>
<Libraries>
<Library>UefiBootServicesTableLib</Library>
<Library>BaseLib</Library>
<Library>UefiLib</Library>
<Library>UefiMemoryLib</Library>
<Library>UefiDriverEntryPoint</Library>
<Library>UefiDriverModelLib</Library>
<Library>DxeReportStatusCodeLib</Library>
<Library>BaseDebugLibReportStatusCode</Library>
<Library>DxePcdLib</Library>
<Library>DxeMemoryAllocationLib</Library>
<Library>UefiDevicePathLib</Library>
</Libraries>
</ModuleBuildDescription>

View File

@@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MsaHeader>
<BaseName>WinNtBusDriver</BaseName>
<ModuleType>UEFI_DRIVER</ModuleType>
<ComponentType>BS_DRIVER</ComponentType>
<Guid>BD7E9A27-D6C5-416a-B245-5F507D95B2BD</Guid>
<Version>0</Version>
<Abstract>Component description file for WinNtBusDriver module.</Abstract>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>0</Specification>
<Created>2006-03-13 17:02</Created>
<Updated>2006-03-19 15:17</Updated>
</MsaHeader>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverModelLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverEntryPoint</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">PcdLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">MemoryAllocationLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">DevicePathLib</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>WinNtBusDriver.h</Filename>
<Filename>WinNtBusDriver.c</Filename>
<Filename>ComponentName.c</Filename>
</SourceFiles>
<Includes>
<PackageName>MdePkg</PackageName>
<PackageName>EdkModulePkg</PackageName>
<PackageName>EdkNt32Pkg</PackageName>
</Includes>
<Protocols>
<Protocol Usage="BY_START">WinNtIo</Protocol>
<Protocol Usage="TO_START">WinNtThunk</Protocol>
<Protocol Usage="TO_START">DevicePath</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">Pcd</Protocol>
</Protocols>
<Guids>
<GuidEntry Usage="ALWAYS_CONSUMED">
<C_Name>WinNtVirtualDisks</C_Name>
</GuidEntry>
<GuidEntry Usage="ALWAYS_CONSUMED">
<C_Name>WinNtPhysicalDisks</C_Name>
</GuidEntry>
<GuidEntry Usage="ALWAYS_CONSUMED">
<C_Name>WinNtFileSystem</C_Name>
</GuidEntry>
<GuidEntry Usage="ALWAYS_CONSUMED">
<C_Name>WinNtSerialPort</C_Name>
</GuidEntry>
<GuidEntry Usage="ALWAYS_CONSUMED">
<C_Name>WinNtUga</C_Name>
</GuidEntry>
<GuidEntry Usage="ALWAYS_CONSUMED">
<C_Name>WinNtConsole</C_Name>
</GuidEntry>
<GuidEntry Usage="ALWAYS_CONSUMED">
<C_Name>WinNtMemory</C_Name>
</GuidEntry>
<GuidEntry Usage="ALWAYS_CONSUMED">
<C_Name>WinNtCPUModel</C_Name>
</GuidEntry>
<GuidEntry Usage="ALWAYS_CONSUMED">
<C_Name>WinNtCPUSpeed</C_Name>
</GuidEntry>
</Guids>
<Externs>
<Extern>
<ModuleEntryPoint></ModuleEntryPoint>
</Extern>
<Extern>
<DriverBinding>gWinNtBusDriverBinding</DriverBinding>
<ComponentName>gWinNtBusDriverComponentName</ComponentName>
</Extern>
</Externs>
<PCDs>
<PcdData ItemType="FIXED_AT_BUILD">
<C_Name>PcdWinNtConsole</C_Name>
<Token>0x0000100a</Token>
<DatumType>VOID*</DatumType>
</PcdData>
<PcdData ItemType="FIXED_AT_BUILD">
<C_Name>PcdWinNtUga</C_Name>
<Token>0x00001003</Token>
<DatumType>VOID*</DatumType>
</PcdData>
<PcdData ItemType="FIXED_AT_BUILD">
<C_Name>PcdWinNtSerialPort</C_Name>
<Token>0x00001002</Token>
<DatumType>VOID*</DatumType>
</PcdData>
<PcdData ItemType="FIXED_AT_BUILD">
<C_Name>PcdWinNtFileSystem</C_Name>
<Token>0x00001004</Token>
<DatumType>VOID*</DatumType>
</PcdData>
<PcdData ItemType="FIXED_AT_BUILD">
<C_Name>PcdWinNtVirtualDisk</C_Name>
<Token>0x00001001</Token>
<DatumType>VOID*</DatumType>
</PcdData>
<PcdData ItemType="FIXED_AT_BUILD">
<C_Name>PcdWinNtPhysicalDisk</C_Name>
<Token>0x00001000</Token>
<DatumType>VOID*</DatumType>
</PcdData>
<PcdData ItemType="FIXED_AT_BUILD">
<C_Name>PcdWinNtCpuModel</C_Name>
<Token>0x00001007</Token>
<DatumType>VOID*</DatumType>
</PcdData>
<PcdData ItemType="FIXED_AT_BUILD">
<C_Name>PcdWinNtCpuSpeed</C_Name>
<Token>0x00001008</Token>
<DatumType>VOID*</DatumType>
</PcdData>
<PcdData ItemType="FIXED_AT_BUILD">
<C_Name>PcdWinNtMemorySize</C_Name>
<Token>0x00001005</Token>
<DatumType>VOID*</DatumType>
</PcdData>
<PcdData ItemType="PATCHABLE_IN_MODULE">
<C_Name>PcdWinNtBinaryPatch1</C_Name>
<Token>0x0001000b</Token>
<DatumType>UINT32</DatumType>
</PcdData>
<PcdData ItemType="PATCHABLE_IN_MODULE">
<C_Name>PcdWinNtBinaryPatch2</C_Name>
<Token>0x0001000c</Token>
<DatumType>UINT32</DatumType>
</PcdData>
<PcdData ItemType="FEATURE_FLAG">
<C_Name>PcdWinNtFeatureFlag1</C_Name>
<Token>0x0001000d</Token>
<DatumType>BOOLEAN</DatumType>
</PcdData>
<PcdData ItemType="DYNAMIC">
<C_Name>PcdWinNtDynamicUINT32</C_Name>
<Token>0x0001000e</Token>
<DatumType>UINT32</DatumType>
</PcdData>
</PCDs>
</ModuleSurfaceArea>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
<project basedir="." default="WinNtBusDriver"><!--Apply external ANT tasks-->
<taskdef resource="GenBuild.tasks"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property environment="env"/>
<property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
<import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
<property name="MODULE_RELATIVE_PATH" value="Dxe\WinNtThunk\Bus\WinNtBusDriver"/>
<property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
<property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
<target name="WinNtBusDriver">
<GenBuild baseName="WinNtBusDriver" mbdFilename="${MODULE_DIR}\WinNtBusDriver.mbd" msaFilename="${MODULE_DIR}\WinNtBusDriver.msa"/>
</target>
<target depends="WinNtBusDriver_clean" name="clean"/>
<target depends="WinNtBusDriver_cleanall" name="cleanall"/>
<target name="WinNtBusDriver_clean">
<OutputDirSetup baseName="WinNtBusDriver" mbdFilename="${MODULE_DIR}\WinNtBusDriver.mbd" msaFilename="${MODULE_DIR}\WinNtBusDriver.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\WinNtBusDriver_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\WinNtBusDriver_build.xml" target="clean"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
</target>
<target name="WinNtBusDriver_cleanall">
<OutputDirSetup baseName="WinNtBusDriver" mbdFilename="${MODULE_DIR}\WinNtBusDriver.mbd" msaFilename="${MODULE_DIR}\WinNtBusDriver.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\WinNtBusDriver_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\WinNtBusDriver_build.xml" target="cleanall"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}"/>
<delete dir="${DEST_DIR_DEBUG}"/>
<delete>
<fileset dir="${BIN_DIR}" includes="**WinNtBusDriver*"/>
</delete>
</target>
</project>

View File

@@ -0,0 +1,129 @@
/*++
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:
Metronome.c
Abstract:
NT Emulation Metronome Architectural Protocol Driver as defined in DXE CIS
--*/
#include "Metronome.h"
//
// Global Variables
//
EFI_METRONOME_ARCH_PROTOCOL mMetronome = {
WinNtMetronomeDriverWaitForTick,
TICK_PERIOD
};
//
// Worker Functions
//
EFI_STATUS
EFIAPI
WinNtMetronomeDriverWaitForTick (
IN EFI_METRONOME_ARCH_PROTOCOL *This,
IN UINT32 TickNumber
)
/*++
Routine Description:
The WaitForTick() function waits for the number of ticks specified by
TickNumber from a known time source in the platform. If TickNumber of
ticks are detected, then EFI_SUCCESS is returned. The actual time passed
between entry of this function and the first tick is between 0 and
TickPeriod 100 nS units. If you want to guarantee that at least TickPeriod
time has elapsed, wait for two ticks. This function waits for a hardware
event to determine when a tick occurs. It is possible for interrupt
processing, or exception processing to interrupt the execution of the
WaitForTick() function. Depending on the hardware source for the ticks, it
is possible for a tick to be missed. This function cannot guarantee that
ticks will not be missed. If a timeout occurs waiting for the specified
number of ticks, then EFI_TIMEOUT is returned.
Arguments:
This - The EFI_METRONOME_ARCH_PROTOCOL instance.
TickNumber - Number of ticks to wait.
Returns:
EFI_SUCCESS - The wait for the number of ticks specified by TickNumber
succeeded.
--*/
{
UINT64 SleepTime;
//
// Calculate the time to sleep. Win API smallest unit to sleep is 1 millisec
// Tick Period is in 100ns units, divide by 10000 to convert to ms
//
SleepTime = DivU64x32 (MultU64x32 ((UINT64) TickNumber, TICK_PERIOD) + 9999, 10000);
gWinNt->Sleep ((UINT32) SleepTime);
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
WinNtMetronomeDriverInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Initialize the Metronome Architectural Protocol driver
Arguments:
ImageHandle - ImageHandle of the loaded driver
SystemTable - Pointer to the System Table
Returns:
EFI_SUCCESS - Metronome Architectural Protocol created
EFI_OUT_OF_RESOURCES - Not enough resources available to initialize driver.
EFI_DEVICE_ERROR - A device error occured attempting to initialize the driver.
--*/
{
EFI_STATUS Status;
EFI_HANDLE Handle;
//
// Install the Metronome Architectural Protocol onto a new handle
//
Handle = NULL;
Status = gBS->InstallProtocolInterface (
&Handle,
&gEfiMetronomeArchProtocolGuid,
EFI_NATIVE_INTERFACE,
&mMetronome
);
return Status;
}

View File

@@ -0,0 +1,27 @@
/*++
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:
Metronome.dxs
Abstract:
Dependency expression source file.
--*/
#include <AutoGen.h>
#include <DxeDepex.h>
DEPENDENCY_START
TRUE
DEPENDENCY_END

View File

@@ -0,0 +1,84 @@
/*++
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:
Metronome.h
Abstract:
NT Emulation Metronome Architectural Protocol Driver as defined in DXE CIS
--*/
#ifndef _NT_THUNK_METRONOME_H_
#define _NT_THUNK_METRONOME_H_
//
// Period of on tick in 100 nanosecond units
//
#define TICK_PERIOD 2000
//
// Function Prototypes
//
EFI_STATUS
EFIAPI
WinNtMetronomeDriverInitialize (
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
EFIAPI
WinNtMetronomeDriverWaitForTick (
IN EFI_METRONOME_ARCH_PROTOCOL *This,
IN UINT32 TickNumber
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
TickNumber - TODO: add argument description
Returns:
TODO: add return values
--*/
;
#endif

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MbdHeader>
<BaseName>Metronome</BaseName>
<Guid>154CAB4A-52B5-46CD-99C3-4368ABBACFFD</Guid>
<Version>0</Version>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>
<Created>2006-03-14 17:04</Created>
<Modified>2006-03-19 15:17</Modified>
</MbdHeader>
<Libraries>
<Library>UefiBootServicesTableLib</Library>
<Library>DxeHobLib</Library>
<Library>BaseLib</Library>
<Library>UefiLib</Library>
<Library>UefiMemoryLib</Library>
<Library>UefiDriverEntryPoint</Library>
<Library>DxeReportStatusCodeLib</Library>
<Library>BaseDebugLibReportStatusCode</Library>
<Library>DxeWinNtLib</Library>
<Library>DxeMemoryAllocationLib</Library>
</Libraries>
<BuildOptions ToolChain="MSFT">
<ImageEntryPoint>_ModuleEntryPoint</ImageEntryPoint>
</BuildOptions>
</ModuleBuildDescription>

View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MsaHeader>
<BaseName>Metronome</BaseName>
<ModuleType>DXE_DRIVER</ModuleType>
<ComponentType>BS_DRIVER</ComponentType>
<Guid>154CAB4A-52B5-46CD-99C3-4368ABBACFFD</Guid>
<Version>0</Version>
<Abstract>Component description file for Metronome module.</Abstract>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>0</Specification>
<Created>2006-03-14 17:04</Created>
<Updated>2006-03-19 15:17</Updated>
</MsaHeader>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverEntryPoint</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">WinNtLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">MemoryAllocationLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>Metronome.c</Filename>
<Filename>Metronome.h</Filename>
<Filename>Metronome.dxs</Filename>
</SourceFiles>
<Includes>
<PackageName>MdePkg</PackageName>
<PackageName>EdkModulePkg</PackageName>
<PackageName>EdkNt32Pkg</PackageName>
</Includes>
<Protocols>
<Protocol Usage="ALWAYS_PRODUCED">Metronome</Protocol>
</Protocols>
<Externs>
<Extern>
<ModuleEntryPoint>WinNtMetronomeDriverInitialize</ModuleEntryPoint>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
<project basedir="." default="Metronome"><!--Apply external ANT tasks-->
<taskdef resource="GenBuild.tasks"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property environment="env"/>
<property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
<import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
<property name="MODULE_RELATIVE_PATH" value="Dxe\WinNtThunk\Chipset\Metronome"/>
<property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
<property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
<target name="Metronome">
<GenBuild baseName="Metronome" mbdFilename="${MODULE_DIR}\Metronome.mbd" msaFilename="${MODULE_DIR}\Metronome.msa"/>
</target>
<target depends="Metronome_clean" name="clean"/>
<target depends="Metronome_cleanall" name="cleanall"/>
<target name="Metronome_clean">
<OutputDirSetup baseName="Metronome" mbdFilename="${MODULE_DIR}\Metronome.mbd" msaFilename="${MODULE_DIR}\Metronome.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\Metronome_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\Metronome_build.xml" target="clean"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
</target>
<target name="Metronome_cleanall">
<OutputDirSetup baseName="Metronome" mbdFilename="${MODULE_DIR}\Metronome.mbd" msaFilename="${MODULE_DIR}\Metronome.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\Metronome_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\Metronome_build.xml" target="cleanall"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}"/>
<delete dir="${DEST_DIR_DEBUG}"/>
<delete>
<fileset dir="${BIN_DIR}" includes="**Metronome*"/>
</delete>
</target>
</project>

View File

@@ -0,0 +1,391 @@
/*++
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:
RealTimeClock.c
Abstract:
NT Emulation Architectural Protocol Driver as defined in Tiano
--*/
BOOLEAN
DayValid (
IN EFI_TIME *Time
);
BOOLEAN
IsLeapYear (
IN EFI_TIME *Time
);
EFI_STATUS
RtcTimeFieldsValid (
IN EFI_TIME *Time
);
EFI_STATUS
EFIAPI
InitializeRealTimeClock (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
STATIC
EFI_STATUS
EFIAPI
WinNtGetTime (
OUT EFI_TIME *Time,
OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
)
/*++
Routine Description:
Service routine for RealTimeClockInstance->GetTime
Arguments:
Time - A pointer to storage that will receive a snapshot of the current time.
Capabilities - A pointer to storage that will receive the capabilities of the real time clock
in the platform. This includes the real time clock's resolution and accuracy.
All reported device capabilities are rounded up. This is an OPTIONAL argument.
Returns:
EFI_SUCEESS - The underlying GetSystemTime call occurred and returned
Note that in the NT32 emulation, the GetSystemTime call has no return value
thus you will always receive a EFI_SUCCESS on this.
--*/
// TODO: EFI_INVALID_PARAMETER - add return value to function comment
{
SYSTEMTIME SystemTime;
TIME_ZONE_INFORMATION TimeZone;
//
// Check parameter for null pointer
//
if (Time == NULL) {
return EFI_INVALID_PARAMETER;
}
gWinNt->GetLocalTime (&SystemTime);
gWinNt->GetTimeZoneInformation (&TimeZone);
Time->Year = (UINT16) SystemTime.wYear;
Time->Month = (UINT8) SystemTime.wMonth;
Time->Day = (UINT8) SystemTime.wDay;
Time->Hour = (UINT8) SystemTime.wHour;
Time->Minute = (UINT8) SystemTime.wMinute;
Time->Second = (UINT8) SystemTime.wSecond;
Time->Nanosecond = (UINT32) (SystemTime.wMilliseconds * 1000000);
Time->TimeZone = (INT16) TimeZone.Bias;
if (Capabilities != NULL) {
Capabilities->Resolution = 1;
Capabilities->Accuracy = 50000000;
Capabilities->SetsToZero = FALSE;
}
Time->Daylight = 0;
if (TimeZone.StandardDate.wMonth) {
Time->Daylight = EFI_TIME_ADJUST_DAYLIGHT;
}
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
EFIAPI
WinNtSetTime (
IN EFI_TIME *Time
)
/*++
Routine Description:
Service routine for RealTimeClockInstance->SetTime
Arguments:
Time - A pointer to storage containing the time and date information to
program into the real time clock.
Returns:
EFI_SUCEESS - The operation completed successfully.
EFI_INVALID_PARAMETER - One of the fields in Time is out of range.
EFI_DEVICE_ERROR - The operation could not be complete due to a device error.
--*/
// TODO: EFI_SUCCESS - add return value to function comment
{
TIME_ZONE_INFORMATION TimeZone;
EFI_STATUS Status;
SYSTEMTIME SystemTime;
BOOL Flag;
if (Time == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Make sure that the time fields are valid
//
Status = RtcTimeFieldsValid (Time);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Set Daylight savings time information and Time Zone
//
gWinNt->GetTimeZoneInformation (&TimeZone);
TimeZone.StandardDate.wMonth = Time->Daylight;
TimeZone.Bias = Time->TimeZone;
gWinNt->SetTimeZoneInformation (&TimeZone);
SystemTime.wYear = Time->Year;
SystemTime.wMonth = Time->Month;
SystemTime.wDay = Time->Day;
SystemTime.wHour = Time->Hour;
SystemTime.wMinute = Time->Minute;
SystemTime.wSecond = Time->Second;
SystemTime.wMilliseconds = (INT16) (Time->Nanosecond / 1000000);
Flag = gWinNt->SetLocalTime (&SystemTime);
if (!Flag) {
return EFI_DEVICE_ERROR;
} else {
return EFI_SUCCESS;
}
}
STATIC
EFI_STATUS
EFIAPI
WinNtGetWakeupTime (
OUT BOOLEAN *Enabled,
OUT BOOLEAN *Pending,
OUT EFI_TIME *Time
)
/*++
Routine Description:
Service routine for RealTimeClockInstance->GetWakeupTime
Arguments:
This - Indicates the protocol instance structure.
Enabled - Indicates if the alarm is currently enabled or disabled.
Pending - Indicates if the alarm signal is pending and requires
acknowledgement.
Time - The current alarm setting.
Returns:
EFI_SUCEESS - The operation completed successfully.
EFI_DEVICE_ERROR - The operation could not be complete due to a device error.
EFI_UNSUPPORTED - The operation is not supported on this platform.
--*/
{
return EFI_UNSUPPORTED;
}
STATIC
EFI_STATUS
EFIAPI
WinNtSetWakeupTime (
IN BOOLEAN Enable,
OUT EFI_TIME *Time
)
/*++
Routine Description:
Service routine for RealTimeClockInstance->SetWakeupTime
Arguments:
Enabled - Enable or disable the wakeup alarm.
Time - If enable is TRUE, the time to set the wakup alarm for.
If enable is FALSE, then this parameter is optional, and
may be NULL.
Returns:
EFI_SUCEESS - The operation completed successfully.
EFI_DEVICE_ERROR - The operation could not be complete due to a device error.
EFI_INVALID_PARAMETER - A field in Time is out of range.
EFI_UNSUPPORTED - The operation is not supported on this platform.
--*/
{
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
InitializeRealTimeClock (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Install Real Time Clock Protocol
Arguments:
(Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
Returns:
EFI_SUCEESS - Real Time Clock Services are installed into the Runtime Services Table
--*/
// TODO: ImageHandle - add argument and description to function comment
// TODO: SystemTable - add argument and description to function comment
{
EFI_STATUS Status;
EFI_HANDLE Handle;
SystemTable->RuntimeServices->GetTime = WinNtGetTime;
SystemTable->RuntimeServices->SetTime = WinNtSetTime;
SystemTable->RuntimeServices->GetWakeupTime = WinNtGetWakeupTime;
SystemTable->RuntimeServices->SetWakeupTime = WinNtSetWakeupTime;
Handle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (
&Handle,
&gEfiRealTimeClockArchProtocolGuid,
NULL,
NULL
);
return Status;
}
EFI_STATUS
RtcTimeFieldsValid (
IN EFI_TIME *Time
)
/*++
Routine Description:
Arguments:
Returns:
--*/
// TODO: Time - add argument and description to function comment
// TODO: EFI_INVALID_PARAMETER - add return value to function comment
// TODO: EFI_SUCCESS - add return value to function comment
{
if (Time->Year < 1998 ||
Time->Year > 2099 ||
Time->Month < 1 ||
Time->Month > 12 ||
(!DayValid (Time)) ||
Time->Hour > 23 ||
Time->Minute > 59 ||
Time->Second > 59 ||
Time->Nanosecond > 999999999 ||
(!(Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE || (Time->TimeZone >= -1440 && Time->TimeZone <= 1440))) ||
(Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT)))
) {
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
BOOLEAN
DayValid (
IN EFI_TIME *Time
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Time - TODO: add argument description
Returns:
TODO: add return values
--*/
{
INTN DayOfMonth[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if (Time->Day < 1 ||
Time->Day > DayOfMonth[Time->Month - 1] ||
(Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
) {
return FALSE;
}
return TRUE;
}
BOOLEAN
IsLeapYear (
IN EFI_TIME *Time
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Time - TODO: add argument description
Returns:
TODO: add return values
--*/
{
if (Time->Year % 4 == 0) {
if (Time->Year % 100 == 0) {
if (Time->Year % 400 == 0) {
return TRUE;
} else {
return FALSE;
}
} else {
return TRUE;
}
} else {
return FALSE;
}
}

View File

@@ -0,0 +1,27 @@
/*++
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:
RealTimeClock.dxs
Abstract:
Dependency expression source file.
--*/
#include <AutoGen.h>
#include <DxeDepex.h>
DEPENDENCY_START
TRUE
DEPENDENCY_END

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MbdHeader>
<BaseName>RealTimeClock</BaseName>
<Guid>27F05AF5-1644-4EF4-8944-48C4F75675A0</Guid>
<Version>0</Version>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>
<Created>2006-03-14 17:04</Created>
<Modified>2006-03-19 15:17</Modified>
</MbdHeader>
<Libraries>
<Library>UefiBootServicesTableLib</Library>
<Library>DxeHobLib</Library>
<Library>DxeWinNtLib</Library>
<Library>BaseLib</Library>
<Library>UefiLib</Library>
<Library>UefiMemoryLib</Library>
<Library>UefiDriverEntryPoint</Library>
<Library>DxeReportStatusCodeLib</Library>
<Library>BaseDebugLibReportStatusCode</Library>
<Library>DxeMemoryAllocationLib</Library>
</Libraries>
<BuildOptions ToolChain="MSFT">
<ImageEntryPoint>_ModuleEntryPoint</ImageEntryPoint>
</BuildOptions>
</ModuleBuildDescription>

View File

@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MsaHeader>
<BaseName>RealTimeClock</BaseName>
<ModuleType>DXE_DRIVER</ModuleType>
<ComponentType>BS_DRIVER</ComponentType>
<Guid>27F05AF5-1644-4EF4-8944-48C4F75675A0</Guid>
<Version>0</Version>
<Abstract>Component description file for RealTimeClock module.</Abstract>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>0</Specification>
<Created>2006-03-14 17:04</Created>
<Updated>2006-03-19 15:17</Updated>
</MsaHeader>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverEntryPoint</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">WinNtLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">MemoryAllocationLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>RealTimeClock.c</Filename>
<Filename>RealTimeClock.dxs</Filename>
</SourceFiles>
<Includes>
<PackageName>MdePkg</PackageName>
<PackageName>EdkModulePkg</PackageName>
<PackageName>EdkNt32Pkg</PackageName>
</Includes>
<Protocols>
<Protocol Usage="ALWAYS_PRODUCED">RealTimeClock</Protocol>
</Protocols>
<Externs>
<Extern>
<ModuleEntryPoint>InitializeRealTimeClock</ModuleEntryPoint>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
<project basedir="." default="RealTimeClock"><!--Apply external ANT tasks-->
<taskdef resource="GenBuild.tasks"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property environment="env"/>
<property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
<import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
<property name="MODULE_RELATIVE_PATH" value="Dxe\WinNtThunk\Chipset\RealTimeClock"/>
<property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
<property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
<target name="RealTimeClock">
<GenBuild baseName="RealTimeClock" mbdFilename="${MODULE_DIR}\RealTimeClock.mbd" msaFilename="${MODULE_DIR}\RealTimeClock.msa"/>
</target>
<target depends="RealTimeClock_clean" name="clean"/>
<target depends="RealTimeClock_cleanall" name="cleanall"/>
<target name="RealTimeClock_clean">
<OutputDirSetup baseName="RealTimeClock" mbdFilename="${MODULE_DIR}\RealTimeClock.mbd" msaFilename="${MODULE_DIR}\RealTimeClock.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\RealTimeClock_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\RealTimeClock_build.xml" target="clean"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
</target>
<target name="RealTimeClock_cleanall">
<OutputDirSetup baseName="RealTimeClock" mbdFilename="${MODULE_DIR}\RealTimeClock.mbd" msaFilename="${MODULE_DIR}\RealTimeClock.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\RealTimeClock_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\RealTimeClock_build.xml" target="cleanall"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}"/>
<delete dir="${DEST_DIR_DEBUG}"/>
<delete>
<fileset dir="${BIN_DIR}" includes="**RealTimeClock*"/>
</delete>
</target>
</project>

View File

@@ -0,0 +1,27 @@
/*++
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:
Reset.dxs
Abstract:
Dependency expression source file.
--*/
#include <AutoGen.h>
#include <DxeDepex.h>
DEPENDENCY_START
TRUE
DEPENDENCY_END

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MbdHeader>
<BaseName>Reset</BaseName>
<Guid>BA929954-35B0-4dd3-90CD-9634BD7E1CF1</Guid>
<Version>0</Version>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>
<Created>2006-03-14 17:04</Created>
<Modified>2006-03-19 15:17</Modified>
</MbdHeader>
<Libraries>
<Library>UefiBootServicesTableLib</Library>
<Library>DxeHobLib</Library>
<Library>BaseLib</Library>
<Library>UefiLib</Library>
<Library>UefiMemoryLib</Library>
<Library>UefiDriverEntryPoint</Library>
<Library>DxeReportStatusCodeLib</Library>
<Library>BaseDebugLibReportStatusCode</Library>
<Library>DxeWinNtLib</Library>
<Library>DxeMemoryAllocationLib</Library>
</Libraries>
<BuildOptions ToolChain="MSFT">
<ImageEntryPoint>_ModuleEntryPoint</ImageEntryPoint>
</BuildOptions>
</ModuleBuildDescription>

View File

@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MsaHeader>
<BaseName>Reset</BaseName>
<ModuleType>DXE_DRIVER</ModuleType>
<ComponentType>BS_DRIVER</ComponentType>
<Guid>BA929954-35B0-4dd3-90CD-9634BD7E1CF1</Guid>
<Version>0</Version>
<Abstract>description of file contents</Abstract>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>0</Specification>
<Created>2006-03-14 17:04</Created>
<Updated>2006-03-19 15:17</Updated>
</MsaHeader>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverEntryPoint</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">WinNtLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">MemoryAllocationLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>Reset.c</Filename>
<Filename>Reset.dxs</Filename>
</SourceFiles>
<Includes>
<PackageName>MdePkg</PackageName>
<PackageName>EdkModulePkg</PackageName>
<PackageName>EdkNt32Pkg</PackageName>
</Includes>
<Protocols>
<Protocol Usage="ALWAYS_PRODUCED">Reset</Protocol>
</Protocols>
<Externs>
<Extern>
<ModuleEntryPoint>InitializeNtReset</ModuleEntryPoint>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
<project basedir="." default="Reset"><!--Apply external ANT tasks-->
<taskdef resource="GenBuild.tasks"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property environment="env"/>
<property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
<import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
<property name="MODULE_RELATIVE_PATH" value="Dxe\WinNtThunk\Chipset\Reset"/>
<property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
<property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
<target name="Reset">
<GenBuild baseName="Reset" mbdFilename="${MODULE_DIR}\Reset.mbd" msaFilename="${MODULE_DIR}\Reset.msa"/>
</target>
<target depends="Reset_clean" name="clean"/>
<target depends="Reset_cleanall" name="cleanall"/>
<target name="Reset_clean">
<OutputDirSetup baseName="Reset" mbdFilename="${MODULE_DIR}\Reset.mbd" msaFilename="${MODULE_DIR}\Reset.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\Reset_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\Reset_build.xml" target="clean"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
</target>
<target name="Reset_cleanall">
<OutputDirSetup baseName="Reset" mbdFilename="${MODULE_DIR}\Reset.mbd" msaFilename="${MODULE_DIR}\Reset.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\Reset_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\Reset_build.xml" target="cleanall"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}"/>
<delete dir="${DEST_DIR_DEBUG}"/>
<delete>
<fileset dir="${BIN_DIR}" includes="**Reset*"/>
</delete>
</target>
</project>

View File

@@ -0,0 +1,121 @@
/*++
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:
Reset.c
Abstract:
Reset Architectural Protocol as defined in Tiano under NT Emulation
--*/
EFI_STATUS
EFIAPI
InitializeNtReset (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
STATIC
EFI_STATUS
EFIAPI
WinNtResetSystem (
IN EFI_RESET_TYPE ResetType,
IN EFI_STATUS ResetStatus,
IN UINTN DataSize,
IN CHAR16 *ResetData OPTIONAL
);
EFI_STATUS
EFIAPI
InitializeNtReset (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Arguments:
ImageHandle of the loaded driver
Pointer to the System Table
Returns:
Status
--*/
// TODO: SystemTable - add argument and description to function comment
{
EFI_STATUS Status;
EFI_HANDLE Handle;
SystemTable->RuntimeServices->ResetSystem = WinNtResetSystem;
Handle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (
&Handle,
&gEfiResetArchProtocolGuid,
NULL,
NULL
);
ASSERT_EFI_ERROR (Status);
return Status;
}
STATIC
EFI_STATUS
EFIAPI
WinNtResetSystem (
IN EFI_RESET_TYPE ResetType,
IN EFI_STATUS ResetStatus,
IN UINTN DataSize,
IN CHAR16 *ResetData OPTIONAL
)
/*++
Routine Description:
TODO: Add function description
Arguments:
ResetType - TODO: add argument description
ResetStatus - TODO: add argument description
DataSize - TODO: add argument description
ResetData - TODO: add argument description
Returns:
EFI_SUCCESS - TODO: Add description for return value
--*/
{
//
// BUGBUG Need to kill all console windows later
//
//
// Discard ResetType, always return 0 as exit code
//
gWinNt->ExitProcess (0);
//
// Should never go here
//
return EFI_SUCCESS;
}

View File

@@ -0,0 +1,597 @@
/*++
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:
Timer.c
Abstract:
NT Emulation Timer Architectural Protocol Driver as defined in DXE CIS
This Timer module uses an NT Thread to simulate the timer-tick driven
timer service. In the future, the Thread creation should possibly be
abstracted by the CPU architectural protocol
--*/
#include "Timer.h"
//
// Pointer to the CPU Architectural Protocol instance
//
EFI_CPU_ARCH_PROTOCOL *mCpu;
//
// The Timer Architectural Protocol that this driver produces
//
EFI_TIMER_ARCH_PROTOCOL mTimer = {
WinNtTimerDriverRegisterHandler,
WinNtTimerDriverSetTimerPeriod,
WinNtTimerDriverGetTimerPeriod,
WinNtTimerDriverGenerateSoftInterrupt
};
//
// Define a global that we can use to shut down the NT timer thread when
// the timer is canceled.
//
BOOLEAN mCancelTimerThread = FALSE;
//
// The notification function to call on every timer interrupt
//
EFI_TIMER_NOTIFY mTimerNotifyFunction = NULL;
//
// The current period of the timer interrupt
//
UINT64 mTimerPeriod;
//
// The thread handle for this driver
//
HANDLE mNtMainThreadHandle;
//
// The timer value from the last timer interrupt
//
UINT32 mNtLastTick;
//
// Critical section used to update varibles shared between the main thread and
// the timer interrupt thread.
//
CRITICAL_SECTION mNtCriticalSection;
//
// Worker Functions
//
UINT mMMTimerThreadID = 0;
VOID
CALLBACK
MMTimerThread (
UINT wTimerID,
UINT msg,
DWORD dwUser,
DWORD dw1,
DWORD dw2
)
/*++
Routine Description:
TODO: Add function description
Arguments:
wTimerID - TODO: add argument description
msg - TODO: add argument description
dwUser - TODO: add argument description
dw1 - TODO: add argument description
dw2 - TODO: add argument description
Returns:
TODO: add return values
--*/
{
EFI_TPL OriginalTPL;
UINT32 CurrentTick;
UINT32 Delta;
EFI_TIMER_NOTIFY CallbackFunction;
BOOLEAN InterruptState;
if (!mCancelTimerThread) {
//
// Suspend the main thread until we are done
//
gWinNt->SuspendThread (mNtMainThreadHandle);
//
// If the timer thread is being canceled, then bail immediately.
// We check again here because there's a small window of time from when
// this thread was kicked off and when we suspended the main thread above.
//
if (mCancelTimerThread) {
gWinNt->ResumeThread (mNtMainThreadHandle);
gWinNt->timeKillEvent (wTimerID);
mMMTimerThreadID = 0;
return ;
}
mCpu->GetInterruptState (mCpu, &InterruptState);
while (!InterruptState) {
//
// Resume the main thread
//
gWinNt->ResumeThread (mNtMainThreadHandle);
//
// Wait for interrupts to be enabled.
//
mCpu->GetInterruptState (mCpu, &InterruptState);
while (!InterruptState) {
gWinNt->Sleep (0);
mCpu->GetInterruptState (mCpu, &InterruptState);
}
//
// Suspend the main thread until we are done
//
gWinNt->SuspendThread (mNtMainThreadHandle);
mCpu->GetInterruptState (mCpu, &InterruptState);
}
//
// Get the current system tick
//
CurrentTick = gWinNt->GetTickCount ();
Delta = CurrentTick - mNtLastTick;
mNtLastTick = CurrentTick;
//
// If delay was more then 1 second, ignore it (probably debugging case)
//
if (Delta < 1000) {
OriginalTPL = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL);
//
// Inform the firmware of an "timer interrupt". The time
// expired since the last call is 10,000 times the number
// of ms. (or 100ns units)
//
gWinNt->EnterCriticalSection (&mNtCriticalSection);
CallbackFunction = mTimerNotifyFunction;
gWinNt->LeaveCriticalSection (&mNtCriticalSection);
//
// Only invoke the callback function if a Non-NULL handler has been
// registered. Assume all other handlers are legal.
//
if (CallbackFunction != NULL) {
CallbackFunction ((UINT64) (Delta * 10000));
}
gBS->RestoreTPL (OriginalTPL);
}
//
// Resume the main thread
//
gWinNt->ResumeThread (mNtMainThreadHandle);
} else {
gWinNt->timeKillEvent (wTimerID);
mMMTimerThreadID = 0;
}
}
UINT
CreateNtTimer (
VOID
)
/*++
Routine Description:
It is used to emulate a platform
timer-driver interrupt handler.
Returns:
Timer ID
--*/
// TODO: function comment is missing 'Arguments:'
{
UINT32 SleepCount;
//
// Set our thread priority higher than the "main" thread.
//
gWinNt->SetThreadPriority (
gWinNt->GetCurrentThread (),
THREAD_PRIORITY_HIGHEST
);
//
// Calc the appropriate interval
//
gWinNt->EnterCriticalSection (&mNtCriticalSection);
SleepCount = (UINT32) (mTimerPeriod + 5000) / 10000;
gWinNt->LeaveCriticalSection (&mNtCriticalSection);
return gWinNt->timeSetEvent (
SleepCount,
0,
MMTimerThread,
(DWORD_PTR) NULL,
TIME_PERIODIC | TIME_KILL_SYNCHRONOUS | TIME_CALLBACK_FUNCTION
);
}
EFI_STATUS
EFIAPI
WinNtTimerDriverRegisterHandler (
IN EFI_TIMER_ARCH_PROTOCOL *This,
IN EFI_TIMER_NOTIFY NotifyFunction
)
/*++
Routine Description:
This function registers the handler NotifyFunction so it is called every time
the timer interrupt fires. It also passes the amount of time since the last
handler call to the NotifyFunction. If NotifyFunction is NULL, then the
handler is unregistered. If the handler is registered, then EFI_SUCCESS is
returned. If the CPU does not support registering a timer interrupt handler,
then EFI_UNSUPPORTED is returned. If an attempt is made to register a handler
when a handler is already registered, then EFI_ALREADY_STARTED is returned.
If an attempt is made to unregister a handler when a handler is not registered,
then EFI_INVALID_PARAMETER is returned. If an error occurs attempting to
register the NotifyFunction with the timer interrupt, then EFI_DEVICE_ERROR
is returned.
Arguments:
This - The EFI_TIMER_ARCH_PROTOCOL instance.
NotifyFunction - The function to call when a timer interrupt fires. This
function executes at TPL_HIGH_LEVEL. The DXE Core will
register a handler for the timer interrupt, so it can know
how much time has passed. This information is used to
signal timer based events. NULL will unregister the handler.
Returns:
EFI_SUCCESS - The timer handler was registered.
EFI_UNSUPPORTED - The platform does not support timer interrupts.
EFI_ALREADY_STARTED - NotifyFunction is not NULL, and a handler is already
registered.
EFI_INVALID_PARAMETER - NotifyFunction is NULL, and a handler was not
previously registered.
EFI_DEVICE_ERROR - The timer handler could not be registered.
--*/
{
//
// Check for invalid parameters
//
if (NotifyFunction == NULL && mTimerNotifyFunction == NULL) {
return EFI_INVALID_PARAMETER;
}
if (NotifyFunction != NULL && mTimerNotifyFunction != NULL) {
return EFI_ALREADY_STARTED;
}
//
// Use Critical Section to update the notification function that is
// used from the timer interrupt thread.
//
gWinNt->EnterCriticalSection (&mNtCriticalSection);
mTimerNotifyFunction = NotifyFunction;
gWinNt->LeaveCriticalSection (&mNtCriticalSection);
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
WinNtTimerDriverSetTimerPeriod (
IN EFI_TIMER_ARCH_PROTOCOL *This,
IN UINT64 TimerPeriod
)
/*++
Routine Description:
This function adjusts the period of timer interrupts to the value specified
by TimerPeriod. If the timer period is updated, then the selected timer
period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned. If
the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.
If an error occurs while attempting to update the timer period, then the
timer hardware will be put back in its state prior to this call, and
EFI_DEVICE_ERROR is returned. If TimerPeriod is 0, then the timer interrupt
is disabled. This is not the same as disabling the CPU's interrupts.
Instead, it must either turn off the timer hardware, or it must adjust the
interrupt controller so that a CPU interrupt is not generated when the timer
interrupt fires.
Arguments:
This - The EFI_TIMER_ARCH_PROTOCOL instance.
TimerPeriod - The rate to program the timer interrupt in 100 nS units. If
the timer hardware is not programmable, then EFI_UNSUPPORTED is
returned. If the timer is programmable, then the timer period
will be rounded up to the nearest timer period that is supported
by the timer hardware. If TimerPeriod is set to 0, then the
timer interrupts will be disabled.
Returns:
EFI_SUCCESS - The timer period was changed.
EFI_UNSUPPORTED - The platform cannot change the period of the timer interrupt.
EFI_DEVICE_ERROR - The timer period could not be changed due to a device error.
--*/
{
//
// If TimerPeriod is 0, then the timer thread should be canceled
//
if (TimerPeriod == 0) {
//
// Cancel the timer thread
//
gWinNt->EnterCriticalSection (&mNtCriticalSection);
mCancelTimerThread = TRUE;
gWinNt->LeaveCriticalSection (&mNtCriticalSection);
//
// Wait for the timer thread to exit
//
if (mMMTimerThreadID) {
gWinNt->timeKillEvent (mMMTimerThreadID);
}
mMMTimerThreadID = 0;
//
// Update the timer period
//
gWinNt->EnterCriticalSection (&mNtCriticalSection);
mTimerPeriod = TimerPeriod;
gWinNt->LeaveCriticalSection (&mNtCriticalSection);
//
// NULL out the thread handle so it will be re-created if the timer is enabled again
//
} else if ((TimerPeriod > TIMER_MINIMUM_VALUE) && (TimerPeriod < TIMER_MAXIMUM_VALUE)) {
//
// If the TimerPeriod is valid, then create and/or adjust the period of the timer thread
//
gWinNt->EnterCriticalSection (&mNtCriticalSection);
mTimerPeriod = TimerPeriod;
mCancelTimerThread = FALSE;
gWinNt->LeaveCriticalSection (&mNtCriticalSection);
//
// Get the starting tick location if we are just starting the timer thread
//
mNtLastTick = gWinNt->GetTickCount ();
if (mMMTimerThreadID) {
gWinNt->timeKillEvent (mMMTimerThreadID);
}
mMMTimerThreadID = 0;
mMMTimerThreadID = CreateNtTimer ();
}
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
WinNtTimerDriverGetTimerPeriod (
IN EFI_TIMER_ARCH_PROTOCOL *This,
OUT UINT64 *TimerPeriod
)
/*++
Routine Description:
This function retrieves the period of timer interrupts in 100 ns units,
returns that value in TimerPeriod, and returns EFI_SUCCESS. If TimerPeriod
is NULL, then EFI_INVALID_PARAMETER is returned. If a TimerPeriod of 0 is
returned, then the timer is currently disabled.
Arguments:
This - The EFI_TIMER_ARCH_PROTOCOL instance.
TimerPeriod - A pointer to the timer period to retrieve in 100 ns units. If
0 is returned, then the timer is currently disabled.
Returns:
EFI_SUCCESS - The timer period was returned in TimerPeriod.
EFI_INVALID_PARAMETER - TimerPeriod is NULL.
--*/
{
if (TimerPeriod == NULL) {
return EFI_INVALID_PARAMETER;
}
*TimerPeriod = mTimerPeriod;
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
WinNtTimerDriverGenerateSoftInterrupt (
IN EFI_TIMER_ARCH_PROTOCOL *This
)
/*++
Routine Description:
This function generates a soft timer interrupt. If the platform does not support soft
timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned.
If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler()
service, then a soft timer interrupt will be generated. If the timer interrupt is
enabled when this service is called, then the registered handler will be invoked. The
registered handler should not be able to distinguish a hardware-generated timer
interrupt from a software-generated timer interrupt.
Arguments:
This - The EFI_TIMER_ARCH_PROTOCOL instance.
Returns:
EFI_SUCCESS - The soft timer interrupt was generated.
EFI_UNSUPPORTEDT - The platform does not support the generation of soft timer interrupts.
--*/
{
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
WinNtTimerDriverInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Initialize the Timer Architectural Protocol driver
Arguments:
ImageHandle - ImageHandle of the loaded driver
SystemTable - Pointer to the System Table
Returns:
EFI_SUCCESS - Timer Architectural Protocol created
EFI_OUT_OF_RESOURCES - Not enough resources available to initialize driver.
EFI_DEVICE_ERROR - A device error occured attempting to initialize the driver.
--*/
{
EFI_STATUS Status;
UINTN Result;
EFI_HANDLE Handle;
//
// Make sure the Timer Architectural Protocol is not already installed in the system
//
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiTimerArchProtocolGuid);
//
// Get the CPU Architectural Protocol instance
//
Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, &mCpu);
ASSERT_EFI_ERROR (Status);
//
// Get our handle so the timer tick thread can suspend
//
Result = gWinNt->DuplicateHandle (
gWinNt->GetCurrentProcess (),
gWinNt->GetCurrentThread (),
gWinNt->GetCurrentProcess (),
&mNtMainThreadHandle,
0,
FALSE,
DUPLICATE_SAME_ACCESS
);
if (Result == 0) {
return EFI_DEVICE_ERROR;
}
//
// Initialize Critical Section used to update variables shared between the main
// thread and the timer interrupt thread.
//
gWinNt->InitializeCriticalSection (&mNtCriticalSection);
//
// Start the timer thread at the default timer period
//
Status = mTimer.SetTimerPeriod (&mTimer, DEFAULT_TIMER_TICK_DURATION);
if (EFI_ERROR (Status)) {
gWinNt->DeleteCriticalSection (&mNtCriticalSection);
return Status;
}
//
// Install the Timer Architectural Protocol onto a new handle
//
Handle = NULL;
Status = gBS->InstallProtocolInterface (
&Handle,
&gEfiTimerArchProtocolGuid,
EFI_NATIVE_INTERFACE,
&mTimer
);
if (EFI_ERROR (Status)) {
//
// Cancel the timer
//
mTimer.SetTimerPeriod (&mTimer, 0);
gWinNt->DeleteCriticalSection (&mNtCriticalSection);
return Status;
}
return EFI_SUCCESS;
}

View File

@@ -0,0 +1,28 @@
/*++
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:
Timer.dxs
Abstract:
Dependency expression source file.
--*/
#include <AutoGen.h>
#include <DxeDepex.h>
DEPENDENCY_START
EFI_CPU_ARCH_PROTOCOL_GUID
DEPENDENCY_END

View File

@@ -0,0 +1,162 @@
/*++
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:
Timer.h
Abstract:
NT Emulation Architectural Protocol Driver as defined in Tiano.
This Timer module uses an NT Thread to simulate the timer-tick driven
timer service.
--*/
#ifndef _TIMER_H_
#define _TIMER_H_
//
// Legal timer value range in 100 ns units
//
#define TIMER_MINIMUM_VALUE 0
#define TIMER_MAXIMUM_VALUE (0x100000000 - 1)
//
// Default timer value in 100 ns units (10 ms)
//
#define DEFAULT_TIMER_TICK_DURATION 100000
//
// Function Prototypes
//
EFI_STATUS
EFIAPI
WinNtTimerDriverInitialize (
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
EFIAPI
WinNtTimerDriverRegisterHandler (
IN EFI_TIMER_ARCH_PROTOCOL *This,
IN EFI_TIMER_NOTIFY NotifyFunction
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
NotifyFunction - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
EFIAPI
WinNtTimerDriverSetTimerPeriod (
IN EFI_TIMER_ARCH_PROTOCOL *This,
IN UINT64 TimerPeriod
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
TimerPeriod - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
EFIAPI
WinNtTimerDriverGetTimerPeriod (
IN EFI_TIMER_ARCH_PROTOCOL *This,
OUT UINT64 *TimerPeriod
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
TimerPeriod - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
EFIAPI
WinNtTimerDriverGenerateSoftInterrupt (
IN EFI_TIMER_ARCH_PROTOCOL *This
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Returns:
TODO: add return values
--*/
;
#endif

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MbdHeader>
<BaseName>Timer</BaseName>
<Guid>C3811036-710B-4E39-8CF1-0AF9BE3A8198</Guid>
<Version>0</Version>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>
<Created>2006-03-14 17:04</Created>
<Modified>2006-03-19 15:17</Modified>
</MbdHeader>
<Libraries>
<Library>UefiBootServicesTableLib</Library>
<Library>BaseDebugLibReportStatusCode</Library>
<Library>DxeHobLib</Library>
<Library>BaseLib</Library>
<Library>UefiLib</Library>
<Library>HiiLib</Library>
<Library>UefiMemoryLib</Library>
<Library>UefiDriverEntryPoint</Library>
<Library>DxeReportStatusCodeLib</Library>
<Library>DxeWinNtLib</Library>
<Library>DxeMemoryAllocationLib</Library>
</Libraries>
<BuildOptions ToolChain="MSFT">
<ImageEntryPoint>_ModuleEntryPoint</ImageEntryPoint>
</BuildOptions>
</ModuleBuildDescription>

View File

@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MsaHeader>
<BaseName>Timer</BaseName>
<ModuleType>DXE_DRIVER</ModuleType>
<ComponentType>BS_DRIVER</ComponentType>
<Guid>C3811036-710B-4E39-8CF1-0AF9BE3A8198</Guid>
<Version>0</Version>
<Abstract>Component description file for Timer module.</Abstract>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>0</Specification>
<Created>2006-03-14 17:04</Created>
<Updated>2006-03-19 15:17</Updated>
</MsaHeader>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverEntryPoint</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">WinNtLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">MemoryAllocationLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>Timer.h</Filename>
<Filename>Timer.c</Filename>
<Filename>Timer.dxs</Filename>
</SourceFiles>
<Includes>
<PackageName>MdePkg</PackageName>
<PackageName>EdkModulePkg</PackageName>
<PackageName>EdkNt32Pkg</PackageName>
</Includes>
<Protocols>
<Protocol Usage="ALWAYS_PRODUCED">Timer</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">Cpu</Protocol>
</Protocols>
<Externs>
<Extern>
<ModuleEntryPoint>WinNtTimerDriverInitialize</ModuleEntryPoint>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
<project basedir="." default="Timer"><!--Apply external ANT tasks-->
<taskdef resource="GenBuild.tasks"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property environment="env"/>
<property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
<import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
<property name="MODULE_RELATIVE_PATH" value="Dxe\WinNtThunk\Chipset\Timer"/>
<property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
<property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
<target name="Timer">
<GenBuild baseName="Timer" mbdFilename="${MODULE_DIR}\Timer.mbd" msaFilename="${MODULE_DIR}\Timer.msa"/>
</target>
<target depends="Timer_clean" name="clean"/>
<target depends="Timer_cleanall" name="cleanall"/>
<target name="Timer_clean">
<OutputDirSetup baseName="Timer" mbdFilename="${MODULE_DIR}\Timer.mbd" msaFilename="${MODULE_DIR}\Timer.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\Timer_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\Timer_build.xml" target="clean"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
</target>
<target name="Timer_cleanall">
<OutputDirSetup baseName="Timer" mbdFilename="${MODULE_DIR}\Timer.mbd" msaFilename="${MODULE_DIR}\Timer.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\Timer_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\Timer_build.xml" target="cleanall"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}"/>
<delete dir="${DEST_DIR_DEBUG}"/>
<delete>
<fileset dir="${BIN_DIR}" includes="**Timer*"/>
</delete>
</target>
</project>

View File

@@ -0,0 +1,736 @@
/*++
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:
Cpu.c
Abstract:
NT Emulation Architectural Protocol Driver as defined in Tiano.
This CPU module abstracts the interrupt subsystem of a platform and
the CPU-specific setjump/long pair. Other services are not implemented
in this driver.
--*/
#include "CpuDriver.h"
//
// This is the VFR compiler generated header file which defines the
// string identifiers.
//
#include STRING_DEFINES_FILE
#define EFI_CPU_DATA_MAXIMUM_LENGTH 0x100
EFI_STATUS
EFIAPI
InitializeCpu (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
VOID
EFIAPI
WinNtIoProtocolNotifyFunction (
IN EFI_EVENT Event,
IN VOID *Context
);
typedef union {
EFI_CPU_DATA_RECORD *DataRecord;
UINT8 *Raw;
} EFI_CPU_DATA_RECORD_BUFFER;
EFI_SUBCLASS_TYPE1_HEADER mCpuDataRecordHeader = {
EFI_PROCESSOR_SUBCLASS_VERSION, // Version
sizeof (EFI_SUBCLASS_TYPE1_HEADER), // Header Size
0, // Instance, Initialize later
EFI_SUBCLASS_INSTANCE_NON_APPLICABLE, // SubInstance
0 // RecordType, Initialize later
};
//
// Service routines for the driver
//
STATIC
EFI_STATUS
EFIAPI
WinNtFlushCpuDataCache (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_PHYSICAL_ADDRESS Start,
IN UINT64 Length,
IN EFI_CPU_FLUSH_TYPE FlushType
)
/*++
Routine Description:
This routine would provide support for flushing the CPU data cache.
In the case of NT emulation environment, this flushing is not necessary and
is thus not implemented.
Arguments:
Pointer to CPU Architectural Protocol interface
Start adddress in memory to flush
Length of memory to flush
Flush type
Returns:
Status
EFI_SUCCESS
--*/
// TODO: This - add argument and description to function comment
// TODO: FlushType - add argument and description to function comment
// TODO: EFI_UNSUPPORTED - add return value to function comment
{
if (FlushType == EfiCpuFlushTypeWriteBackInvalidate) {
//
// Only WB flush is supported. We actually need do nothing on NT emulator
// environment. Classify this to follow EFI spec
//
return EFI_SUCCESS;
}
//
// Other flush types are not supported by NT emulator
//
return EFI_UNSUPPORTED;
}
STATIC
EFI_STATUS
EFIAPI
WinNtEnableInterrupt (
IN EFI_CPU_ARCH_PROTOCOL *This
)
/*++
Routine Description:
This routine provides support for emulation of the interrupt enable of the
the system. For our purposes, CPU enable is just a BOOLEAN that the Timer
Architectural Protocol observes in order to defer behaviour while in its
emulated interrupt, or timer tick.
Arguments:
Pointer to CPU Architectural Protocol interface
Returns:
Status
EFI_SUCCESS
--*/
// TODO: This - add argument and description to function comment
{
CPU_ARCH_PROTOCOL_PRIVATE *Private;
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
Private->InterruptState = TRUE;
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
EFIAPI
WinNtDisableInterrupt (
IN EFI_CPU_ARCH_PROTOCOL *This
)
/*++
Routine Description:
This routine provides support for emulation of the interrupt disable of the
the system. For our purposes, CPU enable is just a BOOLEAN that the Timer
Architectural Protocol observes in order to defer behaviour while in its
emulated interrupt, or timer tick.
Arguments:
Pointer to CPU Architectural Protocol interface
Returns:
Status
EFI_SUCCESS
--*/
// TODO: This - add argument and description to function comment
{
CPU_ARCH_PROTOCOL_PRIVATE *Private;
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
Private->InterruptState = FALSE;
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
EFIAPI
WinNtGetInterruptState (
IN EFI_CPU_ARCH_PROTOCOL *This,
OUT BOOLEAN *State
)
/*++
Routine Description:
This routine provides support for emulation of the interrupt disable of the
the system. For our purposes, CPU enable is just a BOOLEAN that the Timer
Architectural Protocol observes in order to defer behaviour while in its
emulated interrupt, or timer tick.
Arguments:
Pointer to CPU Architectural Protocol interface
Returns:
Status
EFI_SUCCESS
--*/
// TODO: This - add argument and description to function comment
// TODO: State - add argument and description to function comment
// TODO: EFI_INVALID_PARAMETER - add return value to function comment
{
CPU_ARCH_PROTOCOL_PRIVATE *Private;
if (State == NULL) {
return EFI_INVALID_PARAMETER;
}
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
*State = Private->InterruptState;
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
EFIAPI
WinNtInit (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_CPU_INIT_TYPE InitType
)
/*++
Routine Description:
This routine would support generation of a CPU INIT. At
present, this code does not provide emulation.
Arguments:
Pointer to CPU Architectural Protocol interface
INIT Type
Returns:
Status
EFI_UNSUPPORTED - not yet implemented
--*/
// TODO: This - add argument and description to function comment
// TODO: InitType - add argument and description to function comment
{
CPU_ARCH_PROTOCOL_PRIVATE *Private;
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
return EFI_UNSUPPORTED;
}
STATIC
EFI_STATUS
EFIAPI
WinNtRegisterInterruptHandler (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_EXCEPTION_TYPE InterruptType,
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
)
/*++
Routine Description:
This routine would support registration of an interrupt handler. At
present, this code does not provide emulation.
Arguments:
Pointer to CPU Architectural Protocol interface
Pointer to interrupt handlers
Interrupt type
Returns:
Status
EFI_UNSUPPORTED - not yet implemented
--*/
// TODO: This - add argument and description to function comment
// TODO: InterruptType - add argument and description to function comment
// TODO: InterruptHandler - add argument and description to function comment
{
CPU_ARCH_PROTOCOL_PRIVATE *Private;
//
// Do parameter checking for EFI spec conformance
//
if (InterruptType < 0 || InterruptType > 0xff) {
return EFI_UNSUPPORTED;
}
//
// Do nothing for Nt32 emulation
//
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
return EFI_UNSUPPORTED;
}
STATIC
EFI_STATUS
EFIAPI
WinNtGetTimerValue (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN UINT32 TimerIndex,
OUT UINT64 *TimerValue,
OUT UINT64 *TimerPeriod OPTIONAL
)
/*++
Routine Description:
This routine would support querying of an on-CPU timer. At present,
this code does not provide timer emulation.
Arguments:
This - Pointer to CPU Architectural Protocol interface
TimerIndex - Index of given CPU timer
TimerValue - Output of the timer
TimerPeriod - Output of the timer period
Returns:
EFI_UNSUPPORTED - not yet implemented
EFI_INVALID_PARAMETER - TimeValue is NULL
--*/
{
if (TimerValue == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// No timer supported
//
return EFI_UNSUPPORTED;
}
STATIC
EFI_STATUS
EFIAPI
WinNtSetMemoryAttributes (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_PHYSICAL_ADDRESS BaseAddress,
IN UINT64 Length,
IN UINT64 Attributes
)
/*++
Routine Description:
This routine would support querying of an on-CPU timer. At present,
this code does not provide timer emulation.
Arguments:
Pointer to CPU Architectural Protocol interface
Start address of memory region
The size in bytes of the memory region
The bit mask of attributes to set for the memory region
Returns:
Status
EFI_UNSUPPORTED - not yet implemented
--*/
// TODO: This - add argument and description to function comment
// TODO: BaseAddress - add argument and description to function comment
// TODO: Length - add argument and description to function comment
// TODO: Attributes - add argument and description to function comment
// TODO: EFI_INVALID_PARAMETER - add return value to function comment
{
CPU_ARCH_PROTOCOL_PRIVATE *Private;
//
// Check for invalid parameter for Spec conformance
//
if (Length == 0) {
return EFI_INVALID_PARAMETER;
}
//
// Do nothing for Nt32 emulation
//
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
InitializeCpu (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Initialize the state information for the CPU Architectural Protocol
Arguments:
ImageHandle of the loaded driver
Pointer to the System Table
Returns:
Status
EFI_SUCCESS - protocol instance can be published
EFI_OUT_OF_RESOURCES - cannot allocate protocol data structure
EFI_DEVICE_ERROR - cannot create the thread
--*/
// TODO: SystemTable - add argument and description to function comment
{
EFI_STATUS Status;
EFI_EVENT Event;
CPU_ARCH_PROTOCOL_PRIVATE *Private;
VOID *Registration;
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (CPU_ARCH_PROTOCOL_PRIVATE),
&Private
);
ASSERT_EFI_ERROR (Status);
Private->Signature = CPU_ARCH_PROT_PRIVATE_SIGNATURE;
Private->Cpu.FlushDataCache = WinNtFlushCpuDataCache;
Private->Cpu.EnableInterrupt = WinNtEnableInterrupt;
Private->Cpu.DisableInterrupt = WinNtDisableInterrupt;
Private->Cpu.GetInterruptState = WinNtGetInterruptState;
Private->Cpu.Init = WinNtInit;
Private->Cpu.RegisterInterruptHandler = WinNtRegisterInterruptHandler;
Private->Cpu.GetTimerValue = WinNtGetTimerValue;
Private->Cpu.SetMemoryAttributes = WinNtSetMemoryAttributes;
Private->Cpu.NumberOfTimers = 0;
Private->Cpu.DmaBufferAlignment = 4;
Private->InterruptState = TRUE;
Private->CpuIo.Mem.Read = CpuMemoryServiceRead;
Private->CpuIo.Mem.Write = CpuMemoryServiceWrite;
Private->CpuIo.Io.Read = CpuIoServiceRead;
Private->CpuIo.Io.Write = CpuIoServiceWrite;
Private->Handle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (
&Private->Handle,
&gEfiCpuArchProtocolGuid, &Private->Cpu,
&gEfiCpuIoProtocolGuid, &Private->CpuIo,
NULL
);
ASSERT_EFI_ERROR (Status);
//
// Install notify function to store processor data to HII database and data hub.
//
Status = gBS->CreateEvent (
EFI_EVENT_NOTIFY_SIGNAL,
EFI_TPL_CALLBACK,
WinNtIoProtocolNotifyFunction,
ImageHandle,
&Event
);
ASSERT (!EFI_ERROR (Status));
Status = gBS->RegisterProtocolNotify (
&gEfiWinNtIoProtocolGuid,
Event,
&Registration
);
ASSERT (!EFI_ERROR (Status));
//
// Should be at EFI_D_INFO, but lets us now things are running
//
DEBUG ((EFI_D_ERROR, "CPU Architectural Protocol Loaded\n"));
return Status;
}
UINTN
Atoi (
CHAR16 *String
)
/*++
Routine Description:
Convert a unicode string to a UINTN
Arguments:
String - Unicode string.
Returns:
UINTN of the number represented by 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;
}
VOID
EFIAPI
WinNtIoProtocolNotifyFunction (
IN EFI_EVENT Event,
IN VOID *Context
)
/*++
Routine Description:
This function will log processor version and frequency data to data hub.
Arguments:
Event - Event whose notification function is being invoked.
Context - Pointer to the notification function's context.
Returns:
None.
--*/
{
EFI_STATUS Status;
EFI_CPU_DATA_RECORD_BUFFER RecordBuffer;
EFI_DATA_RECORD_HEADER *Record;
EFI_SUBCLASS_TYPE1_HEADER *DataHeader;
UINT32 HeaderSize;
UINT32 TotalSize;
UINTN HandleCount;
UINTN HandleIndex;
UINT64 MonotonicCount;
BOOLEAN RecordFound;
EFI_HANDLE *HandleBuffer;
EFI_WIN_NT_IO_PROTOCOL *WinNtIo;
EFI_DATA_HUB_PROTOCOL *DataHub;
EFI_HII_PROTOCOL *Hii;
EFI_HII_HANDLE StringHandle;
EFI_HII_PACKAGES *PackageList;
STRING_REF Token;
DataHub = NULL;
Token = 0;
MonotonicCount = 0;
RecordFound = FALSE;
//
// Retrieve the list of all handles from the handle database
//
Status = gBS->LocateHandleBuffer (
AllHandles,
&gEfiWinNtIoProtocolGuid,
NULL,
&HandleCount,
&HandleBuffer
);
if (EFI_ERROR (Status)) {
return ;
}
//
// Locate HII protocol
//
Status = gBS->LocateProtocol (&gEfiHiiProtocolGuid, NULL, &Hii);
if (EFI_ERROR (Status)) {
return ;
}
//
// Locate DataHub protocol.
//
Status = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, &DataHub);
if (EFI_ERROR (Status)) {
return ;
}
//
// Initialize data record header
//
mCpuDataRecordHeader.Instance = 1;
HeaderSize = sizeof (EFI_SUBCLASS_TYPE1_HEADER);
RecordBuffer.Raw = AllocatePool (HeaderSize + EFI_CPU_DATA_MAXIMUM_LENGTH);
if (RecordBuffer.Raw == NULL) {
return ;
}
CopyMem (RecordBuffer.Raw, &mCpuDataRecordHeader, HeaderSize);
//
// Search the Handle array to find the CPU model and speed information
//
for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
Status = gBS->OpenProtocol (
HandleBuffer[HandleIndex],
&gEfiWinNtIoProtocolGuid,
&WinNtIo,
Context,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
continue;
}
if ((WinNtIo->WinNtThunk->Signature == EFI_WIN_NT_THUNK_PROTOCOL_SIGNATURE) &&
CompareGuid (WinNtIo->TypeGuid, &gEfiWinNtCPUModelGuid)
) {
//
// Check if this record has been stored in data hub
//
do {
Status = DataHub->GetNextRecord (DataHub, &MonotonicCount, NULL, &Record);
if (Record->DataRecordClass == EFI_DATA_RECORD_CLASS_DATA) {
DataHeader = (EFI_SUBCLASS_TYPE1_HEADER *) (Record + 1);
if (CompareGuid (&Record->DataRecordGuid, &gEfiProcessorSubClassGuid) &&
(DataHeader->RecordType == ProcessorVersionRecordType)
) {
RecordFound = TRUE;
}
}
} while (MonotonicCount != 0);
if (RecordFound) {
RecordFound = FALSE;
continue;
}
//
// Initialize strings to HII database
//
PackageList = PreparePackages (1, &gEfiProcessorProducerGuid, STRING_ARRAY_NAME);
Status = Hii->NewPack (Hii, PackageList, &StringHandle);
ASSERT (!EFI_ERROR (Status));
gBS->FreePool (PackageList);
//
// Store processor version data record to data hub
//
Status = Hii->NewString (Hii, NULL, StringHandle, &Token, WinNtIo->EnvString);
ASSERT (!EFI_ERROR (Status));
RecordBuffer.DataRecord->DataRecordHeader.RecordType = ProcessorVersionRecordType;
RecordBuffer.DataRecord->VariableRecord.ProcessorVersion = Token;
TotalSize = HeaderSize + sizeof (EFI_PROCESSOR_VERSION_DATA);
Status = DataHub->LogData (
DataHub,
&gEfiProcessorSubClassGuid,
&gEfiProcessorProducerGuid,
EFI_DATA_RECORD_CLASS_DATA,
RecordBuffer.Raw,
TotalSize
);
}
if ((WinNtIo->WinNtThunk->Signature == EFI_WIN_NT_THUNK_PROTOCOL_SIGNATURE) &&
CompareGuid (WinNtIo->TypeGuid, &gEfiWinNtCPUSpeedGuid)
) {
//
// Check if this record has been stored in data hub
//
do {
Status = DataHub->GetNextRecord (DataHub, &MonotonicCount, NULL, &Record);
if (Record->DataRecordClass == EFI_DATA_RECORD_CLASS_DATA) {
DataHeader = (EFI_SUBCLASS_TYPE1_HEADER *) (Record + 1);
if (CompareGuid (&Record->DataRecordGuid, &gEfiProcessorSubClassGuid) &&
(DataHeader->RecordType == ProcessorCoreFrequencyRecordType)
) {
RecordFound = TRUE;
}
}
} while (MonotonicCount != 0);
if (RecordFound) {
RecordFound = FALSE;
continue;
}
//
// Store CPU frequency data record to data hub
//
RecordBuffer.DataRecord->DataRecordHeader.RecordType = ProcessorCoreFrequencyRecordType;
RecordBuffer.DataRecord->VariableRecord.ProcessorCoreFrequency.Value = (UINT16) Atoi (WinNtIo->EnvString);
RecordBuffer.DataRecord->VariableRecord.ProcessorCoreFrequency.Exponent = 6;
TotalSize = HeaderSize + sizeof (EFI_PROCESSOR_CORE_FREQUENCY_DATA);
Status = DataHub->LogData (
DataHub,
&gEfiProcessorSubClassGuid,
&gEfiProcessorProducerGuid,
EFI_DATA_RECORD_CLASS_DATA,
RecordBuffer.Raw,
TotalSize
);
gBS->FreePool (RecordBuffer.Raw);
}
gBS->CloseProtocol (
HandleBuffer[HandleIndex],
&gEfiWinNtIoProtocolGuid,
Context,
NULL
);
}
}

View File

@@ -0,0 +1,28 @@
/*++
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:
Cpu.dxs
Abstract:
Dependency expression source file.
--*/
#include <AutoGen.h>
#include <DxeDepex.h>
DEPENDENCY_START
EFI_DATA_HUB_PROTOCOL_GUID AND
EFI_HII_PROTOCOL_GUID
DEPENDENCY_END

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MbdHeader>
<BaseName>Cpu</BaseName>
<Guid>ee993080-5197-4d4e-b63c-f1f7413e33ce</Guid>
<Version>0</Version>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>
<Created>2006-03-14 17:04</Created>
<Modified>2006-03-23 16:17</Modified>
</MbdHeader>
<Libraries>
<Library>UefiBootServicesTableLib</Library>
<Library>BaseLib</Library>
<Library>UefiLib</Library>
<Library>HiiLib</Library>
<Library>UefiMemoryLib</Library>
<Library>UefiDriverEntryPoint</Library>
<Library>DxeReportStatusCodeLib</Library>
<Library>BaseDebugLibReportStatusCode</Library>
<Library>DxeMemoryAllocationLib</Library>
</Libraries>
<BuildOptions ToolChain="MSFT">
<ImageEntryPoint>_ModuleEntryPoint</ImageEntryPoint>
<Option>C_STD_FLAGS = ${C_STD_FLAGS} /DSTRING_ARRAY_NAME=${BASE_NAME}Strings</Option>
<Option>C_STD_FLAGS = ${C_STD_FLAGS} /DSTRING_DEFINES_FILE=\"${BASE_NAME}StrDefs.h\"</Option>
</BuildOptions>
</ModuleBuildDescription>

View File

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MsaHeader>
<BaseName>Cpu</BaseName>
<ModuleType>DXE_DRIVER</ModuleType>
<ComponentType>BS_DRIVER</ComponentType>
<Guid>ee993080-5197-4d4e-b63c-f1f7413e33ce</Guid>
<Version>0</Version>
<Abstract>Component description file for Cpu module.</Abstract>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>0</Specification>
<Created>2006-03-14 17:04</Created>
<Updated>2006-03-23 16:17</Updated>
</MsaHeader>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">HiiLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverEntryPoint</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">MemoryAllocationLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>Strings.uni</Filename>
<Filename>CpuDriver.h</Filename>
<Filename>Cpu.c</Filename>
<Filename>CpuIo.c</Filename>
<Filename>Cpu.dxs</Filename>
</SourceFiles>
<Includes>
<PackageName>MdePkg</PackageName>
<PackageName>EdkModulePkg</PackageName>
<PackageName>EdkNt32Pkg</PackageName>
</Includes>
<Protocols>
<Protocol Usage="ALWAYS_PRODUCED">Cpu</Protocol>
<Protocol Usage="ALWAYS_PRODUCED">CpuIo</Protocol>
<Protocol Usage="SOMETIMES_CONSUMED">Hii</Protocol>
<Protocol Usage="SOMETIMES_CONSUMED">DataHub</Protocol>
<ProtocolNotify Usage="SOMETIMES_CONSUMED">WinNtIo</ProtocolNotify>
</Protocols>
<DataHubs>
<DataHubRecord Usage="SOMETIMES_PRODUCED">ProcessorVersion</DataHubRecord>
<DataHubRecord Usage="SOMETIMES_PRODUCED">ProcessorCoreFrequency</DataHubRecord>
</DataHubs>
<Guids>
<GuidEntry Usage="SOMETIMES_CONSUMED">
<C_Name>ProcessorProducer</C_Name>
</GuidEntry>
<GuidEntry Usage="SOMETIMES_CONSUMED">
<C_Name>ProcessorSubClass</C_Name>
</GuidEntry>
<GuidEntry Usage="SOMETIMES_CONSUMED">
<C_Name>WinNtCPUModel</C_Name>
</GuidEntry>
<GuidEntry Usage="SOMETIMES_CONSUMED">
<C_Name>WinNtCPUSpeed</C_Name>
</GuidEntry>
</Guids>
<Externs>
<Extern>
<ModuleEntryPoint>InitializeCpu</ModuleEntryPoint>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@@ -0,0 +1,97 @@
/*++
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:
CpuDriver.h
Abstract:
NT Emulation Architectural Protocol Driver as defined in Tiano.
--*/
#ifndef _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_
#define _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_
extern UINT8 STRING_ARRAY_NAME[];
//
// Internal Data Structures
//
#define CPU_ARCH_PROT_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('c', 'a', 'p', 'd')
typedef struct {
UINTN Signature;
EFI_HANDLE Handle;
EFI_CPU_ARCH_PROTOCOL Cpu;
EFI_CPU_IO_PROTOCOL CpuIo;
//
// Local Data for CPU interface goes here
//
CRITICAL_SECTION NtCriticalSection;
BOOLEAN InterruptState;
} CPU_ARCH_PROTOCOL_PRIVATE;
#define CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \
CR (a, \
CPU_ARCH_PROTOCOL_PRIVATE, \
Cpu, \
CPU_ARCH_PROT_PRIVATE_SIGNATURE \
)
EFI_STATUS
EFIAPI
CpuMemoryServiceRead (
IN EFI_CPU_IO_PROTOCOL *This,
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
);
EFI_STATUS
EFIAPI
CpuMemoryServiceWrite (
IN EFI_CPU_IO_PROTOCOL *This,
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
);
EFI_STATUS
EFIAPI
CpuIoServiceRead (
IN EFI_CPU_IO_PROTOCOL *This,
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 UserAddress,
IN UINTN Count,
IN OUT VOID *UserBuffer
);
EFI_STATUS
EFIAPI
CpuIoServiceWrite (
IN EFI_CPU_IO_PROTOCOL *This,
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 UserAddress,
IN UINTN Count,
IN OUT VOID *UserBuffer
);
#endif

View File

@@ -0,0 +1,335 @@
/*++
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:
CpuIo.c
Abstract:
This is the code that publishes the CPU I/O Protocol.
The intent herein is to have a single I/O service that can load
as early as possible, extend into runtime, and be layered upon by
the implementations of architectural protocols and the PCI Root
Bridge I/O Protocol.
--*/
#include <CpuDriver.h>
#define IA32_MAX_IO_ADDRESS 0xFFFF
#define IA32_MAX_MEM_ADDRESS 0xFFFFFFFF
EFI_CPU_IO_PROTOCOL mCpuIoProtocol;
EFI_STATUS
CpuIoCheckAddressRange (
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN VOID *Buffer,
IN UINT64 Limit
);
EFI_STATUS
EFIAPI
CpuMemoryServiceRead (
IN EFI_CPU_IO_PROTOCOL *This,
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
/*++
Routine Description:
Perform the Memory Access Read service for the CPU I/O Protocol
Arguments:
Pointer to an instance of the CPU I/O Protocol
Width of the Memory Access
Address of the Memory access
Count of the number of accesses to perform
Pointer to the buffer to read or write from memory
Returns:
Status
EFI_SUCCESS - The data was read from or written to the EFI
System.
EFI_INVALID_PARAMETER - Width is invalid for this EFI System.
EFI_INVALID_PARAMETER - Buffer is NULL.
EFI_UNSUPPORTED - The Buffer is not aligned for the given Width.
EFI_UNSUPPORTED - The address range specified by Address, Width,
and Count is not valid for this EFI System.
--*/
// TODO: This - add argument and description to function comment
{
EFI_STATUS Status;
if (!Buffer) {
return EFI_INVALID_PARAMETER;
}
Status = CpuIoCheckAddressRange (Width, Address, Count, Buffer, IA32_MAX_MEM_ADDRESS);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Do nothing for Nt32 version
//
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
CpuMemoryServiceWrite (
IN EFI_CPU_IO_PROTOCOL *This,
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
/*++
Routine Description:
Perform the Memory Access Read service for the CPU I/O Protocol
Arguments:
Pointer to an instance of the CPU I/O Protocol
Width of the Memory Access
Address of the Memory access
Count of the number of accesses to perform
Pointer to the buffer to read or write from memory
Returns:
Status
EFI_SUCCESS - The data was read from or written to the EFI System.
EFI_INVALID_PARAMETER - Width is invalid for this EFI System.
EFI_INVALID_PARAMETER - Buffer is NULL.
EFI_UNSUPPORTED - The Buffer is not aligned for the given Width.
EFI_UNSUPPORTED - The address range specified by Address, Width, and
Count is not valid for this EFI System.
--*/
// TODO: This - add argument and description to function comment
{
EFI_STATUS Status;
if (!Buffer) {
return EFI_INVALID_PARAMETER;
}
Status = CpuIoCheckAddressRange (Width, Address, Count, Buffer, IA32_MAX_MEM_ADDRESS);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Do nothing for Nt32 version
//
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
CpuIoServiceRead (
IN EFI_CPU_IO_PROTOCOL *This,
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 UserAddress,
IN UINTN Count,
IN OUT VOID *UserBuffer
)
/*++
Routine Description:
This is the service that implements the I/O read
Arguments:
Pointer to an instance of the CPU I/O Protocol
Width of the Memory Access
Address of the I/O access
Count of the number of accesses to perform
Pointer to the buffer to read or write from I/O space
Returns:
Status
EFI_SUCCESS - The data was read from or written to the EFI System.
EFI_INVALID_PARAMETER - Width is invalid for this EFI System.
EFI_INVALID_PARAMETER - Buffer is NULL.
EFI_UNSUPPORTED - The Buffer is not aligned for the given Width.
EFI_UNSUPPORTED - The address range specified by Address, Width, and
Count is not valid for this EFI System.
--*/
// TODO: This - add argument and description to function comment
// TODO: UserAddress - add argument and description to function comment
// TODO: UserBuffer - add argument and description to function comment
{
UINTN Address;
EFI_STATUS Status;
if (!UserBuffer) {
return EFI_INVALID_PARAMETER;
}
Address = (UINTN) UserAddress;
if (Width >= EfiCpuIoWidthMaximum) {
return EFI_INVALID_PARAMETER;
}
Status = CpuIoCheckAddressRange (Width, Address, Count, UserBuffer, IA32_MAX_IO_ADDRESS);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Do nothing for Nt32 version
//
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
CpuIoServiceWrite (
IN EFI_CPU_IO_PROTOCOL *This,
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 UserAddress,
IN UINTN Count,
IN OUT VOID *UserBuffer
)
/*++
Routine Description:
This is the service that implements the I/O Write
Arguments:
Pointer to an instance of the CPU I/O Protocol
Width of the Memory Access
Address of the I/O access
Count of the number of accesses to perform
Pointer to the buffer to read or write from I/O space
Returns:
Status
Status
EFI_SUCCESS - The data was read from or written to the EFI System.
EFI_INVALID_PARAMETER - Width is invalid for this EFI System.
EFI_INVALID_PARAMETER - Buffer is NULL.
EFI_UNSUPPORTED - The Buffer is not aligned for the given Width.
EFI_UNSUPPORTED - The address range specified by Address, Width, and
Count is not valid for this EFI System.
--*/
// TODO: This - add argument and description to function comment
// TODO: UserAddress - add argument and description to function comment
// TODO: UserBuffer - add argument and description to function comment
{
UINTN Address;
EFI_STATUS Status;
if (!UserBuffer) {
return EFI_INVALID_PARAMETER;
}
Address = (UINTN) UserAddress;
if (Width >= EfiCpuIoWidthMaximum) {
return EFI_INVALID_PARAMETER;
}
Status = CpuIoCheckAddressRange (Width, Address, Count, UserBuffer, IA32_MAX_IO_ADDRESS);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Do nothing for Nt32 version
//
return EFI_SUCCESS;
}
EFI_STATUS
CpuIoCheckAddressRange (
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN VOID *Buffer,
IN UINT64 Limit
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Width - TODO: add argument description
Address - TODO: add argument description
Count - TODO: add argument description
Buffer - TODO: add argument description
Limit - TODO: add argument description
Returns:
EFI_UNSUPPORTED - TODO: Add description for return value
EFI_UNSUPPORTED - TODO: Add description for return value
EFI_UNSUPPORTED - TODO: Add description for return value
EFI_SUCCESS - TODO: Add description for return value
--*/
{
UINTN AlignMask;
if (Address > Limit) {
return EFI_UNSUPPORTED;
}
//
// For FiFo type, the target address won't increase during the access, so treat count as 1
//
if (Width >= EfiCpuIoWidthFifoUint8 && Width <= EfiCpuIoWidthFifoUint64) {
Count = 1;
}
Width = Width & 0x03;
if (Address - 1 + (1 << Width) * Count > Limit) {
return EFI_UNSUPPORTED;
}
AlignMask = (1 << Width) - 1;
if ((UINTN) Buffer & AlignMask) {
return EFI_UNSUPPORTED;
}
return EFI_SUCCESS;
}

Binary file not shown.

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
<project basedir="." default="Cpu"><!--Apply external ANT tasks-->
<taskdef resource="GenBuild.tasks"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property environment="env"/>
<property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
<import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
<property name="MODULE_RELATIVE_PATH" value="Dxe\WinNtThunk\Cpu"/>
<property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
<property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
<target name="Cpu">
<GenBuild baseName="Cpu" mbdFilename="${MODULE_DIR}\Cpu.mbd" msaFilename="${MODULE_DIR}\Cpu.msa"/>
</target>
<target depends="Cpu_clean" name="clean"/>
<target depends="Cpu_cleanall" name="cleanall"/>
<target name="Cpu_clean">
<OutputDirSetup baseName="Cpu" mbdFilename="${MODULE_DIR}\Cpu.mbd" msaFilename="${MODULE_DIR}\Cpu.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\Cpu_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\Cpu_build.xml" target="clean"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
</target>
<target name="Cpu_cleanall">
<OutputDirSetup baseName="Cpu" mbdFilename="${MODULE_DIR}\Cpu.mbd" msaFilename="${MODULE_DIR}\Cpu.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\Cpu_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\Cpu_build.xml" target="cleanall"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}"/>
<delete dir="${DEST_DIR_DEBUG}"/>
<delete>
<fileset dir="${BIN_DIR}" includes="**Cpu*"/>
</delete>
</target>
</project>

View File

@@ -0,0 +1,87 @@
/*++
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:
WinNtThunk.c
Abstract:
Produce WinNtThunk protocol and it's associated device path and controller
state protocols. WinNtThunk is to the NT emulation environment as
PCI_ROOT_BRIGE is to real hardware. The WinNtBusDriver is the child of this
driver.
Since we are a root hardware abstraction we do not install a Driver Binding
protocol on this handle. This driver can only support one one WinNtThunk protocol
in the system, since the device path is hard coded.
--*/
#include "WinNtThunk.h"
//
// WinNtThunk Device Path Protocol Instance
//
static WIN_NT_THUNK_DEVICE_PATH mWinNtThunkDevicePath = {
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8),
EFI_WIN_NT_THUNK_PROTOCOL_GUID,
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
END_DEVICE_PATH_LENGTH,
0
}
};
EFI_STATUS
EFIAPI
InitializeWinNtThunk (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Install WinNtThunk Protocol and it's associated Device Path protocol
Arguments:
(Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
Returns:
EFI_SUCEESS - WinNtThunk protocol is added or error status from
gBS->InstallMultiProtocolInterfaces().
--*/
// TODO: ImageHandle - add argument and description to function comment
// TODO: SystemTable - add argument and description to function comment
{
EFI_STATUS Status;
EFI_HANDLE ControllerHandle;
ControllerHandle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (
&ControllerHandle,
&gEfiWinNtThunkProtocolGuid,
gWinNt,
&gEfiDevicePathProtocolGuid,
&mWinNtThunkDevicePath,
NULL
);
return Status;
}

View File

@@ -0,0 +1,27 @@
/*++
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:
WinNtThunk.dxs
Abstract:
Dependency expression source file.
--*/
#include <AutoGen.h>
#include <DxeDepex.h>
DEPENDENCY_START
TRUE
DEPENDENCY_END

View File

@@ -0,0 +1,30 @@
/*++
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:
WinNtThunk.h
Abstract:
--*/
// TODO: add protective #ifndef
//
// WinNtThunk Device Path Protocol Instance Type
//
typedef struct {
VENDOR_DEVICE_PATH Vendor;
EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
} WIN_NT_THUNK_DEVICE_PATH;

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MbdHeader>
<BaseName>WinNtThunk</BaseName>
<Guid>0C95A916-A006-11d4-BCFA-0080C73C8881</Guid>
<Version>0</Version>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>
<Created>2006-03-14 17:04</Created>
<Modified>2006-03-19 15:17</Modified>
</MbdHeader>
<Libraries>
<Library>UefiBootServicesTableLib</Library>
<Library>BaseLib</Library>
<Library>DxeHobLib</Library>
<Library>UefiLib</Library>
<Library>UefiMemoryLib</Library>
<Library>UefiDriverEntryPoint</Library>
<Library>DxeReportStatusCodeLib</Library>
<Library>BaseDebugLibReportStatusCode</Library>
<Library>DxeWinNtLib</Library>
<Library>DxeMemoryAllocationLib</Library>
</Libraries>
<BuildOptions ToolChain="MSFT">
<ImageEntryPoint>_ModuleEntryPoint</ImageEntryPoint>
</BuildOptions>
</ModuleBuildDescription>

View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
<MsaHeader>
<BaseName>WinNtThunk</BaseName>
<ModuleType>DXE_DRIVER</ModuleType>
<ComponentType>BS_DRIVER</ComponentType>
<Guid>0C95A916-A006-11d4-BCFA-0080C73C8881</Guid>
<Version>0</Version>
<Abstract>Component description file for WinNtThunk module.</Abstract>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2004-2006, 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>0</Specification>
<Created>2006-03-14 17:04</Created>
<Updated>2006-03-19 15:17</Updated>
</MsaHeader>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiDriverEntryPoint</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">WinNtLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">MemoryAllocationLib</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>WinNtThunk.h</Filename>
<Filename>WinNtThunk.c</Filename>
<Filename>WinNtThunk.dxs</Filename>
</SourceFiles>
<Includes>
<PackageName>MdePkg</PackageName>
<PackageName>EdkModulePkg</PackageName>
<PackageName>EdkNt32Pkg</PackageName>
</Includes>
<Protocols>
<Protocol Usage="ALWAYS_PRODUCED">WinNtThunk</Protocol>
<Protocol Usage="ALWAYS_PRODUCED">DevicePath</Protocol>
</Protocols>
<Externs>
<Extern>
<ModuleEntryPoint>InitializeWinNtThunk</ModuleEntryPoint>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
<project basedir="." default="WinNtThunk"><!--Apply external ANT tasks-->
<taskdef resource="GenBuild.tasks"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property environment="env"/>
<property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
<import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
<property name="MODULE_RELATIVE_PATH" value="Dxe\WinNtThunk\WinNtThunk"/>
<property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
<property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
<target name="WinNtThunk">
<GenBuild baseName="WinNtThunk" mbdFilename="${MODULE_DIR}\WinNtThunk.mbd" msaFilename="${MODULE_DIR}\WinNtThunk.msa"/>
</target>
<target depends="WinNtThunk_clean" name="clean"/>
<target depends="WinNtThunk_cleanall" name="cleanall"/>
<target name="WinNtThunk_clean">
<OutputDirSetup baseName="WinNtThunk" mbdFilename="${MODULE_DIR}\WinNtThunk.mbd" msaFilename="${MODULE_DIR}\WinNtThunk.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\WinNtThunk_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\WinNtThunk_build.xml" target="clean"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
</target>
<target name="WinNtThunk_cleanall">
<OutputDirSetup baseName="WinNtThunk" mbdFilename="${MODULE_DIR}\WinNtThunk.mbd" msaFilename="${MODULE_DIR}\WinNtThunk.msa"/>
<if>
<available file="${DEST_DIR_OUTPUT}\WinNtThunk_build.xml"/>
<then>
<ant antfile="${DEST_DIR_OUTPUT}\WinNtThunk_build.xml" target="cleanall"/>
</then>
</if>
<delete dir="${DEST_DIR_OUTPUT}"/>
<delete dir="${DEST_DIR_DEBUG}"/>
<delete>
<fileset dir="${BIN_DIR}" includes="**WinNtThunk*"/>
</delete>
</target>
</project>