Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/vax/vsa Adds VAXstation VLC and 4000/60 framebuffer...
details: https://anonhg.NetBSD.org/src/rev/ef8509a4202c
branches: trunk
changeset: 334939:ef8509a4202c
user: jklos <jklos%NetBSD.org@localhost>
date: Tue Dec 16 11:34:17 2014 +0000
description:
Adds VAXstation VLC and 4000/60 framebuffer support. From Blaz Antonic
and updated by Bj?rnJohannesson.
diffstat:
sys/arch/vax/vsa/lcg.c | 1289 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 1289 insertions(+), 0 deletions(-)
diffs (truncated from 1293 to 300 lines):
diff -r 104511fd87d5 -r ef8509a4202c sys/arch/vax/vsa/lcg.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/vax/vsa/lcg.c Tue Dec 16 11:34:17 2014 +0000
@@ -0,0 +1,1289 @@
+/* $NetBSD: lcg.c,v 1.1 2014/12/16 11:34:17 jklos Exp $ */
+/*
+ * LCG accelerated framebuffer driver
+ * Copyright (c) 2003, 2004 Blaz Antonic
+ * 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 abovementioned copyrights
+ * 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.
+ */
+/*
+ * Resurrection and dumb framebuffer mode by Björn Johannesson
+ * rherdware%yahoo.com@localhost in December 2014
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: lcg.c,v 1.1 2014/12/16 11:34:17 jklos Exp $");
+
+#define LCG_NO_ACCEL
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/systm.h>
+#include <sys/callout.h>
+#include <sys/time.h>
+#include <sys/malloc.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+
+#include <machine/vsbus.h>
+#include <machine/sid.h>
+#include <machine/cpu.h>
+#include <machine/lcgreg.h>
+
+#include <dev/cons.h>
+
+#include <dev/dec/dzreg.h>
+#include <dev/dec/dzvar.h>
+#include <dev/dec/dzkbdvar.h>
+
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wscons_callbacks.h>
+#include <dev/wsfont/wsfont.h>
+
+#include "machine/scb.h"
+
+#include "dzkbd.h"
+
+/* Screen hardware defs */
+
+#define LCG_FB_ADDR 0x21801000 /* Frame buffer */
+
+/* FIFO defines */
+#define LCG_FIFO_SIZE 0x10000 /* 64 KB */
+#define LCG_FIFO_WIN_ADDR 0x20180000
+#define LCG_FIFO_WIN_SIZE VAX_NBPG
+#define LCG_FIFO_ALIGN 0x10000
+
+/* font rendering defines */
+#define LCG_FONT_ADDR (LCG_FB_ADDR + lcg_fb_size)
+#define LCG_FONT_STORAGE_SIZE 0x40000 /* 16 KB, enough to accomodate 16x32 font bitmaps */
+
+/* register space defines */
+#define LCG_REG_ADDR 0x20100000 /* LCG registers */
+#define LCG_REG_SIZE 0x4000 /* 16384 bytes */
+#define LCG_REG(reg) regaddr[(reg / 4)]
+
+/* LUT defines */
+#define LCG_LUT_ADDR 0x21800800 /* LUT right before onscreen FB */
+#define LCG_LUT_OFFSET 0x00000800
+#define LCG_LUT_SIZE 0x800 /* 2048 bytes */
+
+#define LCG_BG_COLOR WSCOL_BLACK
+#define LCG_FG_COLOR WSCOL_WHITE
+
+#define LCG_CONFIG 0x200f0010 /* LCG model information */
+
+/* implement sanity checks at certain points to ensure safer operation */
+#define LCG_SAFE
+//#define LCG_DEBUG
+
+static int lcg_match(struct device *, struct cfdata *, void *);
+static void lcg_attach(struct device *, struct device *, void *);
+
+struct lcg_softc {
+ struct device ss_dev;
+ bus_dmamap_t sc_dm;
+};
+
+CFATTACH_DECL_NEW(lcg, sizeof(struct lcg_softc),
+ lcg_match, lcg_attach, NULL, NULL);
+
+static void lcg_cursor(void *, int, int, int);
+static int lcg_mapchar(void *, int, unsigned int *);
+static void lcg_putchar(void *, int, int, u_int, long);
+static void lcg_copycols(void *, int, int, int,int);
+static void lcg_erasecols(void *, int, int, int, long);
+static void lcg_copyrows(void *, int, int, int);
+static void lcg_eraserows(void *, int, int, long);
+static int lcg_allocattr(void *, int, int, int, long *);
+static int lcg_get_cmap(struct wsdisplay_cmap *);
+static int lcg_set_cmap(struct wsdisplay_cmap *);
+static void lcg_init_common(struct device *, struct vsbus_attach_args *);
+
+const struct wsdisplay_emulops lcg_emulops = {
+ lcg_cursor,
+ lcg_mapchar,
+ lcg_putchar,
+ lcg_copycols,
+ lcg_erasecols,
+ lcg_copyrows,
+ lcg_eraserows,
+ lcg_allocattr
+};
+
+static char lcg_stdscreen_name[10] = "160x68";
+struct wsscreen_descr lcg_stdscreen = {
+ lcg_stdscreen_name, 160, 68, /* dynamically set */
+ &lcg_emulops,
+ 8, 15, /* dynamically set */
+ WSSCREEN_UNDERLINE|WSSCREEN_REVERSE|WSSCREEN_WSCOLORS,
+};
+
+const struct wsscreen_descr *_lcg_scrlist[] = {
+ &lcg_stdscreen,
+};
+
+const struct wsscreen_list lcg_screenlist = {
+ sizeof(_lcg_scrlist) / sizeof(struct wsscreen_descr *),
+ _lcg_scrlist,
+};
+
+static char *lcgaddr;
+static char *lutaddr;
+static volatile long *regaddr;
+static volatile long *fifoaddr;
+#ifndef LCG_NO_ACCEL
+static char *fontaddr;
+#endif
+
+static int lcg_xsize;
+static int lcg_ysize;
+static int lcg_depth;
+static int lcg_cols;
+static int lcg_rows;
+static int lcg_onerow;
+static int lcg_fb_size;
+static int lcg_glyph_size; /* bitmap size in bits */
+
+static char *cursor;
+
+static int cur_on;
+
+static int cur_fg, cur_bg;
+
+
+/* Our current hardware colormap */
+static struct hwcmap256 {
+#define CMAP_SIZE 256 /* 256 R/G/B entries */
+ u_int8_t r[CMAP_SIZE];
+ u_int8_t g[CMAP_SIZE];
+ u_int8_t b[CMAP_SIZE];
+} lcg_cmap;
+
+/* The default colormap */
+static struct {
+ u_int8_t r[8];
+ u_int8_t g[8];
+ u_int8_t b[8];
+} lcg_default_cmap = {
+ { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff },
+ { 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff },
+ { 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff }
+};
+
+struct wsdisplay_font lcg_font;
+static u_char *qf;
+static u_short *qf2;
+
+#define QCHAR(c) (c < lcg_font.firstchar ? 0 : \
+ (c >= (lcg_font.firstchar + lcg_font.numchars) ? 0 : c - lcg_font.firstchar))
+#define QFONT(c,line) ((lcg_font.stride == 2 ? \
+ qf2[QCHAR(c) * lcg_font.fontheight + line] : \
+ qf[QCHAR(c) * lcg_font.fontheight + line]))
+#define LCG_ADDR(row, col, line, dot) \
+ lcgaddr[((col) * lcg_font.fontwidth) + ((row) * lcg_font.fontheight * lcg_xsize) + \
+ (line) * lcg_xsize + dot]
+
+
+static int lcg_ioctl(void *, void *, u_long, void *, int, struct lwp *);
+static paddr_t lcg_mmap(void *, void *, off_t, int);
+static int lcg_alloc_screen(void *, const struct wsscreen_descr *,
+ void **, int *, int *, long *);
+static void lcg_free_screen(void *, void *);
+static int lcg_show_screen(void *, void *, int,
+ void (*) (void *, int, int), void *);
+static void lcg_crsr_blink(void *);
+
+/* LCG HW accel functions */
+#ifndef LCG_NO_ACCEL
+static void fifo_put(long data);
+static int fifo_fill(int iterations);
+static u_char fifo_counter = 0;
+
+static void blkcpy(long source, long dest, int xdim, int ydim);
+static void blkset(long dest, int xdim, int ydim, char color);
+static void renderchar(long source, long dest, int xdim, int ydim, char fg, char bg);
+#endif /* LCG_NO_ACCEL */
+
+const struct wsdisplay_accessops lcg_accessops = {
+ lcg_ioctl,
+ lcg_mmap,
+ lcg_alloc_screen,
+ lcg_free_screen,
+ lcg_show_screen,
+ 0 /* load_font */
+};
+
+/* TODO allocate ss_image dynamically for consoles beyond first one */
+struct lcg_screen {
+ int ss_curx;
+ int ss_cury;
+ int ss_cur_fg;
+ int ss_cur_bg;
+ struct {
+ u_char data; /* Image character */
+ u_char attr; /* Attribute: 80/70/08/07 */
+ } ss_image[160 * 128]; /* allow for maximum possible cell matrix */
+};
+#define LCG_ATTR_UNDERLINE 0x80
+#define LCG_BG_MASK 0x70
+#define LCG_ATTR_REVERSE 0x08
+#define LCG_FG_MASK 0x07
+
+static struct lcg_screen lcg_conscreen;
+static struct lcg_screen *curscr;
+static struct lcg_screen *savescr;
+
+static callout_t lcg_cursor_ch;
+
+#ifndef LCG_NO_ACCEL
+void fifo_put(long data)
+{
+ fifo_counter &= 0x3;
+ fifoaddr[fifo_counter] = data;
+ fifo_counter++;
+}
+
+int fifo_fill(int iterations)
+{
+ long status;
+ int counter = 0;;
+
+ while (fifo_counter % 4)
+ fifo_put(0);
+
+#ifdef LCG_SAFE
+ status = LCG_REG(LCG_REG_GRAPHICS_SUB_STATUS);
+ while ((counter < iterations) && ((status & 0x80000000) == 0x80000000)) {
+ delay(1000);
+ status = LCG_REG(LCG_REG_GRAPHICS_SUB_STATUS);
+ counter++;
+ }
+#endif
+
+ if (counter == 0)
+ return 0;
+ else
+ return 1;
+}
+
+void blkcpy(long source, long dest, int xdim, int ydim)
+{
+ int err;
Home |
Main Index |
Thread Index |
Old Index