From aae8fb345fb4c1b3c453f34e5ac37d5b24657e71 Mon Sep 17 00:00:00 2001
From: KATO Takenori <kato@FreeBSD.org>
Date: Tue, 22 Apr 1997 12:20:50 +0000
Subject: [PATCH] Synchronize with sys/i386/conf/Makefile.i386,
 sys/i386/i386/machdep.c and sys/i386/isa/npx.c revisions 1.94, 1.238 and
 1.41, respectively.

---
 sys/conf/Makefile.pc98      | 32 +++++++++++++++++++++++---------
 sys/pc98/conf/Makefile.pc98 | 32 +++++++++++++++++++++++---------
 sys/pc98/i386/machdep.c     |  8 +++++++-
 sys/pc98/pc98/machdep.c     |  8 +++++++-
 sys/pc98/pc98/npx.c         | 14 +++++++++-----
 5 files changed, 69 insertions(+), 25 deletions(-)

diff --git a/sys/conf/Makefile.pc98 b/sys/conf/Makefile.pc98
index ecdb56722a8d..5643b7b495b0 100644
--- a/sys/conf/Makefile.pc98
+++ b/sys/conf/Makefile.pc98
@@ -3,7 +3,7 @@
 # Makefile.i386 -- with config changes.
 # Copyright 1990 W. Jolitz
 #	from: @(#)Makefile.i386	7.1 5/10/91
-#	$Id: Makefile.pc98,v 1.11 1997/02/22 09:43:21 peter Exp $
+#	$Id: Makefile.pc98,v 1.12 1997/03/22 18:54:10 kato Exp $
 #
 # Makefile for FreeBSD
 #
@@ -17,9 +17,9 @@
 #	/sys/i386/conf/Makefile.i386
 # after which config should be rerun for all machines.
 #
-CC?=	cc
-CPP?=	cpp
-LD?=	/usr/bin/ld
+
+BINFORMAT?=	aout
+#BINFORMAT?=	elf
 
 .if exists(./@/.)
 S=	./@
@@ -57,18 +57,26 @@ DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
 DRIVER_S= ${CC} -c -x assembler-with-cpp -DLOCORE ${COPTS} $<
 PROFILE_C= ${CC} -c ${CFLAGS} ${PARAM} $<
 
-SYSTEM_CFILES= ioconf.c param.c vnode_if.c config.c
+SYSTEM_CFILES= ${I386}/i386/setdef0.c ioconf.c param.c vnode_if.c config.c \
+	${I386}/i386/setdef1.c
 SYSTEM_SFILES= ${I386}/i386/locore.s
-SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o config.o
+SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} ioconf.o param.o config.o \
+	setdef1.o
 SYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS}
-SYSTEM_LD_HEAD= @echo loading $@; rm -f $@
-SYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o
 .if ${CFLAGS:M-g} == ""
 SYMORDER_EXCLUDE=-x symbols.exclude
 .endif
+SYSTEM_LD_HEAD= @echo loading $@; rm -f $@
+.if ${BINFORMAT} == aout
+SYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o
 SYSTEM_LD_TAIL= @echo rearranging symbols; \
 	symorder -m ${SYMORDER_EXCLUDE} symbols.sort $@; \
 	size $@; chmod 755 $@
+.endif
+.if ${BINFORMAT} == elf
+SYSTEM_LD= @${LD} -Bstatic -Ttext ${LOAD_ADDRESS} -e btext -o $@ -X ${SYSTEM_OBJS} vers.o
+SYSTEM_LD_TAIL= @size $@; chmod 755 $@
+.endif
 
 %BEFORE_DEPEND
 
@@ -104,6 +112,12 @@ symbols.sort: ${I386}/i386/symbols.raw
 locore.o: ${I386}/i386/locore.s assym.s
 	${NORMAL_S}
 
+setdef0.o: ${I386}/i386/setdef0.c
+	${NORMAL_C}
+
+setdef1.o: ${I386}/i386/setdef1.c
+	${NORMAL_C}
+
 # everything potentially depends on the Makefile since everything potentially
 # depends on the options.  Some things are more dependent on the Makefile for
 # historical reasons.
