-/* $OpenBSD: locore.s,v 1.46 2017/05/27 14:33:39 kettenis Exp $ */
+/* $OpenBSD: locore.s,v 1.47 2017/06/05 17:49:05 deraadt Exp $ */
/* $NetBSD: locore.s,v 1.94 2001/04/26 03:10:44 ross Exp $ */
/*-
bne \reg, \dst
.endm
-/*
- * This is for kvm_mkdb, and should be the address of the beginning
- * of the kernel text segment (not necessarily the same as kernbase).
- */
- EXPORT(kernel_text)
-.loc 1 __LINE__
-kernel_text:
-
-/*
- * bootstack: a temporary stack, for booting.
- *
- * Extends from 'start' down.
- */
-bootstack:
-
-/*
- * __start: Kernel start.
- *
- * Arguments:
- * a0 is the first free page frame number (PFN) (no longer used)
- * a1 is the page table base register (PTBR)
- * a2 is the bootinfo magic number
- * a3 is the pointer to the bootinfo structure
- *
- * All arguments are passed to alpha_init().
- */
-NESTED_NOPROFILE(__start,1,0,ra,0,0)
- br pv,Lstart1
-Lstart1: LDGP(pv)
-
- /* Switch to the boot stack. */
- lda sp,bootstack
-
- /* Load KGP with current GP. */
- or gp,zero,a0
- call_pal PAL_OSF1_wrkgp /* clobbers a0, t0, t8-t11 */
-
- /*
- * Call alpha_init() to do pre-main initialization.
- * alpha_init() gets the arguments we were called with,
- * which are already in a0 (destroyed), a1, a2, a3 and a4.
- */
- CALL(alpha_init)
-
- /* Set up the virtual page table pointer. */
- ldiq a0, VPTBASE
- call_pal PAL_OSF1_wrvptptr /* clobbers a0, t0, t8-t11 */
-
- /*
- * Switch to proc0's PCB.
- */
- lda a0, proc0
- ldq a0, P_MD_PCBPADDR(a0) /* phys addr of PCB */
- SWITCH_CONTEXT
-
- /*
- * We've switched to a new page table base, so invalidate the TLB
- * and I-stream. This happens automatically everywhere but here.
- */
- ldiq a0, -2 /* TBIA */
- call_pal PAL_OSF1_tbi
- call_pal PAL_imb
-
- /*
- * All ready to go! Call main()!
- */
- CALL(main)
-
- /* This should never happen. */
- PANIC("main() returned",Lmain_returned_pmsg)
- END(__start)
-
/**************************************************************************/
/*
--- /dev/null
+/* $OpenBSD: locore0.S,v 1.1 2017/06/05 17:49:05 deraadt Exp $ */
+/* $NetBSD: locore.s,v 1.94 2001/04/26 03:10:44 ross Exp $ */
+
+/*-
+ * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * 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 the
+ * rights to redistribute these changes.
+ */
+
+.file 1 __FILE__
+
+#include <machine/asm.h>
+
+#include "assym.h"
+
+/*
+ * Perform actions necessary to switch to a new context. The
+ * hwpcb should be in a0. Clobbers v0, t0, t8..t11, a0.
+ */
+#define SWITCH_CONTEXT \
+ /* Make a note of the context we're running on. */ \
+ GET_CURPCB ; \
+ stq a0, 0(v0) ; \
+ \
+ /* Swap in the new context. */ \
+ call_pal PAL_OSF1_swpctx
+
+
+ /* don't reorder instructions; paranoia. */
+ .set noreorder
+ .text
+
+ .macro bfalse reg, dst
+ beq \reg, \dst
+ .endm
+
+ .macro btrue reg, dst
+ bne \reg, \dst
+ .endm
+
+#define GET_CURPCB \
+ call_pal PAL_OSF1_rdval ; \
+ addq v0, CPU_INFO_CURPCB, v0
+
+/*
+ * This is for kvm_mkdb, and should be the address of the beginning
+ * of the kernel text segment (not necessarily the same as kernbase).
+ */
+ EXPORT(kernel_text)
+.loc 1 __LINE__
+kernel_text:
+
+/*
+ * bootstack: a temporary stack, for booting.
+ *
+ * Extends from 'start' down.
+ */
+bootstack:
+
+/*
+ * __start: Kernel start.
+ *
+ * Arguments:
+ * a0 is the first free page frame number (PFN) (no longer used)
+ * a1 is the page table base register (PTBR)
+ * a2 is the bootinfo magic number
+ * a3 is the pointer to the bootinfo structure
+ *
+ * All arguments are passed to alpha_init().
+ */
+NESTED_NOPROFILE(__start,1,0,ra,0,0)
+ br pv,Lstart1
+Lstart1: LDGP(pv)
+
+ /* Switch to the boot stack. */
+ lda sp,bootstack
+
+ /* Load KGP with current GP. */
+ or gp,zero,a0
+ call_pal PAL_OSF1_wrkgp /* clobbers a0, t0, t8-t11 */
+
+ /*
+ * Call alpha_init() to do pre-main initialization.
+ * alpha_init() gets the arguments we were called with,
+ * which are already in a0 (destroyed), a1, a2, a3 and a4.
+ */
+ CALL(alpha_init)
+
+ /* Set up the virtual page table pointer. */
+ ldiq a0, VPTBASE
+ call_pal PAL_OSF1_wrvptptr /* clobbers a0, t0, t8-t11 */
+
+ /*
+ * Switch to proc0's PCB.
+ */
+ lda a0, proc0
+ ldq a0, P_MD_PCBPADDR(a0) /* phys addr of PCB */
+ SWITCH_CONTEXT
+
+ /*
+ * We've switched to a new page table base, so invalidate the TLB
+ * and I-stream. This happens automatically everywhere but here.
+ */
+ ldiq a0, -2 /* TBIA */
+ call_pal PAL_OSF1_tbi
+ call_pal PAL_imb
+
+ /*
+ * All ready to go! Call main()!
+ */
+ CALL(main)
+
+ /* This should never happen. */
+ PANIC("main() returned",Lmain_returned_pmsg)
+ END(__start)
-# $OpenBSD: Makefile.alpha,v 1.97 2017/06/05 12:43:57 deraadt Exp $
+# $OpenBSD: Makefile.alpha,v 1.98 2017/06/05 17:49:06 deraadt Exp $
# For instructions on building kernels consult the config(8) and options(4)
# manual pages.
CMACHFLAGS+= -fno-builtin-printf -fno-builtin-snprintf \
-fno-builtin-vsnprintf -fno-builtin-log \
-fno-builtin-log2 -fno-builtin-malloc ${NOPIE_FLAGS}
+SORTR= sort -R
.if ${IDENT:M-DNO_PROPOLICE}
CMACHFLAGS+= -fno-stack-protector
.endif
+.if ${IDENT:M-DSMALL_KERNEL}
+SORTR= cat
+.endif
DEBUG?= -g
COPTS?= -O2
# ${SYSTEM_LD_HEAD}
# ${SYSTEM_LD} swapxxx.o
# ${SYSTEM_LD_TAIL}
-SYSTEM_HEAD= locore.o param.o ioconf.o
-SYSTEM_OBJ= ${SYSTEM_HEAD} ${OBJS}
+SYSTEM_HEAD= locore0.o gap.o
+SYSTEM_OBJ= ${SYSTEM_HEAD} ${OBJS} param.o ioconf.o
SYSTEM_DEP= Makefile ${SYSTEM_OBJ} ld.script
SYSTEM_LD_HEAD= @rm -f $@
SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \
umask 007; \
- ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} vers.o ${OBJS}
+ echo ${OBJS} param.o ioconf.o vers.o | tr " " "\n" | ${SORTR} > lorder; \
+ ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} `cat lorder`
SYSTEM_LD_TAIL= @${SIZE} $@
.if ${DEBUG} == "-g"
sh $S/conf/newvers.sh
${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
+gap.S: ${SYSTEM_SWAP_DEP} Makefile
+ umask 007; sh $S/conf/makegap.sh 0x00 > gap.S
+
+gap.o: gap.S
+ umask 007; ${CC} ${AFLAGS} ${CPPFLAGS} ${PROF} -c gap.S
+
clean:
- rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* ${DB_STRUCTINFO} param.c
+ rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* ${DB_STRUCTINFO} \
+ gap.S lorder param.c
cleandir: clean
rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c
objdump -g db_structinfo.o | perl $S/ddb/parse_structinfo.pl > $@
rm -f db_structinfo.o
+locore0.o: ${_machdir}/${_mach}/locore0.S assym.h
locore.o: ${_machdir}/${_mach}/locore.s assym.h
# The install target can be redefined by putting a
.if !target(install-kernel-${MACHINE_NAME}})
install-kernel-${MACHINE_NAME}:
cmp -s bsd /bsd || ln -f /bsd /obsd
- cp bsd /nbsd
+ cp -p bsd /nbsd
mv /nbsd /bsd
.endif