Index: head/sys/boot/i386/boot2/Makefile =================================================================== --- head/sys/boot/i386/boot2/Makefile (revision 220336) +++ head/sys/boot/i386/boot2/Makefile (revision 220337) @@ -1,108 +1,109 @@ # $FreeBSD$ .include # XXX: clang can compile the boot code just fine, but boot2 gets too big CC:=${CC:C/^(.*\/)?clang$/gcc/1} FILES= boot boot1 boot2 NM?= nm # A value of 0x80 enables LBA support. BOOT_BOOT1_FLAGS?= 0x80 BOOT_COMCONSOLE_PORT?= 0x3f8 BOOT_COMCONSOLE_SPEED?= 9600 B2SIOFMT?= 0x3 REL1= 0x700 ORG1= 0x7c00 ORG2= 0x2000 # Decide level of UFS support. BOOT2_UFS?= UFS1_AND_UFS2 #BOOT2_UFS?= UFS2_ONLY #BOOT2_UFS?= UFS1_ONLY CFLAGS= -Os \ -fno-guess-branch-probability \ -fomit-frame-pointer \ -fno-unit-at-a-time \ -mno-align-long-strings \ -mrtd \ + -mregparm=3 \ -D${BOOT2_UFS} \ -DFLAGS=${BOOT_BOOT1_FLAGS} \ -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ -DSIOFMT=${B2SIOFMT} \ -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ -I${.CURDIR}/../../common \ -I${.CURDIR}/../btx/lib -I. \ -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ -Winline --param max-inline-insns-single=100 LDFLAGS=-static -N --gc-sections # Pick up ../Makefile.inc early. .include CLEANFILES= boot boot: boot1 boot2 cat boot1 boot2 > boot CLEANFILES+= boot1 boot1.out boot1.o boot1: boot1.out objcopy -S -O binary boot1.out ${.TARGET} boot1.out: boot1.o ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o CLEANFILES+= boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \ boot2.s boot2.s.tmp boot2.h sio.o boot2: boot2.ld @set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \ echo "$$x bytes available"; test $$x -ge 0 dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync boot2.ld: boot2.ldr boot2.bin ${BTXKERN} btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \ -o ${.TARGET} -P 1 boot2.bin boot2.ldr: dd if=/dev/zero of=${.TARGET} bs=512 count=1 boot2.bin: boot2.out objcopy -S -O binary boot2.out ${.TARGET} boot2.out: ${BTXCRT} boot2.o sio.o ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} boot2.o: boot2.s SRCS= boot2.c boot2.h boot2.s: boot2.c boot2.h ${.CURDIR}/../../common/ufsread.c ${CC} ${CFLAGS} -S -o boot2.s.tmp ${.CURDIR}/boot2.c sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s rm -f boot2.s.tmp boot2.h: boot1.out ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \ { x = $$1 - ORG1; \ printf("#define XREADORG %#x\n", REL1 + x) }' \ ORG1=`printf "%d" ${ORG1}` \ REL1=`printf "%d" ${REL1}` > ${.TARGET} .if ${MACHINE_CPUARCH} == "amd64" beforedepend boot2.s: machine CLEANFILES+= machine machine: ln -sf ${.CURDIR}/../../../i386/include machine .endif .include Index: head/sys/boot/i386/boot2/lib.h =================================================================== --- head/sys/boot/i386/boot2/lib.h (revision 220336) +++ head/sys/boot/i386/boot2/lib.h (revision 220337) @@ -1,24 +1,24 @@ /* * Copyright (c) 1998 Robert Nordier * All rights reserved. * * Redistribution and use in source and binary forms are freely * permitted provided that the above copyright notice and this * paragraph and the following disclaimer are duplicated in all * such forms. * * This software is provided "AS IS" and without any express or * implied warranties, including, without limitation, the implied * warranties of merchantability and fitness for a particular * purpose. */ /* * $FreeBSD$ */ -void sio_init(int); +void sio_init(int) __attribute__((regparm (3))); void sio_flush(void); -void sio_putc(int); +void sio_putc(int) __attribute__((regparm (3))); int sio_getc(void); int sio_ischar(void); Index: head/sys/boot/i386/boot2/sio.S =================================================================== --- head/sys/boot/i386/boot2/sio.S (revision 220336) +++ head/sys/boot/i386/boot2/sio.S (revision 220337) @@ -1,81 +1,82 @@ /* * Copyright (c) 1998 Robert Nordier * All rights reserved. * * Redistribution and use in source and binary forms are freely * permitted provided that the above copyright notice and this * paragraph and the following disclaimer are duplicated in all * such forms. * * This software is provided "AS IS" and without any express or * implied warranties, including, without limitation, the implied * warranties of merchantability and fitness for a particular * purpose. * * $FreeBSD$ */ .set SIO_PRT,SIOPRT # Base port .set SIO_FMT,SIOFMT # 8N1 .globl sio_init .globl sio_flush .globl sio_putc .globl sio_getc .globl sio_ischar /* void sio_init(int div) */ -sio_init: movw $SIO_PRT+0x3,%dx # Data format reg +sio_init: pushl %eax + movw $SIO_PRT+0x3,%dx # Data format reg movb $SIO_FMT|0x80,%al # Set format outb %al,(%dx) # and DLAB - pushl %edx # Save subb $0x3,%dl # Divisor latch reg - movl 0x8(%esp),%eax # Set + popl %eax outw %ax,(%dx) # BPS - popl %edx # Restore + movw $SIO_PRT+0x3,%dx # Data format reg movb $SIO_FMT,%al # Clear outb %al,(%dx) # DLAB incl %edx # Modem control reg movb $0x3,%al # Set RTS, outb %al,(%dx) # DTR incl %edx # Line status reg call sio_flush - ret $0x4 + ret /* void sio_flush(void) */ sio_flush.0: call sio_getc.1 # Get character sio_flush: call sio_ischar # Check for character jnz sio_flush.0 # Till none ret # To caller /* void sio_putc(int c) */ -sio_putc: movw $SIO_PRT+0x5,%dx # Line status reg +sio_putc: pushl %eax + movw $SIO_PRT+0x5,%dx # Line status reg xor %ecx,%ecx # Timeout movb $0x40,%ch # counter sio_putc.1: inb (%dx),%al # Transmitter testb $0x20,%al # buffer empty? loopz sio_putc.1 # No jz sio_putc.2 # If timeout - movb 0x4(%esp,1),%al # Get character + popl %eax # Get the character subb $0x5,%dl # Transmitter hold reg outb %al,(%dx) # Write character -sio_putc.2: ret $0x4 # To caller +sio_putc.2: ret # To caller /* int sio_getc(void) */ sio_getc: call sio_ischar # Character available? jz sio_getc # No sio_getc.1: subb $0x5,%dl # Receiver buffer reg inb (%dx),%al # Read character ret # To caller /* int sio_ischar(void) */ sio_ischar: movw $SIO_PRT+0x5,%dx # Line status register xorl %eax,%eax # Zero inb (%dx),%al # Received data andb $0x1,%al # ready? ret # To caller