@@ -138,7 +152,7 @@ depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND}
 	rm -f .newdep
 	mkdep -a -f .newdep ${COPTS} ${CFILES} ${SYSTEM_CFILES}
 	mkdep -a -f .newdep ${COPTS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
-	MKDEP_CPP="${CPP}" ; export MKDEP_CPP ; \
+	MKDEP_CPP="${CC} -E -x assembler-with-cpp" ; export MKDEP_CPP ; \
 	mkdep -a -f .newdep -DLOCORE ${COPTS} ${SFILES} ${SYSTEM_SFILES}
 	rm -f .depend
 	mv -f .newdep .depend
diff --git a/sys/pc98/conf/Makefile.pc98 b/sys/pc98/conf/Makefile.pc98
index ecdb56722a8d..5643b7b495b0 100644
--- a/sys/pc98/conf/Makefile.pc98
+++ b/sys/pc98/conf/Makefile.pc98
@@ -3,7 +3,7 @@
 # Makefile.i386 -- with config changes.
 # Copyright 1990 W. Jolitz
 #	from: @(#)Makefile.i386	7.1 5/10/91
-#	$Id: Makefile.pc98,v 1.11 1997/02/22 09:43:21 peter Exp $
+#	$Id: Makefile.pc98,v 1.12 1997/03/22 18:54:10 kato Exp $
 #
 # Makefile for FreeBSD
 #
@@ -17,9 +17,9 @@
 #	/sys/i386/conf/Makefile.i386
 # after which config should be rerun for all machines.
 #
-CC?=	cc
-CPP?=	cpp
-LD?=	/usr/bin/ld
+
+BINFORMAT?=	aout
+#BINFORMAT?=	elf
 
 .if exists(./@/.)
 S=	./@
@@ -57,18 +57,26 @@ DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
 DRIVER_S= ${CC} -c -x assembler-with-cpp -DLOCORE ${COPTS} $<
 PROFILE_C= ${CC} -c ${CFLAGS} ${PARAM} $<
 
-SYSTEM_CFILES= ioconf.c param.c vnode_if.c config.c
+SYSTEM_CFILES= ${I386}/i386/setdef0.c ioconf.c param.c vnode_if.c config.c \
+	${I386}/i386/setdef1.c
 SYSTEM_SFILES= ${I386}/i386/locore.s
-SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o config.o
+SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} ioconf.o param.o config.o \
+	setdef1.o
 SYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS}
-SYSTEM_LD_HEAD= @echo loading $@; rm -f $@
-SYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o
 .if ${CFLAGS:M-g} == ""
 SYMORDER_EXCLUDE=-x symbols.exclude
 .endif
+SYSTEM_LD_HEAD= @echo loading $@; rm -f $@
+.if ${BINFORMAT} == aout
+SYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o
 SYSTEM_LD_TAIL= @echo rearranging symbols; \
 	symorder -m ${SYMORDER_EXCLUDE} symbols.sort $@; \
 	size $@; chmod 755 $@
+.endif
+.if ${BINFORMAT} == elf
+SYSTEM_LD= @${LD} -Bstatic -Ttext ${LOAD_ADDRESS} -e btext -o $@ -X ${SYSTEM_OBJS} vers.o
+SYSTEM_LD_TAIL= @size $@; chmod 755 $@
+.endif
 
 %BEFORE_DEPEND
 
@@ -104,6 +112,12 @@ symbols.sort: ${I386}/i386/symbols.raw
 locore.o: ${I386}/i386/locore.s assym.s
 	${NORMAL_S}
 
+setdef0.o: ${I386}/i386/setdef0.c
+	${NORMAL_C}
+
+setdef1.o: ${I386}/i386/setdef1.c
+	${NORMAL_C}
+
 # everything potentially depends on the Makefile since everything potentially
 # depends on the options.  Some things are more dependent on the Makefile for
 # historical reasons.
