Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add a driver for LUNA's front panel LCD. Ported from OpenBS...
details: https://anonhg.NetBSD.org/src/rev/5748f9a8d968
branches: trunk
changeset: 351999:5748f9a8d968
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Thu Mar 09 14:05:58 2017 +0000
description:
Add a driver for LUNA's front panel LCD. Ported from OpenBSD/luna88k.
Reviewed by enami@. Tested by Naruaki Etomi and me.
A 68k LUNA with this driver will be demonstrated at AsiaBSDCon NetBSD booth
by Etomi-san, with LUNA-88K2 running OpenBSD/luna88k by Kenji Aoyama.
diffstat:
distrib/sets/lists/comp/md.luna68k | 3 +-
etc/etc.luna68k/MAKEDEV.conf | 9 +-
sys/arch/luna68k/conf/GENERIC | 7 +-
sys/arch/luna68k/conf/INSTALL | 5 +-
sys/arch/luna68k/conf/files.luna68k | 7 +-
sys/arch/luna68k/conf/majors.luna68k | 3 +-
sys/arch/luna68k/dev/lcd.c | 213 +++++++++++++++++++++++++++++++++-
sys/arch/luna68k/include/Makefile | 4 +-
sys/arch/luna68k/include/lcd.h | 67 +++++++++++
sys/arch/luna68k/luna68k/machdep.c | 10 +-
sys/arch/luna68k/luna68k/mainbus.c | 6 +-
11 files changed, 305 insertions(+), 29 deletions(-)
diffs (truncated from 550 to 300 lines):
diff -r 03b9a820e9d1 -r 5748f9a8d968 distrib/sets/lists/comp/md.luna68k
--- a/distrib/sets/lists/comp/md.luna68k Thu Mar 09 11:39:43 2017 +0000
+++ b/distrib/sets/lists/comp/md.luna68k Thu Mar 09 14:05:58 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: md.luna68k,v 1.21 2016/12/03 17:38:02 tsutsui Exp $
+# $NetBSD: md.luna68k,v 1.22 2017/03/09 14:05:58 tsutsui Exp $
./usr/include/ieeefp.h comp-c-include
./usr/include/luna68k comp-c-include
./usr/include/luna68k/_G_config.h comp-obsolete obsolete
@@ -27,6 +27,7 @@
./usr/include/luna68k/int_types.h comp-c-include
./usr/include/luna68k/intr.h comp-c-include
./usr/include/luna68k/kcore.h comp-c-include
+./usr/include/luna68k/lcd.h comp-c-include
./usr/include/luna68k/limits.h comp-c-include
./usr/include/luna68k/lock.h comp-c-include
./usr/include/luna68k/math.h comp-c-include
diff -r 03b9a820e9d1 -r 5748f9a8d968 etc/etc.luna68k/MAKEDEV.conf
--- a/etc/etc.luna68k/MAKEDEV.conf Thu Mar 09 11:39:43 2017 +0000
+++ b/etc/etc.luna68k/MAKEDEV.conf Thu Mar 09 14:05:58 2017 +0000
@@ -1,10 +1,10 @@
-# $NetBSD: MAKEDEV.conf,v 1.10 2017/02/16 13:13:39 tsutsui Exp $
+# $NetBSD: MAKEDEV.conf,v 1.11 2017/03/09 14:05:58 tsutsui Exp $
all_md)
makedev ttya sd0 sd1 sd2 sd3 cd0 cd1 st0 st1
makedev wscons
makedev scsibus0 scsibus1
- makedev xp
+ makedev xp lcd
;;
tty[ab])
@@ -26,3 +26,8 @@
major=40; minor=0; mode=0644
mkdev xp c $major $minor $mode
;;
+
+lcd)
+ major=41; minor=0; mode=0644
+ mkdev lcd c $major $minor $mode
+ ;;
diff -r 03b9a820e9d1 -r 5748f9a8d968 sys/arch/luna68k/conf/GENERIC
--- a/sys/arch/luna68k/conf/GENERIC Thu Mar 09 11:39:43 2017 +0000
+++ b/sys/arch/luna68k/conf/GENERIC Thu Mar 09 14:05:58 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.120 2016/12/03 17:38:02 tsutsui Exp $
+# $NetBSD: GENERIC,v 1.121 2017/03/09 14:05:58 tsutsui Exp $
#
# GENERIC machine description file
#
@@ -22,7 +22,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.120 $"
+#ident "GENERIC-$Revision: 1.121 $"
makeoptions COPTS="-O2 -fno-reorder-blocks" # see share/mk/sys.mk
@@ -151,6 +151,9 @@
clock0 at mainbus0
+# LCD on front panel
+lcd0 at mainbus0
+
# uPD7201 SIO
sio0 at mainbus0
siotty0 at sio0 # ttya
diff -r 03b9a820e9d1 -r 5748f9a8d968 sys/arch/luna68k/conf/INSTALL
--- a/sys/arch/luna68k/conf/INSTALL Thu Mar 09 11:39:43 2017 +0000
+++ b/sys/arch/luna68k/conf/INSTALL Thu Mar 09 14:05:58 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.20 2016/09/18 14:20:23 christos Exp $
+# $NetBSD: INSTALL,v 1.21 2017/03/09 14:05:58 tsutsui Exp $
#
# config for installation ramdisk kernel
#
@@ -130,6 +130,9 @@
clock0 at mainbus0
+# LCD on front panel
+lcd0 at mainbus0
+
# uPD7201 SIO
sio0 at mainbus0
siotty0 at sio0 # ttya
diff -r 03b9a820e9d1 -r 5748f9a8d968 sys/arch/luna68k/conf/files.luna68k
--- a/sys/arch/luna68k/conf/files.luna68k Thu Mar 09 11:39:43 2017 +0000
+++ b/sys/arch/luna68k/conf/files.luna68k Thu Mar 09 14:05:58 2017 +0000
@@ -1,5 +1,5 @@
#
-# $NetBSD: files.luna68k,v 1.25 2016/12/03 17:38:02 tsutsui Exp $
+# $NetBSD: files.luna68k,v 1.26 2017/03/09 14:05:58 tsutsui Exp $
#
maxpartitions 8
maxusers 2 8 64
@@ -22,7 +22,6 @@
file arch/m68k/m68k/sys_machdep.c
file arch/m68k/m68k/vm_machdep.c
file dev/cons.c
-file arch/luna68k/dev/lcd.c
device mainbus {}
attach mainbus at root
@@ -32,6 +31,10 @@
attach clock at mainbus
file arch/luna68k/dev/timekeeper.c clock
+device lcd
+attach lcd at mainbus
+file arch/luna68k/dev/lcd.c lcd needs-flag
+
attach le at mainbus: le24
file arch/luna68k/dev/if_le.c le
diff -r 03b9a820e9d1 -r 5748f9a8d968 sys/arch/luna68k/conf/majors.luna68k
--- a/sys/arch/luna68k/conf/majors.luna68k Thu Mar 09 11:39:43 2017 +0000
+++ b/sys/arch/luna68k/conf/majors.luna68k Thu Mar 09 14:05:58 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: majors.luna68k,v 1.21 2016/12/03 17:38:02 tsutsui Exp $
+# $NetBSD: majors.luna68k,v 1.22 2017/03/09 14:05:58 tsutsui Exp $
#
# Device majors for luna68k
#
@@ -37,6 +37,7 @@
device-major ksyms char 38 ksyms
device-major wsfont char 39 wsfont
device-major xp char 40 xp
+device-major lcd char 41 lcd
device-major nsmb char 98 nsmb
diff -r 03b9a820e9d1 -r 5748f9a8d968 sys/arch/luna68k/dev/lcd.c
--- a/sys/arch/luna68k/dev/lcd.c Thu Mar 09 11:39:43 2017 +0000
+++ b/sys/arch/luna68k/dev/lcd.c Thu Mar 09 14:05:58 2017 +0000
@@ -1,4 +1,5 @@
-/* $NetBSD: lcd.c,v 1.7 2011/11/12 13:44:26 tsutsui Exp $ */
+/* $NetBSD: lcd.c,v 1.8 2017/03/09 14:05:58 tsutsui Exp $ */
+/* $OpenBSD: lcd.c,v 1.7 2015/02/10 22:42:35 miod Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,19 +32,21 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: lcd.c,v 1.7 2011/11/12 13:44:26 tsutsui Exp $");
-
-/*
- * XXX
- * Following code segments are subject to change.
- * XXX
- */
+__KERNEL_RCSID(0, "$NetBSD: lcd.c,v 1.8 2017/03/09 14:05:58 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/conf.h>
#include <sys/device.h>
+#include <sys/ioctl.h>
+#include <sys/fcntl.h>
+#include <sys/errno.h>
+#include <machine/autoconf.h>
#include <machine/cpu.h>
+#include <machine/lcd.h>
+
+#include "ioconf.h"
#define PIO1_MODE_OUTPUT 0x84
#define PIO1_MODE_INPUT 0x94
@@ -65,6 +68,8 @@
#define LCD_HOME 0x02
#define LCD_LOCATE(X, Y) (((Y) & 1 ? 0xc0 : 0x80) | ((X) & 0x0f))
+#define LCD_MAXBUFLEN 80
+
struct pio {
volatile u_int8_t portA;
volatile u_int8_t portB;
@@ -72,6 +77,39 @@
volatile u_int8_t cntrl;
};
+/* Autoconf stuff */
+static int lcd_match(device_t, cfdata_t, void *);
+static void lcd_attach(device_t, device_t, void *);
+
+dev_type_open(lcdopen);
+dev_type_close(lcdclose);
+dev_type_write(lcdwrite);
+dev_type_ioctl(lcdioctl);
+
+const struct cdevsw lcd_cdevsw = {
+ .d_open = lcdopen,
+ .d_close = lcdclose,
+ .d_read = noread,
+ .d_write = lcdwrite,
+ .d_ioctl = lcdioctl,
+ .d_stop = nostop,
+ .d_tty = notty,
+ .d_poll = nopoll,
+ .d_mmap = nommap,
+ .d_kqfilter = nokqfilter,
+ .d_discard = nodiscard,
+ .d_flag = 0
+};
+
+struct lcd_softc {
+ device_t sc_dev;
+
+ bool sc_opened;
+};
+
+CFATTACH_DECL_NEW(lcd, sizeof(struct lcd_softc),
+ lcd_match, lcd_attach, NULL, NULL);
+
void lcdbusywait(void);
void lcdput(int);
void lcdctrl(int);
@@ -81,6 +119,165 @@
static char lcd_boot_message1[] = " NetBSD/luna68k ";
static char lcd_boot_message2[] = " SX-9100/DT ";
+/*
+ * Autoconf functions
+ */
+static int
+lcd_match(device_t parent, cfdata_t cf, void *aux)
+{
+ struct mainbus_attach_args *ma = aux;
+
+ if (strcmp(ma->ma_name, lcd_cd.cd_name))
+ return 0;
+ if (badaddr((void *)ma->ma_addr, 4))
+ return 0;
+ return 1;
+}
+
+static void
+lcd_attach(device_t parent, device_t self, void *aux)
+{
+
+ printf("\n");
+
+ /* Say hello to the world on LCD. */
+ greeting();
+}
+
+/*
+ * open/close/write/ioctl
+ */
+int
+lcdopen(dev_t dev, int flags, int fmt, struct lwp *l)
+{
+ int unit;
+ struct lcd_softc *sc;
+
+ unit = minor(dev);
+ sc = device_lookup_private(&lcd_cd, unit);
+ if (sc == NULL)
+ return ENXIO;
+ if (sc->sc_opened)
+ return EBUSY;
+ sc->sc_opened = true;
+
+ return 0;
+}
+
+int
+lcdclose(dev_t dev, int flags, int fmt, struct lwp *l)
+{
+ int unit;
+ struct lcd_softc *sc;
+
+ unit = minor(dev);
+ sc = device_lookup_private(&lcd_cd, unit);
+ sc->sc_opened = false;
+
+ return 0;
+}
+
+int
+lcdwrite(dev_t dev, struct uio *uio, int flag)
+{
+ int error;
+ size_t len, i;
+ char buf[LCD_MAXBUFLEN];
+
+ len = uio->uio_resid;
+
+ if (len > LCD_MAXBUFLEN)
+ return EIO;
+
+ error = uiomove(buf, len, uio);
+ if (error)
+ return EIO;
Home |
Main Index |
Thread Index |
Old Index