diff options
Diffstat (limited to 'com32/mboot')
-rw-r--r-- | com32/mboot/Makefile | 2 | ||||
-rw-r--r-- | com32/mboot/initvesa.c | 43 | ||||
-rw-r--r-- | com32/mboot/mem.c | 35 |
3 files changed, 50 insertions, 30 deletions
diff --git a/com32/mboot/Makefile b/com32/mboot/Makefile index b7ee1154..6e010b1c 100644 --- a/com32/mboot/Makefile +++ b/com32/mboot/Makefile @@ -17,7 +17,7 @@ topdir = ../.. MAKEDIR = $(topdir)/mk -include $(MAKEDIR)/com32.mk +include $(MAKEDIR)/elf.mk LNXLIBS = ../libutil/libutil_lnx.a diff --git a/com32/mboot/initvesa.c b/com32/mboot/initvesa.c index cf2707df..bd869e3d 100644 --- a/com32/mboot/initvesa.c +++ b/com32/mboot/initvesa.c @@ -38,6 +38,7 @@ #include <stdlib.h> #include <string.h> #include <limits.h> +#include <graphics.h> #include "vesa.h" #include "mboot.h" @@ -61,9 +62,13 @@ void set_graphics_mode(const struct multiboot_header *mbh, if (!(mbh->flags & MULTIBOOT_VIDEO_MODE) || mbh->mode_type != 0) return; - /* Allocate space in the bounce buffer for these structures */ - gi = &((struct vesa_info *)__com32.cs_bounce)->gi; - mi = &((struct vesa_info *)__com32.cs_bounce)->mi; + gi = lmalloc(sizeof *gi); + if (!gi) + return; + + mi = lmalloc(sizeof *mi); + if (!mi) + goto out; memset(&rm, 0, sizeof rm); memset(gi, 0, sizeof *gi); @@ -75,11 +80,11 @@ void set_graphics_mode(const struct multiboot_header *mbh, __intcall(0x10, &rm, &rm); if (rm.eax.w[0] != 0x004F) - return; /* Function call failed */ + goto out; /* Function call failed */ if (gi->signature != VESA_MAGIC) - return; /* No magic */ + goto out; /* No magic */ if (gi->version < 0x0102) - return; /* VESA 1.2+ required */ + goto out; /* VESA 1.2+ required */ memcpy(&vesa_info.gi, gi, sizeof *gi); @@ -182,7 +187,7 @@ void set_graphics_mode(const struct multiboot_header *mbh, } if (!bestpxf) - return; /* No mode found */ + goto out; /* No mode found */ mi = &vesa_info.mi; mode = bestmode; @@ -193,7 +198,7 @@ void set_graphics_mode(const struct multiboot_header *mbh, rm.ebx.w[0] = mode; __intcall(0x10, &rm, &rm); if (rm.eax.w[0] != 0x004F) - return; /* Failed to set mode */ + goto out; /* Failed to set mode */ mbi->flags |= MB_INFO_VIDEO_INFO; mbi->vbe_mode = mode; @@ -211,16 +216,16 @@ void set_graphics_mode(const struct multiboot_header *mbh, mbi->vbe_interface_len = rm.ecx.w[0]; } - /* Tell syslinux we changed video mode */ - rm.eax.w[0] = 0x0017; /* Report video mode change */ /* In theory this should be: - - rm.ebx.w[0] = (mi->mode_attr & 4) ? 0x0007 : 0x000f; - - However, that would assume all systems that claim to handle text - output in VESA modes actually do that... */ - rm.ebx.w[0] = 0x000f; - rm.ecx.w[0] = vesa_info.mi.h_res; - rm.edx.w[0] = vesa_info.mi.v_res; - __intcall(0x22, &rm, NULL); + * + * UsingVga = (mi->mode_attr & 4) ? 0x0007 : 0x000f; + * + * However, that would assume all systems that claim to handle text + * output in VESA modes actually do that... + */ + graphics_using_vga(0x0F, vesa_info.mi.h_res, vesa_info.mi.v_res); + +out: + lfree(mi); + lfree(gi); } diff --git a/com32/mboot/mem.c b/com32/mboot/mem.c index 6a31fac0..6e3995bf 100644 --- a/com32/mboot/mem.c +++ b/com32/mboot/mem.c @@ -49,9 +49,10 @@ struct e820_entry { static int mboot_scan_memory(struct AddrRangeDesc **ardp, uint32_t * dosmem) { com32sys_t ireg, oreg; - struct e820_entry *e820buf = __com32.cs_bounce; + struct e820_entry *e820buf; struct AddrRangeDesc *ard; size_t ard_count, ard_space; + int rv = 0; /* Use INT 12h to get DOS memory */ __intcall(0x12, &__com32_zero_regs, &oreg); @@ -65,10 +66,14 @@ static int mboot_scan_memory(struct AddrRangeDesc **ardp, uint32_t * dosmem) *dosmem = 640 * 1024; /* Hope for the best... */ } + e820buf = lmalloc(sizeof(*e820buf)); + if (!e820buf) + return 0; + /* Allocate initial space */ *ardp = ard = malloc(RANGE_ALLOC_BLOCK * sizeof *ard); if (!ard) - return 0; + goto out; ard_count = 0; ard_space = RANGE_ALLOC_BLOCK; @@ -93,8 +98,10 @@ static int mboot_scan_memory(struct AddrRangeDesc **ardp, uint32_t * dosmem) if (ard_count >= ard_space) { ard_space += RANGE_ALLOC_BLOCK; *ardp = ard = realloc(ard, ard_space * sizeof *ard); - if (!ard) - return ard_count; + if (!ard) { + rv = ard_count; + goto out; + } } ard[ard_count].size = 20; @@ -106,8 +113,10 @@ static int mboot_scan_memory(struct AddrRangeDesc **ardp, uint32_t * dosmem) ireg.ebx.l = oreg.ebx.l; } while (oreg.ebx.l); - if (ard_count) - return ard_count; + if (ard_count) { + rv = ard_count; + goto out; + }; ard[0].size = 20; ard[0].BaseAddr = 0; @@ -129,10 +138,12 @@ static int mboot_scan_memory(struct AddrRangeDesc **ardp, uint32_t * dosmem) ard[2].BaseAddr = 16 << 20; ard[2].Length = oreg.edx.w[0] << 16; ard[2].Type = 1; - return 3; + rv = 3; } else { - return 2; + rv = 2; } + + goto out; } /* Finally try INT 15h AH=88h */ @@ -142,10 +153,14 @@ static int mboot_scan_memory(struct AddrRangeDesc **ardp, uint32_t * dosmem) ard[1].BaseAddr = 1 << 20; ard[1].Length = oreg.ecx.w[0] << 10; ard[1].Type = 1; - return 2; + rv = 2; + goto out; } - return 1; /* ... problematic ... */ + rv = 1; /* ... problematic ... */ +out: + lfree(e820buf); + return rv; } void mboot_make_memmap(void) |