--- /dev/null
+/** @file\r
+ This file defines the Human Interface Infrastructure protocol which will\r
+ be used by resources which want to publish IFR/Font/String data and have it\r
+ collected by the Configuration engine.\r
+\r
+ Copyright (c) 2007, Intel Corporation\r
+ All rights reserved. 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: FrameworkHii.h\r
+\r
+ @par Revision Reference:\r
+ This protocol is defined in HII spec 0.92.\r
+\r
+**/\r
+\r
+#ifndef _FRAMEWORK_HII_H_\r
+#define _FRAMEWORK_HII_H_\r
+\r
+#include <PiDxe.h>\r
+\r
+//\r
+// To get EFI_GRAPHICS_OUTPUT_BLT_PIXEL,\r
+// is defined in MdePkg/Protocol/GraphicsOutput.h\r
+//\r
+#include <Protocol/GraphicsOutput.h>\r
+\r
+#define EFI_HII_PROTOCOL_GUID \\r
+ { \\r
+ 0xd7ad636e, 0xb997, 0x459b, {0xbf, 0x3f, 0x88, 0x46, 0x89, 0x79, 0x80, 0xe1} \\r
+ }\r
+\r
+// BugBug:\r
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+// If UGA goes away we need to put this some place. I'm not sure where?\r
+//\r
+//typedef struct {\r
+// UINT8 Blue;\r
+// UINT8 Green;\r
+// UINT8 Red;\r
+// UINT8 Reserved;\r
+//} EFI_UGA_PIXEL;\r
+\r
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+//\r
+\r
+typedef struct _EFI_HII_PROTOCOL EFI_HII_PROTOCOL;\r
+\r
+//\r
+// Global definition\r
+//\r
+#define NARROW_CHAR 0xFFF0\r
+#define WIDE_CHAR 0xFFF1\r
+#define NON_BREAKING_CHAR 0xFFF2\r
+#define GLYPH_WIDTH 8\r
+#define GLYPH_HEIGHT 19\r
+\r
+#define EFI_HII_FONT 1\r
+#define EFI_HII_STRING 2\r
+#define EFI_HII_IFR 3\r
+#define EFI_HII_KEYBOARD 4\r
+#define EFI_HII_HANDLES 5\r
+#define EFI_HII_VARIABLE 6\r
+#define EFI_HII_DEVICE_PATH 7\r
+\r
+\r
+// References to string tokens must use this macro to enable scanning for\r
+// token usages.\r
+//\r
+#define STRING_TOKEN(t) t\r
+\r
+//\r
+// The following types are currently defined:\r
+//\r
+typedef UINT16 EFI_FORM_ID;\r
+typedef UINT16 EFI_FORM_LABEL;\r
+\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+ UINT32 Length;\r
+ UINT16 Type;\r
+} EFI_HII_PACK_HEADER;\r
+\r
+//\r
+// A form list consists of a large variety of structure\r
+// possibilities so to represent the binary blob of data\r
+// associated with a package of forms, we will assume a\r
+// pointer to a self-describing data buffer.\r
+//\r
+typedef struct {\r
+ EFI_HII_PACK_HEADER Header;\r
+} EFI_HII_IFR_PACK;\r
+\r
+typedef struct {\r
+ EFI_HII_PACK_HEADER Header; // Must be filled in\r
+ EFI_HANDLE ImageHandle; // Must be filled in\r
+ EFI_HANDLE DeviceHandle; // Optional\r
+ EFI_HANDLE ControllerHandle; // Optional\r
+ EFI_HANDLE CallbackHandle; // Optional\r
+ EFI_HANDLE COBExportHandle; // Optional\r
+} EFI_HII_HANDLE_PACK;\r
+\r
+//\r
+// ********************************************************\r
+// EFI_VARIABLE_CONTENTS\r
+// ********************************************************\r
+//\r
+typedef struct {\r
+ EFI_HII_PACK_HEADER Header;\r
+ EFI_GUID VariableGuid;\r
+ UINT32 VariableNameLength;\r
+ UINT16 VariableId;\r
+ //\r
+ // CHAR16 VariableName[]; //Null-terminated\r
+ //\r
+} EFI_HII_VARIABLE_PACK;\r
+\r
+//\r
+// ********************************************************\r
+// EFI_DEVICE_PATH_PACK\r
+// ********************************************************\r
+//\r
+typedef struct {\r
+ EFI_HII_PACK_HEADER Header;\r
+ //\r
+ // EFI_DEVICE_PATH DevicePath[];\r
+ //\r
+} EFI_HII_DEVICE_PATH_PACK;\r
+\r
+//\r
+// ********************************************************\r
+// EFI_HII_DATA_TABLE\r
+// ********************************************************\r
+//\r
+typedef struct {\r
+ EFI_HII_HANDLE HiiHandle;\r
+ EFI_GUID PackageGuid;\r
+ UINT32 DataTableSize;\r
+ UINT32 IfrDataOffset;\r
+ UINT32 StringDataOffset;\r
+ UINT32 VariableDataOffset;\r
+ UINT32 DevicePathOffset;\r
+ UINT32 NumberOfVariableData;\r
+ UINT32 NumberOfLanguages;\r
+ //\r
+ // EFI_HII_DEVICE_PATH_PACK DevicePath[];\r
+ // EFI_HII_VARIABLE_PACK VariableData[];\r
+ // EFI_HII_IFR_PACK IfrData;\r
+ // EFI_HII_STRING_PACK StringData[];\r
+ //\r
+} EFI_HII_DATA_TABLE;\r
+\r
+//\r
+// ********************************************************\r
+// EFI_HII_EXPORT_TABLE\r
+// ********************************************************\r
+//\r
+typedef struct {\r
+ UINT32 NumberOfHiiDataTables;\r
+ EFI_GUID Revision;\r
+ //\r
+ // EFI_HII_DATA_TABLE HiiDataTable[];\r
+ //\r
+} EFI_HII_EXPORT_TABLE;\r
+\r
+typedef struct {\r
+ BOOLEAN FormSetUpdate; // If TRUE, next variable is significant\r
+ EFI_PHYSICAL_ADDRESS FormCallbackHandle; // If not 0, will update Formset with this info\r
+ BOOLEAN FormUpdate; // If TRUE, next variable is significant\r
+ UINT16 FormValue; // specify which form is to be updated if FormUpdate value is TRUE.\r
+ STRING_REF FormTitle; // If not 0, will update Form with this info\r
+ UINT16 DataCount; // The number of Data entries in this structure\r
+ UINT8 *Data; // An array of 1+ op-codes, specified by DataCount\r
+} EFI_HII_UPDATE_DATA;\r
+\r
+//\r
+// String attributes\r
+//\r
+#define LANG_RIGHT_TO_LEFT 0x00000001\r
+\r
+//\r
+// A string package is used to localize strings to a particular\r
+// language. The package is associated with a particular driver\r
+// or set of drivers. Tools are used to associate tokens with\r
+// string references in forms and in programs. These tokens are\r
+// language agnostic. When paired with a language pack (directly\r
+// or indirectly), the string token resolves into an actual\r
+// UNICODE string. The NumStringPointers determines how many\r
+// StringPointers (offset values) there are as well as the total\r
+// number of Strings that are defined.\r
+//\r
+typedef struct {\r
+ EFI_HII_PACK_HEADER Header;\r
+ RELOFST LanguageNameString;\r
+ RELOFST PrintableLanguageName;\r
+ UINT32 NumStringPointers;\r
+ UINT32 Attributes;\r
+ //\r
+ // RELOFST StringPointers[];\r
+ // EFI_STRING Strings[];\r
+ //\r
+} EFI_HII_STRING_PACK;\r
+\r
+//\r
+// Glyph Attributes\r
+//\r
+#define EFI_GLYPH_NON_SPACING 1\r
+#define EFI_GLYPH_WIDE 2\r
+\r
+typedef struct {\r
+ CHAR16 UnicodeWeight;\r
+ UINT8 Attributes;\r
+ UINT8 GlyphCol1[GLYPH_HEIGHT];\r
+} EFI_NARROW_GLYPH;\r
+\r
+typedef struct {\r
+ CHAR16 UnicodeWeight;\r
+ UINT8 Attributes;\r
+ UINT8 GlyphCol1[GLYPH_HEIGHT];\r
+ UINT8 GlyphCol2[GLYPH_HEIGHT];\r
+ UINT8 Pad[3];\r
+} EFI_WIDE_GLYPH;\r
+\r
+//\r
+// A font list consists of a font header followed by a series\r
+// of glyph structures. Note that fonts are not language specific.\r
+//\r
+typedef struct {\r
+ EFI_HII_PACK_HEADER Header;\r
+ UINT16 NumberOfNarrowGlyphs;\r
+ UINT16 NumberOfWideGlyphs;\r
+} EFI_HII_FONT_PACK;\r
+\r
+//\r
+// The IfrData in the EFI_HII_IFR_PACK structure definition\r
+// is variable length, and not really part of the header. To\r
+// simplify from code the size of the header, define an\r
+// identical structure that does not include the IfrData field.\r
+// Then use sizeof() this new structure to determine the\r
+// actual size of the header.\r
+//\r
+typedef struct {\r
+ EFI_HII_PACK_HEADER Header;\r
+} EFI_HII_IFR_PACK_HEADER;\r
+\r
+//\r
+// pedef EFI_HII_PACK_HEADER EFI_HII_IFR_PACK_HEADER;\r
+//\r
+typedef enum {\r
+ EfiKeyLCtrl,\r
+ EfiKeyA0,\r
+ EfiKeyLAlt,\r
+ EfiKeySpaceBar,\r
+ EfiKeyA2,\r
+ EfiKeyA3,\r
+ EfiKeyA4,\r
+ EfiKeyRCtrl,\r
+ EfiKeyLeftArrow,\r
+ EfiKeyDownArrow,\r
+ EfiKeyRightArrow,\r
+ EfiKeyZero,\r
+ EfiKeyPeriod,\r
+ EfiKeyEnter,\r
+ EfiKeyLShift,\r
+ EfiKeyB0,\r
+ EfiKeyB1,\r
+ EfiKeyB2,\r
+ EfiKeyB3,\r
+ EfiKeyB4,\r
+ EfiKeyB5,\r
+ EfiKeyB6,\r
+ EfiKeyB7,\r
+ EfiKeyB8,\r
+ EfiKeyB9,\r
+ EfiKeyB10,\r
+ EfiKeyRshift,\r
+ EfiKeyUpArrow,\r
+ EfiKeyOne,\r
+ EfiKeyTwo,\r
+ EfiKeyThree,\r
+ EfiKeyCapsLock,\r
+ EfiKeyC1,\r
+ EfiKeyC2,\r
+ EfiKeyC3,\r
+ EfiKeyC4,\r
+ EfiKeyC5,\r
+ EfiKeyC6,\r
+ EfiKeyC7,\r
+ EfiKeyC8,\r
+ EfiKeyC9,\r
+ EfiKeyC10,\r
+ EfiKeyC11,\r
+ EfiKeyC12,\r
+ EfiKeyFour,\r
+ EfiKeyFive,\r
+ EfiKeySix,\r
+ EfiKeyPlus,\r
+ EfiKeyTab,\r
+ EfiKeyD1,\r
+ EfiKeyD2,\r
+ EfiKeyD3,\r
+ EfiKeyD4,\r
+ EfiKeyD5,\r
+ EfiKeyD6,\r
+ EfiKeyD7,\r
+ EfiKeyD8,\r
+ EfiKeyD9,\r
+ EfiKeyD10,\r
+ EfiKeyD11,\r
+ EfiKeyD12,\r
+ EfiKeyD13,\r
+ EfiKeyDel,\r
+ EfiKeyEnd,\r
+ EfiKeyPgDn,\r
+ EfiKeySeven,\r
+ EfiKeyEight,\r
+ EfiKeyNine,\r
+ EfiKeyE0,\r
+ EfiKeyE1,\r
+ EfiKeyE2,\r
+ EfiKeyE3,\r
+ EfiKeyE4,\r
+ EfiKeyE5,\r
+ EfiKeyE6,\r
+ EfiKeyE7,\r
+ EfiKeyE8,\r
+ EfiKeyE9,\r
+ EfiKeyE10,\r
+ EfiKeyE11,\r
+ EfiKeyE12,\r
+ EfiKeyBackSpace,\r
+ EfiKeyIns,\r
+ EfiKeyHome,\r
+ EfiKeyPgUp,\r
+ EfiKeyNLck,\r
+ EfiKeySlash,\r
+ EfiKeyAsterisk,\r
+ EfiKeyMinus,\r
+ EfiKeyEsc,\r
+ EfiKeyF1,\r
+ EfiKeyF2,\r
+ EfiKeyF3,\r
+ EfiKeyF4,\r
+ EfiKeyF5,\r
+ EfiKeyF6,\r
+ EfiKeyF7,\r
+ EfiKeyF8,\r
+ EfiKeyF9,\r
+ EfiKeyF10,\r
+ EfiKeyF11,\r
+ EfiKeyF12,\r
+ EfiKeyPrint,\r
+ EfiKeySLck,\r
+ EfiKeyPause\r
+} EFI_KEY;\r
+\r
+typedef struct {\r
+ EFI_KEY Key;\r
+ CHAR16 Unicode;\r
+ CHAR16 ShiftedUnicode;\r
+ CHAR16 AltGrUnicode;\r
+ CHAR16 ShiftedAltGrUnicode;\r
+ UINT16 Modifier;\r
+} EFI_KEY_DESCRIPTOR;\r
+\r
+//\r
+// This structure allows a sparse set of keys to be redefined\r
+// or a complete redefinition of the keyboard layout. Most\r
+// keyboards have a lot of commonality in their layouts, therefore\r
+// only defining those keys that need to change from the default\r
+// minimizes the passed in information.\r
+//\r
+// Additionally, when an update occurs, the active keyboard layout\r
+// will be switched to the newly updated keyboard layout. This\r
+// allows for situations that when a keyboard layout driver is\r
+// loaded as part of system initialization, the system will default\r
+// the keyboard behavior to the new layout.\r
+//\r
+// Each call to update the keyboard mapping should contain the\r
+// complete set of key descriptors to be updated, since every\r
+// call to the HII which contains an EFI_HII_KEYBOARD_PACK will\r
+// wipe the previous set of overrides. A call to\r
+//\r
+typedef struct {\r
+ EFI_HII_PACK_HEADER Header;\r
+ EFI_KEY_DESCRIPTOR *Descriptor;\r
+ UINT8 DescriptorCount;\r
+} EFI_HII_KEYBOARD_PACK;\r
+\r
+//\r
+// The EFI_HII_PACKAGES can contain different types of packages just\r
+// after the structure as inline data.\r
+//\r
+typedef struct {\r
+ UINTN NumberOfPackages;\r
+ EFI_GUID *GuidId;\r
+ //\r
+ // EFI_HII_HANDLE_PACK *HandlePack; // Only one pack.\r
+ // EFI_HII_IFR_PACK *IfrPack; // Only one pack.\r
+ // EFI_HII_FONT_PACK *FontPack[]; // Multiple packs ok\r
+ // EFI_HII_STRING_PACK *StringPack[]; // Multiple packs ok\r
+ // EFI_HII_KEYBOARD_PACK *KeyboardPack[]; // Multiple packs ok\r
+ //\r
+} EFI_HII_PACKAGES;\r
+\r
+typedef struct _EFI_HII_VARIABLE_PACK_LIST {\r
+ struct _EFI_HII_VARIABLE_PACK_LIST *NextVariablePack;\r
+ EFI_HII_VARIABLE_PACK *VariablePack;\r
+} EFI_HII_VARIABLE_PACK_LIST;\r
+\r
+#pragma pack()\r
+\r
+/**\r
+ Registers the various packs that are passed in via the Packages parameter.\r
+\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param Packages A pointer to an EFI_HII_PACKAGES package instance.\r
+ @param Handle A pointer to the EFI_HII_HANDLE instance.\r
+\r
+ @retval EFI_SUCCESS Data was extracted from Packages, the database\r
+ was updated with the data, and Handle returned successfully.\r
+ @retval EFI_INVALID_PARAMETER The content of Packages was invalid.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_NEW_PACK) (\r
+ IN EFI_HII_PROTOCOL *This,\r
+ IN EFI_HII_PACKAGES *Packages,\r
+ OUT EFI_HII_HANDLE *Handle\r
+ );\r
+\r
+/**\r
+ Removes a package from the HII database.\r
+\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param Handle The handle that was registered to the data that is requested\r
+ for removal.\r
+\r
+ @retval EFI_SUCCESS The data associated with the Handle was removed\r
+ from the HII database.\r
+ @retval EFI_INVALID_PARAMETER The Handle was not valid.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_REMOVE_PACK) (\r
+ IN EFI_HII_PROTOCOL *This,\r
+ IN EFI_HII_HANDLE Handle\r
+ );\r
+\r
+/**\r
+ Determines the handles that are currently active in the database.\r
+\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param HandleBufferLength On input, a pointer to the length of the handle\r
+ buffer. On output, the length of the handle buffer that is required\r
+ for the handles found.\r
+ @param Handle An array of EFI_HII_HANDLE instances returned.\r
+\r
+ @retval EFI_SUCCESS Handle was updated successfully.\r
+ @retval EFI_BUFFER_TOO_SMALL The HandleBufferLength parameter indicates\r
+ that Handle is too small to support the number of handles.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_FIND_HANDLES) (\r
+ IN EFI_HII_PROTOCOL *This,\r
+ IN OUT UINT16 *HandleBufferLength,\r
+ OUT EFI_HII_HANDLE *Handle\r
+ );\r
+\r
+/**\r
+ Exports the contents of the database into a buffer.\r
+\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param Handle An EFI_HII_HANDLE that corresponds to the desired\r
+ handle to export. If the value is 0, the entire database will be exported.\r
+ In either case, the data will be exported in a format described by the\r
+ structure definition of EFI_HII_EXPORT_TABLE.\r
+ @param BufferSize\r
+ On input, a pointer to the length of the buffer. On output, the length\r
+ of the buffer that is required for the export data.\r
+ @param Buffer A pointer to a buffer that will contain the results of the export function.\r
+\r
+ @retval EFI_SUCCESS The buffer was successfully filled with BufferSize amount of data.\r
+ @retval EFI_BUFFER_TOO_SMALL The value in BufferSize was too small to contain the export data.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_EXPORT) (\r
+ IN EFI_HII_PROTOCOL *This,\r
+ IN EFI_HII_HANDLE Handle,\r
+ IN OUT UINTN *BufferSize,\r
+ OUT VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Remove any new strings that were added after the initial string export\r
+ for this handle.\r
+\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param Handle The handle on which the string resides.\r
+\r
+ @retval EFI_SUCCESS Remove strings from the handle successfully.\r
+ @retval EFI_INVALID_PARAMETER The Handle was unknown.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_RESET_STRINGS) (\r
+ IN EFI_HII_PROTOCOL *This,\r
+ IN EFI_HII_HANDLE Handle\r
+ );\r
+\r
+/**\r
+ Tests if all of the characters in a string have corresponding font characters.\r
+\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param StringToTest A pointer to a Unicode string.\r
+ @param FirstMissing A pointer to an index into the string. On input,\r
+ the index of the first character in the StringToTest to examine. On exit,\r
+ the index of the first character encountered for which a glyph is unavailable.\r
+ If all glyphs in the string are available, the index is the index of the\r
+ terminator of the string.\r
+ @param GlyphBufferSize A pointer to a value. On output, if the function\r
+ returns EFI_SUCCESS, it contains the amount of memory that is required to\r
+ store the string's glyph equivalent.\r
+\r
+ @retval EFI_SUCCESS All glyphs are available. Note that an empty string\r
+ always returns this value.\r
+ @retval EFI_NOT_FOUND A glyph was not found for a character.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_TEST_STRING) (\r
+ IN EFI_HII_PROTOCOL *This,\r
+ IN CHAR16 *StringToTest,\r
+ IN OUT UINT32 *FirstMissing,\r
+ OUT UINT32 *GlyphBufferSize\r
+ );\r
+\r
+/**\r
+ Translates a Unicode character into the corresponding font glyph.\r
+\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param Source A pointer to a Unicode string.\r
+ @param Index On input, the offset into the string from which to fetch\r
+ the character.On successful completion, the index is updated to the first\r
+ character past the character(s) making up the just extracted glyph.\r
+ @param GlyphBuffer Pointer to an array where the glyphs corresponding\r
+ to the characters in the source may be stored. GlyphBuffer is assumed\r
+ to be wide enough to accept a wide glyph character.\r
+ @param BitWidth If EFI_SUCCESS was returned, the UINT16 pointed to by\r
+ this value is filled with the length of the glyph in pixels. It is unchanged\r
+ if the call was unsuccessful.\r
+ @param InternalStatus The cell pointed to by this parameter must be\r
+ initialized to zero prior to invoking the call the first time for any string.\r
+\r
+ @retval EFI_SUCCESS It worked.\r
+ @retval EFI_NOT_FOUND A glyph for a character was not found.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_GLYPH) (\r
+ IN EFI_HII_PROTOCOL *This,\r
+ IN CHAR16 *Source,\r
+ IN OUT UINT16 *Index,\r
+ OUT UINT8 **GlyphBuffer,\r
+ OUT UINT16 *BitWidth,\r
+ IN OUT UINT32 *InternalStatus\r
+ );\r
+\r
+/**\r
+ Translates a glyph into the format required for input to the Universal\r
+ Graphics Adapter (UGA) Block Transfer (BLT) routines.\r
+\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param GlyphBuffer A pointer to the buffer that contains glyph data.\r
+ @param Foreground The foreground setting requested to be used for the\r
+ generated BltBuffer data.\r
+ @param Background The background setting requested to be used for the\r
+ generated BltBuffer data.\r
+ @param Count The entry in the BltBuffer upon which to act.\r
+ @param Width The width in bits of the glyph being converted.\r
+ @param Height The height in bits of the glyph being converted\r
+ @param BltBuffer A pointer to the buffer that contains the data that is\r
+ ready to be used by the UGA BLT routines.\r
+\r
+ @retval EFI_SUCCESS It worked.\r
+ @retval EFI_NOT_FOUND A glyph for a character was not found.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GLYPH_TO_BLT) (\r
+ IN EFI_HII_PROTOCOL *This,\r
+ IN UINT8 *GlyphBuffer,\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,\r
+ IN UINTN Count,\r
+ IN UINTN Width,\r
+ IN UINTN Height,\r
+ IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer\r
+ );\r
+\r
+/**\r
+ Allows a new string to be added to an already existing string package.\r
+\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param Pointer to a NULL-terminated string containing a single ISO 639-2\r
+ language identifier, indicating the language in which the string is translated.\r
+ @param Handle The handle of the language pack to which the string is to be added.\r
+ @param Reference The identifier of the string to be added. If the reference\r
+ value is zero, then the string will be assigned a new identifier on that\r
+ handle for the language specified. Otherwise, the string will be updated\r
+ with the NewString Value.\r
+ @param NewString The string to be added.\r
+\r
+ @retval EFI_SUCCESS The string was effectively registered.\r
+ @retval EFI_INVALID_PARAMETER The Handle was unknown.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_NEW_STRING) (\r
+ IN EFI_HII_PROTOCOL *This,\r
+ IN CHAR16 *Language,\r
+ IN EFI_HII_HANDLE Handle,\r
+ IN OUT STRING_REF *Reference,\r
+ IN CHAR16 *NewString\r
+ );\r
+\r
+/**\r
+ Allows a program to determine the primary languages that are supported\r
+ on a given handle.\r
+\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param Handle The handle on which the strings reside.\r
+ @param LanguageString A string allocated by GetPrimaryLanguages() that\r
+ contains a list of all primary languages registered on the handle.\r
+\r
+ @retval EFI_SUCCESS LanguageString was correctly returned.\r
+ @retval EFI_INVALID_PARAMETER The Handle was unknown.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_PRI_LANGUAGES) (\r
+ IN EFI_HII_PROTOCOL *This,\r
+ IN EFI_HII_HANDLE Handle,\r
+ OUT EFI_STRING *LanguageString\r
+ );\r
+\r
+/**\r
+ Allows a program to determine which secondary languages are supported\r
+ on a given handle for a given primary language.\r
+\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param Handle The handle on which the strings reside.\r
+ @param PrimaryLanguage Pointer to a NULL-terminated string containing a single\r
+ ISO 639-2 language identifier, indicating the primary language.\r
+ @param LanguageString A string allocated by GetSecondaryLanguages()\r
+ containing a list of all secondary languages registered on the handle.\r
+\r
+ @retval EFI_SUCCESS LanguageString was correctly returned.\r
+ @retval EFI_INVALID_PARAMETER The Handle was unknown.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_SEC_LANGUAGES) (\r
+ IN EFI_HII_PROTOCOL *This,\r
+ IN EFI_HII_HANDLE Handle,\r
+ IN CHAR16 *PrimaryLanguage,\r
+ OUT EFI_STRING *LanguageString\r
+ );\r
+\r
+/**\r
+ Extracts a string from a package already registered with the EFI HII database.\r
+\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param Handle The handle on which the string resides.\r
+ @param Token The string token assigned to the string.\r
+ @param Raw If TRUE, the string is returned unedited in the internal\r
+ storage format described above. If false, the string returned is edited\r
+ by replacing <cr> with <space> and by removing special characters such\r
+ as the <wide> prefix.\r
+ @param LanguageString Pointer to a NULL-terminated string containing a\r
+ single ISO 639-2 language identifier, indicating the language to print.\r
+ If the LanguageString is empty (starts with a NULL), the default system\r
+ language will be used to determine the language.\r
+ @param BufferLength Length of the StringBuffer.\r
+ @param StringBuffer The buffer designed to receive the characters in the string.\r
+\r
+ @retval EFI_SUCCESS StringBuffer is filled with a NULL-terminated string.\r
+ @retval EFI_INVALID_PARAMETER The handle or string token is unknown.\r
+ @retval EFI_BUFFER_TOO_SMALL The buffer provided was not large enough to\r
+ allow the entire string to be stored.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_STRING) (\r
+ IN EFI_HII_PROTOCOL *This,\r
+ IN EFI_HII_HANDLE Handle,\r
+ IN STRING_REF Token,\r
+ IN BOOLEAN Raw,\r
+ IN CHAR16 *LanguageString,\r
+ IN OUT UINTN *BufferLength,\r
+ OUT EFI_STRING StringBuffer\r
+ );\r
+\r
+/**\r
+ Allows a program to extract a part of a string of not more than a given width.\r
+\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param Handle The handle on which the string resides.\r
+ @param Token The string token assigned to the string.\r
+ @param Index On input, the offset into the string where the line is to start.\r
+ On output, the index is updated to point to beyond the last character returned\r
+ in the call.\r
+ @param LineWidth The maximum width of the line in units of narrow glyphs.\r
+ @param LanguageString Pointer to a NULL-terminated string containing a\r
+ single ISO 639-2 language identifier, indicating the language to print.\r
+ @param BufferLength Pointer to the length of the StringBuffer.\r
+ @param StringBuffer The buffer designed to receive the characters in the string.\r
+\r
+ @retval EFI_SUCCESS StringBuffer filled with characters that will fit on the line.\r
+ @retval EFI_NOT_FOUND The font glyph for at least one of the characters in\r
+ the string is not in the font database.\r
+ @retval EFI_BUFFER_TOO_SMALL The buffer provided was not large enough\r
+ to allow the entire string to be stored.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_LINE) (\r
+ IN EFI_HII_PROTOCOL *This,\r
+ IN EFI_HII_HANDLE Handle,\r
+ IN STRING_REF Token,\r
+ IN OUT UINT16 *Index,\r
+ IN UINT16 LineWidth,\r
+ IN CHAR16 *LanguageString,\r
+ IN OUT UINT16 *BufferLength,\r
+ OUT EFI_STRING StringBuffer\r
+ );\r
+\r
+/**\r
+ Allows a program to extract a form or form package that has previously\r
+ been registered with the HII database.\r
+\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param Handle Handle on which the form resides.\r
+ @param FormId The ID of the form to return. If the ID is zero,\r
+ the entire form package is returned.\r
+ @param BufferLength On input, the length of the Buffer. On output,\r
+ the length of the returned buffer,\r
+ @param Buffer The buffer designed to receive the form(s).\r
+\r
+ @retval EFI_SUCCESS Buffer filled with the requested forms. BufferLength\r
+ was updated.\r
+ @retval EFI_INVALID_PARAMETER The handle is unknown.\r
+ @retval EFI_NOT_FOUND A form on the requested handle cannot be found with\r
+ the requested FormId.\r
+ @retval EFI_BUFFER_TOO_SMALL The buffer provided was not large enough\r
+ to allow the form to be stored.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_FORMS) (\r
+ IN EFI_HII_PROTOCOL *This,\r
+ IN EFI_HII_HANDLE Handle,\r
+ IN EFI_FORM_ID FormId,\r
+ IN OUT UINTN *BufferLength,\r
+ OUT UINT8 *Buffer\r
+ );\r
+\r
+/**\r
+ Extracts the defaults that are associated with a given handle in the HII database.\r
+\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param Handle The HII handle from which will have default data retrieved.\r
+ @param DefaultMask The mask used to specify some type of default override when extracting\r
+ the default image data.\r
+ @param VariablePackList A indirect pointer to the first entry of a link list with\r
+ type EFI_HII_VARIABLE_PACK_LIST.\r
+\r
+ @retval EFI_SUCCESS The VariablePackList was populated with the appropriate\r
+ default setting data.\r
+ @retval EFI_NOT_FOUND The IFR does not have any explicit or default map(s).\r
+ @retval EFI_INVALID_PARAMETER The HII database entry associated with Handle\r
+ contain invalid data.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_DEFAULT_IMAGE) (\r
+ IN EFI_HII_PROTOCOL *This,\r
+ IN EFI_HII_HANDLE Handle,\r
+ IN UINTN DefaultMask,\r
+ OUT EFI_HII_VARIABLE_PACK_LIST **VariablePackList\r
+ );\r
+\r
+/**\r
+ Allows the caller to update a form or form package that has previously been\r
+ registered with the EFI HII database.\r
+\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param Handle Handle of the package where the form to be updated resides.\r
+ @param Label The label inside the form package where the update is to take place.\r
+ @param AddData If TRUE, adding data at a given Label; otherwise,\r
+ if FALSE, removing data at a given Label.\r
+ @param Data The buffer containing the new tags to insert after the Label\r
+\r
+ @retval EFI_SUCCESS The form was updated with the new tags.\r
+ @retval EFI_INVALID_PARAMETER The buffer for the buffer length does not\r
+ contain an integral number of tags.\r
+ @retval EFI_NOT_FOUND The Handle, Label, or FormId was not found.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_UPDATE_FORM) (\r
+ IN EFI_HII_PROTOCOL *This,\r
+ IN EFI_HII_HANDLE Handle,\r
+ IN EFI_FORM_LABEL Label,\r
+ IN BOOLEAN AddData,\r
+ IN EFI_HII_UPDATE_DATA *Data\r
+ );\r
+\r
+/**\r
+ Retrieves the current keyboard layout.\r
+\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param DescriptorCount A pointer to the number of Descriptor entries being\r
+ described in the keyboard layout being retrieved.\r
+ @param Descriptor A pointer to a buffer containing an array of EFI_KEY_DESCRIPTOR\r
+ entries. Each entry will reflect the definition of a specific physical key.\r
+\r
+ @retval EFI_SUCCESS The keyboard layout was retrieved successfully.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_KEYBOARD_LAYOUT) (\r
+ IN EFI_HII_PROTOCOL *This,\r
+ OUT UINT16 *DescriptorCount,\r
+ OUT EFI_KEY_DESCRIPTOR *Descriptor\r
+ );\r
+\r
+/**\r
+ @par Protocol Description:\r
+ The HII Protocol manages the HII database, which is a repository for data\r
+ having to do with fonts, strings, forms, keyboards, and other future human\r
+ interface items.\r
+\r
+ @param NewPack\r
+ Extracts the various packs from a package list.\r
+\r
+ @param RemovePack\r
+ Removes a package from the HII database.\r
+\r
+ @param FindHandles\r
+ Determines the handles that are currently active in the database.\r
+\r
+ @param ExportDatabase\r
+ Export the entire contents of the database to a buffer.\r
+\r
+ @param TestString\r
+ Tests if all of the characters in a string have corresponding font characters.\r
+\r
+ @param GetGlyph\r
+ Translates a Unicode character into the corresponding font glyph.\r
+\r
+ @param GlyphToBlt\r
+ Converts a glyph value into a format that is ready for a UGA BLT command.\r
+\r
+ @param NewString\r
+ Allows a new string to be added to an already existing string package.\r
+\r
+ @param GetPrimaryLanguages\r
+ Allows a program to determine the primary languages that are supported\r
+ on a given handle.\r
+\r
+ @param GetSecondaryLanguages\r
+ Allows a program to determine which secondary languages are supported\r
+ on a given handle for a given primary language.\r
+\r
+ @param GetString\r
+ Extracts a string from a package that is already registered with the\r
+ EFI HII database.\r
+\r
+ @param ResetString\r
+ Remove any new strings that were added after the initial string export\r
+ for this handle.\r
+\r
+ @param GetLine\r
+ Allows a program to extract a part of a string of not more than a given width.\r
+\r
+ @param GetForms\r
+ Allows a program to extract a form or form package that has been previously registered.\r
+\r
+ @param GetDefaultImage\r
+ Allows a program to extract the nonvolatile image that represents the default storage image.\r
+\r
+ @param UpdateForm\r
+ Allows a program to update a previously registered form.\r
+\r
+ @param GetKeyboardLayout\r
+ Allows a program to extract the current keyboard layout.\r
+\r
+**/\r
+struct _EFI_HII_PROTOCOL {\r
+ EFI_HII_NEW_PACK NewPack;\r
+ EFI_HII_REMOVE_PACK RemovePack;\r
+ EFI_HII_FIND_HANDLES FindHandles;\r
+ EFI_HII_EXPORT ExportDatabase;\r
+\r
+ EFI_HII_TEST_STRING TestString;\r
+ EFI_HII_GET_GLYPH GetGlyph;\r
+ EFI_HII_GLYPH_TO_BLT GlyphToBlt;\r
+\r
+ EFI_HII_NEW_STRING NewString;\r
+ EFI_HII_GET_PRI_LANGUAGES GetPrimaryLanguages;\r
+ EFI_HII_GET_SEC_LANGUAGES GetSecondaryLanguages;\r
+ EFI_HII_GET_STRING GetString;\r
+ EFI_HII_RESET_STRINGS ResetStrings;\r
+ EFI_HII_GET_LINE GetLine;\r
+ EFI_HII_GET_FORMS GetForms;\r
+ EFI_HII_GET_DEFAULT_IMAGE GetDefaultImage;\r
+ EFI_HII_UPDATE_FORM UpdateForm;\r
+\r
+ EFI_HII_GET_KEYBOARD_LAYOUT GetKeyboardLayout;\r
+};\r
+\r
+extern EFI_GUID gEfiHiiProtocolGuid;\r
+\r
+#endif\r
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2006 - 2007, Intel Corporation\r
+ All rights reserved. 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
+ 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
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiPei.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Ppi/DxeIpl.h>\r
+#include <Ppi/S3Resume.h>\r
+#include <Protocol/EdkDecompress.h>\r
+#include <Ppi/EndOfPeiPhase.h>\r
+#include <Protocol/CustomizedDecompress.h>\r
+#include <Protocol/Decompress.h>\r
+#include <Ppi/Security.h>\r
+#include <Ppi/SectionExtraction.h>\r
+#include <Ppi/LoadFile.h>\r
+#include <Ppi/RecoveryModule.h>\r
+#include <Ppi/MemoryDiscovered.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/PeimEntryPoint.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
+#include <Library/CacheMaintenanceLib.h>\r
+#include <Library/PeCoffLoaderLib.h>\r
+#include <Library/UefiDecompressLib.h>\r
+#include <Library/CustomDecompressLib.h>\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/PeCoffLib.h>\r
+\r
+#endif\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ DxeIpl.dxs\r
+\r
+Abstract:\r
+\r
+ Dependency expression file for DXE Initial Program Loader PEIM.\r
+ \r
+--*/ \r
+\r
+#include <PeimDepex.h>\r
+\r
+DEPENDENCY_START\r
+ EFI_PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID\r
+DEPENDENCY_END\r
+\r
+\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. 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
+ DxeIpl.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef __PEI_DXEIPL_H__\r
+#define __PEI_DXEIPL_H__\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#define STACK_SIZE 0x20000\r
+#define BSP_STORE_SIZE 0x4000\r
+\r
+#define GET_OCCUPIED_SIZE(ActualSize, Alignment) ((ActualSize + (Alignment - 1)) & ~(Alignment - 1))\r
+\r
+extern BOOLEAN gInMemory;\r
+\r
+EFI_STATUS\r
+PeiFindFile (\r
+ IN UINT8 Type,\r
+ IN UINT16 SectionType,\r
+ OUT EFI_GUID *FileName,\r
+ OUT VOID **Pe32Data\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+PeiLoadFile (\r
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader,\r
+ IN VOID *Pe32Data,\r
+ OUT EFI_PHYSICAL_ADDRESS *ImageAddress,\r
+ OUT UINT64 *ImageSize,\r
+ OUT EFI_PHYSICAL_ADDRESS *EntryPoint\r
+ )\r
+;\r
+\r
+\r
+EFI_STATUS\r
+GetImageReadFunction (\r
+ IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+PeiImageRead (\r
+ IN VOID *FileHandle,\r
+ IN UINTN FileOffset,\r
+ IN OUT UINTN *ReadSize,\r
+ OUT VOID *Buffer\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DxeIplLoadFile (\r
+ IN EFI_PEI_FV_FILE_LOADER_PPI *This,\r
+ IN EFI_FFS_FILE_HEADER *FfsHeader,\r
+ OUT EFI_PHYSICAL_ADDRESS *ImageAddress,\r
+ OUT UINT64 *ImageSize,\r
+ OUT EFI_PHYSICAL_ADDRESS *EntryPoint\r
+ );\r
+\r
+EFI_STATUS\r
+ShadowDxeIpl (\r
+ IN EFI_FFS_FILE_HEADER *DxeIpl,\r
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DxeLoadCore (\r
+ IN EFI_DXE_IPL_PPI *This,\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_PEI_HOB_POINTERS HobList\r
+ );\r
+\r
+VOID\r
+HandOffToDxeCore (\r
+ IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,\r
+ IN EFI_PEI_HOB_POINTERS HobList,\r
+ IN EFI_PEI_PPI_DESCRIPTOR *EndOfPeiSignal\r
+ );\r
+\r
+EFI_STATUS\r
+PeiProcessFile (\r
+ IN UINT16 SectionType,\r
+ IN EFI_FFS_FILE_HEADER *FfsFileHeader,\r
+ OUT VOID **Pe32Data,\r
+ IN EFI_PEI_HOB_POINTERS *OrigHob\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeimInitializeDxeIpl (\r
+ IN EFI_FFS_FILE_HEADER *FfsHeader,\r
+ IN EFI_PEI_SERVICES **PeiServices\r
+ );\r
+\r
+\r
+#endif\r
--- /dev/null
+#/** @file\r
+# Component description file for DxeIpl module\r
+#\r
+# The responsibility of this module is to load the DXE Core from a Firmware Volume. This implementation i used to load a 32-bit DXE Core.\r
+# Copyright (c) 2006 - 2007, Intel Corporation\r
+#\r
+# All rights reserved. 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
+# 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
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = DxeIpl\r
+ FILE_GUID = 86D70125-BAA3-4296-A62F-602BEBBB9081\r
+ MODULE_TYPE = PEIM\r
+ VERSION_STRING = 1.0\r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+ ENTRY_POINT = PeimInitializeDxeIpl\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ DxeIpl.h\r
+ DxeLoad.c\r
+ CommonHeader.h\r
+\r
+[Sources.Ia32]\r
+ Ia32/VirtualMemory.h\r
+ Ia32/VirtualMemory.c\r
+ Ia32/DxeLoadFunc.c\r
+ Ia32/ImageRead.c\r
+\r
+[Sources.X64]\r
+ X64/DxeLoadFunc.c\r
+ Ia32/ImageRead.c\r
+\r
+[Sources.IPF]\r
+ Ipf/DxeLoadFunc.c\r
+ Ipf/ImageRead.c\r
+\r
+[Sources.EBC]\r
+ X64/DxeLoadFunc.c\r
+ Ia32/ImageRead.c\r
+\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec \r
+ IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+ IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ PeCoffLib\r
+ PcdLib\r
+ MemoryAllocationLib\r
+ BaseMemoryLib\r
+ PeiServicesTablePointerLib\r
+ CustomDecompressLib\r
+ TianoDecompressLib\r
+ UefiDecompressLib\r
+ EdkPeCoffLoaderLib\r
+ CacheMaintenanceLib\r
+ ReportStatusCodeLib\r
+ PeiServicesLib\r
+ HobLib\r
+ BaseLib\r
+ PeimEntryPoint\r
+ DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Guid C Name Section - list of Guids that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+\r
+################################################################################\r
+#\r
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
+# that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Protocols]\r
+ gEfiCustomizedDecompressProtocolGuid # PROTOCOL SOMETIMES_PRODUCED\r
+ gEfiTianoDecompressProtocolGuid # PROTOCOL SOMETIMES_PRODUCED\r
+ gEfiDecompressProtocolGuid # PROTOCOL SOMETIMES_PRODUCED\r
+\r
+\r
+################################################################################\r
+#\r
+# PPI C Name Section - list of PPI and PPI Notify C Names that this module\r
+# uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Ppis]\r
+ gEfiPeiSecurityPpiGuid # PPI SOMETIMES_CONSUMED\r
+ gEfiPeiSectionExtractionPpiGuid # PPI SOMETIMES_CONSUMED\r
+ gEfiPeiS3ResumePpiGuid # PPI SOMETIMES_CONSUMED\r
+ gEfiPeiRecoveryModulePpiGuid # PPI SOMETIMES_CONSUMED\r
+ gEfiEndOfPeiSignalPpiGuid # PPI SOMETIMES_PRODUCED\r
+ gEfiPeiFvFileLoaderPpiGuid # PPI SOMETIMES_PRODUCED\r
+ gEfiDxeIplPpiGuid # PPI SOMETIMES_PRODUCED\r
+ gEfiPeiPeCoffLoaderGuid \r
+\r
+\r
+################################################################################\r
+#\r
+# Pcd FEATURE_FLAG - list of PCDs that this module is coded for.\r
+#\r
+################################################################################\r
+\r
+[PcdsFeatureFlag.common]\r
+ PcdDxeIplSupportCustomDecompress|gEfiEdkModulePkgTokenSpaceGuid\r
+ PcdDxeIplSupportTianoDecompress|gEfiEdkModulePkgTokenSpaceGuid\r
+ PcdDxeIplSupportEfiDecompress|gEfiEdkModulePkgTokenSpaceGuid\r
+ PcdDxeIplBuildShareCodeHobs|gEfiEdkModulePkgTokenSpaceGuid\r
+\r
+[PcdsFeatureFlag.IA32]\r
+ PcdDxeIplSwitchToLongMode|gEfiMdeModulePkgTokenSpaceGuid\r
+\r
+\r
+################################################################################\r
+#\r
+# Dependency Expression Section - list of Dependency expressions that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Depex]\r
+ gEfiPeiMemoryDiscoveredPpiGuid\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>DxeIpl</ModuleName>\r
+ <ModuleType>PEIM</ModuleType>\r
+ <GuidValue>86D70125-BAA3-4296-A62F-602BEBBB9081</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Component description file for DxeIpl module</Abstract>\r
+ <Description>The responsibility of this module is to load the DXE Core from a Firmware Volume. This implementation i used to load a 32-bit DXE Core.</Description>\r
+ <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
+ <License>All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>DxeIpl</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>DebugLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>PeimEntryPoint</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>HobLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>PeiServicesLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>ReportStatusCodeLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>CacheMaintenanceLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>EdkPeCoffLoaderLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiDecompressLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>TianoDecompressLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>CustomDecompressLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>PeiServicesTablePointerLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseMemoryLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>MemoryAllocationLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>PcdLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>PeCoffLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>DxeLoad.c</Filename>\r
+ <Filename>DxeIpl.h</Filename>\r
+ <Filename>DxeIpl.dxs</Filename>\r
+ <Filename SupArchList="IA32 X64 EBC">Ia32/ImageRead.c</Filename>\r
+ <Filename SupArchList="IA32">Ia32/DxeLoadFunc.c</Filename>\r
+ <Filename SupArchList="IA32">Ia32/VirtualMemory.c</Filename>\r
+ <Filename SupArchList="IA32">Ia32/VirtualMemory.h</Filename>\r
+ <Filename SupArchList="X64 EBC">X64/DxeLoadFunc.c</Filename>\r
+ <Filename SupArchList="IPF">Ipf/ImageRead.c</Filename>\r
+ <Filename SupArchList="IPF">Ipf/DxeLoadFunc.c</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+ </PackageDependencies>\r
+ <Protocols>\r
+ <Protocol Usage="SOMETIMES_PRODUCED">\r
+ <ProtocolCName>gEfiDecompressProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="SOMETIMES_PRODUCED">\r
+ <ProtocolCName>gEfiTianoDecompressProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="SOMETIMES_PRODUCED">\r
+ <ProtocolCName>gEfiCustomizedDecompressProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ </Protocols>\r
+ <PPIs>\r
+ <Ppi Usage="SOMETIMES_PRODUCED">\r
+ <PpiCName>gEfiDxeIplPpiGuid</PpiCName>\r
+ </Ppi>\r
+ <Ppi Usage="SOMETIMES_PRODUCED">\r
+ <PpiCName>gEfiPeiFvFileLoaderPpiGuid</PpiCName>\r
+ </Ppi>\r
+ <Ppi Usage="SOMETIMES_PRODUCED">\r
+ <PpiCName>gEfiEndOfPeiSignalPpiGuid</PpiCName>\r
+ </Ppi>\r
+ <Ppi Usage="SOMETIMES_CONSUMED">\r
+ <PpiCName>gEfiPeiRecoveryModulePpiGuid</PpiCName>\r
+ </Ppi>\r
+ <Ppi Usage="SOMETIMES_CONSUMED">\r
+ <PpiCName>gEfiPeiS3ResumePpiGuid</PpiCName>\r
+ </Ppi>\r
+ <Ppi Usage="SOMETIMES_CONSUMED">\r
+ <PpiCName>gEfiPeiSectionExtractionPpiGuid</PpiCName>\r
+ </Ppi>\r
+ <Ppi Usage="SOMETIMES_CONSUMED">\r
+ <PpiCName>gEfiPeiSecurityPpiGuid</PpiCName>\r
+ </Ppi>\r
+ </PPIs>\r
+ <Guids>\r
+ <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+ <GuidCName>gEfiPeiPeCoffLoaderGuid</GuidCName>\r
+ </GuidCNames>\r
+ </Guids>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ <Extern>\r
+ <ModuleEntryPoint>PeimInitializeDxeIpl</ModuleEntryPoint>\r
+ </Extern>\r
+ </Externs>\r
+ <PcdCoded>\r
+ <PcdEntry PcdItemType="FEATURE_FLAG" Usage="ALWAYS_CONSUMED" SupArchList="IA32">\r
+ <C_Name>PcdDxeIplSwitchToLongMode</C_Name>\r
+ <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <DefaultValue>TRUE</DefaultValue>\r
+ <HelpText>If this feature is enabled, then the DXE IPL will load a 64-bit DxeCore.</HelpText>\r
+ </PcdEntry>\r
+ <PcdEntry PcdItemType="FEATURE_FLAG" Usage="ALWAYS_CONSUMED">\r
+ <C_Name>PcdDxeIplBuildShareCodeHobs</C_Name>\r
+ <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <DefaultValue>FALSE</DefaultValue>\r
+ <HelpText>If this feature is enabled, DXE IPL will build a series of HOBs to share code with DXE Core.</HelpText>\r
+ </PcdEntry>\r
+ <PcdEntry PcdItemType="FEATURE_FLAG" Usage="ALWAYS_CONSUMED">\r
+ <C_Name>PcdDxeIplSupportEfiDecompress</C_Name>\r
+ <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <DefaultValue>TRUE</DefaultValue>\r
+ <HelpText>If this feature is enabled, then the DXE IPL must support decompressing files compressed with the EFI Compression algorithm</HelpText>\r
+ </PcdEntry>\r
+ <PcdEntry PcdItemType="FEATURE_FLAG" Usage="ALWAYS_CONSUMED">\r
+ <C_Name>PcdDxeIplSupportTianoDecompress</C_Name>\r
+ <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <DefaultValue>TRUE</DefaultValue>\r
+ <HelpText>If this feature is enabled, then the DXE IPL must support decompressing files compressed with the Tiano Compression algorithm</HelpText>\r
+ </PcdEntry>\r
+ <PcdEntry PcdItemType="FEATURE_FLAG" Usage="ALWAYS_CONSUMED">\r
+ <C_Name>PcdDxeIplSupportCustomDecompress</C_Name>\r
+ <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <DefaultValue>TRUE</DefaultValue>\r
+ <HelpText>If this feature is enabled, then the DXE IPL must support decompressing files compressed with the Custom Compression algorithm</HelpText>\r
+ </PcdEntry>\r
+ </PcdCoded>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. 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
+ DxeLoad.c\r
+\r
+Abstract:\r
+\r
+ Last PEIM.\r
+ Responsibility of this module is to load the DXE Core from a Firmware Volume.\r
+\r
+--*/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "DxeIpl.h"\r
+\r
+// porting note remove later\r
+#include "Common/DecompressLibraryHob.h"\r
+#include "FrameworkPei.h"\r
+// end of remove later\r
+\r
+BOOLEAN gInMemory = FALSE;\r
+\r
+//\r
+// Module Globals used in the DXE to PEI handoff\r
+// These must be module globals, so the stack can be switched\r
+//\r
+static EFI_DXE_IPL_PPI mDxeIplPpi = {\r
+ DxeLoadCore\r
+};\r
+\r
+static EFI_PEI_FV_FILE_LOADER_PPI mLoadFilePpi = {\r
+ DxeIplLoadFile\r
+};\r
+\r
+static EFI_PEI_PPI_DESCRIPTOR mPpiList[] = {\r
+ {\r
+ EFI_PEI_PPI_DESCRIPTOR_PPI,\r
+ &gEfiPeiFvFileLoaderPpiGuid,\r
+ &mLoadFilePpi\r
+ },\r
+ {\r
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+ &gEfiDxeIplPpiGuid,\r
+ &mDxeIplPpi\r
+ }\r
+};\r
+\r
+static EFI_PEI_PPI_DESCRIPTOR mPpiSignal = {\r
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+ &gEfiEndOfPeiSignalPpiGuid,\r
+ NULL\r
+};\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED DECOMPRESS_LIBRARY gEfiDecompress = {\r
+ UefiDecompressGetInfo,\r
+ UefiDecompress\r
+};\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED DECOMPRESS_LIBRARY gCustomDecompress = {\r
+ CustomDecompressGetInfo,\r
+ CustomDecompress\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeimInitializeDxeIpl (\r
+ IN EFI_FFS_FILE_HEADER *FfsHeader,\r
+ IN EFI_PEI_SERVICES **PeiServices\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Initializes the Dxe Ipl PPI\r
+\r
+Arguments:\r
+\r
+ FfsHeader - Pointer to FFS file header\r
+ PeiServices - General purpose services available to every PEIM.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader;\r
+ EFI_BOOT_MODE BootMode;\r
+\r
+ Status = PeiServicesGetBootMode (&BootMode);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ if (!gInMemory && (BootMode != BOOT_ON_S3_RESUME)) { \r
+ //\r
+ // The DxeIpl has not yet been shadowed\r
+ //\r
+ PeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)GetPeCoffLoaderProtocol ();\r
+\r
+ //\r
+ // Shadow DxeIpl and then re-run its entry point\r
+ //\r
+ Status = ShadowDxeIpl (FfsHeader, PeiEfiPeiPeCoffLoader);\r
+ } else {\r
+ //\r
+ // Install FvFileLoader and DxeIpl PPIs.\r
+ //\r
+ Status = PeiServicesInstallPpi (mPpiList);\r
+ ASSERT_EFI_ERROR(Status);\r
+ }\r
+ \r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DxeLoadCore (\r
+ IN EFI_DXE_IPL_PPI *This,\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_PEI_HOB_POINTERS HobList\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Main entry point to last PEIM\r
+\r
+Arguments:\r
+ This - Entry point for DXE IPL PPI\r
+ PeiServices - General purpose services available to every PEIM.\r
+ HobList - Address to the Pei HOB list\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - DEX core was successfully loaded.\r
+ EFI_OUT_OF_RESOURCES - There are not enough resources to load DXE core.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_GUID DxeCoreFileName;\r
+ EFI_GUID FirmwareFileName;\r
+ VOID *Pe32Data;\r
+ VOID *FvImageData; \r
+ EFI_PHYSICAL_ADDRESS DxeCoreAddress;\r
+ UINT64 DxeCoreSize;\r
+ EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint;\r
+ EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader;\r
+ EFI_BOOT_MODE BootMode;\r
+ EFI_PEI_RECOVERY_MODULE_PPI *PeiRecovery;\r
+ EFI_PEI_S3_RESUME_PPI *S3Resume;\r
+\r
+// PERF_START (PeiServices, L"DxeIpl", NULL, 0);\r
+\r
+ //\r
+ // if in S3 Resume, restore configure\r
+ //\r
+ Status = PeiServicesGetBootMode (&BootMode);\r
+ ASSERT_EFI_ERROR(Status);\r
+\r
+ if (BootMode == BOOT_ON_S3_RESUME) {\r
+ Status = PeiServicesLocatePpi (\r
+ &gEfiPeiS3ResumePpiGuid,\r
+ 0,\r
+ NULL,\r
+ (VOID **)&S3Resume\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = S3Resume->S3RestoreConfig (PeiServices);\r
+ ASSERT_EFI_ERROR (Status);\r
+ } else if (BootMode == BOOT_IN_RECOVERY_MODE) {\r
+\r
+ Status = PeiServicesLocatePpi (\r
+ &gEfiPeiRecoveryModulePpiGuid,\r
+ 0,\r
+ NULL,\r
+ (VOID **)&PeiRecovery\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = PeiRecovery->LoadRecoveryCapsule (PeiServices, PeiRecovery);\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "Load Recovery Capsule Failed.(Status = %r)\n", Status));\r
+ CpuDeadLoop ();\r
+ }\r
+\r
+ //\r
+ // Now should have a HOB with the DXE core w/ the old HOB destroyed\r
+ //\r
+ }\r
+\r
+ //\r
+ // Install the PEI Protocols that are shared between PEI and DXE\r
+ //\r
+ PeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)GetPeCoffLoaderProtocol ();\r
+ ASSERT (PeiEfiPeiPeCoffLoader != NULL);\r
+\r
+\r
+ //\r
+ // Find the EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE type compressed Firmware Volume file\r
+ // The file found will be processed by PeiProcessFile: It will first be decompressed to\r
+ // a normal FV, then a corresponding FV type hob will be built. \r
+ //\r
+ Status = PeiFindFile (\r
+ EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE,\r
+ EFI_SECTION_FIRMWARE_VOLUME_IMAGE,\r
+ &FirmwareFileName,\r
+ &FvImageData\r
+ );\r
+\r
+ //\r
+ // Find the DXE Core in a Firmware Volume\r
+ //\r
+ Status = PeiFindFile (\r
+ EFI_FV_FILETYPE_DXE_CORE,\r
+ EFI_SECTION_PE32,\r
+ &DxeCoreFileName,\r
+ &Pe32Data\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ //\r
+ // Load the DXE Core from a Firmware Volume\r
+ //\r
+ Status = PeiLoadFile (\r
+ PeiEfiPeiPeCoffLoader,\r
+ Pe32Data,\r
+ &DxeCoreAddress,\r
+ &DxeCoreSize,\r
+ &DxeCoreEntryPoint\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ //\r
+ // Add HOB for the DXE Core\r
+ //\r
+ BuildModuleHob (\r
+ &DxeCoreFileName,\r
+ DxeCoreAddress,\r
+ DxeCoreSize,\r
+ DxeCoreEntryPoint\r
+ );\r
+\r
+ //\r
+ // Report Status Code EFI_SW_PEI_PC_HANDOFF_TO_NEXT\r
+ //\r
+ REPORT_STATUS_CODE (\r
+ EFI_PROGRESS_CODE,\r
+ EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_CORE_PC_HANDOFF_TO_NEXT\r
+ );\r
+\r
+ if (FeaturePcdGet (PcdDxeIplBuildShareCodeHobs)) {\r
+ if (FeaturePcdGet (PcdDxeIplSupportEfiDecompress)) {\r
+ //\r
+ // Add HOB for the EFI Decompress Protocol\r
+ //\r
+ BuildGuidDataHob (\r
+ &gEfiDecompressProtocolGuid,\r
+ (VOID *)&gEfiDecompress,\r
+ sizeof (gEfiDecompress)\r
+ );\r
+ }\r
+ if (FeaturePcdGet (PcdDxeIplSupportCustomDecompress)) {\r
+ //\r
+ // Add HOB for the user customized Decompress Protocol\r
+ //\r
+ BuildGuidDataHob (\r
+ &gEfiCustomizedDecompressProtocolGuid,\r
+ (VOID *)&gCustomDecompress,\r
+ sizeof (gCustomDecompress)\r
+ );\r
+ }\r
+\r
+ //\r
+ // Add HOB for the PE/COFF Loader Protocol\r
+ //\r
+ BuildGuidDataHob (\r
+ &gEfiPeiPeCoffLoaderGuid,\r
+ (VOID *)&PeiEfiPeiPeCoffLoader,\r
+ sizeof (VOID *)\r
+ );\r
+ }\r
+\r
+ //\r
+ // Transfer control to the DXE Core\r
+ // The handoff state is simply a pointer to the HOB list\r
+ //\r
+\r
+ DEBUG ((EFI_D_INFO, "DXE Core Entry Point 0x%08x\n", (UINTN) DxeCoreEntryPoint));\r
+ HandOffToDxeCore (DxeCoreEntryPoint, HobList, &mPpiSignal);\r
+ //\r
+ // If we get here, then the DXE Core returned. This is an error\r
+ // Dxe Core should not return.\r
+ //\r
+ ASSERT (FALSE);\r
+ CpuDeadLoop ();\r
+\r
+ return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+EFI_STATUS\r
+PeiFindFile (\r
+ IN UINT8 Type,\r
+ IN UINT16 SectionType,\r
+ OUT EFI_GUID *FileName,\r
+ OUT VOID **Pe32Data\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Finds a PE/COFF of a specific Type and SectionType in the Firmware Volumes\r
+ described in the HOB list. Able to search in a compression set in a FFS file.\r
+ But only one level of compression is supported, that is, not able to search\r
+ in a compression set that is within another compression set.\r
+\r
+Arguments:\r
+\r
+ Type - The Type of file to retrieve\r
+\r
+ SectionType - The type of section to retrieve from a file\r
+\r
+ FileName - The name of the file found in the Firmware Volume\r
+\r
+ Pe32Data - Pointer to the beginning of the PE/COFF file found in the Firmware Volume\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The file was found, and the name is returned in FileName, and a pointer to\r
+ the PE/COFF image is returned in Pe32Data\r
+\r
+ EFI_NOT_FOUND - The file was not found in the Firmware Volumes present in the HOB List\r
+\r
+--*/\r
+{\r
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;\r
+ EFI_FFS_FILE_HEADER *FfsFileHeader;\r
+ EFI_STATUS Status;\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+\r
+\r
+ FwVolHeader = NULL;\r
+ FfsFileHeader = NULL;\r
+ Status = EFI_SUCCESS;\r
+\r
+ //\r
+ // For each Firmware Volume, look for a specified type\r
+ // of file and break out until no one is found \r
+ //\r
+ Hob.Raw = GetHobList ();\r
+ while ((Hob.Raw = GetNextHob (EFI_HOB_TYPE_FV, Hob.Raw)) != NULL) {\r
+ FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) (Hob.FirmwareVolume->BaseAddress);\r
+ //\r
+ // Make sure the FV HOB does not get corrupted.\r
+ //\r
+ ASSERT (FwVolHeader->Signature == EFI_FVH_SIGNATURE);\r
+\r
+ Status = PeiServicesFfsFindNextFile (\r
+ Type,\r
+ FwVolHeader,\r
+ &FfsFileHeader\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = PeiProcessFile (\r
+ SectionType,\r
+ FfsFileHeader,\r
+ Pe32Data,\r
+ &Hob\r
+ );\r
+ CopyMem (FileName, &FfsFileHeader->Name, sizeof (EFI_GUID));\r
+ //\r
+ // Find all Fv type ffs to get all FvImage and add them into FvHob\r
+ //\r
+ if (!EFI_ERROR (Status) && (Type != EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE)) {\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+ Hob.Raw = GET_NEXT_HOB (Hob);\r
+ }\r
+ return EFI_NOT_FOUND;\r
+}\r
+\r
+EFI_STATUS\r
+PeiLoadFile (\r
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader,\r
+ IN VOID *Pe32Data,\r
+ OUT EFI_PHYSICAL_ADDRESS *ImageAddress,\r
+ OUT UINT64 *ImageSize,\r
+ OUT EFI_PHYSICAL_ADDRESS *EntryPoint\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Loads and relocates a PE/COFF image into memory.\r
+\r
+Arguments:\r
+\r
+ PeiEfiPeiPeCoffLoader - Pointer to a PE COFF loader protocol\r
+\r
+ Pe32Data - The base address of the PE/COFF file that is to be loaded and relocated\r
+\r
+ ImageAddress - The base address of the relocated PE/COFF image\r
+\r
+ ImageSize - The size of the relocated PE/COFF image\r
+\r
+ EntryPoint - The entry point of the relocated PE/COFF image\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The file was loaded and relocated\r
+\r
+ EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;\r
+\r
+ ZeroMem (&ImageContext, sizeof (ImageContext));\r
+ ImageContext.Handle = Pe32Data;\r
+ Status = GetImageReadFunction (&ImageContext);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = PeiEfiPeiPeCoffLoader->GetImageInfo (PeiEfiPeiPeCoffLoader, &ImageContext);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Allocate Memory for the image\r
+ //\r
+ ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) AllocatePages (EFI_SIZE_TO_PAGES ((UINT32) ImageContext.ImageSize));\r
+ ASSERT (ImageContext.ImageAddress != 0);\r
+\r
+ //\r
+ // Load the image to our new buffer\r
+ //\r
+ Status = PeiEfiPeiPeCoffLoader->LoadImage (PeiEfiPeiPeCoffLoader, &ImageContext);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Relocate the image in our new buffer\r
+ //\r
+ Status = PeiEfiPeiPeCoffLoader->RelocateImage (PeiEfiPeiPeCoffLoader, &ImageContext);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Flush the instruction cache so the image data is written before we execute it\r
+ //\r
+ InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize);\r
+\r
+ *ImageAddress = ImageContext.ImageAddress;\r
+ *ImageSize = ImageContext.ImageSize;\r
+ *EntryPoint = ImageContext.EntryPoint;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+ShadowDxeIpl (\r
+ IN EFI_FFS_FILE_HEADER *DxeIplFileHeader,\r
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Shadow the DXE IPL to a different memory location. This occurs after permanent\r
+ memory has been discovered.\r
+\r
+Arguments:\r
+\r
+ DxeIplFileHeader - Pointer to the FFS file header of the DXE IPL driver\r
+\r
+ PeiEfiPeiPeCoffLoader - Pointer to a PE COFF loader protocol\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - DXE IPL was successfully shadowed to a different memory location.\r
+\r
+ EFI_ ERROR - The shadow was unsuccessful.\r
+\r
+\r
+--*/\r
+{\r
+ UINTN SectionLength;\r
+ UINTN OccupiedSectionLength;\r
+ EFI_PHYSICAL_ADDRESS DxeIplAddress;\r
+ UINT64 DxeIplSize;\r
+ EFI_PHYSICAL_ADDRESS DxeIplEntryPoint;\r
+ EFI_STATUS Status;\r
+ EFI_COMMON_SECTION_HEADER *Section;\r
+\r
+ Section = (EFI_COMMON_SECTION_HEADER *) (DxeIplFileHeader + 1);\r
+\r
+ while ((Section->Type != EFI_SECTION_PE32) && (Section->Type != EFI_SECTION_TE)) {\r
+ SectionLength = *(UINT32 *) (Section->Size) & 0x00ffffff;\r
+ OccupiedSectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);\r
+ Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + OccupiedSectionLength);\r
+ }\r
+ //\r
+ // Relocate DxeIpl into memory by using loadfile service\r
+ //\r
+ Status = PeiLoadFile (\r
+ PeiEfiPeiPeCoffLoader,\r
+ (VOID *) (Section + 1),\r
+ &DxeIplAddress,\r
+ &DxeIplSize,\r
+ &DxeIplEntryPoint\r
+ );\r
+\r
+ if (Status == EFI_SUCCESS) {\r
+ //\r
+ // Set gInMemory global variable to TRUE to indicate the dxeipl is shadowed.\r
+ //\r
+ *(BOOLEAN *) ((UINTN) &gInMemory + (UINTN) DxeIplEntryPoint - (UINTN) _ModuleEntryPoint) = TRUE;\r
+ Status = ((EFI_PEIM_ENTRY_POINT) (UINTN) DxeIplEntryPoint) ((EFI_PEI_FILE_HANDLE *) DxeIplFileHeader, GetPeiServicesTablePointer());\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DxeIplLoadFile (\r
+ IN EFI_PEI_FV_FILE_LOADER_PPI *This,\r
+ IN EFI_FFS_FILE_HEADER *FfsHeader,\r
+ OUT EFI_PHYSICAL_ADDRESS *ImageAddress,\r
+ OUT UINT64 *ImageSize,\r
+ OUT EFI_PHYSICAL_ADDRESS *EntryPoint\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Given a pointer to an FFS file containing a PE32 image, get the\r
+ information on the PE32 image, and then "load" it so that it\r
+ can be executed.\r
+\r
+Arguments:\r
+\r
+ This - pointer to our file loader protocol\r
+\r
+ FfsHeader - pointer to the FFS file header of the FFS file that\r
+ contains the PE32 image we want to load\r
+\r
+ ImageAddress - returned address where the PE32 image is loaded\r
+\r
+ ImageSize - returned size of the loaded PE32 image\r
+\r
+ EntryPoint - entry point to the loaded PE32 image\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The FFS file was successfully loaded.\r
+\r
+ EFI_ERROR - Unable to load the FFS file.\r
+\r
+--*/\r
+{\r
+ EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader;\r
+ EFI_STATUS Status;\r
+ VOID *Pe32Data;\r
+\r
+ Pe32Data = NULL;\r
+ PeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)GetPeCoffLoaderProtocol ();\r
+\r
+ //\r
+ // Preprocess the FFS file to get a pointer to the PE32 information\r
+ // in the enclosed PE32 image.\r
+ //\r
+ Status = PeiProcessFile (\r
+ EFI_SECTION_PE32,\r
+ FfsHeader,\r
+ &Pe32Data,\r
+ NULL\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Load the PE image from the FFS file\r
+ //\r
+ Status = PeiLoadFile (\r
+ PeiEfiPeiPeCoffLoader,\r
+ Pe32Data,\r
+ ImageAddress,\r
+ ImageSize,\r
+ EntryPoint\r
+ );\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+PeiProcessFile (\r
+ IN UINT16 SectionType,\r
+ IN EFI_FFS_FILE_HEADER *FfsFileHeader,\r
+ OUT VOID **Pe32Data,\r
+ IN EFI_PEI_HOB_POINTERS *OrigHob\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+ SectionType - The type of section in the FFS file to process.\r
+\r
+ FfsFileHeader - Pointer to the FFS file to process, looking for the\r
+ specified SectionType\r
+\r
+ Pe32Data - returned pointer to the start of the PE32 image found\r
+ in the FFS file.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - found the PE32 section in the FFS file\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ VOID *SectionData;\r
+ DECOMPRESS_LIBRARY *DecompressLibrary;\r
+ UINT8 *DstBuffer;\r
+ UINT8 *ScratchBuffer;\r
+ UINT32 DstBufferSize;\r
+ UINT32 ScratchBufferSize;\r
+ EFI_COMMON_SECTION_HEADER *CmpSection;\r
+ UINTN CmpSectionLength;\r
+ UINTN OccupiedCmpSectionLength;\r
+ VOID *CmpFileData;\r
+ UINTN CmpFileSize;\r
+ EFI_COMMON_SECTION_HEADER *Section;\r
+ UINTN SectionLength;\r
+ UINTN OccupiedSectionLength;\r
+ UINT64 FileSize;\r
+ UINT32 AuthenticationStatus;\r
+ EFI_PEI_SECTION_EXTRACTION_PPI *SectionExtract;\r
+ UINT32 BufferSize;\r
+ UINT8 *Buffer;\r
+ EFI_PEI_SECURITY_PPI *Security;\r
+ BOOLEAN StartCrisisRecovery;\r
+ EFI_GUID TempGuid;\r
+ EFI_FIRMWARE_VOLUME_HEADER *FvHeader;\r
+ EFI_COMPRESSION_SECTION *CompressionSection;\r
+\r
+ //\r
+ // Initialize local variables.\r
+ //\r
+ DecompressLibrary = NULL;\r
+ DstBuffer = NULL;\r
+ DstBufferSize = 0;\r
+\r
+ Status = PeiServicesFfsFindSectionData (\r
+ EFI_SECTION_COMPRESSION,\r
+ FfsFileHeader,\r
+ &SectionData\r
+ );\r
+\r
+ //\r
+ // First process the compression section\r
+ //\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Yes, there is a compression section, so extract the contents\r
+ // Decompress the image here\r
+ //\r
+ Section = (EFI_COMMON_SECTION_HEADER *) (UINTN) (VOID *) ((UINT8 *) (FfsFileHeader) + (UINTN) sizeof (EFI_FFS_FILE_HEADER));\r
+\r
+ do {\r
+ SectionLength = *(UINT32 *) (Section->Size) & 0x00ffffff;\r
+ OccupiedSectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);\r
+\r
+ //\r
+ // Was the DXE Core file encapsulated in a GUID'd section?\r
+ //\r
+ if (Section->Type == EFI_SECTION_GUID_DEFINED) {\r
+\r
+ //\r
+ // This following code constitutes the addition of the security model\r
+ // to the DXE IPL.\r
+ //\r
+ //\r
+ // Set a default authenticatino state\r
+ //\r
+ AuthenticationStatus = 0;\r
+\r
+ Status = PeiServicesLocatePpi (\r
+ &gEfiPeiSectionExtractionPpiGuid,\r
+ 0,\r
+ NULL,\r
+ (VOID **)&SectionExtract\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Verify Authentication State\r
+ //\r
+ CopyMem (&TempGuid, Section + 1, sizeof (EFI_GUID));\r
+\r
+ Status = SectionExtract->PeiGetSection (\r
+ GetPeiServicesTablePointer(),\r
+ SectionExtract,\r
+ (EFI_SECTION_TYPE *) &SectionType,\r
+ &TempGuid,\r
+ 0,\r
+ (VOID **) &Buffer,\r
+ &BufferSize,\r
+ &AuthenticationStatus\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // If not ask the Security PPI, if exists, for disposition\r
+ //\r
+ //\r
+ Status = PeiServicesLocatePpi (\r
+ &gEfiPeiSecurityPpiGuid,\r
+ 0,\r
+ NULL,\r
+ (VOID **)&Security\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ Status = Security->AuthenticationState (\r
+ GetPeiServicesTablePointer(),\r
+ (struct _EFI_PEI_SECURITY_PPI *) Security,\r
+ AuthenticationStatus,\r
+ FfsFileHeader,\r
+ &StartCrisisRecovery\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // If there is a security violation, report to caller and have\r
+ // the upper-level logic possible engender a crisis recovery\r
+ //\r
+ if (StartCrisisRecovery) {\r
+ return EFI_SECURITY_VIOLATION;\r
+ }\r
+ }\r
+\r
+ if (Section->Type == EFI_SECTION_PE32) {\r
+ //\r
+ // This is what we want\r
+ //\r
+ *Pe32Data = (VOID *) (Section + 1);\r
+ return EFI_SUCCESS;\r
+ } else if (Section->Type == EFI_SECTION_COMPRESSION) {\r
+ //\r
+ // This is a compression set, expand it\r
+ //\r
+ CompressionSection = (EFI_COMPRESSION_SECTION *) Section;\r
+\r
+ switch (CompressionSection->CompressionType) {\r
+ case EFI_STANDARD_COMPRESSION:\r
+ //\r
+ // Load EFI standard compression.\r
+ //\r
+ if (FeaturePcdGet (PcdDxeIplSupportTianoDecompress)) {\r
+ DecompressLibrary = &gEfiDecompress;\r
+ } else {\r
+ ASSERT (FALSE);\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ break;\r
+\r
+ // porting note the original branch for customized compress is removed, it should be change to use GUID compress\r
+\r
+ case EFI_NOT_COMPRESSED:\r
+ //\r
+ // Allocate destination buffer\r
+ //\r
+ DstBufferSize = CompressionSection->UncompressedLength;\r
+ DstBuffer = AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize));\r
+ if (DstBuffer == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ //\r
+ // stream is not actually compressed, just encapsulated. So just copy it.\r
+ //\r
+ CopyMem (DstBuffer, CompressionSection + 1, DstBufferSize);\r
+ break;\r
+\r
+ default:\r
+ //\r
+ // Don't support other unknown compression type.\r
+ //\r
+ ASSERT_EFI_ERROR (Status);\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ \r
+ if (CompressionSection->CompressionType != EFI_NOT_COMPRESSED) {\r
+ //\r
+ // For compressed data, decompress them to dstbuffer.\r
+ //\r
+ Status = DecompressLibrary->GetInfo (\r
+ (UINT8 *) ((EFI_COMPRESSION_SECTION *) Section + 1),\r
+ (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION),\r
+ &DstBufferSize,\r
+ &ScratchBufferSize\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // GetInfo failed\r
+ //\r
+ DEBUG ((EFI_D_ERROR, "Decompress GetInfo Failed - %r\n", Status));\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ \r
+ //\r
+ // Allocate scratch buffer\r
+ //\r
+ ScratchBuffer = AllocatePages (EFI_SIZE_TO_PAGES (ScratchBufferSize));\r
+ if (ScratchBuffer == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ \r
+ //\r
+ // Allocate destination buffer\r
+ //\r
+ DstBuffer = AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize));\r
+ if (DstBuffer == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ \r
+ //\r
+ // Call decompress function\r
+ //\r
+ Status = DecompressLibrary->Decompress (\r
+ (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1),\r
+ DstBuffer,\r
+ ScratchBuffer\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // Decompress failed\r
+ //\r
+ DEBUG ((EFI_D_ERROR, "Decompress Failed - %r\n", Status));\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Decompress successfully.\r
+ // Loop the decompressed data searching for expected section.\r
+ //\r
+ CmpSection = (EFI_COMMON_SECTION_HEADER *) DstBuffer;\r
+ CmpFileData = (VOID *) DstBuffer;\r
+ CmpFileSize = DstBufferSize;\r
+ do {\r
+ CmpSectionLength = *(UINT32 *) (CmpSection->Size) & 0x00ffffff;\r
+ if (CmpSection->Type == SectionType) {\r
+ //\r
+ // This is what we want\r
+ //\r
+ if (SectionType == EFI_SECTION_PE32) {\r
+ *Pe32Data = (VOID *) (CmpSection + 1);\r
+ return EFI_SUCCESS;\r
+ } else if (SectionType == EFI_SECTION_FIRMWARE_VOLUME_IMAGE) {\r
+ // \r
+ // Firmware Volume Image in this Section\r
+ // Skip the section header to get FvHeader\r
+ //\r
+ FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (CmpSection + 1);\r
+ \r
+ if (FvHeader->Signature == EFI_FVH_SIGNATURE) {\r
+ //\r
+ // Because FvLength in FvHeader is UINT64 type, \r
+ // so FvHeader must meed at least 8 bytes alignment.\r
+ // If current FvImage base address doesn't meet its alignment,\r
+ // we need to reload this FvImage to another correct memory address.\r
+ //\r
+ if (((UINTN) FvHeader % sizeof (UINT64)) != 0) {\r
+ DstBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINTN) CmpSectionLength - sizeof (EFI_COMMON_SECTION_HEADER)), sizeof (UINT64));\r
+ if (DstBuffer == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ CopyMem (DstBuffer, FvHeader, (UINTN) CmpSectionLength - sizeof (EFI_COMMON_SECTION_HEADER));\r
+ FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) DstBuffer; \r
+ }\r
+\r
+ //\r
+ // Build new FvHob for new decompressed Fv image.\r
+ //\r
+ BuildFvHob ((EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader, FvHeader->FvLength);\r
+ \r
+ //\r
+ // Set the original FvHob to unused.\r
+ //\r
+ if (OrigHob != NULL) {\r
+ OrigHob->Header->HobType = EFI_HOB_TYPE_UNUSED;\r
+ }\r
+ \r
+ //\r
+ // return found FvImage data.\r
+ //\r
+ *Pe32Data = (VOID *) FvHeader;\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+ }\r
+ OccupiedCmpSectionLength = GET_OCCUPIED_SIZE (CmpSectionLength, 4);\r
+ CmpSection = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) CmpSection + OccupiedCmpSectionLength);\r
+ } while (CmpSection->Type != 0 && (UINTN) ((UINT8 *) CmpSection - (UINT8 *) CmpFileData) < CmpFileSize);\r
+ }\r
+ //\r
+ // End of the decompression activity\r
+ //\r
+\r
+ Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + OccupiedSectionLength);\r
+ FileSize = FfsFileHeader->Size[0] & 0xFF;\r
+ FileSize += (FfsFileHeader->Size[1] << 8) & 0xFF00;\r
+ FileSize += (FfsFileHeader->Size[2] << 16) & 0xFF0000;\r
+ FileSize &= 0x00FFFFFF;\r
+ } while (Section->Type != 0 && (UINTN) ((UINT8 *) Section - (UINT8 *) FfsFileHeader) < FileSize);\r
+ \r
+ //\r
+ // search all sections (compression and non compression) in this FFS, don't \r
+ // find expected section.\r
+ //\r
+ return EFI_NOT_FOUND;\r
+ } else {\r
+ //\r
+ // For those FFS that doesn't contain compression section, directly search \r
+ // PE or TE section in this FFS.\r
+ //\r
+\r
+ Status = PeiServicesFfsFindSectionData (\r
+ EFI_SECTION_PE32,\r
+ FfsFileHeader,\r
+ &SectionData\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ Status = PeiServicesFfsFindSectionData (\r
+ EFI_SECTION_TE,\r
+ FfsFileHeader,\r
+ &SectionData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ }\r
+ }\r
+\r
+ *Pe32Data = SectionData;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. 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
+ DxeLoadFunc.c\r
+\r
+Abstract:\r
+\r
+ Ia32-specifc functionality for DxeLoad.\r
+\r
+--*/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "DxeIpl.h"\r
+#include "VirtualMemory.h"\r
+\r
+//\r
+// Global Descriptor Table (GDT)\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED IA32_GDT gGdtEntries [] = {\r
+/* selector { Global Segment Descriptor } */ \r
+/* 0x00 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, //null descriptor \r
+/* 0x08 */ {{0xffff, 0, 0, 0x2, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //linear data segment descriptor\r
+/* 0x10 */ {{0xffff, 0, 0, 0xf, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //linear code segment descriptor\r
+/* 0x18 */ {{0xffff, 0, 0, 0x3, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //system data segment descriptor\r
+/* 0x20 */ {{0xffff, 0, 0, 0xa, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //system code segment descriptor\r
+/* 0x28 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, //spare segment descriptor\r
+/* 0x30 */ {{0xffff, 0, 0, 0x2, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //system data segment descriptor\r
+/* 0x38 */ {{0xffff, 0, 0, 0xa, 1, 0, 1, 0xf, 0, 1, 0, 1, 0}}, //system code segment descriptor\r
+/* 0x40 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, //spare segment descriptor\r
+};\r
+\r
+//\r
+// IA32 Gdt register\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED CONST IA32_DESCRIPTOR gGdt = {\r
+ sizeof (gGdtEntries) - 1,\r
+ (UINTN) gGdtEntries\r
+ };\r
+\r
+VOID\r
+HandOffToDxeCore (\r
+ IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,\r
+ IN EFI_PEI_HOB_POINTERS HobList,\r
+ IN EFI_PEI_PPI_DESCRIPTOR *EndOfPeiSignal\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PHYSICAL_ADDRESS BaseOfStack;\r
+ EFI_PHYSICAL_ADDRESS TopOfStack;\r
+ UINTN PageTables;\r
+\r
+ Status = PeiServicesAllocatePages (EfiBootServicesData, EFI_SIZE_TO_PAGES (STACK_SIZE), &BaseOfStack);\r
+ ASSERT_EFI_ERROR (Status);\r
+ \r
+ if (FeaturePcdGet(PcdDxeIplSwitchToLongMode)) {\r
+ //\r
+ // Compute the top of the stack we were allocated, which is used to load X64 dxe core. \r
+ // Pre-allocate a 32 bytes which confroms to x64 calling convention.\r
+ //\r
+ // The first four parameters to a function are passed in rcx, rdx, r8 and r9. \r
+ // Any further parameters are pushed on the stack. Furthermore, space (4 * 8bytes) for the \r
+ // register parameters is reserved on the stack, in case the called function \r
+ // wants to spill them; this is important if the function is variadic. \r
+ //\r
+ TopOfStack = BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - 32;\r
+\r
+ //\r
+ // X64 Calling Conventions requires that the stack must be aligned to 16 bytes\r
+ //\r
+ TopOfStack = (EFI_PHYSICAL_ADDRESS) (UINTN) ALIGN_POINTER (TopOfStack, 16);\r
+\r
+ //\r
+ // Load the GDT of Go64. Since the GDT of 32-bit Tiano locates in the BS_DATA\r
+ // memory, it may be corrupted when copying FV to high-end memory \r
+ //\r
+ AsmWriteGdtr (&gGdt);\r
+ //\r
+ // Create page table and save PageMapLevel4 to CR3\r
+ //\r
+ PageTables = CreateIdentityMappingPageTables ();\r
+\r
+ //\r
+ // End of PEI phase singal\r
+ //\r
+ Status = PeiServicesInstallPpi (EndOfPeiSignal);\r
+ ASSERT_EFI_ERROR (Status);\r
+ \r
+ AsmWriteCr3 (PageTables);\r
+ //\r
+ // Go to Long Mode. Interrupts will not get turned on until the CPU AP is loaded.\r
+ // Call x64 drivers passing in single argument, a pointer to the HOBs.\r
+ // \r
+ AsmEnablePaging64 (\r
+ SYS_CODE64_SEL,\r
+ DxeCoreEntryPoint,\r
+ (EFI_PHYSICAL_ADDRESS)(UINTN)(HobList.Raw),\r
+ 0,\r
+ TopOfStack\r
+ );\r
+ } else {\r
+ //\r
+ // Compute the top of the stack we were allocated. Pre-allocate a UINTN\r
+ // for safety.\r
+ //\r
+ TopOfStack = BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT;\r
+ TopOfStack = (EFI_PHYSICAL_ADDRESS) (UINTN) ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);\r
+\r
+ //\r
+ // End of PEI phase singal\r
+ //\r
+ Status = PeiServicesInstallPpi (EndOfPeiSignal);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ SwitchStack (\r
+ (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,\r
+ HobList.Raw,\r
+ NULL,\r
+ (VOID *) (UINTN) TopOfStack\r
+ );\r
+ } \r
+}\r
+\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ ImageRead.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "DxeIpl.h"\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiImageRead (\r
+ IN VOID *FileHandle,\r
+ IN UINTN FileOffset,\r
+ IN OUT UINTN *ReadSize,\r
+ OUT VOID *Buffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file\r
+\r
+Arguments:\r
+\r
+ FileHandle - The handle to the PE/COFF file\r
+\r
+ FileOffset - The offset, in bytes, into the file to read\r
+\r
+ ReadSize - The number of bytes to read from the file starting at FileOffset\r
+\r
+ Buffer - A pointer to the buffer to read the data into.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset\r
+\r
+--*/\r
+{\r
+ UINT8 *Destination32;\r
+ UINT8 *Source32;\r
+ UINTN Length;\r
+\r
+ \r
+ Destination32 = Buffer;\r
+ Source32 = (UINT8 *) ((UINTN) FileHandle + FileOffset);\r
+\r
+ //\r
+ // This function assumes 32-bit alignment to increase performance\r
+ //\r
+// ASSERT (ALIGN_POINTER (Destination32, sizeof (UINT32)) == Destination32);\r
+// ASSERT (ALIGN_POINTER (Source32, sizeof (UINT32)) == Source32);\r
+\r
+ Length = *ReadSize;\r
+ while (Length--) {\r
+ *(Destination32++) = *(Source32++);\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetImageReadFunction (\r
+ IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Support routine to return the PE32 Image Reader.\r
+ If the PeiImageRead() function is less than a page\r
+ in legnth. If the function is more than a page the DXE IPL will crash!!!!\r
+\r
+Arguments:\r
+ ImageContext - The context of the image being loaded\r
+\r
+Returns:\r
+ EFI_SUCCESS - If Image function location is found\r
+\r
+--*/\r
+{\r
+ VOID *MemoryBuffer;\r
+\r
+ if (gInMemory) {\r
+ ImageContext->ImageRead = PeiImageRead;\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ //\r
+ // BugBug; This code assumes PeiImageRead() is less than a page in size!\r
+ // Allocate a page so we can shaddow the read function from FLASH into \r
+ // memory to increase performance. \r
+ //\r
+ \r
+ MemoryBuffer = AllocateCopyPool (0x400, (VOID *)(UINTN) PeiImageRead);\r
+ ASSERT (MemoryBuffer != NULL);\r
+\r
+ ImageContext->ImageRead = (PE_COFF_LOADER_READ_FILE) (UINTN) MemoryBuffer;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ VirtualMemory.c\r
+ \r
+Abstract:\r
+\r
+ x64 Virtual Memory Management Services in the form of an IA-32 driver. \r
+ Used to establish a 1:1 Virtual to Physical Mapping that is required to\r
+ enter Long Mode (x64 64-bit mode).\r
+\r
+ While we make a 1:1 mapping (identity mapping) for all physical pages \r
+ we still need to use the MTRR's to ensure that the cachability attirbutes\r
+ for all memory regions is correct.\r
+\r
+ The basic idea is to use 2MB page table entries where ever possible. If\r
+ more granularity of cachability is required then 4K page tables are used.\r
+\r
+ References:\r
+ 1) IA-32 Intel(R) Atchitecture Software Developer's Manual Volume 1:Basic Architecture, Intel\r
+ 2) IA-32 Intel(R) Atchitecture Software Developer's Manual Volume 2:Instruction Set Reference, Intel\r
+ 3) IA-32 Intel(R) Atchitecture Software Developer's Manual Volume 3:System Programmer's Guide, Intel\r
+ \r
+--*/ \r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "VirtualMemory.h"\r
+\r
+UINTN\r
+CreateIdentityMappingPageTables (\r
+ VOID\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Allocates and fills in the Page Directory and Page Table Entries to\r
+ establish a 1:1 Virtual to Physical mapping.\r
+\r
+Arguments:\r
+\r
+ NumberOfProcessorPhysicalAddressBits - Number of processor address bits to use.\r
+ Limits the number of page table entries \r
+ to the physical address space.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS The 1:1 Virtual to Physical identity mapping was created\r
+\r
+--*/\r
+{ \r
+ UINT8 PhysicalAddressBits;\r
+ EFI_PHYSICAL_ADDRESS PageAddress;\r
+ UINTN IndexOfPml4Entries;\r
+ UINTN IndexOfPdpEntries;\r
+ UINTN IndexOfPageDirectoryEntries;\r
+ UINTN NumberOfPml4EntriesNeeded;\r
+ UINTN NumberOfPdpEntriesNeeded;\r
+ PAGE_MAP_AND_DIRECTORY_POINTER *PageMapLevel4Entry;\r
+ PAGE_MAP_AND_DIRECTORY_POINTER *PageMap;\r
+ PAGE_MAP_AND_DIRECTORY_POINTER *PageDirectoryPointerEntry;\r
+ PAGE_TABLE_ENTRY *PageDirectoryEntry;\r
+ UINTN TotalPagesNum;\r
+ UINTN BigPageAddress;\r
+ VOID *Hob;\r
+\r
+ //\r
+ // Get physical address bits supported from CPU HOB.\r
+ //\r
+ PhysicalAddressBits = 36;\r
+ \r
+ Hob = GetFirstHob (EFI_HOB_TYPE_CPU);\r
+ if (Hob != NULL) {\r
+ PhysicalAddressBits = ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace; \r
+ }\r
+\r
+ //\r
+ // Calculate the table entries needed.\r
+ //\r
+ if (PhysicalAddressBits <= 39 ) {\r
+ NumberOfPml4EntriesNeeded = 1;\r
+ NumberOfPdpEntriesNeeded = 1 << (PhysicalAddressBits - 30);\r
+ } else {\r
+ NumberOfPml4EntriesNeeded = 1 << (PhysicalAddressBits - 39);\r
+ NumberOfPdpEntriesNeeded = 512;\r
+ }\r
+\r
+ //\r
+ // Pre-allocate big pages to avoid later allocations. \r
+ //\r
+ TotalPagesNum = (NumberOfPdpEntriesNeeded + 1) * NumberOfPml4EntriesNeeded + 1;\r
+ BigPageAddress = (UINTN) AllocatePages (TotalPagesNum);\r
+ ASSERT (BigPageAddress != 0);\r
+\r
+ //\r
+ // By architecture only one PageMapLevel4 exists - so lets allocate storage for it.\r
+ //\r
+ PageMap = (VOID *) BigPageAddress;\r
+ BigPageAddress += EFI_PAGE_SIZE;\r
+\r
+ PageMapLevel4Entry = PageMap;\r
+ PageAddress = 0;\r
+ for (IndexOfPml4Entries = 0; IndexOfPml4Entries < NumberOfPml4EntriesNeeded; IndexOfPml4Entries++, PageMapLevel4Entry++) {\r
+ //\r
+ // Each PML4 entry points to a page of Page Directory Pointer entires.\r
+ // So lets allocate space for them and fill them in in the IndexOfPdpEntries loop.\r
+ //\r
+ PageDirectoryPointerEntry = (VOID *) BigPageAddress;\r
+ BigPageAddress += EFI_PAGE_SIZE;\r
+\r
+ //\r
+ // Make a PML4 Entry\r
+ //\r
+ PageMapLevel4Entry->Uint64 = (UINT64)(UINTN)PageDirectoryPointerEntry;\r
+ PageMapLevel4Entry->Bits.ReadWrite = 1;\r
+ PageMapLevel4Entry->Bits.Present = 1;\r
+\r
+ for (IndexOfPdpEntries = 0; IndexOfPdpEntries < NumberOfPdpEntriesNeeded; IndexOfPdpEntries++, PageDirectoryPointerEntry++) {\r
+ //\r
+ // Each Directory Pointer entries points to a page of Page Directory entires.\r
+ // So allocate space for them and fill them in in the IndexOfPageDirectoryEntries loop.\r
+ // \r
+ PageDirectoryEntry = (VOID *) BigPageAddress;\r
+ BigPageAddress += EFI_PAGE_SIZE;\r
+\r
+ //\r
+ // Fill in a Page Directory Pointer Entries\r
+ //\r
+ PageDirectoryPointerEntry->Uint64 = (UINT64)(UINTN)PageDirectoryEntry;\r
+ PageDirectoryPointerEntry->Bits.ReadWrite = 1;\r
+ PageDirectoryPointerEntry->Bits.Present = 1;\r
+\r
+ for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PageAddress += 0x200000) {\r
+ //\r
+ // Fill in the Page Directory entries\r
+ //\r
+ PageDirectoryEntry->Uint64 = (UINT64)PageAddress;\r
+ PageDirectoryEntry->Bits.ReadWrite = 1;\r
+ PageDirectoryEntry->Bits.Present = 1;\r
+ PageDirectoryEntry->Bits.MustBe1 = 1;\r
+\r
+ }\r
+ }\r
+ }\r
+\r
+ //\r
+ // For the PML4 entries we are not using fill in a null entry.\r
+ // For now we just copy the first entry.\r
+ //\r
+ for (; IndexOfPml4Entries < 512; IndexOfPml4Entries++, PageMapLevel4Entry++) {\r
+ CopyMem (\r
+ PageMapLevel4Entry,\r
+ PageMap,\r
+ sizeof (PAGE_MAP_AND_DIRECTORY_POINTER)\r
+ );\r
+ }\r
+\r
+ return (UINTN)PageMap; // FIXME\r
+}\r
+\r
--- /dev/null
+/*++ \r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ VirtualMemory.h\r
+ \r
+Abstract:\r
+\r
+ x64 Long Mode Virtual Memory Management Definitions \r
+\r
+ References:\r
+ 1) IA-32 Intel(R) Atchitecture Software Developer's Manual Volume 1:Basic Architecture, Intel\r
+ 2) IA-32 Intel(R) Atchitecture Software Developer's Manual Volume 2:Instruction Set Reference, Intel\r
+ 3) IA-32 Intel(R) Atchitecture Software Developer's Manual Volume 3:System Programmer's Guide, Intel\r
+ 4) AMD64 Architecture Programmer's Manual Volume 2: System Programming\r
+--*/ \r
+#ifndef _VIRTUAL_MEMORY_H_\r
+#define _VIRTUAL_MEMORY_H_\r
+\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#define SYS_CODE64_SEL 0x38\r
+\r
+#pragma pack(1)\r
+\r
+typedef union {\r
+ struct {\r
+ UINT32 LimitLow : 16;\r
+ UINT32 BaseLow : 16;\r
+ UINT32 BaseMid : 8;\r
+ UINT32 Type : 4;\r
+ UINT32 System : 1;\r
+ UINT32 Dpl : 2;\r
+ UINT32 Present : 1;\r
+ UINT32 LimitHigh : 4;\r
+ UINT32 Software : 1;\r
+ UINT32 Reserved : 1;\r
+ UINT32 DefaultSize : 1;\r
+ UINT32 Granularity : 1;\r
+ UINT32 BaseHigh : 8;\r
+ } Bits;\r
+ UINT64 Uint64;\r
+} IA32_GDT;\r
+\r
+//\r
+// Page-Map Level-4 Offset (PML4) and\r
+// Page-Directory-Pointer Offset (PDPE) entries 4K & 2MB\r
+//\r
+\r
+typedef union {\r
+ struct {\r
+ UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory\r
+ UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write\r
+ UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User\r
+ UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching\r
+ UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached\r
+ UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU)\r
+ UINT64 Reserved:1; // Reserved\r
+ UINT64 MustBeZero:2; // Must Be Zero\r
+ UINT64 Available:3; // Available for use by system software\r
+ UINT64 PageTableBaseAddress:40; // Page Table Base Address\r
+ UINT64 AvabilableHigh:11; // Available for use by system software\r
+ UINT64 Nx:1; // No Execute bit\r
+ } Bits;\r
+ UINT64 Uint64;\r
+} PAGE_MAP_AND_DIRECTORY_POINTER;\r
+\r
+//\r
+// Page Table Entry 2MB\r
+//\r
+typedef union {\r
+ struct {\r
+ UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory\r
+ UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write\r
+ UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User\r
+ UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching\r
+ UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached\r
+ UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU)\r
+ UINT64 Dirty:1; // 0 = Not Dirty, 1 = written by processor on access to page\r
+ UINT64 MustBe1:1; // Must be 1 \r
+ UINT64 Global:1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write\r
+ UINT64 Available:3; // Available for use by system software\r
+ UINT64 PAT:1; //\r
+ UINT64 MustBeZero:8; // Must be zero;\r
+ UINT64 PageTableBaseAddress:31; // Page Table Base Address\r
+ UINT64 AvabilableHigh:11; // Available for use by system software\r
+ UINT64 Nx:1; // 0 = Execute Code, 1 = No Code Execution\r
+ } Bits;\r
+ UINT64 Uint64;\r
+} PAGE_TABLE_ENTRY;\r
+\r
+#pragma pack()\r
+\r
+UINTN\r
+CreateIdentityMappingPageTables (\r
+ VOID\r
+ )\r
+;\r
+\r
+#endif \r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation\r
+All rights reserved. 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
+ IpfDxeLoad.c\r
+\r
+Abstract:\r
+\r
+ Ipf-specifc functionality for DxeLoad.\r
+\r
+--*/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "DxeIpl.h"\r
+\r
+VOID\r
+HandOffToDxeCore (\r
+ IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,\r
+ IN EFI_PEI_HOB_POINTERS HobList,\r
+ IN EFI_PEI_PPI_DESCRIPTOR *EndOfPeiSignal\r
+ )\r
+{\r
+ VOID *BaseOfStack;\r
+ VOID *TopOfStack;\r
+ VOID *BspStore;\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Allocate 128KB for the Stack\r
+ //\r
+ BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));\r
+ ASSERT (BaseOfStack != NULL);\r
+\r
+ //\r
+ // Allocate 16KB for the BspStore\r
+ //\r
+ BspStore = AllocatePages (EFI_SIZE_TO_PAGES (BSP_STORE_SIZE));\r
+ ASSERT (BspStore != NULL);\r
+ //\r
+ // Build BspStoreHob\r
+ //\r
+ BuildBspStoreHob ((EFI_PHYSICAL_ADDRESS) (UINTN) BspStore, BSP_STORE_SIZE, EfiBootServicesData);\r
+\r
+ //\r
+ // Compute the top of the stack we were allocated. Pre-allocate a UINTN\r
+ // for safety.\r
+ //\r
+ TopOfStack = (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);\r
+ TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);\r
+\r
+ //\r
+ // End of PEI phase singal\r
+ //\r
+ Status = PeiServicesInstallPpi (EndOfPeiSignal);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ SwitchStack (\r
+ (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,\r
+ HobList.Raw,\r
+ NULL,\r
+ TopOfStack,\r
+ BspStore\r
+ );\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ ImageRead.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "DxeIpl.h"\r
+\r
+EFI_STATUS\r
+PeiImageRead (\r
+ IN VOID *FileHandle,\r
+ IN UINTN FileOffset,\r
+ IN OUT UINTN *ReadSize,\r
+ OUT VOID *Buffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file\r
+\r
+Arguments:\r
+\r
+ FileHandle - The handle to the PE/COFF file\r
+\r
+ FileOffset - The offset, in bytes, into the file to read\r
+\r
+ ReadSize - The number of bytes to read from the file starting at FileOffset\r
+\r
+ Buffer - A pointer to the buffer to read the data into.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset\r
+\r
+--*/\r
+{\r
+ CHAR8 *Destination8;\r
+ CHAR8 *Source8;\r
+ volatile UINTN Length;\r
+\r
+ Destination8 = Buffer;\r
+ Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset);\r
+ Length = *ReadSize;\r
+ while (Length--) {\r
+ *(Destination8++) = *(Source8++);\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetImageReadFunction (\r
+ IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
+ )\r
+{\r
+ ImageContext->ImageRead = PeiImageRead;\r
+ return EFI_SUCCESS;\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. 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
+ DxeLoadFunc.c\r
+\r
+Abstract:\r
+\r
+ Ia32-specifc functionality for DxeLoad.\r
+\r
+--*/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "DxeIpl.h"\r
+\r
+VOID\r
+HandOffToDxeCore (\r
+ IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,\r
+ IN EFI_PEI_HOB_POINTERS HobList,\r
+ IN EFI_PEI_PPI_DESCRIPTOR *EndOfPeiSignal\r
+ )\r
+{\r
+ VOID *BaseOfStack;\r
+ VOID *TopOfStack;\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Allocate 128KB for the Stack\r
+ //\r
+ BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));\r
+ ASSERT (BaseOfStack != NULL);\r
+\r
+ //\r
+ // Compute the top of the stack we were allocated. Pre-allocate a UINTN\r
+ // for safety.\r
+ //\r
+ TopOfStack = (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);\r
+ TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);\r
+\r
+ //\r
+ // End of PEI phase singal\r
+ //\r
+ Status = PeiServicesInstallPpi (EndOfPeiSignal);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ SwitchStack (\r
+ (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,\r
+ HobList.Raw,\r
+ NULL,\r
+ TopOfStack\r
+ );\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ DecompressLibraryHob.h\r
+\r
+Abstract:\r
+\r
+ Declaration of HOB that is used to pass decompressor library functions from PEI to DXE\r
+\r
+--*/\r
+\r
+#ifndef __DECOMPRESS_LIBRARY_HOB_H__\r
+#define __DECOMPRESS_LIBRARY_HOB_H__\r
+\r
+typedef\r
+RETURN_STATUS\r
+(EFIAPI *DECOMPRESS_LIBRARY_GET_INFO) (\r
+ IN CONST VOID *Source,\r
+ IN UINT32 SourceSize,\r
+ OUT UINT32 *DestinationSize,\r
+ OUT UINT32 *ScratchSize\r
+ );\r
+\r
+typedef\r
+RETURN_STATUS\r
+(EFIAPI *DECOMPRESS_LIBRARY_DECOMPRESS) (\r
+ IN CONST VOID *Source,\r
+ IN OUT VOID *Destination,\r
+ IN OUT VOID *Scratch\r
+ );\r
+\r
+typedef struct {\r
+ DECOMPRESS_LIBRARY_GET_INFO GetInfo;\r
+ DECOMPRESS_LIBRARY_DECOMPRESS Decompress;\r
+} DECOMPRESS_LIBRARY;\r
+\r
+#endif\r
##gEfiPeiPeCoffLoaderGuid will be removed in future\r
gEfiPeiPeCoffLoaderGuid = { 0xd8117cff, 0x94a6, 0x11d4, {0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }\r
gEfiPeiCorePrivateGuid = { 0xd641a0f5, 0xcb7c, 0x4846, { 0xa3, 0x80, 0x1d, 0x01, 0xb4, 0xd9, 0xe3, 0xb9 }}\r
+ gEfiEndOfPeiSignalPpiGuid = { 0x605EA650, 0xC65C, 0x42e1, { 0xBA, 0x80, 0x91, 0xA5, 0x2A, 0xB6, 0x18, 0xC6 }}\r
+ gEfiPeiFvFileLoaderPpiGuid = { 0x7e1f0d85, 0x04ff, 0x4bb2, { 0x86, 0x6a, 0x31, 0xa2, 0x99, 0x6a, 0x48, 0xa8 }}\r
+\r
\r
################################################################################\r
#\r
\r
\r
[PcdsFeatureFlag.IA32]\r
- PcdDxeIplSwitchToLongMode|0x0001003b|gEfiEdkModulePkgTokenSpaceGuid|BOOLEAN|TRUE\r
+ PcdDxeIplSwitchToLongMode|0x0001003b|gEfiMdeModulePkgTokenSpaceGuid|BOOLEAN|TRUE\r
\r
\r
PrintLib|${WORKSPACE}/MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
TimerLib|${WORKSPACE}/MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf\r
UefiDecompressLib|${WORKSPACE}/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf\r
+ EdkPeCoffLoaderLib|${WORKSPACE}/MdeModulePkg/Library/PeiDxePeCoffLoaderLib/PeCoffLoaderLib.inf\r
+ ReportStatusCodeLib|${WORKSPACE}/IntelFrameworkPkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf\r
+ CustomDecompressLib|${WORKSPACE}/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf \r
+ HiiLib|${WORKSPACE}/IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf\r
+ \r
\r
[LibraryClasses.IA32]\r
IoLib|${WORKSPACE}/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
FvbServiceLib|${WORKSPACE}/MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
ReportStatusCodeLib|${WORKSPACE}/IntelFrameworkPkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
ScsiLib|$(WORKSPACE)/MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
+ FrameworkHiiLib|$(WORKSPACE)/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf\r
\r
[LibraryClasses.common.DXE_RUNTIME_DRIVER]\r
HobLib|${WORKSPACE}/MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
PcdPeiPcdDatabaseCallbackOnSetEnabled|gEfiEdkModulePkgTokenSpaceGuid|TRUE\r
PcdPeiPcdDatabaseExEnabled|gEfiEdkModulePkgTokenSpaceGuid|TRUE\r
PcdNtEmulatorEnable|gEfiEdkModulePkgTokenSpaceGuid|FALSE\r
+ PcdDevicePathSupportDevicePathFromText|gEfiEdkModulePkgTokenSpaceGuid|FALSE\r
+ PcdDevicePathSupportDevicePathToText|gEfiEdkModulePkgTokenSpaceGuid|FALSE\r
+ PcdDxeIplSupportCustomDecompress|gEfiEdkModulePkgTokenSpaceGuid|TRUE\r
+ PcdDxeIplBuildShareCodeHobs|gEfiEdkModulePkgTokenSpaceGuid|FALSE \r
+ PcdDxeIplSupportEfiDecompress|gEfiEdkModulePkgTokenSpaceGuid|TRUE\r
+ PcdDxeIplSupportTianoDecompress|gEfiEdkModulePkgTokenSpaceGuid|TRUE\r
+ PcdDxeIplSupportCustomDecompress|gEfiEdkModulePkgTokenSpaceGuid|TRUE \r
\r
# PcdStatusCodeUseOEM|gEfiIntelFrameworkModulePkgTokenSpaceGuid|FALSE\r
\r
+[PcdsFeatureFlag.IA32]\r
+ PcdDxeIplSwitchToLongMode|gEfiMdeModulePkgTokenSpaceGuid|TRUE\r
+\r
[PcdsFixedAtBuild.common]\r
PcdMaximumUnicodeStringLength|gEfiMdePkgTokenSpaceGuid|1000000\r
PcdMaximumAsciiStringLength|gEfiMdePkgTokenSpaceGuid|1000000\r
$(WORKSPACE)/MdeModulePkg/Universal/PCD/Pei/Pcd.inf\r
$(WORKSPACE)/MdeModulePkg/Core/Dxe/DxeMain.inf\r
$(WORKSPACE)/MdeModulePkg/Core/Pei/PeiMain.inf\r
+ ${WORKSPACE}/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.inf\r
+ ${WORKSPACE}/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.inf\r
+ ${WORKSPACE}/MdeModulePkg/Universal/DevicePathDxe/DevicePath.inf\r
+ ${WORKSPACE}/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.inf\r
+ ${WORKSPACE}/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.inf\r
+ ${WORKSPACE}/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf\r
+\r
\r
[Components.X64]\r
${WORKSPACE}/MdeModulePkg/Application/HelloWorld/HelloWorld.inf\r
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2006 - 2007, Intel Corporation\r
+ All rights reserved. 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
+ 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
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <Uefi.h>\r
+\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/SimpleTextOut.h>\r
+#include <Guid/GlobalVariable.h>\r
+#include <Guid/ConsoleInDevice.h>\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/SimpleTextIn.h>\r
+#include <Guid/HotPlugDevice.h>\r
+#include <Guid/StandardErrorDevice.h>\r
+#include <Guid/ConsoleOutDevice.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+//\r
+// Driver Binding Externs\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextInDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName;\r
+extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName;\r
+\r
+#endif\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ ComponentName.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+\r
+\r
+#include "ConPlatform.h"\r
+#include "ComponentName.h"\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName = {\r
+ ConPlatformComponentNameGetDriverName,\r
+ ConPlatformComponentNameGetControllerName,\r
+ "eng"\r
+};\r
+\r
+STATIC EFI_UNICODE_STRING_TABLE mConPlatformDriverNameTable[] = {\r
+ {\r
+ "eng",\r
+ L"Platform Console Management Driver"\r
+ },\r
+ {\r
+ NULL,\r
+ NULL\r
+ }\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConPlatformComponentNameGetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **DriverName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+ Arguments:\r
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ Language - A pointer to a three character ISO 639-2 language identifier.\r
+ This is the language of the driver name that that the caller \r
+ is requesting, and it must match one of the languages specified\r
+ in SupportedLanguages. The number of languages supported by a \r
+ driver is up to the driver writer.\r
+ DriverName - A pointer to the Unicode string to return. This Unicode string\r
+ is the name of the driver specified by This in the language \r
+ specified by Language.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Unicode string for the Driver specified by This\r
+ and the language specified by Language was returned \r
+ in DriverName.\r
+ EFI_INVALID_PARAMETER - Language is NULL.\r
+ EFI_INVALID_PARAMETER - DriverName is NULL.\r
+ EFI_UNSUPPORTED - The driver specified by This does not support the \r
+ language specified by Language.\r
+\r
+--*/\r
+{\r
+ return LookupUnicodeString (\r
+ Language,\r
+ gConPlatformComponentName.SupportedLanguages,\r
+ mConPlatformDriverNameTable,\r
+ DriverName\r
+ );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConPlatformComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Retrieves a Unicode string that is the user readable name of the controller\r
+ that is being managed by an EFI Driver.\r
+\r
+ Arguments:\r
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ ControllerHandle - The handle of a controller that the driver specified by \r
+ This is managing. This handle specifies the controller \r
+ whose name is to be returned.\r
+ ChildHandle - The handle of the child controller to retrieve the name \r
+ of. This is an optional parameter that may be NULL. It \r
+ will be NULL for device drivers. It will also be NULL \r
+ for a bus drivers that wish to retrieve the name of the \r
+ bus controller. It will not be NULL for a bus driver \r
+ that wishes to retrieve the name of a child controller.\r
+ Language - A pointer to a three character ISO 639-2 language \r
+ identifier. This is the language of the controller name \r
+ that that the caller is requesting, and it must match one\r
+ of the languages specified in SupportedLanguages. The \r
+ number of languages supported by a driver is up to the \r
+ driver writer.\r
+ ControllerName - A pointer to the Unicode string to return. This Unicode\r
+ string is the name of the controller specified by \r
+ ControllerHandle and ChildHandle in the language \r
+ specified by Language from the point of view of the \r
+ driver specified by This. \r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Unicode string for the user readable name in the\r
+ language specified by Language for the driver \r
+ specified by This was returned in DriverName.\r
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
+ EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - Language is NULL.\r
+ EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+ EFI_UNSUPPORTED - The driver specified by This is not currently \r
+ managing the controller specified by \r
+ ControllerHandle and ChildHandle.\r
+ EFI_UNSUPPORTED - The driver specified by This does not support the \r
+ language specified by Language.\r
+\r
+--*/\r
+{\r
+ return EFI_UNSUPPORTED;\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ ComponentName.h\r
+ \r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef CON_MANAGE_COMPONENT_NAME_H_\r
+#define CON_MANAGE_COMPONENT_NAME_H_\r
+\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+ConPlatformComponentNameGetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **DriverName\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConPlatformComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ );\r
+\r
+#endif\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation\r
+All rights reserved. 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
+ ConPlatform.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include <Uefi.h>\r
+\r
+#include "ConPlatform.h"\r
+\r
+\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/SimpleTextOut.h>\r
+#include <Guid/GlobalVariable.h>\r
+#include <Guid/ConsoleInDevice.h>\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/SimpleTextIn.h>\r
+#include <Guid/HotPlugDevice.h>\r
+#include <Guid/StandardErrorDevice.h>\r
+#include <Guid/ConsoleOutDevice.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+//\r
+// Driver Binding Externs\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextInDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName;\r
+extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName;\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextInDriverBinding = {\r
+ ConPlatformTextInDriverBindingSupported,\r
+ ConPlatformTextInDriverBindingStart,\r
+ ConPlatformTextInDriverBindingStop,\r
+ 0xa,\r
+ NULL,\r
+ NULL\r
+};\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding = {\r
+ ConPlatformTextOutDriverBindingSupported,\r
+ ConPlatformTextOutDriverBindingStart,\r
+ ConPlatformTextOutDriverBindingStop,\r
+ 0xa,\r
+ NULL,\r
+ NULL\r
+};\r
+\r
+/**\r
+ The user Entry Point for module ConPlatform. 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
+InitializeConPlatform(\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
+ &gConPlatformTextInDriverBinding,\r
+ ImageHandle,\r
+ &gConPlatformComponentName,\r
+ NULL,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = EfiLibInstallAllDriverProtocols (\r
+ ImageHandle,\r
+ SystemTable,\r
+ &gConPlatformTextOutDriverBinding,\r
+ NULL,\r
+ &gConPlatformComponentName,\r
+ NULL,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+\r
+ return Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConPlatformTextInDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Supported\r
+\r
+Arguments:\r
+ (Standard DriverBinding Protocol Supported() function)\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ return ConPlatformDriverBindingSupported (\r
+ This,\r
+ ControllerHandle,\r
+ RemainingDevicePath,\r
+ &gEfiSimpleTextInProtocolGuid\r
+ );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConPlatformTextOutDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Supported\r
+\r
+Arguments:\r
+ (Standard DriverBinding Protocol Supported() function)\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ return ConPlatformDriverBindingSupported (\r
+ This,\r
+ ControllerHandle,\r
+ RemainingDevicePath,\r
+ &gEfiSimpleTextOutProtocolGuid\r
+ );\r
+}\r
+\r
+EFI_STATUS\r
+ConPlatformDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath,\r
+ IN EFI_GUID *ProtocolGuid\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Supported\r
+\r
+Arguments:\r
+ (Standard DriverBinding Protocol Supported() function)\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ VOID *Interface;\r
+\r
+ //\r
+ // Test to see if this is a physical device by checking to see if\r
+ // it has a Device Path Protocol\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ NULL,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Test to see if this device supports the Simple Text Output Protocol\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ ProtocolGuid,\r
+ (VOID **) &Interface,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ gBS->CloseProtocol (\r
+ ControllerHandle,\r
+ ProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle\r
+ );\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConPlatformTextInDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+\r
+Arguments:\r
+ (Standard DriverBinding Protocol Start() function)\r
+\r
+Returns:\r
+\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;\r
+\r
+ //\r
+ // Get the Device Path Protocol so the environment variables can be updated\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID **) &DevicePath,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Open the Simple Input Protocol BY_DRIVER\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiSimpleTextInProtocolGuid,\r
+ (VOID **) &TextIn,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Check the device handle, if it is a hot plug device,\r
+ // do not put the device path into ConInDev, and install\r
+ // gEfiConsoleInDeviceGuid to the device handle directly.\r
+ // The policy is, make hot plug device plug in and play immediately.\r
+ //\r
+ if (IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
+ gBS->InstallMultipleProtocolInterfaces (\r
+ &ControllerHandle,\r
+ &gEfiConsoleInDeviceGuid,\r
+ NULL,\r
+ NULL\r
+ );\r
+ } else {\r
+ //\r
+ // Append the device path to the ConInDev environment variable\r
+ //\r
+ ConPlatformUpdateDeviceVariable (\r
+ VarConsoleInpDev,\r
+ DevicePath,\r
+ APPEND\r
+ );\r
+\r
+ //\r
+ // If the device path is an instance in the ConIn environment variable,\r
+ // then install EfiConsoleInDeviceGuid onto ControllerHandle\r
+ //\r
+ Status = ConPlatformUpdateDeviceVariable (\r
+ VarConsoleInp,\r
+ DevicePath,\r
+ CHECK\r
+ );\r
+\r
+ if (!EFI_ERROR (Status)) {\r
+ gBS->InstallMultipleProtocolInterfaces (\r
+ &ControllerHandle,\r
+ &gEfiConsoleInDeviceGuid,\r
+ NULL,\r
+ NULL\r
+ );\r
+ } else {\r
+ gBS->CloseProtocol (\r
+ ControllerHandle,\r
+ &gEfiSimpleTextInProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle\r
+ );\r
+ }\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConPlatformTextOutDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+\r
+Arguments:\r
+ (Standard DriverBinding Protocol Start() function)\r
+\r
+Returns:\r
+\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r
+ BOOLEAN NeedClose;\r
+\r
+ NeedClose = TRUE;\r
+\r
+ //\r
+ // Get the Device Path Protocol so the environment variables can be updated\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID **) &DevicePath,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Open the Simple Text Output Protocol BY_DRIVER\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ (VOID **) &TextOut,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Check the device handle, if it is a hot plug device,\r
+ // do not put the device path into ConOutDev and StdErrDev,\r
+ // and install gEfiConsoleOutDeviceGuid to the device handle directly.\r
+ // The policy is, make hot plug device plug in and play immediately.\r
+ //\r
+ if (IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
+ gBS->InstallMultipleProtocolInterfaces (\r
+ &ControllerHandle,\r
+ &gEfiConsoleOutDeviceGuid,\r
+ NULL,\r
+ NULL\r
+ );\r
+ } else {\r
+ //\r
+ // Append the device path to the ConOutDev environment variable\r
+ //\r
+ ConPlatformUpdateDeviceVariable (\r
+ VarConsoleOutDev,\r
+ DevicePath,\r
+ APPEND\r
+ );\r
+ //\r
+ // Append the device path to the StdErrDev environment variable\r
+ //\r
+ ConPlatformUpdateDeviceVariable (\r
+ VarErrorOutDev,\r
+ DevicePath,\r
+ APPEND\r
+ );\r
+\r
+ //\r
+ // If the device path is an instance in the ConOut environment variable,\r
+ // then install EfiConsoleOutDeviceGuid onto ControllerHandle\r
+ //\r
+ Status = ConPlatformUpdateDeviceVariable (\r
+ VarConsoleOut,\r
+ DevicePath,\r
+ CHECK\r
+ );\r
+\r
+ if (!EFI_ERROR (Status)) {\r
+ NeedClose = FALSE;\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &ControllerHandle,\r
+ &gEfiConsoleOutDeviceGuid,\r
+ NULL,\r
+ NULL\r
+ );\r
+ }\r
+ //\r
+ // If the device path is an instance in the StdErr environment variable,\r
+ // then install EfiStandardErrorDeviceGuid onto ControllerHandle\r
+ //\r
+ Status = ConPlatformUpdateDeviceVariable (\r
+ VarErrorOut,\r
+ DevicePath,\r
+ CHECK\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ NeedClose = FALSE;\r
+ gBS->InstallMultipleProtocolInterfaces (\r
+ &ControllerHandle,\r
+ &gEfiStandardErrorDeviceGuid,\r
+ NULL,\r
+ NULL\r
+ );\r
+ }\r
+\r
+ if (NeedClose) {\r
+ gBS->CloseProtocol (\r
+ ControllerHandle,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle\r
+ );\r
+ }\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConPlatformTextInDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+ (Standard DriverBinding Protocol Stop() function)\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+\r
+ //\r
+ // hot plug device is not included into the console associated variables,\r
+ // so no need to check variable for those hot plug devices.\r
+ //\r
+ if (!IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
+ //\r
+ // Get the Device Path Protocol so the environment variables can be updated\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID **) &DevicePath,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Remove DevicePath from ConInDev\r
+ //\r
+ ConPlatformUpdateDeviceVariable (\r
+ VarConsoleInpDev,\r
+ DevicePath,\r
+ DELETE\r
+ );\r
+ }\r
+ }\r
+ //\r
+ // Uninstall the Console Device GUIDs from Controller Handle\r
+ //\r
+ ConPlatformUnInstallProtocol (\r
+ This,\r
+ ControllerHandle,\r
+ &gEfiConsoleInDeviceGuid\r
+ );\r
+\r
+ //\r
+ // Close the Simple Input Protocol\r
+ //\r
+ gBS->CloseProtocol (\r
+ ControllerHandle,\r
+ &gEfiSimpleTextInProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle\r
+ );\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConPlatformTextOutDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+ (Standard DriverBinding Protocol Stop() function)\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+\r
+ //\r
+ // hot plug device is not included into the console associated variables,\r
+ // so no need to check variable for those hot plug devices.\r
+ //\r
+ if (!IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
+ //\r
+ // Get the Device Path Protocol so the environment variables can be updated\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID **) &DevicePath,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Remove DevicePath from ConOutDev, and StdErrDev\r
+ //\r
+ ConPlatformUpdateDeviceVariable (\r
+ VarConsoleOutDev,\r
+ DevicePath,\r
+ DELETE\r
+ );\r
+ ConPlatformUpdateDeviceVariable (\r
+ VarErrorOutDev,\r
+ DevicePath,\r
+ DELETE\r
+ );\r
+ }\r
+ }\r
+ //\r
+ // Uninstall the Console Device GUIDs from Controller Handle\r
+ //\r
+ ConPlatformUnInstallProtocol (\r
+ This,\r
+ ControllerHandle,\r
+ &gEfiConsoleOutDeviceGuid\r
+ );\r
+\r
+ ConPlatformUnInstallProtocol (\r
+ This,\r
+ ControllerHandle,\r
+ &gEfiStandardErrorDeviceGuid\r
+ );\r
+\r
+ //\r
+ // Close the Simple Text Output Protocol\r
+ //\r
+ gBS->CloseProtocol (\r
+ ControllerHandle,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle\r
+ );\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+VOID\r
+ConPlatformUnInstallProtocol (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Handle,\r
+ IN EFI_GUID *ProtocolGuid\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = gBS->OpenProtocol (\r
+ Handle,\r
+ ProtocolGuid,\r
+ NULL,\r
+ This->DriverBindingHandle,\r
+ Handle,\r
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+ );\r
+\r
+ if (!EFI_ERROR (Status)) {\r
+ gBS->UninstallMultipleProtocolInterfaces (\r
+ Handle,\r
+ ProtocolGuid,\r
+ NULL,\r
+ NULL\r
+ );\r
+ }\r
+\r
+ return ;\r
+}\r
+\r
+VOID *\r
+ConPlatformGetVariable (\r
+ IN CHAR16 *Name\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Read the EFI variable (Name) and return a dynamically allocated\r
+ buffer, and the size of the buffer. On failure return NULL.\r
+\r
+Arguments:\r
+ Name - String part of EFI variable name\r
+\r
+Returns:\r
+ Dynamically allocated memory that contains a copy of the EFI variable.\r
+ Caller is repsoncible freeing the buffer.\r
+\r
+ NULL - Variable was not read\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ VOID *Buffer;\r
+ UINTN BufferSize;\r
+\r
+ BufferSize = 0;\r
+ Buffer = NULL;\r
+\r
+ //\r
+ // Test to see if the variable exists. If it doesn't reuturn NULL\r
+ //\r
+ Status = gRT->GetVariable (\r
+ Name,\r
+ &gEfiGlobalVariableGuid,\r
+ NULL,\r
+ &BufferSize,\r
+ Buffer\r
+ );\r
+\r
+ if (Status == EFI_BUFFER_TOO_SMALL) {\r
+ //\r
+ // Allocate the buffer to return\r
+ //\r
+ Buffer = AllocatePool (BufferSize);\r
+ if (Buffer == NULL) {\r
+ return NULL;\r
+ }\r
+ //\r
+ // Read variable into the allocated buffer.\r
+ //\r
+ Status = gRT->GetVariable (\r
+ Name,\r
+ &gEfiGlobalVariableGuid,\r
+ NULL,\r
+ &BufferSize,\r
+ Buffer\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ FreePool (Buffer);\r
+ Buffer = NULL;\r
+ }\r
+ }\r
+\r
+ return Buffer;\r
+}\r
+\r
+EFI_STATUS\r
+ConPlatformMatchDevicePaths (\r
+ IN EFI_DEVICE_PATH_PROTOCOL * Multi,\r
+ IN EFI_DEVICE_PATH_PROTOCOL * Single,\r
+ IN EFI_DEVICE_PATH_PROTOCOL **NewDevicePath OPTIONAL,\r
+ IN BOOLEAN Delete\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Function compares a device path data structure to that of all the nodes of a\r
+ second device path instance.\r
+\r
+Arguments:\r
+ Multi - A pointer to a multi-instance device path data structure.\r
+\r
+ Single - A pointer to a single-instance device path data structure.\r
+\r
+ NewDevicePath - If Delete is TRUE, this parameter must not be null, and it\r
+ points to the remaining device path data structure.\r
+ (remaining device path = Multi - Single.)\r
+\r
+ Delete - If TRUE, means removing Single from Multi.\r
+ If FALSE, the routine just check whether Single matches\r
+ with any instance in Multi.\r
+\r
+Returns:\r
+\r
+ The function returns EFI_SUCCESS if the Single is contained within Multi.\r
+ Otherwise, EFI_NOT_FOUND is returned.\r
+\r
+--*/\r
+{\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath1;\r
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath2;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;\r
+ UINTN Size;\r
+\r
+ //\r
+ // The passed in DevicePath should not be NULL\r
+ //\r
+ if ((!Multi) || (!Single)) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ //\r
+ // if performing Delete operation, the NewDevicePath must not be NULL.\r
+ //\r
+ TempDevicePath1 = NULL;\r
+\r
+ DevicePath = Multi;\r
+ DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);\r
+\r
+ //\r
+ // search for the match of 'Single' in 'Multi'\r
+ //\r
+ while (DevicePathInst) {\r
+ if (CompareMem (Single, DevicePathInst, Size) == 0) {\r
+ if (!Delete) {\r
+ FreePool (DevicePathInst);\r
+ return EFI_SUCCESS;\r
+ }\r
+ } else {\r
+ if (Delete) {\r
+ TempDevicePath2 = AppendDevicePathInstance (\r
+ TempDevicePath1,\r
+ DevicePathInst\r
+ );\r
+ if (TempDevicePath1 != NULL) {\r
+ FreePool (TempDevicePath1);\r
+ }\r
+ TempDevicePath1 = TempDevicePath2;\r
+ }\r
+ }\r
+\r
+ FreePool (DevicePathInst);\r
+ DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);\r
+ }\r
+\r
+ if (Delete) {\r
+ *NewDevicePath = TempDevicePath1;\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ return EFI_NOT_FOUND;\r
+}\r
+\r
+EFI_STATUS\r
+ConPlatformUpdateDeviceVariable (\r
+ IN CHAR16 *VariableName,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN CONPLATFORM_VAR_OPERATION Operation\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *VariableDevicePath;\r
+ EFI_DEVICE_PATH_PROTOCOL *NewVariableDevicePath;\r
+\r
+ VariableDevicePath = NULL;\r
+ NewVariableDevicePath = NULL;\r
+\r
+ //\r
+ // Get Variable according to variable name.\r
+ // The memory for Variable is allocated within ConPlatformGetVarible(),\r
+ // it is the caller's responsibility to free the memory before return.\r
+ //\r
+ VariableDevicePath = ConPlatformGetVariable (VariableName);\r
+\r
+ if (Operation != DELETE) {\r
+\r
+ Status = ConPlatformMatchDevicePaths (\r
+ VariableDevicePath,\r
+ DevicePath,\r
+ NULL,\r
+ FALSE\r
+ );\r
+\r
+ if ((Operation == CHECK) || (!EFI_ERROR (Status))) {\r
+ //\r
+ // The device path is already in the variable\r
+ //\r
+ if (VariableDevicePath != NULL) {\r
+ FreePool (VariableDevicePath);\r
+ }\r
+\r
+ return Status;\r
+ }\r
+ //\r
+ // The device path is not in variable. Append DevicePath to the\r
+ // environment variable that is a multi-instance device path.\r
+ //\r
+ Status = EFI_SUCCESS;\r
+ NewVariableDevicePath = AppendDevicePathInstance (\r
+ VariableDevicePath,\r
+ DevicePath\r
+ );\r
+ if (NewVariableDevicePath == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ } else {\r
+ //\r
+ // Remove DevicePath from the environment variable that\r
+ // is a multi-instance device path.\r
+ //\r
+ Status = ConPlatformMatchDevicePaths (\r
+ VariableDevicePath,\r
+ DevicePath,\r
+ &NewVariableDevicePath,\r
+ TRUE\r
+ );\r
+ }\r
+\r
+ if (VariableDevicePath != NULL) {\r
+ FreePool (VariableDevicePath);\r
+ }\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ Status = gRT->SetVariable (\r
+ VariableName,\r
+ &gEfiGlobalVariableGuid,\r
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ GetDevicePathSize (NewVariableDevicePath),\r
+ NewVariableDevicePath\r
+ );\r
+\r
+ FreePool (NewVariableDevicePath);\r
+\r
+ return Status;\r
+}\r
+\r
+BOOLEAN\r
+IsHotPlugDevice (\r
+ EFI_HANDLE DriverBindingHandle,\r
+ EFI_HANDLE ControllerHandle\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // HotPlugDeviceGuid indicates ControllerHandle stands for a hot plug device.\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiHotPlugDeviceGuid,\r
+ NULL,\r
+ DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return FALSE;\r
+ }\r
+\r
+ return TRUE;\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ ConPlatform.h\r
+ \r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef CON_MANAGE_H_\r
+#define CON_MANAGE_H_\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#define VarConsoleInpDev L"ConInDev"\r
+#define VarConsoleInp L"ConIn"\r
+#define VarConsoleOutDev L"ConOutDev"\r
+#define VarConsoleOut L"ConOut"\r
+#define VarErrorOutDev L"ErrOutDev"\r
+#define VarErrorOut L"ErrOut"\r
+\r
+typedef enum {\r
+ CHECK,\r
+ APPEND,\r
+ DELETE\r
+} CONPLATFORM_VAR_OPERATION;\r
+\r
+EFI_STATUS\r
+ConPlatformDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath,\r
+ IN EFI_GUID *ProtocolGuid\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConPlatformTextInDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Handle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConPlatformTextOutDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Handle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConPlatformTextInDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Handle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConPlatformTextOutDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Handle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConPlatformTextInDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Handle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConPlatformTextOutDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Handle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ );\r
+\r
+VOID\r
+ConPlatformUnInstallProtocol (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Handle,\r
+ IN EFI_GUID *ProtocolGuid\r
+ );\r
+\r
+VOID *\r
+ConPlatformGetVariable (\r
+ IN CHAR16 *Name\r
+ );\r
+\r
+EFI_STATUS\r
+ConPlatformMatchDevicePaths (\r
+ IN EFI_DEVICE_PATH_PROTOCOL * Multi,\r
+ IN EFI_DEVICE_PATH_PROTOCOL * Single,\r
+ IN EFI_DEVICE_PATH_PROTOCOL **NewDevicePath OPTIONAL,\r
+ IN BOOLEAN Delete\r
+ );\r
+\r
+EFI_STATUS\r
+ConPlatformUpdateDeviceVariable (\r
+ IN CHAR16 *VariableName,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN CONPLATFORM_VAR_OPERATION Operation\r
+ );\r
+\r
+BOOLEAN\r
+IsHotPlugDevice (\r
+ EFI_HANDLE DriverBindingHandle,\r
+ EFI_HANDLE ControllerHandle\r
+ );\r
+\r
+#endif\r
--- /dev/null
+#/** @file\r
+# Console Platfrom Driver\r
+#\r
+# Console Platfrom DXE Driver, install Console protocols\r
+# Copyright (c) 2006 - 2007, Intel Corporation\r
+#\r
+# All rights reserved. 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
+# 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
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = ConPlatform\r
+ FILE_GUID = 51ccf399-4fdf-4e55-a45b-e123f84d456a\r
+ MODULE_TYPE = UEFI_DRIVER\r
+ VERSION_STRING = 1.0\r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+ ENTRY_POINT = InitializeConPlatform\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+# DRIVER_BINDING = gConPlatformTextInDriverBinding \r
+# COMPONENT_NAME = gConPlatformComponentName \r
+# DRIVER_BINDING = gConPlatformTextOutDriverBinding \r
+# COMPONENT_NAME = gConPlatformComponentName \r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ ComponentName.c\r
+ ComponentName.h\r
+ ConPlatform.h\r
+ ConPlatform.c\r
+ CommonHeader.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ MemoryAllocationLib\r
+ DevicePathLib\r
+ UefiRuntimeServicesTableLib\r
+ UefiBootServicesTableLib\r
+ BaseMemoryLib\r
+ UefiLib\r
+ UefiDriverEntryPoint\r
+ DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Guid C Name Section - list of Guids that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Guids]\r
+ gEfiGlobalVariableGuid # SOMETIMES_CONSUMED L"ErrOut"\r
+\r
+\r
+################################################################################\r
+#\r
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
+# that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Protocols]\r
+ gEfiHotPlugDeviceGuid # PROTOCOL TO_START\r
+ gEfiDevicePathProtocolGuid # PROTOCOL TO_START\r
+ gEfiSimpleTextInProtocolGuid # PROTOCOL TO_START\r
+ gEfiSimpleTextOutProtocolGuid # PROTOCOL TO_START\r
+ gEfiStandardErrorDeviceGuid # PROTOCOL BY_START\r
+ gEfiConsoleOutDeviceGuid # PROTOCOL BY_START\r
+ gEfiConsoleInDeviceGuid # PROTOCOL BY_START\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>ConPlatform</ModuleName>\r
+ <ModuleType>UEFI_DRIVER</ModuleType>\r
+ <GuidValue>51ccf399-4fdf-4e55-a45b-e123f84d456a</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Console Platfrom Driver</Abstract>\r
+ <Description>Console Platfrom DXE Driver, install Console protocols</Description>\r
+ <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
+ <License>All rights reserved. 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
+ 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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>ConPlatform</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>DebugLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiDriverModelLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiDriverEntryPoint</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseMemoryLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiBootServicesTableLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiRuntimeServicesTableLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>DevicePathLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>MemoryAllocationLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>ConPlatform.c</Filename>\r
+ <Filename>ConPlatform.h</Filename>\r
+ <Filename>ComponentName.h</Filename>\r
+ <Filename>ComponentName.c</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+ </PackageDependencies>\r
+ <Protocols>\r
+ <Protocol Usage="BY_START">\r
+ <ProtocolCName>gEfiConsoleInDeviceGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="BY_START">\r
+ <ProtocolCName>gEfiConsoleOutDeviceGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="BY_START">\r
+ <ProtocolCName>gEfiStandardErrorDeviceGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="TO_START">\r
+ <ProtocolCName>gEfiSimpleTextOutProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="TO_START">\r
+ <ProtocolCName>gEfiSimpleTextInProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="TO_START">\r
+ <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="TO_START">\r
+ <ProtocolCName>gEfiHotPlugDeviceGuid</ProtocolCName>\r
+ </Protocol>\r
+ </Protocols>\r
+ <Variables>\r
+ <Variable Usage="SOMETIMES_CONSUMED">\r
+ <VariableName>0x0043 0x006F 0x006E 0x0049 0x006E 0x0044 0x0065 0x0076</VariableName>\r
+ <GuidC_Name>gEfiGlobalVariableGuid</GuidC_Name>\r
+ <HelpText>L"ConInDev" global variable will be updated if the serial device is not a hot plug device.</HelpText>\r
+ </Variable>\r
+ <Variable Usage="SOMETIMES_CONSUMED">\r
+ <VariableName>0x0043 0x006F 0x006E 0x0049 0x006E</VariableName>\r
+ <GuidC_Name>gEfiGlobalVariableGuid</GuidC_Name>\r
+ <HelpText>L"ConIn" global variable will be updated if the serial device is not a hot plug device.</HelpText>\r
+ </Variable>\r
+ <Variable Usage="SOMETIMES_CONSUMED">\r
+ <VariableName>0x0043 0x006F 0x006E 0x004F 0x0075 0x0074 0x0044 0x0065 0x0076</VariableName>\r
+ <GuidC_Name>gEfiGlobalVariableGuid</GuidC_Name>\r
+ <HelpText>L"ConOutDev" global variable will be updated if the serial device is not a hot plug device.</HelpText>\r
+ </Variable>\r
+ <Variable Usage="SOMETIMES_CONSUMED">\r
+ <VariableName>0x0043 0x006F 0x006E 0x004F 0x0075 0x0074</VariableName>\r
+ <GuidC_Name>gEfiGlobalVariableGuid</GuidC_Name>\r
+ <HelpText>L"ConOut" global variable will be updated if the serial device is not a hot plug device.</HelpText>\r
+ </Variable>\r
+ <Variable Usage="SOMETIMES_CONSUMED">\r
+ <VariableName>0x0045 0x0072 0x0072 0x004F 0x0075 0x0074 0x0044 0x0065 0x0076</VariableName>\r
+ <GuidC_Name>gEfiGlobalVariableGuid</GuidC_Name>\r
+ <HelpText>L"ErrOutDev" global variable will be updated if the serial device is not a hot plug device.</HelpText>\r
+ </Variable>\r
+ <Variable Usage="SOMETIMES_CONSUMED">\r
+ <VariableName>0x0045 0x0072 0x0072 0x004F 0x0075 0x0074</VariableName>\r
+ <GuidC_Name>gEfiGlobalVariableGuid</GuidC_Name>\r
+ <HelpText>L"ErrOut" global variable will be updated if the serial device is not a hot plug device.</HelpText>\r
+ </Variable>\r
+ </Variables>\r
+ <Guids>\r
+ <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+ <GuidCName>gEfiGlobalVariableGuid</GuidCName>\r
+ </GuidCNames>\r
+ </Guids>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ <Extern>\r
+ <DriverBinding>gConPlatformTextInDriverBinding</DriverBinding>\r
+ <ComponentName>gConPlatformComponentName</ComponentName>\r
+ </Extern>\r
+ <Extern>\r
+ <DriverBinding>gConPlatformTextOutDriverBinding</DriverBinding>\r
+ <ComponentName>gConPlatformComponentName</ComponentName>\r
+ </Extern>\r
+ </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2006 - 2007, Intel Corporation\r
+ All rights reserved. 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
+ 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
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Guid/PrimaryStandardErrorDevice.h>\r
+#include <Guid/PrimaryConsoleOutDevice.h>\r
+#include <Protocol/GraphicsOutput.h>\r
+#include <Guid/PrimaryConsoleInDevice.h>\r
+#include <Protocol/SimplePointer.h>\r
+#include <Protocol/SimpleTextOut.h>\r
+#include <Guid/ConsoleInDevice.h>\r
+#include <Protocol/SimpleTextIn.h>\r
+#include <Protocol/ConsoleControl.h>\r
+#include <Guid/StandardErrorDevice.h>\r
+#include <Guid/ConsoleOutDevice.h>\r
+#include <Protocol/UgaDraw.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+//\r
+// Driver Binding Externs\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gConSplitterConInComponentName;\r
+extern EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gConSplitterSimplePointerComponentName;\r
+extern EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gConSplitterConOutComponentName;\r
+extern EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gConSplitterStdErrComponentName;\r
+\r
+\r
+#endif\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ ComponentName.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "ConSplitter.h"\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+EFI_COMPONENT_NAME_PROTOCOL gConSplitterConInComponentName = {\r
+ ConSplitterComponentNameGetDriverName,\r
+ ConSplitterConInComponentNameGetControllerName,\r
+ "eng"\r
+};\r
+\r
+EFI_COMPONENT_NAME_PROTOCOL gConSplitterSimplePointerComponentName = {\r
+ ConSplitterComponentNameGetDriverName,\r
+ ConSplitterSimplePointerComponentNameGetControllerName,\r
+ "eng"\r
+};\r
+\r
+EFI_COMPONENT_NAME_PROTOCOL gConSplitterConOutComponentName = {\r
+ ConSplitterComponentNameGetDriverName,\r
+ ConSplitterConOutComponentNameGetControllerName,\r
+ "eng"\r
+};\r
+\r
+EFI_COMPONENT_NAME_PROTOCOL gConSplitterStdErrComponentName = {\r
+ ConSplitterComponentNameGetDriverName,\r
+ ConSplitterStdErrComponentNameGetControllerName,\r
+ "eng"\r
+};\r
+\r
+static EFI_UNICODE_STRING_TABLE mConSplitterDriverNameTable[] = {\r
+ {\r
+ "eng",\r
+ (CHAR16 *) L"Console Splitter Driver"\r
+ },\r
+ {\r
+ NULL,\r
+ NULL\r
+ }\r
+};\r
+\r
+static EFI_UNICODE_STRING_TABLE mConSplitterConInControllerNameTable[] = {\r
+ {\r
+ "eng",\r
+ (CHAR16 *) L"Primary Console Input Device"\r
+ },\r
+ {\r
+ NULL,\r
+ NULL\r
+ }\r
+};\r
+\r
+static EFI_UNICODE_STRING_TABLE mConSplitterSimplePointerControllerNameTable[] = {\r
+ {\r
+ "eng",\r
+ (CHAR16 *) L"Primary Simple Pointer Device"\r
+ },\r
+ {\r
+ NULL,\r
+ NULL\r
+ }\r
+};\r
+\r
+static EFI_UNICODE_STRING_TABLE mConSplitterConOutControllerNameTable[] = {\r
+ {\r
+ "eng",\r
+ (CHAR16 *) L"Primary Console Output Device"\r
+ },\r
+ {\r
+ NULL,\r
+ NULL\r
+ }\r
+};\r
+\r
+static EFI_UNICODE_STRING_TABLE mConSplitterStdErrControllerNameTable[] = {\r
+ {\r
+ "eng",\r
+ (CHAR16 *) L"Primary Standard Error Device"\r
+ },\r
+ {\r
+ NULL,\r
+ NULL\r
+ }\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterComponentNameGetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **DriverName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+ Arguments:\r
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ Language - A pointer to a three character ISO 639-2 language identifier.\r
+ This is the language of the driver name that that the caller \r
+ is requesting, and it must match one of the languages specified\r
+ in SupportedLanguages. The number of languages supported by a \r
+ driver is up to the driver writer.\r
+ DriverName - A pointer to the Unicode string to return. This Unicode string\r
+ is the name of the driver specified by This in the language \r
+ specified by Language.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Unicode string for the Driver specified by This\r
+ and the language specified by Language was returned \r
+ in DriverName.\r
+ EFI_INVALID_PARAMETER - Language is NULL.\r
+ EFI_INVALID_PARAMETER - DriverName is NULL.\r
+ EFI_UNSUPPORTED - The driver specified by This does not support the \r
+ language specified by Language.\r
+\r
+--*/\r
+{\r
+ return LookupUnicodeString (\r
+ Language,\r
+ gConSplitterConInComponentName.SupportedLanguages,\r
+ mConSplitterDriverNameTable,\r
+ DriverName\r
+ );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterConInComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Retrieves a Unicode string that is the user readable name of the controller\r
+ that is being managed by an EFI Driver.\r
+\r
+ Arguments:\r
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ ControllerHandle - The handle of a controller that the driver specified by \r
+ This is managing. This handle specifies the controller \r
+ whose name is to be returned.\r
+ ChildHandle - The handle of the child controller to retrieve the name \r
+ of. This is an optional parameter that may be NULL. It \r
+ will be NULL for device drivers. It will also be NULL \r
+ for a bus drivers that wish to retrieve the name of the \r
+ bus controller. It will not be NULL for a bus driver \r
+ that wishes to retrieve the name of a child controller.\r
+ Language - A pointer to a three character ISO 639-2 language \r
+ identifier. This is the language of the controller name \r
+ that that the caller is requesting, and it must match one\r
+ of the languages specified in SupportedLanguages. The \r
+ number of languages supported by a driver is up to the \r
+ driver writer.\r
+ ControllerName - A pointer to the Unicode string to return. This Unicode\r
+ string is the name of the controller specified by \r
+ ControllerHandle and ChildHandle in the language \r
+ specified by Language from the point of view of the \r
+ driver specified by This. \r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Unicode string for the user readable name in the\r
+ language specified by Language for the driver \r
+ specified by This was returned in DriverName.\r
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
+ EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - Language is NULL.\r
+ EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+ EFI_UNSUPPORTED - The driver specified by This is not currently \r
+ managing the controller specified by \r
+ ControllerHandle and ChildHandle.\r
+ EFI_UNSUPPORTED - The driver specified by This does not support the \r
+ language specified by Language.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;\r
+ //\r
+ // here ChildHandle is not an Optional parameter.\r
+ //\r
+ if (ChildHandle == NULL) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiSimpleTextInProtocolGuid,\r
+ (VOID **) &TextIn,\r
+ NULL,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ return LookupUnicodeString (\r
+ Language,\r
+ gConSplitterConInComponentName.SupportedLanguages,\r
+ mConSplitterConInControllerNameTable,\r
+ ControllerName\r
+ );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterSimplePointerComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Retrieves a Unicode string that is the user readable name of the controller\r
+ that is being managed by an EFI Driver.\r
+\r
+ Arguments:\r
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ ControllerHandle - The handle of a controller that the driver specified by \r
+ This is managing. This handle specifies the controller \r
+ whose name is to be returned.\r
+ ChildHandle - The handle of the child controller to retrieve the name \r
+ of. This is an optional parameter that may be NULL. It \r
+ will be NULL for device drivers. It will also be NULL \r
+ for a bus drivers that wish to retrieve the name of the \r
+ bus controller. It will not be NULL for a bus driver \r
+ that wishes to retrieve the name of a child controller.\r
+ Language - A pointer to a three character ISO 639-2 language \r
+ identifier. This is the language of the controller name \r
+ that that the caller is requesting, and it must match one\r
+ of the languages specified in SupportedLanguages. The \r
+ number of languages supported by a driver is up to the \r
+ driver writer.\r
+ ControllerName - A pointer to the Unicode string to return. This Unicode\r
+ string is the name of the controller specified by \r
+ ControllerHandle and ChildHandle in the language \r
+ specified by Language from the point of view of the \r
+ driver specified by This. \r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Unicode string for the user readable name in the\r
+ language specified by Language for the driver \r
+ specified by This was returned in DriverName.\r
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
+ EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - Language is NULL.\r
+ EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+ EFI_UNSUPPORTED - The driver specified by This is not currently \r
+ managing the controller specified by \r
+ ControllerHandle and ChildHandle.\r
+ EFI_UNSUPPORTED - The driver specified by This does not support the \r
+ language specified by Language.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer;\r
+ //\r
+ // here ChildHandle is not an Optional parameter.\r
+ //\r
+ if (ChildHandle == NULL) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiSimplePointerProtocolGuid,\r
+ (VOID **) &SimplePointer,\r
+ NULL,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ return LookupUnicodeString (\r
+ Language,\r
+ gConSplitterSimplePointerComponentName.SupportedLanguages,\r
+ mConSplitterSimplePointerControllerNameTable,\r
+ ControllerName\r
+ );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterConOutComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Retrieves a Unicode string that is the user readable name of the controller\r
+ that is being managed by an EFI Driver.\r
+\r
+ Arguments:\r
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ ControllerHandle - The handle of a controller that the driver specified by \r
+ This is managing. This handle specifies the controller \r
+ whose name is to be returned.\r
+ ChildHandle - The handle of the child controller to retrieve the name \r
+ of. This is an optional parameter that may be NULL. It \r
+ will be NULL for device drivers. It will also be NULL \r
+ for a bus drivers that wish to retrieve the name of the \r
+ bus controller. It will not be NULL for a bus driver \r
+ that wishes to retrieve the name of a child controller.\r
+ Language - A pointer to a three character ISO 639-2 language \r
+ identifier. This is the language of the controller name \r
+ that that the caller is requesting, and it must match one\r
+ of the languages specified in SupportedLanguages. The \r
+ number of languages supported by a driver is up to the \r
+ driver writer.\r
+ ControllerName - A pointer to the Unicode string to return. This Unicode\r
+ string is the name of the controller specified by \r
+ ControllerHandle and ChildHandle in the language \r
+ specified by Language from the point of view of the \r
+ driver specified by This. \r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Unicode string for the user readable name in the\r
+ language specified by Language for the driver \r
+ specified by This was returned in DriverName.\r
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
+ EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - Language is NULL.\r
+ EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+ EFI_UNSUPPORTED - The driver specified by This is not currently \r
+ managing the controller specified by \r
+ ControllerHandle and ChildHandle.\r
+ EFI_UNSUPPORTED - The driver specified by This does not support the \r
+ language specified by Language.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r
+ //\r
+ // here ChildHandle is not an Optional parameter.\r
+ //\r
+ if (ChildHandle == NULL) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ (VOID **) &TextOut,\r
+ NULL,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ return LookupUnicodeString (\r
+ Language,\r
+ gConSplitterConOutComponentName.SupportedLanguages,\r
+ mConSplitterConOutControllerNameTable,\r
+ ControllerName\r
+ );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterStdErrComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Retrieves a Unicode string that is the user readable name of the controller\r
+ that is being managed by an EFI Driver.\r
+\r
+ Arguments:\r
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ ControllerHandle - The handle of a controller that the driver specified by \r
+ This is managing. This handle specifies the controller \r
+ whose name is to be returned.\r
+ ChildHandle - The handle of the child controller to retrieve the name \r
+ of. This is an optional parameter that may be NULL. It \r
+ will be NULL for device drivers. It will also be NULL \r
+ for a bus drivers that wish to retrieve the name of the \r
+ bus controller. It will not be NULL for a bus driver \r
+ that wishes to retrieve the name of a child controller.\r
+ Language - A pointer to a three character ISO 639-2 language \r
+ identifier. This is the language of the controller name \r
+ that that the caller is requesting, and it must match one\r
+ of the languages specified in SupportedLanguages. The \r
+ number of languages supported by a driver is up to the \r
+ driver writer.\r
+ ControllerName - A pointer to the Unicode string to return. This Unicode\r
+ string is the name of the controller specified by \r
+ ControllerHandle and ChildHandle in the language \r
+ specified by Language from the point of view of the \r
+ driver specified by This. \r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Unicode string for the user readable name in the\r
+ language specified by Language for the driver \r
+ specified by This was returned in DriverName.\r
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
+ EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - Language is NULL.\r
+ EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+ EFI_UNSUPPORTED - The driver specified by This is not currently \r
+ managing the controller specified by \r
+ ControllerHandle and ChildHandle.\r
+ EFI_UNSUPPORTED - The driver specified by This does not support the \r
+ language specified by Language.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ErrOut;\r
+ //\r
+ // here ChildHandle is not an Optional parameter.\r
+ //\r
+ if (ChildHandle == NULL) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ (VOID **) &ErrOut,\r
+ NULL,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ return LookupUnicodeString (\r
+ Language,\r
+ gConSplitterStdErrComponentName.SupportedLanguages,\r
+ mConSplitterStdErrControllerNameTable,\r
+ ControllerName\r
+ );\r
+}\r
--- /dev/null
+/**@file\r
+ Console Splitter Driver. Any Handle that attatched\r
+ EFI_CONSOLE_IDENTIFIER_PROTOCOL can be bound by this driver.\r
+\r
+ So far it works like any other driver by opening a SimpleTextIn and/or\r
+ SimpleTextOut protocol with EFI_OPEN_PROTOCOL_BY_DRIVER attributes. The big\r
+ difference is this driver does not layer a protocol on the passed in\r
+ handle, or construct a child handle like a standard device or bus driver.\r
+ This driver produces three virtual handles as children, one for console input\r
+ splitter, one for console output splitter and one for error output splitter.\r
+ EFI_CONSOLE_SPLIT_PROTOCOL will be attatched onto each virtual handle to\r
+ identify the splitter type.\r
+\r
+ Each virtual handle, that supports both the EFI_CONSOLE_SPLIT_PROTOCOL\r
+ and Console I/O protocol, will be produced in the driver entry point.\r
+ The virtual handle are added on driver entry and never removed.\r
+ Such design ensures sytem function well during none console device situation.\r
+\r
+Copyright (c) 2006 - 2007 Intel Corporation. <BR>\r
+All rights reserved. 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
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "ConSplitter.h"\r
+\r
+//\r
+// Global Variables\r
+//\r
+STATIC TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = {\r
+ TEXT_IN_SPLITTER_PRIVATE_DATA_SIGNATURE,\r
+ (EFI_HANDLE) NULL,\r
+ {\r
+ ConSplitterTextInReset,\r
+ ConSplitterTextInReadKeyStroke,\r
+ (EFI_EVENT) NULL\r
+ },\r
+ 0,\r
+ (EFI_SIMPLE_TEXT_INPUT_PROTOCOL **) NULL,\r
+ 0,\r
+\r
+ {\r
+ ConSplitterSimplePointerReset,\r
+ ConSplitterSimplePointerGetState,\r
+ (EFI_EVENT) NULL,\r
+ (EFI_SIMPLE_POINTER_MODE *) NULL\r
+ },\r
+ {\r
+ 0x10000,\r
+ 0x10000,\r
+ 0x10000,\r
+ TRUE,\r
+ TRUE\r
+ },\r
+ 0,\r
+ (EFI_SIMPLE_POINTER_PROTOCOL **) NULL,\r
+ 0,\r
+\r
+ FALSE,\r
+ {\r
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\r
+ },\r
+ 0,\r
+ {\r
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\r
+ },\r
+ (EFI_EVENT) NULL,\r
+\r
+ FALSE,\r
+ FALSE\r
+};\r
+\r
+STATIC TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut = {\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE,\r
+ (EFI_HANDLE) NULL,\r
+ {\r
+ ConSplitterTextOutReset,\r
+ ConSplitterTextOutOutputString,\r
+ ConSplitterTextOutTestString,\r
+ ConSplitterTextOutQueryMode,\r
+ ConSplitterTextOutSetMode,\r
+ ConSplitterTextOutSetAttribute,\r
+ ConSplitterTextOutClearScreen,\r
+ ConSplitterTextOutSetCursorPosition,\r
+ ConSplitterTextOutEnableCursor,\r
+ (EFI_SIMPLE_TEXT_OUTPUT_MODE *) NULL\r
+ },\r
+ {\r
+ 1,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ FALSE,\r
+ },\r
+ {\r
+ ConSpliterGraphicsOutputQueryMode,\r
+ ConSpliterGraphicsOutputSetMode,\r
+ ConSpliterGraphicsOutputBlt,\r
+ NULL\r
+ },\r
+ (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL,\r
+ (TEXT_OUT_GOP_MODE *) NULL,\r
+ 0,\r
+ TRUE,\r
+ {\r
+ ConSpliterConsoleControlGetMode,\r
+ ConSpliterConsoleControlSetMode,\r
+ ConSpliterConsoleControlLockStdIn\r
+ },\r
+\r
+ 0,\r
+ (TEXT_OUT_AND_GOP_DATA *) NULL,\r
+ 0,\r
+ (TEXT_OUT_SPLITTER_QUERY_DATA *) NULL,\r
+ 0,\r
+ (INT32 *) NULL,\r
+\r
+ EfiConsoleControlScreenText,\r
+ 0,\r
+ 0,\r
+ (CHAR16 *) NULL,\r
+ (INT32 *) NULL\r
+};\r
+\r
+STATIC TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr = {\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE,\r
+ (EFI_HANDLE) NULL,\r
+ {\r
+ ConSplitterTextOutReset,\r
+ ConSplitterTextOutOutputString,\r
+ ConSplitterTextOutTestString,\r
+ ConSplitterTextOutQueryMode,\r
+ ConSplitterTextOutSetMode,\r
+ ConSplitterTextOutSetAttribute,\r
+ ConSplitterTextOutClearScreen,\r
+ ConSplitterTextOutSetCursorPosition,\r
+ ConSplitterTextOutEnableCursor,\r
+ (EFI_SIMPLE_TEXT_OUTPUT_MODE *) NULL\r
+ },\r
+ {\r
+ 1,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ FALSE,\r
+ },\r
+ {\r
+ ConSpliterGraphicsOutputQueryMode,\r
+ ConSpliterGraphicsOutputSetMode,\r
+ ConSpliterGraphicsOutputBlt,\r
+ NULL\r
+ },\r
+ (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL,\r
+ (TEXT_OUT_GOP_MODE *) NULL,\r
+ 0,\r
+ TRUE,\r
+ {\r
+ ConSpliterConsoleControlGetMode,\r
+ ConSpliterConsoleControlSetMode,\r
+ ConSpliterConsoleControlLockStdIn\r
+ },\r
+\r
+ 0,\r
+ (TEXT_OUT_AND_GOP_DATA *) NULL,\r
+ 0,\r
+ (TEXT_OUT_SPLITTER_QUERY_DATA *) NULL,\r
+ 0,\r
+ (INT32 *) NULL,\r
+\r
+ EfiConsoleControlScreenText,\r
+ 0,\r
+ 0,\r
+ (CHAR16 *) NULL,\r
+ (INT32 *) NULL\r
+};\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding = {\r
+ ConSplitterConInDriverBindingSupported,\r
+ ConSplitterConInDriverBindingStart,\r
+ ConSplitterConInDriverBindingStop,\r
+ 0xa,\r
+ NULL,\r
+ NULL\r
+};\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding = {\r
+ ConSplitterSimplePointerDriverBindingSupported,\r
+ ConSplitterSimplePointerDriverBindingStart,\r
+ ConSplitterSimplePointerDriverBindingStop,\r
+ 0xa,\r
+ NULL,\r
+ NULL\r
+};\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding = {\r
+ ConSplitterConOutDriverBindingSupported,\r
+ ConSplitterConOutDriverBindingStart,\r
+ ConSplitterConOutDriverBindingStop,\r
+ 0xa,\r
+ NULL,\r
+ NULL\r
+};\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding = {\r
+ ConSplitterStdErrDriverBindingSupported,\r
+ ConSplitterStdErrDriverBindingStart,\r
+ ConSplitterStdErrDriverBindingStop,\r
+ 0xa,\r
+ NULL,\r
+ NULL\r
+};\r
+\r
+/**\r
+ The user Entry Point for module ConSplitter. 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
+InitializeConSplitter(\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
+ &gConSplitterConInDriverBinding,\r
+ ImageHandle,\r
+ &gConSplitterConInComponentName,\r
+ NULL,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = EfiLibInstallAllDriverProtocols (\r
+ ImageHandle,\r
+ SystemTable,\r
+ &gConSplitterSimplePointerDriverBinding,\r
+ NULL,\r
+ &gConSplitterSimplePointerComponentName,\r
+ NULL,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = EfiLibInstallAllDriverProtocols (\r
+ ImageHandle,\r
+ SystemTable,\r
+ &gConSplitterConOutDriverBinding,\r
+ NULL,\r
+ &gConSplitterConOutComponentName,\r
+ NULL,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = EfiLibInstallAllDriverProtocols (\r
+ ImageHandle,\r
+ SystemTable,\r
+ &gConSplitterStdErrDriverBinding,\r
+ NULL,\r
+ &gConSplitterStdErrComponentName,\r
+ NULL,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+\r
+ //\r
+ // Call the original Entry Point\r
+ //\r
+ Status = ConSplitterDriverEntry (ImageHandle, SystemTable);\r
+\r
+ return Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterDriverEntry (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Intialize a virtual console device to act as an agrigator of physical console\r
+ devices.\r
+\r
+Arguments:\r
+ ImageHandle - (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
+ SystemTable - (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
+Returns:\r
+ EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // The driver creates virtual handles for ConIn, ConOut, and StdErr.\r
+ // The virtual handles will always exist even if no console exist in the\r
+ // system. This is need to support hotplug devices like USB.\r
+ //\r
+ //\r
+ // Create virtual device handle for StdErr Splitter\r
+ //\r
+ Status = ConSplitterTextOutConstructor (&mStdErr);\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &mStdErr.VirtualHandle,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ &mStdErr.TextOut,\r
+ &gEfiPrimaryStandardErrorDeviceGuid,\r
+ NULL,\r
+ NULL\r
+ );\r
+ }\r
+ //\r
+ // Create virtual device handle for ConIn Splitter\r
+ //\r
+ Status = ConSplitterTextInConstructor (&mConIn);\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &mConIn.VirtualHandle,\r
+ &gEfiSimpleTextInProtocolGuid,\r
+ &mConIn.TextIn,\r
+ &gEfiSimplePointerProtocolGuid,\r
+ &mConIn.SimplePointer,\r
+ &gEfiPrimaryConsoleInDeviceGuid,\r
+ NULL,\r
+ NULL\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Update the EFI System Table with new virtual console\r
+ //\r
+ gST->ConsoleInHandle = mConIn.VirtualHandle;\r
+ gST->ConIn = &mConIn.TextIn;\r
+ }\r
+ }\r
+ //\r
+ // Create virtual device handle for ConOut Splitter\r
+ //\r
+ Status = ConSplitterTextOutConstructor (&mConOut);\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // In UEFI mode, Graphics Output Protocol is installed on virtual handle.\r
+ //\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &mConOut.VirtualHandle,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ &mConOut.TextOut,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ &mConOut.GraphicsOutput,\r
+ &gEfiConsoleControlProtocolGuid,\r
+ &mConOut.ConsoleControl,\r
+ &gEfiPrimaryConsoleOutDeviceGuid,\r
+ NULL,\r
+ NULL\r
+ );\r
+\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Update the EFI System Table with new virtual console\r
+ //\r
+ gST->ConsoleOutHandle = mConOut.VirtualHandle;\r
+ gST->ConOut = &mConOut.TextOut;\r
+ }\r
+\r
+ }\r
+ //\r
+ // Update the CRC32 in the EFI System Table header\r
+ //\r
+ gST->Hdr.CRC32 = 0;\r
+ gBS->CalculateCrc32 (\r
+ (UINT8 *) &gST->Hdr,\r
+ gST->Hdr.HeaderSize,\r
+ &gST->Hdr.CRC32\r
+ );\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+ConSplitterTextInConstructor (\r
+ TEXT_IN_SPLITTER_PRIVATE_DATA *ConInPrivate\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Construct the ConSplitter.\r
+\r
+Arguments:\r
+\r
+ ConInPrivate - A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA structure.\r
+\r
+Returns:\r
+ EFI_OUT_OF_RESOURCES - Out of resources.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Initilize console input splitter's private data.\r
+ //\r
+ Status = ConSplitterGrowBuffer (\r
+ sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL *),\r
+ &ConInPrivate->TextInListCount,\r
+ (VOID **) &ConInPrivate->TextInList\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ //\r
+ // Create Event to support locking StdIn Device\r
+ //\r
+ Status = gBS->CreateEvent (\r
+ EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
+ TPL_CALLBACK,\r
+ ConSpliterConsoleControlLockStdInEvent,\r
+ NULL,\r
+ &ConInPrivate->LockEvent\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = gBS->CreateEvent (\r
+ EVT_NOTIFY_WAIT,\r
+ TPL_NOTIFY,\r
+ ConSplitterTextInWaitForKey,\r
+ ConInPrivate,\r
+ &ConInPrivate->TextIn.WaitForKey\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ ConInPrivate->SimplePointer.Mode = &ConInPrivate->SimplePointerMode;\r
+\r
+ Status = ConSplitterGrowBuffer (\r
+ sizeof (EFI_SIMPLE_POINTER_PROTOCOL *),\r
+ &ConInPrivate->PointerListCount,\r
+ (VOID **) &ConInPrivate->PointerList\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ Status = gBS->CreateEvent (\r
+ EVT_NOTIFY_WAIT,\r
+ TPL_NOTIFY,\r
+ ConSplitterSimplePointerWaitForInput,\r
+ ConInPrivate,\r
+ &ConInPrivate->SimplePointer.WaitForInput\r
+ );\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+ConSplitterTextOutConstructor (\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA *ConOutPrivate\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Initilize console output splitter's private data.\r
+ //\r
+ ConOutPrivate->TextOut.Mode = &ConOutPrivate->TextOutMode;\r
+\r
+ Status = ConSplitterGrowBuffer (\r
+ sizeof (TEXT_OUT_AND_GOP_DATA),\r
+ &ConOutPrivate->TextOutListCount,\r
+ (VOID **) &ConOutPrivate->TextOutList\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ Status = ConSplitterGrowBuffer (\r
+ sizeof (TEXT_OUT_SPLITTER_QUERY_DATA),\r
+ &ConOutPrivate->TextOutQueryDataCount,\r
+ (VOID **) &ConOutPrivate->TextOutQueryData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ //\r
+ // Setup the DevNullTextOut console to 80 x 25\r
+ //\r
+ ConOutPrivate->TextOutQueryData[0].Columns = 80;\r
+ ConOutPrivate->TextOutQueryData[0].Rows = 25;\r
+ DevNullTextOutSetMode (ConOutPrivate, 0);\r
+\r
+ //\r
+ // Setup resource for mode information in Graphics Output Protocol interface\r
+ //\r
+ if ((ConOutPrivate->GraphicsOutput.Mode = AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE))) == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ if ((ConOutPrivate->GraphicsOutput.Mode->Info = AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION))) == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ //\r
+ // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel\r
+ //\r
+ if ((ConOutPrivate->GraphicsOutputModeBuffer = AllocateZeroPool (sizeof (TEXT_OUT_GOP_MODE))) == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ ConOutPrivate->GraphicsOutputModeBuffer[0].HorizontalResolution = 800;\r
+ ConOutPrivate->GraphicsOutputModeBuffer[0].VerticalResolution = 600;\r
+\r
+ //\r
+ // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()\r
+ // GraphicsOutputMode->Info->Version, GraphicsOutputMode->Info->PixelFormat\r
+ // GraphicsOutputMode->SizeOfInfo, GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize\r
+ //\r
+ ConOutPrivate->GraphicsOutput.Mode->Info->Version = 0;\r
+ ConOutPrivate->GraphicsOutput.Mode->Info->PixelFormat = PixelBltOnly;\r
+ ConOutPrivate->GraphicsOutput.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r
+ ConOutPrivate->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) NULL;\r
+ ConOutPrivate->GraphicsOutput.Mode->FrameBufferSize = 0;\r
+\r
+ ConOutPrivate->GraphicsOutput.Mode->MaxMode = 1;\r
+ //\r
+ // Initial current mode to unknow state, and then set to mode 0\r
+ //\r
+ ConOutPrivate->GraphicsOutput.Mode->Mode = 0xffff;\r
+ ConOutPrivate->GraphicsOutput.SetMode (&ConOutPrivate->GraphicsOutput, 0);\r
+\r
+ return Status;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+ConSplitterSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_GUID *Guid\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Generic Supported Check\r
+\r
+Arguments:\r
+ This - Pointer to protocol.\r
+ ControllerHandle - Controller Handle.\r
+ Guid - Guid.\r
+\r
+Returns:\r
+\r
+ EFI_UNSUPPORTED - unsupported.\r
+ EFI_SUCCESS - operation is OK.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ VOID *Instance;\r
+\r
+ //\r
+ // Make sure the Console Splitter does not attempt to attach to itself\r
+ //\r
+ if (ControllerHandle == mConIn.VirtualHandle) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ if (ControllerHandle == mConOut.VirtualHandle) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ if (ControllerHandle == mStdErr.VirtualHandle) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+ //\r
+ // Check to see whether the handle has the ConsoleInDevice GUID on it\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ Guid,\r
+ &Instance,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ gBS->CloseProtocol (\r
+ ControllerHandle,\r
+ Guid,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle\r
+ );\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterConInDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Console In Supported Check\r
+\r
+Arguments:\r
+ This - Pointer to protocol.\r
+ ControllerHandle - Controller handle.\r
+ RemainingDevicePath - Remaining device path.\r
+\r
+Returns:\r
+\r
+ EFI_STATUS\r
+\r
+--*/\r
+{\r
+ return ConSplitterSupported (\r
+ This,\r
+ ControllerHandle,\r
+ &gEfiConsoleInDeviceGuid\r
+ );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterSimplePointerDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Standard Error Supported Check\r
+\r
+Arguments:\r
+ This - Pointer to protocol.\r
+ ControllerHandle - Controller handle.\r
+ RemainingDevicePath - Remaining device path.\r
+\r
+Returns:\r
+\r
+ EFI_STATUS\r
+\r
+--*/\r
+{\r
+ return ConSplitterSupported (\r
+ This,\r
+ ControllerHandle,\r
+ &gEfiSimplePointerProtocolGuid\r
+ );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterConOutDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Console Out Supported Check\r
+\r
+Arguments:\r
+ This - Pointer to protocol.\r
+ ControllerHandle - Controller handle.\r
+ RemainingDevicePath - Remaining device path.\r
+\r
+Returns:\r
+\r
+ EFI_STATUS\r
+\r
+--*/\r
+{\r
+ return ConSplitterSupported (\r
+ This,\r
+ ControllerHandle,\r
+ &gEfiConsoleOutDeviceGuid\r
+ );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterStdErrDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Standard Error Supported Check\r
+\r
+Arguments:\r
+ This - Pointer to protocol.\r
+ ControllerHandle - Controller handle.\r
+ RemainingDevicePath - Remaining device path.\r
+\r
+Returns:\r
+\r
+ EFI_STATUS\r
+\r
+--*/\r
+{\r
+ return ConSplitterSupported (\r
+ This,\r
+ ControllerHandle,\r
+ &gEfiStandardErrorDeviceGuid\r
+ );\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ConSplitterVirtualHandle,\r
+ IN EFI_GUID *DeviceGuid,\r
+ IN EFI_GUID *InterfaceGuid,\r
+ IN VOID **Interface\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Start ConSplitter on ControllerHandle, and create the virtual\r
+ agrogated console device on first call Start for a SimpleTextIn handle.\r
+\r
+Arguments:\r
+ (Standard DriverBinding Protocol Start() function)\r
+\r
+Returns:\r
+ EFI_ERROR if a SimpleTextIn protocol is not started.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ VOID *Instance;\r
+\r
+ //\r
+ // Check to see whether the handle has the ConsoleInDevice GUID on it\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ DeviceGuid,\r
+ &Instance,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ DeviceGuid,\r
+ &Instance,\r
+ This->DriverBindingHandle,\r
+ ConSplitterVirtualHandle,\r
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ return gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ InterfaceGuid,\r
+ Interface,\r
+ This->DriverBindingHandle,\r
+ ConSplitterVirtualHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterConInDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Start ConSplitter on ControllerHandle, and create the virtual\r
+ agrogated console device on first call Start for a SimpleTextIn handle.\r
+\r
+Arguments:\r
+ This - Pointer to protocol.\r
+ ControllerHandle - Controller handle.\r
+ RemainingDevicePath - Remaining device path.\r
+\r
+Returns:\r
+\r
+ EFI_STATUS\r
+ EFI_ERROR if a SimpleTextIn protocol is not started.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;\r
+\r
+ //\r
+ // Start ConSplitter on ControllerHandle, and create the virtual\r
+ // agrogated console device on first call Start for a SimpleTextIn handle.\r
+ //\r
+ Status = ConSplitterStart (\r
+ This,\r
+ ControllerHandle,\r
+ mConIn.VirtualHandle,\r
+ &gEfiConsoleInDeviceGuid,\r
+ &gEfiSimpleTextInProtocolGuid,\r
+ (VOID **) &TextIn\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ return ConSplitterTextInAddDevice (&mConIn, TextIn);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterSimplePointerDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Start ConSplitter on ControllerHandle, and create the virtual\r
+ agrogated console device on first call Start for a SimpleTextIn handle.\r
+\r
+Arguments:\r
+ This - Pointer to protocol.\r
+ ControllerHandle - Controller handle.\r
+ RemainingDevicePath - Remaining device path.\r
+\r
+Returns:\r
+\r
+ EFI_ERROR if a SimpleTextIn protocol is not started.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer;\r
+\r
+ Status = ConSplitterStart (\r
+ This,\r
+ ControllerHandle,\r
+ mConIn.VirtualHandle,\r
+ &gEfiSimplePointerProtocolGuid,\r
+ &gEfiSimplePointerProtocolGuid,\r
+ (VOID **) &SimplePointer\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ return ConSplitterSimplePointerAddDevice (&mConIn, SimplePointer);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterConOutDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Start ConSplitter on ControllerHandle, and create the virtual\r
+ agrogated console device on first call Start for a SimpleTextIn handle.\r
+\r
+Arguments:\r
+ This - Pointer to protocol.\r
+ ControllerHandle - Controller handle.\r
+ RemainingDevicePath - Remaining device path.\r
+\r
+Returns:\r
+ EFI_ERROR if a SimpleTextIn protocol is not started.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+\r
+ Status = ConSplitterStart (\r
+ This,\r
+ ControllerHandle,\r
+ mConOut.VirtualHandle,\r
+ &gEfiConsoleOutDeviceGuid,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ (VOID **) &TextOut\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Try to Open Graphics Output protocol\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ (VOID **) &GraphicsOutput,\r
+ This->DriverBindingHandle,\r
+ mConOut.VirtualHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ GraphicsOutput = NULL;\r
+ }\r
+ //\r
+ // Open UGA_DRAW protocol\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiUgaDrawProtocolGuid,\r
+ (VOID **) &UgaDraw,\r
+ This->DriverBindingHandle,\r
+ mConOut.VirtualHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ UgaDraw = NULL;\r
+ }\r
+ //\r
+ // If both ConOut and StdErr incorporate the same Text Out device,\r
+ // their MaxMode and QueryData should be the intersection of both.\r
+ //\r
+ Status = ConSplitterTextOutAddDevice (&mConOut, TextOut, GraphicsOutput, UgaDraw);\r
+ ConSplitterTextOutSetAttribute (&mConOut.TextOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterStdErrDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Start ConSplitter on ControllerHandle, and create the virtual\r
+ agrogated console device on first call Start for a SimpleTextIn handle.\r
+\r
+Arguments:\r
+ This - Pointer to protocol.\r
+ ControllerHandle - Controller handle.\r
+ RemainingDevicePath - Remaining device path.\r
+\r
+Returns:\r
+ EFI_ERROR if a SimpleTextIn protocol is not started.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r
+\r
+ Status = ConSplitterStart (\r
+ This,\r
+ ControllerHandle,\r
+ mStdErr.VirtualHandle,\r
+ &gEfiStandardErrorDeviceGuid,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ (VOID **) &TextOut\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // If both ConOut and StdErr incorporate the same Text Out device,\r
+ // their MaxMode and QueryData should be the intersection of both.\r
+ //\r
+ Status = ConSplitterTextOutAddDevice (&mStdErr, TextOut, NULL, NULL);\r
+ ConSplitterTextOutSetAttribute (&mStdErr.TextOut, EFI_TEXT_ATTR (EFI_MAGENTA, EFI_BLACK));\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ if (mStdErr.CurrentNumberOfConsoles == 1) {\r
+ gST->StandardErrorHandle = mStdErr.VirtualHandle;\r
+ gST->StdErr = &mStdErr.TextOut;\r
+ //\r
+ // Update the CRC32 in the EFI System Table header\r
+ //\r
+ gST->Hdr.CRC32 = 0;\r
+ gBS->CalculateCrc32 (\r
+ (UINT8 *) &gST->Hdr,\r
+ gST->Hdr.HeaderSize,\r
+ &gST->Hdr.CRC32\r
+ );\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ConSplitterVirtualHandle,\r
+ IN EFI_GUID *DeviceGuid,\r
+ IN EFI_GUID *InterfaceGuid,\r
+ IN VOID **Interface\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+ (Standard DriverBinding Protocol Stop() function)\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ InterfaceGuid,\r
+ Interface,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // close the protocol refered.\r
+ //\r
+ gBS->CloseProtocol (\r
+ ControllerHandle,\r
+ DeviceGuid,\r
+ This->DriverBindingHandle,\r
+ ConSplitterVirtualHandle\r
+ );\r
+ gBS->CloseProtocol (\r
+ ControllerHandle,\r
+ DeviceGuid,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle\r
+ );\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterConInDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+ (Standard DriverBinding Protocol Stop() function)\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;\r
+\r
+ if (NumberOfChildren == 0) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ Status = ConSplitterStop (\r
+ This,\r
+ ControllerHandle,\r
+ mConIn.VirtualHandle,\r
+ &gEfiConsoleInDeviceGuid,\r
+ &gEfiSimpleTextInProtocolGuid,\r
+ (VOID **) &TextIn\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Delete this console input device's data structures.\r
+ //\r
+ return ConSplitterTextInDeleteDevice (&mConIn, TextIn);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterSimplePointerDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+ (Standard DriverBinding Protocol Stop() function)\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer;\r
+\r
+ if (NumberOfChildren == 0) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ Status = ConSplitterStop (\r
+ This,\r
+ ControllerHandle,\r
+ mConIn.VirtualHandle,\r
+ &gEfiSimplePointerProtocolGuid,\r
+ &gEfiSimplePointerProtocolGuid,\r
+ (VOID **) &SimplePointer\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Delete this console input device's data structures.\r
+ //\r
+ return ConSplitterSimplePointerDeleteDevice (&mConIn, SimplePointer);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterConOutDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+ (Standard DriverBinding Protocol Stop() function)\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r
+\r
+ if (NumberOfChildren == 0) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ Status = ConSplitterStop (\r
+ This,\r
+ ControllerHandle,\r
+ mConOut.VirtualHandle,\r
+ &gEfiConsoleOutDeviceGuid,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ (VOID **) &TextOut\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Delete this console output device's data structures.\r
+ //\r
+ return ConSplitterTextOutDeleteDevice (&mConOut, TextOut);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterStdErrDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+ (Standard DriverBinding Protocol Stop() function)\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - Complete successfully.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r
+\r
+ if (NumberOfChildren == 0) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ Status = ConSplitterStop (\r
+ This,\r
+ ControllerHandle,\r
+ mStdErr.VirtualHandle,\r
+ &gEfiStandardErrorDeviceGuid,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ (VOID **) &TextOut\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Delete this console error out device's data structures.\r
+ //\r
+ Status = ConSplitterTextOutDeleteDevice (&mStdErr, TextOut);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ if (mStdErr.CurrentNumberOfConsoles == 0) {\r
+ gST->StandardErrorHandle = NULL;\r
+ gST->StdErr = NULL;\r
+ //\r
+ // Update the CRC32 in the EFI System Table header\r
+ //\r
+ gST->Hdr.CRC32 = 0;\r
+ gBS->CalculateCrc32 (\r
+ (UINT8 *) &gST->Hdr,\r
+ gST->Hdr.HeaderSize,\r
+ &gST->Hdr.CRC32\r
+ );\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+ConSplitterGrowBuffer (\r
+ IN UINTN SizeOfCount,\r
+ IN UINTN *Count,\r
+ IN OUT VOID **Buffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Take the passed in Buffer of size SizeOfCount and grow the buffer\r
+ by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount\r
+ bytes. Copy the current data in Buffer to the new version of Buffer\r
+ and free the old version of buffer.\r
+\r
+\r
+Arguments:\r
+ SizeOfCount - Size of element in array\r
+ Count - Current number of elements in array\r
+ Buffer - Bigger version of passed in Buffer with all the data\r
+\r
+Returns:\r
+ EFI_SUCCESS - Buffer size has grown\r
+ EFI_OUT_OF_RESOURCES - Could not grow the buffer size\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ UINTN NewSize;\r
+ UINTN OldSize;\r
+ VOID *Ptr;\r
+\r
+ //\r
+ // grow the buffer to new buffer size,\r
+ // copy the old buffer's content to the new-size buffer,\r
+ // then free the old buffer.\r
+ //\r
+ OldSize = *Count * SizeOfCount;\r
+ *Count += CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT;\r
+ NewSize = *Count * SizeOfCount;\r
+\r
+ Ptr = AllocateZeroPool (NewSize);\r
+ if (Ptr == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ CopyMem (Ptr, *Buffer, OldSize);\r
+\r
+ if (*Buffer != NULL) {\r
+ FreePool (*Buffer);\r
+ }\r
+\r
+ *Buffer = Ptr;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+ConSplitterTextInAddDevice (\r
+ IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS\r
+ EFI_OUT_OF_RESOURCES\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // If the Text In List is full, enlarge it by calling growbuffer().\r
+ //\r
+ if (Private->CurrentNumberOfConsoles >= Private->TextInListCount) {\r
+ Status = ConSplitterGrowBuffer (\r
+ sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL *),\r
+ &Private->TextInListCount,\r
+ (VOID **) &Private->TextInList\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ }\r
+ //\r
+ // Add the new text-in device data structure into the Text In List.\r
+ //\r
+ Private->TextInList[Private->CurrentNumberOfConsoles] = TextIn;\r
+ Private->CurrentNumberOfConsoles++;\r
+\r
+ //\r
+ // Extra CheckEvent added to reduce the double CheckEvent() in UI.c\r
+ //\r
+ gBS->CheckEvent (TextIn->WaitForKey);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+ConSplitterTextInDeleteDevice (\r
+ IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS\r
+ EFI_NOT_FOUND\r
+\r
+--*/\r
+{\r
+ UINTN Index;\r
+ //\r
+ // Remove the specified text-in device data structure from the Text In List,\r
+ // and rearrange the remaining data structures in the Text In List.\r
+ //\r
+ for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r
+ if (Private->TextInList[Index] == TextIn) {\r
+ for (Index = Index; Index < Private->CurrentNumberOfConsoles - 1; Index++) {\r
+ Private->TextInList[Index] = Private->TextInList[Index + 1];\r
+ }\r
+\r
+ Private->CurrentNumberOfConsoles--;\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+\r
+ return EFI_NOT_FOUND;\r
+}\r
+\r
+EFI_STATUS\r
+ConSplitterSimplePointerAddDevice (\r
+ IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+ EFI_OUT_OF_RESOURCES\r
+ EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // If the Text In List is full, enlarge it by calling growbuffer().\r
+ //\r
+ if (Private->CurrentNumberOfPointers >= Private->PointerListCount) {\r
+ Status = ConSplitterGrowBuffer (\r
+ sizeof (EFI_SIMPLE_POINTER_PROTOCOL *),\r
+ &Private->PointerListCount,\r
+ (VOID **) &Private->PointerList\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ }\r
+ //\r
+ // Add the new text-in device data structure into the Text In List.\r
+ //\r
+ Private->PointerList[Private->CurrentNumberOfPointers] = SimplePointer;\r
+ Private->CurrentNumberOfPointers++;\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+ConSplitterSimplePointerDeleteDevice (\r
+ IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ UINTN Index;\r
+ //\r
+ // Remove the specified text-in device data structure from the Text In List,\r
+ // and rearrange the remaining data structures in the Text In List.\r
+ //\r
+ for (Index = 0; Index < Private->CurrentNumberOfPointers; Index++) {\r
+ if (Private->PointerList[Index] == SimplePointer) {\r
+ for (Index = Index; Index < Private->CurrentNumberOfPointers - 1; Index++) {\r
+ Private->PointerList[Index] = Private->PointerList[Index + 1];\r
+ }\r
+\r
+ Private->CurrentNumberOfPointers--;\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+\r
+ return EFI_NOT_FOUND;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+ConSplitterGrowMapTable (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ UINTN Size;\r
+ UINTN NewSize;\r
+ UINTN TotalSize;\r
+ INT32 *TextOutModeMap;\r
+ INT32 *OldTextOutModeMap;\r
+ INT32 *SrcAddress;\r
+ INT32 Index;\r
+\r
+ NewSize = Private->TextOutListCount * sizeof (INT32);\r
+ OldTextOutModeMap = Private->TextOutModeMap;\r
+ TotalSize = NewSize * Private->TextOutQueryDataCount;\r
+\r
+ TextOutModeMap = AllocateZeroPool (TotalSize);\r
+ if (TextOutModeMap == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ SetMem (TextOutModeMap, TotalSize, 0xFF);\r
+ Private->TextOutModeMap = TextOutModeMap;\r
+\r
+ //\r
+ // If TextOutList has been enlarged, need to realloc the mode map table\r
+ // The mode map table is regarded as a two dimension array.\r
+ //\r
+ // Old New\r
+ // 0 ---------> TextOutListCount ----> TextOutListCount\r
+ // | -------------------------------------------\r
+ // | | | |\r
+ // | | | |\r
+ // | | | |\r
+ // | | | |\r
+ // | | | |\r
+ // \/ | | |\r
+ // -------------------------------------------\r
+ // QueryDataCount\r
+ //\r
+ if (OldTextOutModeMap != NULL) {\r
+\r
+ Size = Private->CurrentNumberOfConsoles * sizeof (INT32);\r
+ Index = 0;\r
+ SrcAddress = OldTextOutModeMap;\r
+\r
+ //\r
+ // Copy the old data to the new one\r
+ //\r
+ while (Index < Private->TextOutMode.MaxMode) {\r
+ CopyMem (TextOutModeMap, SrcAddress, Size);\r
+ TextOutModeMap += NewSize;\r
+ SrcAddress += Size;\r
+ Index++;\r
+ }\r
+ //\r
+ // Free the old buffer\r
+ //\r
+ FreePool (OldTextOutModeMap);\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+ConSplitterAddOutputMode (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ INT32 MaxMode;\r
+ INT32 Mode;\r
+ UINTN Index;\r
+\r
+ MaxMode = TextOut->Mode->MaxMode;\r
+ Private->TextOutMode.MaxMode = MaxMode;\r
+\r
+ //\r
+ // Grow the buffer if query data buffer is not large enough to\r
+ // hold all the mode supported by the first console.\r
+ //\r
+ while (MaxMode > (INT32) Private->TextOutQueryDataCount) {\r
+ Status = ConSplitterGrowBuffer (\r
+ sizeof (TEXT_OUT_SPLITTER_QUERY_DATA),\r
+ &Private->TextOutQueryDataCount,\r
+ (VOID **) &Private->TextOutQueryData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ }\r
+ //\r
+ // Allocate buffer for the output mode map\r
+ //\r
+ Status = ConSplitterGrowMapTable (Private);\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ //\r
+ // As the first textout device, directly add the mode in to QueryData\r
+ // and at the same time record the mapping between QueryData and TextOut.\r
+ //\r
+ Mode = 0;\r
+ Index = 0;\r
+ while (Mode < MaxMode) {\r
+ TextOut->QueryMode (\r
+ TextOut,\r
+ Mode,\r
+ &Private->TextOutQueryData[Mode].Columns,\r
+ &Private->TextOutQueryData[Mode].Rows\r
+ );\r
+ Private->TextOutModeMap[Index] = Mode;\r
+ Mode++;\r
+ Index += Private->TextOutListCount;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+VOID\r
+ConSplitterGetIntersection (\r
+ IN INT32 *TextOutModeMap,\r
+ IN INT32 *NewlyAddedMap,\r
+ IN UINTN MapStepSize,\r
+ IN UINTN NewMapStepSize,\r
+ OUT INT32 *MaxMode,\r
+ OUT INT32 *CurrentMode\r
+ )\r
+{\r
+ INT32 Index;\r
+ INT32 *CurrentMapEntry;\r
+ INT32 *NextMapEntry;\r
+ INT32 CurrentMaxMode;\r
+ INT32 Mode;\r
+\r
+ Index = 0;\r
+ CurrentMapEntry = TextOutModeMap;\r
+ NextMapEntry = TextOutModeMap;\r
+ CurrentMaxMode = *MaxMode;\r
+ Mode = *CurrentMode;\r
+\r
+ while (Index < CurrentMaxMode) {\r
+ if (*NewlyAddedMap == -1) {\r
+ //\r
+ // This mode is not supported any more. Remove it. Special care\r
+ // must be taken as this remove will also affect current mode;\r
+ //\r
+ if (Index == *CurrentMode) {\r
+ Mode = -1;\r
+ } else if (Index < *CurrentMode) {\r
+ Mode--;\r
+ }\r
+ (*MaxMode)--;\r
+ } else {\r
+ if (CurrentMapEntry != NextMapEntry) {\r
+ CopyMem (NextMapEntry, CurrentMapEntry, MapStepSize * sizeof (INT32));\r
+ }\r
+\r
+ NextMapEntry += MapStepSize;\r
+ }\r
+\r
+ CurrentMapEntry += MapStepSize;\r
+ NewlyAddedMap += NewMapStepSize;\r
+ Index++;\r
+ }\r
+\r
+ *CurrentMode = Mode;\r
+\r
+ return ;\r
+}\r
+\r
+STATIC\r
+VOID\r
+ConSplitterSyncOutputMode (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+ Private - Private data structure.\r
+ TextOut - Text Out Protocol.\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ INT32 CurrentMaxMode;\r
+ INT32 Mode;\r
+ INT32 Index;\r
+ INT32 *TextOutModeMap;\r
+ INT32 *MapTable;\r
+ TEXT_OUT_SPLITTER_QUERY_DATA *TextOutQueryData;\r
+ UINTN Rows;\r
+ UINTN Columns;\r
+ UINTN StepSize;\r
+\r
+ //\r
+ // Must make sure that current mode won't change even if mode number changes\r
+ //\r
+ CurrentMaxMode = Private->TextOutMode.MaxMode;\r
+ TextOutModeMap = Private->TextOutModeMap;\r
+ StepSize = Private->TextOutListCount;\r
+ TextOutQueryData = Private->TextOutQueryData;\r
+\r
+ //\r
+ // Query all the mode that the newly added TextOut supports\r
+ //\r
+ Mode = 0;\r
+ MapTable = TextOutModeMap + Private->CurrentNumberOfConsoles;\r
+ while (Mode < TextOut->Mode->MaxMode) {\r
+ TextOut->QueryMode (TextOut, Mode, &Columns, &Rows);\r
+\r
+ //\r
+ // Search the QueryData database to see if they intersects\r
+ //\r
+ Index = 0;\r
+ while (Index < CurrentMaxMode) {\r
+ if ((TextOutQueryData[Index].Rows == Rows) && (TextOutQueryData[Index].Columns == Columns)) {\r
+ MapTable[Index * StepSize] = Mode;\r
+ break;\r
+ }\r
+\r
+ Index++;\r
+ }\r
+\r
+ Mode++;\r
+ }\r
+ //\r
+ // Now search the TextOutModeMap table to find the intersection of supported\r
+ // mode between ConSplitter and the newly added device.\r
+ //\r
+ ConSplitterGetIntersection (\r
+ TextOutModeMap,\r
+ MapTable,\r
+ StepSize,\r
+ StepSize,\r
+ &Private->TextOutMode.MaxMode,\r
+ &Private->TextOutMode.Mode\r
+ );\r
+\r
+ return ;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+ConSplitterGetIntersectionBetweenConOutAndStrErr (\r
+ VOID\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+ None\r
+ EFI_OUT_OF_RESOURCES\r
+\r
+--*/\r
+{\r
+ UINTN ConOutNumOfConsoles;\r
+ UINTN StdErrNumOfConsoles;\r
+ TEXT_OUT_AND_GOP_DATA *ConOutTextOutList;\r
+ TEXT_OUT_AND_GOP_DATA *StdErrTextOutList;\r
+ UINTN Indexi;\r
+ UINTN Indexj;\r
+ UINTN Rows;\r
+ UINTN Columns;\r
+ INT32 ConOutMaxMode;\r
+ INT32 StdErrMaxMode;\r
+ INT32 Mode;\r
+ INT32 Index;\r
+ INT32 *ConOutModeMap;\r
+ INT32 *StdErrModeMap;\r
+ INT32 *ConOutMapTable;\r
+ INT32 *StdErrMapTable;\r
+ TEXT_OUT_SPLITTER_QUERY_DATA *ConOutQueryData;\r
+ TEXT_OUT_SPLITTER_QUERY_DATA *StdErrQueryData;\r
+ BOOLEAN FoundTheSameTextOut;\r
+ UINTN ConOutMapTableSize;\r
+ UINTN StdErrMapTableSize;\r
+\r
+ ConOutNumOfConsoles = mConOut.CurrentNumberOfConsoles;\r
+ StdErrNumOfConsoles = mStdErr.CurrentNumberOfConsoles;\r
+ ConOutTextOutList = mConOut.TextOutList;\r
+ StdErrTextOutList = mStdErr.TextOutList;\r
+\r
+ Indexi = 0;\r
+ FoundTheSameTextOut = FALSE;\r
+ while ((Indexi < ConOutNumOfConsoles) && (!FoundTheSameTextOut)) {\r
+ Indexj = 0;\r
+ while (Indexj < StdErrNumOfConsoles) {\r
+ if (ConOutTextOutList->TextOut == StdErrTextOutList->TextOut) {\r
+ FoundTheSameTextOut = TRUE;\r
+ break;\r
+ }\r
+\r
+ Indexj++;\r
+ StdErrTextOutList++;\r
+ }\r
+\r
+ Indexi++;\r
+ ConOutTextOutList++;\r
+ }\r
+\r
+ if (!FoundTheSameTextOut) {\r
+ return EFI_SUCCESS;\r
+ }\r
+ //\r
+ // Must make sure that current mode won't change even if mode number changes\r
+ //\r
+ ConOutMaxMode = mConOut.TextOutMode.MaxMode;\r
+ ConOutModeMap = mConOut.TextOutModeMap;\r
+ ConOutQueryData = mConOut.TextOutQueryData;\r
+\r
+ StdErrMaxMode = mStdErr.TextOutMode.MaxMode;\r
+ StdErrModeMap = mStdErr.TextOutModeMap;\r
+ StdErrQueryData = mStdErr.TextOutQueryData;\r
+\r
+ //\r
+ // Allocate the map table and set the map table's index to -1.\r
+ //\r
+ ConOutMapTableSize = ConOutMaxMode * sizeof (INT32);\r
+ ConOutMapTable = AllocateZeroPool (ConOutMapTableSize);\r
+ if (ConOutMapTable == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ SetMem (ConOutMapTable, ConOutMapTableSize, 0xFF);\r
+\r
+ StdErrMapTableSize = StdErrMaxMode * sizeof (INT32);\r
+ StdErrMapTable = AllocateZeroPool (StdErrMapTableSize);\r
+ if (StdErrMapTable == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ SetMem (StdErrMapTable, StdErrMapTableSize, 0xFF);\r
+\r
+ //\r
+ // Find the intersection of the two set of modes. If they actually intersect, the\r
+ // correponding entry in the map table is set to 1.\r
+ //\r
+ Mode = 0;\r
+ while (Mode < ConOutMaxMode) {\r
+ //\r
+ // Search the other's QueryData database to see if they intersect\r
+ //\r
+ Index = 0;\r
+ Rows = ConOutQueryData[Mode].Rows;\r
+ Columns = ConOutQueryData[Mode].Columns;\r
+ while (Index < StdErrMaxMode) {\r
+ if ((StdErrQueryData[Index].Rows == Rows) && (StdErrQueryData[Index].Columns == Columns)) {\r
+ ConOutMapTable[Mode] = 1;\r
+ StdErrMapTable[Index] = 1;\r
+ break;\r
+ }\r
+\r
+ Index++;\r
+ }\r
+\r
+ Mode++;\r
+ }\r
+ //\r
+ // Now search the TextOutModeMap table to find the intersection of supported\r
+ // mode between ConSplitter and the newly added device.\r
+ //\r
+ ConSplitterGetIntersection (\r
+ ConOutModeMap,\r
+ ConOutMapTable,\r
+ mConOut.TextOutListCount,\r
+ 1,\r
+ &(mConOut.TextOutMode.MaxMode),\r
+ &(mConOut.TextOutMode.Mode)\r
+ );\r
+ if (mConOut.TextOutMode.Mode < 0) {\r
+ mConOut.TextOut.SetMode (&(mConOut.TextOut), 0);\r
+ }\r
+\r
+ ConSplitterGetIntersection (\r
+ StdErrModeMap,\r
+ StdErrMapTable,\r
+ mStdErr.TextOutListCount,\r
+ 1,\r
+ &(mStdErr.TextOutMode.MaxMode),\r
+ &(mStdErr.TextOutMode.Mode)\r
+ );\r
+ if (mStdErr.TextOutMode.Mode < 0) {\r
+ mStdErr.TextOut.SetMode (&(mStdErr.TextOut), 0);\r
+ }\r
+\r
+ FreePool (ConOutMapTable);\r
+ FreePool (StdErrMapTable);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+ConSplitterAddGraphicsOutputMode (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,\r
+ IN EFI_UGA_DRAW_PROTOCOL *UgaDraw\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN Index;\r
+ TEXT_OUT_GOP_MODE *Mode;\r
+ UINTN SizeOfInfo;\r
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *CurrentGraphicsOutputMode;\r
+ TEXT_OUT_GOP_MODE *ModeBuffer;\r
+ TEXT_OUT_GOP_MODE *MatchedMode;\r
+ UINTN NumberIndex;\r
+ BOOLEAN Match;\r
+\r
+ if ((GraphicsOutput == NULL) && (UgaDraw == NULL)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ CurrentGraphicsOutputMode = Private->GraphicsOutput.Mode;\r
+\r
+ if (GraphicsOutput != NULL) {\r
+ if (Private->CurrentNumberOfGraphicsOutput == 0) {\r
+ //\r
+ // This is the first Graphics Output device added\r
+ //\r
+ CurrentGraphicsOutputMode->MaxMode = GraphicsOutput->Mode->MaxMode;\r
+ CurrentGraphicsOutputMode->Mode = GraphicsOutput->Mode->Mode;\r
+ CopyMem (CurrentGraphicsOutputMode->Info, GraphicsOutput->Mode->Info, GraphicsOutput->Mode->SizeOfInfo);\r
+ CurrentGraphicsOutputMode->SizeOfInfo = GraphicsOutput->Mode->SizeOfInfo;\r
+ CurrentGraphicsOutputMode->FrameBufferBase = GraphicsOutput->Mode->FrameBufferBase;\r
+ CurrentGraphicsOutputMode->FrameBufferSize = GraphicsOutput->Mode->FrameBufferSize;\r
+\r
+ //\r
+ // Allocate resource for the private mode buffer\r
+ //\r
+ ModeBuffer = AllocatePool (sizeof (TEXT_OUT_GOP_MODE) * GraphicsOutput->Mode->MaxMode);\r
+ if (ModeBuffer == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ FreePool (Private->GraphicsOutputModeBuffer);\r
+ Private->GraphicsOutputModeBuffer = ModeBuffer;\r
+\r
+ //\r
+ // Store all supported display modes to the private mode buffer\r
+ //\r
+ Mode = ModeBuffer;\r
+ for (Index = 0; Index < GraphicsOutput->Mode->MaxMode; Index++) {\r
+ Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) Index, &SizeOfInfo, &Info);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ Mode->HorizontalResolution = Info->HorizontalResolution;\r
+ Mode->VerticalResolution = Info->VerticalResolution;\r
+ Mode++;\r
+ FreePool (Info);\r
+ }\r
+ } else {\r
+ //\r
+ // Check intersection of display mode\r
+ //\r
+ ModeBuffer = AllocatePool (sizeof (TEXT_OUT_GOP_MODE) * CurrentGraphicsOutputMode->MaxMode);\r
+ if (ModeBuffer == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ MatchedMode = ModeBuffer;\r
+ Mode = &Private->GraphicsOutputModeBuffer[0];\r
+ for (Index = 0; Index < CurrentGraphicsOutputMode->MaxMode; Index++) {\r
+ Match = FALSE;\r
+\r
+ for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex++) {\r
+ Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ if ((Info->HorizontalResolution == Mode->HorizontalResolution) &&\r
+ (Info->VerticalResolution == Mode->VerticalResolution)){\r
+ Match = TRUE;\r
+ FreePool (Info);\r
+ break;\r
+ }\r
+ FreePool (Info);\r
+ }\r
+\r
+ if (Match) {\r
+ CopyMem (MatchedMode, Mode, sizeof (TEXT_OUT_GOP_MODE));\r
+ MatchedMode++;\r
+ }\r
+\r
+ Mode++;\r
+ }\r
+\r
+ //\r
+ // Drop the old mode buffer, assign it to a new one\r
+ //\r
+ FreePool (Private->GraphicsOutputModeBuffer);\r
+ Private->GraphicsOutputModeBuffer = ModeBuffer;\r
+\r
+ //\r
+ // Physical frame buffer is no longer available when there are more than one physical GOP devices\r
+ //\r
+ CurrentGraphicsOutputMode->MaxMode = (UINT32) (((UINTN) MatchedMode - (UINTN) ModeBuffer) / sizeof (TEXT_OUT_GOP_MODE));\r
+ CurrentGraphicsOutputMode->Info->PixelFormat = PixelBltOnly;\r
+ ZeroMem (&CurrentGraphicsOutputMode->Info->PixelInformation, sizeof (EFI_PIXEL_BITMASK));\r
+ CurrentGraphicsOutputMode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r
+ CurrentGraphicsOutputMode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) NULL;\r
+ CurrentGraphicsOutputMode->FrameBufferSize = 0;\r
+ }\r
+\r
+ //\r
+ // Select a prefered Display mode 800x600\r
+ //\r
+ for (Index = 0; Index < CurrentGraphicsOutputMode->MaxMode; Index++) {\r
+ Mode = &Private->GraphicsOutputModeBuffer[Index];\r
+ if ((Mode->HorizontalResolution == 800) && (Mode->VerticalResolution == 600)) {\r
+ break;\r
+ }\r
+ }\r
+ //\r
+ // Prefered mode is not found, set to mode 0\r
+ //\r
+ if (Index >= CurrentGraphicsOutputMode->MaxMode) {\r
+ Index = 0;\r
+ }\r
+\r
+ //\r
+ // Current mode number may need update now, so set it to an invalide mode number\r
+ //\r
+ CurrentGraphicsOutputMode->Mode = 0xffff;\r
+ } else {\r
+ //\r
+ // For UGA device, it's inconvenient to retrieve all the supported display modes.\r
+ // To simplify the implementation, only add one resolution(800x600, 32bit color depth) as defined in UEFI spec\r
+ //\r
+ CurrentGraphicsOutputMode->MaxMode = 1;\r
+ CurrentGraphicsOutputMode->Info->Version = 0;\r
+ CurrentGraphicsOutputMode->Info->HorizontalResolution = 800;\r
+ CurrentGraphicsOutputMode->Info->VerticalResolution = 600;\r
+ CurrentGraphicsOutputMode->Info->PixelFormat = PixelBltOnly;\r
+ CurrentGraphicsOutputMode->Info->PixelsPerScanLine = 800;\r
+ CurrentGraphicsOutputMode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r
+ CurrentGraphicsOutputMode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) NULL;\r
+ CurrentGraphicsOutputMode->FrameBufferSize = 0;\r
+\r
+ //\r
+ // Update the private mode buffer\r
+ //\r
+ ModeBuffer = &Private->GraphicsOutputModeBuffer[0];\r
+ ModeBuffer->HorizontalResolution = 800;\r
+ ModeBuffer->VerticalResolution = 600;\r
+\r
+ //\r
+ // Current mode is unknow now, set it to an invalid mode number 0xffff\r
+ //\r
+ CurrentGraphicsOutputMode->Mode = 0xffff;\r
+ Index = 0;\r
+ }\r
+\r
+ //\r
+ // Force GraphicsOutput mode to be set,\r
+ // regardless whether the console is in EfiConsoleControlScreenGraphics or EfiConsoleControlScreenText mode\r
+ //\r
+ Private->HardwareNeedsStarting = TRUE;\r
+ Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, (UINT32) Index);\r
+\r
+ Private->CurrentNumberOfGraphicsOutput++;\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+ConSplitterTextOutAddDevice (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut,\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,\r
+ IN EFI_UGA_DRAW_PROTOCOL *UgaDraw\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN CurrentNumOfConsoles;\r
+ INT32 CurrentMode;\r
+ INT32 MaxMode;\r
+ TEXT_OUT_AND_GOP_DATA *TextAndGop;\r
+\r
+ Status = EFI_SUCCESS;\r
+ CurrentNumOfConsoles = Private->CurrentNumberOfConsoles;\r
+\r
+ //\r
+ // If the Text Out List is full, enlarge it by calling growbuffer().\r
+ //\r
+ while (CurrentNumOfConsoles >= Private->TextOutListCount) {\r
+ Status = ConSplitterGrowBuffer (\r
+ sizeof (TEXT_OUT_AND_GOP_DATA),\r
+ &Private->TextOutListCount,\r
+ (VOID **) &Private->TextOutList\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ //\r
+ // Also need to reallocate the TextOutModeMap table\r
+ //\r
+ Status = ConSplitterGrowMapTable (Private);\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ }\r
+\r
+ TextAndGop = &Private->TextOutList[CurrentNumOfConsoles];\r
+\r
+ TextAndGop->TextOut = TextOut;\r
+ TextAndGop->GraphicsOutput = GraphicsOutput;\r
+ TextAndGop->UgaDraw = UgaDraw;\r
+\r
+ if ((GraphicsOutput == NULL) && (UgaDraw == NULL)) {\r
+ //\r
+ // If No UGA device then use the ConOut device\r
+ //\r
+ TextAndGop->TextOutEnabled = TRUE;\r
+ } else {\r
+ //\r
+ // If UGA device use ConOut device only used if UGA screen is in Text mode\r
+ //\r
+ TextAndGop->TextOutEnabled = (BOOLEAN) (Private->ConsoleOutputMode == EfiConsoleControlScreenText);\r
+ }\r
+\r
+ if (CurrentNumOfConsoles == 0) {\r
+ //\r
+ // Add the first device's output mode to console splitter's mode list\r
+ //\r
+ Status = ConSplitterAddOutputMode (Private, TextOut);\r
+ } else {\r
+ ConSplitterSyncOutputMode (Private, TextOut);\r
+ }\r
+\r
+ Private->CurrentNumberOfConsoles++;\r
+\r
+ //\r
+ // Scan both TextOutList, for the intersection TextOut device\r
+ // maybe both ConOut and StdErr incorporate the same Text Out\r
+ // device in them, thus the output of both should be synced.\r
+ //\r
+ ConSplitterGetIntersectionBetweenConOutAndStrErr ();\r
+\r
+ CurrentMode = Private->TextOutMode.Mode;\r
+ MaxMode = Private->TextOutMode.MaxMode;\r
+ ASSERT (MaxMode >= 1);\r
+\r
+ if ((GraphicsOutput != NULL) || (UgaDraw != NULL)) {\r
+ ConSplitterAddGraphicsOutputMode (Private, GraphicsOutput, UgaDraw);\r
+ }\r
+\r
+ if (Private->ConsoleOutputMode == EfiConsoleControlScreenGraphics && GraphicsOutput != NULL) {\r
+ //\r
+ // We just added a new UGA device in graphics mode\r
+ //\r
+ DevNullGopSync (Private, GraphicsOutput, UgaDraw);\r
+ } else if ((CurrentMode >= 0) && ((GraphicsOutput != NULL) || (UgaDraw != NULL)) && (CurrentMode < Private->TextOutMode.MaxMode)) {\r
+ //\r
+ // The new console supports the same mode of the current console so sync up\r
+ //\r
+ DevNullSyncGopStdOut (Private);\r
+ } else {\r
+ //\r
+ // If ConOut, then set the mode to Mode #0 which us 80 x 25\r
+ //\r
+ Private->TextOut.SetMode (&Private->TextOut, 0);\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+ConSplitterTextOutDeleteDevice (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ INT32 Index;\r
+ UINTN CurrentNumOfConsoles;\r
+ TEXT_OUT_AND_GOP_DATA *TextOutList;\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Remove the specified text-out device data structure from the Text out List,\r
+ // and rearrange the remaining data structures in the Text out List.\r
+ //\r
+ CurrentNumOfConsoles = Private->CurrentNumberOfConsoles;\r
+ Index = (INT32) CurrentNumOfConsoles - 1;\r
+ TextOutList = Private->TextOutList;\r
+ while (Index >= 0) {\r
+ if (TextOutList->TextOut == TextOut) {\r
+ CopyMem (TextOutList, TextOutList + 1, sizeof (TEXT_OUT_AND_GOP_DATA) * Index);\r
+ CurrentNumOfConsoles--;\r
+ break;\r
+ }\r
+\r
+ Index--;\r
+ TextOutList++;\r
+ }\r
+ //\r
+ // The specified TextOut is not managed by the ConSplitter driver\r
+ //\r
+ if (Index < 0) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+\r
+ if (CurrentNumOfConsoles == 0) {\r
+ //\r
+ // If the number of consoles is zero clear the Dev NULL device\r
+ //\r
+ Private->CurrentNumberOfConsoles = 0;\r
+ Private->TextOutMode.MaxMode = 1;\r
+ Private->TextOutQueryData[0].Columns = 80;\r
+ Private->TextOutQueryData[0].Rows = 25;\r
+ DevNullTextOutSetMode (Private, 0);\r
+\r
+ return EFI_SUCCESS;\r
+ }\r
+ //\r
+ // Max Mode is realy an intersection of the QueryMode command to all\r
+ // devices. So we must copy the QueryMode of the first device to\r
+ // QueryData.\r
+ //\r
+ ZeroMem (\r
+ Private->TextOutQueryData,\r
+ Private->TextOutQueryDataCount * sizeof (TEXT_OUT_SPLITTER_QUERY_DATA)\r
+ );\r
+\r
+ FreePool (Private->TextOutModeMap);\r
+ Private->TextOutModeMap = NULL;\r
+ TextOutList = Private->TextOutList;\r
+\r
+ //\r
+ // Add the first TextOut to the QueryData array and ModeMap table\r
+ //\r
+ Status = ConSplitterAddOutputMode (Private, TextOutList->TextOut);\r
+\r
+ //\r
+ // Now add one by one\r
+ //\r
+ Index = 1;\r
+ Private->CurrentNumberOfConsoles = 1;\r
+ TextOutList++;\r
+ while ((UINTN) Index < CurrentNumOfConsoles) {\r
+ ConSplitterSyncOutputMode (Private, TextOutList->TextOut);\r
+ Index++;\r
+ Private->CurrentNumberOfConsoles++;\r
+ TextOutList++;\r
+ }\r
+\r
+ ConSplitterGetIntersectionBetweenConOutAndStrErr ();\r
+\r
+ return Status;\r
+}\r
+//\r
+// ConSplitter TextIn member functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextInReset (\r
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
+ IN BOOLEAN ExtendedVerification\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Reset the input device and optionaly run diagnostics\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ ExtendedVerification - Driver may perform diagnostics on reset.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The device was reset.\r
+ EFI_DEVICE_ERROR - The device is not functioning properly and could\r
+ not be reset.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_STATUS ReturnStatus;\r
+ TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r
+ UINTN Index;\r
+\r
+ Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+ Private->KeyEventSignalState = FALSE;\r
+\r
+ //\r
+ // return the worst status met\r
+ //\r
+ for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r
+ Status = Private->TextInList[Index]->Reset (\r
+ Private->TextInList[Index],\r
+ ExtendedVerification\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+ }\r
+\r
+ return ReturnStatus;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextInPrivateReadKeyStroke (\r
+ IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r
+ OUT EFI_INPUT_KEY *Key\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Reads the next keystroke from the input device. The WaitForKey Event can\r
+ be used to test for existance of a keystroke via WaitForEvent () call.\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ Key - Driver may perform diagnostics on reset.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The keystroke information was returned.\r
+ EFI_NOT_READY - There was no keystroke data availiable.\r
+ EFI_DEVICE_ERROR - The keydtroke information was not returned due to\r
+ hardware errors.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN Index;\r
+ EFI_INPUT_KEY CurrentKey;\r
+\r
+ Key->UnicodeChar = 0;\r
+ Key->ScanCode = SCAN_NULL;\r
+\r
+ //\r
+ // if no physical console input device exists, return EFI_NOT_READY;\r
+ // if any physical console input device has key input,\r
+ // return the key and EFI_SUCCESS.\r
+ //\r
+ for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r
+ Status = Private->TextInList[Index]->ReadKeyStroke (\r
+ Private->TextInList[Index],\r
+ &CurrentKey\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ *Key = CurrentKey;\r
+ return Status;\r
+ }\r
+ }\r
+\r
+ return EFI_NOT_READY;\r
+}\r
+\r
+BOOLEAN\r
+ConSpliterConssoleControlStdInLocked (\r
+ VOID\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Return TRUE if StdIn is locked. The ConIn device on the virtual handle is\r
+ the only device locked.\r
+\r
+Arguments:\r
+ NONE\r
+\r
+Returns:\r
+ TRUE - StdIn locked\r
+ FALSE - StdIn working normally\r
+\r
+--*/\r
+{\r
+ return mConIn.PasswordEnabled;\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+ConSpliterConsoleControlLockStdInEvent (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ This timer event will fire when StdIn is locked. It will check the key\r
+ sequence on StdIn to see if it matches the password. Any error in the\r
+ password will cause the check to reset. As long a mConIn.PasswordEnabled is\r
+ TRUE the StdIn splitter will not report any input.\r
+\r
+Arguments:\r
+ (Standard EFI_EVENT_NOTIFY)\r
+\r
+Returns:\r
+ None\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_INPUT_KEY Key;\r
+ CHAR16 BackSpaceString[2];\r
+ CHAR16 SpaceString[2];\r
+\r
+ do {\r
+ Status = ConSplitterTextInPrivateReadKeyStroke (&mConIn, &Key);\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // if it's an ENTER, match password\r
+ //\r
+ if ((Key.UnicodeChar == CHAR_CARRIAGE_RETURN) && (Key.ScanCode == SCAN_NULL)) {\r
+ mConIn.PwdAttempt[mConIn.PwdIndex] = CHAR_NULL;\r
+ if (StrCmp (mConIn.Password, mConIn.PwdAttempt)) {\r
+ //\r
+ // Password not match\r
+ //\r
+ ConSplitterTextOutOutputString (&mConOut.TextOut, (CHAR16 *) L"\n\rPassword not correct\n\r");\r
+ mConIn.PwdIndex = 0;\r
+ } else {\r
+ //\r
+ // Key matches password sequence\r
+ //\r
+ gBS->SetTimer (mConIn.LockEvent, TimerPeriodic, 0);\r
+ mConIn.PasswordEnabled = FALSE;\r
+ Status = EFI_NOT_READY;\r
+ }\r
+ } else if ((Key.UnicodeChar == CHAR_BACKSPACE) && (Key.ScanCode == SCAN_NULL)) {\r
+ //\r
+ // BackSpace met\r
+ //\r
+ if (mConIn.PwdIndex > 0) {\r
+ BackSpaceString[0] = CHAR_BACKSPACE;\r
+ BackSpaceString[1] = 0;\r
+\r
+ SpaceString[0] = ' ';\r
+ SpaceString[1] = 0;\r
+\r
+ ConSplitterTextOutOutputString (&mConOut.TextOut, BackSpaceString);\r
+ ConSplitterTextOutOutputString (&mConOut.TextOut, SpaceString);\r
+ ConSplitterTextOutOutputString (&mConOut.TextOut, BackSpaceString);\r
+\r
+ mConIn.PwdIndex--;\r
+ }\r
+ } else if ((Key.ScanCode == SCAN_NULL) && (Key.UnicodeChar >= 32)) {\r
+ //\r
+ // If it's not an ENTER, neigher a function key, nor a CTRL-X or ALT-X, record the input\r
+ //\r
+ if (mConIn.PwdIndex < (MAX_STD_IN_PASSWORD - 1)) {\r
+ if (mConIn.PwdIndex == 0) {\r
+ ConSplitterTextOutOutputString (&mConOut.TextOut, (CHAR16 *) L"\n\r");\r
+ }\r
+\r
+ ConSplitterTextOutOutputString (&mConOut.TextOut, (CHAR16 *) L"*");\r
+ mConIn.PwdAttempt[mConIn.PwdIndex] = Key.UnicodeChar;\r
+ mConIn.PwdIndex++;\r
+ }\r
+ }\r
+ }\r
+ } while (!EFI_ERROR (Status));\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSpliterConsoleControlLockStdIn (\r
+ IN EFI_CONSOLE_CONTROL_PROTOCOL *This,\r
+ IN CHAR16 *Password\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ If Password is NULL unlock the password state variable and set the event\r
+ timer. If the Password is too big return an error. If the Password is valid\r
+ Copy the Password and enable state variable and then arm the periodic timer\r
+\r
+Arguments:\r
+\r
+Returns:\r
+ EFI_SUCCESS - Lock the StdIn device\r
+ EFI_INVALID_PARAMETER - Password is NULL\r
+ EFI_OUT_OF_RESOURCES - Buffer allocation to store the password fails\r
+\r
+--*/\r
+{\r
+ if (Password == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (StrLen (Password) >= MAX_STD_IN_PASSWORD) {\r
+ //\r
+ // Currently have a max password size\r
+ //\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ //\r
+ // Save the password, initialize state variables and arm event timer\r
+ //\r
+ StrCpy (mConIn.Password, Password);\r
+ mConIn.PasswordEnabled = TRUE;\r
+ mConIn.PwdIndex = 0;\r
+ gBS->SetTimer (mConIn.LockEvent, TimerPeriodic, (10000 * 25));\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextInReadKeyStroke (\r
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
+ OUT EFI_INPUT_KEY *Key\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Reads the next keystroke from the input device. The WaitForKey Event can\r
+ be used to test for existance of a keystroke via WaitForEvent () call.\r
+ If the ConIn is password locked make it look like no keystroke is availible\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ Key - Driver may perform diagnostics on reset.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The keystroke information was returned.\r
+ EFI_NOT_READY - There was no keystroke data availiable.\r
+ EFI_DEVICE_ERROR - The keydtroke information was not returned due to\r
+ hardware errors.\r
+\r
+--*/\r
+{\r
+ TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r
+\r
+ Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
+ if (Private->PasswordEnabled) {\r
+ //\r
+ // If StdIn Locked return not ready\r
+ //\r
+ return EFI_NOT_READY;\r
+ }\r
+\r
+ Private->KeyEventSignalState = FALSE;\r
+\r
+ return ConSplitterTextInPrivateReadKeyStroke (Private, Key);\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+ConSplitterTextInWaitForKey (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ This event agregates all the events of the ConIn devices in the spliter.\r
+ If the ConIn is password locked then return.\r
+ If any events of physical ConIn devices are signaled, signal the ConIn\r
+ spliter event. This will cause the calling code to call\r
+ ConSplitterTextInReadKeyStroke ().\r
+\r
+Arguments:\r
+ Event - The Event assoicated with callback.\r
+ Context - Context registered when Event was created.\r
+\r
+Returns:\r
+ None\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r
+ UINTN Index;\r
+\r
+ Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context;\r
+ if (Private->PasswordEnabled) {\r
+ //\r
+ // If StdIn Locked return not ready\r
+ //\r
+ return ;\r
+ }\r
+\r
+ //\r
+ // if KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()\r
+ //\r
+ if (Private->KeyEventSignalState) {\r
+ gBS->SignalEvent (Event);\r
+ return ;\r
+ }\r
+ //\r
+ // if any physical console input device has key input, signal the event.\r
+ //\r
+ for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r
+ Status = gBS->CheckEvent (Private->TextInList[Index]->WaitForKey);\r
+ if (!EFI_ERROR (Status)) {\r
+ gBS->SignalEvent (Event);\r
+ Private->KeyEventSignalState = TRUE;\r
+ }\r
+ }\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterSimplePointerReset (\r
+ IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r
+ IN BOOLEAN ExtendedVerification\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Reset the input device and optionaly run diagnostics\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ ExtendedVerification - Driver may perform diagnostics on reset.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The device was reset.\r
+ EFI_DEVICE_ERROR - The device is not functioning properly and could\r
+ not be reset.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_STATUS ReturnStatus;\r
+ TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r
+ UINTN Index;\r
+\r
+ Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This);\r
+\r
+ Private->InputEventSignalState = FALSE;\r
+\r
+ if (Private->CurrentNumberOfPointers == 0) {\r
+ return EFI_SUCCESS;\r
+ }\r
+ //\r
+ // return the worst status met\r
+ //\r
+ for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfPointers; Index++) {\r
+ Status = Private->PointerList[Index]->Reset (\r
+ Private->PointerList[Index],\r
+ ExtendedVerification\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+ }\r
+\r
+ return ReturnStatus;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterSimplePointerPrivateGetState (\r
+ IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r
+ IN OUT EFI_SIMPLE_POINTER_STATE *State\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Reads the next keystroke from the input device. The WaitForKey Event can\r
+ be used to test for existance of a keystroke via WaitForEvent () call.\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ State -\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The keystroke information was returned.\r
+ EFI_NOT_READY - There was no keystroke data availiable.\r
+ EFI_DEVICE_ERROR - The keydtroke information was not returned due to\r
+ hardware errors.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_STATUS ReturnStatus;\r
+ UINTN Index;\r
+ EFI_SIMPLE_POINTER_STATE CurrentState;\r
+\r
+ State->RelativeMovementX = 0;\r
+ State->RelativeMovementY = 0;\r
+ State->RelativeMovementZ = 0;\r
+ State->LeftButton = FALSE;\r
+ State->RightButton = FALSE;\r
+\r
+ //\r
+ // if no physical console input device exists, return EFI_NOT_READY;\r
+ // if any physical console input device has key input,\r
+ // return the key and EFI_SUCCESS.\r
+ //\r
+ ReturnStatus = EFI_NOT_READY;\r
+ for (Index = 0; Index < Private->CurrentNumberOfPointers; Index++) {\r
+\r
+ Status = Private->PointerList[Index]->GetState (\r
+ Private->PointerList[Index],\r
+ &CurrentState\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ if (ReturnStatus == EFI_NOT_READY) {\r
+ ReturnStatus = EFI_SUCCESS;\r
+ }\r
+\r
+ if (CurrentState.LeftButton) {\r
+ State->LeftButton = TRUE;\r
+ }\r
+\r
+ if (CurrentState.RightButton) {\r
+ State->RightButton = TRUE;\r
+ }\r
+\r
+ if (CurrentState.RelativeMovementX != 0 && Private->PointerList[Index]->Mode->ResolutionX != 0) {\r
+ State->RelativeMovementX += (CurrentState.RelativeMovementX * (INT32) Private->SimplePointerMode.ResolutionX) / (INT32) Private->PointerList[Index]->Mode->ResolutionX;\r
+ }\r
+\r
+ if (CurrentState.RelativeMovementY != 0 && Private->PointerList[Index]->Mode->ResolutionY != 0) {\r
+ State->RelativeMovementY += (CurrentState.RelativeMovementY * (INT32) Private->SimplePointerMode.ResolutionY) / (INT32) Private->PointerList[Index]->Mode->ResolutionY;\r
+ }\r
+\r
+ if (CurrentState.RelativeMovementZ != 0 && Private->PointerList[Index]->Mode->ResolutionZ != 0) {\r
+ State->RelativeMovementZ += (CurrentState.RelativeMovementZ * (INT32) Private->SimplePointerMode.ResolutionZ) / (INT32) Private->PointerList[Index]->Mode->ResolutionZ;\r
+ }\r
+ } else if (Status == EFI_DEVICE_ERROR) {\r
+ ReturnStatus = EFI_DEVICE_ERROR;\r
+ }\r
+ }\r
+\r
+ return ReturnStatus;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterSimplePointerGetState (\r
+ IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r
+ IN OUT EFI_SIMPLE_POINTER_STATE *State\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Reads the next keystroke from the input device. The WaitForKey Event can\r
+ be used to test for existance of a keystroke via WaitForEvent () call.\r
+ If the ConIn is password locked make it look like no keystroke is availible\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ State -\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The keystroke information was returned.\r
+ EFI_NOT_READY - There was no keystroke data availiable.\r
+ EFI_DEVICE_ERROR - The keydtroke information was not returned due to\r
+ hardware errors.\r
+\r
+--*/\r
+{\r
+ TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r
+\r
+ Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This);\r
+ if (Private->PasswordEnabled) {\r
+ //\r
+ // If StdIn Locked return not ready\r
+ //\r
+ return EFI_NOT_READY;\r
+ }\r
+\r
+ Private->InputEventSignalState = FALSE;\r
+\r
+ return ConSplitterSimplePointerPrivateGetState (Private, State);\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+ConSplitterSimplePointerWaitForInput (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ This event agregates all the events of the ConIn devices in the spliter.\r
+ If the ConIn is password locked then return.\r
+ If any events of physical ConIn devices are signaled, signal the ConIn\r
+ spliter event. This will cause the calling code to call\r
+ ConSplitterTextInReadKeyStroke ().\r
+\r
+Arguments:\r
+ Event - The Event assoicated with callback.\r
+ Context - Context registered when Event was created.\r
+\r
+Returns:\r
+ None\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r
+ UINTN Index;\r
+\r
+ Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context;\r
+ if (Private->PasswordEnabled) {\r
+ //\r
+ // If StdIn Locked return not ready\r
+ //\r
+ return ;\r
+ }\r
+\r
+ //\r
+ // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()\r
+ //\r
+ if (Private->InputEventSignalState) {\r
+ gBS->SignalEvent (Event);\r
+ return ;\r
+ }\r
+ //\r
+ // if any physical console input device has key input, signal the event.\r
+ //\r
+ for (Index = 0; Index < Private->CurrentNumberOfPointers; Index++) {\r
+ Status = gBS->CheckEvent (Private->PointerList[Index]->WaitForInput);\r
+ if (!EFI_ERROR (Status)) {\r
+ gBS->SignalEvent (Event);\r
+ Private->InputEventSignalState = TRUE;\r
+ }\r
+ }\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutReset (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN BOOLEAN ExtendedVerification\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Reset the text output device hardware and optionaly run diagnostics\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ ExtendedVerification - Driver may perform more exhaustive verfication\r
+ operation of the device during reset.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The text output device was reset.\r
+ EFI_DEVICE_ERROR - The text output device is not functioning correctly and\r
+ could not be reset.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r
+ UINTN Index;\r
+ EFI_STATUS ReturnStatus;\r
+\r
+ Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+ //\r
+ // return the worst status met\r
+ //\r
+ for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r
+\r
+ if (Private->TextOutList[Index].TextOutEnabled) {\r
+\r
+ Status = Private->TextOutList[Index].TextOut->Reset (\r
+ Private->TextOutList[Index].TextOut,\r
+ ExtendedVerification\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+ }\r
+ }\r
+\r
+ This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK));\r
+\r
+ Status = DevNullTextOutSetMode (Private, 0);\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+\r
+ return ReturnStatus;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutOutputString (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN CHAR16 *WString\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Write a Unicode string to the output device.\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ String - The NULL-terminated Unicode string to be displayed on the output\r
+ device(s). All output devices must also support the Unicode\r
+ drawing defined in this file.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The string was output to the device.\r
+ EFI_DEVICE_ERROR - The device reported an error while attempting to output\r
+ the text.\r
+ EFI_UNSUPPORTED - The output device's mode is not currently in a\r
+ defined text mode.\r
+ EFI_WARN_UNKNOWN_GLYPH - This warning code indicates that some of the\r
+ characters in the Unicode string could not be\r
+ rendered and were skipped.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r
+ UINTN Index;\r
+ UINTN BackSpaceCount;\r
+ EFI_STATUS ReturnStatus;\r
+ CHAR16 *TargetString;\r
+\r
+ This->SetAttribute (This, This->Mode->Attribute);\r
+\r
+ Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+ BackSpaceCount = 0;\r
+ for (TargetString = WString; *TargetString; TargetString++) {\r
+ if (*TargetString == CHAR_BACKSPACE) {\r
+ BackSpaceCount++;\r
+ }\r
+\r
+ }\r
+\r
+ if (BackSpaceCount == 0) {\r
+ TargetString = WString;\r
+ } else {\r
+ TargetString = AllocatePool (sizeof (CHAR16) * (StrLen (WString) + BackSpaceCount + 1));\r
+ StrCpy (TargetString, WString);\r
+ }\r
+ //\r
+ // return the worst status met\r
+ //\r
+ Status = DevNullTextOutOutputString (Private, TargetString);\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+\r
+ for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r
+\r
+ if (Private->TextOutList[Index].TextOutEnabled) {\r
+ Status = Private->TextOutList[Index].TextOut->OutputString (\r
+ Private->TextOutList[Index].TextOut,\r
+ TargetString\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+ }\r
+ }\r
+\r
+ if (BackSpaceCount) {\r
+ FreePool (TargetString);\r
+ }\r
+\r
+ return ReturnStatus;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutTestString (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN CHAR16 *WString\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Verifies that all characters in a Unicode string can be output to the\r
+ target device.\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ String - The NULL-terminated Unicode string to be examined for the output\r
+ device(s).\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The device(s) are capable of rendering the output string.\r
+ EFI_UNSUPPORTED - Some of the characters in the Unicode string cannot be\r
+ rendered by one or more of the output devices mapped\r
+ by the EFI handle.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r
+ UINTN Index;\r
+ EFI_STATUS ReturnStatus;\r
+\r
+ Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+ //\r
+ // return the worst status met\r
+ //\r
+ for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r
+ if (Private->TextOutList[Index].TextOutEnabled) {\r
+ Status = Private->TextOutList[Index].TextOut->TestString (\r
+ Private->TextOutList[Index].TextOut,\r
+ WString\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+ }\r
+ }\r
+ //\r
+ // There is no DevNullTextOutTestString () since a Unicode buffer would\r
+ // always return EFI_SUCCESS.\r
+ // ReturnStatus will be EFI_SUCCESS if no consoles are present\r
+ //\r
+ return ReturnStatus;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutQueryMode (\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
+ Returns information for an available text mode that the output device(s)\r
+ supports.\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ ModeNumber - The mode number to return information on.\r
+ Columns, Rows - Returns the geometry of the text output device for the\r
+ requested ModeNumber.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The requested mode information was returned.\r
+ EFI_DEVICE_ERROR - The device had an error and could not\r
+ complete the request.\r
+ EFI_UNSUPPORTED - The mode number was not valid.\r
+\r
+--*/\r
+{\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r
+\r
+ Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+ //\r
+ // Check whether param ModeNumber is valid.\r
+ // ModeNumber should be within range 0 ~ MaxMode - 1.\r
+ //\r
+ if ( (ModeNumber > (UINTN)(((UINT32)-1)>>1)) ) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ if ((INT32) ModeNumber >= This->Mode->MaxMode) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ *Columns = Private->TextOutQueryData[ModeNumber].Columns;\r
+ *Rows = Private->TextOutQueryData[ModeNumber].Rows;\r
+\r
+ if (*Columns <= 0 && *Rows <= 0) {\r
+ return EFI_UNSUPPORTED;\r
+\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutSetMode (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN ModeNumber\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Sets the output device(s) to a specified mode.\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ ModeNumber - The mode number to set.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The requested text mode was set.\r
+ EFI_DEVICE_ERROR - The device had an error and\r
+ could not complete the request.\r
+ EFI_UNSUPPORTED - The mode number was not valid.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r
+ UINTN Index;\r
+ INT32 *TextOutModeMap;\r
+ EFI_STATUS ReturnStatus;\r
+\r
+ Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+ //\r
+ // Check whether param ModeNumber is valid.\r
+ // ModeNumber should be within range 0 ~ MaxMode - 1.\r
+ //\r
+ if ( (ModeNumber > (UINTN)(((UINT32)-1)>>1)) ) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ if ((INT32) ModeNumber >= This->Mode->MaxMode) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+ //\r
+ // If the mode is being set to the curent mode, then just clear the screen and return.\r
+ //\r
+ if (Private->TextOutMode.Mode == (INT32) ModeNumber) {\r
+ return ConSplitterTextOutClearScreen (This);\r
+ }\r
+ //\r
+ // return the worst status met\r
+ //\r
+ TextOutModeMap = Private->TextOutModeMap + Private->TextOutListCount * ModeNumber;\r
+ for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r
+\r
+ if (Private->TextOutList[Index].TextOutEnabled) {\r
+ Status = Private->TextOutList[Index].TextOut->SetMode (\r
+ Private->TextOutList[Index].TextOut,\r
+ TextOutModeMap[Index]\r
+ );\r
+ //\r
+ // If this console device is based on a UGA device, then sync up the bitmap from\r
+ // the UGA splitter and reclear the text portion of the display in the new mode.\r
+ //\r
+ if ((Private->TextOutList[Index].GraphicsOutput != NULL) || (Private->TextOutList[Index].UgaDraw != NULL)) {\r
+ Private->TextOutList[Index].TextOut->ClearScreen (Private->TextOutList[Index].TextOut);\r
+ }\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+ }\r
+ }\r
+ //\r
+ // The DevNull Console will support any possible mode as it allocates memory\r
+ //\r
+ Status = DevNullTextOutSetMode (Private, ModeNumber);\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+\r
+ return ReturnStatus;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutSetAttribute (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN Attribute\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Sets the background and foreground colors for the OutputString () and\r
+ ClearScreen () functions.\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ Attribute - The attribute to set. Bits 0..3 are the foreground color, and\r
+ bits 4..6 are the background color. All other bits are undefined\r
+ and must be zero. The valid Attributes are defined in this file.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The attribute was set.\r
+ EFI_DEVICE_ERROR - The device had an error and\r
+ could not complete the request.\r
+ EFI_UNSUPPORTED - The attribute requested is not defined.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r
+ UINTN Index;\r
+ EFI_STATUS ReturnStatus;\r
+\r
+ Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+ //\r
+ // Check whether param Attribute is valid.\r
+ //\r
+ if ( (Attribute > (UINTN)(((UINT32)-1)>>1)) ) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // return the worst status met\r
+ //\r
+ for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r
+\r
+ if (Private->TextOutList[Index].TextOutEnabled) {\r
+ Status = Private->TextOutList[Index].TextOut->SetAttribute (\r
+ Private->TextOutList[Index].TextOut,\r
+ Attribute\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+ }\r
+ }\r
+\r
+ Private->TextOutMode.Attribute = (INT32) Attribute;\r
+\r
+ return ReturnStatus;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutClearScreen (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Clears the output device(s) display to the currently selected background\r
+ color.\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The operation completed successfully.\r
+ EFI_DEVICE_ERROR - The device had an error and\r
+ could not complete the request.\r
+ EFI_UNSUPPORTED - The output device is not in a valid text mode.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r
+ UINTN Index;\r
+ EFI_STATUS ReturnStatus;\r
+\r
+ Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+ //\r
+ // return the worst status met\r
+ //\r
+ for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r
+\r
+ if (Private->TextOutList[Index].TextOutEnabled) {\r
+ Status = Private->TextOutList[Index].TextOut->ClearScreen (Private->TextOutList[Index].TextOut);\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+ }\r
+ }\r
+\r
+ Status = DevNullTextOutClearScreen (Private);\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+\r
+ return ReturnStatus;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutSetCursorPosition (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN Column,\r
+ IN UINTN Row\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Sets the current coordinates of the cursor position\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ Column, Row - the position to set the cursor to. Must be greater than or\r
+ equal to zero and less than the number of columns and rows\r
+ by QueryMode ().\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The operation completed successfully.\r
+ EFI_DEVICE_ERROR - The device had an error and\r
+ could not complete the request.\r
+ EFI_UNSUPPORTED - The output device is not in a valid text mode, or the\r
+ cursor position is invalid for the current mode.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r
+ UINTN Index;\r
+ EFI_STATUS ReturnStatus;\r
+ UINTN MaxColumn;\r
+ UINTN MaxRow;\r
+\r
+ Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+ MaxColumn = Private->TextOutQueryData[Private->TextOutMode.Mode].Columns;\r
+ MaxRow = Private->TextOutQueryData[Private->TextOutMode.Mode].Rows;\r
+\r
+ if (Column >= MaxColumn || Row >= MaxRow) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+ //\r
+ // return the worst status met\r
+ //\r
+ for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r
+\r
+ if (Private->TextOutList[Index].TextOutEnabled) {\r
+ Status = Private->TextOutList[Index].TextOut->SetCursorPosition (\r
+ Private->TextOutList[Index].TextOut,\r
+ Column,\r
+ Row\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+ }\r
+ }\r
+\r
+ DevNullTextOutSetCursorPosition (Private, Column, Row);\r
+\r
+ return ReturnStatus;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutEnableCursor (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN BOOLEAN Visible\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Makes the cursor visible or invisible\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ Visible - If TRUE, the cursor is set to be visible. If FALSE, the cursor is\r
+ set to be invisible.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The operation completed successfully.\r
+ EFI_DEVICE_ERROR - The device had an error and could not complete the\r
+ request, or the device does not support changing\r
+ the cursor mode.\r
+ EFI_UNSUPPORTED - The output device is not in a valid text mode.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r
+ UINTN Index;\r
+ EFI_STATUS ReturnStatus;\r
+\r
+ Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+ //\r
+ // return the worst status met\r
+ //\r
+ for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r
+\r
+ if (Private->TextOutList[Index].TextOutEnabled) {\r
+ Status = Private->TextOutList[Index].TextOut->EnableCursor (\r
+ Private->TextOutList[Index].TextOut,\r
+ Visible\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+ }\r
+ }\r
+\r
+ DevNullTextOutEnableCursor (Private, Visible);\r
+\r
+ return ReturnStatus;\r
+}\r
--- /dev/null
+/**@file\r
+ Private data structures for the Console Splitter driver\r
+\r
+Copyright (c) 2006 - 2007 Intel Corporation. <BR>\r
+All rights reserved. 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
+**/\r
+\r
+#ifndef _CON_SPLITTER_H_\r
+#define _CON_SPLITTER_H_\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+//\r
+// Private Data Structures\r
+//\r
+#define CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT 32\r
+#define CONSOLE_SPLITTER_MODES_ALLOC_UNIT 32\r
+#define MAX_STD_IN_PASSWORD 80\r
+\r
+typedef struct {\r
+ UINTN Columns;\r
+ UINTN Rows;\r
+} TEXT_OUT_SPLITTER_QUERY_DATA;\r
+\r
+//\r
+// Private data for the EFI_SIMPLE_TEXT_INPUT_PROTOCOL splitter\r
+//\r
+#define TEXT_IN_SPLITTER_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('T', 'i', 'S', 'p')\r
+\r
+typedef struct {\r
+ UINT64 Signature;\r
+ EFI_HANDLE VirtualHandle;\r
+\r
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL TextIn;\r
+ UINTN CurrentNumberOfConsoles;\r
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL **TextInList;\r
+ UINTN TextInListCount;\r
+\r
+ EFI_SIMPLE_POINTER_PROTOCOL SimplePointer;\r
+ EFI_SIMPLE_POINTER_MODE SimplePointerMode;\r
+ UINTN CurrentNumberOfPointers;\r
+ EFI_SIMPLE_POINTER_PROTOCOL **PointerList;\r
+ UINTN PointerListCount;\r
+\r
+ BOOLEAN PasswordEnabled;\r
+ CHAR16 Password[MAX_STD_IN_PASSWORD];\r
+ UINTN PwdIndex;\r
+ CHAR16 PwdAttempt[MAX_STD_IN_PASSWORD];\r
+ EFI_EVENT LockEvent;\r
+\r
+ BOOLEAN KeyEventSignalState;\r
+ BOOLEAN InputEventSignalState;\r
+} TEXT_IN_SPLITTER_PRIVATE_DATA;\r
+\r
+#define TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS(a) \\r
+ CR ((a), \\r
+ TEXT_IN_SPLITTER_PRIVATE_DATA, \\r
+ TextIn, \\r
+ TEXT_IN_SPLITTER_PRIVATE_DATA_SIGNATURE \\r
+ )\r
+\r
+#define TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS(a) \\r
+ CR ((a), \\r
+ TEXT_IN_SPLITTER_PRIVATE_DATA, \\r
+ SimplePointer, \\r
+ TEXT_IN_SPLITTER_PRIVATE_DATA_SIGNATURE \\r
+ )\r
+\r
+//\r
+// Private data for the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL splitter\r
+//\r
+#define TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('T', 'o', 'S', 'p')\r
+\r
+typedef struct {\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r
+ BOOLEAN TextOutEnabled;\r
+} TEXT_OUT_AND_GOP_DATA;\r
+\r
+typedef struct {\r
+ UINT32 HorizontalResolution;\r
+ UINT32 VerticalResolution;\r
+} TEXT_OUT_GOP_MODE;\r
+\r
+typedef struct {\r
+ UINT64 Signature;\r
+ EFI_HANDLE VirtualHandle;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL TextOut;\r
+ EFI_SIMPLE_TEXT_OUTPUT_MODE TextOutMode;\r
+\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *GraphicsOutputBlt;\r
+ TEXT_OUT_GOP_MODE *GraphicsOutputModeBuffer;\r
+ UINTN CurrentNumberOfGraphicsOutput;\r
+ BOOLEAN HardwareNeedsStarting;\r
+\r
+ EFI_CONSOLE_CONTROL_PROTOCOL ConsoleControl;\r
+\r
+ UINTN CurrentNumberOfConsoles;\r
+ TEXT_OUT_AND_GOP_DATA *TextOutList;\r
+ UINTN TextOutListCount;\r
+ TEXT_OUT_SPLITTER_QUERY_DATA *TextOutQueryData;\r
+ UINTN TextOutQueryDataCount;\r
+ INT32 *TextOutModeMap;\r
+\r
+ EFI_CONSOLE_CONTROL_SCREEN_MODE ConsoleOutputMode;\r
+\r
+ UINTN DevNullColumns;\r
+ UINTN DevNullRows;\r
+ CHAR16 *DevNullScreen;\r
+ INT32 *DevNullAttributes;\r
+\r
+} TEXT_OUT_SPLITTER_PRIVATE_DATA;\r
+\r
+#define TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS(a) \\r
+ CR ((a), \\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA, \\r
+ TextOut, \\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE \\r
+ )\r
+\r
+#define GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS(a) \\r
+ CR ((a), \\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA, \\r
+ GraphicsOutput, \\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE \\r
+ )\r
+\r
+#define UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS(a) \\r
+ CR ((a), \\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA, \\r
+ UgaDraw, \\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE \\r
+ )\r
+\r
+#define CONSOLE_CONTROL_SPLITTER_PRIVATE_DATA_FROM_THIS(a) \\r
+ CR ((a), \\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA, \\r
+ ConsoleControl, \\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE \\r
+ )\r
+\r
+//\r
+// Function Prototypes\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterDriverEntry (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+ConSplitterTextInConstructor (\r
+ TEXT_IN_SPLITTER_PRIVATE_DATA *Private\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+ConSplitterTextOutConstructor (\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA *Private\r
+ )\r
+;\r
+\r
+//\r
+// Driver Binding Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterConInDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterSimplePointerDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterConOutDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterStdErrDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterConInDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterSimplePointerDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterConOutDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterStdErrDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterConInDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterSimplePointerDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterConOutDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterStdErrDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterComponentNameGetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **DriverName\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterConInComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterSimplePointerComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterConOutComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterStdErrComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ );\r
+\r
+//\r
+// TextIn Constructor/Destructor functions\r
+//\r
+EFI_STATUS\r
+ConSplitterTextInAddDevice (\r
+ IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+ConSplitterTextInDeleteDevice (\r
+ IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn\r
+ )\r
+;\r
+\r
+//\r
+// SimplePointer Constuctor/Destructor functions\r
+//\r
+EFI_STATUS\r
+ConSplitterSimplePointerAddDevice (\r
+ IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+ConSplitterSimplePointerDeleteDevice (\r
+ IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer\r
+ )\r
+;\r
+\r
+//\r
+// TextOut Constuctor/Destructor functions\r
+//\r
+EFI_STATUS\r
+ConSplitterTextOutAddDevice (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut,\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,\r
+ IN EFI_UGA_DRAW_PROTOCOL *UgaDraw\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+ConSplitterTextOutDeleteDevice (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut\r
+ )\r
+;\r
+\r
+//\r
+// TextIn I/O Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextInReset (\r
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
+ IN BOOLEAN ExtendedVerification\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextInReadKeyStroke (\r
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
+ OUT EFI_INPUT_KEY *Key\r
+ )\r
+;\r
+\r
+VOID\r
+EFIAPI\r
+ConSplitterTextInWaitForKey (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+;\r
+\r
+BOOLEAN\r
+ConSpliterConssoleControlStdInLocked (\r
+ VOID\r
+ )\r
+;\r
+\r
+VOID\r
+EFIAPI\r
+ConSpliterConsoleControlLockStdInEvent (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSpliterConsoleControlLockStdIn (\r
+ IN EFI_CONSOLE_CONTROL_PROTOCOL *This,\r
+ IN CHAR16 *Password\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextInPrivateReadKeyStroke (\r
+ IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r
+ OUT EFI_INPUT_KEY *Key\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterSimplePointerReset (\r
+ IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r
+ IN BOOLEAN ExtendedVerification\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterSimplePointerGetState (\r
+ IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r
+ IN OUT EFI_SIMPLE_POINTER_STATE *State\r
+ )\r
+;\r
+\r
+VOID\r
+EFIAPI\r
+ConSplitterSimplePointerWaitForInput (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+;\r
+\r
+//\r
+// TextOut I/O Functions\r
+//\r
+VOID\r
+ConSplitterSynchronizeModeData (\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA *Private\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutReset (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN BOOLEAN ExtendedVerification\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutOutputString (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN CHAR16 *WString\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutTestString (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN CHAR16 *WString\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutQueryMode (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN ModeNumber,\r
+ OUT UINTN *Columns,\r
+ OUT UINTN *Rows\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutSetMode (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN ModeNumber\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutSetAttribute (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN Attribute\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutClearScreen (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutSetCursorPosition (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN Column,\r
+ IN UINTN Row\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterTextOutEnableCursor (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN BOOLEAN Visible\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+ConSplitterGrowBuffer (\r
+ IN UINTN SizeOfCount,\r
+ IN UINTN *Count,\r
+ IN OUT VOID **Buffer\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSpliterConsoleControlGetMode (\r
+ IN EFI_CONSOLE_CONTROL_PROTOCOL *This,\r
+ OUT EFI_CONSOLE_CONTROL_SCREEN_MODE *Mode,\r
+ OUT BOOLEAN *GopExists,\r
+ OUT BOOLEAN *StdInLocked\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSpliterConsoleControlSetMode (\r
+ IN EFI_CONSOLE_CONTROL_PROTOCOL *This,\r
+ IN EFI_CONSOLE_CONTROL_SCREEN_MODE Mode\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSpliterGraphicsOutputQueryMode (\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
+ IN UINT32 ModeNumber,\r
+ OUT UINTN *SizeOfInfo,\r
+ OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSpliterGraphicsOutputSetMode (\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This,\r
+ IN UINT32 ModeNumber\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSpliterGraphicsOutputBlt (\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r
+ IN UINTN SourceX,\r
+ IN UINTN SourceY,\r
+ IN UINTN DestinationX,\r
+ IN UINTN DestinationY,\r
+ IN UINTN Width,\r
+ IN UINTN Height,\r
+ IN UINTN Delta OPTIONAL\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+DevNullGopSync (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,\r
+ IN EFI_UGA_DRAW_PROTOCOL *UgaDraw\r
+ )\r
+;\r
+\r
+\r
+EFI_STATUS\r
+DevNullTextOutOutputString (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN CHAR16 *WString\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+DevNullTextOutSetMode (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN UINTN ModeNumber\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+DevNullTextOutClearScreen (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+DevNullTextOutSetCursorPosition (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN UINTN Column,\r
+ IN UINTN Row\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+DevNullTextOutEnableCursor (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN BOOLEAN Visible\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+DevNullSyncGopStdOut (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private\r
+ )\r
+;\r
+\r
+#endif\r
--- /dev/null
+#/** @file\r
+# Component description file for ConSplitter module.\r
+#\r
+# Any Handle that attatched EFI_CONSOLE_IDENTIFIER_PROTOCOL can be bound by this driver.\r
+# Copyright (c) 2006 - 2007, Intel Corporation\r
+#\r
+# All rights reserved. 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
+# 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
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = ConSplitter\r
+ FILE_GUID = 408edcec-cf6d-477c-a5a8-b4844e3de281\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+ ENTRY_POINT = InitializeConSplitter\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+# DRIVER_BINDING = gConSplitterConInDriverBinding \r
+# COMPONENT_NAME = gConSplitterConInComponentName \r
+# DRIVER_BINDING = gConSplitterSimplePointerDriverBinding \r
+# COMPONENT_NAME = gConSplitterSimplePointerComponentName \r
+# DRIVER_BINDING = gConSplitterConOutDriverBinding \r
+# COMPONENT_NAME = gConSplitterConOutComponentName \r
+# DRIVER_BINDING = gConSplitterStdErrDriverBinding \r
+# COMPONENT_NAME = gConSplitterStdErrComponentName \r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ ConSplitterGraphics.c\r
+ ComponentName.c\r
+ ConSplitter.h\r
+ ConSplitter.c\r
+ CommonHeader.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ UefiBootServicesTableLib\r
+ MemoryAllocationLib\r
+ BaseMemoryLib\r
+ BaseLib\r
+ UefiLib\r
+ UefiDriverEntryPoint\r
+ DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Guid C Name Section - list of Guids that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Guids]\r
+ gEfiConsoleInDeviceGuid # ALWAYS_CONSUMED\r
+ gEfiStandardErrorDeviceGuid # ALWAYS_CONSUMED\r
+ gEfiConsoleOutDeviceGuid # ALWAYS_CONSUMED\r
+ gEfiPrimaryConsoleOutDeviceGuid # ALWAYS_PRODUCED\r
+ gEfiPrimaryConsoleInDeviceGuid # ALWAYS_PRODUCED\r
+ gEfiPrimaryStandardErrorDeviceGuid # ALWAYS_PRODUCED\r
+\r
+\r
+################################################################################\r
+#\r
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
+# that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Protocols]\r
+ gEfiConsoleControlProtocolGuid # PROTOCOL ALWAYS_PRODUCED\r
+ gEfiSimplePointerProtocolGuid # PROTOCOL ALWAYS_PRODUCED\r
+ gEfiSimpleTextInProtocolGuid # PROTOCOL ALWAYS_PRODUCED\r
+ gEfiSimpleTextOutProtocolGuid # PROTOCOL ALWAYS_PRODUCED\r
+ gEfiGraphicsOutputProtocolGuid # PROTOCOL ALWAYS_PRODUCED\r
+ gEfiUgaDrawProtocolGuid # PROTOCOL ALWAYS_PRODUCED\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+ <MsaHeader>\r
+ <ModuleName>ConSplitter</ModuleName>\r
+ <ModuleType>DXE_DRIVER</ModuleType>\r
+ <GuidValue>408edcec-cf6d-477c-a5a8-b4844e3de281</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Component description file for ConSplitter module.</Abstract>\r
+ <Description>Any Handle that attatched EFI_CONSOLE_IDENTIFIER_PROTOCOL can be bound by this driver.</Description>\r
+ <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
+ <License>All rights reserved. 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
+ 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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>ConSplitter</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED" RecommendedInstanceGuid="bda39d3a-451b-4350-8266-81ab10fa0523">\r
+ <Keyword>DebugLib</Keyword>\r
+ <HelpText>Recommended libary Instance is PeiDxeDebugLibReportStatusCode instance in MdePkg.</HelpText>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiDriverModelLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiDriverEntryPoint</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseMemoryLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>MemoryAllocationLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiBootServicesTableLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>ConSplitter.c</Filename>\r
+ <Filename>ConSplitter.h</Filename>\r
+ <Filename>ComponentName.c</Filename>\r
+ <Filename>ConSplitterGraphics.c</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+ </PackageDependencies>\r
+ <Protocols>\r
+ <Protocol Usage="ALWAYS_PRODUCED">\r
+ <ProtocolCName>gEfiUgaDrawProtocolGuid</ProtocolCName>\r
+ <HelpText>UGA Draw protocol is only installed in EFI mode.</HelpText>\r
+ </Protocol>\r
+ <Protocol Usage="ALWAYS_PRODUCED">\r
+ <ProtocolCName>gEfiGraphicsOutputProtocolGuid</ProtocolCName>\r
+ <HelpText>Graphics Output Protocol is only installed in UEFI mode.</HelpText>\r
+ </Protocol>\r
+ <Protocol Usage="ALWAYS_PRODUCED">\r
+ <ProtocolCName>gEfiSimpleTextOutProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="ALWAYS_PRODUCED">\r
+ <ProtocolCName>gEfiSimpleTextInProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="ALWAYS_PRODUCED">\r
+ <ProtocolCName>gEfiSimplePointerProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="ALWAYS_PRODUCED">\r
+ <ProtocolCName>gEfiConsoleControlProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ </Protocols>\r
+ <Guids>\r
+ <GuidCNames Usage="ALWAYS_PRODUCED">\r
+ <GuidCName>gEfiPrimaryStandardErrorDeviceGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="ALWAYS_PRODUCED">\r
+ <GuidCName>gEfiPrimaryConsoleInDeviceGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="ALWAYS_PRODUCED">\r
+ <GuidCName>gEfiPrimaryConsoleOutDeviceGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiConsoleOutDeviceGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiStandardErrorDeviceGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiConsoleInDeviceGuid</GuidCName>\r
+ </GuidCNames>\r
+ </Guids>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ <Extern>\r
+ <ModuleEntryPoint>ConSplitterDriverEntry</ModuleEntryPoint>\r
+ </Extern>\r
+ <Extern>\r
+ <DriverBinding>gConSplitterConInDriverBinding</DriverBinding>\r
+ <ComponentName>gConSplitterConInComponentName</ComponentName>\r
+ </Extern>\r
+ <Extern>\r
+ <DriverBinding>gConSplitterSimplePointerDriverBinding</DriverBinding>\r
+ <ComponentName>gConSplitterSimplePointerComponentName</ComponentName>\r
+ </Extern>\r
+ <Extern>\r
+ <DriverBinding>gConSplitterConOutDriverBinding</DriverBinding>\r
+ <ComponentName>gConSplitterConOutComponentName</ComponentName>\r
+ </Extern>\r
+ <Extern>\r
+ <DriverBinding>gConSplitterStdErrDriverBinding</DriverBinding>\r
+ <ComponentName>gConSplitterStdErrComponentName</ComponentName>\r
+ </Extern>\r
+ </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation\r
+All rights reserved. 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
+ ConSplitterGraphics.c\r
+\r
+Abstract:\r
+\r
+ Support for ConsoleControl protocol. Support for UGA Draw spliter.\r
+ Support for DevNull Console Out. This console uses memory buffers\r
+ to represnt the console. It allows a console to start very early and\r
+ when a new console is added it is synced up with the current console\r
+\r
+--*/\r
+\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "ConSplitter.h"\r
+\r
+#include <Protocol/FrameworkHii.h>\r
+\r
+static CHAR16 mCrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL };\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSpliterConsoleControlGetMode (\r
+ IN EFI_CONSOLE_CONTROL_PROTOCOL *This,\r
+ OUT EFI_CONSOLE_CONTROL_SCREEN_MODE *Mode,\r
+ OUT BOOLEAN *GopExists,\r
+ OUT BOOLEAN *StdInLocked\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Return the current video mode information. Also returns info about existence\r
+ of UGA Draw devices in system, and if the Std In device is locked. All the\r
+ arguments are optional and only returned if a non NULL pointer is passed in.\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ Mode - Are we in text of grahics mode.\r
+ UgaExists - TRUE if UGA Spliter has found a UGA device\r
+ StdInLocked - TRUE if StdIn device is keyboard locked\r
+\r
+ Returns:\r
+ EFI_SUCCESS - Mode information returned.\r
+ EFI_INVALID_PARAMETER - Invalid parameters.\r
+\r
+--*/\r
+{\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r
+ UINTN Index;\r
+\r
+ Private = CONSOLE_CONTROL_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+ if (Mode == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ *Mode = Private->ConsoleOutputMode;\r
+\r
+ if (GopExists != NULL) {\r
+ *GopExists = FALSE;\r
+ for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r
+ if ((Private->TextOutList[Index].GraphicsOutput != NULL) || (Private->TextOutList[Index].UgaDraw != NULL)) {\r
+ *GopExists = TRUE;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ if (StdInLocked != NULL) {\r
+ *StdInLocked = ConSpliterConssoleControlStdInLocked ();\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSpliterConsoleControlSetMode (\r
+ IN EFI_CONSOLE_CONTROL_PROTOCOL *This,\r
+ IN EFI_CONSOLE_CONTROL_SCREEN_MODE Mode\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Set the current mode to either text or graphics. Graphics is\r
+ for Quiet Boot.\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ Mode - Mode to set the\r
+\r
+ Returns:\r
+ EFI_SUCCESS - Mode information returned.\r
+ EFI_INVALID_PARAMETER - Invalid parameter.\r
+ EFI_UNSUPPORTED - Operation unsupported.\r
+\r
+--*/\r
+{\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r
+ UINTN Index;\r
+ TEXT_OUT_AND_GOP_DATA *TextAndGop;\r
+ BOOLEAN Supported;\r
+\r
+ Private = CONSOLE_CONTROL_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+ if (Mode >= EfiConsoleControlScreenMaxValue) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // Judge current mode with wanted mode at first.\r
+ //\r
+ if (Private->ConsoleOutputMode == Mode) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ Supported = FALSE;\r
+ TextAndGop = &Private->TextOutList[0];\r
+ for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++, TextAndGop++) {\r
+ if ((TextAndGop->GraphicsOutput != NULL) || (TextAndGop->UgaDraw != NULL)) {\r
+ Supported = TRUE;\r
+ break;\r
+ }\r
+ }\r
+\r
+ if ((!Supported) && (Mode == EfiConsoleControlScreenGraphics)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ Private->ConsoleOutputMode = Mode;\r
+\r
+ TextAndGop = &Private->TextOutList[0];\r
+ for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++, TextAndGop++) {\r
+\r
+ TextAndGop->TextOutEnabled = TRUE;\r
+ //\r
+ // If we are going into Graphics mode disable ConOut to any UGA device\r
+ //\r
+ if ((Mode == EfiConsoleControlScreenGraphics) &&((TextAndGop->GraphicsOutput != NULL) || (TextAndGop->UgaDraw != NULL))) {\r
+ TextAndGop->TextOutEnabled = FALSE;\r
+ DevNullGopSync (Private, TextAndGop->GraphicsOutput, TextAndGop->UgaDraw);\r
+ }\r
+ }\r
+\r
+ if (Mode == EfiConsoleControlScreenText) {\r
+ DevNullSyncGopStdOut (Private);\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSpliterGraphicsOutputQueryMode (\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
+ IN UINT32 ModeNumber,\r
+ OUT UINTN *SizeOfInfo,\r
+ OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Return the current video mode information.\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ ModeNumber - The mode number to return information on.\r
+ Info - Caller allocated buffer that returns information about ModeNumber.\r
+ SizeOfInfo - A pointer to the size, in bytes, of the Info buffer.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - Mode information returned.\r
+ EFI_BUFFER_TOO_SMALL - The Info buffer was too small.\r
+ EFI_DEVICE_ERROR - A hardware error occurred trying to retrieve the video mode.\r
+ EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()\r
+ EFI_INVALID_PARAMETER - One of the input args was NULL.\r
+\r
+--*/\r
+{\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r
+ TEXT_OUT_GOP_MODE *Mode;\r
+\r
+ if (This == NULL || Info == NULL || SizeOfInfo == NULL || ModeNumber >= This->Mode->MaxMode) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // retrieve private data\r
+ //\r
+ Private = GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+ if (Private->HardwareNeedsStarting) {\r
+ return EFI_NOT_STARTED;\r
+ }\r
+\r
+ *Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r
+\r
+ if (*Info == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r
+\r
+ CopyMem (*Info, Private->GraphicsOutput.Mode->Info, *SizeOfInfo);\r
+ Mode = &Private->GraphicsOutputModeBuffer[ModeNumber];\r
+ (*Info)->HorizontalResolution = Mode->HorizontalResolution;\r
+ (*Info)->VerticalResolution = Mode->VerticalResolution;\r
+ (*Info)->PixelsPerScanLine = Mode->HorizontalResolution;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSpliterGraphicsOutputSetMode (\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This,\r
+ IN UINT32 ModeNumber\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Graphics output protocol interface to set video mode\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ ModeNumber - The mode number to be set.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - Graphics mode was changed.\r
+ EFI_DEVICE_ERROR - The device had an error and could not complete the request.\r
+ EFI_UNSUPPORTED - ModeNumber is not supported by this device.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r
+ UINTN Index;\r
+ EFI_STATUS ReturnStatus;\r
+ TEXT_OUT_GOP_MODE *Mode;\r
+ UINTN Size;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+ UINTN NumberIndex;\r
+ UINTN SizeOfInfo;\r
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+\r
+ if (ModeNumber >= This->Mode->MaxMode) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ if (ModeNumber == This->Mode->Mode) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ Private = GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+ //\r
+ // GopDevNullSetMode ()\r
+ //\r
+ ReturnStatus = EFI_SUCCESS;\r
+\r
+ //\r
+ // Free the old version\r
+ //\r
+ if (Private->GraphicsOutputBlt != NULL) {\r
+ FreePool (Private->GraphicsOutputBlt);\r
+ }\r
+\r
+ //\r
+ // Allocate the virtual Blt buffer\r
+ //\r
+ Mode = &Private->GraphicsOutputModeBuffer[ModeNumber];\r
+ Size = Mode->HorizontalResolution * Mode->VerticalResolution * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);\r
+ Private->GraphicsOutputBlt = AllocateZeroPool (Size);\r
+\r
+ if (Private->GraphicsOutputBlt == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ if (!Private->HardwareNeedsStarting) {\r
+ if (Private->ConsoleOutputMode != EfiConsoleControlScreenGraphics) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+ }\r
+ //\r
+ // return the worst status met\r
+ //\r
+ for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r
+ GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;\r
+ if (GraphicsOutput != NULL) {\r
+ //\r
+ // Find corresponding ModeNumber of this GraphicsOutput instance\r
+ //\r
+ for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex ++) {\r
+ Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ if ((Info->HorizontalResolution == Mode->HorizontalResolution) && (Info->VerticalResolution == Mode->VerticalResolution)) {\r
+ FreePool (Info);\r
+ break;\r
+ }\r
+ FreePool (Info);\r
+ }\r
+\r
+ Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32) NumberIndex);\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+ }\r
+\r
+ UgaDraw = Private->TextOutList[Index].UgaDraw;\r
+ if (UgaDraw != NULL) {\r
+ Status = UgaDraw->SetMode (\r
+ UgaDraw,\r
+ Mode->HorizontalResolution,\r
+ Mode->VerticalResolution,\r
+ 32,\r
+ 60\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+ }\r
+ }\r
+\r
+ This->Mode->Mode = ModeNumber;\r
+\r
+ Info = This->Mode->Info;\r
+ Info->HorizontalResolution = Mode->HorizontalResolution;\r
+ Info->VerticalResolution = Mode->VerticalResolution;\r
+ Info->PixelsPerScanLine = Mode->HorizontalResolution;\r
+\r
+ //\r
+ // Information is not enough here, so the following items remain unchanged:\r
+ // GraphicsOutputMode->Info->Version, GraphicsOutputMode->Info->PixelFormat\r
+ // GraphicsOutputMode->SizeOfInfo, GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize\r
+ // These items will be initialized/updated when a new GOP device is added into ConsoleSplitter.\r
+ //\r
+\r
+ Private->HardwareNeedsStarting = FALSE;\r
+\r
+ return ReturnStatus;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+DevNullGraphicsOutputBlt (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r
+ IN UINTN SourceX,\r
+ IN UINTN SourceY,\r
+ IN UINTN DestinationX,\r
+ IN UINTN DestinationY,\r
+ IN UINTN Width,\r
+ IN UINTN Height,\r
+ IN UINTN Delta OPTIONAL\r
+ )\r
+{\r
+ UINTN SrcY;\r
+ BOOLEAN Forward;\r
+ UINTN Index;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltPtr;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ScreenPtr;\r
+ UINTN HorizontalResolution;\r
+ UINTN VerticalResolution;\r
+\r
+ if ((BltOperation < EfiBltVideoFill) || (BltOperation >= EfiGraphicsOutputBltOperationMax)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (Width == 0 || Height == 0) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (Delta == 0) {\r
+ Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);\r
+ }\r
+\r
+ HorizontalResolution = Private->GraphicsOutput.Mode->Info->HorizontalResolution;\r
+ VerticalResolution = Private->GraphicsOutput.Mode->Info->VerticalResolution;\r
+\r
+ //\r
+ // We need to fill the Virtual Screen buffer with the blt data.\r
+ //\r
+ if (BltOperation == EfiBltVideoToBltBuffer) {\r
+ //\r
+ // Video to BltBuffer: Source is Video, destination is BltBuffer\r
+ //\r
+ if ((SourceY + Height) > VerticalResolution) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if ((SourceX + Width) > HorizontalResolution) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ BltPtr = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) ((UINT8 *) BltBuffer + DestinationY * Delta + DestinationX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+ ScreenPtr = &Private->GraphicsOutputBlt[SourceY * HorizontalResolution + SourceX];\r
+ while (Height) {\r
+ CopyMem (BltPtr, ScreenPtr, Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+ BltPtr = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) ((UINT8 *) BltPtr + Delta);\r
+ ScreenPtr += HorizontalResolution;\r
+ Height--;\r
+ }\r
+ } else {\r
+ //\r
+ // BltBuffer to Video: Source is BltBuffer, destination is Video\r
+ //\r
+ if (DestinationY + Height > VerticalResolution) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (DestinationX + Width > HorizontalResolution) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if ((BltOperation == EfiBltVideoToVideo) && (DestinationY > SourceY)) {\r
+ //\r
+ // Copy backwards, only care the Video to Video Blt\r
+ //\r
+ ScreenPtr = &Private->GraphicsOutputBlt[(DestinationY + Height - 1) * HorizontalResolution + DestinationX];\r
+ SrcY = SourceY + Height - 1;\r
+ Forward = FALSE;\r
+ } else {\r
+ //\r
+ // Copy forwards, for other cases\r
+ //\r
+ ScreenPtr = &Private->GraphicsOutputBlt[DestinationY * HorizontalResolution + DestinationX];\r
+ SrcY = SourceY;\r
+ Forward = TRUE;\r
+ }\r
+\r
+ while (Height != 0) {\r
+ if (BltOperation == EfiBltVideoFill) {\r
+ for (Index = 0; Index < Width; Index++) {\r
+ ScreenPtr[Index] = *BltBuffer;\r
+ }\r
+ } else {\r
+ if (BltOperation == EfiBltBufferToVideo) {\r
+ BltPtr = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) ((UINT8 *) BltBuffer + SrcY * Delta + SourceX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+ } else {\r
+ BltPtr = &Private->GraphicsOutputBlt[SrcY * HorizontalResolution + SourceX];\r
+ }\r
+\r
+ CopyMem (ScreenPtr, BltPtr, Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+ }\r
+\r
+ if (Forward) {\r
+ ScreenPtr += HorizontalResolution;\r
+ SrcY ++;\r
+ } else {\r
+ ScreenPtr -= HorizontalResolution;\r
+ SrcY --;\r
+ }\r
+ Height--;\r
+ }\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSpliterGraphicsOutputBlt (\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r
+ IN UINTN SourceX,\r
+ IN UINTN SourceY,\r
+ IN UINTN DestinationX,\r
+ IN UINTN DestinationY,\r
+ IN UINTN Width,\r
+ IN UINTN Height,\r
+ IN UINTN Delta OPTIONAL\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ The following table defines actions for BltOperations:\r
+ EfiBltVideoFill - Write data from the BltBuffer pixel (SourceX, SourceY)\r
+ directly to every pixel of the video display rectangle\r
+ (DestinationX, DestinationY)\r
+ (DestinationX + Width, DestinationY + Height).\r
+ Only one pixel will be used from the BltBuffer. Delta is NOT used.\r
+ EfiBltVideoToBltBuffer - Read data from the video display rectangle\r
+ (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in\r
+ the BltBuffer rectangle (DestinationX, DestinationY )\r
+ (DestinationX + Width, DestinationY + Height). If DestinationX or\r
+ DestinationY is not zero then Delta must be set to the length in bytes\r
+ of a row in the BltBuffer.\r
+ EfiBltBufferToVideo - Write data from the BltBuffer rectangle\r
+ (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the\r
+ video display rectangle (DestinationX, DestinationY)\r
+ (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is\r
+ not zero then Delta must be set to the length in bytes of a row in the\r
+ BltBuffer.\r
+ EfiBltVideoToVideo - Copy from the video display rectangle\r
+ (SourceX, SourceY) (SourceX + Width, SourceY + Height) .\r
+ to the video display rectangle (DestinationX, DestinationY)\r
+ (DestinationX + Width, DestinationY + Height).\r
+ The BltBuffer and Delta are not used in this mode.\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ BltBuffer - Buffer containing data to blit into video buffer. This\r
+ buffer has a size of Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+ BltOperation - Operation to perform on BlitBuffer and video memory\r
+ SourceX - X coordinate of source for the BltBuffer.\r
+ SourceY - Y coordinate of source for the BltBuffer.\r
+ DestinationX - X coordinate of destination for the BltBuffer.\r
+ DestinationY - Y coordinate of destination for the BltBuffer.\r
+ Width - Width of rectangle in BltBuffer in pixels.\r
+ Height - Hight of rectangle in BltBuffer in pixels.\r
+ Delta -\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Blt operation completed.\r
+ EFI_INVALID_PARAMETER - BltOperation is not valid.\r
+ EFI_DEVICE_ERROR - A hardware error occured writting to the video\r
+ buffer.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r
+ UINTN Index;\r
+ EFI_STATUS ReturnStatus;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+\r
+ Private = GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+ //\r
+ // Sync up DevNull GOP device\r
+ //\r
+ ReturnStatus = DevNullGraphicsOutputBlt (\r
+ Private,\r
+ BltBuffer,\r
+ BltOperation,\r
+ SourceX,\r
+ SourceY,\r
+ DestinationX,\r
+ DestinationY,\r
+ Width,\r
+ Height,\r
+ Delta\r
+ );\r
+\r
+ if (Private->ConsoleOutputMode != EfiConsoleControlScreenGraphics) {\r
+ return ReturnStatus;\r
+ }\r
+ //\r
+ // return the worst status met\r
+ //\r
+ for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r
+ GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;\r
+ if (GraphicsOutput != NULL) {\r
+ Status = GraphicsOutput->Blt (\r
+ GraphicsOutput,\r
+ BltBuffer,\r
+ BltOperation,\r
+ SourceX,\r
+ SourceY,\r
+ DestinationX,\r
+ DestinationY,\r
+ Width,\r
+ Height,\r
+ Delta\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ } else if (BltOperation == EfiBltVideoToBltBuffer) {\r
+ //\r
+ // Only need to read the data into buffer one time\r
+ //\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+\r
+ UgaDraw = Private->TextOutList[Index].UgaDraw;\r
+ if (UgaDraw != NULL) {\r
+ Status = UgaDraw->Blt (\r
+ UgaDraw,\r
+ (EFI_UGA_PIXEL *) BltBuffer,\r
+ (EFI_UGA_BLT_OPERATION) BltOperation,\r
+ SourceX,\r
+ SourceY,\r
+ DestinationX,\r
+ DestinationY,\r
+ Width,\r
+ Height,\r
+ Delta\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ } else if (BltOperation == EfiBltVideoToBltBuffer) {\r
+ //\r
+ // Only need to read the data into buffer one time\r
+ //\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+ }\r
+\r
+ return ReturnStatus;\r
+}\r
+\r
+EFI_STATUS\r
+DevNullGopSync (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,\r
+ IN EFI_UGA_DRAW_PROTOCOL *UgaDraw\r
+ )\r
+{\r
+ if (GraphicsOutput != NULL) {\r
+ return GraphicsOutput->Blt (\r
+ GraphicsOutput,\r
+ Private->GraphicsOutputBlt,\r
+ EfiBltBufferToVideo,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ Private->GraphicsOutput.Mode->Info->HorizontalResolution,\r
+ Private->GraphicsOutput.Mode->Info->VerticalResolution,\r
+ 0\r
+ );\r
+ } else {\r
+ return UgaDraw->Blt (\r
+ UgaDraw,\r
+ (EFI_UGA_PIXEL *) Private->GraphicsOutputBlt,\r
+ EfiUgaBltBufferToVideo,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ Private->GraphicsOutput.Mode->Info->HorizontalResolution,\r
+ Private->GraphicsOutput.Mode->Info->VerticalResolution,\r
+ 0\r
+ );\r
+ }\r
+}\r
+\r
+\r
+EFI_STATUS\r
+DevNullTextOutOutputString (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN CHAR16 *WString\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Write a Unicode string to the output device.\r
+\r
+ Arguments:\r
+ Private - Pointer to the console output splitter's private data. It\r
+ indicates the calling context.\r
+ WString - The NULL-terminated Unicode string to be displayed on the output\r
+ device(s). All output devices must also support the Unicode\r
+ drawing defined in this file.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The string was output to the device.\r
+ EFI_DEVICE_ERROR - The device reported an error while attempting to\r
+ output the text.\r
+ EFI_UNSUPPORTED - The output device's mode is not currently in a\r
+ defined text mode.\r
+ EFI_WARN_UNKNOWN_GLYPH - This warning code indicates that some of the\r
+ characters in the Unicode string could not be\r
+ rendered and were skipped.\r
+\r
+--*/\r
+{\r
+ UINTN SizeScreen;\r
+ UINTN SizeAttribute;\r
+ UINTN Index;\r
+ EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;\r
+ CHAR16 *Screen;\r
+ CHAR16 *NullScreen;\r
+ CHAR16 InsertChar;\r
+ CHAR16 TempChar;\r
+ CHAR16 *PStr;\r
+ INT32 *Attribute;\r
+ INT32 *NullAttributes;\r
+ INT32 CurrentWidth;\r
+ UINTN LastRow;\r
+ UINTN MaxColumn;\r
+\r
+ Mode = &Private->TextOutMode;\r
+ NullScreen = Private->DevNullScreen;\r
+ NullAttributes = Private->DevNullAttributes;\r
+ LastRow = Private->DevNullRows - 1;\r
+ MaxColumn = Private->DevNullColumns;\r
+\r
+ if (Mode->Attribute & EFI_WIDE_ATTRIBUTE) {\r
+ CurrentWidth = 2;\r
+ } else {\r
+ CurrentWidth = 1;\r
+ }\r
+\r
+ while (*WString) {\r
+\r
+ if (*WString == CHAR_BACKSPACE) {\r
+ //\r
+ // If the cursor is at the left edge of the display, then move the cursor\r
+ // one row up.\r
+ //\r
+ if (Mode->CursorColumn == 0 && Mode->CursorRow > 0) {\r
+ Mode->CursorRow--;\r
+ Mode->CursorColumn = (INT32) MaxColumn;\r
+ }\r
+\r
+ //\r
+ // If the cursor is not at the left edge of the display,\r
+ // then move the cursor left one column.\r
+ //\r
+ if (Mode->CursorColumn > 0) {\r
+ Mode->CursorColumn--;\r
+ if (Mode->CursorColumn > 0 &&\r
+ NullAttributes[Mode->CursorRow * MaxColumn + Mode->CursorColumn - 1] & EFI_WIDE_ATTRIBUTE\r
+ ) {\r
+ Mode->CursorColumn--;\r
+\r
+ //\r
+ // Insert an extra backspace\r
+ //\r
+ InsertChar = CHAR_BACKSPACE;\r
+ PStr = WString + 1;\r
+ while (*PStr) {\r
+ TempChar = *PStr;\r
+ *PStr = InsertChar;\r
+ InsertChar = TempChar;\r
+ PStr++;\r
+ }\r
+\r
+ *PStr = InsertChar;\r
+ *(++PStr) = 0;\r
+\r
+ WString++;\r
+ }\r
+ }\r
+\r
+ WString++;\r
+\r
+ } else if (*WString == CHAR_LINEFEED) {\r
+ //\r
+ // If the cursor is at the bottom of the display,\r
+ // then scroll the display one row, and do not update\r
+ // the cursor position. Otherwise, move the cursor down one row.\r
+ //\r
+ if (Mode->CursorRow == (INT32) (LastRow)) {\r
+ //\r
+ // Scroll Screen Up One Row\r
+ //\r
+ SizeAttribute = LastRow * MaxColumn;\r
+ CopyMem (\r
+ NullAttributes,\r
+ NullAttributes + MaxColumn,\r
+ SizeAttribute * sizeof (INT32)\r
+ );\r
+\r
+ //\r
+ // Each row has an ending CHAR_NULL. So one more character each line\r
+ // for DevNullScreen than DevNullAttributes\r
+ //\r
+ SizeScreen = SizeAttribute + LastRow;\r
+ CopyMem (\r
+ NullScreen,\r
+ NullScreen + (MaxColumn + 1),\r
+ SizeScreen * sizeof (CHAR16)\r
+ );\r
+\r
+ //\r
+ // Print Blank Line at last line\r
+ //\r
+ Screen = NullScreen + SizeScreen;\r
+ Attribute = NullAttributes + SizeAttribute;\r
+\r
+ for (Index = 0; Index < MaxColumn; Index++, Screen++, Attribute++) {\r
+ *Screen = ' ';\r
+ *Attribute = Mode->Attribute;\r
+ }\r
+ } else {\r
+ Mode->CursorRow++;\r
+ }\r
+\r
+ WString++;\r
+ } else if (*WString == CHAR_CARRIAGE_RETURN) {\r
+ //\r
+ // Move the cursor to the beginning of the current row.\r
+ //\r
+ Mode->CursorColumn = 0;\r
+ WString++;\r
+ } else {\r
+ //\r
+ // Print the character at the current cursor position and\r
+ // move the cursor right one column. If this moves the cursor\r
+ // past the right edge of the display, then the line should wrap to\r
+ // the beginning of the next line. This is equivalent to inserting\r
+ // a CR and an LF. Note that if the cursor is at the bottom of the\r
+ // display, and the line wraps, then the display will be scrolled\r
+ // one line.\r
+ //\r
+ Index = Mode->CursorRow * MaxColumn + Mode->CursorColumn;\r
+\r
+ while (Mode->CursorColumn < (INT32) MaxColumn) {\r
+ if (*WString == CHAR_NULL) {\r
+ break;\r
+ }\r
+\r
+ if (*WString == CHAR_BACKSPACE) {\r
+ break;\r
+ }\r
+\r
+ if (*WString == CHAR_LINEFEED) {\r
+ break;\r
+ }\r
+\r
+ if (*WString == CHAR_CARRIAGE_RETURN) {\r
+ break;\r
+ }\r
+\r
+ if (*WString == WIDE_CHAR || *WString == NARROW_CHAR) {\r
+ CurrentWidth = (*WString == WIDE_CHAR) ? 2 : 1;\r
+ WString++;\r
+ continue;\r
+ }\r
+\r
+ if (Mode->CursorColumn + CurrentWidth > (INT32) MaxColumn) {\r
+ //\r
+ // If a wide char is at the rightmost column, then move the char\r
+ // to the beginning of the next row\r
+ //\r
+ NullScreen[Index + Mode->CursorRow] = L' ';\r
+ NullAttributes[Index] = Mode->Attribute | (UINT32) EFI_WIDE_ATTRIBUTE;\r
+ Index++;\r
+ Mode->CursorColumn++;\r
+ } else {\r
+ NullScreen[Index + Mode->CursorRow] = *WString;\r
+ NullAttributes[Index] = Mode->Attribute;\r
+ if (CurrentWidth == 1) {\r
+ NullAttributes[Index] &= (~ (UINT32) EFI_WIDE_ATTRIBUTE);\r
+ } else {\r
+ NullAttributes[Index] |= (UINT32) EFI_WIDE_ATTRIBUTE;\r
+ NullAttributes[Index + 1] &= (~ (UINT32) EFI_WIDE_ATTRIBUTE);\r
+ }\r
+\r
+ Index += CurrentWidth;\r
+ WString++;\r
+ Mode->CursorColumn += CurrentWidth;\r
+ }\r
+ }\r
+ //\r
+ // At the end of line, output carriage return and line feed\r
+ //\r
+ if (Mode->CursorColumn >= (INT32) MaxColumn) {\r
+ DevNullTextOutOutputString (Private, mCrLfString);\r
+ }\r
+ }\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+DevNullTextOutSetMode (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN UINTN ModeNumber\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Sets the output device(s) to a specified mode.\r
+\r
+ Arguments:\r
+ Private - Private data structure pointer.\r
+ ModeNumber - The mode number to set.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The requested text mode was set.\r
+ EFI_DEVICE_ERROR - The device had an error and\r
+ could not complete the request.\r
+ EFI_UNSUPPORTED - The mode number was not valid.\r
+ EFI_OUT_OF_RESOURCES - Out of resources.\r
+\r
+--*/\r
+{\r
+ UINTN Size;\r
+ UINTN Row;\r
+ UINTN Column;\r
+ TEXT_OUT_SPLITTER_QUERY_DATA *Mode;\r
+\r
+ //\r
+ // No extra check for ModeNumber here, as it has been checked in\r
+ // ConSplitterTextOutSetMode. And mode 0 should always be supported.\r
+ //\r
+ Mode = &(Private->TextOutQueryData[ModeNumber]);\r
+ Row = Mode->Rows;\r
+ Column = Mode->Columns;\r
+\r
+ if (Row <= 0 && Column <= 0) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ if (Private->DevNullColumns != Column || Private->DevNullRows != Row) {\r
+\r
+ Private->TextOutMode.Mode = (INT32) ModeNumber;\r
+ Private->DevNullColumns = Column;\r
+ Private->DevNullRows = Row;\r
+\r
+ if (Private->DevNullScreen != NULL) {\r
+ FreePool (Private->DevNullScreen);\r
+ }\r
+\r
+ Size = (Row * (Column + 1)) * sizeof (CHAR16);\r
+ Private->DevNullScreen = AllocateZeroPool (Size);\r
+ if (Private->DevNullScreen == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ if (Private->DevNullAttributes != NULL) {\r
+ FreePool (Private->DevNullAttributes);\r
+ }\r
+\r
+ Size = Row * Column * sizeof (INT32);\r
+ Private->DevNullAttributes = AllocateZeroPool (Size);\r
+ if (Private->DevNullAttributes == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ }\r
+\r
+ DevNullTextOutClearScreen (Private);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+DevNullTextOutClearScreen (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Clears the output device(s) display to the currently selected background\r
+ color.\r
+\r
+ Arguments:\r
+ Private - Protocol instance pointer.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The operation completed successfully.\r
+ EFI_DEVICE_ERROR - The device had an error and\r
+ could not complete the request.\r
+ EFI_UNSUPPORTED - The output device is not in a valid text mode.\r
+\r
+--*/\r
+{\r
+ UINTN Row;\r
+ UINTN Column;\r
+ CHAR16 *Screen;\r
+ INT32 *Attributes;\r
+ INT32 CurrentAttribute;\r
+\r
+ //\r
+ // Clear the DevNull Text Out Buffers.\r
+ // The screen is filled with spaces.\r
+ // The attributes are all synced with the current Simple Text Out Attribute\r
+ //\r
+ Screen = Private->DevNullScreen;\r
+ Attributes = Private->DevNullAttributes;\r
+ CurrentAttribute = Private->TextOutMode.Attribute;\r
+\r
+ for (Row = 0; Row < Private->DevNullRows; Row++) {\r
+ for (Column = 0; Column < Private->DevNullColumns; Column++, Screen++, Attributes++) {\r
+ *Screen = ' ';\r
+ *Attributes = CurrentAttribute;\r
+ }\r
+ //\r
+ // Each line of the screen has a NULL on the end so we must skip over it\r
+ //\r
+ Screen++;\r
+ }\r
+\r
+ DevNullTextOutSetCursorPosition (Private, 0, 0);\r
+\r
+ return DevNullTextOutEnableCursor (Private, TRUE);\r
+}\r
+\r
+EFI_STATUS\r
+DevNullTextOutSetCursorPosition (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN UINTN Column,\r
+ IN UINTN Row\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Sets the current coordinates of the cursor position\r
+\r
+ Arguments:\r
+ Private - Protocol instance pointer.\r
+ Column, Row - the position to set the cursor to. Must be greater than or\r
+ equal to zero and less than the number of columns and rows\r
+ by QueryMode ().\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The operation completed successfully.\r
+ EFI_DEVICE_ERROR - The device had an error and\r
+ could not complete the request.\r
+ EFI_UNSUPPORTED - The output device is not in a valid text mode, or the\r
+ cursor position is invalid for the current mode.\r
+\r
+--*/\r
+{\r
+ //\r
+ // No need to do extra check here as whether (Column, Row) is valid has\r
+ // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should\r
+ // always be supported.\r
+ //\r
+ Private->TextOutMode.CursorColumn = (INT32) Column;\r
+ Private->TextOutMode.CursorRow = (INT32) Row;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+DevNullTextOutEnableCursor (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r
+ IN BOOLEAN Visible\r
+ )\r
+/*++\r
+ Routine Description:\r
+\r
+ Implements SIMPLE_TEXT_OUTPUT.EnableCursor().\r
+ In this driver, the cursor cannot be hidden.\r
+\r
+ Arguments:\r
+\r
+ Private - Indicates the calling context.\r
+\r
+ Visible - If TRUE, the cursor is set to be visible, If FALSE, the cursor\r
+ is set to be invisible.\r
+\r
+ Returns:\r
+\r
+ EFI_SUCCESS - The request is valid.\r
+\r
+\r
+--*/\r
+{\r
+ Private->TextOutMode.CursorVisible = Visible;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+DevNullSyncGopStdOut (\r
+ IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private\r
+ )\r
+/*++\r
+ Routine Description:\r
+ Take the DevNull TextOut device and update the Simple Text Out on every\r
+ UGA device.\r
+\r
+ Arguments:\r
+ Private - Indicates the calling context.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The request is valid.\r
+ other - Return status of TextOut->OutputString ()\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_STATUS ReturnStatus;\r
+ UINTN Row;\r
+ UINTN Column;\r
+ UINTN List;\r
+ UINTN MaxColumn;\r
+ UINTN CurrentColumn;\r
+ UINTN StartRow;\r
+ UINTN StartColumn;\r
+ INT32 StartAttribute;\r
+ BOOLEAN StartCursorState;\r
+ CHAR16 *Screen;\r
+ CHAR16 *Str;\r
+ CHAR16 *Buffer;\r
+ CHAR16 *BufferTail;\r
+ CHAR16 *ScreenStart;\r
+ INT32 CurrentAttribute;\r
+ INT32 *Attributes;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Sto;\r
+\r
+ //\r
+ // Save the devices Attributes, Cursor enable state and location\r
+ //\r
+ StartColumn = Private->TextOutMode.CursorColumn;\r
+ StartRow = Private->TextOutMode.CursorRow;\r
+ StartAttribute = Private->TextOutMode.Attribute;\r
+ StartCursorState = Private->TextOutMode.CursorVisible;\r
+\r
+ for (List = 0; List < Private->CurrentNumberOfConsoles; List++) {\r
+\r
+ Sto = Private->TextOutList[List].TextOut;\r
+\r
+ //\r
+ // Skip non GOP/UGA devices\r
+ //\r
+ if ((Private->TextOutList[List].GraphicsOutput != NULL) || (Private->TextOutList[List].UgaDraw != NULL)) {\r
+ Sto->EnableCursor (Sto, FALSE);\r
+ Sto->ClearScreen (Sto);\r
+ }\r
+ }\r
+\r
+ ReturnStatus = EFI_SUCCESS;\r
+ Screen = Private->DevNullScreen;\r
+ Attributes = Private->DevNullAttributes;\r
+ MaxColumn = Private->DevNullColumns;\r
+\r
+ Buffer = AllocateZeroPool ((MaxColumn + 1) * sizeof (CHAR16));\r
+\r
+ for (Row = 0; Row < Private->DevNullRows; Row++, Screen += (MaxColumn + 1), Attributes += MaxColumn) {\r
+\r
+ if (Row == (Private->DevNullRows - 1)) {\r
+ //\r
+ // Don't ever sync the last character as it will scroll the screen\r
+ //\r
+ Screen[MaxColumn - 1] = 0x00;\r
+ }\r
+\r
+ Column = 0;\r
+ while (Column < MaxColumn) {\r
+ if (Screen[Column]) {\r
+ CurrentAttribute = Attributes[Column];\r
+ CurrentColumn = Column;\r
+ ScreenStart = &Screen[Column];\r
+\r
+ //\r
+ // the line end is alway 0x0. So Column should be less than MaxColumn\r
+ // It should be still in the same row\r
+ //\r
+ for (Str = ScreenStart, BufferTail = Buffer; *Str != 0; Str++, Column++) {\r
+\r
+ if (Attributes[Column] != CurrentAttribute) {\r
+ Column--;\r
+ break;\r
+ }\r
+\r
+ *BufferTail = *Str;\r
+ BufferTail++;\r
+ if (Attributes[Column] & EFI_WIDE_ATTRIBUTE) {\r
+ Str++;\r
+ Column++;\r
+ }\r
+ }\r
+\r
+ *BufferTail = 0;\r
+\r
+ for (List = 0; List < Private->CurrentNumberOfConsoles; List++) {\r
+\r
+ Sto = Private->TextOutList[List].TextOut;\r
+\r
+ //\r
+ // Skip non GOP/UGA devices\r
+ //\r
+ if ((Private->TextOutList[List].GraphicsOutput != NULL) || (Private->TextOutList[List].UgaDraw != NULL)) {\r
+ Sto->SetAttribute (Sto, CurrentAttribute);\r
+ Sto->SetCursorPosition (Sto, CurrentColumn, Row);\r
+ Status = Sto->OutputString (Sto, Buffer);\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ Column++;\r
+ }\r
+ }\r
+ //\r
+ // Restore the devices Attributes, Cursor enable state and location\r
+ //\r
+ for (List = 0; List < Private->CurrentNumberOfConsoles; List++) {\r
+ Sto = Private->TextOutList[List].TextOut;\r
+\r
+ //\r
+ // Skip non GOP/UGA devices\r
+ //\r
+ if ((Private->TextOutList[List].GraphicsOutput != NULL) || (Private->TextOutList[List].UgaDraw != NULL)) {\r
+ Sto->SetAttribute (Sto, StartAttribute);\r
+ Sto->SetCursorPosition (Sto, StartColumn, StartRow);\r
+ Status = Sto->EnableCursor (Sto, StartCursorState);\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+ }\r
+ }\r
+\r
+ FreePool (Buffer);\r
+\r
+ return ReturnStatus;\r
+}\r
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2006 - 2007, Intel Corporation\r
+ All rights reserved. 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
+ 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
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/FrameworkHii.h>\r
+#include <Protocol/SimpleTextOut.h>\r
+#include <Protocol/GraphicsOutput.h>\r
+#include <Protocol/UgaDraw.h>\r
+#include <Protocol/DevicePath.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/HiiLibFramework.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+//\r
+// Driver Binding Externs\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gGraphicsConsoleComponentName;\r
+\r
+#endif\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ ComponentName.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "GraphicsConsole.h"\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+EFI_COMPONENT_NAME_PROTOCOL gGraphicsConsoleComponentName = {\r
+ GraphicsConsoleComponentNameGetDriverName,\r
+ GraphicsConsoleComponentNameGetControllerName,\r
+ "eng"\r
+};\r
+\r
+STATIC EFI_UNICODE_STRING_TABLE mGraphicsConsoleDriverNameTable[] = {\r
+ {\r
+ "eng",\r
+ (CHAR16 *)L"UGA Console Driver"\r
+ },\r
+ {\r
+ NULL,\r
+ NULL\r
+ }\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleComponentNameGetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **DriverName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+ Arguments:\r
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ Language - A pointer to a three character ISO 639-2 language identifier.\r
+ This is the language of the driver name that that the caller \r
+ is requesting, and it must match one of the languages specified\r
+ in SupportedLanguages. The number of languages supported by a \r
+ driver is up to the driver writer.\r
+ DriverName - A pointer to the Unicode string to return. This Unicode string\r
+ is the name of the driver specified by This in the language \r
+ specified by Language.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Unicode string for the Driver specified by This\r
+ and the language specified by Language was returned \r
+ in DriverName.\r
+ EFI_INVALID_PARAMETER - Language is NULL.\r
+ EFI_INVALID_PARAMETER - DriverName is NULL.\r
+ EFI_UNSUPPORTED - The driver specified by This does not support the \r
+ language specified by Language.\r
+\r
+--*/\r
+{\r
+ return LookupUnicodeString (\r
+ Language,\r
+ gGraphicsConsoleComponentName.SupportedLanguages,\r
+ mGraphicsConsoleDriverNameTable,\r
+ DriverName\r
+ );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Retrieves a Unicode string that is the user readable name of the controller\r
+ that is being managed by an EFI Driver.\r
+\r
+ Arguments:\r
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ ControllerHandle - The handle of a controller that the driver specified by \r
+ This is managing. This handle specifies the controller \r
+ whose name is to be returned.\r
+ ChildHandle - The handle of the child controller to retrieve the name \r
+ of. This is an optional parameter that may be NULL. It \r
+ will be NULL for device drivers. It will also be NULL \r
+ for a bus drivers that wish to retrieve the name of the \r
+ bus controller. It will not be NULL for a bus driver \r
+ that wishes to retrieve the name of a child controller.\r
+ Language - A pointer to a three character ISO 639-2 language \r
+ identifier. This is the language of the controller name \r
+ that that the caller is requesting, and it must match one\r
+ of the languages specified in SupportedLanguages. The \r
+ number of languages supported by a driver is up to the \r
+ driver writer.\r
+ ControllerName - A pointer to the Unicode string to return. This Unicode\r
+ string is the name of the controller specified by \r
+ ControllerHandle and ChildHandle in the language specified\r
+ by Language from the point of view of the driver specified\r
+ by This. \r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Unicode string for the user readable name in the \r
+ language specified by Language for the driver \r
+ specified by This was returned in DriverName.\r
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - Language is NULL.\r
+ EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+ EFI_UNSUPPORTED - The driver specified by This is not currently managing \r
+ the controller specified by ControllerHandle and \r
+ ChildHandle.\r
+ EFI_UNSUPPORTED - The driver specified by This does not support the \r
+ language specified by Language.\r
+\r
+--*/\r
+{\r
+ return EFI_UNSUPPORTED;\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ ComponentName.h\r
+\r
+Abstract:\r
+\r
+ \r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _GRAPHICS_CONSOLE_COMPONENT_NAME_H\r
+#define _GRAPHICS_CONSOLE_COMPONENT_NAME_H\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+extern EFI_COMPONENT_NAME_PROTOCOL gGraphicsConsoleComponentName;\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleComponentNameGetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **DriverName\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ )\r
+;\r
+\r
+#endif\r
--- /dev/null
+/**@file\r
+ Entry Point Source file.\r
+\r
+ This file contains the user entry point \r
+\r
+ Copyright (c) 2006 - 2007, Intel Corporation\r
+ All rights reserved. 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
+ 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
+\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+/**\r
+ The user Entry Point for module GraphicsConsole. 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
+InitializeGraphicsConsole(\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
+ &gGraphicsConsoleDriverBinding,\r
+ ImageHandle,\r
+ &gGraphicsConsoleComponentName,\r
+ NULL,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+\r
+ return Status;\r
+}\r
--- /dev/null
+/**@file\r
+ This is the main routine for initializing the Graphics Console support routines.\r
+Remaining Tasks\r
+ Add all standard Glyphs from EFI 1.02 Specification\r
+ Implement optimal automatic Mode creation algorithm\r
+ Solve palette issues for mixed graphics and text\r
+ When does this protocol reset the palette?\r
+ \r
+Copyright (c) 2006 - 2007 Intel Corporation. <BR>\r
+All rights reserved. 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
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "GraphicsConsole.h"\r
+\r
+STATIC\r
+EFI_STATUS\r
+GetTextColors (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,\r
+ OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background\r
+ );\r
+\r
+STATIC\r
+EFI_STATUS\r
+DrawUnicodeWeightAtCursorN (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN CHAR16 *UnicodeWeight,\r
+ IN UINTN Count\r
+ );\r
+\r
+STATIC\r
+EFI_STATUS\r
+EraseCursor (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r
+ );\r
+\r
+//\r
+// Globals\r
+//\r
+GRAPHICS_CONSOLE_DEV mGraphicsConsoleDevTemplate = {\r
+ GRAPHICS_CONSOLE_DEV_SIGNATURE,\r
+ (EFI_GRAPHICS_OUTPUT_PROTOCOL *) NULL,\r
+ (EFI_UGA_DRAW_PROTOCOL *) NULL,\r
+ {\r
+ GraphicsConsoleConOutReset,\r
+ GraphicsConsoleConOutOutputString,\r
+ GraphicsConsoleConOutTestString,\r
+ GraphicsConsoleConOutQueryMode,\r
+ GraphicsConsoleConOutSetMode,\r
+ GraphicsConsoleConOutSetAttribute,\r
+ GraphicsConsoleConOutClearScreen,\r
+ GraphicsConsoleConOutSetCursorPosition,\r
+ GraphicsConsoleConOutEnableCursor,\r
+ (EFI_SIMPLE_TEXT_OUTPUT_MODE *) NULL\r
+ },\r
+ {\r
+ 0,\r
+ 0,\r
+ EFI_TEXT_ATTR(EFI_LIGHTGRAY, EFI_BLACK),\r
+ 0,\r
+ 0,\r
+ TRUE\r
+ },\r
+ {\r
+ { 80, 25, 0, 0, 0, 0 }, // Mode 0\r
+ { 80, 50, 0, 0, 0, 0 }, // Mode 1 \r
+ { 0, 0, 0, 0, 0, 0 } // Mode 2\r
+ },\r
+ (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL,\r
+ (EFI_HII_HANDLE) 0\r
+};\r
+\r
+EFI_HII_PROTOCOL *mHii;\r
+\r
+static CHAR16 mCrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL };\r
+\r
+static EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {\r
+ //\r
+ // B G R\r
+ //\r
+ {0x00, 0x00, 0x00, 0x00}, // BLACK\r
+ {0x98, 0x00, 0x00, 0x00}, // BLUE\r
+ {0x00, 0x98, 0x00, 0x00}, // GREEN\r
+ {0x98, 0x98, 0x00, 0x00}, // CYAN\r
+ {0x00, 0x00, 0x98, 0x00}, // RED\r
+ {0x98, 0x00, 0x98, 0x00}, // MAGENTA\r
+ {0x00, 0x98, 0x98, 0x00}, // BROWN\r
+ {0x98, 0x98, 0x98, 0x00}, // LIGHTGRAY\r
+ {0x30, 0x30, 0x30, 0x00}, // DARKGRAY - BRIGHT BLACK\r
+ {0xff, 0x00, 0x00, 0x00}, // LIGHTBLUE - ?\r
+ {0x00, 0xff, 0x00, 0x00}, // LIGHTGREEN - ?\r
+ {0xff, 0xff, 0x00, 0x00}, // LIGHTCYAN\r
+ {0x00, 0x00, 0xff, 0x00}, // LIGHTRED\r
+ {0xff, 0x00, 0xff, 0x00}, // LIGHTMAGENTA\r
+ {0x00, 0xff, 0xff, 0x00}, // LIGHTBROWN\r
+ {0xff, 0xff, 0xff, 0x00} // WHITE\r
+};\r
+\r
+static EFI_NARROW_GLYPH mCursorGlyph = {\r
+ 0x0000,\r
+ 0x00,\r
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF }\r
+};\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding = {\r
+ GraphicsConsoleControllerDriverSupported,\r
+ GraphicsConsoleControllerDriverStart,\r
+ GraphicsConsoleControllerDriverStop,\r
+ 0xa,\r
+ NULL,\r
+ NULL\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleControllerDriverSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+\r
+ UgaDraw = NULL;\r
+ //\r
+ // Open the IO Abstraction(s) needed to perform the supported test\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ (VOID **) &GraphicsOutput,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ \r
+ if (EFI_ERROR (Status)) {\r
+ GraphicsOutput = NULL;\r
+ //\r
+ // Open Graphics Output Protocol failed, try to open UGA Draw Protocol\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiUgaDrawProtocolGuid,\r
+ (VOID **) &UgaDraw,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ }\r
+\r
+ //\r
+ // We need to ensure that we do not layer on top of a virtual handle.\r
+ // We need to ensure that the handles produced by the conspliter do not\r
+ // get used.\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID **) &DevicePath,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiDevicePathProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+ } else {\r
+ goto Error;\r
+ }\r
+ //\r
+ // Does Hii Exist? If not, we aren't ready to run\r
+ //\r
+ Status = EfiLocateHiiProtocol ();\r
+\r
+ //\r
+ // Close the I/O Abstraction(s) used to perform the supported test\r
+ //\r
+Error:\r
+ if (GraphicsOutput != NULL) {\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+ } else {\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiUgaDrawProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+ }\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleControllerDriverStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+\r
+ Start the controller.\r
+\r
+ Arguments:\r
+\r
+ This - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ Controller - The handle of the controller to start.\r
+ RemainingDevicePath - A pointer to the remaining portion of a devcie path.\r
+\r
+ Returns:\r
+\r
+ EFI_SUCCESS - Return successfully.\r
+ EFI_OUT_OF_RESOURCES - Out of resources.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ GRAPHICS_CONSOLE_DEV *Private;\r
+ EFI_HII_PACKAGES *Package;\r
+ EFI_HII_FONT_PACK *FontPack;\r
+ UINTN NarrowFontSize;\r
+ UINT32 HorizontalResolution;\r
+ UINT32 VerticalResolution;\r
+ UINT32 ColorDepth;\r
+ UINT32 RefreshRate;\r
+ UINTN MaxMode;\r
+ UINTN Columns;\r
+ UINTN Rows;\r
+ UINT8 *Location;\r
+ UINT32 ModeNumber;\r
+ UINTN SizeOfInfo;\r
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r
+ \r
+ ModeNumber = 0;\r
+\r
+ //\r
+ // Initialize the Graphics Console device instance\r
+ //\r
+ Private = AllocateCopyPool (\r
+ sizeof (GRAPHICS_CONSOLE_DEV),\r
+ &mGraphicsConsoleDevTemplate\r
+ );\r
+ if (Private == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ Private->SimpleTextOutput.Mode = &(Private->SimpleTextOutputMode);\r
+\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ (VOID **) &Private->GraphicsOutput,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR(Status)) {\r
+ Private->GraphicsOutput = NULL;\r
+\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiUgaDrawProtocolGuid,\r
+ (VOID **) &Private->UgaDraw,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Get the HII protocol. If Supported() succeeds, do we really\r
+ // need to get HII protocol again?\r
+ //\r
+ Status = EfiLocateHiiProtocol ();\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+\r
+ NarrowFontSize = ReturnNarrowFontSize ();\r
+\r
+ FontPack = AllocateZeroPool (sizeof (EFI_HII_FONT_PACK) + NarrowFontSize);\r
+ ASSERT (FontPack);\r
+\r
+ FontPack->Header.Length = (UINT32) (sizeof (EFI_HII_FONT_PACK) + NarrowFontSize);\r
+ FontPack->Header.Type = EFI_HII_FONT;\r
+ FontPack->NumberOfNarrowGlyphs = (UINT16) (NarrowFontSize / sizeof (EFI_NARROW_GLYPH));\r
+\r
+ Location = (UINT8 *) (&FontPack->NumberOfWideGlyphs + sizeof (UINT8));\r
+ CopyMem (Location, UsStdNarrowGlyphData, NarrowFontSize);\r
+\r
+ //\r
+ // Register our Fonts into the global database\r
+ //\r
+ Package = PreparePackages (1, NULL, FontPack);\r
+ mHii->NewPack (mHii, Package, &(Private->HiiHandle));\r
+ FreePool (Package);\r
+\r
+ //\r
+ // Free the font database\r
+ //\r
+ FreePool (FontPack);\r
+\r
+ //\r
+ // If the current mode information can not be retrieved, then attemp to set the default mode\r
+ // of 800x600, 32 bit colot, 60 Hz refresh.\r
+ //\r
+ HorizontalResolution = 800;\r
+ VerticalResolution = 600;\r
+\r
+ if (Private->GraphicsOutput != NULL) {\r
+ //\r
+ // The console is build on top of Graphics Output Protocol, find the mode number for 800x600\r
+ //\r
+ for (ModeNumber = 0; ModeNumber < Private->GraphicsOutput->Mode->MaxMode; ModeNumber++) {\r
+ Status = Private->GraphicsOutput->QueryMode (\r
+ Private->GraphicsOutput,\r
+ ModeNumber,\r
+ &SizeOfInfo,\r
+ &Info\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ if ((Info->HorizontalResolution == 800) &&\r
+ (Info->VerticalResolution == 600)) {\r
+ Status = Private->GraphicsOutput->SetMode (Private->GraphicsOutput, ModeNumber);\r
+ if (!EFI_ERROR (Status)) {\r
+ FreePool (Info);\r
+ break;\r
+ }\r
+ }\r
+ FreePool (Info);\r
+ }\r
+ }\r
+\r
+ if (EFI_ERROR (Status) || (ModeNumber == Private->GraphicsOutput->Mode->MaxMode)) {\r
+ //\r
+ // Set default mode failed or device don't support default mode, then get the current mode information\r
+ //\r
+ HorizontalResolution = Private->GraphicsOutput->Mode->Info->HorizontalResolution;\r
+ VerticalResolution = Private->GraphicsOutput->Mode->Info->VerticalResolution;\r
+ ModeNumber = Private->GraphicsOutput->Mode->Mode;\r
+ }\r
+ } else {\r
+ //\r
+ // The console is build on top of UGA Draw Protocol\r
+ //\r
+ ColorDepth = 32;\r
+ RefreshRate = 60;\r
+ Status = Private->UgaDraw->SetMode (\r
+ Private->UgaDraw,\r
+ HorizontalResolution,\r
+ VerticalResolution,\r
+ ColorDepth,\r
+ RefreshRate\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // Get the current mode information from the UGA Draw Protocol\r
+ //\r
+ Status = Private->UgaDraw->GetMode (\r
+ Private->UgaDraw,\r
+ &HorizontalResolution,\r
+ &VerticalResolution,\r
+ &ColorDepth,\r
+ &RefreshRate\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+ }\r
+ }\r
+\r
+ //\r
+ // Compute the maximum number of text Rows and Columns that this current graphics mode can support\r
+ //\r
+ Columns = HorizontalResolution / GLYPH_WIDTH;\r
+ Rows = VerticalResolution / GLYPH_HEIGHT;\r
+\r
+ //\r
+ // See if the mode is too small to support the required 80x25 text mode\r
+ //\r
+ if (Columns < 80 || Rows < 25) {\r
+ goto Error;\r
+ }\r
+ //\r
+ // Add Mode #0 that must be 80x25\r
+ //\r
+ MaxMode = 0;\r
+ Private->ModeData[MaxMode].GopWidth = HorizontalResolution;\r
+ Private->ModeData[MaxMode].GopHeight = VerticalResolution;\r
+ Private->ModeData[MaxMode].GopModeNumber = ModeNumber;\r
+ Private->ModeData[MaxMode].DeltaX = (HorizontalResolution - (80 * GLYPH_WIDTH)) >> 1;\r
+ Private->ModeData[MaxMode].DeltaY = (VerticalResolution - (25 * GLYPH_HEIGHT)) >> 1;\r
+ MaxMode++;\r
+\r
+ //\r
+ // If it is possible to support Mode #1 - 80x50, than add it as an active mode\r
+ //\r
+ if (Rows >= 50) {\r
+ Private->ModeData[MaxMode].GopWidth = HorizontalResolution;\r
+ Private->ModeData[MaxMode].GopHeight = VerticalResolution;\r
+ Private->ModeData[MaxMode].GopModeNumber = ModeNumber;\r
+ Private->ModeData[MaxMode].DeltaX = (HorizontalResolution - (80 * GLYPH_WIDTH)) >> 1;\r
+ Private->ModeData[MaxMode].DeltaY = (VerticalResolution - (50 * GLYPH_HEIGHT)) >> 1;\r
+ MaxMode++;\r
+ }\r
+ //\r
+ // If the graphics mode is 800x600, than add a text mode that uses the entire display\r
+ //\r
+ if (HorizontalResolution == 800 && VerticalResolution == 600) {\r
+\r
+ if (MaxMode < 2) {\r
+ Private->ModeData[MaxMode].Columns = 0;\r
+ Private->ModeData[MaxMode].Rows = 0;\r
+ Private->ModeData[MaxMode].GopWidth = 800;\r
+ Private->ModeData[MaxMode].GopHeight = 600;\r
+ Private->ModeData[MaxMode].GopModeNumber = ModeNumber;\r
+ Private->ModeData[MaxMode].DeltaX = 0;\r
+ Private->ModeData[MaxMode].DeltaY = 0;\r
+ MaxMode++;\r
+ }\r
+\r
+ Private->ModeData[MaxMode].Columns = 800 / GLYPH_WIDTH;\r
+ Private->ModeData[MaxMode].Rows = 600 / GLYPH_HEIGHT;\r
+ Private->ModeData[MaxMode].GopWidth = 800;\r
+ Private->ModeData[MaxMode].GopHeight = 600;\r
+ Private->ModeData[MaxMode].GopModeNumber = ModeNumber;\r
+ Private->ModeData[MaxMode].DeltaX = (800 % GLYPH_WIDTH) >> 1;\r
+ Private->ModeData[MaxMode].DeltaY = (600 % GLYPH_HEIGHT) >> 1;\r
+ MaxMode++;\r
+ }\r
+ //\r
+ // Update the maximum number of modes\r
+ //\r
+ Private->SimpleTextOutputMode.MaxMode = (INT32) MaxMode;\r
+\r
+ //\r
+ // Determine the number of text modes that this protocol can support\r
+ //\r
+ Status = GraphicsConsoleConOutSetMode (&Private->SimpleTextOutput, 0);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+\r
+ DEBUG_CODE_BEGIN ();\r
+ GraphicsConsoleConOutOutputString (&Private->SimpleTextOutput, (CHAR16 *)L"Graphics Console Started\n\r");\r
+ DEBUG_CODE_END ();\r
+\r
+ //\r
+ // Install protocol interfaces for the Graphics Console device.\r
+ //\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &Controller,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ &Private->SimpleTextOutput,\r
+ NULL\r
+ );\r
+\r
+Error:\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // Close the GOP or UGA IO Protocol\r
+ //\r
+ if (Private->GraphicsOutput != NULL) {\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+ } else {\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiUgaDrawProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+ }\r
+\r
+ //\r
+ // Free private data\r
+ //\r
+ if (Private != NULL) {\r
+ if (Private->LineBuffer != NULL) {\r
+ FreePool (Private->LineBuffer);\r
+ }\r
+ FreePool (Private);\r
+ }\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleControllerDriverStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOutput;\r
+ GRAPHICS_CONSOLE_DEV *Private;\r
+\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ (VOID **) &SimpleTextOutput,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_NOT_STARTED;\r
+ }\r
+\r
+ Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (SimpleTextOutput);\r
+\r
+ Status = gBS->UninstallProtocolInterface (\r
+ Controller,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ &Private->SimpleTextOutput\r
+ );\r
+\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Close the GOP or UGA IO Protocol\r
+ //\r
+ if (Private->GraphicsOutput != NULL) {\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+ } else {\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiUgaDrawProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+ }\r
+\r
+ //\r
+ // Remove the font pack\r
+ //\r
+ mHii->RemovePack (mHii, Private->HiiHandle);\r
+\r
+ //\r
+ // Free our instance data\r
+ //\r
+ if (Private != NULL) {\r
+ FreePool (Private->LineBuffer);\r
+ FreePool (Private);\r
+ }\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EfiLocateHiiProtocol (\r
+ VOID\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Find if the HII protocol is available. If yes, locate the HII protocol\r
+\r
+ Arguments:\r
+\r
+ Returns:\r
+\r
+--*/\r
+{\r
+ EFI_HANDLE Handle;\r
+ UINTN Size;\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // There should only be one - so buffer size is this\r
+ //\r
+ Size = sizeof (EFI_HANDLE);\r
+\r
+ Status = gBS->LocateHandle (\r
+ ByProtocol,\r
+ &gEfiHiiProtocolGuid,\r
+ NULL,\r
+ &Size,\r
+ &Handle\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ Status = gBS->HandleProtocol (\r
+ Handle,\r
+ &gEfiHiiProtocolGuid,\r
+ (VOID **)&mHii\r
+ );\r
+\r
+ return Status;\r
+}\r
+//\r
+// Body of the STO functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutReset (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN BOOLEAN ExtendedVerification\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements SIMPLE_TEXT_OUTPUT.Reset().\r
+ If ExtendeVerification is TRUE, then perform dependent Graphics Console \r
+ device reset, and set display mode to mode 0.\r
+ If ExtendedVerification is FALSE, only set display mode to mode 0.\r
+ \r
+ Arguments:\r
+ \r
+ This - Indicates the calling context.\r
+ \r
+ ExtendedVerification - Indicates that the driver may perform a more exhaustive\r
+ verification operation of the device during reset.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The reset operation succeeds. \r
+ \r
+ EFI_DEVICE_ERROR\r
+ The Graphics Console is not functioning correctly \r
+ \r
+--*/\r
+{\r
+ This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK));\r
+ return This->SetMode (This, 0);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutOutputString (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN CHAR16 *WString\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements SIMPLE_TEXT_OUTPUT.OutputString().\r
+ The Unicode string will be converted to Glyphs and will be \r
+ sent to the Graphics Console.\r
+ \r
+ \r
+ Arguments:\r
+ \r
+ This - Indicates the calling context.\r
+ \r
+ WString - The Null-terminated Unicode string to be displayed on \r
+ the Graphics Console.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The string is output successfully. \r
+ \r
+ EFI_DEVICE_ERROR\r
+ The Graphics Console failed to send the string out.\r
+ \r
+ EFI_WARN_UNKNOWN_GLYPH\r
+ Indicates that some of the characters in the Unicode string could not \r
+ be rendered and are skipped. \r
+ \r
+--*/\r
+{\r
+ GRAPHICS_CONSOLE_DEV *Private;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+ INTN Mode;\r
+ UINTN MaxColumn;\r
+ UINTN MaxRow;\r
+ UINTN Width;\r
+ UINTN Height;\r
+ UINTN Delta;\r
+ EFI_STATUS Status;\r
+ BOOLEAN Warning;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r
+ UINTN DeltaX;\r
+ UINTN DeltaY;\r
+ UINTN Count;\r
+ UINTN Index;\r
+ INT32 OriginAttribute;\r
+ EFI_TPL OldTpl;\r
+ CHAR16 SpaceStr[] = { NARROW_CHAR, ' ', 0 };\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+ //\r
+ // Current mode\r
+ //\r
+ Mode = This->Mode->Mode;\r
+ Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);\r
+ GraphicsOutput = Private->GraphicsOutput;\r
+ UgaDraw = Private->UgaDraw;\r
+\r
+ MaxColumn = Private->ModeData[Mode].Columns;\r
+ MaxRow = Private->ModeData[Mode].Rows;\r
+ DeltaX = Private->ModeData[Mode].DeltaX;\r
+ DeltaY = Private->ModeData[Mode].DeltaY;\r
+ Width = MaxColumn * GLYPH_WIDTH;\r
+ Height = (MaxRow - 1) * GLYPH_HEIGHT;\r
+ Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);\r
+\r
+ //\r
+ // The Attributes won't change when during the time OutputString is called\r
+ //\r
+ GetTextColors (This, &Foreground, &Background);\r
+\r
+ EraseCursor (This);\r
+\r
+ Warning = FALSE;\r
+\r
+ //\r
+ // Backup attribute\r
+ //\r
+ OriginAttribute = This->Mode->Attribute;\r
+\r
+ while (*WString) {\r
+\r
+ if (*WString == CHAR_BACKSPACE) {\r
+ //\r
+ // If the cursor is at the left edge of the display, then move the cursor\r
+ // one row up.\r
+ //\r
+ if (This->Mode->CursorColumn == 0 && This->Mode->CursorRow > 0) {\r
+ This->Mode->CursorRow--;\r
+ This->Mode->CursorColumn = (INT32) (MaxColumn - 1);\r
+ This->OutputString (This, SpaceStr);\r
+ EraseCursor (This);\r
+ This->Mode->CursorRow--;\r
+ This->Mode->CursorColumn = (INT32) (MaxColumn - 1);\r
+ } else if (This->Mode->CursorColumn > 0) {\r
+ //\r
+ // If the cursor is not at the left edge of the display, then move the cursor\r
+ // left one column.\r
+ //\r
+ This->Mode->CursorColumn--;\r
+ This->OutputString (This, SpaceStr);\r
+ EraseCursor (This);\r
+ This->Mode->CursorColumn--;\r
+ }\r
+\r
+ WString++;\r
+\r
+ } else if (*WString == CHAR_LINEFEED) {\r
+ //\r
+ // If the cursor is at the bottom of the display, then scroll the display one\r
+ // row, and do not update the cursor position. Otherwise, move the cursor\r
+ // down one row.\r
+ //\r
+ if (This->Mode->CursorRow == (INT32) (MaxRow - 1)) {\r
+ if (GraphicsOutput != NULL) {\r
+ //\r
+ // Scroll Screen Up One Row\r
+ //\r
+ GraphicsOutput->Blt (\r
+ GraphicsOutput,\r
+ NULL,\r
+ EfiBltVideoToVideo,\r
+ DeltaX,\r
+ DeltaY + GLYPH_HEIGHT,\r
+ DeltaX,\r
+ DeltaY,\r
+ Width,\r
+ Height,\r
+ Delta\r
+ );\r
+\r
+ //\r
+ // Print Blank Line at last line\r
+ //\r
+ GraphicsOutput->Blt (\r
+ GraphicsOutput,\r
+ &Background,\r
+ EfiBltVideoFill,\r
+ 0,\r
+ 0,\r
+ DeltaX,\r
+ DeltaY + Height,\r
+ Width,\r
+ GLYPH_HEIGHT,\r
+ Delta\r
+ );\r
+ } else {\r
+ //\r
+ // Scroll Screen Up One Row\r
+ //\r
+ UgaDraw->Blt (\r
+ UgaDraw,\r
+ NULL,\r
+ EfiUgaVideoToVideo,\r
+ DeltaX,\r
+ DeltaY + GLYPH_HEIGHT,\r
+ DeltaX,\r
+ DeltaY,\r
+ Width,\r
+ Height,\r
+ Delta\r
+ );\r
+\r
+ //\r
+ // Print Blank Line at last line\r
+ //\r
+ UgaDraw->Blt (\r
+ UgaDraw,\r
+ (EFI_UGA_PIXEL *) (UINTN) &Background,\r
+ EfiUgaVideoFill,\r
+ 0,\r
+ 0,\r
+ DeltaX,\r
+ DeltaY + Height,\r
+ Width,\r
+ GLYPH_HEIGHT,\r
+ Delta\r
+ );\r
+ }\r
+ } else {\r
+ This->Mode->CursorRow++;\r
+ }\r
+\r
+ WString++;\r
+\r
+ } else if (*WString == CHAR_CARRIAGE_RETURN) {\r
+ //\r
+ // Move the cursor to the beginning of the current row.\r
+ //\r
+ This->Mode->CursorColumn = 0;\r
+ WString++;\r
+\r
+ } else if (*WString == WIDE_CHAR) {\r
+\r
+ This->Mode->Attribute |= EFI_WIDE_ATTRIBUTE;\r
+ WString++;\r
+\r
+ } else if (*WString == NARROW_CHAR) {\r
+\r
+ This->Mode->Attribute &= (~ (UINT32) EFI_WIDE_ATTRIBUTE);\r
+ WString++;\r
+\r
+ } else {\r
+ //\r
+ // Print the character at the current cursor position and move the cursor\r
+ // right one column. If this moves the cursor past the right edge of the\r
+ // display, then the line should wrap to the beginning of the next line. This\r
+ // is equivalent to inserting a CR and an LF. Note that if the cursor is at the\r
+ // bottom of the display, and the line wraps, then the display will be scrolled\r
+ // one line.\r
+ // If wide char is going to be displayed, need to display one character at a time\r
+ // Or, need to know the display length of a certain string.\r
+ //\r
+ // Index is used to determine how many character width units (wide = 2, narrow = 1)\r
+ // Count is used to determine how many characters are used regardless of their attributes\r
+ //\r
+ for (Count = 0, Index = 0; (This->Mode->CursorColumn + Index) < MaxColumn; Count++, Index++) {\r
+ if (WString[Count] == CHAR_NULL) {\r
+ break;\r
+ }\r
+\r
+ if (WString[Count] == CHAR_BACKSPACE) {\r
+ break;\r
+ }\r
+\r
+ if (WString[Count] == CHAR_LINEFEED) {\r
+ break;\r
+ }\r
+\r
+ if (WString[Count] == CHAR_CARRIAGE_RETURN) {\r
+ break;\r
+ }\r
+\r
+ if (WString[Count] == WIDE_CHAR) {\r
+ break;\r
+ }\r
+\r
+ if (WString[Count] == NARROW_CHAR) {\r
+ break;\r
+ }\r
+ //\r
+ // Is the wide attribute on?\r
+ //\r
+ if (This->Mode->Attribute & EFI_WIDE_ATTRIBUTE) {\r
+ //\r
+ // If wide, add one more width unit than normal since we are going to increment at the end of the for loop\r
+ //\r
+ Index++;\r
+ //\r
+ // This is the end-case where if we are at column 79 and about to print a wide character\r
+ // We should prevent this from happening because we will wrap inappropriately. We should\r
+ // not print this character until the next line.\r
+ //\r
+ if ((This->Mode->CursorColumn + Index + 1) > MaxColumn) {\r
+ Index++;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ Status = DrawUnicodeWeightAtCursorN (This, WString, Count);\r
+ if (EFI_ERROR (Status)) {\r
+ Warning = TRUE;\r
+ }\r
+ //\r
+ // At the end of line, output carriage return and line feed\r
+ //\r
+ WString += Count;\r
+ This->Mode->CursorColumn += (INT32) Index;\r
+ if (This->Mode->CursorColumn > (INT32) MaxColumn) {\r
+ This->Mode->CursorColumn -= 2;\r
+ This->OutputString (This, SpaceStr);\r
+ }\r
+\r
+ if (This->Mode->CursorColumn >= (INT32) MaxColumn) {\r
+ EraseCursor (This);\r
+ This->OutputString (This, mCrLfString);\r
+ EraseCursor (This);\r
+ }\r
+ }\r
+ }\r
+\r
+ This->Mode->Attribute = OriginAttribute;\r
+\r
+ EraseCursor (This);\r
+\r
+ if (Warning) {\r
+ Status = EFI_WARN_UNKNOWN_GLYPH;\r
+ }\r
+\r
+ gBS->RestoreTPL (OldTpl);\r
+ return Status;\r
+\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutTestString (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN CHAR16 *WString\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements SIMPLE_TEXT_OUTPUT.TestString().\r
+ If one of the characters in the *Wstring is\r
+ neither valid valid Unicode drawing characters,\r
+ not ASCII code, then this function will return\r
+ EFI_UNSUPPORTED.\r
+ \r
+ \r
+ Arguments:\r
+ \r
+ This - Indicates the calling context.\r
+ \r
+ WString - The Null-terminated Unicode string to be tested.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The Graphics Console is capable of rendering the output string. \r
+ \r
+ EFI_UNSUPPORTED\r
+ Some of the characters in the Unicode string cannot be rendered. \r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ UINT16 GlyphWidth;\r
+ UINT32 GlyphStatus;\r
+ UINT16 Count;\r
+ GLYPH_UNION *Glyph;\r
+\r
+ GlyphStatus = 0;\r
+ Count = 0;\r
+\r
+ while (WString[Count]) {\r
+ Status = mHii->GetGlyph (\r
+ mHii,\r
+ WString,\r
+ &Count,\r
+ (UINT8 **) &Glyph,\r
+ &GlyphWidth,\r
+ &GlyphStatus\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutQueryMode (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN ModeNumber,\r
+ OUT UINTN *Columns,\r
+ OUT UINTN *Rows\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements SIMPLE_TEXT_OUTPUT.QueryMode().\r
+ It returnes information for an available text mode\r
+ that the Graphics Console supports.\r
+ In this driver,we only support text mode 80x25, which is\r
+ defined as mode 0.\r
+ \r
+ \r
+ Arguments:\r
+ \r
+ This - Indicates the calling context.\r
+ \r
+ ModeNumber - The mode number to return information on.\r
+ \r
+ Columns - The returned columns of the requested mode.\r
+ \r
+ Rows - The returned rows of the requested mode. \r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The requested mode information is returned. \r
+ \r
+ EFI_UNSUPPORTED\r
+ The mode number is not valid. \r
+ \r
+--*/\r
+{\r
+ GRAPHICS_CONSOLE_DEV *Private;\r
+ EFI_STATUS Status;\r
+ EFI_TPL OldTpl;\r
+\r
+ if (ModeNumber >= (UINTN) This->Mode->MaxMode) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+ Status = EFI_SUCCESS;\r
+ \r
+ Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);\r
+\r
+ *Columns = Private->ModeData[ModeNumber].Columns;\r
+ *Rows = Private->ModeData[ModeNumber].Rows;\r
+\r
+ if (*Columns <= 0 && *Rows <= 0) {\r
+ Status = EFI_UNSUPPORTED;\r
+ goto Done;\r
+\r
+ }\r
+\r
+Done:\r
+ gBS->RestoreTPL (OldTpl);\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutSetMode (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN ModeNumber\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements SIMPLE_TEXT_OUTPUT.SetMode().\r
+ Set the Graphics Console to a specified mode.\r
+ In this driver, we only support mode 0. \r
+ \r
+ Arguments:\r
+ \r
+ This - Indicates the calling context.\r
+ \r
+ ModeNumber - The text mode to set.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The requested text mode is set.\r
+ \r
+ EFI_DEVICE_ERROR\r
+ The requested text mode cannot be set because of Graphics Console device error.\r
+ \r
+ EFI_UNSUPPORTED\r
+ The text mode number is not valid. \r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ GRAPHICS_CONSOLE_DEV *Private;\r
+ GRAPHICS_CONSOLE_MODE_DATA *ModeData;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *NewLineBuffer;\r
+ UINT32 HorizontalResolution;\r
+ UINT32 VerticalResolution;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+ UINT32 ColorDepth;\r
+ UINT32 RefreshRate;\r
+ EFI_TPL OldTpl;\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+ Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);\r
+ GraphicsOutput = Private->GraphicsOutput;\r
+ UgaDraw = Private->UgaDraw;\r
+ ModeData = &(Private->ModeData[ModeNumber]);\r
+\r
+ if (ModeData->Columns <= 0 && ModeData->Rows <= 0) {\r
+ Status = EFI_UNSUPPORTED;\r
+ goto Done;\r
+ }\r
+\r
+ //\r
+ // Make sure the requested mode number is supported\r
+ //\r
+ if (ModeNumber >= (UINTN) This->Mode->MaxMode) {\r
+ Status = EFI_UNSUPPORTED;\r
+ goto Done;\r
+ }\r
+\r
+ if (ModeData->Columns <= 0 && ModeData->Rows <= 0) {\r
+ Status = EFI_UNSUPPORTED;\r
+ goto Done;\r
+ }\r
+ //\r
+ // Attempt to allocate a line buffer for the requested mode number\r
+ //\r
+ NewLineBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * ModeData->Columns * GLYPH_WIDTH * GLYPH_HEIGHT);\r
+\r
+ if (NewLineBuffer == NULL) {\r
+ //\r
+ // The new line buffer could not be allocated, so return an error.\r
+ // No changes to the state of the current console have been made, so the current console is still valid\r
+ //\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
+ //\r
+ // If the mode has been set at least one other time, then LineBuffer will not be NULL\r
+ //\r
+ if (Private->LineBuffer != NULL) {\r
+ //\r
+ // Clear the current text window on the current graphics console\r
+ //\r
+ This->ClearScreen (This);\r
+\r
+ //\r
+ // If the new mode is the same as the old mode, then just return EFI_SUCCESS\r
+ //\r
+ if ((INT32) ModeNumber == This->Mode->Mode) {\r
+ FreePool (NewLineBuffer);\r
+ Status = EFI_SUCCESS;\r
+ goto Done;\r
+ }\r
+ //\r
+ // Otherwise, the size of the text console and/or the UGA mode will be changed,\r
+ // so turn off the cursor, and free the LineBuffer for the current mode\r
+ //\r
+ This->EnableCursor (This, FALSE);\r
+\r
+ FreePool (Private->LineBuffer);\r
+ }\r
+ //\r
+ // Assign the current line buffer to the newly allocated line buffer\r
+ //\r
+ Private->LineBuffer = NewLineBuffer;\r
+\r
+ if (GraphicsOutput != NULL) {\r
+ if (ModeData->GopModeNumber != GraphicsOutput->Mode->Mode) {\r
+ //\r
+ // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode\r
+ //\r
+ Status = GraphicsOutput->SetMode (GraphicsOutput, ModeData->GopModeNumber);\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // The mode set operation failed\r
+ //\r
+ goto Done;\r
+ }\r
+ } else {\r
+ //\r
+ // The current graphics mode is correct, so simply clear the entire display\r
+ //\r
+ Status = GraphicsOutput->Blt (\r
+ GraphicsOutput,\r
+ &mEfiColors[0],\r
+ EfiBltVideoFill,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ ModeData->GopWidth,\r
+ ModeData->GopHeight,\r
+ 0\r
+ );\r
+ }\r
+ } else {\r
+ //\r
+ // Get the current UGA Draw mode information\r
+ //\r
+ Status = UgaDraw->GetMode (\r
+ UgaDraw,\r
+ &HorizontalResolution,\r
+ &VerticalResolution,\r
+ &ColorDepth,\r
+ &RefreshRate\r
+ );\r
+ if (EFI_ERROR (Status) || HorizontalResolution != ModeData->GopWidth || VerticalResolution != ModeData->GopHeight) {\r
+ //\r
+ // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode\r
+ //\r
+ Status = UgaDraw->SetMode (\r
+ UgaDraw,\r
+ ModeData->GopWidth,\r
+ ModeData->GopHeight,\r
+ 32,\r
+ 60\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // The mode set operation failed\r
+ //\r
+ goto Done;\r
+ }\r
+ } else {\r
+ //\r
+ // The current graphics mode is correct, so simply clear the entire display\r
+ //\r
+ Status = UgaDraw->Blt (\r
+ UgaDraw,\r
+ (EFI_UGA_PIXEL *) (UINTN) &mEfiColors[0],\r
+ EfiUgaVideoFill,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ ModeData->GopWidth,\r
+ ModeData->GopHeight,\r
+ 0\r
+ );\r
+ }\r
+ }\r
+\r
+ //\r
+ // The new mode is valid, so commit the mode change\r
+ //\r
+ This->Mode->Mode = (INT32) ModeNumber;\r
+\r
+ //\r
+ // Move the text cursor to the upper left hand corner of the displat and enable it\r
+ //\r
+ This->SetCursorPosition (This, 0, 0);\r
+ This->EnableCursor (This, TRUE);\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+Done:\r
+ gBS->RestoreTPL (OldTpl);\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutSetAttribute (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN Attribute\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements SIMPLE_TEXT_OUTPUT.SetAttribute(). \r
+ \r
+ Arguments:\r
+ \r
+ This - Indicates the calling context.\r
+ \r
+ Attrubute - The attribute to set. Only bit0..6 are valid, all other bits\r
+ are undefined and must be zero.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The requested attribute is set. \r
+ \r
+ EFI_DEVICE_ERROR\r
+ The requested attribute cannot be set due to Graphics Console port error.\r
+ \r
+ EFI_UNSUPPORTED\r
+ The attribute requested is not defined by EFI spec. \r
+ \r
+--*/\r
+{\r
+ EFI_TPL OldTpl;\r
+ \r
+ if ((Attribute | 0xFF) != 0xFF) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ if ((INT32) Attribute == This->Mode->Attribute) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+ EraseCursor (This);\r
+\r
+ This->Mode->Attribute = (INT32) Attribute;\r
+\r
+ EraseCursor (This);\r
+\r
+ gBS->RestoreTPL (OldTpl);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutClearScreen (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements SIMPLE_TEXT_OUTPUT.ClearScreen().\r
+ It clears the Graphics Console's display to the \r
+ currently selected background color.\r
+ \r
+ \r
+ Arguments:\r
+ \r
+ This - Indicates the calling context.\r
+\r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The operation completed successfully.\r
+ \r
+ EFI_DEVICE_ERROR\r
+ The Graphics Console cannot be cleared due to Graphics Console device error. \r
+ \r
+ EFI_UNSUPPORTED\r
+ The Graphics Console is not in a valid text mode. \r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ GRAPHICS_CONSOLE_DEV *Private;\r
+ GRAPHICS_CONSOLE_MODE_DATA *ModeData;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r
+ EFI_TPL OldTpl;\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+ Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);\r
+ GraphicsOutput = Private->GraphicsOutput;\r
+ UgaDraw = Private->UgaDraw;\r
+ ModeData = &(Private->ModeData[This->Mode->Mode]);\r
+\r
+ GetTextColors (This, &Foreground, &Background);\r
+ if (GraphicsOutput != NULL) {\r
+ Status = GraphicsOutput->Blt (\r
+ GraphicsOutput,\r
+ &Background,\r
+ EfiBltVideoFill,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ ModeData->GopWidth,\r
+ ModeData->GopHeight,\r
+ 0\r
+ );\r
+ } else {\r
+ Status = UgaDraw->Blt (\r
+ UgaDraw,\r
+ (EFI_UGA_PIXEL *) (UINTN) &Background,\r
+ EfiUgaVideoFill,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ ModeData->GopWidth,\r
+ ModeData->GopHeight,\r
+ 0\r
+ );\r
+ }\r
+\r
+ This->Mode->CursorColumn = 0;\r
+ This->Mode->CursorRow = 0;\r
+\r
+ EraseCursor (This);\r
+\r
+ gBS->RestoreTPL (OldTpl);\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutSetCursorPosition (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN Column,\r
+ IN UINTN Row\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition(). \r
+ \r
+ Arguments:\r
+ \r
+ This - Indicates the calling context.\r
+ \r
+ Column - The row to set cursor to.\r
+ \r
+ Row - The column to set cursor to. \r
+\r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The operation completed successfully.\r
+ \r
+ EFI_DEVICE_ERROR\r
+ The request fails due to Graphics Console device error. \r
+ \r
+ EFI_UNSUPPORTED\r
+ The Graphics Console is not in a valid text mode, or the cursor position\r
+ is invalid for current mode. \r
+ \r
+--*/\r
+{\r
+ GRAPHICS_CONSOLE_DEV *Private;\r
+ GRAPHICS_CONSOLE_MODE_DATA *ModeData;\r
+ EFI_STATUS Status;\r
+ EFI_TPL OldTpl;\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+ Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);\r
+ ModeData = &(Private->ModeData[This->Mode->Mode]);\r
+\r
+ if ((Column >= ModeData->Columns) || (Row >= ModeData->Rows)) {\r
+ Status = EFI_UNSUPPORTED;\r
+ goto Done;\r
+ }\r
+\r
+ if (((INT32) Column == This->Mode->CursorColumn) && ((INT32) Row == This->Mode->CursorRow)) {\r
+ Status = EFI_SUCCESS;\r
+ goto Done;\r
+ }\r
+\r
+ EraseCursor (This);\r
+\r
+ This->Mode->CursorColumn = (INT32) Column;\r
+ This->Mode->CursorRow = (INT32) Row;\r
+\r
+ EraseCursor (This);\r
+\r
+Done:\r
+ gBS->RestoreTPL (OldTpl);\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutEnableCursor (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN BOOLEAN Visible\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements SIMPLE_TEXT_OUTPUT.EnableCursor().\r
+ In this driver, the cursor cannot be hidden. \r
+ \r
+ Arguments:\r
+ \r
+ This - Indicates the calling context.\r
+ \r
+ Visible - If TRUE, the cursor is set to be visible,\r
+ If FALSE, the cursor is set to be invisible. \r
+\r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The request is valid.\r
+ \r
+ EFI_UNSUPPORTED\r
+ The Graphics Console does not support a hidden cursor. \r
+ \r
+--*/\r
+{\r
+ EFI_TPL OldTpl;\r
+ \r
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+ \r
+ EraseCursor (This);\r
+\r
+ This->Mode->CursorVisible = Visible;\r
+\r
+ EraseCursor (This);\r
+\r
+ gBS->RestoreTPL (OldTpl);\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+GetTextColors (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,\r
+ OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background\r
+ )\r
+{\r
+ INTN Attribute;\r
+\r
+ Attribute = This->Mode->Attribute & 0x7F;\r
+\r
+ *Foreground = mEfiColors[Attribute & 0x0f];\r
+ *Background = mEfiColors[Attribute >> 4];\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+DrawUnicodeWeightAtCursorN (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN CHAR16 *UnicodeWeight,\r
+ IN UINTN Count\r
+ )\r
+{\r
+ GRAPHICS_CONSOLE_DEV *Private;\r
+ EFI_STATUS Status;\r
+ EFI_STATUS ReturnStatus;\r
+ GLYPH_UNION *Glyph;\r
+ GLYPH_UNION GlyphData;\r
+ INTN GlyphX;\r
+ INTN GlyphY;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r
+ UINTN Index;\r
+ UINTN ArrayIndex;\r
+ UINTN Counts;\r
+ UINT16 GlyphWidth;\r
+ UINT32 GlyphStatus;\r
+\r
+ Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);\r
+\r
+ ReturnStatus = EFI_SUCCESS;\r
+ GlyphStatus = 0;\r
+ GlyphWidth = 0x08;\r
+\r
+ GetTextColors (This, &Foreground, &Background);\r
+\r
+ Index = 0;\r
+ ArrayIndex = 0;\r
+ while (Index < Count) {\r
+ if (This->Mode->Attribute & EFI_WIDE_ATTRIBUTE) {\r
+ GlyphStatus = WIDE_CHAR;\r
+ } else {\r
+ GlyphStatus = NARROW_CHAR;\r
+ }\r
+\r
+ Status = mHii->GetGlyph (\r
+ mHii,\r
+ UnicodeWeight,\r
+ (UINT16 *) &Index,\r
+ (UINT8 **) &Glyph,\r
+ &GlyphWidth,\r
+ &GlyphStatus\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ ReturnStatus = Status;\r
+ }\r
+\r
+ Counts = 0;\r
+\r
+ CopyMem (&GlyphData, Glyph, sizeof (GLYPH_UNION));\r
+\r
+ do {\r
+ //\r
+ // We are creating the second half of the wide character's BLT buffer\r
+ //\r
+ if (GlyphWidth == 0x10 && Counts == 1) {\r
+ CopyMem (&GlyphData.NarrowGlyph.GlyphCol1, &Glyph->WideGlyph.GlyphCol2, sizeof (Glyph->WideGlyph.GlyphCol2));\r
+ }\r
+\r
+ Counts++;\r
+\r
+ if (GlyphWidth == 0x10) {\r
+ mHii->GlyphToBlt (\r
+ mHii,\r
+ (UINT8 *) &GlyphData,\r
+ Foreground,\r
+ Background,\r
+ Count * 2,\r
+ GLYPH_WIDTH,\r
+ GLYPH_HEIGHT,\r
+ &Private->LineBuffer[ArrayIndex * GLYPH_WIDTH]\r
+ );\r
+ } else {\r
+ mHii->GlyphToBlt (\r
+ mHii,\r
+ (UINT8 *) &GlyphData,\r
+ Foreground,\r
+ Background,\r
+ Count,\r
+ GLYPH_WIDTH,\r
+ GLYPH_HEIGHT,\r
+ &Private->LineBuffer[ArrayIndex * GLYPH_WIDTH]\r
+ );\r
+ }\r
+\r
+ ArrayIndex++;\r
+\r
+ } while (Counts < 2 && GlyphWidth == 0x10);\r
+\r
+ }\r
+ //\r
+ // If we are printing Wide characters, treat the BLT as if it is twice as many characters\r
+ //\r
+ if (GlyphWidth == 0x10) {\r
+ Count = Count * 2;\r
+ }\r
+ //\r
+ // Blt a character to the screen\r
+ //\r
+ GlyphX = This->Mode->CursorColumn * GLYPH_WIDTH;\r
+ GlyphY = This->Mode->CursorRow * GLYPH_HEIGHT;\r
+ GraphicsOutput = Private->GraphicsOutput;\r
+ UgaDraw = Private->UgaDraw;\r
+ if (GraphicsOutput != NULL) {\r
+ GraphicsOutput->Blt (\r
+ GraphicsOutput,\r
+ Private->LineBuffer,\r
+ EfiBltBufferToVideo,\r
+ 0,\r
+ 0,\r
+ GlyphX + Private->ModeData[This->Mode->Mode].DeltaX,\r
+ GlyphY + Private->ModeData[This->Mode->Mode].DeltaY,\r
+ GLYPH_WIDTH * Count,\r
+ GLYPH_HEIGHT,\r
+ GLYPH_WIDTH * Count * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+ );\r
+ } else {\r
+ UgaDraw->Blt (\r
+ UgaDraw,\r
+ (EFI_UGA_PIXEL *) (UINTN) Private->LineBuffer,\r
+ EfiUgaBltBufferToVideo,\r
+ 0,\r
+ 0,\r
+ GlyphX + Private->ModeData[This->Mode->Mode].DeltaX,\r
+ GlyphY + Private->ModeData[This->Mode->Mode].DeltaY,\r
+ GLYPH_WIDTH * Count,\r
+ GLYPH_HEIGHT,\r
+ GLYPH_WIDTH * Count * sizeof (EFI_UGA_PIXEL)\r
+ );\r
+ }\r
+\r
+ return ReturnStatus;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EraseCursor (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r
+ )\r
+{\r
+ GRAPHICS_CONSOLE_DEV *Private;\r
+ EFI_SIMPLE_TEXT_OUTPUT_MODE *CurrentMode;\r
+ INTN GlyphX;\r
+ INTN GlyphY;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Foreground;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Background;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION BltChar[GLYPH_HEIGHT][GLYPH_WIDTH];\r
+ UINTN X;\r
+ UINTN Y;\r
+\r
+ CurrentMode = This->Mode;\r
+\r
+ if (!CurrentMode->CursorVisible) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);\r
+ GraphicsOutput = Private->GraphicsOutput;\r
+ UgaDraw = Private->UgaDraw;\r
+\r
+ //\r
+ // BUGBUG - we need to think about what to do with wide and narrow character deletions.\r
+ //\r
+ //\r
+ // Blt a character to the screen\r
+ //\r
+ GlyphX = (CurrentMode->CursorColumn * GLYPH_WIDTH) + Private->ModeData[CurrentMode->Mode].DeltaX;\r
+ GlyphY = (CurrentMode->CursorRow * GLYPH_HEIGHT) + Private->ModeData[CurrentMode->Mode].DeltaY;\r
+ if (GraphicsOutput != NULL) {\r
+ GraphicsOutput->Blt (\r
+ GraphicsOutput,\r
+ (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) BltChar,\r
+ EfiBltVideoToBltBuffer,\r
+ GlyphX,\r
+ GlyphY,\r
+ 0,\r
+ 0,\r
+ GLYPH_WIDTH,\r
+ GLYPH_HEIGHT,\r
+ GLYPH_WIDTH * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+ );\r
+ } else {\r
+ UgaDraw->Blt (\r
+ UgaDraw,\r
+ (EFI_UGA_PIXEL *) (UINTN) BltChar,\r
+ EfiUgaVideoToBltBuffer,\r
+ GlyphX,\r
+ GlyphY,\r
+ 0,\r
+ 0,\r
+ GLYPH_WIDTH,\r
+ GLYPH_HEIGHT,\r
+ GLYPH_WIDTH * sizeof (EFI_UGA_PIXEL)\r
+ );\r
+ }\r
+\r
+ GetTextColors (This, &Foreground.Pixel, &Background.Pixel);\r
+\r
+ //\r
+ // Convert Monochrome bitmap of the Glyph to BltBuffer structure\r
+ //\r
+ for (Y = 0; Y < GLYPH_HEIGHT; Y++) {\r
+ for (X = 0; X < GLYPH_WIDTH; X++) {\r
+ if ((mCursorGlyph.GlyphCol1[Y] & (1 << X)) != 0) {\r
+ BltChar[Y][GLYPH_WIDTH - X - 1].Raw ^= Foreground.Raw;\r
+ }\r
+ }\r
+ }\r
+\r
+ if (GraphicsOutput != NULL) {\r
+ GraphicsOutput->Blt (\r
+ GraphicsOutput,\r
+ (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) BltChar,\r
+ EfiBltBufferToVideo,\r
+ 0,\r
+ 0,\r
+ GlyphX,\r
+ GlyphY,\r
+ GLYPH_WIDTH,\r
+ GLYPH_HEIGHT,\r
+ GLYPH_WIDTH * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+ );\r
+ } else {\r
+ UgaDraw->Blt (\r
+ UgaDraw,\r
+ (EFI_UGA_PIXEL *) (UINTN) BltChar,\r
+ EfiUgaBltBufferToVideo,\r
+ 0,\r
+ 0,\r
+ GlyphX,\r
+ GlyphY,\r
+ GLYPH_WIDTH,\r
+ GLYPH_HEIGHT,\r
+ GLYPH_WIDTH * sizeof (EFI_UGA_PIXEL)\r
+ );\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ GraphicsConsole.h\r
+\r
+Abstract:\r
+\r
+ \r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _GRAPHICS_CONSOLE_H\r
+#define _GRAPHICS_CONSOLE_H\r
+\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "ComponentName.h"\r
+\r
+//\r
+// Glyph database\r
+//\r
+#define GLYPH_WIDTH 8\r
+#define GLYPH_HEIGHT 19\r
+\r
+typedef union {\r
+ EFI_NARROW_GLYPH NarrowGlyph;\r
+ EFI_WIDE_GLYPH WideGlyph;\r
+} GLYPH_UNION;\r
+\r
+extern EFI_NARROW_GLYPH UsStdNarrowGlyphData[];\r
+extern EFI_WIDE_GLYPH UsStdWideGlyphData[];\r
+\r
+//\r
+// Device Structure\r
+//\r
+#define GRAPHICS_CONSOLE_DEV_SIGNATURE EFI_SIGNATURE_32 ('g', 's', 't', 'o')\r
+\r
+typedef struct {\r
+ UINTN Columns;\r
+ UINTN Rows;\r
+ INTN DeltaX;\r
+ INTN DeltaY;\r
+ UINT32 GopWidth;\r
+ UINT32 GopHeight;\r
+ UINT32 GopModeNumber;\r
+} GRAPHICS_CONSOLE_MODE_DATA;\r
+\r
+#define GRAPHICS_MAX_MODE 3\r
+\r
+typedef struct {\r
+ UINTN Signature;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;\r
+ EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;\r
+ GRAPHICS_CONSOLE_MODE_DATA ModeData[GRAPHICS_MAX_MODE];\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LineBuffer;\r
+ EFI_HII_HANDLE HiiHandle;\r
+} GRAPHICS_CONSOLE_DEV;\r
+\r
+#define GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS(a) \\r
+ CR (a, GRAPHICS_CONSOLE_DEV, SimpleTextOutput, GRAPHICS_CONSOLE_DEV_SIGNATURE)\r
+\r
+//\r
+// Global Variables\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding;\r
+\r
+//\r
+// Prototypes\r
+//\r
+UINTN\r
+ReturnNarrowFontSize (\r
+ VOID\r
+ );\r
+\r
+UINTN\r
+ReturnWideFontSize (\r
+ VOID\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutReset (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN BOOLEAN ExtendedVerification\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutOutputString (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN CHAR16 *WString\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutTestString (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN CHAR16 *WString\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutQueryMode (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN ModeNumber,\r
+ OUT UINTN *Columns,\r
+ OUT UINTN *Rows\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutSetMode (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN ModeNumber\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutSetAttribute (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN Attribute\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutClearScreen (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutSetCursorPosition (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN Column,\r
+ IN UINTN Row\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleConOutEnableCursor (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN BOOLEAN Visible\r
+ );\r
+\r
+EFI_STATUS\r
+EfiLocateHiiProtocol (\r
+ VOID\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleControllerDriverSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleControllerDriverStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GraphicsConsoleControllerDriverStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ );\r
+\r
+#endif\r
--- /dev/null
+#/** @file\r
+# Component description file for GraphicsConsole module\r
+#\r
+# This is the main routine for initializing the Graphics Console support routines.\r
+# Copyright (c) 2006 - 2007, Intel Corporation\r
+#\r
+# All rights reserved. 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
+# 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
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = GraphicsConsole\r
+ FILE_GUID = CCCB0C28-4B24-11d5-9A5A-0090273FC14D\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+ ENTRY_POINT = InitializeGraphicsConsole\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+# DRIVER_BINDING = gGraphicsConsoleDriverBinding \r
+# COMPONENT_NAME = gGraphicsConsoleComponentName \r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ ComponentName.c\r
+ ComponentName.h\r
+ LaffStd.c\r
+ GraphicsConsole.c\r
+ GraphicsConsole.h\r
+ CommonHeader.h\r
+ EntryPoint.c\r
+\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ IntelFrameworkPkg/IntelFrameworkPkg.dec \r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ UefiBootServicesTableLib\r
+ MemoryAllocationLib\r
+ BaseMemoryLib\r
+ UefiLib\r
+ UefiDriverEntryPoint\r
+ DebugLib\r
+ HiiLib \r
+\r
+\r
+################################################################################\r
+#\r
+# Guid C Name Section - list of Guids that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Guids]\r
+ FontPack # ALWAYS_PRODUCED HII Formset\r
+\r
+\r
+################################################################################\r
+#\r
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
+# that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Protocols]\r
+ gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
+ gEfiSimpleTextOutProtocolGuid # PROTOCOL BY_START\r
+ gEfiHiiProtocolGuid # PROTOCOL TO_START\r
+ gEfiGraphicsOutputProtocolGuid # PROTOCOL TO_START\r
+ gEfiUgaDrawProtocolGuid # PROTOCOL TO_START\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>GraphicsConsole</ModuleName>\r
+ <ModuleType>DXE_DRIVER</ModuleType>\r
+ <GuidValue>CCCB0C28-4B24-11d5-9A5A-0090273FC14D</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Component description file for GraphicsConsole module</Abstract>\r
+ <Description>This is the main routine for initializing the Graphics Console support routines.</Description>\r
+ <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
+ <License>All rights reserved. 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
+ 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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>GraphicsConsole</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED" RecommendedInstanceGuid="bda39d3a-451b-4350-8266-81ab10fa0523">\r
+ <Keyword>DebugLib</Keyword>\r
+ <HelpText>Recommended libary Instance is PeiDxeDebugLibReportStatusCode instance in MdePkg.</HelpText>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiDriverModelLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiDriverEntryPoint</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>HiiLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseMemoryLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>MemoryAllocationLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiBootServicesTableLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>GraphicsConsole.h</Filename>\r
+ <Filename>GraphicsConsole.c</Filename>\r
+ <Filename>LaffStd.c</Filename>\r
+ <Filename>ComponentName.h</Filename>\r
+ <Filename>ComponentName.c</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ </PackageDependencies>\r
+ <Protocols>\r
+ <Protocol Usage="TO_START">\r
+ <ProtocolCName>gEfiUgaDrawProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="TO_START">\r
+ <ProtocolCName>gEfiGraphicsOutputProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="TO_START">\r
+ <ProtocolCName>gEfiHiiProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="BY_START">\r
+ <ProtocolCName>gEfiSimpleTextOutProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="ALWAYS_CONSUMED">\r
+ <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ </Protocols>\r
+ <HiiPackages>\r
+ <HiiPackage Usage="ALWAYS_PRODUCED">\r
+ <HiiCName>FontPack</HiiCName>\r
+ <HelpText>Register UsStdNarrow Fonts into the global database.</HelpText>\r
+ </HiiPackage>\r
+ </HiiPackages>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ <Extern>\r
+ <DriverBinding>gGraphicsConsoleDriverBinding</DriverBinding>\r
+ <ComponentName>gGraphicsConsoleComponentName</ComponentName>\r
+ </Extern>\r
+ </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ LaffStd.c\r
+\r
+Abstract:\r
+\r
+ \r
+Revision History\r
+\r
+--*/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "GraphicsConsole.h"\r
+\r
+EFI_NARROW_GLYPH UsStdNarrowGlyphData[] = {\r
+ //\r
+ // Unicode glyphs from 0x20 to 0x7e are the same as ASCII characters 0x20 to 0x7e\r
+ //\r
+ { 0x0020, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x0021, 0x00, {0x00,0x00,0x00,0x18,0x3C,0x3C,0x3C,0x18,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00}},\r
+ { 0x0022, 0x00, {0x00,0x00,0x00,0x6C,0x6C,0x6C,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x0023, 0x00, {0x00,0x00,0x00,0x00,0x6C,0x6C,0x6C,0xFE,0x6C,0x6C,0x6C,0xFE,0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00}},\r
+ { 0x0024, 0x00, {0x00,0x00,0x18,0x18,0x7C,0xC6,0xC6,0x60,0x38,0x0C,0x06,0xC6,0xC6,0x7C,0x18,0x18,0x00,0x00,0x00}},\r
+ { 0x0025, 0x00, {0x00,0x00,0x00,0xC6,0xC6,0x0C,0x0C,0x18,0x18,0x30,0x30,0x60,0x60,0xC6,0xC6,0x00,0x00,0x00,0x00}},\r
+ { 0x0026, 0x00, {0x00,0x00,0x00,0x78,0xCC,0xCC,0xCC,0x78,0x76,0xDC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00}},\r
+ { 0x0027, 0x00, {0x00,0x00,0x18,0x18,0x18,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x0028, 0x00, {0x00,0x00,0x00,0x06,0x0C,0x0C,0x18,0x18,0x18,0x18,0x18,0x18,0x0C,0x0C,0x06,0x00,0x00,0x00,0x00}},\r
+ { 0x0029, 0x00, {0x00,0x00,0x00,0xC0,0x60,0x60,0x30,0x30,0x30,0x30,0x30,0x30,0x60,0x60,0xC0,0x00,0x00,0x00,0x00}},\r
+ { 0x002a, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6C,0x38,0xFE,0x38,0x6C,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x002b, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x7E,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x002c, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x30,0x00,0x00,0x00,0x00}},\r
+ { 0x002d, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x002e, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x002f, 0x00, {0x00,0x00,0x00,0x06,0x06,0x0C,0x0C,0x18,0x18,0x30,0x30,0x60,0x60,0xC0,0xC0,0x00,0x00,0x00,0x00}},\r
+ { 0x0030, 0x00, {0x00,0x00,0x00,0x38,0x6C,0xC6,0xC6,0xC6,0xD6,0xD6,0xC6,0xC6,0xC6,0x6C,0x38,0x00,0x00,0x00,0x00}},\r
+ { 0x0031, 0x00, {0x00,0x00,0x00,0x18,0x38,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00}},\r
+ { 0x0032, 0x00, {0x00,0x00,0x00,0x7C,0xC6,0x06,0x06,0x06,0x0C,0x18,0x30,0x60,0xC0,0xC2,0xFE,0x00,0x00,0x00,0x00}},\r
+ { 0x0033, 0x00, {0x00,0x00,0x00,0x7C,0xC6,0x06,0x06,0x06,0x3C,0x06,0x06,0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x0034, 0x00, {0x00,0x00,0x00,0x1C,0x1C,0x3C,0x3C,0x6C,0x6C,0xCC,0xFE,0x0C,0x0C,0x0C,0x1E,0x00,0x00,0x00,0x00}},\r
+ { 0x0035, 0x00, {0x00,0x00,0x00,0xFE,0xC0,0xC0,0xC0,0xC0,0xFC,0x06,0x06,0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x0036, 0x00, {0x00,0x00,0x00,0x3C,0x60,0xC0,0xC0,0xC0,0xFC,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x0037, 0x00, {0x00,0x00,0x00,0xFE,0xC6,0x06,0x06,0x06,0x0C,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00}},\r
+ { 0x0038, 0x00, {0x00,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x0039, 0x00, {0x00,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0x7E,0x06,0x06,0x06,0x06,0x0C,0x78,0x00,0x00,0x00,0x00}},\r
+ { 0x003a, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x003b, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x30,0x00,0x00,0x00,0x00}},\r
+ { 0x003c, 0x00, {0x00,0x00,0x00,0x00,0x06,0x0C,0x18,0x30,0x60,0xC0,0x60,0x30,0x18,0x0C,0x06,0x00,0x00,0x00,0x00}},\r
+ { 0x003d, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x003e, 0x00, {0x00,0x00,0x00,0x00,0xC0,0x60,0x30,0x18,0x0C,0x06,0x0C,0x18,0x30,0x60,0xC0,0x00,0x00,0x00,0x00}},\r
+ { 0x003f, 0x00, {0x00,0x00,0x00,0x7C,0xC6,0xC6,0x0C,0x0C,0x18,0x18,0x18,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00}},\r
+ { 0x0040, 0x00, {0x00,0x00,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xDE,0xDE,0xDE,0xDC,0xC0,0xC0,0x7E,0x00,0x00,0x00,0x00}},\r
+\r
+ { 0x0041, 0x00, {0x00,0x00,0x00,0x10,0x38,0x6C,0xC6,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00}},\r
+\r
+ { 0x0042, 0x00, {0x00,0x00,0x00,0xFC,0x66,0x66,0x66,0x66,0x7C,0x66,0x66,0x66,0x66,0x66,0xFC,0x00,0x00,0x00,0x00}},\r
+ { 0x0043, 0x00, {0x00,0x00,0x00,0x3C,0x66,0xC2,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC2,0x66,0x3C,0x00,0x00,0x00,0x00}},\r
+ { 0x0044, 0x00, {0x00,0x00,0x00,0xF8,0x6C,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x6C,0xF8,0x00,0x00,0x00,0x00}},\r
+ { 0x0045, 0x00, {0x00,0x00,0x00,0xFE,0x66,0x62,0x60,0x68,0x78,0x68,0x60,0x60,0x62,0x66,0xFE,0x00,0x00,0x00,0x00}},\r
+ { 0x0046, 0x00, {0x00,0x00,0x00,0xFE,0x66,0x62,0x60,0x64,0x7C,0x64,0x60,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00}},\r
+ { 0x0047, 0x00, {0x00,0x00,0x00,0x3C,0x66,0xC2,0xC0,0xC0,0xC0,0xDE,0xC6,0xC6,0xC6,0x66,0x3C,0x00,0x00,0x00,0x00}},\r
+ { 0x0048, 0x00, {0x00,0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00}},\r
+ { 0x0049, 0x00, {0x00,0x00,0x00,0xFC,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0xFC,0x00,0x00,0x00,0x00}},\r
+ { 0x004a, 0x00, {0x00,0x00,0x00,0x1E,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0xCC,0xCC,0x78,0x00,0x00,0x00,0x00}},\r
+ { 0x004b, 0x00, {0x00,0x00,0x00,0xE6,0x66,0x6C,0x6C,0x78,0x70,0x78,0x6C,0x6C,0x66,0x66,0xE6,0x00,0x00,0x00,0x00}},\r
+ { 0x004c, 0x00, {0x00,0x00,0x00,0xF0,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x62,0x66,0xFE,0x00,0x00,0x00,0x00}},\r
+ { 0x004d, 0x00, {0x00,0x00,0x00,0xC6,0xEE,0xEE,0xFE,0xFE,0xD6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00}},\r
+ { 0x004e, 0x00, {0x00,0x00,0x00,0xC6,0xE6,0xF6,0xF6,0xF6,0xDE,0xCE,0xCE,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00}},\r
+ { 0x004f, 0x00, {0x00,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x0050, 0x00, {0x00,0x00,0x00,0xFC,0x66,0x66,0x66,0x66,0x66,0x7C,0x60,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00}},\r
+ { 0x0051, 0x00, {0x00,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xD6,0xD6,0x7C,0x1C,0x0E,0x00,0x00}},\r
+ { 0x0052, 0x00, {0x00,0x00,0x00,0xFC,0x66,0x66,0x66,0x66,0x7C,0x78,0x6C,0x6C,0x66,0x66,0xE6,0x00,0x00,0x00,0x00}},\r
+ { 0x0053, 0x00, {0x00,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0x60,0x38,0x0C,0x06,0x06,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x0054, 0x00, {0x00,0x00,0x00,0xFC,0xFC,0xB4,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00,0x00,0x00}},\r
+ { 0x0055, 0x00, {0x00,0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x0056, 0x00, {0x00,0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x6C,0x38,0x10,0x00,0x00,0x00,0x00}},\r
+ { 0x0057, 0x00, {0x00,0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xD6,0xD6,0xD6,0xFE,0x6C,0x6C,0x00,0x00,0x00,0x00}},\r
+ { 0x0058, 0x00, {0x00,0x00,0x00,0xC6,0xC6,0xC6,0x6C,0x6C,0x38,0x6C,0x6C,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00}},\r
+ { 0x0059, 0x00, {0x00,0x00,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00,0x00,0x00}},\r
+ { 0x005a, 0x00, {0x00,0x00,0x00,0xFE,0xC6,0x86,0x0C,0x0C,0x18,0x30,0x60,0xC0,0xC2,0xC6,0xFE,0x00,0x00,0x00,0x00}},\r
+ { 0x005b, 0x00, {0x00,0x00,0x00,0x1E,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1E,0x00,0x00,0x00,0x00}},\r
+ { 0x005c, 0x00, {0x00,0x00,0x00,0xC0,0xC0,0x60,0x60,0x30,0x30,0x18,0x18,0x0C,0x0C,0x06,0x06,0x00,0x00,0x00,0x00}},\r
+ { 0x005d, 0x00, {0x00,0x00,0x00,0xF0,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0xF0,0x00,0x00,0x00,0x00}},\r
+ { 0x005e, 0x00, {0x00,0x00,0x10,0x38,0x6C,0xC6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x005f, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00}},\r
+ { 0x0060, 0x00, {0x00,0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x0061, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x0C,0x0C,0x7C,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00}},\r
+ { 0x0062, 0x00, {0x00,0x00,0x00,0xE0,0x60,0x60,0x60,0x7C,0x66,0x66,0x66,0x66,0x66,0x66,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x0063, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC0,0xC0,0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x0064, 0x00, {0x00,0x00,0x00,0x1C,0x0C,0x0C,0x0C,0x3C,0x6C,0xCC,0xCC,0xCC,0xCC,0xCC,0x7E,0x00,0x00,0x00,0x00}},\r
+ { 0x0065, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC6,0xFE,0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x0066, 0x00, {0x00,0x00,0x00,0x1E,0x33,0x30,0x30,0x30,0x78,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00,0x00,0x00}},\r
+ { 0x0067, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x76,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x7C,0x0C,0xCC,0x78,0x00}},\r
+ { 0x0068, 0x00, {0x00,0x00,0x00,0xE0,0x60,0x60,0x60,0x7C,0x76,0x66,0x66,0x66,0x66,0x66,0xE6,0x00,0x00,0x00,0x00}},\r
+ { 0x0069, 0x00, {0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00}},\r
+ { 0x006a, 0x00, {0x00,0x00,0x00,0x0C,0x0C,0x0C,0x00,0x1C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x6C,0x38,0x00}},\r
+ { 0x006b, 0x00, {0x00,0x00,0x00,0xE0,0x60,0x60,0x66,0x6C,0x78,0x70,0x78,0x6C,0x6C,0x66,0xE6,0x00,0x00,0x00,0x00}},\r
+ { 0x006c, 0x00, {0x00,0x00,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00}},\r
+ { 0x006d, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEC,0xEE,0xFE,0xD6,0xD6,0xD6,0xD6,0xD6,0x00,0x00,0x00,0x00}},\r
+ { 0x006e, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xDC,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00}},\r
+ { 0x006f, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x0070, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xDC,0x66,0x66,0x66,0x66,0x66,0x66,0x7C,0x60,0x60,0xF0,0x00}},\r
+ { 0x0071, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x76,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x7C,0x0C,0x0C,0x1E,0x00}},\r
+ { 0x0072, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xDC,0x66,0x60,0x60,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00}},\r
+ { 0x0073, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC0,0x7C,0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x0074, 0x00, {0x00,0x00,0x00,0x10,0x30,0x30,0x30,0xFC,0x30,0x30,0x30,0x30,0x30,0x36,0x1C,0x00,0x00,0x00,0x00}},\r
+ { 0x0075, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00}},\r
+ { 0x0076, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x30,0x00,0x00,0x00,0x00}},\r
+ { 0x0077, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC6,0xC6,0xC6,0xD6,0xD6,0xFE,0xEE,0x6C,0x00,0x00,0x00,0x00}},\r
+ { 0x0078, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC6,0x6C,0x38,0x38,0x6C,0x6C,0xC6,0xC6,0x00,0x00,0x00,0x00}},\r
+ { 0x0079, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7E,0x06,0x0C,0xF8,0x00}},\r
+ { 0x007a, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x86,0x0C,0x18,0x30,0x60,0xC0,0xFE,0x00,0x00,0x00,0x00}},\r
+ { 0x007b, 0x00, {0x00,0x00,0x00,0x0E,0x18,0x18,0x18,0x18,0x30,0x18,0x18,0x18,0x18,0x18,0x0E,0x00,0x00,0x00,0x00}},\r
+ { 0x007c, 0x00, {0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00}},\r
+ { 0x007d, 0x00, {0x00,0x00,0x00,0xE0,0x30,0x30,0x30,0x30,0x18,0x30,0x30,0x30,0x30,0x30,0xE0,0x00,0x00,0x00,0x00}},\r
+ { 0x007e, 0x00, {0x00,0x00,0x00,0x76,0xDC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+\r
+ { 0x00a0, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00a1, 0x00, {0x00,0x00,0x00,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x18,0x3C,0x3C,0x3C,0x18,0x00,0x00,0x00,0x00}},\r
+ { 0x00a2, 0x00, {0x00,0x00,0x00,0x00,0x18,0x18,0x7C,0xC6,0xC0,0xC0,0xC0,0xC6,0x7C,0x18,0x18,0x00,0x00,0x00,0x00}},\r
+ { 0x00a3, 0x00, {0x00,0x00,0x00,0x38,0x6C,0x64,0x60,0x60,0xF0,0x60,0x60,0x60,0x60,0xE6,0xFC,0x00,0x00,0x00,0x00}},\r
+ { 0x00a4, 0x00, {0x00,0x00,0x18,0x00,0x00,0x00,0xC6,0x7C,0xC6,0xC6,0xC6,0xC6,0x7C,0xC6,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00a5, 0x00, {0x00,0x00,0x00,0x66,0x66,0x66,0x3C,0x18,0x7E,0x18,0x7E,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00}},\r
+ { 0x00a6, 0x00, {0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00}},\r
+ { 0x00a7, 0x00, {0x00,0x00,0x18,0x7C,0xC6,0x60,0x38,0x6C,0xC6,0xC6,0x6C,0x38,0x0C,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00a8, 0x00, {0x00,0x00,0x00,0xC6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00a9, 0x00, {0x00,0x00,0x00,0x00,0x7C,0x82,0x9A,0xA2,0xA2,0xA2,0x9A,0x82,0x7C,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00aa, 0x00, {0x00,0x00,0x00,0x00,0x3C,0x6C,0x6C,0x6C,0x3E,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00ab, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x6C,0xD8,0x6C,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00ac, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00ad, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00ae, 0x00, {0x00,0x00,0x00,0x00,0x7C,0x82,0xB2,0xAA,0xAA,0xB2,0xAA,0xAA,0x82,0x7C,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00af, 0x00, {0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00b0, 0x00, {0x00,0x00,0x00,0x38,0x6C,0x6C,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00b1, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x7E,0x18,0x18,0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00b2, 0x00, {0x00,0x00,0x00,0x3C,0x66,0x0C,0x18,0x32,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00b3, 0x00, {0x00,0x00,0x00,0x7C,0x06,0x3C,0x06,0x06,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00b4, 0x00, {0x00,0x00,0x00,0x0C,0x18,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00b5, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x7C,0x60,0x60,0xC0,0x00}},\r
+ { 0x00b6, 0x00, {0x00,0x00,0x00,0x7F,0xDB,0xDB,0xDB,0xDB,0x7B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x00,0x00,0x00,0x00}},\r
+ { 0x00b7, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00b8, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x0C,0x78,0x00,0x00,0x00}},\r
+ { 0x00b9, 0x00, {0x00,0x00,0x00,0x18,0x38,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00ba, 0x00, {0x00,0x00,0x00,0x00,0x38,0x6C,0x6C,0x6C,0x38,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00bb, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD8,0x6C,0x36,0x6C,0xD8,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00bc, 0x00, {0x00,0x00,0x00,0x60,0xE0,0x62,0x66,0x6C,0x18,0x30,0x66,0xCE,0x9A,0x3F,0x06,0x06,0x00,0x00,0x00}},\r
+ { 0x00bd, 0x00, {0x00,0x00,0x00,0x60,0xE0,0x62,0x66,0x6C,0x18,0x30,0x60,0xDC,0x86,0x0C,0x18,0x3E,0x00,0x00,0x00}},\r
+ { 0x00be, 0x00, {0x00,0x00,0x00,0xE0,0x30,0x62,0x36,0xEC,0x18,0x30,0x66,0xCE,0x9A,0x3F,0x06,0x06,0x00,0x00,0x00}},\r
+ { 0x00bf, 0x00, {0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x60,0x60,0xC0,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00c0, 0x00, {0x60,0x30,0x18,0x10,0x38,0x6C,0xC6,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00}},\r
+ { 0x00c1, 0x00, {0x18,0x30,0x60,0x10,0x38,0x6C,0xC6,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00}},\r
+ { 0x00c2, 0x00, {0x10,0x38,0x6C,0x10,0x38,0x6C,0xC6,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00}},\r
+ { 0x00c3, 0x00, {0x76,0xDC,0x00,0x00,0x38,0x6C,0xC6,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00}},\r
+ { 0x00c4, 0x00, {0xCC,0xCC,0x00,0x00,0x10,0x38,0x6C,0xC6,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00}},\r
+ { 0x00c5, 0x00, {0x38,0x6C,0x38,0x00,0x10,0x38,0x6C,0xC6,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00}},\r
+ { 0x00c6, 0x00, {0x00,0x00,0x00,0x00,0x3E,0x6C,0xCC,0xCC,0xCC,0xFE,0xCC,0xCC,0xCC,0xCC,0xCE,0x00,0x00,0x00,0x00}},\r
+ { 0x00c7, 0x00, {0x00,0x00,0x00,0x3C,0x66,0xC2,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC2,0x66,0x3C,0x18,0x70,0x00,0x00}},\r
+ { 0x00c8, 0x00, {0x60,0x30,0x18,0x00,0xFE,0x66,0x62,0x60,0x68,0x78,0x68,0x60,0x62,0x66,0xFE,0x00,0x00,0x00,0x00}},\r
+ { 0x00c9, 0x00, {0x18,0x30,0x60,0x00,0xFE,0x66,0x62,0x60,0x68,0x78,0x68,0x60,0x62,0x66,0xFE,0x00,0x00,0x00,0x00}},\r
+ { 0x00ca, 0x00, {0x10,0x38,0x6C,0x00,0xFE,0x66,0x62,0x60,0x68,0x78,0x68,0x60,0x62,0x66,0xFE,0x00,0x00,0x00,0x00}},\r
+ { 0x00cb, 0x00, {0xCC,0xCC,0x00,0x00,0xFE,0x66,0x62,0x60,0x68,0x78,0x68,0x60,0x62,0x66,0xFE,0x00,0x00,0x00,0x00}},\r
+ { 0x00cc, 0x00, {0x60,0x30,0x00,0x00,0x3C,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00}},\r
+ { 0x00cd, 0x00, {0x18,0x30,0x00,0x00,0x3C,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00}},\r
+ { 0x00ce, 0x00, {0x10,0x38,0x6C,0x00,0x3C,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00}},\r
+ { 0x00cf, 0x00, {0xCC,0xCC,0x00,0x00,0x3C,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00}},\r
+ { 0x00d0, 0x00, {0x00,0x00,0x00,0xF8,0x6C,0x66,0x66,0x66,0xF6,0x66,0x66,0x66,0x66,0x6C,0xF8,0x00,0x00,0x00,0x00}},\r
+ { 0x00d1, 0x00, {0x76,0xDC,0x00,0x00,0xC6,0xE6,0xE6,0xF6,0xF6,0xDE,0xDE,0xCE,0xCE,0xC6,0xC6,0x00,0x00,0x00,0x00}},\r
+ { 0x00d2, 0x00, {0x60,0x30,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00d3, 0x00, {0x18,0x30,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00d4, 0x00, {0x10,0x38,0x6C,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00d5, 0x00, {0x76,0xDC,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00d6, 0x00, {0xCC,0xCC,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00d7, 0x00, {0x10,0x28,0x00,0x00,0x00,0x00,0x00,0xC6,0x6C,0x38,0x38,0x6C,0x6C,0xC6,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00d8, 0x00, {0x00,0x00,0x00,0x7C,0xCE,0xCE,0xDE,0xD6,0xD6,0xD6,0xD6,0xF6,0xE6,0xE6,0x7C,0x40,0x00,0x00,0x00}},\r
+ { 0x00d9, 0x00, {0x60,0x30,0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00da, 0x00, {0x18,0x30,0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00db, 0x00, {0x10,0x38,0x6C,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00dc, 0x00, {0xCC,0xCC,0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00dd, 0x00, {0x18,0x30,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x3C,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00}},\r
+ { 0x00de, 0x00, {0x00,0x00,0x10,0x00,0xF0,0x60,0x60,0x7C,0x66,0x66,0x66,0x66,0x7C,0x60,0xF0,0x00,0x00,0x00,0x00}},\r
+ { 0x00df, 0x00, {0x00,0x00,0x00,0x78,0xCC,0xCC,0xCC,0xCC,0xD8,0xCC,0xC6,0xC6,0xC6,0xC6,0xCC,0x00,0x00,0x00,0x00}},\r
+ { 0x00e0, 0x00, {0x00,0x30,0x30,0x60,0x30,0x18,0x00,0x78,0x0C,0x0C,0x7C,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00}},\r
+ { 0x00e1, 0x00, {0x00,0x00,0x00,0x18,0x30,0x60,0x00,0x78,0x0C,0x0C,0x7C,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00}},\r
+ { 0x00e2, 0x00, {0x00,0x00,0x00,0x10,0x38,0x6C,0x00,0x78,0x0C,0x0C,0x7C,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00}},\r
+ { 0x00e3, 0x00, {0x00,0x00,0x00,0x00,0x76,0xDC,0x00,0x78,0x0C,0x0C,0x7C,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00}},\r
+ { 0x00e4, 0x00, {0x00,0x00,0x00,0xCC,0xCC,0x00,0x00,0x78,0x0C,0x0C,0x7C,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00}},\r
+ { 0x00e5, 0x00, {0x00,0x00,0x00,0x38,0x6C,0x38,0x00,0x78,0x0C,0x0C,0x7C,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00}},\r
+ { 0x00e6, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEC,0x36,0x36,0x7E,0xD8,0xD8,0xD8,0x6E,0x00,0x00,0x00,0x00}},\r
+ { 0x00e7, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC0,0xC0,0xC0,0xC0,0xC6,0x7C,0x18,0x70,0x00,0x00}},\r
+ { 0x00e8, 0x00, {0x00,0x00,0x00,0x60,0x30,0x18,0x00,0x7C,0xC6,0xC6,0xFE,0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00e9, 0x00, {0x00,0x00,0x00,0x0C,0x18,0x30,0x00,0x7C,0xC6,0xC6,0xFE,0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00ea, 0x00, {0x00,0x00,0x00,0x10,0x38,0x6C,0x00,0x7C,0xC6,0xC6,0xFE,0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00eb, 0x00, {0x00,0x00,0x00,0xC6,0xC6,0x00,0x00,0x7C,0xC6,0xC6,0xFE,0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00ec, 0x00, {0x00,0x00,0x00,0x60,0x30,0x18,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00}},\r
+ { 0x00ed, 0x00, {0x00,0x00,0x00,0x0C,0x18,0x30,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00}},\r
+ { 0x00ee, 0x00, {0x00,0x00,0x00,0x18,0x3C,0x66,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00}},\r
+ { 0x00ef, 0x00, {0x00,0x00,0x00,0x66,0x66,0x00,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00}},\r
+ { 0x00f0, 0x00, {0x00,0x00,0x00,0x34,0x18,0x2C,0x0C,0x06,0x3E,0x66,0x66,0x66,0x66,0x66,0x3C,0x00,0x00,0x00,0x00}},\r
+ { 0x00f1, 0x00, {0x00,0x00,0x00,0x00,0x76,0xDC,0x00,0xDC,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00}},\r
+ { 0x00f2, 0x00, {0x00,0x00,0x00,0x60,0x30,0x18,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00f3, 0x00, {0x00,0x00,0x00,0x18,0x30,0x60,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00f4, 0x00, {0x00,0x00,0x00,0x10,0x38,0x6C,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00f5, 0x00, {0x00,0x00,0x00,0x00,0x76,0xDC,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00f6, 0x00, {0x00,0x00,0x00,0xC6,0xC6,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00f7, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x7E,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { 0x00f8, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0xCE,0xDE,0xD6,0xF6,0xE6,0xC6,0x7C,0x00,0x00,0x00,0x00}},\r
+ { 0x00f9, 0x00, {0x00,0x00,0x00,0x60,0x30,0x18,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00}},\r
+ { 0x00fa, 0x00, {0x00,0x00,0x00,0x18,0x30,0x60,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00}},\r
+ { 0x00fb, 0x00, {0x00,0x00,0x00,0x30,0x78,0xCC,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00}},\r
+ { 0x00fc, 0x00, {0x00,0x00,0x00,0xCC,0xCC,0x00,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00}},\r
+ { 0x00fd, 0x00, {0x00,0x00,0x00,0x0C,0x18,0x30,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7E,0x06,0x0C,0xF8,0x00}},\r
+ { 0x00fe, 0x00, {0x00,0x00,0x00,0xE0,0x60,0x60,0x60,0x7C,0x66,0x66,0x66,0x66,0x66,0x66,0x7C,0x60,0x60,0xF0,0x00}},\r
+ { 0x00ff, 0x00, {0x00,0x00,0x00,0xC6,0xC6,0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7E,0x06,0x0C,0x78,0x00}},\r
+\r
+ { (CHAR16)BOXDRAW_HORIZONTAL, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)BOXDRAW_VERTICAL, 0x00, {0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}},\r
+ { (CHAR16)BOXDRAW_DOWN_RIGHT, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}},\r
+ { (CHAR16)BOXDRAW_DOWN_LEFT, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}},\r
+ { (CHAR16)BOXDRAW_UP_RIGHT, 0x00, {0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)BOXDRAW_UP_LEFT, 0x00, {0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)BOXDRAW_VERTICAL_RIGHT, 0x00, {0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1F,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}},\r
+ { (CHAR16)BOXDRAW_VERTICAL_LEFT, 0x00, {0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xF8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}},\r
+ { (CHAR16)BOXDRAW_DOWN_HORIZONTAL, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}},\r
+ { (CHAR16)BOXDRAW_UP_HORIZONTAL, 0x00, {0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)BOXDRAW_VERTICAL_HORIZONTAL, 0x00, {0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xFF,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}},\r
+ { (CHAR16)BOXDRAW_DOUBLE_HORIZONTAL, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)BOXDRAW_DOUBLE_VERTICAL, 0x00, {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36}},\r
+ { (CHAR16)BOXDRAW_DOWN_RIGHT_DOUBLE, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x18,0x1F,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}},\r
+ { (CHAR16)BOXDRAW_DOWN_DOUBLE_RIGHT, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36}},\r
+ { (CHAR16)BOXDRAW_DOUBLE_DOWN_RIGHT, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x30,0x37,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36}},\r
+ { (CHAR16)BOXDRAW_DOWN_LEFT_DOUBLE, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x18,0xF8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}},\r
+ { (CHAR16)BOXDRAW_DOWN_DOUBLE_LEFT, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36}},\r
+ { (CHAR16)BOXDRAW_DOUBLE_DOWN_LEFT, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x06,0xF6,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36}},\r
+ { (CHAR16)BOXDRAW_UP_RIGHT_DOUBLE, 0x00, {0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1F,0x18,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)BOXDRAW_UP_DOUBLE_RIGHT, 0x00, {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)BOXDRAW_DOUBLE_UP_RIGHT, 0x00, {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x37,0x30,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)BOXDRAW_UP_LEFT_DOUBLE, 0x00, {0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xF8,0x18,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)BOXDRAW_UP_DOUBLE_LEFT, 0x00, {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)BOXDRAW_DOUBLE_UP_LEFT, 0x00, {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xF6,0x06,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)BOXDRAW_VERTICAL_RIGHT_DOUBLE, 0x00, {0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1F,0x18,0x1F,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}},\r
+ { (CHAR16)BOXDRAW_VERTICAL_DOUBLE_RIGHT, 0x00, {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x37,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36}},\r
+ { (CHAR16)BOXDRAW_DOUBLE_VERTICAL_RIGHT, 0x00, {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x37,0x30,0x37,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36}},\r
+ { (CHAR16)BOXDRAW_VERTICAL_LEFT_DOUBLE, 0x00, {0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xF8,0x18,0xF8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}},\r
+ { (CHAR16)BOXDRAW_VERTICAL_DOUBLE_LEFT, 0x00, {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xF6,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36}},\r
+ { (CHAR16)BOXDRAW_DOUBLE_VERTICAL_LEFT, 0x00, {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xF6,0x06,0xF6,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36}},\r
+ { (CHAR16)BOXDRAW_DOWN_HORIZONTAL_DOUBLE, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0xFF,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}},\r
+ { (CHAR16)BOXDRAW_DOWN_DOUBLE_HORIZONTAL, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36}},\r
+ { (CHAR16)BOXDRAW_DOUBLE_DOWN_HORIZONTAL, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0xF7,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36}},\r
+ { (CHAR16)BOXDRAW_UP_HORIZONTAL_DOUBLE, 0x00, {0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)BOXDRAW_UP_DOUBLE_HORIZONTAL, 0x00, {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)BOXDRAW_DOUBLE_UP_HORIZONTAL, 0x00, {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xF7,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0x00, {0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xFF,0x18,0xFF,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}},\r
+ { (CHAR16)BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0x00, {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xFF,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36}},\r
+ { (CHAR16)BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0x00, {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xF7,0x00,0xF7,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36}},\r
+\r
+ { (CHAR16)BLOCKELEMENT_FULL_BLOCK, 0x00, {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}},\r
+ { (CHAR16)BLOCKELEMENT_LIGHT_SHADE, 0x00, {0x22,0x88,0x22,0x88,0x22,0x88,0x22,0x88,0x22,0x88,0x22,0x88,0x22,0x88,0x22,0x88,0x22,0x88,0x22}},\r
+\r
+ { (CHAR16)GEOMETRICSHAPE_RIGHT_TRIANGLE, 0x00, {0x00,0x00,0x00,0x00,0x00,0xC0,0xE0,0xF0,0xF8,0xFE,0xF8,0xF0,0xE0,0xC0,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)GEOMETRICSHAPE_LEFT_TRIANGLE, 0x00, {0x00,0x00,0x00,0x00,0x00,0x06,0x0E,0x1E,0x3E,0xFE,0x3E,0x1E,0x0E,0x06,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)GEOMETRICSHAPE_UP_TRIANGLE, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x38,0x38,0x7C,0x7C,0xFE,0xFE,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)GEOMETRICSHAPE_DOWN_TRIANGLE, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0xFE,0x7C,0x7C,0x38,0x38,0x10,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+\r
+ { (CHAR16)ARROW_UP, 0x00, {0x00,0x00,0x00,0x18,0x3C,0x7E,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)ARROW_DOWN, 0x00, {0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7E,0x3C,0x18,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)ARROW_LEFT, 0x00, {0x00,0x00,0x00,0x00,0x00,0x20,0x60,0x60,0xFE,0xFE,0x60,0x60,0x20,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+ { (CHAR16)ARROW_RIGHT, 0x00, {0x00,0x00,0x00,0x00,0x00,0x08,0x0C,0x0C,0xFE,0xFE,0x0C,0x0C,0x08,0x00,0x00,0x00,0x00,0x00,0x00}},\r
+\r
+ { 0x0000, 0x00, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} //EOL\r
+};\r
+\r
+UINTN\r
+ReturnNarrowFontSize (\r
+ VOID\r
+ )\r
+{\r
+ //\r
+ // I need the size of this outside of this file, so here is a stub function to do that for me\r
+ //\r
+ return sizeof (UsStdNarrowGlyphData);\r
+}\r
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2006 - 2007, Intel Corporation\r
+ All rights reserved. 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
+ 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
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/SimpleTextOut.h>\r
+#include <Protocol/SerialIo.h>\r
+#include <Guid/GlobalVariable.h>\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/SimpleTextIn.h>\r
+#include <Guid/HotPlugDevice.h>\r
+#include <Guid/PcAnsi.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
+//\r
+// Driver Binding Externs\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL gTerminalDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gTerminalComponentName;\r
+\r
+#endif\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ ComponentName.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "Terminal.h"\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+EFI_COMPONENT_NAME_PROTOCOL gTerminalComponentName = {\r
+ TerminalComponentNameGetDriverName,\r
+ TerminalComponentNameGetControllerName,\r
+ "eng"\r
+};\r
+\r
+static EFI_UNICODE_STRING_TABLE mTerminalDriverNameTable[] = {\r
+ {\r
+ "eng",\r
+ (CHAR16 *) L"Serial Terminal Driver"\r
+ },\r
+ {\r
+ NULL,\r
+ NULL\r
+ }\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalComponentNameGetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **DriverName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+ Arguments:\r
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ Language - A pointer to a three character ISO 639-2 language identifier.\r
+ This is the language of the driver name that that the caller \r
+ is requesting, and it must match one of the languages specified\r
+ in SupportedLanguages. The number of languages supported by a \r
+ driver is up to the driver writer.\r
+ DriverName - A pointer to the Unicode string to return. This Unicode string\r
+ is the name of the driver specified by This in the language \r
+ specified by Language.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Unicode string for the Driver specified by This\r
+ and the language specified by Language was returned \r
+ in DriverName.\r
+ EFI_INVALID_PARAMETER - Language is NULL.\r
+ EFI_INVALID_PARAMETER - DriverName is NULL.\r
+ EFI_UNSUPPORTED - The driver specified by This does not support the \r
+ language specified by Language.\r
+\r
+--*/\r
+{\r
+ return LookupUnicodeString (\r
+ Language,\r
+ gTerminalComponentName.SupportedLanguages,\r
+ mTerminalDriverNameTable,\r
+ DriverName\r
+ );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Retrieves a Unicode string that is the user readable name of the controller\r
+ that is being managed by an EFI Driver.\r
+\r
+ Arguments:\r
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ ControllerHandle - The handle of a controller that the driver specified by \r
+ This is managing. This handle specifies the controller \r
+ whose name is to be returned.\r
+ ChildHandle - The handle of the child controller to retrieve the name \r
+ of. This is an optional parameter that may be NULL. It \r
+ will be NULL for device drivers. It will also be NULL \r
+ for a bus drivers that wish to retrieve the name of the \r
+ bus controller. It will not be NULL for a bus driver \r
+ that wishes to retrieve the name of a child controller.\r
+ Language - A pointer to a three character ISO 639-2 language \r
+ identifier. This is the language of the controller name \r
+ that that the caller is requesting, and it must match one\r
+ of the languages specified in SupportedLanguages. The \r
+ number of languages supported by a driver is up to the \r
+ driver writer.\r
+ ControllerName - A pointer to the Unicode string to return. This Unicode\r
+ string is the name of the controller specified by \r
+ ControllerHandle and ChildHandle in the language \r
+ specified by Language from the point of view of the \r
+ driver specified by This. \r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Unicode string for the user readable name in the\r
+ language specified by Language for the driver \r
+ specified by This was returned in DriverName.\r
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
+ EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - Language is NULL.\r
+ EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+ EFI_UNSUPPORTED - The driver specified by This is not currently \r
+ managing the controller specified by \r
+ ControllerHandle and ChildHandle.\r
+ EFI_UNSUPPORTED - The driver specified by This does not support the \r
+ language specified by Language.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOutput;\r
+ TERMINAL_DEV *TerminalDevice;\r
+\r
+ //\r
+ // Make sure this driver is currently managing ControllHandle\r
+ //\r
+ Status = EfiTestManagedDevice (\r
+ ControllerHandle,\r
+ gTerminalDriverBinding.DriverBindingHandle,\r
+ &gEfiSerialIoProtocolGuid\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // This is a bus driver, so ChildHandle can not be NULL.\r
+ //\r
+ if (ChildHandle == NULL) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ Status = EfiTestChildHandle (\r
+ ControllerHandle,\r
+ ChildHandle,\r
+ &gEfiSerialIoProtocolGuid\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Get our context back\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ChildHandle,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ (VOID **) &SimpleTextOutput,\r
+ gTerminalDriverBinding.DriverBindingHandle,\r
+ ChildHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (SimpleTextOutput);\r
+\r
+ return LookupUnicodeString (\r
+ Language,\r
+ gTerminalComponentName.SupportedLanguages,\r
+ TerminalDevice->ControllerNameTable,\r
+ ControllerName\r
+ );\r
+}\r
--- /dev/null
+/**@file\r
+ Entry Point Source file.\r
+\r
+ This file contains the user entry point \r
+\r
+ Copyright (c) 2006 - 2007, Intel Corporation\r
+ All rights reserved. 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
+ 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
+\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+/**\r
+ The user Entry Point for module Terminal. 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
+InitializeTerminal(\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
+ &gTerminalDriverBinding,\r
+ ImageHandle,\r
+ &gTerminalComponentName,\r
+ NULL,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+\r
+ return Status;\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. 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
+ Terminal.c\r
+\r
+Abstract:\r
+\r
+Revision History:\r
+\r
+--*/\r
+\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "Terminal.h"\r
+\r
+#include "FrameworkDxe.h"\r
+\r
+//\r
+// Globals\r
+//\r
+EFI_DRIVER_BINDING_PROTOCOL gTerminalDriverBinding = {\r
+ TerminalDriverBindingSupported,\r
+ TerminalDriverBindingStart,\r
+ TerminalDriverBindingStop,\r
+ 0xa,\r
+ NULL,\r
+ NULL\r
+};\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
+ EFI_SERIAL_IO_PROTOCOL *SerialIo;\r
+ VENDOR_DEVICE_PATH *Node;\r
+\r
+ //\r
+ // If remaining device path is not NULL, then make sure it is a\r
+ // device path that describes a terminal communications protocol.\r
+ //\r
+ if (RemainingDevicePath != NULL) {\r
+\r
+ Node = (VENDOR_DEVICE_PATH *) RemainingDevicePath;\r
+\r
+ if (Node->Header.Type != MESSAGING_DEVICE_PATH ||\r
+ Node->Header.SubType != MSG_VENDOR_DP ||\r
+ DevicePathNodeLength(&Node->Header) != sizeof(VENDOR_DEVICE_PATH)) {\r
+\r
+ return EFI_UNSUPPORTED;\r
+\r
+ }\r
+ //\r
+ // only supports PC ANSI, VT100, VT100+ and VT-UTF8 terminal types\r
+ //\r
+ if (!CompareGuid (&Node->Guid, &gEfiPcAnsiGuid) &&\r
+ !CompareGuid (&Node->Guid, &gEfiVT100Guid) &&\r
+ !CompareGuid (&Node->Guid, &gEfiVT100PlusGuid) &&\r
+ !CompareGuid (&Node->Guid, &gEfiVTUTF8Guid)) {\r
+\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+ }\r
+ //\r
+ // Open the IO Abstraction(s) needed to perform the supported test\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID **) &ParentDevicePath,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (Status == EFI_ALREADY_STARTED) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiDevicePathProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+\r
+ //\r
+ // The Controller must support the Serial I/O Protocol.\r
+ // This driver is a bus driver with at most 1 child device, so it is\r
+ // ok for it to be already started.\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiSerialIoProtocolGuid,\r
+ (VOID **) &SerialIo,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (Status == EFI_ALREADY_STARTED) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Close the I/O Abstraction(s) used to perform the supported test\r
+ //\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiSerialIoProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+\r
+ Start the controller.\r
+\r
+ Arguments:\r
+\r
+ This - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ Controller - The handle of the controller to start.\r
+ RemainingDevicePath - A pointer to the remaining portion of a devcie path.\r
+\r
+ Returns:\r
+\r
+ EFI_SUCCESS.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SERIAL_IO_PROTOCOL *SerialIo;\r
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
+ VENDOR_DEVICE_PATH *Node;\r
+ VENDOR_DEVICE_PATH *DefaultNode;\r
+ EFI_SERIAL_IO_MODE *Mode;\r
+ UINTN SerialInTimeOut;\r
+ TERMINAL_DEV *TerminalDevice;\r
+ UINT8 TerminalType;\r
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;\r
+ UINTN EntryCount;\r
+ UINTN Index;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+\r
+ TerminalDevice = NULL;\r
+ DefaultNode = NULL;\r
+ //\r
+ // Get the Device Path Protocol to build the device path of the child device\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID **) &ParentDevicePath,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Report that the remote terminal is being enabled\r
+ //\r
+ DevicePath = ParentDevicePath;\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_PROGRESS_CODE,\r
+ EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_PC_ENABLE,\r
+ DevicePath\r
+ );\r
+\r
+ //\r
+ // Open the Serial I/O Protocol BY_DRIVER. It might already be started.\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiSerialIoProtocolGuid,\r
+ (VOID **) &SerialIo,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
+ return Status;\r
+ }\r
+\r
+ if (Status != EFI_ALREADY_STARTED) {\r
+ //\r
+ // If Serial I/O is not already open by this driver, then tag the handle\r
+ // with the Terminal Driver GUID and update the ConInDev, ConOutDev, and\r
+ // StdErrDev variables with the list of possible terminal types on this\r
+ // serial port.\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiCallerIdGuid,\r
+ NULL,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &Controller,\r
+ &gEfiCallerIdGuid,\r
+ DuplicateDevicePath (ParentDevicePath),\r
+ NULL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+ //\r
+ // if the serial device is a hot plug device, do not update the\r
+ // ConInDev, ConOutDev, and StdErrDev variables.\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiHotPlugDeviceGuid,\r
+ NULL,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ TerminalUpdateConsoleDevVariable ((CHAR16 *)VarConsoleInpDev, ParentDevicePath);\r
+ TerminalUpdateConsoleDevVariable ((CHAR16 *)VarConsoleOutDev, ParentDevicePath);\r
+ TerminalUpdateConsoleDevVariable ((CHAR16 *)VarErrorOutDev, ParentDevicePath);\r
+ }\r
+ }\r
+ }\r
+ //\r
+ // Make sure a child handle does not already exist. This driver can only\r
+ // produce one child per serial port.\r
+ //\r
+ Status = gBS->OpenProtocolInformation (\r
+ Controller,\r
+ &gEfiSerialIoProtocolGuid,\r
+ &OpenInfoBuffer,\r
+ &EntryCount\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = EFI_SUCCESS;\r
+ for (Index = 0; Index < EntryCount; Index++) {\r
+ if (OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) {\r
+ Status = EFI_ALREADY_STARTED;\r
+ }\r
+ }\r
+\r
+ FreePool (OpenInfoBuffer);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ }\r
+ //\r
+ // If RemainingDevicePath is NULL, then create default device path node\r
+ //\r
+ if (RemainingDevicePath == NULL) {\r
+ DefaultNode = AllocatePool (sizeof (VENDOR_DEVICE_PATH));\r
+ if (DefaultNode == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Error;\r
+ }\r
+\r
+ CopyMem (&DefaultNode->Guid, &gEfiPcAnsiGuid, sizeof (EFI_GUID));\r
+ RemainingDevicePath = (EFI_DEVICE_PATH_PROTOCOL*) DefaultNode;\r
+ }\r
+ //\r
+ // Use the RemainingDevicePath to determine the terminal type\r
+ //\r
+ Node = (VENDOR_DEVICE_PATH *) RemainingDevicePath;\r
+\r
+ if (CompareGuid (&Node->Guid, &gEfiPcAnsiGuid)) {\r
+\r
+ TerminalType = PcAnsiType;\r
+\r
+ } else if (CompareGuid (&Node->Guid, &gEfiVT100Guid)) {\r
+\r
+ TerminalType = VT100Type;\r
+\r
+ } else if (CompareGuid (&Node->Guid, &gEfiVT100PlusGuid)) {\r
+\r
+ TerminalType = VT100PlusType;\r
+\r
+ } else if (CompareGuid (&Node->Guid, &gEfiVTUTF8Guid)) {\r
+\r
+ TerminalType = VTUTF8Type;\r
+\r
+ } else {\r
+ goto Error;\r
+ }\r
+ //\r
+ // Initialize the Terminal Dev\r
+ //\r
+ TerminalDevice = AllocatePool (sizeof (TERMINAL_DEV));\r
+ if (TerminalDevice == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Error;\r
+ }\r
+\r
+ ZeroMem (TerminalDevice, sizeof (TERMINAL_DEV));\r
+\r
+ TerminalDevice->Signature = TERMINAL_DEV_SIGNATURE;\r
+\r
+ TerminalDevice->TerminalType = TerminalType;\r
+\r
+ TerminalDevice->SerialIo = SerialIo;\r
+\r
+ //\r
+ // Simple Input Protocol\r
+ //\r
+ TerminalDevice->SimpleInput.Reset = TerminalConInReset;\r
+ TerminalDevice->SimpleInput.ReadKeyStroke = TerminalConInReadKeyStroke;\r
+\r
+ Status = gBS->CreateEvent (\r
+ EVT_NOTIFY_WAIT,\r
+ TPL_NOTIFY,\r
+ TerminalConInWaitForKey,\r
+ &TerminalDevice->SimpleInput,\r
+ &TerminalDevice->SimpleInput.WaitForKey\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+ //\r
+ // initialize the FIFO buffer used for accommodating\r
+ // the pre-read pending characters\r
+ //\r
+ InitializeRawFiFo (TerminalDevice);\r
+ InitializeUnicodeFiFo (TerminalDevice);\r
+ InitializeEfiKeyFiFo (TerminalDevice);\r
+\r
+ //\r
+ // Set the timeout value of serial buffer for\r
+ // keystroke response performance issue\r
+ //\r
+ Mode = TerminalDevice->SerialIo->Mode;\r
+\r
+ SerialInTimeOut = 0;\r
+ if (Mode->BaudRate != 0) {\r
+ SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) * 2 * 1000000 / (UINTN) Mode->BaudRate;\r
+ }\r
+\r
+ Status = TerminalDevice->SerialIo->SetAttributes (\r
+ TerminalDevice->SerialIo,\r
+ Mode->BaudRate,\r
+ Mode->ReceiveFifoDepth,\r
+ (UINT32) SerialInTimeOut,\r
+ (EFI_PARITY_TYPE) (Mode->Parity),\r
+ (UINT8) Mode->DataBits,\r
+ (EFI_STOP_BITS_TYPE) (Mode->StopBits)\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // if set attributes operation fails, invalidate\r
+ // the value of SerialInTimeOut,thus make it\r
+ // inconsistent with the default timeout value\r
+ // of serial buffer. This will invoke the recalculation\r
+ // in the readkeystroke routine.\r
+ //\r
+ TerminalDevice->SerialInTimeOut = 0;\r
+ } else {\r
+ TerminalDevice->SerialInTimeOut = SerialInTimeOut;\r
+ }\r
+ //\r
+ // Build the device path for the child device\r
+ //\r
+ Status = SetTerminalDevicePath (\r
+ TerminalDevice->TerminalType,\r
+ ParentDevicePath,\r
+ &TerminalDevice->DevicePath\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+\r
+ DevicePath = TerminalDevice->DevicePath;\r
+\r
+ Status = TerminalDevice->SimpleInput.Reset (\r
+ &TerminalDevice->SimpleInput,\r
+ FALSE\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // Need to report Error Code first\r
+ //\r
+ goto ReportError;\r
+ }\r
+ //\r
+ // Simple Text Output Protocol\r
+ //\r
+ TerminalDevice->SimpleTextOutput.Reset = TerminalConOutReset;\r
+ TerminalDevice->SimpleTextOutput.OutputString = TerminalConOutOutputString;\r
+ TerminalDevice->SimpleTextOutput.TestString = TerminalConOutTestString;\r
+ TerminalDevice->SimpleTextOutput.QueryMode = TerminalConOutQueryMode;\r
+ TerminalDevice->SimpleTextOutput.SetMode = TerminalConOutSetMode;\r
+ TerminalDevice->SimpleTextOutput.SetAttribute = TerminalConOutSetAttribute;\r
+ TerminalDevice->SimpleTextOutput.ClearScreen = TerminalConOutClearScreen;\r
+ TerminalDevice->SimpleTextOutput.SetCursorPosition = TerminalConOutSetCursorPosition;\r
+ TerminalDevice->SimpleTextOutput.EnableCursor = TerminalConOutEnableCursor;\r
+ TerminalDevice->SimpleTextOutput.Mode = &TerminalDevice->SimpleTextOutputMode;\r
+\r
+ TerminalDevice->SimpleTextOutputMode.MaxMode = 1;\r
+ //\r
+ // For terminal devices, cursor is always visible\r
+ //\r
+ TerminalDevice->SimpleTextOutputMode.CursorVisible = TRUE;\r
+ TerminalDevice->SimpleTextOutputMode.Attribute = EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK);\r
+\r
+ Status = TerminalDevice->SimpleTextOutput.Reset (\r
+ &TerminalDevice->SimpleTextOutput,\r
+ FALSE\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto ReportError;\r
+ }\r
+\r
+ Status = TerminalDevice->SimpleTextOutput.SetMode (\r
+ &TerminalDevice->SimpleTextOutput,\r
+ 0\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto ReportError;\r
+ }\r
+\r
+ Status = TerminalDevice->SimpleTextOutput.EnableCursor (\r
+ &TerminalDevice->SimpleTextOutput,\r
+ TRUE\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto ReportError;\r
+ }\r
+ //\r
+ //\r
+ //\r
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;\r
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;\r
+\r
+ Status = gBS->CreateEvent (\r
+ EVT_TIMER,\r
+ TPL_CALLBACK,\r
+ NULL,\r
+ NULL,\r
+ &TerminalDevice->TwoSecondTimeOut\r
+ );\r
+\r
+ //\r
+ // Build the component name for the child device\r
+ //\r
+ TerminalDevice->ControllerNameTable = NULL;\r
+ switch (TerminalDevice->TerminalType) {\r
+ case PcAnsiType:\r
+ AddUnicodeString (\r
+ "eng",\r
+ gTerminalComponentName.SupportedLanguages,\r
+ &TerminalDevice->ControllerNameTable,\r
+ (CHAR16 *)L"PC-ANSI Serial Console"\r
+ );\r
+ break;\r
+\r
+ case VT100Type:\r
+ AddUnicodeString (\r
+ "eng",\r
+ gTerminalComponentName.SupportedLanguages,\r
+ &TerminalDevice->ControllerNameTable,\r
+ (CHAR16 *)L"VT-100 Serial Console"\r
+ );\r
+ break;\r
+\r
+ case VT100PlusType:\r
+ AddUnicodeString (\r
+ "eng",\r
+ gTerminalComponentName.SupportedLanguages,\r
+ &TerminalDevice->ControllerNameTable,\r
+ (CHAR16 *)L"VT-100+ Serial Console"\r
+ );\r
+ break;\r
+\r
+ case VTUTF8Type:\r
+ AddUnicodeString (\r
+ "eng",\r
+ gTerminalComponentName.SupportedLanguages,\r
+ &TerminalDevice->ControllerNameTable,\r
+ (CHAR16 *)L"VT-UTF8 Serial Console"\r
+ );\r
+ break;\r
+ }\r
+ //\r
+ // Install protocol interfaces for the serial device.\r
+ //\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &TerminalDevice->Handle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ TerminalDevice->DevicePath,\r
+ &gEfiSimpleTextInProtocolGuid,\r
+ &TerminalDevice->SimpleInput,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ &TerminalDevice->SimpleTextOutput,\r
+ NULL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+ //\r
+ // if the serial device is a hot plug device, attaches the HotPlugGuid\r
+ // onto the terminal device handle.\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiHotPlugDeviceGuid,\r
+ NULL,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &TerminalDevice->Handle,\r
+ &gEfiHotPlugDeviceGuid,\r
+ NULL,\r
+ NULL\r
+ );\r
+ }\r
+ //\r
+ // Register the Parent-Child relationship via\r
+ // EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiSerialIoProtocolGuid,\r
+ (VOID **) &TerminalDevice->SerialIo,\r
+ This->DriverBindingHandle,\r
+ TerminalDevice->Handle,\r
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+\r
+ if (DefaultNode != NULL) {\r
+ FreePool (DefaultNode);\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+\r
+ReportError:\r
+ //\r
+ // Report error code before exiting\r
+ //\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+ EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_CONTROLLER_ERROR,\r
+ DevicePath\r
+ );\r
+\r
+Error:\r
+ //\r
+ // Use the Stop() function to free all resources allocated in Start()\r
+ //\r
+ if (TerminalDevice != NULL) {\r
+\r
+ if (TerminalDevice->Handle != NULL) {\r
+ This->Stop (This, Controller, 1, &TerminalDevice->Handle);\r
+ } else {\r
+\r
+ if (TerminalDevice->TwoSecondTimeOut != NULL) {\r
+ gBS->CloseEvent (TerminalDevice->TwoSecondTimeOut);\r
+ }\r
+\r
+ if (TerminalDevice->SimpleInput.WaitForKey != NULL) {\r
+ gBS->CloseEvent (TerminalDevice->SimpleInput.WaitForKey);\r
+ }\r
+\r
+ if (TerminalDevice->ControllerNameTable != NULL) {\r
+ FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);\r
+ }\r
+\r
+ if (TerminalDevice->DevicePath != NULL) {\r
+ FreePool (TerminalDevice->DevicePath);\r
+ }\r
+\r
+ FreePool (TerminalDevice);\r
+ }\r
+ }\r
+\r
+ if (DefaultNode != NULL) {\r
+ FreePool (DefaultNode);\r
+ }\r
+\r
+ This->Stop (This, Controller, 0, NULL);\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+\r
+ Stop a device controller.\r
+\r
+ Arguments:\r
+\r
+ This - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ Controller - A handle to the device being stopped.\r
+ NumberOfChildren - The number of child device handles in ChildHandleBuffer.\r
+ ChildHandleBuffer - An array of child handles to be freed.\r
+\r
+ Returns:\r
+\r
+ EFI_SUCCESS - Operation successful.\r
+ EFI_DEVICE_ERROR - Devices error.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN Index;\r
+ BOOLEAN AllChildrenStopped;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOutput;\r
+ TERMINAL_DEV *TerminalDevice;\r
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
+ EFI_SERIAL_IO_PROTOCOL *SerialIo;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+\r
+ Status = gBS->HandleProtocol (\r
+ Controller,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID **) &DevicePath\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Report that the remote terminal is being disabled\r
+ //\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_PROGRESS_CODE,\r
+ EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_PC_DISABLE,\r
+ DevicePath\r
+ );\r
+\r
+ //\r
+ // Complete all outstanding transactions to Controller.\r
+ // Don't allow any new transaction to Controller to be started.\r
+ //\r
+ if (NumberOfChildren == 0) {\r
+ //\r
+ // Close the bus driver\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiCallerIdGuid,\r
+ (VOID **) &ParentDevicePath,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Remove Parent Device Path from\r
+ // the Console Device Environment Variables\r
+ //\r
+ TerminalRemoveConsoleDevVariable ((CHAR16 *)VarConsoleInpDev, ParentDevicePath);\r
+ TerminalRemoveConsoleDevVariable ((CHAR16 *)VarConsoleOutDev, ParentDevicePath);\r
+ TerminalRemoveConsoleDevVariable ((CHAR16 *)VarErrorOutDev, ParentDevicePath);\r
+\r
+ //\r
+ // Uninstall the Terminal Driver's GUID Tag from the Serial controller\r
+ //\r
+ Status = gBS->UninstallMultipleProtocolInterfaces (\r
+ Controller,\r
+ &gEfiCallerIdGuid,\r
+ ParentDevicePath,\r
+ NULL\r
+ );\r
+\r
+ //\r
+ // Free the ParentDevicePath that was duplicated in Start()\r
+ //\r
+ if (!EFI_ERROR (Status)) {\r
+ FreePool (ParentDevicePath);\r
+ }\r
+ }\r
+\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiSerialIoProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiDevicePathProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ AllChildrenStopped = TRUE;\r
+\r
+ for (Index = 0; Index < NumberOfChildren; Index++) {\r
+\r
+ Status = gBS->OpenProtocol (\r
+ ChildHandleBuffer[Index],\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ (VOID **) &SimpleTextOutput,\r
+ This->DriverBindingHandle,\r
+ ChildHandleBuffer[Index],\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+\r
+ TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (SimpleTextOutput);\r
+\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiSerialIoProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ ChildHandleBuffer[Index]\r
+ );\r
+\r
+ Status = gBS->UninstallMultipleProtocolInterfaces (\r
+ ChildHandleBuffer[Index],\r
+ &gEfiSimpleTextInProtocolGuid,\r
+ &TerminalDevice->SimpleInput,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ &TerminalDevice->SimpleTextOutput,\r
+ &gEfiDevicePathProtocolGuid,\r
+ TerminalDevice->DevicePath,\r
+ NULL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiSerialIoProtocolGuid,\r
+ (VOID **) &SerialIo,\r
+ This->DriverBindingHandle,\r
+ ChildHandleBuffer[Index],\r
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+ );\r
+ } else {\r
+\r
+ if (TerminalDevice->ControllerNameTable != NULL) {\r
+ FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);\r
+ }\r
+\r
+ Status = gBS->OpenProtocol (\r
+ ChildHandleBuffer[Index],\r
+ &gEfiHotPlugDeviceGuid,\r
+ NULL,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = gBS->UninstallMultipleProtocolInterfaces (\r
+ ChildHandleBuffer[Index],\r
+ &gEfiHotPlugDeviceGuid,\r
+ NULL,\r
+ NULL\r
+ );\r
+ } else {\r
+ Status = EFI_SUCCESS;\r
+ }\r
+\r
+ gBS->CloseEvent (TerminalDevice->TwoSecondTimeOut);\r
+ gBS->CloseEvent (TerminalDevice->SimpleInput.WaitForKey);\r
+ FreePool (TerminalDevice->DevicePath);\r
+ FreePool (TerminalDevice);\r
+ }\r
+ }\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ AllChildrenStopped = FALSE;\r
+ }\r
+ }\r
+\r
+ if (!AllChildrenStopped) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+TerminalUpdateConsoleDevVariable (\r
+ IN CHAR16 *VariableName,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN VariableSize;\r
+ UINT8 TerminalType;\r
+ EFI_DEVICE_PATH_PROTOCOL *Variable;\r
+ EFI_DEVICE_PATH_PROTOCOL *NewVariable;\r
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r
+\r
+ Variable = NULL;\r
+\r
+ //\r
+ // Get global variable and its size according to the name given.\r
+ //\r
+ Variable = TerminalGetVariableAndSize (\r
+ VariableName,\r
+ &gEfiGlobalVariableGuid,\r
+ &VariableSize\r
+ );\r
+ //\r
+ // Append terminal device path onto the variable.\r
+ //\r
+ for (TerminalType = PcAnsiType; TerminalType <= VTUTF8Type; TerminalType++) {\r
+ SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath);\r
+ NewVariable = AppendDevicePathInstance (Variable, TempDevicePath);\r
+ if (Variable != NULL) {\r
+ FreePool (Variable);\r
+ }\r
+\r
+ if (TempDevicePath != NULL) {\r
+ FreePool (TempDevicePath);\r
+ }\r
+\r
+ Variable = NewVariable;\r
+ }\r
+\r
+ VariableSize = GetDevicePathSize (Variable);\r
+\r
+ Status = gRT->SetVariable (\r
+ VariableName,\r
+ &gEfiGlobalVariableGuid,\r
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ VariableSize,\r
+ Variable\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ FreePool (Variable);\r
+\r
+ return ;\r
+}\r
+\r
+VOID\r
+TerminalRemoveConsoleDevVariable (\r
+ IN CHAR16 *VariableName,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+\r
+ Remove console device variable.\r
+\r
+ Arguments:\r
+\r
+ VariableName - A pointer to the variable name.\r
+ ParentDevicePath - A pointer to the parent device path.\r
+\r
+ Returns:\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ BOOLEAN FoundOne;\r
+ BOOLEAN Match;\r
+ UINTN VariableSize;\r
+ UINTN InstanceSize;\r
+ UINT8 TerminalType;\r
+ EFI_DEVICE_PATH_PROTOCOL *Instance;\r
+ EFI_DEVICE_PATH_PROTOCOL *Variable;\r
+ EFI_DEVICE_PATH_PROTOCOL *OriginalVariable;\r
+ EFI_DEVICE_PATH_PROTOCOL *NewVariable;\r
+ EFI_DEVICE_PATH_PROTOCOL *SavedNewVariable;\r
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r
+\r
+ Variable = NULL;\r
+ Instance = NULL;\r
+\r
+ //\r
+ // Get global variable and its size according to the name given.\r
+ //\r
+ Variable = TerminalGetVariableAndSize (\r
+ VariableName,\r
+ &gEfiGlobalVariableGuid,\r
+ &VariableSize\r
+ );\r
+ if (Variable == NULL) {\r
+ return ;\r
+ }\r
+\r
+ FoundOne = FALSE;\r
+ OriginalVariable = Variable;\r
+ NewVariable = NULL;\r
+\r
+ //\r
+ // Get first device path instance from Variable\r
+ //\r
+ Instance = GetNextDevicePathInstance (&Variable, &InstanceSize);\r
+ if (Instance == NULL) {\r
+ FreePool (OriginalVariable);\r
+ return ;\r
+ }\r
+ //\r
+ // Loop through all the device path instances of Variable\r
+ //\r
+ do {\r
+ //\r
+ // Loop through all the terminal types that this driver supports\r
+ //\r
+ Match = FALSE;\r
+ for (TerminalType = PcAnsiType; TerminalType <= VTUTF8Type; TerminalType++) {\r
+\r
+ SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath);\r
+\r
+ //\r
+ // Compare the genterated device path to the current device path instance\r
+ //\r
+ if (TempDevicePath != NULL) {\r
+ if (CompareMem (Instance, TempDevicePath, InstanceSize) == 0) {\r
+ Match = TRUE;\r
+ FoundOne = TRUE;\r
+ }\r
+\r
+ FreePool (TempDevicePath);\r
+ }\r
+ }\r
+ //\r
+ // If a match was not found, then keep the current device path instance\r
+ //\r
+ if (!Match) {\r
+ SavedNewVariable = NewVariable;\r
+ NewVariable = AppendDevicePathInstance (NewVariable, Instance);\r
+ if (SavedNewVariable != NULL) {\r
+ FreePool (SavedNewVariable);\r
+ }\r
+ }\r
+ //\r
+ // Get next device path instance from Variable\r
+ //\r
+ FreePool (Instance);\r
+ Instance = GetNextDevicePathInstance (&Variable, &InstanceSize);\r
+ } while (Instance != NULL);\r
+\r
+ FreePool (OriginalVariable);\r
+\r
+ if (FoundOne) {\r
+ VariableSize = GetDevicePathSize (NewVariable);\r
+\r
+ Status = gRT->SetVariable (\r
+ VariableName,\r
+ &gEfiGlobalVariableGuid,\r
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ VariableSize,\r
+ NewVariable\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+\r
+ if (NewVariable != NULL) {\r
+ FreePool (NewVariable);\r
+ }\r
+\r
+ return ;\r
+}\r
+\r
+VOID *\r
+TerminalGetVariableAndSize (\r
+ IN CHAR16 *Name,\r
+ IN EFI_GUID *VendorGuid,\r
+ OUT UINTN *VariableSize\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Read the EFI variable (VendorGuid/Name) and return a dynamically allocated\r
+ buffer, and the size of the buffer. On failure return NULL.\r
+\r
+Arguments:\r
+ Name - String part of EFI variable name\r
+\r
+ VendorGuid - GUID part of EFI variable name\r
+\r
+ VariableSize - Returns the size of the EFI variable that was read\r
+\r
+Returns:\r
+ Dynamically allocated memory that contains a copy of the EFI variable.\r
+ Caller is repsoncible freeing the buffer.\r
+\r
+ NULL - Variable was not read\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN BufferSize;\r
+ VOID *Buffer;\r
+\r
+ Buffer = NULL;\r
+\r
+ //\r
+ // Pass in a small size buffer to find the actual variable size.\r
+ //\r
+ BufferSize = 1;\r
+ Buffer = AllocatePool (BufferSize);\r
+ if (Buffer == NULL) {\r
+ *VariableSize = 0;\r
+ return NULL;\r
+ }\r
+\r
+ Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);\r
+\r
+ if (Status == EFI_SUCCESS) {\r
+ *VariableSize = BufferSize;\r
+ return Buffer;\r
+\r
+ } else if (Status == EFI_BUFFER_TOO_SMALL) {\r
+ //\r
+ // Allocate the buffer to return\r
+ //\r
+ FreePool (Buffer);\r
+ Buffer = AllocatePool (BufferSize);\r
+ if (Buffer == NULL) {\r
+ *VariableSize = 0;\r
+ return NULL;\r
+ }\r
+ //\r
+ // Read variable into the allocated buffer.\r
+ //\r
+ Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);\r
+ if (EFI_ERROR (Status)) {\r
+ BufferSize = 0;\r
+ FreePool (Buffer);\r
+ Buffer = NULL;\r
+ }\r
+ } else {\r
+ //\r
+ // Variable not found or other errors met.\r
+ //\r
+ BufferSize = 0;\r
+ FreePool (Buffer);\r
+ Buffer = NULL;\r
+ }\r
+\r
+ *VariableSize = BufferSize;\r
+ return Buffer;\r
+}\r
+\r
+EFI_STATUS\r
+SetTerminalDevicePath (\r
+ IN UINT8 TerminalType,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,\r
+ OUT EFI_DEVICE_PATH_PROTOCOL **TerminalDevicePath\r
+ )\r
+{\r
+ VENDOR_DEVICE_PATH Node;\r
+\r
+ *TerminalDevicePath = NULL;\r
+ Node.Header.Type = MESSAGING_DEVICE_PATH;\r
+ Node.Header.SubType = MSG_VENDOR_DP;\r
+\r
+ //\r
+ // generate terminal device path node according to terminal type.\r
+ //\r
+ switch (TerminalType) {\r
+\r
+ case PcAnsiType:\r
+ CopyMem (\r
+ &Node.Guid,\r
+ &gEfiPcAnsiGuid,\r
+ sizeof (EFI_GUID)\r
+ );\r
+ break;\r
+\r
+ case VT100Type:\r
+ CopyMem (\r
+ &Node.Guid,\r
+ &gEfiVT100Guid,\r
+ sizeof (EFI_GUID)\r
+ );\r
+ break;\r
+\r
+ case VT100PlusType:\r
+ CopyMem (\r
+ &Node.Guid,\r
+ &gEfiVT100PlusGuid,\r
+ sizeof (EFI_GUID)\r
+ );\r
+ break;\r
+\r
+ case VTUTF8Type:\r
+ CopyMem (\r
+ &Node.Guid,\r
+ &gEfiVTUTF8Guid,\r
+ sizeof (EFI_GUID)\r
+ );\r
+ break;\r
+\r
+ default:\r
+ return EFI_UNSUPPORTED;\r
+ break;\r
+ }\r
+\r
+ SetDevicePathNodeLength (\r
+ &Node.Header,\r
+ sizeof (VENDOR_DEVICE_PATH)\r
+ );\r
+ //\r
+ // append the terminal node onto parent device path\r
+ // to generate a complete terminal device path.\r
+ //\r
+ *TerminalDevicePath = AppendDevicePathNode (\r
+ ParentDevicePath,\r
+ (EFI_DEVICE_PATH_PROTOCOL *) &Node\r
+ );\r
+ if (*TerminalDevicePath == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+InitializeRawFiFo (\r
+ IN TERMINAL_DEV *TerminalDevice\r
+ )\r
+{\r
+ //\r
+ // Make the raw fifo empty.\r
+ //\r
+ TerminalDevice->RawFiFo.Head = TerminalDevice->RawFiFo.Tail;\r
+}\r
+\r
+VOID\r
+InitializeUnicodeFiFo (\r
+ IN TERMINAL_DEV *TerminalDevice\r
+ )\r
+{\r
+ //\r
+ // Make the unicode fifo empty\r
+ //\r
+ TerminalDevice->UnicodeFiFo.Head = TerminalDevice->UnicodeFiFo.Tail;\r
+}\r
+\r
+VOID\r
+InitializeEfiKeyFiFo (\r
+ IN TERMINAL_DEV *TerminalDevice\r
+ )\r
+{\r
+ //\r
+ // Make the efi key fifo empty\r
+ //\r
+ TerminalDevice->EfiKeyFiFo.Head = TerminalDevice->EfiKeyFiFo.Tail;\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ terminal.h\r
+\r
+Abstract:\r
+\r
+ \r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _TERMINAL_H\r
+#define _TERMINAL_H\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#define RAW_FIFO_MAX_NUMBER 256\r
+#define FIFO_MAX_NUMBER 128\r
+\r
+typedef struct {\r
+ UINT8 Head;\r
+ UINT8 Tail;\r
+ UINT8 Data[RAW_FIFO_MAX_NUMBER + 1];\r
+} RAW_DATA_FIFO;\r
+\r
+typedef struct {\r
+ UINT8 Head;\r
+ UINT8 Tail;\r
+ UINT16 Data[FIFO_MAX_NUMBER + 1];\r
+} UNICODE_FIFO;\r
+\r
+typedef struct {\r
+ UINT8 Head;\r
+ UINT8 Tail;\r
+ EFI_INPUT_KEY Data[FIFO_MAX_NUMBER + 1];\r
+} EFI_KEY_FIFO;\r
+\r
+#define TERMINAL_DEV_SIGNATURE EFI_SIGNATURE_32 ('t', 'm', 'n', 'l')\r
+\r
+typedef struct {\r
+ UINTN Signature;\r
+ EFI_HANDLE Handle;\r
+ UINT8 TerminalType;\r
+ EFI_SERIAL_IO_PROTOCOL *SerialIo;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ VENDOR_DEVICE_PATH Node;\r
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;\r
+ EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;\r
+ UINTN SerialInTimeOut;\r
+ RAW_DATA_FIFO RawFiFo;\r
+ UNICODE_FIFO UnicodeFiFo;\r
+ EFI_KEY_FIFO EfiKeyFiFo;\r
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
+ EFI_EVENT TwoSecondTimeOut;\r
+ UINT32 InputState;\r
+ UINT32 ResetState;\r
+\r
+ //\r
+ // Esc could not be output to the screen by user,\r
+ // but the terminal driver need to output it to\r
+ // the terminal emulation software to send control sequence.\r
+ // This boolean is used by the terminal driver only\r
+ // to indicate whether the Esc could be sent or not.\r
+ //\r
+ BOOLEAN OutputEscChar;\r
+} TERMINAL_DEV;\r
+\r
+#define INPUT_STATE_DEFAULT 0x00\r
+#define INPUT_STATE_ESC 0x01\r
+#define INPUT_STATE_CSI 0x02\r
+#define INPUT_STATE_LEFTOPENBRACKET 0x04\r
+#define INPUT_STATE_O 0x08\r
+#define INPUT_STATE_2 0x10\r
+\r
+#define RESET_STATE_DEFAULT 0x00\r
+#define RESET_STATE_ESC_R 0x01\r
+#define RESET_STATE_ESC_R_ESC_r 0x02\r
+\r
+#define TERMINAL_CON_IN_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleInput, TERMINAL_DEV_SIGNATURE)\r
+#define TERMINAL_CON_OUT_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleTextOutput, TERMINAL_DEV_SIGNATURE)\r
+\r
+typedef union {\r
+ UINT8 Utf8_1;\r
+ UINT8 Utf8_2[2];\r
+ UINT8 Utf8_3[3];\r
+} UTF8_CHAR;\r
+\r
+#define PcAnsiType 0\r
+#define VT100Type 1\r
+#define VT100PlusType 2\r
+#define VTUTF8Type 3\r
+\r
+#define LEFTOPENBRACKET 0x5b // '['\r
+#define ACAP 0x41\r
+#define BCAP 0x42\r
+#define CCAP 0x43\r
+#define DCAP 0x44\r
+\r
+#define MODE0_COLUMN_COUNT 80\r
+#define MODE0_ROW_COUNT 25\r
+\r
+#define BACKSPACE 8\r
+#define ESC 27\r
+#define CSI 0x9B\r
+#define DEL 127\r
+#define BRIGHT_CONTROL_OFFSET 2\r
+#define FOREGROUND_CONTROL_OFFSET 6\r
+#define BACKGROUND_CONTROL_OFFSET 11\r
+#define ROW_OFFSET 2\r
+#define COLUMN_OFFSET 5\r
+\r
+typedef struct {\r
+ UINT16 Unicode;\r
+ CHAR8 PcAnsi;\r
+ CHAR8 Ascii;\r
+} UNICODE_TO_CHAR;\r
+\r
+#define VarConsoleInpDev L"ConInDev"\r
+#define VarConsoleOutDev L"ConOutDev"\r
+#define VarErrorOutDev L"ErrOutDev"\r
+\r
+//\r
+// Global Variables\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL gTerminalDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gTerminalComponentName;\r
+\r
+//\r
+// Prototypes\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeTerminal (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConInReset (\r
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
+ IN BOOLEAN ExtendedVerification\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConInReadKeyStroke (\r
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
+ OUT EFI_INPUT_KEY *Key\r
+ )\r
+;\r
+\r
+VOID\r
+EFIAPI\r
+TerminalConInWaitForKey (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutReset (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN BOOLEAN ExtendedVerification\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutOutputString (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN CHAR16 *WString\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutTestString (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN CHAR16 *WString\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutQueryMode (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN ModeNumber,\r
+ OUT UINTN *Columns,\r
+ OUT UINTN *Rows\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutSetMode (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN ModeNumber\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutSetAttribute (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN Attribute\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutClearScreen (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutSetCursorPosition (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN Column,\r
+ IN UINTN Row\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutEnableCursor (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN BOOLEAN Visible\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalComponentNameGetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **DriverName\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ );\r
+\r
+//\r
+// internal functions\r
+//\r
+EFI_STATUS\r
+TerminalConInCheckForKey (\r
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This\r
+ )\r
+;\r
+\r
+VOID\r
+TerminalUpdateConsoleDevVariable (\r
+ IN CHAR16 *VariableName,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath\r
+ )\r
+;\r
+\r
+VOID\r
+TerminalRemoveConsoleDevVariable (\r
+ IN CHAR16 *VariableName,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath\r
+ )\r
+;\r
+\r
+VOID *\r
+TerminalGetVariableAndSize (\r
+ IN CHAR16 *Name,\r
+ IN EFI_GUID *VendorGuid,\r
+ OUT UINTN *VariableSize\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+SetTerminalDevicePath (\r
+ IN UINT8 TerminalType,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,\r
+ OUT EFI_DEVICE_PATH_PROTOCOL **TerminalDevicePath\r
+ )\r
+;\r
+\r
+VOID\r
+InitializeRawFiFo (\r
+ IN TERMINAL_DEV *TerminalDevice\r
+ )\r
+;\r
+\r
+VOID\r
+InitializeUnicodeFiFo (\r
+ IN TERMINAL_DEV *TerminalDevice\r
+ )\r
+;\r
+\r
+VOID\r
+InitializeEfiKeyFiFo (\r
+ IN TERMINAL_DEV *TerminalDevice\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+GetOneKeyFromSerial (\r
+ EFI_SERIAL_IO_PROTOCOL *SerialIo,\r
+ UINT8 *Input\r
+ )\r
+;\r
+\r
+BOOLEAN\r
+RawFiFoInsertOneKey (\r
+ TERMINAL_DEV *TerminalDevice,\r
+ UINT8 Input\r
+ )\r
+;\r
+\r
+BOOLEAN\r
+RawFiFoRemoveOneKey (\r
+ TERMINAL_DEV *TerminalDevice,\r
+ UINT8 *Output\r
+ )\r
+;\r
+\r
+BOOLEAN\r
+IsRawFiFoEmpty (\r
+ TERMINAL_DEV *TerminalDevice\r
+ )\r
+;\r
+\r
+BOOLEAN\r
+IsRawFiFoFull (\r
+ TERMINAL_DEV *TerminalDevice\r
+ )\r
+;\r
+\r
+BOOLEAN\r
+EfiKeyFiFoInsertOneKey (\r
+ TERMINAL_DEV *TerminalDevice,\r
+ EFI_INPUT_KEY Key\r
+ )\r
+;\r
+\r
+BOOLEAN\r
+EfiKeyFiFoRemoveOneKey (\r
+ TERMINAL_DEV *TerminalDevice,\r
+ EFI_INPUT_KEY *Output\r
+ )\r
+;\r
+\r
+BOOLEAN\r
+IsEfiKeyFiFoEmpty (\r
+ TERMINAL_DEV *TerminalDevice\r
+ )\r
+;\r
+\r
+BOOLEAN\r
+IsEfiKeyFiFoFull (\r
+ TERMINAL_DEV *TerminalDevice\r
+ )\r
+;\r
+\r
+BOOLEAN\r
+UnicodeFiFoInsertOneKey (\r
+ TERMINAL_DEV *TerminalDevice,\r
+ UINT16 Input\r
+ )\r
+;\r
+\r
+BOOLEAN\r
+UnicodeFiFoRemoveOneKey (\r
+ TERMINAL_DEV *TerminalDevice,\r
+ UINT16 *Output\r
+ )\r
+;\r
+\r
+BOOLEAN\r
+IsUnicodeFiFoEmpty (\r
+ TERMINAL_DEV *TerminalDevice\r
+ )\r
+;\r
+\r
+BOOLEAN\r
+IsUnicodeFiFoFull (\r
+ TERMINAL_DEV *TerminalDevice\r
+ )\r
+;\r
+\r
+UINT8\r
+UnicodeFiFoGetKeyCount (\r
+ TERMINAL_DEV *TerminalDevice\r
+ )\r
+;\r
+\r
+VOID\r
+TranslateRawDataToEfiKey (\r
+ IN TERMINAL_DEV *TerminalDevice\r
+ )\r
+;\r
+\r
+//\r
+// internal functions for PC ANSI\r
+//\r
+VOID\r
+AnsiRawDataToUnicode (\r
+ IN TERMINAL_DEV *PcAnsiDevice\r
+ )\r
+;\r
+\r
+VOID\r
+UnicodeToEfiKey (\r
+ IN TERMINAL_DEV *PcAnsiDevice\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+AnsiTestString (\r
+ IN TERMINAL_DEV *TerminalDevice,\r
+ IN CHAR16 *WString\r
+ )\r
+;\r
+\r
+//\r
+// internal functions for VT100\r
+//\r
+EFI_STATUS\r
+VT100TestString (\r
+ IN TERMINAL_DEV *VT100Device,\r
+ IN CHAR16 *WString\r
+ )\r
+;\r
+\r
+//\r
+// internal functions for VT100Plus\r
+//\r
+EFI_STATUS\r
+VT100PlusTestString (\r
+ IN TERMINAL_DEV *TerminalDevice,\r
+ IN CHAR16 *WString\r
+ )\r
+;\r
+\r
+//\r
+// internal functions for VTUTF8\r
+//\r
+VOID\r
+VTUTF8RawDataToUnicode (\r
+ IN TERMINAL_DEV *VtUtf8Device\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+VTUTF8TestString (\r
+ IN TERMINAL_DEV *TerminalDevice,\r
+ IN CHAR16 *WString\r
+ )\r
+;\r
+\r
+VOID\r
+UnicodeToUtf8 (\r
+ IN CHAR16 Unicode,\r
+ OUT UTF8_CHAR *Utf8Char,\r
+ OUT UINT8 *ValidBytes\r
+ )\r
+;\r
+\r
+VOID\r
+GetOneValidUtf8Char (\r
+ IN TERMINAL_DEV *Utf8Device,\r
+ OUT UTF8_CHAR *Utf8Char,\r
+ OUT UINT8 *ValidBytes\r
+ )\r
+;\r
+\r
+VOID\r
+Utf8ToUnicode (\r
+ IN UTF8_CHAR Utf8Char,\r
+ IN UINT8 ValidBytes,\r
+ OUT CHAR16 *UnicodeChar\r
+ )\r
+;\r
+\r
+//\r
+// functions for boxdraw unicode\r
+//\r
+BOOLEAN\r
+TerminalIsValidTextGraphics (\r
+ IN CHAR16 Graphic,\r
+ OUT CHAR8 *PcAnsi, OPTIONAL\r
+ OUT CHAR8 *Ascii OPTIONAL\r
+ )\r
+;\r
+\r
+BOOLEAN\r
+TerminalIsValidAscii (\r
+ IN CHAR16 Ascii\r
+ )\r
+;\r
+\r
+BOOLEAN\r
+TerminalIsValidEfiCntlChar (\r
+ IN CHAR16 CharC\r
+ )\r
+;\r
+\r
+#endif\r
--- /dev/null
+#/** @file\r
+# Component description file for Terminal module.\r
+#\r
+# This driver installs Simple Text In/Out protocol for terminal devices (serial devices or hotplug devices).\r
+# Copyright (c) 2006 - 2007, Intel Corporation\r
+#\r
+# All rights reserved. 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
+# 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
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = Terminal\r
+ FILE_GUID = 9E863906-A40F-4875-977F-5B93FF237FC6\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+ ENTRY_POINT = InitializeTerminal\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+# DRIVER_BINDING = gTerminalDriverBinding \r
+# COMPONENT_NAME = gTerminalComponentName \r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ ComponentName.c\r
+ vtutf8.c\r
+ ansi.c\r
+ TerminalConOut.c\r
+ TerminalConIn.c\r
+ Terminal.c\r
+ Terminal.h\r
+ CommonHeader.h\r
+ EntryPoint.c\r
+\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ IntelFrameworkPkg/IntelFrameworkPkg.dec \r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ DevicePathLib\r
+ UefiRuntimeServicesTableLib\r
+ UefiBootServicesTableLib\r
+ MemoryAllocationLib\r
+ BaseMemoryLib\r
+ ReportStatusCodeLib\r
+ UefiLib\r
+ UefiDriverEntryPoint\r
+ DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Guid C Name Section - list of Guids that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Guids]\r
+ gEfiGlobalVariableGuid # SOMETIMES_CONSUMED L"ErrOutDev"\r
+ gEfiVTUTF8Guid # SOMETIMES_CONSUMED\r
+ gEfiVT100Guid # SOMETIMES_CONSUMED\r
+ gEfiVT100PlusGuid # SOMETIMES_CONSUMED\r
+ gEfiPcAnsiGuid # SOMETIMES_CONSUMED\r
+\r
+\r
+################################################################################\r
+#\r
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
+# that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Protocols]\r
+ gEfiHotPlugDeviceGuid # PROTOCOL SOMETIMES_CONSUMED\r
+ gEfiSerialIoProtocolGuid # PROTOCOL TO_START\r
+ gEfiDevicePathProtocolGuid # PROTOCOL TO_START\r
+ gEfiSimpleTextInProtocolGuid # PROTOCOL BY_START\r
+ gEfiSimpleTextOutProtocolGuid # PROTOCOL BY_START\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+ <MsaHeader>\r
+ <ModuleName>Terminal</ModuleName>\r
+ <ModuleType>DXE_DRIVER</ModuleType>\r
+ <GuidValue>9E863906-A40F-4875-977F-5B93FF237FC6</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Component description file for Terminal module.</Abstract>\r
+ <Description>This driver installs Simple Text In/Out protocol for terminal devices (serial devices or hotplug devices).</Description>\r
+ <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
+ <License>All rights reserved. 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
+ 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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>Terminal</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED" RecommendedInstanceGuid="bda39d3a-451b-4350-8266-81ab10fa0523">\r
+ <Keyword>DebugLib</Keyword>\r
+ <HelpText>Recommended libary Instance is PeiDxeDebugLibReportStatusCode instance in MdePkg.</HelpText>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiDriverModelLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiDriverEntryPoint</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>ReportStatusCodeLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseMemoryLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>MemoryAllocationLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiBootServicesTableLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiRuntimeServicesTableLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>DevicePathLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>Terminal.h</Filename>\r
+ <Filename>Terminal.c</Filename>\r
+ <Filename>TerminalConIn.c</Filename>\r
+ <Filename>TerminalConOut.c</Filename>\r
+ <Filename>ansi.c</Filename>\r
+ <Filename>vtutf8.c</Filename>\r
+ <Filename>ComponentName.c</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+ </PackageDependencies>\r
+ <Protocols>\r
+ <Protocol Usage="BY_START">\r
+ <ProtocolCName>gEfiSimpleTextOutProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="BY_START">\r
+ <ProtocolCName>gEfiSimpleTextInProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="TO_START">\r
+ <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="TO_START">\r
+ <ProtocolCName>gEfiSerialIoProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="SOMETIMES_CONSUMED">\r
+ <ProtocolCName>gEfiHotPlugDeviceGuid</ProtocolCName>\r
+ </Protocol>\r
+ </Protocols>\r
+ <Variables>\r
+ <Variable Usage="SOMETIMES_CONSUMED">\r
+ <VariableName>0x0043 0x006F 0x006E 0x0049 0x006E 0x0044 0x0065 0x0076</VariableName>\r
+ <GuidC_Name>gEfiGlobalVariableGuid</GuidC_Name>\r
+ <HelpText>L"ConInDev" global variable will be updated if the serial device is not a hot plug device.</HelpText>\r
+ </Variable>\r
+ <Variable Usage="SOMETIMES_CONSUMED">\r
+ <VariableName>0x0043 0x006F 0x006E 0x004F 0x0075 0x0074 0x0044 0x0065 0x0076</VariableName>\r
+ <GuidC_Name>gEfiGlobalVariableGuid</GuidC_Name>\r
+ <HelpText>L"ConOutDev" global variable will be updated if the serial device is not a hot plug device.</HelpText>\r
+ </Variable>\r
+ <Variable Usage="SOMETIMES_CONSUMED">\r
+ <VariableName>0x0045 0x0072 0x0072 0x004F 0x0075 0x0074 0x0044 0x0065 0x0076</VariableName>\r
+ <GuidC_Name>gEfiGlobalVariableGuid</GuidC_Name>\r
+ <HelpText>L"ErrOutDev" global variable will be updated if the serial device is not a hot plug device.</HelpText>\r
+ </Variable>\r
+ </Variables>\r
+ <Guids>\r
+ <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+ <GuidCName>gEfiGlobalVariableGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+ <GuidCName>gEfiPcAnsiGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+ <GuidCName>gEfiVT100PlusGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+ <GuidCName>gEfiVT100Guid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+ <GuidCName>gEfiVTUTF8Guid</GuidCName>\r
+ </GuidCNames>\r
+ </Guids>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ <Extern>\r
+ <DriverBinding>gTerminalDriverBinding</DriverBinding>\r
+ <ComponentName>gTerminalComponentName</ComponentName>\r
+ </Extern>\r
+ </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/**@file\r
+ Implementation for EFI_SIMPLE_TEXT_INPUT_PROTOCOL protocol.\r
+ \r
+Copyright (c) 2006 - 2007 Intel Corporation. <BR>\r
+All rights reserved. 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
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "Terminal.h"\r
+\r
+#include "FrameworkDxe.h"\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConInReset (\r
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
+ IN BOOLEAN ExtendedVerification\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.Reset().\r
+ This driver only perform dependent serial device reset regardless of \r
+ the value of ExtendeVerification\r
+ \r
+ Arguments:\r
+ \r
+ This - Indicates the calling context.\r
+ \r
+ ExtendedVerification - Skip by this driver.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The reset operation succeeds. \r
+ \r
+ EFI_DEVICE_ERROR\r
+ The dependent serial port reset fails.\r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ TERMINAL_DEV *TerminalDevice;\r
+\r
+ TerminalDevice = TERMINAL_CON_IN_DEV_FROM_THIS (This);\r
+\r
+ //\r
+ // Report progress code here\r
+ //\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_PROGRESS_CODE,\r
+ EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_PC_RESET,\r
+ TerminalDevice->DevicePath\r
+ );\r
+\r
+ Status = TerminalDevice->SerialIo->Reset (TerminalDevice->SerialIo);\r
+\r
+ //\r
+ // clear all the internal buffer for keys\r
+ //\r
+ InitializeRawFiFo (TerminalDevice);\r
+ InitializeUnicodeFiFo (TerminalDevice);\r
+ InitializeEfiKeyFiFo (TerminalDevice);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+ EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_CONTROLLER_ERROR,\r
+ TerminalDevice->DevicePath\r
+ );\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConInReadKeyStroke (\r
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
+ OUT EFI_INPUT_KEY *Key\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke().\r
+ \r
+ Arguments:\r
+ \r
+ This - Indicates the calling context.\r
+ \r
+ Key - A pointer to a buffer that is filled in with the keystroke\r
+ information for the key that was sent from terminal. \r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The keystroke information is returned successfully.\r
+ \r
+ EFI_NOT_READY\r
+ There is no keystroke data available.\r
+ \r
+ EFI_DEVICE_ERROR\r
+ The dependent serial device encounters error.\r
+ \r
+--*/\r
+{\r
+ TERMINAL_DEV *TerminalDevice;\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Initialize *Key to nonsense value.\r
+ //\r
+ Key->ScanCode = SCAN_NULL;\r
+ Key->UnicodeChar = 0;\r
+ //\r
+ // get TERMINAL_DEV from "This" parameter.\r
+ //\r
+ TerminalDevice = TERMINAL_CON_IN_DEV_FROM_THIS (This);\r
+\r
+ Status = TerminalConInCheckForKey (This);\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_NOT_READY;\r
+ }\r
+\r
+ EfiKeyFiFoRemoveOneKey (TerminalDevice, Key);\r
+\r
+ return EFI_SUCCESS;\r
+\r
+}\r
+\r
+VOID\r
+TranslateRawDataToEfiKey (\r
+ IN TERMINAL_DEV *TerminalDevice\r
+ )\r
+/*++\r
+ Step1: Turn raw data into Unicode (according to different encode).\r
+ Step2: Translate Unicode into key information. \r
+ (according to different terminal standard).\r
+--*/\r
+{\r
+ switch (TerminalDevice->TerminalType) {\r
+\r
+ case PcAnsiType:\r
+ case VT100Type:\r
+ case VT100PlusType:\r
+ AnsiRawDataToUnicode (TerminalDevice);\r
+ UnicodeToEfiKey (TerminalDevice);\r
+ break;\r
+\r
+ case VTUTF8Type:\r
+ //\r
+ // Process all the raw data in the RawFIFO,\r
+ // put the processed key into UnicodeFIFO.\r
+ //\r
+ VTUTF8RawDataToUnicode (TerminalDevice);\r
+\r
+ //\r
+ // Translate all the Unicode data in the UnicodeFIFO to Efi key,\r
+ // then put into EfiKeyFIFO.\r
+ //\r
+ UnicodeToEfiKey (TerminalDevice);\r
+\r
+ break;\r
+ }\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+TerminalConInWaitForKey (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Event notification function for EFI_SIMPLE_TEXT_INPUT_PROTOCOL.WaitForKey event\r
+ Signal the event if there is key available \r
+ \r
+ Arguments:\r
+ \r
+ Event - Indicates the event that invoke this function.\r
+ \r
+ Context - Indicates the calling context.\r
+ \r
+ Returns:\r
+ \r
+ N/A\r
+ \r
+--*/\r
+{\r
+ //\r
+ // Someone is waiting on the keystroke event, if there's\r
+ // a key pending, signal the event\r
+ //\r
+ // Context is the pointer to EFI_SIMPLE_TEXT_INPUT_PROTOCOL\r
+ //\r
+ if (!EFI_ERROR (TerminalConInCheckForKey (Context))) {\r
+\r
+ gBS->SignalEvent (Event);\r
+ }\r
+}\r
+\r
+EFI_STATUS\r
+TerminalConInCheckForKey (\r
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Check for a pending key in the Efi Key FIFO or Serial device buffer.\r
+ \r
+ Arguments:\r
+ \r
+ This - Indicates the calling context.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ There is key pending. \r
+ \r
+ EFI_NOT_READY\r
+ There is no key pending.\r
+ \r
+ EFI_DEVICE_ERROR\r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ TERMINAL_DEV *TerminalDevice;\r
+ UINT32 Control;\r
+ UINT8 Input;\r
+ EFI_SERIAL_IO_MODE *Mode;\r
+ EFI_SERIAL_IO_PROTOCOL *SerialIo;\r
+ UINTN SerialInTimeOut;\r
+\r
+ TerminalDevice = TERMINAL_CON_IN_DEV_FROM_THIS (This);\r
+\r
+ SerialIo = TerminalDevice->SerialIo;\r
+ if (SerialIo == NULL) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+ //\r
+ // if current timeout value for serial device is not identical with\r
+ // the value saved in TERMINAL_DEV structure, then recalculate the\r
+ // timeout value again and set serial attribute according to this value.\r
+ //\r
+ Mode = SerialIo->Mode;\r
+ if (Mode->Timeout != TerminalDevice->SerialInTimeOut) {\r
+\r
+ SerialInTimeOut = 0;\r
+ if (Mode->BaudRate != 0) {\r
+ SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) * 2 * 1000000 / (UINTN) Mode->BaudRate;\r
+ }\r
+\r
+ Status = SerialIo->SetAttributes (\r
+ SerialIo,\r
+ Mode->BaudRate,\r
+ Mode->ReceiveFifoDepth,\r
+ (UINT32) SerialInTimeOut,\r
+ (EFI_PARITY_TYPE) (Mode->Parity),\r
+ (UINT8) Mode->DataBits,\r
+ (EFI_STOP_BITS_TYPE) (Mode->StopBits)\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ TerminalDevice->SerialInTimeOut = 0;\r
+ } else {\r
+ TerminalDevice->SerialInTimeOut = SerialInTimeOut;\r
+ }\r
+ }\r
+ //\r
+ // check whether serial buffer is empty\r
+ //\r
+ Status = SerialIo->GetControl (SerialIo, &Control);\r
+\r
+ if (Control & EFI_SERIAL_INPUT_BUFFER_EMPTY) {\r
+ //\r
+ // Translate all the raw data in RawFIFO into EFI Key,\r
+ // according to different terminal type supported.\r
+ //\r
+ TranslateRawDataToEfiKey (TerminalDevice);\r
+\r
+ //\r
+ // if there is pre-fetched Efi Key in EfiKeyFIFO buffer,\r
+ // return directly.\r
+ //\r
+ if (!IsEfiKeyFiFoEmpty (TerminalDevice)) {\r
+ return EFI_SUCCESS;\r
+ } else {\r
+ return EFI_NOT_READY;\r
+ }\r
+ }\r
+ //\r
+ // Fetch all the keys in the serial buffer,\r
+ // and insert the byte stream into RawFIFO.\r
+ //\r
+ do {\r
+\r
+ Status = GetOneKeyFromSerial (TerminalDevice->SerialIo, &Input);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ if (Status == EFI_DEVICE_ERROR) {\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+ EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_EC_INPUT_ERROR,\r
+ TerminalDevice->DevicePath\r
+ );\r
+ }\r
+ break;\r
+ }\r
+\r
+ RawFiFoInsertOneKey (TerminalDevice, Input);\r
+ } while (TRUE);\r
+\r
+ //\r
+ // Translate all the raw data in RawFIFO into EFI Key,\r
+ // according to different terminal type supported.\r
+ //\r
+ TranslateRawDataToEfiKey (TerminalDevice);\r
+\r
+ if (IsEfiKeyFiFoEmpty (TerminalDevice)) {\r
+ return EFI_NOT_READY;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetOneKeyFromSerial (\r
+ EFI_SERIAL_IO_PROTOCOL *SerialIo,\r
+ UINT8 *Input\r
+ )\r
+/*++\r
+ Get one key out of serial buffer.\r
+ If serial buffer is empty, return EFI_NOT_READY;\r
+ if reading serial buffer encounter error, returns EFI_DEVICE_ERROR;\r
+ if reading serial buffer successfully, put the fetched key to \r
+ the parameter "Input", and return EFI_SUCCESS.\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN Size;\r
+\r
+ Size = 1;\r
+ *Input = 0;\r
+\r
+ Status = SerialIo->Read (SerialIo, &Size, Input);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+\r
+ if (Status == EFI_TIMEOUT) {\r
+ return EFI_NOT_READY;\r
+ }\r
+\r
+ return EFI_DEVICE_ERROR;\r
+\r
+ }\r
+\r
+ if (*Input == 0) {\r
+ return EFI_NOT_READY;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+BOOLEAN\r
+RawFiFoInsertOneKey (\r
+ TERMINAL_DEV *TerminalDevice,\r
+ UINT8 Input\r
+ )\r
+/*++\r
+ Insert one byte raw data into the Raw Data FIFO.\r
+ If FIFO is FULL before data insertion,\r
+ return FALSE, and the key is lost.\r
+--*/\r
+{\r
+ UINT8 Tail;\r
+\r
+ Tail = TerminalDevice->RawFiFo.Tail;\r
+\r
+ if (IsRawFiFoFull (TerminalDevice)) {\r
+ //\r
+ // Raw FIFO is full\r
+ //\r
+ return FALSE;\r
+ }\r
+\r
+ TerminalDevice->RawFiFo.Data[Tail] = Input;\r
+\r
+ TerminalDevice->RawFiFo.Tail = (UINT8) ((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1));\r
+\r
+ return TRUE;\r
+}\r
+\r
+BOOLEAN\r
+RawFiFoRemoveOneKey (\r
+ TERMINAL_DEV *TerminalDevice,\r
+ UINT8 *Output\r
+ )\r
+/*++\r
+ Remove one byte raw data out of the Raw Data FIFO.\r
+ If FIFO buffer is empty before remove operation,\r
+ return FALSE.\r
+--*/\r
+{\r
+ UINT8 Head;\r
+\r
+ Head = TerminalDevice->RawFiFo.Head;\r
+\r
+ if (IsRawFiFoEmpty (TerminalDevice)) {\r
+ //\r
+ // FIFO is empty\r
+ //\r
+ *Output = 0;\r
+ return FALSE;\r
+ }\r
+\r
+ *Output = TerminalDevice->RawFiFo.Data[Head];\r
+\r
+ TerminalDevice->RawFiFo.Head = (UINT8) ((Head + 1) % (RAW_FIFO_MAX_NUMBER + 1));\r
+\r
+ return TRUE;\r
+}\r
+\r
+BOOLEAN\r
+IsRawFiFoEmpty (\r
+ TERMINAL_DEV *TerminalDevice\r
+ )\r
+/*++\r
+ Clarify whether FIFO buffer is empty.\r
+--*/\r
+{\r
+ if (TerminalDevice->RawFiFo.Head == TerminalDevice->RawFiFo.Tail) {\r
+ return TRUE;\r
+ } else {\r
+ return FALSE;\r
+ }\r
+}\r
+\r
+BOOLEAN\r
+IsRawFiFoFull (\r
+ TERMINAL_DEV *TerminalDevice\r
+ )\r
+/*++\r
+ Clarify whether FIFO buffer is full.\r
+--*/\r
+{\r
+ UINT8 Tail;\r
+ UINT8 Head;\r
+\r
+ Tail = TerminalDevice->RawFiFo.Tail;\r
+ Head = TerminalDevice->RawFiFo.Head;\r
+\r
+ if (((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1)) == Head) {\r
+\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+EfiKeyFiFoInsertOneKey (\r
+ TERMINAL_DEV *TerminalDevice,\r
+ EFI_INPUT_KEY Key\r
+ )\r
+/*++\r
+ Insert one pre-fetched key into the FIFO buffer.\r
+ If FIFO buffer is FULL before key insertion,\r
+ return FALSE, and the key is lost.\r
+--*/\r
+{\r
+ UINT8 Tail;\r
+\r
+ Tail = TerminalDevice->EfiKeyFiFo.Tail;\r
+\r
+ if (IsEfiKeyFiFoFull (TerminalDevice)) {\r
+ //\r
+ // Efi Key FIFO is full\r
+ //\r
+ return FALSE;\r
+ }\r
+\r
+ TerminalDevice->EfiKeyFiFo.Data[Tail] = Key;\r
+\r
+ TerminalDevice->EfiKeyFiFo.Tail = (UINT8) ((Tail + 1) % (FIFO_MAX_NUMBER + 1));\r
+\r
+ return TRUE;\r
+}\r
+\r
+BOOLEAN\r
+EfiKeyFiFoRemoveOneKey (\r
+ TERMINAL_DEV *TerminalDevice,\r
+ EFI_INPUT_KEY *Output\r
+ )\r
+/*++\r
+ Remove one pre-fetched key out of the FIFO buffer.\r
+ If FIFO buffer is empty before remove operation,\r
+ return FALSE.\r
+--*/\r
+{\r
+ UINT8 Head;\r
+\r
+ Head = TerminalDevice->EfiKeyFiFo.Head;\r
+\r
+ if (IsEfiKeyFiFoEmpty (TerminalDevice)) {\r
+ //\r
+ // FIFO is empty\r
+ //\r
+ Output->ScanCode = SCAN_NULL;\r
+ Output->UnicodeChar = 0;\r
+ return FALSE;\r
+ }\r
+\r
+ *Output = TerminalDevice->EfiKeyFiFo.Data[Head];\r
+\r
+ TerminalDevice->EfiKeyFiFo.Head = (UINT8) ((Head + 1) % (FIFO_MAX_NUMBER + 1));\r
+\r
+ return TRUE;\r
+}\r
+\r
+BOOLEAN\r
+IsEfiKeyFiFoEmpty (\r
+ TERMINAL_DEV *TerminalDevice\r
+ )\r
+/*++\r
+ Clarify whether FIFO buffer is empty.\r
+--*/\r
+{\r
+ if (TerminalDevice->EfiKeyFiFo.Head == TerminalDevice->EfiKeyFiFo.Tail) {\r
+ return TRUE;\r
+ } else {\r
+ return FALSE;\r
+ }\r
+}\r
+\r
+BOOLEAN\r
+IsEfiKeyFiFoFull (\r
+ TERMINAL_DEV *TerminalDevice\r
+ )\r
+/*++\r
+ Clarify whether FIFO buffer is full.\r
+--*/\r
+{\r
+ UINT8 Tail;\r
+ UINT8 Head;\r
+\r
+ Tail = TerminalDevice->EfiKeyFiFo.Tail;\r
+ Head = TerminalDevice->EfiKeyFiFo.Head;\r
+\r
+ if (((Tail + 1) % (FIFO_MAX_NUMBER + 1)) == Head) {\r
+\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+UnicodeFiFoInsertOneKey (\r
+ TERMINAL_DEV *TerminalDevice,\r
+ UINT16 Input\r
+ )\r
+/*++\r
+ Insert one pre-fetched key into the FIFO buffer.\r
+ If FIFO buffer is FULL before key insertion,\r
+ return FALSE, and the key is lost.\r
+--*/\r
+{\r
+ UINT8 Tail;\r
+\r
+ Tail = TerminalDevice->UnicodeFiFo.Tail;\r
+\r
+ if (IsUnicodeFiFoFull (TerminalDevice)) {\r
+ //\r
+ // Unicode FIFO is full\r
+ //\r
+ return FALSE;\r
+ }\r
+\r
+ TerminalDevice->UnicodeFiFo.Data[Tail] = Input;\r
+\r
+ TerminalDevice->UnicodeFiFo.Tail = (UINT8) ((Tail + 1) % (FIFO_MAX_NUMBER + 1));\r
+\r
+ return TRUE;\r
+}\r
+\r
+BOOLEAN\r
+UnicodeFiFoRemoveOneKey (\r
+ TERMINAL_DEV *TerminalDevice,\r
+ UINT16 *Output\r
+ )\r
+/*++\r
+ Remove one pre-fetched key out of the FIFO buffer.\r
+ If FIFO buffer is empty before remove operation,\r
+ return FALSE.\r
+--*/\r
+{\r
+ UINT8 Head;\r
+\r
+ Head = TerminalDevice->UnicodeFiFo.Head;\r
+\r
+ if (IsUnicodeFiFoEmpty (TerminalDevice)) {\r
+ //\r
+ // FIFO is empty\r
+ //\r
+ Output = NULL;\r
+ return FALSE;\r
+ }\r
+\r
+ *Output = TerminalDevice->UnicodeFiFo.Data[Head];\r
+\r
+ TerminalDevice->UnicodeFiFo.Head = (UINT8) ((Head + 1) % (FIFO_MAX_NUMBER + 1));\r
+\r
+ return TRUE;\r
+}\r
+\r
+BOOLEAN\r
+IsUnicodeFiFoEmpty (\r
+ TERMINAL_DEV *TerminalDevice\r
+ )\r
+/*++\r
+ Clarify whether FIFO buffer is empty.\r
+--*/\r
+{\r
+ if (TerminalDevice->UnicodeFiFo.Head == TerminalDevice->UnicodeFiFo.Tail) {\r
+ return TRUE;\r
+ } else {\r
+ return FALSE;\r
+ }\r
+}\r
+\r
+BOOLEAN\r
+IsUnicodeFiFoFull (\r
+ TERMINAL_DEV *TerminalDevice\r
+ )\r
+/*++\r
+ Clarify whether FIFO buffer is full.\r
+--*/\r
+{\r
+ UINT8 Tail;\r
+ UINT8 Head;\r
+\r
+ Tail = TerminalDevice->UnicodeFiFo.Tail;\r
+ Head = TerminalDevice->UnicodeFiFo.Head;\r
+\r
+ if (((Tail + 1) % (FIFO_MAX_NUMBER + 1)) == Head) {\r
+\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+UINT8\r
+UnicodeFiFoGetKeyCount (\r
+ TERMINAL_DEV *TerminalDevice\r
+ )\r
+{\r
+ UINT8 Tail;\r
+ UINT8 Head;\r
+\r
+ Tail = TerminalDevice->UnicodeFiFo.Tail;\r
+ Head = TerminalDevice->UnicodeFiFo.Head;\r
+\r
+ if (Tail >= Head) {\r
+ return (UINT8) (Tail - Head);\r
+ } else {\r
+ return (UINT8) (Tail + FIFO_MAX_NUMBER + 1 - Head);\r
+ }\r
+}\r
+\r
+STATIC\r
+VOID\r
+UnicodeToEfiKeyFlushState (\r
+ IN TERMINAL_DEV *TerminalDevice\r
+ )\r
+{\r
+ EFI_INPUT_KEY Key;\r
+\r
+ if (TerminalDevice->InputState & INPUT_STATE_ESC) {\r
+ Key.ScanCode = SCAN_ESC;\r
+ Key.UnicodeChar = 0;\r
+ EfiKeyFiFoInsertOneKey (TerminalDevice, Key);\r
+ }\r
+\r
+ if (TerminalDevice->InputState & INPUT_STATE_CSI) {\r
+ Key.ScanCode = SCAN_NULL;\r
+ Key.UnicodeChar = CSI;\r
+ EfiKeyFiFoInsertOneKey (TerminalDevice, Key);\r
+ }\r
+\r
+ if (TerminalDevice->InputState & INPUT_STATE_LEFTOPENBRACKET) {\r
+ Key.ScanCode = SCAN_NULL;\r
+ Key.UnicodeChar = LEFTOPENBRACKET;\r
+ EfiKeyFiFoInsertOneKey (TerminalDevice, Key);\r
+ }\r
+\r
+ if (TerminalDevice->InputState & INPUT_STATE_O) {\r
+ Key.ScanCode = SCAN_NULL;\r
+ Key.UnicodeChar = 'O';\r
+ EfiKeyFiFoInsertOneKey (TerminalDevice, Key);\r
+ }\r
+\r
+ if (TerminalDevice->InputState & INPUT_STATE_2) {\r
+ Key.ScanCode = SCAN_NULL;\r
+ Key.UnicodeChar = '2';\r
+ EfiKeyFiFoInsertOneKey (TerminalDevice, Key);\r
+ }\r
+\r
+ gBS->SetTimer (\r
+ TerminalDevice->TwoSecondTimeOut,\r
+ TimerCancel,\r
+ 0\r
+ );\r
+\r
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;\r
+}\r
+\r
+VOID\r
+UnicodeToEfiKey (\r
+ IN TERMINAL_DEV *TerminalDevice\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Converts a stream of Unicode characters from a terminal input device into EFI Keys that\r
+ can be read through the Simple Input Protocol. The table below shows the keyboard\r
+ input mappings that this function supports. If the ESC sequence listed in one of the \r
+ columns is presented, then it is translated into the coorespoding EFI Scan Code. If a\r
+ matching sequence is not found, then the raw key strokes are converted into EFI Keys.\r
+ \r
+ 2 seconds are allowed for an ESC sequence to be completed. If the ESC sequence is not \r
+ completed in 2 seconds, then the raw key strokes of the partial ESC sequence are \r
+ converted into EFI Keys.\r
+ \r
+ There is one special input sequence that will force the system to reset. \r
+ This is ESC R ESC r ESC R.\r
+ \r
+ Arguments:\r
+\r
+ TerminaDevice : The terminal device to use to translate raw input into EFI Keys\r
+ \r
+ Returns:\r
+\r
+ None\r
+\r
+Symbols used in table below\r
+===========================\r
+ ESC = 0x1B \r
+ CSI = 0x9B \r
+ DEL = 0x7f \r
+ ^ = CTRL\r
+\r
++=========+======+===========+==========+==========+\r
+| | EFI | EFI 1.10 | | |\r
+| | Scan | | VT100+ | |\r
+| KEY | Code | PC ANSI | VTUTF8 | VT100 |\r
++=========+======+===========+==========+==========+\r
+| NULL | 0x00 | | | |\r
+| UP | 0x01 | ESC [ A | ESC [ A | ESC [ A |\r
+| DOWN | 0x02 | ESC [ B | ESC [ B | ESC [ B |\r
+| RIGHT | 0x03 | ESC [ C | ESC [ C | ESC [ C | \r
+| LEFT | 0x04 | ESC [ D | ESC [ D | ESC [ D |\r
+| HOME | 0x05 | ESC [ H | ESC h | ESC [ H |\r
+| END | 0x06 | ESC [ F | ESC k | ESC [ K |\r
+| INSERT | 0x07 | ESC [ @ | ESC + | ESC [ @ |\r
+| | | ESC [ L | | ESC [ L |\r
+| DELETE | 0x08 | ESC [ X | ESC - | ESC [ P |\r
+| PG UP | 0x09 | ESC [ I | ESC ? | ESC [ V |\r
+| | | | | ESC [ ? |\r
+| PG DOWN | 0x0A | ESC [ G | ESC / | ESC [ U |\r
+| | | | | ESC [ / |\r
+| F1 | 0x0B | ESC [ M | ESC 1 | ESC O P |\r
+| F2 | 0x0C | ESC [ N | ESC 2 | ESC O Q |\r
+| F3 | 0x0D | ESC [ O | ESC 3 | ESC O w |\r
+| F4 | 0x0E | ESC [ P | ESC 4 | ESC O x |\r
+| F5 | 0x0F | ESC [ Q | ESC 5 | ESC O t |\r
+| F6 | 0x10 | ESC [ R | ESC 6 | ESC O u |\r
+| F7 | 0x11 | ESC [ S | ESC 7 | ESC O q |\r
+| F8 | 0x12 | ESC [ T | ESC 8 | ESC O r |\r
+| F9 | 0x13 | ESC [ U | ESC 9 | ESC O p |\r
+| F10 | 0x14 | ESC [ V | ESC 0 | ESC O M |\r
+| Escape | 0x17 | ESC | ESC | ESC |\r
++=========+======+===========+==========+=========+\r
+\r
+Special Mappings\r
+================\r
+ESC R ESC r ESC R = Reset System\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_STATUS TimerStatus;\r
+ UINT16 UnicodeChar;\r
+ EFI_INPUT_KEY Key;\r
+ BOOLEAN SetDefaultResetState;\r
+ \r
+ TimerStatus = gBS->CheckEvent (TerminalDevice->TwoSecondTimeOut);\r
+\r
+ if (!EFI_ERROR (TimerStatus)) {\r
+ UnicodeToEfiKeyFlushState (TerminalDevice);\r
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;\r
+ }\r
+\r
+ while (!IsUnicodeFiFoEmpty(TerminalDevice)) {\r
+ \r
+ if (TerminalDevice->InputState != INPUT_STATE_DEFAULT) {\r
+ //\r
+ // Check to see if the 2 second timer has expired\r
+ //\r
+ TimerStatus = gBS->CheckEvent (TerminalDevice->TwoSecondTimeOut);\r
+ if (!EFI_ERROR (TimerStatus)) {\r
+ UnicodeToEfiKeyFlushState (TerminalDevice);\r
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Fetch one Unicode character from the Unicode FIFO\r
+ //\r
+ UnicodeFiFoRemoveOneKey (TerminalDevice,&UnicodeChar);\r
+\r
+ SetDefaultResetState = TRUE;\r
+\r
+ switch (TerminalDevice->InputState) {\r
+ case INPUT_STATE_DEFAULT:\r
+\r
+ break;\r
+\r
+ case INPUT_STATE_ESC:\r
+\r
+ if (UnicodeChar == LEFTOPENBRACKET) {\r
+ TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET;\r
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;\r
+ continue;\r
+ }\r
+\r
+ if (UnicodeChar == 'O' && TerminalDevice->TerminalType == VT100Type) {\r
+ TerminalDevice->InputState |= INPUT_STATE_O;\r
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;\r
+ continue;\r
+ }\r
+\r
+ Key.ScanCode = SCAN_NULL;\r
+ \r
+ if (TerminalDevice->TerminalType == VT100PlusType || \r
+ TerminalDevice->TerminalType == VTUTF8Type) {\r
+ switch (UnicodeChar) {\r
+ case '1': \r
+ Key.ScanCode = SCAN_F1; \r
+ break;\r
+ case '2': \r
+ Key.ScanCode = SCAN_F2; \r
+ break;\r
+ case '3': \r
+ Key.ScanCode = SCAN_F3; \r
+ break;\r
+ case '4': \r
+ Key.ScanCode = SCAN_F4; \r
+ break;\r
+ case '5': \r
+ Key.ScanCode = SCAN_F5; \r
+ break;\r
+ case '6': \r
+ Key.ScanCode = SCAN_F6; \r
+ break;\r
+ case '7': \r
+ Key.ScanCode = SCAN_F7; \r
+ break;\r
+ case '8': \r
+ Key.ScanCode = SCAN_F8; \r
+ break;\r
+ case '9': \r
+ Key.ScanCode = SCAN_F9; \r
+ break;\r
+ case '0': \r
+ Key.ScanCode = SCAN_F10; \r
+ break;\r
+ case 'h': \r
+ Key.ScanCode = SCAN_HOME; \r
+ break;\r
+ case 'k': \r
+ Key.ScanCode = SCAN_END; \r
+ break;\r
+ case '+': \r
+ Key.ScanCode = SCAN_INSERT; \r
+ break;\r
+ case '-': \r
+ Key.ScanCode = SCAN_DELETE; \r
+ break;\r
+ case '/': \r
+ Key.ScanCode = SCAN_PAGE_DOWN; \r
+ break;\r
+ case '?': \r
+ Key.ScanCode = SCAN_PAGE_UP; \r
+ break; \r
+ default : \r
+ break;\r
+ }\r
+ }\r
+ \r
+ switch (UnicodeChar) {\r
+ case 'R': \r
+ if (TerminalDevice->ResetState == RESET_STATE_DEFAULT) {\r
+ TerminalDevice->ResetState = RESET_STATE_ESC_R;\r
+ SetDefaultResetState = FALSE;\r
+ } else if (TerminalDevice->ResetState == RESET_STATE_ESC_R_ESC_r) {\r
+ gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
+ }\r
+ Key.ScanCode = SCAN_NULL;\r
+ break;\r
+ case 'r': \r
+ if (TerminalDevice->ResetState == RESET_STATE_ESC_R) {\r
+ TerminalDevice->ResetState = RESET_STATE_ESC_R_ESC_r;\r
+ SetDefaultResetState = FALSE;\r
+ }\r
+ Key.ScanCode = SCAN_NULL;\r
+ break;\r
+ default : \r
+ break;\r
+ }\r
+\r
+ if (SetDefaultResetState) {\r
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;\r
+ }\r
+\r
+ if (Key.ScanCode != SCAN_NULL) {\r
+ Key.UnicodeChar = 0;\r
+ EfiKeyFiFoInsertOneKey (TerminalDevice,Key);\r
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;\r
+ UnicodeToEfiKeyFlushState (TerminalDevice);\r
+ continue;\r
+ }\r
+\r
+ UnicodeToEfiKeyFlushState (TerminalDevice);\r
+\r
+ break;\r
+\r
+ case INPUT_STATE_ESC | INPUT_STATE_O:\r
+\r
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;\r
+\r
+ Key.ScanCode = SCAN_NULL;\r
+ \r
+ if (TerminalDevice->TerminalType == VT100Type) {\r
+ switch (UnicodeChar) {\r
+ case 'P': \r
+ Key.ScanCode = SCAN_F1; \r
+ break;\r
+ case 'Q': \r
+ Key.ScanCode = SCAN_F2; \r
+ break;\r
+ case 'w': \r
+ Key.ScanCode = SCAN_F3; \r
+ break;\r
+ case 'x': \r
+ Key.ScanCode = SCAN_F4; \r
+ break;\r
+ case 't': \r
+ Key.ScanCode = SCAN_F5; \r
+ break;\r
+ case 'u': \r
+ Key.ScanCode = SCAN_F6; \r
+ break;\r
+ case 'q': \r
+ Key.ScanCode = SCAN_F7; \r
+ break;\r
+ case 'r': \r
+ Key.ScanCode = SCAN_F8; \r
+ break;\r
+ case 'p': \r
+ Key.ScanCode = SCAN_F9; \r
+ break;\r
+ case 'M': \r
+ Key.ScanCode = SCAN_F10; \r
+ break;\r
+ default : \r
+ break;\r
+ }\r
+ }\r
+\r
+ if (Key.ScanCode != SCAN_NULL) {\r
+ Key.UnicodeChar = 0;\r
+ EfiKeyFiFoInsertOneKey (TerminalDevice,Key);\r
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;\r
+ UnicodeToEfiKeyFlushState (TerminalDevice);\r
+ continue;\r
+ }\r
+\r
+ UnicodeToEfiKeyFlushState (TerminalDevice);\r
+\r
+ break;\r
+\r
+ case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET:\r
+ \r
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;\r
+ \r
+ Key.ScanCode = SCAN_NULL;\r
+ \r
+ if (TerminalDevice->TerminalType == PcAnsiType ||\r
+ TerminalDevice->TerminalType == VT100Type ||\r
+ TerminalDevice->TerminalType == VT100PlusType || \r
+ TerminalDevice->TerminalType == VTUTF8Type) {\r
+ switch (UnicodeChar) {\r
+ case 'A': \r
+ Key.ScanCode = SCAN_UP; \r
+ break;\r
+ case 'B': \r
+ Key.ScanCode = SCAN_DOWN; \r
+ break;\r
+ case 'C': \r
+ Key.ScanCode = SCAN_RIGHT; \r
+ break;\r
+ case 'D': \r
+ Key.ScanCode = SCAN_LEFT; \r
+ break;\r
+ case 'H': \r
+ if (TerminalDevice->TerminalType == PcAnsiType ||\r
+ TerminalDevice->TerminalType == VT100Type) {\r
+ Key.ScanCode = SCAN_HOME; \r
+ }\r
+ break;\r
+ case 'F': \r
+ if (TerminalDevice->TerminalType == PcAnsiType) {\r
+ Key.ScanCode = SCAN_END;\r
+ }\r
+ break;\r
+ case 'K': \r
+ if (TerminalDevice->TerminalType == VT100Type) {\r
+ Key.ScanCode = SCAN_END; \r
+ }\r
+ break;\r
+ case 'L': \r
+ case '@': \r
+ if (TerminalDevice->TerminalType == PcAnsiType ||\r
+ TerminalDevice->TerminalType == VT100Type) {\r
+ Key.ScanCode = SCAN_INSERT; \r
+ }\r
+ break;\r
+ case 'X': \r
+ if (TerminalDevice->TerminalType == PcAnsiType) {\r
+ Key.ScanCode = SCAN_DELETE;\r
+ }\r
+ break;\r
+ case 'P': \r
+ if (TerminalDevice->TerminalType == VT100Type) {\r
+ Key.ScanCode = SCAN_DELETE; \r
+ } else if (TerminalDevice->TerminalType == PcAnsiType) {\r
+ Key.ScanCode = SCAN_F4;\r
+ }\r
+ break;\r
+ case 'I': \r
+ if (TerminalDevice->TerminalType == PcAnsiType) {\r
+ Key.ScanCode = SCAN_PAGE_UP;\r
+ }\r
+ break; \r
+ case 'V': \r
+ if (TerminalDevice->TerminalType == PcAnsiType) {\r
+ Key.ScanCode = SCAN_F10;\r
+ } \r
+ case '?': \r
+ if (TerminalDevice->TerminalType == VT100Type) {\r
+ Key.ScanCode = SCAN_PAGE_UP; \r
+ }\r
+ break;\r
+ case 'G': \r
+ if (TerminalDevice->TerminalType == PcAnsiType) {\r
+ Key.ScanCode = SCAN_PAGE_DOWN;\r
+ }\r
+ break; \r
+ case 'U': \r
+ if (TerminalDevice->TerminalType == PcAnsiType) {\r
+ Key.ScanCode = SCAN_F9;\r
+ }\r
+ case '/': \r
+ if (TerminalDevice->TerminalType == VT100Type) {\r
+ Key.ScanCode = SCAN_PAGE_DOWN; \r
+ }\r
+ break;\r
+ case 'M': \r
+ if (TerminalDevice->TerminalType == PcAnsiType) {\r
+ Key.ScanCode = SCAN_F1;\r
+ }\r
+ break; \r
+ case 'N': \r
+ if (TerminalDevice->TerminalType == PcAnsiType) {\r
+ Key.ScanCode = SCAN_F2;\r
+ }\r
+ break; \r
+ case 'O': \r
+ if (TerminalDevice->TerminalType == PcAnsiType) {\r
+ Key.ScanCode = SCAN_F3;\r
+ }\r
+ break; \r
+ case 'Q': \r
+ if (TerminalDevice->TerminalType == PcAnsiType) {\r
+ Key.ScanCode = SCAN_F5;\r
+ }\r
+ break; \r
+ case 'R': \r
+ if (TerminalDevice->TerminalType == PcAnsiType) {\r
+ Key.ScanCode = SCAN_F6;\r
+ }\r
+ break; \r
+ case 'S': \r
+ if (TerminalDevice->TerminalType == PcAnsiType) {\r
+ Key.ScanCode = SCAN_F7;\r
+ }\r
+ break; \r
+ case 'T': \r
+ if (TerminalDevice->TerminalType == PcAnsiType) {\r
+ Key.ScanCode = SCAN_F8;\r
+ }\r
+ break; \r
+ default : \r
+ break;\r
+ }\r
+ }\r
+\r
+ if (Key.ScanCode != SCAN_NULL) {\r
+ Key.UnicodeChar = 0;\r
+ EfiKeyFiFoInsertOneKey (TerminalDevice,Key);\r
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;\r
+ UnicodeToEfiKeyFlushState (TerminalDevice);\r
+ continue;\r
+ }\r
+\r
+ UnicodeToEfiKeyFlushState (TerminalDevice);\r
+\r
+ break;\r
+\r
+ \r
+ default:\r
+ //\r
+ // Invalid state. This should never happen.\r
+ //\r
+ ASSERT (FALSE);\r
+\r
+ UnicodeToEfiKeyFlushState (TerminalDevice);\r
+\r
+ break;\r
+ }\r
+\r
+ if (UnicodeChar == ESC) {\r
+ TerminalDevice->InputState = INPUT_STATE_ESC;\r
+ }\r
+ \r
+ if (TerminalDevice->InputState != INPUT_STATE_DEFAULT) {\r
+ Status = gBS->SetTimer(\r
+ TerminalDevice->TwoSecondTimeOut,\r
+ TimerRelative,\r
+ (UINT64)20000000\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ continue;\r
+ }\r
+\r
+ if (SetDefaultResetState) {\r
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;\r
+ }\r
+\r
+ if (UnicodeChar == DEL) {\r
+ Key.ScanCode = SCAN_DELETE;\r
+ Key.UnicodeChar = 0;\r
+ } else {\r
+ Key.ScanCode = SCAN_NULL;\r
+ Key.UnicodeChar = UnicodeChar;\r
+ }\r
+\r
+ EfiKeyFiFoInsertOneKey (TerminalDevice,Key);\r
+ }\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ TerminalConOut.c\r
+ \r
+Abstract: \r
+ \r
+\r
+Revision History\r
+--*/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "Terminal.h"\r
+\r
+#include "FrameworkDxe.h"\r
+\r
+//\r
+// This list is used to define the valid extend chars.\r
+// It also provides a mapping from Unicode to PCANSI or\r
+// ASCII. The ASCII mapping we just made up.\r
+//\r
+//\r
+STATIC UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] = {\r
+ { BOXDRAW_HORIZONTAL, 0xc4, L'-' }, \r
+ { BOXDRAW_VERTICAL, 0xb3, L'|' },\r
+ { BOXDRAW_DOWN_RIGHT, 0xda, L'/' },\r
+ { BOXDRAW_DOWN_LEFT, 0xbf, L'\\' },\r
+ { BOXDRAW_UP_RIGHT, 0xc0, L'\\' },\r
+ { BOXDRAW_UP_LEFT, 0xd9, L'/' },\r
+ { BOXDRAW_VERTICAL_RIGHT, 0xc3, L'|' },\r
+ { BOXDRAW_VERTICAL_LEFT, 0xb4, L'|' },\r
+ { BOXDRAW_DOWN_HORIZONTAL, 0xc2, L'+' },\r
+ { BOXDRAW_UP_HORIZONTAL, 0xc1, L'+' },\r
+ { BOXDRAW_VERTICAL_HORIZONTAL, 0xc5, L'+' },\r
+ { BOXDRAW_DOUBLE_HORIZONTAL, 0xcd, L'-' },\r
+ { BOXDRAW_DOUBLE_VERTICAL, 0xba, L'|' },\r
+ { BOXDRAW_DOWN_RIGHT_DOUBLE, 0xd5, L'/' },\r
+ { BOXDRAW_DOWN_DOUBLE_RIGHT, 0xd6, L'/' },\r
+ { BOXDRAW_DOUBLE_DOWN_RIGHT, 0xc9, L'/' },\r
+ { BOXDRAW_DOWN_LEFT_DOUBLE, 0xb8, L'\\' },\r
+ { BOXDRAW_DOWN_DOUBLE_LEFT, 0xb7, L'\\' },\r
+ { BOXDRAW_DOUBLE_DOWN_LEFT, 0xbb, L'\\' },\r
+ { BOXDRAW_UP_RIGHT_DOUBLE, 0xd4, L'\\' },\r
+ { BOXDRAW_UP_DOUBLE_RIGHT, 0xd3, L'\\' },\r
+ { BOXDRAW_DOUBLE_UP_RIGHT, 0xc8, L'\\' },\r
+ { BOXDRAW_UP_LEFT_DOUBLE, 0xbe, L'/' },\r
+ { BOXDRAW_UP_DOUBLE_LEFT, 0xbd, L'/' },\r
+ { BOXDRAW_DOUBLE_UP_LEFT, 0xbc, L'/' },\r
+ { BOXDRAW_VERTICAL_RIGHT_DOUBLE, 0xc6, L'|' },\r
+ { BOXDRAW_VERTICAL_DOUBLE_RIGHT, 0xc7, L'|' },\r
+ { BOXDRAW_DOUBLE_VERTICAL_RIGHT, 0xcc, L'|' },\r
+ { BOXDRAW_VERTICAL_LEFT_DOUBLE, 0xb5, L'|' },\r
+ { BOXDRAW_VERTICAL_DOUBLE_LEFT, 0xb6, L'|' },\r
+ { BOXDRAW_DOUBLE_VERTICAL_LEFT, 0xb9, L'|' },\r
+ { BOXDRAW_DOWN_HORIZONTAL_DOUBLE, 0xd1, L'+' },\r
+ { BOXDRAW_DOWN_DOUBLE_HORIZONTAL, 0xd2, L'+' },\r
+ { BOXDRAW_DOUBLE_DOWN_HORIZONTAL, 0xcb, L'+' },\r
+ { BOXDRAW_UP_HORIZONTAL_DOUBLE, 0xcf, L'+' },\r
+ { BOXDRAW_UP_DOUBLE_HORIZONTAL, 0xd0, L'+' },\r
+ { BOXDRAW_DOUBLE_UP_HORIZONTAL, 0xca, L'+' },\r
+ { BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+' },\r
+ { BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+' },\r
+ { BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+' },\r
+\r
+ { BLOCKELEMENT_FULL_BLOCK, 0xdb, L'*' },\r
+ { BLOCKELEMENT_LIGHT_SHADE, 0xb0, L'+' },\r
+\r
+ { GEOMETRICSHAPE_UP_TRIANGLE, 0x1e, L'^' },\r
+ { GEOMETRICSHAPE_RIGHT_TRIANGLE, 0x10, L'>' },\r
+ { GEOMETRICSHAPE_DOWN_TRIANGLE, 0x1f, L'v' },\r
+ { GEOMETRICSHAPE_LEFT_TRIANGLE, 0x11, L'<' },\r
+\r
+ { ARROW_LEFT, 0x3c, L'<' },\r
+ { ARROW_UP, 0x18, L'^' },\r
+ { ARROW_RIGHT, 0x3e, L'>' },\r
+ { ARROW_DOWN, 0x19, L'v' },\r
+\r
+ { 0x0000, 0x00, L'\0' }\r
+};\r
+\r
+CHAR16 mSetModeString[] = { ESC, '[', '=', '3', 'h', 0 };\r
+CHAR16 mSetAttributeString[] = { ESC, '[', '0', 'm', ESC, '[', '4', '0', 'm', ESC, '[', '4', '0', 'm', 0 };\r
+CHAR16 mClearScreenString[] = { ESC, '[', '2', 'J', 0 };\r
+CHAR16 mSetCursorPositionString[] = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0 };\r
+\r
+//\r
+// Body of the ConOut functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutReset (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN BOOLEAN ExtendedVerification\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().\r
+ If ExtendeVerification is TRUE, then perform dependent serial device reset,\r
+ and set display mode to mode 0.\r
+ If ExtendedVerification is FALSE, only set display mode to mode 0.\r
+ \r
+ Arguments:\r
+ \r
+ This - Indicates the calling context.\r
+ \r
+ ExtendedVerification - Indicates that the driver may perform a more exhaustive\r
+ verification operation of the device during reset.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The reset operation succeeds. \r
+ \r
+ EFI_DEVICE_ERROR\r
+ The terminal is not functioning correctly or the serial port reset fails.\r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ TERMINAL_DEV *TerminalDevice;\r
+\r
+ TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);\r
+\r
+ //\r
+ // Perform a more exhaustive reset by resetting the serial port.\r
+ //\r
+ if (ExtendedVerification) {\r
+ //\r
+ // Report progress code here\r
+ //\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_PROGRESS_CODE,\r
+ EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_PC_RESET,\r
+ TerminalDevice->DevicePath\r
+ );\r
+\r
+ Status = TerminalDevice->SerialIo->Reset (TerminalDevice->SerialIo);\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // Report error code here\r
+ //\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+ EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_EC_CONTROLLER_ERROR,\r
+ TerminalDevice->DevicePath\r
+ );\r
+\r
+ return Status;\r
+ }\r
+ }\r
+\r
+ This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK));\r
+\r
+ Status = This->SetMode (This, 0);\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutOutputString (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN CHAR16 *WString\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().\r
+ The Unicode string will be converted to terminal expressible data stream\r
+ and send to terminal via serial port.\r
+ \r
+ \r
+ Arguments:\r
+ \r
+ This - Indicates the calling context.\r
+ \r
+ WString - The Null-terminated Unicode string to be displayed on \r
+ the terminal screen.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The string is output successfully. \r
+ \r
+ EFI_DEVICE_ERROR\r
+ The serial port fails to send the string out.\r
+ \r
+ EFI_WARN_UNKNOWN_GLYPH\r
+ Indicates that some of the characters in the Unicode string could not \r
+ be rendered and are skipped. \r
+ \r
+ EFI_UNSUPPORTED\r
+ \r
+--*/\r
+{\r
+ TERMINAL_DEV *TerminalDevice;\r
+ EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;\r
+ UINTN MaxColumn;\r
+ UINTN MaxRow;\r
+ UINTN Length;\r
+ UTF8_CHAR Utf8Char;\r
+ CHAR8 GraphicChar;\r
+ CHAR8 AsciiChar;\r
+ EFI_STATUS Status;\r
+ UINT8 ValidBytes;\r
+ //\r
+ // flag used to indicate whether condition happens which will cause\r
+ // return EFI_WARN_UNKNOWN_GLYPH\r
+ //\r
+ BOOLEAN Warning;\r
+\r
+ ValidBytes = 0;\r
+ Warning = FALSE;\r
+\r
+ //\r
+ // get Terminal device data structure pointer.\r
+ //\r
+ TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);\r
+\r
+ //\r
+ // get current display mode\r
+ // Terminal driver only support mode 0\r
+ //\r
+ Mode = This->Mode;\r
+ if (Mode->Mode != 0) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ This->QueryMode (\r
+ This,\r
+ Mode->Mode,\r
+ &MaxColumn,\r
+ &MaxRow\r
+ );\r
+\r
+ for (; *WString != CHAR_NULL; WString++) {\r
+\r
+ switch (TerminalDevice->TerminalType) {\r
+\r
+ case PcAnsiType:\r
+ case VT100Type:\r
+ case VT100PlusType:\r
+\r
+ if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar)) {\r
+ //\r
+ // If it's not a graphic character convert Unicode to ASCII.\r
+ //\r
+ GraphicChar = (CHAR8) *WString;\r
+\r
+ if (!(TerminalIsValidAscii (GraphicChar) || TerminalIsValidEfiCntlChar (GraphicChar))) {\r
+ //\r
+ // when this driver use the OutputString to output control string,\r
+ // TerminalDevice->OutputEscChar is set to let the Esc char\r
+ // to be output to the terminal emulation software.\r
+ //\r
+ if ((GraphicChar == 27) && TerminalDevice->OutputEscChar) {\r
+ GraphicChar = 27;\r
+ } else {\r
+ GraphicChar = '?';\r
+ Warning = TRUE;\r
+ }\r
+ }\r
+\r
+ AsciiChar = GraphicChar;\r
+\r
+ }\r
+\r
+ if (TerminalDevice->TerminalType != PcAnsiType) {\r
+ GraphicChar = AsciiChar;\r
+ }\r
+\r
+ Length = 1;\r
+\r
+ Status = TerminalDevice->SerialIo->Write (\r
+ TerminalDevice->SerialIo,\r
+ &Length,\r
+ &GraphicChar\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ goto OutputError;\r
+ }\r
+\r
+ break;\r
+\r
+ case VTUTF8Type:\r
+ UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes);\r
+ Length = ValidBytes;\r
+ Status = TerminalDevice->SerialIo->Write (\r
+ TerminalDevice->SerialIo,\r
+ &Length,\r
+ (UINT8 *) &Utf8Char\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto OutputError;\r
+ }\r
+ break;\r
+ }\r
+ //\r
+ // Update cursor position.\r
+ //\r
+ switch (*WString) {\r
+\r
+ case CHAR_BACKSPACE:\r
+ if (Mode->CursorColumn > 0) {\r
+ Mode->CursorColumn--;\r
+ }\r
+ break;\r
+\r
+ case CHAR_LINEFEED:\r
+ if (Mode->CursorRow < (INT32) (MaxRow - 1)) {\r
+ Mode->CursorRow++;\r
+ }\r
+ break;\r
+\r
+ case CHAR_CARRIAGE_RETURN:\r
+ Mode->CursorColumn = 0;\r
+ break;\r
+\r
+ default:\r
+ if (Mode->CursorColumn < (INT32) (MaxColumn - 1)) {\r
+\r
+ Mode->CursorColumn++;\r
+\r
+ } else {\r
+\r
+ Mode->CursorColumn = 0;\r
+ if (Mode->CursorRow < (INT32) (MaxRow - 1)) {\r
+ Mode->CursorRow++;\r
+ }\r
+\r
+ }\r
+ break;\r
+\r
+ };\r
+\r
+ }\r
+\r
+ if (Warning) {\r
+ return EFI_WARN_UNKNOWN_GLYPH;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+\r
+OutputError:\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+ EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_EC_OUTPUT_ERROR,\r
+ TerminalDevice->DevicePath\r
+ );\r
+\r
+ return EFI_DEVICE_ERROR;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutTestString (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN CHAR16 *WString\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().\r
+ If one of the characters in the *Wstring is\r
+ neither valid Unicode drawing characters,\r
+ not ASCII code, then this function will return\r
+ EFI_UNSUPPORTED.\r
+ \r
+ \r
+ Arguments:\r
+ \r
+ This - Indicates the calling context.\r
+ \r
+ WString - The Null-terminated Unicode string to be tested.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The terminal is capable of rendering the output string. \r
+ \r
+ EFI_UNSUPPORTED\r
+ Some of the characters in the Unicode string cannot be rendered. \r
+ \r
+--*/\r
+{\r
+ TERMINAL_DEV *TerminalDevice;\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // get Terminal device data structure pointer.\r
+ //\r
+ TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);\r
+\r
+ switch (TerminalDevice->TerminalType) {\r
+\r
+ case PcAnsiType:\r
+ case VT100Type:\r
+ case VT100PlusType:\r
+ Status = AnsiTestString (TerminalDevice, WString);\r
+ break;\r
+\r
+ case VTUTF8Type:\r
+ Status = VTUTF8TestString (TerminalDevice, WString);\r
+ break;\r
+\r
+ default:\r
+ Status = EFI_UNSUPPORTED;\r
+ break;\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutQueryMode (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN ModeNumber,\r
+ OUT UINTN *Columns,\r
+ OUT UINTN *Rows\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().\r
+ It returns information for an available text mode\r
+ that the terminal supports.\r
+ In this driver, we only support text mode 80x25, which is\r
+ defined as mode 0.\r
+ \r
+ \r
+ Arguments:\r
+ \r
+ *This\r
+ Indicates the calling context.\r
+ \r
+ ModeNumber\r
+ The mode number to return information on.\r
+ \r
+ Columns\r
+ The returned columns of the requested mode.\r
+ \r
+ Rows\r
+ The returned rows of the requested mode. \r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The requested mode information is returned. \r
+ \r
+ EFI_UNSUPPORTED\r
+ The mode number is not valid. \r
+ \r
+ EFI_DEVICE_ERROR\r
+ \r
+--*/\r
+{\r
+ if (This->Mode->MaxMode > 1) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ if (ModeNumber == 0) {\r
+\r
+ *Columns = MODE0_COLUMN_COUNT;\r
+ *Rows = MODE0_ROW_COUNT;\r
+\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutSetMode (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN ModeNumber\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements EFI_SIMPLE_TEXT_OUT.SetMode().\r
+ Set the terminal to a specified display mode.\r
+ In this driver, we only support mode 0. \r
+ \r
+ Arguments:\r
+ \r
+ This\r
+ Indicates the calling context.\r
+ \r
+ ModeNumber\r
+ The text mode to set.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The requested text mode is set.\r
+ \r
+ EFI_DEVICE_ERROR\r
+ The requested text mode cannot be set because of serial device error.\r
+ \r
+ EFI_UNSUPPORTED\r
+ The text mode number is not valid. \r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ TERMINAL_DEV *TerminalDevice;\r
+\r
+ //\r
+ // get Terminal device data structure pointer.\r
+ //\r
+ TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);\r
+\r
+ if (ModeNumber != 0) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ This->Mode->Mode = 0;\r
+\r
+ This->ClearScreen (This);\r
+\r
+ TerminalDevice->OutputEscChar = TRUE;\r
+ Status = This->OutputString (This, mSetModeString);\r
+ TerminalDevice->OutputEscChar = FALSE;\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ This->Mode->Mode = 0;\r
+\r
+ Status = This->ClearScreen (This);\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutSetAttribute (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN Attribute\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute(). \r
+ \r
+ Arguments:\r
+ \r
+ This\r
+ Indicates the calling context.\r
+ \r
+ Attribute\r
+ The attribute to set. Only bit0..6 are valid, all other bits\r
+ are undefined and must be zero.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The requested attribute is set. \r
+ \r
+ EFI_DEVICE_ERROR\r
+ The requested attribute cannot be set due to serial port error.\r
+ \r
+ EFI_UNSUPPORTED\r
+ The attribute requested is not defined by EFI spec. \r
+ \r
+--*/\r
+{\r
+ UINT8 ForegroundControl;\r
+ UINT8 BackgroundControl;\r
+ UINT8 BrightControl;\r
+ INT32 SavedColumn;\r
+ INT32 SavedRow;\r
+ EFI_STATUS Status;\r
+ TERMINAL_DEV *TerminalDevice;\r
+\r
+ SavedColumn = 0;\r
+ SavedRow = 0;\r
+\r
+ //\r
+ // get Terminal device data structure pointer.\r
+ //\r
+ TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);\r
+\r
+ //\r
+ // only the bit0..6 of the Attribute is valid\r
+ //\r
+ if ((Attribute | 0x7f) != 0x7f) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+ //\r
+ // convert Attribute value to terminal emulator\r
+ // understandable foreground color\r
+ //\r
+ switch (Attribute & 0x07) {\r
+\r
+ case EFI_BLACK:\r
+ ForegroundControl = 30;\r
+ break;\r
+\r
+ case EFI_BLUE:\r
+ ForegroundControl = 34;\r
+ break;\r
+\r
+ case EFI_GREEN:\r
+ ForegroundControl = 32;\r
+ break;\r
+\r
+ case EFI_CYAN:\r
+ ForegroundControl = 36;\r
+ break;\r
+\r
+ case EFI_RED:\r
+ ForegroundControl = 31;\r
+ break;\r
+\r
+ case EFI_MAGENTA:\r
+ ForegroundControl = 35;\r
+ break;\r
+\r
+ case EFI_BROWN:\r
+ ForegroundControl = 33;\r
+ break;\r
+\r
+ default:\r
+\r
+ case EFI_LIGHTGRAY:\r
+ ForegroundControl = 37;\r
+ break;\r
+\r
+ }\r
+ //\r
+ // bit4 of the Attribute indicates bright control\r
+ // of terminal emulator.\r
+ //\r
+ BrightControl = (UINT8) ((Attribute >> 3) & 1);\r
+\r
+ //\r
+ // convert Attribute value to terminal emulator\r
+ // understandable background color.\r
+ //\r
+ switch ((Attribute >> 4) & 0x07) {\r
+\r
+ case EFI_BLACK:\r
+ BackgroundControl = 40;\r
+ break;\r
+\r
+ case EFI_BLUE:\r
+ BackgroundControl = 44;\r
+ break;\r
+\r
+ case EFI_GREEN:\r
+ BackgroundControl = 42;\r
+ break;\r
+\r
+ case EFI_CYAN:\r
+ BackgroundControl = 46;\r
+ break;\r
+\r
+ case EFI_RED:\r
+ BackgroundControl = 41;\r
+ break;\r
+\r
+ case EFI_MAGENTA:\r
+ BackgroundControl = 45;\r
+ break;\r
+\r
+ case EFI_BROWN:\r
+ BackgroundControl = 43;\r
+ break;\r
+\r
+ default:\r
+\r
+ case EFI_LIGHTGRAY:\r
+ BackgroundControl = 47;\r
+ break;\r
+ }\r
+ //\r
+ // terminal emulator's control sequence to set attributes\r
+ //\r
+ mSetAttributeString[BRIGHT_CONTROL_OFFSET] = (CHAR16) ('0' + BrightControl);\r
+ mSetAttributeString[FOREGROUND_CONTROL_OFFSET + 0] = (CHAR16) ('0' + (ForegroundControl / 10));\r
+ mSetAttributeString[FOREGROUND_CONTROL_OFFSET + 1] = (CHAR16) ('0' + (ForegroundControl % 10));\r
+ mSetAttributeString[BACKGROUND_CONTROL_OFFSET + 0] = (CHAR16) ('0' + (BackgroundControl / 10));\r
+ mSetAttributeString[BACKGROUND_CONTROL_OFFSET + 1] = (CHAR16) ('0' + (BackgroundControl % 10));\r
+\r
+ //\r
+ // save current column and row\r
+ // for future scrolling back use.\r
+ //\r
+ SavedColumn = This->Mode->CursorColumn;\r
+ SavedRow = This->Mode->CursorRow;\r
+\r
+ TerminalDevice->OutputEscChar = TRUE;\r
+ Status = This->OutputString (This, mSetAttributeString);\r
+ TerminalDevice->OutputEscChar = FALSE;\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+ //\r
+ // scroll back to saved cursor position.\r
+ //\r
+ This->Mode->CursorColumn = SavedColumn;\r
+ This->Mode->CursorRow = SavedRow;\r
+\r
+ This->Mode->Attribute = (INT32) Attribute;\r
+\r
+ return EFI_SUCCESS;\r
+\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutClearScreen (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen().\r
+ It clears the ANSI terminal's display to the \r
+ currently selected background color.\r
+ \r
+ \r
+ Arguments:\r
+ \r
+ This\r
+ Indicates the calling context.\r
+\r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The operation completed successfully.\r
+ \r
+ EFI_DEVICE_ERROR\r
+ The terminal screen cannot be cleared due to serial port error. \r
+ \r
+ EFI_UNSUPPORTED\r
+ The terminal is not in a valid display mode. \r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ TERMINAL_DEV *TerminalDevice;\r
+\r
+ TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);\r
+\r
+ //\r
+ // control sequence for clear screen request\r
+ //\r
+ TerminalDevice->OutputEscChar = TRUE;\r
+ Status = This->OutputString (This, mClearScreenString);\r
+ TerminalDevice->OutputEscChar = FALSE;\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ Status = This->SetCursorPosition (This, 0, 0);\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutSetCursorPosition (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN UINTN Column,\r
+ IN UINTN Row\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition(). \r
+ \r
+ Arguments:\r
+ \r
+ This\r
+ Indicates the calling context.\r
+ \r
+ Column\r
+ The row to set cursor to.\r
+ \r
+ Row\r
+ The column to set cursor to. \r
+\r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The operation completed successfully.\r
+ \r
+ EFI_DEVICE_ERROR\r
+ The request fails due to serial port error. \r
+ \r
+ EFI_UNSUPPORTED\r
+ The terminal is not in a valid text mode, or the cursor position\r
+ is invalid for current mode. \r
+ \r
+--*/\r
+{\r
+ EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;\r
+ UINTN MaxColumn;\r
+ UINTN MaxRow;\r
+ EFI_STATUS Status;\r
+ TERMINAL_DEV *TerminalDevice;\r
+\r
+ TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);\r
+\r
+ //\r
+ // get current mode\r
+ //\r
+ Mode = This->Mode;\r
+\r
+ //\r
+ // get geometry of current mode\r
+ //\r
+ Status = This->QueryMode (\r
+ This,\r
+ Mode->Mode,\r
+ &MaxColumn,\r
+ &MaxRow\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ if (Column >= MaxColumn || Row >= MaxRow) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+ //\r
+ // control sequence to move the cursor\r
+ //\r
+ mSetCursorPositionString[ROW_OFFSET + 0] = (CHAR16) ('0' + ((Row + 1) / 10));\r
+ mSetCursorPositionString[ROW_OFFSET + 1] = (CHAR16) ('0' + ((Row + 1) % 10));\r
+ mSetCursorPositionString[COLUMN_OFFSET + 0] = (CHAR16) ('0' + ((Column + 1) / 10));\r
+ mSetCursorPositionString[COLUMN_OFFSET + 1] = (CHAR16) ('0' + ((Column + 1) % 10));\r
+\r
+ TerminalDevice->OutputEscChar = TRUE;\r
+ Status = This->OutputString (This, mSetCursorPositionString);\r
+ TerminalDevice->OutputEscChar = FALSE;\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+ //\r
+ // update current cursor position\r
+ // in the Mode data structure.\r
+ //\r
+ Mode->CursorColumn = (INT32) Column;\r
+ Mode->CursorRow = (INT32) Row;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TerminalConOutEnableCursor (\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
+ IN BOOLEAN Visible\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Implements SIMPLE_TEXT_OUTPUT.EnableCursor().\r
+ In this driver, the cursor cannot be hidden. \r
+ \r
+ Arguments:\r
+ \r
+ This\r
+ Indicates the calling context.\r
+ \r
+ Visible\r
+ If TRUE, the cursor is set to be visible,\r
+ If FALSE, the cursor is set to be invisible. \r
+\r
+ Returns:\r
+ \r
+ EFI_SUCCESS\r
+ The request is valid.\r
+ \r
+ EFI_UNSUPPORTED\r
+ The terminal does not support cursor hidden. \r
+ \r
+--*/\r
+{\r
+ if (!Visible) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+BOOLEAN\r
+TerminalIsValidTextGraphics (\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
+ Graphic - Unicode char to test.\r
+\r
+ PcAnsi - Optional pointer to return PCANSI equivalent of Graphic.\r
+\r
+ Ascii - Optional pointer to return ASCII equivalent of Graphic.\r
+\r
+Returns:\r
+\r
+ TRUE if Graphic is a supported Unicode Box Drawing character.\r
+\r
+--*/\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 != NULL) {\r
+ *PcAnsi = Table->PcAnsi;\r
+ }\r
+\r
+ if (Ascii != NULL) {\r
+ *Ascii = Table->Ascii;\r
+ }\r
+\r
+ return TRUE;\r
+ }\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+TerminalIsValidAscii (\r
+ IN CHAR16 Ascii\r
+ )\r
+{\r
+ //\r
+ // valid ascii code lies in the extent of 0x20 ~ 0x7f\r
+ //\r
+ if ((Ascii >= 0x20) && (Ascii <= 0x7f)) {\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+TerminalIsValidEfiCntlChar (\r
+ IN CHAR16 CharC\r
+ )\r
+{\r
+ //\r
+ // only support four control characters.\r
+ //\r
+ if (CharC == CHAR_NULL ||\r
+ CharC == CHAR_BACKSPACE ||\r
+ CharC == CHAR_LINEFEED ||\r
+ CharC == CHAR_CARRIAGE_RETURN ||\r
+ CharC == CHAR_TAB\r
+ ) {\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ ansi.c\r
+ \r
+Abstract: \r
+ \r
+\r
+Revision History\r
+--*/\r
+\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "Terminal.h"\r
+\r
+VOID\r
+AnsiRawDataToUnicode (\r
+ IN TERMINAL_DEV *TerminalDevice\r
+ )\r
+{\r
+ UINT8 RawData;\r
+\r
+ //\r
+ // pop the raw data out from the raw fifo,\r
+ // and translate it into unicode, then push\r
+ // the unicode into unicode fifo, until the raw fifo is empty.\r
+ //\r
+ while (!IsRawFiFoEmpty (TerminalDevice)) {\r
+\r
+ RawFiFoRemoveOneKey (TerminalDevice, &RawData);\r
+\r
+ UnicodeFiFoInsertOneKey (TerminalDevice, (UINT16) RawData);\r
+ }\r
+}\r
+\r
+EFI_STATUS\r
+AnsiTestString (\r
+ IN TERMINAL_DEV *TerminalDevice,\r
+ IN CHAR16 *WString\r
+ )\r
+{\r
+ CHAR8 GraphicChar;\r
+\r
+ //\r
+ // support three kind of character:\r
+ // valid ascii, valid efi control char, valid text graphics.\r
+ //\r
+ for (; *WString != CHAR_NULL; WString++) {\r
+\r
+ if ( !(TerminalIsValidAscii (*WString) || \r
+ TerminalIsValidEfiCntlChar (*WString) ||\r
+ TerminalIsValidTextGraphics (*WString, &GraphicChar, NULL) )) {\r
+\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ vtutf8.c\r
+ \r
+Abstract: \r
+ \r
+\r
+Revision History\r
+--*/\r
+\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "Terminal.h"\r
+\r
+VOID\r
+VTUTF8RawDataToUnicode (\r
+ IN TERMINAL_DEV *TerminalDevice\r
+ )\r
+{\r
+ UTF8_CHAR Utf8Char;\r
+ UINT8 ValidBytes;\r
+ UINT16 UnicodeChar;\r
+\r
+ ValidBytes = 0;\r
+ //\r
+ // pop the raw data out from the raw fifo,\r
+ // and translate it into unicode, then push\r
+ // the unicode into unicode fifo, until the raw fifo is empty.\r
+ //\r
+ while (!IsRawFiFoEmpty (TerminalDevice)) {\r
+\r
+ GetOneValidUtf8Char (TerminalDevice, &Utf8Char, &ValidBytes);\r
+\r
+ if (ValidBytes < 1 || ValidBytes > 3) {\r
+ continue;\r
+ }\r
+\r
+ Utf8ToUnicode (Utf8Char, ValidBytes, (CHAR16 *) &UnicodeChar);\r
+\r
+ UnicodeFiFoInsertOneKey (TerminalDevice, UnicodeChar);\r
+ }\r
+}\r
+\r
+VOID\r
+GetOneValidUtf8Char (\r
+ IN TERMINAL_DEV *Utf8Device,\r
+ OUT UTF8_CHAR *Utf8Char,\r
+ OUT UINT8 *ValidBytes\r
+ )\r
+{\r
+ UINT8 Temp;\r
+ UINT8 Index;\r
+ BOOLEAN FetchFlag;\r
+\r
+ Temp = 0;\r
+ Index = 0;\r
+ FetchFlag = TRUE;\r
+\r
+ //\r
+ // if no valid Utf8 char is found in the RawFiFo,\r
+ // then *ValidBytes will be zero.\r
+ //\r
+ *ValidBytes = 0;\r
+\r
+ while (!IsRawFiFoEmpty (Utf8Device)) {\r
+\r
+ RawFiFoRemoveOneKey (Utf8Device, &Temp);\r
+\r
+ switch (*ValidBytes) {\r
+\r
+ case 0:\r
+ if ((Temp & 0x80) == 0) {\r
+ //\r
+ // one-byte utf8 char\r
+ //\r
+ *ValidBytes = 1;\r
+\r
+ Utf8Char->Utf8_1 = Temp;\r
+\r
+ FetchFlag = FALSE;\r
+\r
+ } else if ((Temp & 0xe0) == 0xc0) {\r
+ //\r
+ // two-byte utf8 char\r
+ //\r
+ *ValidBytes = 2;\r
+\r
+ Utf8Char->Utf8_2[1] = Temp;\r
+\r
+ } else if ((Temp & 0xf0) == 0xe0) {\r
+ //\r
+ // three-byte utf8 char\r
+ //\r
+ *ValidBytes = 3;\r
+\r
+ Utf8Char->Utf8_3[2] = Temp;\r
+\r
+ Index++;\r
+\r
+ } else {\r
+ //\r
+ // reset *ValidBytes to zero, let valid utf8 char search restart\r
+ //\r
+ *ValidBytes = 0;\r
+ }\r
+\r
+ break;\r
+\r
+ case 2:\r
+ if ((Temp & 0xc0) == 0x80) {\r
+\r
+ Utf8Char->Utf8_2[0] = Temp;\r
+\r
+ FetchFlag = FALSE;\r
+\r
+ } else {\r
+\r
+ *ValidBytes = 0;\r
+ }\r
+ break;\r
+\r
+ case 3:\r
+ if ((Temp & 0xc0) == 0x80) {\r
+\r
+ Utf8Char->Utf8_3[2 - Index] = Temp;\r
+ Index++;\r
+ if (Index == 3) {\r
+ FetchFlag = FALSE;\r
+ }\r
+ } else {\r
+\r
+ *ValidBytes = 0;\r
+ Index = 0;\r
+ }\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ if (!FetchFlag) {\r
+ break;\r
+ }\r
+ }\r
+\r
+ return ;\r
+}\r
+\r
+VOID\r
+Utf8ToUnicode (\r
+ IN UTF8_CHAR Utf8Char,\r
+ IN UINT8 ValidBytes,\r
+ OUT CHAR16 *UnicodeChar\r
+ )\r
+{\r
+ UINT8 UnicodeByte0;\r
+ UINT8 UnicodeByte1;\r
+ UINT8 Byte0;\r
+ UINT8 Byte1;\r
+ UINT8 Byte2;\r
+\r
+ *UnicodeChar = 0;\r
+\r
+ //\r
+ // translate utf8 code to unicode, in terminal standard,\r
+ // up to 3 bytes utf8 code is supported.\r
+ //\r
+ switch (ValidBytes) {\r
+ case 1:\r
+ //\r
+ // one-byte utf8 code\r
+ //\r
+ *UnicodeChar = (UINT16) Utf8Char.Utf8_1;\r
+ break;\r
+\r
+ case 2:\r
+ //\r
+ // two-byte utf8 code\r
+ //\r
+ Byte0 = Utf8Char.Utf8_2[0];\r
+ Byte1 = Utf8Char.Utf8_2[1];\r
+\r
+ UnicodeByte0 = (UINT8) ((Byte1 << 6) | (Byte0 & 0x3f));\r
+ UnicodeByte1 = (UINT8) ((Byte1 >> 2) & 0x07);\r
+ *UnicodeChar = (UINT16) (UnicodeByte0 | (UnicodeByte1 << 8));\r
+ break;\r
+\r
+ case 3:\r
+ //\r
+ // three-byte utf8 code\r
+ //\r
+ Byte0 = Utf8Char.Utf8_3[0];\r
+ Byte1 = Utf8Char.Utf8_3[1];\r
+ Byte2 = Utf8Char.Utf8_3[2];\r
+\r
+ UnicodeByte0 = (UINT8) ((Byte1 << 6) | (Byte0 & 0x3f));\r
+ UnicodeByte1 = (UINT8) ((Byte2 << 4) | ((Byte1 >> 2) & 0x0f));\r
+ *UnicodeChar = (UINT16) (UnicodeByte0 | (UnicodeByte1 << 8));\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return ;\r
+}\r
+\r
+VOID\r
+UnicodeToUtf8 (\r
+ IN CHAR16 Unicode,\r
+ OUT UTF8_CHAR *Utf8Char,\r
+ OUT UINT8 *ValidBytes\r
+ )\r
+{\r
+ UINT8 UnicodeByte0;\r
+ UINT8 UnicodeByte1;\r
+ //\r
+ // translate unicode to utf8 code\r
+ //\r
+ UnicodeByte0 = (UINT8) Unicode;\r
+ UnicodeByte1 = (UINT8) (Unicode >> 8);\r
+\r
+ if (Unicode < 0x0080) {\r
+\r
+ Utf8Char->Utf8_1 = (UINT8) (UnicodeByte0 & 0x7f);\r
+ *ValidBytes = 1;\r
+\r
+ } else if (Unicode < 0x0800) {\r
+ //\r
+ // byte sequence: high -> low\r
+ // Utf8_2[0], Utf8_2[1]\r
+ //\r
+ Utf8Char->Utf8_2[1] = (UINT8) ((UnicodeByte0 & 0x3f) + 0x80);\r
+ Utf8Char->Utf8_2[0] = (UINT8) ((((UnicodeByte1 << 2) + (UnicodeByte0 >> 6)) & 0x1f) + 0xc0);\r
+\r
+ *ValidBytes = 2;\r
+\r
+ } else {\r
+ //\r
+ // byte sequence: high -> low\r
+ // Utf8_3[0], Utf8_3[1], Utf8_3[2]\r
+ //\r
+ Utf8Char->Utf8_3[2] = (UINT8) ((UnicodeByte0 & 0x3f) + 0x80);\r
+ Utf8Char->Utf8_3[1] = (UINT8) ((((UnicodeByte1 << 2) + (UnicodeByte0 >> 6)) & 0x3f) + 0x80);\r
+ Utf8Char->Utf8_3[0] = (UINT8) (((UnicodeByte1 >> 4) & 0x0f) + 0xe0);\r
+\r
+ *ValidBytes = 3;\r
+ }\r
+}\r
+\r
+EFI_STATUS\r
+VTUTF8TestString (\r
+ IN TERMINAL_DEV *TerminalDevice,\r
+ IN CHAR16 *WString\r
+ )\r
+{\r
+ //\r
+ // to utf8, all kind of characters are supported.\r
+ //\r
+ return EFI_SUCCESS;\r
+}\r
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2006 - 2007, Intel Corporation\r
+ All rights reserved. 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
+ 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
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/DevicePathUtilities.h>\r
+#include <Protocol/DebugPort.h>\r
+#include <Protocol/DevicePathToText.h>\r
+#include <Protocol/DevicePathFromText.h>\r
+#include <Guid/PcAnsi.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+#endif\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ DevicePathDriver.c\r
+\r
+Abstract:\r
+\r
+ Device Path Driver to produce DevPathUtilities Protocol, DevPathFromText Protocol\r
+ and DevPathToText Protocol.\r
+\r
+--*/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "DevicePath.h"\r
+\r
+EFI_HANDLE mDevicePathHandle = NULL;\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DEVICE_PATH_UTILITIES_PROTOCOL mDevicePathUtilities = {\r
+ GetDevicePathSizeProtocolInterface,\r
+ DuplicateDevicePathProtocolInterface,\r
+ AppendDevicePathProtocolInterface,\r
+ AppendDeviceNodeProtocolInterface,\r
+ AppendDevicePathInstanceProtocolInterface,\r
+ GetNextDevicePathInstanceProtocolInterface,\r
+ IsDevicePathMultiInstanceProtocolInterface,\r
+ CreateDeviceNodeProtocolInterface\r
+};\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DEVICE_PATH_TO_TEXT_PROTOCOL mDevicePathToText = {\r
+ ConvertDeviceNodeToText,\r
+ ConvertDevicePathToText\r
+};\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL mDevicePathFromText = {\r
+ ConvertTextToDeviceNode, \r
+ ConvertTextToDevicePath \r
+};\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED const EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid = DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL;\r
+GLOBAL_REMOVE_IF_UNREFERENCED const EFI_GUID mEfiDevicePathMessagingSASGuid = DEVICE_PATH_MESSAGING_SAS;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DevicePathEntryPoint (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Entry point for EFI drivers.\r
+\r
+ Arguments:\r
+ ImageHandle - EFI_HANDLE\r
+ SystemTable - EFI_SYSTEM_TABLE\r
+\r
+ Returns:\r
+ EFI_SUCCESS\r
+ others\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ \r
+ Status = EFI_UNSUPPORTED;\r
+ if (FeaturePcdGet (PcdDevicePathSupportDevicePathToText)) {\r
+ if (FeaturePcdGet (PcdDevicePathSupportDevicePathFromText)) {\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &mDevicePathHandle,\r
+ &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,\r
+ &gEfiDevicePathToTextProtocolGuid, &mDevicePathToText,\r
+ &gEfiDevicePathFromTextProtocolGuid, &mDevicePathFromText,\r
+ NULL\r
+ );\r
+ } else {\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &mDevicePathHandle,\r
+ &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,\r
+ &gEfiDevicePathToTextProtocolGuid, &mDevicePathToText,\r
+ NULL\r
+ );\r
+ }\r
+ } else {\r
+ if (FeaturePcdGet (PcdDevicePathSupportDevicePathFromText)) {\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &mDevicePathHandle,\r
+ &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,\r
+ &gEfiDevicePathFromTextProtocolGuid, &mDevicePathFromText,\r
+ NULL\r
+ );\r
+ } else {\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &mDevicePathHandle,\r
+ &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,\r
+ NULL\r
+ );\r
+ }\r
+ }\r
+ return Status;\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ DevicePath.h\r
+ \r
+Abstract:\r
+ Definition for Device Path Utilities driver\r
+\r
+--*/\r
+\r
+#ifndef _DEVICE_PATH_DRIVER_H\r
+#define _DEVICE_PATH_DRIVER_H\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+extern const EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid;\r
+extern const EFI_GUID mEfiDevicePathMessagingSASGuid;\r
+\r
+#define MAX_CHAR 480\r
+\r
+#define MIN_ALIGNMENT_SIZE sizeof(UINTN)\r
+#define ALIGN_SIZE(a) ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)\r
+\r
+#define IS_COMMA(a) ((a) == L',')\r
+#define IS_HYPHEN(a) ((a) == L'-')\r
+#define IS_DOT(a) ((a) == L'.')\r
+#define IS_LEFT_PARENTH(a) ((a) == L'(')\r
+#define IS_RIGHT_PARENTH(a) ((a) == L')')\r
+#define IS_SLASH(a) ((a) == L'/')\r
+#define IS_NULL(a) ((a) == L'\0')\r
+\r
+#define DEVICE_NODE_END 1\r
+#define DEVICE_PATH_INSTANCE_END 2\r
+#define DEVICE_PATH_END 3\r
+\r
+#define SetDevicePathInstanceEndNode(a) { \\r
+ (a)->Type = END_DEVICE_PATH_TYPE; \\r
+ (a)->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE; \\r
+ (a)->Length[0] = sizeof (EFI_DEVICE_PATH_PROTOCOL); \\r
+ (a)->Length[1] = 0; \\r
+ }\r
+\r
+//\r
+// Private Data structure\r
+//\r
+typedef struct {\r
+ CHAR16 *Str;\r
+ UINTN Len;\r
+ UINTN MaxLen;\r
+} POOL_PRINT;\r
+\r
+typedef struct {\r
+ UINT8 Type;\r
+ UINT8 SubType;\r
+ VOID (*Function) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
+} DEVICE_PATH_TO_TEXT_TABLE;\r
+\r
+typedef struct {\r
+ CHAR16 *DevicePathNodeText;\r
+ EFI_DEVICE_PATH_PROTOCOL * (*Function) (CHAR16 *);\r
+} DEVICE_PATH_FROM_TEXT_TABLE;\r
+\r
+typedef struct {\r
+ BOOLEAN ClassExist;\r
+ UINT8 Class;\r
+ BOOLEAN SubClassExist;\r
+ UINT8 SubClass;\r
+} USB_CLASS_TEXT;\r
+\r
+#define USB_CLASS_AUDIO 1\r
+#define USB_CLASS_CDCCONTROL 2\r
+#define USB_CLASS_HID 3\r
+#define USB_CLASS_IMAGE 6\r
+#define USB_CLASS_PRINTER 7\r
+#define USB_CLASS_MASS_STORAGE 8\r
+#define USB_CLASS_HUB 9\r
+#define USB_CLASS_CDCDATA 10\r
+#define USB_CLASS_SMART_CARD 11\r
+#define USB_CLASS_VIDEO 14\r
+#define USB_CLASS_DIAGNOSTIC 220\r
+#define USB_CLASS_WIRELESS 224\r
+\r
+#define USB_CLASS_RESERVE 254\r
+#define USB_SUBCLASS_FW_UPDATE 1\r
+#define USB_SUBCLASS_IRDA_BRIDGE 2\r
+#define USB_SUBCLASS_TEST 3\r
+\r
+typedef struct {\r
+ EFI_DEVICE_PATH_PROTOCOL Header;\r
+ EFI_GUID Guid;\r
+ UINT8 VendorDefinedData[1];\r
+} VENDOR_DEFINED_HARDWARE_DEVICE_PATH;\r
+\r
+typedef struct {\r
+ EFI_DEVICE_PATH_PROTOCOL Header;\r
+ EFI_GUID Guid;\r
+ UINT8 VendorDefinedData[1];\r
+} VENDOR_DEFINED_MESSAGING_DEVICE_PATH;\r
+\r
+typedef struct {\r
+ EFI_DEVICE_PATH_PROTOCOL Header;\r
+ EFI_GUID Guid;\r
+ UINT8 VendorDefinedData[1];\r
+} VENDOR_DEFINED_MEDIA_DEVICE_PATH;\r
+\r
+typedef struct {\r
+ EFI_DEVICE_PATH_PROTOCOL Header;\r
+ UINT32 HID;\r
+ UINT32 UID;\r
+ UINT32 CID;\r
+ CHAR8 HidUidCidStr[3];\r
+} ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR;\r
+\r
+typedef struct {\r
+ EFI_DEVICE_PATH_PROTOCOL Header;\r
+ UINT16 NetworkProtocol;\r
+ UINT16 LoginOption;\r
+ UINT16 Reserved;\r
+ UINT16 TargetPortalGroupTag;\r
+ UINT64 Lun;\r
+ CHAR16 iSCSITargetName[1];\r
+} ISCSI_DEVICE_PATH_WITH_NAME;\r
+\r
+typedef struct {\r
+ EFI_DEVICE_PATH_PROTOCOL Header;\r
+ EFI_GUID Guid;\r
+ UINT8 VendorDefinedData[1];\r
+} VENDOR_DEVICE_PATH_WITH_DATA;\r
+\r
+CHAR16 *\r
+ConvertDeviceNodeToText (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Convert a device node to its text representation.\r
+\r
+ Arguments:\r
+ DeviceNode - Points to the device node to be converted.\r
+ DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation\r
+ of the display node is used, where applicable. If DisplayOnly\r
+ is FALSE, then the longer text representation of the display node\r
+ is used.\r
+ AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text\r
+ representation for a device node can be used, where applicable.\r
+\r
+ Returns:\r
+ A pointer - a pointer to the allocated text representation of the device node.\r
+ NULL - if DeviceNode is NULL or there was insufficient memory.\r
+\r
+--*/\r
+;\r
+\r
+CHAR16 *\r
+ConvertDevicePathToText (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Convert a device path to its text representation.\r
+\r
+ Arguments:\r
+ DeviceNode - Points to the device path to be converted.\r
+ DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation\r
+ of the display node is used, where applicable. If DisplayOnly\r
+ is FALSE, then the longer text representation of the display node\r
+ is used.\r
+ AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text\r
+ representation for a device node can be used, where applicable.\r
+\r
+ Returns:\r
+ A pointer - a pointer to the allocated text representation of the device path.\r
+ NULL - if DeviceNode is NULL or there was insufficient memory.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+ConvertTextToDeviceNode (\r
+ IN CONST CHAR16 *TextDeviceNode\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Convert text to the binary representation of a device node.\r
+\r
+ Arguments:\r
+ TextDeviceNode - TextDeviceNode points to the text representation of a device\r
+ node. Conversion starts with the first character and continues\r
+ until the first non-device node character.\r
+\r
+ Returns:\r
+ A pointer - Pointer to the EFI device node.\r
+ NULL - if TextDeviceNode is NULL or there was insufficient memory.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+ConvertTextToDevicePath (\r
+ IN CONST CHAR16 *TextDevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Convert text to the binary representation of a device path.\r
+\r
+ Arguments:\r
+ TextDevicePath - TextDevicePath points to the text representation of a device\r
+ path. Conversion starts with the first character and continues\r
+ until the first non-device node character.\r
+\r
+ Returns:\r
+ A pointer - Pointer to the allocated device path.\r
+ NULL - if TextDeviceNode is NULL or there was insufficient memory.\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+GetDevicePathSizeProtocolInterface (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Returns the size of the device path, in bytes.\r
+\r
+ Arguments:\r
+ DevicePath - Points to the start of the EFI device path.\r
+\r
+ Returns:\r
+ Size - Size of the specified device path, in bytes, including the end-of-path tag.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DuplicateDevicePathProtocolInterface (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Create a duplicate of the specified path.\r
+\r
+ Arguments:\r
+ DevicePath - Points to the source EFI device path.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the duplicate device path.\r
+ NULL - Insufficient memory.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+AppendDevicePathProtocolInterface (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Create a new path by appending the second device path to the first.\r
+\r
+ Arguments:\r
+ Src1 - Points to the first device path. If NULL, then it is ignored.\r
+ Src2 - Points to the second device path. If NULL, then it is ignored.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the newly created device path.\r
+ NULL - Memory could not be allocated\r
+ or either DevicePath or DeviceNode is NULL.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+AppendDeviceNodeProtocolInterface (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Creates a new path by appending the device node to the device path.\r
+\r
+ Arguments:\r
+ DevicePath - Points to the device path.\r
+ DeviceNode - Points to the device node.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the allocated device node.\r
+ NULL - Memory could not be allocated\r
+ or either DevicePath or DeviceNode is NULL.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+AppendDevicePathInstanceProtocolInterface (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Creates a new path by appending the specified device path instance to the specified device path.\r
+\r
+ Arguments:\r
+ DevicePath - Points to the device path. If NULL, then ignored.\r
+ DevicePathInstance - Points to the device path instance.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the newly created device path\r
+ NULL - Memory could not be allocated or DevicePathInstance is NULL.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+GetNextDevicePathInstanceProtocolInterface (\r
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance,\r
+ OUT UINTN *DevicePathInstanceSize\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Creates a copy of the current device path instance and returns a pointer to the next device path instance.\r
+\r
+ Arguments:\r
+ DevicePathInstance - On input, this holds the pointer to the current device path\r
+ instance. On output, this holds the pointer to the next\r
+ device path instance or NULL if there are no more device\r
+ path instances in the device path.\r
+ DevicePathInstanceSize - On output, this holds the size of the device path instance,\r
+ in bytes or zero, if DevicePathInstance is zero.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the copy of the current device path instance.\r
+ NULL - DevicePathInstace was NULL on entry or there was insufficient memory.\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+IsDevicePathMultiInstanceProtocolInterface (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Returns whether a device path is multi-instance.\r
+\r
+ Arguments:\r
+ DevicePath - Points to the device path. If NULL, then ignored.\r
+\r
+ Returns:\r
+ TRUE - The device path has more than one instance\r
+ FALSE - The device path is empty or contains only a single instance.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+CreateDeviceNodeProtocolInterface (\r
+ IN UINT8 NodeType,\r
+ IN UINT8 NodeSubType,\r
+ IN UINT16 NodeLength\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Creates a device node\r
+\r
+ Arguments:\r
+ NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for\r
+ the new device node.\r
+ NodeSubType - NodeSubType is the device node sub-type\r
+ EFI_DEVICE_PATH.SubType) for the new device node.\r
+ NodeLength - NodeLength is the length of the device node\r
+ (EFI_DEVICE_PATH.Length) for the new device node.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the newly created device node.\r
+ NULL - NodeLength is less than\r
+ the size of the header or there was insufficient memory.\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
--- /dev/null
+#/** @file\r
+# Component description file for Device Path Driver.\r
+#\r
+# This driver implement these three UEFI deveice path protocols (\r
+# DevicePathUtilities, DevicePahtToText and DevicePathFromText) and install them.\r
+# Copyright (c) 2006 - 2007, Intel Corporation\r
+#\r
+# All rights reserved. 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
+# 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
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = DevicePath\r
+ FILE_GUID = 9B680FCE-AD6B-4F3A-B60B-F59899003443\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ EDK_RELEASE_VERSION = 0x00090000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+ ENTRY_POINT = DevicePathEntryPoint\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ DevicePathUtilities.c\r
+ DevicePathToText.c\r
+ DevicePathFromText.c\r
+ DevicePath.h\r
+ DevicePath.c\r
+ CommonHeader.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdeModulePkg/MdeModulePkg.dec\r
+ MdePkg/MdePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ PcdLib\r
+ DevicePathLib\r
+ UefiBootServicesTableLib\r
+ MemoryAllocationLib\r
+ BaseMemoryLib\r
+ BaseLib\r
+ UefiDriverEntryPoint\r
+ PrintLib\r
+ DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Guid C Name Section - list of Guids that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Guids]\r
+ gEfiVTUTF8Guid # ALWAYS_CONSUMED\r
+ gEfiVT100Guid # ALWAYS_CONSUMED\r
+ gEfiVT100PlusGuid # ALWAYS_CONSUMED\r
+ gEfiPcAnsiGuid # ALWAYS_CONSUMED\r
+\r
+\r
+################################################################################\r
+#\r
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
+# that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Protocols]\r
+ gEfiDevicePathToTextProtocolGuid # PROTOCOL ALWAYS_PRODUCED\r
+ gEfiDevicePathFromTextProtocolGuid # PROTOCOL ALWAYS_PRODUCED\r
+ gEfiDevicePathUtilitiesProtocolGuid # PROTOCOL ALWAYS_PRODUCED\r
+ gEfiDebugPortProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
+\r
+\r
+################################################################################\r
+#\r
+# Pcd FEATURE_FLAG - list of PCDs that this module is coded for.\r
+#\r
+################################################################################\r
+\r
+[PcdsFeatureFlag.common]\r
+ PcdDevicePathSupportDevicePathFromText|gEfiEdkModulePkgTokenSpaceGuid\r
+ PcdDevicePathSupportDevicePathToText|gEfiEdkModulePkgTokenSpaceGuid\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>DevicePath</ModuleName>\r
+ <ModuleType>DXE_DRIVER</ModuleType>\r
+ <GuidValue>9B680FCE-AD6B-4F3A-B60B-F59899003443</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Component description file for Device Path Driver.</Abstract>\r
+ <Description>This driver implement these three UEFI deveice path protocols (\r
+ DevicePathUtilities, DevicePahtToText and DevicePathFromText) and install them.</Description>\r
+ <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
+ <License>All rights reserved. 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
+ 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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>DevicePath</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED" RecommendedInstanceGuid="bda39d3a-451b-4350-8266-81ab10fa0523">\r
+ <Keyword>DebugLib</Keyword>\r
+ <HelpText>Recommended libary Instance is PeiDxeDebugLibReportStatusCode instance in MdePkg.</HelpText>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED" RecommendedInstanceGuid="a86fbfca-0183-4eeb-aa8a-762e3b7da1f3">\r
+ <Keyword>PrintLib</Keyword>\r
+ <HelpText>Recommended libary Instance is BasePrintLib instance in MdePkg.</HelpText>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiDriverEntryPoint</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseMemoryLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>MemoryAllocationLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiBootServicesTableLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED" RecommendedInstanceGuid="91c1677a-e57f-4191-8b8e-eb7711a716e0">\r
+ <Keyword>DevicePathLib</Keyword>\r
+ <HelpText>Recommended libary Instance is UefiDevicePathLib instance in MdePkg.</HelpText>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>PcdLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>DevicePath.c</Filename>\r
+ <Filename>DevicePath.h</Filename>\r
+ <Filename>DevicePathFromText.c</Filename>\r
+ <Filename>DevicePathToText.c</Filename>\r
+ <Filename>DevicePathUtilities.c</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+ </PackageDependencies>\r
+ <Protocols>\r
+ <Protocol Usage="ALWAYS_CONSUMED">\r
+ <ProtocolCName>gEfiDebugPortProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="ALWAYS_PRODUCED">\r
+ <ProtocolCName>gEfiDevicePathUtilitiesProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="ALWAYS_PRODUCED">\r
+ <ProtocolCName>gEfiDevicePathFromTextProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="ALWAYS_PRODUCED">\r
+ <ProtocolCName>gEfiDevicePathToTextProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ </Protocols>\r
+ <Guids>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiPcAnsiGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiVT100PlusGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiVT100Guid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiVTUTF8Guid</GuidCName>\r
+ </GuidCNames>\r
+ </Guids>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00090000</Specification>\r
+ <Extern>\r
+ <ModuleEntryPoint>DevicePathEntryPoint</ModuleEntryPoint>\r
+ </Extern>\r
+ </Externs>\r
+ <PcdCoded>\r
+ <PcdEntry PcdItemType="FEATURE_FLAG" Usage="ALWAYS_PRODUCED">\r
+ <C_Name>PcdDevicePathSupportDevicePathToText</C_Name>\r
+ <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <DefaultValue>FALSE</DefaultValue>\r
+ <HelpText>If TRUE, then the Device Path To Text Protocol should be produced by the platform</HelpText>\r
+ </PcdEntry>\r
+ <PcdEntry PcdItemType="FEATURE_FLAG" Usage="ALWAYS_PRODUCED">\r
+ <C_Name>PcdDevicePathSupportDevicePathFromText</C_Name>\r
+ <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <DefaultValue>FALSE</DefaultValue>\r
+ <HelpText>If TRUE, then the Device Path From Text Protocol should be produced by the platform</HelpText>\r
+ </PcdEntry>\r
+ </PcdCoded>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ DevicePathFromText.c\r
+\r
+Abstract:\r
+\r
+ DevicePathFromText protocol as defined in the UEFI 2.0 specification.\r
+\r
+--*/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "DevicePath.h"\r
+\r
+STATIC\r
+CHAR16 *\r
+StrDuplicate (\r
+ IN CONST CHAR16 *Src\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Duplicate a string\r
+\r
+ Arguments:\r
+ Src - Source string\r
+\r
+ Returns:\r
+ Duplicated string\r
+\r
+--*/\r
+{\r
+ UINTN Length;\r
+ CHAR16 *ReturnStr;\r
+\r
+ Length = StrLen ((CHAR16 *) Src);\r
+\r
+ ReturnStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), (VOID *) Src);\r
+\r
+ return ReturnStr;\r
+}\r
+\r
+STATIC\r
+CHAR16 *\r
+GetParamByNodeName (\r
+ IN CHAR16 *Str,\r
+ IN CHAR16 *NodeName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Get parameter in a pair of parentheses follow the given node name.\r
+ For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1".\r
+\r
+ Arguments:\r
+ Str - Device Path Text\r
+ NodeName - Name of the node\r
+\r
+ Returns:\r
+ Parameter text for the node\r
+\r
+--*/\r
+{\r
+ CHAR16 *ParamStr;\r
+ CHAR16 *StrPointer;\r
+ UINTN NodeNameLength;\r
+ UINTN ParameterLength;\r
+\r
+ //\r
+ // Check whether the node name matchs\r
+ //\r
+ NodeNameLength = StrLen (NodeName);\r
+ if (CompareMem (Str, NodeName, NodeNameLength * sizeof (CHAR16)) != 0) {\r
+ return NULL;\r
+ }\r
+\r
+ ParamStr = Str + NodeNameLength;\r
+ if (!IS_LEFT_PARENTH (*ParamStr)) {\r
+ return NULL;\r
+ }\r
+\r
+ //\r
+ // Skip the found '(' and find first occurrence of ')'\r
+ //\r
+ ParamStr++;\r
+ ParameterLength = 0;\r
+ StrPointer = ParamStr;\r
+ while (!IS_NULL (*StrPointer)) {\r
+ if (IS_RIGHT_PARENTH (*StrPointer)) {\r
+ break;\r
+ }\r
+ StrPointer++;\r
+ ParameterLength++;\r
+ }\r
+ if (IS_NULL (*StrPointer)) {\r
+ //\r
+ // ')' not found\r
+ //\r
+ return NULL;\r
+ }\r
+\r
+ ParamStr = AllocateCopyPool ((ParameterLength + 1) * sizeof (CHAR16), ParamStr);\r
+ if (ParamStr == NULL) {\r
+ return NULL;\r
+ }\r
+ //\r
+ // Terminate the parameter string\r
+ //\r
+ ParamStr[ParameterLength] = L'\0';\r
+\r
+ return ParamStr;\r
+}\r
+\r
+STATIC\r
+CHAR16 *\r
+SplitStr (\r
+ IN OUT CHAR16 **List,\r
+ IN CHAR16 Separator\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Get current sub-string from a string list, before return\r
+ the list header is moved to next sub-string. The sub-string is separated\r
+ by the specified character. For example, the separator is ',', the string\r
+ list is "2,0,3", it returns "2", the remain list move to "2,3"\r
+\r
+ Arguments:\r
+ List - A string list separated by the specified separator\r
+ Separator - The separator character\r
+\r
+ Returns:\r
+ pointer - The current sub-string\r
+\r
+--*/\r
+{\r
+ CHAR16 *Str;\r
+ CHAR16 *ReturnStr;\r
+\r
+ Str = *List;\r
+ ReturnStr = Str;\r
+\r
+ if (IS_NULL (*Str)) {\r
+ return ReturnStr;\r
+ }\r
+\r
+ //\r
+ // Find first occurrence of the separator\r
+ //\r
+ while (!IS_NULL (*Str)) {\r
+ if (*Str == Separator) {\r
+ break;\r
+ }\r
+ Str++;\r
+ }\r
+\r
+ if (*Str == Separator) {\r
+ //\r
+ // Find a sub-string, terminate it\r
+ //\r
+ *Str = L'\0';\r
+ Str++;\r
+ }\r
+\r
+ //\r
+ // Move to next sub-string\r
+ //\r
+ *List = Str;\r
+\r
+ return ReturnStr;\r
+}\r
+\r
+STATIC\r
+CHAR16 *\r
+GetNextParamStr (\r
+ IN OUT CHAR16 **List\r
+ )\r
+{\r
+ //\r
+ // The separator is comma\r
+ //\r
+ return SplitStr (List, L',');\r
+}\r
+\r
+STATIC\r
+CHAR16 *\r
+GetNextDeviceNodeStr (\r
+ IN OUT CHAR16 **DevicePath,\r
+ OUT BOOLEAN *IsInstanceEnd\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Get one device node from entire device path text.\r
+\r
+ Arguments:\r
+ Str - The entire device path text string\r
+ IsInstanceEnd - This node is the end of a device path instance\r
+\r
+ Returns:\r
+ a pointer - A device node text\r
+ NULL - No more device node available\r
+\r
+--*/\r
+{\r
+ CHAR16 *Str;\r
+ CHAR16 *ReturnStr;\r
+ UINTN ParenthesesStack;\r
+\r
+ Str = *DevicePath;\r
+ if (IS_NULL (*Str)) {\r
+ return NULL;\r
+ }\r
+\r
+ //\r
+ // Skip the leading '/', '(', ')' and ','\r
+ //\r
+ while (!IS_NULL (*Str)) {\r
+ if (!IS_SLASH (*Str) &&\r
+ !IS_COMMA (*Str) &&\r
+ !IS_LEFT_PARENTH (*Str) &&\r
+ !IS_RIGHT_PARENTH (*Str)) {\r
+ break;\r
+ }\r
+ Str++;\r
+ }\r
+\r
+ ReturnStr = Str;\r
+\r
+ //\r
+ // Scan for the separator of this device node, '/' or ','\r
+ //\r
+ ParenthesesStack = 0;\r
+ while (!IS_NULL (*Str)) {\r
+ if ((IS_COMMA (*Str) || IS_SLASH (*Str)) && (ParenthesesStack == 0)) {\r
+ break;\r
+ }\r
+\r
+ if (IS_LEFT_PARENTH (*Str)) {\r
+ ParenthesesStack++;\r
+ } else if (IS_RIGHT_PARENTH (*Str)) {\r
+ ParenthesesStack--;\r
+ }\r
+\r
+ Str++;\r
+ }\r
+\r
+ if (ParenthesesStack != 0) {\r
+ //\r
+ // The '(' doesn't pair with ')', invalid device path text\r
+ //\r
+ return NULL;\r
+ }\r
+\r
+ if (IS_COMMA (*Str)) {\r
+ *IsInstanceEnd = TRUE;\r
+ *Str = L'\0';\r
+ Str++;\r
+ } else {\r
+ *IsInstanceEnd = FALSE;\r
+ if (!IS_NULL (*Str)) {\r
+ *Str = L'\0';\r
+ Str++;\r
+ }\r
+ }\r
+\r
+ *DevicePath = Str;\r
+\r
+ return ReturnStr;\r
+}\r
+\r
+STATIC\r
+BOOLEAN\r
+IsHexDigit (\r
+ OUT UINT8 *Digit,\r
+ IN CHAR16 Char\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Determines if a Unicode character is a hexadecimal digit.\r
+ The test is case insensitive.\r
+\r
+ Arguments:\r
+ Digit - Pointer to byte that receives the value of the hex character.\r
+ Char - Unicode character to test.\r
+\r
+ Returns:\r
+ TRUE - If the character is a hexadecimal digit.\r
+ FALSE - Otherwise.\r
+\r
+--*/\r
+{\r
+ if ((Char >= L'0') && (Char <= L'9')) {\r
+ *Digit = (UINT8) (Char - L'0');\r
+ return TRUE;\r
+ }\r
+\r
+ if ((Char >= L'A') && (Char <= L'F')) {\r
+ *Digit = (UINT8) (Char - L'A' + 0x0A);\r
+ return TRUE;\r
+ }\r
+\r
+ if ((Char >= L'a') && (Char <= L'f')) {\r
+ *Digit = (UINT8) (Char - L'a' + 0x0A);\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+HexStringToBuf (\r
+ IN OUT UINT8 *Buf, \r
+ IN OUT UINTN *Len,\r
+ IN CHAR16 *Str,\r
+ OUT UINTN *ConvertedStrLen OPTIONAL\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Converts Unicode string to binary buffer.\r
+ The conversion may be partial.\r
+ The first character in the string that is not hex digit stops the conversion.\r
+ At a minimum, any blob of data could be represented as a hex string.\r
+\r
+ Arguments:\r
+ Buf - Pointer to buffer that receives the data.\r
+ Len - Length in bytes of the buffer to hold converted data.\r
+ If routine return with EFI_SUCCESS, containing length of converted data.\r
+ If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.\r
+ Str - String to be converted from.\r
+ ConvertedStrLen - Length of the Hex String consumed.\r
+\r
+ Returns:\r
+ EFI_SUCCESS: Routine Success.\r
+ EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data.\r
+ EFI_\r
+\r
+--*/\r
+{\r
+ UINTN HexCnt;\r
+ UINTN Idx;\r
+ UINTN BufferLength;\r
+ UINT8 Digit;\r
+ UINT8 Byte;\r
+\r
+ //\r
+ // Find out how many hex characters the string has.\r
+ //\r
+ for (Idx = 0, HexCnt = 0; IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++);\r
+\r
+ if (HexCnt == 0) {\r
+ *Len = 0;\r
+ return EFI_SUCCESS;\r
+ }\r
+ //\r
+ // Two Unicode characters make up 1 buffer byte. Round up.\r
+ //\r
+ BufferLength = (HexCnt + 1) / 2; \r
+\r
+ //\r
+ // Test if buffer is passed enough.\r
+ //\r
+ if (BufferLength > (*Len)) {\r
+ *Len = BufferLength;\r
+ return EFI_BUFFER_TOO_SMALL;\r
+ }\r
+\r
+ *Len = BufferLength;\r
+\r
+ for (Idx = 0; Idx < HexCnt; Idx++) {\r
+\r
+ IsHexDigit (&Digit, Str[HexCnt - 1 - Idx]);\r
+\r
+ //\r
+ // For odd charaters, write the lower nibble for each buffer byte,\r
+ // and for even characters, the upper nibble.\r
+ //\r
+ if ((Idx & 1) == 0) {\r
+ Byte = Digit;\r
+ } else {\r
+ Byte = Buf[Idx / 2];\r
+ Byte &= 0x0F;\r
+ Byte = (UINT8) (Byte | Digit << 4);\r
+ }\r
+\r
+ Buf[Idx / 2] = Byte;\r
+ }\r
+\r
+ if (ConvertedStrLen != NULL) {\r
+ *ConvertedStrLen = HexCnt;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+CHAR16 *\r
+TrimHexStr (\r
+ IN CHAR16 *Str\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Skip the leading white space and '0x' or '0X' of a hex string\r
+\r
+ Arguments:\r
+ Str - The hex string\r
+\r
+ Returns:\r
+\r
+--*/\r
+{\r
+ //\r
+ // skip preceeding white space\r
+ //\r
+ while (*Str && *Str == ' ') {\r
+ Str += 1;\r
+ }\r
+ //\r
+ // skip preceeding zeros\r
+ //\r
+ while (*Str && *Str == '0') {\r
+ Str += 1;\r
+ }\r
+ //\r
+ // skip preceeding character 'x' or 'X'\r
+ //\r
+ if (*Str && (*Str == 'x' || *Str == 'X')) {\r
+ Str += 1;\r
+ }\r
+\r
+ return Str;\r
+}\r
+\r
+STATIC\r
+UINTN\r
+Xtoi (\r
+ IN CHAR16 *Str\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Convert hex string to uint\r
+\r
+Arguments:\r
+\r
+ Str - The string\r
+ \r
+Returns:\r
+\r
+--*/\r
+{\r
+ UINTN Rvalue;\r
+ UINTN Length;\r
+\r
+ ASSERT (Str != NULL);\r
+\r
+ //\r
+ // convert hex digits\r
+ //\r
+ Rvalue = 0;\r
+ Length = sizeof (UINTN);\r
+ HexStringToBuf ((UINT8 *) &Rvalue, &Length, TrimHexStr (Str), NULL);\r
+\r
+ return Rvalue;\r
+}\r
+\r
+STATIC\r
+VOID\r
+Xtoi64 (\r
+ IN CHAR16 *Str,\r
+ IN UINT64 *Data\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Convert hex string to 64 bit data.\r
+\r
+Arguments:\r
+\r
+ Str - The string\r
+ \r
+Returns:\r
+\r
+--*/\r
+{\r
+ UINTN Length;\r
+\r
+ *Data = 0;\r
+ Length = sizeof (UINT64);\r
+ HexStringToBuf ((UINT8 *) Data, &Length, TrimHexStr (Str), NULL);\r
+}\r
+\r
+STATIC\r
+UINTN\r
+Atoi (\r
+ IN CHAR16 *str\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Convert decimal string to uint\r
+\r
+Arguments:\r
+\r
+ Str - The string\r
+ \r
+Returns:\r
+\r
+--*/\r
+{\r
+ UINTN Rvalue;\r
+ CHAR16 Char;\r
+ UINTN High;\r
+ UINTN Low;\r
+\r
+ ASSERT (str != NULL);\r
+\r
+ High = (UINTN) -1 / 10;\r
+ Low = (UINTN) -1 % 10;\r
+ //\r
+ // skip preceeding white space\r
+ //\r
+ while (*str && *str == ' ') {\r
+ str += 1;\r
+ }\r
+ //\r
+ // convert digits\r
+ //\r
+ Rvalue = 0;\r
+ Char = *(str++);\r
+ while (Char) {\r
+ if (Char >= '0' && Char <= '9') {\r
+ if ((Rvalue > High || Rvalue == High) && (Char - '0' > (INTN) Low)) {\r
+ return (UINTN) -1;\r
+ }\r
+\r
+ Rvalue = (Rvalue * 10) + Char - '0';\r
+ } else {\r
+ break;\r
+ }\r
+\r
+ Char = *(str++);\r
+ }\r
+\r
+ return Rvalue;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS \r
+StrToBuf (\r
+ OUT UINT8 *Buf,\r
+ IN UINTN BufferLength,\r
+ IN CHAR16 *Str\r
+ )\r
+{\r
+ UINTN Index;\r
+ UINTN StrLength;\r
+ UINT8 Digit;\r
+ UINT8 Byte;\r
+\r
+ //\r
+ // Two hex char make up one byte\r
+ //\r
+ StrLength = BufferLength * sizeof (CHAR16);\r
+\r
+ for(Index = 0; Index < StrLength; Index++, Str++) {\r
+\r
+ IsHexDigit (&Digit, *Str);\r
+\r
+ //\r
+ // For odd charaters, write the upper nibble for each buffer byte,\r
+ // and for even characters, the lower nibble.\r
+ //\r
+ if ((Index & 1) == 0) {\r
+ Byte = (UINT8) (Digit << 4);\r
+ } else {\r
+ Byte = Buf[Index / 2];\r
+ Byte &= 0xF0;\r
+ Byte = (UINT8) (Byte | Digit);\r
+ }\r
+\r
+ Buf[Index / 2] = Byte;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+StrToGuid (\r
+ IN CHAR16 *Str,\r
+ OUT EFI_GUID *Guid\r
+ )\r
+{\r
+ UINTN BufferLength;\r
+ UINTN ConvertedStrLen;\r
+ EFI_STATUS Status;\r
+\r
+ BufferLength = sizeof (Guid->Data1);\r
+ Status = HexStringToBuf ((UINT8 *) &Guid->Data1, &BufferLength, Str, &ConvertedStrLen);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ Str += ConvertedStrLen;\r
+ if (IS_HYPHEN (*Str)) {\r
+ Str++; \r
+ } else {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ BufferLength = sizeof (Guid->Data2);\r
+ Status = HexStringToBuf ((UINT8 *) &Guid->Data2, &BufferLength, Str, &ConvertedStrLen);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ Str += ConvertedStrLen;\r
+ if (IS_HYPHEN (*Str)) {\r
+ Str++;\r
+ } else {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ BufferLength = sizeof (Guid->Data3);\r
+ Status = HexStringToBuf ((UINT8 *) &Guid->Data3, &BufferLength, Str, &ConvertedStrLen);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ Str += ConvertedStrLen;\r
+ if (IS_HYPHEN (*Str)) {\r
+ Str++;\r
+ } else {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ StrToBuf (&Guid->Data4[0], 2, Str);\r
+ //\r
+ // Skip 2 byte hex chars\r
+ //\r
+ Str += 2 * 2;\r
+\r
+ if (IS_HYPHEN (*Str)) {\r
+ Str++;\r
+ } else {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+ StrToBuf (&Guid->Data4[2], 6, Str);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+VOID\r
+StrToIPv4Addr (\r
+ IN OUT CHAR16 **Str,\r
+ OUT EFI_IPv4_ADDRESS *IPv4Addr\r
+ )\r
+{\r
+ UINTN Index;\r
+\r
+ for (Index = 0; Index < 4; Index++) {\r
+ IPv4Addr->Addr[Index] = (UINT8) Atoi (SplitStr (Str, L'.'));\r
+ }\r
+}\r
+\r
+STATIC\r
+VOID\r
+StrToIPv6Addr (\r
+ IN OUT CHAR16 **Str,\r
+ OUT EFI_IPv6_ADDRESS *IPv6Addr\r
+ )\r
+{\r
+ UINTN Index;\r
+ UINT16 Data;\r
+\r
+ for (Index = 0; Index < 8; Index++) {\r
+ Data = (UINT16) Xtoi (SplitStr (Str, L':'));\r
+ IPv6Addr->Addr[Index * 2] = (UINT8) (Data >> 8);\r
+ IPv6Addr->Addr[Index * 2 + 1] = (UINT8) (Data & 0xff);\r
+ }\r
+}\r
+\r
+STATIC\r
+VOID\r
+StrToAscii (\r
+ IN CHAR16 *Str,\r
+ IN OUT CHAR8 **AsciiStr\r
+ )\r
+{\r
+ CHAR8 *Dest;\r
+\r
+ Dest = *AsciiStr;\r
+ while (!IS_NULL (*Str)) {\r
+ *(Dest++) = (CHAR8) *(Str++);\r
+ }\r
+ *Dest = 0;\r
+\r
+ //\r
+ // Return the string next to it\r
+ //\r
+ *AsciiStr = Dest + 1;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextPci (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *FunctionStr;\r
+ CHAR16 *DeviceStr;\r
+ PCI_DEVICE_PATH *Pci;\r
+\r
+ FunctionStr = GetNextParamStr (&TextDeviceNode);\r
+ DeviceStr = GetNextParamStr (&TextDeviceNode);\r
+ Pci = (PCI_DEVICE_PATH *) CreateDeviceNode (\r
+ HARDWARE_DEVICE_PATH,\r
+ HW_PCI_DP,\r
+ sizeof (PCI_DEVICE_PATH)\r
+ );\r
+\r
+ Pci->Function = (UINT8) Xtoi (FunctionStr);\r
+ Pci->Device = (UINT8) Xtoi (DeviceStr);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Pci;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextPcCard (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *FunctionNumberStr;\r
+ PCCARD_DEVICE_PATH *Pccard;\r
+\r
+ FunctionNumberStr = GetNextParamStr (&TextDeviceNode);\r
+ Pccard = (PCCARD_DEVICE_PATH *) CreateDeviceNode (\r
+ HARDWARE_DEVICE_PATH,\r
+ HW_PCCARD_DP,\r
+ sizeof (PCCARD_DEVICE_PATH)\r
+ );\r
+\r
+ Pccard->FunctionNumber = (UINT8) Xtoi (FunctionNumberStr);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Pccard;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextMemoryMapped (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *StartingAddressStr;\r
+ CHAR16 *EndingAddressStr;\r
+ MEMMAP_DEVICE_PATH *MemMap;\r
+\r
+ StartingAddressStr = GetNextParamStr (&TextDeviceNode);\r
+ EndingAddressStr = GetNextParamStr (&TextDeviceNode);\r
+ MemMap = (MEMMAP_DEVICE_PATH *) CreateDeviceNode (\r
+ HARDWARE_DEVICE_PATH,\r
+ HW_MEMMAP_DP,\r
+ sizeof (MEMMAP_DEVICE_PATH)\r
+ );\r
+\r
+ MemMap->MemoryType = 0;\r
+\r
+ Xtoi64 (StartingAddressStr, &MemMap->StartingAddress);\r
+ Xtoi64 (EndingAddressStr, &MemMap->EndingAddress);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) MemMap;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+ConvertFromTextVendor (\r
+ IN CHAR16 *TextDeviceNode,\r
+ IN UINT8 Type,\r
+ IN UINT8 SubType\r
+ )\r
+{\r
+ CHAR16 *GuidStr;\r
+ CHAR16 *DataStr;\r
+ UINTN Length;\r
+ VENDOR_DEVICE_PATH *Vendor;\r
+\r
+ GuidStr = GetNextParamStr (&TextDeviceNode);\r
+\r
+ DataStr = GetNextParamStr (&TextDeviceNode);\r
+ Length = StrLen (DataStr);\r
+ //\r
+ // Two hex characters make up 1 buffer byte\r
+ //\r
+ Length = (Length + 1) / 2;\r
+\r
+ Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
+ Type,\r
+ SubType,\r
+ sizeof (VENDOR_DEVICE_PATH) + (UINT16) Length\r
+ );\r
+\r
+ StrToGuid (GuidStr, &Vendor->Guid);\r
+ StrToBuf (((UINT8 *) Vendor) + sizeof (VENDOR_DEVICE_PATH), Length, DataStr);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextVenHw (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ return ConvertFromTextVendor (\r
+ TextDeviceNode,\r
+ HARDWARE_DEVICE_PATH,\r
+ HW_VENDOR_DP\r
+ );\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextCtrl (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *ControllerStr;\r
+ CONTROLLER_DEVICE_PATH *Controller;\r
+\r
+ ControllerStr = GetNextParamStr (&TextDeviceNode);\r
+ Controller = (CONTROLLER_DEVICE_PATH *) CreateDeviceNode (\r
+ HARDWARE_DEVICE_PATH,\r
+ HW_CONTROLLER_DP,\r
+ sizeof (CONTROLLER_DEVICE_PATH)\r
+ );\r
+ Controller->ControllerNumber = (UINT32) Xtoi (ControllerStr);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Controller;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextAcpi (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *HIDStr;\r
+ CHAR16 *UIDStr;\r
+ ACPI_HID_DEVICE_PATH *Acpi;\r
+\r
+ HIDStr = GetNextParamStr (&TextDeviceNode);\r
+ UIDStr = GetNextParamStr (&TextDeviceNode);\r
+ Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (\r
+ ACPI_DEVICE_PATH,\r
+ ACPI_DP,\r
+ sizeof (ACPI_HID_DEVICE_PATH)\r
+ );\r
+\r
+ if ((HIDStr[0] == L'P') && (HIDStr[1] == L'N') && (HIDStr[2] == L'P')) {\r
+ HIDStr += 3;\r
+ }\r
+\r
+ Acpi->HID = EISA_PNP_ID (Xtoi (HIDStr));\r
+ Acpi->UID = (UINT32) Xtoi (UIDStr);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+ConvertFromTextAcpi (\r
+ IN CHAR16 *TextDeviceNode,\r
+ IN UINT32 Hid\r
+ )\r
+{\r
+ CHAR16 *UIDStr;\r
+ ACPI_HID_DEVICE_PATH *Acpi;\r
+\r
+ UIDStr = GetNextParamStr (&TextDeviceNode);\r
+ Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (\r
+ ACPI_DEVICE_PATH,\r
+ ACPI_DP,\r
+ sizeof (ACPI_HID_DEVICE_PATH)\r
+ );\r
+\r
+ Acpi->HID = Hid;\r
+ Acpi->UID = (UINT32) Xtoi (UIDStr);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextPciRoot (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ return ConvertFromTextAcpi (TextDeviceNode, 0x0a0341d0);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextFloppy (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ return ConvertFromTextAcpi (TextDeviceNode, 0x060441d0);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextKeyboard (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ return ConvertFromTextAcpi (TextDeviceNode, 0x030141d0);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextSerial (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ return ConvertFromTextAcpi (TextDeviceNode, 0x050141d0);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextParallelPort (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ return ConvertFromTextAcpi (TextDeviceNode, 0x040141d0);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextAcpiEx (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *HIDStr;\r
+ CHAR16 *CIDStr;\r
+ CHAR16 *UIDStr;\r
+ CHAR16 *HIDSTRStr;\r
+ CHAR16 *CIDSTRStr;\r
+ CHAR16 *UIDSTRStr;\r
+ CHAR8 *AsciiStr;\r
+ UINT16 Length;\r
+ ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *AcpiExt;\r
+\r
+ HIDStr = GetNextParamStr (&TextDeviceNode);\r
+ CIDStr = GetNextParamStr (&TextDeviceNode);\r
+ UIDStr = GetNextParamStr (&TextDeviceNode);\r
+ HIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
+ CIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
+ UIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
+\r
+ Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (HIDSTRStr) + 1);\r
+ Length = (UINT16) (Length + StrLen (UIDSTRStr) + 1);\r
+ Length = (UINT16) (Length + StrLen (CIDSTRStr) + 1);\r
+ AcpiExt = (ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *) CreateDeviceNode (\r
+ ACPI_DEVICE_PATH,\r
+ ACPI_EXTENDED_DP,\r
+ Length\r
+ );\r
+\r
+ if ((HIDStr[0] == L'P') && (HIDStr[1] == L'N') && (HIDStr[2] == L'P')) {\r
+ HIDStr += 3;\r
+ AcpiExt->HID = EISA_PNP_ID (Xtoi (HIDStr));\r
+ } else {\r
+ AcpiExt->HID = (UINT32) Xtoi (HIDStr);\r
+ }\r
+\r
+ AcpiExt->UID = (UINT32) Xtoi (UIDStr);\r
+ AcpiExt->CID = (UINT32) Xtoi (CIDStr);\r
+\r
+ AsciiStr = AcpiExt->HidUidCidStr;\r
+ StrToAscii (HIDSTRStr, &AsciiStr);\r
+ StrToAscii (UIDSTRStr, &AsciiStr);\r
+ StrToAscii (CIDSTRStr, &AsciiStr);\r
+ \r
+ return (EFI_DEVICE_PATH_PROTOCOL *) AcpiExt;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextAcpiExp (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *HIDStr;\r
+ CHAR16 *CIDStr;\r
+ CHAR16 *UIDSTRStr;\r
+ CHAR8 *AsciiStr;\r
+ UINT16 Length;\r
+ ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *AcpiExt;\r
+\r
+ HIDStr = GetNextParamStr (&TextDeviceNode);\r
+ CIDStr = GetNextParamStr (&TextDeviceNode);\r
+ UIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
+ Length = sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + (UINT16) StrLen (UIDSTRStr) + 3;\r
+ AcpiExt = (ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *) CreateDeviceNode (\r
+ ACPI_DEVICE_PATH,\r
+ ACPI_EXTENDED_DP,\r
+ Length\r
+ );\r
+\r
+ if ((HIDStr[0] == L'P') && (HIDStr[1] == L'N') && (HIDStr[2] == L'P')) {\r
+ HIDStr += 3;\r
+ AcpiExt->HID = EISA_PNP_ID (Xtoi (HIDStr));\r
+ } else {\r
+ AcpiExt->HID = (UINT32) Xtoi (HIDStr);\r
+ }\r
+\r
+ AcpiExt->UID = 0;\r
+ AcpiExt->CID = (UINT32) Xtoi (CIDStr);\r
+\r
+ AsciiStr = AcpiExt->HidUidCidStr;\r
+ //\r
+ // HID string is NULL\r
+ //\r
+ *AsciiStr = 0;\r
+ //\r
+ // Convert UID string\r
+ //\r
+ AsciiStr++;\r
+ StrToAscii (UIDSTRStr, &AsciiStr);\r
+ //\r
+ // CID string is NULL\r
+ //\r
+ *AsciiStr = 0;\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) AcpiExt;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextAta (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *PrimarySecondaryStr;\r
+ CHAR16 *SlaveMasterStr;\r
+ CHAR16 *LunStr;\r
+ ATAPI_DEVICE_PATH *Atapi;\r
+\r
+ Atapi = (ATAPI_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_ATAPI_DP,\r
+ sizeof (ATAPI_DEVICE_PATH)\r
+ );\r
+\r
+ PrimarySecondaryStr = GetNextParamStr (&TextDeviceNode);\r
+ SlaveMasterStr = GetNextParamStr (&TextDeviceNode);\r
+ LunStr = GetNextParamStr (&TextDeviceNode);\r
+\r
+ Atapi->PrimarySecondary = (UINT8) ((StrCmp (PrimarySecondaryStr, L"Primary") == 0) ? 0 : 1);\r
+ Atapi->SlaveMaster = (UINT8) ((StrCmp (SlaveMasterStr, L"Master") == 0) ? 0 : 1);\r
+ Atapi->Lun = (UINT16) Xtoi (LunStr);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Atapi;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextScsi (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *PunStr;\r
+ CHAR16 *LunStr;\r
+ SCSI_DEVICE_PATH *Scsi;\r
+\r
+ PunStr = GetNextParamStr (&TextDeviceNode);\r
+ LunStr = GetNextParamStr (&TextDeviceNode);\r
+ Scsi = (SCSI_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_SCSI_DP,\r
+ sizeof (SCSI_DEVICE_PATH)\r
+ );\r
+\r
+ Scsi->Pun = (UINT16) Xtoi (PunStr);\r
+ Scsi->Lun = (UINT16) Xtoi (LunStr);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Scsi;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextFibre (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *WWNStr;\r
+ CHAR16 *LunStr;\r
+ FIBRECHANNEL_DEVICE_PATH *Fibre;\r
+\r
+ WWNStr = GetNextParamStr (&TextDeviceNode);\r
+ LunStr = GetNextParamStr (&TextDeviceNode);\r
+ Fibre = (FIBRECHANNEL_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_FIBRECHANNEL_DP,\r
+ sizeof (FIBRECHANNEL_DEVICE_PATH)\r
+ );\r
+\r
+ Fibre->Reserved = 0;\r
+ Xtoi64 (WWNStr, &Fibre->WWN);\r
+ Xtoi64 (LunStr, &Fibre->Lun);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Fibre;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromText1394 (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *GuidStr;\r
+ F1394_DEVICE_PATH *F1394;\r
+\r
+ GuidStr = GetNextParamStr (&TextDeviceNode);\r
+ F1394 = (F1394_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_1394_DP,\r
+ sizeof (F1394_DEVICE_PATH)\r
+ );\r
+\r
+ F1394->Reserved = 0;\r
+ Xtoi64 (GuidStr, &F1394->Guid);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) F1394;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsb (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *PortStr;\r
+ CHAR16 *InterfaceStr;\r
+ USB_DEVICE_PATH *Usb;\r
+\r
+ PortStr = GetNextParamStr (&TextDeviceNode);\r
+ InterfaceStr = GetNextParamStr (&TextDeviceNode);\r
+ Usb = (USB_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_USB_DP,\r
+ sizeof (USB_DEVICE_PATH)\r
+ );\r
+\r
+ Usb->ParentPortNumber = (UINT8) Xtoi (PortStr);\r
+ Usb->InterfaceNumber = (UINT8) Xtoi (InterfaceStr);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Usb;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextI2O (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *TIDStr;\r
+ I2O_DEVICE_PATH *I2O;\r
+\r
+ TIDStr = GetNextParamStr (&TextDeviceNode);\r
+ I2O = (I2O_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_I2O_DP,\r
+ sizeof (I2O_DEVICE_PATH)\r
+ );\r
+\r
+ I2O->Tid = (UINT32) Xtoi (TIDStr);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) I2O;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextInfiniband (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *FlagsStr;\r
+ CHAR16 *GuidStr;\r
+ CHAR16 *SidStr;\r
+ CHAR16 *TidStr;\r
+ CHAR16 *DidStr;\r
+ EFI_GUID PortGid;\r
+ INFINIBAND_DEVICE_PATH *InfiniBand;\r
+\r
+ FlagsStr = GetNextParamStr (&TextDeviceNode);\r
+ GuidStr = GetNextParamStr (&TextDeviceNode);\r
+ SidStr = GetNextParamStr (&TextDeviceNode);\r
+ TidStr = GetNextParamStr (&TextDeviceNode);\r
+ DidStr = GetNextParamStr (&TextDeviceNode);\r
+ InfiniBand = (INFINIBAND_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_INFINIBAND_DP,\r
+ sizeof (INFINIBAND_DEVICE_PATH)\r
+ );\r
+\r
+ InfiniBand->ResourceFlags = (UINT32) Xtoi (FlagsStr);\r
+ StrToGuid (GuidStr, &PortGid);\r
+ CopyMem (InfiniBand->PortGid, &PortGid, sizeof (EFI_GUID));\r
+ Xtoi64 (SidStr, &InfiniBand->ServiceId);\r
+ Xtoi64 (TidStr, &InfiniBand->TargetPortId);\r
+ Xtoi64 (DidStr, &InfiniBand->DeviceId);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) InfiniBand;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextVenMsg (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ return ConvertFromTextVendor (\r
+ TextDeviceNode,\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_VENDOR_DP\r
+ );\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextVenPcAnsi (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ VENDOR_DEVICE_PATH *Vendor;\r
+\r
+ Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_VENDOR_DP,\r
+ sizeof (VENDOR_DEVICE_PATH));\r
+ CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextVenVt100 (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ VENDOR_DEVICE_PATH *Vendor;\r
+\r
+ Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_VENDOR_DP,\r
+ sizeof (VENDOR_DEVICE_PATH));\r
+ CopyGuid (&Vendor->Guid, &gEfiVT100Guid);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextVenVt100Plus (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ VENDOR_DEVICE_PATH *Vendor;\r
+\r
+ Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_VENDOR_DP,\r
+ sizeof (VENDOR_DEVICE_PATH));\r
+ CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextVenUtf8 (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ VENDOR_DEVICE_PATH *Vendor;\r
+\r
+ Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_VENDOR_DP,\r
+ sizeof (VENDOR_DEVICE_PATH));\r
+ CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUartFlowCtrl (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *ValueStr;\r
+ UART_FLOW_CONTROL_DEVICE_PATH *UartFlowControl;\r
+\r
+ ValueStr = GetNextParamStr (&TextDeviceNode);\r
+ UartFlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_VENDOR_DP,\r
+ sizeof (UART_FLOW_CONTROL_DEVICE_PATH)\r
+ );\r
+\r
+ CopyGuid (&UartFlowControl->Guid, &mEfiDevicePathMessagingUartFlowControlGuid);\r
+ if (StrCmp (ValueStr, L"XonXoff") == 0) {\r
+ UartFlowControl->FlowControlMap = 2;\r
+ } else if (StrCmp (ValueStr, L"Hardware") == 0) {\r
+ UartFlowControl->FlowControlMap = 1;\r
+ } else {\r
+ UartFlowControl->FlowControlMap = 0;\r
+ }\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) UartFlowControl;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextSAS (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *AddressStr;\r
+ CHAR16 *LunStr;\r
+ CHAR16 *RTPStr;\r
+ CHAR16 *SASSATAStr;\r
+ CHAR16 *LocationStr;\r
+ CHAR16 *ConnectStr;\r
+ CHAR16 *DriveBayStr;\r
+ CHAR16 *ReservedStr;\r
+ UINT16 Info;\r
+ SAS_DEVICE_PATH *Sas;\r
+\r
+ AddressStr = GetNextParamStr (&TextDeviceNode);\r
+ LunStr = GetNextParamStr (&TextDeviceNode);\r
+ RTPStr = GetNextParamStr (&TextDeviceNode);\r
+ SASSATAStr = GetNextParamStr (&TextDeviceNode);\r
+ LocationStr = GetNextParamStr (&TextDeviceNode);\r
+ ConnectStr = GetNextParamStr (&TextDeviceNode);\r
+ DriveBayStr = GetNextParamStr (&TextDeviceNode);\r
+ ReservedStr = GetNextParamStr (&TextDeviceNode);\r
+ Info = 0x0000;\r
+ Sas = (SAS_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_VENDOR_DP,\r
+ sizeof (SAS_DEVICE_PATH)\r
+ );\r
+\r
+ CopyGuid (&Sas->Guid, &mEfiDevicePathMessagingSASGuid);\r
+ Xtoi64 (AddressStr, &Sas->SasAddress);\r
+ Xtoi64 (LunStr, &Sas->Lun);\r
+ Sas->RelativeTargetPort = (UINT16) Xtoi (RTPStr);\r
+ if (StrCmp (SASSATAStr, L"NoTopology") == 0)\r
+ ;\r
+ else {\r
+ if (StrCmp (DriveBayStr, L"0") == 0) {\r
+ Info |= 0x0001;\r
+ } else {\r
+ Info |= 0x0002;\r
+ Info |= (Xtoi (DriveBayStr) << 8);\r
+ }\r
+\r
+ if (StrCmp (SASSATAStr, L"SATA") == 0) {\r
+ Info |= 0x0010;\r
+ }\r
+\r
+ if (StrCmp (LocationStr, L"External") == 0) {\r
+ Info |= 0x0020;\r
+ }\r
+\r
+ if (StrCmp (ConnectStr, L"Expanded") == 0) {\r
+ Info |= 0x0040;\r
+ }\r
+ }\r
+\r
+ Sas->DeviceTopology = Info;\r
+ Sas->Reserved = (UINT32) Xtoi (ReservedStr);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Sas;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextDebugPort (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ VENDOR_DEFINED_MESSAGING_DEVICE_PATH *Vend;\r
+\r
+ Vend = (VENDOR_DEFINED_MESSAGING_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_VENDOR_DP,\r
+ sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH)\r
+ );\r
+\r
+ CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Vend;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextMAC (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *AddressStr;\r
+ CHAR16 *IfTypeStr;\r
+ UINTN Length;\r
+ MAC_ADDR_DEVICE_PATH *MAC;\r
+\r
+ AddressStr = GetNextParamStr (&TextDeviceNode);\r
+ IfTypeStr = GetNextParamStr (&TextDeviceNode);\r
+ MAC = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_MAC_ADDR_DP,\r
+ sizeof (MAC_ADDR_DEVICE_PATH)\r
+ );\r
+\r
+ MAC->IfType = (UINT8) Xtoi (IfTypeStr);\r
+\r
+ Length = sizeof (EFI_MAC_ADDRESS);\r
+ StrToBuf (&MAC->MacAddress.Addr[0], Length, AddressStr);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) MAC;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextIPv4 (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *RemoteIPStr;\r
+ CHAR16 *ProtocolStr;\r
+ CHAR16 *TypeStr;\r
+ CHAR16 *LocalIPStr;\r
+ IPv4_DEVICE_PATH *IPv4;\r
+\r
+ RemoteIPStr = GetNextParamStr (&TextDeviceNode);\r
+ ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
+ TypeStr = GetNextParamStr (&TextDeviceNode);\r
+ LocalIPStr = GetNextParamStr (&TextDeviceNode);\r
+ IPv4 = (IPv4_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_IPv4_DP,\r
+ sizeof (IPv4_DEVICE_PATH)\r
+ );\r
+\r
+ StrToIPv4Addr (&RemoteIPStr, &IPv4->RemoteIpAddress);\r
+ IPv4->Protocol = (UINT16) ((StrCmp (ProtocolStr, L"UDP") == 0) ? 0 : 1);\r
+ if (StrCmp (TypeStr, L"Static") == 0) {\r
+ IPv4->StaticIpAddress = TRUE;\r
+ } else {\r
+ IPv4->StaticIpAddress = FALSE;\r
+ }\r
+\r
+ StrToIPv4Addr (&LocalIPStr, &IPv4->LocalIpAddress);\r
+\r
+ IPv4->LocalPort = 0;\r
+ IPv4->RemotePort = 0;\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) IPv4;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextIPv6 (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *RemoteIPStr;\r
+ CHAR16 *ProtocolStr;\r
+ CHAR16 *TypeStr;\r
+ CHAR16 *LocalIPStr;\r
+ IPv6_DEVICE_PATH *IPv6;\r
+\r
+ RemoteIPStr = GetNextParamStr (&TextDeviceNode);\r
+ ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
+ TypeStr = GetNextParamStr (&TextDeviceNode);\r
+ LocalIPStr = GetNextParamStr (&TextDeviceNode);\r
+ IPv6 = (IPv6_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_IPv6_DP,\r
+ sizeof (IPv6_DEVICE_PATH)\r
+ );\r
+\r
+ StrToIPv6Addr (&RemoteIPStr, &IPv6->RemoteIpAddress);\r
+ IPv6->Protocol = (UINT16) ((StrCmp (ProtocolStr, L"UDP") == 0) ? 0 : 1);\r
+ if (StrCmp (TypeStr, L"Static") == 0) {\r
+ IPv6->StaticIpAddress = TRUE;\r
+ } else {\r
+ IPv6->StaticIpAddress = FALSE;\r
+ }\r
+\r
+ StrToIPv6Addr (&LocalIPStr, &IPv6->LocalIpAddress);\r
+\r
+ IPv6->LocalPort = 0;\r
+ IPv6->RemotePort = 0;\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) IPv6;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUart (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *BaudStr;\r
+ CHAR16 *DataBitsStr;\r
+ CHAR16 *ParityStr;\r
+ CHAR16 *StopBitsStr;\r
+ UART_DEVICE_PATH *Uart;\r
+\r
+ BaudStr = GetNextParamStr (&TextDeviceNode);\r
+ DataBitsStr = GetNextParamStr (&TextDeviceNode);\r
+ ParityStr = GetNextParamStr (&TextDeviceNode);\r
+ StopBitsStr = GetNextParamStr (&TextDeviceNode);\r
+ Uart = (UART_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_UART_DP,\r
+ sizeof (UART_DEVICE_PATH)\r
+ );\r
+\r
+ Uart->BaudRate = (StrCmp (BaudStr, L"DEFAULT") == 0) ? 115200 : Atoi (BaudStr);\r
+ Uart->DataBits = (UINT8) ((StrCmp (DataBitsStr, L"DEFAULT") == 0) ? 8 : Atoi (DataBitsStr));\r
+ switch (*ParityStr) {\r
+ case L'D':\r
+ Uart->Parity = 0;\r
+ break;\r
+\r
+ case L'N':\r
+ Uart->Parity = 1;\r
+ break;\r
+\r
+ case L'E':\r
+ Uart->Parity = 2;\r
+ break;\r
+\r
+ case L'O':\r
+ Uart->Parity = 3;\r
+ break;\r
+\r
+ case L'M':\r
+ Uart->Parity = 4;\r
+ break;\r
+\r
+ case L'S':\r
+ Uart->Parity = 5;\r
+\r
+ default:\r
+ Uart->Parity = 0xff;\r
+ }\r
+\r
+ if (StrCmp (StopBitsStr, L"D") == 0) {\r
+ Uart->StopBits = (UINT8) 0;\r
+ } else if (StrCmp (StopBitsStr, L"1") == 0) {\r
+ Uart->StopBits = (UINT8) 1;\r
+ } else if (StrCmp (StopBitsStr, L"1.5") == 0) {\r
+ Uart->StopBits = (UINT8) 2;\r
+ } else if (StrCmp (StopBitsStr, L"2") == 0) {\r
+ Uart->StopBits = (UINT8) 3;\r
+ } else {\r
+ Uart->StopBits = 0xff;\r
+ }\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Uart;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+ConvertFromTextUsbClass (\r
+ IN CHAR16 *TextDeviceNode,\r
+ IN USB_CLASS_TEXT *UsbClassText\r
+ )\r
+{\r
+ CHAR16 *VIDStr;\r
+ CHAR16 *PIDStr;\r
+ CHAR16 *ClassStr;\r
+ CHAR16 *SubClassStr;\r
+ CHAR16 *ProtocolStr;\r
+ USB_CLASS_DEVICE_PATH *UsbClass;\r
+\r
+ UsbClass = (USB_CLASS_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_USB_CLASS_DP,\r
+ sizeof (USB_CLASS_DEVICE_PATH)\r
+ );\r
+\r
+ VIDStr = GetNextParamStr (&TextDeviceNode);\r
+ PIDStr = GetNextParamStr (&TextDeviceNode);\r
+ if (UsbClassText->ClassExist) {\r
+ ClassStr = GetNextParamStr (&TextDeviceNode);\r
+ UsbClass->DeviceClass = (UINT8) Xtoi (ClassStr);\r
+ } else {\r
+ UsbClass->DeviceClass = UsbClassText->Class;\r
+ }\r
+ if (UsbClassText->SubClassExist) {\r
+ SubClassStr = GetNextParamStr (&TextDeviceNode);\r
+ UsbClass->DeviceSubClass = (UINT8) Xtoi (SubClassStr);\r
+ } else {\r
+ UsbClass->DeviceSubClass = UsbClassText->SubClass;\r
+ } \r
+\r
+ ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
+\r
+ UsbClass->VendorId = (UINT16) Xtoi (VIDStr);\r
+ UsbClass->ProductId = (UINT16) Xtoi (PIDStr);\r
+ UsbClass->DeviceProtocol = (UINT8) Xtoi (ProtocolStr);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;\r
+}\r
+\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbClass (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ USB_CLASS_TEXT UsbClassText;\r
+\r
+ UsbClassText.ClassExist = TRUE;\r
+ UsbClassText.SubClassExist = TRUE;\r
+\r
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbAudio (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ USB_CLASS_TEXT UsbClassText;\r
+\r
+ UsbClassText.ClassExist = FALSE;\r
+ UsbClassText.Class = USB_CLASS_AUDIO;\r
+ UsbClassText.SubClassExist = TRUE;\r
+\r
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbCDCControl (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ USB_CLASS_TEXT UsbClassText;\r
+\r
+ UsbClassText.ClassExist = FALSE;\r
+ UsbClassText.Class = USB_CLASS_CDCCONTROL;\r
+ UsbClassText.SubClassExist = TRUE;\r
+\r
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbHID (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ USB_CLASS_TEXT UsbClassText;\r
+\r
+ UsbClassText.ClassExist = FALSE;\r
+ UsbClassText.Class = USB_CLASS_HID;\r
+ UsbClassText.SubClassExist = TRUE;\r
+\r
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbImage (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ USB_CLASS_TEXT UsbClassText;\r
+\r
+ UsbClassText.ClassExist = FALSE;\r
+ UsbClassText.Class = USB_CLASS_IMAGE;\r
+ UsbClassText.SubClassExist = TRUE;\r
+\r
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbPrinter (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ USB_CLASS_TEXT UsbClassText;\r
+\r
+ UsbClassText.ClassExist = FALSE;\r
+ UsbClassText.Class = USB_CLASS_PRINTER;\r
+ UsbClassText.SubClassExist = TRUE;\r
+\r
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbMassStorage (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ USB_CLASS_TEXT UsbClassText;\r
+\r
+ UsbClassText.ClassExist = FALSE;\r
+ UsbClassText.Class = USB_CLASS_MASS_STORAGE;\r
+ UsbClassText.SubClassExist = TRUE;\r
+\r
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbHub (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ USB_CLASS_TEXT UsbClassText;\r
+\r
+ UsbClassText.ClassExist = FALSE;\r
+ UsbClassText.Class = USB_CLASS_HUB;\r
+ UsbClassText.SubClassExist = TRUE;\r
+\r
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbCDCData (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ USB_CLASS_TEXT UsbClassText;\r
+\r
+ UsbClassText.ClassExist = FALSE;\r
+ UsbClassText.Class = USB_CLASS_CDCDATA;\r
+ UsbClassText.SubClassExist = TRUE;\r
+\r
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbSmartCard (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ USB_CLASS_TEXT UsbClassText;\r
+\r
+ UsbClassText.ClassExist = FALSE;\r
+ UsbClassText.Class = USB_CLASS_SMART_CARD;\r
+ UsbClassText.SubClassExist = TRUE;\r
+\r
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbVideo (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ USB_CLASS_TEXT UsbClassText;\r
+\r
+ UsbClassText.ClassExist = FALSE;\r
+ UsbClassText.Class = USB_CLASS_VIDEO;\r
+ UsbClassText.SubClassExist = TRUE;\r
+\r
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbDiagnostic (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ USB_CLASS_TEXT UsbClassText;\r
+\r
+ UsbClassText.ClassExist = FALSE;\r
+ UsbClassText.Class = USB_CLASS_DIAGNOSTIC;\r
+ UsbClassText.SubClassExist = TRUE;\r
+\r
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbWireless (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ USB_CLASS_TEXT UsbClassText;\r
+\r
+ UsbClassText.ClassExist = FALSE;\r
+ UsbClassText.Class = USB_CLASS_WIRELESS;\r
+ UsbClassText.SubClassExist = TRUE;\r
+\r
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbDeviceFirmwareUpdate (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ USB_CLASS_TEXT UsbClassText;\r
+\r
+ UsbClassText.ClassExist = FALSE;\r
+ UsbClassText.Class = USB_CLASS_RESERVE;\r
+ UsbClassText.SubClassExist = FALSE;\r
+ UsbClassText.SubClass = USB_SUBCLASS_FW_UPDATE;\r
+\r
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbIrdaBridge (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ USB_CLASS_TEXT UsbClassText;\r
+\r
+ UsbClassText.ClassExist = FALSE;\r
+ UsbClassText.Class = USB_CLASS_RESERVE;\r
+ UsbClassText.SubClassExist = FALSE;\r
+ UsbClassText.SubClass = USB_SUBCLASS_IRDA_BRIDGE;\r
+\r
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbTestAndMeasurement (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ USB_CLASS_TEXT UsbClassText;\r
+\r
+ UsbClassText.ClassExist = FALSE;\r
+ UsbClassText.Class = USB_CLASS_RESERVE;\r
+ UsbClassText.SubClassExist = FALSE;\r
+ UsbClassText.SubClass = USB_SUBCLASS_TEST;\r
+\r
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbWwid (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *VIDStr;\r
+ CHAR16 *PIDStr;\r
+ CHAR16 *InterfaceNumStr;\r
+ USB_WWID_DEVICE_PATH *UsbWwid;\r
+\r
+ VIDStr = GetNextParamStr (&TextDeviceNode);\r
+ PIDStr = GetNextParamStr (&TextDeviceNode);\r
+ InterfaceNumStr = GetNextParamStr (&TextDeviceNode);\r
+ UsbWwid = (USB_WWID_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_USB_WWID_DP,\r
+ sizeof (USB_WWID_DEVICE_PATH)\r
+ );\r
+\r
+ UsbWwid->VendorId = (UINT16) Xtoi (VIDStr);\r
+ UsbWwid->ProductId = (UINT16) Xtoi (PIDStr);\r
+ UsbWwid->InterfaceNumber = (UINT16) Xtoi (InterfaceNumStr);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) UsbWwid;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUnit (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *LunStr;\r
+ DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
+\r
+ LunStr = GetNextParamStr (&TextDeviceNode);\r
+ LogicalUnit = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_DEVICE_LOGICAL_UNIT_DP,\r
+ sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH)\r
+ );\r
+\r
+ LogicalUnit->Lun = (UINT8) Xtoi (LunStr);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) LogicalUnit;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextiSCSI (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ UINT16 Options;\r
+ CHAR16 *NameStr;\r
+ CHAR16 *PortalGroupStr;\r
+ CHAR16 *LunStr;\r
+ CHAR16 *HeaderDigestStr;\r
+ CHAR16 *DataDigestStr;\r
+ CHAR16 *AuthenticationStr;\r
+ CHAR16 *ProtocolStr;\r
+ ISCSI_DEVICE_PATH_WITH_NAME *iSCSI;\r
+\r
+ NameStr = GetNextParamStr (&TextDeviceNode);\r
+ PortalGroupStr = GetNextParamStr (&TextDeviceNode);\r
+ LunStr = GetNextParamStr (&TextDeviceNode);\r
+ HeaderDigestStr = GetNextParamStr (&TextDeviceNode);\r
+ DataDigestStr = GetNextParamStr (&TextDeviceNode);\r
+ AuthenticationStr = GetNextParamStr (&TextDeviceNode);\r
+ ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
+ iSCSI = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_ISCSI_DP,\r
+ sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + (UINT16) (StrLen (NameStr) * 2)\r
+ );\r
+\r
+ StrCpy (iSCSI->iSCSITargetName, NameStr);\r
+ iSCSI->TargetPortalGroupTag = (UINT16) Xtoi (PortalGroupStr);\r
+ Xtoi64 (LunStr, &iSCSI->Lun);\r
+\r
+ Options = 0x0000;\r
+ if (StrCmp (HeaderDigestStr, L"CRC32C") == 0) {\r
+ Options |= 0x0002;\r
+ }\r
+\r
+ if (StrCmp (DataDigestStr, L"CRC32C") == 0) {\r
+ Options |= 0x0008;\r
+ }\r
+\r
+ if (StrCmp (AuthenticationStr, L"None") == 0) {\r
+ Options |= 0x0800;\r
+ }\r
+\r
+ if (StrCmp (AuthenticationStr, L"CHAP_UNI") == 0) {\r
+ Options |= 0x1000;\r
+ }\r
+\r
+ iSCSI->LoginOption = (UINT16) Options;\r
+\r
+ iSCSI->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, L"TCP");\r
+ iSCSI->Reserved = (UINT16) 0;\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) iSCSI;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextHD (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *PartitionStr;\r
+ CHAR16 *TypeStr;\r
+ CHAR16 *SignatureStr;\r
+ CHAR16 *StartStr;\r
+ CHAR16 *SizeStr;\r
+ UINT32 Signature32;\r
+ EFI_GUID SignatureGuid;\r
+ HARDDRIVE_DEVICE_PATH *Hd;\r
+\r
+ PartitionStr = GetNextParamStr (&TextDeviceNode);\r
+ TypeStr = GetNextParamStr (&TextDeviceNode);\r
+ SignatureStr = GetNextParamStr (&TextDeviceNode);\r
+ StartStr = GetNextParamStr (&TextDeviceNode);\r
+ SizeStr = GetNextParamStr (&TextDeviceNode);\r
+ Hd = (HARDDRIVE_DEVICE_PATH *) CreateDeviceNode (\r
+ MEDIA_DEVICE_PATH,\r
+ MEDIA_HARDDRIVE_DP,\r
+ sizeof (HARDDRIVE_DEVICE_PATH)\r
+ );\r
+\r
+ Hd->PartitionNumber = (UINT32) Atoi (PartitionStr);\r
+\r
+ ZeroMem (Hd->Signature, 16);\r
+ Hd->MBRType = (UINT8) 0;\r
+\r
+ if (StrCmp (TypeStr, L"None") == 0) {\r
+ Hd->SignatureType = (UINT8) 0;\r
+ } else if (StrCmp (TypeStr, L"MBR") == 0) {\r
+ Hd->SignatureType = SIGNATURE_TYPE_MBR;\r
+ Hd->MBRType = 0x01;\r
+\r
+ Signature32 = (UINT32) Xtoi (SignatureStr);\r
+ CopyMem (Hd->Signature, &Signature32, sizeof (UINT32));\r
+ } else if (StrCmp (TypeStr, L"GUID") == 0) {\r
+ Hd->SignatureType = SIGNATURE_TYPE_GUID;\r
+ Hd->MBRType = 0x02;\r
+\r
+ StrToGuid (SignatureStr, &SignatureGuid);\r
+ CopyMem (Hd->Signature, &SignatureGuid, sizeof (EFI_GUID));\r
+ } else {\r
+ Hd->SignatureType = 0xff;\r
+\r
+ }\r
+\r
+ Xtoi64 (StartStr, &Hd->PartitionStart);\r
+ Xtoi64 (SizeStr, &Hd->PartitionSize);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Hd;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextCDROM (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *EntryStr;\r
+ CHAR16 *StartStr;\r
+ CHAR16 *SizeStr;\r
+ CDROM_DEVICE_PATH *CDROM;\r
+\r
+ EntryStr = GetNextParamStr (&TextDeviceNode);\r
+ StartStr = GetNextParamStr (&TextDeviceNode);\r
+ SizeStr = GetNextParamStr (&TextDeviceNode);\r
+ CDROM = (CDROM_DEVICE_PATH *) CreateDeviceNode (\r
+ MEDIA_DEVICE_PATH,\r
+ MEDIA_CDROM_DP,\r
+ sizeof (CDROM_DEVICE_PATH)\r
+ );\r
+\r
+ CDROM->BootEntry = (UINT32) Xtoi (EntryStr);\r
+ Xtoi64 (StartStr, &CDROM->PartitionStart);\r
+ Xtoi64 (SizeStr, &CDROM->PartitionSize);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) CDROM;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextVenMEDIA (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ return ConvertFromTextVendor (\r
+ TextDeviceNode,\r
+ MEDIA_DEVICE_PATH,\r
+ MEDIA_VENDOR_DP\r
+ );\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextFilePath (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ FILEPATH_DEVICE_PATH *File;\r
+\r
+ File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode (\r
+ MEDIA_DEVICE_PATH,\r
+ MEDIA_FILEPATH_DP,\r
+ sizeof (FILEPATH_DEVICE_PATH) + (UINT16) (StrLen (TextDeviceNode) * 2)\r
+ );\r
+\r
+ StrCpy (File->PathName, TextDeviceNode);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) File;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextMedia (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *GuidStr;\r
+ MEDIA_PROTOCOL_DEVICE_PATH *Media;\r
+\r
+ GuidStr = GetNextParamStr (&TextDeviceNode);\r
+ Media = (MEDIA_PROTOCOL_DEVICE_PATH *) CreateDeviceNode (\r
+ MEDIA_DEVICE_PATH,\r
+ MEDIA_PROTOCOL_DP,\r
+ sizeof (MEDIA_PROTOCOL_DEVICE_PATH)\r
+ );\r
+\r
+ StrToGuid (GuidStr, &Media->Protocol);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Media;\r
+}\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextBBS (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *TypeStr;\r
+ CHAR16 *IdStr;\r
+ CHAR16 *FlagsStr;\r
+ UINT8 *AsciiStr;\r
+ BBS_BBS_DEVICE_PATH *Bbs;\r
+\r
+ TypeStr = GetNextParamStr (&TextDeviceNode);\r
+ IdStr = GetNextParamStr (&TextDeviceNode);\r
+ FlagsStr = GetNextParamStr (&TextDeviceNode);\r
+ Bbs = (BBS_BBS_DEVICE_PATH *) CreateDeviceNode (\r
+ BBS_DEVICE_PATH,\r
+ BBS_BBS_DP,\r
+ sizeof (BBS_BBS_DEVICE_PATH) + (UINT16) (StrLen (IdStr))\r
+ );\r
+\r
+ if (StrCmp (TypeStr, L"Floppy") == 0) {\r
+ Bbs->DeviceType = BBS_TYPE_FLOPPY;\r
+ } else if (StrCmp (TypeStr, L"HD") == 0) {\r
+ Bbs->DeviceType = BBS_TYPE_HARDDRIVE;\r
+ } else if (StrCmp (TypeStr, L"CDROM") == 0) {\r
+ Bbs->DeviceType = BBS_TYPE_CDROM;\r
+ } else if (StrCmp (TypeStr, L"PCMCIA") == 0) {\r
+ Bbs->DeviceType = BBS_TYPE_PCMCIA;\r
+ } else if (StrCmp (TypeStr, L"USB") == 0) {\r
+ Bbs->DeviceType = BBS_TYPE_USB;\r
+ } else if (StrCmp (TypeStr, L"Network") == 0) {\r
+ Bbs->DeviceType = BBS_TYPE_EMBEDDED_NETWORK;\r
+ } else {\r
+ Bbs->DeviceType = BBS_TYPE_UNKNOWN;\r
+ }\r
+\r
+ AsciiStr = (UINT8 *) Bbs->String;\r
+ StrToAscii (IdStr, (CHAR8 **) &AsciiStr);\r
+\r
+ Bbs->StatusFlag = (UINT16) Xtoi (FlagsStr);\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) Bbs;\r
+}\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable[] = {\r
+ {L"Pci", DevPathFromTextPci},\r
+ {L"PcCard", DevPathFromTextPcCard},\r
+ {L"MemoryMapped", DevPathFromTextMemoryMapped},\r
+ {L"VenHw", DevPathFromTextVenHw},\r
+ {L"Ctrl", DevPathFromTextCtrl},\r
+ {L"Acpi", DevPathFromTextAcpi},\r
+ {L"PciRoot", DevPathFromTextPciRoot},\r
+ {L"Floppy", DevPathFromTextFloppy},\r
+ {L"Keyboard", DevPathFromTextKeyboard},\r
+ {L"Serial", DevPathFromTextSerial},\r
+ {L"ParallelPort", DevPathFromTextParallelPort},\r
+ {L"AcpiEx", DevPathFromTextAcpiEx},\r
+ {L"AcpiExp", DevPathFromTextAcpiExp},\r
+ {L"Ata", DevPathFromTextAta},\r
+ {L"Scsi", DevPathFromTextScsi},\r
+ {L"Fibre", DevPathFromTextFibre},\r
+ {L"I1394", DevPathFromText1394},\r
+ {L"USB", DevPathFromTextUsb},\r
+ {L"I2O", DevPathFromTextI2O},\r
+ {L"Infiniband", DevPathFromTextInfiniband},\r
+ {L"VenMsg", DevPathFromTextVenMsg},\r
+ {L"VenPcAnsi", DevPathFromTextVenPcAnsi},\r
+ {L"VenVt100", DevPathFromTextVenVt100},\r
+ {L"VenVt100Plus", DevPathFromTextVenVt100Plus},\r
+ {L"VenUtf8", DevPathFromTextVenUtf8},\r
+ {L"UartFlowCtrl", DevPathFromTextUartFlowCtrl},\r
+ {L"SAS", DevPathFromTextSAS},\r
+ {L"DebugPort", DevPathFromTextDebugPort},\r
+ {L"MAC", DevPathFromTextMAC},\r
+ {L"IPv4", DevPathFromTextIPv4},\r
+ {L"IPv6", DevPathFromTextIPv6},\r
+ {L"Uart", DevPathFromTextUart},\r
+ {L"UsbClass", DevPathFromTextUsbClass},\r
+ {L"UsbAudio", DevPathFromTextUsbAudio},\r
+ {L"UsbCDCControl", DevPathFromTextUsbCDCControl},\r
+ {L"UsbHID", DevPathFromTextUsbHID},\r
+ {L"UsbImage", DevPathFromTextUsbImage},\r
+ {L"UsbPrinter", DevPathFromTextUsbPrinter},\r
+ {L"UsbMassStorage", DevPathFromTextUsbMassStorage},\r
+ {L"UsbHub", DevPathFromTextUsbHub},\r
+ {L"UsbCDCData", DevPathFromTextUsbCDCData},\r
+ {L"UsbSmartCard", DevPathFromTextUsbSmartCard},\r
+ {L"UsbVideo", DevPathFromTextUsbVideo},\r
+ {L"UsbDiagnostic", DevPathFromTextUsbDiagnostic},\r
+ {L"UsbWireless", DevPathFromTextUsbWireless},\r
+ {L"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate},\r
+ {L"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge},\r
+ {L"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement},\r
+ {L"UsbWwid", DevPathFromTextUsbWwid},\r
+ {L"Unit", DevPathFromTextUnit},\r
+ {L"iSCSI", DevPathFromTextiSCSI},\r
+ {L"HD", DevPathFromTextHD},\r
+ {L"CDROM", DevPathFromTextCDROM},\r
+ {L"VenMEDIA", DevPathFromTextVenMEDIA},\r
+ {L"Media", DevPathFromTextMedia},\r
+ {L"BBS", DevPathFromTextBBS},\r
+ {NULL, NULL}\r
+};\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+ConvertTextToDeviceNode (\r
+ IN CONST CHAR16 *TextDeviceNode\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Convert text to the binary representation of a device node.\r
+\r
+ Arguments:\r
+ TextDeviceNode - TextDeviceNode points to the text representation of a device\r
+ node. Conversion starts with the first character and continues\r
+ until the first non-device node character.\r
+\r
+ Returns:\r
+ A pointer - Pointer to the EFI device node.\r
+ NULL - If TextDeviceNode is NULL or there was insufficient memory or text unsupported.\r
+\r
+--*/\r
+{\r
+ EFI_DEVICE_PATH_PROTOCOL * (*DumpNode) (CHAR16 *);\r
+ CHAR16 *ParamStr;\r
+ EFI_DEVICE_PATH_PROTOCOL *DeviceNode;\r
+ CHAR16 *DeviceNodeStr;\r
+ UINTN Index;\r
+\r
+ if ((TextDeviceNode == NULL) || (IS_NULL (*TextDeviceNode))) {\r
+ return NULL;\r
+ }\r
+\r
+ ParamStr = NULL;\r
+ DumpNode = NULL;\r
+ DeviceNodeStr = StrDuplicate (TextDeviceNode);\r
+\r
+ for (Index = 0; DevPathFromTextTable[Index].Function; Index++) {\r
+ ParamStr = GetParamByNodeName (DeviceNodeStr, DevPathFromTextTable[Index].DevicePathNodeText);\r
+ if (ParamStr != NULL) {\r
+ DumpNode = DevPathFromTextTable[Index].Function;\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (DumpNode == NULL) {\r
+ //\r
+ // A file path\r
+ //\r
+ DumpNode = DevPathFromTextFilePath;\r
+ DeviceNode = DumpNode (DeviceNodeStr);\r
+ } else {\r
+ DeviceNode = DumpNode (ParamStr);\r
+ FreePool (ParamStr);\r
+ }\r
+\r
+ FreePool (DeviceNodeStr);\r
+\r
+ return DeviceNode;\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+ConvertTextToDevicePath (\r
+ IN CONST CHAR16 *TextDevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Convert text to the binary representation of a device path.\r
+\r
+ Arguments:\r
+ TextDevicePath - TextDevicePath points to the text representation of a device\r
+ path. Conversion starts with the first character and continues\r
+ until the first non-device node character.\r
+\r
+ Returns:\r
+ A pointer - Pointer to the allocated device path.\r
+ NULL - If TextDeviceNode is NULL or there was insufficient memory.\r
+\r
+--*/\r
+{\r
+ EFI_DEVICE_PATH_PROTOCOL * (*DumpNode) (CHAR16 *);\r
+ CHAR16 *ParamStr;\r
+ EFI_DEVICE_PATH_PROTOCOL *DeviceNode;\r
+ UINTN Index;\r
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;\r
+ CHAR16 *DevicePathStr;\r
+ CHAR16 *Str;\r
+ CHAR16 *DeviceNodeStr;\r
+ UINT8 IsInstanceEnd;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+\r
+ if ((TextDevicePath == NULL) || (IS_NULL (*TextDevicePath))) {\r
+ return NULL;\r
+ }\r
+\r
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r
+ SetDevicePathEndNode (DevicePath);\r
+\r
+ ParamStr = NULL;\r
+ DeviceNodeStr = NULL;\r
+ DevicePathStr = StrDuplicate (TextDevicePath);\r
+\r
+ Str = DevicePathStr;\r
+ while ((DeviceNodeStr = GetNextDeviceNodeStr (&Str, &IsInstanceEnd)) != NULL) {\r
+ DumpNode = NULL;\r
+ for (Index = 0; DevPathFromTextTable[Index].Function; Index++) {\r
+ ParamStr = GetParamByNodeName (DeviceNodeStr, DevPathFromTextTable[Index].DevicePathNodeText);\r
+ if (ParamStr != NULL) {\r
+ DumpNode = DevPathFromTextTable[Index].Function;\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (DumpNode == NULL) {\r
+ //\r
+ // A file path\r
+ //\r
+ DumpNode = DevPathFromTextFilePath;\r
+ DeviceNode = DumpNode (DeviceNodeStr);\r
+ } else {\r
+ DeviceNode = DumpNode (ParamStr);\r
+ FreePool (ParamStr);\r
+ }\r
+\r
+ NewDevicePath = AppendDeviceNodeProtocolInterface (DevicePath, DeviceNode);\r
+ FreePool (DevicePath);\r
+ FreePool (DeviceNode);\r
+ DevicePath = NewDevicePath;\r
+\r
+ if (IsInstanceEnd) {\r
+ DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r
+ SetDevicePathInstanceEndNode (DeviceNode);\r
+\r
+ NewDevicePath = AppendDeviceNodeProtocolInterface (DevicePath, DeviceNode);\r
+ FreePool (DevicePath);\r
+ FreePool (DeviceNode);\r
+ DevicePath = NewDevicePath;\r
+ }\r
+ }\r
+\r
+ FreePool (DevicePathStr);\r
+ return DevicePath;\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ DevicePathToText.c\r
+\r
+Abstract:\r
+\r
+ DevicePathToText protocol as defined in the UEFI 2.0 specification.\r
+\r
+--*/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "DevicePath.h"\r
+\r
+STATIC\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+UnpackDevicePath (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Function unpacks a device path data structure so that all the nodes of a device path \r
+ are naturally aligned.\r
+\r
+ Arguments:\r
+ DevPath - A pointer to a device path data structure\r
+\r
+ Returns:\r
+ If the memory for the device path is successfully allocated, then a pointer to the \r
+ new device path is returned. Otherwise, NULL is returned.\r
+\r
+--*/\r
+{\r
+ EFI_DEVICE_PATH_PROTOCOL *Src;\r
+ EFI_DEVICE_PATH_PROTOCOL *Dest;\r
+ EFI_DEVICE_PATH_PROTOCOL *NewPath;\r
+ UINTN Size;\r
+\r
+ if (DevPath == NULL) {\r
+ return NULL;\r
+ }\r
+ //\r
+ // Walk device path and round sizes to valid boundries\r
+ //\r
+ Src = DevPath;\r
+ Size = 0;\r
+ for (;;) {\r
+ Size += DevicePathNodeLength (Src);\r
+ Size += ALIGN_SIZE (Size);\r
+\r
+ if (IsDevicePathEnd (Src)) {\r
+ break;\r
+ }\r
+\r
+ Src = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (Src);\r
+ }\r
+ //\r
+ // Allocate space for the unpacked path\r
+ //\r
+ NewPath = AllocateZeroPool (Size);\r
+ if (NewPath != NULL) {\r
+\r
+ ASSERT (((UINTN) NewPath) % MIN_ALIGNMENT_SIZE == 0);\r
+\r
+ //\r
+ // Copy each node\r
+ //\r
+ Src = DevPath;\r
+ Dest = NewPath;\r
+ for (;;) {\r
+ Size = DevicePathNodeLength (Src);\r
+ CopyMem (Dest, Src, Size);\r
+ Size += ALIGN_SIZE (Size);\r
+ SetDevicePathNodeLength (Dest, Size);\r
+ Dest->Type |= EFI_DP_TYPE_UNPACKED;\r
+ Dest = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) Dest) + Size);\r
+\r
+ if (IsDevicePathEnd (Src)) {\r
+ break;\r
+ }\r
+\r
+ Src = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (Src);\r
+ }\r
+ }\r
+\r
+ return NewPath;\r
+}\r
+\r
+STATIC\r
+VOID *\r
+ReallocatePool (\r
+ IN VOID *OldPool,\r
+ IN UINTN OldSize,\r
+ IN UINTN NewSize\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Adjusts the size of a previously allocated buffer.\r
+\r
+ Arguments:\r
+ OldPool - A pointer to the buffer whose size is being adjusted.\r
+ OldSize - The size of the current buffer.\r
+ NewSize - The size of the new buffer.\r
+\r
+ Returns:\r
+ EFI_SUCEESS - The requested number of bytes were allocated.\r
+ EFI_OUT_OF_RESOURCES - The pool requested could not be allocated.\r
+ EFI_INVALID_PARAMETER - The buffer was invalid.\r
+\r
+--*/\r
+{\r
+ VOID *NewPool;\r
+\r
+ NewPool = NULL;\r
+ if (NewSize) {\r
+ NewPool = AllocateZeroPool (NewSize);\r
+ }\r
+\r
+ if (OldPool) {\r
+ if (NewPool) {\r
+ CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);\r
+ }\r
+\r
+ FreePool (OldPool);\r
+ }\r
+\r
+ return NewPool;\r
+}\r
+\r
+STATIC\r
+CHAR16 *\r
+CatPrint (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN CHAR16 *Fmt,\r
+ ...\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Concatenates a formatted unicode string to allocated pool. \r
+ The caller must free the resulting buffer.\r
+\r
+ Arguments:\r
+ Str - Tracks the allocated pool, size in use, and \r
+ amount of pool allocated.\r
+ Fmt - The format string\r
+\r
+ Returns:\r
+ Allocated buffer with the formatted string printed in it. \r
+ The caller must free the allocated buffer. The buffer\r
+ allocation is not packed.\r
+\r
+--*/\r
+{\r
+ UINT16 *AppendStr;\r
+ VA_LIST Args;\r
+ UINTN Size;\r
+\r
+ AppendStr = AllocateZeroPool (0x1000);\r
+ if (AppendStr == NULL) {\r
+ return Str->Str;\r
+ }\r
+\r
+ VA_START (Args, Fmt);\r
+ UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args);\r
+ VA_END (Args);\r
+ if (NULL == Str->Str) {\r
+ Size = StrSize (AppendStr);\r
+ Str->Str = AllocateZeroPool (Size);\r
+ ASSERT (Str->Str != NULL);\r
+ } else {\r
+ Size = StrSize (AppendStr) - sizeof (UINT16);\r
+ Size = Size + StrSize (Str->Str);\r
+ Str->Str = ReallocatePool (\r
+ Str->Str,\r
+ StrSize (Str->Str),\r
+ Size\r
+ );\r
+ ASSERT (Str->Str != NULL);\r
+ }\r
+\r
+ Str->MaxLen = MAX_CHAR * sizeof (UINT16);\r
+ if (Size < Str->MaxLen) {\r
+ StrCat (Str->Str, AppendStr);\r
+ Str->Len = Size - sizeof (UINT16);\r
+ }\r
+\r
+ FreePool (AppendStr);\r
+ return Str->Str;\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextPci (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ PCI_DEVICE_PATH *Pci;\r
+\r
+ Pci = DevPath;\r
+ CatPrint (Str, L"Pci(%x,%x)", Pci->Function, Pci->Device);\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextPccard (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ PCCARD_DEVICE_PATH *Pccard;\r
+\r
+ Pccard = DevPath;\r
+ CatPrint (Str, L"PcCard(%x)", Pccard->FunctionNumber);\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextMemMap (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ MEMMAP_DEVICE_PATH *MemMap;\r
+\r
+ MemMap = DevPath;\r
+ CatPrint (\r
+ Str,\r
+ L"MemoryMapped(%lx,%lx)",\r
+ MemMap->StartingAddress,\r
+ MemMap->EndingAddress\r
+ );\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextVendor (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ VENDOR_DEVICE_PATH *Vendor;\r
+ CHAR16 *Type;\r
+ UINTN Index;\r
+ UINT32 FlowControlMap;\r
+ UINT16 Info;\r
+\r
+ Vendor = (VENDOR_DEVICE_PATH *) DevPath;\r
+ switch (DevicePathType (&Vendor->Header)) {\r
+ case HARDWARE_DEVICE_PATH:\r
+ Type = L"Hw";\r
+ break;\r
+\r
+ case MESSAGING_DEVICE_PATH:\r
+ Type = L"Msg";\r
+ if (AllowShortcuts) {\r
+ if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) {\r
+ CatPrint (Str, L"VenPcAnsi()");\r
+ return ;\r
+ } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) {\r
+ CatPrint (Str, L"VenVt100()");\r
+ return ;\r
+ } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) {\r
+ CatPrint (Str, L"VenVt100Plus()");\r
+ return ;\r
+ } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) {\r
+ CatPrint (Str, L"VenUft8()");\r
+ return ;\r
+ } else if (CompareGuid (&Vendor->Guid, &mEfiDevicePathMessagingUartFlowControlGuid)) {\r
+ FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap);\r
+ switch (FlowControlMap & 0x00000003) {\r
+ case 0:\r
+ CatPrint (Str, L"UartFlowCtrl(%s)", L"None");\r
+ break;\r
+\r
+ case 1:\r
+ CatPrint (Str, L"UartFlowCtrl(%s)", L"Hardware");\r
+ break;\r
+\r
+ case 2:\r
+ CatPrint (Str, L"UartFlowCtrl(%s)", L"XonXoff");\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return ;\r
+ } else if (CompareGuid (&Vendor->Guid, &mEfiDevicePathMessagingSASGuid)) {\r
+ CatPrint (\r
+ Str,\r
+ L"SAS(%lx,%lx,%x,",\r
+ ((SAS_DEVICE_PATH *) Vendor)->SasAddress,\r
+ ((SAS_DEVICE_PATH *) Vendor)->Lun,\r
+ ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort\r
+ );\r
+ Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);\r
+ if ((Info & 0x0f) == 0) {\r
+ CatPrint (Str, L"NoTopology,0,0,0,");\r
+ } else if (((Info & 0x0f) == 1) || ((Info & 0x0f) == 2)) {\r
+ CatPrint (\r
+ Str,\r
+ L"%s,%s,%s,",\r
+ (Info & (0x1 << 4)) ? L"SATA" : L"SAS",\r
+ (Info & (0x1 << 5)) ? L"External" : L"Internal",\r
+ (Info & (0x1 << 6)) ? L"Expanded" : L"Direct"\r
+ );\r
+ if ((Info & 0x0f) == 1) {\r
+ CatPrint (Str, L"0,");\r
+ } else {\r
+ CatPrint (Str, L"%x,", (Info >> 8) & 0xff);\r
+ }\r
+ } else {\r
+ CatPrint (Str, L"0,0,0,0,");\r
+ }\r
+\r
+ CatPrint (Str, L"%x)", ((SAS_DEVICE_PATH *) Vendor)->Reserved);\r
+ return ;\r
+ } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {\r
+ CatPrint (Str, L"DebugPort()");\r
+ return ;\r
+ } else {\r
+ return ;\r
+ //\r
+ // reserved\r
+ //\r
+ }\r
+ }\r
+ break;\r
+\r
+ case MEDIA_DEVICE_PATH:\r
+ Type = L"Media";\r
+ break;\r
+\r
+ default:\r
+ Type = L"?";\r
+ break;\r
+ }\r
+\r
+ CatPrint (Str, L"Ven%s(%g,", Type, &Vendor->Guid);\r
+ for (Index = 0; Index < DevicePathNodeLength (&Vendor->Header) - sizeof (VENDOR_DEVICE_PATH); Index++) {\r
+ CatPrint (Str, L"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);\r
+ }\r
+\r
+ CatPrint (Str, L")");\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextController (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ CONTROLLER_DEVICE_PATH *Controller;\r
+\r
+ Controller = DevPath;\r
+ CatPrint (\r
+ Str,\r
+ L"Ctrl(%x)",\r
+ Controller->ControllerNumber\r
+ );\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextAcpi (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ ACPI_HID_DEVICE_PATH *Acpi;\r
+\r
+ Acpi = DevPath;\r
+ if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+ if (AllowShortcuts) {\r
+ switch (EISA_ID_TO_NUM (Acpi->HID)) {\r
+ case 0x0a03:\r
+ CatPrint (Str, L"PciRoot(%x)", Acpi->UID);\r
+ break;\r
+\r
+ case 0x0604:\r
+ CatPrint (Str, L"Floppy(%x)", Acpi->UID);\r
+ break;\r
+\r
+ case 0x0301:\r
+ CatPrint (Str, L"Keyboard(%x)", Acpi->UID);\r
+ break;\r
+\r
+ case 0x0501:\r
+ CatPrint (Str, L"Serial(%x)", Acpi->UID);\r
+ break;\r
+\r
+ case 0x0401:\r
+ CatPrint (Str, L"ParallelPort(%x)", Acpi->UID);\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return ;\r
+ }\r
+\r
+ CatPrint (Str, L"Acpi(PNP%04x,%x)", EISA_ID_TO_NUM (Acpi->HID), Acpi->UID);\r
+ } else {\r
+ CatPrint (Str, L"Acpi(%08x,%x)", Acpi->HID, Acpi->UID);\r
+ }\r
+}\r
+\r
+#define NextStrA(a) ((UINT8 *) (((UINT8 *) (a)) + AsciiStrLen ((CHAR8 *) (a)) + 1))\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextExtAcpi (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *AcpiExt;\r
+ UINT8 *NextString;\r
+\r
+ AcpiExt = DevPath;\r
+\r
+ if (AllowShortcuts) {\r
+ NextString = NextStrA (AcpiExt->HidUidCidStr);\r
+ if ((*(AcpiExt->HidUidCidStr) == '\0') &&\r
+ (*(NextStrA (NextString)) == '\0') &&\r
+ (AcpiExt->UID == 0)\r
+ ) {\r
+ if ((AcpiExt->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+ CatPrint (\r
+ Str,\r
+ L"AcpiExp(PNP%04x,%x,%a)",\r
+ EISA_ID_TO_NUM (AcpiExt->HID),\r
+ AcpiExt->CID,\r
+ NextStrA (AcpiExt->HidUidCidStr)\r
+ );\r
+ } else {\r
+ CatPrint (\r
+ Str,\r
+ L"AcpiExp(%08x,%x,%a)",\r
+ AcpiExt->HID,\r
+ AcpiExt->CID,\r
+ NextStrA (AcpiExt->HidUidCidStr)\r
+ );\r
+ }\r
+ }\r
+ return ;\r
+ }\r
+\r
+ NextString = NextStrA (AcpiExt->HidUidCidStr);\r
+ NextString = NextStrA (NextString);\r
+ if ((AcpiExt->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+ CatPrint (\r
+ Str,\r
+ L"AcpiEx(PNP%04x,%x,%x,%a,%a,%a)",\r
+ EISA_ID_TO_NUM (AcpiExt->HID),\r
+ AcpiExt->CID,\r
+ AcpiExt->UID,\r
+ AcpiExt->HidUidCidStr,\r
+ NextString,\r
+ NextStrA (AcpiExt->HidUidCidStr)\r
+ );\r
+ } else {\r
+ CatPrint (\r
+ Str,\r
+ L"AcpiEx(%08x,%x,%x,%a,%a,%a)",\r
+ AcpiExt->HID,\r
+ AcpiExt->CID,\r
+ AcpiExt->UID,\r
+ AcpiExt->HidUidCidStr,\r
+ NextString,\r
+ NextStrA (AcpiExt->HidUidCidStr)\r
+ );\r
+ }\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextAtapi (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ ATAPI_DEVICE_PATH *Atapi;\r
+\r
+ Atapi = DevPath;\r
+\r
+ if (DisplayOnly) {\r
+ CatPrint (Str, L"Ata(%x)", Atapi->Lun);\r
+ } else {\r
+ CatPrint (\r
+ Str,\r
+ L"Ata(%s,%s,%x)",\r
+ Atapi->PrimarySecondary ? L"Secondary" : L"Primary",\r
+ Atapi->SlaveMaster ? L"Slave" : L"Master",\r
+ Atapi->Lun\r
+ );\r
+ }\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextScsi (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ SCSI_DEVICE_PATH *Scsi;\r
+\r
+ Scsi = DevPath;\r
+ CatPrint (Str, L"Scsi(%x,%x)", Scsi->Pun, Scsi->Lun);\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextFibre (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ FIBRECHANNEL_DEVICE_PATH *Fibre;\r
+\r
+ Fibre = DevPath;\r
+ CatPrint (Str, L"Fibre(%lx,%lx)", Fibre->WWN, Fibre->Lun);\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToText1394 (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ F1394_DEVICE_PATH *F1394;\r
+\r
+ F1394 = DevPath;\r
+ CatPrint (Str, L"I1394(%lx)", F1394->Guid);\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextUsb (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ USB_DEVICE_PATH *Usb;\r
+\r
+ Usb = DevPath;\r
+ CatPrint (Str, L"USB(%x,%x)", Usb->ParentPortNumber, Usb->InterfaceNumber);\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextUsbWWID (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ USB_WWID_DEVICE_PATH *UsbWWId;\r
+\r
+ UsbWWId = DevPath;\r
+ CatPrint (\r
+ Str,\r
+ L"UsbWwid(%x,%x,%x,\"WWID\")",\r
+ UsbWWId->VendorId,\r
+ UsbWWId->ProductId,\r
+ UsbWWId->InterfaceNumber\r
+ );\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextLogicalUnit (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
+\r
+ LogicalUnit = DevPath;\r
+ CatPrint (Str, L"Unit(%x)", LogicalUnit->Lun);\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextUsbClass (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ USB_CLASS_DEVICE_PATH *UsbClass;\r
+\r
+ UsbClass = DevPath;\r
+\r
+ if (AllowShortcuts == TRUE) {\r
+ switch (UsbClass->DeviceClass) {\r
+ case 1:\r
+ CatPrint (\r
+ Str,\r
+ L"UsbAudio(%x,%x,%x,%x)",\r
+ UsbClass->VendorId,\r
+ UsbClass->ProductId,\r
+ UsbClass->DeviceSubClass,\r
+ UsbClass->DeviceProtocol\r
+ );\r
+ break;\r
+\r
+ case 2:\r
+ CatPrint (\r
+ Str,\r
+ L"UsbCDCControl(%x,%x,%x,%x)",\r
+ UsbClass->VendorId,\r
+ UsbClass->ProductId,\r
+ UsbClass->DeviceSubClass,\r
+ UsbClass->DeviceProtocol\r
+ );\r
+ break;\r
+\r
+ case 3:\r
+ CatPrint (\r
+ Str,\r
+ L"UsbHID(%x,%x,%x,%x)",\r
+ UsbClass->VendorId,\r
+ UsbClass->ProductId,\r
+ UsbClass->DeviceSubClass,\r
+ UsbClass->DeviceProtocol\r
+ );\r
+ break;\r
+\r
+ case 6:\r
+ CatPrint (\r
+ Str,\r
+ L"UsbImage(%x,%x,%x,%x)",\r
+ UsbClass->VendorId,\r
+ UsbClass->ProductId,\r
+ UsbClass->DeviceSubClass,\r
+ UsbClass->DeviceProtocol\r
+ );\r
+ break;\r
+\r
+ case 7:\r
+ CatPrint (\r
+ Str,\r
+ L"UsbPrinter(%x,%x,%x,%x)",\r
+ UsbClass->VendorId,\r
+ UsbClass->ProductId,\r
+ UsbClass->DeviceSubClass,\r
+ UsbClass->DeviceProtocol\r
+ );\r
+ break;\r
+\r
+ case 8:\r
+ CatPrint (\r
+ Str,\r
+ L"UsbMassStorage(%x,%x,%x,%x)",\r
+ UsbClass->VendorId,\r
+ UsbClass->ProductId,\r
+ UsbClass->DeviceSubClass,\r
+ UsbClass->DeviceProtocol\r
+ );\r
+ break;\r
+\r
+ case 9:\r
+ CatPrint (\r
+ Str,\r
+ L"UsbHub(%x,%x,%x,%x)",\r
+ UsbClass->VendorId,\r
+ UsbClass->ProductId,\r
+ UsbClass->DeviceSubClass,\r
+ UsbClass->DeviceProtocol\r
+ );\r
+ break;\r
+\r
+ case 10:\r
+ CatPrint (\r
+ Str,\r
+ L"UsbCDCData(%x,%x,%x,%x)",\r
+ UsbClass->VendorId,\r
+ UsbClass->ProductId,\r
+ UsbClass->DeviceSubClass,\r
+ UsbClass->DeviceProtocol\r
+ );\r
+ break;\r
+\r
+ case 11:\r
+ CatPrint (\r
+ Str,\r
+ L"UsbSmartCard(%x,%x,%x,%x)",\r
+ UsbClass->VendorId,\r
+ UsbClass->ProductId,\r
+ UsbClass->DeviceSubClass,\r
+ UsbClass->DeviceProtocol\r
+ );\r
+ break;\r
+\r
+ case 14:\r
+ CatPrint (\r
+ Str,\r
+ L"UsbVideo(%x,%x,%x,%x)",\r
+ UsbClass->VendorId,\r
+ UsbClass->ProductId,\r
+ UsbClass->DeviceSubClass,\r
+ UsbClass->DeviceProtocol\r
+ );\r
+ break;\r
+\r
+ case 220:\r
+ CatPrint (\r
+ Str,\r
+ L"UsbDiagnostic(%x,%x,%x,%x)",\r
+ UsbClass->VendorId,\r
+ UsbClass->ProductId,\r
+ UsbClass->DeviceSubClass,\r
+ UsbClass->DeviceProtocol\r
+ );\r
+ break;\r
+\r
+ case 224:\r
+ CatPrint (\r
+ Str,\r
+ L"UsbWireless(%x,%x,%x,%x)",\r
+ UsbClass->VendorId,\r
+ UsbClass->ProductId,\r
+ UsbClass->DeviceSubClass,\r
+ UsbClass->DeviceProtocol\r
+ );\r
+ break;\r
+\r
+ case 254:\r
+ if (UsbClass->DeviceSubClass == 1) {\r
+ CatPrint (\r
+ Str,\r
+ L"UsbDeviceFirmwareUpdate(%x,%x,%x)",\r
+ UsbClass->VendorId,\r
+ UsbClass->ProductId,\r
+ UsbClass->DeviceProtocol\r
+ );\r
+ } else if (UsbClass->DeviceSubClass == 2) {\r
+ CatPrint (\r
+ Str,\r
+ L"UsbIrdaBridge(%x,%x,%x)",\r
+ UsbClass->VendorId,\r
+ UsbClass->ProductId,\r
+ UsbClass->DeviceProtocol\r
+ );\r
+ } else if (UsbClass->DeviceSubClass == 3) {\r
+ CatPrint (\r
+ Str,\r
+ L"UsbTestAndMeasurement(%x,%x,%x)",\r
+ UsbClass->VendorId,\r
+ UsbClass->ProductId,\r
+ UsbClass->DeviceProtocol\r
+ );\r
+ }\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return ;\r
+ }\r
+\r
+ CatPrint (\r
+ Str,\r
+ L"UsbClass(%x,%x,%x,%x,%x)",\r
+ UsbClass->VendorId,\r
+ UsbClass->ProductId,\r
+ UsbClass->DeviceClass,\r
+ UsbClass->DeviceSubClass,\r
+ UsbClass->DeviceProtocol\r
+ );\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextI2O (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ I2O_DEVICE_PATH *I2O;\r
+\r
+ I2O = DevPath;\r
+ CatPrint (Str, L"I2O(%x)", I2O->Tid);\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextMacAddr (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ MAC_ADDR_DEVICE_PATH *MAC;\r
+ UINTN HwAddressSize;\r
+ UINTN Index;\r
+\r
+ MAC = DevPath;\r
+\r
+ HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
+ if (MAC->IfType == 0x01 || MAC->IfType == 0x00) {\r
+ HwAddressSize = 6;\r
+ }\r
+\r
+ CatPrint (Str, L"MAC(");\r
+\r
+ for (Index = 0; Index < HwAddressSize; Index++) {\r
+ CatPrint (Str, L"%02x", MAC->MacAddress.Addr[Index]);\r
+ }\r
+\r
+ CatPrint (Str, L",%x)", MAC->IfType);\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextIPv4 (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ IPv4_DEVICE_PATH *IP;\r
+\r
+ IP = DevPath;\r
+ if (DisplayOnly == TRUE) {\r
+ CatPrint (\r
+ Str,\r
+ L"IPv4(%d.%d.%d.%d)",\r
+ IP->RemoteIpAddress.Addr[0],\r
+ IP->RemoteIpAddress.Addr[1],\r
+ IP->RemoteIpAddress.Addr[2],\r
+ IP->RemoteIpAddress.Addr[3]\r
+ );\r
+ return ;\r
+ }\r
+\r
+ CatPrint (\r
+ Str,\r
+ L"IPv4(%d.%d.%d.%d,%s,%s,%d.%d.%d.%d)",\r
+ IP->RemoteIpAddress.Addr[0],\r
+ IP->RemoteIpAddress.Addr[1],\r
+ IP->RemoteIpAddress.Addr[2],\r
+ IP->RemoteIpAddress.Addr[3],\r
+ IP->Protocol ? L"TCP" : L"UDP",\r
+ (IP->StaticIpAddress == TRUE) ? L"Static" : L"DHCP",\r
+ IP->LocalIpAddress.Addr[0],\r
+ IP->LocalIpAddress.Addr[1],\r
+ IP->LocalIpAddress.Addr[2],\r
+ IP->LocalIpAddress.Addr[3]\r
+ );\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextIPv6 (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ IPv6_DEVICE_PATH *IP;\r
+\r
+ IP = DevPath;\r
+ if (DisplayOnly == TRUE) {\r
+ CatPrint (\r
+ Str,\r
+ L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
+ IP->RemoteIpAddress.Addr[0],\r
+ IP->RemoteIpAddress.Addr[1],\r
+ IP->RemoteIpAddress.Addr[2],\r
+ IP->RemoteIpAddress.Addr[3],\r
+ IP->RemoteIpAddress.Addr[4],\r
+ IP->RemoteIpAddress.Addr[5],\r
+ IP->RemoteIpAddress.Addr[6],\r
+ IP->RemoteIpAddress.Addr[7],\r
+ IP->RemoteIpAddress.Addr[8],\r
+ IP->RemoteIpAddress.Addr[9],\r
+ IP->RemoteIpAddress.Addr[10],\r
+ IP->RemoteIpAddress.Addr[11],\r
+ IP->RemoteIpAddress.Addr[12],\r
+ IP->RemoteIpAddress.Addr[13],\r
+ IP->RemoteIpAddress.Addr[14],\r
+ IP->RemoteIpAddress.Addr[15]\r
+ );\r
+ return ;\r
+ }\r
+\r
+ CatPrint (\r
+ Str,\r
+ L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x,%s,%s,%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
+ IP->RemoteIpAddress.Addr[0],\r
+ IP->RemoteIpAddress.Addr[1],\r
+ IP->RemoteIpAddress.Addr[2],\r
+ IP->RemoteIpAddress.Addr[3],\r
+ IP->RemoteIpAddress.Addr[4],\r
+ IP->RemoteIpAddress.Addr[5],\r
+ IP->RemoteIpAddress.Addr[6],\r
+ IP->RemoteIpAddress.Addr[7],\r
+ IP->RemoteIpAddress.Addr[8],\r
+ IP->RemoteIpAddress.Addr[9],\r
+ IP->RemoteIpAddress.Addr[10],\r
+ IP->RemoteIpAddress.Addr[11],\r
+ IP->RemoteIpAddress.Addr[12],\r
+ IP->RemoteIpAddress.Addr[13],\r
+ IP->RemoteIpAddress.Addr[14],\r
+ IP->RemoteIpAddress.Addr[15],\r
+ IP->Protocol ? L"TCP" : L"UDP",\r
+ (IP->StaticIpAddress == TRUE) ? L"Static" : L"DHCP",\r
+ IP->LocalIpAddress.Addr[0],\r
+ IP->LocalIpAddress.Addr[1],\r
+ IP->LocalIpAddress.Addr[2],\r
+ IP->LocalIpAddress.Addr[3],\r
+ IP->LocalIpAddress.Addr[4],\r
+ IP->LocalIpAddress.Addr[5],\r
+ IP->LocalIpAddress.Addr[6],\r
+ IP->LocalIpAddress.Addr[7],\r
+ IP->LocalIpAddress.Addr[8],\r
+ IP->LocalIpAddress.Addr[9],\r
+ IP->LocalIpAddress.Addr[10],\r
+ IP->LocalIpAddress.Addr[11],\r
+ IP->LocalIpAddress.Addr[12],\r
+ IP->LocalIpAddress.Addr[13],\r
+ IP->LocalIpAddress.Addr[14],\r
+ IP->LocalIpAddress.Addr[15]\r
+ );\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextInfiniBand (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ INFINIBAND_DEVICE_PATH *InfiniBand;\r
+\r
+ InfiniBand = DevPath;\r
+ CatPrint (\r
+ Str,\r
+ L"Infiniband(%x,%g,%lx,%lx,%lx)",\r
+ InfiniBand->ResourceFlags,\r
+ InfiniBand->PortGid,\r
+ InfiniBand->ServiceId,\r
+ InfiniBand->TargetPortId,\r
+ InfiniBand->DeviceId\r
+ );\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextUart (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ UART_DEVICE_PATH *Uart;\r
+ CHAR8 Parity;\r
+\r
+ Uart = DevPath;\r
+ switch (Uart->Parity) {\r
+ case 0:\r
+ Parity = 'D';\r
+ break;\r
+\r
+ case 1:\r
+ Parity = 'N';\r
+ break;\r
+\r
+ case 2:\r
+ Parity = 'E';\r
+ break;\r
+\r
+ case 3:\r
+ Parity = 'O';\r
+ break;\r
+\r
+ case 4:\r
+ Parity = 'M';\r
+ break;\r
+\r
+ case 5:\r
+ Parity = 'S';\r
+ break;\r
+\r
+ default:\r
+ Parity = 'x';\r
+ break;\r
+ }\r
+\r
+ if (Uart->BaudRate == 0) {\r
+ CatPrint (Str, L"Uart(DEFAULT,");\r
+ } else {\r
+ CatPrint (Str, L"Uart(%ld,", Uart->BaudRate);\r
+ }\r
+\r
+ if (Uart->DataBits == 0) {\r
+ CatPrint (Str, L"DEFAULT,");\r
+ } else {\r
+ CatPrint (Str, L"%d,", Uart->DataBits);\r
+ }\r
+\r
+ CatPrint (Str, L"%c,", Parity);\r
+\r
+ switch (Uart->StopBits) {\r
+ case 0:\r
+ CatPrint (Str, L"D)");\r
+ break;\r
+\r
+ case 1:\r
+ CatPrint (Str, L"1)");\r
+ break;\r
+\r
+ case 2:\r
+ CatPrint (Str, L"1.5)");\r
+ break;\r
+\r
+ case 3:\r
+ CatPrint (Str, L"2)");\r
+ break;\r
+\r
+ default:\r
+ CatPrint (Str, L"x)");\r
+ break;\r
+ }\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextiSCSI (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ ISCSI_DEVICE_PATH_WITH_NAME *iSCSI;\r
+ UINT16 Options;\r
+\r
+ iSCSI = DevPath;\r
+ CatPrint (\r
+ Str,\r
+ L"iSCSI(%s,%x,%lx,",\r
+ iSCSI->iSCSITargetName,\r
+ iSCSI->TargetPortalGroupTag,\r
+ iSCSI->Lun\r
+ );\r
+\r
+ Options = iSCSI->LoginOption;\r
+ CatPrint (Str, L"%s,", ((Options >> 1) & 0x0001) ? L"CRC32C" : L"None");\r
+ CatPrint (Str, L"%s,", ((Options >> 3) & 0x0001) ? L"CRC32C" : L"None");\r
+ if ((Options >> 11) & 0x0001) {\r
+ CatPrint (Str, L"%s,", L"None");\r
+ } else if ((Options >> 12) & 0x0001) {\r
+ CatPrint (Str, L"%s,", L"CHAP_UNI");\r
+ } else {\r
+ CatPrint (Str, L"%s,", L"CHAP_BI");\r
+\r
+ }\r
+\r
+ CatPrint (Str, L"%s)", (iSCSI->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextHardDrive (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ HARDDRIVE_DEVICE_PATH *Hd;\r
+\r
+ Hd = DevPath;\r
+ switch (Hd->SignatureType) {\r
+ case 0:\r
+ CatPrint (\r
+ Str,\r
+ L"HD(%d,%s,0,",\r
+ Hd->PartitionNumber,\r
+ L"None"\r
+ );\r
+ break;\r
+\r
+ case SIGNATURE_TYPE_MBR:\r
+ CatPrint (\r
+ Str,\r
+ L"HD(%d,%s,%08x,",\r
+ Hd->PartitionNumber,\r
+ L"MBR",\r
+ *((UINT32 *) (&(Hd->Signature[0])))\r
+ );\r
+ break;\r
+\r
+ case SIGNATURE_TYPE_GUID:\r
+ CatPrint (\r
+ Str,\r
+ L"HD(%d,%s,%g,",\r
+ Hd->PartitionNumber,\r
+ L"GUID",\r
+ (EFI_GUID *) &(Hd->Signature[0])\r
+ );\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ CatPrint (Str, L"%lx,%lx)", Hd->PartitionStart, Hd->PartitionSize);\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextCDROM (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ CDROM_DEVICE_PATH *Cd;\r
+\r
+ Cd = DevPath;\r
+ if (DisplayOnly == TRUE) {\r
+ CatPrint (Str, L"CDROM(%x)", Cd->BootEntry);\r
+ return ;\r
+ }\r
+\r
+ CatPrint (Str, L"CDROM(%x,%lx,%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextFilePath (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ FILEPATH_DEVICE_PATH *Fp;\r
+\r
+ Fp = DevPath;\r
+ CatPrint (Str, L"%s", Fp->PathName);\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextMediaProtocol (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;\r
+\r
+ MediaProt = DevPath;\r
+ CatPrint (Str, L"Media(%g)", &MediaProt->Protocol);\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextBBS (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ BBS_BBS_DEVICE_PATH *Bbs;\r
+ CHAR16 *Type;\r
+\r
+ Bbs = DevPath;\r
+ switch (Bbs->DeviceType) {\r
+ case BBS_TYPE_FLOPPY:\r
+ Type = L"Floppy";\r
+ break;\r
+\r
+ case BBS_TYPE_HARDDRIVE:\r
+ Type = L"HD";\r
+ break;\r
+\r
+ case BBS_TYPE_CDROM:\r
+ Type = L"CDROM";\r
+ break;\r
+\r
+ case BBS_TYPE_PCMCIA:\r
+ Type = L"PCMCIA";\r
+ break;\r
+\r
+ case BBS_TYPE_USB:\r
+ Type = L"USB";\r
+ break;\r
+\r
+ case BBS_TYPE_EMBEDDED_NETWORK:\r
+ Type = L"Network";\r
+ break;\r
+\r
+ default:\r
+ Type = L"?";\r
+ break;\r
+ }\r
+\r
+ CatPrint (Str, L"BBS(%s,%a", Type, Bbs->String);\r
+\r
+ if (DisplayOnly == TRUE) {\r
+ CatPrint (Str, L")");\r
+ return ;\r
+ }\r
+\r
+ CatPrint (Str, L",%x)", Bbs->StatusFlag);\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextEndInstance (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ CatPrint (Str, L",");\r
+}\r
+\r
+STATIC\r
+VOID\r
+DevPathToTextNodeUnknown (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ CatPrint (Str, L"?");\r
+}\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable[] = {\r
+ {HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci},\r
+ {HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard},\r
+ {HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap},\r
+ {HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor},\r
+ {HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController},\r
+ {ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi},\r
+ {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextExtAcpi},\r
+ {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi},\r
+ {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi},\r
+ {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre},\r
+ {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394},\r
+ {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb},\r
+ {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID},\r
+ {MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit},\r
+ {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass},\r
+ {MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O},\r
+ {MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr},\r
+ {MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4},\r
+ {MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6},\r
+ {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand},\r
+ {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart},\r
+ {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor},\r
+ {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI},\r
+ {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive},\r
+ {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM},\r
+ {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor},\r
+ {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath},\r
+ {MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol},\r
+ {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath},\r
+ {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS},\r
+ {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance},\r
+ {0, 0, NULL}\r
+};\r
+\r
+CHAR16 *\r
+ConvertDeviceNodeToText (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Convert a device node to its text representation.\r
+\r
+ Arguments:\r
+ DeviceNode - Points to the device node to be converted.\r
+ DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation\r
+ of the display node is used, where applicable. If DisplayOnly\r
+ is FALSE, then the longer text representation of the display node\r
+ is used.\r
+ AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text\r
+ representation for a device node can be used, where applicable.\r
+\r
+ Returns:\r
+ A pointer - a pointer to the allocated text representation of the device node.\r
+ NULL - if DeviceNode is NULL or there was insufficient memory.\r
+\r
+--*/\r
+{\r
+ POOL_PRINT Str;\r
+ UINTN Index;\r
+ UINTN NewSize;\r
+ VOID (*DumpNode)(POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
+\r
+ if (DeviceNode == NULL) {\r
+ return NULL;\r
+ }\r
+\r
+ ZeroMem (&Str, sizeof (Str));\r
+\r
+ //\r
+ // Process the device path node\r
+ //\r
+ DumpNode = NULL;\r
+ for (Index = 0; DevPathToTextTable[Index].Function != NULL; Index++) {\r
+ if (DevicePathType (DeviceNode) == DevPathToTextTable[Index].Type &&\r
+ DevicePathSubType (DeviceNode) == DevPathToTextTable[Index].SubType\r
+ ) {\r
+ DumpNode = DevPathToTextTable[Index].Function;\r
+ break;\r
+ }\r
+ }\r
+ //\r
+ // If not found, use a generic function\r
+ //\r
+ if (DumpNode == NULL) {\r
+ DumpNode = DevPathToTextNodeUnknown;\r
+ }\r
+\r
+ //\r
+ // Print this node\r
+ //\r
+ DumpNode (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts);\r
+\r
+ //\r
+ // Shrink pool used for string allocation\r
+ //\r
+ NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
+ Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);\r
+ ASSERT (Str.Str != NULL);\r
+ Str.Str[Str.Len] = 0;\r
+ return Str.Str;\r
+}\r
+\r
+CHAR16 *\r
+ConvertDevicePathToText (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Convert a device path to its text representation.\r
+\r
+ Arguments:\r
+ DeviceNode - Points to the device path to be converted.\r
+ DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation\r
+ of the display node is used, where applicable. If DisplayOnly\r
+ is FALSE, then the longer text representation of the display node\r
+ is used.\r
+ AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text\r
+ representation for a device node can be used, where applicable.\r
+\r
+ Returns:\r
+ A pointer - a pointer to the allocated text representation of the device path.\r
+ NULL - if DeviceNode is NULL or there was insufficient memory.\r
+\r
+--*/\r
+{\r
+ POOL_PRINT Str;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevPathNode;\r
+ EFI_DEVICE_PATH_PROTOCOL *UnpackDevPath;\r
+ UINTN Index;\r
+ UINTN NewSize;\r
+ VOID (*DumpNode) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
+\r
+ if (DevicePath == NULL) {\r
+ return NULL;\r
+ }\r
+\r
+ ZeroMem (&Str, sizeof (Str));\r
+\r
+ //\r
+ // Unpacked the device path\r
+ //\r
+ UnpackDevPath = UnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) DevicePath);\r
+ ASSERT (UnpackDevPath != NULL);\r
+\r
+ //\r
+ // Process each device path node\r
+ //\r
+ DevPathNode = UnpackDevPath;\r
+ while (!IsDevicePathEnd (DevPathNode)) {\r
+ //\r
+ // Find the handler to dump this device path node\r
+ //\r
+ DumpNode = NULL;\r
+ for (Index = 0; DevPathToTextTable[Index].Function; Index += 1) {\r
+\r
+ if (DevicePathType (DevPathNode) == DevPathToTextTable[Index].Type &&\r
+ DevicePathSubType (DevPathNode) == DevPathToTextTable[Index].SubType\r
+ ) {\r
+ DumpNode = DevPathToTextTable[Index].Function;\r
+ break;\r
+ }\r
+ }\r
+ //\r
+ // If not found, use a generic function\r
+ //\r
+ if (!DumpNode) {\r
+ DumpNode = DevPathToTextNodeUnknown;\r
+ }\r
+ //\r
+ // Put a path seperator in if needed\r
+ //\r
+ if (Str.Len && DumpNode != DevPathToTextEndInstance) {\r
+ if (*(Str.Str + Str.Len / sizeof (CHAR16) - 1) != L',') { \r
+ CatPrint (&Str, L"/");\r
+ } \r
+ }\r
+ //\r
+ // Print this node of the device path\r
+ //\r
+ DumpNode (&Str, DevPathNode, DisplayOnly, AllowShortcuts);\r
+\r
+ //\r
+ // Next device path node\r
+ //\r
+ DevPathNode = NextDevicePathNode (DevPathNode);\r
+ }\r
+ //\r
+ // Shrink pool used for string allocation\r
+ //\r
+ FreePool (UnpackDevPath);\r
+\r
+ NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
+ Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);\r
+ ASSERT (Str.Str != NULL);\r
+ Str.Str[Str.Len] = 0;\r
+ return Str.Str;\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+ DevicePathUtilities.c\r
+\r
+Abstract:\r
+\r
+ Implementation file for Device Path Utilities Protocol\r
+\r
+--*/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "DevicePath.h"\r
+\r
+UINTN\r
+GetDevicePathSizeProtocolInterface (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Returns the size of the device path, in bytes.\r
+\r
+ Arguments:\r
+ DevicePath - Points to the start of the EFI device path.\r
+\r
+ Returns:\r
+ Size - Size of the specified device path, in bytes, including the end-of-path tag.\r
+\r
+--*/\r
+{\r
+ return GetDevicePathSize (DevicePath);\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DuplicateDevicePathProtocolInterface (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Create a duplicate of the specified path.\r
+\r
+ Arguments:\r
+ DevicePath - Points to the source EFI device path.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the duplicate device path.\r
+ NULL - Insufficient memory.\r
+\r
+--*/\r
+{\r
+ return DuplicateDevicePath (DevicePath);\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+AppendDevicePathProtocolInterface (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Create a new path by appending the second device path to the first.\r
+\r
+ Arguments:\r
+ Src1 - Points to the first device path. If NULL, then it is ignored.\r
+ Src2 - Points to the second device path. If NULL, then it is ignored.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the newly created device path.\r
+ NULL - Memory could not be allocated\r
+ or either DevicePath or DeviceNode is NULL.\r
+\r
+--*/\r
+{\r
+ return AppendDevicePath (Src1, Src2);\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+AppendDeviceNodeProtocolInterface (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Creates a new path by appending the device node to the device path.\r
+\r
+ Arguments:\r
+ DevicePath - Points to the device path.\r
+ DeviceNode - Points to the device node.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the allocated device node.\r
+ NULL - Memory could not be allocated\r
+ or either DevicePath or DeviceNode is NULL.\r
+\r
+--*/\r
+{\r
+ return AppendDevicePathNode (DevicePath, DeviceNode);\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+AppendDevicePathInstanceProtocolInterface (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Creates a new path by appending the specified device path instance to the specified device path.\r
+\r
+ Arguments:\r
+ DevicePath - Points to the device path. If NULL, then ignored.\r
+ DevicePathInstance - Points to the device path instance.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the newly created device path\r
+ NULL - Memory could not be allocated or DevicePathInstance is NULL.\r
+\r
+--*/\r
+{\r
+ return AppendDevicePathInstance (DevicePath, DevicePathInstance);\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+GetNextDevicePathInstanceProtocolInterface (\r
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance,\r
+ OUT UINTN *DevicePathInstanceSize\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Creates a copy of the current device path instance and returns a pointer to the next device path instance.\r
+\r
+ Arguments:\r
+ DevicePathInstance - On input, this holds the pointer to the current device path\r
+ instance. On output, this holds the pointer to the next\r
+ device path instance or NULL if there are no more device\r
+ path instances in the device path.\r
+ DevicePathInstanceSize - On output, this holds the size of the device path instance,\r
+ in bytes or zero, if DevicePathInstance is zero.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the copy of the current device path instance.\r
+ NULL - DevicePathInstace was NULL on entry or there was insufficient memory.\r
+\r
+--*/\r
+{\r
+ return GetNextDevicePathInstance (DevicePathInstance, DevicePathInstanceSize);\r
+}\r
+\r
+BOOLEAN\r
+IsDevicePathMultiInstanceProtocolInterface (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Returns whether a device path is multi-instance.\r
+\r
+ Arguments:\r
+ DevicePath - Points to the device path. If NULL, then ignored.\r
+\r
+ Returns:\r
+ TRUE - The device path has more than one instance\r
+ FALSE - The device path is empty or contains only a single instance.\r
+\r
+--*/\r
+{\r
+ return IsDevicePathMultiInstance (DevicePath);\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+CreateDeviceNodeProtocolInterface (\r
+ IN UINT8 NodeType,\r
+ IN UINT8 NodeSubType,\r
+ IN UINT16 NodeLength\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Creates a device node\r
+\r
+ Arguments:\r
+ NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for\r
+ the new device node.\r
+ NodeSubType - NodeSubType is the device node sub-type\r
+ EFI_DEVICE_PATH.SubType) for the new device node.\r
+ NodeLength - NodeLength is the length of the device node\r
+ (EFI_DEVICE_PATH.Length) for the new device node.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the newly created device node.\r
+ NULL - NodeLength is less than\r
+ the size of the header or there was insufficient memory.\r
+\r
+--*/\r
+{\r
+ return CreateDeviceNode (NodeType, NodeSubType, NodeLength);\r
+}\r
//\r
// The package level header files this module uses\r
//\r
-#include <Peim.h>\r
-#include <EdkPeim.h>\r
+#include <PiPei.h>\r
//\r
// The protocols, PPI and GUID defintions for this module\r
//\r
//\r
// The Library classes this module consumes\r
//\r
-#include <Library/EdkPeCoffLoaderLib.h>\r
+#include <Library/PeCoffLoaderLib.h>\r
\r
#endif\r
\r
[Packages]\r
MdePkg/MdePkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
\r
\r
################################################################################\r
gEfiWinNtPhysicalDisksGuid = { 0x0C95A92F, 0xA006, 0x11D4, { 0xBC, 0xFA, 0x00, 0x80, 0xC7, 0x3C, 0x88, 0x81 }}\r
gEfiWinNtVirtualDisksGuid = { 0x0C95A928, 0xA006, 0x11D4, { 0xBC, 0xFA, 0x00, 0x80, 0xC7, 0x3C, 0x88, 0x81 }}\r
gEfiNt32PkgTokenSpaceGuid = { 0x0D79A645, 0x1D91, 0x40a6, { 0xA8, 0x1F, 0x61, 0xE6, 0x98, 0x2B, 0x32, 0xB4 }}\r
+ gEfiEndOfPeiSignalPpiGuid = { 0x605EA650, 0xC65C, 0x42e1, { 0xBA, 0x80, 0x91, 0xA5, 0x2A, 0xB6, 0x18, 0xC6 }}\r
+ gEfiPeiFvFileLoaderPpiGuid = { 0x7e1f0d85, 0x04ff, 0x4bb2, { 0x86, 0x6a, 0x31, 0xa2, 0x99, 0x6a, 0x48, 0xa8 }}\r
\r
\r
################################################################################\r
[LibraryClasses.common]\r
TimerLib|$(WORKSPACE)/MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf\r
PrintLib|$(WORKSPACE)/MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
- UefiDecompressLib|$(WORKSPACE)/MdeModulePkg/Library/BaseUefiTianoDecompressLib/BaseUefiTianoDecompressLib.inf\r
DebugLib|$(WORKSPACE)/MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
SerialPortLib|$(WORKSPACE)/MdePkg/Library/SerialPortLibNull/SerialPortLibNull.inf\r
BaseMemoryLib|$(WORKSPACE)/MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf\r
BaseLib|$(WORKSPACE)/MdePkg/Library/BaseLib/BaseLib.inf\r
- CustomDecompressLib|$(WORKSPACE)/MdeModulePkg/Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.inf\r
PerformanceLib|$(WORKSPACE)/MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf\r
PeCoffLib|$(WORKSPACE)/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf\r
PciIncompatibleDeviceSupportLib|${WORKSPACE}/IntelFrameworkModulePkg/Library/PciIncompatibleDeviceSupportLib/PciIncompatibleDeviceSupportLib.inf\r
GraphicsLib|$(WORKSPACE)/IntelFrameworkModulePkg/Library/GraphicsLib/GraphicsLib.inf\r
FvbServiceLib|${WORKSPACE}/MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
IoLib|$(WORKSPACE)/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
+ CustomDecompressLib|${WORKSPACE}/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf \r
+ HiiLib|${WORKSPACE}/IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf\r
\r
[LibraryClasses.common.DXE_CORE]\r
DevicePathLib|$(WORKSPACE)/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf\r
#\r
################################################################################\r
\r
+[PcdsFeatureFlag.common]\r
+ PcdDevicePathSupportDevicePathFromText|gEfiEdkModulePkgTokenSpaceGuid|FALSE\r
+ PcdDevicePathSupportDevicePathToText|gEfiEdkModulePkgTokenSpaceGuid|FALSE\r
+ PcdDxeIplSupportCustomDecompress|gEfiEdkModulePkgTokenSpaceGuid|TRUE\r
+ PcdDxeIplBuildShareCodeHobs|gEfiEdkModulePkgTokenSpaceGuid|FALSE \r
+ PcdDxeIplSupportEfiDecompress|gEfiEdkModulePkgTokenSpaceGuid|TRUE\r
+ PcdDxeIplSupportTianoDecompress|gEfiEdkModulePkgTokenSpaceGuid|TRUE\r
+ PcdDxeIplSupportCustomDecompress|gEfiEdkModulePkgTokenSpaceGuid|TRUE \r
+\r
[PcdsPatchableInModule.IA32]\r
PcdStatusCodeMemorySize|gEfiIntelFrameworkModulePkgTokenSpaceGuid|1\r
PcdStatusCodeRuntimeMemorySize|gEfiIntelFrameworkModulePkgTokenSpaceGuid|128\r
$(WORKSPACE)/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.inf ##This driver follows UEFI specification definition\r
$(WORKSPACE)/Nt32Pkg/Sec/SecMain.inf\r
$(WORKSPACE)/MdeModulePkg/Core/Pei/PeiMain.inf\r
-
\ No newline at end of file
+ ${WORKSPACE}/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.inf\r
+ ${WORKSPACE}/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.inf\r
+ ${WORKSPACE}/MdeModulePkg/Universal/DevicePathDxe/DevicePath.inf\r
+ ${WORKSPACE}/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.inf\r
+ ${WORKSPACE}/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf\r
+ ${WORKSPACE}/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.inf
\ No newline at end of file