Commit 447ae4f7adb2c667eec1e0861e2346694c57a2e0

Authored by Bin Meng
1 parent 611309383d

bootvx: x86: Make VxWorks EFI console driver happy

When booting from EFI BIOS, VxWorks bootloader stores the EFI GOP
framebuffer info at a pre-defined offset @ 0x6100. When VxWorks
kernel boots up, its EFI console driver tries to find such a block
and if the signature matches, the framebuffer information will be
used to initialize the driver.

However it is not necessary to prepare an EFI environment for
VxWorks's EFI console driver to function (eg: EFI loader in
U-Boot). If U-Boot has already initialized the graphics card and
set it to a VESA mode that is compatible with EFI GOP, we can
simply prepare such a block for VxWorks.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

Showing 2 changed files with 45 additions and 0 deletions Side-by-side Diff

... ... @@ -20,6 +20,7 @@
20 20 #include <net.h>
21 21 #include <vxworks.h>
22 22 #ifdef CONFIG_X86
  23 +#include <vbe.h>
23 24 #include <asm/e820.h>
24 25 #include <linux/linkage.h>
25 26 #endif
... ... @@ -254,6 +255,8 @@
254 255 ulong base;
255 256 struct e820_info *info;
256 257 struct e820_entry *data;
  258 + struct efi_gop_info *gop;
  259 + struct vesa_mode_info *vesa = &mode_info.vesa;
257 260 #endif
258 261  
259 262 /*
... ... @@ -397,6 +400,22 @@
397 400 * available memory size for the kernel is insane.
398 401 */
399 402 *(u32 *)(base + BOOT_IMAGE_SIZE_OFFSET) = 0;
  403 +
  404 + /*
  405 + * Prepare compatible framebuffer information block.
  406 + * The VESA mode has to be 32-bit RGBA.
  407 + */
  408 + if (vesa->x_resolution && vesa->y_resolution) {
  409 + gop = (struct efi_gop_info *)(base + EFI_GOP_INFO_OFFSET);
  410 + gop->magic = EFI_GOP_INFO_MAGIC;
  411 + gop->info.version = 0;
  412 + gop->info.width = vesa->x_resolution;
  413 + gop->info.height = vesa->y_resolution;
  414 + gop->info.pixel_format = EFI_GOT_RGBA8;
  415 + gop->info.pixels_per_scanline = vesa->bytes_per_scanline / 4;
  416 + gop->fb_base = vesa->phys_base_ptr;
  417 + gop->fb_size = vesa->bytes_per_scanline * vesa->y_resolution;
  418 + }
400 419 #endif
401 420  
402 421 /*
... ... @@ -8,6 +8,8 @@
8 8 #ifndef _VXWORKS_H_
9 9 #define _VXWORKS_H_
10 10  
  11 +#include <efi_api.h>
  12 +
11 13 /*
12 14 * Physical address of memory base for VxWorks x86
13 15 * This is LOCAL_MEM_LOCAL_ADRS in the VxWorks kernel configuration.
... ... @@ -51,6 +53,30 @@
51 53 * memory for the OS.
52 54 */
53 55 #define BOOT_IMAGE_SIZE_OFFSET 0x5004
  56 +
  57 +/*
  58 + * When booting from EFI BIOS, VxWorks bootloader stores the EFI GOP
  59 + * framebuffer info at a pre-defined offset @ 0x6100. When VxWorks kernel
  60 + * boots up, its EFI console driver tries to find such a block and if
  61 + * the signature matches, the framebuffer information will be used to
  62 + * initialize the driver.
  63 + *
  64 + * However it is not necessary to prepare an EFI environment for VxWorks's
  65 + * EFI console driver to function (eg: EFI loader in U-Boot). If U-Boot has
  66 + * already initialized the graphics card and set it to a VESA mode that is
  67 + * compatible with EFI GOP, we can simply prepare such a block for VxWorks.
  68 + */
  69 +#define EFI_GOP_INFO_OFFSET 0x6100
  70 +
  71 +/* EFI GOP info signatiure */
  72 +#define EFI_GOP_INFO_MAGIC 0xfeedface
  73 +
  74 +struct efi_gop_info {
  75 + u32 magic; /* signature */
  76 + struct efi_gop_mode_info info; /* EFI GOP mode info structure */
  77 + phys_addr_t fb_base; /* framebuffer base address */
  78 + u32 fb_size; /* framebuffer size */
  79 +};
54 80  
55 81 int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
56 82 void boot_prep_vxworks(bootm_headers_t *images);