@@ -138,7 +152,7 @@ depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND}
 	rm -f .newdep
 	mkdep -a -f .newdep ${COPTS} ${CFILES} ${SYSTEM_CFILES}
 	mkdep -a -f .newdep ${COPTS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
-	MKDEP_CPP="${CPP}" ; export MKDEP_CPP ; \
+	MKDEP_CPP="${CC} -E -x assembler-with-cpp" ; export MKDEP_CPP ; \
 	mkdep -a -f .newdep -DLOCORE ${COPTS} ${SFILES} ${SYSTEM_SFILES}
 	rm -f .depend
 	mv -f .newdep .depend
diff --git a/sys/pc98/i386/machdep.c b/sys/pc98/i386/machdep.c
index ed46bc2d548c..f762f1d41eab 100644
--- a/sys/pc98/i386/machdep.c
+++ b/sys/pc98/i386/machdep.c
@@ -35,7 +35,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)machdep.c	7.4 (Berkeley) 6/3/91
- *	$Id: machdep.c,v 1.35 1997/04/07 11:00:45 kato Exp $
+ *	$Id: machdep.c,v 1.36 1997/04/13 06:02:52 kato Exp $
  */
 
 #include "npx.h"
@@ -130,6 +130,7 @@ extern void earlysetcpuclass(void);	/* same header file */
 extern void finishidentcpu(void);
 extern void panicifcpuunsupported(void);
 extern void initializecpu(void);
+extern void init_sets(void);
 
 static void cpu_startup __P((void *));
 SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL)
@@ -988,6 +989,11 @@ init386(first)
 
 	atdevbase = ISA_HOLE_START + KERNBASE;
 
+	/*
+	 * Fill in the length fields of all linker sets (necessary for ELF).
+	 */
+	init_sets();
+
 	/*
 	 * Initialize the console before we print anything out.
 	 */
diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c
index ed46bc2d548c..f762f1d41eab 100644
--- a/sys/pc98/pc98/machdep.c
+++ b/sys/pc98/pc98/machdep.c
@@ -35,7 +35,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)machdep.c	7.4 (Berkeley) 6/3/91
- *	$Id: machdep.c,v 1.35 1997/04/07 11:00:45 kato Exp $
+ *	$Id: machdep.c,v 1.36 1997/04/13 06:02:52 kato Exp $
  */
 
 #include "npx.h"
@@ -130,6 +130,7 @@ extern void earlysetcpuclass(void);	/* same header file */
 extern void finishidentcpu(void);
 extern void panicifcpuunsupported(void);
 extern void initializecpu(void);
+extern void init_sets(void);
 
 static void cpu_startup __P((void *));
 SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL)
@@ -988,6 +989,11 @@ init386(first)
 
 	atdevbase = ISA_HOLE_START + KERNBASE;
 
+	/*
+	 * Fill in the length fields of all linker sets (necessary for ELF).
+	 */
+	init_sets();
+
 	/*
 	 * Initialize the console before we print anything out.
 	 */
diff --git a/sys/pc98/pc98/npx.c b/sys/pc98/pc98/npx.c
index e7ac7f68554b..4249fe01b48e 100644
--- a/sys/pc98/pc98/npx.c
+++ b/sys/pc98/pc98/npx.c
@@ -32,7 +32,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)npx.c	7.2 (Berkeley) 5/12/91
- *	$Id: npx.c,v 1.14 1997/02/22 09:43:41 peter Exp $
+ *	$Id: npx.c,v 1.15 1997/03/24 12:29:39 bde Exp $
  */
 
 #include "npx.h"
@@ -53,6 +53,7 @@
 #endif
 #include <sys/signalvar.h>
 
+#include <machine/asmacros.h>
 #include <machine/cpu.h>
 #include <machine/pcb.h>
 #include <machine/md_var.h>
@@ -152,13 +153,15 @@ static	volatile u_int		npx_traps_while_probing;
  * interrupts.  We'll still need a special exception 16 handler.  The busy
  * latch stuff in probeintr() can be moved to npxprobe().
  */
+
 inthand_t probeintr;
 asm
 ("
 	.text
-_probeintr:
+	.p2align 2,0x90
+" __XSTRING(CNAME(probeintr)) ":
 	ss
-	incl	_npx_intrs_while_probing
+	incl	" __XSTRING(CNAME(npx_intrs_while_probing)) "
 	pushl	%eax
 	movb	$0x20,%al	# EOI (asm in strings loses cpp features)
 #ifdef PC98
@@ -182,9 +185,10 @@ inthand_t probetrap;
 asm
 ("
 	.text
-_probetrap:
+	.p2align 2,0x90
+" __XSTRING(CNAME(probetrap)) ":
 	ss
-	incl	_npx_traps_while_probing
+	incl	" __XSTRING(CNAME(npx_traps_while_probing)) "
 	fnclex
 	iret
 ");