本文整理汇总了C++中EFI_GRAPHICS_OUTPUT_PROTOCOL::SetMode方法的典型用法代码示例。如果您正苦于以下问题:C++ EFI_GRAPHICS_OUTPUT_PROTOCOL::SetMode方法的具体用法?C++ EFI_GRAPHICS_OUTPUT_PROTOCOL::SetMode怎么用?C++ EFI_GRAPHICS_OUTPUT_PROTOCOL::SetMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EFI_GRAPHICS_OUTPUT_PROTOCOL
的用法示例。
在下文中一共展示了EFI_GRAPHICS_OUTPUT_PROTOCOL::SetMode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FreePool
//.........这里部分代码省略.........
Status = GraphicsOutput->QueryMode (
GraphicsOutput,
ModeNumber,
&SizeOfInfo,
&Info
);
if (!EFI_ERROR (Status)) {
if ((Info->HorizontalResolution == NewHorizontalResolution) &&
(Info->VerticalResolution == NewVerticalResolution)) {
if ((GraphicsOutput->Mode->Info->HorizontalResolution == NewHorizontalResolution) &&
(GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution)) {
//
// Current resolution is same with required resolution, check if text mode need be set
//
Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);
ASSERT_EFI_ERROR (Status);
if (CurrentColumn == NewColumns && CurrentRow == NewRows) {
//
// If current text mode is same with required text mode. Do nothing
//
FreePool (Info);
return EFI_SUCCESS;
} else {
//
// If current text mode is different from requried text mode. Set new video mode
//
for (Index = 0; Index < MaxTextMode; Index++) {
Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);
if (!EFI_ERROR(Status)) {
if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {
//
// Required text mode is supported, set it.
//
Status = SimpleTextOut->SetMode (SimpleTextOut, Index);
ASSERT_EFI_ERROR (Status);
//
// Update text mode PCD.
//
Status = PcdSet32S (PcdConOutColumn, mBmSetupTextModeColumn);
ASSERT_EFI_ERROR (Status);
Status = PcdSet32S (PcdConOutRow, mBmSetupTextModeRow);
ASSERT_EFI_ERROR (Status);
FreePool (Info);
return EFI_SUCCESS;
}
}
}
if (Index == MaxTextMode) {
//
// If requried text mode is not supported, return error.
//
FreePool (Info);
return EFI_UNSUPPORTED;
}
}
} else {
//
// If current video resolution is not same with the new one, set new video resolution.
// In this case, the driver which produces simple text out need be restarted.
//
Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);
if (!EFI_ERROR (Status)) {
FreePool (Info);
break;
}
}
示例2: SetMode
/**
Set the current video mode information.
@param This The EFI_UGA_DRAW_PROTOCOL instance.
@param HorizontalResolution The size of video screen in pixels in the X dimension.
@param VerticalResolution The size of video screen in pixels in the Y dimension.
@param ColorDepth Number of bits per pixel, currently defined to be 32.
@param RefreshRate The refresh rate of the monitor in Hertz.
@retval EFI_SUCCESS Mode information returned.
@retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()
@retval EFI_OUT_OF_RESOURCES Out of resources.
**/
EFI_STATUS
EFIAPI
ConSplitterUgaDrawSetMode (
IN EFI_UGA_DRAW_PROTOCOL *This,
IN UINT32 HorizontalResolution,
IN UINT32 VerticalResolution,
IN UINT32 ColorDepth,
IN UINT32 RefreshRate
)
{
EFI_STATUS Status;
TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
UINTN Index;
EFI_STATUS ReturnStatus;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
UINTN NumberIndex;
UINTN SizeOfInfo;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
EFI_UGA_DRAW_PROTOCOL *UgaDraw;
Private = UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
ReturnStatus = EFI_SUCCESS;
//
// Update the Mode data
//
Private->UgaHorizontalResolution = HorizontalResolution;
Private->UgaVerticalResolution = VerticalResolution;
Private->UgaColorDepth = ColorDepth;
Private->UgaRefreshRate = RefreshRate;
//
// return the worst status met
//
for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;
if (GraphicsOutput != NULL) {
//
// Find corresponding ModeNumber of this GraphicsOutput instance
//
for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex ++) {
Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info);
if (EFI_ERROR (Status)) {
return Status;
}
if ((Info->HorizontalResolution == HorizontalResolution) && (Info->VerticalResolution == VerticalResolution)) {
FreePool (Info);
break;
}
FreePool (Info);
}
Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32) NumberIndex);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
}
} else if (FeaturePcdGet (PcdUgaConsumeSupport)){
UgaDraw = Private->TextOutList[Index].UgaDraw;
if (UgaDraw != NULL) {
Status = UgaDraw->SetMode (
UgaDraw,
HorizontalResolution,
VerticalResolution,
ColorDepth,
RefreshRate
);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
}
}
}
}
return ReturnStatus;
}
示例3: FreePool
/**
Set the video device into the specified mode and clears the visible portions of
the output display to black.
@param This The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.
@param ModeNumber Abstraction that defines the current video mode.
@retval EFI_SUCCESS The graphics mode specified by ModeNumber was selected.
@retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
@retval EFI_UNSUPPORTED ModeNumber is not supported by this device.
@retval EFI_OUT_OF_RESOURCES No resource available.
**/
EFI_STATUS
EFIAPI
ConSplitterGraphicsOutputSetMode (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This,
IN UINT32 ModeNumber
)
{
EFI_STATUS Status;
TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
UINTN Index;
EFI_STATUS ReturnStatus;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Mode;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
UINTN NumberIndex;
UINTN SizeOfInfo;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
EFI_UGA_DRAW_PROTOCOL *UgaDraw;
if (ModeNumber >= This->Mode->MaxMode) {
return EFI_UNSUPPORTED;
}
Private = GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
Mode = &Private->GraphicsOutputModeBuffer[ModeNumber];
ReturnStatus = EFI_SUCCESS;
//
// return the worst status met
//
for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;
if (GraphicsOutput != NULL) {
//
// Find corresponding ModeNumber of this GraphicsOutput instance
//
for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex ++) {
Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info);
if (EFI_ERROR (Status)) {
return Status;
}
if ((Info->HorizontalResolution == Mode->HorizontalResolution) && (Info->VerticalResolution == Mode->VerticalResolution)) {
FreePool (Info);
break;
}
FreePool (Info);
}
Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32) NumberIndex);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
}
} else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
UgaDraw = Private->TextOutList[Index].UgaDraw;
if (UgaDraw != NULL) {
Status = UgaDraw->SetMode (
UgaDraw,
Mode->HorizontalResolution,
Mode->VerticalResolution,
32,
60
);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
}
}
}
}
This->Mode->Mode = ModeNumber;
CopyMem (This->Mode->Info, &Private->GraphicsOutputModeBuffer[ModeNumber], This->Mode->SizeOfInfo);
//
// Information is not enough here, so the following items remain unchanged:
// GraphicsOutputMode->Info->Version, GraphicsOutputMode->Info->PixelFormat
// GraphicsOutputMode->SizeOfInfo, GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize
// These items will be initialized/updated when a new GOP device is added into ConsoleSplitter.
//
return ReturnStatus;
}
示例4: sizeof
EFI_STATUS
QemuVideoGraphicsOutputConstructor (
QEMU_VIDEO_PRIVATE_DATA *Private
)
{
EFI_STATUS Status;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
GraphicsOutput = &Private->GraphicsOutput;
GraphicsOutput->QueryMode = QemuVideoGraphicsOutputQueryMode;
GraphicsOutput->SetMode = QemuVideoGraphicsOutputSetMode;
GraphicsOutput->Blt = QemuVideoGraphicsOutputBlt;
//
// Initialize the private data
//
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE),
(VOID **) &Private->GraphicsOutput.Mode
);
if (EFI_ERROR (Status)) {
return Status;
}
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),
(VOID **) &Private->GraphicsOutput.Mode->Info
);
if (EFI_ERROR (Status)) {
goto FreeMode;
}
Private->GraphicsOutput.Mode->MaxMode = (UINT32) Private->MaxMode;
Private->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;
Private->FrameBufferBltConfigure = NULL;
Private->FrameBufferBltConfigureSize = 0;
//
// Initialize the hardware
//
Status = GraphicsOutput->SetMode (GraphicsOutput, 0);
if (EFI_ERROR (Status)) {
goto FreeInfo;
}
DrawLogo (
Private,
Private->ModeData[Private->GraphicsOutput.Mode->Mode].HorizontalResolution,
Private->ModeData[Private->GraphicsOutput.Mode->Mode].VerticalResolution
);
return EFI_SUCCESS;
FreeInfo:
FreePool (Private->GraphicsOutput.Mode->Info);
FreeMode:
FreePool (Private->GraphicsOutput.Mode);
Private->GraphicsOutput.Mode = NULL;
return Status;
}
示例5: DEBUG
EFI_STATUS
VBoxVgaGraphicsOutputConstructor (
VBOX_VGA_PRIVATE_DATA *Private
)
{
EFI_STATUS Status;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
UINT32 Index;
UINT32 HorizontalResolution = 1024;
UINT32 VerticalResolution = 768;
UINT32 ColorDepth = 32;
DEBUG((DEBUG_INFO, "%a:%d construct\n", __FILE__, __LINE__));
GraphicsOutput = &Private->GraphicsOutput;
GraphicsOutput->QueryMode = VBoxVgaGraphicsOutputQueryMode;
GraphicsOutput->SetMode = VBoxVgaGraphicsOutputSetMode;
GraphicsOutput->Blt = VBoxVgaGraphicsOutputBlt;
//
// Initialize the private data
//
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE),
(VOID **) &Private->GraphicsOutput.Mode
);
if (EFI_ERROR (Status)) {
return Status;
}
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),
(VOID **) &Private->GraphicsOutput.Mode->Info
);
if (EFI_ERROR (Status)) {
return Status;
}
Private->GraphicsOutput.Mode->MaxMode = (UINT32) Private->MaxMode;
Private->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;
Private->HardwareNeedsStarting = TRUE;
//
// Initialize the hardware
//
VBoxVgaGetVmVariable(EFI_INFO_INDEX_HORIZONTAL_RESOLUTION, (CHAR8 *)&HorizontalResolution,
sizeof(HorizontalResolution));
VBoxVgaGetVmVariable(EFI_INFO_INDEX_VERTICAL_RESOLUTION, (CHAR8 *)&VerticalResolution,
sizeof(VerticalResolution));
for (Index = 0; Index < Private->MaxMode; Index++)
{
if ( HorizontalResolution == Private->ModeData[Index].HorizontalResolution
&& VerticalResolution == Private->ModeData[Index].VerticalResolution
&& ColorDepth == Private->ModeData[Index].ColorDepth)
break;
}
// not found? try mode number
if (Index >= Private->MaxMode)
{
VBoxVgaGetVmVariable(EFI_INFO_INDEX_GRAPHICS_MODE, (CHAR8 *)&Index, sizeof(Index));
// try with mode 2 (usually 1024x768) as a fallback
if (Index >= Private->MaxMode)
Index = 2;
// try with mode 0 (usually 640x480) as a fallback
if (Index >= Private->MaxMode)
Index = 0;
}
// skip mode setting completely if there is no valid mode
if (Index >= Private->MaxMode)
return EFI_UNSUPPORTED;
GraphicsOutput->SetMode (GraphicsOutput, Index);
DrawLogo (
Private,
Private->ModeData[Private->GraphicsOutput.Mode->Mode].HorizontalResolution,
Private->ModeData[Private->GraphicsOutput.Mode->Mode].VerticalResolution
);
PcdSet32S(PcdVideoHorizontalResolution, Private->ModeData[Private->GraphicsOutput.Mode->Mode].HorizontalResolution);
PcdSet32S(PcdVideoVerticalResolution, Private->ModeData[Private->GraphicsOutput.Mode->Mode].VerticalResolution);
return EFI_SUCCESS;
}
示例6: RGB
/**
* efi_main - The entry point for the EFI application
* @image: firmware-allocated handle that identifies the image
* @SystemTable: EFI system table
*/
EFI_STATUS
efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systemTable)
{
EFI_BOOT_SERVICES *bs = systemTable->BootServices;
EFI_GRAPHICS_OUTPUT_PROTOCOL *graphicsProtocol;
SIMPLE_TEXT_OUTPUT_INTERFACE *conOut = systemTable->ConOut;
EFI_EVENT event = systemTable->ConIn->WaitForKey;
UINTN index;
int i, modeCount;
EFI_STATUS status = bs->LocateProtocol(&GraphicsOutputProtocolGUID, NULL,
(void**)&graphicsProtocol);
if (EFI_ERROR(status) || graphicsProtocol == NULL) {
conOut->OutputString(conOut, L"Failed to init gfx!\r\n");
return status;
}
//Switch to current mode so gfx is started.
status = graphicsProtocol->SetMode(graphicsProtocol, graphicsProtocol->Mode->Mode);
if (EFI_ERROR(status)) {
conOut->OutputString(conOut, L"Failed to set default mode!\r\n");
return status;
}
conOut->OutputString(conOut, L"Current mode: ");
printInt(conOut, graphicsProtocol->Mode->Mode);
conOut->OutputString(conOut, L"\r\n");
modeCount = graphicsProtocol->Mode->MaxMode;
for (i = 0; i < modeCount; i++) {
conOut->OutputString(conOut, L"\r\n");
printInt(conOut, i);
conOut->OutputString(conOut, L": ");
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info;
UINTN SizeOfInfo;
status = graphicsProtocol->QueryMode(graphicsProtocol, i, &SizeOfInfo, &info);
if (EFI_ERROR(status)) {
conOut->OutputString(conOut, L" Failure to query mode: ");
printInt(conOut, status);
continue;
}
printInt(conOut, info->HorizontalResolution);
conOut->OutputString(conOut, L" x ");
printInt(conOut, info->VerticalResolution);
switch(info->PixelFormat) {
case PixelRedGreenBlueReserved8BitPerColor:
conOut->OutputString(conOut, L" RGB(R)");
break;
case PixelBlueGreenRedReserved8BitPerColor:
conOut->OutputString(conOut, L" BGR(R)");
break;
case PixelBitMask:
conOut->OutputString(conOut, L" BitMask ");
printInt(conOut, info->PixelInformation.RedMask);
conOut->OutputString(conOut, L"R ");
printInt(conOut, info->PixelInformation.GreenMask);
conOut->OutputString(conOut, L"G ");
printInt(conOut, info->PixelInformation.BlueMask);
conOut->OutputString(conOut, L"B ");
printInt(conOut, info->PixelInformation.ReservedMask);
conOut->OutputString(conOut, L"Reserved ");
break;
case PixelBltOnly:
conOut->OutputString(conOut, L" (blt only)");
break;
default:
conOut->OutputString(conOut, L" (Invalid pixel format)");
break;
}
conOut->OutputString(conOut, L" Pixel per scanline: ");
printInt(conOut, info->PixelsPerScanLine);
}
bs->WaitForEvent(1, &event, &index);
return EFI_SUCCESS;
}
示例7: SetMode
//
// TDS 4.2.2
//
EFI_STATUS
BBTestSetModeConformanceAutoTest (
IN EFI_BB_TEST_PROTOCOL *This,
IN VOID *ClientInterface,
IN EFI_TEST_LEVEL TestLevel,
IN EFI_HANDLE SupportHandle
)
/*++
Routine Description:
Entrypoint for EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode() Conformance Test
Arguments:
This - A pointer of EFI_BB_TEST_PROTOCOL
ClientInterface - A pointer to the interface to be tested
TestLevel - Test "thoroughness" control
SupportHandle - A handle containing protocols required
Returns:
EFI_SUCCESS - Finish the test successfully
--*/
{
EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;
EFI_STATUS Status;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
EFI_TEST_ASSERTION AssertionType;
UINT32 Index;
UINT32 CurrentMode;
UINT32 MaxMode;
UINTN sizeofInfo;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info;
GraphicsOutput = (EFI_GRAPHICS_OUTPUT_PROTOCOL *) ClientInterface;
CurrentMode = GraphicsOutput->Mode->Mode;
if ((Status = InitTestEnv (SupportHandle, &StandardLib, GraphicsOutput)) != EFI_SUCCESS) {
return Status;
}
//
// Assertion Point
//
//
MaxMode = GraphicsOutput->Mode->MaxMode;
for (Index = 0; Index < MaxMode; Index++) {
Status = GraphicsOutput->SetMode (
GraphicsOutput,
Index
);
if (Status == EFI_UNSUPPORTED) {
AssertionType = EFI_TEST_ASSERTION_FAILED;
} else {
AssertionType = EFI_TEST_ASSERTION_PASSED;
}
StandardLib->RecordAssertion (
StandardLib,
AssertionType,
gGraphicsOutputSetModeConformanceTestAssertionGuid001,
L"EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode - SetMode() with valid mode",
L"%a:%d: mode:%d,Status = %r,Expected = not EFI_UNSUPPORTED ",
__FILE__,
(UINTN)__LINE__,
Index,
Status
);
//
// Check the content of info
//
if (Status == EFI_SUCCESS) {
sizeofInfo = 0;
info = NULL;
Status = GraphicsOutput->QueryMode (
GraphicsOutput,
Index,
&sizeofInfo,
&info
);
if (Status != EFI_SUCCESS) {
AssertionType = EFI_TEST_ASSERTION_FAILED;
} else {
AssertionType = EFI_TEST_ASSERTION_PASSED;
}
if (EfiCompareMem (
(void *) info,
(void *) GraphicsOutput->Mode->Info,
//.........这里部分代码省略.........
示例8: sizeof
EFI_STATUS
QemuVideoGraphicsOutputConstructor (
QEMU_VIDEO_PRIVATE_DATA *Private
)
{
EFI_STATUS Status;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
UINT32 ModeNumber;
UINT32 InitialModeNumber;
GraphicsOutput = &Private->GraphicsOutput;
GraphicsOutput->QueryMode = QemuVideoGraphicsOutputQueryMode;
GraphicsOutput->SetMode = QemuVideoGraphicsOutputSetMode;
GraphicsOutput->Blt = QemuVideoGraphicsOutputBlt;
//
// Initialize the private data
//
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE),
(VOID **) &Private->GraphicsOutput.Mode
);
if (EFI_ERROR (Status)) {
return Status;
}
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),
(VOID **) &Private->GraphicsOutput.Mode->Info
);
if (EFI_ERROR (Status)) {
goto FreeMode;
}
Private->GraphicsOutput.Mode->MaxMode = (UINT32) Private->MaxMode;
Private->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;
Private->LineBuffer = NULL;
//
// Initialize the hardware
//
// Search for 800x600 resolution for initial mode
InitialModeNumber = 0;
for (ModeNumber = 0; ModeNumber < Private->MaxMode; ModeNumber++) {
if (Private->ModeData[ModeNumber].HorizontalResolution == 800 && Private->ModeData[ModeNumber].VerticalResolution == 600) {
InitialModeNumber = ModeNumber;
break;
}
}
Status = GraphicsOutput->SetMode (GraphicsOutput, InitialModeNumber);
if (EFI_ERROR (Status)) {
goto FreeInfo;
}
DrawLogo (
Private,
Private->ModeData[Private->GraphicsOutput.Mode->Mode].HorizontalResolution,
Private->ModeData[Private->GraphicsOutput.Mode->Mode].VerticalResolution
);
return EFI_SUCCESS;
FreeInfo:
FreePool (Private->GraphicsOutput.Mode->Info);
FreeMode:
FreePool (Private->GraphicsOutput.Mode);
Private->GraphicsOutput.Mode = NULL;
return Status;
}