本文整理汇总了C++中EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL类的典型用法代码示例。如果您正苦于以下问题:C++ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL类的具体用法?C++ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL怎么用?C++ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
/**
Draws a dialog box to the console output device specified by
ConOut defined in the EFI_SYSTEM_TABLE and waits for a keystroke
from the console input device specified by ConIn defined in the
EFI_SYSTEM_TABLE.
If there are no strings in the variable argument list, then ASSERT().
If all the strings in the variable argument list are empty, then ASSERT().
@param[in] Attribute Specifies the foreground and background color of the popup.
@param[out] Key A pointer to the EFI_KEY value of the key that was
pressed. This is an optional parameter that may be NULL.
If it is NULL then no wait for a keypress will be performed.
@param[in] ... The variable argument list that contains pointers to Null-
terminated Unicode strings to display in the dialog box.
The variable argument list is terminated by a NULL.
**/
VOID
EFIAPI
CreatePopUp (
IN UINTN Attribute,
OUT EFI_INPUT_KEY *Key, OPTIONAL
...
)
{
EFI_STATUS Status;
VA_LIST Args;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
EFI_SIMPLE_TEXT_OUTPUT_MODE SavedConsoleMode;
UINTN Columns;
UINTN Rows;
UINTN Column;
UINTN Row;
UINTN NumberOfLines;
UINTN MaxLength;
CHAR16 *String;
UINTN Length;
CHAR16 *Line;
UINTN EventIndex;
//
// Determine the length of the longest line in the popup and the the total
// number of lines in the popup
//
VA_START (Args, Key);
MaxLength = 0;
NumberOfLines = 0;
while ((String = VA_ARG (Args, CHAR16 *)) != NULL) {
MaxLength = MAX (MaxLength, StrLen (String));
NumberOfLines++;
}
VA_END (Args);
//
// If the total number of lines in the popup is zero, then ASSERT()
//
ASSERT (NumberOfLines != 0);
//
// If the maximum length of all the strings is zero, then ASSERT()
//
ASSERT (MaxLength != 0);
//
// Cache a pointer to the Simple Text Output Protocol in the EFI System Table
//
ConOut = gST->ConOut;
//
// Save the current console cursor position and attributes
//
CopyMem (&SavedConsoleMode, ConOut->Mode, sizeof (SavedConsoleMode));
//
// Retrieve the number of columns and rows in the current console mode
//
ConOut->QueryMode (ConOut, SavedConsoleMode.Mode, &Columns, &Rows);
//
// Disable cursor and set the foreground and background colors specified by Attribute
//
ConOut->EnableCursor (ConOut, FALSE);
ConOut->SetAttribute (ConOut, Attribute);
//
// Limit NumberOfLines to height of the screen minus 3 rows for the box itself
//
NumberOfLines = MIN (NumberOfLines, Rows - 3);
//
// Limit MaxLength to width of the screen minus 2 columns for the box itself
//
MaxLength = MIN (MaxLength, Columns - 2);
//
// Compute the starting row and starting column for the popup
//
Row = (Rows - (NumberOfLines + 3)) / 2;
Column = (Columns - (MaxLength + 2)) / 2;
//.........这里部分代码省略.........
示例2: UpdateConModePage
/**
Refresh the text mode page.
@param CallbackData The BMM context data.
**/
VOID
UpdateConModePage (
IN BMM_CALLBACK_DATA *CallbackData
)
{
UINTN Mode;
UINTN Index;
UINTN Col;
UINTN Row;
CHAR16 ModeString[50];
CHAR16 *PStr;
UINTN MaxMode;
UINTN ValidMode;
EFI_STRING_ID *ModeToken;
EFI_STATUS Status;
VOID *OptionsOpCodeHandle;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
ConOut = gST->ConOut;
Index = 0;
ValidMode = 0;
MaxMode = (UINTN) (ConOut->Mode->MaxMode);
CallbackData->BmmAskSaveOrNot = TRUE;
UpdatePageStart (CallbackData);
//
// Check valid mode
//
for (Mode = 0; Mode < MaxMode; Mode++) {
Status = ConOut->QueryMode (ConOut, Mode, &Col, &Row);
if (EFI_ERROR (Status)) {
continue;
}
ValidMode++;
}
if (ValidMode == 0) {
return;
}
OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
ASSERT (OptionsOpCodeHandle != NULL);
ModeToken = AllocateZeroPool (sizeof (EFI_STRING_ID) * ValidMode);
ASSERT(ModeToken != NULL);
//
// Determin which mode should be the first entry in menu
//
GetConsoleOutMode (CallbackData);
//
// Build text mode options
//
for (Mode = 0; Mode < MaxMode; Mode++) {
Status = ConOut->QueryMode (ConOut, Mode, &Col, &Row);
if (EFI_ERROR (Status)) {
continue;
}
//
// Build mode string Column x Row
//
UnicodeValueToString (ModeString, 0, Col, 0);
PStr = &ModeString[0];
StrnCatS (PStr, ARRAY_SIZE (ModeString), L" x ", StrLen(L" x ") + 1);
PStr = PStr + StrLen (PStr);
UnicodeValueToString (PStr , 0, Row, 0);
ModeToken[Index] = HiiSetString (CallbackData->BmmHiiHandle, 0, ModeString, NULL);
if (Mode == CallbackData->BmmFakeNvData.ConsoleOutMode) {
HiiCreateOneOfOptionOpCode (
OptionsOpCodeHandle,
ModeToken[Index],
EFI_IFR_OPTION_DEFAULT,
EFI_IFR_TYPE_NUM_SIZE_16,
(UINT16) Mode
);
} else {
HiiCreateOneOfOptionOpCode (
OptionsOpCodeHandle,
ModeToken[Index],
0,
EFI_IFR_TYPE_NUM_SIZE_16,
(UINT16) Mode
);
}
Index++;
}
HiiCreateOneOfOpCode (
//.........这里部分代码省略.........
示例3: PlatformBdsEnterFrontPage
/**
This function is the main entry of the platform setup entry.
The function will present the main menu of the system setup,
this is the platform reference part and can be customize.
@param TimeoutDefault The fault time out value before the system
continue to boot.
@param ConnectAllHappened The indicater to check if the connect all have
already happened.
**/
VOID
PlatformBdsEnterFrontPage (
IN UINT16 TimeoutDefault,
IN BOOLEAN ConnectAllHappened
)
{
EFI_STATUS Status;
EFI_STATUS StatusHotkey;
EFI_BOOT_LOGO_PROTOCOL *BootLogo;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
UINTN BootTextColumn;
UINTN BootTextRow;
UINT64 OsIndication;
UINTN DataSize;
EFI_INPUT_KEY Key;
GraphicsOutput = NULL;
SimpleTextOut = NULL;
PERF_START (NULL, "BdsTimeOut", "BDS", 0);
//
// Indicate if we need connect all in the platform setup
//
if (ConnectAllHappened) {
gConnectAllHappened = TRUE;
}
if (!mModeInitialized) {
//
// After the console is ready, get current video resolution
// and text mode before launching setup at first time.
//
Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiGraphicsOutputProtocolGuid,
(VOID**)&GraphicsOutput
);
if (EFI_ERROR (Status)) {
GraphicsOutput = NULL;
}
Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiSimpleTextOutProtocolGuid,
(VOID**)&SimpleTextOut
);
if (EFI_ERROR (Status)) {
SimpleTextOut = NULL;
}
if (GraphicsOutput != NULL) {
//
// Get current video resolution and text mode.
//
mBootHorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;
mBootVerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;
}
if (SimpleTextOut != NULL) {
Status = SimpleTextOut->QueryMode (
SimpleTextOut,
SimpleTextOut->Mode->Mode,
&BootTextColumn,
&BootTextRow
);
mBootTextModeColumn = (UINT32)BootTextColumn;
mBootTextModeRow = (UINT32)BootTextRow;
}
//
// Get user defined text mode for setup.
//
mSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);
mSetupVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution);
mSetupTextModeColumn = PcdGet32 (PcdSetupConOutColumn);
mSetupTextModeRow = PcdGet32 (PcdSetupConOutRow);
mModeInitialized = TRUE;
}
//
// goto FrontPage directly when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set
//
OsIndication = 0;
DataSize = sizeof(UINT64);
Status = gRT->GetVariable (
//.........这里部分代码省略.........
示例4: da_ConWrite
/* Write a NULL terminated WCS to the EFI console.
@param[in,out] BufferSize Number of bytes in Buffer. Set to zero if
the string couldn't be displayed.
@param[in] Buffer The WCS string to be displayed
@return The number of characters written.
*/
static
ssize_t
EFIAPI
da_ConWrite(
IN struct __filedes *filp,
IN off_t *Position,
IN size_t BufferSize,
IN const void *Buffer
)
{
EFI_STATUS Status;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Proto;
ConInstance *Stream;
ssize_t NumChar;
//XYoffset CursorPos;
Stream = BASE_CR(filp->f_ops, ConInstance, Abstraction);
// Quick check to see if Stream looks reasonable
if(Stream->Cookie != CON_COOKIE) { // Cookie == 'IoAb'
EFIerrno = RETURN_INVALID_PARAMETER;
return -1; // Looks like a bad This pointer
}
if(Stream->InstanceNum == STDIN_FILENO) {
// Write is not valid for stdin
EFIerrno = RETURN_UNSUPPORTED;
return -1;
}
// Everything is OK to do the write.
Proto = (EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)Stream->Dev;
// Convert string from MBCS to WCS and translate \n to \r\n.
NumChar = WideTtyCvt(gMD->UString, (const char *)Buffer, BufferSize);
//if(NumChar > 0) {
// BufferSize = (size_t)(NumChar * sizeof(CHAR16));
//}
BufferSize = NumChar;
//if( Position != NULL) {
// CursorPos.Offset = (UINT64)*Position;
// Status = Proto->SetCursorPosition(Proto,
// (INTN)CursorPos.XYpos.Column,
// (INTN)CursorPos.XYpos.Row);
// if(RETURN_ERROR(Status)) {
// return -1;
// }
//}
// Send the Unicode buffer to the console
Status = Proto->OutputString( Proto, gMD->UString);
// Depending on status, update BufferSize and return
if(RETURN_ERROR(Status)) {
BufferSize = 0; // We don't really know how many characters made it out
}
else {
//BufferSize = NumChar;
Stream->NumWritten += NumChar;
}
EFIerrno = Status;
return BufferSize;
}
示例5: BdsSetConsoleMode
/**
This function will change video resolution and text mode
according to defined setup mode or defined boot mode
@param IsSetupMode Indicate mode is changed to setup mode or boot mode.
@retval EFI_SUCCESS Mode is changed successfully.
@retval Others Mode failed to be changed.
**/
EFI_STATUS
EFIAPI
BdsSetConsoleMode (
BOOLEAN IsSetupMode
)
{
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
UINTN SizeOfInfo;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
UINT32 MaxGopMode;
UINT32 MaxTextMode;
UINT32 ModeNumber;
UINT32 NewHorizontalResolution;
UINT32 NewVerticalResolution;
UINT32 NewColumns;
UINT32 NewRows;
UINTN HandleCount;
EFI_HANDLE *HandleBuffer;
EFI_STATUS Status;
UINTN Index;
UINTN CurrentColumn;
UINTN CurrentRow;
MaxGopMode = 0;
MaxTextMode = 0;
//
// Get current video resolution and text mode
//
Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiGraphicsOutputProtocolGuid,
(VOID**)&GraphicsOutput
);
if (EFI_ERROR (Status)) {
GraphicsOutput = NULL;
}
Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiSimpleTextOutProtocolGuid,
(VOID**)&SimpleTextOut
);
if (EFI_ERROR (Status)) {
SimpleTextOut = NULL;
}
if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) {
return EFI_UNSUPPORTED;
}
if (IsSetupMode) {
//
// The requried resolution and text mode is setup mode.
//
NewHorizontalResolution = mSetupHorizontalResolution;
NewVerticalResolution = mSetupVerticalResolution;
NewColumns = mSetupTextModeColumn;
NewRows = mSetupTextModeRow;
} else {
//
// The required resolution and text mode is boot mode.
//
NewHorizontalResolution = mBootHorizontalResolution;
NewVerticalResolution = mBootVerticalResolution;
NewColumns = mBootTextModeColumn;
NewRows = mBootTextModeRow;
}
if (GraphicsOutput != NULL) {
MaxGopMode = GraphicsOutput->Mode->MaxMode;
}
if (SimpleTextOut != NULL) {
MaxTextMode = SimpleTextOut->Mode->MaxMode;
}
//
// 1. If current video resolution is same with required video resolution,
// video resolution need not be changed.
// 1.1. If current text mode is same with required text mode, text mode need not be changed.
// 1.2. If current text mode is different from required text mode, text mode need be changed.
// 2. If current video resolution is different from required video resolution, we need restart whole console drivers.
//
for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {
Status = GraphicsOutput->QueryMode (
GraphicsOutput,
ModeNumber,
&SizeOfInfo,
//.........这里部分代码省略.........