diff --git a/sys/amd64/amd64/genassym.c b/sys/amd64/amd64/genassym.c index b92aebd0e65..ef324a58500 100644 --- a/sys/amd64/amd64/genassym.c +++ b/sys/amd64/amd64/genassym.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 - * $Id: genassym.c,v 1.21 1994/12/03 10:02:20 bde Exp $ + * $Id: genassym.c,v 1.22 1995/01/21 15:22:28 bde Exp $ */ #include @@ -76,7 +76,7 @@ main() struct pcb *pcb = (struct pcb *)0; struct trapframe *tf = (struct trapframe *)0; struct sigframe *sigf = (struct sigframe *)0; - struct bootinfo_t *bootinfo = (struct bootinfo_t *)0; + struct bootinfo *bootinfo = (struct bootinfo *)0; /* XXX should use %p to print pointers. About 80 lines are wrong. */ printf("#define\tUDOT_SZ %d\n", sizeof(struct user)); @@ -194,11 +194,16 @@ main() printf("#define\tEFAULT %d\n", EFAULT); printf("#define\tENAMETOOLONG %d\n", ENAMETOOLONG); printf("#define\tMAXPATHLEN %d\n", MAXPATHLEN); + printf("#define\tBOOTINFO_SIZE %d\n", sizeof *bootinfo); - printf("#define\tBOOTINFO_VERSION %d\n", &bootinfo->version); - printf("#define\tBOOTINFO_KERNELNAME %d\n", &bootinfo->kernelname); - printf("#define\tBOOTINFO_NFS_DISKLESS %d\n", &bootinfo->nfs_diskless); + printf("#define\tBI_VERSION %d\n", &bootinfo->bi_version); + printf("#define\tBI_KERNELNAME %d\n", &bootinfo->bi_kernelname); + printf("#define\tBI_NFS_DISKLESS %d\n", &bootinfo->bi_nfs_diskless); + printf("#define\tBI_ENDCOMMON %d\n", &bootinfo->bi_endcommon); printf("#define\tNFSDISKLESS_SIZE %d\n", sizeof(struct nfs_diskless)); + printf("#define\tBI_SIZE %d\n", &bootinfo->bi_size); + printf("#define\tBI_SYMTAB %d\n", &bootinfo->bi_symtab); + printf("#define\tBI_ESYMTAB %d\n", &bootinfo->bi_esymtab); return (0); } diff --git a/sys/amd64/amd64/locore.S b/sys/amd64/amd64/locore.S index e28f0655c54..29870ace322 100644 --- a/sys/amd64/amd64/locore.S +++ b/sys/amd64/amd64/locore.S @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)locore.s 7.3 (Berkeley) 5/13/91 - * $Id: locore.s,v 1.45 1994/11/18 05:27:34 phk Exp $ + * $Id: locore.s,v 1.46 1995/01/14 13:20:07 bde Exp $ */ /* @@ -53,6 +53,7 @@ #include /* x86 cpu type definitions */ #include /* system call numbers */ #include /* miscellaneous asm macros */ +#include #include "apm.h" #if NAPM > 0 #define ASM @@ -124,7 +125,7 @@ tmpstk: _cpu: .long 0 /* are we 386, 386sx, or 486 */ _cpu_id: .long 0 /* stepping ID */ _cpu_vendor: .space 20 /* CPU origin code */ -_bootinfo: .space BOOTINFO_SIZE /* the bootstrapper knew it! */ +_bootinfo: .space BOOTINFO_SIZE /* bootinfo that we can handle */ _cold: .long 1 /* cold till we are not */ _atdevbase: .long 0 /* location of start of iomem in virtual */ _atdevphys: .long 0 /* location of device mapping ptes (phys) */ @@ -243,7 +244,7 @@ NON_GPROF_ENTRY(btext) */ 1: /* newboot: */ movl 28(%ebp),%ebx /* &bootinfo.version */ - movl BOOTINFO_VERSION(%ebx),%eax + movl BI_VERSION(%ebx),%eax cmpl $1,%eax /* We only understand version 1 */ je 1f movl $1,%eax /* Return status */ @@ -254,7 +255,7 @@ NON_GPROF_ENTRY(btext) /* * If we have a kernelname copy it in */ - movl BOOTINFO_KERNELNAME(%ebx),%esi + movl BI_KERNELNAME(%ebx),%esi cmpl $0,%esi je 1f /* No kernelname */ lea _kernelname-KERNBASE,%edi @@ -265,11 +266,26 @@ NON_GPROF_ENTRY(btext) 1: /* - * Copy the bootinfo structure + * Determine the size of the boot loader's copy of the bootinfo + * struct. This is impossible to do properly because old versions + * of the struct don't contain a size field and there are 2 old + * versions with the same version number. + */ + movl $BI_ENDCOMMON,%ecx /* prepare for sizeless version */ + testl $RB_BOOTINFO,8(%ebp) /* bi_size (and bootinfo) valid? */ + je got_bi_size /* no, sizeless version */ + movl BI_SIZE(%ebx),%ecx +got_bi_size: + + /* + * Copy the common part of the bootinfo struct */ movl %ebx,%esi - lea _bootinfo-KERNBASE,%edi + movl $_bootinfo-KERNBASE,%edi + cmpl $BOOTINFO_SIZE,%ecx + jbe got_common_bi_size movl $BOOTINFO_SIZE,%ecx +got_common_bi_size: cld rep movsb @@ -278,7 +294,7 @@ NON_GPROF_ENTRY(btext) /* * If we have a nfs_diskless structure copy it in */ - movl BOOTINFO_NFS_DISKLESS(%ebx),%esi + movl BI_NFS_DISKLESS(%ebx),%esi cmpl $0,%esi je 2f lea _nfs_diskless-KERNBASE,%edi @@ -517,6 +533,21 @@ NON_GPROF_ENTRY(btext) rep stosb +#ifdef DDB +/* include symbols in "kernel image" if they are loaded */ + movl _bootinfo+BI_ESYMTAB-KERNBASE,%edi + testl %edi,%edi + je over_symalloc + addl $NBPG-1,%edi + andl $~(NBPG-1),%edi + movl %edi,%esi + movl %esi,_KERNend-KERNBASE + movl $KERNBASE,%edi + addl %edi,_bootinfo+BI_SYMTAB-KERNBASE + addl %edi,_bootinfo+BI_ESYMTAB-KERNBASE +over_symalloc: +#endif + /* * The value in esi is both the end of the kernel bss and a pointer to * the kernel page directory, and is used by the rest of locore to build diff --git a/sys/amd64/amd64/locore.s b/sys/amd64/amd64/locore.s index e28f0655c54..29870ace322 100644 --- a/sys/amd64/amd64/locore.s +++ b/sys/amd64/amd64/locore.s @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)locore.s 7.3 (Berkeley) 5/13/91 - * $Id: locore.s,v 1.45 1994/11/18 05:27:34 phk Exp $ + * $Id: locore.s,v 1.46 1995/01/14 13:20:07 bde Exp $ */ /* @@ -53,6 +53,7 @@ #include /* x86 cpu type definitions */ #include /* system call numbers */ #include /* miscellaneous asm macros */ +#include #include "apm.h" #if NAPM > 0 #define ASM @@ -124,7 +125,7 @@ tmpstk: _cpu: .long 0 /* are we 386, 386sx, or 486 */ _cpu_id: .long 0 /* stepping ID */ _cpu_vendor: .space 20 /* CPU origin code */ -_bootinfo: .space BOOTINFO_SIZE /* the bootstrapper knew it! */ +_bootinfo: .space BOOTINFO_SIZE /* bootinfo that we can handle */ _cold: .long 1 /* cold till we are not */ _atdevbase: .long 0 /* location of start of iomem in virtual */ _atdevphys: .long 0 /* location of device mapping ptes (phys) */ @@ -243,7 +244,7 @@ NON_GPROF_ENTRY(btext) */ 1: /* newboot: */ movl 28(%ebp),%ebx /* &bootinfo.version */ - movl BOOTINFO_VERSION(%ebx),%eax + movl BI_VERSION(%ebx),%eax cmpl $1,%eax /* We only understand version 1 */ je 1f movl $1,%eax /* Return status */ @@ -254,7 +255,7 @@ NON_GPROF_ENTRY(btext) /* * If we have a kernelname copy it in */ - movl BOOTINFO_KERNELNAME(%ebx),%esi + movl BI_KERNELNAME(%ebx),%esi cmpl $0,%esi je 1f /* No kernelname */ lea _kernelname-KERNBASE,%edi @@ -265,11 +266,26 @@ NON_GPROF_ENTRY(btext) 1: /* - * Copy the bootinfo structure + * Determine the size of the boot loader's copy of the bootinfo + * struct. This is impossible to do properly because old versions + * of the struct don't contain a size field and there are 2 old + * versions with the same version number. + */ + movl $BI_ENDCOMMON,%ecx /* prepare for sizeless version */ + testl $RB_BOOTINFO,8(%ebp) /* bi_size (and bootinfo) valid? */ + je got_bi_size /* no, sizeless version */ + movl BI_SIZE(%ebx),%ecx +got_bi_size: + + /* + * Copy the common part of the bootinfo struct */ movl %ebx,%esi - lea _bootinfo-KERNBASE,%edi + movl $_bootinfo-KERNBASE,%edi + cmpl $BOOTINFO_SIZE,%ecx + jbe got_common_bi_size movl $BOOTINFO_SIZE,%ecx +got_common_bi_size: cld rep movsb @@ -278,7 +294,7 @@ NON_GPROF_ENTRY(btext) /* * If we have a nfs_diskless structure copy it in */ - movl BOOTINFO_NFS_DISKLESS(%ebx),%esi + movl BI_NFS_DISKLESS(%ebx),%esi cmpl $0,%esi je 2f lea _nfs_diskless-KERNBASE,%edi @@ -517,6 +533,21 @@ NON_GPROF_ENTRY(btext) rep stosb +#ifdef DDB +/* include symbols in "kernel image" if they are loaded */ + movl _bootinfo+BI_ESYMTAB-KERNBASE,%edi + testl %edi,%edi + je over_symalloc + addl $NBPG-1,%edi + andl $~(NBPG-1),%edi + movl %edi,%esi + movl %esi,_KERNend-KERNBASE + movl $KERNBASE,%edi + addl %edi,_bootinfo+BI_SYMTAB-KERNBASE + addl %edi,_bootinfo+BI_ESYMTAB-KERNBASE +over_symalloc: +#endif + /* * The value in esi is both the end of the kernel bss and a pointer to * the kernel page directory, and is used by the rest of locore to build diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index bdbbadf120d..d0d6d97c536 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.102 1995/01/17 01:15:12 bde Exp $ + * $Id: machdep.c,v 1.103 1995/01/24 09:56:29 davidg Exp $ */ #include "npx.h" @@ -359,8 +359,8 @@ again: if (bootverbose) { printf("BIOS Geometries:"); for (i=0; i < N_BIOS_GEOM; i++) - printf(" %x:%x\n", i, bootinfo.bios_geom[i]); - printf(" %d accounted for\n",bootinfo.n_bios_used); + printf(" %x:%x\n", i, bootinfo.bi_bios_geom[i]); + printf(" %d accounted for\n", bootinfo.bi_n_bios_used); } } @@ -1234,6 +1234,20 @@ init386(first) biosbasemem = rtcin(RTC_BASELO)+ (rtcin(RTC_BASEHI)<<8); biosextmem = rtcin(RTC_EXTLO)+ (rtcin(RTC_EXTHI)<<8); + /* + * Print a warning if the official BIOS interface disagrees + * with the hackish interface used above. Eventually only + * the official interface should be used. + */ + if (bootinfo.bi_memsizes_valid) { + if (bootinfo.bi_basemem != biosbasemem) + printf("BIOS basemem (%dK) != RTC basemem (%dK)\n", + bootinfo.bi_basemem, biosbasemem); + if (bootinfo.bi_extmem != biosextmem) + printf("BIOS extmem (%dK) != RTC extmem (%dK)\n", + bootinfo.bi_extmem, biosextmem); + } + /* * If BIOS tells us that it has more than 640k in the basemem, * don't believe it - set it to 640k. diff --git a/sys/conf/Makefile.i386 b/sys/conf/Makefile.i386 index 85a40e6acca..faff7117693 100644 --- a/sys/conf/Makefile.i386 +++ b/sys/conf/Makefile.i386 @@ -1,6 +1,6 @@ # Copyright 1990 W. Jolitz # from: @(#)Makefile.i386 7.1 5/10/91 -# $Id: Makefile.i386,v 1.51 1994/11/27 14:26:16 davidg Exp $ +# $Id: Makefile.i386,v 1.52 1994/12/31 19:27:28 gibbs Exp $ # # Makefile for FreeBSD # @@ -14,17 +14,16 @@ # /sys/i386/conf/Makefile.i386 # after which config should be rerun for all machines. # -# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE INVISIBLE TO MAKEFILE +# N.B.: DEPENDENCIES ON FOLLOWING FLAGS ARE INVISIBLE TO MAKEFILE # IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING # # -DTRACE compile in kernel tracing hooks # -DQUOTA compile in file system quotas +# -DFOO almost all options # -TOUCH?= touch -f -c -LD?= /usr/bin/ld CC?= cc CPP?= cpp -DBSYM?= /usr/sbin/dbsym +LD?= /usr/bin/ld .if exists(./@/.) S= ./@ @@ -61,12 +60,16 @@ SFILES= ${I386}/i386/exception.s ${I386}/i386/microtime.s \ ${I386}/i386/support.s ${I386}/i386/swtch.s ${I386}/apm/apm_setup.s SYSTEM_CFILES= ioconf.c param.c vnode_if.c SYSTEM_SFILES= ${I386}/i386/locore.s -SYSTEM_OBJS=locore.o vnode_if.o ${OBJS} ioconf.o param.o -SYSTEM_DEP=Makefile symbols.sort ${SYSTEM_OBJS} libkern.a -SYSTEM_LD_HEAD= @echo loading $@; rm -f $@ +SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o +SYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS} libkern.a +SYSTEM_LD_HEAD= @echo loading $@; rm -f $@ SYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o libkern.a -SYSTEM_LD_TAIL= @echo rearranging symbols; symorder symbols.sort $@; \ - ${DBSYM} -fT ${LOAD_ADDRESS} $@; size $@; chmod 755 $@ +.if ${CFLAGS:M-g} == "" +SYMORDER_EXCLUDE=-x symbols.exclude +.endif +SYSTEM_LD_TAIL= @echo rearranging symbols; \ + symorder ${SYMORDER_EXCLUDE} symbols.sort $@; \ + size $@; chmod 755 $@ %BEFORE_DEPEND @@ -99,7 +102,8 @@ ${LIBKERN}: @(cd $S/libkern; make) clean: - rm -f eddep kernel tags *.o *.s errs linterrs makelinks genassym + rm -f eddep kernel tags *.o *.s errs linterrs makelinks genassym \ + symbols.exclude symbols.sort #lint: /tmp param.c # @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} \ @@ -107,6 +111,10 @@ clean: # grep -v 'struct/union .* never defined' | \ # grep -v 'possible pointer alignment problem' +symbols.exclude: Makefile + echo "gcc2_compiled." >symbols.exclude + echo "___gnu_compiled_c" >>symbols.exclude + symbols.sort: ${I386}/i386/symbols.raw grep -v '^#' ${I386}/i386/symbols.raw \ | sed 's/^ //' | sort -u > symbols.sort diff --git a/sys/conf/Makefile.powerpc b/sys/conf/Makefile.powerpc index 85a40e6acca..faff7117693 100644 --- a/sys/conf/Makefile.powerpc +++ b/sys/conf/Makefile.powerpc @@ -1,6 +1,6 @@ # Copyright 1990 W. Jolitz # from: @(#)Makefile.i386 7.1 5/10/91 -# $Id: Makefile.i386,v 1.51 1994/11/27 14:26:16 davidg Exp $ +# $Id: Makefile.i386,v 1.52 1994/12/31 19:27:28 gibbs Exp $ # # Makefile for FreeBSD # @@ -14,17 +14,16 @@ # /sys/i386/conf/Makefile.i386 # after which config should be rerun for all machines. # -# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE INVISIBLE TO MAKEFILE +# N.B.: DEPENDENCIES ON FOLLOWING FLAGS ARE INVISIBLE TO MAKEFILE # IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING # # -DTRACE compile in kernel tracing hooks # -DQUOTA compile in file system quotas +# -DFOO almost all options # -TOUCH?= touch -f -c -LD?= /usr/bin/ld CC?= cc CPP?= cpp -DBSYM?= /usr/sbin/dbsym +LD?= /usr/bin/ld .if exists(./@/.) S= ./@ @@ -61,12 +60,16 @@ SFILES= ${I386}/i386/exception.s ${I386}/i386/microtime.s \ ${I386}/i386/support.s ${I386}/i386/swtch.s ${I386}/apm/apm_setup.s SYSTEM_CFILES= ioconf.c param.c vnode_if.c SYSTEM_SFILES= ${I386}/i386/locore.s -SYSTEM_OBJS=locore.o vnode_if.o ${OBJS} ioconf.o param.o -SYSTEM_DEP=Makefile symbols.sort ${SYSTEM_OBJS} libkern.a -SYSTEM_LD_HEAD= @echo loading $@; rm -f $@ +SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o +SYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS} libkern.a +SYSTEM_LD_HEAD= @echo loading $@; rm -f $@ SYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o libkern.a -SYSTEM_LD_TAIL= @echo rearranging symbols; symorder symbols.sort $@; \ - ${DBSYM} -fT ${LOAD_ADDRESS} $@; size $@; chmod 755 $@ +.if ${CFLAGS:M-g} == "" +SYMORDER_EXCLUDE=-x symbols.exclude +.endif +SYSTEM_LD_TAIL= @echo rearranging symbols; \ + symorder ${SYMORDER_EXCLUDE} symbols.sort $@; \ + size $@; chmod 755 $@ %BEFORE_DEPEND @@ -99,7 +102,8 @@ ${LIBKERN}: @(cd $S/libkern; make) clean: - rm -f eddep kernel tags *.o *.s errs linterrs makelinks genassym + rm -f eddep kernel tags *.o *.s errs linterrs makelinks genassym \ + symbols.exclude symbols.sort #lint: /tmp param.c # @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} \ @@ -107,6 +111,10 @@ clean: # grep -v 'struct/union .* never defined' | \ # grep -v 'possible pointer alignment problem' +symbols.exclude: Makefile + echo "gcc2_compiled." >symbols.exclude + echo "___gnu_compiled_c" >>symbols.exclude + symbols.sort: ${I386}/i386/symbols.raw grep -v '^#' ${I386}/i386/symbols.raw \ | sed 's/^ //' | sort -u > symbols.sort diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 4c230ae8753..b134e2d2e80 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -2,7 +2,7 @@ # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.127 1995/01/24 20:38:39 paul Exp $ +# $Id: LINT,v 1.128 1995/01/25 20:35:14 jmz Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -91,14 +91,16 @@ options SYSVMSG # DEBUGGING OPTIONS # -# This line enables the kernel debugger, DDB, and the line following -# allocates extra space for a copy of the debugger symbol table which -# is stored in the initialized data area of the kernel. If you change -# the latter option, remove db_aout.o before compiling. +# Enable the kernel debugger. # -options DODUMP #We dump core-image on panic -options DDB #Kernel debugger -options "SYMTAB_SPACE=163834" #This kernel needs LOTS of symtable +options DDB + +# +# Enable dumping of the kernel image to swap for panics. This is not +# the default because writing to misconfigured swap may wipe out file +# systems. +# +options DODUMP # # KTRACE enables the system-call tracing facility ktrace(2). diff --git a/sys/ddb/db_aout.c b/sys/ddb/db_aout.c index b704ded2d64..91c67ce7c40 100644 --- a/sys/ddb/db_aout.c +++ b/sys/ddb/db_aout.c @@ -23,7 +23,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: db_aout.c,v 1.8 1994/09/05 14:04:56 bde Exp $ + * $Id: db_aout.c,v 1.9 1994/09/27 03:34:52 phk Exp $ */ /* @@ -37,6 +37,9 @@ #include #include #include + +#include + #include #include @@ -67,13 +70,6 @@ (sp = (struct nlist *)((symtab) + 1), \ ep = (struct nlist *)((char *)sp + *(symtab))) -#ifndef SYMTAB_SPACE -#define SYMTAB_SPACE 73000 -#endif /*SYMTAB_SPACE*/ - -int db_symtabsize = SYMTAB_SPACE; -char db_symtab[SYMTAB_SPACE] = { 1 }; - void X_db_sym_init(symtab, esymtab, name) int * symtab; /* pointer to start of symbol table */ @@ -97,7 +93,6 @@ X_db_sym_init(symtab, esymtab, name) strtab = (char *)sym_end; strlen = *(int *)strtab; -#if 0 if (strtab + ((strlen + sizeof(int) - 1) & ~(sizeof(int)-1)) != esymtab) { @@ -107,7 +102,6 @@ X_db_sym_init(symtab, esymtab, name) db_printf("[ preserving %#x bytes of %s symbol table ]\n", esymtab - (char *)symtab, name); -#endif for (sp = sym_start; sp < sym_end; sp++) { register int strx; @@ -233,9 +227,11 @@ X_db_line_at_pc(symtab, cursym, filename, linenum, off) sp = (struct nlist *)symtab->start; ep = (struct nlist *)symtab->end; -/* XXX - gcc specific */ -#define NEWSRC(str) ((str) != NULL && \ - (str)[0] == 'g' && strcmp((str), "gcc_compiled.") == 0) +/* + * XXX - this used to remove "gcc_compiled.", but that is obsolete. We + * now remove unwanted names using symorder. + */ +#define NEWSRC(str) 0 for (; sp < ep; sp++) { @@ -327,16 +323,11 @@ X_db_sym_numargs(symtab, cursym, nargp, argnamep) void kdb_init(void) { -#if 0 - extern char *esym; - extern int end; - - if (esym > (char *)&end) { - X_db_sym_init((int *)&end, esym, "kernel"); - } -#endif - - X_db_sym_init (db_symtab, 0, "kernel"); + if (bootinfo.bi_esymtab != bootinfo.bi_symtab) + X_db_sym_init((int *)bootinfo.bi_symtab, + (char *)((bootinfo.bi_esymtab + sizeof(int) - 1) + & ~(sizeof(int) - 1)), + "kernel"); } #if 0 diff --git a/sys/i386/boot/biosboot/asm.S b/sys/i386/boot/biosboot/asm.S index 90f523f4425..ac59d5bb3bc 100644 --- a/sys/i386/boot/biosboot/asm.S +++ b/sys/i386/boot/biosboot/asm.S @@ -24,7 +24,7 @@ * the rights to redistribute these changes. * * from: Mach, Revision 2.2 92/04/04 11:34:13 rpd - * $Id: asm.S,v 1.4 1994/10/02 05:18:24 rgrimes Exp $ + * $Id: asm.S,v 1.5 1994/10/06 09:41:01 rgrimes Exp $ */ @@ -59,7 +59,6 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. CR0_PE_ON = 0x1 CR0_PE_OFF = 0xfffffffe -.globl _ouraddr .text /* @@ -118,8 +117,7 @@ xprot: ENTRY(prot_to_real) /* set up a dummy stack frame for the second seg change. */ - movl _ouraddr, %eax - sarl $4, %eax + movw $BOOTSEG, %ax pushw %ax movw $xreal, %ax /* gas botches pushw $xreal, extra bytes 0, 0 */ pushw %ax /* decode to add %al, (%eax) (%al usually 0) */ diff --git a/sys/i386/boot/biosboot/boot.c b/sys/i386/boot/biosboot/boot.c index a9a31eea398..5cb0eb14f69 100644 --- a/sys/i386/boot/biosboot/boot.c +++ b/sys/i386/boot/biosboot/boot.c @@ -24,7 +24,7 @@ * the rights to redistribute these changes. * * from: Mach, [92/04/03 16:51:14 rvb] - * $Id: boot.c,v 1.29 1994/12/18 20:30:10 joerg Exp $ + * $Id: boot.c,v 1.30 1995/01/20 07:48:19 wpaul Exp $ */ @@ -57,13 +57,15 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +#define ouraddr (BOOTSEG << 4) /* XXX */ + struct exec head; -struct bootinfo_t bootinfo; -char *name = { "/kernel" }; +struct bootinfo bootinfo; extern void init_serial(void); extern int probe_keyboard(void); -int loadflags = 0; +int loadflags; +unsigned char loadsyms; extern int end; boot(drive) @@ -75,31 +77,39 @@ int drive; if (probe_keyboard()) { init_serial(); loadflags |= RB_SERIAL; - printf ("\nNo keyboard found.\n"); + printf("\nNo keyboard found.\n"); } /* Pick up the story from the Bios on geometry of disks */ for(ret = 0; ret < N_BIOS_GEOM; ret ++) - bootinfo.bios_geom[ret] = get_diskinfo(ret + 0x80); + bootinfo.bi_bios_geom[ret] = get_diskinfo(ret + 0x80); - /* This is nasty, but why use 4 printf()s when 1 will do. */ + bootinfo.bi_basemem = memsize(0); + bootinfo.bi_extmem = memsize(1); + bootinfo.bi_memsizes_valid = 1; - printf("\n>> FreeBSD BOOT @ 0x%x: %d/%d k of memory\nUse hd(1,a)/kernel to boot sd0 when wd0 is also installed.\nUsage: [[[%s(%d,a)]%s][-s][-r][-a][-c][-d][-b][-v][-h]]\nUse ? for file list or simply press Return for defaults\n", ouraddr, memsize(0), memsize(1), devs[(drive & 0x80) ? 0 : 2], - (unit = (drive & 0x7f)), name); + /* This is ugly, but why use 4 printf()s when 1 will do? */ + printf("\n\ +>> FreeBSD BOOT @ 0x%x: %d/%d k of memory\n\ +Use hd(1,a)/kernel to boot sd0 when wd0 is also installed.\n\ +Usage: [[[%s(%d,a)]%s][-s][-r][-a][-c][-d][-D][-b][-v][-h]]\n\ +Use ? for file list or simply press Return for defaults\n", + ouraddr, bootinfo.bi_basemem, bootinfo.bi_extmem, + devs[drive & 0x80 ? 0 : 2], drive & 0x7f, name); gateA20(); loadstart: /***************************************************************\ - * As a default set it to the first partition of the first * + * As a default set it to the first partition of the boot * * floppy or hard drive * \***************************************************************/ - part = 0; + unit = drive & 0x7f; maj = (drive&0x80 ? 0 : 2); /* a good first bet */ - printf ("Boot: "); + printf("Boot: "); getbootdev(&loadflags); ret = openrd(); if (ret != 0) { @@ -120,9 +130,10 @@ loadprog(howto) long int startaddr; long int addr; /* physical address.. not directly useable */ long int bootdev; - long int total; int i; +#ifdef REDUNDANT unsigned char tmpbuf[4096]; /* we need to load the first 4k here */ +#endif read(&head, sizeof(head)); if ( N_BADMAG(head)) { @@ -134,7 +145,12 @@ loadprog(howto) /*if(poff==0) poff = 32;*/ - startaddr = (int)head.a_entry & 0x00FFFFFF; /* some MEG boundary */ + /* + * We assume that the entry address is the same as the lowest text + * address and that the kernel startup code handles relocation by + * this address rounded down to a multiple of 16M. + */ + startaddr = head.a_entry & 0x00FFFFFF; addr = startaddr; printf("Booting %s(%d,%c)%s @ 0x%x\n" , devs[maj] @@ -165,12 +181,18 @@ loadprog(howto) printf("text=0x%x ", head.a_text); /********************************************************/ /* LOAD THE TEXT SEGMENT */ +#ifdef REDUNDANT /* don't clobber the first 4k yet (BIOS NEEDS IT) */ /********************************************************/ read(tmpbuf,4096); addr += 4096; xread(addr, head.a_text - 4096); addr += head.a_text - 4096; +#else + /* Assume we're loading high, so that the BIOS isn't in the way. */ + xread(addr, head.a_text); + addr += head.a_text; +#endif /********************************************************/ /* Load the Initialised data after the text */ @@ -190,6 +212,9 @@ loadprog(howto) /* * This doesn't do us any good anymore either. + * XXX however, we should be checking that we don't load over the top of + * ourselves or into nonexistent memory. A full symbol table is unlikely + * to fit on 4MB machines. */ #ifdef REDUNDANT if( (addr < ouraddr) && ((addr + head.a_bss) > ouraddr)) @@ -200,50 +225,53 @@ loadprog(howto) { pbzero(addr,head.a_bss); } - addr += head.a_bss; #else pbzero(addr,head.a_bss); #endif -#ifdef LOADSYMS /* not yet, haven't worked this out yet */ - if (addr > 0x100000) + addr += head.a_bss; + if (loadsyms) { + unsigned pad; + + /* Pad to a page boundary. */ + pad = (unsigned)addr % NBPG; + if (pad != 0) { + pad = NBPG - pad; + addr += pad; + } + bootinfo.bi_symtab = addr; + /********************************************************/ - /*copy in the symbol header */ + /* Copy the symbol table size */ /********************************************************/ pcpy(&head.a_syms, addr, sizeof(head.a_syms)); addr += sizeof(head.a_syms); /********************************************************/ - /* READ in the symbol table */ + /* Load the symbol table */ /********************************************************/ - printf("symbols=[+0x%x", head.a_syms); + printf("symbols=[+0x%x+0x%x+0x%x", pad, sizeof(head.a_syms), + head.a_syms); xread(addr, head.a_syms); addr += head.a_syms; /********************************************************/ - /* Followed by the next integer (another header) */ - /* more debug symbols? */ + /* Load the string table size */ /********************************************************/ read(&i, sizeof(int)); pcpy(&i, addr, sizeof(int)); i -= sizeof(int); addr += sizeof(int); - /********************************************************/ - /* and that many bytes of (debug symbols?) */ + /* Load the string table */ /********************************************************/ - printf("+0x%x] ", i); + printf("+0x%x+0x%x] ", sizeof(int), i); xread(addr, i); addr += i; - } -#endif LOADSYMS - /********************************************************/ - /* and note the end address of all this */ - /********************************************************/ - total = ((addr+sizeof(int)-1))&~(sizeof(int)-1); - printf("total=0x%x ", total); + bootinfo.bi_esymtab = addr; + } /* * For backwards compatibility, use the previously-unused adaptor @@ -251,18 +279,22 @@ loadprog(howto) */ bootdev = MAKEBOOTDEV(maj, (slice >> 4), slice & 0xf, unit, part); +#ifdef REDUNDANT /****************************************************************/ /* copy that first page and overwrite any BIOS variables */ /****************************************************************/ - printf("entry point=0x%x\n" ,(int)startaddr); /* Under no circumstances overwrite precious BIOS variables! */ pcpy(tmpbuf, startaddr, 0x400); pcpy(tmpbuf + 0x500, startaddr + 0x500, 4096 - 0x500); - bootinfo.version=1; - bootinfo.kernelname=(char *)((int)name + (BOOTSEG<<4)); - bootinfo.nfs_diskless=0; - startprog((int)startaddr, howto, bootdev, (int)&bootinfo+(BOOTSEG<<4)); - return; +#endif + + bootinfo.bi_version = BOOTINFO_VERSION; + bootinfo.bi_kernelname = name + ouraddr; + bootinfo.bi_nfs_diskless = NULL; + bootinfo.bi_size = sizeof(bootinfo); + printf("total=0x%x entry point=0x%x\n", (int)addr, (int)startaddr); + startprog((int)startaddr, howto | RB_BOOTINFO, bootdev, + (int)&bootinfo + ouraddr); } #define NAMEBUF_LEN 100 @@ -291,12 +323,17 @@ getbootdev(howto) *howto |= RB_SINGLE; continue; case 'd': *howto |= RB_KDB; continue; + case 'D': + loadsyms = 1; continue; case 'b': *howto |= RB_HALT; continue; case 'v': *howto |= RB_VERBOSE; continue; case 'h': - *howto ^= RB_SERIAL; continue; + *howto ^= RB_SERIAL; + if (*howto & RB_SERIAL) + init_serial(); + continue; } else { name = ptr; @@ -308,4 +345,3 @@ getbootdev(howto) } else printf("\n"); } - diff --git a/sys/i386/boot/biosboot/boot.h b/sys/i386/boot/biosboot/boot.h index ad51cc58304..5a4e5593a13 100644 --- a/sys/i386/boot/biosboot/boot.h +++ b/sys/i386/boot/biosboot/boot.h @@ -24,7 +24,7 @@ * the rights to redistribute these changes. * * from: Mach, Revision 2.2 92/04/04 11:35:03 rpd - * $Id: boot.h,v 1.4 1994/08/21 17:47:26 paul Exp $ + * $Id: boot.h,v 1.5 1994/12/18 19:14:15 bde Exp $ */ #include @@ -38,4 +38,4 @@ extern char *devs[], *name, *iodest; extern struct fs *fs; extern struct inode inode; extern int dosdev, unit, slice, part, maj, boff, poff, bnum, cnt; -extern long int ouraddr; +extern unsigned long tw_chars; diff --git a/sys/i386/boot/biosboot/boot2.S b/sys/i386/boot/biosboot/boot2.S index 5984f836590..26a5442dc70 100644 --- a/sys/i386/boot/biosboot/boot2.S +++ b/sys/i386/boot/biosboot/boot2.S @@ -24,7 +24,7 @@ * the rights to redistribute these changes. * * from: Mach, Revision 2.2 92/04/04 11:35:26 rpd - * $Id: boot2.S,v 1.4 1994/06/22 05:52:25 jkh Exp $ + * $Id: boot2.S,v 1.5 1994/08/30 01:38:03 bde Exp $ */ #include "asm.h" @@ -49,8 +49,6 @@ * boot2() -- second stage boot */ -.globl EXT(ouraddr) - ENTRY(boot2) data32 subl %eax, %eax @@ -59,9 +57,6 @@ ENTRY(boot2) mov %ax, %es data32 shll $4, %eax - addr32 - data32 - movl %eax, EXT(ouraddr) /* fix up GDT entries for bootstrap */ #define FIXUP(gdt_index) \ @@ -175,12 +170,3 @@ ENTRY(boot2) oops: hlt jmp oops - - .data - .align 2 -#if 0 /* XXX this would give losing "_ouraddr :". Better declared in C */ -EXT(ouraddr): -#else -_ouraddr: -#endif - .long 0 diff --git a/sys/i386/boot/biosboot/disk.c b/sys/i386/boot/biosboot/disk.c index 566926233a5..0cc0b54bca4 100644 --- a/sys/i386/boot/biosboot/disk.c +++ b/sys/i386/boot/biosboot/disk.c @@ -24,7 +24,7 @@ * the rights to redistribute these changes. * * from: Mach, Revision 2.2 92/04/04 11:35:49 rpd - * $Id: disk.c,v 1.5 1994/05/16 03:06:00 ache Exp $ + * $Id: disk.c,v 1.6 1994/12/18 19:14:19 bde Exp $ */ /* @@ -50,8 +50,6 @@ #define SPT(di) ((di)&0xff) #define HEADS(di) ((((di)>>8)&0xff)+1) -char *devs[] = {"wd", "hd", "fd", "wt", "sd", 0}; - #ifdef DO_BAD144 struct dkbad dkb; int do_bad144; diff --git a/sys/i386/boot/biosboot/io.c b/sys/i386/boot/biosboot/io.c index 7932385df4e..169fa562f1c 100644 --- a/sys/i386/boot/biosboot/io.c +++ b/sys/i386/boot/biosboot/io.c @@ -24,9 +24,10 @@ * the rights to redistribute these changes. * * from: Mach, Revision 2.2 92/04/04 11:35:57 rpd - * $Id: io.c,v 1.10 1994/11/07 11:26:29 davidg Exp $ + * $Id: io.c,v 1.11 1995/01/20 07:48:21 wpaul Exp $ */ +#include "boot.h" #include #include @@ -49,7 +50,6 @@ extern int loadflags; /* * Gate A20 for high memory */ -unsigned char x_20 = KB_A20; gateA20() { #ifdef IBM_L40 @@ -61,7 +61,7 @@ gateA20() outb(K_CMD, KC_CMD_WOUT); while (inb(K_STATUS) & K_IBUF_FUL); - outb(K_RDWR, x_20); + outb(K_RDWR, KB_A20); while (inb(K_STATUS) & K_IBUF_FUL); #endif IBM_L40 } @@ -121,11 +121,15 @@ printf(format,data) putchar(c) { if (c == '\n') { - if (loadflags & RB_SERIAL) serial_putc('\r'); - else putc('\r'); + if (loadflags & RB_SERIAL) + serial_putc('\r'); + else + putc('\r'); } - if (loadflags & RB_SERIAL) serial_putc(c); - else putc(c); + if (loadflags & RB_SERIAL) + serial_putc(c); + else + putc(c); } getchar(in_buf) @@ -190,7 +194,6 @@ char *buf; default: ptr++; } - return 0; } @@ -215,8 +218,6 @@ int len; /* To quote Ken: "You are not expected to understand this." :) */ -static unsigned long tw_chars = 0x5C2D2F7C; /* "\-/|" */ - twiddle() { putchar((char)tw_chars); diff --git a/sys/i386/boot/biosboot/table.c b/sys/i386/boot/biosboot/table.c index 677a12f473c..981994e8647 100644 --- a/sys/i386/boot/biosboot/table.c +++ b/sys/i386/boot/biosboot/table.c @@ -24,7 +24,7 @@ * the rights to redistribute these changes. * * from: Mach, Revision 2.2 92/04/04 11:36:43 rpd - * $Id: table.c,v 1.3 1993/10/16 19:11:40 rgrimes Exp $ + * $Id: table.c,v 1.4 1994/08/30 01:38:04 bde Exp $ */ /* @@ -129,3 +129,11 @@ struct pseudo_desc Gdtr = { sizeof Gdt - 1, RUN, RUN }; struct pseudo_desc Idtr_prot = { sizeof Idt - 1, RUN, RUN }; struct pseudo_desc Idtr_real = { 0x400 - 1, 0x0, 0x0 }; #endif + +/* + * All initialized data is defined in one file to reduce space wastage from + * fragmentation. + */ +char *devs[] = { "wd", "hd", "fd", "wt", "sd", 0 }; +char *name = "/kernel"; +unsigned long tw_chars = 0x5C2D2F7C; /* "\-/|" */ diff --git a/sys/i386/boot/netboot/main.c b/sys/i386/boot/netboot/main.c index 3116d13b1ee..09b6a17165e 100644 --- a/sys/i386/boot/netboot/main.c +++ b/sys/i386/boot/netboot/main.c @@ -25,7 +25,7 @@ void (*kernelentry)(); struct nfs_diskless nfsdiskless; int hostnamelen; char config_buffer[512]; /* Max TFTP packet */ -struct bootinfo_t bootinfo; +struct bootinfo bootinfo; unsigned long netmask; extern char packet[]; @@ -281,9 +281,9 @@ load() printf("entry=0x%X.\n\r",head.a_entry); /* Jump to kernel */ - bootinfo.version = 1; - bootinfo.kernelname = kernel; - bootinfo.nfs_diskless = &nfsdiskless; + bootinfo.bi_version = BOOTINFO_VERSION; + bootinfo.bi_kernelname = kernel; + bootinfo.bi_nfs_diskless = &nfsdiskless; kernelentry = (void *)(head.a_entry & 0x00FFFFFF); (*kernelentry)(0,NODEV,0,0,0,&bootinfo,0,0,0); printf("*** %s execute failure ***\n",kernel); diff --git a/sys/i386/conf/LINT b/sys/i386/conf/LINT index 4c230ae8753..b134e2d2e80 100644 --- a/sys/i386/conf/LINT +++ b/sys/i386/conf/LINT @@ -2,7 +2,7 @@ # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.127 1995/01/24 20:38:39 paul Exp $ +# $Id: LINT,v 1.128 1995/01/25 20:35:14 jmz Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -91,14 +91,16 @@ options SYSVMSG # DEBUGGING OPTIONS # -# This line enables the kernel debugger, DDB, and the line following -# allocates extra space for a copy of the debugger symbol table which -# is stored in the initialized data area of the kernel. If you change -# the latter option, remove db_aout.o before compiling. +# Enable the kernel debugger. # -options DODUMP #We dump core-image on panic -options DDB #Kernel debugger -options "SYMTAB_SPACE=163834" #This kernel needs LOTS of symtable +options DDB + +# +# Enable dumping of the kernel image to swap for panics. This is not +# the default because writing to misconfigured swap may wipe out file +# systems. +# +options DODUMP # # KTRACE enables the system-call tracing facility ktrace(2). diff --git a/sys/i386/conf/Makefile.i386 b/sys/i386/conf/Makefile.i386 index 85a40e6acca..faff7117693 100644 --- a/sys/i386/conf/Makefile.i386 +++ b/sys/i386/conf/Makefile.i386 @@ -1,6 +1,6 @@ # Copyright 1990 W. Jolitz # from: @(#)Makefile.i386 7.1 5/10/91 -# $Id: Makefile.i386,v 1.51 1994/11/27 14:26:16 davidg Exp $ +# $Id: Makefile.i386,v 1.52 1994/12/31 19:27:28 gibbs Exp $ # # Makefile for FreeBSD # @@ -14,17 +14,16 @@ # /sys/i386/conf/Makefile.i386 # after which config should be rerun for all machines. # -# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE INVISIBLE TO MAKEFILE +# N.B.: DEPENDENCIES ON FOLLOWING FLAGS ARE INVISIBLE TO MAKEFILE # IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING # # -DTRACE compile in kernel tracing hooks # -DQUOTA compile in file system quotas +# -DFOO almost all options # -TOUCH?= touch -f -c -LD?= /usr/bin/ld CC?= cc CPP?= cpp -DBSYM?= /usr/sbin/dbsym +LD?= /usr/bin/ld .if exists(./@/.) S= ./@ @@ -61,12 +60,16 @@ SFILES= ${I386}/i386/exception.s ${I386}/i386/microtime.s \ ${I386}/i386/support.s ${I386}/i386/swtch.s ${I386}/apm/apm_setup.s SYSTEM_CFILES= ioconf.c param.c vnode_if.c SYSTEM_SFILES= ${I386}/i386/locore.s -SYSTEM_OBJS=locore.o vnode_if.o ${OBJS} ioconf.o param.o -SYSTEM_DEP=Makefile symbols.sort ${SYSTEM_OBJS} libkern.a -SYSTEM_LD_HEAD= @echo loading $@; rm -f $@ +SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o +SYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS} libkern.a +SYSTEM_LD_HEAD= @echo loading $@; rm -f $@ SYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o libkern.a -SYSTEM_LD_TAIL= @echo rearranging symbols; symorder symbols.sort $@; \ - ${DBSYM} -fT ${LOAD_ADDRESS} $@; size $@; chmod 755 $@ +.if ${CFLAGS:M-g} == "" +SYMORDER_EXCLUDE=-x symbols.exclude +.endif +SYSTEM_LD_TAIL= @echo rearranging symbols; \ + symorder ${SYMORDER_EXCLUDE} symbols.sort $@; \ + size $@; chmod 755 $@ %BEFORE_DEPEND @@ -99,7 +102,8 @@ ${LIBKERN}: @(cd $S/libkern; make) clean: - rm -f eddep kernel tags *.o *.s errs linterrs makelinks genassym + rm -f eddep kernel tags *.o *.s errs linterrs makelinks genassym \ + symbols.exclude symbols.sort #lint: /tmp param.c # @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} \ @@ -107,6 +111,10 @@ clean: # grep -v 'struct/union .* never defined' | \ # grep -v 'possible pointer alignment problem' +symbols.exclude: Makefile + echo "gcc2_compiled." >symbols.exclude + echo "___gnu_compiled_c" >>symbols.exclude + symbols.sort: ${I386}/i386/symbols.raw grep -v '^#' ${I386}/i386/symbols.raw \ | sed 's/^ //' | sort -u > symbols.sort diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index 4c230ae8753..b134e2d2e80 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -2,7 +2,7 @@ # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.127 1995/01/24 20:38:39 paul Exp $ +# $Id: LINT,v 1.128 1995/01/25 20:35:14 jmz Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -91,14 +91,16 @@ options SYSVMSG # DEBUGGING OPTIONS # -# This line enables the kernel debugger, DDB, and the line following -# allocates extra space for a copy of the debugger symbol table which -# is stored in the initialized data area of the kernel. If you change -# the latter option, remove db_aout.o before compiling. +# Enable the kernel debugger. # -options DODUMP #We dump core-image on panic -options DDB #Kernel debugger -options "SYMTAB_SPACE=163834" #This kernel needs LOTS of symtable +options DDB + +# +# Enable dumping of the kernel image to swap for panics. This is not +# the default because writing to misconfigured swap may wipe out file +# systems. +# +options DODUMP # # KTRACE enables the system-call tracing facility ktrace(2). diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c index b92aebd0e65..ef324a58500 100644 --- a/sys/i386/i386/genassym.c +++ b/sys/i386/i386/genassym.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 - * $Id: genassym.c,v 1.21 1994/12/03 10:02:20 bde Exp $ + * $Id: genassym.c,v 1.22 1995/01/21 15:22:28 bde Exp $ */ #include @@ -76,7 +76,7 @@ main() struct pcb *pcb = (struct pcb *)0; struct trapframe *tf = (struct trapframe *)0; struct sigframe *sigf = (struct sigframe *)0; - struct bootinfo_t *bootinfo = (struct bootinfo_t *)0; + struct bootinfo *bootinfo = (struct bootinfo *)0; /* XXX should use %p to print pointers. About 80 lines are wrong. */ printf("#define\tUDOT_SZ %d\n", sizeof(struct user)); @@ -194,11 +194,16 @@ main() printf("#define\tEFAULT %d\n", EFAULT); printf("#define\tENAMETOOLONG %d\n", ENAMETOOLONG); printf("#define\tMAXPATHLEN %d\n", MAXPATHLEN); + printf("#define\tBOOTINFO_SIZE %d\n", sizeof *bootinfo); - printf("#define\tBOOTINFO_VERSION %d\n", &bootinfo->version); - printf("#define\tBOOTINFO_KERNELNAME %d\n", &bootinfo->kernelname); - printf("#define\tBOOTINFO_NFS_DISKLESS %d\n", &bootinfo->nfs_diskless); + printf("#define\tBI_VERSION %d\n", &bootinfo->bi_version); + printf("#define\tBI_KERNELNAME %d\n", &bootinfo->bi_kernelname); + printf("#define\tBI_NFS_DISKLESS %d\n", &bootinfo->bi_nfs_diskless); + printf("#define\tBI_ENDCOMMON %d\n", &bootinfo->bi_endcommon); printf("#define\tNFSDISKLESS_SIZE %d\n", sizeof(struct nfs_diskless)); + printf("#define\tBI_SIZE %d\n", &bootinfo->bi_size); + printf("#define\tBI_SYMTAB %d\n", &bootinfo->bi_symtab); + printf("#define\tBI_ESYMTAB %d\n", &bootinfo->bi_esymtab); return (0); } diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s index e28f0655c54..29870ace322 100644 --- a/sys/i386/i386/locore.s +++ b/sys/i386/i386/locore.s @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)locore.s 7.3 (Berkeley) 5/13/91 - * $Id: locore.s,v 1.45 1994/11/18 05:27:34 phk Exp $ + * $Id: locore.s,v 1.46 1995/01/14 13:20:07 bde Exp $ */ /* @@ -53,6 +53,7 @@ #include /* x86 cpu type definitions */ #include /* system call numbers */ #include /* miscellaneous asm macros */ +#include #include "apm.h" #if NAPM > 0 #define ASM @@ -124,7 +125,7 @@ tmpstk: _cpu: .long 0 /* are we 386, 386sx, or 486 */ _cpu_id: .long 0 /* stepping ID */ _cpu_vendor: .space 20 /* CPU origin code */ -_bootinfo: .space BOOTINFO_SIZE /* the bootstrapper knew it! */ +_bootinfo: .space BOOTINFO_SIZE /* bootinfo that we can handle */ _cold: .long 1 /* cold till we are not */ _atdevbase: .long 0 /* location of start of iomem in virtual */ _atdevphys: .long 0 /* location of device mapping ptes (phys) */ @@ -243,7 +244,7 @@ NON_GPROF_ENTRY(btext) */ 1: /* newboot: */ movl 28(%ebp),%ebx /* &bootinfo.version */ - movl BOOTINFO_VERSION(%ebx),%eax + movl BI_VERSION(%ebx),%eax cmpl $1,%eax /* We only understand version 1 */ je 1f movl $1,%eax /* Return status */ @@ -254,7 +255,7 @@ NON_GPROF_ENTRY(btext) /* * If we have a kernelname copy it in */ - movl BOOTINFO_KERNELNAME(%ebx),%esi + movl BI_KERNELNAME(%ebx),%esi cmpl $0,%esi je 1f /* No kernelname */ lea _kernelname-KERNBASE,%edi @@ -265,11 +266,26 @@ NON_GPROF_ENTRY(btext) 1: /* - * Copy the bootinfo structure + * Determine the size of the boot loader's copy of the bootinfo + * struct. This is impossible to do properly because old versions + * of the struct don't contain a size field and there are 2 old + * versions with the same version number. + */ + movl $BI_ENDCOMMON,%ecx /* prepare for sizeless version */ + testl $RB_BOOTINFO,8(%ebp) /* bi_size (and bootinfo) valid? */ + je got_bi_size /* no, sizeless version */ + movl BI_SIZE(%ebx),%ecx +got_bi_size: + + /* + * Copy the common part of the bootinfo struct */ movl %ebx,%esi - lea _bootinfo-KERNBASE,%edi + movl $_bootinfo-KERNBASE,%edi + cmpl $BOOTINFO_SIZE,%ecx + jbe got_common_bi_size movl $BOOTINFO_SIZE,%ecx +got_common_bi_size: cld rep movsb @@ -278,7 +294,7 @@ NON_GPROF_ENTRY(btext) /* * If we have a nfs_diskless structure copy it in */ - movl BOOTINFO_NFS_DISKLESS(%ebx),%esi + movl BI_NFS_DISKLESS(%ebx),%esi cmpl $0,%esi je 2f lea _nfs_diskless-KERNBASE,%edi @@ -517,6 +533,21 @@ NON_GPROF_ENTRY(btext) rep stosb +#ifdef DDB +/* include symbols in "kernel image" if they are loaded */ + movl _bootinfo+BI_ESYMTAB-KERNBASE,%edi + testl %edi,%edi + je over_symalloc + addl $NBPG-1,%edi + andl $~(NBPG-1),%edi + movl %edi,%esi + movl %esi,_KERNend-KERNBASE + movl $KERNBASE,%edi + addl %edi,_bootinfo+BI_SYMTAB-KERNBASE + addl %edi,_bootinfo+BI_ESYMTAB-KERNBASE +over_symalloc: +#endif + /* * The value in esi is both the end of the kernel bss and a pointer to * the kernel page directory, and is used by the rest of locore to build diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index bdbbadf120d..d0d6d97c536 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.102 1995/01/17 01:15:12 bde Exp $ + * $Id: machdep.c,v 1.103 1995/01/24 09:56:29 davidg Exp $ */ #include "npx.h" @@ -359,8 +359,8 @@ again: if (bootverbose) { printf("BIOS Geometries:"); for (i=0; i < N_BIOS_GEOM; i++) - printf(" %x:%x\n", i, bootinfo.bios_geom[i]); - printf(" %d accounted for\n",bootinfo.n_bios_used); + printf(" %x:%x\n", i, bootinfo.bi_bios_geom[i]); + printf(" %d accounted for\n", bootinfo.bi_n_bios_used); } } @@ -1234,6 +1234,20 @@ init386(first) biosbasemem = rtcin(RTC_BASELO)+ (rtcin(RTC_BASEHI)<<8); biosextmem = rtcin(RTC_EXTLO)+ (rtcin(RTC_EXTHI)<<8); + /* + * Print a warning if the official BIOS interface disagrees + * with the hackish interface used above. Eventually only + * the official interface should be used. + */ + if (bootinfo.bi_memsizes_valid) { + if (bootinfo.bi_basemem != biosbasemem) + printf("BIOS basemem (%dK) != RTC basemem (%dK)\n", + bootinfo.bi_basemem, biosbasemem); + if (bootinfo.bi_extmem != biosextmem) + printf("BIOS extmem (%dK) != RTC extmem (%dK)\n", + bootinfo.bi_extmem, biosextmem); + } + /* * If BIOS tells us that it has more than 640k in the basemem, * don't believe it - set it to 640k. diff --git a/sys/i386/include/bootinfo.h b/sys/i386/include/bootinfo.h index b86a034715f..757e7e489a9 100644 --- a/sys/i386/include/bootinfo.h +++ b/sys/i386/include/bootinfo.h @@ -29,22 +29,41 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bootinfo.h,v 1.2 1994/11/18 05:02:43 phk Exp $ + * $Id: bootinfo.h,v 1.3 1994/11/18 05:26:52 phk Exp $ */ #ifndef _MACHINE_BOOTINFO_H_ #define _MACHINE_BOOTINFO_H_ -#define N_BIOS_GEOM 8 -struct bootinfo_t { - unsigned int version; - unsigned char *kernelname; - struct nfs_diskless *nfs_diskless; - unsigned int n_bios_used; - unsigned long bios_geom[N_BIOS_GEOM]; +/* Only change the version number if you break compatibility. */ +#define BOOTINFO_VERSION 1 + +#define N_BIOS_GEOM 8 + +/* + * A zero bootinfo field often means that there is no info available. + * Flags are used to indicate the validity of fields where zero is a + * normal value. + */ +struct bootinfo { + unsigned int bi_version; + unsigned char *bi_kernelname; + struct nfs_diskless *bi_nfs_diskless; + /* End of fields that are always present. */ +#define bi_endcommon bi_n_bios_used + unsigned int bi_n_bios_used; + unsigned long bi_bios_geom[N_BIOS_GEOM]; + unsigned int bi_size; + unsigned char bi_memsizes_valid; + unsigned char bi_pad[3]; + unsigned long bi_basemem; + unsigned long bi_extmem; + unsigned long bi_symtab; + unsigned long bi_esymtab; }; #ifdef KERNEL -extern struct bootinfo_t bootinfo; +extern struct bootinfo bootinfo; #endif -#endif /* _MACHINE_BOOTINFO_H_ */ + +#endif /* !_MACHINE_BOOTINFO_H_ */ diff --git a/sys/i386/isa/wd.c b/sys/i386/isa/wd.c index 87e695c8854..8f850604345 100644 --- a/sys/i386/isa/wd.c +++ b/sys/i386/isa/wd.c @@ -37,7 +37,7 @@ static int wdtest = 0; * SUCH DAMAGE. * * from: @(#)wd.c 7.2 (Berkeley) 5/9/91 - * $Id: wd.c,v 1.62 1994/12/13 18:20:08 guido Exp $ + * $Id: wd.c,v 1.63 1994/12/24 09:43:12 bde Exp $ */ /* TODO: @@ -1269,15 +1269,16 @@ wdgetctlr(struct disk *du) || wdwait(du, WDCS_READY | WDCS_SEEKCMPLT, TIMEOUT) != 0) return (1); - if (du->dk_unit == bootinfo.n_bios_used) { + if (du->dk_unit == bootinfo.bi_n_bios_used) { du->dk_dd.d_secsize = DEV_BSIZE; du->dk_dd.d_nsectors = - bootinfo.bios_geom[du->dk_unit] & 0xff; + bootinfo.bi_bios_geom[du->dk_unit] & 0xff; du->dk_dd.d_ntracks = - ((bootinfo.bios_geom[du->dk_unit] >> 8) & 0xff) +1; + ((bootinfo.bi_bios_geom[du->dk_unit] >> 8) & 0xff) + + 1; /* XXX Why 2 ? */ du->dk_dd.d_ncylinders = - (bootinfo.bios_geom[du->dk_unit] >> 16) + 2; + (bootinfo.bi_bios_geom[du->dk_unit] >> 16) + 2; du->dk_dd.d_secpercyl = du->dk_dd.d_ntracks * du->dk_dd.d_nsectors; du->dk_dd.d_secperunit = @@ -1290,7 +1291,7 @@ wdgetctlr(struct disk *du) sizeof du->dk_dd.d_typename); strncpy(du->dk_params.wdp_model, "ST506", sizeof du->dk_params.wdp_model); - bootinfo.n_bios_used ++; + bootinfo.bi_n_bios_used ++; return 0; } /*