summaryrefslogtreecommitdiff
path: root/sys/arch/alpha/stand/boot
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-10-18 08:53:40 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-10-18 08:53:40 +0000
commitd6583bb2a13f329cf0332ef2570eb8bb8fc0e39c (patch)
treeece253b876159b39c620e62b6c9b1174642e070e /sys/arch/alpha/stand/boot
initial import of NetBSD tree
Diffstat (limited to 'sys/arch/alpha/stand/boot')
-rw-r--r--sys/arch/alpha/stand/boot/Makefile61
-rw-r--r--sys/arch/alpha/stand/boot/TODO7
-rw-r--r--sys/arch/alpha/stand/boot/boot.c280
-rw-r--r--sys/arch/alpha/stand/boot/conf.c54
-rw-r--r--sys/arch/alpha/stand/boot/disk.c167
-rw-r--r--sys/arch/alpha/stand/boot/libsa/Makefile14
-rw-r--r--sys/arch/alpha/stand/boot/libsa/devopen.c157
-rw-r--r--sys/arch/alpha/stand/boot/libsa/filesystem.c44
-rw-r--r--sys/arch/alpha/stand/boot/newvers.sh44
-rw-r--r--sys/arch/alpha/stand/boot/prom.c135
-rw-r--r--sys/arch/alpha/stand/boot/prom_disp.S116
-rw-r--r--sys/arch/alpha/stand/boot/prom_swpal.S136
-rw-r--r--sys/arch/alpha/stand/boot/start.S81
-rw-r--r--sys/arch/alpha/stand/boot/test.c61
-rw-r--r--sys/arch/alpha/stand/boot/version5
15 files changed, 1362 insertions, 0 deletions
diff --git a/sys/arch/alpha/stand/boot/Makefile b/sys/arch/alpha/stand/boot/Makefile
new file mode 100644
index 00000000000..03d7c126bfa
--- /dev/null
+++ b/sys/arch/alpha/stand/boot/Makefile
@@ -0,0 +1,61 @@
+# $NetBSD: Makefile,v 1.4 1995/06/28 00:58:44 cgd Exp $
+#
+# BSD Boot blocks for the Alpha
+#
+# XXX should generate a primary boot block, too...
+
+INCPATH=-I../../../.. -I.
+
+# Boot relocation address
+RELOC1= 20020000
+# Low memory test program relocation address
+#RELOC2= 20004000
+# High memory test program relocation address
+RELOC2= fffffc0000230000
+
+# Compiler and assembler flags used to generate boot blocks.
+#
+DEFS= -DSTANDALONE
+AFLAGS+=-DASSEMBLER ${INCPATH}
+CFLAGS= -mno-fp-regs ${INCPATH} ${DEFS}
+
+LIBS= libsa/libsa.a -lc
+SRCS= boot.c disk.c conf.c prom.c test.c
+
+all: boot
+
+libsa/libsa.a::
+ cd libsa; make
+
+# This boot is supposed to be installed in this way:
+# cp boot <true_root_of_disk>/boot
+BOBJS= boot.o conf.o disk.o prom.o prom_disp.o prom_swpal.o vers.o
+boot: start.o ${BOBJS} ${LIBS}
+ ${LD} -Ttext ${RELOC1} -N \
+ -e start -o ${.TARGET} start.o ${BOBJS} ${LIBS}
+
+# This boot is supposed to be installed in this way:
+# cp test_boot <true_root_of_disk>/test_boot
+#
+# It is used presumably in this way:
+# boot -fi "test_boot" dka300
+TOBJS= prom.o prom_disp.o prom_swpal.o test.o
+test_boot: start.o ${TOBJS} ${LIBS}
+ ${LD} -T ${RELOC2} -N -e start -o ${.TARGET} start.o ${TOBJS} ${LIBS}
+
+clean cleandir:
+ rm -f .depend *.o *.exe *.i errs make.out core* vers.c
+ rm -f a.out boot test_boot
+ cd libsa && make cleandir
+
+install:
+ install -c -o root -g wheel -m 555 boot ${DESTDIR}/
+
+depend: ${SRCS}
+ mkdep -p ${INCPATH} ${DEFS} ${SRCS}
+ cd libsa && make depend
+
+newvers:
+ sh newvers.sh
+
+vers.c: newvers
diff --git a/sys/arch/alpha/stand/boot/TODO b/sys/arch/alpha/stand/boot/TODO
new file mode 100644
index 00000000000..57c1ab2f87d
--- /dev/null
+++ b/sys/arch/alpha/stand/boot/TODO
@@ -0,0 +1,7 @@
+$NetBSD: TODO,v 1.2 1995/02/16 02:32:53 cgd Exp $
+
+libsa/devopen.c should replace the PMAX source code, and
+they should then share it.
+
+Standalone programs should load against libkern, and sys/stand
+should lose things like strchr() in favor of the libkern versions.
diff --git a/sys/arch/alpha/stand/boot/boot.c b/sys/arch/alpha/stand/boot/boot.c
new file mode 100644
index 00000000000..375b0070834
--- /dev/null
+++ b/sys/arch/alpha/stand/boot/boot.c
@@ -0,0 +1,280 @@
+/* $NetBSD: boot.c,v 1.3 1995/06/28 00:58:48 cgd Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)boot.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <lib/libsa/stand.h>
+
+#include <sys/param.h>
+#include <sys/exec.h>
+
+#include <machine/prom.h>
+
+#include "../../include/coff.h"
+#define _KERNEL
+#include "../../include/pte.h"
+
+static int aout_exec __P((int, struct exec *, u_int64_t *));
+static int coff_exec __P((int, struct exechdr *, u_int64_t *));
+static int loadfile __P((char *, u_int64_t *));
+
+char line[64] = "/netbsd";
+
+char boot_file[128];
+char boot_dev[128];
+char boot_flags[128];
+char boot_console[8];
+
+extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[];
+
+#define KERNEL_ARGC 4
+char *kernel_argv[KERNEL_ARGC+1] = {
+ boot_file,
+ boot_flags,
+ boot_console,
+ boot_dev,
+ NULL
+};
+
+vm_offset_t ffp_save, ptbr_save;
+
+void
+main(argc, argv, envp)
+ int argc;
+ char **argv;
+ char **envp;
+{
+ u_int64_t entry;
+ int ask;
+ prom_return_t ret;
+
+#ifdef notdef
+ {
+ extern char *_EDATA, *_end;
+ bzero(_EDATA, _end - _EDATA);
+ }
+#endif
+
+ /* Init prom callback vector. */
+ init_prom_calls();
+
+ /* print a banner */
+ printf("\n\n");
+ printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
+ printf("(%s, %s)\n", bootprog_maker, bootprog_date);
+ printf("\n");
+
+ /* switch to OSF pal code. */
+ OSFpal();
+
+ printf("\n");
+
+ prom_getenv(PROM_E_BOOTED_DEV, boot_dev, sizeof(boot_dev));
+ prom_getenv(PROM_E_BOOTED_FILE, boot_file, sizeof(boot_file));
+ prom_getenv(PROM_E_BOOTED_OSFLAGS, boot_flags, sizeof(boot_flags));
+ prom_getenv(PROM_E_TTY_DEV, boot_console, sizeof(boot_console));
+
+ printf("boot_dev = \"%s\"\n", boot_dev);
+ printf("boot_file = \"%s\"\n", boot_file);
+ printf("boot_flags = \"%s\"\n", boot_flags);
+ printf("boot_console = \"%s\"\n", boot_console);
+
+ if (boot_file[0] == '\0')
+ bcopy(line, boot_file, strlen(line)+1);
+
+#ifdef JUSTASK
+ ask = 1;
+#else
+ ask = 0;
+#endif
+ for (;;) {
+ if (ask) {
+ (void)printf("Boot: ");
+ gets(line);
+ if (line[0] == '\0')
+ continue;
+ if (!strcmp(line, "halt"))
+ halt();
+/* XXX TURN LINE INTO BOOT FILE/FLAGS */
+ bcopy(line, boot_file, strlen(line)+1);
+ } else
+ (void)printf("Boot: %s %s\n", boot_file, boot_flags);
+
+ if (!loadfile(boot_file, &entry)) {
+
+printf("calling %lx with %lx, %lx, %lx, %lx, %lx\n", entry,
+ffp_save, ptbr_save, KERNEL_ARGC, kernel_argv, NULL);
+ (*(void (*)())entry)(ffp_save, ptbr_save, KERNEL_ARGC,
+ kernel_argv, NULL);
+ }
+
+ ask = 1;
+ }
+ /* NOTREACHED */
+}
+
+/*
+ * Open 'filename', read in program and return the entry point or -1 if error.
+ */
+static int
+loadfile(fname, entryp)
+ char *fname;
+ u_int64_t *entryp;
+{
+ struct devices *dp;
+ union {
+ struct exec aout;
+ struct exechdr coff;
+ } hdr;
+ ssize_t nr;
+ int fd, rval;
+
+ /* Open the file. */
+ rval = 1;
+ if ((fd = open(fname, 0)) < 0) {
+ (void)printf("open error: %d\n", errno);
+ goto err;
+ }
+
+ /* Read the exec header. */
+ if ((nr = read(fd, &hdr, sizeof(hdr))) != sizeof(hdr)) {
+ (void)printf("read error: %d\n", errno);
+ goto err;
+ }
+
+ /* Exec a.out or COFF. */
+ rval = N_COFFBADMAG(hdr.coff.a) ?
+ aout_exec(fd, &hdr.aout, entryp) :
+ coff_exec(fd, &hdr.coff, entryp);
+
+err:
+#ifndef SMALL
+ if (fd >= 0)
+ (void)close(fd);
+#endif
+ if (rval)
+ (void)printf("can't boot '%s'\n", fname);
+ return (rval);
+}
+
+static int
+aout_exec(fd, aout, entryp)
+ int fd;
+ struct exec *aout;
+ u_int64_t *entryp;
+{
+ size_t sz;
+
+ /* Check the magic number. */
+ if (N_GETMAGIC(*aout) != OMAGIC) {
+ (void)printf("bad magic: %o\n", N_GETMAGIC(*aout));
+ return (1);
+ }
+
+ /* Read in text, data. */
+ (void)printf("%lu+%lu", aout->a_text, aout->a_data);
+ if (lseek(fd, (off_t)N_TXTOFF(*aout), SEEK_SET) < 0) {
+ (void)printf("lseek: %d\n", errno);
+ return (1);
+ }
+ sz = aout->a_text + aout->a_data;
+ if (read(fd, (void *)aout->a_entry, sz) != sz) {
+ (void)printf("read text/data: %d\n", errno);
+ return (1);
+ }
+
+ /* Zero out bss. */
+ if (aout->a_bss != 0) {
+ (void)printf("+%lu", aout->a_bss);
+ bzero(aout->a_entry + sz, aout->a_bss);
+ }
+
+ ffp_save = aout->a_entry + aout->a_text + aout->a_data + aout->a_bss;
+ ffp_save = k0segtophys((ffp_save + PGOFSET & ~PGOFSET)) >> PGSHIFT;
+ ffp_save += 2; /* XXX OSF/1 does this, no idea why. */
+
+ (void)printf("\n");
+ *entryp = aout->a_entry;
+ return (0);
+}
+
+static int
+coff_exec(fd, coff, entryp)
+ int fd;
+ struct exechdr *coff;
+ u_int64_t *entryp;
+{
+
+ /* Read in text. */
+ (void)printf("%lu", coff->a.tsize);
+ (void)lseek(fd, N_COFFTXTOFF(coff->f, coff->a), 0);
+ if (read(fd, (void *)coff->a.text_start, coff->a.tsize) !=
+ coff->a.tsize) {
+ (void)printf("read text: %d\n", errno);
+ return (1);
+ }
+
+ /* Read in data. */
+ if (coff->a.dsize != 0) {
+ (void)printf("+%lu", coff->a.dsize);
+ if (read(fd, (void *)coff->a.data_start, coff->a.dsize) !=
+ coff->a.dsize) {
+ (void)printf("read data: %d\n", errno);
+ return (1);
+ }
+ }
+
+
+ /* Zero out bss. */
+ if (coff->a.bsize != 0) {
+ (void)printf("+%lu", coff->a.bsize);
+ bzero(coff->a.bss_start, coff->a.bsize);
+ }
+
+ ffp_save = coff->a.text_start + coff->a.tsize;
+ if (ffp_save < coff->a.data_start + coff->a.dsize)
+ ffp_save = coff->a.data_start + coff->a.dsize;
+ if (ffp_save < coff->a.bss_start + coff->a.bsize)
+ ffp_save = coff->a.bss_start + coff->a.bsize;
+ ffp_save = k0segtophys((ffp_save + PGOFSET & ~PGOFSET)) >> PGSHIFT;
+ ffp_save += 2; /* XXX OSF/1 does this, no idea why. */
+
+ (void)printf("\n");
+ *entryp = coff->a.entry;
+ return (0);
+}
diff --git a/sys/arch/alpha/stand/boot/conf.c b/sys/arch/alpha/stand/boot/conf.c
new file mode 100644
index 00000000000..9cc3d1b6621
--- /dev/null
+++ b/sys/arch/alpha/stand/boot/conf.c
@@ -0,0 +1,54 @@
+/* $NetBSD: conf.c,v 1.2 1995/02/16 02:32:54 cgd Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)conf.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <lib/libsa/stand.h>
+#include <lib/libsa/ufs.h>
+
+int errno;
+int noioctl __P((void));
+
+int diskstrategy(), diskopen(), diskclose();
+#define diskioctl noioctl
+
+struct devsw devsw[] = {
+ { "disk", diskstrategy, diskopen, diskclose, diskioctl }, /*0*/
+};
+
+int ndevs = (sizeof(devsw)/sizeof(devsw[0]));
diff --git a/sys/arch/alpha/stand/boot/disk.c b/sys/arch/alpha/stand/boot/disk.c
new file mode 100644
index 00000000000..f03c0bc2daa
--- /dev/null
+++ b/sys/arch/alpha/stand/boot/disk.c
@@ -0,0 +1,167 @@
+/* $NetBSD: disk.c,v 1.2 1995/02/16 02:32:55 cgd Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Van Jacobson of Lawrence Berkeley Laboratory and Ralph Campbell.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)rz.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <lib/libsa/stand.h>
+
+#include <sys/param.h>
+#include <sys/disklabel.h>
+
+#include <machine/prom.h>
+
+struct disk_softc {
+ int sc_fd; /* PROM channel number */
+ int sc_ctlr; /* controller number */
+ int sc_unit; /* disk unit number */
+ int sc_part; /* disk partition number */
+ struct disklabel sc_label; /* disk label for this disk */
+};
+
+int
+diskstrategy(devdata, rw, bn, reqcnt, addr, cnt)
+ void *devdata;
+ int rw;
+ daddr_t bn;
+ u_int reqcnt;
+ char *addr;
+ u_int *cnt; /* out: number of bytes transfered */
+{
+ struct disk_softc *sc;
+ struct partition *pp;
+ prom_return_t ret;
+ int s;
+
+ twiddle();
+
+ /* Partial-block transfers not handled. */
+ if (reqcnt & (DEV_BSIZE - 1)) {
+ *cnt = 0;
+ return (EINVAL);
+ }
+
+ sc = (struct disk_softc *)devdata;
+ pp = &sc->sc_label.d_partitions[sc->sc_part];
+
+ ret.bits = prom_read(sc->sc_fd, reqcnt, addr, bn + pp->p_offset);
+ if (ret.u.status)
+ return (EIO);
+ *cnt = ret.u.retval;
+ return (0);
+}
+
+int
+diskopen(f, ctlr, unit, part)
+ struct open_file *f;
+ int ctlr, unit, part;
+{
+ struct disklabel *lp;
+ prom_return_t ret;
+ int cnt, devlen, i;
+ char *msg, buf[DEV_BSIZE], devname[32];
+ static struct disk_softc *sc;
+
+if (sc != NULL) {
+ f->f_devdata = (void *)sc;
+ return 0;
+}
+
+ if (unit >= 8 || part >= 8)
+ return (ENXIO);
+ /*
+ * XXX
+ * We don't know what device names look like yet,
+ * so we can't change them.
+ */
+ ret.bits = prom_getenv(PROM_E_BOOTED_DEV, devname, sizeof(devname));
+ devlen = ret.u.retval;
+
+ ret.bits = prom_open(devname, devlen);
+ if (ret.u.status == 2)
+ return (ENXIO);
+ if (ret.u.status == 3)
+ return (EIO);
+
+ sc = alloc(sizeof(struct disk_softc));
+ bzero(sc, sizeof(struct disk_softc));
+ f->f_devdata = (void *)sc;
+
+ sc->sc_fd = ret.u.retval;
+ sc->sc_ctlr = ctlr;
+ sc->sc_unit = unit;
+ sc->sc_part = part;
+
+ /* Try to read disk label and partition table information. */
+ lp = &sc->sc_label;
+ lp->d_secsize = DEV_BSIZE;
+ lp->d_secpercyl = 1;
+ lp->d_npartitions = MAXPARTITIONS;
+ lp->d_partitions[part].p_offset = 0;
+ lp->d_partitions[part].p_size = 0x7fffffff;
+ i = diskstrategy(sc, F_READ,
+ (daddr_t)LABELSECTOR, DEV_BSIZE, buf, &cnt);
+ if (i || cnt != DEV_BSIZE) {
+ printf("disk%d: error reading disk label\n", unit);
+ goto bad;
+ } else {
+ msg = getdisklabel(buf, lp);
+ if (msg) {
+ printf("disk%d: %s\n", unit, msg);
+ goto bad;
+ }
+ }
+
+ if (part >= lp->d_npartitions || lp->d_partitions[part].p_size == 0) {
+bad: free(sc, sizeof(struct disk_softc));
+ return (ENXIO);
+ }
+ return (0);
+}
+
+diskclose(f)
+ struct open_file *f;
+{
+ struct disk_softc *sc;
+
+ sc = f->f_devdata;
+ (void)prom_close(sc->sc_fd);
+
+ free(sc, sizeof(struct disk_softc));
+ f->f_devdata = NULL;
+ return (0);
+}
diff --git a/sys/arch/alpha/stand/boot/libsa/Makefile b/sys/arch/alpha/stand/boot/libsa/Makefile
new file mode 100644
index 00000000000..c84169984f7
--- /dev/null
+++ b/sys/arch/alpha/stand/boot/libsa/Makefile
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.2 1995/02/16 02:33:03 cgd Exp $
+
+LIB= sa
+SRCS= alloc.c bzero.c close.c dev.c devopen.c disklabel.c getfile.c \
+ gets.c ioctl.c lseek.c open.c printf.c read.c strcmp.c ufs.c \
+ write.c bcopy.c filesystem.c strlen.c ntohl.c
+
+.PATH: ../../../../../lib/libsa ../../../../../lib/libkern
+NOPIC=nopic
+NOPROFILE=noprofile
+
+.include <bsd.lib.mk>
+
+CFLAGS= -mno-fp-regs -I../../../../.. -I. -DCOMPAT_UFS
diff --git a/sys/arch/alpha/stand/boot/libsa/devopen.c b/sys/arch/alpha/stand/boot/libsa/devopen.c
new file mode 100644
index 00000000000..78a8cc8efc1
--- /dev/null
+++ b/sys/arch/alpha/stand/boot/libsa/devopen.c
@@ -0,0 +1,157 @@
+/* $NetBSD: devopen.c,v 1.2 1995/02/16 02:33:04 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)devopen.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <lib/libsa/stand.h>
+
+/*
+ * Decode the string 'fname', open the device and return the remaining
+ * file name if any.
+ */
+devopen(f, fname, file)
+ struct open_file *f;
+ const char *fname;
+ char **file; /* out */
+{
+ register char *cp;
+ register char *ncp;
+ register struct devsw *dp;
+ register int c, i;
+ int ctlr = 0, unit = 0, part = 0;
+ char namebuf[20];
+ int rc;
+
+ cp = fname;
+ ncp = namebuf;
+
+ /* look for a string like '5/rz0/vmunix' or '5/rz3f/vmunix */
+ if ((c = *cp) >= '0' && c <= '9') {
+ ctlr = c - '0';
+ /* skip the '/' */
+ if (*++cp != '/')
+ return (ENXIO);
+ cp++;
+ while ((c = *cp) != '\0') {
+ if (c == '/')
+ break;
+ if (c >= '0' && c <= '9') {
+ /* read unit number */
+ unit = c - '0';
+
+ /* look for a partition */
+ if ((c = *++cp) >= 'a' && c <= 'h') {
+ part = c - 'a';
+ c = *++cp;
+ }
+ if (c != '/')
+ return (ENXIO);
+ break;
+ }
+ if (ncp < namebuf + sizeof(namebuf) - 1)
+ *ncp++ = c;
+ cp++;
+ }
+ *ncp = '\0';
+ /*
+ * XXX
+ * pulling strchr from the C library, should pull from libkern.
+ */
+ } else if (strchr(cp, '(')) {
+ /* expect a string like 'rz(0,0,0)vmunix' */
+ while ((c = *cp) != '\0') {
+ if (c == '(') {
+ cp++;
+ break;
+ }
+ if (ncp < namebuf + sizeof(namebuf) - 1)
+ *ncp++ = c;
+ cp++;
+ }
+
+ /* get controller number */
+ if ((c = *cp) >= '0' && c <= '9') {
+ ctlr = c - '0';
+ c = *++cp;
+ }
+
+ if (c == ',') {
+ /* get SCSI device number */
+ if ((c = *++cp) >= '0' && c <= '9') {
+ unit = c - '0';
+ c = *++cp;
+ }
+
+ if (c == ',') {
+ /* get partition number */
+ if ((c = *++cp) >= '0' && c <= '9') {
+ part = c - '0';
+ c = *++cp;
+ }
+ }
+ }
+ if (c != ')')
+ return (ENXIO);
+ cp++;
+ *ncp = '\0';
+ } else {
+ dp = devsw;
+ ctlr = unit = part = 0;
+ goto fnd;
+ }
+
+ for (dp = devsw, i = 0; i < ndevs; dp++, i++)
+ if (dp->dv_name && strcmp(namebuf, dp->dv_name) == 0)
+ goto fnd;
+ printf("Unknown device '%s'\nKnown devices are:", namebuf);
+ for (dp = devsw, i = 0; i < ndevs; dp++, i++)
+ if (dp->dv_name)
+ printf(" %s", dp->dv_name);
+ printf("\n");
+ return (ENXIO);
+
+fnd:
+ rc = (dp->dv_open)(f, ctlr, unit, part);
+ if (rc)
+ return (rc);
+
+ f->f_dev = dp;
+ if (file && *cp != '\0')
+ *file = cp;
+ return (0);
+}
diff --git a/sys/arch/alpha/stand/boot/libsa/filesystem.c b/sys/arch/alpha/stand/boot/libsa/filesystem.c
new file mode 100644
index 00000000000..514e6e809bf
--- /dev/null
+++ b/sys/arch/alpha/stand/boot/libsa/filesystem.c
@@ -0,0 +1,44 @@
+/* $NetBSD: filesystem.c,v 1.2 1995/02/16 02:33:05 cgd Exp $ */
+
+/*
+ * Copyright (c) 1993 Philip A. Nelson.
+ * All rights reserved.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Philip A. Nelson.
+ * 4. The name of Philip A. Nelson may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY PHILIP NELSON ``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 PHILIP NELSON 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.
+ *
+ * filesystem.c
+ */
+
+#include <lib/libsa/stand.h>
+#include <lib/libsa/ufs.h>
+
+struct fs_ops file_system[] = {
+ { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat },
+};
+
+int nfsys = sizeof(file_system)/sizeof(struct fs_ops);
+
diff --git a/sys/arch/alpha/stand/boot/newvers.sh b/sys/arch/alpha/stand/boot/newvers.sh
new file mode 100644
index 00000000000..8e4737c48a6
--- /dev/null
+++ b/sys/arch/alpha/stand/boot/newvers.sh
@@ -0,0 +1,44 @@
+#!/bin/sh -
+#
+# $NetBSD: newvers.sh,v 1.1 1995/02/13 23:08:10 cgd Exp $
+#
+# Copyright (c) 1984, 1986, 1990, 1993
+# The Regents of the University of California. All rights reserved.
+#
+# 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.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the University of
+# California, Berkeley and its contributors.
+# 4. Neither the name of the University nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+#
+# @(#)newvers.sh 8.1 (Berkeley) 4/20/94
+
+u=${USER-root} h=`hostname` t=`date`
+r=`head -1 version`
+
+echo "char bootprog_name[] = \"NetBSD/Alpha boot\";" > vers.c
+echo "char bootprog_rev[] = \"${r}\";" >> vers.c
+echo "char bootprog_date[] = \"${t}\";" >> vers.c
+echo "char bootprog_maker[] = \"${u}@${h}\";" >> vers.c
diff --git a/sys/arch/alpha/stand/boot/prom.c b/sys/arch/alpha/stand/boot/prom.c
new file mode 100644
index 00000000000..92e58cfefe3
--- /dev/null
+++ b/sys/arch/alpha/stand/boot/prom.c
@@ -0,0 +1,135 @@
+/* $NetBSD: prom.c,v 1.3 1995/06/28 00:58:49 cgd Exp $ */
+
+/*
+ * Mach Operating System
+ * Copyright (c) 1992 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * 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.
+ */
+
+#include <sys/types.h>
+
+#include <machine/prom.h>
+#include <machine/rpb.h>
+
+int console;
+
+void
+init_prom_calls()
+{
+ extern struct prom_vec prom_dispatch_v;
+ struct rpb *r;
+ struct crb *c;
+ char buf[4];
+
+ r = (struct rpb *)HWRPB_ADDR;
+ c = (struct crb *)((u_int8_t *)r + r->rpb_crb_off);
+
+ prom_dispatch_v.routine_arg = c->crb_v_dispatch;
+ prom_dispatch_v.routine = c->crb_v_dispatch->code;
+
+ /* Look for console tty. */
+ prom_getenv(PROM_E_TTY_DEV, buf, 4);
+ console = buf[0] - '0';
+}
+
+void
+OSFpal()
+{
+ struct rpb *r;
+ struct ctb *t;
+ struct pcs *p;
+ long result;
+ int offset;
+
+ r = (struct rpb *)HWRPB_ADDR;
+ offset = r->rpb_pcs_size * cpu_number();
+ p = (struct pcs *)((u_int8_t *)r + r->rpb_pcs_off + offset);
+
+ printf("VMS PAL revision: 0x%lx\n",
+ p->pcs_palrevisions[PALvar_OpenVMS]);
+ printf("OSF PAL rev: 0x%lx\n", p->pcs_palrevisions[PALvar_OSF1]);
+ (void)switch_palcode();
+ printf("Switch to OSF PAL code succeeded.\n");
+}
+
+int
+getchar()
+{
+ prom_return_t ret;
+
+ for (;;) {
+ ret.bits = prom_dispatch(PROM_R_GETC, console);
+ if (ret.u.status == 0 || ret.u.status == 1)
+ return (ret.u.retval);
+ }
+}
+
+void
+putchar(c)
+ int c;
+{
+ prom_return_t ret;
+ char cbuf;
+
+ if (c == '\r' || c == '\n') {
+ cbuf = '\r';
+ do {
+ ret.bits = prom_dispatch(PROM_R_PUTS, console,
+ &cbuf, 1);
+ } while ((ret.u.retval & 1) == 0);
+ cbuf = '\n';
+ } else
+ cbuf = c;
+ do {
+ ret.bits = prom_dispatch(PROM_R_PUTS, console, &cbuf, 1);
+ } while ((ret.u.retval & 1) == 0);
+}
+
+int
+prom_getenv(id, buf, len)
+ int id, len;
+ char *buf;
+{
+ prom_return_t ret;
+
+ ret.bits = prom_dispatch(PROM_R_GETENV, id, buf, len-1);
+ if (ret.u.status & 0x4)
+ ret.u.retval = 0;
+ buf[ret.u.retval] = '\0';
+
+ return (ret.u.retval);
+}
+
+int
+prom_open(dev, len)
+ char *dev;
+ int len;
+{
+ prom_return_t ret;
+
+ ret.bits = prom_dispatch(PROM_R_OPEN, dev, len);
+ if (ret.u.status & 0x4)
+ return (-1);
+ else
+ return (ret.u.retval);
+}
diff --git a/sys/arch/alpha/stand/boot/prom_disp.S b/sys/arch/alpha/stand/boot/prom_disp.S
new file mode 100644
index 00000000000..8387dadc9b2
--- /dev/null
+++ b/sys/arch/alpha/stand/boot/prom_disp.S
@@ -0,0 +1,116 @@
+/* $NetBSD: prom_disp.S,v 1.2 1995/02/16 02:32:57 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 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.
+ */
+
+#ifndef LOCORE
+#include "../../include/asm.h"
+#include "../../include/prom.h"
+#include "../../include/rpb.h"
+#endif
+
+ .globl prom_dispatch_v
+ .comm prom_dispatch_v 16
+
+ .text
+ .align 4
+
+/*
+ * Dispatcher routine. Implements prom's calling machinery, saves our
+ * callee-saved registers as required by C.
+ */
+#define D_RA (7*8)
+#define D_S0 (8*8)
+#define D_S1 (9*8)
+#define D_S2 (10*8)
+#define D_S3 (11*8)
+#define D_S4 (12*8)
+#define D_S5 (13*8)
+#define D_S6 (14*8)
+#define DISPATCH_FRAME_SIZE (15*8)
+#define DISPATCH_REGS IM_RA|IM_S0|IM_S1|IM_S2|IM_S3|IM_S4|IM_S5|IM_S6
+
+NESTED(prom_dispatch, 5, DISPATCH_FRAME_SIZE, ra, DISPATCH_REGS, 0)
+
+/* ldgp gp, 0(pv)*/
+ SETGP(pv)
+
+ lda sp, -DISPATCH_FRAME_SIZE(sp)
+ stq ra, D_RA(sp)
+ stq s0, D_S0(sp)
+ stq s1, D_S1(sp)
+ stq s2, D_S2(sp)
+ stq s3, D_S3(sp)
+ stq s4, D_S4(sp)
+ stq s5, D_S5(sp)
+ stq s6, D_S6(sp)
+
+ /* Lord have mercy because.. I would not. */
+/* #define STUPID_PROM_IS_32_BITS */
+#ifdef STUPID_PROM_IS_32_BITS
+ ldah s0, 0x2000(zero) /* hack for hack */
+ lda s0, (0x2000-8)(s0)
+
+ stq sp, 0(s0)
+ or s0, zero, sp
+#endif /* STUPID_PROM_IS_32_BITS */
+
+ lda pv, prom_dispatch_v
+ ldq v0, 0(pv) /* routine */
+ ldq pv, 8(pv) /* routine_arg */
+
+ jsr ra, (v0)
+
+#ifdef STUPID_PROM_IS_32_BITS
+ ldah s0, 0x2000(zero) /* hack for hack */
+ lda s0, (0x2000-8)(s0)
+
+ ldq sp, 0(s0)
+#endif /* STUPID_PROM_IS_32_BITS */
+
+ ldq ra, D_RA(sp)
+ ldq s0, D_S0(sp)
+ ldq s1, D_S1(sp)
+ ldq s2, D_S2(sp)
+ ldq s3, D_S3(sp)
+ ldq s4, D_S4(sp)
+ ldq s5, D_S5(sp)
+ ldq s6, D_S6(sp)
+ lda sp, DISPATCH_FRAME_SIZE(sp)
+ RET
+END(prom_dispatch)
+
+#undef D_RA
+#undef D_S0
+#undef D_S1
+#undef D_S2
+#undef D_S3
+#undef D_S4
+#undef D_S5
+#undef D_S6
+#undef DISPATCH_FRAME_SIZE
+#undef DISPATCH_REGS
diff --git a/sys/arch/alpha/stand/boot/prom_swpal.S b/sys/arch/alpha/stand/boot/prom_swpal.S
new file mode 100644
index 00000000000..7adb240bd20
--- /dev/null
+++ b/sys/arch/alpha/stand/boot/prom_swpal.S
@@ -0,0 +1,136 @@
+/* $NetBSD: prom_swpal.S,v 1.2 1995/02/16 02:32:58 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Keith Bostic
+ *
+ * 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.
+ */
+
+#include "../../include/asm.h"
+#include "../../include/prom.h"
+#include "../../include/rpb.h"
+
+/* Offsets from base of HWRPB. */
+#define RPB_SELFREF 0x00
+#define RPB_SLOTSIZE 0x98
+#define RPB_PERCPU_OFF 0xA0
+
+/* Offsets in a boot PCB. */
+#define PCB_KSP 0x00
+#define PCB_PTBR 0x10
+#define PCB_ASN 0x1c
+#define PCB_FEN 0x28
+
+/* Pal values. */
+#define PAL_RESERVED 0 /* Reserved to Digital. */
+#define PAL_VMS 1 /* VMS */
+#define PAL_OSF 2 /* OSF */
+
+/*
+ * PAL code switch routine.
+ */
+#define D_RA (7*8)
+#define D_S0 (8*8)
+#define D_S1 (9*8)
+#define D_S2 (10*8)
+#define D_S3 (11*8)
+#define D_S4 (12*8)
+#define D_S5 (13*8)
+#define PALSW_FRAME_SIZE (14*8)
+#define PALSW_REGS IM_RA|IM_S0|IM_S1|IM_S2|IM_S3|IM_S4|IM_S5
+
+ .comm ptbr_save 8
+
+ .text
+ .align 4
+
+NESTED(switch_palcode, 0, PALSW_FRAME_SIZE, ra, PALSW_REGS, 0)
+ SETGP(pv)
+/* ldgp gp, 0(pv)*/
+
+ lda sp, -PALSW_FRAME_SIZE(sp)
+ stq ra, D_RA(sp)
+ stq s0, D_S0(sp)
+ stq s1, D_S1(sp)
+ stq s2, D_S2(sp)
+ stq s3, D_S3(sp)
+ stq s4, D_S4(sp)
+ stq s5, D_S5(sp)
+
+ stq pv, 0(sp)
+ stq gp, 8(sp)
+
+ ldiq s0, HWRPB_ADDR /* s0 HWRPB_ADDR */
+ ldq s1, RPB_SLOTSIZE(s0)
+ call_pal PAL_VMS_mfpr_whami
+ mulq s1, v0, s1 /* s1 per_cpu offset from base */
+ ldq s2, RPB_PERCPU_OFF(s0)
+ addq s0, s2, s2
+ addq s2, s1, s2 /* s2 PCB (virtual) */
+
+ call_pal PAL_VMS_mfpr_ptbr
+ stq v0, PCB_PTBR(s2)
+ stq v0, ptbr_save /* save PTBR for the kernel */
+ stl zero, PCB_ASN(s2)
+ stq zero, PCB_FEN(s2)
+ stq sp, PCB_KSP(s2)
+
+ ldq t0, RPB_SELFREF(s0) /* HWRBP base (physical) */
+ ldq t1, RPB_PERCPU_OFF(s0)
+ addq t0, t1, t0
+ addq t0, s1, t0 /* PCB base (phys) */
+ stq t0, 16(sp)
+
+ call_pal PAL_VMS_mfpr_vptb
+ mov v0, a3
+/* movi PAL_OSF, a0 */
+ CONST(PAL_OSF, a0)
+ lda a1, contin
+ ldq a2, 16(sp)
+
+ call_pal PAL_swppal /* a0, a1, a2, a3 */
+
+contin: ldq pv, 0(sp)
+ ldq gp, 8(sp)
+
+ ldq ra, D_RA(sp)
+ ldq s0, D_S0(sp)
+ ldq s1, D_S1(sp)
+ ldq s2, D_S2(sp)
+ ldq s3, D_S3(sp)
+ ldq s4, D_S4(sp)
+ ldq s5, D_S5(sp)
+ lda sp, PALSW_FRAME_SIZE(sp)
+ RET
+END(switch_palcode)
+
+#undef D_RA
+#undef D_S0
+#undef D_S1
+#undef D_S2
+#undef D_S3
+#undef D_S4
+#undef D_S5
+#undef PALSW_FRAME_SIZE
+#undef PALSW_REGS
diff --git a/sys/arch/alpha/stand/boot/start.S b/sys/arch/alpha/stand/boot/start.S
new file mode 100644
index 00000000000..fe7b93a23dc
--- /dev/null
+++ b/sys/arch/alpha/stand/boot/start.S
@@ -0,0 +1,81 @@
+/* $NetBSD: start.S,v 1.2 1995/02/16 02:32:59 cgd Exp $ */
+
+/*
+ * Mach Operating System
+ * Copyright (c) 1992 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * 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.
+ */
+
+#include "../../include/asm.h"
+
+/*
+ * start --
+ * Entry point for boot/standalone programs.
+ *
+ * Arguments:
+ * a0 long (first free physical page)
+ *
+ * This is where the prom comes to. Leaves all exception and interrupts
+ * to prom, runs off prom's stack too. No return values.
+ */
+ .text
+ .set noreorder /* don't reorder instructions */
+
+#define ENTRY_FRAME 32
+
+NESTED(start, 1, ENTRY_FRAME, ra, 0, 0)
+ br pv,1f /* XXX I have no idea what this does. */
+1: SETGP(pv)
+
+ lda sp,start /* start stack below text */
+ lda sp,-ENTRY_FRAME(sp)
+
+ CALL(main) /* transfer to C */
+
+ call_pal PAL_halt /* halt if we ever return */
+END(start)
+
+/*
+ * Dummy routine for GCC2.
+ */
+LEAF(__main,0)
+ RET
+END(__main)
+
+/*
+ * cpu_number
+ * Return the cpu number, using the whami instruction.
+ */
+LEAF(cpu_number, 0)
+ call_pal PAL_VMS_mfpr_whami
+ RET
+END(cpu_number)
+
+/*
+ * halt
+ * Halt
+ */
+LEAF(halt, 0)
+ call_pal PAL_halt
+ RET
+END(halt)
diff --git a/sys/arch/alpha/stand/boot/test.c b/sys/arch/alpha/stand/boot/test.c
new file mode 100644
index 00000000000..6f9f3614bdc
--- /dev/null
+++ b/sys/arch/alpha/stand/boot/test.c
@@ -0,0 +1,61 @@
+/* $NetBSD: test.c,v 1.2 1995/02/16 02:33:00 cgd Exp $ */
+
+/*
+ * Mach Operating System
+ * Copyright (c) 1993 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * 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.
+ */
+#include <sys/types.h>
+
+#include <machine/prom.h>
+#include <machine/rpb.h>
+#include <machine/varargs.h>
+
+main(a1, a2, a3, a4, a5)
+ u_int64_t a1, a2, a3;
+ char *a4[], *a5[];
+{
+ extern int console;
+ prom_return_t ret;
+ int cnt;
+ char devname[128];
+
+ init_prom_calls(); /* Init prom callback vector. */
+
+ (void)printf("TEST BOOT\n");
+ (void)printf("PFN: %lx\n", a1);
+ (void)printf("PTBR: %lx\n", a2);
+ (void)printf("argc: %lu\n", a3);
+ (void)printf("argv[0]: %ls\n", a4[0]);
+ (void)printf("envp: %lx\n", a5);
+
+ ret.bits = prom_getenv(PROM_E_BOOTED_DEV, devname, sizeof(devname));
+ devname[ret.u.retval] = '\0';
+ (void)printf("booted_dev: %s\n", devname);
+
+ ret.bits = prom_getenv(PROM_E_BOOTED_FILE, devname, sizeof(devname));
+ devname[ret.u.retval] = '\0';
+ (void)printf("booted_file: %s\n", devname);
+
+ halt();
+}
diff --git a/sys/arch/alpha/stand/boot/version b/sys/arch/alpha/stand/boot/version
new file mode 100644
index 00000000000..d6a53b8ab55
--- /dev/null
+++ b/sys/arch/alpha/stand/boot/version
@@ -0,0 +1,5 @@
+$NetBSD: version,v 1.3 1995/06/28 00:58:52 cgd Exp $
+
+1.1: Initial version
+1.2: don't forget the Id string!
+1.3: make it work on AlphaStations