This patch series fixes some bugs in the bootsplash code, and adds some cleanups. It is in preparation for turning bootsplash on by default.
Kevin O'Connor (6): Bootsplash fixes and cleanups. Check that malloc succeeds in bootsplash code. Don't do "double buffering" in bootsplash code. Add call16_int10 helper to bootsplash.c. Be sure to disable bootsplash on all BIOS boot cases. Cleanup bootsplash vesa signature detection.
src/biosvar.h | 3 +- src/boot.c | 8 +- src/bootsplash.c | 210 ++++++++++++++++++++++-------------------------------- src/post.c | 8 ++- src/util.h | 5 +- 5 files changed, 101 insertions(+), 133 deletions(-)
VESA structs must be in first 1Meg - so use malloc_tmplow().
Use 'struct segoff_s' for segment/offset pairs in vesa structs.
Don't call start/finish_preempt() around jpeg_decode() - the preempt only works when calling functions in 16bit mode.
Some indentation and debug output enhancements. --- src/bootsplash.c | 44 +++++++++++++++++++------------------------- src/util.h | 5 ++++- 2 files changed, 23 insertions(+), 26 deletions(-)
diff --git a/src/bootsplash.c b/src/bootsplash.c index 0b550ad..6302133 100644 --- a/src/bootsplash.c +++ b/src/bootsplash.c @@ -22,14 +22,14 @@ struct vesa_info { u8 vesa_signature[4]; u16 vesa_version; - u32 oem_string_ptr; + struct segoff_s oem_string_ptr; u8 capabilities[4]; - u32 video_mode_ptr; + struct segoff_s video_mode_ptr; u16 total_memory; u16 oem_software_rev; - u32 oem_vendor_name_ptr; - u32 oem_product_name_ptr; - u32 oem_product_rev_ptr; + struct segoff_s oem_vendor_name_ptr; + struct segoff_s oem_product_name_ptr; + struct segoff_s oem_product_rev_ptr; u8 reserved[222]; u8 oem_data[256]; } PACKED; @@ -123,8 +123,8 @@ void enable_vga_console(void) struct vesa_mode_info *mode_info; struct jpeg_decdata *decdata;
- vesa_info = malloc_tmphigh(sizeof(*vesa_info)); - mode_info = malloc_tmphigh(sizeof(*mode_info)); + vesa_info = malloc_tmplow(sizeof(*vesa_info)); + mode_info = malloc_tmplow(sizeof(*mode_info)); decdata = malloc_tmphigh(sizeof(*decdata));
/* Check whether we have a VESA 2.0 compliant BIOS */ @@ -146,16 +146,12 @@ void enable_vga_console(void) }
/* Print some debugging information about our card. */ - char *vendor, *product; - vendor = (char *)(((vesa_info->oem_vendor_name_ptr & 0xffff0000) >> 12) | - (vesa_info->oem_vendor_name_ptr & 0xffff)); - - product = (char *)(((vesa_info->oem_product_name_ptr & 0xffff0000) >> 12) | - (vesa_info->oem_product_name_ptr & 0xffff)); + char *vendor = SEGOFF_TO_FLATPTR(vesa_info->oem_vendor_name_ptr); + char *product = SEGOFF_TO_FLATPTR(vesa_info->oem_product_name_ptr);
dprintf(8, "VESA %d.%d\nVENDOR: %s\nPRODUCT: %s\n", - vesa_info->vesa_version>>8,vesa_info->vesa_version&0xff, - vendor, product); + vesa_info->vesa_version>>8, vesa_info->vesa_version&0xff, + vendor, product);
/* Get information about our graphics mode, like the * framebuffer start address @@ -197,9 +193,9 @@ void enable_vga_console(void) /* We use "double buffering" to make things look nicer */ framebuffer += imagesize;
- dprintf(9, "framebuffer: %x\n", (u32)framebuffer); - dprintf(9, "bytes per scanline: %d\n", mode_info->bytes_per_scanline); - dprintf(9, "bits per pixel: %d\n", mode_info->bits_per_pixel); + dprintf(8, "framebuffer: %x\n", (u32)framebuffer); + dprintf(8, "bytes per scanline: %d\n", mode_info->bytes_per_scanline); + dprintf(8, "bits per pixel: %d\n", mode_info->bits_per_pixel);
/* Look for bootsplash.jpg in CBFS and decompress it... */ int ret = 0; @@ -215,15 +211,13 @@ void enable_vga_console(void) dprintf(1, "Could not find boot splash screen "bootsplash.jpg"\n"); } if(jpeg) { - dprintf(9, "Copying boot splash screen...\n"); + dprintf(8, "Copying boot splash screen...\n"); cbfs_copyfile(file, jpeg, filesize); - dprintf(9, "Decompressing boot splash screen...\n"); - start_preempt(); + dprintf(8, "Decompressing boot splash screen...\n"); ret = jpeg_decode(jpeg, framebuffer, CONFIG_BOOTSPLASH_X, - CONFIG_BOOTSPLASH_Y, CONFIG_BOOTSPLASH_DEPTH, decdata); - finish_preempt(); + CONFIG_BOOTSPLASH_Y, CONFIG_BOOTSPLASH_DEPTH, decdata); if (ret) - dprintf(1, "Failed with return code %x...\n", ret); + dprintf(1, "Failed with return code %d...\n", ret); } else { ret = -1; } @@ -243,7 +237,7 @@ void enable_vga_console(void) call16_int(0x10, &br); finish_preempt(); if (br.ax != 0x4f) { - dprintf(1, "display_start failed.\n"); + dprintf(1, "display_start failed (ax=%04x).\n", br.ax); enable_vga_text_console(); }
diff --git a/src/util.h b/src/util.h index 63999e0..45896c6 100644 --- a/src/util.h +++ b/src/util.h @@ -414,6 +414,9 @@ static inline void *malloc_high(u32 size) { static inline void *malloc_fseg(u32 size) { return pmm_malloc(&ZoneFSeg, PMM_DEFAULT_HANDLE, size, MALLOC_MIN_ALIGN); } +static inline void *malloc_tmplow(u32 size) { + return pmm_malloc(&ZoneTmpLow, PMM_DEFAULT_HANDLE, size, MALLOC_MIN_ALIGN); +} static inline void *malloc_tmphigh(u32 size) { return pmm_malloc(&ZoneTmpHigh, PMM_DEFAULT_HANDLE, size, MALLOC_MIN_ALIGN); } @@ -421,7 +424,7 @@ static inline void *malloc_tmp(u32 size) { void *ret = malloc_tmphigh(size); if (ret) return ret; - return pmm_malloc(&ZoneTmpLow, PMM_DEFAULT_HANDLE, size, MALLOC_MIN_ALIGN); + return malloc_tmplow(size); } static inline void *memalign_low(u32 align, u32 size) { return pmm_malloc(&ZoneLow, PMM_DEFAULT_HANDLE, size, align);
Perform all the memory allocations up front and verify that all of them succeed. --- src/bootsplash.c | 81 ++++++++++++++++++++++++------------------------------ 1 files changed, 36 insertions(+), 45 deletions(-)
diff --git a/src/bootsplash.c b/src/bootsplash.c index 6302133..1b44355 100644 --- a/src/bootsplash.c +++ b/src/bootsplash.c @@ -112,25 +112,33 @@ static void enable_vga_text_console(void)
void enable_vga_console(void) { - /* Needs coreboot support for CBFS */ - if (!CONFIG_BOOTSPLASH || !CONFIG_COREBOOT) { - enable_vga_text_console(); - return; - } + struct vesa_info *vesa_info = NULL; + struct vesa_mode_info *mode_info = NULL; + struct jpeg_decdata *decdata = NULL; + unsigned char *jpeg = NULL;
- struct bregs br; - struct vesa_info *vesa_info; - struct vesa_mode_info *mode_info; - struct jpeg_decdata *decdata; + /* Needs coreboot support for CBFS */ + if (!CONFIG_BOOTSPLASH || !CONFIG_COREBOOT) + goto gotext; + struct cbfs_file *file = cbfs_finddatafile("bootsplash.jpg"); + if (!file) + goto gotext; + int filesize = cbfs_datasize(file);
+ jpeg = malloc_tmphigh(filesize); vesa_info = malloc_tmplow(sizeof(*vesa_info)); mode_info = malloc_tmplow(sizeof(*mode_info)); decdata = malloc_tmphigh(sizeof(*decdata)); + if (!jpeg || !vesa_info || !mode_info || !decdata) { + warn_noalloc(); + goto gotext; + }
/* Check whether we have a VESA 2.0 compliant BIOS */ memset(vesa_info, 0, sizeof(struct vesa_info)); memcpy(vesa_info, "VBE2", 4);
+ struct bregs br; memset(&br, 0, sizeof(br)); br.flags = F_IF; br.ax = 0x4f00; @@ -140,15 +148,14 @@ void enable_vga_console(void) call16_int(0x10, &br); finish_preempt();
- if(strcmp("VESA", (char *)vesa_info) != 0) { + if (strcmp("VESA", (char *)vesa_info) != 0) { dprintf(1,"No VBE2 found.\n"); - goto cleanup; + goto gotext; }
/* Print some debugging information about our card. */ char *vendor = SEGOFF_TO_FLATPTR(vesa_info->oem_vendor_name_ptr); char *product = SEGOFF_TO_FLATPTR(vesa_info->oem_product_name_ptr); - dprintf(8, "VESA %d.%d\nVENDOR: %s\nPRODUCT: %s\n", vesa_info->vesa_version>>8, vesa_info->vesa_version&0xff, vendor, product); @@ -167,8 +174,7 @@ void enable_vga_console(void) finish_preempt(); if (br.ax != 0x4f) { dprintf(1, "get_mode failed.\n"); - enable_vga_text_console(); - goto cleanup; + goto gotext; } unsigned char *framebuffer = (unsigned char *) (mode_info->phys_base_ptr);
@@ -182,8 +188,7 @@ void enable_vga_console(void) finish_preempt(); if (br.ax != 0x4f) { dprintf(1, "set_mode failed.\n"); - enable_vga_text_console(); - goto cleanup; + goto gotext; }
/* Switching Intel IGD to 1MB video memory will break this. Who cares. */ @@ -198,33 +203,14 @@ void enable_vga_console(void) dprintf(8, "bits per pixel: %d\n", mode_info->bits_per_pixel);
/* Look for bootsplash.jpg in CBFS and decompress it... */ - int ret = 0; - unsigned char *jpeg = NULL; - - struct cbfs_file *file = cbfs_finddatafile("bootsplash.jpg"); - int filesize = 0; - - if (file) { - filesize = cbfs_datasize(file); - jpeg = malloc_tmphigh(filesize); - } else { - dprintf(1, "Could not find boot splash screen "bootsplash.jpg"\n"); - } - if(jpeg) { - dprintf(8, "Copying boot splash screen...\n"); - cbfs_copyfile(file, jpeg, filesize); - dprintf(8, "Decompressing boot splash screen...\n"); - ret = jpeg_decode(jpeg, framebuffer, CONFIG_BOOTSPLASH_X, + dprintf(8, "Copying boot splash screen...\n"); + cbfs_copyfile(file, jpeg, filesize); + dprintf(8, "Decompressing boot splash screen...\n"); + int ret = jpeg_decode(jpeg, framebuffer, CONFIG_BOOTSPLASH_X, CONFIG_BOOTSPLASH_Y, CONFIG_BOOTSPLASH_DEPTH, decdata); - if (ret) - dprintf(1, "Failed with return code %d...\n", ret); - } else { - ret = -1; - } - free(jpeg); if (ret) { - enable_vga_text_console(); - goto cleanup; + dprintf(1, "jpeg_decode failed with return code %d...\n", ret); + goto gotext; }
/* Show the picture */ @@ -238,13 +224,18 @@ void enable_vga_console(void) finish_preempt(); if (br.ax != 0x4f) { dprintf(1, "display_start failed (ax=%04x).\n", br.ax); - enable_vga_text_console(); + goto gotext; }
cleanup: - free (vesa_info); - free (mode_info); - free (decdata); + free(jpeg); + free(vesa_info); + free(mode_info); + free(decdata); + return; +gotext: + enable_vga_text_console(); + goto cleanup; }
void
Not all vgabios support off screen framebuffers. Instead, decompress the picture into ram, and then copy it into the framebuffer. This ensures a fast display time without requiring any special vga support. --- src/bootsplash.c | 49 +++++++++---------------------------------------- 1 files changed, 9 insertions(+), 40 deletions(-)
diff --git a/src/bootsplash.c b/src/bootsplash.c index 1b44355..e2156f2 100644 --- a/src/bootsplash.c +++ b/src/bootsplash.c @@ -1,6 +1,7 @@ // Option rom scanning code. // // Copyright (C) 2009-2010 coresystems GmbH +// Copyright (C) 2010 Kevin O'Connor kevin@koconnor.net // // This file may be distributed under the terms of the GNU LGPLv3 license.
@@ -10,9 +11,6 @@ #include "util.h" // dprintf #include "jpeg.h" // splash
-/**************************************************************** - * Definitions - ****************************************************************/
/**************************************************************** * VESA structures @@ -91,21 +89,6 @@ static void enable_vga_text_console(void) call16_int(0x10, &br); finish_preempt();
- if (CONFIG_BOOTSPLASH) { - /* Switch back to start of the framebuffer - * (disable "double buffering") - */ - memset(&br, 0, sizeof(br)); - br.flags = F_IF; - br.ax = 0x4f07; - br.bl = 0x02; - br.ecx = 0; - - start_preempt(); - call16_int(0x10, &br); - finish_preempt(); - } - // Write to screen. printf("Starting SeaBIOS (version %s)\n\n", VERSION); } @@ -115,7 +98,7 @@ void enable_vga_console(void) struct vesa_info *vesa_info = NULL; struct vesa_mode_info *mode_info = NULL; struct jpeg_decdata *decdata = NULL; - unsigned char *jpeg = NULL; + u8 *jpeg = NULL, *picture = NULL;
/* Needs coreboot support for CBFS */ if (!CONFIG_BOOTSPLASH || !CONFIG_COREBOOT) @@ -125,11 +108,14 @@ void enable_vga_console(void) goto gotext; int filesize = cbfs_datasize(file);
+ int imagesize = (CONFIG_BOOTSPLASH_X * CONFIG_BOOTSPLASH_Y * + (CONFIG_BOOTSPLASH_DEPTH / 8)); jpeg = malloc_tmphigh(filesize); + picture = malloc_tmphigh(imagesize); vesa_info = malloc_tmplow(sizeof(*vesa_info)); mode_info = malloc_tmplow(sizeof(*mode_info)); decdata = malloc_tmphigh(sizeof(*decdata)); - if (!jpeg || !vesa_info || !mode_info || !decdata) { + if (!jpeg || !picture || !vesa_info || !mode_info || !decdata) { warn_noalloc(); goto gotext; } @@ -191,13 +177,6 @@ void enable_vga_console(void) goto gotext; }
- /* Switching Intel IGD to 1MB video memory will break this. Who cares. */ - int imagesize = CONFIG_BOOTSPLASH_X * CONFIG_BOOTSPLASH_Y * - (CONFIG_BOOTSPLASH_DEPTH / 8); - - /* We use "double buffering" to make things look nicer */ - framebuffer += imagesize; - dprintf(8, "framebuffer: %x\n", (u32)framebuffer); dprintf(8, "bytes per scanline: %d\n", mode_info->bytes_per_scanline); dprintf(8, "bits per pixel: %d\n", mode_info->bits_per_pixel); @@ -206,7 +185,7 @@ void enable_vga_console(void) dprintf(8, "Copying boot splash screen...\n"); cbfs_copyfile(file, jpeg, filesize); dprintf(8, "Decompressing boot splash screen...\n"); - int ret = jpeg_decode(jpeg, framebuffer, CONFIG_BOOTSPLASH_X, + int ret = jpeg_decode(jpeg, picture, CONFIG_BOOTSPLASH_X, CONFIG_BOOTSPLASH_Y, CONFIG_BOOTSPLASH_DEPTH, decdata); if (ret) { dprintf(1, "jpeg_decode failed with return code %d...\n", ret); @@ -214,21 +193,11 @@ void enable_vga_console(void) }
/* Show the picture */ - memset(&br, 0, sizeof(br)); - br.flags = F_IF; - br.ax = 0x4f07; - br.bl = 0x02; - br.ecx = imagesize; - start_preempt(); - call16_int(0x10, &br); - finish_preempt(); - if (br.ax != 0x4f) { - dprintf(1, "display_start failed (ax=%04x).\n", br.ax); - goto gotext; - } + iomemcpy(framebuffer, picture, imagesize);
cleanup: free(jpeg); + free(picture); free(vesa_info); free(mode_info); free(decdata);
--- src/bootsplash.c | 32 ++++++++++++++++---------------- 1 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/bootsplash.c b/src/bootsplash.c index e2156f2..b96e066 100644 --- a/src/bootsplash.c +++ b/src/bootsplash.c @@ -73,9 +73,21 @@ struct vesa_mode_info * Helper functions ****************************************************************/
+// Call int10 vga handler. +static void +call16_int10(struct bregs *br) +{ + br->flags = F_IF; + start_preempt(); + call16_int(0x10, br); + finish_preempt(); +} + + /**************************************************************** * VGA text / graphics console ****************************************************************/ + static void enable_vga_text_console(void) { dprintf(1, "Turning on vga text mode console\n"); @@ -83,11 +95,8 @@ static void enable_vga_text_console(void)
/* Enable VGA text mode */ memset(&br, 0, sizeof(br)); - br.flags = F_IF; br.ax = 0x0003; - start_preempt(); - call16_int(0x10, &br); - finish_preempt(); + call16_int10(&br);
// Write to screen. printf("Starting SeaBIOS (version %s)\n\n", VERSION); @@ -126,13 +135,10 @@ void enable_vga_console(void)
struct bregs br; memset(&br, 0, sizeof(br)); - br.flags = F_IF; br.ax = 0x4f00; br.di = FLATPTR_TO_OFFSET(vesa_info); br.es = FLATPTR_TO_SEG(vesa_info); - start_preempt(); - call16_int(0x10, &br); - finish_preempt(); + call16_int10(&br);
if (strcmp("VESA", (char *)vesa_info) != 0) { dprintf(1,"No VBE2 found.\n"); @@ -150,14 +156,11 @@ void enable_vga_console(void) * framebuffer start address */ memset(&br, 0, sizeof(br)); - br.flags = F_IF; br.ax = 0x4f01; br.cx = (1 << 14) | CONFIG_BOOTSPLASH_VESA_MODE; br.di = FLATPTR_TO_OFFSET(mode_info); br.es = FLATPTR_TO_SEG(mode_info); - start_preempt(); - call16_int(0x10, &br); - finish_preempt(); + call16_int10(&br); if (br.ax != 0x4f) { dprintf(1, "get_mode failed.\n"); goto gotext; @@ -166,12 +169,9 @@ void enable_vga_console(void)
/* Switch to graphics mode */ memset(&br, 0, sizeof(br)); - br.flags = F_IF; br.ax = 0x4f02; br.bx = (1 << 14) | CONFIG_BOOTSPLASH_VESA_MODE; - start_preempt(); - call16_int(0x10, &br); - finish_preempt(); + call16_int10(&br); if (br.ax != 0x4f) { dprintf(1, "set_mode failed.\n"); goto gotext;
Disable the bootsplash on cbfs payload exec, and if something hooks int19.
Also, be sure to only disable the bootsplash (revert to text mode) once. --- src/biosvar.h | 3 ++- src/boot.c | 8 ++++---- src/bootsplash.c | 9 ++++++--- src/post.c | 8 +++++++- 4 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/src/biosvar.h b/src/biosvar.h index dce35af..df0df0e 100644 --- a/src/biosvar.h +++ b/src/biosvar.h @@ -1,6 +1,6 @@ // Variable layouts of bios. // -// Copyright (C) 2008,2009 Kevin O'Connor kevin@koconnor.net +// Copyright (C) 2008-2010 Kevin O'Connor kevin@koconnor.net // // This file may be distributed under the terms of the GNU LGPLv3 license. #ifndef __BIOSVAR_H @@ -216,6 +216,7 @@ struct extended_bios_data_area_s { u8 other2[0xC4];
// 0x121 - Begin custom storage. + u8 bootsplash_active; u8 ps2ctr; struct usbkeyinfo usbkey_last;
diff --git a/src/boot.c b/src/boot.c index 814dee1..44964a7 100644 --- a/src/boot.c +++ b/src/boot.c @@ -1,6 +1,6 @@ // Code to load disk image and start system boot. // -// Copyright (C) 2008 Kevin O'Connor kevin@koconnor.net +// Copyright (C) 2008-2010 Kevin O'Connor kevin@koconnor.net // Copyright (C) 2002 MandrakeSoft S.A. // // This file may be distributed under the terms of the GNU LGPLv3 license. @@ -343,11 +343,10 @@ boot_prep(void) static void call_boot_entry(u16 bootseg, u16 bootip, u8 bootdrv) { - dprintf(1, "Booting from %04x:%04x\n", bootseg, bootip); - /* Go back to text, the OS might expect it... (Can't do this any later) */ disable_bootsplash();
+ dprintf(1, "Booting from %04x:%04x\n", bootseg, bootip); struct bregs br; memset(&br, 0, sizeof(br)); br.flags = F_IF; @@ -431,6 +430,7 @@ boot_cbfs(struct ipl_entry_s *ie) return; if (count--) continue; + disable_bootsplash(); cbfs_run_payload(file); } } @@ -462,7 +462,7 @@ do_boot(u16 seq_nr) printf("Booting from %s...\n" , strtcpy(desc, ie->description, ARRAY_SIZE(desc)));
- switch(ie->type) { + switch (ie->type) { case IPL_TYPE_FLOPPY: boot_disk(0x00, IPL.checkfloppysig); break; diff --git a/src/bootsplash.c b/src/bootsplash.c index b96e066..9ff81b3 100644 --- a/src/bootsplash.c +++ b/src/bootsplash.c @@ -10,6 +10,7 @@ #include "config.h" // CONFIG_* #include "util.h" // dprintf #include "jpeg.h" // splash +#include "biosvar.h" // SET_EBDA
/**************************************************************** @@ -99,7 +100,7 @@ static void enable_vga_text_console(void) call16_int10(&br);
// Write to screen. - printf("Starting SeaBIOS (version %s)\n\n", VERSION); + printf("SeaBIOS (version %s)\n\n", VERSION); }
void enable_vga_console(void) @@ -181,7 +182,7 @@ void enable_vga_console(void) dprintf(8, "bytes per scanline: %d\n", mode_info->bytes_per_scanline); dprintf(8, "bits per pixel: %d\n", mode_info->bits_per_pixel);
- /* Look for bootsplash.jpg in CBFS and decompress it... */ + /* Decompress jpeg */ dprintf(8, "Copying boot splash screen...\n"); cbfs_copyfile(file, jpeg, filesize); dprintf(8, "Decompressing boot splash screen...\n"); @@ -194,6 +195,7 @@ void enable_vga_console(void)
/* Show the picture */ iomemcpy(framebuffer, picture, imagesize); + SET_EBDA(bootsplash_active, 1);
cleanup: free(jpeg); @@ -210,7 +212,8 @@ gotext: void disable_bootsplash(void) { - if (! CONFIG_BOOTSPLASH) + if (! CONFIG_BOOTSPLASH || !GET_EBDA(bootsplash_active)) return; + SET_EBDA(bootsplash_active, 0); enable_vga_text_console(); } diff --git a/src/post.c b/src/post.c index fc7acc5..0cb9e57 100644 --- a/src/post.c +++ b/src/post.c @@ -1,6 +1,6 @@ // 32bit code to Power On Self Test (POST) a machine. // -// Copyright (C) 2008,2009 Kevin O'Connor kevin@koconnor.net +// Copyright (C) 2008-2010 Kevin O'Connor kevin@koconnor.net // Copyright (C) 2002 MandrakeSoft S.A. // // This file may be distributed under the terms of the GNU LGPLv3 license. @@ -276,6 +276,12 @@ _start(void) // Write protect bios memory. make_bios_readonly();
+ // Disable bootsplash if something has hooked int19. + extern void entry_19_official(void); + if (GET_IVT(0x19).segoff + != SEGOFF(SEG_BIOS, (u32)entry_19_official - BUILD_BIOS_ADDR).segoff) + disable_bootsplash(); + // Invoke int 19 to start boot process. dprintf(3, "Jump to int19\n"); struct bregs br;
--- src/bootsplash.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/bootsplash.c b/src/bootsplash.c index 9ff81b3..ed10415 100644 --- a/src/bootsplash.c +++ b/src/bootsplash.c @@ -19,7 +19,7 @@
struct vesa_info { - u8 vesa_signature[4]; + u32 vesa_signature; u16 vesa_version; struct segoff_s oem_string_ptr; u8 capabilities[4]; @@ -33,6 +33,9 @@ struct vesa_info u8 oem_data[256]; } PACKED;
+#define VESA_SIGNATURE 0x41534556 // VESA +#define VBE2_SIGNATURE 0x32454256 // VBE2 + struct vesa_mode_info { u16 mode_attributes; @@ -132,16 +135,14 @@ void enable_vga_console(void)
/* Check whether we have a VESA 2.0 compliant BIOS */ memset(vesa_info, 0, sizeof(struct vesa_info)); - memcpy(vesa_info, "VBE2", 4); - + vesa_info->vesa_signature = VBE2_SIGNATURE; struct bregs br; memset(&br, 0, sizeof(br)); br.ax = 0x4f00; br.di = FLATPTR_TO_OFFSET(vesa_info); br.es = FLATPTR_TO_SEG(vesa_info); call16_int10(&br); - - if (strcmp("VESA", (char *)vesa_info) != 0) { + if (vesa_info->vesa_signature != VESA_SIGNATURE) { dprintf(1,"No VBE2 found.\n"); goto gotext; }