CVS commit: [netbsd-6] src/sys/arch/luna68k/dev

2014-01-12 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Jan 12 12:25:03 UTC 2014

Modified Files:
src/sys/arch/luna68k/dev [netbsd-6]: lunafb.c omrasops.c omrasopsvar.h

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1005):
sys/arch/luna68k/dev/omrasops.c: revision 1.15
sys/arch/luna68k/dev/omrasops.c: revision 1.16
sys/arch/luna68k/dev/lunafb.c: revision 1.27
sys/arch/luna68k/dev/lunafb.c: revision 1.28
sys/arch/luna68k/dev/lunafb.c: revision 1.29
sys/arch/luna68k/dev/lunafb.c: revision 1.30
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.2
sys/arch/luna68k/dev/omrasops.c: revision 1.14
Properly initialize the palette for while on black even on 1bpp framebuffer.
Preparing for demonstration in Open Source Conference 2013 Kyoto.
Fix off by one in copyrows() backward case.
Make omrasops copycols() op work even if columns are not 32 bit aligned.
This means command line editing works properly in any cases.
The bitcopy strategies for 1bpp copycols() op are taken from
recently fixed MI sys/dev/rasops/rasops_bitops.h.
GETBITS() and PUTBITS() m68k asm macro are taken from hp300.
Tested on both 1bpp (on LUNA-II) and 4bpp (on LUNA) framebuffers.
Initialize capabilities in struct wsscreen_descr per omrasops settings.
Now REVERSE characters are drawn properly.
Add preleminary support of 4bpp LUNA framebuffer.
Changes details:
- prepare and switch 4bpp rasops functions that read/write all 4 planes
  and also handle both fg and bg colors
- make 1bpp ops use first plane on write rather than common bitmap plane
  (which is prepared for multiple plane write with raster ops)
- prepare 4bpp allocattr function to handle ANSI 16 color text
- split omrasops_init() function for each bpp
- move struct hwcmap from softc to hwdevconfig to sync palette values
  on initialization
- allow mmap(2) against all available planes
Now we can use ANSI 16 color text console and also can
demonstrate mlterm-fb with color sixel graphics and wallpaper.
XXX: Xserver needs much more work.
Pull a fix of Bt458 (8bpp framebuffer) initialization from OpenBSD/luna88k.
http://marc.info/?l=openbsd-cvs&m=138838884202196
> Correct initialization of Bt458, used in LUNA's 8bpp frame buffer.
>
> According to the manual, the address register does not automatically
> increment when we access to the control registers.  Also we disable
> overlay planes, because we do not use them.


To generate a diff of this commit:
cvs rdiff -u -r1.25.8.1 -r1.25.8.2 src/sys/arch/luna68k/dev/lunafb.c
cvs rdiff -u -r1.11.8.1 -r1.11.8.2 src/sys/arch/luna68k/dev/omrasops.c
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/arch/luna68k/dev/omrasopsvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/luna68k/dev/lunafb.c
diff -u src/sys/arch/luna68k/dev/lunafb.c:1.25.8.1 src/sys/arch/luna68k/dev/lunafb.c:1.25.8.2
--- src/sys/arch/luna68k/dev/lunafb.c:1.25.8.1	Wed Jul 25 21:30:35 2012
+++ src/sys/arch/luna68k/dev/lunafb.c	Sun Jan 12 12:25:03 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: lunafb.c,v 1.25.8.1 2012/07/25 21:30:35 martin Exp $ */
+/* $NetBSD: lunafb.c,v 1.25.8.2 2014/01/12 12:25:03 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.25.8.1 2012/07/25 21:30:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.25.8.2 2014/01/12 12:25:03 bouyer Exp $");
 
 #include 
 #include 
@@ -82,27 +82,50 @@ struct bt458 {
 #define	OMFB_RAMDAC	0xC110	/* Bt454/Bt458 RAMDAC */
 #define	OMFB_SIZE	(0xB130 - 0xB108 + PAGE_SIZE)
 
