[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/18] efi: create efi_find_gop_mode()
From: |
Daniel Kiper |
Subject: |
[PATCH 12/18] efi: create efi_find_gop_mode() |
Date: |
Fri, 30 Jan 2015 18:54:16 +0100 |
..which finds suitable GOP mode. We need this to support
multiboot2 protocol on EFI platforms.
Signed-off-by: Daniel Kiper <address@hidden>
---
xen/common/efi/boot.c | 94 ++++++++++++++++++++++++++++---------------------
1 file changed, 54 insertions(+), 40 deletions(-)
diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index 6bbcb3b..114019e 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -655,6 +655,58 @@ static EFI_GRAPHICS_OUTPUT_PROTOCOL __init
*efi_get_gop(void)
return gop;
}
+static UINTN __init efi_find_gop_mode(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop,
+ UINTN cols, UINTN rows, UINTN depth)
+{
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info;
+ EFI_STATUS status;
+ UINTN gop_mode = ~0, info_size, size;
+ unsigned int i;
+
+ if ( !gop )
+ return gop_mode;
+
+ for ( i = size = 0; i < gop->Mode->MaxMode; ++i )
+ {
+ unsigned int bpp = 0;
+
+ status = gop->QueryMode(gop, i, &info_size, &mode_info);
+ if ( EFI_ERROR(status) )
+ continue;
+ switch ( mode_info->PixelFormat )
+ {
+ case PixelBitMask:
+ bpp = hweight32(mode_info->PixelInformation.RedMask |
+ mode_info->PixelInformation.GreenMask |
+ mode_info->PixelInformation.BlueMask);
+ break;
+ case PixelRedGreenBlueReserved8BitPerColor:
+ case PixelBlueGreenRedReserved8BitPerColor:
+ bpp = 24;
+ break;
+ default:
+ continue;
+ }
+ if ( cols == mode_info->HorizontalResolution &&
+ rows == mode_info->VerticalResolution &&
+ (!depth || bpp == depth) )
+ {
+ gop_mode = i;
+ break;
+ }
+ if ( !cols && !rows &&
+ mode_info->HorizontalResolution *
+ mode_info->VerticalResolution > size )
+ {
+ size = mode_info->HorizontalResolution *
+ mode_info->VerticalResolution;
+ gop_mode = i;
+ }
+ }
+
+ return gop_mode;
+}
+
static void __init setup_efi_pci(void)
{
EFI_STATUS status;
@@ -966,46 +1018,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE
*SystemTable)
dir_handle->Close(dir_handle);
- if ( gop && !base_video )
- {
- for ( i = size = 0; i < gop->Mode->MaxMode; ++i )
- {
- unsigned int bpp = 0;
-
- status = gop->QueryMode(gop, i, &info_size, &mode_info);
- if ( EFI_ERROR(status) )
- continue;
- switch ( mode_info->PixelFormat )
- {
- case PixelBitMask:
- bpp = hweight32(mode_info->PixelInformation.RedMask |
- mode_info->PixelInformation.GreenMask |
- mode_info->PixelInformation.BlueMask);
- break;
- case PixelRedGreenBlueReserved8BitPerColor:
- case PixelBlueGreenRedReserved8BitPerColor:
- bpp = 24;
- break;
- default:
- continue;
- }
- if ( cols == mode_info->HorizontalResolution &&
- rows == mode_info->VerticalResolution &&
- (!depth || bpp == depth) )
- {
- gop_mode = i;
- break;
- }
- if ( !cols && !rows &&
- mode_info->HorizontalResolution *
- mode_info->VerticalResolution > size )
- {
- size = mode_info->HorizontalResolution *
- mode_info->VerticalResolution;
- gop_mode = i;
- }
- }
- }
+ if ( !base_video )
+ gop_mode = efi_find_gop_mode(gop, cols, rows, depth);
}
efi_arch_edd();
--
1.7.10.4
- Re: [Xen-devel] [PATCH 01/18] x86/boot/reloc: mask out MBI_BOOTDEV from mbi flags, (continued)
- [PATCH 02/18] x86/boot/reloc: create generic alloc and copy functions, Daniel Kiper, 2015/01/30
- [PATCH 03/18] x86/boot: use %ecx instead of %eax, Daniel Kiper, 2015/01/30
- [PATCH 04/18] xen/x86: add multiboot2 protocol support, Daniel Kiper, 2015/01/30
- [PATCH 05/18] efi: split efi_enabled to efi_platform and efi_loader, Daniel Kiper, 2015/01/30
- [PATCH 06/18] x86: remove commented out stale references to efi_enabled, Daniel Kiper, 2015/01/30
- [PATCH 08/18] efi: build xen.gz with EFI code, Daniel Kiper, 2015/01/30
- [PATCH 07/18] efi: run EFI specific code on EFI platform only, Daniel Kiper, 2015/01/30
- [PATCH 12/18] efi: create efi_find_gop_mode(),
Daniel Kiper <=
- [PATCH 09/18] efi: create efi_init(), Daniel Kiper, 2015/01/30
- [PATCH 10/18] efi: create efi_console_set_mode(), Daniel Kiper, 2015/01/30
- [PATCH 11/18] efi: create efi_get_gop(), Daniel Kiper, 2015/01/30
- [PATCH 13/18] efi: create efi_tables(), Daniel Kiper, 2015/01/30
- [PATCH 14/18] efi: create efi_variables(), Daniel Kiper, 2015/01/30
- [PATCH 16/18] efi: create efi_exit_boot(), Daniel Kiper, 2015/01/30
- [PATCH 15/18] efi: create efi_set_gop_mode(), Daniel Kiper, 2015/01/30
- [PATCH 17/18] x86/efi: create new early memory allocator, Daniel Kiper, 2015/01/30
- [PATCH 18/18] x86: add multiboot2 protocol support for EFI platforms, Daniel Kiper, 2015/01/30