summaryrefslogtreecommitdiff
path: root/UnixPkg/UnixUgaDxe
diff options
context:
space:
mode:
authoreric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524>2008-06-30 05:08:49 +0000
committereric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524>2008-06-30 05:08:49 +0000
commit804405e7d10525e41720216137b2551f62a0663f (patch)
treea615301e36e63aba81adcb0a963e4d3aa7830863 /UnixPkg/UnixUgaDxe
parent27d55a2d56320e6e7a1dda2b02089721540d6bc3 (diff)
downloadedk2-platforms-804405e7d10525e41720216137b2551f62a0663f.tar.xz
Port EdkUnixPkg to UnixPkg. The changes are listed as follows:
1. change *.msa to *.inf, and create platform configuration files .dec&.dsc&.fdf to comply with Edk2 build process 2. using PCD mechanism to replace macro. 3. change Sec code to cowork with PI1.0 Pei Core and produce temparory memory ppi. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5380 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'UnixPkg/UnixUgaDxe')
-rw-r--r--UnixPkg/UnixUgaDxe/ComponentName.c198
-rw-r--r--UnixPkg/UnixUgaDxe/EntryPoint.c49
-rw-r--r--UnixPkg/UnixUgaDxe/UnixUga.h304
-rw-r--r--UnixPkg/UnixUgaDxe/UnixUga.inf74
-rw-r--r--UnixPkg/UnixUgaDxe/UnixUga.msa101
-rw-r--r--UnixPkg/UnixUgaDxe/UnixUgaDriver.c296
-rw-r--r--UnixPkg/UnixUgaDxe/UnixUgaInput.c221
-rw-r--r--UnixPkg/UnixUgaDxe/UnixUgaScreen.c446
8 files changed, 1689 insertions, 0 deletions
diff --git a/UnixPkg/UnixUgaDxe/ComponentName.c b/UnixPkg/UnixUgaDxe/ComponentName.c
new file mode 100644
index 0000000000..5c50d5689c
--- /dev/null
+++ b/UnixPkg/UnixUgaDxe/ComponentName.c
@@ -0,0 +1,198 @@
+/*++
+
+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 "UnixUga.h"
+
+//
+// EFI Component Name Functions
+//
+EFI_STATUS
+EFIAPI
+UnixUgaComponentNameGetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ );
+
+EFI_STATUS
+EFIAPI
+UnixUgaComponentNameGetControllerName (
+ 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 gUnixUgaComponentName = {
+ UnixUgaComponentNameGetDriverName,
+ UnixUgaComponentNameGetControllerName,
+ "eng"
+};
+
+static EFI_UNICODE_STRING_TABLE mUnixUgaDriverNameTable[] = {
+ { "eng", L"Unix Universal Graphics Adapter Driver" },
+ { NULL , NULL }
+};
+
+EFI_STATUS
+EFIAPI
+UnixUgaComponentNameGetDriverName (
+ 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,
+ gUnixUgaComponentName.SupportedLanguages,
+ mUnixUgaDriverNameTable,
+ DriverName
+ );
+}
+
+EFI_STATUS
+EFIAPI
+UnixUgaComponentNameGetControllerName (
+ 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;
+ }
+
+ //
+ // Make sure this driver is currently managing ControllerHandle
+ //
+ Status = EfiTestManagedDevice (
+ ControllerHandle,
+ gUnixUgaDriverBinding.DriverBindingHandle,
+ &gEfiUnixIoProtocolGuid
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+ //
+ // Get our context back
+ //
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiUgaDrawProtocolGuid,
+ (VOID **)&UgaDraw,
+ gUnixUgaDriverBinding.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,
+ gUnixUgaComponentName.SupportedLanguages,
+ Private->ControllerNameTable,
+ ControllerName
+ );
+}
diff --git a/UnixPkg/UnixUgaDxe/EntryPoint.c b/UnixPkg/UnixUgaDxe/EntryPoint.c
new file mode 100644
index 0000000000..a2ed2414d6
--- /dev/null
+++ b/UnixPkg/UnixUgaDxe/EntryPoint.c
@@ -0,0 +1,49 @@
+/**@file
+ Entry Point Source file.
+
+ This file contains the user entry point
+
+ 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.
+**/
+
+#include "UnixUga.h"
+
+/**
+ The user Entry Point for module UnixUga. The user code starts with this function.
+
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.
+ @param[in] SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The entry point is executed successfully.
+ @retval other Some error occurs when executing this entry point.
+
+**/
+EFI_STATUS
+EFIAPI
+InitializeUnixUga(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ Status = EfiLibInstallAllDriverProtocols (
+ ImageHandle,
+ SystemTable,
+ &gUnixUgaDriverBinding,
+ ImageHandle,
+ &gUnixUgaComponentName,
+ NULL,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+
+ return Status;
+}
diff --git a/UnixPkg/UnixUgaDxe/UnixUga.h b/UnixPkg/UnixUgaDxe/UnixUga.h
new file mode 100644
index 0000000000..8401029af7
--- /dev/null
+++ b/UnixPkg/UnixUgaDxe/UnixUga.h
@@ -0,0 +1,304 @@
+/*++
+
+Copyright (c) 2006 - 2008, 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:
+
+ UnixUga.h
+
+Abstract:
+
+ Private data for the Uga driver that is bound to the Unix Thunk protocol
+
+--*/
+
+#ifndef _UNIX_UGA_H_
+#define _UNIX_UGA_H_
+
+#include "PiDxe.h"
+#include <Guid/EventGroup.h>
+#include <Protocol/SimpleTextIn.h>
+#include <Protocol/UgaDraw.h>
+#include "Protocol/UnixUgaIo.h"
+#include <Library/DebugLib.h>
+#include <Library/BaseLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include "UnixDxe.h"
+
+extern EFI_DRIVER_BINDING_PROTOCOL gUnixUgaDriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL gUnixUgaComponentName;
+
+#define UNIX_UGA_CLASS_NAME L"UnixUgaWindow"
+
+#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_INPUT_PROTOCOL SimpleTextIn;
+
+ EFI_UNIX_THUNK_PROTOCOL *UnixThunk;
+
+ 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;
+
+ EFI_UNIX_UGA_IO_PROTOCOL *UgaIo;
+
+} 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 gUnixUgaDriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL gUnixUgaComponentName;
+
+//
+// Uga Hardware abstraction internal worker functions
+//
+EFI_STATUS
+UnixUgaSupported (
+ IN EFI_UNIX_IO_PROTOCOL *UnixIo
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ UnixIo - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+UnixUgaConstructor (
+ IN UGA_PRIVATE_DATA *Private
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Private - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+UnixUgaDestructor (
+ 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 UNIX UGA
+//
+
+EFI_STATUS
+EFIAPI
+UnixUgaInitialize (
+ 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
+UnixUgaDriverBindingSupported (
+ 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
+UnixUgaDriverBindingStart (
+ 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
+UnixUgaDriverBindingStop (
+ 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
+UnixUgaInitializeSimpleTextInForWindow (
+ IN UGA_PRIVATE_DATA *Private
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Private - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+#endif
diff --git a/UnixPkg/UnixUgaDxe/UnixUga.inf b/UnixPkg/UnixUgaDxe/UnixUga.inf
new file mode 100644
index 0000000000..787f193771
--- /dev/null
+++ b/UnixPkg/UnixUgaDxe/UnixUga.inf
@@ -0,0 +1,74 @@
+#/** @file
+# Uga driver
+#
+# UGA is short hand for Universal Graphics Abstraction protocol.
+# This file is a verision of UgaIo the uses UnixThunk system calls as an IO
+# abstraction. For a PCI device UnixIo would be replaced with
+# a PCI IO abstraction that abstracted a specific PCI device.
+# 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.
+#
+#
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = UnixUga
+ FILE_GUID = f33cad86-8985-11db-8040-0040d02b1835
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+ EDK_RELEASE_VERSION = 0x00020000
+ EFI_SPECIFICATION_VERSION = 0x00020000
+
+ ENTRY_POINT = InitializeUnixUga
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+# DRIVER_BINDING = gUnixUgaDriverBinding
+# COMPONENT_NAME = gUnixUgaComponentName
+#
+
+[Sources.common]
+ ComponentName.c
+ UnixUgaScreen.c
+ UnixUgaDriver.c
+ UnixUgaInput.c
+ UnixUga.h
+ EntryPoint.c
+
+
+[Packages]
+ MdePkg/MdePkg.dec
+ UnixPkg/UnixPkg.dec
+
+
+[LibraryClasses]
+ UefiBootServicesTableLib
+ MemoryAllocationLib
+ BaseMemoryLib
+ UefiLib
+ UefiDriverEntryPoint
+ BaseLib
+ DebugLib
+
+
+[Guids]
+ gEfiEventExitBootServicesGuid # SOMETIMES_CONSUMED Create Event: EVENT_GROUP_GUID
+ gEfiUnixUgaGuid # ALWAYS_CONSUMED
+
+
+[Protocols]
+ gEfiSimpleTextInProtocolGuid # PROTOCOL BY_START
+ gEfiUnixUgaIoProtocolGuid # PROTOCOL BY_START
+ gEfiUgaDrawProtocolGuid # PROTOCOL BY_START
+ gEfiUnixIoProtocolGuid # PROTOCOL TO_START
+
diff --git a/UnixPkg/UnixUgaDxe/UnixUga.msa b/UnixPkg/UnixUgaDxe/UnixUga.msa
new file mode 100644
index 0000000000..864576f6ac
--- /dev/null
+++ b/UnixPkg/UnixUgaDxe/UnixUga.msa
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
+ <MsaHeader>
+ <ModuleName>UnixUga</ModuleName>
+ <ModuleType>UEFI_DRIVER</ModuleType>
+ <GuidValue>f33cad86-8985-11db-8040-0040d02b1835</GuidValue>
+ <Version>1.0</Version>
+ <Abstract>Uga driver</Abstract>
+ <Description>
+ UGA is short hand for Universal Graphics Abstraction protocol.
+ This file is a verision of UgaIo the uses UnixThunk system calls as an IO
+ abstraction. For a PCI device UnixIo would be replaced with
+ a PCI IO abstraction that abstracted a specific PCI device.
+ </Description>
+ <Copyright>Copyright (c) 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>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
+ </MsaHeader>
+ <ModuleDefinitions>
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
+ <BinaryModule>false</BinaryModule>
+ <OutputFileBasename>UnixUga</OutputFileBasename>
+ </ModuleDefinitions>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>DebugLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>BaseLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>UefiDriverModelLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>UefiDriverEntryPoint</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>UefiLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>BaseMemoryLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>MemoryAllocationLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>UefiBootServicesTableLib</Keyword>
+ </LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>UnixUga.h</Filename>
+ <Filename>UnixUgaInput.c</Filename>
+ <Filename>UnixUgaDriver.c</Filename>
+ <Filename>UnixUgaScreen.c</Filename>
+ <Filename>ComponentName.c</Filename>
+ </SourceFiles>
+ <PackageDependencies>
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+ <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+ <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
+ </PackageDependencies>
+ <Protocols>
+ <Protocol Usage="TO_START">
+ <ProtocolCName>gEfiUnixIoProtocolGuid</ProtocolCName>
+ </Protocol>
+ <Protocol Usage="BY_START">
+ <ProtocolCName>gEfiUgaDrawProtocolGuid</ProtocolCName>
+ </Protocol>
+ <Protocol Usage="BY_START">
+ <ProtocolCName>gEfiUnixUgaIoProtocolGuid</ProtocolCName>
+ </Protocol>
+ <Protocol Usage="BY_START">
+ <ProtocolCName>gEfiSimpleTextInProtocolGuid</ProtocolCName>
+ </Protocol>
+ </Protocols>
+ <Events>
+ <CreateEvents>
+ <EventTypes EventGuidCName="gEfiEventExitBootServicesGuid" Usage="SOMETIMES_CONSUMED">
+ <EventType>EVENT_GROUP_GUID</EventType>
+ </EventTypes>
+ </CreateEvents>
+ </Events>
+ <Guids>
+ <GuidCNames Usage="ALWAYS_CONSUMED">
+ <GuidCName>gEfiUnixUgaGuid</GuidCName>
+ </GuidCNames>
+ </Guids>
+ <Externs>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
+ <Extern>
+ <DriverBinding>gUnixUgaDriverBinding</DriverBinding>
+ <ComponentName>gUnixUgaComponentName</ComponentName>
+ </Extern>
+ </Externs>
+</ModuleSurfaceArea>
diff --git a/UnixPkg/UnixUgaDxe/UnixUgaDriver.c b/UnixPkg/UnixUgaDxe/UnixUgaDriver.c
new file mode 100644
index 0000000000..6073202bd7
--- /dev/null
+++ b/UnixPkg/UnixUgaDxe/UnixUgaDriver.c
@@ -0,0 +1,296 @@
+/*++
+
+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:
+
+ UnixUgaDriver.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 UnixThunk system calls as an IO
+ abstraction. For a PCI device UnixIo would be replaced with
+ a PCI IO abstraction that abstracted a specific PCI device.
+
+--*/
+
+#include "UnixUga.h"
+
+EFI_DRIVER_BINDING_PROTOCOL gUnixUgaDriverBinding = {
+ UnixUgaDriverBindingSupported,
+ UnixUgaDriverBindingStart,
+ UnixUgaDriverBindingStop,
+ 0xa,
+ NULL,
+ NULL
+};
+
+
+EFI_STATUS
+EFIAPI
+UnixUgaDriverBindingSupported (
+ 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_UNIX_IO_PROTOCOL *UnixIo;
+
+ //
+ // Open the IO Abstraction(s) needed to perform the supported test
+ //
+ Status = gBS->OpenProtocol (
+ Handle,
+ &gEfiUnixIoProtocolGuid,
+ (VOID **)&UnixIo,
+ This->DriverBindingHandle,
+ Handle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = UnixUgaSupported (UnixIo);
+
+ //
+ // Close the I/O Abstraction(s) used to perform the supported test
+ //
+ gBS->CloseProtocol (
+ Handle,
+ &gEfiUnixIoProtocolGuid,
+ This->DriverBindingHandle,
+ Handle
+ );
+
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+UnixUgaDriverBindingStart (
+ 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_UNIX_IO_PROTOCOL *UnixIo;
+ EFI_STATUS Status;
+ UGA_PRIVATE_DATA *Private;
+
+ //
+ // Grab the protocols we need
+ //
+ Status = gBS->OpenProtocol (
+ Handle,
+ &gEfiUnixIoProtocolGuid,
+ (VOID **)&UnixIo,
+ 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),
+ (VOID **)&Private
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+ //
+ // Set up context record
+ //
+ Private->Signature = UGA_PRIVATE_DATA_SIGNATURE;
+ Private->Handle = Handle;
+ Private->UnixThunk = UnixIo->UnixThunk;
+
+ Private->ControllerNameTable = NULL;
+
+ AddUnicodeString (
+ "eng",
+ gUnixUgaComponentName.SupportedLanguages,
+ &Private->ControllerNameTable,
+ UnixIo->EnvString
+ );
+
+ Private->WindowName = UnixIo->EnvString;
+
+ Status = UnixUgaConstructor (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,
+ &gEfiUnixIoProtocolGuid,
+ 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
+UnixUgaDriverBindingStop (
+ 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,
+ (VOID **)&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 = UnixUgaDestructor (Private);
+ if (EFI_ERROR (Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ gBS->CloseProtocol (
+ Handle,
+ &gEfiUnixIoProtocolGuid,
+ This->DriverBindingHandle,
+ Handle
+ );
+
+ //
+ // Free our instance data
+ //
+ FreeUnicodeStringTable (Private->ControllerNameTable);
+
+ gBS->FreePool (Private);
+
+ }
+
+ return Status;
+}
+
diff --git a/UnixPkg/UnixUgaDxe/UnixUgaInput.c b/UnixPkg/UnixUgaDxe/UnixUgaInput.c
new file mode 100644
index 0000000000..29e605c16f
--- /dev/null
+++ b/UnixPkg/UnixUgaDxe/UnixUgaInput.c
@@ -0,0 +1,221 @@
+/*++
+
+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:
+
+ UnixUgaInput.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 UnixUgaImplementation.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 "UnixUga.h"
+
+//
+// Simple Text In implementation.
+//
+
+EFI_STATUS
+EFIAPI
+UnixUgaSimpleTextInReset (
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ This - TODO: add argument description
+ ExtendedVerification - TODO: add argument description
+
+Returns:
+
+ EFI_SUCCESS - TODO: Add description for return value
+
+--*/
+{
+ UGA_PRIVATE_DATA *Private;
+ EFI_INPUT_KEY Key;
+ EFI_TPL OldTpl;
+
+ Private = UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
+ if (Private->UgaIo == NULL) {
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Enter critical section
+ //
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+
+ //
+ // A reset is draining the Queue
+ //
+ while (Private->UgaIo->UgaGetKey(Private->UgaIo, &Key) == EFI_SUCCESS)
+ ;
+
+ //
+ // Leave critical section and return
+ //
+ gBS->RestoreTPL (OldTpl);
+ return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
+EFIAPI
+UnixUgaSimpleTextInReadKeyStroke (
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ OUT EFI_INPUT_KEY *Key
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ This - TODO: add argument description
+ Key - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+{
+ UGA_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
+
+ Private = UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
+ if (Private->UgaIo == NULL) {
+ return EFI_NOT_READY;
+ }
+
+ //
+ // Enter critical section
+ //
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+
+ Status = Private->UgaIo->UgaGetKey(Private->UgaIo, Key);
+ //
+ // Leave critical section and return
+ //
+ gBS->RestoreTPL (OldTpl);
+
+ return Status;
+}
+
+STATIC
+VOID
+EFIAPI
+UnixUgaSimpleTextInWaitForKey (
+ 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;
+ if (Private->UgaIo == NULL) {
+ return;
+ }
+
+ //
+ // Enter critical section
+ //
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+
+ Status = Private->UgaIo->UgaCheckKey(Private->UgaIo);
+ if (!EFI_ERROR (Status)) {
+ //
+ // If a there is a key in the queue signal our event.
+ //
+ gBS->SignalEvent (Event);
+ }
+ //
+ // Leave critical section and return
+ //
+ gBS->RestoreTPL (OldTpl);
+}
+
+EFI_STATUS
+UnixUgaInitializeSimpleTextInForWindow (
+ 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;
+
+ //
+ // Initialize Simple Text In protoocol
+ //
+ Private->SimpleTextIn.Reset = UnixUgaSimpleTextInReset;
+ Private->SimpleTextIn.ReadKeyStroke = UnixUgaSimpleTextInReadKeyStroke;
+
+ Status = gBS->CreateEvent (
+ EVT_NOTIFY_WAIT,
+ TPL_NOTIFY,
+ UnixUgaSimpleTextInWaitForKey,
+ Private,
+ &Private->SimpleTextIn.WaitForKey
+ );
+
+ return Status;
+}
diff --git a/UnixPkg/UnixUgaDxe/UnixUgaScreen.c b/UnixPkg/UnixUgaDxe/UnixUgaScreen.c
new file mode 100644
index 0000000000..d9118aa00f
--- /dev/null
+++ b/UnixPkg/UnixUgaDxe/UnixUgaScreen.c
@@ -0,0 +1,446 @@
+/*++
+
+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:
+
+ UnixUgaScreen.c
+
+Abstract:
+
+ This file produces the graphics abstration of UGA. It is called by
+ UnixUgaDriver.c file which deals with the EFI 1.1 driver model.
+ This file just does graphics.
+
+--*/
+
+#include "UnixUga.h"
+
+EFI_UNIX_THUNK_PROTOCOL *mUnix;
+static EFI_EVENT mUgaScreenExitBootServicesEvent;
+
+STATIC
+EFI_STATUS
+UnixUgaStartWindow (
+ 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
+UnixUgaGetMode (
+ 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
+UnixUgaSetMode (
+ 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;
+
+ Private = UGA_DRAW_PRIVATE_DATA_FROM_THIS (This);
+
+ if (Private->HardwareNeedsStarting) {
+ Status = UnixUgaStartWindow (
+ Private,
+ HorizontalResolution,
+ VerticalResolution,
+ ColorDepth,
+ RefreshRate
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ Private->HardwareNeedsStarting = FALSE;
+ }
+ Status = Private->UgaIo->UgaSize(Private->UgaIo,
+ HorizontalResolution,
+ VerticalResolution);
+
+ Private->HorizontalResolution = HorizontalResolution;
+ Private->VerticalResolution = VerticalResolution;
+ Private->ColorDepth = ColorDepth;
+ Private->RefreshRate = RefreshRate;
+
+ Fill.Red = 0x7f;
+ Fill.Green = 0x7F;
+ Fill.Blue = 0x7f;
+ This->Blt (
+ This,
+ &Fill,
+ EfiUgaVideoFill,
+ 0,
+ 0,
+ 0,
+ 0,
+ HorizontalResolution,
+ VerticalResolution,
+ HorizontalResolution * sizeof (EFI_UGA_PIXEL)
+ );
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+UnixUgaBlt (
+ 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;
+ EFI_STATUS Status;
+
+ 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 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 (TPL_NOTIFY);
+
+ Status = Private->UgaIo->UgaBlt (Private->UgaIo,
+ BltBuffer,
+ BltOperation,
+ SourceX, SourceY,
+ DestinationX, DestinationY,
+ Width, Height,
+ Delta);
+
+ gBS->RestoreTPL (OriginalTPL);
+
+ return Status;
+}
+
+
+//
+// Construction and Destruction functions
+//
+
+EFI_STATUS
+UnixUgaSupported (
+ IN EFI_UNIX_IO_PROTOCOL *UnixIo
+ )
+/*++
+
+Routine Description:
+
+Arguments:
+
+Returns:
+
+ None
+
+--*/
+// TODO: UnixIo - 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 (UnixIo->TypeGuid, &gEfiUnixUgaGuid)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+STATIC
+EFI_STATUS
+UnixUgaStartWindow (
+ 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;
+
+ mUnix = Private->UnixThunk;
+
+ Private->HorizontalResolution = HorizontalResolution;
+ Private->VerticalResolution = VerticalResolution;
+
+ //
+ // Register to be notified on exit boot services so we can destroy the window.
+ //
+ Status = gBS->CreateEvent (
+ EVT_SIGNAL_EXIT_BOOT_SERVICES,
+ TPL_CALLBACK,
+ KillNtUgaThread,
+ Private,
+ &mUgaScreenExitBootServicesEvent
+ );
+
+ Status = Private->UnixThunk->UgaCreate(&Private->UgaIo, Private->WindowName);
+ return Status;
+}
+
+EFI_STATUS
+UnixUgaConstructor (
+ 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 = UnixUgaGetMode;
+ Private->UgaDraw.SetMode = UnixUgaSetMode;
+ Private->UgaDraw.Blt = UnixUgaBlt;
+
+ Private->HardwareNeedsStarting = TRUE;
+ Private->UgaIo = NULL;
+
+ UnixUgaInitializeSimpleTextInForWindow (Private);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+UnixUgaDestructor (
+ 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
+{
+ if (!Private->HardwareNeedsStarting) {
+ Private->UgaIo->UgaClose(Private->UgaIo);
+ Private->UgaIo = NULL;
+ }
+
+ 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 UnixUgaDestructor().
+
+Arguments:
+
+ Event - not used
+ Context - pointer to the Private structure.
+
+Returns:
+
+ None.
+
+--*/
+{
+ EFI_STATUS Status;
+ Status = UnixUgaDestructor (Context);
+}