From f3b2b7af08efd9872c973f47410b39de63490230 Mon Sep 17 00:00:00 2001 From: hpa Date: Mon, 18 Nov 2002 19:31:19 +0000 Subject: [PATCH] Fix MEMDISK initalization bugs --- NEWS | 4 ++++ memdisk/msetup.c | 24 ++++++++++++++---------- memdisk/setup.c | 22 ++++++++++++++++++---- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/NEWS b/NEWS index acaa087..42bd36f 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,10 @@ apply to that specific program only; other changes apply to all of them. Changes in 2.01: + * MEMDISK: Fix memory sizing bug when the ramdisk crosses the + 16 MB boundary. + * MEMDISK: Add a "pause" option to stop immediately before + booting, to read off the messages. * MEMDISK: Support disk images with DOSEMU headers. * Update the mkdiskimage script to handle newer mtools versions, and be able to generate disk images with DOSEMU diff --git a/memdisk/msetup.c b/memdisk/msetup.c index f9ed071..3c0b1c7 100644 --- a/memdisk/msetup.c +++ b/memdisk/msetup.c @@ -131,31 +131,35 @@ void get_mem(void) } } +#define PW(x) (1ULL << (x)) + void parse_mem(void) { struct e820range *ep; + dos_mem = low_mem = high_mem = 0; + /* Derive "dos mem", "high mem", and "low mem" from the range array */ for ( ep = ranges ; ep->type != -1 ; ep++ ) { if ( ep->type == 1 ) { /* Only look at memory ranges */ if ( ep->start == 0 ) { - if ( ep[1].start > 0x100000 ) - dos_mem = 0x100000; + if ( ep[1].start > PW(20) ) + dos_mem = PW(20); else dos_mem = ep[1].start; } - if ( ep->start <= 0x00100000 && ep[1].start > 0x00100000 ) { - if ( ep[1].start > 0x01000000 ) - low_mem = 0x01000000 - 0x00100000; + if ( ep->start <= PW(20) && ep[1].start > PW(20) ) { + if ( ep[1].start > PW(24) ) + low_mem = PW(24) - PW(20); else - low_mem = ep[1].start - 0x00100000; + low_mem = ep[1].start - PW(20); } - if ( ep->start <= 0x01000000 && ep[1].start > 0x01000000 ) { - if ( ep[1].start > 0x100000000 ) - high_mem = 0x100000000 - 0x01000000; + if ( ep->start <= PW(24) && ep[1].start > PW(24) ) { + if ( ep[1].start > PW(32) ) + high_mem = PW(32) - PW(24); else - high_mem = ep[1].start - 0x01000000; + high_mem = ep[1].start - PW(24); } } } diff --git a/memdisk/setup.c b/memdisk/setup.c index b96b431..249d847 100644 --- a/memdisk/setup.c +++ b/memdisk/setup.c @@ -572,6 +572,13 @@ uint32_t setup(void) insertrange(driveraddr, dos_mem-driveraddr, 2); parse_mem(); + printf("dos_mem = %#10x (%u K)\n" + "low_mem = %#10x (%u K)\n" + "high_mem = %#10x (%u K)\n", + dos_mem, dos_mem >> 10, + low_mem, low_mem >> 10, + high_mem, high_mem >> 10); + pptr->mem1mb = low_mem >> 10; pptr->mem16mb = high_mem >> 16; if ( low_mem == (15 << 20) ) { @@ -582,9 +589,8 @@ uint32_t setup(void) pptr->memint1588 = low_mem >> 10; } - printf("mem1mb = %5u (0x%04x)\n", pptr->mem1mb, pptr->mem1mb); - printf("mem16mb = %5u (0x%04x)\n", pptr->mem16mb, pptr->mem16mb); - printf("mem1588 = %5u (0x%04x)\n", pptr->memint1588, pptr->memint1588); + printf("1588: 0x%04x 15E801: 0x%04x 0x%04x\n", + pptr->memint1588, pptr->mem1mb, pptr->mem16mb); driverseg = driveraddr >> 4; driverptr = driverseg << 16; @@ -622,7 +628,7 @@ uint32_t setup(void) : "esi", "ebx", "ebp"); if ( cf ) { - printf("INT 13 08: Failure\n"); + printf("INT 13 08: Failure, assuming this is the only drive\n"); pptr->drivecnt = 1; } else { printf("INT 13 08: Success, count = %u, BPT = %04x:%04x\n", @@ -705,6 +711,14 @@ uint32_t setup(void) die(); } + if ( getcmditem("pause") != CMD_NOTFOUND ) { + puts("Press any key to boot... "); + asm volatile("pushal ; " + "xorw %ax,%ax ; " + "int $0x16 ; " + "popal"); + } + puts("Booting...\n"); /* On return the assembly code will jump to the boot vector */ -- 2.7.4