summaryrefslogtreecommitdiff
path: root/sys/arch/kbus/stand/sk
diff options
context:
space:
mode:
authorgingold <gingold@cvs.openbsd.org>1997-10-14 07:25:35 +0000
committergingold <gingold@cvs.openbsd.org>1997-10-14 07:25:35 +0000
commitf6491d400ca651a8a1493d72c6a74c622aa231b1 (patch)
tree39f29255154f230f637c12e9214f12a9e64bd9d4 /sys/arch/kbus/stand/sk
parent7a9e3739a66bd0fadfdc611c72e879fcc6f9ef01 (diff)
Gingold's port for kbus Series5 machine. Not fully finished and not very stable
Diffstat (limited to 'sys/arch/kbus/stand/sk')
-rw-r--r--sys/arch/kbus/stand/sk/.gdb_history17
-rw-r--r--sys/arch/kbus/stand/sk/Makefile61
-rw-r--r--sys/arch/kbus/stand/sk/app.c111
-rw-r--r--sys/arch/kbus/stand/sk/boot.c208
-rw-r--r--sys/arch/kbus/stand/sk/clock.c121
-rw-r--r--sys/arch/kbus/stand/sk/clock.h6
-rw-r--r--sys/arch/kbus/stand/sk/clockreg.h70
-rw-r--r--sys/arch/kbus/stand/sk/conf.c32
-rw-r--r--sys/arch/kbus/stand/sk/config.h41
-rw-r--r--sys/arch/kbus/stand/sk/crt0.S860
-rw-r--r--sys/arch/kbus/stand/sk/dev_disk.c132
-rw-r--r--sys/arch/kbus/stand/sk/dev_disk.h6
-rw-r--r--sys/arch/kbus/stand/sk/dev_net.c231
-rw-r--r--sys/arch/kbus/stand/sk/dev_net.h6
-rw-r--r--sys/arch/kbus/stand/sk/devopen.c32
-rw-r--r--sys/arch/kbus/stand/sk/disp-asi.c644
-rw-r--r--sys/arch/kbus/stand/sk/dvma.c68
-rw-r--r--sys/arch/kbus/stand/sk/dvma.h6
-rw-r--r--sys/arch/kbus/stand/sk/eeprom.h6
-rw-r--r--sys/arch/kbus/stand/sk/exec_sun.c212
-rw-r--r--sys/arch/kbus/stand/sk/gets.c141
-rw-r--r--sys/arch/kbus/stand/sk/idprom.h90
-rw-r--r--sys/arch/kbus/stand/sk/if_le.c615
-rw-r--r--sys/arch/kbus/stand/sk/if_lereg.h176
-rw-r--r--sys/arch/kbus/stand/sk/intr.c173
-rw-r--r--sys/arch/kbus/stand/sk/main.c4
-rw-r--r--sys/arch/kbus/stand/sk/panic.c16
-rw-r--r--sys/arch/kbus/stand/sk/probe.c235
-rw-r--r--sys/arch/kbus/stand/sk/prom.h24
-rw-r--r--sys/arch/kbus/stand/sk/promboot.c95
-rw-r--r--sys/arch/kbus/stand/sk/promboot.h5
-rw-r--r--sys/arch/kbus/stand/sk/promcons.c71
-rw-r--r--sys/arch/kbus/stand/sk/version.c9
-rw-r--r--sys/arch/kbus/stand/sk/zs.c218
34 files changed, 4742 insertions, 0 deletions
diff --git a/sys/arch/kbus/stand/sk/.gdb_history b/sys/arch/kbus/stand/sk/.gdb_history
new file mode 100644
index 00000000000..62062332e5d
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/.gdb_history
@@ -0,0 +1,17 @@
+r
+set args "hello"
+r
+print i
+break do_cmd
+r
+n
+n
+n
+n
+print line
+print 0x30d2
+print 12500 * 6 / 10
+print /x 7500
+print /x 7500 - 2
+print 12500 / 6 * 10
+print /x 12500 / 6 * 10 - 2
diff --git a/sys/arch/kbus/stand/sk/Makefile b/sys/arch/kbus/stand/sk/Makefile
new file mode 100644
index 00000000000..8a07f3e0316
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/Makefile
@@ -0,0 +1,61 @@
+# $Id: Makefile,v 1.1 1997/10/14 07:25:32 gingold Exp $
+
+RELOC=0xfff10000
+
+S= ${.CURDIR}/../../../..
+
+SRTOBJ= crt0.o
+DIR_SA=$S/lib/libsa
+DIR_KERN=$S/lib/libkern
+M=$S/lib/libkern/arch/${MACHINE_ARCH}
+
+.if exists ($M/Makefile.inc)
+.PATH: $M
+.include "$M/Makefile.inc"
+.endif
+
+SRC_net= nfs.c rpc.c net.c ether.c arp.c in_cksum.c netif.c \
+ bootparam.c rarp.c
+
+#SRC_sa = alloc.c bcopy.c memcpy.c close.c getfile.c open.c \
+# printf.c read.c strerror.c ufs.c globals.c lseek.c \
+# closeall.c dev.c dkcksum.c nullfs.c fstat.c
+
+SRC_sa = alloc.c memcpy.c memcmp.c memset.c strncmp.c close.c getfile.c \
+ open.c printf.c read.c strerror.c ufs.c globals.c lseek.c \
+ dev.c
+
+SRC_kern= ashrdi3.c bcmp.c bzero.c strcmp.c strlen.c strncpy.c __main.c \
+ urem.S udiv.S sdiv.S umul.S rem.S
+
+SRC_here= clock.c devopen.c dvma.c gets.c panic.c \
+ promboot.c zs.c exec_sun.c \
+ boot.c conf.c version.c dev_net.c if_le.c intr.c app.c \
+ probe.c
+
+SRCS= ${SRC_net} ${SRC_sa} ${SRC_kern} ${SRC_here}
+
+OBJS= ${SRTOBJ} ${SRCS:S/.c/.o/g:S/.S/.o/g}
+
+DEFS= -DSTANDALONE -DSUN_BOOTPARAMS # -DNFS_DEBUG -DDEBUG
+INCL=-I${.CURDIR} -I${S} -I${S}/lib/libsa -I${M}
+COPTS= #-fno-defer-pop
+CFLAGS= -g ${COPTS} ${DEFS} ${DBG} ${INCL}
+
+
+.PATH: ${DIR_SA} ${DIR_KERN} ${DIR_KERN_ARCH}
+
+all: sk
+
+.S.o:
+ ${CC} -c ${CFLAGS} -o $@ $<
+
+sk: ${OBJS}
+ ${LD} -N -Ttext ${RELOC} -e start -o $@ ${OBJS}
+ cp $@ /tftpboot
+
+install:
+ ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ netboot.bin ${DESTDIR}${MDEC_DIR}/netboot
+
+.include <bsd.prog.mk>
diff --git a/sys/arch/kbus/stand/sk/app.c b/sys/arch/kbus/stand/sk/app.c
new file mode 100644
index 00000000000..617c69656d5
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/app.c
@@ -0,0 +1,111 @@
+#define _KERNEL
+#include <sys/param.h>
+#include <machine/psl.h>
+
+extern unsigned int hz_ticks;
+
+#define SPL_BODY(new_spl) \
+{ \
+ int oldspl; \
+ \
+ /* Get old spl. */ \
+ oldspl = lda (ASI_IPR, 0) & 0xff; \
+ \
+ setpil15(); \
+ sta (ASI_IPR, 0, new_spl & 0xff); \
+ setpil0(); \
+ \
+ return oldspl; \
+}
+
+int
+spl0 (void)
+SPL_BODY (0)
+
+int
+spl1 (void)
+SPL_BODY (140)
+
+int
+get_hz (void)
+{
+ int sec;
+ int ticks;
+
+ sec = getsecs () + 1;
+ while (getsecs () < sec)
+ ;
+ ticks = hz_ticks;
+ setpil0 ();
+ while (getsecs () < sec + 8)
+ ;
+ setpil15 ();
+ return (hz_ticks - ticks) / 8;
+}
+
+void
+do_cmd (char *line)
+{
+ char *argv[40];
+ int argc;
+ int i, j;
+
+ for (argc = 0, i = 0; ; argc++)
+ {
+ while (line[i] == ' ')
+ line[i++] = 0;
+ if (line[i] == 0)
+ break;
+ argv[argc] = line + i;
+ while (line[i] && line[i] != ' ')
+ i++;
+ }
+#if 0
+ printf ("argc = %d, argv = ", argc);
+ for (i = 0; i < argc; i++)
+ printf ("%s ", argv[i]);
+ printf ("\n");
+#endif
+
+ if (argc == 0)
+ return;
+ if (strcmp (argv[0], "quit") == 0)
+ _exit (0);
+ else if (strcmp (argv[0], "le") == 0)
+ le_disp_status ();
+ else if (strcmp (argv[0], "ipr?") == 0)
+ printf ("ipr = %d, pil = %d\n",
+ lda (ASI_IPR, 0) & 0xff,
+ (getpsr() & PSR_PIL) >> 8);
+ else if (strcmp (argv[0], "pil0") == 0)
+ setpil0 ();
+ else if (strcmp (argv[0], "pil15") == 0)
+ setpil15 ();
+ else if (strcmp (argv[0], "spl0") == 0)
+ spl0 ();
+ else if (strcmp (argv[0], "spl1") == 0)
+ spl1 ();
+ else if (strcmp (argv[0], "le_intr") == 0)
+ le_intr ();
+ else if (strcmp (argv[0], "zs_intr") == 0)
+ zs_intr ();
+ else if (strcmp (argv[0], "sic?") == 0)
+ printf ("DIR: %x, IPR: %x, IRC: %x, IXR: %x, IXC: %x\n",
+ lduba (ASI_DIR, 0) & SIC_DIR_MASK,
+ lda (ASI_IPR, 0) & SIC_IPR_MASK,
+ lduba (ASI_IRXC, 0) & 0x3,
+ lda (ASI_IXR, 0) & 0xffff,
+ lduba (ASI_ITXC, 0) & 0x3);
+ else if (strcmp (argv[0], "clk?") == 0)
+ printf ("clk: %d\n", hz_ticks);
+ else if (strcmp (argv[0], "init_kbd") == 0)
+ init_kbd ();
+ else if (strcmp (argv[0], "irxc0") == 0)
+ stba (ASI_IRXC, 0, 0);
+ else if (strcmp (argv[0], "irxc1") == 0)
+ stba (ASI_IRXC, 0, 1);
+ else if (strcmp (argv[0], "hz?") == 0)
+ printf ("hz = %d\n", get_hz ());
+ else
+ printf ("Unknown command\n");
+}
diff --git a/sys/arch/kbus/stand/sk/boot.c b/sys/arch/kbus/stand/sk/boot.c
new file mode 100644
index 00000000000..7cbc9a15c52
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/boot.c
@@ -0,0 +1,208 @@
+/* $Id: boot.c,v 1.1 1997/10/14 07:25:31 gingold Exp $ */
+
+/*-
+ * Copyright (c) 1995 Theo de Raadt
+ * 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 Theo de Raadt
+ * 4. The name of the Author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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) 1982, 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.
+ *
+ * @(#)boot.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <sys/param.h>
+#include <sys/reboot.h>
+
+#define _KERNEL
+#include <machine/sic.h>
+#include <machine/asi.h>
+#include <machine/asm.h>
+#include <machine/psl.h>
+
+#include "stand.h"
+#include "promboot.h"
+
+/*
+ * Boot device is derived from ROM provided information.
+ */
+#define LOADADDR 0x10000
+
+extern char version[];
+char defname[32] = "hello";
+char line[80];
+
+#if 0
+u_int bootdev = MAKEBOOTDEV(0, sdmajor, 0, 0, 0); /* disk boot */
+#endif
+u_int bootdev = MAKEBOOTDEV(1, 0, 0, 0, 0); /* network boot */
+
+char **environ;
+
+char *
+getenv (const char *str)
+{
+ char **c;
+ size_t len = strlen (str);
+
+ for (c = environ; *c; c++)
+ {
+ if ((*c)[len] == '=' && strncmp (*c, str, len) == 0)
+ return (*c) + len + 1;
+ }
+ return NULL;
+}
+
+void
+disp_hex (unsigned char c)
+{
+ putchar ("0123456789abcdef"[c >> 4]);
+ putchar ("0123456789abcdef"[c & 0x0f]);
+ putchar (' ');
+}
+
+void
+dump (unsigned char *addr, int len)
+{
+ int i, j;
+
+ for (i = 0; i < len; i+= 16)
+ {
+ printf ("%x: ", i);
+ for (j = 0; j < 16 && (i + j < len); j++)
+ disp_hex(addr[i+j]);
+ printf ("\n");
+ }
+}
+
+extern int debug;
+
+void
+main (int argc, char *argv[], char *envp[])
+{
+ char *cp, *file;
+ int io;
+ int ask = 0;
+
+ environ = envp;
+ printf(">> OpenBSD netboot [%s]\n", version);
+ /* printf("model MVME%x\n", cputyp); */
+
+ printf ("Intr: ");
+ sic_init ();
+ printf ("Enabled\n");
+
+ disp_zs0_b ();
+ udelay (10000);
+#if 0
+ printf ("Before sendint...\n");
+ sendint (1, 150);
+ printf ("Again...\n");
+ sendint (1, 150);
+#endif
+#if 0
+ printf ("Set IPR to 160 and send 160\n");
+ sta (ASI_IPR, 0, 0xa0);
+ sendint (1, 161);
+ sendint (1, 160);
+ printf ("Set IPR to 0\n");
+ sta (ASI_IPR, 0, 0);
+#endif
+#if 0
+ printf ("Set psl to 15, sendint and reset it\n");
+ setpil15();
+ sendint (1, 155);
+ sendint (1,160);
+ sendint (1,160);
+ setpil0();
+
+ disp_date ();
+ udelay (1000000);
+ printf ("Exit\n");
+ _exit (0);
+#endif
+
+ le_low_init ();
+
+ while (1)
+ {
+ printf ("SK> ");
+ gets (line);
+ do_cmd (line);
+ }
+
+ _exit (0);
+
+ prom_get_boot_info();
+ file = defname;
+
+ cp = prom_bootfile;
+ if (cp && *cp)
+ file = cp;
+
+ for (;;) {
+ if (ask) {
+ printf("boot: ");
+ gets(line);
+ if (line[0]) {
+ prom_get_boot_info();
+ }
+ }
+ exec_sun(file, (char *)LOADADDR, prom_boothow);
+ printf("boot: %s\n", strerror(errno));
+ ask = 1;
+ }
+}
diff --git a/sys/arch/kbus/stand/sk/clock.c b/sys/arch/kbus/stand/sk/clock.c
new file mode 100644
index 00000000000..f0cdb090c27
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/clock.c
@@ -0,0 +1,121 @@
+#include <sys/types.h>
+
+#include "clockreg.h"
+#include "config.h"
+#include "clock.h"
+
+/*
+ * BCD to decimal and decimal to BCD.
+ */
+#define FROM_BCD(x,y) ((x) + 10 * (y))
+
+#define SECDAY (24 * 60 * 60)
+#define SECYR (SECDAY * 365)
+#define LEAPYEAR(y) (((y) & 3) == 0)
+
+/*
+ * This code is defunct after 2068.
+ * Will Unix still be here then??
+ */
+const short dayyr[12] =
+{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
+
+static u_long
+chiptotime(sec, min, hour, day, mon, year)
+ register int sec, min, hour, day, mon, year;
+{
+ register int days, yr;
+
+ if (year < 70)
+ year = 70;
+
+ /* simple sanity checks */
+ if (year < 70 || mon < 1 || mon > 12 || day < 1 || day > 31)
+ return (0);
+ days = 0;
+ for (yr = 70; yr < year; yr++)
+ days += LEAPYEAR(yr) ? 366 : 365;
+ days += dayyr[mon - 1] + day - 1;
+ if (LEAPYEAR(yr) && mon > 2)
+ days++;
+ /* now have days since Jan 1, 1970; the rest is easy... */
+ return (days * SECDAY + hour * 3600 + min * 60 + sec);
+}
+
+static u_char *rtc_byte = (u_char *) 0x17020000;
+
+static u_char
+rtc_read_reg (int reg)
+{
+ u_char res;
+
+ reg &= 0x0f;
+ *rtc_byte = RTC_WRITE_ADDR | reg;
+ *rtc_byte = reg;
+ *rtc_byte = RTC_READ | 0x0f;
+ res = *rtc_byte & 0x0f;
+ *rtc_byte = RTC_WRITE_ADDR | 0x0f;
+ *rtc_byte = 0x0f;
+ return res;
+}
+
+time_t
+getsecs()
+{
+ int sec, min, hour, hourl, hourh, day, mon, year;
+
+ sec = FROM_BCD (rtc_read_reg (RTC_SEC_LOW),
+ rtc_read_reg (RTC_SEC_HIGH));
+ min = FROM_BCD (rtc_read_reg (RTC_MIN_LOW),
+ rtc_read_reg (RTC_MIN_HIGH));
+ day = FROM_BCD (rtc_read_reg (RTC_DAY_LOW),
+ rtc_read_reg (RTC_DAY_HIGH));
+ mon = FROM_BCD (rtc_read_reg (RTC_MON_LOW),
+ rtc_read_reg (RTC_MON_HIGH));
+ year = RTC_YEAR_BASE + FROM_BCD (rtc_read_reg (RTC_YEAR_LOW),
+ rtc_read_reg (RTC_YEAR_HIGH));
+ hourl = rtc_read_reg (RTC_HOUR_LOW);
+ hourh = rtc_read_reg (RTC_HOUR_HIGH);
+ if (hourh & RTC_HOUR_PM)
+ hour = 12 + (hourh & 1) * 10 + hourl;
+ else
+ hour = (hourh & 0x03) * 10 + hourl;
+ return (chiptotime(sec, min, hour, day, mon, year));
+}
+
+void
+disp_date (void)
+{
+ static char *days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
+ int hour, hourl, hourh, day, wday, mon, year;
+
+ wday = rtc_read_reg (RTC_WEEK_DAY);
+ day = FROM_BCD (rtc_read_reg (RTC_DAY_LOW),
+ rtc_read_reg (RTC_DAY_HIGH));
+ mon = FROM_BCD (rtc_read_reg (RTC_MON_LOW),
+ rtc_read_reg (RTC_MON_HIGH));
+ year = RTC_YEAR_BASE + FROM_BCD (rtc_read_reg (RTC_YEAR_LOW),
+ rtc_read_reg (RTC_YEAR_HIGH));
+ hourl = rtc_read_reg (RTC_HOUR_LOW);
+ hourh = rtc_read_reg (RTC_HOUR_HIGH);
+
+ if (hourh & RTC_HOUR_PM)
+ hour = 12 + (hourh & 1) * 10 + hourl;
+ else
+ hour = (hourh & 0x03) * 10 + hourl;
+
+ printf ("Date: %s %d-%d-%d %d:%d%d:%d%d\n",
+ days[wday],
+ 1900 + year, mon, day,
+ hour,
+ rtc_read_reg (RTC_MIN_HIGH),
+ rtc_read_reg (RTC_MIN_LOW),
+ rtc_read_reg (RTC_SEC_HIGH),
+ rtc_read_reg (RTC_SEC_LOW));
+}
+
+int
+getticks()
+{
+ return getsecs() * 100;
+}
diff --git a/sys/arch/kbus/stand/sk/clock.h b/sys/arch/kbus/stand/sk/clock.h
new file mode 100644
index 00000000000..d61bc9b03b8
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/clock.h
@@ -0,0 +1,6 @@
+
+extern int hz;
+
+time_t getsecs();
+int getticks();
+
diff --git a/sys/arch/kbus/stand/sk/clockreg.h b/sys/arch/kbus/stand/sk/clockreg.h
new file mode 100644
index 00000000000..ff46693e2e2
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/clockreg.h
@@ -0,0 +1,70 @@
+/* $Id: clockreg.h,v 1.1 1997/10/14 07:25:31 gingold Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * 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, Lawrence Berkeley Laboratory.
+ *
+ * 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.
+ *
+ * @(#)clockreg.h 8.1 (Berkeley) 6/11/93
+ */
+
+/* RTC 58321. */
+#define RTC_STOP 0x80 /* Stop RTC clock. */
+#define RTC_WRITE 0x40 /* Write access. */
+#define RTC_READ 0x20 /* Read access. */
+#define RTC_WRITE_ADDR 0x10 /* Write address. */
+
+#define RTC_SEC_LOW 0x00 /* RTC seconds (low nibble). */
+#define RTC_SEC_HIGH 0x01 /* RTC seconds (high nibble). */
+#define RTC_MIN_LOW 0x02 /* RTC minutes (low nibble). */
+#define RTC_MIN_HIGH 0x03 /* RTC minutes (high nibble). */
+#define RTC_HOUR_LOW 0x04 /* RTC hours (low nibble). */
+#define RTC_HOUR_HIGH 0x05 /* RTC hours (high nibble). */
+#define RTC_HOUR_24 0x08 /* RTC 24 hours mode bit. */
+#define RTC_HOUR_PM 0x04 /* RTC p.m. bit. */
+#define RTC_WEEK_DAY 0x06 /* RTC day of the week. */
+#define RTC_DAY_LOW 0x07 /* RTC day of the month (low nibble). */
+#define RTC_DAY_HIGH 0x08 /* RTC day of the month (high nibble). */
+#define RTC_MON_LOW 0x09 /* RTC month (low nibble). */
+#define RTC_MON_HIGH 0x0a /* RTC month (high nibble). */
+#define RTC_YEAR_LOW 0x0b /* RTC year (low nibble). */
+#define RTC_YEAR_HIGH 0x0c /* RTC year (high nibble). */
+
+#define RTC_YEAR_BASE 68
+
diff --git a/sys/arch/kbus/stand/sk/conf.c b/sys/arch/kbus/stand/sk/conf.c
new file mode 100644
index 00000000000..69218ec3c93
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/conf.c
@@ -0,0 +1,32 @@
+/* $Id: conf.c,v 1.1 1997/10/14 07:25:31 gingold Exp $ */
+
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+
+#include <stand.h>
+#include <nfs.h>
+#include <dev_net.h>
+
+struct fs_ops file_system[] = {
+ { nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat },
+};
+int nfsys = sizeof(file_system) / sizeof(file_system[0]);
+
+struct devsw devsw[] = {
+ { "net", net_strategy, net_open, net_close, net_ioctl },
+};
+int ndevs = sizeof(devsw) / sizeof(devsw[0]);
+
+extern struct netif_driver le_driver;
+
+struct netif_driver *netif_drivers[] = {
+ &le_driver
+};
+int n_netif_drivers = sizeof(netif_drivers) / sizeof(netif_drivers[0]);
+
+
+/* XXX */
+int netif_debug;
+int debug;
+int errno;
diff --git a/sys/arch/kbus/stand/sk/config.h b/sys/arch/kbus/stand/sk/config.h
new file mode 100644
index 00000000000..04449843278
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/config.h
@@ -0,0 +1,41 @@
+/* $Id: config.h,v 1.1 1997/10/14 07:25:31 gingold Exp $ */
+
+/*
+ * Copyright (c) 1995 Theo de Raadt
+ * 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 Theo de Raadt
+ * 4. The name of the Author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+/* configuration information for base-line code */
+
+#if 0
+#define ETHER_ADDR_147 (0xfffe0778)
+#define ETHER_ADDR_16X (0xfffc0000+7980)
+#define ERAM_ADDR (0xfffe0774)
+#endif
+#define LANCE_REG_ADDR (0x90001000)
diff --git a/sys/arch/kbus/stand/sk/crt0.S b/sys/arch/kbus/stand/sk/crt0.S
new file mode 100644
index 00000000000..03348ca60c5
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/crt0.S
@@ -0,0 +1,860 @@
+#include <machine/led.h>
+#include <machine/asi.h>
+#include <machine/kbus.h>
+#include <machine/psl.h>
+#include <machine/pmap.h>
+
+ .text
+#define __WINSIZE 8
+
+#define DEF_TRAP(func,val) \
+ mov val, %l3; \
+ b func; \
+ mov %wim, %l0; \
+ nop
+
+ .globl start
+ .globl _exception_table
+_exception_table:
+start:
+reset:
+ b real_start
+ nop
+ nop
+ nop
+DEF_TRAP (bad_except, 1) ! 1: Instruction access
+DEF_TRAP (bad_except, 2) ! 2: Illegal Instruction
+DEF_TRAP (bad_except, 3) ! 3: Privilegied Instruction
+DEF_TRAP (bad_except, 4) ! 4: Floating-Point disabled
+DEF_TRAP (win_ovf, 5) ! 5: Window overflow
+DEF_TRAP (win_unf, 6) ! 6: Window undeflow
+DEF_TRAP (bad_except, 7) ! 7: Memory address not aligned
+DEF_TRAP (bad_except, 8) ! 8: Floating point exception
+#if 1
+DEF_TRAP (bad_except, 9) ! 9: data access exception
+#else
+DEF_TRAP (chk_data_tlbmiss, 9) ! 9: data access exception
+#endif
+DEF_TRAP (bad_except, 10) ! 10: Tag overflow
+DEF_TRAP (bad_except, 11) ! 11: -
+DEF_TRAP (bad_except, 12) ! 12: -
+DEF_TRAP (bad_except, 13) ! 13: -
+DEF_TRAP (bad_except, 14) ! 14: -
+DEF_TRAP (bad_except, 15) ! 15: -
+DEF_TRAP (bad_except, 16) ! 16: -
+DEF_TRAP (interrupt, 1) ! 17: Interrupt level 1
+DEF_TRAP (interrupt, 2) ! 18: Interrupt level 2
+DEF_TRAP (interrupt, 3) ! 19: Interrupt level 3
+DEF_TRAP (interrupt, 4) ! 20: Interrupt level 4
+DEF_TRAP (interrupt, 5) ! 21: Interrupt level 5
+DEF_TRAP (interrupt, 6) ! 22: Interrupt level 6
+DEF_TRAP (interrupt, 7) ! 23: Interrupt level 7
+DEF_TRAP (interrupt, 8) ! 24: Interrupt level 8
+DEF_TRAP (interrupt, 9) ! 25: Interrupt level 9
+DEF_TRAP (interrupt, 10) ! 26: Interrupt level 10
+DEF_TRAP (interrupt, 11) ! 27: Interrupt level 11
+DEF_TRAP (interrupt, 12) ! 28: Interrupt level 12
+DEF_TRAP (interrupt, 13) ! 29: Interrupt level 13
+DEF_TRAP (interrupt, 14) ! 30: Interrupt level 14
+DEF_TRAP (nmi, 15) ! 31: Interrupt level 15
+DEF_TRAP (bad_except, 32) ! 32: -
+DEF_TRAP (bad_except, 33) ! 33: -
+DEF_TRAP (bad_except, 34) ! 34: -
+DEF_TRAP (bad_except, 35) ! 35: -
+DEF_TRAP (bad_except, 36) ! 36: Coprocessor disabled
+DEF_TRAP (bad_except, 37) ! 37: -
+DEF_TRAP (bad_except, 38) ! 38: -
+DEF_TRAP (bad_except, 39) ! 39: -
+DEF_TRAP (bad_except, 40) ! 40: -
+DEF_TRAP (bad_except, 41) ! 41: -
+DEF_TRAP (bad_except, 42) ! 42: -
+DEF_TRAP (bad_except, 43) ! 43: -
+DEF_TRAP (bad_except, 44) ! 44: -
+DEF_TRAP (bad_except, 45) ! 45: -
+DEF_TRAP (bad_except, 46) ! 46: -
+DEF_TRAP (bad_except, 47) ! 47: -
+DEF_TRAP (bad_except, 48) ! 48: -
+DEF_TRAP (bad_except, 49) ! 49: -
+DEF_TRAP (bad_except, 50) ! 50: -
+DEF_TRAP (bad_except, 51) ! 51: -
+DEF_TRAP (bad_except, 52) ! 52: -
+DEF_TRAP (bad_except, 53) ! 53: -
+DEF_TRAP (bad_except, 54) ! 54: -
+DEF_TRAP (bad_except, 55) ! 55: -
+DEF_TRAP (bad_except, 56) ! 56: -
+DEF_TRAP (bad_except, 57) ! 57: -
+DEF_TRAP (bad_except, 58) ! 58: -
+DEF_TRAP (bad_except, 59) ! 59: -
+DEF_TRAP (bad_except, 60) ! 60: -
+DEF_TRAP (bad_except, 61) ! 61: -
+DEF_TRAP (bad_except, 62) ! 62: -
+DEF_TRAP (bad_except, 63) ! 63: -
+DEF_TRAP (bad_except, 64) ! 64: -
+DEF_TRAP (bad_except, 65) ! 65: -
+DEF_TRAP (bad_except, 66) ! 66: -
+DEF_TRAP (bad_except, 67) ! 67: -
+DEF_TRAP (bad_except, 68) ! 68: -
+DEF_TRAP (bad_except, 69) ! 69: -
+DEF_TRAP (bad_except, 70) ! 70: -
+DEF_TRAP (bad_except, 71) ! 71: -
+DEF_TRAP (bad_except, 72) ! 72: -
+DEF_TRAP (bad_except, 73) ! 73: -
+DEF_TRAP (bad_except, 74) ! 74: -
+DEF_TRAP (bad_except, 75) ! 75: -
+DEF_TRAP (bad_except, 76) ! 76: -
+DEF_TRAP (bad_except, 77) ! 77: -
+DEF_TRAP (bad_except, 78) ! 78: -
+DEF_TRAP (bad_except, 79) ! 79: -
+DEF_TRAP (bad_except, 80) ! 80: -
+DEF_TRAP (bad_except, 81) ! 81: -
+DEF_TRAP (bad_except, 82) ! 82: -
+DEF_TRAP (bad_except, 83) ! 83: -
+DEF_TRAP (bad_except, 84) ! 84: -
+DEF_TRAP (bad_except, 85) ! 85: -
+DEF_TRAP (bad_except, 86) ! 86: -
+DEF_TRAP (bad_except, 87) ! 87: -
+DEF_TRAP (bad_except, 88) ! 88: -
+DEF_TRAP (bad_except, 89) ! 89: -
+DEF_TRAP (bad_except, 90) ! 90: -
+DEF_TRAP (bad_except, 91) ! 91: -
+DEF_TRAP (bad_except, 92) ! 92: -
+DEF_TRAP (bad_except, 93) ! 93: -
+DEF_TRAP (bad_except, 94) ! 94: -
+DEF_TRAP (bad_except, 95) ! 95: -
+DEF_TRAP (bad_except, 96) ! 96: -
+DEF_TRAP (bad_except, 97) ! 97: -
+DEF_TRAP (bad_except, 98) ! 98: -
+DEF_TRAP (bad_except, 99) ! 99: -
+DEF_TRAP (bad_except, 100) ! 100: -
+DEF_TRAP (bad_except, 101) ! 101: -
+DEF_TRAP (bad_except, 102) ! 102: -
+DEF_TRAP (bad_except, 103) ! 103: -
+DEF_TRAP (bad_except, 104) ! 104: -
+DEF_TRAP (bad_except, 105) ! 105: -
+DEF_TRAP (bad_except, 106) ! 106: -
+DEF_TRAP (bad_except, 107) ! 107: -
+DEF_TRAP (bad_except, 108) ! 108: -
+DEF_TRAP (bad_except, 109) ! 109: -
+DEF_TRAP (bad_except, 110) ! 110: -
+DEF_TRAP (bad_except, 111) ! 111: -
+DEF_TRAP (bad_except, 112) ! 112: -
+DEF_TRAP (bad_except, 113) ! 113: -
+DEF_TRAP (bad_except, 114) ! 114: -
+DEF_TRAP (bad_except, 115) ! 115: -
+DEF_TRAP (bad_except, 116) ! 116: -
+DEF_TRAP (bad_except, 117) ! 117: -
+DEF_TRAP (bad_except, 118) ! 118: -
+DEF_TRAP (bad_except, 119) ! 119: -
+DEF_TRAP (bad_except, 120) ! 120: -
+DEF_TRAP (bad_except, 121) ! 121: -
+DEF_TRAP (bad_except, 122) ! 122: -
+DEF_TRAP (bad_except, 123) ! 123: -
+DEF_TRAP (bad_except, 124) ! 124: -
+DEF_TRAP (bad_except, 125) ! 125: -
+DEF_TRAP (bad_except, 126) ! 126: -
+DEF_TRAP (bad_except, 127) ! 127: -
+DEF_TRAP (bad_except, 128) ! 128: Trap instruction
+DEF_TRAP (bad_except, 129) ! 129: Trap instruction
+DEF_TRAP (bad_except, 130) ! 130: Trap instruction
+DEF_TRAP (bad_except, 131) ! 131: Trap instruction
+DEF_TRAP (bad_except, 132) ! 132: Trap instruction
+DEF_TRAP (bad_except, 133) ! 133: Trap instruction
+DEF_TRAP (bad_except, 134) ! 134: Trap instruction
+DEF_TRAP (bad_except, 135) ! 135: Trap instruction
+DEF_TRAP (bad_except, 136) ! 136: Trap instruction
+DEF_TRAP (bad_except, 137) ! 137: Trap instruction
+DEF_TRAP (bad_except, 138) ! 138: Trap instruction
+DEF_TRAP (bad_except, 139) ! 139: Trap instruction
+DEF_TRAP (bad_except, 140) ! 140: Trap instruction
+DEF_TRAP (bad_except, 141) ! 141: Trap instruction
+DEF_TRAP (bad_except, 142) ! 142: Trap instruction
+DEF_TRAP (bad_except, 143) ! 143: Trap instruction
+DEF_TRAP (bad_except, 144) ! 144: Trap instruction
+DEF_TRAP (bad_except, 145) ! 145: Trap instruction
+DEF_TRAP (bad_except, 146) ! 146: Trap instruction
+DEF_TRAP (bad_except, 147) ! 147: Trap instruction
+DEF_TRAP (bad_except, 148) ! 148: Trap instruction
+DEF_TRAP (bad_except, 149) ! 149: Trap instruction
+DEF_TRAP (bad_except, 150) ! 150: Trap instruction
+DEF_TRAP (bad_except, 151) ! 151: Trap instruction
+DEF_TRAP (bad_except, 152) ! 152: Trap instruction
+DEF_TRAP (bad_except, 153) ! 153: Trap instruction
+DEF_TRAP (bad_except, 154) ! 154: Trap instruction
+DEF_TRAP (bad_except, 155) ! 155: Trap instruction
+DEF_TRAP (bad_except, 156) ! 156: Trap instruction
+DEF_TRAP (bad_except, 157) ! 157: Trap instruction
+DEF_TRAP (bad_except, 158) ! 158: Trap instruction
+DEF_TRAP (bad_except, 159) ! 159: Trap instruction
+DEF_TRAP (bad_except, 160) ! 160: Trap instruction
+DEF_TRAP (bad_except, 161) ! 161: Trap instruction
+DEF_TRAP (bad_except, 162) ! 162: Trap instruction
+DEF_TRAP (bad_except, 163) ! 163: Trap instruction
+DEF_TRAP (bad_except, 164) ! 164: Trap instruction
+DEF_TRAP (bad_except, 165) ! 165: Trap instruction
+DEF_TRAP (bad_except, 166) ! 166: Trap instruction
+DEF_TRAP (bad_except, 167) ! 167: Trap instruction
+DEF_TRAP (bad_except, 168) ! 168: Trap instruction
+DEF_TRAP (bad_except, 169) ! 169: Trap instruction
+DEF_TRAP (bad_except, 170) ! 170: Trap instruction
+DEF_TRAP (bad_except, 171) ! 171: Trap instruction
+DEF_TRAP (bad_except, 172) ! 172: Trap instruction
+DEF_TRAP (bad_except, 173) ! 173: Trap instruction
+DEF_TRAP (bad_except, 174) ! 174: Trap instruction
+DEF_TRAP (bad_except, 175) ! 175: Trap instruction
+DEF_TRAP (bad_except, 176) ! 176: Trap instruction
+DEF_TRAP (bad_except, 177) ! 177: Trap instruction
+DEF_TRAP (bad_except, 178) ! 178: Trap instruction
+DEF_TRAP (bad_except, 179) ! 179: Trap instruction
+DEF_TRAP (bad_except, 180) ! 180: Trap instruction
+DEF_TRAP (bad_except, 181) ! 181: Trap instruction
+DEF_TRAP (bad_except, 182) ! 182: Trap instruction
+DEF_TRAP (bad_except, 183) ! 183: Trap instruction
+DEF_TRAP (bad_except, 184) ! 184: Trap instruction
+DEF_TRAP (bad_except, 185) ! 185: Trap instruction
+DEF_TRAP (bad_except, 186) ! 186: Trap instruction
+DEF_TRAP (bad_except, 187) ! 187: Trap instruction
+DEF_TRAP (bad_except, 188) ! 188: Trap instruction
+DEF_TRAP (bad_except, 189) ! 189: Trap instruction
+DEF_TRAP (bad_except, 190) ! 190: Trap instruction
+DEF_TRAP (bad_except, 191) ! 191: Trap instruction
+DEF_TRAP (bad_except, 192) ! 192: Trap instruction
+DEF_TRAP (bad_except, 193) ! 193: Trap instruction
+DEF_TRAP (bad_except, 194) ! 194: Trap instruction
+DEF_TRAP (bad_except, 195) ! 195: Trap instruction
+DEF_TRAP (bad_except, 196) ! 196: Trap instruction
+DEF_TRAP (bad_except, 197) ! 197: Trap instruction
+DEF_TRAP (bad_except, 198) ! 198: Trap instruction
+DEF_TRAP (bad_except, 199) ! 199: Trap instruction
+DEF_TRAP (bad_except, 200) ! 200: Trap instruction
+DEF_TRAP (bad_except, 201) ! 201: Trap instruction
+DEF_TRAP (bad_except, 202) ! 202: Trap instruction
+DEF_TRAP (bad_except, 203) ! 203: Trap instruction
+DEF_TRAP (bad_except, 204) ! 204: Trap instruction
+DEF_TRAP (bad_except, 205) ! 205: Trap instruction
+DEF_TRAP (bad_except, 206) ! 206: Trap instruction
+DEF_TRAP (bad_except, 207) ! 207: Trap instruction
+DEF_TRAP (bad_except, 208) ! 208: Trap instruction
+DEF_TRAP (bad_except, 209) ! 209: Trap instruction
+DEF_TRAP (bad_except, 210) ! 210: Trap instruction
+DEF_TRAP (bad_except, 211) ! 211: Trap instruction
+DEF_TRAP (bad_except, 212) ! 212: Trap instruction
+DEF_TRAP (bad_except, 213) ! 213: Trap instruction
+DEF_TRAP (bad_except, 214) ! 214: Trap instruction
+DEF_TRAP (bad_except, 215) ! 215: Trap instruction
+DEF_TRAP (bad_except, 216) ! 216: Trap instruction
+DEF_TRAP (bad_except, 217) ! 217: Trap instruction
+DEF_TRAP (bad_except, 218) ! 218: Trap instruction
+DEF_TRAP (bad_except, 219) ! 219: Trap instruction
+DEF_TRAP (bad_except, 220) ! 220: Trap instruction
+DEF_TRAP (bad_except, 221) ! 221: Trap instruction
+DEF_TRAP (bad_except, 222) ! 222: Trap instruction
+DEF_TRAP (bad_except, 223) ! 223: Trap instruction
+DEF_TRAP (bad_except, 224) ! 224: Trap instruction
+DEF_TRAP (bad_except, 225) ! 225: Trap instruction
+DEF_TRAP (bad_except, 226) ! 226: Trap instruction
+DEF_TRAP (bad_except, 227) ! 227: Trap instruction
+DEF_TRAP (bad_except, 228) ! 228: Trap instruction
+DEF_TRAP (bad_except, 229) ! 229: Trap instruction
+DEF_TRAP (bad_except, 230) ! 230: Trap instruction
+DEF_TRAP (bad_except, 231) ! 231: Trap instruction
+DEF_TRAP (bad_except, 232) ! 232: Trap instruction
+DEF_TRAP (bad_except, 233) ! 233: Trap instruction
+DEF_TRAP (bad_except, 234) ! 234: Trap instruction
+DEF_TRAP (bad_except, 235) ! 235: Trap instruction
+DEF_TRAP (bad_except, 236) ! 236: Trap instruction
+DEF_TRAP (bad_except, 237) ! 237: Trap instruction
+DEF_TRAP (bad_except, 238) ! 238: Trap instruction
+DEF_TRAP (bad_except, 239) ! 239: Trap instruction
+DEF_TRAP (bad_except, 240) ! 240: Trap instruction
+DEF_TRAP (bad_except, 241) ! 241: Trap instruction
+DEF_TRAP (bad_except, 242) ! 242: Trap instruction
+DEF_TRAP (bad_except, 243) ! 243: Trap instruction
+DEF_TRAP (bad_except, 244) ! 244: Trap instruction
+DEF_TRAP (bad_except, 245) ! 245: Trap instruction
+DEF_TRAP (bad_except, 246) ! 246: Trap instruction
+DEF_TRAP (bad_except, 247) ! 247: Trap instruction
+DEF_TRAP (bad_except, 248) ! 248: Trap instruction
+DEF_TRAP (bad_except, 249) ! 249: Trap instruction
+DEF_TRAP (bad_except, 250) ! 250: Trap instruction
+DEF_TRAP (bad_except, 251) ! 251: Trap instruction
+DEF_TRAP (bad_except, 252) ! 252: Trap instruction
+DEF_TRAP (bad_except, 253) ! 253: Trap instruction
+DEF_TRAP (bad_except, 254) ! 254: Trap instruction
+DEF_TRAP (bad_except, 255) ! 255: Trap instruction
+
+ .reserve trapstack, 1000 * 4, "bss", 8
+
+ .data
+ .align 4
+
+ .globl _in_trap_handler
+_in_trap_handler:
+in_trap_handler:
+ .word 0
+
+ .globl _debug_tbr
+_debug_tbr:
+ .word 0
+ .globl _debug_ret
+_debug_ret:
+ .word 0
+
+ .globl _nofault
+_nofault:
+ .word 0
+
+led_xlat:
+ .byte LED_0
+ .byte LED_1
+ .byte LED_2
+ .byte LED_3
+ .byte LED_4
+ .byte LED_5
+ .byte LED_6
+ .byte LED_7
+ .byte LED_8
+ .byte LED_9
+ .byte LED_A
+ .byte LED_b
+ .byte LED_C
+ .byte LED_d
+ .byte LED_E
+ .byte LED_F
+
+ .text
+ .align 4
+
+
+#if 0
+excpt_dataaccess:
+ ! %l3 contains the trap number.
+ ! Disp it on the leds.
+
+ ! Load the led table addressin %l4
+ sethi %hi(led_xlat), %l4
+ or %l4, %lo(led_xlat), %l4
+
+ ! Convert %l3 into a led half word.
+ and %l3, 0x0f, %l5
+ ldub [%l4 + %l5], %l5
+ srl %l3, 4, %l3
+ and %l3, 0x0f, %l3
+ ldub [%l4 + %l3], %l3
+ and %l3, LED_DP, %l3
+ sll %l3, 8, %l3
+ or %l3, %l5, %l3
+
+ ! Disp it on the led
+ stha %l3, [%g0](0xc1)
+
+ lda [%g0](0x81), %l3
+ lda [%g0](0x82), %g0
+ sethi %hi(_nofault), %l3
+ st %g0, [%l3 + %lo(_nofault)]
+
+ ! Return to the next instruction
+ jmp %l2
+ rett %l2 + 4
+#endif
+! This function is called when any SPARC trap (except window overflow or
+! underflow) occurs. It makes sure that the invalid register window is still
+! available before jumping into C code. It will also restore the world if you
+! return from handle_exception.
+
+! %l1 contains %pc
+! %l2 contains %npc
+ .globl bad_except
+bad_except:
+interrupt:
+ rd %psr, %l0
+#if 1
+ ! %l3 contains the trap number.
+ ! Disp it on the leds.
+
+ ! Load the led table addressin %l4
+ sethi %hi(led_xlat), %l4
+ or %l4, %lo(led_xlat), %l4
+
+ ! Convert %l3 into a led half word.
+ and %l3, 0x0f, %l5
+ ldub [%l4 + %l5], %l5
+ srl %l3, 4, %l3
+ and %l3, 0x0f, %l3
+ ldub [%l4 + %l3], %l3
+ and %l3, LED_DP, %l3
+ sll %l3, 8, %l3
+ or %l3, %l5, %l3
+
+ ! Disp it on the led
+ stha %l3, [%g0](ASI_LED)
+#endif
+#if 0
+ ! Return
+ jmp %l2
+ rett %l2 + 4
+
+ ! Wait for ever.
+1:
+ b 1b
+ nop
+#endif
+
+ mov %wim, %l3
+
+ ! Read FCR and FVAR now, otherwise data access to memory is disabled.
+ lda [%g0](ASI_FCR), %l6
+ lda [%g0](ASI_FVAR), %l7
+
+ srl %l3, %l0, %l4 ! wim >> cwp
+ cmp %l4, 1
+ bne window_fine ! Branch if not in the invalid window
+ nop
+
+! Handle window overflow
+ mov %g1, %l4
+ sll %l3, 1, %g1 ! Rotate wim left
+ srl %l3, __WINSIZE-1, %l3
+ or %g1, %l3, %g1
+
+ save %g0, %g0, %g0 ! Slip into next window
+ mov %g1, %wim ! Install the new wim
+
+ std %l0, [%sp + 0 * 4] ! save L & I registers
+ std %l2, [%sp + 2 * 4]
+ std %l4, [%sp + 4 * 4]
+ std %l6, [%sp + 6 * 4]
+
+ std %i0, [%sp + 8 * 4]
+ std %i2, [%sp + 10 * 4]
+ std %i4, [%sp + 12 * 4]
+ std %i6, [%sp + 14 * 4]
+
+ restore ! Go back to trap window.
+ mov %l4, %g1 ! Restore %g1
+
+window_fine:
+ sethi %hi(in_trap_handler), %l4
+ ld [%lo(in_trap_handler) + %l4], %l5
+ tst %l5
+ bg recursive_trap
+ inc %l5
+
+ set trapstack+1000*4, %sp ! Switch to trap stack
+
+recursive_trap:
+ st %l5, [%lo(in_trap_handler) + %l4]
+ sub %sp,(16+1+6+1+80)*4,%sp ! Make room for input & locals
+ ! + hidden arg + arg spill
+ ! + doubleword alignment
+ ! + registers[72] local var
+
+ std %g0, [%sp + (24 + 0) * 4] ! registers[Gx]
+ std %g2, [%sp + (24 + 2) * 4]
+ std %g4, [%sp + (24 + 4) * 4]
+ std %g6, [%sp + (24 + 6) * 4]
+
+ std %i0, [%sp + (24 + 8) * 4] ! registers[Ox]
+ std %i2, [%sp + (24 + 10) * 4]
+ std %i4, [%sp + (24 + 12) * 4]
+ std %i6, [%sp + (24 + 14) * 4]
+
+ mov %y, %l4
+ mov %tbr, %l5
+ st %l4, [%sp + (24 + 64) * 4] ! Y
+ st %l0, [%sp + (24 + 65) * 4] ! PSR
+ st %l3, [%sp + (24 + 66) * 4] ! WIM
+ st %l5, [%sp + (24 + 67) * 4] ! TBR
+ st %l1, [%sp + (24 + 68) * 4] ! PC
+ st %l2, [%sp + (24 + 69) * 4] ! NPC
+
+ or %l0, 0xf20, %l4
+ mov %l4, %psr ! Turn on traps, disable interrupts
+ nop
+ nop
+ nop
+
+ set 0x1000, %l1
+ btst %l1, %l0 ! FP enabled?
+ be no_fpstore
+ nop
+
+! Must save fsr first, to flush the FQ. This may cause a deferred fp trap, so
+! traps must be enabled to allow the trap handler to clean things up.
+
+ st %fsr, [%sp + (24 + 70) * 4]
+
+ std %f0, [%sp + (24 + 32) * 4]
+ std %f2, [%sp + (24 + 34) * 4]
+ std %f4, [%sp + (24 + 36) * 4]
+ std %f6, [%sp + (24 + 38) * 4]
+ std %f8, [%sp + (24 + 40) * 4]
+ std %f10, [%sp + (24 + 42) * 4]
+ std %f12, [%sp + (24 + 44) * 4]
+ std %f14, [%sp + (24 + 46) * 4]
+ std %f16, [%sp + (24 + 48) * 4]
+ std %f18, [%sp + (24 + 50) * 4]
+ std %f20, [%sp + (24 + 52) * 4]
+ std %f22, [%sp + (24 + 54) * 4]
+ std %f24, [%sp + (24 + 56) * 4]
+ std %f26, [%sp + (24 + 58) * 4]
+ std %f28, [%sp + (24 + 60) * 4]
+ std %f30, [%sp + (24 + 62) * 4]
+no_fpstore:
+
+! call _get_in_break_mode
+! nop
+
+ lda [%g0](ASI_MMCR), %l4
+ st %l4, [%sp + (24 + 72) * 4]
+! Disable mmu
+! andn %l4, 1, %l4
+! sta %l4, [%g0](ASI_MMCR)
+ st %l6, [%sp + (24 + 73) * 4]
+ st %l7, [%sp + (24 + 74) * 4]
+ lda [%g0](ASI_PDBA), %l4
+ st %l4, [%sp + (24 + 75) * 4]
+ lda [%g0](ASI_FPAR), %l4
+ st %l4, [%sp + (24 + 76) * 4]
+ lda [%g0](ASI_FTOR), %l4
+ st %l4, [%sp + (24 + 77) * 4]
+ lduha [%g0](ASI_FES), %l4
+ st %l4, [%sp + (24 + 78) * 4]
+ lda [%g0](ASI_FTSR), %l4
+ st %l4, [%sp + (24 + 79) * 4]
+
+ call _handle_exception
+ add %sp, 24 * 4, %o0 ! Pass address of registers
+
+! Reload all of the registers that are not on the stack
+
+ ld [%sp + (24 + 1) * 4], %g1 ! registers[Gx]
+ ldd [%sp + (24 + 2) * 4], %g2
+ ldd [%sp + (24 + 4) * 4], %g4
+ ldd [%sp + (24 + 6) * 4], %g6
+
+ ldd [%sp + (24 + 8) * 4], %i0 ! registers[Ox]
+ ldd [%sp + (24 + 10) * 4], %i2
+ ldd [%sp + (24 + 12) * 4], %i4
+ ldd [%sp + (24 + 14) * 4], %i6
+
+! set 0xff00, %l2
+! ldd [%sp + (24 + 72) * 4], %l4
+! stda %l4, [%l2]0x1 ! DIA1, debug instr addr 1
+ ! DIA2, debug instr addr 2
+! inc 8, %l2
+! ldd [%sp + (24 + 74) * 4], %l4
+! stda %l4, [%l2]0x1 ! DDA1, debug data addr 1
+ ! DDA2, debug data addr 2
+! inc 8, %l2
+! ldd [%sp + (24 + 76) * 4], %l4
+! stda %l4, [%l2]0x1 ! DDV1, debug data value 1
+ ! DDV2, debug data val 2
+! inc 8, %l2
+! ldd [%sp + (24 + 78) * 4], %l4
+! bset 0x200, %l4
+! stda %l4, [%l2]0x1 ! DCR, debug control reg
+ ! DSR, debug control reg
+
+
+ ldd [%sp + (24 + 64) * 4], %l0 ! Y & PSR
+ ldd [%sp + (24 + 68) * 4], %l2 ! PC & NPC
+
+ set 0x1000, %l5
+ btst %l5, %l1 ! FP enabled?
+ be no_fpreload
+ nop
+
+ ldd [%sp + (24 + 32) * 4], %f0
+ ldd [%sp + (24 + 34) * 4], %f2
+ ldd [%sp + (24 + 36) * 4], %f4
+ ldd [%sp + (24 + 38) * 4], %f6
+ ldd [%sp + (24 + 40) * 4], %f8
+ ldd [%sp + (24 + 42) * 4], %f10
+ ldd [%sp + (24 + 44) * 4], %f12
+ ldd [%sp + (24 + 46) * 4], %f14
+ ldd [%sp + (24 + 48) * 4], %f16
+ ldd [%sp + (24 + 50) * 4], %f18
+ ldd [%sp + (24 + 52) * 4], %f20
+ ldd [%sp + (24 + 54) * 4], %f22
+ ldd [%sp + (24 + 56) * 4], %f24
+ ldd [%sp + (24 + 58) * 4], %f26
+ ldd [%sp + (24 + 60) * 4], %f28
+ ldd [%sp + (24 + 62) * 4], %f30
+
+ ld [%sp + (24 + 70) * 4], %fsr
+no_fpreload:
+
+ restore ! Ensure that previous window is valid
+ save %g0, %g0, %g0 ! by causing a window_underflow trap
+
+
+ mov %l1, %psr ! Make sure that traps are disabled
+ ! for rett
+ mov %l0, %y
+ nop
+
+ sethi %hi(in_trap_handler), %l4
+ ld [%lo(in_trap_handler) + %l4], %l5
+ dec %l5
+ st %l5, [%lo(in_trap_handler) + %l4]
+
+ jmpl %l2, %g0 ! Restore old PC
+ rett %l3 ! Restore old nPC
+
+ .text
+ .align 4
+
+! Register window overflow handler. Come here when save would move us
+! into the invalid window. This routine runs with traps disabled, and
+! must be careful not to touch the condition codes, as PSR is never
+! restored.
+!
+! We are called with %l0 = wim, %l1 = pc, %l2 = npc
+win_ovf:
+ save %g0, %g0, %g0
+ std %l0, [%sp + (0*8)]
+ rd %psr, %l0
+ mov 1, %l1
+ sll %l1, %l0, %l0
+ wr %l0, 0, %wim
+ std %l2, [%sp + (1*8)]
+ std %l4, [%sp + (2*8)]
+ std %l6, [%sp + (3*8)]
+ std %i0, [%sp + (4*8)]
+ std %i2, [%sp + (5*8)]
+ std %i4, [%sp + (6*8)]
+ std %i6, [%sp + (7*8)]
+ restore
+ jmpl %l1, %g0
+ rett %l2
+
+! Register window underflow handler. Come here when restore would move us
+! into the invalid window. This routine runs with traps disabled, and
+! must be careful not to touch the condition codes, as PSR is never
+! restored.
+!
+! We are called with %l0 = wim, %l1 = pc, %l2 = npc
+win_unf:
+ sll %l0, 1, %l3 ! Rotate wim left
+ srl %l0, __WINSIZE-1, %l0
+ or %l0, %l3, %l0
+
+ mov %l0, %wim ! Install the new wim
+
+ restore ! User window
+ restore ! His caller window
+
+ ldd [%sp + 0 * 4], %l0 ! restore L & I registers
+ ldd [%sp + 2 * 4], %l2
+ ldd [%sp + 4 * 4], %l4
+ ldd [%sp + 6 * 4], %l6
+
+ ldd [%sp + 8 * 4], %i0
+ ldd [%sp + 10 * 4], %i2
+ ldd [%sp + 12 * 4], %i4
+ ldd [%sp + 14 * 4], %i6
+
+ save %g0, %g0, %g0 ! Back to trap window
+ save %g0, %g0, %g0
+
+ jmpl %l1, %g0
+ rett %l2
+
+ .globl chk_data_tlbmiss
+chk_data_tlbmiss:
+ ! Save PSR.
+ rd %psr, %l0
+
+ ! Read fault cause register.
+ lda [ %g0 ] (0x81), %l7
+
+ ! If nofault is null, go to bad_except.
+ sethi %hi(_nofault), %l6
+ ld [%l6 + %lo(_nofault)], %l5
+ cmp %l5, %g0
+ be 1f
+ st %g0, [%l6 + %lo(_nofault)]
+
+ ! Test if this is a tlb miss exception.
+ btst 128, %l7
+ bne,a have_data_tlbmiss
+ lda [ %g0 ] (0x83), %l3
+1: rd %wim, %l0
+ b interrupt
+ mov 9, %l3
+
+have_data_tlbmiss:
+ ! This is a tlb miss exception.
+ ! %l3 now contains the page directory base register.
+ ! Test if bit 2 is set.
+ btst 2, %l3
+ bne clean_data_tlbmiss
+
+ ! Read the fault virtual address.
+ lda [ %g0 ] (0x82), %l4
+
+ ! Read the corresponding pde.
+ srl %l4, 23, %l5
+ sll %l5, 3, %l5
+ ldd [ %l3 + %l5 ], %l6
+
+ ! Store the pte into the cache.
+ sta %l7, [ %l6 ] (0xaa)
+
+ ! Read the pte corresponding to the virtual address.
+ ! And store it into the cache.
+ srl %l4, 11, %l5
+ and %l5, 0xffc, %l5
+ ld [ %l6 + %l5 ], %l7
+ andn %l4, 3, %l4
+ sta %l7, [ %l4 ] (0xaa)
+
+ ! Return.
+ wr %l0, %g0, %psr
+ jmp %l1
+ rett %l2
+ nop
+clean_data_tlbmiss:
+ andn %l3, 2, %l3
+ srl %l4, 23, %l5
+ sll %l5, 3, %l5
+ ldd [ %l3 + %l5 ], %l6
+ sta %l7, [ %l6 ] (0xaa)
+ srl %l4, 11, %l5
+ and %l5, 0xffc, %l5
+ ld [ %l6 + %l5 ], %l7
+ andn %l4, 3, %l4
+ sta %l7, [ %l4 ] (0xaa)
+ mov 1, %l5
+ and %l0, 31, %l6
+ sll %l5, %l6, %l5
+ rd %wim, %l3
+ btst %l5, %l3
+ be data_must_clean
+ wr %l0, %g0, %psr
+ jmp %l1
+ rett %l2
+ nop
+data_must_clean:
+ mov %l1, %sp
+ mov %l2, %o7
+ mov %g0, %l0
+ mov %g0, %l1
+ mov %g0, %l2
+ mov %g0, %l3
+ mov %g0, %l4
+ mov %g0, %l5
+ mov %g0, %l6
+ mov %g0, %l7
+ jmp %sp
+ rett %o7
+ nop
+
+nmi:
+ set 400000, %l6
+nmi2:
+ lda [%g0](ASI_BID), %l7
+ deccc %l6
+ be nmi3
+ btst BID_NMI, %l7
+ bne nmi2
+ nop
+ b nmi
+ nop
+nmi3:
+ set (LED_t << 8) | LED_1, %l0
+ stha %l0, [%g0](ASI_LED)
+
+ .globl _rom_reset
+_rom_reset:
+ /*
+ * like Startup. */
+
+ ! Disable the mmu.
+ lda [%g0] (ASI_MMCR), %o1
+ andn %o1, MMCR_ME, %o1
+ sta %o1, [%g0] (ASI_MMCR)
+
+ ! Invalidate FTLB & GTLB.
+ sta %g0, [%g0] (ASI_FGTLB_INV) ! 0x87
+
+ ! Read the fault virtual address reg.
+ lda [%g0] (ASI_FVAR), %g0
+
+ ! Read the fault physical address reg.
+ lda [%g0] (ASI_FPAR), %g0
+
+ ! Read the fault time out reg.
+ lda [%g0] (ASI_FTOR), %g0
+
+ rd %psr, %g3 ! paranoia: make sure ...
+ andn %g3, PSR_ET, %g3 ! we have traps off
+ wr %g3, 0, %psr ! so that we can fiddle safely
+ nop; nop; nop
+
+ wr %g0, 0, %wim ! make sure we can set psr
+ nop; nop; nop
+ wr %g0, PSR_S|PSR_PS|PSR_PIL, %psr ! set initial psr
+ nop; nop; nop
+
+ wr %g0, 2, %wim ! set initial %wim (w1 invalid)
+
+! set USRSTACK - CCFSZ, %fp ! as if called from user code
+! set estack0 - CCFSZ - 80, %sp ! via syscall(boot_me_up) or somesuch
+ rd %psr, %l0
+ wr %l0, PSR_ET, %psr
+ nop; nop; nop
+
+1: call __exit
+ nop
+ b 1b
+ nop
+
+! Reset entry point
+real_start:
+ ! Disp on the led (=0)
+ sethi %hi(0xb6c0), %l1
+ or %l1, %lo(0xB6c0), %l1
+ stha %l1, [%g0](0xc1)
+
+ ! Save the return point
+ sethi %hi(_debug_ret), %l1
+ st %o7, [%l1 + %lo(_debug_ret)]
+
+ ! Just change the new TBR.
+ mov %tbr, %l0
+ sethi %hi(_debug_tbr), %l1
+ st %l0, [%l1 + %lo(_debug_tbr)]
+ sethi %hi(start), %l1
+ wr %l1, %lo(start), %tbr
+ nop
+ nop
+ nop
+
+ ! Misc info
+! mov %sp, %o0
+ ld [%sp + 0x5c], %o0
+ ld [%sp + 0x60], %o1
+ ld [%sp + 0x64], %o2
+
+ ! Call main
+ call _main
+ nop
+
+ ! Exit
+ call __exit
+ nop
+ ret
+
+ .globl _set_ipl
+_set_ipl:
+ rd %psr, %o1
+ andn %o1, 0xf00, %o1
+ and %o0, 0x0f, %o0
+ sll %o0, 8, %o0
+ wr %o0, %o1, %psr
+ nop
+ nop
+ nop
+ retl
+ nop
diff --git a/sys/arch/kbus/stand/sk/dev_disk.c b/sys/arch/kbus/stand/sk/dev_disk.c
new file mode 100644
index 00000000000..228d710c50d
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/dev_disk.c
@@ -0,0 +1,132 @@
+/* $Id: dev_disk.c,v 1.1 1997/10/14 07:25:31 gingold Exp $ */
+
+/*
+ * Copyright (c) 1993 Paul Kranenburg
+ * 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 Paul Kranenburg.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+/*
+ * This module implements a "raw device" interface suitable for
+ * use by the stand-alone I/O library UFS file-system code, and
+ * possibly for direct access (i.e. boot from tape).
+ *
+ * The implementation is deceptively simple because it uses the
+ * drivers provided by the Sun PROM monitor. Note that only the
+ * PROM driver used to load the boot program is available here.
+ */
+
+#include <sys/types.h>
+#include <machine/mon.h>
+#include <machine/saio.h>
+
+#include "stand.h"
+
+#include "dvma.h"
+#include "promdev.h"
+
+int
+disk_open(f, devname)
+ struct open_file *f;
+ char *devname; /* Device part of file name (or NULL). */
+{
+ struct saioreq *sip;
+ int error;
+
+#ifdef DEBUG_PROM
+ printf("disk_open: %s\n", devname);
+#endif
+
+ if ((error = prom_iopen(&sip)) != 0)
+ return (error);
+
+ f->f_devdata = sip;
+ return 0;
+}
+
+int
+disk_close(f)
+ struct open_file *f;
+{
+ struct saioreq *sip;
+
+ sip = f->f_devdata;
+ prom_iclose(sip);
+ f->f_devdata = NULL;
+ return 0;
+}
+
+int
+disk_strategy(devdata, flag, dblk, size, buf, rsize)
+ void *devdata;
+ int flag;
+ daddr_t dblk;
+ u_int size;
+ char *buf;
+ u_int *rsize;
+{
+ struct saioreq *si;
+ struct boottab *ops;
+ char *dmabuf;
+ int si_flag, xcnt;
+
+ si = devdata;
+ ops = si->si_boottab;
+
+#ifdef DEBUG_PROM
+ printf("disk_strategy: size=%d dblk=%d\n", size, dblk);
+#else
+ twiddle();
+#endif
+
+ dmabuf = dvma_mapin(buf, size);
+
+ si->si_bn = dblk;
+ si->si_ma = dmabuf;
+ si->si_cc = size;
+
+ si_flag = (flag == F_READ) ? SAIO_F_READ : SAIO_F_WRITE;
+ xcnt = (*ops->b_strategy)(si, si_flag);
+ dvma_mapout(dmabuf, size);
+
+#ifdef DEBUG_PROM
+ printf("disk_strategy: xcnt = %x\n", xcnt);
+#endif
+
+ if (xcnt <= 0)
+ return (EIO);
+
+ *rsize = xcnt;
+ return (0);
+}
+
+int
+disk_ioctl()
+{
+ return EIO;
+}
+
diff --git a/sys/arch/kbus/stand/sk/dev_disk.h b/sys/arch/kbus/stand/sk/dev_disk.h
new file mode 100644
index 00000000000..9f05f74bd82
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/dev_disk.h
@@ -0,0 +1,6 @@
+
+int disk_open __P((struct open_file *, ...));
+int disk_close __P((struct open_file *));
+int disk_strategy __P((void *, int, daddr_t, u_int, char *, u_int *));
+int disk_ioctl();
+
diff --git a/sys/arch/kbus/stand/sk/dev_net.c b/sys/arch/kbus/stand/sk/dev_net.c
new file mode 100644
index 00000000000..bffda185afa
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/dev_net.c
@@ -0,0 +1,231 @@
+/* $Id: dev_net.c,v 1.1 1997/10/14 07:25:31 gingold Exp $ */
+
+/*
+ * Copyright (c) 1995 Gordon W. Ross
+ * 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. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ * 4. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Gordon W. Ross
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+/*
+ * This module implements a "raw device" interface suitable for
+ * use by the stand-alone I/O library NFS code. This interface
+ * does not support any "block" access, and exists only for the
+ * purpose of initializing the network interface, getting boot
+ * parameters, and performing the NFS mount.
+ *
+ * At open time, this does:
+ *
+ * find interface - netif_open()
+ * RARP for IP address - rarp_getipaddress()
+ * RPC/bootparams - callrpc(d, RPC_BOOTPARAMS, ...)
+ * RPC/mountd - nfs_mount(sock, ip, path)
+ *
+ * the root file handle from mountd is saved in a global
+ * for use by the NFS open code (NFS/lookup).
+ */
+
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#include <netinet/in_systm.h>
+
+#include "stand.h"
+#include "net.h"
+#include "netif.h"
+#include "config.h"
+#include "bootparam.h"
+
+extern int nfs_root_node[]; /* XXX - get from nfs_mount() */
+
+struct in_addr myip, rootip, gateip, mask;
+char rootpath[FNAME_SIZE];
+
+int netdev_sock = -1;
+static int open_count;
+
+extern char *getenv (const char *);
+
+/*
+ * Called by devopen after it sets f->f_dev to our devsw entry.
+ * This opens the low-level device and sets f->f_devdata.
+ */
+int
+net_open(f, devname)
+ struct open_file *f;
+ char *devname; /* Device part of file name (or NULL). */
+{
+ int error = 0;
+
+ /* On first open, do netif open, mount, etc. */
+ if (open_count == 0) {
+ /* Find network interface. */
+ if ((netdev_sock = netif_open(devname)) < 0)
+ return (error=ENXIO);
+ if ((error = net_mountroot(f, devname)) != 0)
+ return (error);
+ }
+ open_count++;
+ f->f_devdata = nfs_root_node;
+ return (error);
+}
+
+int
+net_close(f)
+ struct open_file *f;
+{
+ /* On last close, do netif close, etc. */
+ if (open_count > 0)
+ if (--open_count == 0)
+ netif_close(netdev_sock);
+ f->f_devdata = NULL;
+}
+
+int
+net_ioctl()
+{
+ return EIO;
+}
+
+int
+net_strategy()
+{
+ return EIO;
+}
+
+int
+net_mountroot(f, devname)
+ struct open_file *f;
+ char *devname; /* Device part of file name (or NULL). */
+{
+ int error;
+
+#ifdef DEBUG
+ printf("net_mountroot: %s\n", devname);
+#endif
+
+ /*
+ * Get info for NFS boot: our IP address, our hostname,
+ * server IP address, and our root path on the server.
+ * There are two ways to do this: The old, Sun way,
+ * and the more modern, BOOTP way. (RFC951, RFC1048)
+ */
+
+#ifdef SUN_BOOTPARAMS
+ /* Get boot info using RARP and Sun bootparams. */
+
+ /* Get our IP address. (rarp.c) */
+ if (rarp_getipaddress(netdev_sock) == -1)
+ return (EIO);
+ printf("boot: client IP address: %s\n", intoa(myip.s_addr));
+
+ /* Get our hostname, server IP address. */
+ if (bp_whoami(netdev_sock))
+ return (EIO);
+ printf("boot: client name: %s\n", hostname);
+
+ /* Get the root pathname. */
+ if (bp_getfile(netdev_sock, "root", &rootip, rootpath))
+ return (EIO);
+
+#else
+
+ /* Get boot info using BOOTP way. (RFC951, RFC1048) */
+ bootp(netdev_sock);
+
+ printf("Using IP address: %s\n", intoa(myip.s_addr));
+
+ printf("myip: %s (%s)", hostname, intoa(myip));
+ if (gateip)
+ printf(", gateip: %s", intoa(gateip));
+ if (mask)
+ printf(", mask: %s", intoa(mask));
+ printf("\n");
+
+#endif
+
+ printf("root addr=%s path=%s\n", intoa(rootip.s_addr), rootpath);
+
+ /* Get the NFS file handle (mount). */
+ error = nfs_mount(netdev_sock, rootip, rootpath);
+
+ return (error);
+}
+
+/*
+ * machdep_common_ether: get ethernet address
+ */
+void
+machdep_common_ether(ether)
+ u_char *ether;
+{
+ char *ea = getenv ("ENETADDR");
+ u_char c;
+ int i;
+
+ if (ea == NULL)
+ panic ("ERROR: ethernet address not set!\n");
+ else
+ printf ("Try to parse %s\n", ea);
+
+ for (i = 0; i < 6; i++)
+ {
+ if (*ea >= '0' && *ea <= '9')
+ c = *ea - '0';
+ else if (*ea >= 'a' && *ea <= 'f')
+ c = *ea - 'a' + 10;
+ else if (*ea >= 'A' && *ea <= 'F')
+ c = *ea - 'A' + 10;
+ else
+ panic ("Bad character for enet addr (%s)\n", ea);
+ ea++;
+ if (i == 5 && *ea == 0)
+ break;
+ if (i < 5 && *ea == ':')
+ {
+ *ether++ = c;
+ ea++;
+ continue;
+ }
+ c <<= 4;
+ if (*ea >= '0' && *ea <= '9')
+ c |= *ea - '0';
+ else if (*ea >= 'a' && *ea <= 'f')
+ c |= *ea - 'a' + 10;
+ else if (*ea >= 'A' && *ea <= 'F')
+ c |= *ea - 'A' + 10;
+ else
+ panic ("Bad character for enet addr (%s)\n", ea);
+ ea++;
+ if (i != 5 && *ea != ':')
+ panic ("Bad character for enet addr (%s)\n", ea);
+ ea++;
+ *ether++ = c;
+ }
+
+}
diff --git a/sys/arch/kbus/stand/sk/dev_net.h b/sys/arch/kbus/stand/sk/dev_net.h
new file mode 100644
index 00000000000..093ba193bfd
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/dev_net.h
@@ -0,0 +1,6 @@
+
+int net_open __P((struct open_file *, ...));
+int net_close __P((struct open_file *));
+int net_ioctl();
+int net_strategy();
+
diff --git a/sys/arch/kbus/stand/sk/devopen.c b/sys/arch/kbus/stand/sk/devopen.c
new file mode 100644
index 00000000000..92c083983cb
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/devopen.c
@@ -0,0 +1,32 @@
+
+#include <sys/param.h>
+#include <stand.h>
+#include "promboot.h"
+
+/*
+ * Open the device named by the combined device/file name
+ * given as the "fname" arg, something like: "sd()bsd"
+ *
+ * However, Sun PROMs don't really let you choose which
+ * device you will talk to. You can only open the device
+ * that was used to load the boot program. Therefore, we
+ * do not accept a "device" part in the "fname" string.
+ * Pass the PROM device name to open in case it needs it.
+ */
+int
+devopen(f, fname, file)
+ struct open_file *f;
+ const char *fname;
+ char **file;
+{
+ struct devsw *dp;
+ char *cp, *path, *devname;
+ int error;
+
+ *file = (char*)fname;
+ dp = &devsw[0];
+ f->f_dev = dp;
+ error = (*dp->dv_open)(f, prom_bootdev);
+
+ return (error);
+}
diff --git a/sys/arch/kbus/stand/sk/disp-asi.c b/sys/arch/kbus/stand/sk/disp-asi.c
new file mode 100644
index 00000000000..7510644f842
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/disp-asi.c
@@ -0,0 +1,644 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <kbus/mmu.h>
+#include <kbus/pte.h>
+#include <kbus/kbus.h>
+#include <kbus/led.h>
+#include "sparc-asm.h"
+#include "idprom.h"
+#include "eeprom.h"
+#include "prom.h"
+
+#define NOFAULT_CONTINUE 0x01
+#define NOFAULT_QUIET 0x02
+
+extern char edata, end;
+extern daddr_t debug_tbr, debug_ret;
+extern int nofault;
+extern char exception_table;
+
+void
+set_led (char val)
+{
+ static const xtab[] =
+ {
+ LED_0, LED_1, LED_2, LED_3,
+ LED_4, LED_5, LED_6, LED_7,
+ LED_8, LED_9, LED_A, LED_b,
+ LED_C, LED_d, LED_E, LED_F
+ };
+ write_asi_half (ASI_LED, 0, (LED_U << 8) | xtab[val & 0x0f]);
+}
+
+void
+set_debug (void)
+{
+ char *old_tbr = (char *)(debug_tbr & 0xfffff000UL);
+ char *new_tbr = &exception_table;
+
+#define COPY_VECTOR(n) memcpy (new_tbr + n * 16, old_tbr + n * 16, 16)
+ COPY_VECTOR (0x1f);
+ COPY_VECTOR (0xf0);
+}
+
+void
+disp (int n)
+{
+ if (n > 0)
+ disp (n - 1);
+ printf ("In disp %d\n", n);
+}
+
+void
+dump_dg (void)
+{
+ int i, j;
+ unsigned char buf[16];
+
+ for (i = 0; i < 2048; i += 16)
+ {
+ printf ("%03x: ", i);
+ for (j = 0; j < 16; j++)
+ {
+ buf[j] = read_asi_byte (ASI_DIAG_RAM, (i + j) << 2);
+ printf ("%02x ", buf[j]);
+ }
+ for (j = 0; j < 16; j++)
+ if (buf[j] >= 32 && buf[j] <= 127)
+ putchar (buf[j]);
+ else
+ putchar ('.');
+ putchar ('\n');
+ }
+}
+
+
+void
+uninitialize_dg (void)
+{
+ unsigned int val;
+
+ write_asi_byte (ASI_DIAG_RAM, 16 << 2, 0);
+ val = read_asi (ASI_MMCR, 0);
+ /* As a cold start and enable watch-dog. */
+ val |= MMCR_CS /* | MMCR_WDEN */ ;
+ write_asi (ASI_MMCR, 0, val);
+}
+
+void
+initialize_dg (void)
+{
+ unsigned int val;
+
+ write_asi_byte (ASI_DIAG_RAM, 16 << 2, 'G');
+ val = read_asi (ASI_MMCR, 0);
+ val &= ~MMCR_CS;
+ write_asi (ASI_MMCR, 0, val);
+}
+
+void
+udelay (unsigned long usec)
+{
+ register int i;
+
+ while (usec--)
+ for (i = 20; i; i--)
+ ;
+}
+
+void
+play_with_led (void)
+{
+ int i, j;
+
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 16; j++)
+ {
+ set_led (j);
+ ta (j);
+ udelay (100000);
+ }
+}
+
+void
+disp_pte (unsigned long pte)
+{
+ printf ("%08x ", pte);
+ if (pte & PG_IO)
+ printf ("io ");
+ if (pte & PG_V)
+ printf ("v ");
+}
+
+void
+dump_pde (unsigned long *pdba)
+{
+ int i,j;
+ unsigned long pte;
+ unsigned long *ptp;
+ unsigned long pt;
+ unsigned long *optp;
+
+ for (i = 0; i < NPDEPERPDT; i++)
+ {
+ printf ("(%03x) 0x%08x 0x%08x ", i, pdba[i * 2], pdba[i * 2 + 1]);
+ if (i & 1)
+ printf ("\n");
+ }
+
+#if 1
+ optp = 0;
+ for (i = 0; i < NPDEPERPDT; i++)
+ {
+ ptp = (unsigned long *)pdba[2 * i];
+ printf ("PT # %02x at 0x%08x\n", i, (unsigned long) ptp);
+ if (ptp == optp)
+ continue;
+ if (((unsigned long) ptp & 0xff000000) != 0xff000000)
+ continue;
+ optp = ptp;
+ for (j = 0; j < NPTEPERPT; j++)
+ if (ptp[j] != 0)
+ goto not_null;
+ printf ("--- all entries are null\n");
+ continue;
+ not_null:
+ for (j = 0; j < NPTEPERPT; j++)
+ {
+ printf ("%04x: ", j);
+ disp_pte (ptp[j]);
+ printf ("\n");
+ }
+ printf ("\n");
+ }
+#endif
+}
+
+void
+dump_dtlb (void)
+{
+ unsigned long i;
+ unsigned long pte;
+
+ for (i = 0xff000000UL; i != 0xff100000; i += 0x00002000)
+ {
+ pte = read_asi (ASI_GTLB_RDD, i);
+ printf ("dtlb for 0x%08x: ", i);
+ disp_pte (pte);
+ printf ("\n");
+ }
+}
+
+void
+dump_itlb (void)
+{
+ unsigned long i;
+ unsigned long pte;
+
+ for (i = 0xfe000000UL; i != 0; i += 0x00001000)
+ {
+ pte = read_asi (ASI_GTLB_RDI, i);
+ printf ("itlb for 0x%08x: ", i);
+ disp_pte (pte);
+ printf ("\n");
+ }
+}
+
+#define MASK 0xffffe000
+void
+disp_dmap (void)
+{
+ unsigned long i;
+ unsigned long map;
+ unsigned long pte;
+
+ map = 0;
+ for (i = 0x00002000UL; i != 0; i += 0x00002000)
+ {
+ pte = read_asi (ASI_GTLB_RDD, i);
+ if ((pte & MASK) == map + i)
+ continue;
+ printf (" - 0x%08x\n", i);
+ map = (pte & MASK) - i;
+ printf ("Mapped at 0x%08x : 0x%08x", pte, i);
+ }
+}
+
+void
+try_dtlb (void)
+{
+ unsigned long addr = 0xffe00000;
+ unsigned long val;
+ unsigned long nval[16];
+ int i;
+
+ val = read_asi (ASI_GTLB_RDD, addr);
+ printf ("DTLB: addr = 0x%08x, val = 0x%08x\n", addr, val);
+ i = *(int *)addr;
+ printf ("i = %d...", i);
+ write_asi (ASI_GTLB_VALD, addr, 0);
+ i = *(int *)addr;
+ printf ("i = %d\n", i);
+ for (i = 1; i < 16; i++)
+ nval[i] = read_asi (ASI_GTLB_RDD, addr + i * 0x1000);
+ nval[0] = read_asi (ASI_GTLB_RDD, addr);
+ write_asi (ASI_GTLB_VALD, addr, val);
+ for (i = 0; i < 16; i++)
+ printf ("DTLB: addr = 0x%08x, nval[%d] = 0x%08x, val = 0x%08x\n",
+ addr, i, nval[i], read_asi (ASI_GTLB_RDD, addr + i * 0x1000));
+}
+
+void
+dump_page (int pg)
+{
+ int i;
+ unsigned long *addr = (unsigned long *)0xff000000;
+
+ for (i = 0; i < 2048; i++)
+ {
+ printf ("0x%04x: 0x%08x ", i, addr[i]);
+ if ((i & 3) == 3)
+ printf ("\n");
+ }
+}
+
+int
+disp_prom_string (unsigned char *ptr, int maxlen)
+{
+ int i;
+ char c;
+
+ for (i = 0; i < maxlen; i++)
+ {
+ c = ptr[i * ID_BYTE_OFFSET];
+ if (c == 0)
+ return i + 1;
+ putchar (c);
+ }
+ return maxlen;
+}
+
+void
+probe_kbus (void)
+{
+ unsigned char *pa;
+ unsigned char *va;
+ unsigned char *p;
+ unsigned char c;
+ unsigned char id;
+ unsigned int offset;
+ unsigned int size;
+ unsigned int nbr_bytes_read;
+ int i, j;
+
+ for (i = 1; i < 8; i++)
+ {
+ printf ("Slot %d: ", i);
+ fflush (stdout);
+ pa = (char *)MK_IOADDR (SPACE_ID, i, 0);
+ va = (unsigned char *) alloc_page ((daddr_t) pa, PG_IO | PG_V);
+ again:
+ nofault = NOFAULT_QUIET | NOFAULT_CONTINUE;
+ id = va[0];
+ if (nofault == 0)
+ {
+ printf ("-\n");
+ continue;
+ }
+ printf ("id: 0x%02x -%c-", id, id & ID_MASK);
+#if 0
+ for (j = 1; j < 8; j++)
+ {
+ nofault = NOFAULT_QUIET | NOFAULT_CONTINUE;
+ c = va[j];
+ if (nofault != 0)
+ printf (", [%d] = 0x%02x", j, c);
+ }
+#endif
+
+ printf (" Minor: %d, rev: %c%c",
+ va[ID_OFF_MINOR], va[ID_OFF_REVLEV1], va[ID_OFF_REVLEV2]);
+ offset = ID_4BYTES_TO_LONG (va[ID_OFF_OFFSET1], va[ID_OFF_OFFSET2],
+ va[ID_OFF_OFFSET3], va[ID_OFF_OFFSET4]);
+ size = ID_4BYTES_TO_LONG (va[ID_OFF_SIZE1], va[ID_OFF_SIZE2],
+ va[ID_OFF_SIZE3], va[ID_OFF_SIZE4]);
+ printf (" offset: %ld, size: %ld", offset, size);
+ nbr_bytes_read = 13;
+ putchar (' ');
+ nbr_bytes_read += disp_prom_string (va + ID_OFF_STRING,
+ ID_MAX_STRING_SIZE);
+ p = va + nbr_bytes_read * ID_BYTE_OFFSET;
+ printf ("\n");
+ if (nbr_bytes_read == size)
+ printf ("All bytes read\n");
+ else
+ {
+ printf ("%d bytes to read\n", size - nbr_bytes_read);
+ switch (id & ID_MASK)
+ {
+ case ID_MEMORY_BOARD:
+ printf ("Size: %d Mb\n", *p);
+ break;
+ case ID_SYSTEM_BOARD + 1:
+ printf ("Hostid: %lx\n",
+ ID_4BYTES_TO_LONG (p[ID_S_OFF_HOSTID1],
+ p[ID_S_OFF_HOSTID2],
+ p[ID_S_OFF_HOSTID3],
+ p[ID_S_OFF_HOSTID4]));
+ printf ("Serial: ");
+ disp_prom_string (p + ID_S_OFF_SERIAL, ID_S_SERIAL_SIZE);
+ printf ("\nEnet addr: %x:%x:%x:%x:%x:%x\n",
+ p[ID_S_OFF_ENETADDR],
+ p[ID_S_OFF_ENETADDR + 1 * ID_BYTE_OFFSET],
+ p[ID_S_OFF_ENETADDR + 2 * ID_BYTE_OFFSET],
+ p[ID_S_OFF_ENETADDR + 3 * ID_BYTE_OFFSET],
+ p[ID_S_OFF_ENETADDR + 4 * ID_BYTE_OFFSET],
+ p[ID_S_OFF_ENETADDR + 5 * ID_BYTE_OFFSET]);
+ printf ("mfg date: ");
+ disp_prom_string (p + ID_S_OFF_MFGDATE, ID_S_MFGDATE_SIZE);
+ printf ("Oem flag: 0x%02x\n",
+ p[ID_S_OFF_OEM_FLAG]);
+ printf ("Banner: ");
+ disp_prom_string (p + ID_S_OFF_BANNER, ID_S_BANNER_SIZE);
+ printf ("\nCopyright: ");
+ disp_prom_string (p + ID_S_OFF_COPYRIGHT, ID_S_COPYRIGHT_SIZE);
+ printf ("\nLogo:\n");
+ for (j = 0; j < ID_S_LOGOBITMAP_SIZE; j++)
+ {
+ int k;
+ c = p[ID_S_OFF_LOGOBITMAP + j * ID_BYTE_OFFSET];
+ for (k = 0; k < 8; k++)
+ {
+ putchar ((c & 0x80) ? '*': ' ');
+ c <<= 1;
+ }
+ if ((j & 7) == 7)
+ putchar ('\n');
+ }
+ break;
+ case ID_GRAPHIC_BOARD:
+ {
+ int nbr_res = p[ID_G_OFF_RES_COUNT];
+ int k;
+
+ printf ("Type: %d, nbr of plane: %d, access size: %d, "
+ "nbr of resolutions: %d\n",
+ p[ID_G_OFF_TYPE], p[ID_G_OFF_NBR_PLANE],
+ p[ID_G_OFF_ACCESS_SIZE], nbr_res);
+ p += ID_G_OFF_FB_SIZES;
+ for (k = 0; k < nbr_res; k++)
+ {
+ printf ("Res %d: %dx%d, xoff: %d, "
+ "fb_size: 0x%08x, itbl: 0x%08x, font: 0x%08x\n",
+ k,
+ ID_2BYTES_TO_SHORT (p[ID_G_OFF_X_RES1],
+ p[ID_G_OFF_X_RES2]),
+ ID_2BYTES_TO_SHORT (p[ID_G_OFF_Y_RES1],
+ p[ID_G_OFF_Y_RES2]),
+ ID_2BYTES_TO_SHORT (p[ID_G_OFF_XOFFSET1],
+ p[ID_G_OFF_XOFFSET2]),
+ ID_4BYTES_TO_LONG (p[ID_G_OFF_FB_SIZE1],
+ p[ID_G_OFF_FB_SIZE2],
+ p[ID_G_OFF_FB_SIZE3],
+ p[ID_G_OFF_FB_SIZE4]),
+ ID_4BYTES_TO_LONG (p[ID_G_OFF_ITBL_OFF1],
+ p[ID_G_OFF_ITBL_OFF2],
+ p[ID_G_OFF_ITBL_OFF3],
+ p[ID_G_OFF_ITBL_OFF4]),
+ ID_4BYTES_TO_LONG (p[ID_G_OFF_FONT_OFF1],
+ p[ID_G_OFF_FONT_OFF2],
+ p[ID_G_OFF_FONT_OFF3],
+ p[ID_G_OFF_FONT_OFF4]));
+ p += ID_G_SIZE_FB_SIZES;
+ }
+ printf ("White value: 0x%08x, Black value: 0x%08x, "
+ "fb offset: 0x%08x, kb offset: 0x%08x\n",
+ ID_4BYTES_TO_LONG (p[ID_G_OFF_WHITE_OFF1],
+ p[ID_G_OFF_WHITE_OFF2],
+ p[ID_G_OFF_WHITE_OFF3],
+ p[ID_G_OFF_WHITE_OFF4]),
+ ID_4BYTES_TO_LONG (p[ID_G_OFF_BLACK_OFF1],
+ p[ID_G_OFF_BLACK_OFF2],
+ p[ID_G_OFF_BLACK_OFF3],
+ p[ID_G_OFF_BLACK_OFF4]),
+ ID_4BYTES_TO_LONG (p[ID_G_OFF_FB_OFF1],
+ p[ID_G_OFF_FB_OFF2],
+ p[ID_G_OFF_FB_OFF3],
+ p[ID_G_OFF_FB_OFF4]),
+ ID_4BYTES_TO_LONG (p[ID_G_OFF_KB_OFF1],
+ p[ID_G_OFF_KB_OFF2],
+ p[ID_G_OFF_KB_OFF3],
+ p[ID_G_OFF_KB_OFF4]));
+ }
+ break;
+ }
+ }
+ if (offset != 0)
+ {
+ printf ("Slot %d: ", i);
+ va += offset;
+ goto again;
+ }
+ }
+}
+
+void
+disp_eeprom (void)
+{
+ unsigned char *va;
+ unsigned char ch[16];
+ int i, j;
+
+ va = (unsigned char *) alloc_page ((daddr_t) 0x17002000, PG_IO | PG_V);
+
+ printf ("Model: ");
+ disp_prom_string (va + EEPROM_OFF_MODEL, EEPROM_SIZE_MODEL);
+ printf ("\n");
+ for (i = 0; i < EEPROM_SIZE; i += 16)
+ {
+ printf ("%03x: ", i);
+ for (j = 0; j < 16; j++)
+ {
+ ch[j] = va[(i + j) * EEPROM_BYTE_OFFSET];
+ printf ("%02x%c", ch[j], j == 7 ? '-' : ' ');
+ }
+ for (j = 0; j < 16; j++)
+ putchar ((ch[j] < 32 || ch[j] > 127) ? '.' : ch[j]);
+ putchar ('\n');
+ }
+}
+
+#define ROM_VECTORS 0xff000000
+void
+disp_prom (void)
+{
+ unsigned long *addr;
+ int i;
+ struct prom_command_area *ca;
+
+ printf ("version: %s\n", *(unsigned long *)ROM_VERSION);
+ printf ("DGRAM version: 0x%08x\n", *(unsigned long *)ROM_DGRAM);
+ printf ("EE version: 0x%08x\n", *(unsigned long *)ROM_EEVERSION);
+ printf ("ROM version: 0x%08x\n", *(unsigned long *)ROM_REVISION);
+ ca = *(struct prom_command_area **) ROM_COMM_AREA;
+ printf ("first_free: 0x%08x\n", ca->first_free);
+ printf ("memsize: %d Mb\n", ca->memsize);
+ printf ("ramdisk: 0x%08x\n", ca->ramdisk);
+ printf ("iomap_addr: 0x%08x\n", ca->iomap_addr);
+ printf ("row: %d, col: %d\n", ca->row, ca->col);
+ printf ("silent: %d\n", ca->silent);
+ addr = (unsigned long *)ca->iomap_addr;
+ for (i = 0; i < 10; i++)
+ printf ("%d: 0x%08x\n", i, addr[i]);
+
+}
+
+void
+start (int argc, char *argv[], char *envp[])
+{
+ int i;
+ char *addr;
+ char *pa;
+ unsigned char c;
+
+ set_led (0);
+ bzero (&edata, &end - &edata);
+ set_led (1);
+
+ printf ("Hello world\n\r");
+ fflush (stdout);
+
+ /* set_debug (); */
+ setvbuf (stdout, NULL, _IONBF, 0);
+
+ printf ("MMCR: 0x%08x\n", read_asi (ASI_MMCR, 0));
+ printf ("PDBA: 0x%08x\n", read_asi (ASI_PDBA, 0));
+ printf ("BID: 0x%08x\n", read_asi (ASI_BID, 0));
+
+ printf ("ret: 0x%08x\n", debug_ret);
+ printf ("tbr: old = 0x%08x, new = 0x%08x\n", debug_tbr, read_tbr ());
+
+ printf ("Args:");
+ for (i = 0; i < argc; i++)
+ printf (" %s", argv[i]);
+ putchar ('\n');
+ for (i = 0; envp[i]; i++)
+ printf ("%s\n", envp[i]);
+
+
+/* dump_dg (); */
+ uninitialize_dg ();
+
+#if 0
+ disp (10);
+ play_with_led ();
+#endif
+
+#if 0
+ set_led (0);
+ for (i = -1; i ; i--)
+ ;
+ set_led (1);
+#endif
+ disp_zs0_status ();
+ nofault = 1;
+ for (i = 0; i < 4; i++)
+ {
+ zs0_putc ('h');
+ zs0_putc ('e');
+ zs0_putc ('l');
+ }
+ zs0_putc ('\n');
+ zs0_putc ('\r');
+ if (nofault == 0)
+ printf ("Fault\n");
+
+ set_debug ();
+ fflush (stdout);
+
+ /* At first, initialize the mmu. */
+ init_mmu ();
+
+ /* Then, the serial line. */
+ init_zs0 ();
+
+ printf ("mmu Hello again\n");
+
+ try_mmu ();
+ /* Probe the hardware. */
+ probe_kbus ();
+ /* disp_eeprom (); */
+/* disp_prom (); */
+
+/* try_dtlb (); */
+/* dump_dtlb (); */
+
+ ta (127);
+ _exit ();
+#if 0
+ dump_pde ((unsigned long*) 0xff23a000);
+#endif
+#if 0
+ init_mmu ();
+ try_mmu ();
+#endif
+
+ ta (127);
+
+ initialize_dg ();
+ write (1, "end\n", 4);
+}
+
+#define NUMREGS 80
+
+/* Number of bytes of registers. */
+#define NUMREGBYTES (NUMREGS * 4)
+enum regnames
+{
+ G0, G1, G2, G3, G4, G5, G6, G7,
+ O0, O1, O2, O3, O4, O5, SP, O7,
+ L0, L1, L2, L3, L4, L5, L6, L7,
+ I0, I1, I2, I3, I4, I5, FP, I7,
+
+ F0, F1, F2, F3, F4, F5, F6, F7,
+ F8, F9, F10, F11, F12, F13, F14, F15,
+ F16, F17, F18, F19, F20, F21, F22, F23,
+ F24, F25, F26, F27, F28, F29, F30, F31,
+ Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR,
+ MMCR, FCR, FVAR, PDBA, FPAR, FTOR, FES, FTSR}; /* MMCR at 72. */
+
+
+void
+handle_exception (unsigned long *registers)
+{
+ int trap = (registers[TBR] >> 4) & 0xff;
+
+ if (trap == 15)
+ _exit ();
+
+ if (1 || trap != 9 || !(nofault & NOFAULT_QUIET))
+ {
+ printf ("Trap %d:\n"
+ "psr = 0x%08x, tbr = 0x%08x, pc = 0x%08x, npc = 0x%08x\n",
+ trap,
+ registers[PSR], registers[TBR], registers[PC], registers[NPC]);
+ printf ("sp = %08x, fp = %08x\n",
+ registers[SP], registers[FP]);
+ printf ("MMCR = %08x, FCR = %08x, FVAR = %08x, PDBA = %08x\n",
+ registers[MMCR], registers[FCR],
+ registers[FVAR], registers[PDBA]);
+ printf ("FPAR = %08x, FTOR = %08x, FES = %08x, FTSR = %08x\n",
+ registers[FPAR], registers[FTOR],
+ registers[FES], registers[FTSR]);
+ }
+
+ if (trap == 9 && (nofault & NOFAULT_CONTINUE))
+ {
+ nofault = 0;
+ registers[PC] = registers[NPC];
+ registers[NPC] += 4;
+ }
+ else
+ _exit ();
+}
+
diff --git a/sys/arch/kbus/stand/sk/dvma.c b/sys/arch/kbus/stand/sk/dvma.c
new file mode 100644
index 00000000000..11526106c2a
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/dvma.c
@@ -0,0 +1,68 @@
+
+/*
+ * The easiest way to deal with the need for DVMA mappings is
+ * to just map the first four megabytes of RAM into DVMA space.
+ * That way, dvma_mapin can just compute the DVMA alias address,
+ * and dvma_mapout does nothing.
+ */
+
+#include <sys/param.h>
+
+#define DVMA_BASE 0x00000000
+#define DVMA_MASK 0x00ffFFff
+#define DVMA_MAPLEN 0x400000 /* 4 MB */
+
+void
+dvma_init()
+{
+#if 0
+ int segva, sme;
+
+ for (segva = 0; segva < DVMA_MAPLEN; segva += NBSG) {
+ sme = get_segmap(segva);
+ set_segmap((DVMA_BASE | segva), sme);
+ }
+#endif
+}
+
+/* Convert a local address to a DVMA address. */
+char *
+dvma_mapin(char *addr, int len)
+{
+ int va = (int)addr;
+
+ va |= DVMA_BASE;
+ return ((char *) va);
+}
+
+/* Convert a DVMA address to a local address. */
+char *
+dvma_mapout(char *dmabuf, int len)
+{
+ if (dmabuf < (char*)DVMA_BASE)
+ panic("dvma_mapout");
+ return (dmabuf - DVMA_BASE);
+}
+
+extern char *alloc(int len);
+char *
+dvma_alloc(int len)
+{
+ char *mem;
+
+ mem = alloc(len);
+ if (!mem)
+ return(mem);
+ return(dvma_mapin(mem, len));
+}
+
+extern void free(void *ptr, int len);
+void
+dvma_free(char *dvma, int len)
+{
+ char *mem;
+
+ mem = dvma_mapout(dvma, len);
+ if (mem)
+ free(mem, len);
+}
diff --git a/sys/arch/kbus/stand/sk/dvma.h b/sys/arch/kbus/stand/sk/dvma.h
new file mode 100644
index 00000000000..2b8be37cbe0
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/dvma.h
@@ -0,0 +1,6 @@
+
+char * dvma_mapin(char *pkt, int len);
+void dvma_mapout(char *dmabuf, int len);
+
+char * dvma_alloc(int len);
+
diff --git a/sys/arch/kbus/stand/sk/eeprom.h b/sys/arch/kbus/stand/sk/eeprom.h
new file mode 100644
index 00000000000..97e028e41e6
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/eeprom.h
@@ -0,0 +1,6 @@
+#define EEPROM_BYTE_OFFSET 8
+
+#define EEPROM_SIZE 0x400
+
+#define EEPROM_OFF_MODEL 0x08
+#define EEPROM_SIZE_MODEL 16
diff --git a/sys/arch/kbus/stand/sk/exec_sun.c b/sys/arch/kbus/stand/sk/exec_sun.c
new file mode 100644
index 00000000000..3553a679e0e
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/exec_sun.c
@@ -0,0 +1,212 @@
+/* $Id: exec_sun.c,v 1.1 1997/10/14 07:25:31 gingold Exp $ */
+
+/*-
+ * Copyright (c) 1995 Theo de Raadt
+ * 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 Theo de Raadt
+ * 4. The name of the Author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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) 1982, 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.
+ *
+ * @(#)boot.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <sys/param.h>
+#include <sys/reboot.h>
+#include <a.out.h>
+
+#include "stand.h"
+
+extern int debug;
+
+extern u_int bootdev;
+
+/*ARGSUSED*/
+exec_sun(file, loadaddr, howto)
+ char *file;
+ char *loadaddr;
+ int howto;
+{
+ register int io;
+ struct exec x;
+ int cc, magic;
+ void (*entry)();
+ register char *cp;
+ register int *ip;
+ int textlen;
+
+#ifdef DEBUG
+ printf("exec_sun: file=%s loadaddr=0x%x\n", file, loadaddr);
+#endif
+
+ io = open(file, 0);
+ if (io < 0)
+ return(-1);
+
+ /*
+ * Read in the exec header, and validate it.
+ */
+ if (read(io, (char *)&x, sizeof(x)) != sizeof(x))
+ goto shread;
+ if (N_BADMAG(x)) {
+ errno = EFTYPE;
+ goto closeout;
+ }
+
+ cp = x.a_entry; /* loadaddr; */
+ textlen = x.a_text;
+ magic = N_GETMAGIC(x);
+ if (magic == ZMAGIC) {
+ cp += sizeof(x);
+ textlen -= sizeof(x);
+ }
+ entry = (void (*)())cp;
+
+ printf ("Entry at %x\n", cp);
+ /*
+ * Leave a copy of the exec header before the text.
+ * The sun3 kernel uses this to verify that the
+ * symbols were loaded by this boot program.
+ */
+ bcopy(&x, cp - sizeof(x), sizeof(x));
+
+ /*
+ * Read in the text segment.
+ */
+ printf("%x", x.a_text);
+ if (read(io, cp, textlen) != textlen)
+ goto shread;
+ cp += textlen;
+
+ /*
+ * NMAGIC may have a gap between text and data.
+ */
+ if (magic == NMAGIC) {
+ register int mask = N_PAGSIZ(x) - 1;
+ while ((int)cp & mask)
+ *cp++ = 0;
+ }
+
+ /*
+ * Read in the data segment.
+ */
+ printf("+%x", x.a_data);
+ if (read(io, cp, x.a_data) != x.a_data)
+ goto shread;
+ cp += x.a_data;
+
+ /*
+ * Zero out the BSS section.
+ * (Kernel does not do it itself)
+ */
+ printf("+%x", x.a_bss);
+ cc = x.a_bss;
+ while ((int)cp & 3) {
+ *cp++ = 0;
+ --cc;
+ }
+ ip = (int *)cp;
+ cp += cc;
+ while ((char *)ip < cp)
+ *ip++ = 0;
+
+ /*
+ * Read in the symbol table and strings.
+ * (Always set the symtab size word.)
+ */
+ *ip++ = x.a_syms;
+ cp = (char *)ip;
+
+ if (x.a_syms > 0) {
+
+ /* Symbol table and string table length word. */
+ cc = x.a_syms;
+ printf("+[%x", cc);
+ cc += sizeof(int); /* strtab length too */
+ if (read(io, cp, cc) != cc)
+ goto shread;
+ cp += x.a_syms;
+ ip = (int *)cp; /* points to strtab length */
+ cp += sizeof(int);
+
+ /* String table. Length word includes itself. */
+ cc = *ip;
+ printf("+%x]", cc);
+ cc -= sizeof(int);
+ if (cc <= 0)
+ goto shread;
+ if (read(io, cp, cc) != cc)
+ goto shread;
+ cp += cc;
+ }
+ printf("=%x\n", cp - loadaddr);
+ close(io);
+
+ if (debug) {
+ printf("Debug mode - enter c to continue\n");
+ }
+
+ printf("Starting program at 0x%x\n", (int)entry);
+ (*entry)(howto, bootdev, cp, 0, 0);
+ panic("exec returned");
+
+shread:
+ printf("exec: short read\n");
+ errno = EIO;
+closeout:
+ close(io);
+ return(-1);
+}
diff --git a/sys/arch/kbus/stand/sk/gets.c b/sys/arch/kbus/stand/sk/gets.c
new file mode 100644
index 00000000000..fe50ebf5be6
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/gets.c
@@ -0,0 +1,141 @@
+/* $Id: gets.c,v 1.1 1997/10/14 07:25:31 gingold Exp $ */
+
+/*-
+ * Copyright (c) 1995 Theo de Raadt
+ * 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 Theo de Raadt
+ * 4. The name of the Author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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) 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.
+ *
+ * @(#)gets.c 8.1 (Berkeley) 6/11/93
+ */
+
+#include "stand.h"
+
+/*
+ * This implementation assumes that getchar() does echo, because
+ * on some machines, it is hard to keep echo from being done.
+ * Those that need it can do echo in their getchar() function.
+ *
+ * Yes, the code below will echo CR, DEL, and other control chars,
+ * but sending CR or DEL here is harmless. All the other editing
+ * characters will be followed by a newline, so it doesn't matter.
+ * (Most terminals will not show them anyway.)
+ */
+
+void
+gets(buf)
+ char *buf;
+{
+ register int c;
+ register char *lp;
+
+top:
+ lp = buf;
+
+ for (;;) {
+ c = getchar() & 0177;
+
+ putchar(c);
+
+ switch (c) {
+
+ default:
+ *lp++ = c;
+ continue;
+
+ case '\177':
+ putchar('\b');
+ /* fall through */
+ case '\b':
+ putchar(' ');
+ putchar('\b');
+ /* fall through */
+ case '#':
+ if (lp > buf)
+ lp--;
+ continue;
+
+ /*
+ * This is not very useful in a boot program.
+ * (It costs you 52 bytes on m68k, gcc -O3).
+ */
+ case 'r'&037: {
+ register char *p;
+ putchar('\n');
+ for (p = buf; p < lp; ++p)
+ putchar(*p);
+ continue;
+ }
+
+ case '@':
+ case 'u'&037:
+ case 'w'&037:
+ putchar('\n');
+ goto top;
+
+ case '\r':
+ putchar('\n');
+ /* fall through */
+ case '\n':
+ *lp = '\0';
+ return;
+
+ } /* switch */
+ }
+ /*NOTREACHED*/
+}
diff --git a/sys/arch/kbus/stand/sk/idprom.h b/sys/arch/kbus/stand/sk/idprom.h
new file mode 100644
index 00000000000..007b40674c1
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/idprom.h
@@ -0,0 +1,90 @@
+#define ID_BYTE_OFFSET 0x08
+
+#define ID_MASK 0x7f
+#define ID_OFF_MAJOR 0x00
+#define ID_OFF_MINOR 0x08
+#define ID_OFF_REVLEV1 0x10
+#define ID_OFF_REVLEV2 0x18
+#define ID_OFF_OFFSET1 0x20
+#define ID_OFF_OFFSET2 0x28
+#define ID_OFF_OFFSET3 0x30
+#define ID_OFF_OFFSET4 0x38
+#define ID_OFF_SIZE1 0x40
+#define ID_OFF_SIZE2 0x48
+#define ID_OFF_SIZE3 0x50
+#define ID_OFF_SIZE4 0x58
+#define ID_OFF_CKSUM 0x60
+#define ID_OFF_STRING 0x68
+
+#define ID_MAX_STRING_SIZE 129
+
+#define ID_4BYTES_TO_LONG(a1, a2, a3, a4) \
+ ((a1 << 24) | (a2 << 16) | (a3 << 8) | a4)
+#define ID_2BYTES_TO_SHORT(a1, a2) ((a1 << 8) | a2)
+
+#define ID_MEMORY_BOARD 'M'
+#define ID_SYSTEM_BOARD 'S'
+#define ID_GRAPHIC_BOARD 'G'
+
+/* For the system board. */
+#define ID_S_SERIAL_SIZE 16
+#define ID_S_ENET_SIZE 6
+#define ID_S_MFGDATE_SIZE 6
+#define ID_S_BANNER_SIZE 64
+#define ID_S_COPYRIGHT_SIZE 64
+#define ID_S_LOGOBITMAP_SIZE 512
+
+#define ID_S_OFF_HOSTID1 0x000
+#define ID_S_OFF_HOSTID2 0x008
+#define ID_S_OFF_HOSTID3 0x010
+#define ID_S_OFF_HOSTID4 0x018
+#define ID_S_OFF_SERIAL 0x080
+#define ID_S_OFF_ENETADDR 0x180
+#define ID_S_OFF_MFGDATE 0x1c0
+#define ID_S_OFF_OEM_FLAG 0x1f0
+#define ID_S_OFF_BANNER 0x1f8
+#define ID_S_OFF_COPYRIGHT 0x3f8
+#define ID_S_OFF_LOGOBITMAP 0x5f8
+
+#define ID_G_OFF_TYPE 0x00
+#define ID_G_OFF_NBR_PLANE 0x08
+#define ID_G_OFF_ACCESS_SIZE 0x10
+#define ID_G_OFF_RES_COUNT 0x18
+
+#define ID_G_OFF_FB_SIZES 0x20
+#define ID_G_SIZE_FB_SIZES 0x90
+#define ID_G_OFF_X_RES1 0x00
+#define ID_G_OFF_X_RES2 0x08
+#define ID_G_OFF_Y_RES1 0x10
+#define ID_G_OFF_Y_RES2 0x18
+#define ID_G_OFF_XOFFSET1 0x20
+#define ID_G_OFF_XOFFSET2 0x28
+#define ID_G_OFF_FB_SIZE1 0x30
+#define ID_G_OFF_FB_SIZE2 0x38
+#define ID_G_OFF_FB_SIZE3 0x40
+#define ID_G_OFF_FB_SIZE4 0x48
+#define ID_G_OFF_ITBL_OFF1 0x50
+#define ID_G_OFF_ITBL_OFF2 0x58
+#define ID_G_OFF_ITBL_OFF3 0x60
+#define ID_G_OFF_ITBL_OFF4 0x68
+#define ID_G_OFF_FONT_OFF1 0x70
+#define ID_G_OFF_FONT_OFF2 0x78
+#define ID_G_OFF_FONT_OFF3 0x80
+#define ID_G_OFF_FONT_OFF4 0x88
+
+#define ID_G_OFF_WHITE_OFF1 0x00
+#define ID_G_OFF_WHITE_OFF2 0x08
+#define ID_G_OFF_WHITE_OFF3 0x10
+#define ID_G_OFF_WHITE_OFF4 0x18
+#define ID_G_OFF_BLACK_OFF1 0x20
+#define ID_G_OFF_BLACK_OFF2 0x28
+#define ID_G_OFF_BLACK_OFF3 0x30
+#define ID_G_OFF_BLACK_OFF4 0x38
+#define ID_G_OFF_FB_OFF1 0x40
+#define ID_G_OFF_FB_OFF2 0x48
+#define ID_G_OFF_FB_OFF3 0x50
+#define ID_G_OFF_FB_OFF4 0x58
+#define ID_G_OFF_KB_OFF1 0x60
+#define ID_G_OFF_KB_OFF2 0x68
+#define ID_G_OFF_KB_OFF3 0x70
+#define ID_G_OFF_KB_OFF4 0x78
diff --git a/sys/arch/kbus/stand/sk/if_le.c b/sys/arch/kbus/stand/sk/if_le.c
new file mode 100644
index 00000000000..0fa04fad29f
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/if_le.c
@@ -0,0 +1,615 @@
+/* $Id: if_le.c,v 1.1 1997/10/14 07:25:31 gingold Exp $ */
+
+/*
+ * Copyright (c) 1995 Theo de Raadt
+ *
+ * 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 under OpenBSD by
+ * Theo de Raadt for Willowglen Singapore.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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) 1993 Adam Glass
+ * 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 Adam Glass.
+ * 4. The name of the Author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Adam Glass ``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.
+ */
+
+#include <sys/param.h>
+#include <sys/types.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+
+#include "stand.h"
+#include "netif.h"
+#include "config.h"
+
+#include "if_lereg.h"
+
+int le_debug = 0;
+
+void le_end __P((struct netif *));
+void le_error __P((struct netif *, char *, volatile struct lereg1 *));
+int le_get __P((struct iodesc *, void *, size_t, time_t));
+void le_init __P((struct iodesc *, void *));
+int le_match __P((struct netif *, void *));
+int le_poll __P((struct iodesc *, void *, int));
+int le_probe __P((struct netif *, void *));
+int le_put __P((struct iodesc *, void *, size_t));
+static void le_reset __P((int unit));
+
+struct netif_stats le_stats;
+
+struct netif_dif le0_dif = {
+ 0, /* unit */
+ 1, /* nsel */
+ &le_stats,
+ 0,
+ 0,
+};
+
+struct netif_driver le_driver = {
+ "le", /* netif_bname */
+ le_match, /* match */
+ le_probe, /* probe */
+ le_init, /* init */
+ le_get, /* get */
+ le_put, /* put */
+ le_end, /* end */
+ &le0_dif, /* netif_ifs */
+ 1, /* netif_nifs */
+};
+
+static struct le_configuration {
+ unsigned int phys_addr;
+ int used;
+ int init;
+ unsigned char ea[8];
+} le_config[] = {
+ { LANCE_REG_ADDR, 0, 0 }
+};
+
+int nle_config = sizeof(le_config) / (sizeof(le_config[0]));
+
+struct {
+ struct lereg1 *sc_r1; /* LANCE registers */
+ struct lereg2 *sc_r2; /* RAM */
+ void *recv_mem;
+ void *xmit_mem;
+ int next_rmd;
+ int next_tmd;
+} le_softc;
+
+int
+le_match(nif, machdep_hint)
+ struct netif *nif;
+ void *machdep_hint;
+{
+ char *name;
+ int i, val = 0;
+
+ name = machdep_hint;
+ if (name && !bcmp(le_driver.netif_bname, name, 2))
+ val += 10;
+ for (i = 0; i < nle_config; i++) {
+ if (le_config[i].used)
+ continue;
+ if (le_debug)
+ printf("le%d: le_match --> %d\n", i, val + 1);
+ le_config[i].used++;
+ return val + 1;
+ }
+ if (le_debug)
+ printf("le%d: le_match --> 0\n", i);
+ return 0;
+}
+
+int
+le_probe(nif, machdep_hint)
+ struct netif *nif;
+ void *machdep_hint;
+{
+ /* the set unit is the current unit */
+ if (le_debug)
+ printf("le%d: le_probe called\n", nif->nif_unit);
+
+ return 0;
+}
+
+void
+le_error(nif, str, ler1)
+ struct netif *nif;
+ char *str;
+ volatile struct lereg1 *ler1;
+{
+
+ printf ("le_error (%s) C0: %b\n", str, ler1->ler1_rdp, LE_C0_BITS);
+ /* ler1->ler1_rap = LE_CSRO done in caller */
+ if (ler1->ler1_rdp & LE_C0_BABL)
+ panic("le%d: been babbling, found by '%s'\n",
+ nif->nif_unit, str);
+ if (ler1->ler1_rdp & LE_C0_CERR) {
+ le_stats.collision_error++;
+ ler1->ler1_rdp = LE_C0_CERR;
+ }
+ if (ler1->ler1_rdp & LE_C0_MISS) {
+ le_stats.missed++;
+ ler1->ler1_rdp = LE_C0_MISS;
+ }
+ if (ler1->ler1_rdp & LE_C0_MERR) {
+ printf("le%d: memory error in '%s'\n", nif->nif_unit, str);
+ panic("memory error");
+ }
+}
+
+static void
+le_reset(unit)
+ int unit;
+{
+ struct lereg1 *ler1 = le_softc.sc_r1;
+ struct lereg2 *ler2 = le_softc.sc_r2;
+ unsigned int a;
+ int timo = 40, stat, i;
+
+ if (le_debug)
+ {
+ printf("le%d: le_reset called\n", unit);
+ printf ("addr: 0x%x, data: 0x%x, xmit_mem: 0x%x, recv_mem: 0x%x\n",
+ &ler1->ler1_rap, &ler1->ler1_rdp,
+ le_softc.xmit_mem, le_softc.recv_mem);
+ }
+
+ /* Set IOASIC. */
+ *(u_long *)0x90000004 = ((u_long)le_softc.recv_mem & 0x00ffffff) >> 15;
+ *(u_long *)0x90000008 = ((u_long)le_softc.xmit_mem & 0x00ffffff) >> 13;
+
+ ler1->ler1_rap = LE_CSR0;
+ ler1->ler1_rdp = LE_C0_STOP; /* do nothing until we are finished */
+
+ if (le_debug)
+ printf ("le%d: stopped\n", unit);
+
+ bzero(ler2, sizeof(*ler2));
+
+ ler2->ler2_mode = LE_MODE_NORMAL;
+ ler2->ler2_padr[0] = le_config[unit].ea[1];
+ ler2->ler2_padr[1] = le_config[unit].ea[0];
+ ler2->ler2_padr[2] = le_config[unit].ea[3];
+ ler2->ler2_padr[3] = le_config[unit].ea[2];
+ ler2->ler2_padr[4] = le_config[unit].ea[5];
+ ler2->ler2_padr[5] = le_config[unit].ea[4];
+
+
+ ler2->ler2_ladrf0 = 0;
+ ler2->ler2_ladrf1 = 0;
+
+ a = (u_int) ler2->ler2_rmd;
+ ler2->ler2_rlen = LE_RLEN | 0;
+ ler2->ler2_rdra = LE_GET_MD_ADDR (a);
+
+ a = (u_int) ler2->ler2_tmd;
+ ler2->ler2_tlen = LE_TLEN | 0;
+ ler2->ler2_tdra = LE_GET_MD_ADDR (a);
+
+ ler1->ler1_rap = LE_CSR1;
+ a = (u_int) ler2;
+ ler1->ler1_rdp = LE_GET_MD_ADDR (a);
+ ler1->ler1_rap = LE_CSR2;
+ ler1->ler1_rdp = 0;
+
+ for (i = 0; i < LERBUF; i++)
+ {
+ a = (u_int) & ler2->ler2_rbuf[i];
+ ler2->ler2_rmd[i].rmd0 = LE_GET_RECV_ADDR (a);
+ ler2->ler2_rmd[i].rmd1_bits = LE_R1_OWN;
+ ler2->ler2_rmd[i].rmd1_hadr = 0;
+ ler2->ler2_rmd[i].rmd2 = -LEMTU;
+ ler2->ler2_rmd[i].rmd3 = 0;
+ }
+ for (i = 0; i < LETBUF; i++)
+ {
+ ler2->ler2_tbuf[i] = (char *)(le_softc.xmit_mem + i * LEMTU);
+ a = (u_int) ler2->ler2_tbuf[i];
+ ler2->ler2_tmd[i].tmd0 = LE_GET_XMIT_ADDR (a);
+ ler2->ler2_tmd[i].tmd1_bits = 0;
+ ler2->ler2_tmd[i].tmd1_hadr = 0;
+ ler2->ler2_tmd[i].tmd2 = 0;
+ ler2->ler2_tmd[i].tmd3 = 0;
+ }
+
+ ler1->ler1_rap = LE_CSR3;
+ ler1->ler1_rdp = LE_C3_BSWP;
+
+ ler1->ler1_rap = LE_CSR0;
+ ler1->ler1_rdp = LE_C0_INIT;
+ do {
+ if (--timo == 0) {
+ printf("le%d: init timeout, stat = 0x%x\n",
+ unit, stat);
+ break;
+ }
+ stat = ler1->ler1_rdp;
+ } while ((stat & LE_C0_IDON) == 0);
+
+ ler1->ler1_rdp = LE_C0_IDON;
+ le_softc.next_rmd = 0;
+ le_softc.next_tmd = 0;
+ ler1->ler1_rap = LE_CSR0;
+ ler1->ler1_rdp = LE_C0_STRT | LE_C0_INEA;
+/* printf ("C0: %b\n", ler1->ler1_rdp, LE_C0_BITS); TG */
+}
+
+int
+le_poll(desc, pkt, len)
+ struct iodesc *desc;
+ void *pkt;
+ int len;
+{
+ struct lereg1 *ler1 = le_softc.sc_r1;
+ struct lereg2 *ler2 = le_softc.sc_r2;
+ unsigned int a;
+ int length;
+ struct lermd *rmd;
+
+
+ ler1->ler1_rap = LE_CSR0;
+
+ if ((ler1->ler1_rdp & LE_C0_RINT) != 0)
+ ler1->ler1_rdp = LE_C0_RINT;
+ rmd = &ler2->ler2_rmd[le_softc.next_rmd];
+ if (rmd->rmd1_bits & LE_R1_OWN) {
+ return (0);
+ }
+ if (ler1->ler1_rdp & LE_C0_ERR)
+ le_error(desc->io_netif, "le_poll", ler1);
+ if (rmd->rmd1_bits & LE_R1_ERR) {
+ printf("le%d_poll: rmd status 0x%x\n", desc->io_netif->nif_unit,
+ rmd->rmd1_bits);
+ length = 0;
+ goto cleanup;
+ }
+ if ((rmd->rmd1_bits & (LE_R1_STP | LE_R1_ENP)) != (LE_R1_STP | LE_R1_ENP))
+ panic("le_poll: chained packet\n");
+
+ length = rmd->rmd3;
+ if (length >= LEMTU) {
+ length = 0;
+ panic("csr0 when bad things happen: %x\n", ler1->ler1_rdp);
+ goto cleanup;
+ }
+ if (!length)
+ goto cleanup;
+ length -= 4;
+ if (length > 0) {
+
+ /*
+ * if buffer is smaller than the packet truncate it.
+ * (is this wise?)
+ */
+ if (length > len)
+ length = len;
+
+ bcopy((void *)&ler2->ler2_rbuf[le_softc.next_rmd], pkt, length);
+ }
+cleanup:
+ a = (u_int) & ler2->ler2_rbuf[le_softc.next_rmd];
+ rmd->rmd0 = LE_GET_RECV_ADDR (a);
+ rmd->rmd1_hadr = 0;
+ rmd->rmd2 = -LEMTU;
+ le_softc.next_rmd =
+ (le_softc.next_rmd == (LERBUF - 1)) ? 0 : (le_softc.next_rmd + 1);
+ rmd->rmd1_bits = LE_R1_OWN;
+/* printf ("C0: %b\n", ler1->ler1_rdp, LE_C0_BITS); TG */
+ return length;
+}
+
+int
+le_put(desc, pkt, len)
+ struct iodesc *desc;
+ void *pkt;
+ size_t len;
+{
+ volatile struct lereg1 *ler1 = le_softc.sc_r1;
+ volatile struct lereg2 *ler2 = le_softc.sc_r2;
+ volatile struct letmd *tmd;
+ int timo = 100000, stat, i;
+ unsigned int a;
+
+ /* Check status. */
+ ler1->ler1_rap = LE_CSR0;
+ if (ler1->ler1_rdp & LE_C0_ERR)
+ le_error(desc->io_netif, "le_put(way before xmit)", ler1);
+
+ tmd = &ler2->ler2_tmd[le_softc.next_tmd];
+ while (tmd->tmd1_bits & LE_T1_OWN)
+ {
+ printf("le%d: output buffer busy\n", desc->io_netif->nif_unit);
+ }
+
+ bcopy (pkt, (void *)ler2->ler2_tbuf[le_softc.next_tmd], len);
+ if (len < 64)
+ tmd->tmd2 = -64;
+ else
+ tmd->tmd2 = -len;
+ tmd->tmd3 = 0;
+ if (ler1->ler1_rdp & LE_C0_ERR)
+ le_error(desc->io_netif, "le_put(before xmit)", ler1);
+
+ tmd->tmd1_bits = LE_T1_STP | LE_T1_ENP | LE_T1_OWN;
+ a = (u_int) ler2->ler2_tbuf[le_softc.next_tmd];
+ tmd->tmd0 = LE_GET_XMIT_ADDR (a);
+ tmd->tmd1_hadr = 0;
+ ler1->ler1_rdp = LE_C0_TDMD;
+ if (ler1->ler1_rdp & LE_C0_ERR)
+ le_error(desc->io_netif, "le_put(after xmit)", ler1);
+ do
+ {
+ if (--timo == 0) {
+ printf("le%d: transmit timeout, stat = 0x%x\n",
+ desc->io_netif->nif_unit, stat);
+ if (ler1->ler1_rdp & LE_C0_ERR)
+ le_error(desc->io_netif, "le_put(timeout)", ler1);
+ break;
+ }
+ stat = ler1->ler1_rdp;
+ udelay (1000);
+ } while ((stat & LE_C0_TINT) == 0);
+/* printf ("C0: %b\n", ler1->ler1_rdp, LE_C0_BITS); TG */
+ ler1->ler1_rdp = LE_C0_TINT;
+ if (ler1->ler1_rdp & LE_C0_ERR) {
+ if ((ler1->ler1_rdp & (LE_C0_BABL | LE_C0_CERR | LE_C0_MISS |
+ LE_C0_MERR)) !=
+ LE_C0_CERR)
+ printf("le_put: xmit error, buf %d\n", le_softc.next_tmd);
+ le_error(desc->io_netif, "le_put(xmit error)", ler1);
+ }
+ le_softc.next_tmd = 0;
+ /* (le_softc.next_tmd == (LETBUF - 1)) ? 0 : le_softc.next_tmd + 1;*/
+ if (tmd->tmd1_bits & LE_T1_DEF)
+ le_stats.deferred++;
+ if (tmd->tmd1_bits & LE_T1_ONE)
+ le_stats.collisions++;
+ if (tmd->tmd1_bits & LE_T1_MORE)
+ le_stats.collisions += 2;
+ if (tmd->tmd1_bits & LE_T1_ERR) {
+ printf("le%d: transmit error, error = 0x%x\n", desc->io_netif->nif_unit,
+ tmd->tmd3);
+ return -1;
+ }
+ if (le_debug) {
+ printf("le%d: le_put() successful: sent %d\n",
+ desc->io_netif->nif_unit, len);
+ printf("le%d: le_put(): tmd1_bits: %x tmd3: %x\n",
+ desc->io_netif->nif_unit,
+ (unsigned int) tmd->tmd1_bits,
+ (unsigned int) tmd->tmd3);
+ }
+ return len;
+}
+
+int
+le_get(desc, pkt, len, timeout)
+ struct iodesc *desc;
+ void *pkt;
+ size_t len;
+ time_t timeout;
+{
+ time_t t;
+ int cc;
+
+ t = getsecs();
+ cc = 0;
+ while (((getsecs() - t) < timeout) && !cc) {
+ cc = le_poll(desc, pkt, len);
+ }
+ return cc;
+}
+/*
+ * init le device. return 0 on failure, 1 if ok.
+ */
+/* 32kb alignment required. */
+#define RECV_ALIGN 0x8000
+#define XMIT_ALIGN 0x2000
+void
+le_low_init (void)
+{
+ u_long mem;
+ u_long xmit_mem;
+ u_long recv_mem;
+ int unit = 0;
+
+ if (le_config[unit].init)
+ return;
+ else
+ le_config[unit].init = 1;
+
+ machdep_common_ether(le_config[unit].ea);
+ printf ("le_low_init: addr is %s\n", ether_sprintf (le_config[unit].ea));
+ bzero(&le_softc, sizeof(le_softc));
+ le_softc.sc_r1 =
+ (struct lereg1 *) le_config[unit].phys_addr;
+
+ mem = (u_long) alloc (2 * RECV_ALIGN + XMIT_ALIGN);
+ recv_mem = (mem & ~(RECV_ALIGN - 1)) + RECV_ALIGN;
+ xmit_mem = recv_mem + RECV_ALIGN;
+
+ le_softc.sc_r2 = (struct lereg2 *) recv_mem;
+ le_softc.recv_mem = (void *) recv_mem;
+ le_softc.xmit_mem = (void *) xmit_mem;
+ le_reset (unit);
+}
+
+void
+le_init(desc, machdep_hint)
+ struct iodesc *desc;
+ void *machdep_hint;
+{
+ u_long mem;
+ u_long xmit_mem;
+ u_long recv_mem;
+
+ struct netif *nif = desc->io_netif;
+ int unit = nif->nif_unit;
+
+ if (le_debug)
+ printf("le%d: le_init called\n", unit);
+
+/* le_low_init (); */
+ bcopy (le_config[unit].ea, desc->myea, 6);
+ printf ("device: %s%d attached to %s\n",
+ nif->nif_driver->netif_bname,
+ nif->nif_unit,
+ ether_sprintf(desc->myea));
+}
+
+void
+le_end(nif)
+ struct netif *nif;
+{
+ struct lereg1 *ler1 = le_softc.sc_r1;
+
+ if (le_debug)
+ printf("le%d: le_end called\n", nif->nif_unit);
+ ler1->ler1_rap = LE_CSR0;
+ ler1->ler1_rdp = LE_C0_STOP;
+}
+
+void
+le_disp_status (void)
+{
+ u_int16_t isr;
+ struct lereg1 *ler1 = le_softc.sc_r1;
+
+ ler1->ler1_rap = LE_CSR0;
+ isr = ler1->ler1_rdp;
+ printf ("le_int: isr = %x\n", isr);
+}
+
+void
+le_intr (void)
+{
+ struct lereg1 *ler1 = le_softc.sc_r1;
+ struct lereg2 *ler2 = le_softc.sc_r2;
+ unsigned int a;
+ int length;
+ struct lermd *rmd;
+ u_int16_t isr;
+
+ if (!le_config[0].init)
+ {
+ printf ("le not init\n");
+ return;
+ }
+
+ ler1->ler1_rap = LE_CSR0;
+ isr = ler1->ler1_rdp;
+ if (!(isr & LE_C0_INTR))
+ {
+ printf ("le: no intr\n");
+ return;
+ }
+ printf ("le_int: isr = %x\n", isr);
+
+ /* Clear the flags. */
+ ler1->ler1_rdp = isr & (LE_C0_INEA | LE_C0_BABL | LE_C0_CERR | LE_C0_MISS
+ | LE_C0_MERR | LE_C0_RINT | LE_C0_TINT | LE_C0_IDON);
+
+ /* Return if nothing to read. */
+ if (!(isr & LE_C0_RINT))
+ return;
+
+ rmd = &ler2->ler2_rmd[le_softc.next_rmd];
+ if (rmd->rmd1_bits & LE_R1_OWN)
+ return;
+
+ if (isr & LE_C0_ERR)
+ le_error(NULL, "le_poll", ler1);
+ if (rmd->rmd1_bits & LE_R1_ERR)
+ {
+ printf("le%d_poll: rmd status 0x%x\n", 0,
+ rmd->rmd1_bits);
+ length = 0;
+ goto cleanup;
+ }
+ if ((rmd->rmd1_bits & (LE_R1_STP | LE_R1_ENP)) != (LE_R1_STP | LE_R1_ENP))
+ panic("le_poll: chained packet\n");
+
+ length = rmd->rmd3;
+ if (length >= LEMTU)
+ {
+ length = 0;
+ panic("csr0 when bad things happen: %x\n", ler1->ler1_rdp);
+ goto cleanup;
+ }
+ if (!length)
+ goto cleanup;
+ length -= 4;
+ if (length > 0)
+ {
+#if 0
+ /*
+ * if buffer is smaller than the packet truncate it.
+ * (is this wise?)
+ */
+ if (length > len)
+ length = len;
+
+ bcopy((void *)&ler2->ler2_rbuf[le_softc.next_rmd], pkt, length);
+#endif
+ }
+cleanup:
+ a = (u_int) & ler2->ler2_rbuf[le_softc.next_rmd];
+ rmd->rmd0 = LE_GET_RECV_ADDR (a);
+ rmd->rmd1_hadr = 0;
+ rmd->rmd2 = -LEMTU;
+ le_softc.next_rmd =
+ (le_softc.next_rmd == (LERBUF - 1)) ? 0 : (le_softc.next_rmd + 1);
+ rmd->rmd1_bits = LE_R1_OWN;
+ /* printf ("C0: %b\n", ler1->ler1_rdp, LE_C0_BITS); TG */
+}
diff --git a/sys/arch/kbus/stand/sk/if_lereg.h b/sys/arch/kbus/stand/sk/if_lereg.h
new file mode 100644
index 00000000000..2742840935e
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/if_lereg.h
@@ -0,0 +1,176 @@
+/* $Id: if_lereg.h,v 1.1 1997/10/14 07:25:31 gingold Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1992, 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.
+ *
+ * @(#)if_lereg.h 8.2 (Berkeley) 10/30/93
+ */
+
+#define LEMTU 1518
+#define LEMINSIZE 60 /* should be 64 if mode DTCR is set */
+#define LERBUF 8
+#define LERBUFLOG2 3
+#define LE_RLEN (LERBUFLOG2 << 13)
+#define LETBUF 1
+#define LETBUFLOG2 0
+#define LE_TLEN (LETBUFLOG2 << 13)
+
+/* Local Area Network Controller for Ethernet (LANCE) registers */
+struct lereg1 {
+ volatile u_short ler1_rdp; /* register data port */
+ char pad[0x20 - sizeof (u_short)];/* Pad. */
+ volatile u_short ler1_rap; /* register address port */
+};
+/* register addresses */
+#define LE_CSR0 0 /* Control and status register */
+#define LE_CSR1 1 /* low address of init block */
+#define LE_CSR2 2 /* high address of init block */
+#define LE_CSR3 3 /* Bus master and control */
+
+/* Control and status register 0 (csr0) */
+#define LE_C0_ERR 0x8000 /* error summary */
+#define LE_C0_BABL 0x4000 /* transmitter timeout error */
+#define LE_C0_CERR 0x2000 /* collision */
+#define LE_C0_MISS 0x1000 /* missed a packet */
+#define LE_C0_MERR 0x0800 /* memory error */
+#define LE_C0_RINT 0x0400 /* receiver interrupt */
+#define LE_C0_TINT 0x0200 /* transmitter interrupt */
+#define LE_C0_IDON 0x0100 /* initalization done */
+#define LE_C0_INTR 0x0080 /* interrupt condition */
+#define LE_C0_INEA 0x0040 /* interrupt enable */
+#define LE_C0_RXON 0x0020 /* receiver on */
+#define LE_C0_TXON 0x0010 /* transmitter on */
+#define LE_C0_TDMD 0x0008 /* transmit demand */
+#define LE_C0_STOP 0x0004 /* disable all external activity */
+#define LE_C0_STRT 0x0002 /* enable external activity */
+#define LE_C0_INIT 0x0001 /* begin initalization */
+
+#define LE_C0_BITS \
+ "\20\20ERR\17BABL\16CERR\15MISS\14MERR\13RINT\
+\12TINT\11IDON\10INTR\07INEA\06RXON\05TXON\04TDMD\03STOP\02STRT\01INIT"
+
+/* Control and status register 3 (csr3) */
+#define LE_C3_BSWP 0x4 /* byte swap */
+#define LE_C3_ACON 0x2 /* ALE control, eh? */
+#define LE_C3_BCON 0x1 /* byte control */
+/*
+ * Current size is 13,758 bytes with 8 x 1518 receive buffers and
+ * 1 x 1518 transmit buffer.
+ */
+struct lereg2 {
+ /* initialization block */
+ volatile u_short ler2_mode; /* mode */
+ volatile u_char ler2_padr[6]; /* physical address */
+#ifdef new_code
+ volatile u_short ler2_ladrf[4]; /* logical address filter */
+#else
+ volatile u_long ler2_ladrf0; /* logical address filter */
+ volatile u_long ler2_ladrf1; /* logical address filter */
+#endif
+ volatile u_short ler2_rdra; /* receive descriptor addr */
+ volatile u_short ler2_rlen; /* rda high and ring size */
+ volatile u_short ler2_tdra; /* transmit descriptor addr */
+ volatile u_short ler2_tlen; /* tda high and ring size */
+ /* receive message descriptors. bits/hadr are byte order dependent. */
+ struct lermd {
+ volatile u_short rmd0; /* low address of packet */
+ volatile u_char rmd1_bits; /* descriptor bits */
+ volatile u_char rmd1_hadr; /* high address of packet */
+ volatile short rmd2; /* buffer byte count */
+ volatile u_short rmd3; /* message byte count */
+ } ler2_rmd[LERBUF];
+ /* transmit message descriptors */
+ struct letmd {
+ volatile u_short tmd0; /* low address of packet */
+ volatile u_char tmd1_bits; /* descriptor bits */
+ volatile u_char tmd1_hadr; /* high address of packet */
+ volatile short tmd2; /* buffer byte count */
+ volatile u_short tmd3; /* transmit error bits */
+ } ler2_tmd[LETBUF];
+ volatile char ler2_rbuf[LERBUF][LEMTU];
+ volatile char *ler2_tbuf[LETBUF];
+};
+/* Initialzation block (mode) */
+#define LE_MODE_PROM 0x8000 /* promiscuous mode */
+/* 0x7f80 reserved, must be zero */
+#define LE_MODE_INTL 0x0040 /* internal loopback */
+#define LE_MODE_DRTY 0x0020 /* disable retry */
+#define LE_MODE_COLL 0x0010 /* force a collision */
+#define LE_MODE_DTCR 0x0008 /* disable transmit CRC */
+#define LE_MODE_LOOP 0x0004 /* loopback mode */
+#define LE_MODE_DTX 0x0002 /* disable transmitter */
+#define LE_MODE_DRX 0x0001 /* disable receiver */
+#define LE_MODE_NORMAL 0 /* none of the above */
+
+
+/* Receive message descriptor 1 (rmd1_bits) */
+#define LE_R1_OWN 0x80 /* LANCE owns the packet */
+#define LE_R1_ERR 0x40 /* error summary */
+#define LE_R1_FRAM 0x20 /* framing error */
+#define LE_R1_OFLO 0x10 /* overflow error */
+#define LE_R1_CRC 0x08 /* CRC error */
+#define LE_R1_BUFF 0x04 /* buffer error */
+#define LE_R1_STP 0x02 /* start of packet */
+#define LE_R1_ENP 0x01 /* end of packet */
+
+#define LE_R1_BITS \
+ "\20\10OWN\7ERR\6FRAM\5OFLO\4CRC\3BUFF\2STP\1ENP"
+
+/* Transmit message descriptor 1 (tmd1_bits) */
+#define LE_T1_OWN 0x80 /* LANCE owns the packet */
+#define LE_T1_ERR 0x40 /* error summary */
+#define LE_T1_MORE 0x10 /* multiple collisions */
+#define LE_T1_ONE 0x08 /* single collision */
+#define LE_T1_DEF 0x04 /* defferred transmit */
+#define LE_T1_STP 0x02 /* start of packet */
+#define LE_T1_ENP 0x01 /* end of packet */
+
+#define LE_T1_BITS \
+ "\20\10OWN\7ERR\6RES\5MORE\4ONE\3DEF\2STP\1ENP"
+
+/* Transmit message descriptor 3 (tmd3) */
+#define LE_T3_BUFF 0x8000 /* buffer error */
+#define LE_T3_UFLO 0x4000 /* underflow error */
+#define LE_T3_LCOL 0x1000 /* late collision */
+#define LE_T3_LCAR 0x0800 /* loss of carrier */
+#define LE_T3_RTRY 0x0400 /* retry error */
+#define LE_T3_TDR_MASK 0x03ff /* time domain reflectometry counter */
+
+#define LE_XMD2_ONES 0xf000
+
+#define LE_T3_BITS \
+ "\20\20BUFF\17UFLO\16RES\15LCOL\14LCAR\13RTRY"
+
+
+#define LE_GET_MD_ADDR(a) (((a) & 0x7fff) | 0x8000)
+#define LE_GET_RECV_ADDR(a) ((a) & 0x7fff)
+#define LE_GET_XMIT_ADDR(a) (((a) & 0x7fff) | 0xc000)
diff --git a/sys/arch/kbus/stand/sk/intr.c b/sys/arch/kbus/stand/sk/intr.c
new file mode 100644
index 00000000000..fecbd2b3d56
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/intr.c
@@ -0,0 +1,173 @@
+#include <dev/ic/z8530reg.h>
+#include <machine/prom.h>
+#include <machine/sic.h>
+#include <machine/asi.h>
+#include <machine/asm.h>
+
+#define NOFAULT_CONTINUE 0x01
+#define NOFAULT_QUIET 0x02
+
+extern int nofault;
+
+#define CALL_ROM_COMMAND (**(void (**)(void))ROM_COMMAND)()
+#define GET_ROM_COMMAREA (*(struct prom_command_area **)ROM_COMM_AREA)
+
+void
+_exit (int val)
+{
+ char *command = "reset intr";
+
+ GET_ROM_COMMAREA->command_ptr = command;
+ CALL_ROM_COMMAND;
+}
+
+void
+sic_init (void)
+{
+ unsigned char irc_status;
+ unsigned char id;
+ unsigned char v;
+
+ set_ipl (0x0f);
+
+ printf ("1");
+ /* Disable the receiver. */
+ irc_status = lduba (ASI_IRXC, 0);
+ while (irc_status & SIC_IRC_E)
+ {
+ stba (ASI_IRXC, 0, irc_status & ~SIC_IRC_E);
+ irc_status = lduba (ASI_IRXC, 0);
+ printf ("2");
+ }
+
+ /* Enable all interruptions. */
+ sta (ASI_IPR, 0, 0);
+
+ printf ("3");
+
+ /* Set device id. */
+ id = lda (ASI_BID, 0) & 0x0f;
+ stba (ASI_DIR, 0, id);
+
+ printf ("4");
+ /* Ack int. */
+ lda (ASI_ACK_IPV, 0);
+
+ printf ("5");
+ /* Enable the receiver. */
+ stba (ASI_IRXC, 0, irc_status | SIC_IRC_E);
+
+ printf ("6");
+ set_ipl (0);
+ *(unsigned long *)0x17030000 = 0; /* id | 0x40; */
+
+ printf ("7");
+ /* Enable interruptions from the system board. */
+ v = *(volatile char *)0x17031000;
+ putchar ('8');
+ printf ("9\n");
+}
+
+void
+sendint (int boardid, int level)
+{
+ printf ("sendint level %d: ", level);
+ if (lduba (ASI_ITXC, 0) & SIC_ITXC_E)
+ {
+ printf ("busy\n");
+ return;
+ }
+ else
+ printf ("not busy...\n");
+ sta (ASI_IXR, 0, ((level & 0xff) << 8) | SIC_IXR_DIR | (boardid & 0x0f));
+ stba (ASI_ITXC, 0, SIC_ITXC_E);
+}
+
+#define NUMREGS 80
+
+/* Number of bytes of registers. */
+#define NUMREGBYTES (NUMREGS * 4)
+enum regnames
+{
+ G0, G1, G2, G3, G4, G5, G6, G7,
+ O0, O1, O2, O3, O4, O5, SP, O7,
+ L0, L1, L2, L3, L4, L5, L6, L7,
+ I0, I1, I2, I3, I4, I5, FP, I7,
+
+ F0, F1, F2, F3, F4, F5, F6, F7,
+ F8, F9, F10, F11, F12, F13, F14, F15,
+ F16, F17, F18, F19, F20, F21, F22, F23,
+ F24, F25, F26, F27, F28, F29, F30, F31,
+ Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR,
+ MMCR, FCR, FVAR, PDBA, FPAR, FTOR, FES, FTSR}; /* MMCR at 72. */
+
+
+extern int in_trap_handler;
+unsigned int hz_ticks;
+
+void
+handle_exception (unsigned long *registers)
+{
+ int trap = (registers[TBR] >> 4) & 0xff;
+
+ if (trap != 9 && trap != 28 && !(nofault & NOFAULT_QUIET))
+ {
+ printf ("Trap %d: (in: %d)\n"
+ "psr = 0x%x, tbr = 0x%x, pc = 0x%x, npc = 0x%x\n",
+ trap, in_trap_handler,
+ registers[PSR], registers[TBR], registers[PC], registers[NPC]);
+ printf ("sp = %x fp = %x\n",
+ registers[SP], registers[FP]);
+ printf ("MMCR = %x, FCR = %x, FVAR = %x, PDBA = %x\n",
+ registers[MMCR], registers[FCR],
+ registers[FVAR], registers[PDBA]);
+ printf ("FPAR = %x, FTOR = %x, FES = %x, FTSR = %x\n",
+ registers[FPAR], registers[FTOR],
+ registers[FES], registers[FTSR]);
+ printf ("DIR: %x, IPR: %x, IRC: %x, IXR: %x, IXC: %x\n",
+ lduba (ASI_DIR, 0) & SIC_DIR_MASK,
+ lda (ASI_IPR, 0) & SIC_IPR_MASK,
+ lduba (ASI_IRXC, 0) & 0x3,
+ lda (ASI_IXR, 0) & 0xffff,
+ lduba (ASI_ITXC, 0) & 0x3);
+ }
+
+ if (trap == 9 && (nofault & NOFAULT_CONTINUE))
+ {
+ nofault = 0;
+ registers[PC] = registers[NPC];
+ registers[NPC] += 4;
+ }
+ else if (trap == 28)
+ {
+ int ipv;
+
+ ipv = lda (ASI_ACK_IPV, 0) & 0xffff;
+
+#if 1
+ if ((ipv & SIC_IPV_IVL) >> 8 != 141)
+ printf ("interrupt: vector: %d, info: %x, IRXC: %x\n",
+ (ipv & SIC_IPV_IVL) >> 8,
+ ipv & 0xff,
+ lduba (ASI_IRXC, 0) & 0x3);
+#endif
+ stba (ASI_IRXC, 0, SIC_IRC_E);
+
+ switch ((ipv & SIC_IPV_IVL) >> 8)
+ {
+ case 137:
+ zs_intr ();
+ break;
+ case 135:
+ le_intr ();
+ break;
+ case 141:
+ hz_ticks++;
+ break;
+ default:
+ printf ("No handler for %d\n", ipv >> 8);
+ }
+ }
+ else
+ _exit (1);
+}
diff --git a/sys/arch/kbus/stand/sk/main.c b/sys/arch/kbus/stand/sk/main.c
new file mode 100644
index 00000000000..0a6b59920b5
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/main.c
@@ -0,0 +1,4 @@
+main (int argc, char *argv[])
+{
+ do_cmd (argv[1]);
+}
diff --git a/sys/arch/kbus/stand/sk/panic.c b/sys/arch/kbus/stand/sk/panic.c
new file mode 100644
index 00000000000..3d7a2cbf58b
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/panic.c
@@ -0,0 +1,16 @@
+
+#include <stdarg.h>
+#include "stand.h"
+
+__dead void
+panic(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ printf(fmt, ap);
+ printf("\n");
+ va_end(ap);
+ _exit ();
+}
+
diff --git a/sys/arch/kbus/stand/sk/probe.c b/sys/arch/kbus/stand/sk/probe.c
new file mode 100644
index 00000000000..8b6392dfd6d
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/probe.c
@@ -0,0 +1,235 @@
+#include <sys/types.h>
+#include <machine/kbus.h>
+#include "idprom.h"
+#include "eeprom.h"
+#include "prom.h"
+
+int
+disp_prom_string (unsigned char *ptr, int maxlen)
+{
+ int i;
+ char c;
+
+ for (i = 0; i < maxlen; i++)
+ {
+ c = ptr[i * ID_BYTE_OFFSET];
+ if (c == 0)
+ return i + 1;
+ putchar (c);
+ }
+ return maxlen;
+}
+
+void
+probe_kbus (void)
+{
+ unsigned char *pa;
+ unsigned char *va;
+ unsigned char *p;
+ unsigned char c;
+ unsigned char id;
+ unsigned int offset;
+ unsigned int size;
+ unsigned int nbr_bytes_read;
+ int i, j;
+
+ for (i = 1; i < 8; i++)
+ {
+ printf ("Slot %d: ", i);
+ pa = (char *)MK_IOADDR (SPACE_ID, i, 0);
+ va = (unsigned char *) alloc_page ((daddr_t) pa, PG_IO | PG_V);
+ again:
+ nofault = NOFAULT_QUIET | NOFAULT_CONTINUE;
+ id = va[0];
+ if (nofault == 0)
+ {
+ printf ("-\n");
+ continue;
+ }
+ printf ("id: 0x%02x -%c-", id, id & ID_MASK);
+#if 0
+ for (j = 1; j < 8; j++)
+ {
+ nofault = NOFAULT_QUIET | NOFAULT_CONTINUE;
+ c = va[j];
+ if (nofault != 0)
+ printf (", [%d] = 0x%02x", j, c);
+ }
+#endif
+
+ printf (" Minor: %d, rev: %c%c",
+ va[ID_OFF_MINOR], va[ID_OFF_REVLEV1], va[ID_OFF_REVLEV2]);
+ offset = ID_4BYTES_TO_LONG (va[ID_OFF_OFFSET1], va[ID_OFF_OFFSET2],
+ va[ID_OFF_OFFSET3], va[ID_OFF_OFFSET4]);
+ size = ID_4BYTES_TO_LONG (va[ID_OFF_SIZE1], va[ID_OFF_SIZE2],
+ va[ID_OFF_SIZE3], va[ID_OFF_SIZE4]);
+ printf (" offset: %ld, size: %ld", offset, size);
+ nbr_bytes_read = 13;
+ putchar (' ');
+ nbr_bytes_read += disp_prom_string (va + ID_OFF_STRING,
+ ID_MAX_STRING_SIZE);
+ p = va + nbr_bytes_read * ID_BYTE_OFFSET;
+ printf ("\n");
+ if (nbr_bytes_read == size)
+ printf ("All bytes read\n");
+ else
+ {
+ printf ("%d bytes to read\n", size - nbr_bytes_read);
+ switch (id & ID_MASK)
+ {
+ case ID_MEMORY_BOARD:
+ printf ("Size: %d Mb\n", *p);
+ break;
+ case ID_SYSTEM_BOARD + 1:
+ printf ("Hostid: %lx\n",
+ ID_4BYTES_TO_LONG (p[ID_S_OFF_HOSTID1],
+ p[ID_S_OFF_HOSTID2],
+ p[ID_S_OFF_HOSTID3],
+ p[ID_S_OFF_HOSTID4]));
+ printf ("Serial: ");
+ disp_prom_string (p + ID_S_OFF_SERIAL, ID_S_SERIAL_SIZE);
+ printf ("\nEnet addr: %x:%x:%x:%x:%x:%x\n",
+ p[ID_S_OFF_ENETADDR],
+ p[ID_S_OFF_ENETADDR + 1 * ID_BYTE_OFFSET],
+ p[ID_S_OFF_ENETADDR + 2 * ID_BYTE_OFFSET],
+ p[ID_S_OFF_ENETADDR + 3 * ID_BYTE_OFFSET],
+ p[ID_S_OFF_ENETADDR + 4 * ID_BYTE_OFFSET],
+ p[ID_S_OFF_ENETADDR + 5 * ID_BYTE_OFFSET]);
+ printf ("mfg date: ");
+ disp_prom_string (p + ID_S_OFF_MFGDATE, ID_S_MFGDATE_SIZE);
+ printf ("Oem flag: 0x%02x\n",
+ p[ID_S_OFF_OEM_FLAG]);
+ printf ("Banner: ");
+ disp_prom_string (p + ID_S_OFF_BANNER, ID_S_BANNER_SIZE);
+ printf ("\nCopyright: ");
+ disp_prom_string (p + ID_S_OFF_COPYRIGHT, ID_S_COPYRIGHT_SIZE);
+ printf ("\nLogo:\n");
+ for (j = 0; j < ID_S_LOGOBITMAP_SIZE; j++)
+ {
+ int k;
+ c = p[ID_S_OFF_LOGOBITMAP + j * ID_BYTE_OFFSET];
+ for (k = 0; k < 8; k++)
+ {
+ putchar ((c & 0x80) ? '*': ' ');
+ c <<= 1;
+ }
+ if ((j & 7) == 7)
+ putchar ('\n');
+ }
+ break;
+ case ID_GRAPHIC_BOARD:
+ {
+ int nbr_res = p[ID_G_OFF_RES_COUNT];
+ int k;
+
+ printf ("Type: %d, nbr of plane: %d, access size: %d, "
+ "nbr of resolutions: %d\n",
+ p[ID_G_OFF_TYPE], p[ID_G_OFF_NBR_PLANE],
+ p[ID_G_OFF_ACCESS_SIZE], nbr_res);
+ p += ID_G_OFF_FB_SIZES;
+ for (k = 0; k < nbr_res; k++)
+ {
+ printf ("Res %d: %dx%d, xoff: %d, "
+ "fb_size: 0x%08x, itbl: 0x%08x, font: 0x%08x\n",
+ k,
+ ID_2BYTES_TO_SHORT (p[ID_G_OFF_X_RES1],
+ p[ID_G_OFF_X_RES2]),
+ ID_2BYTES_TO_SHORT (p[ID_G_OFF_Y_RES1],
+ p[ID_G_OFF_Y_RES2]),
+ ID_2BYTES_TO_SHORT (p[ID_G_OFF_XOFFSET1],
+ p[ID_G_OFF_XOFFSET2]),
+ ID_4BYTES_TO_LONG (p[ID_G_OFF_FB_SIZE1],
+ p[ID_G_OFF_FB_SIZE2],
+ p[ID_G_OFF_FB_SIZE3],
+ p[ID_G_OFF_FB_SIZE4]),
+ ID_4BYTES_TO_LONG (p[ID_G_OFF_ITBL_OFF1],
+ p[ID_G_OFF_ITBL_OFF2],
+ p[ID_G_OFF_ITBL_OFF3],
+ p[ID_G_OFF_ITBL_OFF4]),
+ ID_4BYTES_TO_LONG (p[ID_G_OFF_FONT_OFF1],
+ p[ID_G_OFF_FONT_OFF2],
+ p[ID_G_OFF_FONT_OFF3],
+ p[ID_G_OFF_FONT_OFF4]));
+ p += ID_G_SIZE_FB_SIZES;
+ }
+ printf ("White value: 0x%08x, Black value: 0x%08x, "
+ "fb offset: 0x%08x, kb offset: 0x%08x\n",
+ ID_4BYTES_TO_LONG (p[ID_G_OFF_WHITE_OFF1],
+ p[ID_G_OFF_WHITE_OFF2],
+ p[ID_G_OFF_WHITE_OFF3],
+ p[ID_G_OFF_WHITE_OFF4]),
+ ID_4BYTES_TO_LONG (p[ID_G_OFF_BLACK_OFF1],
+ p[ID_G_OFF_BLACK_OFF2],
+ p[ID_G_OFF_BLACK_OFF3],
+ p[ID_G_OFF_BLACK_OFF4]),
+ ID_4BYTES_TO_LONG (p[ID_G_OFF_FB_OFF1],
+ p[ID_G_OFF_FB_OFF2],
+ p[ID_G_OFF_FB_OFF3],
+ p[ID_G_OFF_FB_OFF4]),
+ ID_4BYTES_TO_LONG (p[ID_G_OFF_KB_OFF1],
+ p[ID_G_OFF_KB_OFF2],
+ p[ID_G_OFF_KB_OFF3],
+ p[ID_G_OFF_KB_OFF4]));
+ }
+ break;
+ }
+ }
+ if (offset != 0)
+ {
+ printf ("Slot %d: ", i);
+ va += offset;
+ goto again;
+ }
+ }
+}
+
+void
+disp_eeprom (void)
+{
+ unsigned char *va;
+ unsigned char ch[16];
+ int i, j;
+
+ va = (unsigned char *) alloc_page ((daddr_t) 0x17002000, PG_IO | PG_V);
+
+ printf ("Model: ");
+ disp_prom_string (va + EEPROM_OFF_MODEL, EEPROM_SIZE_MODEL);
+ printf ("\n");
+ for (i = 0; i < EEPROM_SIZE; i += 16)
+ {
+ printf ("%03x: ", i);
+ for (j = 0; j < 16; j++)
+ {
+ ch[j] = va[(i + j) * EEPROM_BYTE_OFFSET];
+ printf ("%02x%c", ch[j], j == 7 ? '-' : ' ');
+ }
+ for (j = 0; j < 16; j++)
+ putchar ((ch[j] < 32 || ch[j] > 127) ? '.' : ch[j]);
+ putchar ('\n');
+ }
+}
+
+#define ROM_VECTORS 0xff000000
+void
+disp_prom (void)
+{
+ unsigned long *addr;
+ int i;
+ struct prom_command_area *ca;
+
+ printf ("version: %s\n", *(unsigned long *)ROM_VERSION);
+ printf ("DGRAM version: 0x%08x\n", *(unsigned long *)ROM_DGRAM);
+ printf ("EE version: 0x%08x\n", *(unsigned long *)ROM_EEVERSION);
+ printf ("ROM version: 0x%08x\n", *(unsigned long *)ROM_REVISION);
+ ca = *(struct prom_command_area **) ROM_COMM_AREA;
+ printf ("first_free: 0x%08x\n", ca->first_free);
+ printf ("memsize: %d Mb\n", ca->memsize);
+ printf ("ramdisk: 0x%08x\n", ca->ramdisk);
+ printf ("iomap_addr: 0x%08x\n", ca->iomap_addr);
+ printf ("row: %d, col: %d\n", ca->row, ca->col);
+ printf ("silent: %d\n", ca->silent);
+ addr = (unsigned long *)ca->iomap_addr;
+ for (i = 0; i < 10; i++)
+ printf ("%d: 0x%08x\n", i, addr[i]);
+
+}
diff --git a/sys/arch/kbus/stand/sk/prom.h b/sys/arch/kbus/stand/sk/prom.h
new file mode 100644
index 00000000000..b39cfe32d6c
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/prom.h
@@ -0,0 +1,24 @@
+#define ROM_VECTORS 0xff000000
+
+#define ROM_VERSION (ROM_VECTORS + 0)
+#define ROM_COMM_AREA (ROM_VECTORS + 8)
+#define ROM_COMMAND (ROM_VECTORS + 16)
+#define ROM_SLAVEHALT (ROM_VECTORS + 24)
+#define ROM_MSGBUFP (ROM_VECTORS + 32)
+#define ROM_DGRAM (ROM_VECTORS + 40)
+#define ROM_EEVERSION (ROM_VECTORS + 48)
+#define ROM_REVISION (ROM_VECTORS + 56)
+
+struct prom_command_area
+{
+ char *command_ptr;
+ int ret_val;
+ int first_free;
+ int memsize;
+ int ramdisk;
+ char *iomap_addr;
+ int (*slave_start)();
+ int row;
+ int col;
+ int silent;
+};
diff --git a/sys/arch/kbus/stand/sk/promboot.c b/sys/arch/kbus/stand/sk/promboot.c
new file mode 100644
index 00000000000..f1dde276802
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/promboot.c
@@ -0,0 +1,95 @@
+/* $Id: promboot.c,v 1.1 1997/10/14 07:25:31 gingold Exp $ */
+
+/*
+ * Copyright (c) 1995 Theo de Raadt
+ * 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 Theo de Raadt
+ * 4. The name of the Author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+#include <sys/param.h>
+#include <sys/reboot.h>
+#include "stand.h"
+#include "promboot.h"
+
+char prom_bootdev[32];
+char prom_bootfile[32];
+int prom_boothow;
+int debug;
+
+void
+prom_get_boot_info()
+{
+#if 0
+ char c, *src, *dst;
+ extern int devlun, ctrlun;
+ extern char *oparg, *opargend;
+
+#ifdef DEBUG
+ printf("prom_get_boot_info\n");
+#endif
+
+ /* Get kernel filename */
+ src = oparg;
+ while (src && (*src == ' ' || *src == '\t'))
+ src++;
+
+ dst = prom_bootfile;
+ if (src && *src != '-') {
+ while (src && *src) {
+ if (*src == ' ' || *src == '\t')
+ break;
+ *dst++ = *src++;
+ }
+ }
+ *dst = '\0';
+
+ /* Get boothowto flags */
+ while (src && (*src == ' ' || *src == '\t'))
+ src++;
+ if (src && (*src == '-')) {
+ while (*src) {
+ switch (*src++) {
+ case 'a':
+ prom_boothow |= RB_ASKNAME;
+ break;
+ case 's':
+ prom_boothow |= RB_SINGLE;
+ break;
+ case 'd':
+ prom_boothow |= RB_KDB;
+ debug = 1;
+ break;
+ }
+ }
+ }
+#ifdef DEBUG
+ printf("promboot: device=\"%s\" file=\"%s\" how=0x%x\n",
+ prom_bootdev, prom_bootfile, prom_boothow);
+#endif
+#endif
+}
diff --git a/sys/arch/kbus/stand/sk/promboot.h b/sys/arch/kbus/stand/sk/promboot.h
new file mode 100644
index 00000000000..86b5aace21c
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/promboot.h
@@ -0,0 +1,5 @@
+
+extern char prom_bootdev[];
+extern char prom_bootfile[];
+extern int prom_boothow;
+
diff --git a/sys/arch/kbus/stand/sk/promcons.c b/sys/arch/kbus/stand/sk/promcons.c
new file mode 100644
index 00000000000..6bc8cf473a2
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/promcons.c
@@ -0,0 +1,71 @@
+/* $Id: promcons.c,v 1.1 1997/10/14 07:25:32 gingold Exp $ */
+
+/*
+ * Copyright (c) 1996 Nivas Madhur
+ * Copyright (c) 1995 Theo de Raadt
+ * 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 Theo de Raadt
+ * 4. The name of the Author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+#include <stdarg.h>
+#include <sys/types.h>
+
+int
+getchar()
+{
+ char c;
+
+ __asm volatile("or r9, r0, 0\n
+ tb0 0, r0, 496\n
+ st.b r2, %0" : "=m" (c));
+ return (c);
+}
+
+peekchar()
+{
+ int have = 0;
+
+ __asm volatile("or r9, r0, 1\n
+ tb0 0, r0, 496\n
+ bb1 2, r2, 1f\n
+ or r2,r0, 1\n
+ st r2, %0\n1:" : "=m" (have) :);
+ return (have);
+}
+
+void
+putchar(c)
+ int c;
+{
+ if (c == '\n')
+ putchar('\r');
+ __asm volatile("or r9, r0, 0x20\n
+ or r2, r0, %0\n
+ tb0 0, r0, 496\n" : : "r" (c));
+}
+
diff --git a/sys/arch/kbus/stand/sk/version.c b/sys/arch/kbus/stand/sk/version.c
new file mode 100644
index 00000000000..2954c683589
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/version.c
@@ -0,0 +1,9 @@
+/* $Id: version.c,v 1.1 1997/10/14 07:25:32 gingold Exp $ */
+
+/*
+ * NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.
+ *
+ * 1.1
+ */
+
+char version[] = "$Revision: 1.1 $";
diff --git a/sys/arch/kbus/stand/sk/zs.c b/sys/arch/kbus/stand/sk/zs.c
new file mode 100644
index 00000000000..4e1eae5dffb
--- /dev/null
+++ b/sys/arch/kbus/stand/sk/zs.c
@@ -0,0 +1,218 @@
+#include <dev/ic/z8530reg.h>
+#include <machine/prom.h>
+#include <machine/asm.h>
+
+void udelay (unsigned long usec);
+
+static unsigned char *zs0_a = (unsigned char *) 0x17012020;
+static unsigned char *zs0_b = (unsigned char *) 0x17012000;
+static unsigned char *zs_ms = (unsigned char *) 0x17011020;
+static unsigned char *zs_kb = (unsigned char *) 0x17011000;
+
+void
+zs_reg_write (unsigned char *zs_addr, unsigned char reg, unsigned char val)
+{
+ *zs_addr = reg;
+ udelay (2);
+ *zs_addr = val;
+}
+
+unsigned char
+zs_reg_read (unsigned char *zs_addr, unsigned char reg)
+{
+ *zs_addr = reg;
+ udelay (2);
+ return *zs_addr;
+}
+
+void
+zs0_putc (char c)
+{
+ unsigned char r0;
+
+ /* Wait until Tx is free. */
+ do
+ {
+ *zs0_a = 0;
+ udelay (2);
+ }
+ while ((*zs0_a & ZSRR0_TX_READY) == 0);
+
+ /* Write the character. */
+ zs0_a[0x10] = c;
+ udelay (2);
+
+ /* Wait until transmission. */
+ do
+ {
+ *zs0_a = 0;
+ udelay (2);
+ }
+ while ((*zs0_a & ZSRR0_TX_READY) == 0);
+}
+
+void
+putchar (char c)
+{
+ if (c == '\n')
+ zs0_putc ('\r');
+ zs0_putc (c);
+}
+
+int
+getchar (void)
+{
+ unsigned char r0;
+
+ /* Wait until Rx is free. */
+ do
+ {
+ *zs0_a = 0;
+ udelay (2);
+ }
+ while ((*zs0_a & ZSRR0_RX_READY) == 0);
+
+ /* Read the character. */
+ return zs0_a[0x10];
+}
+
+void
+udelay (unsigned long usec)
+{
+ register int i;
+
+ while (usec--)
+ for (i = 20; i; i--)
+ ;
+}
+
+
+static void
+zs_loadreg (char *zsc, char *reg)
+{
+ /* Reset int. */
+ zs_reg_write (zsc, 0, ZSM_RESET_STINT);
+ zs_reg_write (zsc, 0, ZSM_RESET_TXINT);
+ zs_reg_write (zsc, 0, ZSM_RESET_ERR);
+ zs_reg_write (zsc, 0, ZSM_RESET_IUS);
+
+ /* Set vector. */
+ zs_reg_write (zsc, 2, reg[2]);
+
+ zs_reg_write (zsc, 3, reg[3] & ~ZSWR3_RX_ENABLE);
+
+ zs_reg_write (zsc, 4, reg[4]);
+
+ zs_reg_write (zsc, 5, reg[5] & ~ZSWR5_TX_ENABLE);
+
+ zs_reg_write (zsc, 9, reg[9]);
+
+ zs_reg_write (zsc, 10, reg[10]);
+
+ zs_reg_write (zsc, 11, reg[11]);
+ zs_reg_write (zsc, 12, reg[12]);
+ zs_reg_write (zsc, 13, reg[13]);
+ zs_reg_write (zsc, 14, reg[14]);
+ zs_reg_write (zsc, 15, reg[15]);
+
+ zs_reg_write (zsc, 3, reg[3]);
+ zs_reg_write (zsc, 5, reg[5]);
+ zs_reg_write (zsc, 1, reg[1]);
+}
+
+void
+set_zs (char *zsc)
+{
+ static char regs[16]=
+ {
+ 0, /* 0 */
+ /* ZSWR1_RIE | */ ZSWR1_SIE,
+ 64, /* Vector. */
+ ZSWR3_RX_8 | ZSWR3_RX_ENABLE,
+ ZSWR4_CLK_X16 | ZSWR4_ONESB,
+ ZSWR5_TX_8 | ZSWR5_TX_ENABLE,
+ 0,
+ 0,
+ 0,
+ ZSWR9_MASTER_IE, /* 9 */
+ 0,
+ ZSWR11_RXCLK_BAUD | ZSWR11_TXCLK_BAUD,
+ 10, /* 12: baud rate. */
+ 0,
+ ZSWR14_BAUD_FROM_PCLK | ZSWR14_BAUD_ENA,
+ ZSWR15_BREAK_IE
+ };
+ zs_loadreg (zsc, regs);
+ zs_reg_write (zsc, 0, ZSWR0_CLR_INTR);
+}
+
+void
+set_kbd_zs (char *zsc)
+{
+ static char regs[16]=
+ {
+ 0, /* 0 */
+ 0, /* ZSWR1_RIE | ZSWR1_SIE, */
+ 64, /* Vector. */
+ ZSWR3_RX_8 | ZSWR3_RX_ENABLE,
+ ZSWR4_CLK_X1 | ZSWR4_ONESB | ZSWR4_PARENB,
+ ZSWR5_TX_8 | ZSWR5_TX_ENABLE,
+ 0,
+ 0,
+ 0,
+ ZSWR9_MASTER_IE, /* 9 */
+ 0,
+ ZSWR11_RXCLK_RTXC | ZSWR11_TXCLK_RTXC
+ | ZSWR11_TRXC_OUT_ENA | ZSWR11_TRXC_BAUD,
+#ifdef HZ_100
+ /* HZ = 100 */
+ 0xd2, /* 12: baud rate. */
+ 0x30,
+#else
+ /* HZ = 60 */
+ 0x5c,
+ 0x51,
+#endif
+ ZSWR14_BAUD_FROM_PCLK | ZSWR14_BAUD_ENA,
+ 0
+ };
+ zs_loadreg (zsc, regs);
+ zs_reg_write (zsc, 0, ZSWR0_CLR_INTR);
+}
+
+void
+disp_zs0_b (void)
+{
+ int brg;
+
+ set_zs (zs0_a);
+ brg = ((zs_reg_read (zs0_a, 13) & 0xff) << 8)
+ | (zs_reg_read (zs0_a, 12) & 0xff);
+ printf ("brg = %d\n", brg);
+ printf ("clock: %d\n", (brg + 2) * 2 * 9600 * 16);
+}
+
+void
+init_kbd (void)
+{
+ set_kbd_zs (zs_kb);
+}
+
+void
+zs_intr (void)
+{
+ char rr3 = zs_reg_read (zs0_a, 3);
+#if 1
+ printf ("ZS status: 0x%x, pending: 0x%x\n",
+ zs_reg_read (zs0_a, 0), rr3);
+#else
+ putchar ('I');
+#endif
+#if 0
+ /* Ack it. */
+ if (rr3 & ZSRR3_IP_A_RX)
+ printf ("char: 0x%x\n", zs0_a[0x10]);
+#endif
+ zs_reg_write (zs0_a, 0, ZSWR0_RESET_STATUS);
+ zs_reg_write (zs0_a, 0, ZSWR0_CLR_INTR);
+}