From 12fafb2d5ae3a12b8dc46c12124b079cf798a991 Mon Sep 17 00:00:00 2001 From: "Rodney W. Grimes" Date: Sun, 2 Oct 1994 05:18:26 +0000 Subject: 1. Completely rewritten Makefile that uses bsd.prog.mk more effectively. 2. Clean up the .S files to use /* */ style comments. This is a totally cosmetic change, not one byte of the resulting boot code changes. But at least it is installed with correct owners and in the right places, and gets recompiled correctly when things change! --- sys/i386/boot/Makefile | 133 +++++++++--------------------- sys/i386/boot/asm.S | 132 +++++++++++++++--------------- sys/i386/boot/bios.S | 175 ++++++++++++++++++++-------------------- sys/i386/boot/biosboot/Makefile | 133 +++++++++--------------------- sys/i386/boot/biosboot/asm.S | 132 +++++++++++++++--------------- sys/i386/boot/biosboot/bios.S | 175 ++++++++++++++++++++-------------------- sys/i386/boot/biosboot/start.S | 106 ++++++++++++------------ sys/i386/boot/start.S | 106 ++++++++++++------------ 8 files changed, 498 insertions(+), 594 deletions(-) diff --git a/sys/i386/boot/Makefile b/sys/i386/boot/Makefile index 568fec905532..0c5d1386a091 100644 --- a/sys/i386/boot/Makefile +++ b/sys/i386/boot/Makefile @@ -1,107 +1,50 @@ +# $Id$ # -# Permission to use, copy, modify and distribute this software and its -# documentation is hereby granted, provided that both the copyright -# notice and this permission notice appear in all copies of the -# software, derivative works or modified versions, and any portions -# thereof, and that both notices appear in supporting documentation. -# -# CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" -# CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR -# ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. -# -# Carnegie Mellon requests users of this software to return to -# -# Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU -# School of Computer Science -# Carnegie Mellon University -# Pittsburgh PA 15213-3890 -# -# any improvements or extensions that they make and grant Carnegie Mellon -# the rights to redistribute these changes. -# -# from: Mach, Revision 2.2 92/04/04 11:33:46 rpd -# $Id: Makefile,v 1.15 1994/09/19 19:54:49 adam Exp $ -# - -wd0: - dd if=boot of=biosboot count=1 - dd if=boot of=bootbios skip=1 - disklabel -B -b biosboot -s bootbios wd0 - rm biosboot bootbios -NOPROG= noprog -NOMAN= noman +PROG= boot +# Order is very important on the SRCS line for this prog +SRCS= start.S table.c boot2.S boot.c asm.S bios.S io.c disk.c sys.c + +BINDIR= /usr/mdec +BINMODE= 444 +CFLAGS+= -O2 -DDO_BAD144 -DBOOTWAIT=${BOOTWAIT} +CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../.. +CLEANFILES+= boot.nohdr boot.strip boot1 boot2 +DPADD= ${LIBC} +LDFLAGS+= -N -T 0 -nostdlib +LDADD= -lc +LINKS= ${BINDIR}/sdboot ${BINDIR}/wdboot\ + ${BINDIR}/sdboot ${BINDIR}/fdboot\ + ${BINDIR}/bootsd ${BINDIR}/bootwd\ + ${BINDIR}/bootsd ${BINDIR}/bootfd +NOSHARED= YES +NOMAN= +STRIP= # tunable timeout parameter, waiting for keypress, calibrated in mS BOOTWAIT?= 5000 - -CFLAGS = -O2 -DDO_BAD144 -DBOOTWAIT=${BOOTWAIT} -I${.CURDIR} -LIBS= -lc -INC= -I${.CURDIR}/../.. - -# start.o should be first -OBJS = start.o table.o boot2.o boot.o asm.o bios.o io.o disk.o sys.o - -.SUFFIXES: .S .c .o - -.c.o: - $(CC) $(CFLAGS) $(INC) -c $< - -.S.o: - $(CC) $(CFLAGS) -c $< - -boot: $(OBJS) - $(LD) -Bstatic -N -T 0 -o boot $(OBJS) ${LDDESTDIR} $(LIBS) - cp boot boot.sym - @strip boot - @size boot - @sh ${.CURDIR}/rmaouthdr boot boot.tmp - @mv -f boot.tmp boot - @ls -l boot - -biosboot: boot - dd if=boot of=biosboot count=1 - -bootbios: boot - dd if=boot of=bootbios skip=1 - -${DESTDIR}/usr/mdec/bootsd: bootbios - cp bootbios ${DESTDIR}/usr/mdec/bootsd - -${DESTDIR}/usr/mdec/sdboot: biosboot - cp biosboot ${DESTDIR}/usr/mdec/sdboot - -${DESTDIR}/usr/mdec/bootwd: ${DESTDIR}/usr/mdec/bootsd - rm -f ${DESTDIR}/usr/mdec/bootwd - ln ${DESTDIR}/usr/mdec/bootsd ${DESTDIR}/usr/mdec/bootwd - -${DESTDIR}/usr/mdec/wdboot: ${DESTDIR}/usr/mdec/sdboot - rm -f ${DESTDIR}/usr/mdec/wdboot - ln ${DESTDIR}/usr/mdec/sdboot ${DESTDIR}/usr/mdec/wdboot - -${DESTDIR}/usr/mdec/bootfd: ${DESTDIR}/usr/mdec/bootsd - rm -f ${DESTDIR}/usr/mdec/bootfd - ln ${DESTDIR}/usr/mdec/bootsd ${DESTDIR}/usr/mdec/bootfd - -${DESTDIR}/usr/mdec/fdboot: ${DESTDIR}/usr/mdec/sdboot - rm -f ${DESTDIR}/usr/mdec/fdboot - ln ${DESTDIR}/usr/mdec/sdboot ${DESTDIR}/usr/mdec/fdboot -sd: ${DESTDIR}/usr/mdec/bootsd ${DESTDIR}/usr/mdec/sdboot -wd: ${DESTDIR}/usr/mdec/bootwd ${DESTDIR}/usr/mdec/wdboot -fd: ${DESTDIR}/usr/mdec/bootfd ${DESTDIR}/usr/mdec/fdboot +boot.strip: boot + cp -p boot boot.strip + strip boot.strip + size boot.strip -all: biosboot bootbios +boot.nohdr: boot.strip + dd if=boot.strip of=boot.nohdr ibs=32 skip=1 obs=1024b + ls -l boot.nohdr -fd0: - dd if=boot of=biosboot count=1 - dd if=boot of=bootbios skip=1 - disklabel -B -b biosboot -s bootbios fd0 - rm biosboot bootbios +boot1: boot.nohdr + dd if=boot.nohdr of=boot1 bs=512 count=1 -install: wd sd fd +boot2: boot.nohdr + dd if=boot.nohdr of=boot2 bs=512 skip=1 -clean: - /bin/rm -f *.o *.d boot bootbios biosboot boot.sym +all: boot1 boot2 +beforeinstall: + install ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}\ + boot1 ${BINDIR}/sdboot + install ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}\ + boot2 ${BINDIR}/bootsd + .include diff --git a/sys/i386/boot/asm.S b/sys/i386/boot/asm.S index f9bf4e06fd23..2993bc992ddf 100644 --- a/sys/i386/boot/asm.S +++ b/sys/i386/boot/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.2 1993/10/16 19:11:27 rgrimes Exp $ + * $Id: asm.S,v 1.3 1994/08/30 01:38:02 bde Exp $ */ @@ -63,88 +63,96 @@ CR0_PE_OFF = 0xfffffffe .text /* -# -# real_to_prot() -# transfer from real mode to protected mode. -*/ + * + * real_to_prot() + * transfer from real mode to protected mode. + */ ENTRY(real_to_prot) - # guarantee that interrupt is disabled when in prot mode + /* guarantee that interrupt is disabled when in prot mode */ cli - # load the gdtr + /* load the gdtr */ addr32 data32 lgdt EXT(Gdtr) - # set the PE bit of CR0 + /* set the PE bit of CR0 */ mov %cr0, %eax data32 or $CR0_PE_ON, %eax mov %eax, %cr0 - # make intrasegment jump to flush the processor pipeline and - # reload CS register + /* + * make intrasegment jump to flush the processor pipeline and + * reload CS register + */ data32 ljmp $0x18, $xprot xprot: - # we are in USE32 mode now - # set up the protected mode segment registers : DS, SS, ES + /* + * we are in USE32 mode now + * set up the protected mode segment registers : DS, SS, ES + */ mov $0x20, %eax movw %ax, %ds movw %ax, %ss movw %ax, %es #ifdef BDE_DEBUGGER - # load idtr so we can debug + /* load idtr so we can debug */ lidt EXT(Idtr_prot) #endif ret /* -# -# prot_to_real() -# transfer from protected mode to real mode -# -*/ + * + * prot_to_real() + * transfer from protected mode to real mode + * + */ ENTRY(prot_to_real) - # set up a dummy stack frame for the second seg change. + /* set up a dummy stack frame for the second seg change. */ movl _ouraddr, %eax sarl $4, %eax pushw %ax - movw $xreal, %ax # gas botches pushw $xreal - extra bytes 0, 0 - pushw %ax # decode to add %al, (%eax) (%al usually 0) + movw $xreal, %ax /* gas botches pushw $xreal, extra bytes 0, 0 */ + pushw %ax /* decode to add %al, (%eax) (%al usually 0) */ - # Change to use16 mode. + /* Change to use16 mode. */ ljmp $0x28, $x16 x16: - # clear the PE bit of CR0 + /* clear the PE bit of CR0 */ mov %cr0, %eax data32 and $CR0_PE_OFF, %eax mov %eax, %cr0 - # make intersegment jmp to flush the processor pipeline - # using the fake stack frame set up earlier - # and reload CS register + /* + * make intersegment jmp to flush the processor pipeline + * using the fake stack frame set up earlier + * and reload CS register + */ lret xreal: - # we are in real mode now - # set up the real mode segment registers : DS, SS, ES + /* + * we are in real mode now + * set up the real mode segment registers : DS, SS, ES + */ movw %cs, %ax movw %ax, %ds movw %ax, %ss movw %ax, %es #ifdef BDE_DEBUGGER - # load idtr so we can debug + /* load idtr so we can debug */ addr32 data32 lidt EXT(Idtr_real) @@ -154,49 +162,47 @@ xreal: ret /* -# -# startprog(phyaddr) -# start the program on protected mode where phyaddr is the entry point -# -*/ + * startprog(phyaddr) + * start the program on protected mode where phyaddr is the entry point + */ ENTRY(startprog) push %ebp mov %esp, %ebp - # get things we need into registers - movl 0x8(%ebp), %ecx # entry offset - movl 0x0c(%ebp), %eax # &argv + /* get things we need into registers */ + movl 0x8(%ebp), %ecx /* entry offset */ + movl 0x0c(%ebp), %eax /* &argv */ - # make a new stack at 0:0xa0000 (big segs) + /* make a new stack at 0:0xa0000 (big segs) */ mov $0x10, %ebx movw %bx, %ss movl $0xa0000, %ebx movl %ebx, %esp - # push some number of args onto the stack - pushl $0 # nominally a cyl offset in the boot. - pushl 0x8(%eax) # argv[2] = bootdev - pushl 0x4(%eax) # argv[1] = howto - pushl $0 # dummy 'return' address + /* push some number of args onto the stack */ + pushl $0 /* was a cyl offset in the boot. */ + pushl 0x8(%eax) /* argv[2] = bootdev */ + pushl 0x4(%eax) /* argv[1] = howto */ + pushl $0 /* dummy 'return' address */ - # push on our entry address - mov $0x08, %ebx # segment + /* push on our entry address */ + mov $0x08, %ebx /* segment */ pushl %ebx pushl %ecx - # convert over the other data segs + /* convert over the other data segs */ mov $0x10, %ebx movw %bx, %ds movw %bx, %es - # convert the PC (and code seg) + /* convert the PC (and code seg) */ lret /* -# -# pbzero( dst, cnt) -# where src is a virtual address and dst is a physical address -*/ + * + * pbzero( dst, cnt) + * where src is a virtual address and dst is a physical address + */ ENTRY(pbzero) push %ebp @@ -208,13 +214,13 @@ ENTRY(pbzero) cld - # set %es to point at the flat segment + /* set %es to point at the flat segment */ mov $0x10, %eax movw %ax, %es - mov 0x8(%ebp), %edi # destination - mov 0xc(%ebp), %ecx # count - mov $0x0, %eax # value + mov 0x8(%ebp), %edi /* destination */ + mov 0xc(%ebp), %ecx /* count */ + mov $0x0, %eax /* value */ rep stosb @@ -227,11 +233,9 @@ ENTRY(pbzero) ret /* -# -# pcpy(src, dst, cnt) -# where src is a virtual address and dst is a physical address -# -*/ + * pcpy(src, dst, cnt) + * where src is a virtual address and dst is a physical address + */ ENTRY(pcpy) push %ebp @@ -243,13 +247,13 @@ ENTRY(pcpy) cld - # set %es to point at the flat segment + /* set %es to point at the flat segment */ mov $0x10, %eax movw %ax, %es - mov 0x8(%ebp), %esi # source - mov 0xc(%ebp), %edi # destination - mov 0x10(%ebp), %ecx # count + mov 0x8(%ebp), %esi /* source */ + mov 0xc(%ebp), %edi /* destination */ + mov 0x10(%ebp), %ecx /* count */ rep movsb diff --git a/sys/i386/boot/bios.S b/sys/i386/boot/bios.S index 687ca18c7d4b..16ded4dfc7db 100644 --- a/sys/i386/boot/bios.S +++ b/sys/i386/boot/bios.S @@ -24,7 +24,7 @@ * the rights to redistribute these changes. * * from: Mach, Revision 2.2 92/04/04 11:34:26 rpd - * $Id$ + * $Id: bios.S,v 1.2 1993/10/16 19:11:30 rgrimes Exp $ */ /* @@ -56,19 +56,19 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .text /* -# biosread(dev, cyl, head, sec, nsec, offset) -# Read "nsec" sectors from disk to offset "offset" in boot segment -# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory -# Call with %ah = 0x2 -# %al = number of sectors -# %ch = cylinder -# %cl = sector -# %dh = head -# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) -# %es:%bx = segment:offset of buffer -# Return: -# %al = 0x0 on success; err code on failure -*/ + * biosread(dev, cyl, head, sec, nsec, offset) + * Read "nsec" sectors from disk to offset "offset" in boot segment + * BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory + * Call with %ah = 0x2 + * %al = number of sectors + * %ch = cylinder + * %cl = sector + * %dh = head + * %dl = drive (0x80 for hard disk, 0x0 for floppy disk) + * %es:%bx = segment:offset of buffer + * Return: + * %al = 0x0 on success; err code on failure + */ ENTRY(biosread) push %ebp @@ -81,31 +81,33 @@ ENTRY(biosread) movb 0x10(%ebp), %dh movw 0x0c(%ebp), %cx - xchgb %ch, %cl # cylinder; the highest 2 bits of cyl is in %cl + /* cylinder; the highest 2 bits of cyl is in %cl */ + xchgb %ch, %cl rorb $2, %cl movb 0x14(%ebp), %al orb %al, %cl - incb %cl # sector; sec starts from 1, not 0 - movb 0x8(%ebp), %dl # device - movl 0x1c(%ebp), %ebx # offset - # prot_to_real will set %es to BOOTSEG + incb %cl /* sector; sec starts from 1, not 0 */ + movb 0x8(%ebp), %dl /* device */ + movl 0x1c(%ebp), %ebx /* offset */ - call EXT(prot_to_real) # enter real mode - movb $0x2, %ah # subfunction + /* prot_to_real will set %es to BOOTSEG */ + call EXT(prot_to_real) /* enter real mode */ + movb $0x2, %ah /* subfunction */ addr32 - movb 0x18(%ebp), %al # number of sectors + movb 0x18(%ebp), %al /* number of sectors */ sti int $0x13 cli - mov %eax, %ebx # save return value (actually movw %ax, %bx) + /* save return value (actually movw %ax, %bx) */ + mov %eax, %ebx data32 - call EXT(real_to_prot) # back to protected mode + call EXT(real_to_prot) /* back to protected mode */ xor %eax, %eax - movb %bh, %al # return value in %ax + movb %bh, %al /* return value in %ax */ pop %es pop %edx @@ -117,13 +119,13 @@ ENTRY(biosread) /* -# putc(ch) -# BIOS call "INT 10H Function 0Eh" to write character to console -# Call with %ah = 0x0e -# %al = character -# %bh = page -# %bl = foreground color ( graphics modes) -*/ + * putc(ch) + * BIOS call "INT 10H Function 0Eh" to write character to console + * Call with %ah = 0x0e + * %al = character + * %bh = page + * %bl = foreground color ( graphics modes) + */ ENTRY(putc) @@ -137,11 +139,11 @@ ENTRY(putc) call EXT(prot_to_real) data32 - mov $0x1, %ebx # %bh=0, %bl=1 (blue) + mov $0x1, %ebx /* %bh=0, %bl=1 (blue) */ movb $0xe, %ah movb %cl, %al sti - int $0x10 # display a byte + int $0x10 /* display a byte */ cli data32 @@ -154,17 +156,17 @@ ENTRY(putc) /* -# getc() -# BIOS call "INT 16H Function 00H" to read character from keyboard -# Call with %ah = 0x0 -# Return: %ah = keyboard scan code -# %al = ASCII character -*/ + * getc() + * BIOS call "INT 16H Function 00H" to read character from keyboard + * Call with %ah = 0x0 + * Return: %ah = keyboard scan code + * %al = ASCII character + */ ENTRY(getc) push %ebp mov %esp, %ebp - push %ebx # save %ebx + push %ebx /* save %ebx */ call EXT(prot_to_real) @@ -173,7 +175,7 @@ ENTRY(getc) int $0x16 cli - movb %al, %bl # real_to_prot uses %eax + movb %al, %bl /* real_to_prot uses %eax */ data32 call EXT(real_to_prot) @@ -185,24 +187,24 @@ ENTRY(getc) pop %ebp ret /* -# ischar() -# if there is a character pending, return it; otherwise return 0 -# BIOS call "INT 16H Function 01H" to check whether a character is pending -# Call with %ah = 0x1 -# Return: -# If key waiting to be input: -# %ah = keyboard scan code -# %al = ASCII character -# Zero flag = clear -# else -# Zero flag = set -*/ + * ischar() + * if there is a character pending, return it; otherwise return 0 + * BIOS call "INT 16H Function 01H" to check whether a character is pending + * Call with %ah = 0x1 + * Return: + * If key waiting to be input: + * %ah = keyboard scan code + * %al = ASCII character + * Zero flag = clear + * else + * Zero flag = set + */ ENTRY(ischar) push %ebp mov %esp, %ebp push %ebx - call EXT(prot_to_real) # enter real mode + call EXT(prot_to_real) /* enter real mode */ xor %ebx, %ebx movb $0x1, %ah @@ -225,11 +227,11 @@ nochar: ret /* -# -# get_diskinfo(): return a word that represents the -# max number of sectors and heads and drives for this device -# -*/ + * + * get_diskinfo(): return a word that represents the + * max number of sectors and heads and drives for this device + * + */ ENTRY(get_diskinfo) push %ebp @@ -239,10 +241,10 @@ ENTRY(get_diskinfo) push %ecx push %edx - movb 0x8(%ebp), %dl # diskinfo(drive #) - call EXT(prot_to_real) # enter real mode + movb 0x8(%ebp), %dl /* diskinfo(drive #) */ + call EXT(prot_to_real) /* enter real mode */ - movb $0x8, %ah # ask for disk info + movb $0x8, %ah /* ask for disk info */ sti int $0x13 @@ -254,27 +256,28 @@ ENTRY(get_diskinfo) * Guess it's a 15-sector floppy. Initialize all the registers for * documentation, although we only need head and sector counts. */ - subb %ah, %ah # %ax = 0 + subb %ah, %ah /* %ax = 0 */ movb %al, %al - movb %ah, %bh # %bh = 0 - movb $2, %bl # %bl bits 0-3 = drive type, 2 = 1.2M - movb $79, %ch # max track - movb $15, %cl # max sector - movb $1, %dh # max head - movb $1, %dl # # floppy drives installed - # es:di = parameter table - # carry = 0 + movb %ah, %bh /* %bh = 0 */ + movb $2, %bl /* %bl bits 0-3 = drive type, + bit 2 = 1.2M */ + movb $79, %ch /* max track */ + movb $15, %cl /* max sector */ + movb $1, %dh /* max head */ + movb $1, %dl /* # floppy drives installed */ + /* es:di = parameter table */ + /* carry = 0 */ ok: data32 - call EXT(real_to_prot) # back to protected mode + call EXT(real_to_prot) /* back to protected mode */ xor %eax, %eax - /*form a longword representing all this gunk*/ - movb %dh, %ah # max head - andb $0x3f, %cl # mask of cylinder gunk - movb %cl, %al # max sector (and # sectors) + /* form a longword representing all this gunk */ + movb %dh, %ah /* max head */ + andb $0x3f, %cl /* mask of cylinder gunk */ + movb %cl, %al /* max sector (and # sectors) */ pop %edx pop %ecx @@ -284,14 +287,14 @@ ok: ret /* -# -# memsize(i) : return the memory size in KB. i == 0 for conventional memory, -# i == 1 for extended memory -# BIOS call "INT 12H" to get conventional memory size -# BIOS call "INT 15H, AH=88H" to get extended memory size -# Both have the return value in AX. -# -*/ + * + * memsize(i) : return the memory size in KB. i == 0 for conventional memory, + * i == 1 for extended memory + * BIOS call "INT 12H" to get conventional memory size + * BIOS call "INT 15H, AH=88H" to get extended memory size + * Both have the return value in AX. + * + */ ENTRY(memsize) push %ebp @@ -300,7 +303,7 @@ ENTRY(memsize) mov 8(%ebp), %ebx - call EXT(prot_to_real) # enter real mode + call EXT(prot_to_real) /* enter real mode */ cmpb $0x1, %bl data32 diff --git a/sys/i386/boot/biosboot/Makefile b/sys/i386/boot/biosboot/Makefile index 568fec905532..0c5d1386a091 100644 --- a/sys/i386/boot/biosboot/Makefile +++ b/sys/i386/boot/biosboot/Makefile @@ -1,107 +1,50 @@ +# $Id$ # -# Permission to use, copy, modify and distribute this software and its -# documentation is hereby granted, provided that both the copyright -# notice and this permission notice appear in all copies of the -# software, derivative works or modified versions, and any portions -# thereof, and that both notices appear in supporting documentation. -# -# CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" -# CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR -# ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. -# -# Carnegie Mellon requests users of this software to return to -# -# Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU -# School of Computer Science -# Carnegie Mellon University -# Pittsburgh PA 15213-3890 -# -# any improvements or extensions that they make and grant Carnegie Mellon -# the rights to redistribute these changes. -# -# from: Mach, Revision 2.2 92/04/04 11:33:46 rpd -# $Id: Makefile,v 1.15 1994/09/19 19:54:49 adam Exp $ -# - -wd0: - dd if=boot of=biosboot count=1 - dd if=boot of=bootbios skip=1 - disklabel -B -b biosboot -s bootbios wd0 - rm biosboot bootbios -NOPROG= noprog -NOMAN= noman +PROG= boot +# Order is very important on the SRCS line for this prog +SRCS= start.S table.c boot2.S boot.c asm.S bios.S io.c disk.c sys.c + +BINDIR= /usr/mdec +BINMODE= 444 +CFLAGS+= -O2 -DDO_BAD144 -DBOOTWAIT=${BOOTWAIT} +CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../.. +CLEANFILES+= boot.nohdr boot.strip boot1 boot2 +DPADD= ${LIBC} +LDFLAGS+= -N -T 0 -nostdlib +LDADD= -lc +LINKS= ${BINDIR}/sdboot ${BINDIR}/wdboot\ + ${BINDIR}/sdboot ${BINDIR}/fdboot\ + ${BINDIR}/bootsd ${BINDIR}/bootwd\ + ${BINDIR}/bootsd ${BINDIR}/bootfd +NOSHARED= YES +NOMAN= +STRIP= # tunable timeout parameter, waiting for keypress, calibrated in mS BOOTWAIT?= 5000 - -CFLAGS = -O2 -DDO_BAD144 -DBOOTWAIT=${BOOTWAIT} -I${.CURDIR} -LIBS= -lc -INC= -I${.CURDIR}/../.. - -# start.o should be first -OBJS = start.o table.o boot2.o boot.o asm.o bios.o io.o disk.o sys.o - -.SUFFIXES: .S .c .o - -.c.o: - $(CC) $(CFLAGS) $(INC) -c $< - -.S.o: - $(CC) $(CFLAGS) -c $< - -boot: $(OBJS) - $(LD) -Bstatic -N -T 0 -o boot $(OBJS) ${LDDESTDIR} $(LIBS) - cp boot boot.sym - @strip boot - @size boot - @sh ${.CURDIR}/rmaouthdr boot boot.tmp - @mv -f boot.tmp boot - @ls -l boot - -biosboot: boot - dd if=boot of=biosboot count=1 - -bootbios: boot - dd if=boot of=bootbios skip=1 - -${DESTDIR}/usr/mdec/bootsd: bootbios - cp bootbios ${DESTDIR}/usr/mdec/bootsd - -${DESTDIR}/usr/mdec/sdboot: biosboot - cp biosboot ${DESTDIR}/usr/mdec/sdboot - -${DESTDIR}/usr/mdec/bootwd: ${DESTDIR}/usr/mdec/bootsd - rm -f ${DESTDIR}/usr/mdec/bootwd - ln ${DESTDIR}/usr/mdec/bootsd ${DESTDIR}/usr/mdec/bootwd - -${DESTDIR}/usr/mdec/wdboot: ${DESTDIR}/usr/mdec/sdboot - rm -f ${DESTDIR}/usr/mdec/wdboot - ln ${DESTDIR}/usr/mdec/sdboot ${DESTDIR}/usr/mdec/wdboot - -${DESTDIR}/usr/mdec/bootfd: ${DESTDIR}/usr/mdec/bootsd - rm -f ${DESTDIR}/usr/mdec/bootfd - ln ${DESTDIR}/usr/mdec/bootsd ${DESTDIR}/usr/mdec/bootfd - -${DESTDIR}/usr/mdec/fdboot: ${DESTDIR}/usr/mdec/sdboot - rm -f ${DESTDIR}/usr/mdec/fdboot - ln ${DESTDIR}/usr/mdec/sdboot ${DESTDIR}/usr/mdec/fdboot -sd: ${DESTDIR}/usr/mdec/bootsd ${DESTDIR}/usr/mdec/sdboot -wd: ${DESTDIR}/usr/mdec/bootwd ${DESTDIR}/usr/mdec/wdboot -fd: ${DESTDIR}/usr/mdec/bootfd ${DESTDIR}/usr/mdec/fdboot +boot.strip: boot + cp -p boot boot.strip + strip boot.strip + size boot.strip -all: biosboot bootbios +boot.nohdr: boot.strip + dd if=boot.strip of=boot.nohdr ibs=32 skip=1 obs=1024b + ls -l boot.nohdr -fd0: - dd if=boot of=biosboot count=1 - dd if=boot of=bootbios skip=1 - disklabel -B -b biosboot -s bootbios fd0 - rm biosboot bootbios +boot1: boot.nohdr + dd if=boot.nohdr of=boot1 bs=512 count=1 -install: wd sd fd +boot2: boot.nohdr + dd if=boot.nohdr of=boot2 bs=512 skip=1 -clean: - /bin/rm -f *.o *.d boot bootbios biosboot boot.sym +all: boot1 boot2 +beforeinstall: + install ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}\ + boot1 ${BINDIR}/sdboot + install ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}\ + boot2 ${BINDIR}/bootsd + .include diff --git a/sys/i386/boot/biosboot/asm.S b/sys/i386/boot/biosboot/asm.S index f9bf4e06fd23..2993bc992ddf 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.2 1993/10/16 19:11:27 rgrimes Exp $ + * $Id: asm.S,v 1.3 1994/08/30 01:38:02 bde Exp $ */ @@ -63,88 +63,96 @@ CR0_PE_OFF = 0xfffffffe .text /* -# -# real_to_prot() -# transfer from real mode to protected mode. -*/ + * + * real_to_prot() + * transfer from real mode to protected mode. + */ ENTRY(real_to_prot) - # guarantee that interrupt is disabled when in prot mode + /* guarantee that interrupt is disabled when in prot mode */ cli - # load the gdtr + /* load the gdtr */ addr32 data32 lgdt EXT(Gdtr) - # set the PE bit of CR0 + /* set the PE bit of CR0 */ mov %cr0, %eax data32 or $CR0_PE_ON, %eax mov %eax, %cr0 - # make intrasegment jump to flush the processor pipeline and - # reload CS register + /* + * make intrasegment jump to flush the processor pipeline and + * reload CS register + */ data32 ljmp $0x18, $xprot xprot: - # we are in USE32 mode now - # set up the protected mode segment registers : DS, SS, ES + /* + * we are in USE32 mode now + * set up the protected mode segment registers : DS, SS, ES + */ mov $0x20, %eax movw %ax, %ds movw %ax, %ss movw %ax, %es #ifdef BDE_DEBUGGER - # load idtr so we can debug + /* load idtr so we can debug */ lidt EXT(Idtr_prot) #endif ret /* -# -# prot_to_real() -# transfer from protected mode to real mode -# -*/ + * + * prot_to_real() + * transfer from protected mode to real mode + * + */ ENTRY(prot_to_real) - # set up a dummy stack frame for the second seg change. + /* set up a dummy stack frame for the second seg change. */ movl _ouraddr, %eax sarl $4, %eax pushw %ax - movw $xreal, %ax # gas botches pushw $xreal - extra bytes 0, 0 - pushw %ax # decode to add %al, (%eax) (%al usually 0) + movw $xreal, %ax /* gas botches pushw $xreal, extra bytes 0, 0 */ + pushw %ax /* decode to add %al, (%eax) (%al usually 0) */ - # Change to use16 mode. + /* Change to use16 mode. */ ljmp $0x28, $x16 x16: - # clear the PE bit of CR0 + /* clear the PE bit of CR0 */ mov %cr0, %eax data32 and $CR0_PE_OFF, %eax mov %eax, %cr0 - # make intersegment jmp to flush the processor pipeline - # using the fake stack frame set up earlier - # and reload CS register + /* + * make intersegment jmp to flush the processor pipeline + * using the fake stack frame set up earlier + * and reload CS register + */ lret xreal: - # we are in real mode now - # set up the real mode segment registers : DS, SS, ES + /* + * we are in real mode now + * set up the real mode segment registers : DS, SS, ES + */ movw %cs, %ax movw %ax, %ds movw %ax, %ss movw %ax, %es #ifdef BDE_DEBUGGER - # load idtr so we can debug + /* load idtr so we can debug */ addr32 data32 lidt EXT(Idtr_real) @@ -154,49 +162,47 @@ xreal: ret /* -# -# startprog(phyaddr) -# start the program on protected mode where phyaddr is the entry point -# -*/ + * startprog(phyaddr) + * start the program on protected mode where phyaddr is the entry point + */ ENTRY(startprog) push %ebp mov %esp, %ebp - # get things we need into registers - movl 0x8(%ebp), %ecx # entry offset - movl 0x0c(%ebp), %eax # &argv + /* get things we need into registers */ + movl 0x8(%ebp), %ecx /* entry offset */ + movl 0x0c(%ebp), %eax /* &argv */ - # make a new stack at 0:0xa0000 (big segs) + /* make a new stack at 0:0xa0000 (big segs) */ mov $0x10, %ebx movw %bx, %ss movl $0xa0000, %ebx movl %ebx, %esp - # push some number of args onto the stack - pushl $0 # nominally a cyl offset in the boot. - pushl 0x8(%eax) # argv[2] = bootdev - pushl 0x4(%eax) # argv[1] = howto - pushl $0 # dummy 'return' address + /* push some number of args onto the stack */ + pushl $0 /* was a cyl offset in the boot. */ + pushl 0x8(%eax) /* argv[2] = bootdev */ + pushl 0x4(%eax) /* argv[1] = howto */ + pushl $0 /* dummy 'return' address */ - # push on our entry address - mov $0x08, %ebx # segment + /* push on our entry address */ + mov $0x08, %ebx /* segment */ pushl %ebx pushl %ecx - # convert over the other data segs + /* convert over the other data segs */ mov $0x10, %ebx movw %bx, %ds movw %bx, %es - # convert the PC (and code seg) + /* convert the PC (and code seg) */ lret /* -# -# pbzero( dst, cnt) -# where src is a virtual address and dst is a physical address -*/ + * + * pbzero( dst, cnt) + * where src is a virtual address and dst is a physical address + */ ENTRY(pbzero) push %ebp @@ -208,13 +214,13 @@ ENTRY(pbzero) cld - # set %es to point at the flat segment + /* set %es to point at the flat segment */ mov $0x10, %eax movw %ax, %es - mov 0x8(%ebp), %edi # destination - mov 0xc(%ebp), %ecx # count - mov $0x0, %eax # value + mov 0x8(%ebp), %edi /* destination */ + mov 0xc(%ebp), %ecx /* count */ + mov $0x0, %eax /* value */ rep stosb @@ -227,11 +233,9 @@ ENTRY(pbzero) ret /* -# -# pcpy(src, dst, cnt) -# where src is a virtual address and dst is a physical address -# -*/ + * pcpy(src, dst, cnt) + * where src is a virtual address and dst is a physical address + */ ENTRY(pcpy) push %ebp @@ -243,13 +247,13 @@ ENTRY(pcpy) cld - # set %es to point at the flat segment + /* set %es to point at the flat segment */ mov $0x10, %eax movw %ax, %es - mov 0x8(%ebp), %esi # source - mov 0xc(%ebp), %edi # destination - mov 0x10(%ebp), %ecx # count + mov 0x8(%ebp), %esi /* source */ + mov 0xc(%ebp), %edi /* destination */ + mov 0x10(%ebp), %ecx /* count */ rep movsb diff --git a/sys/i386/boot/biosboot/bios.S b/sys/i386/boot/biosboot/bios.S index 687ca18c7d4b..16ded4dfc7db 100644 --- a/sys/i386/boot/biosboot/bios.S +++ b/sys/i386/boot/biosboot/bios.S @@ -24,7 +24,7 @@ * the rights to redistribute these changes. * * from: Mach, Revision 2.2 92/04/04 11:34:26 rpd - * $Id$ + * $Id: bios.S,v 1.2 1993/10/16 19:11:30 rgrimes Exp $ */ /* @@ -56,19 +56,19 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .text /* -# biosread(dev, cyl, head, sec, nsec, offset) -# Read "nsec" sectors from disk to offset "offset" in boot segment -# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory -# Call with %ah = 0x2 -# %al = number of sectors -# %ch = cylinder -# %cl = sector -# %dh = head -# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) -# %es:%bx = segment:offset of buffer -# Return: -# %al = 0x0 on success; err code on failure -*/ + * biosread(dev, cyl, head, sec, nsec, offset) + * Read "nsec" sectors from disk to offset "offset" in boot segment + * BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory + * Call with %ah = 0x2 + * %al = number of sectors + * %ch = cylinder + * %cl = sector + * %dh = head + * %dl = drive (0x80 for hard disk, 0x0 for floppy disk) + * %es:%bx = segment:offset of buffer + * Return: + * %al = 0x0 on success; err code on failure + */ ENTRY(biosread) push %ebp @@ -81,31 +81,33 @@ ENTRY(biosread) movb 0x10(%ebp), %dh movw 0x0c(%ebp), %cx - xchgb %ch, %cl # cylinder; the highest 2 bits of cyl is in %cl + /* cylinder; the highest 2 bits of cyl is in %cl */ + xchgb %ch, %cl rorb $2, %cl movb 0x14(%ebp), %al orb %al, %cl - incb %cl # sector; sec starts from 1, not 0 - movb 0x8(%ebp), %dl # device - movl 0x1c(%ebp), %ebx # offset - # prot_to_real will set %es to BOOTSEG + incb %cl /* sector; sec starts from 1, not 0 */ + movb 0x8(%ebp), %dl /* device */ + movl 0x1c(%ebp), %ebx /* offset */ - call EXT(prot_to_real) # enter real mode - movb $0x2, %ah # subfunction + /* prot_to_real will set %es to BOOTSEG */ + call EXT(prot_to_real) /* enter real mode */ + movb $0x2, %ah /* subfunction */ addr32 - movb 0x18(%ebp), %al # number of sectors + movb 0x18(%ebp), %al /* number of sectors */ sti int $0x13 cli - mov %eax, %ebx # save return value (actually movw %ax, %bx) + /* save return value (actually movw %ax, %bx) */ + mov %eax, %ebx data32 - call EXT(real_to_prot) # back to protected mode + call EXT(real_to_prot) /* back to protected mode */ xor %eax, %eax - movb %bh, %al # return value in %ax + movb %bh, %al /* return value in %ax */ pop %es pop %edx @@ -117,13 +119,13 @@ ENTRY(biosread) /* -# putc(ch) -# BIOS call "INT 10H Function 0Eh" to write character to console -# Call with %ah = 0x0e -# %al = character -# %bh = page -# %bl = foreground color ( graphics modes) -*/ + * putc(ch) + * BIOS call "INT 10H Function 0Eh" to write character to console + * Call with %ah = 0x0e + * %al = character + * %bh = page + * %bl = foreground color ( graphics modes) + */ ENTRY(putc) @@ -137,11 +139,11 @@ ENTRY(putc) call EXT(prot_to_real) data32 - mov $0x1, %ebx # %bh=0, %bl=1 (blue) + mov $0x1, %ebx /* %bh=0, %bl=1 (blue) */ movb $0xe, %ah movb %cl, %al sti - int $0x10 # display a byte + int $0x10 /* display a byte */ cli data32 @@ -154,17 +156,17 @@ ENTRY(putc) /* -# getc() -# BIOS call "INT 16H Function 00H" to read character from keyboard -# Call with %ah = 0x0 -# Return: %ah = keyboard scan code -# %al = ASCII character -*/ + * getc() + * BIOS call "INT 16H Function 00H" to read character from keyboard + * Call with %ah = 0x0 + * Return: %ah = keyboard scan code + * %al = ASCII character + */ ENTRY(getc) push %ebp mov %esp, %ebp - push %ebx # save %ebx + push %ebx /* save %ebx */ call EXT(prot_to_real) @@ -173,7 +175,7 @@ ENTRY(getc) int $0x16 cli - movb %al, %bl # real_to_prot uses %eax + movb %al, %bl /* real_to_prot uses %eax */ data32 call EXT(real_to_prot) @@ -185,24 +187,24 @@ ENTRY(getc) pop %ebp ret /* -# ischar() -# if there is a character pending, return it; otherwise return 0 -# BIOS call "INT 16H Function 01H" to check whether a character is pending -# Call with %ah = 0x1 -# Return: -# If key waiting to be input: -# %ah = keyboard scan code -# %al = ASCII character -# Zero flag = clear -# else -# Zero flag = set -*/ + * ischar() + * if there is a character pending, return it; otherwise return 0 + * BIOS call "INT 16H Function 01H" to check whether a character is pending + * Call with %ah = 0x1 + * Return: + * If key waiting to be input: + * %ah = keyboard scan code + * %al = ASCII character + * Zero flag = clear + * else + * Zero flag = set + */ ENTRY(ischar) push %ebp mov %esp, %ebp push %ebx - call EXT(prot_to_real) # enter real mode + call EXT(prot_to_real) /* enter real mode */ xor %ebx, %ebx movb $0x1, %ah @@ -225,11 +227,11 @@ nochar: ret /* -# -# get_diskinfo(): return a word that represents the -# max number of sectors and heads and drives for this device -# -*/ + * + * get_diskinfo(): return a word that represents the + * max number of sectors and heads and drives for this device + * + */ ENTRY(get_diskinfo) push %ebp @@ -239,10 +241,10 @@ ENTRY(get_diskinfo) push %ecx push %edx - movb 0x8(%ebp), %dl # diskinfo(drive #) - call EXT(prot_to_real) # enter real mode + movb 0x8(%ebp), %dl /* diskinfo(drive #) */ + call EXT(prot_to_real) /* enter real mode */ - movb $0x8, %ah # ask for disk info + movb $0x8, %ah /* ask for disk info */ sti int $0x13 @@ -254,27 +256,28 @@ ENTRY(get_diskinfo) * Guess it's a 15-sector floppy. Initialize all the registers for * documentation, although we only need head and sector counts. */ - subb %ah, %ah # %ax = 0 + subb %ah, %ah /* %ax = 0 */ movb %al, %al - movb %ah, %bh # %bh = 0 - movb $2, %bl # %bl bits 0-3 = drive type, 2 = 1.2M - movb $79, %ch # max track - movb $15, %cl # max sector - movb $1, %dh # max head - movb $1, %dl # # floppy drives installed - # es:di = parameter table - # carry = 0 + movb %ah, %bh /* %bh = 0 */ + movb $2, %bl /* %bl bits 0-3 = drive type, + bit 2 = 1.2M */ + movb $79, %ch /* max track */ + movb $15, %cl /* max sector */ + movb $1, %dh /* max head */ + movb $1, %dl /* # floppy drives installed */ + /* es:di = parameter table */ + /* carry = 0 */ ok: data32 - call EXT(real_to_prot) # back to protected mode + call EXT(real_to_prot) /* back to protected mode */ xor %eax, %eax - /*form a longword representing all this gunk*/ - movb %dh, %ah # max head - andb $0x3f, %cl # mask of cylinder gunk - movb %cl, %al # max sector (and # sectors) + /* form a longword representing all this gunk */ + movb %dh, %ah /* max head */ + andb $0x3f, %cl /* mask of cylinder gunk */ + movb %cl, %al /* max sector (and # sectors) */ pop %edx pop %ecx @@ -284,14 +287,14 @@ ok: ret /* -# -# memsize(i) : return the memory size in KB. i == 0 for conventional memory, -# i == 1 for extended memory -# BIOS call "INT 12H" to get conventional memory size -# BIOS call "INT 15H, AH=88H" to get extended memory size -# Both have the return value in AX. -# -*/ + * + * memsize(i) : return the memory size in KB. i == 0 for conventional memory, + * i == 1 for extended memory + * BIOS call "INT 12H" to get conventional memory size + * BIOS call "INT 15H, AH=88H" to get extended memory size + * Both have the return value in AX. + * + */ ENTRY(memsize) push %ebp @@ -300,7 +303,7 @@ ENTRY(memsize) mov 8(%ebp), %ebx - call EXT(prot_to_real) # enter real mode + call EXT(prot_to_real) /* enter real mode */ cmpb $0x1, %bl data32 diff --git a/sys/i386/boot/biosboot/start.S b/sys/i386/boot/biosboot/start.S index aa6521293d9b..7b1770147093 100644 --- a/sys/i386/boot/biosboot/start.S +++ b/sys/i386/boot/biosboot/start.S @@ -24,7 +24,7 @@ * the rights to redistribute these changes. * * from: Mach, Revision 2.2 92/04/04 11:36:29 rpd - * $Id: start.S,v 1.2 1993/10/16 19:11:38 rgrimes Exp $ + * $Id: start.S,v 1.3 1994/06/13 19:27:52 jkh Exp $ */ /* @@ -53,37 +53,39 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .file "start.s" -BOOTSEG = 0x9000 # boot will be loaded here (below 640K) -BOOTSTACK = 0xe000 # boot stack -SIGNATURE = 0xaa55 -LOADSZ = 15 # size of unix boot -PARTSTART = 0x1be # starting address of partition table -NUMPART = 4 # number of partitions in partition table -PARTSZ = 16 # each partition table entry is 16 bytes -BSDPART = 0xA5 # value of boot_ind, means bootable partition -BOOTABLE = 0x80 # value of boot_ind, means bootable partition +BOOTSEG= 0x9000 /* boot will be loaded here (below 640K) */ +BOOTSTACK= 0xe000 /* boot stack */ +SIGNATURE= 0xaa55 +LOADSZ= 15 /* size of unix boot */ +PARTSTART= 0x1be /* starting address of partition table */ +NUMPART= 4 /* number of partitions in partition table */ +PARTSZ= 16 /* each partition table entry is 16 bytes */ +BSDPART= 0xA5 /* value of boot_ind, means bootable partition */ +BOOTABLE= 0x80 /* value of boot_ind, means bootable partition */ .text ENTRY(boot1) - # start (aka boot1) is loaded at 0x0:0x7c00 but we want 0x7c0:0 - # ljmp to the next instruction to adjust %cs + /* + * start (aka boot1) is loaded at 0x0:0x7c00 but we want 0x7c0:0 + * ljmp to the next instruction to adjust %cs + */ data32 ljmp $0x7c0, $start start: - # set up %ds + /* set up %ds */ mov %cs, %ax mov %ax, %ds - # set up %ss and %esp + /* set up %ss and %esp */ data32 mov $BOOTSEG, %eax mov %ax, %ss data32 mov $BOOTSTACK, %esp - /*** set up %es, (where we will load boot2 to) ***/ + /* set up %es, (where we will load boot2 to) */ mov %ax, %es #ifdef DEBUG @@ -93,14 +95,14 @@ start: call message #endif - # bootstrap passes us drive number in %dl + /* bootstrap passes us drive number in %dl */ cmpb $0x80, %dl data32 jae hd fd: mov $0x0, %dl -# reset the disk system + /* reset the disk system */ #ifdef DEBUG data32 mov $two, %esi @@ -110,8 +112,8 @@ fd: movb $0x0, %ah int $0x13 data32 - mov $0x0001, %ecx # cyl 0, sector 1 - movb $0, %dh # head + mov $0x0001, %ecx /* cyl 0, sector 1 */ + movb $0, %dh /* head */ #ifdef DEBUG data32 mov $three, %esi @@ -130,7 +132,7 @@ hd: /**** load sector 0 into the BOOTSEG ****/ #endif data32 mov $0x0201, %eax - xor %ebx, %ebx # %bx = 0 + xor %ebx, %ebx /* %bx = 0 */ data32 mov $0x0001, %ecx #ifdef DEBUG @@ -146,14 +148,14 @@ hd: /**** load sector 0 into the BOOTSEG ****/ data32 jb read_error - /***# find the first 386BSD partition *****/ + /* find the first 386BSD partition */ data32 mov $PARTSTART, %ebx data32 mov $NUMPART, %ecx again: addr32 - movb %es:4(%ebx), %al + movb %es:4(%ebx), %al cmpb $BSDPART, %al data32 je found @@ -168,17 +170,17 @@ again: /* -# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory -# Call with %ah = 0x2 -# %al = number of sectors -# %ch = cylinder -# %cl = sector -# %dh = head -# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) -# %es:%bx = segment:offset of buffer -# Return: -# %al = 0x0 on success; err code on failure -*/ + * BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory + * Call with %ah = 0x2 + * %al = number of sectors + * %ch = cylinder + * %cl = sector + * %dh = head + * %dl = drive (0x80 for hard disk, 0x0 for floppy disk) + * %es:%bx = segment:offset of buffer + * Return: + * %al = 0x0 on success; err code on failure + */ found: addr32 @@ -194,9 +196,11 @@ load: data32 jb read_error - # ljmp to the second stage boot loader (boot2). - # After ljmp, %cs is BOOTSEG and boot1 (512 bytes) will be used - # as an internal buffer "intbuf". + /* + * ljmp to the second stage boot loader (boot2). + * After ljmp, %cs is BOOTSEG and boot1 (512 bytes) will be used + * as an internal buffer "intbuf". + */ #ifdef DEBUG data32 @@ -207,10 +211,9 @@ load: data32 ljmp $BOOTSEG, $ EXT(boot2) -# -# read_error -# - +/* + * read_error + */ read_error: data32 mov $eread, %esi @@ -220,16 +223,15 @@ err_stop: data32 jmp stop -# -# message: write the error message in %ds:%esi to console -# - -message: /* - # Use BIOS "int 10H Function 0Eh" to write character in teletype mode - # %ah = 0xe %al = character - # %bh = page %bl = foreground color (graphics modes) -*/ + * message: write the error message in %ds:%esi to console + */ +message: + /* + * Use BIOS "int 10H Function 0Eh" to write character in teletype mode + * %ah = 0xe %al = character + * %bh = page %bl = foreground color (graphics modes) + */ data32 push %eax @@ -240,12 +242,12 @@ message: cld nextb: - lodsb # load a byte into %al + lodsb /* load a byte into %al */ cmpb $0x0, %al data32 je done movb $0xe, %ah - int $0x10 # display a byte + int $0x10 /* display a byte */ data32 jmp nextb done: @@ -258,7 +260,7 @@ done: stop: hlt data32 - jmp stop # halt doesnt actually halt forever + jmp stop /* halt doesnt actually halt forever */ /* error messages */ diff --git a/sys/i386/boot/start.S b/sys/i386/boot/start.S index aa6521293d9b..7b1770147093 100644 --- a/sys/i386/boot/start.S +++ b/sys/i386/boot/start.S @@ -24,7 +24,7 @@ * the rights to redistribute these changes. * * from: Mach, Revision 2.2 92/04/04 11:36:29 rpd - * $Id: start.S,v 1.2 1993/10/16 19:11:38 rgrimes Exp $ + * $Id: start.S,v 1.3 1994/06/13 19:27:52 jkh Exp $ */ /* @@ -53,37 +53,39 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .file "start.s" -BOOTSEG = 0x9000 # boot will be loaded here (below 640K) -BOOTSTACK = 0xe000 # boot stack -SIGNATURE = 0xaa55 -LOADSZ = 15 # size of unix boot -PARTSTART = 0x1be # starting address of partition table -NUMPART = 4 # number of partitions in partition table -PARTSZ = 16 # each partition table entry is 16 bytes -BSDPART = 0xA5 # value of boot_ind, means bootable partition -BOOTABLE = 0x80 # value of boot_ind, means bootable partition +BOOTSEG= 0x9000 /* boot will be loaded here (below 640K) */ +BOOTSTACK= 0xe000 /* boot stack */ +SIGNATURE= 0xaa55 +LOADSZ= 15 /* size of unix boot */ +PARTSTART= 0x1be /* starting address of partition table */ +NUMPART= 4 /* number of partitions in partition table */ +PARTSZ= 16 /* each partition table entry is 16 bytes */ +BSDPART= 0xA5 /* value of boot_ind, means bootable partition */ +BOOTABLE= 0x80 /* value of boot_ind, means bootable partition */ .text ENTRY(boot1) - # start (aka boot1) is loaded at 0x0:0x7c00 but we want 0x7c0:0 - # ljmp to the next instruction to adjust %cs + /* + * start (aka boot1) is loaded at 0x0:0x7c00 but we want 0x7c0:0 + * ljmp to the next instruction to adjust %cs + */ data32 ljmp $0x7c0, $start start: - # set up %ds + /* set up %ds */ mov %cs, %ax mov %ax, %ds - # set up %ss and %esp + /* set up %ss and %esp */ data32 mov $BOOTSEG, %eax mov %ax, %ss data32 mov $BOOTSTACK, %esp - /*** set up %es, (where we will load boot2 to) ***/ + /* set up %es, (where we will load boot2 to) */ mov %ax, %es #ifdef DEBUG @@ -93,14 +95,14 @@ start: call message #endif - # bootstrap passes us drive number in %dl + /* bootstrap passes us drive number in %dl */ cmpb $0x80, %dl data32 jae hd fd: mov $0x0, %dl -# reset the disk system + /* reset the disk system */ #ifdef DEBUG data32 mov $two, %esi @@ -110,8 +112,8 @@ fd: movb $0x0, %ah int $0x13 data32 - mov $0x0001, %ecx # cyl 0, sector 1 - movb $0, %dh # head + mov $0x0001, %ecx /* cyl 0, sector 1 */ + movb $0, %dh /* head */ #ifdef DEBUG data32 mov $three, %esi @@ -130,7 +132,7 @@ hd: /**** load sector 0 into the BOOTSEG ****/ #endif data32 mov $0x0201, %eax - xor %ebx, %ebx # %bx = 0 + xor %ebx, %ebx /* %bx = 0 */ data32 mov $0x0001, %ecx #ifdef DEBUG @@ -146,14 +148,14 @@ hd: /**** load sector 0 into the BOOTSEG ****/ data32 jb read_error - /***# find the first 386BSD partition *****/ + /* find the first 386BSD partition */ data32 mov $PARTSTART, %ebx data32 mov $NUMPART, %ecx again: addr32 - movb %es:4(%ebx), %al + movb %es:4(%ebx), %al cmpb $BSDPART, %al data32 je found @@ -168,17 +170,17 @@ again: /* -# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory -# Call with %ah = 0x2 -# %al = number of sectors -# %ch = cylinder -# %cl = sector -# %dh = head -# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) -# %es:%bx = segment:offset of buffer -# Return: -# %al = 0x0 on success; err code on failure -*/ + * BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory + * Call with %ah = 0x2 + * %al = number of sectors + * %ch = cylinder + * %cl = sector + * %dh = head + * %dl = drive (0x80 for hard disk, 0x0 for floppy disk) + * %es:%bx = segment:offset of buffer + * Return: + * %al = 0x0 on success; err code on failure + */ found: addr32 @@ -194,9 +196,11 @@ load: data32 jb read_error - # ljmp to the second stage boot loader (boot2). - # After ljmp, %cs is BOOTSEG and boot1 (512 bytes) will be used - # as an internal buffer "intbuf". + /* + * ljmp to the second stage boot loader (boot2). + * After ljmp, %cs is BOOTSEG and boot1 (512 bytes) will be used + * as an internal buffer "intbuf". + */ #ifdef DEBUG data32 @@ -207,10 +211,9 @@ load: data32 ljmp $BOOTSEG, $ EXT(boot2) -# -# read_error -# - +/* + * read_error + */ read_error: data32 mov $eread, %esi @@ -220,16 +223,15 @@ err_stop: data32 jmp stop -# -# message: write the error message in %ds:%esi to console -# - -message: /* - # Use BIOS "int 10H Function 0Eh" to write character in teletype mode - # %ah = 0xe %al = character - # %bh = page %bl = foreground color (graphics modes) -*/ + * message: write the error message in %ds:%esi to console + */ +message: + /* + * Use BIOS "int 10H Function 0Eh" to write character in teletype mode + * %ah = 0xe %al = character + * %bh = page %bl = foreground color (graphics modes) + */ data32 push %eax @@ -240,12 +242,12 @@ message: cld nextb: - lodsb # load a byte into %al + lodsb /* load a byte into %al */ cmpb $0x0, %al data32 je done movb $0xe, %ah - int $0x10 # display a byte + int $0x10 /* display a byte */ data32 jmp nextb done: @@ -258,7 +260,7 @@ done: stop: hlt data32 - jmp stop # halt doesnt actually halt forever + jmp stop /* halt doesnt actually halt forever */ /* error messages */ -- cgit v1.3