From 9e3377b8b315cb49a63387ce0bef943d73673378 Mon Sep 17 00:00:00 2001 From: Robert Nordier Date: Sat, 4 Nov 2000 13:03:52 +0000 Subject: [PATCH] Support a.out: avoid (%dx) in in/out instructions, and use an m4 macro to supply underscores for externals. --- sys/boot/i386/kgzldr/Makefile | 11 ++++++++--- sys/boot/i386/kgzldr/crt.s | 4 ++-- sys/boot/i386/kgzldr/kgzldr.m4 | 18 ++++++++++++++++++ sys/boot/i386/kgzldr/sio.s | 8 ++++---- sys/boot/i386/kgzldr/start.s | 4 ++-- 5 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 sys/boot/i386/kgzldr/kgzldr.m4 diff --git a/sys/boot/i386/kgzldr/Makefile b/sys/boot/i386/kgzldr/Makefile index ea4e70174d20..2a4513d4b568 100644 --- a/sys/boot/i386/kgzldr/Makefile +++ b/sys/boot/i386/kgzldr/Makefile @@ -4,7 +4,12 @@ MAINTAINER= rnordier PROG= kgzldr.o SRCS= start.s boot.c inflate.c lib.c crt.s sio.s -CFLAGS= -fno-builtin -Os +CFLAGS= -fno-builtin +.if ${OBJFORMAT} == aout +CFLAGS+=-O2 +.else +CFLAGS+=-Os +.endif CFLAGS+=-DKZIP LDFLAGS=-nostdlib -static -r NOMAN= @@ -14,7 +19,7 @@ STRIP= .PATH: ${.CURDIR}/../../../kern M4?= m4 -M4FLAGS= +M4FLAGS=-DOBJFORMAT=${OBJFORMAT} BOOT_COMCONSOLE_PORT?= 0x3f8 M4FLAGS+=-DSIOPRT=${BOOT_COMCONSOLE_PORT} @@ -25,7 +30,7 @@ kgzldr.o: ${OBJS} ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} .s.o: - (cd ${.CURDIR}; ${M4} ${M4FLAGS} ${.IMPSRC}) |\ + (cd ${.CURDIR}; ${M4} ${M4FLAGS} kgzldr.m4 ${.IMPSRC}) |\ ${AS} ${AFLAGS} -o ${.TARGET} .include diff --git a/sys/boot/i386/kgzldr/crt.s b/sys/boot/i386/kgzldr/crt.s index cfb479fd2d84..ac26a20409ed 100644 --- a/sys/boot/i386/kgzldr/crt.s +++ b/sys/boot/i386/kgzldr/crt.s @@ -38,11 +38,11 @@ .set BDA_SCR,0x449 # Video mode .set BDA_POS,0x450 # Cursor position - .globl crt_putchr + .globl _(crt_putchr) # void crt_putchr(int c) -crt_putchr: movb 0x4(%esp,1),%al # Get character +_(crt_putchr): movb 0x4(%esp,1),%al # Get character pusha # Save xorl %ecx,%ecx # Zero for loops movb $SCR_MAT,%ah # Mode/attribute diff --git a/sys/boot/i386/kgzldr/kgzldr.m4 b/sys/boot/i386/kgzldr/kgzldr.m4 new file mode 100644 index 000000000000..1441a4b4a01c --- /dev/null +++ b/sys/boot/i386/kgzldr/kgzldr.m4 @@ -0,0 +1,18 @@ +# +# Copyright (c) 2000 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$ + +define(_,`ifelse(OBJFORMAT,`aout',`_$1',`$1')') diff --git a/sys/boot/i386/kgzldr/sio.s b/sys/boot/i386/kgzldr/sio.s index bb354e297dd0..86b8ccd1d1a4 100644 --- a/sys/boot/i386/kgzldr/sio.s +++ b/sys/boot/i386/kgzldr/sio.s @@ -29,18 +29,18 @@ .set SIO_PRT,SIOPRT # Base port - .globl sio_putchr + .globl _(sio_putchr) # void sio_putchr(int c) -sio_putchr: movw $SIO_PRT+0x5,%dx # Line status reg +_(sio_putchr): movw $SIO_PRT+0x5,%dx # Line status reg xor %ecx,%ecx # Timeout movb $0x40,%ch # counter -sio_putchr.1: inb (%dx),%al # Transmitter +sio_putchr.1: inb %dx,%al # Transmitter testb $0x20,%al # buffer empty? loopz sio_putchr.1 # No jz sio_putchr.2 # If timeout movb 0x4(%esp,1),%al # Get character subb $0x5,%dl # Transmitter hold reg - outb %al,(%dx) # Write character + outb %al,%dx # Write character sio_putchr.2: ret # To caller diff --git a/sys/boot/i386/kgzldr/start.s b/sys/boot/i386/kgzldr/start.s index 550fa526d946..ff43c77b3f2e 100644 --- a/sys/boot/i386/kgzldr/start.s +++ b/sys/boot/i386/kgzldr/start.s @@ -40,6 +40,6 @@ _start: cld # String ops inc rep # Clear stosb # bss pushl 0x4(%esp) # Pass howto flags - call boot # Call C code + call _(boot) # Call C code popl %ecx # Clear stack - jmp *kgz+entry # To loaded code + jmp *_(kgz)+entry # To loaded code