Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ao-kenji/6cef238e2b327585225e80ac563af0cf to your computer and use it in GitHub Desktop.
Save ao-kenji/6cef238e2b327585225e80ac563af0cf to your computer and use it in GitHub Desktop.
Experimental code to use RSA-98 serial board on LUNA-88K2
Index: luna88k/cbus/cbus.c
===================================================================
RCS file: /cvs/src/sys/arch/luna88k/cbus/cbus.c,v
diff -u -r1.9 cbus.c
--- luna88k/cbus/cbus.c 11 Mar 2021 11:16:58 -0000 1.9
+++ luna88k/cbus/cbus.c 4 May 2024 07:46:55 -0000
@@ -36,11 +36,16 @@
#define CBUS_DEBUG
#endif
+#include "com_rsa.h"
#include "ne.h"
#include "necsb.h"
#include "pcic.h"
static struct cbus_attach_args cbus_devs[] = {
+#if NCOM_RSA > 0
+ /* I-O DATA RSA-98 serial interface board */
+ { "com", -1, -1, -1, -1, -1 },
+#endif
#if NNE > 0
/* NE-2000 compatible ethernet */
{ "ne", -1, -1, -1, -1, -1 },
@@ -353,7 +358,7 @@
while ((n = ff1(intr_status)) != 32) {
cbus_isrdispatch(6 - n);
*cbus_isreg = (u_int8_t)n;
- intr_status &= ~(1 << n);
+ intr_status &= ~(1 << n);
}
return 1;
Index: luna88k/cbus/com_rsa_cbus.c
===================================================================
RCS file: luna88k/cbus/com_rsa_cbus.c
diff -N luna88k/cbus/com_rsa_cbus.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ luna88k/cbus/com_rsa_cbus.c 4 May 2024 07:46:55 -0000
@@ -0,0 +1,157 @@
+/* $OpenBSD: com_isa.c,v 1.10 2022/04/06 18:59:28 naddy Exp $ */
+/*
+ * Copyright (c) 1997 - 1999, Jason Downs. 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. Neither the name(s) of the author(s) nor the name OpenBSD
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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(S) 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, 1994, 1995, 1996
+ * Charles M. Hannum. All rights reserved.
+ * Copyright (c) 1991 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. 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.
+ *
+ * @(#)com.c 7.5 (Berkeley) 5/16/91
+ */
+
+/* based on src/sys/dev/isa/com_isa.c */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/tty.h>
+#include <sys/device.h>
+
+#include <machine/board.h> /* PC_BASE */
+#include <machine/bus.h>
+
+#include <dev/ic/comreg.h>
+#include <dev/ic/comvar.h>
+
+#include <arch/luna88k/cbus/cbusvar.h>
+
+#define PCEXIO_BASE PC_BASE + 0x1000000
+
+struct luna88k_bus_space_tag com_rsa_cbus_io_bst = {
+ .bs_stride_1 = 1, /* for RSA-98 */
+ .bs_stride_2 = 0,
+ .bs_stride_4 = 0,
+ .bs_stride_8 = 0,
+ .bs_offset = PCEXIO_BASE,
+ .bs_flags = 0 /* not used */
+};
+
+int com_rsa_cbus_match(struct device *, void *, void *);
+void com_rsa_cbus_attach(struct device *, struct device *, void *);
+
+const struct cfattach com_rsa_ca = {
+ sizeof(struct com_softc), com_rsa_cbus_match, com_rsa_cbus_attach,
+ NULL, com_activate
+};
+
+int
+com_rsa_cbus_match(struct device *parent, void *self, void *aux)
+{
+ struct cfdata *cf = self;
+ struct cbus_attach_args *caa = aux;
+ bus_space_handle_t ioh;
+ bus_space_tag_t iot = &com_rsa_cbus_io_bst;
+ bus_size_t iosize;
+ int rv;
+
+ if (strcmp(caa->ca_name, cf->cf_driver->cd_name) != 0)
+ return 0;
+
+ caa->ca_iobase = cf->cf_iobase;
+ caa->ca_int = cf->cf_int;
+
+ /* Disallow wildcarded values. */
+ if ((caa->ca_int == -1) || (caa->ca_iobase == -1))
+ return 0;
+
+ iosize = COM_NPORTS * 2; /* for RSA-98 */
+ if (bus_space_map(iot, caa->ca_iobase, iosize, 0, &ioh))
+ return 0;
+
+ rv = comprobe1(iot, ioh);
+
+ bus_space_unmap(iot, ioh, iosize);
+
+ if (rv == 0)
+ return 0;
+
+ return 1;
+}
+
+void
+com_rsa_cbus_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct com_softc *sc = (struct com_softc *)self;
+ struct cbus_attach_args *caa = aux;
+ bus_space_handle_t ioh;
+ bus_space_tag_t iot;
+ bus_size_t iosize;
+
+ sc->sc_hwflags = 0;
+ sc->sc_swflags = 0;
+
+ iot = &com_rsa_cbus_io_bst;
+ iosize = COM_NPORTS * 2; /* for RSA-98 */
+ if (bus_space_map(iot, caa->ca_iobase, iosize, 0, &ioh))
+ panic("%s: mapping failed", __func__);
+
+ sc->sc_iot = &com_rsa_cbus_io_bst;
+ sc->sc_ioh = ioh;
+ sc->sc_iobase = caa->ca_iobase; /* XXX: may not used in com.c */
+ sc->sc_frequency = COM_FREQ * 8; /* for RSA-98: 14.7456MHz */
+
+ com_attach_subr(sc);
+
+ if (cbus_isrlink(comintr, sc, caa->ca_int, IPL_NET,
+ sc->sc_dev.dv_xname) != 0)
+ printf(":couldn't establish interrupt handler\n");
+}
Index: luna88k/conf/OSCDEMO.MP
===================================================================
RCS file: luna88k/conf/OSCDEMO.MP
diff -N luna88k/conf/OSCDEMO.MP
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ luna88k/conf/OSCDEMO.MP 4 May 2024 07:46:55 -0000
@@ -0,0 +1,105 @@
+# $OpenBSD: GENERIC,v 1.24 2019/12/30 12:16:12 aoyama Exp $
+#
+# For further information on compiling OpenBSD kernels, see the config(8)
+# man page.
+#
+# For further information on hardware support for this architecture, see
+# the intro(4) man page. For further information about kernel options
+# for this architecture, see the options(4) man page. For an explanation
+# of each device driver in this file see the section 4 man page for the
+# device.
+
+machine luna88k m88k
+include "../../../conf/GENERIC"
+maxusers 64 # estimated number of users
+
+# Processor type
+option M88100 # 88100 support; mandatory
+
+# Number of maximum processors
+option MAX_CPUS=4 # may have up to 4 processors
+
+# Define this if your processor has the xxx.usr bug (mask C82N)
+option ERRATA__XXX_USR
+
+# Options for luna88k hardware
+option WSDISPLAY_COMPAT_RAWKBD # Provide raw scancodes; needed for X11
+
+config bsd swap generic
+
+#
+# devices
+#
+
+mainbus0 at root
+clock0 at mainbus0
+lcd0 at mainbus0
+le0 at mainbus0
+sio0 at mainbus0
+siotty0 at sio0
+ws0 at sio0
+fb0 at mainbus0
+spc0 at mainbus0
+spc1 at mainbus0
+
+# Workstation Console attachments
+wsdisplay* at fb?
+wskbd* at ws? mux 1
+wsmouse* at ws? mux 0
+
+# HD647180X I/O processor
+xp0 at mainbus0
+
+# PC-9801 extension board slot
+cbus0 at mainbus0
+
+# PC-9801 extension board slot 'generic' driver
+pcex0 at cbus0
+
+# NE2000 ethernet
+ne0 at cbus0 port 0xc8d0 int 0 # CentreCOM LA-98
+
+# PC-9801 extended serial boards
+com* at cbus0 port 0x50e0 int 1 # I-O DATA RSA-98
+#com* at cbus0 port 0x50e1 int 1 # I-O DATA RSA-98
+
+# NEC PC-9801-86 sound board
+#necsb* at cbus?
+#audio* at necsb?
+
+# NEC PC-9801-102 & PC-9821X[AE]-E01 PC Card slot adapter
+#pcic0 at cbus? port 0x3e0 iomem 0xd0000 iosiz 0x10000
+#pcmcia* at pcic?
+
+# SCSI devices
+scsibus* at scsi?
+sd* at scsibus?
+st* at scsibus?
+cd* at scsibus?
+ch* at scsibus?
+safte* at scsibus?
+ses* at scsibus?
+uk* at scsibus?
+
+# Pseudo-device
+pseudo-device wsmux 2
+
+# PCMCIA devices
+# XXX: malo(4) is not supported, because LUNA-88K does not have DMA.
+#com* at pcmcia? # PCMCIA modems/serial ports
+##aic* at pcmcia? # PCMCIA Adaptec 152[02] SCSI (not yet)
+#wdc* at pcmcia? # IDE controllers
+#ne* at pcmcia? # PCMCIA based NE2000 ethernet
+#ep* at pcmcia? # PCMCIA based 3C5xx ethernet
+#sm* at pcmcia? # PCMCIA based sm ethernet
+#xe* at pcmcia? # Xircom ethernet
+#wi* at pcmcia? # WaveLAN IEEE 802.11DS
+#an* at pcmcia? # Aironet IEEE 802.11DS
+
+# IDE/ATAPI (with PCMCIA)
+#wd* at wdc? flags 0x0000
+#atapiscsi* at wdc?
+
+option MULTIPROCESSOR
+#option MP_LOCKDEBUG
+
Index: luna88k/conf/files.luna88k
===================================================================
RCS file: /cvs/src/sys/arch/luna88k/conf/files.luna88k,v
diff -u -r1.34 files.luna88k
--- luna88k/conf/files.luna88k 8 Oct 2023 10:40:23 -0000 1.34
+++ luna88k/conf/files.luna88k 4 May 2024 07:46:55 -0000
@@ -76,6 +76,10 @@
attach ne at cbus with ne_cbus: rtl80x9
file arch/luna88k/cbus/if_ne_cbus.c ne needs-flag
+# Serial (IO DATA RSA-98)
+attach com at cbus with com_rsa
+file arch/luna88k/cbus/com_rsa_cbus.c com_rsa needs-flag
+
# NEC PC-9801-86 sound board
device necsb: audio
attach necsb at cbus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment