diff --git a/elks/arch/i86/boot/setup.S b/elks/arch/i86/boot/setup.S index 46fd92d4a..c7db93a12 100644 --- a/elks/arch/i86/boot/setup.S +++ b/elks/arch/i86/boot/setup.S @@ -94,8 +94,8 @@ debug_loader = 0 // display relocations #define KERNEL_MAGICNUMBER MINIX_SPLITID_LOW #ifndef CONFIG_ROMCODE - INITSEG = DEF_INITSEG // initial setup data seg, we move boot here - out of the way - SYSSEG = DEF_SYSSEG // first kernel blob load point before relocation + INITSEG = DEF_INITSEG // initial setup data seg and initial Image load address + SYSSEG = DEF_SYSSEG // first kernel blob copy load point before relocation SETUPSEG = DEF_SETUPSEG // this is the current code segment #else INITSEG = CONFIG_ROM_SETUP_DATA @@ -245,8 +245,7 @@ done_move_kernel: cld mov $INITSEG,%ax mov %ax,%ss - //mov $0x4000-12,%sp - mov $0x1000,%sp // 2K stack: 0x0800 setup size + 0x0800 stack + mov $0x1000,%sp // 4k gives 7 setup sectors and 512 byte stack above .hex4sp %ss,"\nNew INIT SS:" .hex4sp %sp,"SP:" diff --git a/elks/arch/i86/tools/build.c b/elks/arch/i86/tools/build.c index e23ee2402..0874fdbe6 100644 --- a/elks/arch/i86/tools/build.c +++ b/elks/arch/i86/tools/build.c @@ -33,8 +33,6 @@ #define MINIX_HEADER 0x20 #define SUPL_HEADER 0x40 -#define SYS_SIZE DEF_SYSSIZE - #define DEFAULT_MAJOR_ROOT 0x03 /* BIOS floppy 0 */ #define DEFAULT_MINOR_ROOT 0x80 @@ -161,7 +159,7 @@ int main(int argc, char **argv) /* for compatibility with LILO */ if (setup_sectors < SETUP_SECTS) setup_sectors = SETUP_SECTS; - fprintf(stderr, "Setup is %d bytes.\n", i); + fprintf(stderr, "Setup is %d bytes (%d sectors).\n", i, setup_sectors); for (c = 0; c < sizeof(buf); c++) buf[c] = '\0'; while (i < setup_sectors * 512) { @@ -204,18 +202,20 @@ int main(int argc, char **argv) lseek(id, 0, 0); sys_size = (sz + 15) / 16; - fprintf(stderr, "System is %d (%xh paras)\n", sz, sys_size); - if (sys_size > SYS_SIZE) + fprintf(stderr, "System is %d B (0x%x paras)\n", sz, sys_size); + if (sys_size > DEF_SYSMAX) die("System is too big"); -#if 0 && !defined(CONFIG_ROMCODE) /* no longer correct */ - /* compute boot load address to avoid overwriting image at boot relocation time*/ - fsz = (ex->a_hdrlen + (intel_long(ex->a_text) + intel_long(ex->a_data)) + 15) / 16 - + REL_SYSSEG; - fprintf(stderr, "Text/Data load ending segment is %x, limit %x\n", fsz, DEF_SYSSEG); - if (fsz > DEF_SYSSEG + REL_SYSSEG) { /* start of reloc entry table at boot */ - fprintf(stderr, "System too large for DEF_SYSSEG at %x, increase DEF_SYSSEG\n", - DEF_SYSSEG); - exit(1); +#ifndef CONFIG_ROMCODE + /* display start and end setup.S copy address for informational purposes */ + fsz = (ex->a_hdrlen + (intel_long(ex->a_text) + intel_long(ex->a_data)) + 15) / 16; + if (ex->a_hdrlen == SUPL_HEADER) { + fsz += (intel_long(ex->a_trsize) + intel_long(ex->a_drsize) + + intel_long(ex->esh_ftrsize) + intel_long(ex->esh_ftseg) + 15) / 16; + } + fsz += REL_SYSSEG; + fprintf(stderr, "Load segment start 0x%x end 0x%x\n", DEF_SYSSEG, fsz); + if (DEF_SYSSEG < REL_SYSSEG + 0x1000) { + fprintf(stderr, "Warning: Load segment too low for REL_SYSSEG at %x, increase DEF_SYSSEG\n", REL_SYSSEG); } #endif while (sz > 0) { diff --git a/elks/include/linuxmt/config.h b/elks/include/linuxmt/config.h index 7d7b15b79..0d5cac6e6 100644 --- a/elks/include/linuxmt/config.h +++ b/elks/include/linuxmt/config.h @@ -97,9 +97,9 @@ /* Don't touch these, unless you really know what you are doing. */ #define DEF_INITSEG 0x0100 /* initial Image load address by boot code */ -#define DEF_SYSSEG 0x1300 /* kernel copied here by setup.S code */ +#define DEF_SYSSEG 0x1300 /* address setup then copies kernel to, then REL_SYSSEG */ #define DEF_SETUPSEG DEF_INITSEG + 0x20 -#define DEF_SYSSIZE 0x2F00 +#define DEF_SYSMAX 0x2F00 /* maximum system size (=.text+.fartext+.data) */ /* DMASEG is a bounce buffer of 1K (=BLOCKSIZE) below the first 64K boundary (=0x1000:0) * for use with the old 8237 DMA controller OR a disk track buffer of 9K (18 ectors).