From 55a1bb43aa37fc948911197a99e23199fcc58b72 Mon Sep 17 00:00:00 2001 From: xli24 Date: Thu, 23 Apr 2009 09:31:15 +0000 Subject: [PATCH] Code scrub for VgaClass Driver. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8163 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Console/VgaClassDxe/ComponentName.c | 36 +- .../Console/VgaClassDxe/ComponentName.h | 153 ---- .../Universal/Console/VgaClassDxe/VgaClass.c | 773 +++++++++--------- .../Universal/Console/VgaClassDxe/VgaClass.h | 562 +++++++------ .../Console/VgaClassDxe/VgaClassDxe.inf | 18 +- 5 files changed, 756 insertions(+), 786 deletions(-) delete mode 100644 IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/ComponentName.h diff --git a/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/ComponentName.c b/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/ComponentName.c index 50058ef5d8..89deaa5027 100644 --- a/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/ComponentName.c +++ b/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/ComponentName.c @@ -1,6 +1,7 @@ -/**@file +/** @file + UEFI Component Name(2) protocol implementation for VGA Class Driver. -Copyright (c) 2006, Intel Corporation +Copyright (c) 2006 - 2009, 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 @@ -53,10 +54,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mVgaClassDriverNameTable[ by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned. - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string + @param Language A pointer to a Null-terminated ASCII string array indicating the language. This is the language of the driver name that the caller is requesting, and it must match one of the @@ -64,8 +64,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mVgaClassDriverNameTable[ number of languages supported by a driver is up to the driver writer. Language is specified in RFC 3066 or ISO 639-2 language code format. - - @param DriverName[out] A pointer to the Unicode string to return. + @param DriverName A pointer to the Unicode string to return. This Unicode string is the name of the driver specified by This in the language specified by Language. @@ -73,11 +72,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mVgaClassDriverNameTable[ @retval EFI_SUCCESS The Unicode string for the Driver specified by This and the language specified by Language was returned in DriverName. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER DriverName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This does not support the language specified by Language. @@ -112,15 +108,13 @@ VgaClassComponentNameGetDriverName ( then EFI_UNSUPPORTED is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned. - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver + @param ControllerHandle The handle of a controller that the driver specified by This is managing. This handle specifies the controller whose name is to be returned. - - @param ChildHandle[in] The handle of the child controller to retrieve + @param ChildHandle The handle of the child controller to retrieve the name of. This is an optional parameter that may be NULL. It will be NULL for device drivers. It will also be NULL for a bus drivers @@ -128,8 +122,7 @@ VgaClassComponentNameGetDriverName ( controller. It will not be NULL for a bus driver that wishes to retrieve the name of a child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string + @param Language A pointer to a Null-terminated ASCII string array indicating the language. This is the language of the driver name that the caller is requesting, and it must match one of the @@ -137,8 +130,7 @@ VgaClassComponentNameGetDriverName ( number of languages supported by a driver is up to the driver writer. Language is specified in RFC 3066 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. + @param ControllerName A pointer to the Unicode string to return. This Unicode string is the name of the controller specified by ControllerHandle and ChildHandle in the language specified by @@ -149,20 +141,14 @@ VgaClassComponentNameGetDriverName ( the language specified by Language for the driver specified by This was returned in DriverName. - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This is not currently managing the controller specified by ControllerHandle and ChildHandle. - @retval EFI_UNSUPPORTED The driver specified by This does not support the language specified by Language. diff --git a/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/ComponentName.h b/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/ComponentName.h deleted file mode 100644 index 0a2012f2c2..0000000000 --- a/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/ComponentName.h +++ /dev/null @@ -1,153 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _VGA_CLASS_COMPONENT_NAME_H -#define _VGA_CLASS_COMPONENT_NAME_H - -#include -#include - -extern EFI_COMPONENT_NAME_PROTOCOL gVgaClassComponentName; -extern EFI_COMPONENT_NAME2_PROTOCOL gVgaClassComponentName2; - -// -// EFI Component Name Functions -// -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name 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. Language is specified - in RFC 3066 or ISO 639-2 language code format. - - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER DriverName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -VgaClassComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ); - - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - - @param ChildHandle[in] The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name 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. Language is specified in - RFC 3066 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -VgaClassComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ); - - -#endif diff --git a/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClass.c b/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClass.c index 5b5877d905..dbf9aa9f70 100644 --- a/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClass.c +++ b/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClass.c @@ -1,7 +1,7 @@ -/**@file - This driver produces a VGA console. +/** @file + VGA Class Driver that managers VGA devices and produces Simple Text Output Protocol. -Copyright (c) 2006, Intel Corporation +Copyright (c) 2006 - 2009, 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 @@ -26,53 +26,11 @@ EFI_DRIVER_BINDING_PROTOCOL gVgaClassDriverBinding = { NULL }; -/** - The user Entry Point for module VgaClass. 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 -InitializeVgaClass( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - // - // Install driver model protocol(s). - // - Status = EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gVgaClassDriverBinding, - ImageHandle, - &gVgaClassComponentName, - &gVgaClassComponentName2 - ); - ASSERT_EFI_ERROR (Status); - - - return Status; -} - // // Local variables // CHAR16 CrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL }; -typedef struct { - CHAR16 Unicode; - CHAR8 PcAnsi; - CHAR8 Ascii; -} UNICODE_TO_CHAR; - // // This list is used to define the valid extend chars. // It also provides a mapping from Unicode to PCANSI or @@ -344,53 +302,220 @@ UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] = { } }; -// -// Private worker functions -// +/** + Entrypoint of this VGA Class Driver. + + This function is the entrypoint of this VGA Class Driver. It installs Driver Binding + Protocols together with Component Name Protocols. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The entry point is executed successfully. + +**/ +EFI_STATUS +EFIAPI +InitializeVgaClass( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + // + // Install driver model protocol(s). + // + Status = EfiLibInstallDriverBindingComponentName2 ( + ImageHandle, + SystemTable, + &gVgaClassDriverBinding, + ImageHandle, + &gVgaClassComponentName, + &gVgaClassComponentName2 + ); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +/** + Internal worker function to program CRTC register via PCI I/O Protocol. + + @param VgaClassDev device instance object + @param Address Address of register to write + @param Data Data to write to register. + +**/ +VOID +WriteCrtc ( + IN VGA_CLASS_DEV *VgaClassDev, + IN UINT16 Address, + IN UINT8 Data + ) +{ + VgaClassDev->PciIo->Io.Write ( + VgaClassDev->PciIo, + EfiPciIoWidthUint8, + VgaClassDev->VgaMiniPort->CrtcAddressRegisterBar, + VgaClassDev->VgaMiniPort->CrtcAddressRegisterOffset, + 1, + &Address + ); + + VgaClassDev->PciIo->Io.Write ( + VgaClassDev->PciIo, + EfiPciIoWidthUint8, + VgaClassDev->VgaMiniPort->CrtcDataRegisterBar, + VgaClassDev->VgaMiniPort->CrtcDataRegisterOffset, + 1, + &Data + ); +} + +/** + Internal worker function to set cursor's position to VgaClass device + + @param VgaClassDev Private data structure for device instance. + @param Column Colomn of position to set cursor to. + @param Row Row of position to set cursor to. + @param MaxColumn Max value of column. + +**/ VOID SetVideoCursorPosition ( IN VGA_CLASS_DEV *VgaClassDev, IN UINTN Column, IN UINTN Row, IN UINTN MaxColumn - ); + ) +{ + Column = Column & 0xff; + Row = Row & 0xff; + MaxColumn = MaxColumn & 0xff; -VOID -WriteCrtc ( - IN VGA_CLASS_DEV *VgaClassDev, - IN UINT16 Address, - IN UINT8 Data - ); + WriteCrtc ( + VgaClassDev, + CRTC_CURSOR_LOCATION_HIGH, + (UINT8) ((Row * MaxColumn + Column) >> 8) + ); + WriteCrtc ( + VgaClassDev, + CRTC_CURSOR_LOCATION_LOW, + (UINT8) ((Row * MaxColumn + Column) & 0xff) + ); +} + +/** + Internal worker function to detect if a Unicode char is for Box Drawing text graphics. + @param Graphic Unicode char to test. + @param PcAnsi Pointer to PCANSI equivalent of Graphic for output. + If NULL, then PCANSI value is not returned. + @param Ascii Pointer to ASCII equivalent of Graphic for output. + If NULL, then ASCII value is not returned. + + @retval TRUE Gpaphic is a supported Unicode Box Drawing character. + @retval FALSE Gpaphic is not a supported Unicode Box Drawing character. + +**/ BOOLEAN LibIsValidTextGraphics ( IN CHAR16 Graphic, OUT CHAR8 *PcAnsi, OPTIONAL OUT CHAR8 *Ascii OPTIONAL - ); + ) +{ + UNICODE_TO_CHAR *Table; + + // + // Unicode drawing code charts are all in the 0x25xx range, arrows are 0x21xx. + // So first filter out values not in these 2 ranges. + // + if ((((Graphic & 0xff00) != 0x2500) && ((Graphic & 0xff00) != 0x2100))) { + return FALSE; + } + + // + // Search UnicodeToPcAnsiOrAscii table for matching entry. + // + for (Table = UnicodeToPcAnsiOrAscii; Table->Unicode != 0x0000; Table++) { + if (Graphic == Table->Unicode) { + if (PcAnsi != NULL) { + *PcAnsi = Table->PcAnsi; + } + + if (Ascii != NULL) { + *Ascii = Table->Ascii; + } + + return TRUE; + } + } + + // + // If value is not found in UnicodeToPcAnsiOrAscii table, then return FALSE. + // + return FALSE; +} + +/** + Internal worker function to check whether input value is an ASCII char. + + @param Char Character to check. + + @retval TRUE Input value is an ASCII char. + @retval FALSE Input value is not an ASCII char. +**/ BOOLEAN IsValidAscii ( - IN CHAR16 Ascii - ); + IN CHAR16 Char + ) +{ + if ((Char >= 0x20) && (Char <= 0x7f)) { + return TRUE; + } + return FALSE; +} + +/** + Internal worker function to check whether input value is a unicode control char. + + @param Char Character to check. + + @retval TRUE Input value is a unicode control char. + @retval FALSE Input value is not a unicode control char. + +**/ BOOLEAN IsValidEfiCntlChar ( - IN CHAR16 c - ); + IN CHAR16 Char + ) +{ + if (Char == CHAR_NULL || Char == CHAR_BACKSPACE || Char == CHAR_LINEFEED || Char == CHAR_CARRIAGE_RETURN) { + return TRUE; + } + + return FALSE; +} /** - Test to see if this driver supports ControllerHandle. Any ControllerHandle - than contains a VgaMiniPort and PciIo protocol can be supported. + Tests to see if this driver supports a given controller. - @param This Protocol instance pointer. + This function implments EFI_DRIVER_BINDING_PROTOCOL.Supported(). + It Checks if this driver supports the controller specified. Any Controller + with VgaMiniPort Protocol and Pci I/O protocol can be supported. + + @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. @param ControllerHandle Handle of device to test @param RemainingDevicePath Optional parameter use to pick a specific child device to start. - @retval EFI_SUCCESS This driver supports this device - @retval EFI_ALREADY_STARTED This driver is already running on this device - @retval other This driver does not support this device + @retval EFI_SUCCESS This driver supports this device. + @retval EFI_ALREADY_STARTED This driver is already running on this device. + @retval EFI_UNSUPPORTED This driver does not support this device. **/ EFI_STATUS @@ -398,19 +523,18 @@ EFIAPI VgaClassDriverBindingSupported ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL ) { EFI_STATUS Status; - EFI_VGA_MINI_PORT_PROTOCOL *VgaMiniPort; // - // Open the IO Abstraction(s) needed to perform the supported test + // Checks if Abstraction(s) needed to perform the supported test // Status = gBS->OpenProtocol ( Controller, &gEfiVgaMiniPortProtocolGuid, - (VOID **) &VgaMiniPort, + NULL, This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_TEST_PROTOCOL @@ -437,18 +561,19 @@ VgaClassDriverBindingSupported ( } /** - Start this driver on ControllerHandle by opening a PciIo and VgaMiniPort - protocol, creating VGA_CLASS_DEV device and install gEfiSimpleTextOutProtocolGuid - finnally. + Starts the device controller. - @param This Protocol instance pointer. + This function implments EFI_DRIVER_BINDING_PROTOCOL.Start(). + It starts the device specified by Controller with the driver based on PCI I/O Protocol + and VgaMiniPort Protocol. It creates context for device instance and install EFI_SIMPLE_TEXT_OUT_PROTOCOL. + + @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. @param ControllerHandle Handle of device to bind driver to @param RemainingDevicePath Optional parameter use to pick a specific child device to start. - @retval EFI_SUCCESS This driver is added to ControllerHandle - @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle - @retval other This driver does not support this device + @retval EFI_SUCCESS The device was started. + @retval other Fail to start the device. **/ EFI_STATUS @@ -456,7 +581,7 @@ EFIAPI VgaClassDriverBindingStart ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL ) { EFI_STATUS Status; @@ -483,7 +608,7 @@ VgaClassDriverBindingStart ( ); // - // Open the IO Abstraction(s) needed + // Open the PCI I/O Protocol // Status = gBS->OpenProtocol ( Controller, @@ -496,7 +621,9 @@ VgaClassDriverBindingStart ( if (EFI_ERROR (Status)) { return Status; } - + // + // Open the VGA Mini Port Protocol + // Status = gBS->OpenProtocol ( Controller, &gEfiVgaMiniPortProtocolGuid, @@ -511,49 +638,37 @@ VgaClassDriverBindingStart ( // // Allocate the private device structure // - Status = gBS->AllocatePool ( - EfiBootServicesData, - sizeof (VGA_CLASS_DEV), - (VOID **) &VgaClassPrivate - ); - if (EFI_ERROR (Status)) { - gBS->CloseProtocol ( - Controller, - &gEfiVgaMiniPortProtocolGuid, - This->DriverBindingHandle, - Controller - ); - return EFI_OUT_OF_RESOURCES; - } - - ZeroMem (VgaClassPrivate, sizeof (VGA_CLASS_DEV)); + VgaClassPrivate = AllocateZeroPool (sizeof (VGA_CLASS_DEV)); + ASSERT (VgaClassPrivate != NULL); // // Initialize the private device structure // - VgaClassPrivate->Signature = VGA_CLASS_DEV_SIGNATURE; - VgaClassPrivate->Handle = Controller; + VgaClassPrivate->Signature = VGA_CLASS_DEV_SIGNATURE; + VgaClassPrivate->Handle = Controller; VgaClassPrivate->VgaMiniPort = VgaMiniPort; - VgaClassPrivate->PciIo = PciIo; + VgaClassPrivate->PciIo = PciIo; - VgaClassPrivate->SimpleTextOut.Reset = VgaClassReset; - VgaClassPrivate->SimpleTextOut.OutputString = VgaClassOutputString; - VgaClassPrivate->SimpleTextOut.TestString = VgaClassTestString; - VgaClassPrivate->SimpleTextOut.ClearScreen = VgaClassClearScreen; - VgaClassPrivate->SimpleTextOut.SetAttribute = VgaClassSetAttribute; + VgaClassPrivate->SimpleTextOut.Reset = VgaClassReset; + VgaClassPrivate->SimpleTextOut.OutputString = VgaClassOutputString; + VgaClassPrivate->SimpleTextOut.TestString = VgaClassTestString; + VgaClassPrivate->SimpleTextOut.ClearScreen = VgaClassClearScreen; + VgaClassPrivate->SimpleTextOut.SetAttribute = VgaClassSetAttribute; VgaClassPrivate->SimpleTextOut.SetCursorPosition = VgaClassSetCursorPosition; - VgaClassPrivate->SimpleTextOut.EnableCursor = VgaClassEnableCursor; - VgaClassPrivate->SimpleTextOut.QueryMode = VgaClassQueryMode; - VgaClassPrivate->SimpleTextOut.SetMode = VgaClassSetMode; + VgaClassPrivate->SimpleTextOut.EnableCursor = VgaClassEnableCursor; + VgaClassPrivate->SimpleTextOut.QueryMode = VgaClassQueryMode; + VgaClassPrivate->SimpleTextOut.SetMode = VgaClassSetMode; - VgaClassPrivate->SimpleTextOut.Mode = &VgaClassPrivate->SimpleTextOutputMode; - VgaClassPrivate->SimpleTextOutputMode.MaxMode = VgaMiniPort->MaxMode; - VgaClassPrivate->DevicePath = DevicePath; + VgaClassPrivate->SimpleTextOut.Mode = &VgaClassPrivate->SimpleTextOutputMode; + VgaClassPrivate->SimpleTextOutputMode.MaxMode = VgaMiniPort->MaxMode; + VgaClassPrivate->DevicePath = DevicePath; + // + // Initialize the VGA device. + // Status = VgaClassPrivate->SimpleTextOut.SetAttribute ( &VgaClassPrivate->SimpleTextOut, - EFI_TEXT_ATTR (EFI_WHITE, - EFI_BLACK) + EFI_TEXT_ATTR (EFI_WHITE, EFI_BLACK) ); if (EFI_ERROR (Status)) { goto ErrorExit; @@ -596,14 +711,16 @@ ErrorExit: } /** - Stop this driver on ControllerHandle. Support stoping any child handles + Starts the device controller. + + This function implments EFI_DRIVER_BINDING_PROTOCOL.Stop(). + It stops this driver on Controller. Support stoping any child handles created by this driver. - @param This Protocol instance pointer. - @param ControllerHandle Handle of device to stop driver on - @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of - children is zero stop the entire bus driver. - @param ChildHandleBuffer List of Child Handles to Stop. + @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param ControllerHandle A handle to the device being stopped. + @param NumberOfChildren The number of child device handles in ChildHandleBuffer. + @param ChildHandleBuffer An array of child handles to be freed. @retval EFI_SUCCESS This driver is removed ControllerHandle @retval other This driver was not removed from this device @@ -615,7 +732,7 @@ VgaClassDriverBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer + IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { EFI_STATUS Status; @@ -657,34 +774,43 @@ VgaClassDriverBindingStop ( // Release PCI I/O and VGA Mini Port Protocols on the controller handle. // gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, - Controller - ); + Controller, + &gEfiPciIoProtocolGuid, + This->DriverBindingHandle, + Controller + ); gBS->CloseProtocol ( - Controller, - &gEfiVgaMiniPortProtocolGuid, - This->DriverBindingHandle, - Controller - ); + Controller, + &gEfiVgaMiniPortProtocolGuid, + This->DriverBindingHandle, + Controller + ); - gBS->FreePool (VgaClassPrivate); + FreePool (VgaClassPrivate); return EFI_SUCCESS; } /** - Reset VgaClass device and clear output. + Resets the text output device hardware. + + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset(). + It resets the text output device hardware. The cursor position is set to (0, 0), + and the screen is cleared to the default background color for the output device. - @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL. - @param ExtendedVerification Whether need additional judgement + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + @param ExtendedVerification Indicates that the driver may perform a more exhaustive + verification operation of the device during reset. + + @retval EFI_SUCCESS The text output device was reset. + @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and could not be reset. + **/ EFI_STATUS EFIAPI VgaClassReset ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN BOOLEAN ExtendedVerification ) { @@ -710,16 +836,27 @@ VgaClassReset ( } /** - Output a string to VgaClass device. + Writes a Unicode string to the output device. - @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL. - @param WString wide chars. + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString(). + It writes a Unicode string to the output device. This is the most basic output mechanism + on an output device. + + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + @param String The Null-terminated Unicode string to be displayed on the output device(s). + + @retval EFI_SUCCESS The string was output to the device. + @retval EFI_DEVICE_ERROR The device reported an error while attempting to output the text. + @retval EFI_UNSUPPORTED The output device’s mode is not currently in a defined text mode. + @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the characters in + the Unicode string could not be rendered and were skipped. + **/ EFI_STATUS EFIAPI VgaClassOutputString ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN CHAR16 *WString + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN CHAR16 *String ) { EFI_STATUS Status; @@ -731,22 +868,24 @@ VgaClassOutputString ( CHAR8 GraphicChar; VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This); - Mode = This->Mode; Status = This->QueryMode ( - This, - Mode->Mode, - &MaxColumn, - &MaxRow - ); + This, + Mode->Mode, + &MaxColumn, + &MaxRow + ); if (EFI_ERROR (Status)) { return Status; } - for (; *WString != CHAR_NULL; WString++) { + // + // Parse each character of the string to output + // + for (; *String != CHAR_NULL; String++) { - switch (*WString) { + switch (*String) { case CHAR_BACKSPACE: if (Mode->CursorColumn > 0) { Mode->CursorColumn--; @@ -794,14 +933,14 @@ VgaClassOutputString ( break; default: - if (!LibIsValidTextGraphics (*WString, &GraphicChar, NULL)) { + if (!LibIsValidTextGraphics (*String, &GraphicChar, NULL)) { // - // Just convert to ASCII + // If this character is not ,Box Drawing text graphics, then convert it to ASCII. // - GraphicChar = (CHAR8) *WString; + GraphicChar = (CHAR8) *String; if (!IsValidAscii (GraphicChar)) { // - // Keep the API from supporting PCANSI Graphics chars + // If not valid ASCII char, convert it to "?" // GraphicChar = '?'; } @@ -837,38 +976,50 @@ VgaClassOutputString ( } /** - Detects if a Unicode char is for Box Drawing text graphics. - - @param This Pointer of EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL - @param WString Unicode chars + Verifies that all characters in a Unicode string can be output to the target device. - @return if a Unicode char is for Box Drawing text graphics. + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString(). + It verifies that all characters in a Unicode string can be output to the target device. + + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + @param String The Null-terminated Unicode string to be examined for the output device(s). + + @retval EFI_SUCCESS The device(s) are capable of rendering the output string. + @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be rendered by + one or more of the output devices mapped by the EFI handle. + **/ EFI_STATUS EFIAPI VgaClassTestString ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN CHAR16 *WString + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN CHAR16 *String ) { - while (*WString != 0x0000) { - if (!(IsValidAscii (*WString) || IsValidEfiCntlChar (*WString) || LibIsValidTextGraphics (*WString, NULL, NULL))) { + while (*String != CHAR_NULL) { + if (!(IsValidAscii (*String) || IsValidEfiCntlChar (*String) || LibIsValidTextGraphics (*String, NULL, NULL))) { return EFI_UNSUPPORTED; } - WString++; + String++; } return EFI_SUCCESS; } /** - Clear Screen via VgaClass device + Clears the output device(s) display to the currently selected background color. - @param This Pointer of EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen(). + The ClearScreen() function clears the output device(s) display to the currently + selected background color. The cursor position is set to (0, 0). + + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. - @retval EFI_SUCESS Success to clear screen - @retval Others Wrong displaying mode. + @retval EFI_SUCESS The operation completed successfully. + @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. + @retval EFI_UNSUPPORTED The output device is not in a valid text mode. + **/ EFI_STATUS EFIAPI @@ -885,11 +1036,11 @@ VgaClassClearScreen ( VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This); Status = This->QueryMode ( - This, - This->Mode->Mode, - &MaxColumn, - &MaxRow - ); + This, + This->Mode->Mode, + &MaxColumn, + &MaxRow + ); if (EFI_ERROR (Status)) { return Status; } @@ -911,18 +1062,27 @@ VgaClassClearScreen ( } /** - Set displaying mode's attribute + Sets the background and foreground colors for theOutputString() and ClearScreen() functions. - @param This Pointer of EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL - @param Attribute Mode's attribute + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute(). + It sets the background and foreground colors for the OutputString() and ClearScreen() functions. + The color mask can be set even when the device is in an invalid text mode. + Devices supporting a different number of text colors are required to emulate the above colors + to the best of the device’s capabilities. + + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + @param Attribute The attribute to set. + Bits 0..3 are the foreground color, + and bits 4..6 are the background color. - @param EFI_SUCCESS Success to set attribute - @param EFI_UNSUPPORTED Wrong mode's attribute wanted to be set + @retval EFI_SUCCESS The requested attributes were set. + @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. + **/ EFI_STATUS EFIAPI VgaClassSetAttribute ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN UINTN Attribute ) { @@ -935,19 +1095,26 @@ VgaClassSetAttribute ( } /** - Set cursor position. + Sets the current coordinates of the cursor position. + + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition(). + It sets the current coordinates of the cursor position. + The upper left corner of the screen is defined as coordinate (0, 0). - @param This Pointer of EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL - @param Column Column of new cursor position. - @param Row Row of new cursor position. + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + @param Column Column of position to set the cursor to. + @param Row Row of position to set the cursor to. - @retval EFI_SUCCESS Sucess to set cursor's position. - @retval Others Wrong current displaying mode. + @retval EFI_SUCCESS The operation completed successfully. + @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. + @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the cursor + position is invalid for the current mode. + **/ EFI_STATUS EFIAPI VgaClassSetCursorPosition ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN UINTN Column, IN UINTN Row ) @@ -960,11 +1127,11 @@ VgaClassSetCursorPosition ( VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This); Status = This->QueryMode ( - This, - This->Mode->Mode, - &MaxColumn, - &MaxRow - ); + This, + This->Mode->Mode, + &MaxColumn, + &MaxRow + ); if (EFI_ERROR (Status)) { return Status; } @@ -982,17 +1149,25 @@ VgaClassSetCursorPosition ( } /** - Enable cursor to display or not. + Makes the cursor visible or invisible. - @param This Pointer of EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL - @param Visible Display cursor or not. + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.EnableCursor(). + It makes the cursor visible or invisible. + + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + @param Visible If TRUE, the cursor is set to be visible. + If FALSE, the cursor is set to be invisible. - @retval EFI_SUCESS Success to display the cursor or not. + @retval EFI_SUCESS The operation completed successfully. + @retval EFI_DEVICE_ERROR The device had an error and could not complete the request or the + device does not support changing the cursor mode. + @retval EFI_UNSUPPORTED The output device does not support visibility control of the cursor. + **/ EFI_STATUS EFIAPI VgaClassEnableCursor ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN BOOLEAN Visible ) { @@ -1000,16 +1175,18 @@ VgaClassEnableCursor ( VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This); if (Visible) { - switch (This->Mode->Mode) { - case 1: + if (This->Mode->Mode == 1) { + // + // 80 * 50 + // WriteCrtc (VgaClassDev, CRTC_CURSOR_START, 0x06); WriteCrtc (VgaClassDev, CRTC_CURSOR_END, 0x07); - break; - - default: + } else { + // + // 80 * 25 + // WriteCrtc (VgaClassDev, CRTC_CURSOR_START, 0x0e); WriteCrtc (VgaClassDev, CRTC_CURSOR_END, 0x0f); - break; } } else { WriteCrtc (VgaClassDev, CRTC_CURSOR_START, 0x20); @@ -1020,23 +1197,27 @@ VgaClassEnableCursor ( } /** - Query colum and row according displaying mode number - The mode: - 0: 80 * 25 - 1: 80 * 50 - - @param This Pointer of EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL - @param ModeNumber Mode number - @param Columns return the columen in current mode number - @param Rows return the row in current mode number. + Returns information for an available text mode that the output device(s) supports. + + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode(). + It returns information for an available text mode that the output device(s) supports. + It is required that all output devices support at least 80x25 text mode. This mode is defined to be mode 0. + If the output devices support 80x50, that is defined to be mode 1. + + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + @param ModeNumber The mode number to return information on. + @param Columns Columen in current mode number + @param Rows Row in current mode number. - @return EFI_SUCCESS Sucess to get columns and rows according to mode number - @return EFI_UNSUPPORTED Unsupported mode number + @retval EFI_SUCCESS The requested mode information was returned. + @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. + @retval EFI_UNSUPPORTED The mode number was not valid. + **/ EFI_STATUS EFIAPI VgaClassQueryMode ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN UINTN ModeNumber, OUT UINTN *Columns, OUT UINTN *Rows @@ -1069,22 +1250,28 @@ VgaClassQueryMode ( } /** - Set displaying mode number + Sets the output device(s) to a specified mode. - @param This Pointer of EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL - @param ModeNumber mode number + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode(). + It sets the output device(s) to the requested mode. + On success the device is in the geometry for the requested mode, + and the device has been cleared to the current background color with the cursor at (0,0). + + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + @param ModeNumber The text mode to set. - @retval EFI_UNSUPPORTED Unsupported mode number in parameter - @retval EFI_SUCCESS Success to set the mode number. + @retval EFI_SUCCESS The requested text mode was set. + @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. + @retval EFI_UNSUPPORTED The mode number was not valid. + **/ EFI_STATUS EFIAPI VgaClassSetMode ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN UINTN ModeNumber ) { - EFI_STATUS Status; VGA_CLASS_DEV *VgaClassDev; VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This); @@ -1097,153 +1284,5 @@ VgaClassSetMode ( This->Mode->Mode = (INT32) ModeNumber; - Status = VgaClassDev->VgaMiniPort->SetMode (VgaClassDev->VgaMiniPort, ModeNumber); - - return Status; -} - -/** - Set logic cursor's position to VgaClass device - - @param VgaClassDev device instance object - @param Column cursor logic position. - @param Row cursor logic position. - @param MaxColumn max logic column - -**/ -VOID -SetVideoCursorPosition ( - IN VGA_CLASS_DEV *VgaClassDev, - IN UINTN Column, - IN UINTN Row, - IN UINTN MaxColumn - ) -{ - Column = Column & 0xff; - Row = Row & 0xff; - MaxColumn = MaxColumn & 0xff; - WriteCrtc ( - VgaClassDev, - CRTC_CURSOR_LOCATION_HIGH, - (UINT8) ((Row * MaxColumn + Column) >> 8) - ); - WriteCrtc ( - VgaClassDev, - CRTC_CURSOR_LOCATION_LOW, - (UINT8) ((Row * MaxColumn + Column) & 0xff) - ); -} - -/** - Program CRTC register via PCI IO. - - @param VgaClassDev device instance object - @param Address address - @param Data data -**/ -VOID -WriteCrtc ( - IN VGA_CLASS_DEV *VgaClassDev, - IN UINT16 Address, - IN UINT8 Data - ) -{ - VgaClassDev->PciIo->Io.Write ( - VgaClassDev->PciIo, - EfiPciIoWidthUint8, - VgaClassDev->VgaMiniPort->CrtcAddressRegisterBar, - VgaClassDev->VgaMiniPort->CrtcAddressRegisterOffset, - 1, - &Address - ); - - VgaClassDev->PciIo->Io.Write ( - VgaClassDev->PciIo, - EfiPciIoWidthUint8, - VgaClassDev->VgaMiniPort->CrtcDataRegisterBar, - VgaClassDev->VgaMiniPort->CrtcDataRegisterOffset, - 1, - &Data - ); -} - -/** - Detects if a Unicode char is for Box Drawing text graphics. - - @param Grphic Unicode char to test. - @param PcAnsi Optional pointer to return PCANSI equivalent of Graphic. - @param Asci Optional pointer to return Ascii equivalent of Graphic. - - @return TRUE if Gpaphic is a supported Unicode Box Drawing character. - -**/ -BOOLEAN -LibIsValidTextGraphics ( - IN CHAR16 Graphic, - OUT CHAR8 *PcAnsi, OPTIONAL - OUT CHAR8 *Ascii OPTIONAL - ) -{ - UNICODE_TO_CHAR *Table; - - if ((((Graphic & 0xff00) != 0x2500) && ((Graphic & 0xff00) != 0x2100))) { - // - // Unicode drawing code charts are all in the 0x25xx range, - // arrows are 0x21xx - // - return FALSE; - } - - for (Table = UnicodeToPcAnsiOrAscii; Table->Unicode != 0x0000; Table++) { - if (Graphic == Table->Unicode) { - if (PcAnsi) { - *PcAnsi = Table->PcAnsi; - } - - if (Ascii) { - *Ascii = Table->Ascii; - } - - return TRUE; - } - } - - return FALSE; -} - -/** - Judge whether is an ASCII char. - - @param Ascii character - @return whether is an ASCII char. -**/ -BOOLEAN -IsValidAscii ( - IN CHAR16 Ascii - ) -{ - if ((Ascii >= 0x20) && (Ascii <= 0x7f)) { - return TRUE; - } - - return FALSE; -} - -/** - Judge whether is diplaying control character. - - @param c character - @return whether is diplaying control character. -**/ -BOOLEAN -IsValidEfiCntlChar ( - IN CHAR16 c - ) -{ - if (c == CHAR_NULL || c == CHAR_BACKSPACE || c == CHAR_LINEFEED || c == CHAR_CARRIAGE_RETURN) { - return TRUE; - } - - return FALSE; + return VgaClassDev->VgaMiniPort->SetMode (VgaClassDev->VgaMiniPort, ModeNumber); } - diff --git a/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClass.h b/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClass.h index 33d870fc70..27c32ef531 100644 --- a/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClass.h +++ b/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClass.h @@ -1,6 +1,7 @@ -/**@file +/** @file + Internal include file of the VGA Class Driver. -Copyright (c) 2006, Intel Corporation +Copyright (c) 2006 - 2009, 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 @@ -12,13 +13,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ -#ifndef _VGA_CLASS_H -#define _VGA_CLASS_H +#ifndef _VGA_CLASS_H__ +#define _VGA_CLASS_H__ #include #include -#include #include #include #include @@ -26,17 +26,21 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include -#include #include -#include #include #include #include - #include -#include "ComponentName.h" -#include + +// +// Structure for tuple containing mapping among uniocde, PC Ansi and ASCII code. +// +typedef struct { + CHAR16 Unicode; + CHAR8 PcAnsi; + CHAR8 Ascii; +} UNICODE_TO_CHAR; // // VGA specific registers @@ -55,13 +59,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define VGA_CLASS_DEV_SIGNATURE SIGNATURE_32 ('V', 'G', 'A', 'C') typedef struct { - UINTN Signature; - EFI_HANDLE Handle; + UINTN Signature; + EFI_HANDLE Handle; EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOut; - EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode; - EFI_VGA_MINI_PORT_PROTOCOL *VgaMiniPort; - EFI_PCI_IO_PROTOCOL *PciIo; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; + EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode; + EFI_VGA_MINI_PORT_PROTOCOL *VgaMiniPort; + EFI_PCI_IO_PROTOCOL *PciIo; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; } VGA_CLASS_DEV; #define VGA_CLASS_DEV_FROM_THIS(a) CR (a, VGA_CLASS_DEV, SimpleTextOut, VGA_CLASS_DEV_SIGNATURE) @@ -69,312 +73,412 @@ typedef struct { // // Global Variables // -extern EFI_DRIVER_BINDING_PROTOCOL gVgaClassDriverBinding; +extern EFI_DRIVER_BINDING_PROTOCOL gVgaClassDriverBinding; +extern EFI_COMPONENT_NAME_PROTOCOL gVgaClassComponentName; +extern EFI_COMPONENT_NAME2_PROTOCOL gVgaClassComponentName2; // // Driver Binding Protocol functions // -EFI_STATUS -EFIAPI -VgaClassDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -/** - -Routine Description: - GC_TODO: Add function description - -Arguments: +/** + Tests to see if this driver supports a given controller. - This - GC_TODO: add argument description - Controller - GC_TODO: add argument description - RemainingDevicePath - GC_TODO: add argument description + This function implments EFI_DRIVER_BINDING_PROTOCOL.Supported(). + It Checks if this driver supports the controller specified. Any Controller + with VgaMiniPort Protocol and Pci I/O protocol can be supported. -Returns: + @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param ControllerHandle Handle of device to test + @param RemainingDevicePath Optional parameter use to pick a specific child + device to start. - GC_TODO: add return values + @retval EFI_SUCCESS This driver supports this device. + @retval EFI_ALREADY_STARTED This driver is already running on this device. + @retval EFI_UNSUPPORTED This driver does not support this device. **/ -; - EFI_STATUS EFIAPI -VgaClassDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) +VgaClassDriverBindingSupported ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE Controller, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ); + /** + Starts the device controller. + + This function implments EFI_DRIVER_BINDING_PROTOCOL.Start(). + It starts the device specified by Controller with the driver based on PCI I/O Protocol + and VgaMiniPort Protocol. It creates context for device instance and install EFI_SIMPLE_TEXT_OUT_PROTOCOL. -Routine Description: + @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param ControllerHandle Handle of device to bind driver to + @param RemainingDevicePath Optional parameter use to pick a specific child + device to start. - GC_TODO: Add function description + @retval EFI_SUCCESS The device was started. + @retval other Fail to start the device. -Arguments: +**/ +EFI_STATUS +EFIAPI +VgaClassDriverBindingStart ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE Controller, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ); - This - GC_TODO: add argument description - Controller - GC_TODO: add argument description - RemainingDevicePath - GC_TODO: add argument description +/** + Starts the device controller. + + This function implments EFI_DRIVER_BINDING_PROTOCOL.Stop(). + It stops this driver on Controller. Support stoping any child handles + created by this driver. -Returns: + @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param ControllerHandle A handle to the device being stopped. + @param NumberOfChildren The number of child device handles in ChildHandleBuffer. + @param ChildHandleBuffer An array of child handles to be freed. - GC_TODO: add return values + @retval EFI_SUCCESS This driver is removed ControllerHandle + @retval other This driver was not removed from this device **/ -; - EFI_STATUS EFIAPI VgaClassDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -/** + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE Controller, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer OPTIONAL + ); -Routine Description: - - GC_TODO: Add function description - -Arguments: +// +// EFI Component Name Functions +// - This - GC_TODO: add argument description - Controller - GC_TODO: add argument description - NumberOfChildren - GC_TODO: add argument description - ChildHandleBuffer - GC_TODO: add argument description +/** + Retrieves a Unicode string that is the user readable name of the driver. + + This function retrieves the user readable name of a driver in the form of a + Unicode string. If the driver specified by This has a user readable name in + the language specified by Language, then a pointer to the driver name is + returned in DriverName, and EFI_SUCCESS is returned. If the driver specified + by This does not support the language specified by Language, + then EFI_UNSUPPORTED is returned. + + @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + @param Language A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name 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. Language is specified + in RFC 3066 or ISO 639-2 language code format. + @param DriverName A pointer to the Unicode string to return. + This Unicode string is the name of the + driver specified by This in the language + specified by Language. + + @retval EFI_SUCCESS The Unicode string for the Driver specified by + This and the language specified by Language was + returned in DriverName. + @retval EFI_INVALID_PARAMETER Language is NULL. + @retval EFI_INVALID_PARAMETER DriverName is NULL. + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. -Returns: +**/ +EFI_STATUS +EFIAPI +VgaClassComponentNameGetDriverName ( + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN CHAR8 *Language, + OUT CHAR16 **DriverName + ); - GC_TODO: add return values +/** + Retrieves a Unicode string that is the user readable name of the controller + that is being managed by a driver. + + This function retrieves the user readable name of the controller specified by + ControllerHandle and ChildHandle in the form of a Unicode string. If the + driver specified by This has a user readable name in the language specified by + Language, then a pointer to the controller name is returned in ControllerName, + and EFI_SUCCESS is returned. If the driver specified by This is not currently + managing the controller specified by ControllerHandle and ChildHandle, + then EFI_UNSUPPORTED is returned. If the driver specified by This does not + support the language specified by Language, then EFI_UNSUPPORTED is returned. + + @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + @param ControllerHandle The handle of a controller that the driver + specified by This is managing. This handle + specifies the controller whose name is to be + returned. + @param ChildHandle The handle of the child controller to retrieve + the name of. This is an optional parameter that + may be NULL. It will be NULL for device + drivers. It will also be NULL for a bus drivers + that wish to retrieve the name of the bus + controller. It will not be NULL for a bus + driver that wishes to retrieve the name of a + child controller. + @param Language A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name 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. Language is specified in + RFC 3066 or ISO 639-2 language code format. + @param ControllerName A pointer to the Unicode string to return. + This Unicode string is the name of the + controller specified by ControllerHandle and + ChildHandle in the language specified by + Language from the point of view of the driver + specified by This. + + @retval EFI_SUCCESS The Unicode string for the user readable name in + the language specified by Language for the + driver specified by This was returned in + DriverName. + @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. + @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid + EFI_HANDLE. + @retval EFI_INVALID_PARAMETER Language is NULL. + @retval EFI_INVALID_PARAMETER ControllerName is NULL. + @retval EFI_UNSUPPORTED The driver specified by This is not currently + managing the controller specified by + ControllerHandle and ChildHandle. + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. **/ -; +EFI_STATUS +EFIAPI +VgaClassComponentNameGetControllerName ( + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName + ); // // Simple Text Output Protocol functions // -EFI_STATUS -EFIAPI -VgaClassReset ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN BOOLEAN ExtendedVerification - ) /** + Resets the text output device hardware. -Routine Description: - - GC_TODO: Add function description - -Arguments: + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset(). + It resets the text output device hardware. The cursor position is set to (0, 0), + and the screen is cleared to the default background color for the output device. + + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + @param ExtendedVerification Indicates that the driver may perform a more exhaustive + verification operation of the device during reset. - This - GC_TODO: add argument description - ExtendedVerification - GC_TODO: add argument description - -Returns: - - GC_TODO: add return values + @retval EFI_SUCCESS The text output device was reset. + @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and could not be reset. **/ -; +EFI_STATUS +EFIAPI +VgaClassReset ( + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN BOOLEAN ExtendedVerification + ); +/** + Writes a Unicode string to the output device. + + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString(). + It writes a Unicode string to the output device. This is the most basic output mechanism + on an output device. + + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + @param String The Null-terminated Unicode string to be displayed on the output device(s). + + @retval EFI_SUCCESS The string was output to the device. + @retval EFI_DEVICE_ERROR The device reported an error while attempting to output the text. + @retval EFI_UNSUPPORTED The output device’s mode is not currently in a defined text mode. + @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the characters in + the Unicode string could not be rendered and were skipped. +**/ EFI_STATUS EFIAPI VgaClassOutputString ( IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN CHAR16 *WString - ) -/** - -Routine Description: - - GC_TODO: Add function description - -Arguments: + IN CHAR16 *String + ); - This - GC_TODO: add argument description - WString - GC_TODO: add argument description +/** + Verifies that all characters in a Unicode string can be output to the target device. + + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString(). + It verifies that all characters in a Unicode string can be output to the target device. -Returns: + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + @param String The Null-terminated Unicode string to be examined for the output device(s). - GC_TODO: add return values + @retval EFI_SUCCESS The device(s) are capable of rendering the output string. + @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be rendered by + one or more of the output devices mapped by the EFI handle. **/ -; - EFI_STATUS EFIAPI VgaClassTestString ( IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN CHAR16 *WString - ) -/** + IN CHAR16 *String + ); -Routine Description: - - GC_TODO: Add function description - -Arguments: - - This - GC_TODO: add argument description - WString - GC_TODO: add argument description - -Returns: - - GC_TODO: add return values +/** + Clears the output device(s) display to the currently selected background color. + + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen(). + The ClearScreen() function clears the output device(s) display to the currently + selected background color. The cursor position is set to (0, 0). + + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + + @retval EFI_SUCESS The operation completed successfully. + @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. + @retval EFI_UNSUPPORTED The output device is not in a valid text mode. **/ -; - EFI_STATUS EFIAPI VgaClassClearScreen ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This - ) -/** - -Routine Description: - - GC_TODO: Add function description - -Arguments: + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This + ); - This - GC_TODO: add argument description - -Returns: - - GC_TODO: add return values +/** + Sets the background and foreground colors for theOutputString() and ClearScreen() functions. + + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute(). + It sets the background and foreground colors for the OutputString() and ClearScreen() functions. + The color mask can be set even when the device is in an invalid text mode. + Devices supporting a different number of text colors are required to emulate the above colors + to the best of the device’s capabilities. + + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + @param Attribute The attribute to set. + Bits 0..3 are the foreground color, + and bits 4..6 are the background color. + + @retval EFI_SUCCESS The requested attributes were set. + @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. **/ -; - EFI_STATUS EFIAPI VgaClassSetAttribute ( IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN UINTN Attribute - ) -/** - -Routine Description: - - GC_TODO: Add function description - -Arguments: - - This - GC_TODO: add argument description - Attribute - GC_TODO: add argument description - -Returns: + IN UINTN Attribute + ); - GC_TODO: add return values +/** + Sets the current coordinates of the cursor position. + + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition(). + It sets the current coordinates of the cursor position. + The upper left corner of the screen is defined as coordinate (0, 0). + + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + @param Column Column of position to set the cursor to. + @param Row Row of position to set the cursor to. + + @retval EFI_SUCCESS The operation completed successfully. + @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. + @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the cursor + position is invalid for the current mode. **/ -; - EFI_STATUS EFIAPI VgaClassSetCursorPosition ( IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN UINTN Column, - IN UINTN Row - ) -/** - -Routine Description: - - GC_TODO: Add function description - -Arguments: - - This - GC_TODO: add argument description - Column - GC_TODO: add argument description - Row - GC_TODO: add argument description + IN UINTN Column, + IN UINTN Row + ); -Returns: - - GC_TODO: add return values +/** + Makes the cursor visible or invisible. + + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.EnableCursor(). + It makes the cursor visible or invisible. + + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + @param Visible If TRUE, the cursor is set to be visible. + If FALSE, the cursor is set to be invisible. + + @retval EFI_SUCESS The operation completed successfully. + @retval EFI_DEVICE_ERROR The device had an error and could not complete the request or the + device does not support changing the cursor mode. + @retval EFI_UNSUPPORTED The output device does not support visibility control of the cursor. **/ -; - EFI_STATUS EFIAPI VgaClassEnableCursor ( IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN BOOLEAN Visible - ) -/** - -Routine Description: - - GC_TODO: Add function description - -Arguments: + IN BOOLEAN Visible + ); - This - GC_TODO: add argument description - Visible - GC_TODO: add argument description - -Returns: - - GC_TODO: add return values +/** + Returns information for an available text mode that the output device(s) supports. + + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode(). + It returns information for an available text mode that the output device(s) supports. + It is required that all output devices support at least 80x25 text mode. This mode is defined to be mode 0. + If the output devices support 80x50, that is defined to be mode 1. + + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + @param ModeNumber The mode number to return information on. + @param Columns Columen in current mode number + @param Rows Row in current mode number. + + @retval EFI_SUCCESS The requested mode information was returned. + @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. + @retval EFI_UNSUPPORTED The mode number was not valid. **/ -; - EFI_STATUS EFIAPI VgaClassQueryMode ( IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN UINTN ModeNumber, - OUT UINTN *Columns, - OUT UINTN *Rows - ) -/** - -Routine Description: - - GC_TODO: Add function description + IN UINTN ModeNumber, + OUT UINTN *Columns, + OUT UINTN *Rows + ); -Arguments: - - This - GC_TODO: add argument description - ModeNumber - GC_TODO: add argument description - Columns - GC_TODO: add argument description - Rows - GC_TODO: add argument description - -Returns: - - GC_TODO: add return values +/** + Sets the output device(s) to a specified mode. + + This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode(). + It sets the output device(s) to the requested mode. + On success the device is in the geometry for the requested mode, + and the device has been cleared to the current background color with the cursor at (0,0). + + @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + @param ModeNumber The text mode to set. + + @retval EFI_SUCCESS The requested text mode was set. + @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. + @retval EFI_UNSUPPORTED The mode number was not valid. **/ -; - EFI_STATUS EFIAPI VgaClassSetMode ( IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN UINTN ModeNumber - ) -/** - -Routine Description: - - GC_TODO: Add function description - -Arguments: - - This - GC_TODO: add argument description - ModeNumber - GC_TODO: add argument description - -Returns: - - GC_TODO: add return values - -**/ -; + IN UINTN ModeNumber + ); #endif diff --git a/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxe.inf b/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxe.inf index d278730a85..cd10db94c2 100644 --- a/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxe.inf +++ b/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxe.inf @@ -1,8 +1,7 @@ #/** @file -# Component description file for VgaClass module. +# VGA Class Driver that managers VGA devices and produces Simple Text Output Protocol. # -# This driver produces a VGA console. -# Copyright (c) 2006, Intel Corporation. +# Copyright (c) 2006 - 2009, 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 @@ -35,14 +34,12 @@ [Sources.common] ComponentName.c - ComponentName.h VgaClass.h VgaClass.c [Packages] MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec IntelFrameworkPkg/IntelFrameworkPkg.dec IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec @@ -51,18 +48,15 @@ ReportStatusCodeLib UefiBootServicesTableLib MemoryAllocationLib - BaseMemoryLib UefiLib - BaseLib UefiDriverEntryPoint DebugLib [Protocols] - gEfiSimpleTextOutProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiSimpleTextInProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiVgaMiniPortProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiPciIoProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED + gEfiSimpleTextOutProtocolGuid # PROTOCOL BY_START + gEfiVgaMiniPortProtocolGuid # PROTOCOL TO_START + gEfiPciIoProtocolGuid # PROTOCOL TO_START + gEfiDevicePathProtocolGuid # PROTOCOL TO_START -- 2.39.2