[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pbsd-mg2] com0 attach code
練習がてら作ってみた com0 を attachするコードを流します。
コンソール上は attachでいているように見えているのですが
実際に使ってはいないので動くかどうかはわかりません。
その程度ですが、参考までに流しておきます。
com_vrip.c では CMUをいじるためのコードを書いていますが、
これは別のところにわけるべきでしょうね。
# KIUであそべるようにしないと..
takesi(佐々木毅史)
----------------------------------------------------------------
Index: hpcmips/sys/arch/hpcmips/conf/GENERIC
diff -u hpcmips/sys/arch/hpcmips/conf/GENERIC:1.7 hpcmips/sys/arch/hpcmips/conf/GENERIC:1.7.2.1
--- hpcmips/sys/arch/hpcmips/conf/GENERIC:1.7 Sun Apr 4 21:39:15 1999
+++ hpcmips/sys/arch/hpcmips/conf/GENERIC Thu Apr 8 22:02:57 1999
@@ -91,6 +91,8 @@
vrbcu* at vrip?
#pcic* at vrip? addr 0x150003e0 addr2 0x10070000 size2 0x4000 intr 4
pcic* at vrip? addr 0x150003e0 addr2 0x10070000 size2 0x4000 intr 8
+com* at vrip? addr 0x0C000000 intr 9
+options __NO_SOFT_SERIAL_INTERRUPT
# PCMCIA bus support
pcmcia* at pcic? controller ? socket ?
Index: hpcmips/sys/arch/hpcmips/conf/files.hpcmips
diff -u hpcmips/sys/arch/hpcmips/conf/files.hpcmips:1.6 hpcmips/sys/arch/hpcmips/conf/files.hpcmips:1.6.2.1
--- hpcmips/sys/arch/hpcmips/conf/files.hpcmips:1.6 Sun Apr 4 21:39:15 1999
+++ hpcmips/sys/arch/hpcmips/conf/files.hpcmips Thu Apr 8 22:02:58 1999
@@ -117,3 +117,8 @@
# PCMCIA IDE controller
attach wdc at pcmcia with wdc_pcmcia
file dev/pcmcia/wdc_pcmcia.c wdc_pcmcia
+
+
+# Serial Interface Unit
+attach com at vrip with com_vrip
+file arch/hpcmips/vr/com_vrip.c com_vrip
Index: hpcmips/sys/arch/hpcmips/include/intr.h
diff -u hpcmips/sys/arch/hpcmips/include/intr.h:1.1 hpcmips/sys/arch/hpcmips/include/intr.h:1.1.2.1
--- hpcmips/sys/arch/hpcmips/include/intr.h:1.1 Thu Feb 11 20:37:19 1999
+++ hpcmips/sys/arch/hpcmips/include/intr.h Thu Apr 8 22:03:08 1999
@@ -30,8 +30,8 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _PMAX_INTR_H_
-#define _PMAX_INTR_H_
+#ifndef _HPCMIPS_INTR_H_
+#define _HPCMIPS_INTR_H_
#define IPL_NONE 0 /* disable only this interrupt */
#define IPL_BIO 1 /* disable block I/O interrupts */
@@ -39,7 +39,9 @@
#define IPL_TTY 3 /* disable terminal interrupts */
#define IPL_CLOCK 4 /* disable clock interrupts */
#define IPL_STATCLOCK 5 /* disable profiling interrupts */
-#define IPL_SERIAL 6 /* disable serial hardware interrupts */
+#if 0
+#define IPL_SERIAL 6 /* disable serial hardware interrupts */
+#endif
#define IPL_DMA 7 /* disable DMA reload interrupts */
#define IPL_HIGH 8 /* disable all interrupts */
@@ -97,4 +99,4 @@
#endif /* !_LOCORE */
#endif /* _KERNEL */
-#endif /* !_PMAX_INTR_H_ */
+#endif /* !_HPCMIPS_INTR_H_ */
Index: hpcmips/sys/arch/hpcmips/vr/com_vrip.c
diff -u /dev/null hpcmips/sys/arch/hpcmips/vr/com_vrip.c:1.1.2.1
--- /dev/null Mon Apr 12 18:49:53 1999
+++ hpcmips/sys/arch/hpcmips/vr/com_vrip.c Thu Apr 8 22:03:13 1999
@@ -0,0 +1,175 @@
+/* $Id: com_vrip.c,v 1.1.2.1 1999/04/08 13:03:13 takesi Exp $ */
+
+/*
+ * Copyright (c) 1999 SASAKI Takesi.
+ * Copyright (c) 1999 PocketBSD Project. All rights reserved.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/ioctl.h>
+#include <sys/termios.h>
+#include <sys/select.h>
+#include <sys/tty.h>
+#include <sys/proc.h>
+#include <sys/user.h>
+#include <sys/conf.h>
+#include <sys/file.h>
+#include <sys/uio.h>
+#include <sys/kernel.h>
+#include <sys/syslog.h>
+#include <sys/types.h>
+#include <sys/device.h>
+#include <sys/reboot.h>
+
+#include <machine/autoconf.h>
+#include <machine/intr.h>
+#include <machine/bus.h>
+
+#include <hpcmips/vr/vr.h>
+#include <hpcmips/vr/vripvar.h>
+#include <hpcmips/vr/cmureg.h>
+
+#include <dev/ic/comvar.h>
+#include <dev/ic/comreg.h>
+
+#ifdef COMVRIPDEBUG
+int com_vrip_debug = 0;
+#define DPRINTF(arg) if (com_vrip_debug) printf arg;
+#else
+#define DPRINTF(arg)
+#endif
+
+struct com_vrip_softc {
+ struct com_softc sc_com;
+};
+
+static int com_vrip_probe __P((struct device *, struct cfdata *, void *));
+static void com_vrip_attach __P((struct device *, struct device *, void *));
+
+void vrcmu_init __P((void));
+void vrcmu_supply __P((int));
+void vrcmu_mask __P((int));
+
+struct cfattach com_vrip_ca = {
+ sizeof(struct com_vrip_softc), com_vrip_probe, com_vrip_attach
+};
+
+/* XXX: CMU should be a device or a part of vrip. */
+static bus_space_tag_t vrcmu_iot = 0;
+static bus_space_handle_t vrcmu_ioh = 0;
+
+void
+vrcmu_init()
+{
+ bus_space_map(vrcmu_iot, 0x0b000060, 1, 0, &vrcmu_ioh);
+}
+
+void
+vrcmu_supply(mask)
+ int mask;
+{
+ int r;
+
+ if (vrcmu_ioh == 0) vrcmu_init();
+
+ r = bus_space_read_2(vrcmu_iot, vrcmu_ioh, 0);
+ bus_space_write_2(vrcmu_iot, vrcmu_ioh, 0, r | mask);
+}
+
+void
+vrcmu_mask(mask)
+ int mask;
+{
+ int r;
+
+ if (vrcmu_ioh == 0) vrcmu_init();
+
+ r = bus_space_read_2(vrcmu_iot, vrcmu_ioh, 0);
+ bus_space_write_2(vrcmu_iot, vrcmu_ioh, 0, r & ~mask);
+}
+
+static int
+com_vrip_probe(parent, cf, aux)
+ struct device *parent;
+ struct cfdata *cf;
+ void *aux;
+{
+ struct vrip_attach_args *va = aux;
+ bus_space_tag_t iot = va->va_iot;
+ bus_space_handle_t ioh;
+ int rv;
+
+ DPRINTF(("==com_vrip_probe"));
+
+ if (va->va_addr == VRIPCF_ADDR_DEFAULT ||
+ va->va_intr == VRIPCF_INTR_DEFAULT) {
+ printf(": need addr and intr.\n");
+ return (0);
+ }
+
+ if (strcmp(parent->dv_cfdata->cf_driver->cd_name, "vrip") != 0)
+ return 0;
+
+ if (strcmp("com", va->va_name) != 0)
+ return 0;
+
+ if (bus_space_map(iot, va->va_addr, 1, 0, &ioh)) {
+ printf(": can't map i/o space\n");
+ return 0;
+ }
+ vrcmu_supply(CMUMSKSSIU | CMUMSKSIU);
+
+ rv = comprobe1(iot, ioh);
+ DPRINTF((rv ? ": found COM ports\n" : ": can't probe COM device\n"));
+ bus_space_unmap(iot, ioh, 1);
+
+ if (rv) {
+ va->va_size = COM_NPORTS;
+ }
+ return (rv);
+}
+
+static void
+com_vrip_intr(void *ctx, vrip_intr_mask_t mask, unsigned pc, unsigned status)
+{
+ struct com_vrip_softc *vsc = ctx;
+ comintr(&vsc->sc_com);
+}
+
+static void
+com_vrip_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct com_vrip_softc *vsc = (void *) self;
+ struct com_softc *sc = &vsc->sc_com;
+ struct vrip_attach_args *va = aux;
+
+ bus_space_tag_t iot = va->va_iot;
+ bus_space_handle_t ioh;
+
+ DPRINTF(("==com_vrip_attach"));
+
+ if (bus_space_map(iot, va->va_addr, 1, 0, &ioh)) {
+ printf(": can't map bus space\n");
+ return;
+ }
+ sc->sc_iobase = va->va_addr;
+ sc->sc_iot = iot;
+ sc->sc_ioh = ioh;
+
+ sc->enable = NULL; /* XXX: CMU control */
+ sc->disable = NULL;
+
+ sc->sc_frequency = COM_FREQ;
+ vrcmu_supply(CMUMSKSSIU | CMUMSKSIU);
+
+ DPRINTF(("Try to attach com.\n"));
+ com_attach_subr(sc);
+ DPRINTF(("Establish intr"));
+ vrip_intr_establish(va, com_vrip_intr, self);
+ DPRINTF((":return()"));
+}
+
+
Index: hpcmips/sys/arch/hpcmips/vr/vripreg.h
diff -u hpcmips/sys/arch/hpcmips/vr/vripreg.h:1.1 hpcmips/sys/arch/hpcmips/vr/vripreg.h:1.1.2.1
--- hpcmips/sys/arch/hpcmips/vr/vripreg.h:1.1 Thu Feb 11 20:37:23 1999
+++ hpcmips/sys/arch/hpcmips/vr/vripreg.h Thu Apr 8 22:03:13 1999
@@ -8,7 +8,7 @@
*
*/
-/* XXX, We are't interested in I/O register size. */
+/* XXX, We aren't interested in I/O register size. */
#define VRIP_SIZE 0x02000000
#define VRIP_BCU_ADDR 0x0b000000
----------------------------------------------------------------