+struct hwcmap {
+#define CMAP_SIZE 256
+	uint8_t r[CMAP_SIZE];
+	uint8_t g[CMAP_SIZE];
+	uint8_t b[CMAP_SIZE];
+};
+
+static const struct {
+	uint8_t r;
+	uint8_t g;
+	uint8_t b;
+} ansicmap[16] = {
+	{0,0,0},
+	{ 0x80,0,0},
+	{0, 0x80,0},
+	{ 0x80, 0x80,0},
+	{0,0, 0x80},
+	{ 0x80,0, 0x80},
+	{0, 0x80, 0x80},
+	{ 0xc0, 0xc0, 0xc0},
+	{ 0x80, 0x80, 0x80},
+	{ 0xff,0,0},
+	{0, 0xff,0},
+	{ 0xff, 0xff,0},
+	{0,0, 0xff},
+	{ 0xff,0, 0xff},
+	{0, 0xff, 0xff},
+	{ 0xff, 0xff, 0xff},
+};
+
 struct om_hwdevconfig {
 	int	dc_wid;			/* width of frame buffer */
 	int	dc_ht;			/* height of frame buffer */
 	int	dc_depth;		/* depth, bits per pixel */
 	int	dc_rowbytes;		/* bytes in a FB scan line */
 	int	dc_cmsize;		/* colormap size */
+	struct hwcmap dc_cmap;		/* software copy of colormap */
 	vaddr_t	dc_videobase;		/* base of flat frame buffer */
 	struct rasops_info dc_ri;	/* raster blitter variables */
 };
 
-struct hwcmap {
-#define CMAP_SIZE 256
-	uint8_t r[CMAP_SIZE];
-	uint8_t g[CMAP_SIZE];
-	uint8_t b[CMAP_SIZE];
-};
-
 struct omfb_softc {
 	device_t sc_dev;		/* base device */
 	struct om_hwdevconfig *sc_dc;	/* device configuration */
-	struct hwcm

CVS commit: [netbsd-6] src/sys/arch/luna68k/dev

2014-01-12 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Jan 12 12:21:16 UTC 2014

Modified Files:
src/sys/arch/luna68k/dev [netbsd-6]: lunaws.c siotty.c siovar.h

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1004):
sys/arch/luna68k/dev/siotty.c: revision 1.35
sys/arch/luna68k/dev/siotty.c: revision 1.36
sys/arch/luna68k/dev/siotty.c: revision 1.37
sys/arch/luna68k/dev/siotty.c: revision 1.38
sys/arch/luna68k/dev/lunaws.c: revision 1.25
sys/arch/luna68k/dev/lunaws.c: revision 1.26
sys/arch/luna68k/dev/lunaws.c: revision 1.27
sys/arch/luna68k/dev/siovar.h: revision 1.7
sys/arch/luna68k/dev/siotty.c: revision 1.34
struct device * -> device_t, use device_xname()  (from chs@)
Whitespace cleanup.
Use softint(9) to pass received data into wskbd(9) and wsmouse(9) layers.
It might be problematic to call them from an interrupt handler at IPL_SERIAL.
Tab/space cleanup.
Use softint(9) properly to process TX/RX data between tty(4) layer.
It could cause possible locking issue to call tty(4) layer functions
from IPL_SERIAL interrupt handlers.
Changes details (mostly similar to com(4) and z8530tty(4)):
 - allocate RX buffer and put data and status into it in the interrupt handler
 - call t_linesw->l_rint from the software interrupt handler
 - set the only first byte in siottystart() and use t_outq buffer to send
   multiple TX data
 - call the next t_linesw->l_start on TX complete in the software interrupt
   handler
Also put more changes:
 - handle cnmagic(9) properly (now entering ddb(4) by console BREAK works)
 - allocate tty in the attach function as other drivers rather than first open
 - use proper variable types
Remove initialization of unused t_softc in struct tty (to make pullup easier).


To generate a diff of this commit:
cvs rdiff -u -r1.23.8.1 -r1.23.8.2 src/sys/arch/luna68k/dev/lunaws.c
cvs rdiff -u -r1.33 -r1.33.4.1 src/sys/arch/luna68k/dev/siotty.c
cvs rdiff -u -r1.6 -r1.6.8.1 src/sys/arch/luna68k/dev/siovar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/luna68k/dev/lunaws.c
diff -u src/sys/arch/luna68k/dev/lunaws.c:1.23.8.1 src/sys/arch/luna68k/dev/lunaws.c:1.23.8.2
--- src/sys/arch/luna68k/dev/lunaws.c:1.23.8.1	Wed Jul 25 21:30:35 2012
+++ src/sys/arch/luna68k/dev/lunaws.c	Sun Jan 12 12:21:16 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: lunaws.c,v 1.23.8.1 2012/07/25 21:30:35 martin Exp $ */
+/* $NetBSD: lunaws.c,v 1.23.8.2 2014/01/12 12:21:16 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.23.8.1 2012/07/25 21:30:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.23.8.2 2014/01/12 12:21:16 bouyer Exp $");
 
 #include "wsmouse.h"
 
@@ -51,6 +51,10 @@ __KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1
 
 #include "ioconf.h"
 
+#define OMKBD_RXQ_LEN		64
+#define OMKBD_RXQ_LEN_MASK	(OMKBD_RXQ_LEN - 1)
+#define OMKBD_NEXTRXQ(x)	(((x) + 1) & OMKBD_RXQ_LEN_MASK)
+
 static const uint8_t ch1_regs[6] = {
 	WR0_RSTINT,/* Reset E/S Interrupt */
 	WR1_RXALLS,/* Rx per char, No Tx */
