-/*++\r
+/** @file\r
+ VGA Class Driver that managers VGA devices and produces Simple Text Output Protocol.\r
\r
-Copyright (c) 2006, Intel Corporation. All rights reserved. <BR> \r
-This software and associated documentation (if any) is furnished\r
-under a license and may only be used or copied in accordance\r
-with the terms of the license. Except as permitted by such\r
-license, no part of this software or documentation may be\r
-reproduced, stored in a retrieval system, or transmitted in any\r
-form or by any means without the express written consent of\r
-Intel Corporation.\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
-Module Name:\r
-\r
- VgaClass.c\r
- \r
-Abstract: \r
- This driver produces a VGA console.\r
- \r
---*/\r
+**/\r
\r
#include "VgaClass.h"\r
\r
NULL\r
};\r
\r
-/**\r
- The user Entry Point for module VgaClass. The user code starts with this function.\r
-\r
- @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
- @param[in] SystemTable A pointer to the EFI System Table.\r
- \r
- @retval EFI_SUCCESS The entry point is executed successfully.\r
- @retval other Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeVgaClass(\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- //\r
- // Install driver model protocol(s).\r
- //\r
- Status = EfiLibInstallAllDriverProtocols (\r
- ImageHandle,\r
- SystemTable,\r
- &gVgaClassDriverBinding,\r
- ImageHandle,\r
- &gVgaClassComponentName,\r
- NULL,\r
- NULL\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
-\r
- return Status;\r
-}\r
-\r
//\r
// Local variables\r
//\r
-static CHAR16 CrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL };\r
-\r
-typedef struct {\r
- CHAR16 Unicode;\r
- CHAR8 PcAnsi;\r
- CHAR8 Ascii;\r
-} UNICODE_TO_CHAR;\r
+CHAR16 CrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL };\r
\r
//\r
// This list is used to define the valid extend chars.\r
// ASCII. The ASCII mapping we just made up.\r
//\r
//\r
-STATIC UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] = {\r
+UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] = {\r
{\r
BOXDRAW_HORIZONTAL,\r
0xc4,\r
}\r
};\r
\r
-//\r
-// Private worker functions\r
-//\r
-STATIC\r
+/**\r
+ Entrypoint of this VGA Class Driver.\r
+\r
+ This function is the entrypoint of this VGA Class Driver. It installs Driver Binding\r
+ Protocols together with Component Name Protocols.\r
+\r
+ @param ImageHandle The firmware allocated handle for the EFI image.\r
+ @param SystemTable A pointer to the EFI System Table.\r
+\r
+ @retval EFI_SUCCESS The entry point is executed successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeVgaClass(\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Install driver model protocol(s).\r
+ //\r
+ Status = EfiLibInstallDriverBindingComponentName2 (\r
+ ImageHandle,\r
+ SystemTable,\r
+ &gVgaClassDriverBinding,\r
+ ImageHandle,\r
+ &gVgaClassComponentName,\r
+ &gVgaClassComponentName2\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Internal worker function to program CRTC register via PCI I/O Protocol.\r
+\r
+ @param VgaClassDev device instance object\r
+ @param Address Address of register to write\r
+ @param Data Data to write to register.\r
+\r
+**/\r
+VOID\r
+WriteCrtc (\r
+ IN VGA_CLASS_DEV *VgaClassDev,\r
+ IN UINT16 Address,\r
+ IN UINT8 Data\r
+ )\r
+{\r
+ VgaClassDev->PciIo->Io.Write (\r
+ VgaClassDev->PciIo,\r
+ EfiPciIoWidthUint8,\r
+ VgaClassDev->VgaMiniPort->CrtcAddressRegisterBar,\r
+ VgaClassDev->VgaMiniPort->CrtcAddressRegisterOffset,\r
+ 1,\r
+ &Address\r
+ );\r
+\r
+ VgaClassDev->PciIo->Io.Write (\r
+ VgaClassDev->PciIo,\r
+ EfiPciIoWidthUint8,\r
+ VgaClassDev->VgaMiniPort->CrtcDataRegisterBar,\r
+ VgaClassDev->VgaMiniPort->CrtcDataRegisterOffset,\r
+ 1,\r
+ &Data\r
+ );\r
+}\r
+\r
+/**\r
+ Internal worker function to set cursor's position to VgaClass device\r
+\r
+ @param VgaClassDev Private data structure for device instance.\r
+ @param Column Colomn of position to set cursor to.\r
+ @param Row Row of position to set cursor to.\r
+ @param MaxColumn Max value of column.\r
+\r
+**/\r
VOID\r
SetVideoCursorPosition (\r
IN VGA_CLASS_DEV *VgaClassDev,\r
IN UINTN Column,\r
IN UINTN Row,\r
IN UINTN MaxColumn\r
- );\r
+ )\r
+{\r
+ Column = Column & 0xff;\r
+ Row = Row & 0xff;\r
+ MaxColumn = MaxColumn & 0xff;\r
\r
-STATIC\r
-VOID\r
-WriteCrtc (\r
- IN VGA_CLASS_DEV *VgaClassDev,\r
- IN UINT16 Address,\r
- IN UINT8 Data\r
- );\r
+ WriteCrtc (\r
+ VgaClassDev,\r
+ CRTC_CURSOR_LOCATION_HIGH,\r
+ (UINT8) ((Row * MaxColumn + Column) >> 8)\r
+ );\r
+ WriteCrtc (\r
+ VgaClassDev,\r
+ CRTC_CURSOR_LOCATION_LOW,\r
+ (UINT8) ((Row * MaxColumn + Column) & 0xff)\r
+ );\r
+}\r
\r
-STATIC\r
+/**\r
+ Internal worker function to detect if a Unicode char is for Box Drawing text graphics.\r
+\r
+ @param Graphic Unicode char to test.\r
+ @param PcAnsi Pointer to PCANSI equivalent of Graphic for output.\r
+ If NULL, then PCANSI value is not returned.\r
+ @param Ascii Pointer to ASCII equivalent of Graphic for output.\r
+ If NULL, then ASCII value is not returned.\r
+\r
+ @retval TRUE Gpaphic is a supported Unicode Box Drawing character.\r
+ @retval FALSE Gpaphic is not a supported Unicode Box Drawing character.\r
+\r
+**/\r
BOOLEAN\r
LibIsValidTextGraphics (\r
IN CHAR16 Graphic,\r
OUT CHAR8 *PcAnsi, OPTIONAL\r
OUT CHAR8 *Ascii OPTIONAL\r
- );\r
+ )\r
+{\r
+ UNICODE_TO_CHAR *Table;\r
+\r
+ //\r
+ // Unicode drawing code charts are all in the 0x25xx range, arrows are 0x21xx.\r
+ // So first filter out values not in these 2 ranges.\r
+ //\r
+ if ((((Graphic & 0xff00) != 0x2500) && ((Graphic & 0xff00) != 0x2100))) {\r
+ return FALSE;\r
+ }\r
+\r
+ //\r
+ // Search UnicodeToPcAnsiOrAscii table for matching entry.\r
+ //\r
+ for (Table = UnicodeToPcAnsiOrAscii; Table->Unicode != 0x0000; Table++) {\r
+ if (Graphic == Table->Unicode) {\r
+ if (PcAnsi != NULL) {\r
+ *PcAnsi = Table->PcAnsi;\r
+ }\r
+\r
+ if (Ascii != NULL) {\r
+ *Ascii = Table->Ascii;\r
+ }\r
+\r
+ return TRUE;\r
+ }\r
+ }\r
+\r
+ //\r
+ // If value is not found in UnicodeToPcAnsiOrAscii table, then return FALSE.\r
+ //\r
+ return FALSE;\r
+}\r
+\r
+/**\r
+ Internal worker function to check whether input value is an ASCII char.\r
\r
-STATIC\r
+ @param Char Character to check.\r
+\r
+ @retval TRUE Input value is an ASCII char.\r
+ @retval FALSE Input value is not an ASCII char.\r
+\r
+**/\r
BOOLEAN\r
IsValidAscii (\r
- IN CHAR16 Ascii\r
- );\r
+ IN CHAR16 Char\r
+ )\r
+{\r
+ if ((Char >= 0x20) && (Char <= 0x7f)) {\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+/**\r
+ Internal worker function to check whether input value is a unicode control char.\r
+\r
+ @param Char Character to check.\r
+\r
+ @retval TRUE Input value is a unicode control char.\r
+ @retval FALSE Input value is not a unicode control char.\r
\r
-STATIC\r
+**/\r
BOOLEAN\r
IsValidEfiCntlChar (\r
- IN CHAR16 c\r
- );\r
+ IN CHAR16 Char\r
+ )\r
+{\r
+ if (Char == CHAR_NULL || Char == CHAR_BACKSPACE || Char == CHAR_LINEFEED || Char == CHAR_CARRIAGE_RETURN) {\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+/**\r
+ Tests to see if this driver supports a given controller.\r
+\r
+ This function implments EFI_DRIVER_BINDING_PROTOCOL.Supported().\r
+ It Checks if this driver supports the controller specified. Any Controller\r
+ with VgaMiniPort Protocol and Pci I/O protocol can be supported.\r
\r
+ @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ @param ControllerHandle Handle of device to test\r
+ @param RemainingDevicePath Optional parameter use to pick a specific child\r
+ device to start.\r
+\r
+ @retval EFI_SUCCESS This driver supports this device.\r
+ @retval EFI_ALREADY_STARTED This driver is already running on this device.\r
+ @retval EFI_UNSUPPORTED This driver does not support this device.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
VgaClassDriverBindingSupported (\r
IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
IN EFI_HANDLE Controller,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
)\r
-/*++\r
- \r
- Routine Description:\r
- \r
- Supported.\r
- \r
- Arguments:\r
- \r
- (Standard DriverBinding Protocol Supported() function)\r
- \r
- Returns:\r
- \r
- EFI_STATUS\r
- \r
---*/\r
-// GC_TODO: This - add argument and description to function comment\r
-// GC_TODO: Controller - add argument and description to function comment\r
-// GC_TODO: RemainingDevicePath - add argument and description to function comment\r
{\r
EFI_STATUS Status;\r
- EFI_VGA_MINI_PORT_PROTOCOL *VgaMiniPort;\r
\r
//\r
- // Open the IO Abstraction(s) needed to perform the supported test\r
+ // Checks if Abstraction(s) needed to perform the supported test\r
//\r
Status = gBS->OpenProtocol (\r
Controller,\r
&gEfiVgaMiniPortProtocolGuid,\r
- (VOID **) &VgaMiniPort,\r
+ NULL,\r
This->DriverBindingHandle,\r
Controller,\r
EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
return Status;\r
}\r
\r
+/**\r
+ Starts the device controller.\r
+\r
+ This function implments EFI_DRIVER_BINDING_PROTOCOL.Start().\r
+ It starts the device specified by Controller with the driver based on PCI I/O Protocol\r
+ and VgaMiniPort Protocol. It creates context for device instance and install EFI_SIMPLE_TEXT_OUT_PROTOCOL.\r
+\r
+ @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ @param ControllerHandle Handle of device to bind driver to\r
+ @param RemainingDevicePath Optional parameter use to pick a specific child\r
+ device to start.\r
+\r
+ @retval EFI_SUCCESS The device was started.\r
+ @retval other Fail to start the device.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
VgaClassDriverBindingStart (\r
IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
IN EFI_HANDLE Controller,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
)\r
-/*++\r
- \r
- Routine Description:\r
- \r
- Layers the Simple Text Output Protocol on top of the \r
- VGA Mini Port Protocol\r
- \r
- Arguments:\r
- \r
- (Standard DriverBinding Protocol Start() function)\r
- \r
- Returns:\r
- \r
- EFI_STATUS\r
- \r
---*/\r
-// GC_TODO: This - add argument and description to function comment\r
-// GC_TODO: Controller - add argument and description to function comment\r
-// GC_TODO: RemainingDevicePath - add argument and description to function comment\r
-// GC_TODO: EFI_OUT_OF_RESOURCES - add return value to function comment\r
{\r
EFI_STATUS Status;\r
EFI_VGA_MINI_PORT_PROTOCOL *VgaMiniPort;\r
);\r
\r
//\r
- // Open the IO Abstraction(s) needed\r
+ // Open the PCI I/O Protocol\r
//\r
Status = gBS->OpenProtocol (\r
Controller,\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
-\r
+ //\r
+ // Open the VGA Mini Port Protocol\r
+ //\r
Status = gBS->OpenProtocol (\r
Controller,\r
&gEfiVgaMiniPortProtocolGuid,\r
//\r
// Allocate the private device structure\r
//\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- sizeof (VGA_CLASS_DEV),\r
- (VOID **) &VgaClassPrivate\r
- );\r
- if (EFI_ERROR (Status)) {\r
- gBS->CloseProtocol (\r
- Controller,\r
- &gEfiVgaMiniPortProtocolGuid,\r
- This->DriverBindingHandle,\r
- Controller\r
- );\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- ZeroMem (VgaClassPrivate, sizeof (VGA_CLASS_DEV));\r
+ VgaClassPrivate = AllocateZeroPool (sizeof (VGA_CLASS_DEV));\r
+ ASSERT (VgaClassPrivate != NULL);\r
\r
//\r
// Initialize the private device structure\r
//\r
- VgaClassPrivate->Signature = VGA_CLASS_DEV_SIGNATURE;\r
- VgaClassPrivate->Handle = Controller;\r
+ VgaClassPrivate->Signature = VGA_CLASS_DEV_SIGNATURE;\r
+ VgaClassPrivate->Handle = Controller;\r
VgaClassPrivate->VgaMiniPort = VgaMiniPort;\r
- VgaClassPrivate->PciIo = PciIo;\r
+ VgaClassPrivate->PciIo = PciIo;\r
\r
- VgaClassPrivate->SimpleTextOut.Reset = VgaClassReset;\r
- VgaClassPrivate->SimpleTextOut.OutputString = VgaClassOutputString;\r
- VgaClassPrivate->SimpleTextOut.TestString = VgaClassTestString;\r
- VgaClassPrivate->SimpleTextOut.ClearScreen = VgaClassClearScreen;\r
- VgaClassPrivate->SimpleTextOut.SetAttribute = VgaClassSetAttribute;\r
+ VgaClassPrivate->SimpleTextOut.Reset = VgaClassReset;\r
+ VgaClassPrivate->SimpleTextOut.OutputString = VgaClassOutputString;\r
+ VgaClassPrivate->SimpleTextOut.TestString = VgaClassTestString;\r
+ VgaClassPrivate->SimpleTextOut.ClearScreen = VgaClassClearScreen;\r
+ VgaClassPrivate->SimpleTextOut.SetAttribute = VgaClassSetAttribute;\r
VgaClassPrivate->SimpleTextOut.SetCursorPosition = VgaClassSetCursorPosition;\r
- VgaClassPrivate->SimpleTextOut.EnableCursor = VgaClassEnableCursor;\r
- VgaClassPrivate->SimpleTextOut.QueryMode = VgaClassQueryMode;\r
- VgaClassPrivate->SimpleTextOut.SetMode = VgaClassSetMode;\r
+ VgaClassPrivate->SimpleTextOut.EnableCursor = VgaClassEnableCursor;\r
+ VgaClassPrivate->SimpleTextOut.QueryMode = VgaClassQueryMode;\r
+ VgaClassPrivate->SimpleTextOut.SetMode = VgaClassSetMode;\r
\r
- VgaClassPrivate->SimpleTextOut.Mode = &VgaClassPrivate->SimpleTextOutputMode;\r
- VgaClassPrivate->SimpleTextOutputMode.MaxMode = VgaMiniPort->MaxMode;\r
- VgaClassPrivate->DevicePath = DevicePath;\r
+ VgaClassPrivate->SimpleTextOut.Mode = &VgaClassPrivate->SimpleTextOutputMode;\r
+ VgaClassPrivate->SimpleTextOutputMode.MaxMode = VgaMiniPort->MaxMode;\r
+ VgaClassPrivate->DevicePath = DevicePath;\r
\r
+ //\r
+ // Initialize the VGA device.\r
+ //\r
Status = VgaClassPrivate->SimpleTextOut.SetAttribute (\r
&VgaClassPrivate->SimpleTextOut,\r
- EFI_TEXT_ATTR (EFI_WHITE,\r
- EFI_BLACK)\r
+ EFI_TEXT_ATTR (EFI_WHITE, EFI_BLACK)\r
);\r
if (EFI_ERROR (Status)) {\r
goto ErrorExit;\r
\r
}\r
\r
+/**\r
+ Starts the device controller.\r
+\r
+ This function implments EFI_DRIVER_BINDING_PROTOCOL.Stop().\r
+ It stops this driver on Controller. Support stopping any child handles\r
+ created by this driver.\r
+\r
+ @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ @param ControllerHandle A handle to the device being stopped.\r
+ @param NumberOfChildren The number of child device handles in ChildHandleBuffer.\r
+ @param ChildHandleBuffer An array of child handles to be freed.\r
+\r
+ @retval EFI_SUCCESS This driver is removed ControllerHandle\r
+ @retval other This driver was not removed from this device\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
VgaClassDriverBindingStop (\r
IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
IN EFI_HANDLE Controller,\r
IN UINTN NumberOfChildren,\r
- IN EFI_HANDLE *ChildHandleBuffer\r
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r
)\r
-/*++\r
- \r
- Routine Description:\r
- \r
- Stop.\r
- \r
- Arguments:\r
- \r
- (Standard DriverBinding Protocol Stop() function)\r
- \r
- Returns:\r
- \r
- EFI_STATUS\r
- \r
---*/\r
-// GC_TODO: This - add argument and description to function comment\r
-// GC_TODO: Controller - add argument and description to function comment\r
-// GC_TODO: NumberOfChildren - add argument and description to function comment\r
-// GC_TODO: ChildHandleBuffer - add argument and description to function comment\r
-// GC_TODO: EFI_SUCCESS - add return value to function comment\r
{\r
EFI_STATUS Status;\r
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;\r
// Release PCI I/O and VGA Mini Port Protocols on the controller handle.\r
//\r
gBS->CloseProtocol (\r
- Controller,\r
- &gEfiPciIoProtocolGuid,\r
- This->DriverBindingHandle,\r
- Controller\r
- );\r
+ Controller,\r
+ &gEfiPciIoProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
\r
gBS->CloseProtocol (\r
- Controller,\r
- &gEfiVgaMiniPortProtocolGuid,\r
- This->DriverBindingHandle,\r
- Controller\r
- );\r
+ Controller,\r
+ &gEfiVgaMiniPortProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
\r
- gBS->FreePool (VgaClassPrivate);\r
+ FreePool (VgaClassPrivate);\r
\r
return EFI_SUCCESS;\r
}\r
-//\r
-// Simple Text Output Protocol Functions\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassReset (\r
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
- IN BOOLEAN ExtendedVerification\r
- )\r
-/*++\r
\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
+/**\r
+ Resets the text output device hardware.\r
\r
- This - GC_TODO: add argument description\r
- ExtendedVerification - GC_TODO: add argument description\r
+ This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().\r
+ It resets the text output device hardware. The cursor position is set to (0, 0),\r
+ and the screen is cleared to the default background color for the output device.\r
\r
-Returns:\r
+ @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
+ @param ExtendedVerification Indicates that the driver may perform a more exhaustive\r
+ verification operation of the device during reset.\r
\r
- GC_TODO: add return values\r
+ @retval EFI_SUCCESS The text output device was reset.\r
+ @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and could not be reset.\r
\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+VgaClassReset (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN BOOLEAN ExtendedVerification\r
+ )\r
{\r
EFI_STATUS Status;\r
VGA_CLASS_DEV *VgaClassPrivate;\r
return This->ClearScreen (This);\r
}\r
\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassOutputString (\r
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
- IN CHAR16 *WString\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
+/**\r
+ Writes a Unicode string to the output device.\r
\r
- This - GC_TODO: add argument description\r
- WString - GC_TODO: add argument description\r
+ This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().\r
+ It writes a Unicode string to the output device. This is the most basic output mechanism\r
+ on an output device.\r
\r
-Returns:\r
+ @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
+ @param String The Null-terminated Unicode string to be displayed on the output device(s).\r
\r
- EFI_SUCCESS - GC_TODO: Add description for return value\r
+ @retval EFI_SUCCESS The string was output to the device.\r
+ @retval EFI_DEVICE_ERROR The device reported an error while attempting to output the text.\r
+ @retval EFI_UNSUPPORTED The output device's mode is not currently in a defined text mode.\r
+ @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the characters in\r
+ the Unicode string could not be rendered and were skipped.\r
\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+VgaClassOutputString (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN CHAR16 *String\r
+ )\r
{\r
EFI_STATUS Status;\r
VGA_CLASS_DEV *VgaClassDev;\r
CHAR8 GraphicChar;\r
\r
VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This);\r
-\r
Mode = This->Mode;\r
\r
Status = This->QueryMode (\r
- This,\r
- Mode->Mode,\r
- &MaxColumn,\r
- &MaxRow\r
- );\r
+ This,\r
+ Mode->Mode,\r
+ &MaxColumn,\r
+ &MaxRow\r
+ );\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
- for (; *WString != CHAR_NULL; WString++) {\r
+ //\r
+ // Parse each character of the string to output\r
+ //\r
+ for (; *String != CHAR_NULL; String++) {\r
\r
- switch (*WString) {\r
+ switch (*String) {\r
case CHAR_BACKSPACE:\r
if (Mode->CursorColumn > 0) {\r
Mode->CursorColumn--;\r
break;\r
\r
default:\r
- if (!LibIsValidTextGraphics (*WString, &GraphicChar, NULL)) {\r
+ if (!LibIsValidTextGraphics (*String, &GraphicChar, NULL)) {\r
//\r
- // Just convert to ASCII\r
+ // If this character is not ,Box Drawing text graphics, then convert it to ASCII.\r
//\r
- GraphicChar = (CHAR8) *WString;\r
+ GraphicChar = (CHAR8) *String;\r
if (!IsValidAscii (GraphicChar)) {\r
//\r
- // Keep the API from supporting PCANSI Graphics chars\r
+ // If not valid ASCII char, convert it to "?"\r
//\r
GraphicChar = '?';\r
}\r
return EFI_SUCCESS;\r
}\r
\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassTestString (\r
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
- IN CHAR16 *WString\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
+/**\r
+ Verifies that all characters in a Unicode string can be output to the target device.\r
\r
- This - GC_TODO: add argument description\r
- WString - GC_TODO: add argument description\r
+ This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().\r
+ It verifies that all characters in a Unicode string can be output to the target device.\r
\r
-Returns:\r
+ @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
+ @param String The Null-terminated Unicode string to be examined for the output device(s).\r
\r
- EFI_UNSUPPORTED - GC_TODO: Add description for return value\r
- EFI_SUCCESS - GC_TODO: Add description for return value\r
+ @retval EFI_SUCCESS The device(s) are capable of rendering the output string.\r
+ @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be rendered by\r
+ one or more of the output devices mapped by the EFI handle.\r
\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+VgaClassTestString (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN CHAR16 *String\r
+ )\r
{\r
- while (*WString != 0x0000) {\r
- if (!(IsValidAscii (*WString) || IsValidEfiCntlChar (*WString) || LibIsValidTextGraphics (*WString, NULL, NULL))) {\r
+ while (*String != CHAR_NULL) {\r
+ if (!(IsValidAscii (*String) || IsValidEfiCntlChar (*String) || LibIsValidTextGraphics (*String, NULL, NULL))) {\r
return EFI_UNSUPPORTED;\r
}\r
\r
- WString++;\r
+ String++;\r
}\r
\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Clears the output device(s) display to the currently selected background color.\r
+\r
+ This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen().\r
+ The ClearScreen() function clears the output device(s) display to the currently\r
+ selected background color. The cursor position is set to (0, 0).\r
+\r
+ @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
+\r
+ @retval EFI_SUCESS The operation completed successfully.\r
+ @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.\r
+ @retval EFI_UNSUPPORTED The output device is not in a valid text mode.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
VgaClassClearScreen (\r
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- This - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - GC_TODO: Add description for return value\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
VGA_CLASS_DEV *VgaClassDev;\r
VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This);\r
\r
Status = This->QueryMode (\r
- This,\r
- This->Mode->Mode,\r
- &MaxColumn,\r
- &MaxRow\r
- );\r
+ This,\r
+ This->Mode->Mode,\r
+ &MaxColumn,\r
+ &MaxRow\r
+ );\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Sets the background and foreground colors for theOutputString() and ClearScreen() functions.\r
+\r
+ This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute().\r
+ It sets the background and foreground colors for the OutputString() and ClearScreen() functions.\r
+ The color mask can be set even when the device is in an invalid text mode.\r
+ Devices supporting a different number of text colors are required to emulate the above colors\r
+ to the best of the device's capabilities.\r
+\r
+ @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
+ @param Attribute The attribute to set.\r
+ Bits 0..3 are the foreground color,\r
+ and bits 4..6 are the background color.\r
+\r
+ @retval EFI_SUCCESS The requested attributes were set.\r
+ @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
VgaClassSetAttribute (\r
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
IN UINTN Attribute\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- This - GC_TODO: add argument description\r
- Attribute - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - GC_TODO: Add description for return value\r
- EFI_UNSUPPORTED - GC_TODO: Add description for return value\r
-\r
---*/\r
{\r
if (Attribute <= EFI_MAX_ATTRIBUTE) {\r
This->Mode->Attribute = (INT32) Attribute;\r
return EFI_UNSUPPORTED;\r
}\r
\r
+/**\r
+ Sets the current coordinates of the cursor position.\r
+\r
+ This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition().\r
+ It sets the current coordinates of the cursor position.\r
+ The upper left corner of the screen is defined as coordinate (0, 0).\r
+\r
+ @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
+ @param Column Column of position to set the cursor to.\r
+ @param Row Row of position to set the cursor to.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.\r
+ @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the cursor\r
+ position is invalid for the current mode.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
VgaClassSetCursorPosition (\r
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
IN UINTN Column,\r
IN UINTN Row\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- This - GC_TODO: add argument description\r
- Column - GC_TODO: add argument description\r
- Row - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- EFI_UNSUPPORTED - GC_TODO: Add description for return value\r
- EFI_SUCCESS - GC_TODO: Add description for return value\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
VGA_CLASS_DEV *VgaClassDev;\r
VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This);\r
\r
Status = This->QueryMode (\r
- This,\r
- This->Mode->Mode,\r
- &MaxColumn,\r
- &MaxRow\r
- );\r
+ This,\r
+ This->Mode->Mode,\r
+ &MaxColumn,\r
+ &MaxRow\r
+ );\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Makes the cursor visible or invisible.\r
+\r
+ This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.EnableCursor().\r
+ It makes the cursor visible or invisible.\r
+\r
+ @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
+ @param Visible If TRUE, the cursor is set to be visible.\r
+ If FALSE, the cursor is set to be invisible.\r
+\r
+ @retval EFI_SUCESS The operation completed successfully.\r
+ @retval EFI_DEVICE_ERROR The device had an error and could not complete the request or the\r
+ device does not support changing the cursor mode.\r
+ @retval EFI_UNSUPPORTED The output device does not support visibility control of the cursor.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
VgaClassEnableCursor (\r
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
IN BOOLEAN Visible\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- This - GC_TODO: add argument description\r
- Visible - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - GC_TODO: Add description for return value\r
-\r
---*/\r
{\r
VGA_CLASS_DEV *VgaClassDev;\r
\r
VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This);\r
if (Visible) {\r
- switch (This->Mode->Mode) {\r
- case 1:\r
+ if (This->Mode->Mode == 1) {\r
+ //\r
+ // 80 * 50\r
+ //\r
WriteCrtc (VgaClassDev, CRTC_CURSOR_START, 0x06);\r
WriteCrtc (VgaClassDev, CRTC_CURSOR_END, 0x07);\r
- break;\r
-\r
- default:\r
+ } else {\r
+ //\r
+ // 80 * 25\r
+ //\r
WriteCrtc (VgaClassDev, CRTC_CURSOR_START, 0x0e);\r
WriteCrtc (VgaClassDev, CRTC_CURSOR_END, 0x0f);\r
- break;\r
}\r
} else {\r
WriteCrtc (VgaClassDev, CRTC_CURSOR_START, 0x20);\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Returns information for an available text mode that the output device(s) supports.\r
+\r
+ This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().\r
+ It returns information for an available text mode that the output device(s) supports.\r
+ It is required that all output devices support at least 80x25 text mode. This mode is defined to be mode 0.\r
+ If the output devices support 80x50, that is defined to be mode 1.\r
+\r
+ @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
+ @param ModeNumber The mode number to return information on.\r
+ @param Columns Columen in current mode number\r
+ @param Rows Row in current mode number.\r
+\r
+ @retval EFI_SUCCESS The requested mode information was returned.\r
+ @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.\r
+ @retval EFI_UNSUPPORTED The mode number was not valid.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
VgaClassQueryMode (\r
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
IN UINTN ModeNumber,\r
OUT UINTN *Columns,\r
OUT UINTN *Rows\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- This - GC_TODO: add argument description\r
- ModeNumber - GC_TODO: add argument description\r
- Columns - GC_TODO: add argument description\r
- Rows - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- EFI_UNSUPPORTED - GC_TODO: Add description for return value\r
- EFI_UNSUPPORTED - GC_TODO: Add description for return value\r
- EFI_SUCCESS - GC_TODO: Add description for return value\r
-\r
---*/\r
{\r
if ((INT32) ModeNumber >= This->Mode->MaxMode) {\r
*Columns = 0;\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Sets the output device(s) to a specified mode.\r
+\r
+ This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().\r
+ It sets the output device(s) to the requested mode.\r
+ On success the device is in the geometry for the requested mode,\r
+ and the device has been cleared to the current background color with the cursor at (0,0).\r
+\r
+ @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
+ @param ModeNumber The text mode to set.\r
+\r
+ @retval EFI_SUCCESS The requested text mode was set.\r
+ @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.\r
+ @retval EFI_UNSUPPORTED The mode number was not valid.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
VgaClassSetMode (\r
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
IN UINTN ModeNumber\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- This - GC_TODO: add argument description\r
- ModeNumber - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- EFI_UNSUPPORTED - GC_TODO: Add description for return value\r
-\r
---*/\r
{\r
- EFI_STATUS Status;\r
VGA_CLASS_DEV *VgaClassDev;\r
\r
VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This);\r
\r
This->Mode->Mode = (INT32) ModeNumber;\r
\r
- Status = VgaClassDev->VgaMiniPort->SetMode (VgaClassDev->VgaMiniPort, ModeNumber);\r
-\r
- return Status;\r
-}\r
-//\r
-// Private Worker Functions\r
-//\r
-STATIC\r
-VOID\r
-SetVideoCursorPosition (\r
- IN VGA_CLASS_DEV *VgaClassDev,\r
- IN UINTN Column,\r
- IN UINTN Row,\r
- IN UINTN MaxColumn\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- VgaClassDev - GC_TODO: add argument description\r
- Column - GC_TODO: add argument description\r
- Row - GC_TODO: add argument description\r
- MaxColumn - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
-\r
---*/\r
-{\r
- Column = Column & 0xff;\r
- Row = Row & 0xff;\r
- MaxColumn = MaxColumn & 0xff;\r
- WriteCrtc (\r
- VgaClassDev,\r
- CRTC_CURSOR_LOCATION_HIGH,\r
- (UINT8) ((Row * MaxColumn + Column) >> 8)\r
- );\r
- WriteCrtc (\r
- VgaClassDev,\r
- CRTC_CURSOR_LOCATION_LOW,\r
- (UINT8) ((Row * MaxColumn + Column) & 0xff)\r
- );\r
-}\r
-\r
-STATIC\r
-VOID\r
-WriteCrtc (\r
- IN VGA_CLASS_DEV *VgaClassDev,\r
- IN UINT16 Address,\r
- IN UINT8 Data\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- VgaClassDev - GC_TODO: add argument description\r
- Address - GC_TODO: add argument description\r
- Data - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
-\r
---*/\r
-{\r
- VgaClassDev->PciIo->Io.Write (\r
- VgaClassDev->PciIo,\r
- EfiPciIoWidthUint8,\r
- VgaClassDev->VgaMiniPort->CrtcAddressRegisterBar,\r
- VgaClassDev->VgaMiniPort->CrtcAddressRegisterOffset,\r
- 1,\r
- &Address\r
- );\r
-\r
- VgaClassDev->PciIo->Io.Write (\r
- VgaClassDev->PciIo,\r
- EfiPciIoWidthUint8,\r
- VgaClassDev->VgaMiniPort->CrtcDataRegisterBar,\r
- VgaClassDev->VgaMiniPort->CrtcDataRegisterOffset,\r
- 1,\r
- &Data\r
- );\r
-}\r
-\r
-STATIC\r
-BOOLEAN\r
-LibIsValidTextGraphics (\r
- IN CHAR16 Graphic,\r
- OUT CHAR8 *PcAnsi, OPTIONAL\r
- OUT CHAR8 *Ascii OPTIONAL\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Detects if a Unicode char is for Box Drawing text graphics.\r
-\r
-Arguments:\r
-\r
- Grphic - Unicode char to test.\r
-\r
- PcAnsi - Optional pointer to return PCANSI equivalent of Graphic.\r
-\r
- Asci - Optional pointer to return Ascii equivalent of Graphic.\r
-\r
-Returns:\r
-\r
- TRUE if Gpaphic is a supported Unicode Box Drawing character.\r
-\r
---*/\r
-// GC_TODO: Graphic - add argument and description to function comment\r
-{\r
- UNICODE_TO_CHAR *Table;\r
-\r
- if ((((Graphic & 0xff00) != 0x2500) && ((Graphic & 0xff00) != 0x2100))) {\r
- //\r
- // Unicode drawing code charts are all in the 0x25xx range,\r
- // arrows are 0x21xx\r
- //\r
- return FALSE;\r
- }\r
-\r
- for (Table = UnicodeToPcAnsiOrAscii; Table->Unicode != 0x0000; Table++) {\r
- if (Graphic == Table->Unicode) {\r
- if (PcAnsi) {\r
- *PcAnsi = Table->PcAnsi;\r
- }\r
-\r
- if (Ascii) {\r
- *Ascii = Table->Ascii;\r
- }\r
-\r
- return TRUE;\r
- }\r
- }\r
-\r
- return FALSE;\r
-}\r
-\r
-STATIC\r
-BOOLEAN\r
-IsValidAscii (\r
- IN CHAR16 Ascii\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- Ascii - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
-\r
---*/\r
-{\r
- if ((Ascii >= 0x20) && (Ascii <= 0x7f)) {\r
- return TRUE;\r
- }\r
-\r
- return FALSE;\r
-}\r
-\r
-STATIC\r
-BOOLEAN\r
-IsValidEfiCntlChar (\r
- IN CHAR16 c\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- c - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
-\r
---*/\r
-{\r
- if (c == CHAR_NULL || c == CHAR_BACKSPACE || c == CHAR_LINEFEED || c == CHAR_CARRIAGE_RETURN) {\r
- return TRUE;\r
- }\r
-\r
- return FALSE;\r
+ return VgaClassDev->VgaMiniPort->SetMode (VgaClassDev->VgaMiniPort, ModeNumber);\r
}\r