@@ -64,12 +68,16 @@ struct ws_softc {
 	device_t	sc_dev;
 	struct sioreg	*sc_ctl;
 	uint8_t		sc_wr[6];
-	struct device	*sc_wskbddev;
+	device_t	sc_wskbddev;
+	uint8_t		sc_rxq[OMKBD_RXQ_LEN];
+	u_int		sc_rxqhead;
+	u_int		sc_rxqtail;
 #if NWSMOUSE > 0
-	struct device	*sc_wsmousedev;
+	device_t	sc_wsmousedev;
 	int		sc_msreport;
-	int		buttons, dx, dy;
+	int		sc_msbuttons, sc_msdx, sc_msdy;
 #endif
+	void		*sc_si;
 };
 
 static void omkbd_input(void *, int);
@@ -111,6 +119,7 @@ static const struct wsmouse_accessops om
 #endif
 
 static void wsintr(int);
+static void wssoftintr(void *);
 
 static int  wsmatch(device_t, cfdata_t, void *);
 static void wsattach(device_t, device_t, void *);
@@ -143,7 +152,7 @@ wsattach(device_t parent, device_t self,
 	sc->sc_ctl = (struct sioreg *)scp->scp_ctl + 1;
 	memcpy(sc->sc_wr, ch1_regs, sizeof(ch1_regs));
 	scp->scp_intr[1] = wsintr;
-	
+
 	setsioreg(sc->sc_ctl, WR0, sc->sc_wr[WR0]);
 	setsioreg(sc->sc_ctl, WR4, sc->sc_wr[WR4]);
 	setsioreg(sc->sc_ctl, WR3, sc->sc_wr[WR3]);
@@ -153,6 +162,11 @@ wsattach(device_t parent, device_t self,
 
 	syscnputc((dev_t)1, 0x20); /* keep quiet mouse */
 
+	sc->sc_rxqhead = 0;
+	sc->sc_rxqtail = 0;
+
+	sc->sc_si = softint_establish(SOFTINT_SERIAL, wssoftintr, sc);
+
 	aprint_normal("\n");
 
 	a.console = (args->hwflags == 1);
@@ -165,7 +179,7 @@ wsattach(device_t parent, device_t self,
 	{
 	struct wsmousedev_attach_args b;
 	b.accessops = &omms_accessops;
-	b.accesscookie = (void *)sc;	
+	b.accesscookie = (void *)sc;
 	sc->sc_wsmousedev =
 	config_found_ia(self, "wsmousedev", &b, wsmousedevprint);
 	sc->sc_msreport = 0;
@@ -179,7 +193,7 @@ wsintr(int chan)
 {
 	struct ws_softc *sc = device_lookup_private(&ws_

CVS commit: [netbsd-6] src/sys/arch/luna68k/dev

2014-01-12 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Jan 12 12:16:51 UTC 2014

Modified Files:
src/sys/arch/luna68k/dev [netbsd-6]: timekeeper.c timekeeper.h

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1003):
sys/arch/luna68k/dev/timekeeper.h: revision 1.3
sys/arch/luna68k/dev/timekeeper.c: revision 1.11
sys/arch/luna68k/dev/timekeeper.c: revision 1.12
sys/arch/luna68k/dev/timekeeper.c: revision 1.13
Whitespace cleanup.
Fix offset of DS1287A NVRAM address on LUNA-II.
Add an initialization function of DS1287A RTC and call it during attach.
It looks the boot firmware doesn't initialize the control registers
of DS1287A (while it resets NVRAM settings) and RTC oscillator is not
started properly after replacement.
Now my LUNA-II can keep RTC properly even after reboot.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.8.1 src/sys/arch/luna68k/dev/timekeeper.c
cvs rdiff -u -r1.2 -r1.2.40.1 src/sys/arch/luna68k/dev/timekeeper.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/luna68k/dev/timekeeper.c
diff -u src/sys/arch/luna68k/dev/timekeeper.c:1.10 src/sys/arch/luna68k/dev/timekeeper.c:1.10.8.1
--- src/sys/arch/luna68k/dev/timekeeper.c:1.10	Wed Jul 27 14:17:55 2011
+++ src/sys/arch/luna68k/dev/timekeeper.c	Sun Jan 12 12:16:51 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: timekeeper.c,v 1.10 2011/07/27 14:17:55 tsutsui Exp $ */
+/* $NetBSD: timekeeper.c,v 1.10.8.1 2014/01/12 12:16:51 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: timekeeper.c,v 1.10 2011/07/27 14:17:55 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: timekeeper.c,v 1.10.8.1 2014/01/12 12:16:51 bouyer Exp $");
 
 #include 
 #include 
@@ -58,6 +58,7 @@ struct timekeeper_softc {
 
 static int  clock_match(device_t, cfdata_t, void *);
 static void clock_attach(device_t, device_t, void *);
+static void dsclock_init(struct timekeeper_softc *);
 
 CFATTACH_DECL_NEW(clock, sizeof (struct timekeeper_softc),
 clock_match, clock_attach, NULL, NULL);
@@ -93,16 +94,17 @@ clock_attach(device_t parent, device_t s
 		sc->sc_nvramsize = 2040;
 		sc->sc_todr.todr_gettime_ymdhms = mkclock_get;
 		sc->sc_todr.todr_settime_ymdhms = mkclock_set;
-		sc->sc_todr.cookie = sc; 
+		sc->sc_todr.cookie = sc;
 		aprint_normal(": mk48t02\n");
 		break;
 	case LUNA_II: /* Dallas DS1287A */
 		sc->sc_clock = (void *)ma->ma_addr;
-		sc->sc_nvram = (void *)(ma->ma_addr + 50);
+		sc->sc_nvram = (void *)(ma->ma_addr + MC_NREGS);
 		sc->sc_nvramsize = 50;
 		sc->sc_todr.todr_gettime_ymdhms = dsclock_get;
 		sc->sc_todr.todr_settime_ymdhms = dsclock_set;
-		sc->sc_todr.cookie = sc; 
+		sc->sc_todr.cookie = sc;
+		dsclock_init(sc);
 		aprint_normal(": ds1287a\n");
 		break;
 	}
@@ -161,6 +163,28 @@ mkclock_set(todr_chip_handle_t tch, stru
 	return 0;
 }
 
+static void
+dsclock_init(struct timekeeper_softc *sc)
+{
+	volatile uint8_t *chiptime = (void *)sc->sc_clock;
+
+	/*
+	 * It looks the firmware ROM doesn't initialize DS1287 at all
+	 * even after the chip is replaced, so explicitly initialize
+	 * control registers here.
+	 */
+	chiptime = (void *)sc->sc_clock;
+
+	/* No DSE, 24HR, BINARY */
+	chiptime[MC_REGB] =
+	(chiptime[MC_REGB] & ~MC_REGB_DSE) |
+	(MC_REGB_24HR | MC_REGB_BINARY);
+
+	/* make sure to start integrated clock OSC */
+	chiptime[MC_REGA] =
+	(chiptime[MC_REGA] & ~MC_REGA_DVMASK) | MC_BASE_32_KHz;
+}
+
 /*
  * Get the time of day, based on the clock's value and/or the base value.
  */

Index: src/sys/arch/luna68k/dev/timekeeper.h
diff -u src/sys/arch/luna68k/dev/timekeeper.h:1.2 src/sys/arch/luna68k/dev/timekeeper.h:1.2.40.1
--- src/sys/arch/luna68k/dev/timekeeper.h:1.2	Mon Apr 28 20:23:26 2008
+++ src/sys/arch/luna68k/dev/timekeeper.h	Sun Jan 12 12:16:51 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: timekeeper.h,v 1.2 2008/04/28 20:23:26 martin Exp $ */
+/* $NetBSD: timekeeper.h,v 1.2.40.1 2014/01/12 12:16:51 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -62,6 +62,7 @@
 #define  MC_REGA_RSMASK 0x0f/* Interrupt rate select mask (see below) */
 #define  MC_REGA_DVMASK 0x70/* Divisor select mask (see below) */
 #define  MC_REGA_UIP0x80/* Update in progress; read only. */
+#define  MC_BASE_32_KHz	0x20/* 32 KHz crystal (enable OSC on DS1287) */
 
 #define MC_REGB 0xb /* Control register B */
 #define  MC_REGB_DSE0x01/* Daylight Savings Enable */