diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-09-15 21:13:29 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-09-15 21:13:29 +0000 |
commit | c7944dc0d2be35242202bdad3b511d6b6e60cf3a (patch) | |
tree | 49728a73374c694c8937e8c1903dabf1e19ec820 /sys/arch/pmax/dev | |
parent | 9923345416a4c9f9c668f0ca1c8b259113aac9e7 (diff) |
sync to netbsd; for graichen
Diffstat (limited to 'sys/arch/pmax/dev')
35 files changed, 1251 insertions, 720 deletions
diff --git a/sys/arch/pmax/dev/ascreg.h b/sys/arch/pmax/dev/ascreg.h index a9673d62ccc..7d4f4fd0724 100644 --- a/sys/arch/pmax/dev/ascreg.h +++ b/sys/arch/pmax/dev/ascreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: ascreg.h,v 1.5 1994/10/26 21:08:52 cgd Exp $ */ +/* $NetBSD: ascreg.h,v 1.6 1996/01/31 23:38:55 jonathan Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -229,13 +229,13 @@ typedef volatile struct { #define ASC_CSR_IO 0x01 #define ASC_PHASE(csr) ((csr) & 0x7) -#define ASC_PHASE_DATAO 0x0 -#define ASC_PHASE_DATAI 0x1 -#define ASC_PHASE_COMMAND 0x2 -#define ASC_PHASE_STATUS 0x3 +#define SCSI_PHASE_DATAO 0x0 +#define SCSI_PHASE_DATAI 0x1 +#define SCSI_PHASE_COMMAND 0x2 +#define SCSI_PHASE_STATUS 0x3 /* 4..5 ANSI reserved */ -#define ASC_PHASE_MSG_OUT 0x6 -#define ASC_PHASE_MSG_IN 0x7 +#define SCSI_PHASE_MSG_OUT 0x6 +#define SCSI_PHASE_MSG_IN 0x7 /* * Destination Bus ID diff --git a/sys/arch/pmax/dev/bt459.c b/sys/arch/pmax/dev/bt459.c index db288b7c113..45667ff2c1c 100644 --- a/sys/arch/pmax/dev/bt459.c +++ b/sys/arch/pmax/dev/bt459.c @@ -1,3 +1,5 @@ +/* $NetBSD: bt459.c,v 1.4 1996/04/08 00:57:41 jonathan Exp $ */ + /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -34,7 +36,6 @@ * SUCH DAMAGE. * * from: @(#)sfb.c 8.1 (Berkeley) 6/10/93 - * $Id: bt459.c,v 1.1 1995/10/18 08:51:25 deraadt Exp $ */ /* @@ -52,7 +53,6 @@ * * from: Header: /sprite/src/kernel/dev/ds3100.md/RCS/devGraphics.c, * v 9.2 90/02/13 22:16:24 shirriff Exp SPRITE (DECWRL)"; - * $Id: bt459.c,v 1.1 1995/10/18 08:51:25 deraadt Exp $ */ /* * Mach Operating System @@ -81,6 +81,7 @@ */ #include <sys/param.h> +#include <sys/systm.h> #include <sys/kernel.h> #include <sys/device.h> #include <sys/select.h> @@ -291,12 +292,12 @@ bt459RestoreCursorColor(fi) bt459_select_reg(regs, BT459_REG_CCOLOR_1); for (i = 0; i < 3; i++) { regs->addr_reg = cursor_RGB[i]; - MachEmptyWriteBuffer(); + wbflush(); } bt459_select_reg(regs, BT459_REG_CCOLOR_3); for (i = 3; i < 6; i++) { regs->addr_reg = cursor_RGB[i]; - MachEmptyWriteBuffer(); + wbflush(); } } @@ -307,7 +308,7 @@ bt459CursorColor(fi, color) unsigned int color[]; struct fbinfo *fi; { - register int i, j; + register int i; for (i = 0; i < 6; i++) cursor_RGB[i] = (u_char)(color[i] >> 8); @@ -350,23 +351,23 @@ bt459PosCursor(fi, x, y) fbu->scrInfo.cursor.x = x; /* keep track of real cursor */ fbu->scrInfo.cursor.y = y; /* position, indep. of mouse */ -#ifdef MELLON /* perhaps this is right for sfb ? */ - x += 369; /* is this correct for rcons on an sfb?? */ -#else - x += 219; /* this is right for old pmax fb drivers on a cfb */ -#endif + /* XXX is this a linear function of x-dimension screen size? */ + if (fi->fi_type.fb_boardtype == PMAX_FBTYPE_SFB) + x += 369; /* is this correct for rcons on an sfb?? */ + else + x += 219; /* correct for a cfb */ y += 34; bt459_select_reg(regs, BT459_REG_CXLO); regs->addr_reg = x; - MachEmptyWriteBuffer(); + wbflush(); regs->addr_reg = x >> 8; - MachEmptyWriteBuffer(); + wbflush(); regs->addr_reg = y; - MachEmptyWriteBuffer(); + wbflush(); regs->addr_reg = y >> 8; - MachEmptyWriteBuffer(); + wbflush(); } /* Initialize the colormap to the default state, which is that entry @@ -382,22 +383,22 @@ bt459InitColorMap(fi) bt459_select_reg(regs, 0); ((u_char *)(fi -> fi_cmap_bits)) [0] = regs->addr_cmap = 0; - MachEmptyWriteBuffer(); + wbflush(); ((u_char *)(fi -> fi_cmap_bits)) [1] = regs->addr_cmap = 0; - MachEmptyWriteBuffer(); + wbflush(); ((u_char *)(fi -> fi_cmap_bits)) [2] = regs->addr_cmap = 0; - MachEmptyWriteBuffer(); + wbflush(); for (i = 0; i < 256; i++) { ((u_char *)(fi -> fi_cmap_bits)) [i * 3] = regs->addr_cmap = 0xff; - MachEmptyWriteBuffer(); + wbflush(); ((u_char *)(fi -> fi_cmap_bits)) [i * 3 + 1] = regs->addr_cmap = 0xff; - MachEmptyWriteBuffer(); + wbflush(); ((u_char *)(fi -> fi_cmap_bits)) [i * 3 + 2] = regs -> addr_cmap = 0xff; - MachEmptyWriteBuffer(); + wbflush(); } for (i = 0; i < 3; i++) { @@ -484,11 +485,11 @@ bt459_video_on(fi) /* restore old color map entry zero */ bt459_select_reg(regs, 0); regs->addr_cmap = cmap_bits [0]; - MachEmptyWriteBuffer(); + wbflush(); regs->addr_cmap = cmap_bits [0]; - MachEmptyWriteBuffer(); + wbflush(); regs->addr_cmap = cmap_bits [0]; - MachEmptyWriteBuffer(); + wbflush(); /* enable normal display */ bt459_write_reg(regs, BT459_REG_PRM, 0xff); @@ -513,11 +514,11 @@ bt459_video_off(fi) /* set color map entry zero to zero */ bt459_select_reg(regs, 0); regs->addr_cmap = 0; - MachEmptyWriteBuffer(); + wbflush(); regs->addr_cmap = 0; - MachEmptyWriteBuffer(); + wbflush(); regs->addr_cmap = 0; - MachEmptyWriteBuffer(); + wbflush(); /* disable display */ bt459_write_reg(regs, BT459_REG_PRM, 0); @@ -536,7 +537,7 @@ bt459_select_reg(regs, regno) { regs->addr_lo = regno; regs->addr_hi = regno >> 8; - MachEmptyWriteBuffer(); + wbflush(); } static void @@ -545,9 +546,9 @@ bt459_write_reg(regs, regno, val) { regs->addr_lo = regno; regs->addr_hi = regno >> 8; - MachEmptyWriteBuffer(); + wbflush(); regs->addr_reg = val; - MachEmptyWriteBuffer(); + wbflush(); } static u_char @@ -556,7 +557,7 @@ bt459_read_reg(regs, regno) { regs->addr_lo = regno; regs->addr_hi = regno >> 8; - MachEmptyWriteBuffer(); + wbflush(); return (regs->addr_reg); } diff --git a/sys/arch/pmax/dev/bt478.c b/sys/arch/pmax/dev/bt478.c index e672cfd1c2c..aa8a8485a3b 100644 --- a/sys/arch/pmax/dev/bt478.c +++ b/sys/arch/pmax/dev/bt478.c @@ -1,4 +1,4 @@ -/* $NetBSD: bt478.c,v 1.2 1995/11/25 10:38:42 mellon Exp $ */ +/* $NetBSD: bt478.c,v 1.4 1996/04/08 00:57:43 jonathan Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -57,6 +57,7 @@ #include <sys/param.h> +#include <sys/systm.h> #include <sys/kernel.h> #include <sys/device.h> #include <sys/select.h> @@ -73,12 +74,22 @@ /* * Forward references. */ -void bt478RestoreCursorColor(); -void bt478CursorColor(); /* qvss ioctl interface uses this */ -/*static*/ void bt478InitColorMap(); -int bt478GetColorMap(); -static void bt478VDACInit(); -int bt478LoadColorMap(); + + +int bt478init __P((struct fbinfo *fi)); + +void bt478RestoreCursorColor __P((struct fbinfo *fi)); +/* qvss ioctl interface uses this */ +void bt478CursorColor __P((struct fbinfo *fi, unsigned int color[])); + +void bt478BlankCursor __P((struct fbinfo *fi)); +/*static*/ void bt478InitColorMap __P((struct fbinfo *fi)); +int bt478GetColorMap __P((struct fbinfo *fi, caddr_t bits, + int index, int count)); +int bt478LoadColorMap __P((struct fbinfo *fi, caddr_t bits, + int index, int count)); + + extern int pmax_boardtype; extern u_short defCursor[32]; @@ -98,18 +109,18 @@ bt478init(fi) * * Initialize the VDAC */ - vdac->overWA = 0x04; MachEmptyWriteBuffer(); - vdac->over = 0x00; MachEmptyWriteBuffer(); - vdac->over = 0x00; MachEmptyWriteBuffer(); - vdac->over = 0x00; MachEmptyWriteBuffer(); - vdac->overWA = 0x08; MachEmptyWriteBuffer(); - vdac->over = 0x00; MachEmptyWriteBuffer(); - vdac->over = 0x00; MachEmptyWriteBuffer(); - vdac->over = 0x7f; MachEmptyWriteBuffer(); - vdac->overWA = 0x0c; MachEmptyWriteBuffer(); - vdac->over = 0xff; MachEmptyWriteBuffer(); - vdac->over = 0xff; MachEmptyWriteBuffer(); - vdac->over = 0xff; MachEmptyWriteBuffer(); + vdac->overWA = 0x04; wbflush(); + vdac->over = 0x00; wbflush(); + vdac->over = 0x00; wbflush(); + vdac->over = 0x00; wbflush(); + vdac->overWA = 0x08; wbflush(); + vdac->over = 0x00; wbflush(); + vdac->over = 0x00; wbflush(); + vdac->over = 0x7f; wbflush(); + vdac->overWA = 0x0c; wbflush(); + vdac->over = 0xff; wbflush(); + vdac->over = 0xff; wbflush(); + vdac->over = 0xff; wbflush(); /* Initialize the cursor position... */ fi -> fi_cursor.width = 16; @@ -134,26 +145,26 @@ bt478RestoreCursorColor(fi) register int i; vdac->overWA = 0x04; - MachEmptyWriteBuffer(); + wbflush(); for (i = 0; i < 3; i++) { vdac->over = bg_RGB[i]; - MachEmptyWriteBuffer(); + wbflush(); } vdac->overWA = 0x08; - MachEmptyWriteBuffer(); + wbflush(); vdac->over = 0x00; - MachEmptyWriteBuffer(); + wbflush(); vdac->over = 0x00; - MachEmptyWriteBuffer(); + wbflush(); vdac->over = 0x7f; - MachEmptyWriteBuffer(); + wbflush(); vdac->overWA = 0x0c; - MachEmptyWriteBuffer(); + wbflush(); for (i = 0; i < 3; i++) { vdac->over = fg_RGB[i]; - MachEmptyWriteBuffer(); + wbflush(); } } @@ -186,10 +197,10 @@ bt478BlankCursor(fi) register int i; vdac->overWA = 0x0c; - MachEmptyWriteBuffer(); + wbflush(); for (i = 0; i < 3; i++) { vdac->over = 0; - MachEmptyWriteBuffer(); + wbflush(); } } @@ -205,44 +216,44 @@ bt478InitColorMap (fi) *(volatile char *)MACH_PHYS_TO_UNCACHED (KN01_PHYS_COLMASK_START) = 0xff; /* XXX */ - MachEmptyWriteBuffer(); + wbflush(); if (fi -> fi_type.fb_depth == 1) { - vdac->mapWA = 0; MachEmptyWriteBuffer(); + vdac->mapWA = 0; wbflush(); for (i = 0; i < 256; i++) { ((u_char *)(fi -> fi_cmap_bits)) [i * 3] = 0; ((u_char *)(fi -> fi_cmap_bits)) [i * 3 + 1] = (i < 128) ? 0x00 : 0xff; ((u_char *)(fi -> fi_cmap_bits)) [i * 3 + 2] = 0; vdac->map = 0; - MachEmptyWriteBuffer(); + wbflush(); vdac->map = (i < 128) ? 0x00 : 0xff; - MachEmptyWriteBuffer(); + wbflush(); vdac->map = 0; - MachEmptyWriteBuffer(); + wbflush(); } } else { - vdac->mapWA = 0; MachEmptyWriteBuffer(); + vdac->mapWA = 0; wbflush(); ((u_char *)(fi -> fi_cmap_bits)) [0] = 0; ((u_char *)(fi -> fi_cmap_bits)) [1] = 0; ((u_char *)(fi -> fi_cmap_bits)) [2] = 0; vdac->map = 0; - MachEmptyWriteBuffer(); + wbflush(); vdac->map = 0; - MachEmptyWriteBuffer(); + wbflush(); vdac->map = 0; - MachEmptyWriteBuffer(); + wbflush(); for (i = 1; i < 256; i++) { ((u_char *)(fi -> fi_cmap_bits)) [i * 3] = 0xff; ((u_char *)(fi -> fi_cmap_bits)) [i * 3 + 1] = 0xff; ((u_char *)(fi -> fi_cmap_bits)) [i * 3 + 2] = 0xff; vdac->map = 0xff; - MachEmptyWriteBuffer(); + wbflush(); vdac->map = 0xff; - MachEmptyWriteBuffer(); + wbflush(); vdac->map = 0xff; - MachEmptyWriteBuffer(); + wbflush(); } } @@ -250,7 +261,7 @@ bt478InitColorMap (fi) bg_RGB[i] = 0x00; fg_RGB[i] = 0xff; } - bt478RestoreCursorColor(); + bt478RestoreCursorColor(fi); } /* Load the color map. */ @@ -266,23 +277,26 @@ bt478LoadColorMap(fi, bits, index, count) u_char *cmap; int i; - if (index > 256 || index < 0 || index + count > 256) + if (index < 0 || count < 1 || index + count > 256) return EINVAL; cmap_bits = (u_char *)bits; cmap = (u_char *)(fi -> fi_cmap_bits) + index * 3; - vdac->mapWA = index; MachEmptyWriteBuffer(); for (i = 0; i < count; i++) { - cmap [(i + index) * 3] - = vdac->map = cmap_bits [i * 3]; - MachEmptyWriteBuffer(); - cmap [(i + index) * 3 + 1] - = vdac->map = cmap_bits [i * 3 + 1]; - MachEmptyWriteBuffer(); - cmap [(i + index) * 3 + 2] - = vdac -> map = cmap_bits [i * 3 + 2]; - MachEmptyWriteBuffer(); + vdac->mapWA = i + index; wbflush(); + + cmap [i * 3] = cmap_bits [i * 3]; + vdac->map = cmap_bits [i * 3]; + wbflush(); + + cmap [i * 3 + 1] = cmap_bits [i * 3 + 1]; + vdac->map = cmap_bits [i * 3 + 1]; + wbflush(); + + cmap [i * 3 + 2] = cmap_bits [i * 3 + 2]; + vdac -> map = cmap_bits [i * 3 + 2]; + wbflush(); } return 0; } diff --git a/sys/arch/pmax/dev/cfb.c b/sys/arch/pmax/dev/cfb.c index 9a93c36ea2e..3fb3b7db294 100644 --- a/sys/arch/pmax/dev/cfb.c +++ b/sys/arch/pmax/dev/cfb.c @@ -1,4 +1,4 @@ -/* $NetBSD: cfb.c,v 1.11 1995/09/12 22:36:09 jonathan Exp $ */ +/* $NetBSD: cfb.c,v 1.18.4.2 1996/09/09 20:45:26 thorpej Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -36,7 +36,6 @@ * SUCH DAMAGE. * * from: @(#)sfb.c 8.1 (Berkeley) 6/10/93 - * $Id: cfb.c,v 1.1 1995/10/18 08:51:26 deraadt Exp $ */ /* @@ -81,14 +80,18 @@ * rights to redistribute these changes. */ -#include <fb.h> -#include <cfb.h> +#include "fb.h" +#include "cfb.h" + #if NCFB > 0 #include <sys/param.h> +#include <sys/systm.h> /* printf() */ #include <sys/kernel.h> #include <sys/errno.h> #include <sys/fcntl.h> +#include <sys/malloc.h> #include <sys/device.h> +#include <dev/tc/tcvar.h> #include <machine/machConst.h> #include <machine/pmioctl.h> @@ -116,11 +119,15 @@ struct fbinfo cfbfi; /*XXX*/ /* should be softc */ * Forward references. */ -extern struct cfdriver cfb; +extern struct cfdriver cfb_cd; #define CMAP_BITS (3 * 256) /* 256 entries, 3 bytes per. */ -static u_char cmap_bits [NCFB * CMAP_BITS]; /* One colormap per cfb... */ +static u_char cmap_bits [CMAP_BITS]; /* colormap for console... */ +/* + * Method table for standard framebuffer operations on a CFB. + * The CFB uses a Brooktree bt479 ramdac. + */ struct fbdriver cfb_driver = { bt459_video_on, bt459_video_off, @@ -132,6 +139,7 @@ struct fbdriver cfb_driver = { bt459CursorColor }; +int cfbinit __P((struct fbinfo *fi, caddr_t cfbaddr, int unit, int silent)); extern void fbScreenInit __P((struct fbinfo *fi)); void genConfigMouse(), genDeconfigMouse(); @@ -157,29 +165,14 @@ int cfbmatch __P((struct device *, void *, void *)); void cfbattach __P((struct device *, struct device *, void *)); int cfb_intr __P((void *sc)); -struct cfdriver cfbcd = { - NULL, "cfb", cfbmatch, cfbattach, DV_DULL, sizeof(struct fbinfo), 0 +struct cfattach cfb_ca = { + sizeof(struct fbinfo), cfbmatch, cfbattach }; -#if 0 -/* - * Look for a cfb. Separated out from cfbmatch() so consinit() can call it. - */ -int -cfbprobe(cfbaddr) - caddr_t cfbaddr; -{ - /* check for no frame buffer */ - if (badaddr(cfbaddr, 4)) - return (0); - - /* make sure that we're looking for this type of device. */ - if (!BUS_MATCHNAME(ca, "PMAG-BA ")) - return (0); +struct cfdriver cfb_cd = { + NULL, "cfb", DV_DULL +}; - return 1; -} -#endif int @@ -188,10 +181,8 @@ cfbmatch(parent, match, aux) void *match; void *aux; { - struct cfdata *cf = match; - struct confargs *ca = aux; - static int ncfbs = 1; - caddr_t cfbaddr = BUS_CVTADDR(ca); + /*struct cfdata *cf = match;*/ + struct tc_attach_args *ta = aux; #ifdef FBDRIVER_DOES_ATTACH /* leave configuration to the fb driver */ @@ -199,22 +190,16 @@ cfbmatch(parent, match, aux) #endif /* make sure that we're looking for this type of device. */ - /*if (!cfbprobe(cfbaddr)) return 0;*/ - if (!BUS_MATCHNAME(ca, "PMAG-BA ")) + if (!TC_BUS_MATCHNAME(ta, "PMAG-BA ")) return (0); - -#ifdef notyet - /* if it can't have the one mentioned, reject it */ - if (cf->cf_unit >= ncfbs) - return (0); -#endif return (1); } /* * Attach a device. Hand off all the work to cfbinit(), - * so console-config cod can attach cfbs early in boot. + * so console-config code can attach cfb devices very early in boot, + * to use as system console. */ void cfbattach(parent, self, aux) @@ -222,15 +207,15 @@ cfbattach(parent, self, aux) struct device *self; void *aux; { - struct confargs *ca = aux; - caddr_t base = BUS_CVTADDR(ca); + struct tc_attach_args *ta = aux; + caddr_t base = (caddr_t)(ta->ta_addr); int unit = self->dv_unit; struct fbinfo *fi = (struct fbinfo *) self; #ifdef notyet /* if this is the console, it's already configured. */ if (ca->ca_slotpri == cons_slot) - return; /* XXX patch up f softc pointer */ + return; /* XXX patch up softc pointer */ #endif if (!cfbinit(fi, base, unit, 0)) @@ -238,21 +223,24 @@ cfbattach(parent, self, aux) /* * The only interrupt on the CFB proper is the vertical-blank - * interrupt, which cannot be disabled. The CFB always requests it. + * interrupt, which cannot be disabled. The CFB always requests + * an interrupt during every vertical-retrace period. * We never enable interrupts from CFB cards, except on the * 3MIN, where TC options interrupt at spl0 through spl2, and - * disabling those interrupts isn't currently honoured. + * disabling of TC option interrupts doesn't work. */ if (pmax_boardtype == DS_3MIN) { - BUS_INTR_ESTABLISH(ca, cfb_intr, self); + tc_intr_establish(parent, (void*)ta->ta_cookie, TC_IPL_NONE, + cfb_intr, fi); } + printf("\n"); } - /* - * Initialization + * CFB initialization. This is divorced from cfbattch() so that + * a console framebuffer can be initialized early during boot. */ int cfbinit(fi, cfbaddr, unit, silent) @@ -261,11 +249,25 @@ cfbinit(fi, cfbaddr, unit, silent) int unit; int silent; { - if (fi == NULL) fi = &cfbfi; /* XXX */ + /* + * If this device is being intialized as the console, malloc() + * is not yet up and we must use statically-allocated space. + */ + if (fi == NULL) { + fi = &cfbfi; /* XXX */ + fi->fi_cmap_bits = (caddr_t)cmap_bits; + } + else { + fi->fi_cmap_bits = malloc(CMAP_BITS, M_DEVBUF, M_NOWAIT); + if (fi->fi_cmap_bits == NULL) { + printf("cfb%d: no memory for cmap\n", unit); + return (0); + } + } /* check for no frame buffer */ if (badaddr(cfbaddr, 4)) { - printf("cfb: bad address 0x%x\n", cfbaddr); + printf("cfb: bad address 0x%p\n", cfbaddr); return (0); } @@ -281,7 +283,6 @@ cfbinit(fi, cfbaddr, unit, silent) fi->fi_linebytes = 1024; fi->fi_driver = &cfb_driver; fi->fi_blanked = 0; - fi->fi_cmap_bits = (caddr_t)&cmap_bits [CMAP_BITS * unit]; /* Fill in Frame Buffer Type struct. */ fi->fi_type.fb_boardtype = PMAX_FBTYPE_CFB; @@ -300,6 +301,8 @@ cfbinit(fi, cfbaddr, unit, silent) printf("cfb%d: vdac init failed.\n", unit); return (0); } + /*cfbInitColorMap();*/ /* done by bt459init() */ + /* * qvss/pm-style mmap()ed event queue compatibility glue @@ -333,8 +336,6 @@ cfbinit(fi, cfbaddr, unit, silent) } - /*cfbInitColorMap();*/ /* done by bt459init() */ - /* * Connect to the raster-console pseudo-driver */ @@ -352,8 +353,11 @@ cfbinit(fi, cfbaddr, unit, silent) * The original TURBOChannel cfb interrupts on every vertical * retrace, and we can't disable the board from requesting those * interrupts. The 4.4BSD kernel never enabled those interrupts; - * but there's a kernel design bug on the 3MIN, where the cfb - * interrupts at spl0, spl1, or spl2. + * but there's a kernel design bug on the 3MIN, where disabling + * (or enabling) TC option interrupts has no effect the interrupts + * are mapped to R3000 interrupts and always seem to be taken. + * This function simply dismisses CFB interrupts, or the interrupt + * request from the card will still be active. */ int cfb_intr(sc) @@ -365,6 +369,8 @@ cfb_intr(sc) /* reset vertical-retrace interrupt by writing a dont-care */ *(int*) (slot_addr+CFB_OFFSET_IREQ) = 0; + + return (0); } #endif /* NCFB */ diff --git a/sys/arch/pmax/dev/dc.c b/sys/arch/pmax/dev/dc.c index d758f77d56d..0a180c1cd49 100644 --- a/sys/arch/pmax/dev/dc.c +++ b/sys/arch/pmax/dev/dc.c @@ -1,4 +1,4 @@ -/* $NetBSD: dc.c,v 1.12 1995/09/11 21:29:23 jonathan Exp $ */ +/* $NetBSD: dc.c,v 1.16.4.5 1996/06/16 17:15:51 mhitch Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -56,7 +56,7 @@ * v 1.4 89/08/29 11:55:30 nelson Exp SPRITE (DECWRL)"; */ -#include <dc.h> +#include "dc.h" #if NDC > 0 /* * DC7085 (DZ-11 look alike) Driver @@ -74,9 +74,12 @@ #include <sys/kernel.h> #include <sys/syslog.h> +#include <machine/conf.h> #include <sys/device.h> #include <machine/autoconf.h> #include <machine/machConst.h> +#include <dev/tc/tcvar.h> +#include <dev/tc/ioasicvar.h> #include <machine/dc7085cons.h> #include <machine/pmioctl.h> @@ -88,14 +91,23 @@ #include <pmax/dev/lk201.h> #include "dcvar.h" +#include "tc.h" + +#include <pmax/dev/lk201var.h> /* XXX KbdReset band friends */ extern int pmax_boardtype; +extern struct cfdriver mainbus_cd; + +struct dc_softc { + struct device sc_dv; + struct pdma dc_pdma[4]; +}; /* - * Autoconfiguration data for config.new. + * Autoconfiguration data for config. + * * Use the statically-allocated softc until old autoconfig code and * config.old are completely gone. - * */ int dcmatch __P((struct device * parent, void *cfdata, void *aux)); void dcattach __P((struct device *parent, struct device *self, void *aux)); @@ -103,9 +115,14 @@ void dcattach __P((struct device *parent, struct device *self, void *aux)); int dc_doprobe __P((void *addr, int unit, int flags, int pri)); int dcintr __P((void * xxxunit)); -extern struct cfdriver dccd; -struct cfdriver dccd = { - NULL, "dc", dcmatch, dcattach, DV_DULL, sizeof(struct device), 0 +extern struct cfdriver dc_cd; + +struct cfattach dc_ca = { + sizeof(struct dc_softc), dcmatch, dcattach +}; + +struct cfdriver dc_cd = { + NULL, "dc", DV_TTY }; @@ -146,21 +163,21 @@ int dc_timer; /* true if timer started */ struct pdma dcpdma[NDCLINE]; struct speedtab dcspeedtab[] = { - 0, 0, - 50, LPR_B50, - 75, LPR_B75, - 110, LPR_B110, - 134, LPR_B134, - 150, LPR_B150, - 300, LPR_B300, - 600, LPR_B600, - 1200, LPR_B1200, - 1800, LPR_B1800, - 2400, LPR_B2400, - 4800, LPR_B4800, - 9600, LPR_B9600, - 19200, LPR_B19200, - -1, -1 + { 0, 0, }, + { 50, LPR_B50 }, + { 75, LPR_B75 }, + { 110, LPR_B110 }, + { 134, LPR_B134 }, + { 150, LPR_B150 }, + { 300, LPR_B300 }, + { 600, LPR_B600 }, + { 1200, LPR_B1200 }, + { 1800, LPR_B1800 }, + { 2400, LPR_B2400 }, + { 4800, LPR_B4800 }, + { 9600, LPR_B9600 }, + { 19200,LPR_B19200 }, + { -1, -1 } }; #ifndef PORTSELECTOR @@ -172,6 +189,15 @@ struct speedtab dcspeedtab[] = { #endif /* + * Forward declarations + */ +struct tty *dctty __P((dev_t dev)); +void dcrint __P((int)); +int dcmctl __P((dev_t dev, int bits, int how)); + + + +/* * Match driver based on name */ int @@ -180,12 +206,29 @@ dcmatch(parent, match, aux) void *match; void *aux; { - struct cfdata *cf = match; struct confargs *ca = aux; +#if NTC>0 + struct ioasicdev_attach_args *d = aux; +#endif static int nunits = 0; - if (!BUS_MATCHNAME(ca, "dc")) +#if NTC > 0 + if (parent->dv_cfdata->cf_driver == &ioasic_cd) { + if (strcmp(d->iada_modname, "dc") != 0 && + strcmp(d->iada_modname, "dc7085") != 0) + return (0); + } + else +#endif /* NTC */ + + if (parent->dv_cfdata->cf_driver == &mainbus_cd) { + if (strcmp(ca->ca_name, "dc") != 0 && + strcmp(ca->ca_name, "mdc") != 0 && + strcmp(ca->ca_name, "dc7085") != 0) + return (0); + } + else return (0); /* @@ -207,13 +250,33 @@ dcattach(parent, self, aux) void *aux; { register struct confargs *ca = aux; - - (void) dc_doprobe((void*)MACH_PHYS_TO_UNCACHED(BUS_CVTADDR(ca)), - self->dv_unit, self->dv_cfdata->cf_flags, - ca->ca_slot); - - /* tie pseudo-slot to device */ - BUS_INTR_ESTABLISH(ca, dcintr, (void *)self->dv_unit); +#if NTC > 0 + struct ioasicdev_attach_args *d = aux; +#endif /* NTC */ + caddr_t dcaddr; + + +#if NTC > 0 + if (parent->dv_cfdata->cf_driver == &ioasic_cd) { + dcaddr = (caddr_t)d->iada_addr; + (void) dc_doprobe((void*)MACH_PHYS_TO_UNCACHED(dcaddr), + self->dv_unit, self->dv_cfdata->cf_flags, + (int)d->iada_cookie); + /* tie pseudo-slot to device */ + ioasic_intr_establish(parent, d->iada_cookie, TC_IPL_TTY, + dcintr, self); + } + else +#endif /* NTC */ + if (parent->dv_cfdata->cf_driver == &mainbus_cd) { + dcaddr = (caddr_t)ca->ca_addr; + (void) dc_doprobe((void*)MACH_PHYS_TO_UNCACHED(dcaddr), + self->dv_unit, self->dv_cfdata->cf_flags, + ca->ca_slot); + + /* tie pseudo-slot to device */ + BUS_INTR_ESTABLISH(ca, dcintr, self); + } printf("\n"); } @@ -222,6 +285,8 @@ dcattach(parent, self, aux) * XXX used for ugly special-cased console input that should be redone * more cleanly. */ +static inline int raster_console __P((void)); + static inline int raster_console() { @@ -230,6 +295,11 @@ raster_console() } +/* + * DC7085 (dz-11) probe routine from old-style config. + * This is only here out of intertia. + */ +int dc_doprobe(addr, unit, flags, priority) void *addr; int unit, flags, priority; @@ -256,7 +326,7 @@ dc_doprobe(addr, unit, flags, priority) /* reset chip */ dcaddr = (dcregs *)addr; dcaddr->dc_csr = CSR_CLR; - MachEmptyWriteBuffer(); + wbflush(); while (dcaddr->dc_csr & CSR_CLR) ; dcaddr->dc_csr = CSR_MSE | CSR_TIE | CSR_RIE; @@ -266,6 +336,8 @@ dc_doprobe(addr, unit, flags, priority) for (cntr = 0; cntr < 4; cntr++) { pdp->p_addr = (void *)dcaddr; tp = dc_tty[unit * 4 + cntr] = ttymalloc(); + if (cntr != DCKBD_PORT && cntr != DCMOUSE_PORT) + tty_attach(tp); pdp->p_arg = (int) tp; pdp->p_fcn = dcxint; pdp++; @@ -286,10 +358,10 @@ dc_doprobe(addr, unit, flags, priority) s = spltty(); dcaddr->dc_lpr = LPR_RXENAB | LPR_8_BIT_CHAR | LPR_B4800 | DCKBD_PORT; - MachEmptyWriteBuffer(); + wbflush(); dcaddr->dc_lpr = LPR_RXENAB | LPR_B4800 | LPR_OPAR | LPR_PARENB | LPR_8_BIT_CHAR | DCMOUSE_PORT; - MachEmptyWriteBuffer(); + wbflush(); DELAY(1000); KBDReset(makedev(DCDEV, DCKBD_PORT), dcPutc); MouseInit(makedev(DCDEV, DCMOUSE_PORT), dcPutc, dcGetc); @@ -298,7 +370,7 @@ dc_doprobe(addr, unit, flags, priority) s = spltty(); dcaddr->dc_lpr = LPR_RXENAB | LPR_8_BIT_CHAR | LPR_B9600 | minor(cn_tab->cn_dev); - MachEmptyWriteBuffer(); + wbflush(); DELAY(1000); /*cn_tab.cn_disabled = 0;*/ /* FIXME */ splx(s); @@ -308,6 +380,7 @@ dc_doprobe(addr, unit, flags, priority) return (1); } +int dcopen(dev, flag, mode, p) dev_t dev; int flag, mode; @@ -321,8 +394,10 @@ dcopen(dev, flag, mode, p) if (unit >= dc_cnt || dcpdma[unit].p_addr == (void *)0) return (ENXIO); tp = dc_tty[unit]; - if (tp == NULL) + if (tp == NULL) { tp = dc_tty[unit] = ttymalloc(); + tty_attach(tp); + } tp->t_oproc = dcstart; tp->t_param = dcparam; tp->t_dev = dev; @@ -351,8 +426,8 @@ dcopen(dev, flag, mode, p) while (!(flag & O_NONBLOCK) && !(tp->t_cflag & CLOCAL) && !(tp->t_state & TS_CARR_ON)) { tp->t_state |= TS_WOPEN; - if (error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH, - ttopen, 0)) + if ((error = ttysleep(tp, (caddr_t)&tp->t_rawq, + TTIPRI | PCATCH, ttopen, 0)) != 0) break; } splx(s); @@ -362,6 +437,7 @@ dcopen(dev, flag, mode, p) } /*ARGSUSED*/ +int dcclose(dev, flag, mode, p) dev_t dev; int flag, mode; @@ -384,6 +460,7 @@ dcclose(dev, flag, mode, p) return (ttyclose(tp)); } +int dcread(dev, uio, flag) dev_t dev; struct uio *uio; @@ -394,6 +471,7 @@ dcread(dev, uio, flag) return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); } +int dcwrite(dev, uio, flag) dev_t dev; struct uio *uio; @@ -413,9 +491,10 @@ dctty(dev) } /*ARGSUSED*/ +int dcioctl(dev, cmd, data, flag, p) dev_t dev; - int cmd; + u_long cmd; caddr_t data; int flag; struct proc *p; @@ -475,6 +554,7 @@ dcioctl(dev, cmd, data, flag, p) return (0); } +int dcparam(tp, t) register struct tty *tp; register struct termios *t; @@ -504,18 +584,18 @@ dcparam(tp, t) if (unit == DCKBD_PORT) { dcaddr->dc_lpr = LPR_RXENAB | LPR_8_BIT_CHAR | LPR_B4800 | DCKBD_PORT; - MachEmptyWriteBuffer(); + wbflush(); return (0); } else if (unit == DCMOUSE_PORT) { dcaddr->dc_lpr = LPR_RXENAB | LPR_B4800 | LPR_OPAR | LPR_PARENB | LPR_8_BIT_CHAR | DCMOUSE_PORT; - MachEmptyWriteBuffer(); + wbflush(); return (0); } } else if (tp->t_dev == cn_tab->cn_dev) { dcaddr->dc_lpr = LPR_RXENAB | LPR_8_BIT_CHAR | LPR_B9600 | unit; - MachEmptyWriteBuffer(); + wbflush(); return (0); } if (ospeed == 0) { @@ -534,7 +614,7 @@ dcparam(tp, t) if (cflag & CSTOPB) lpr |= LPR_2_STOP; dcaddr->dc_lpr = lpr; - MachEmptyWriteBuffer(); + wbflush(); DELAY(10); return (0); } @@ -546,10 +626,12 @@ int dcintr(xxxunit) void *xxxunit; { - register int unit = (int)xxxunit; + register struct dc_softc *sc = xxxunit; register dcregs *dcaddr; register unsigned csr; + register int unit = sc->sc_dv.dv_unit; + unit <<= 2; dcaddr = (dcregs *)dcpdma[unit].p_addr; while ((csr = dcaddr->dc_csr) & (CSR_RDONE | CSR_TRDY)) { @@ -562,6 +644,7 @@ dcintr(xxxunit) return 0; } +void dcrint(unit) register int unit; { @@ -629,7 +712,7 @@ dcxint(tp) if (dp->p_mem < dp->p_end) { dcaddr = (dcregs *)dp->p_addr; dcaddr->dc_tdr = dc_brk[unit >> 2] | *dp->p_mem++; - MachEmptyWriteBuffer(); + wbflush(); DELAY(10); return; } @@ -647,7 +730,7 @@ dcxint(tp) if (tp->t_outq.c_cc == 0 || !(tp->t_state & TS_BUSY)) { dcaddr = (dcregs *)dp->p_addr; dcaddr->dc_tcr &= ~(1 << (unit & 03)); - MachEmptyWriteBuffer(); + wbflush(); DELAY(10); } } @@ -702,7 +785,7 @@ dcstart(tp) dp->p_end = dp->p_mem = tp->t_outq.c_cf; dp->p_end += cc; dcaddr->dc_tcr |= 1 << (minor(tp->t_dev) & 03); - MachEmptyWriteBuffer(); + wbflush(); out: splx(s); } @@ -711,6 +794,7 @@ out: * Stop output on a line. */ /*ARGSUSED*/ +int dcstop(tp, flag) register struct tty *tp; { @@ -725,8 +809,11 @@ dcstop(tp, flag) tp->t_state |= TS_FLUSH; } splx(s); + + return (0); } +int dcmctl(dev, bits, how) dev_t dev; int bits, how; @@ -899,7 +986,7 @@ dcPutc(dev, c) dcaddr = (dcregs *)dcpdma[minor(dev)].p_addr; tcr = dcaddr->dc_tcr; dcaddr->dc_tcr = tcr | (1 << minor(dev)); - MachEmptyWriteBuffer(); + wbflush(); DELAY(10); while (1) { /* @@ -919,7 +1006,7 @@ dcPutc(dev, c) if (line != minor(dev)) { tcr |= 1 << line; dcaddr->dc_tcr &= ~(1 << line); - MachEmptyWriteBuffer(); + wbflush(); DELAY(10); continue; } @@ -927,7 +1014,7 @@ dcPutc(dev, c) * Start sending the character. */ dcaddr->dc_tdr = dc_brk[0] | (c & 0xff); - MachEmptyWriteBuffer(); + wbflush(); DELAY(10); /* * Wait for character to be sent. @@ -945,12 +1032,12 @@ dcPutc(dev, c) if (line != minor(dev)) { tcr |= 1 << line; dcaddr->dc_tcr &= ~(1 << line); - MachEmptyWriteBuffer(); + wbflush(); DELAY(10); continue; } dcaddr->dc_tcr &= ~(1 << minor(dev)); - MachEmptyWriteBuffer(); + wbflush(); DELAY(10); break; } @@ -961,7 +1048,7 @@ dcPutc(dev, c) */ if (tcr & 0xF) { dcaddr->dc_tcr = tcr; - MachEmptyWriteBuffer(); + wbflush(); DELAY(10); } diff --git a/sys/arch/pmax/dev/dcvar.h b/sys/arch/pmax/dev/dcvar.h index be8f0f81926..1e5c3e9b8f2 100644 --- a/sys/arch/pmax/dev/dcvar.h +++ b/sys/arch/pmax/dev/dcvar.h @@ -1,11 +1,10 @@ -/* $NetBSD: dcvar.h,v 1.1 1995/08/04 00:22:12 jonathan Exp $ */ +/* $NetBSD: dcvar.h,v 1.2 1996/01/29 22:52:18 jonathan Exp $ */ /* - * external declarations from DECstation dc serial driver + * External declarations from DECstation dc serial driver. */ extern int dcGetc __P ((dev_t dev)); extern int dcparam __P((register struct tty *tp, register struct termios *t)); -extern void dcPutc __P ((dev_t dev, int c)); - +extern void dcPutc __P((dev_t dev, int c)); diff --git a/sys/arch/pmax/dev/device.h b/sys/arch/pmax/dev/device.h index 9030c3ec20c..e21b7b08d76 100644 --- a/sys/arch/pmax/dev/device.h +++ b/sys/arch/pmax/dev/device.h @@ -1,4 +1,4 @@ -/* $NetBSD: device.h,v 1.8 1995/09/25 21:10:03 jonathan Exp $ */ +/* $NetBSD: device.h,v 1.9 1996/04/10 16:27:38 jonathan Exp $ */ /* * Copyright (c) 1992, 1993 @@ -125,4 +125,13 @@ typedef struct ScsiCmd { #ifdef _KERNEL extern struct pmax_ctlr pmax_cinit[]; extern struct pmax_scsi_device scsi_dinit[]; -#endif + +/* + * Old-style pmax driver glue: + * Callbacks to add known a controller, and to configure all slaves on + * all known controllers. + */ +void pmax_add_scsi __P((struct pmax_driver *dp, int unit)); +void configure_scsi __P((void)); + +#endif /* _KERNEL */ diff --git a/sys/arch/pmax/dev/dtop.c b/sys/arch/pmax/dev/dtop.c index 31ae2c9a612..a13ac2dd887 100644 --- a/sys/arch/pmax/dev/dtop.c +++ b/sys/arch/pmax/dev/dtop.c @@ -1,4 +1,4 @@ -/* $NetBSD: dtop.c,v 1.9 1995/09/25 21:12:33 jonathan Exp $ */ +/* $NetBSD: dtop.c,v 1.14.4.2 1996/06/16 17:17:14 mhitch Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -93,7 +93,7 @@ SOFTWARE. ********************************************************/ -#include <dtop.h> +#include "dtop.h" #if NDTOP > 0 #include <sys/param.h> #include <sys/systm.h> @@ -110,17 +110,23 @@ SOFTWARE. #include <sys/device.h> #include <machine/autoconf.h> +#include <machine/conf.h> + +#include <dev/cons.h> #include <machine/pmioctl.h> #include <machine/machConst.h> #include <machine/dc7085cons.h> -#include <pmax/pmax/pmaxtype.h> -#include <pmax/pmax/maxine.h> #include <pmax/pmax/asic.h> +#include <pmax/pmax/maxine.h> +#include <dev/tc/tcvar.h> +#include <dev/tc/ioasicvar.h> #include <pmax/dev/dtopreg.h> #include <pmax/dev/lk201.h> +#include <pmax/dev/lk201var.h> +#include <pmax/dev/dtopvar.h> #include <machine/fbio.h> #include <machine/fbvar.h> @@ -128,19 +134,6 @@ SOFTWARE. extern int pmax_boardtype; -void dtop_keyboard_repeat __P((void *)); -int dtop_null_device_handler __P((dtop_device_t, dtop_message_t, int, int)); -int dtop_locator_handler __P((dtop_device_t, dtop_message_t, int, int)); -int dtop_keyboard_handler __P((dtop_device_t, dtop_message_t, int, int)); -int dtopparam __P((struct tty *, struct termios *)); -int dtopstop __P((struct tty *, int)); -void dtopstart __P((struct tty *)); -void dtopKBDPutc __P((dev_t, int)); - -struct tty *dtop_tty[NDTOP]; -void (*dtopDivertXInput)(); /* X windows keyboard input routine */ -void (*dtopMouseEvent)(); /* X windows mouse motion event routine */ -void (*dtopMouseButtons)(); /* X windows mouse buttons event routine */ #define DTOP_MAX_POLL 0x7fff /* about half a sec */ @@ -158,7 +151,8 @@ typedef volatile unsigned int *poll_reg_t; /* SIR */ * Driver status */ struct dtop_softc { - struct device dtop_dv; + struct device sc_dv; + struct tty *dtop_tty; data_reg_t data; poll_reg_t poll; char polling_mode; @@ -172,10 +166,31 @@ struct dtop_softc { # define DTOP_DEVICE_NO(address) (((address)-DTOP_ADDR_FIRST)>>1) -} dtop_softc[NDTOP]; +}; +#define DTOP_TTY(unit) \ + ( ((struct dtop_softc*) dtop_cd.cd_devs[(unit)]) -> dtop_tty) typedef struct dtop_softc *dtop_softc_t; -struct tty *dtop_tty[NDTOP]; + +/* + * Forward/prototyped declarations + */ +int dtop_get_packet __P((dtop_softc_t dtop, dtop_message_t pkt)); +int dtop_escape __P((int c)); +void dtop_keyboard_repeat __P((void *)); +int dtop_null_device_handler __P((dtop_device_t, dtop_message_t, int, int)); +int dtop_locator_handler __P((dtop_device_t, dtop_message_t, int, int)); +int dtop_keyboard_handler __P((dtop_device_t, dtop_message_t, int, int)); +int dtopparam __P((struct tty *, struct termios *)); +void dtopstart __P((struct tty *)); + +void dtopKBDPutc __P((dev_t, int)); +int dtopKBDGetc __P((dev_t)); + + +void (*dtopDivertXInput)(); /* X windows keyboard input routine */ +void (*dtopMouseEvent)(); /* X windows mouse motion event routine */ +void (*dtopMouseButtons)(); /* X windows mouse buttons event routine */ /* @@ -193,6 +208,7 @@ static u_long keymodes[8] = {0, 0, 0, 0, 0, 0x0003e000, 0, 0}; + /* * Autoconfiguration data for config.new. * Use the statically-allocated softc until old autoconfig code and @@ -203,15 +219,19 @@ int dtopmatch __P((struct device * parent, void *cfdata, void *aux)); void dtopattach __P((struct device *parent, struct device *self, void *aux)); int dtopintr __P((void *sc)); -int dtop_doprobe __P((void *addr, int unit, int pri)); +extern struct cfdriver dtop_cd; -extern struct cfdriver dtopcd; -struct cfdriver dtopcd = { - NULL, "dtop", dtopmatch, dtopattach, DV_DULL, sizeof(struct device), 0 +struct cfattach dtop_ca = { + sizeof(struct dtop_softc), dtopmatch, dtopattach }; +struct cfdriver dtop_cd = { + NULL, "dtop", DV_DULL +}; + + /* - * match driver based on name + * Match driver based on name */ int dtopmatch(parent, match, aux) @@ -219,23 +239,15 @@ dtopmatch(parent, match, aux) void *match; void *aux; { - struct cfdata *cf = match; - struct confargs *ca = aux; - - static int nunits = 0; + /*struct cfdata *cf = match;*/ + struct ioasicdev_attach_args *d = aux; - if (!BUS_MATCHNAME(ca, "dtop")) + if (badaddr((caddr_t)(d->iada_addr), 2)) return (0); - /* - * Use statically-allocated softc and attach code until - * old config is completely gone. Don't over-run softc. - */ - if (nunits > NDTOP) { - printf("dtop: too many units for old config\n"); + if (strcmp(d->iada_modname, "dtop") != 0) return (0); - } - nunits++; + return (1); } @@ -245,49 +257,32 @@ dtopattach(parent, self, aux) struct device *self; void *aux; { - register struct confargs *ca = aux; + register struct ioasicdev_attach_args *d = aux; + struct dtop_softc *sc = (struct dtop_softc*) self; + int i; - (void) dtop_doprobe((void*)MACH_PHYS_TO_UNCACHED(BUS_CVTADDR(ca)), - self->dv_unit, ca->ca_slot); - /* tie pseudo-slot to device */ - BUS_INTR_ESTABLISH(ca, dtopintr, (void*)&dtop_softc[self->dv_unit]); - printf("\n"); -} - -dtop_doprobe(addr, unit, priority) - void *addr; - int unit, priority; -{ - register struct tty *tp; - register int cntr; - int i, s; - dtop_softc_t dtop; - - if (unit >= NDTOP) - return (0); - if (badaddr(addr, 2)) - return (0); - dtop = &dtop_softc[unit]; - - dtop->poll = (poll_reg_t)MACH_PHYS_TO_UNCACHED(XINE_REG_INTR); - dtop->data = (data_reg_t)addr; + sc->poll = (poll_reg_t)MACH_PHYS_TO_UNCACHED(XINE_REG_INTR); + sc->data = (data_reg_t)d->iada_addr; for (i = 0; i < DTOP_MAX_DEVICES; i++) - dtop->device[i].handler = dtop_null_device_handler; + sc->device[i].handler = dtop_null_device_handler; /* a lot more needed here, fornow: */ - dtop->device[DTOP_DEVICE_NO(0x6a)].handler = dtop_locator_handler; - dtop->device[DTOP_DEVICE_NO(0x6c)].handler = dtop_keyboard_handler; - dtop->device[DTOP_DEVICE_NO(0x6c)].status.keyboard.k_ar_state = + sc->device[DTOP_DEVICE_NO(0x6a)].handler = dtop_locator_handler; + sc->device[DTOP_DEVICE_NO(0x6c)].handler = dtop_keyboard_handler; + sc->device[DTOP_DEVICE_NO(0x6c)].status.keyboard.k_ar_state = K_AR_IDLE; - dtop->probed_once = 1; - printf("dtop%d at nexus0 csr 0x%x priority %d\n", - unit, addr, priority); - return (1); + sc->probed_once = 1; + + /* tie pseudo-slot to device */ + ioasic_intr_establish(parent, d->iada_cookie, TC_IPL_NONE, dtopintr, sc); + printf("\n"); } + +int dtopopen(dev, flag, mode, p) dev_t dev; int flag, mode; @@ -298,11 +293,13 @@ dtopopen(dev, flag, mode, p) int s, error = 0; unit = minor(dev); - if (unit >= NDTOP) + if (unit >= dtop_cd.cd_ndevs) return (ENXIO); - tp = dtop_tty[unit]; - if (tp == NULL) - tp = dtop_tty[unit] = ttymalloc(); + tp = DTOP_TTY(unit); + if (tp == NULL) { + tp = DTOP_TTY(unit) = ttymalloc(); + tty_attach(tp); + } tp->t_oproc = dtopstart; tp->t_param = dtopparam; tp->t_dev = dev; @@ -324,8 +321,8 @@ dtopopen(dev, flag, mode, p) while (!(flag & O_NONBLOCK) && !(tp->t_cflag & CLOCAL) && !(tp->t_state & TS_CARR_ON)) { tp->t_state |= TS_WOPEN; - if (error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH, - ttopen, 0)) + if ((error = ttysleep(tp, (caddr_t)&tp->t_rawq, + TTIPRI | PCATCH, ttopen, 0)) != 0) break; } splx(s); @@ -336,6 +333,7 @@ dtopopen(dev, flag, mode, p) } /*ARGSUSED*/ +int dtopclose(dev, flag, mode, p) dev_t dev; int flag, mode; @@ -345,28 +343,30 @@ dtopclose(dev, flag, mode, p) register int unit; unit = minor(dev); - tp = dtop_tty[unit]; + tp = DTOP_TTY(unit); (*linesw[tp->t_line].l_close)(tp, flag); return (ttyclose(tp)); } +int dtopread(dev, uio, flag) dev_t dev; struct uio *uio; { register struct tty *tp; - tp = dtop_tty[minor(dev)]; + tp = DTOP_TTY(minor(dev)); return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); } +int dtopwrite(dev, uio, flag) dev_t dev; struct uio *uio; { register struct tty *tp; - tp = dtop_tty[minor(dev)]; + tp = DTOP_TTY(minor(dev)); return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); } @@ -374,14 +374,15 @@ struct tty * dtoptty(dev) dev_t dev; { - struct tty *tp = dtop_tty[minor(dev)]; + struct tty *tp = DTOP_TTY(minor(dev)); return (tp); } /*ARGSUSED*/ +int dtopioctl(dev, cmd, data, flag, p) dev_t dev; - int cmd; + u_long cmd; caddr_t data; int flag; struct proc *p; @@ -390,7 +391,7 @@ dtopioctl(dev, cmd, data, flag, p) register int unit = minor(dev); int error; - tp = dtop_tty[unit]; + tp = DTOP_TTY(unit); error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); if (error >= 0) return (error); @@ -449,14 +450,16 @@ dtopintr(sc) * If not probed yet, just throw the data away. */ if (!dtop->probed_once) - return; + return 0; devno = DTOP_DEVICE_NO(msg.src_address); if (devno < 0 || devno > 15) - return; + return (0); + (void) (*dtop->device[devno].handler) (&dtop->device[devno].status, &msg, DTOP_EVENT_RECEIVE_PACKET, 0); + return(0); } void @@ -479,7 +482,7 @@ dtopstart(tp) if (tp->t_outq.c_cc == 0) goto out; /* handle console specially */ - if (tp == dtop_tty[0]) { + if (tp == DTOP_TTY(0)) { while (tp->t_outq.c_cc > 0) { cc = getc(&tp->t_outq) & 0x7f; cnputc(cc); @@ -552,7 +555,9 @@ dtopKBDPutc(dev, c) * A packet MUST be there, this is not checked for. */ #define DTOP_ESC_CHAR 0xf8 +int dtop_escape(c) + int c; { /* I donno much about this stuff.. */ switch (c) { @@ -565,6 +570,7 @@ dtop_escape(c) } } +int dtop_get_packet(dtop, pkt) dtop_softc_t dtop; dtop_message_t pkt; @@ -624,12 +630,14 @@ bad: /* * Get a keyboard char for the console */ -dtopKBDGetc() +int +dtopKBDGetc(dev) + dev_t dev; { register int c; dtop_softc_t dtop; - dtop = &dtop_softc[0]; + dtop = dtop_cd.cd_devs[0]; again: c = -1; @@ -682,6 +690,7 @@ dtopparam(tp, t) * Stop output on a line. */ /*ARGSUSED*/ +int dtopstop(tp, flag) register struct tty *tp; int flag; @@ -694,6 +703,8 @@ dtopstop(tp, flag) tp->t_state |= TS_FLUSH; } splx(s); + + return (0); } /* @@ -782,7 +793,7 @@ dtop_keyboard_handler(dev, msg, event, outc) register u_char *ls, *le, *ns, *ne; u_char save[11], retc; int msg_len, c, s; - struct tty *tp = dtop_tty[0]; + struct tty *tp = DTOP_TTY(0); /* * Fiddle about emulating an lk201 keyboard. The lk501 @@ -838,7 +849,8 @@ dtop_keyboard_handler(dev, msg, event, outc) */ if (msg_len > 0 && dev->keyboard.last_codes_count > 0) { ls = dev->keyboard.last_codes; - le = &dev->keyboard.last_codes[dev->keyboard.last_codes_count]; + le = &dev->keyboard.last_codes[ ((u_int)dev->keyboard. + last_codes_count) ]; ne = &msg->body[msg_len]; for (; ls < le; ls++) { for (ns = msg->body; ns < ne; ns++) @@ -855,7 +867,7 @@ dtop_keyboard_handler(dev, msg, event, outc) le = dev->keyboard.last_codes; ls = &dev->keyboard.last_codes[dev->keyboard.last_codes_count - 1]; for ( ; ls >= le; ls--) - if (c = *ls) { + if ((c = *ls) != 0) { (void) kbdMapChar(c); if (outc == 0 && dtopDivertXInput && @@ -875,7 +887,7 @@ dtop_keyboard_handler(dev, msg, event, outc) if (dtopDivertXInput) { (*dtopDivertXInput)(*ns); c = -1; /* consumed by X */ - } else if (c >= 0) + } else if (c >= 0 && tp != NULL) (*linesw[tp->t_line].l_rint)(c, tp); dev->keyboard.k_ar_state = K_AR_ACTIVE; } @@ -904,7 +916,7 @@ dtop_keyboard_repeat(arg) { dtop_device_t dev = (dtop_device_t)arg; register int i, c; - struct tty *tp = dtop_tty[0]; + struct tty *tp = DTOP_TTY(0); int s = spltty(), gotone = 0; for (i = 0; i < dev->keyboard.last_codes_count; i++) { diff --git a/sys/arch/pmax/dev/dtopvar.h b/sys/arch/pmax/dev/dtopvar.h new file mode 100644 index 00000000000..0f47e91c284 --- /dev/null +++ b/sys/arch/pmax/dev/dtopvar.h @@ -0,0 +1,8 @@ +int dtopKBDGetc __P((dev_t dev)); +void dtopKBDPutc __P((dev_t dev, int c)); + +/* + * Device numbers. + */ +#define DTOPKBD_PORT 0 +#define DTOPMOUSE_PORT 1 diff --git a/sys/arch/pmax/dev/fb.c b/sys/arch/pmax/dev/fb.c index e44d98f12f4..0edc22e46bc 100644 --- a/sys/arch/pmax/dev/fb.c +++ b/sys/arch/pmax/dev/fb.c @@ -1,4 +1,4 @@ -/* $NetBSD: fb.c,v 1.9 1995/10/05 01:52:57 jonathan Exp $ */ +/* $NetBSD: fb.c,v 1.10.4.1 1996/08/13 08:32:18 jonathan Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -80,24 +80,28 @@ #include <miscfs/specfs/specdev.h> #include <machine/autoconf.h> +#include <sys/conf.h> +#include <machine/conf.h> + #include <machine/machConst.h> #include <machine/pmioctl.h> #include <machine/fbio.h> #include <machine/fbvar.h> #include <pmax/dev/fbreg.h> -/*#include <pmax/dev/lk201.h>*/ +#include <pmax/dev/qvssvar.h> + #include <pmax/stand/dec_prom.h> #include <pmax/pmax/cons.h> #include <pmax/pmax/pmaxtype.h> -#include <rasterconsole.h> +#include "rasterconsole.h" -#include <dc.h> -#include <scc.h> -#include <dtop.h> +#include "dc.h" +#include "scc.h" +#include "dtop.h" /* * This framebuffer driver is a generic driver for all supported @@ -121,26 +125,26 @@ extern void fbScreenInit __P (( struct fbinfo *fi)); #if NDC > 0 #include <machine/dc7085cons.h> -extern int dcGetc(), dcparam(); -extern void dcPutc(); +#include <pmax/dev/dcvar.h> #endif + #if NDTOP > 0 -#include <pmax/dev/dtopreg.h> -extern void dtopKBDPutc(); +#include <pmax/dev/dtopvar.h> #endif + #if NSCC > 0 -#include <pmax/dev/sccreg.h> -extern int sccGetc(), sccparam(); -extern void sccPutc(); +#include <pmax/tc/sccvar.h> #endif -/* LK-201 and successor keycode mapping */ -extern int kbdMapChar __P((int keycode)); -extern void KBDReset __P(( dev_t dev, void (*putc) (dev_t, int) )); +/* + * LK-201 and successor keycode mapping +*/ +#include <pmax/dev/lk201var.h> +extern void rcons_connect __P((struct fbinfo *info)); /* XXX */ /* - * The blessed framebuffer; the fb that gets + * The "blessed" framebuffer; the fb that gets * the qvss-style ring buffer of mouse/kbd events, and is used * for glass-tty fb console output. */ @@ -163,7 +167,7 @@ u_short defCursor[32] = { */ #include <sys/device.h> -#include <fb.h> +#include "fb.h" static struct { @@ -171,11 +175,18 @@ static struct { int cd_ndevs; } fbcd = { {NULL}, 0} ; +void fbattach __P((int n)); + + +/* + * attach routine: required for pseudo-device + */ void fbattach(n) int n; { + /* allocate space for n framebuffers... */ } /* @@ -193,15 +204,17 @@ fbconnect (name, info, silent) static int first = 1; #ifndef FBDRIVER_DOES_ATTACH - /* See if we've already configured this frame buffer; if not, - find a slot for it. */ + /* + * See if we've already configured this frame buffer; + * if not, find an "fb" pseudo-device entry for it. + */ for (fbix = 0; fbix < fbcd.cd_ndevs; fbix++) if ((fbcd.cd_devs [fbix]->fi_type.fb_boardtype == info -> fi_type.fb_boardtype) && fbcd.cd_devs [fbix]->fi_unit == info -> fi_unit) goto got_it; - if (fbcd.cd_ndevs == NFB) { + if (fbcd.cd_ndevs >= NFB) { printf ("fb: more frame buffers probed than configured!\n"); return; } @@ -210,7 +223,9 @@ fbconnect (name, info, silent) fbcd.cd_devs [fbix] = info; #endif /* FBDRIVER_DOES_ATTACH */ - /* If this is the first frame buffer we've seen, pass it to rcons. */ + /* + * If this is the first frame buffer we've seen, pass it to rcons. + */ if (first) { extern dev_t cn_in_dev; /* XXX rcons hackery */ @@ -219,12 +234,7 @@ fbconnect (name, info, silent) #if NRASTERCONSOLE > 0 /*XXX*/ cn_in_dev = cn_tab->cn_dev; /*XXX*/ /* FIXME */ rcons_connect (info); -#else /* no raster console */ - printf("\n"); /* XXX flush out any prom output */ - fbScreenInit(firstfi); - fbScroll(firstfi); - cn_tab->cn_putc = fbPutc; -#endif /* no raster console */ +#endif /* NRASTERCONSOLE */ first = 0; } @@ -240,11 +250,8 @@ got_it: return; } -#if 0 -#include "new_fb.c" /* new framebufer driver with no X support yet */ -#else + #include "fb_usrreq.c" /* old pm-compatblie driver that supports X11R5 */ -#endif /* @@ -264,41 +271,44 @@ tb_kbdmouseconfig(fi) } switch (pmax_boardtype) { + #if NDC > 0 case DS_PMAX: case DS_3MAX: fi->fi_glasstty->KBDPutc = dcPutc; fi->fi_glasstty->kbddev = makedev(DCDEV, DCKBD_PORT); break; -#endif +#endif /* NDC */ + #if NSCC > 0 case DS_3MIN: case DS_3MAXPLUS: fi->fi_glasstty->KBDPutc = sccPutc; fi->fi_glasstty->kbddev = makedev(SCCDEV, SCCKBD_PORT); break; -#endif +#endif /* NSCC */ + #if NDTOP > 0 case DS_MAXINE: fi->fi_glasstty->KBDPutc = dtopKBDPutc; fi->fi_glasstty->kbddev = makedev(DTOPDEV, DTOPKBD_PORT); break; -#endif +#endif /* NDTOP */ + default: printf("Can't configure keyboard/mouse\n"); return (1); }; + return (0); } +/* + * pre-rcons glass-tty emulator (stub) + */ void fbScreenInit(fi) struct fbinfo *fi; { /* how to do this on rcons ? */ } - -#if 0 -/* Use 4.4bsd/pmax frambeuffer glass-tty for console output */ -#include "fb-tty.c" -#endif diff --git a/sys/arch/pmax/dev/fb_usrreq.c b/sys/arch/pmax/dev/fb_usrreq.c index 85e351f8090..5d87a27dfff 100644 --- a/sys/arch/pmax/dev/fb_usrreq.c +++ b/sys/arch/pmax/dev/fb_usrreq.c @@ -1,10 +1,11 @@ /*ARGSUSED*/ -fbopen(dev, flag) +int +fbopen(dev, flag, mode, p) dev_t dev; - int flag; + int flag, mode; + struct proc *p; { register struct fbinfo *fi; - int s; #ifdef fpinitialized if (!fp->initialized) @@ -32,14 +33,14 @@ fbopen(dev, flag) } /*ARGSUSED*/ -fbclose(dev, flag) +int +fbclose(dev, flag, mode, p) dev_t dev; - int flag; + int flag, mode; + struct proc *p; { register struct fbinfo *fi; register struct pmax_fbtty *fbtty; - int pixelsize; - int s; if (minor(dev) >= fbcd.cd_ndevs || (fi = fbcd.cd_devs[minor(dev)]) == NULL) @@ -61,14 +62,15 @@ fbclose(dev, flag) } /*ARGSUSED*/ +int fbioctl(dev, cmd, data, flag, p) dev_t dev; + u_long cmd; caddr_t data; struct proc *p; { register struct fbinfo *fi; register struct pmax_fbtty *fbtty; - int s; char cmap_buf [3]; if (minor(dev) >= fbcd.cd_ndevs || @@ -78,6 +80,11 @@ fbioctl(dev, cmd, data, flag, p) fbtty = fi->fi_glasstty; switch (cmd) { + + /* + * Ultrix-compatible, pm/qvss-style ioctls(). Mostly + * so that X consortium Xservers work. + */ case QIOCGINFO: return (fbmmap_fb(fi, dev, data, p)); @@ -157,13 +164,45 @@ fbioctl(dev, cmd, data, flag, p) (*fi->fi_driver->fbd_blank) (fi); break; + + /* + * Sun-style ioctls, mostly so that screenblank(1) and other + * ``native'' NetBSD applications work. + */ + case FBIOGTYPE: + *(struct fbtype *)data = fi->fi_type; + break; + + case FBIOGETCMAP: + return ((*(fi->fi_driver -> fbd_getcmap)) + (fi, data, 0, fi->fi_type.fb_cmsize)); + + case FBIOPUTCMAP: + return ((*(fi->fi_driver -> fbd_putcmap)) + (fi, data, 0, fi->fi_type.fb_cmsize)); + break; + + case FBIOGVIDEO: + *(int *)data = fi->fi_blanked; + break; + + case FBIOSVIDEO: + if (*(int *)data) + return (*(fi->fi_driver->fbd_blank)) (fi); + else + return (*(fi->fi_driver->fbd_unblank)) (fi); + default: - printf("fb%d: Unknown ioctl command %x\n", minor(dev), cmd); + printf("fb%d: Unknown ioctl command %lx\n", minor(dev), cmd); return (EINVAL); } return (0); } +/* + * Select on Digital-OS-compatible in-kernel input-event ringbuffer. + */ +int fbselect(dev, flag, p) dev_t dev; int flag; @@ -187,8 +226,10 @@ fbselect(dev, flag, p) * Return the physical page number that corresponds to byte offset 'off'. */ /*ARGSUSED*/ +int fbmmap(dev, off, prot) dev_t dev; + int off, prot; { int len; register struct fbinfo *fi; @@ -197,12 +238,12 @@ fbmmap(dev, off, prot) (fi = fbcd.cd_devs[minor(dev)]) == NULL) return(-1); - len = pmax_round_page(((vm_offset_t)fi->fi_fbu & PGOFSET) + len = mips_round_page(((vm_offset_t)fi->fi_fbu & PGOFSET) + sizeof(*fi->fi_fbu)); if (off < len) - return pmax_btop(MACH_CACHED_TO_PHYS(fi->fi_fbu) + off); + return (int)mips_btop(MACH_CACHED_TO_PHYS(fi->fi_fbu) + off); off -= len; if (off >= fi->fi_type.fb_size) return (-1); - return pmax_btop(MACH_UNCACHED_TO_PHYS(fi->fi_pixels) + off); + return (int)mips_btop(MACH_UNCACHED_TO_PHYS(fi->fi_pixels) + off); } diff --git a/sys/arch/pmax/dev/font.c b/sys/arch/pmax/dev/font.c index d8986811158..7452ec7a83d 100644 --- a/sys/arch/pmax/dev/font.c +++ b/sys/arch/pmax/dev/font.c @@ -1,4 +1,4 @@ -/* $NetBSD: font.c,v 1.7 1995/10/05 01:52:44 jonathan Exp $ */ +/* $NetBSD: font.c,v 1.8 1996/04/07 19:53:36 jonathan Exp $ */ /* * Copyright (c) 1991, 1993, 1995 @@ -60,6 +60,8 @@ #include <pmax/dev/qvss.h> /* Little-endian font for rcons */ +void rcons_font __P((struct rconsole *rc)); + void rcons_font(rc) register struct rconsole *rc; diff --git a/sys/arch/pmax/dev/ims332.c b/sys/arch/pmax/dev/ims332.c index 651a6b77a71..83abb3f9b63 100644 --- a/sys/arch/pmax/dev/ims332.c +++ b/sys/arch/pmax/dev/ims332.c @@ -1,4 +1,4 @@ -/* $NetBSD: ims332.c,v 1.1 1995/09/11 08:11:24 jonathan Exp $ */ +/* $NetBSD: ims332.c,v 1.2.4.1 1996/09/09 20:16:32 thorpej Exp $ */ /*- * Copyright (c) 1992, 1993, 1995 @@ -40,6 +40,7 @@ */ #include <sys/param.h> +#include <sys/systm.h> #include <sys/device.h> #include <sys/kernel.h> #include <sys/errno.h> @@ -50,19 +51,25 @@ #include <machine/machConst.h> #include <pmax/dev/ims332.h> +static u_int ims332_read_register (struct fbinfo *, int); +static void ims332_write_register (struct fbinfo *, int, unsigned int); + #define assert_ims332_reset_bit(r) *r &= ~0x40 #define deassert_ims332_reset_bit(r) *r |= 0x40 -int ims332init(fi) +int +ims332init(fi) struct fbinfo *fi; { - register u_int *reset = (u_int *)fi -> fi_base; int i; /* * Initialize the screen. (xcfb-specific) */ #ifdef notdef + register u_int *reset = (u_int *)fi -> fi_base; + + assert_ims332_reset_bit(reset); DELAY(1); /* specs sez 50ns.. */ deassert_ims332_reset_bit(reset); @@ -95,7 +102,7 @@ int ims332init(fi) ims332_write_register (fi, IMS332_REG_XFER_DELAY, 0xa); ims332_write_register (fi, IMS332_REG_COLOR_MASK, 0xffffff); -#endif +#endif /* notdef */ /* Zero out the cursor RAM... */ for (i = 0; i < 512; i++) @@ -191,13 +198,13 @@ ims332LoadColorMap(fi, bits, index, count) for (i = 0; i < count; i++) { ims332_write_register (fi, - IMS332_REG_LUT_BASE + i, - (cmap_bits [i * 3 + 1] << 16) | + IMS332_REG_LUT_BASE + i + index, + (cmap_bits [i * 3 + 2] << 16) | (cmap_bits [i * 3 + 1] << 8) | (cmap_bits [i * 3])); - cmap [(i + index) * 3] = cmap_bits [i * 3]; - cmap [(i + index) * 3 + 1] = cmap_bits [i * 3 + 1]; - cmap [(i + index) * 3 + 2] = cmap_bits [i * 3 + 2]; + cmap [i * 3] = cmap_bits [i * 3]; + cmap [i * 3 + 1] = cmap_bits [i * 3 + 1]; + cmap [i * 3 + 2] = cmap_bits [i * 3 + 2]; } return 0; } @@ -212,7 +219,6 @@ ims332GetColorMap(fi, bits, index, count) { u_char *cmap_bits; u_char *cmap; - int i; if (index > 256 || index < 0 || index + count > 256) return EINVAL; @@ -262,7 +268,6 @@ ims332_video_on (fi) struct fbinfo *fi; { u_char *cmap; - int i; u_int csr; if (!fi -> fi_blanked) @@ -334,7 +339,7 @@ ims332CursorColor (fi, color) struct fbinfo *fi; unsigned int color[]; { - register int i, j; + register int i; for (i = 0; i < 6; i++) cursor_RGB[i] = (u_char)(color[i] >> 8); diff --git a/sys/arch/pmax/dev/ims332.h b/sys/arch/pmax/dev/ims332.h index ff4659d2fdf..0f64e1b2db0 100644 --- a/sys/arch/pmax/dev/ims332.h +++ b/sys/arch/pmax/dev/ims332.h @@ -1,4 +1,4 @@ -/* $NetBSD: ims332.h,v 1.1 1995/09/11 08:11:25 jonathan Exp $ */ +/* $NetBSD: ims332.h,v 1.2 1996/04/08 00:57:38 jonathan Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -168,8 +168,6 @@ #define IMS332_BOOT_xxx 0xffff80 /* reserved, mbz */ int ims332init (struct fbinfo *); -static u_int ims332_read_register (struct fbinfo *, int); -static void ims332_write_register (struct fbinfo *, int, unsigned int); void ims332InitColorMap (struct fbinfo *); int ims332LoadColorMap (struct fbinfo *, caddr_t, int, int); int ims332GetColorMap (struct fbinfo *, caddr_t, int, int); diff --git a/sys/arch/pmax/dev/lk201.c b/sys/arch/pmax/dev/lk201.c index 59f5972e40a..6a792aecf58 100644 --- a/sys/arch/pmax/dev/lk201.c +++ b/sys/arch/pmax/dev/lk201.c @@ -5,6 +5,7 @@ #include <sys/param.h> +#include <sys/systm.h> #include <sys/syslog.h> #include <sys/select.h> #include <dev/cons.h> @@ -12,6 +13,7 @@ #include <machine/pmioctl.h> #include <pmax/dev/lk201.h> +#include <pmax/dev/lk201var.h> /* Exported functions */ diff --git a/sys/arch/pmax/dev/lk201var.h b/sys/arch/pmax/dev/lk201var.h new file mode 100644 index 00000000000..038ac8891f1 --- /dev/null +++ b/sys/arch/pmax/dev/lk201var.h @@ -0,0 +1,15 @@ +#ifndef _LK201VAR_H_ +#define _LK201VAR_H_ + + +#ifdef _KERNEL + +extern int kbdMapChar __P((int)); +extern void KBDReset __P((dev_t, void (*)(dev_t, int))); +extern void MouseInit __P((dev_t, void (*)(dev_t, int), int (*)(dev_t))); +extern void mouseInput __P((int cc)); + +extern int LKgetc __P((dev_t dev)); +extern void lk_divert __P((int (*getfn) __P ((dev_t dev)), dev_t in_dev)); +#endif +#endif /* _LK201VAR_H_ */ diff --git a/sys/arch/pmax/dev/mfb.c b/sys/arch/pmax/dev/mfb.c index 927467e4c8a..d1b243ce73e 100644 --- a/sys/arch/pmax/dev/mfb.c +++ b/sys/arch/pmax/dev/mfb.c @@ -1,4 +1,4 @@ -/* $NetBSD: mfb.c,v 1.8 1995/09/11 07:45:41 jonathan Exp $ */ +/* $NetBSD: mfb.c,v 1.13.4.2 1996/09/09 20:07:04 thorpej Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -80,14 +80,19 @@ * v 9.2 90/02/13 22:16:24 shirriff Exp SPRITE (DECWRL)"; */ -#include <fb.h> -#include <mfb.h> +#include "fb.h" +#include "mfb.h" #if NMFB > 0 #include <sys/param.h> #include <sys/kernel.h> #include <sys/fcntl.h> +#include <sys/malloc.h> #include <sys/errno.h> #include <sys/device.h> +#include <sys/systm.h> + +#include <machine/autoconf.h> +#include <dev/tc/tcvar.h> #include <machine/machConst.h> #include <machine/pmioctl.h> @@ -107,15 +112,22 @@ struct fbuaccess mfbu; struct pmax_fbtty mfbfb; struct fbinfo mfbfi; /*XXX*/ +extern int pmax_boardtype; + /* * Forward references. */ +#define CMAP_BITS (3 * 256) /* 256 entries, 3 bytes per. */ +static u_char cmap_bits [CMAP_BITS]; /* colormap for console... */ + extern void fbScreenInit __P((struct fbinfo *fia)); void mfbPosCursor __P((struct fbinfo *fi, int x, int y)); +int mfbinit __P((struct fbinfo *fi, caddr_t mfbaddr, int unit, int silent)); + #if 1 /* these go away when we use the abstracted-out chip drivers */ static void mfbLoadCursor __P((struct fbinfo *fi, u_short *ptr)); static void mfbRestoreCursorColor __P((struct fbinfo *fi)); @@ -136,9 +148,16 @@ int mfbGetColorMap __P((struct fbinfo *fi, caddr_t, int, int)); static int bt455_video_on __P((struct fbinfo *)); static int bt455_video_off __P((struct fbinfo *)); -static void bt431_select_reg(); -static void bt431_write_reg(), bt431_init(); -static u_char bt431_read_reg(); + +static void bt431_init __P((bt431_regmap_t *regs)); +static void bt431_select_reg __P((bt431_regmap_t *regs, int regno)); +static void bt431_write_reg __P((bt431_regmap_t *regs, int regno, int val)); + +#ifdef notused +static u_char bt431_read_reg __P((bt431_regmap_t *regs, int regno)); +#endif + + /* * old pmax-framebuffer hackery @@ -173,8 +192,6 @@ struct fbdriver mfb_driver = { #define MFB_OFFSET_ROM 0x0 /* Diagnostic ROM */ #define MFB_FB_SIZE 0x200000 /* frame buffer size */ -#include <sys/device.h> -#include <machine/autoconf.h> /* * Autoconfiguration data for config.new. @@ -184,22 +201,15 @@ struct fbdriver mfb_driver = { int mfbmatch __P((struct device *, void *, void *)); void mfbattach __P((struct device *, struct device *, void *)); +int mfb_intr __P((void *sc)); -struct cfdriver mfbcd = { - NULL, "mfb", mfbmatch, mfbattach, DV_DULL, sizeof(struct device), 0 +struct cfattach mfb_ca = { + sizeof(struct device), mfbmatch, mfbattach }; -#if 0 -int -mfbprobe(addr) - caddr_t addr; -{ - - /* make sure that we're looking for this type of device. */ - if (!BUS_MATCHNAME(ca, "PMAG-AA ")) - return (0); -} -#endif +struct cfdriver mfb_cd = { + NULL, "mfb", DV_DULL +}; int mfbmatch(parent, match, aux) @@ -207,9 +217,7 @@ mfbmatch(parent, match, aux) void *match; void *aux; { - struct cfdata *cf = match; - struct confargs *ca = aux; - static int nmfbs = 1; + struct tc_attach_args *ta = aux; #ifdef FBDRIVER_DOES_ATTACH /* leave configuration to the fb driver */ @@ -217,14 +225,9 @@ mfbmatch(parent, match, aux) #endif /* make sure that we're looking for this type of device. */ - if (!BUS_MATCHNAME(ca, "PMAG-AA ")) + if (!TC_BUS_MATCHNAME(ta, "PMAG-AA ")) return (0); -#ifdef notyet - /* if it can't have the one mentioned, reject it */ - if (cf->cf_unit >= nmfbs) - return (0); -#endif return (1); } @@ -234,23 +237,32 @@ mfbattach(parent, self, aux) struct device *self; void *aux; { - struct confargs *ca = aux; - caddr_t base = BUS_CVTADDR(ca); + struct tc_attach_args *ta = aux; + caddr_t mfbaddr = (caddr_t) ta->ta_addr; int unit = self->dv_unit; - struct fbinfo *fi = &mfbfi; + struct fbinfo *fi = (struct fbinfo *) self; #ifdef notyet + struct fbinfo *fi = &mfbfi; + /* if this is the console, it's already configured. */ - if (ca->ca_slotpri == cons_slot) + if (ta->ta_cookie == cons_slot) return; /* XXX patch up f softc pointer */ #endif - - if (!mfbinit(BUS_CVTADDR(ca), unit, 0)) + if (!mfbinit(fi, mfbaddr, unit, 0)) return; - /* no interrupts for MFB */ - /*BUS_INTR_ESTABLISH(ca, sccintr, self->dv_unit);*/ + /* + * 3MIN does not mask un-established TC option interrupts, + * so establish a handler. + * XXX Should store cmap updates in softc and apply in the + * interrupt handler, which interrupts during vertical-retrace. + */ + if (pmax_boardtype == DS_3MIN) { + tc_intr_establish(parent, (void*)ta->ta_cookie, TC_IPL_NONE, + mfb_intr, fi); + } printf("\n"); } @@ -259,17 +271,37 @@ mfbattach(parent, self, aux) * Initialization */ int -mfbinit(mfbaddr, unit, silent) +mfbinit(fi, mfbaddr, unit, silent) + struct fbinfo *fi; caddr_t mfbaddr; int unit; int silent; { - register struct fbinfo *fi = &mfbfi; + + register int isconsole = 0; + + /* + * If this device is being intialized as the console, malloc() + * is not yet up and we must use statically-allocated space. + */ + if (fi == NULL) { + fi = &mfbfi; /* XXX */ + fi->fi_cmap_bits = (caddr_t)cmap_bits; + isconsole = 1; + } + else { + fi->fi_cmap_bits = malloc(CMAP_BITS, M_DEVBUF, M_NOWAIT); + if (fi->fi_cmap_bits == NULL) { + printf("mfb%d: no memory for cmap\n", unit); + return (0); + } + } /* check for no frame buffer */ - if (badaddr(mfbaddr, 4)) + if (badaddr(mfbaddr, 4)) { + printf("mfb: bad address 0x%p\n", mfbaddr); return (0); - + } /* Fill in main frame buffer info struct. */ fi->fi_unit = unit; @@ -281,7 +313,6 @@ mfbinit(mfbaddr, unit, silent) fi->fi_linebytes = 1280; fi->fi_driver = &mfb_driver; fi->fi_blanked = 0; - fi->fi_cmap_bits = (caddr_t)0; /* Fill in Frame Buffer Type struct. */ fi->fi_type.fb_boardtype = PMAX_FBTYPE_MFB; @@ -326,7 +357,9 @@ mfbinit(mfbaddr, unit, silent) if (tb_kbdmouseconfig(fi)) return (0); - mfbInitColorMapBlack(fi, 0); + /* white-on-black if console, black-on-black otherwise. */ + mfbInitColorMapBlack(fi, isconsole); + /* * Connect to the raster-console pseudo-driver. @@ -417,11 +450,11 @@ mfbRestoreCursorColor (fi) else fg = 0; regs->addr_ovly = fg; - MachEmptyWriteBuffer(); + wbflush(); regs->addr_ovly = fg; - MachEmptyWriteBuffer(); + wbflush(); regs->addr_ovly = fg; - MachEmptyWriteBuffer(); + wbflush(); } /* Set the color of the cursor. */ @@ -431,7 +464,7 @@ mfbCursorColor(fi, color) struct fbinfo *fi; unsigned int color[]; { - register int i, j; + register int i; for (i = 0; i < 6; i++) cursor_RGB[i] = (u_char)(color[i] >> 8); @@ -544,14 +577,15 @@ mfbLoadColorMap(fi, bits, index, count) for (i = 0; i < count; i++) { cmap [(i + index) * 3] = regs->addr_cmap_data = cmap_bits [i * 3] >> 4; - MachEmptyWriteBuffer(); + wbflush(); cmap [(i + index) * 3 + 1] = regs->addr_cmap_data = cmap_bits [i * 3 + 1] >> 4; - MachEmptyWriteBuffer(); + wbflush(); cmap [(i + index) * 3 + 2] = regs->addr_cmap_data = cmap_bits [i * 3 + 2] >> 4; - MachEmptyWriteBuffer(); + wbflush(); } + return 0; } /* stub for driver */ @@ -573,10 +607,9 @@ mfbGetColorMap(fi, bits, index, count) caddr_t bits; int index, count; { - bt455_regmap_t *regs = (bt455_regmap_t *)(fi -> fi_vdac); + /*bt455_regmap_t *regs = (bt455_regmap_t *)(fi -> fi_vdac);*/ u_char *cmap_bits; u_char *cmap; - int i; if (index > 15 || index < 0 || index + count > 15) return EINVAL; @@ -599,7 +632,7 @@ bt455_video_on(fi) u_char *cmap; if (!fi -> fi_blanked) - return; + return 0; cmap = (u_char *)(fi -> fi_cmap_bits); @@ -607,10 +640,12 @@ bt455_video_on(fi) BT455_SELECT_ENTRY(regs, 0); for (i = 0; i < 6; i++) { regs->addr_cmap_data = cmap [i]; - MachEmptyWriteBuffer(); + wbflush(); } mfbRestoreCursorColor (fi); fi -> fi_blanked = 0; + + return 0; } /* @@ -638,7 +673,7 @@ bt455_video_off(fi) u_char *cmap; if (fi -> fi_blanked) - return; + return 0; cmap = (u_char *)(fi -> fi_cmap_bits); @@ -649,13 +684,15 @@ bt455_video_off(fi) for (i = 0; i < 6; i++) { cursor_RGB[i] = 0; regs->addr_cmap_data = 0; - MachEmptyWriteBuffer(); + wbflush(); } mfbRestoreCursorColor (fi); bcopy (cursor_save, cursor_RGB, 6); fi -> fi_blanked = 0; + + return 0; } /* @@ -667,7 +704,7 @@ bt431_select_reg(regs, regno) { regs->addr_lo = SET_VALUE(regno & 0xff); regs->addr_hi = SET_VALUE((regno >> 8) & 0xff); - MachEmptyWriteBuffer(); + wbflush(); } static void @@ -676,9 +713,10 @@ bt431_write_reg(regs, regno, val) { bt431_select_reg(regs, regno); regs->addr_reg = SET_VALUE(val); - MachEmptyWriteBuffer(); + wbflush(); } +#ifdef notused static u_char bt431_read_reg(regs, regno) bt431_regmap_t *regs; @@ -686,12 +724,13 @@ bt431_read_reg(regs, regno) bt431_select_reg(regs, regno); return (GET_VALUE(regs->addr_reg)); } +#endif + static void bt431_init(regs) bt431_regmap_t *regs; { - register int i; /* use 4:1 input mux */ bt431_write_reg(regs, BT431_REG_CMD, @@ -714,5 +753,24 @@ bt431_init(regs) BT431_WRITE_REG_AUTOI(regs, 0x00); BT431_WRITE_REG_AUTOI(regs, 0x00); } + +/* + * copied from cfb_intr + */ +int +mfb_intr(sc) + void *sc; +{ + struct fbinfo *fi = /* XXX (struct fbinfo *)sc */ &mfbfi; + volatile int junk; + char *slot_addr = (((char *)fi->fi_base) - MFB_OFFSET_BT431); + + /* reset vertical-retrace interrupt by writing a dont-care */ + junk = *(volatile int*) (slot_addr + MFB_OFFSET_IREQ); + *(volatile int*) (slot_addr + MFB_OFFSET_IREQ) = 0; + + return (0); +} + #endif /* NMFB */ diff --git a/sys/arch/pmax/dev/mfbreg.h b/sys/arch/pmax/dev/mfbreg.h index d4a25a6f49d..039ad395a42 100644 --- a/sys/arch/pmax/dev/mfbreg.h +++ b/sys/arch/pmax/dev/mfbreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: mfbreg.h,v 1.4 1994/10/26 21:09:11 cgd Exp $ */ +/* $NetBSD: mfbreg.h,v 1.4.6.1 1996/08/13 08:03:52 jonathan Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -87,7 +87,7 @@ typedef struct { /* when using autoincrement */ #define BT431_WRITE_REG_AUTOI(regs, val) { \ (regs)->addr_reg = SET_VALUE(val); \ - MachEmptyWriteBuffer(); \ + wbflush(); \ } #define BT431_READ_REG_AUTOI(regs) \ @@ -95,7 +95,7 @@ typedef struct { #define BT431_WRITE_CMAP_AUTOI(regs, val) { \ (regs)->addr_cmap = (val); \ - MachEmptyWriteBuffer(); \ + wbflush(); \ } #define BT431_READ_CMAP_AUTOI(regs) \ @@ -118,7 +118,7 @@ typedef struct { */ #define BT455_SELECT_ENTRY(regs, regno) { \ (regs)->addr_cmap = (regno)&0x0f; \ - MachEmptyWriteBuffer(); \ + wbflush(); \ } /* diff --git a/sys/arch/pmax/dev/pdma.h b/sys/arch/pmax/dev/pdma.h index 96a74169f01..f0bc1c153ce 100644 --- a/sys/arch/pmax/dev/pdma.h +++ b/sys/arch/pmax/dev/pdma.h @@ -1,4 +1,4 @@ -/* $NetBSD: pdma.h,v 1.4 1994/10/26 21:09:11 cgd Exp $ */ +/* $NetBSD: pdma.h,v 1.5 1996/04/10 17:38:04 jonathan Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -43,5 +43,5 @@ struct pdma { char *p_mem; char *p_end; int p_arg; - void (*p_fcn)(); + void (*p_fcn) __P((struct tty *tp)); }; diff --git a/sys/arch/pmax/dev/pm.c b/sys/arch/pmax/dev/pm.c index 28a4a093ee9..fa4244302ba 100644 --- a/sys/arch/pmax/dev/pm.c +++ b/sys/arch/pmax/dev/pm.c @@ -1,4 +1,4 @@ -/* $NetBSD: pm.c,v 1.10 1995/11/25 10:39:57 mellon Exp $ */ +/* $NetBSD: pm.c,v 1.14.4.1 1996/09/09 20:49:38 thorpej Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -56,9 +56,9 @@ */ -#include <fb.h> -#include <pm.h> -#include <dc.h> +#include "fb.h" +#include "pm.h" +#include "dc.h" #if NPM > 0 #if NDC == 0 pm needs dc device @@ -72,6 +72,7 @@ pm needs dc device #include <sys/errno.h> #include <sys/proc.h> #include <sys/mman.h> +#include <sys/malloc.h> #include <vm/vm.h> @@ -113,10 +114,6 @@ extern void pmScreenInit __P((struct fbinfo *fi)); static void pmLoadCursor __P((struct fbinfo *fi, u_short *ptr)); void pmPosCursor __P((struct fbinfo *fi, int x, int y)); -#ifdef notyet /* these should be removed */ -static void pmRestoreCursorColor __P(()); - -#endif void bt478CursorColor __P((struct fbinfo *fi, u_int *color)); void bt478InitColorMap __P((struct fbinfo *fi)); @@ -151,7 +148,7 @@ void genKbdEvent(), genMouseEvent(), genMouseButtons(); extern void pmEventQueueInit __P((pmEventQueue *qe)); #define CMAP_BITS (3 * 256) /* 256 entries, 3 bytes per. */ -static u_char cmap_bits [NPM * CMAP_BITS]; /* One colormap per pm... */ +static u_char cmap_bits [CMAP_BITS]; /* colormap for console... */ /* @@ -163,8 +160,12 @@ static u_char cmap_bits [NPM * CMAP_BITS]; /* One colormap per pm... */ int pmmatch __P((struct device *, void *, void *)); void pmattach __P((struct device *, struct device *, void *)); -struct cfdriver pmcd = { - NULL, "pm", pmmatch, pmattach, DV_DULL, sizeof(struct device), 0 +struct cfattach pm_ca = { + sizeof(struct device), pmmatch, pmattach +}; + +struct cfdriver pm_cd = { + NULL, "pm", DV_DULL }; /* new-style raster-cons "driver" methods */ @@ -188,22 +189,15 @@ pmmatch(parent, match, aux) { struct cfdata *cf = match; struct confargs *ca = aux; - static int npms = 1; - caddr_t pmaddr = BUS_CVTADDR(ca); - + caddr_t pmaddr = (caddr_t)ca->ca_addr; /* make sure that we're looking for this type of device. */ - if (!BUS_MATCHNAME(ca, "pm")) + if (strcmp(ca->ca_name, "pm") != 0) return (0); if (badaddr(pmaddr, 4)) return (0); -#ifdef notyet - /* if it can't have the one mentioned, reject it */ - if (cf->cf_unit >= npms) - return (0); -#endif return (1); } @@ -214,20 +208,21 @@ pmattach(parent, self, aux) void *aux; { struct confargs *ca = aux; - caddr_t pmaddr = BUS_CVTADDR(ca); + caddr_t pmaddr = (caddr_t)ca->ca_addr; if (!pminit(&pmfi, 0, 0)) return; /* no interrupts for PM */ /*BUS_INTR_ESTABLISH(ca, sccintr, self->dv_unit);*/ + printf("\n"); return; } /* - * Test to see if device is present. - * Return true if found and initialized ok. + * pmax FB initialization. This is abstracted out from pmbattch() so + * that a console framebuffer can be initialized early in boot. */ pminit(fi, unit, silent) struct fbinfo *fi; @@ -236,7 +231,21 @@ pminit(fi, unit, silent) { register PCCRegs *pcc = (PCCRegs *)MACH_PHYS_TO_UNCACHED(KN01_SYS_PCC); - if (fi == 0) fi = &pmfi; + /*XXX*/ + /* + * If this device is being intialized as the console, malloc() + * is not yet up and we must use statically-allocated space. + */ + if (fi == NULL) { + fi = &pmfi; /* XXX */ + fi->fi_cmap_bits = (caddr_t)cmap_bits; + } else { + fi->fi_cmap_bits = malloc(CMAP_BITS, M_DEVBUF, M_NOWAIT); + if (fi->fi_cmap_bits == NULL) { + printf("pm%d: no memory for cmap 0x%x\n", unit); + return (0); + } + } /* Set address of frame buffer... */ fi->fi_pixels = (caddr_t)MACH_PHYS_TO_UNCACHED(KN01_PHYS_FBUF_START); @@ -310,7 +319,7 @@ pminit(fi, unit, silent) /* * Initialize the color map, the screen, and the mouse. */ - bt478init(&pmfi); + bt478init(fi); /* * Initialize old-style pmax screen info. @@ -326,7 +335,7 @@ pminit(fi, unit, silent) #ifdef notanymore - bt478InitColorMap(&pmfi); /* done inside bt478init() */ + bt478InitColorMap(fi); /* done inside bt478init() */ #endif /* diff --git a/sys/arch/pmax/dev/pmvar.h b/sys/arch/pmax/dev/pmvar.h new file mode 100644 index 00000000000..c56f1b8c9ac --- /dev/null +++ b/sys/arch/pmax/dev/pmvar.h @@ -0,0 +1,5 @@ +/* + * Initialize a Decstation 3100/2100 baseboard framebuffer, + * so it can be used as a bitmapped glass-tty console device. + */ +int pminit __P((struct fbinfo *fi, int unit, int silent)); diff --git a/sys/arch/pmax/dev/qvss.h b/sys/arch/pmax/dev/qvss.h index 8fc863f07e9..e2fb9145bcd 100644 --- a/sys/arch/pmax/dev/qvss.h +++ b/sys/arch/pmax/dev/qvss.h @@ -1,4 +1,4 @@ -/* $NetBSD: qvss.h,v 1.3 1995/12/14 16:27:33 jonathan Exp $ */ +/* $NetBSD: qvss.h,v 1.4 1996/04/07 19:54:37 jonathan Exp $ */ /* * Copyright (c) 1992, 1993 @@ -567,21 +567,21 @@ static u_int32_t qvss_58_pixels [] = { static struct raster qvss_58 = { 8, 15, 1, 1, qvss_58_pixels, 0 }; static u_int32_t qvss_59_pixels [] = { - 0x00, /* 0x00000000 /* */ - 0x00, /* 0x00000000 /* */ - 0x00, /* 0x00000000 /* */ - 0x00, /* 0x00000000 /* */ - 0x00, /* 0x00000000 /* */ - 0x08, /* 0x00001000 /* */ - 0x1c, /* 0x00011100 /* */ - 0x08, /* 0x00001000 /* */ - 0x00, /* 0x00000000 /* */ - 0x00, /* 0x00000000 /* */ - 0x1c, /* 0x00011100 /* */ - 0x0c, /* 0x00001100 /* */ - 0x02, /* 0x00000010 /* */ - 0x00, /* 0x00000000 /* */ - 0x00, /* 0x00000000 /* */ + 0x00, /* 0x00000000 ; */ + 0x00, /* 0x00000000 ; */ + 0x00, /* 0x00000000 ; */ + 0x00, /* 0x00000000 ; */ + 0x00, /* 0x00000000 ; */ + 0x08, /* 0x00001000 ; */ + 0x1c, /* 0x00011100 ; */ + 0x08, /* 0x00001000 ; */ + 0x00, /* 0x00000000 ; */ + 0x00, /* 0x00000000 ; */ + 0x1c, /* 0x00011100 ; */ + 0x0c, /* 0x00001100 ; */ + 0x02, /* 0x00000010 ; */ + 0x00, /* 0x00000000 ; */ + 0x00, /* 0x00000000 ; */ }; static struct raster qvss_59 = { 8, 15, 1, 1, qvss_59_pixels, 0 }; diff --git a/sys/arch/pmax/dev/qvss_compat.c b/sys/arch/pmax/dev/qvss_compat.c index ebca22aabac..f618efd81f9 100644 --- a/sys/arch/pmax/dev/qvss_compat.c +++ b/sys/arch/pmax/dev/qvss_compat.c @@ -1,4 +1,4 @@ -/* $NetBSD: qvss_compat.c,v 1.2 1995/09/18 03:01:24 jonathan Exp $ */ +/* $NetBSD: qvss_compat.c,v 1.4 1996/05/19 01:16:18 jonathan Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -81,7 +81,7 @@ #include <machine/fbio.h> #include <machine/fbvar.h> -#include <pmax/dev/fbreg.h> +#include <pmax/dev/fbreg.h> /* XXX should be renamed fbvar.h */ #include <pmax/dev/lk201.h> /*#include <pmax/stand/dec_prom.h>*/ @@ -89,19 +89,27 @@ #include <pmax/pmax/cons.h> #include <pmax/pmax/pmaxtype.h> -#include <dc.h> -#include <scc.h> -#include <dtop.h> +#include "dc.h" +#include "scc.h" +#include "dtop.h" /* * Forward / extern references. */ -extern void pmEventQueueInit __P((pmEventQueue *qe)); -void fbKbdEvent(), fbMouseEvent(), fbMouseButtons(), fbScroll(); +#include <pmax/dev/qvssvar.h> /* our own externs */ extern int pmax_boardtype; +extern void pmEventQueueInit __P((pmEventQueue *qe)); +void genKbdEvent __P((int ch)); +void genMouseEvent __P((MouseReport *newRepPtr)); +void genMouseButtons __P((MouseReport *newRepPtr)); +void genConfigMouse __P((void)); +void genDeconfigMouse __P((void)); +void mouseInput __P((int cc)); + + #if NDC > 0 extern void (*dcDivertXInput)(); @@ -146,6 +154,7 @@ extern struct fbinfo *firstfi; * are gone. Note that the QVSS/pm mapped event buffer includes the * fbu field initialized below. */ +void init_pmaxfbu(fi) struct fbinfo *fi; { @@ -188,8 +197,7 @@ init_pmaxfbu(fi) if (tty_rows != fbu->scrInfo.max_row || tty_cols != fbu->scrInfo.max_col) - printf("framebuffer init: size mismatch", - "given %dx%d, compute %dx%x\n", + printf("framebuffer init: size mismatch: given %dx%d, compute %dx%d\n", fbu->scrInfo.max_row, fbu->scrInfo.max_col, tty_rows, tty_cols); @@ -471,6 +479,7 @@ fbMouseButtons(newRepPtr, fi) * address space. * Return errno if there was an error. */ +int fbmmap_fb(fi, dev, data, p) struct fbinfo *fi; dev_t dev; @@ -485,9 +494,9 @@ fbmmap_fb(fi, dev, data, p) struct fbuaccess *fbp; register struct fbuaccess *fbu = fi->fi_fbu; - len = pmax_round_page(((vm_offset_t)fbu & PGOFSET) + + len = mips_round_page(((vm_offset_t)fbu & PGOFSET) + sizeof(struct fbuaccess)) + - pmax_round_page(fi->fi_type.fb_size); + mips_round_page(fi->fi_type.fb_size); addr = (vm_offset_t)0x20000000; /* XXX */ vn.v_type = VCHR; /* XXX */ vn.v_specinfo = &si; /* XXX */ @@ -509,7 +518,7 @@ fbmmap_fb(fi, dev, data, p) /* * Map the frame buffer into the user's address space. */ - fbu->scrInfo.bitmap = (char *)pmax_round_page(fbp + 1); + fbu->scrInfo.bitmap = (char *)mips_round_page(fbp + 1); return (0); } diff --git a/sys/arch/pmax/dev/qvssvar.h b/sys/arch/pmax/dev/qvssvar.h new file mode 100644 index 00000000000..8b8a9ea1c80 --- /dev/null +++ b/sys/arch/pmax/dev/qvssvar.h @@ -0,0 +1,28 @@ +/* $NetBSD: qvssvar.h,v 1.1 1996/05/19 00:48:43 jonathan Exp $ */ +/* + * Copyright 1996 The Board of Trustees of The Leland Stanford + * Junior University. All Rights Reserved. + * + * Permission to use, copy, modify, and distribute this + * software and its documentation for any purpose and without + * fee is hereby granted, provided that the above copyright + * notice appear in all copies. Stanford University + * makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * This file contributed by Jonathan Stone. + */ + +#ifdef _KERNEL + +void pmEventQueueInit __P((pmEventQueue *qe)); + +void genKbdEvent __P((int ch)); +void genMouseEvent __P((MouseReport *newRepPtr)); +void genMouseButtons __P((MouseReport *newRepPtr)); +void genConfigMouse __P((void)); +void genDeconfigMouse __P((void)); +void mouseInput __P((int cc)); + +#endif /* _KERNEL */ diff --git a/sys/arch/pmax/dev/rcons.c b/sys/arch/pmax/dev/rcons.c index 12defae2008..6d07990b995 100644 --- a/sys/arch/pmax/dev/rcons.c +++ b/sys/arch/pmax/dev/rcons.c @@ -1,4 +1,4 @@ -/* $NetBSD: rcons.c,v 1.6 1995/10/05 01:52:51 jonathan Exp $ */ +/* $NetBSD: rcons.c,v 1.9 1996/05/19 01:06:14 jonathan Exp $ */ /* * Copyright (c) 1995 @@ -37,7 +37,7 @@ * */ -#include <rasterconsole.h> +#include "rasterconsole.h" #if NRASTERCONSOLE > 0 #include <sys/param.h> @@ -49,10 +49,12 @@ #include <sys/file.h> #include <sys/stat.h> #include <sys/conf.h> +#include <machine/conf.h> #include <sys/vnode.h> #include <pmax/stand/dec_prom.h> + #include <pmax/dev/sccreg.h> #include <pmax/pmax/kn01.h> #include <pmax/pmax/kn02.h> @@ -67,6 +69,7 @@ #include <sys/device.h> #include <machine/fbio.h> #include <dev/rcons/rcons.h> +#include <dev/rcons/rcons_subr.h> #include <dev/rcons/raster.h> #include <machine/fbvar.h> @@ -91,11 +94,20 @@ dev_t cn_in_dev = NODEV; /* console input device. */ char rcons_maxcols [20]; -void rcons_vputc __P ((dev_t dev, int c)); +void rcons_connect __P((struct fbinfo *info)); +void rasterconsoleattach __P((int n)); +void rcons_vputc __P ((dev_t dev, int c)); + + +void rconsreset __P((struct tty *tp, int rw)); +void rconsstrategy __P((struct buf *bp)); +void rcons_input __P((dev_t dev, int ic)); + +void rconsstart __P((struct tty *)); -extern int (*v_putc) /*__P((dev_t dev, int c))*/ (); void nobell __P ((int)); + /* * rcons_connect is called by fbconnect when the first frame buffer is * attached. That frame buffer will always be the console frame buffer. @@ -107,7 +119,6 @@ rcons_connect (info) static struct rconsole rc; static int row, col; - void * tem; /* If we're running a serial console, don't set up a raster console even if there's a device that can support it. */ if (cn_tab -> cn_pri == CN_REMOTE) @@ -153,7 +164,6 @@ rcons_connect (info) row = (rc.rc_height / HW_FONT_HEIGHT) - 1; col = 0; - tem = v_putc; /* rcons putchar signature doesn't match dev/cons */ rcons_init (&rc); @@ -177,8 +187,6 @@ rcons_vputc(dev, c) dev_t dev; int c; { - int s; - /* * Call the pointer-to-function that rcons_init tried to give us, * discarding the dev_t argument. @@ -192,12 +200,18 @@ rcons_vputc(dev, c) * device, and isn't on a sparc; this is a useful point to set up * the vnode, clean up pmax console initialization, and set * the initial tty size. + */ /* ARGSUSED */ +void rasterconsoleattach (n) int n; { register struct tty *tp = &rcons_tty [0]; + +#ifdef notyet int status; +#endif + /* Set up the tty queues now... */ clalloc(&tp->t_rawq, 1024, 1); @@ -229,13 +243,14 @@ rasterconsoleattach (n) } /* ARGSUSED */ +int rconsopen(dev, flag, mode, p) dev_t dev; int flag, mode; struct proc *p; { register struct tty *tp = &rcons_tty [0]; - static int firstopen = 1; + /*static int firstopen = 1;*/ int status; if ((tp->t_state & TS_ISOPEN) == 0) { @@ -258,13 +273,13 @@ rconsopen(dev, flag, mode, p) } /* ARGSUSED */ +int rconsclose(dev, flag, mode, p) dev_t dev; int flag, mode; struct proc *p; { register struct tty *tp = &rcons_tty [0]; - struct vnode *vp; (*linesw[tp->t_line].l_close)(tp, flag); ttyclose(tp); @@ -273,6 +288,7 @@ rconsclose(dev, flag, mode, p) } /* ARGSUSED */ +int rconsread(dev, uio, flag) dev_t dev; struct uio *uio; @@ -284,6 +300,7 @@ rconsread(dev, uio, flag) } /* ARGSUSED */ +int rconswrite(dev, uio, flag) dev_t dev; struct uio *uio; @@ -303,6 +320,7 @@ rconstty(dev) return (tp); } +int rconsioctl(dev, cmd, data, flag, p) dev_t dev; u_long cmd; @@ -322,13 +340,16 @@ rconsioctl(dev, cmd, data, flag, p) } /* ARGSUSED */ +int rconsstop (tp, rw) struct tty *tp; int rw; { + return (0); } /*ARGSUSED*/ +void rconsreset (tp, rw) struct tty *tp; int rw; @@ -336,6 +357,7 @@ rconsreset (tp, rw) } /*ARGSUSED*/ +int rconsselect(dev, which, p) dev_t dev; int which; @@ -345,11 +367,16 @@ rconsselect(dev, which, p) } /*ARGSUSED*/ -rconsmmap () +int +rconsmmap (dev, off, prot) + dev_t dev; + int off; + int prot; { return 0; } +void rconsstrategy(bp) struct buf *bp; { @@ -358,6 +385,7 @@ rconsstrategy(bp) /* Called by real input device when there is input for rcons. Passes input through line discpline interrupt routine... */ +void rcons_input (dev, ic) dev_t dev; int ic; diff --git a/sys/arch/pmax/dev/rz.c b/sys/arch/pmax/dev/rz.c index 3de5bea69da..d387755c60f 100644 --- a/sys/arch/pmax/dev/rz.c +++ b/sys/arch/pmax/dev/rz.c @@ -1,4 +1,4 @@ -/* $NetBSD: rz.c,v 1.13 1996/01/07 22:02:52 thorpej Exp $ */ +/* $NetBSD: rz.c,v 1.15.4.1 1996/06/16 17:20:48 mhitch Exp $ */ /* * Copyright (c) 1992, 1993 @@ -68,15 +68,21 @@ #include <machine/pte.h> -extern int splbio(); -extern void splx(); -extern int physio(); +#include <sys/conf.h> +#include <machine/conf.h> + +int rzprobe __P((void /*register struct pmax_scsi_device*/ *sd)); +void rzstart __P((int unit)); +void rzdone __P((int unit, int error, int resid, int status)); +void rzgetinfo __P((dev_t dev)); +int rzsize __P((dev_t dev)); + -int rzprobe(); -void rzstrategy(), rzstart(), rzdone(); struct pmax_driver rzdriver = { - "rz", rzprobe, rzstart, rzdone, + "rz", rzprobe, + (void (*) __P((struct ScsiCmd *cmd))) rzstart, + rzdone, }; struct size { @@ -94,28 +100,29 @@ struct size { */ static struct size rzdefaultpart[MAXPARTITIONS] = { #ifdef GENERIC /* greedy machines have 64 meg of swap */ - 0, 32768, /* A */ - 32768, 131072, /* B */ - 0, 0, /* C */ - 17408, 0, /* D */ - 115712, 0, /* E */ - 218112, 0, /* F */ - 163840, 0, /* G */ - 115712, 0, /* H */ + { 0, 32768 }, /* A */ + { 32768, 131072 }, /* B */ + { 0, 0 }, /* C */ + { 17408, 0 }, /* D */ + { 115712, 0 }, /* E */ + { 218112, 0 }, /* F */ + { 163840, 0 }, /* G */ + { 115712, 0 } /* H */ #else - 0, 16384, /* A */ - 16384, 65536, /* B */ - 0, 0, /* C */ - 17408, 0, /* D */ - 115712, 0, /* E */ - 218112, 0, /* F */ - 81920, 0, /* G */ - 115712, 0, /* H */ + { 0, 16384 }, /* A */ + { 16384, 65536 }, /* B */ + { 0, 0 }, /* C */ + { 17408, 0 }, /* D */ + { 115712, 0 }, /* E */ + { 218112, 0 }, /* F */ + { 81920, 0 }, /* G */ + { 115712, 0 } /* H */ #endif }; -extern char *readdisklabel __P((dev_t dev, void (*strat)(), - struct disklabel *lp, struct cpu_disklabel *osdep)); +extern char * +readdisklabel __P((dev_t dev, void (*strat) __P((struct buf *bp)), + struct disklabel *lp, struct cpu_disklabel *osdep)); /* * Ultrix disklabel declarations @@ -124,7 +131,7 @@ extern char *readdisklabel __P((dev_t dev, void (*strat)(), #include "../../stand/dec_boot.h" extern char * -compat_label __P((dev_t dev, void (*strat)(), +compat_label __P((dev_t dev, void (*strat) __P((struct buf *bp)), struct disklabel *lp, struct cpu_disklabel *osdep)); #endif @@ -325,13 +332,17 @@ rzready(sc) * Test to see if device is present. * Return true if found and initialized ok. */ -rzprobe(sd) - register struct pmax_scsi_device *sd; +int +rzprobe(xxxsd) + void *xxxsd; { + register struct pmax_scsi_device *sd = xxxsd; register struct rz_softc *sc = &rz_softc[sd->sd_unit]; register int i; ScsiInquiryData inqbuf; - ScsiClass7Sense *sp; + + if (sd->sd_unit >= NRZ) + return (0); /* init some parameters that don't change */ sc->sc_sd = sd; @@ -373,7 +384,8 @@ rzprobe(sd) break; default: /* not a disk */ - printf("rz%d: unknown media code 0x%x\n", inqbuf.type); + printf("rz%d: unknown media code 0x%x\n", + sd->sd_unit, inqbuf.type); goto bad; } sc->sc_type = inqbuf.type; @@ -388,7 +400,7 @@ rzprobe(sd) printf("rz%d at %s%d drive %d slave %d", sd->sd_unit, sd->sd_cdriver->d_name, sd->sd_ctlr, sd->sd_drive, sd->sd_slave); - if (inqbuf.version > 1 || i < 36) + if (inqbuf.version < 1 || i < 36) printf(" type 0x%x, qual 0x%x, ver %d", inqbuf.type, inqbuf.qualifier, inqbuf.version); else { @@ -469,7 +481,7 @@ rzlblkstrat(bp, bsize) addr = bp->b_un.b_addr; #ifdef DEBUG if (rzdebug & RZB_PARTIAL) - printf("rzlblkstrat: bp %x flags %x bn %x resid %x addr %x\n", + printf("rzlblkstrat: bp %p flags %lx bn %x resid %x addr %p\n", bp, bp->b_flags, bn, resid, addr); #endif @@ -486,7 +498,7 @@ rzlblkstrat(bp, bsize) cbp->b_bcount = bsize; #ifdef DEBUG if (rzdebug & RZB_PARTIAL) - printf(" readahead: bn %x cnt %x off %x addr %x\n", + printf(" readahead: bn %x cnt %x off %x addr %p\n", cbp->b_blkno, count, boff, addr); #endif rzstrategy(cbp); @@ -503,7 +515,7 @@ rzlblkstrat(bp, bsize) bcopy(addr, &cbuf[boff], count); #ifdef DEBUG if (rzdebug & RZB_PARTIAL) - printf(" writeback: bn %x cnt %x off %x addr %x\n", + printf(" writeback: bn %x cnt %x off %x addr %p\n", cbp->b_blkno, count, boff, addr); #endif } else { @@ -513,7 +525,7 @@ rzlblkstrat(bp, bsize) cbp->b_bcount = count; #ifdef DEBUG if (rzdebug & RZB_PARTIAL) - printf(" fulltrans: bn %x cnt %x addr %x\n", + printf(" fulltrans: bn %x cnt %x addr %p\n", cbp->b_blkno, count, addr); #endif } @@ -531,7 +543,7 @@ done: addr += count; #ifdef DEBUG if (rzdebug & RZB_PARTIAL) - printf(" done: bn %x resid %x addr %x\n", + printf(" done: bn %x resid %x addr %p\n", bn, resid, addr); #endif } @@ -647,7 +659,7 @@ rzstart(unit) sc->sc_rwcmd.lowBlockCount = n; #ifdef DEBUG if ((bp->b_bcount & (sc->sc_blksize - 1)) != 0) - printf("rz%d: partial block xfer -- %x bytes\n", + printf("rz%d: partial block xfer -- %lx bytes\n", unit, bp->b_bcount); #endif sc->sc_stats.rztransfers++; @@ -693,7 +705,7 @@ rzdone(unit, error, resid, status) if (sd->sd_dk >= 0) dk_busy &= ~(1 << sd->sd_dk); - disk_unbusy(&sc->sc_dkdev, (bp->b_bcount - bp->b_resid)); + disk_unbusy(&sc->sc_dkdev, (bp->b_bcount - resid)); if (sc->sc_flags & RZF_SENSEINPROGRESS) { sc->sc_flags &= ~RZF_SENSEINPROGRESS; @@ -932,9 +944,11 @@ rzopen(dev, flags, mode, p) return (0); } -rzclose(dev, flags, mode) +int +rzclose(dev, flags, mode, p) dev_t dev; int flags, mode; + struct proc *p; { register struct rz_softc *sc = &rz_softc[rzunit(dev)]; int mask = (1 << rzpart(dev)); @@ -965,9 +979,10 @@ rzclose(dev, flags, mode) } int -rzread(dev, uio) +rzread(dev, uio, ioflag) dev_t dev; struct uio *uio; + int ioflag; { register struct rz_softc *sc = &rz_softc[rzunit(dev)]; @@ -982,9 +997,10 @@ rzread(dev, uio) } int -rzwrite(dev, uio) +rzwrite(dev, uio, ioflag) dev_t dev; struct uio *uio; + int ioflag; { register struct rz_softc *sc = &rz_softc[rzunit(dev)]; @@ -998,7 +1014,7 @@ rzwrite(dev, uio) int rzioctl(dev, cmd, data, flag, p) dev_t dev; - int cmd; + u_long cmd; caddr_t data; int flag; struct proc *p; @@ -1129,20 +1145,27 @@ rzsize(dev) /* * Non-interrupt driven, non-dma dump routine. + * XXX + * Still an old-style dump function: arguments after "dev" are ignored. */ int -rzdump(dev) +rzdump(dev, blkno, va, size) dev_t dev; + daddr_t blkno; + caddr_t va; + size_t size; { int part = rzpart(dev); int unit = rzunit(dev); register struct rz_softc *sc = &rz_softc[unit]; - register struct pmax_scsi_device *sd = sc->sc_sd; register daddr_t baddr; register int maddr; register int pages, i; - int stat; extern int lowram; +#ifdef later + register struct pmax_scsi_device *sd = sc->sc_sd; + int stat; +#endif /* * Hmm... all vax drivers dump maxfree pages which is physmem minus diff --git a/sys/arch/pmax/dev/sccvar.h b/sys/arch/pmax/dev/sccvar.h deleted file mode 100644 index aa643752228..00000000000 --- a/sys/arch/pmax/dev/sccvar.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $NetBSD: sccvar.h,v 1.1 1995/08/04 00:22:02 jonathan Exp $ */ - -/* - * external declarations from DECstation scc driver - */ - -extern int sccGetc __P ((dev_t dev)); -extern int sccparam __P((register struct tty *tp, register struct termios *t)); -extern void sccPutc __P ((dev_t dev, int c)); diff --git a/sys/arch/pmax/dev/scsi.c b/sys/arch/pmax/dev/scsi.c index a5f0f310463..ceab29a1625 100644 --- a/sys/arch/pmax/dev/scsi.c +++ b/sys/arch/pmax/dev/scsi.c @@ -1,4 +1,4 @@ -/* $NetBSD: scsi.c,v 1.4 1994/10/26 21:09:18 cgd Exp $ */ +/* $NetBSD: scsi.c,v 1.5 1996/04/07 22:53:55 jonathan Exp $ */ /* * Copyright (c) 1992, 1993 @@ -43,6 +43,7 @@ */ #include <sys/param.h> +#include <sys/systm.h> #include <pmax/dev/device.h> #include <pmax/dev/scsi.h> @@ -120,6 +121,7 @@ static char **scsiErrors[] = { /* * Decode the sense data and print a suitable message. */ +void scsiPrintSense(sp, len) register ScsiClass7Sense *sp; int len; @@ -202,3 +204,36 @@ scsiGroup1Cmd(cmd, lun, block, count, c) c->lowBlockCount = count; c->control = 0; } + +/* + * Print a SCSI identify resutl + */ +void +scsiPrintInquiry(inqbuf, i) + ScsiInquiryData *inqbuf; + int i; +{ + if (inqbuf->version > 1 || i < 36) + printf(" type 0x%x, qual 0x%x, ver %d", + inqbuf->type, inqbuf->qualifier, inqbuf->version); + else { + char vid[9], pid[17], revl[5]; + + bcopy((caddr_t)inqbuf->vendorID, (caddr_t)vid, 8); + bcopy((caddr_t)inqbuf->productID, (caddr_t)pid, 16); + bcopy((caddr_t)inqbuf->revLevel, (caddr_t)revl, 4); + for (i = 8; --i > 0; ) + if (vid[i] != ' ') + break; + vid[i+1] = 0; + for (i = 16; --i > 0; ) + if (pid[i] != ' ') + break; + pid[i+1] = 0; + for (i = 4; --i > 0; ) + if (revl[i] != ' ') + break; + revl[i+1] = 0; + printf(" %s %s rev %s", vid, pid, revl); + } +}
\ No newline at end of file diff --git a/sys/arch/pmax/dev/scsi.h b/sys/arch/pmax/dev/scsi.h index 0a0ebd15750..1043a745bc6 100644 --- a/sys/arch/pmax/dev/scsi.h +++ b/sys/arch/pmax/dev/scsi.h @@ -1,4 +1,4 @@ -/* $NetBSD: scsi.h,v 1.5 1995/03/28 18:19:00 jtc Exp $ */ +/* $NetBSD: scsi.h,v 1.7 1996/04/07 22:53:54 jonathan Exp $ */ /* * Copyright (c) 1992, 1993 @@ -380,6 +380,7 @@ typedef struct ScsiInquiryData { u_char revLevel[4]; /* Revision level (ASCII) */ u_char revData[8]; /* Revision data (ASCII) */ #endif + u_char pading[1024]; /* newer SCSI II drives give additional data */ } ScsiInquiryData; /* @@ -551,8 +552,20 @@ struct scsi_fmt_sense { /* * Routines. */ -extern void scsiGroup0Cmd(); -extern void scsiGroup1Cmd(); +extern void scsiGroup0Cmd __P((unsigned cmd, /* group0 SCSI command */ + unsigned lun, /* Logical Unit Number */ + register unsigned block, + unsigned count, + register ScsiGroup0Cmd *c)); + +extern void scsiGroup1Cmd __P((unsigned cmd, /* group0 SCSI command */ + unsigned lun, /* Logical Unit Number */ + register unsigned block, + unsigned count, + register ScsiGroup1Cmd *c)); + +extern void scsiPrintSense __P((register ScsiClass7Sense *sp, int len)); +extern void scsiPrintInquiry __P((ScsiInquiryData *inqbuf, int len)); #endif /* _KERNEL */ #endif /* _SCSI_H */ diff --git a/sys/arch/pmax/dev/sfb.c b/sys/arch/pmax/dev/sfb.c index 89cd89a4b3d..1e744970f3d 100644 --- a/sys/arch/pmax/dev/sfb.c +++ b/sys/arch/pmax/dev/sfb.c @@ -1,4 +1,4 @@ -/* $NetBSD: sfb.c,v 1.4 1995/09/12 07:30:45 jonathan Exp $ */ +/* $NetBSD: sfb.c,v 1.11.4.3 1996/09/09 20:47:40 thorpej Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -36,7 +36,6 @@ * SUCH DAMAGE. * * from: @(#)sfb.c 8.1 (Berkeley) 6/10/93 - * $Id: sfb.c,v 1.1 1995/10/18 08:51:28 deraadt Exp $ */ /* @@ -81,16 +80,19 @@ * rights to redistribute these changes. */ -#include <fb.h> -#include <sfb.h> +#include "fb.h" +#include "sfb.h" #include <sys/param.h> +#include <sys/systm.h> /* printf() */ #include <sys/kernel.h> #include <sys/errno.h> #include <sys/device.h> #include <sys/fcntl.h> +#include <sys/malloc.h> #include <machine/autoconf.h> +#include <dev/tc/tcvar.h> #include <machine/fbio.h> #include <machine/fbvar.h> @@ -117,16 +119,21 @@ extern int pmax_boardtype; * Forward references. */ -int sfbinit (char *, int, int); +int sfbinit __P((struct fbinfo *fi, caddr_t sfbaddr, int unit, int silent)); #define CMAP_BITS (3 * 256) /* 256 entries, 3 bytes per. */ -static u_char cmap_bits [NSFB * CMAP_BITS]; /* One colormap per sfb... */ +static u_char cmap_bits [CMAP_BITS]; /* colormap for console... */ int sfbmatch __P((struct device *, void *, void *)); void sfbattach __P((struct device *, struct device *, void *)); +int sfb_intr __P((void *sc)); -struct cfdriver sfbcd = { - NULL, "sfb", sfbmatch, sfbattach, DV_DULL, sizeof(struct device), 0 +struct cfattach sfb_ca = { + sizeof(struct device), sfbmatch, sfbattach +}; + +struct cfdriver sfb_cd = { + NULL, "sfb", DV_DULL }; struct fbdriver sfb_driver = { @@ -149,28 +156,27 @@ sfbmatch(parent, match, aux) void *match; void *aux; { - struct cfdata *cf = match; - struct confargs *ca = aux; - static int nsfbs = 1; - caddr_t sfbaddr = BUS_CVTADDR(ca); + /*struct cfdata *cf = match;*/ + struct tc_attach_args *ta = aux; /* make sure that we're looking for this type of device. */ - /*if (!sfbprobe(sfbaddr)) return 0;*/ - if (!BUS_MATCHNAME(ca, "PMAGB-BA")) + if (!TC_BUS_MATCHNAME(ta, "PMAGB-BA")) return (0); - -#ifdef notyet - /* if it can't have the one mentioned, reject it */ - if (cf->cf_unit >= nsfbs) + /* + * if the TC rom ident matches, assume the VRAM is present too. + */ +#if 0 + if (badaddr( ((caddr_t)ta->ta_addr) + SFB_OFFSET_VRAM, 4)) return (0); #endif + return (1); } /* * Attach a device. Hand off all the work to sfbinit(), - * so console-config cod can attach sfbs early in boot. + * so console-config code can attach sfbs early in boot. */ void sfbattach(parent, self, aux) @@ -178,51 +184,70 @@ sfbattach(parent, self, aux) struct device *self; void *aux; { - struct confargs *ca = aux; - caddr_t base = BUS_CVTADDR(ca); + struct tc_attach_args *ta = aux; + caddr_t sfbaddr = (caddr_t)ta->ta_addr; int unit = self->dv_unit; + struct fbinfo *fi = (struct fbinfo *) self; #ifdef notyet /* if this is the console, it's already configured. */ - if (ca->ca_slotpri == cons_slot) + if (ta->ta_cookie == cons_slot) return; /* XXX patch up f softc pointer */ #endif - if (!sfbinit(base, unit, 0)) + if (!sfbinit(fi, sfbaddr, unit, 0)) return; #if 0 /*XXX*/ - *(base + SFB_INTERRUPT_ENABLE) = 0; -#endif -} + /* + * Sean Davidson (davidson@sean.zk3.dec.com) reports this + * isn't sufficient on a 3MIN, Use an interrupt handler instead. + */ -/* - * Test to see if device is present. - * Return true if found and initialized ok. - */ -/*ARGSUSED*/ -sfbprobe(cp) - struct pmax_ctlr *cp; -{ + *(sfbaddr + SFB_INTERRUPT_ENABLE) = 0; + +#endif + /* + * By default, the SFB requests an interrupt during every vertical-retrace period. + * We never enable interrupts from SFB cards, except on the + * 3MIN, where TC options interrupt at spl0 through spl2, and + * disabling of TC option interrupts doesn't work. + */ + if (pmax_boardtype == DS_3MIN) { + tc_intr_establish(parent, (void*)ta->ta_cookie, TC_IPL_NONE, + sfb_intr, fi); + } + printf("\n"); } + /* * Initialization */ int -sfbinit(base, unit, silent) +sfbinit(fi, base, unit, silent) + struct fbinfo *fi; char *base; int unit; int silent; { - struct fbinfo *fi; - u_char foo; - - fi = &sfbfi; /* XXX use softc */ - if (unit > NSFB) - return (0); + /* + * If this device is being intialized as the console, malloc() + * is not yet up and we must use statically-allocated space. + */ + if (fi == NULL) { + fi = &sfbfi; /* XXX */ + fi->fi_cmap_bits = (caddr_t)cmap_bits; + } + else { + fi->fi_cmap_bits = malloc(CMAP_BITS, M_DEVBUF, M_NOWAIT); + if (fi->fi_cmap_bits == NULL) { + printf("sfb%d: no memory for cmap\n", unit); + return (0); + } + } /* check for no frame buffer */ if (badaddr(base + SFB_OFFSET_VRAM, 4)) @@ -238,7 +263,6 @@ sfbinit(base, unit, silent) fi->fi_linebytes = 1280; fi->fi_driver = &sfb_driver; fi->fi_blanked = 0; - fi->fi_cmap_bits = (caddr_t)&cmap_bits [CMAP_BITS * unit]; /* Fill in Frame Buffer Type struct. */ fi->fi_type.fb_boardtype = PMAX_FBTYPE_SFB; @@ -298,4 +322,30 @@ sfbinit(base, unit, silent) return (1); } + +/* + * The TURBOChannel sfb interrupts by default on every vertical retrace, + * and we don't know to disable those interrupt requests. + * The 4.4BSD/pamx kernel never enabled delivery of those interrupts from the TC bus, + * but there's a kernel design bug on the 3MIN, where disabling + * (or enabling) TC option interrupts has no effect; each slot interrupt is + * mapped directly to a separate R3000 interrupt and they always seem to be taken. + * + * This function simply dismisses SFB interrupts, or the interrupt + * request from the card will still be active. + */ +int +sfb_intr(sc) + void *sc; +{ + struct fbinfo *fi = /* XXX (struct fbinfo *)sc */ &sfbfi; + + char *slot_addr = (((char *)fi->fi_base) - SFB_ASIC_OFFSET); + + /* reset vertical-retrace interrupt by writing a dont-care */ + *(int*) (slot_addr + SFB_CLEAR) = 0; + + return (0); +} + /* old bt459 code used to be here */ diff --git a/sys/arch/pmax/dev/sfbreg.h b/sys/arch/pmax/dev/sfbreg.h index bb1bcc5be44..3e760dab0ca 100644 --- a/sys/arch/pmax/dev/sfbreg.h +++ b/sys/arch/pmax/dev/sfbreg.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)sfb.c 8.1 (Berkeley) 6/10/93 - * $Id: sfbreg.h,v 1.1 1995/10/18 08:51:28 deraadt Exp $ + * $Id: sfbreg.h,v 1.2 1996/09/15 21:12:35 deraadt Exp $ */ #define SFB_OFFSET_VRAM 0x201000 /* from module's base */ diff --git a/sys/arch/pmax/dev/sii.c b/sys/arch/pmax/dev/sii.c index 4cd2086dd7b..e0d310d8f1a 100644 --- a/sys/arch/pmax/dev/sii.c +++ b/sys/arch/pmax/dev/sii.c @@ -1,4 +1,4 @@ -/* $NetBSD: sii.c,v 1.8 1995/09/13 19:35:58 jonathan Exp $ */ +/* $NetBSD: sii.c,v 1.12.4.2 1996/09/09 20:24:36 thorpej Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -118,9 +118,14 @@ int sii_doprobe __P((void *addr, int unit, int flags, int pri, struct device *self)); int siiintr __P((void *sc)); -extern struct cfdriver siicd; -struct cfdriver siicd = { - NULL, "sii", siimatch, siiattach, DV_DULL, sizeof(struct siisoftc) +extern struct cfdriver sii_cd; + +struct cfattach sii_ca = { + sizeof(struct siisoftc), siimatch, siiattach +}; + +struct cfdriver sii_cd = { + NULL, "sii", DV_DULL }; #ifdef USE_NEW_SCSI @@ -145,13 +150,15 @@ struct scsi_device sii_dev = { #endif /* - * Definition of the controller for the old auto-configuration program. + * Definition of the controller for the old auto-configuration program + * and old-style pmax scsi drivers. */ void siistart(); struct pmax_driver siidriver = { "sii", NULL, siistart, 0, }; + /* * MACROS for timing out spin loops. * @@ -208,14 +215,29 @@ u_char sii_buf[256]; /* used for extended messages */ #define SII_BUF_ADDR (MACH_PHYS_TO_UNCACHED(KN01_SYS_SII_B_START) \ + SII_MAX_DMA_XFER_LENGTH * 14) -static void sii_Reset(); -static void sii_StartCmd(); -static void sii_CmdDone(); -static void sii_DoIntr(); -static void sii_StateChg(); -static void sii_DoSync(); -static void sii_StartDMA(); -static int sii_GetByte(); + +/* + * Other forward references + */ + +static void sii_Reset __P((register struct siisoftc *sc, int resetbus)); +static void sii_StartCmd __P((register struct siisoftc *sc, int target)); +static void sii_CmdDone __P((register struct siisoftc *sc, int target, + int error)); +static void sii_DoIntr __P((register struct siisoftc *sc, u_int dstat)); +static void sii_StateChg __P((register struct siisoftc *sc, u_int cstat)); +static int sii_GetByte __P((register SIIRegs *regs, int phase, int ack)); +static void sii_DoSync __P((register SIIRegs *regs, register State *state)); +static void sii_StartDMA __P((register SIIRegs *regs, int phase, + u_short *dmaAddr, int size)); + +void siistart __P((register ScsiCmd *scsicmd)); +void sii_DumpLog __P((void)); + +void CopyToBuffer __P((u_short *src, /* NOTE: must be short aligned */ + volatile u_short *dst, int length)); +void CopyFromBuffer __P((volatile u_short *src, char *dst, int length)); + /* @@ -227,14 +249,20 @@ siimatch(parent, match, aux) void *match; void *aux; { - struct cfdata *cf = match; struct confargs *ca = aux; - if (!BUS_MATCHNAME(ca, "sii") && !BUS_MATCHNAME(ca, "PMAZ-AA ")) + if (strcmp(ca->ca_name, "sii") != 0 && + strncmp(ca->ca_name, "PMAZ-AA ", 8) != 0) /*XXX*/ return (0); /* XXX check for bad address */ - /* XXX kn01s have exactly one SII. Does any other machine use them? */ + /* + * XXX KN01s (3100/2100) have exactly one SII. + * the Decsystem 5100 apparently uses them also, but as yet we + * don't know at what address. + * + * XXX PVAXES apparently use the SII also. + */ return (1); } @@ -249,7 +277,7 @@ siiattach(parent, self, aux) register void *siiaddr; register int i; - siiaddr = (void*)MACH_PHYS_TO_UNCACHED(BUS_CVTADDR(ca)); + siiaddr = (void*)MACH_PHYS_TO_UNCACHED(ca->ca_addr); sc->sc_regs = (SIIRegs *)siiaddr; sc->sc_flags = sc->sc_dev.dv_cfdata->cf_flags; @@ -288,7 +316,7 @@ siistart(scsicmd) register ScsiCmd *scsicmd; /* command to start */ { register struct pmax_scsi_device *sdp = scsicmd->sd; - register struct siisoftc *sc = siicd.cd_devs[sdp->sd_ctlr]; + register struct siisoftc *sc = sii_cd.cd_devs[sdp->sd_ctlr]; int s; s = splbio(); @@ -324,8 +352,12 @@ siiintr(xxxsc) * Find which controller caused the interrupt. */ dstat = sc->sc_regs->dstat; - if (dstat & (SII_CI | SII_DI)) + if (dstat & (SII_CI | SII_DI)) { sii_DoIntr(sc, dstat); + return (0); /* XXX */ + } + + return (1); /* XXX spurious interrupt? */ } /* @@ -371,7 +403,7 @@ sii_Reset(sc, reset) * Delay 250 ms before doing any commands. */ regs->comm = SII_DO_RST; - MachEmptyWriteBuffer(); + wbflush(); DELAY(250000); /* rearbitrate synchronous offset */ @@ -389,7 +421,7 @@ sii_Reset(sc, reset) * Reselect Enable, and Interrupt Enable. */ regs->csr = SII_HPM | SII_RSE | SII_PCE | SII_IE; - MachEmptyWriteBuffer(); + wbflush(); } /* @@ -436,7 +468,7 @@ sii_StartCmd(sc, target) #ifdef DEBUG if (sii_debug > 1) { - printf("sii_StartCmd: %s target %d cmd 0x%x addr %x size %d dma %d\n", + printf("sii_StartCmd: %s target %d cmd 0x%x addr %p size %d dma %d\n", scsicmd->sd->sd_driver->d_name, target, scsicmd->cmd[0], scsicmd->buf, scsicmd->buflen, state->dmaDataPhase); @@ -504,7 +536,7 @@ sii_StartCmd(sc, target) regs->comm = SII_INXFER | SII_SELECT | SII_ATN | SII_CON | SII_MSG_OUT_PHASE; } - MachEmptyWriteBuffer(); + wbflush(); /* * Wait for something to happen @@ -517,7 +549,7 @@ sii_StartCmd(sc, target) if ((status & (SII_RST | SII_SCH | SII_STATE_MSK)) == (SII_SCH | SII_CON)) { regs->cstat = status; - MachEmptyWriteBuffer(); + wbflush(); #ifdef DEBUG sii_logp->target = target; @@ -586,7 +618,7 @@ sii_StartCmd(sc, target) if (status & SII_SIP) { error = ENXIO; /* device didn't respond */ regs->comm = SII_DISCON; - MachEmptyWriteBuffer(); + wbflush(); SII_WAIT_UNTIL(status, regs->cstat, !(status & (SII_CON | SII_SIP)), SII_WAIT_COUNT, retval); @@ -601,7 +633,7 @@ sii_StartCmd(sc, target) regs->cstat = 0xffff; regs->dstat = 0xffff; regs->comm = 0; - MachEmptyWriteBuffer(); + wbflush(); sii_CmdDone(sc, target, error); } @@ -643,7 +675,7 @@ again: #endif regs->dstat = dstat; /* acknowledge everything */ - MachEmptyWriteBuffer(); + wbflush(); if (dstat & SII_CI) { /* deglitch cstat register */ @@ -651,7 +683,7 @@ again: while (msg != (cstat = regs->cstat)) msg = cstat; regs->cstat = cstat; /* acknowledge everything */ - MachEmptyWriteBuffer(); + wbflush(); #ifdef DEBUG if (sii_logp > sii_log) sii_logp[-1].cstat = cstat; @@ -760,7 +792,7 @@ again: sii_StartDMA(regs, state->dmaCurPhase = SII_DATA_IN_PHASE, state->dmaAddr[state->dmaBufIndex], - state->dmalen = len); + state->dmaCnt = state->dmalen = len); dstat &= ~(SII_IBF | SII_TBE); } /* copy in the data */ @@ -782,7 +814,7 @@ again: sii_StartDMA(regs, state->dmaCurPhase = SII_DATA_OUT_PHASE, state->dmaAddr[state->dmaBufIndex], - state->dmalen = + state->dmaCnt = state->dmalen = SII_MAX_DMA_XFER_LENGTH); /* prepare for next chunk */ i -= SII_MAX_DMA_XFER_LENGTH; @@ -796,7 +828,7 @@ again: sii_StartDMA(regs, state->dmaCurPhase = SII_DATA_OUT_PHASE, state->dmaAddr[state->dmaBufIndex], - state->dmalen = i); + state->dmaCnt = state->dmalen = i); } dstat &= ~(SII_IBF | SII_TBE); } @@ -846,7 +878,7 @@ again: regs->dmabyte = state->dmaByte; regs->comm = SII_DMA | SII_INXFER | (comm & SII_STATE_MSK) | SII_CMD_PHASE; - MachEmptyWriteBuffer(); + wbflush(); #ifdef DEBUG if (sii_debug > 4) printf("Cmd dcnt %d dadr %x ", @@ -867,7 +899,7 @@ again: i); sii_StartDMA(regs, state->dmaCurPhase = SII_CMD_PHASE, state->dmaAddr[0], - state->dmalen = i); + state->dmaCnt = state->dmalen = i); } /* wait a short time for XFER complete */ SII_WAIT_UNTIL(dstat, regs->dstat, @@ -914,7 +946,7 @@ again: regs->comm = SII_DMA | SII_INXFER | (comm & SII_STATE_MSK) | state->dmaCurPhase; - MachEmptyWriteBuffer(); + wbflush(); #ifdef DEBUG if (sii_debug > 4) printf("Data %d dcnt %d dadr %x ", @@ -950,7 +982,7 @@ again: sii_StartDMA(regs, state->dmaCurPhase = SII_DATA_IN_PHASE, state->dmaAddr[state->dmaBufIndex], - state->dmalen = i); + state->dmaCnt = state->dmalen = i); break; } /* start first chunk */ @@ -963,7 +995,7 @@ again: sii_StartDMA(regs, state->dmaCurPhase = SII_DATA_OUT_PHASE, state->dmaAddr[state->dmaBufIndex], - state->dmalen = i); + state->dmaCnt = state->dmalen = i); i = state->buflen - SII_MAX_DMA_XFER_LENGTH; if (i > 0) { /* prepare for next chunk */ @@ -996,9 +1028,9 @@ again: regs->dmlotc = 0; regs->comm = comm & (SII_STATE_MSK | SII_PHASE_MSK); - MachEmptyWriteBuffer(); + wbflush(); regs->dstat = SII_DNE; - MachEmptyWriteBuffer(); + wbflush(); #ifdef DEBUG if (sii_debug > 4) printf("DMA amt %d ", i); @@ -1056,20 +1088,22 @@ again: /* save dma registers */ state->dmaPrevPhase = state->dmaCurPhase; state->dmaCurPhase = -1; - state->dmaCnt = i = regs->dmlotc; if (dstat & SII_OBB) state->dmaByte = regs->dmabyte; - if (i == 0) - i = SII_MAX_DMA_XFER_LENGTH; - i = state->dmalen - i; + i = regs->dmlotc; + if (i != 0) + i = state->dmaCnt - i; /* note: no carry from dmaddrl to dmaddrh */ state->dmaAddrL = regs->dmaddrl + i; state->dmaAddrH = regs->dmaddrh; + state->dmaCnt = regs->dmlotc; + if (state->dmaCnt == 0) + state->dmaCnt = SII_MAX_DMA_XFER_LENGTH; regs->comm = comm & (SII_STATE_MSK | SII_PHASE_MSK); - MachEmptyWriteBuffer(); + wbflush(); regs->dstat = SII_DNE; - MachEmptyWriteBuffer(); + wbflush(); #ifdef DEBUG if (sii_debug > 4) { printf("SavP dcnt %d dadr %x ", @@ -1114,7 +1148,7 @@ again: SII_WAIT_UNTIL(dstat, regs->dstat, dstat & SII_DNE, SII_WAIT_COUNT, i); regs->dstat = SII_DNE; - MachEmptyWriteBuffer(); + wbflush(); msg = sc->sc_target; sc->sc_target = -1; /* @@ -1129,7 +1163,7 @@ again: SII_STATE_MSK)) == SII_SCH) { regs->cstat = SII_SCH | SII_BER; regs->comm = 0; - MachEmptyWriteBuffer(); + wbflush(); /* * Double check that we didn't miss a * state change between seeing it and @@ -1155,7 +1189,7 @@ again: SII_WAIT_UNTIL(dstat, regs->dstat, dstat & SII_DNE, SII_WAIT_COUNT, i); regs->dstat = SII_DNE; - MachEmptyWriteBuffer(); + wbflush(); /* read the message length */ msg = sii_GetByte(regs, SII_MSG_IN_PHASE, 1); if (msg < 0) { @@ -1190,7 +1224,7 @@ again: dstat & SII_DNE, SII_WAIT_COUNT, i); regs->dstat = SII_DNE; - MachEmptyWriteBuffer(); + wbflush(); i = (sii_buf[3] << 24) | (sii_buf[4] << 16) | (sii_buf[5] << 8) | @@ -1213,7 +1247,7 @@ again: dstat & SII_DNE, SII_WAIT_COUNT, i); regs->dstat = SII_DNE; - MachEmptyWriteBuffer(); + wbflush(); sii_DoSync(regs, state); break; @@ -1230,7 +1264,7 @@ again: dstat & SII_DNE, SII_WAIT_COUNT, i); regs->dstat = SII_DNE; - MachEmptyWriteBuffer(); + wbflush(); /* wait for MSG_OUT phase */ SII_WAIT_UNTIL(dstat, regs->dstat, @@ -1246,7 +1280,7 @@ again: dstat & SII_DNE, SII_WAIT_COUNT, i); regs->dstat = SII_DNE; - MachEmptyWriteBuffer(); + wbflush(); } break; @@ -1258,7 +1292,7 @@ again: SII_WAIT_UNTIL(dstat, regs->dstat, dstat & SII_DNE, SII_WAIT_COUNT, i); regs->dstat = SII_DNE; - MachEmptyWriteBuffer(); + wbflush(); /* wait a short time for another msg */ SII_WAIT_UNTIL(dstat, regs->dstat, dstat & (SII_CI | SII_DI), @@ -1279,7 +1313,7 @@ again: SII_WAIT_UNTIL(dstat, regs->dstat, dstat & SII_DNE, SII_WAIT_COUNT, i); regs->dstat = SII_DNE; - MachEmptyWriteBuffer(); + wbflush(); state->prevComm = comm; #ifdef DEBUG if (sii_debug > 4) @@ -1304,7 +1338,7 @@ again: } regs->cstat = SII_SCH | SII_BER; regs->comm = 0; - MachEmptyWriteBuffer(); + wbflush(); sc->sc_target = -1; /* * Double check that we didn't miss a state @@ -1324,7 +1358,7 @@ again: SII_WAIT_UNTIL(dstat, regs->dstat, dstat & SII_DNE, SII_WAIT_COUNT, i); regs->dstat = SII_DNE; - MachEmptyWriteBuffer(); + wbflush(); printf("%s: device %d: message reject.\n", sc->sc_dev.dv_xname, sc->sc_target); break; @@ -1345,7 +1379,7 @@ again: SII_WAIT_UNTIL(dstat, regs->dstat, dstat & SII_DNE, SII_WAIT_COUNT, i); regs->dstat = SII_DNE; - MachEmptyWriteBuffer(); + wbflush(); /* may want to check LUN some day */ /* wait a short time for another msg */ SII_WAIT_UNTIL(dstat, regs->dstat, @@ -1380,7 +1414,7 @@ again: regs->data = SCSI_NO_OP; regs->comm = SII_INXFER | (comm & SII_STATE_MSK) | SII_MSG_OUT_PHASE; - MachEmptyWriteBuffer(); + wbflush(); /* wait a short time for XFER complete */ SII_WAIT_UNTIL(dstat, regs->dstat, dstat & SII_DNE, @@ -1392,7 +1426,7 @@ again: /* just clear the DNE bit and check errors later */ if (dstat & SII_DNE) { regs->dstat = SII_DNE; - MachEmptyWriteBuffer(); + wbflush(); } break; @@ -1442,7 +1476,7 @@ abort: regs->data = SCSI_ABORT; regs->comm = SII_INXFER | SII_ATN | (cstat & SII_STATE_MSK) | SII_MSG_OUT_PHASE; - MachEmptyWriteBuffer(); + wbflush(); SII_WAIT_UNTIL(dstat, regs->dstat, (dstat & (SII_DNE | SII_PHASE_MSK)) == (SII_DNE | SII_MSG_OUT_PHASE), @@ -1451,11 +1485,11 @@ abort: if (sii_debug > 0) printf("Abort: cs %x ds %x i %d\n", cstat, dstat, i); #endif - if (dstat & (SII_DNE | SII_PHASE_MSK) == + if ((dstat & (SII_DNE | SII_PHASE_MSK)) == (SII_DNE | SII_MSG_OUT_PHASE)) { /* disconnect if command in progress */ regs->comm = SII_DISCON; - MachEmptyWriteBuffer(); + wbflush(); SII_WAIT_UNTIL(cstat, regs->cstat, !(cstat & SII_CON), SII_WAIT_COUNT, i); } @@ -1468,7 +1502,7 @@ abort: regs->cstat = 0xffff; regs->dstat = 0xffff; regs->comm = 0; - MachEmptyWriteBuffer(); + wbflush(); i = sc->sc_target; sc->sc_target = -1; @@ -1544,7 +1578,7 @@ sii_StateChg(sc, cstat) state = &sc->sc_st[i]; regs->comm = SII_CON | SII_DST | SII_MSG_IN_PHASE; regs->dmctrl = state->dmaReqAck; - MachEmptyWriteBuffer(); + wbflush(); if (!state->prevComm) { printf("%s: device %d: spurious reselection\n", sc->sc_dev.dv_xname, i); @@ -1564,7 +1598,7 @@ sii_StateChg(sc, cstat) printf("%s: Selected by device %d as target!!\n", sc->sc_dev.dv_xname, regs->destat); regs->comm = SII_DISCON; - MachEmptyWriteBuffer(); + wbflush(); SII_WAIT_UNTIL(!(regs->cstat & SII_CON), SII_WAIT_COUNT, i); regs->cstat = 0xffff; @@ -1600,7 +1634,7 @@ sii_GetByte(regs, phase, ack) state = regs->cstat & SII_STATE_MSK; if (!(dstat & SII_IBF) || (dstat & SII_MIS)) { regs->comm = state | phase; - MachEmptyWriteBuffer(); + wbflush(); /* wait a short time for IBF */ SII_WAIT_UNTIL(dstat, regs->dstat, dstat & SII_IBF, SII_WAIT_COUNT, i); @@ -1631,7 +1665,7 @@ sii_GetByte(regs, phase, ack) if (ack) { regs->comm = SII_INXFER | state | phase; - MachEmptyWriteBuffer(); + wbflush(); /* wait a short time for XFER complete */ SII_WAIT_UNTIL(dstat, regs->dstat, dstat & SII_DNE, @@ -1640,7 +1674,7 @@ sii_GetByte(regs, phase, ack) /* clear the DNE */ if (dstat & SII_DNE) { regs->dstat = SII_DNE; - MachEmptyWriteBuffer(); + wbflush(); } } @@ -1698,7 +1732,7 @@ sii_DoSync(regs, state) regs->data = sii_buf[j]; regs->comm = comm; - MachEmptyWriteBuffer(); + wbflush(); /* wait a short time for XFER complete */ SII_WAIT_UNTIL(dstat, regs->dstat, dstat & SII_DNE, @@ -1712,7 +1746,7 @@ sii_DoSync(regs, state) /* clear the DNE, other errors handled later */ regs->dstat = SII_DNE; - MachEmptyWriteBuffer(); + wbflush(); } #else CopyToBuffer((u_short *)sii_buf, (volatile u_short *)SII_BUF_ADDR, 5); @@ -1726,7 +1760,7 @@ sii_DoSync(regs, state) regs->dmlotc = 5; regs->comm = SII_DMA | SII_INXFER | SII_ATN | (regs->cstat & SII_STATE_MSK) | SII_MSG_OUT_PHASE; - MachEmptyWriteBuffer(); + wbflush(); /* wait a short time for XFER complete */ SII_WAIT_UNTIL(dstat, regs->dstat, @@ -1741,7 +1775,7 @@ sii_DoSync(regs, state) } /* clear the DNE, other errors handled later */ regs->dstat = SII_DNE; - MachEmptyWriteBuffer(); + wbflush(); #endif #if 0 @@ -1778,7 +1812,7 @@ sii_StartDMA(regs, phase, dmaAddr, size) regs->dmlotc = size; regs->comm = SII_DMA | SII_INXFER | (regs->cstat & SII_STATE_MSK) | phase; - MachEmptyWriteBuffer(); + wbflush(); #ifdef DEBUG if (sii_debug > 5) { @@ -1831,6 +1865,7 @@ sii_CmdDone(sc, target, error) } #ifdef DEBUG +void sii_DumpLog() { register struct sii_log *lp; diff --git a/sys/arch/pmax/dev/tz.c b/sys/arch/pmax/dev/tz.c index b556191ad11..a8b99d367ea 100644 --- a/sys/arch/pmax/dev/tz.c +++ b/sys/arch/pmax/dev/tz.c @@ -1,4 +1,4 @@ -/* $NetBSD: tz.c,v 1.8 1995/09/18 03:04:55 jonathan Exp $ */ +/* $NetBSD: tz.c,v 1.10 1996/04/10 16:33:44 jonathan Exp $ */ /* * Copyright (c) 1992, 1993 @@ -54,17 +54,26 @@ #include <sys/file.h> #include <sys/ioctl.h> #include <sys/mtio.h> +#include <sys/proc.h> #include <sys/syslog.h> #include <sys/tprintf.h> +#include <sys/conf.h> +#include <machine/conf.h> + #include <pmax/dev/device.h> #include <pmax/dev/scsi.h> -int tzprobe(); -void tzstart(), tzdone(); +int tzprobe __P(( void *sd /*struct pmax_scsi_device *sd*/)); +int tzcommand __P((dev_t dev, int command, int code, + int count, caddr_t data)); +void tzstart __P((int unit)); +void tzdone __P((int unit, int error, int resid, int status)); struct pmax_driver tzdriver = { - "tz", tzprobe, tzstart, tzdone, + "tz", tzprobe, + (void (*) __P((struct ScsiCmd *cmd))) tzstart, + tzdone, }; struct tz_softc { @@ -105,19 +114,21 @@ struct tz_softc { int tzdebug = 0; #endif -void tzstrategy __P((register struct buf *bp)); /* * Test to see if device is present. * Return true if found and initialized ok. */ -tzprobe(sd) - struct pmax_scsi_device *sd; +int +tzprobe(xxxsd) + void *xxxsd; { + + register struct pmax_scsi_device *sd = xxxsd; + register struct tz_softc *sc = &tz_softc[sd->sd_unit]; register int i; ScsiInquiryData inqbuf; - ScsiClass7Sense *sp; /* init some parameters that don't change */ sc->sc_sd = sd; @@ -214,8 +225,7 @@ tzprobe(sd) sc->sc_tapeid = MT_ISMFOUR; } else { printf("tz%d: assuming GENERIC SCSI tape device\n", - sd->sd_unit, - inqbuf.type, inqbuf.qualifier, inqbuf.version); + sd->sd_unit); sc->sc_tapeid = 0; } } @@ -231,6 +241,7 @@ bad: /* * Perform a special tape command on a SCSI Tape drive. */ +int tzcommand(dev, command, code, count, data) dev_t dev; int command; @@ -280,7 +291,7 @@ tzcommand(dev, command, code, count, data) sc->sc_buf.b_flags = 0; sc->sc_cmd.flags = 0; if (sc->sc_buf.b_resid) - printf("tzcommand: resid %d\n", sc->sc_buf.b_resid); /* XXX */ + printf("tzcommand: resid %ld\n", sc->sc_buf.b_resid); /* XXX */ if (error == 0) switch (command) { case SCSI_SPACE: @@ -386,7 +397,7 @@ tzdone(unit, error, resid, status) sc->sc_sense.sense[2] = SCSI_CLASS7_NO_SENSE; } else if (!cold) { ScsiClass7Sense *sp; - long resid; + long resid = 0; sp = (ScsiClass7Sense *)sc->sc_sense.sense; if (sp->error7 != 0x70) @@ -412,7 +423,7 @@ tzdone(unit, error, resid, status) } if (sc->sc_blklen && sp->badBlockLen) { tprintf(sc->sc_ctty, - "tz%d: Incorrect Block Length, expected %d got %d\n", + "tz%d: Incorrect Block Length, expected %d got %ld\n", unit, sc->sc_blklen, resid); break; } @@ -423,7 +434,7 @@ tzdone(unit, error, resid, status) * full record. */ tprintf(sc->sc_ctty, - "tz%d: Partial Read of Variable Length Tape Block, expected %d read %d\n", + "tz%d: Partial Read of Variable Length Tape Block, expected %ld read %ld\n", unit, bp->b_bcount - resid, bp->b_bcount); bp->b_resid = 0; @@ -491,7 +502,7 @@ tzdone(unit, error, resid, status) bp->b_resid = resid; } - if (dp = bp->b_actf) + if ((dp = bp->b_actf) != 0) dp->b_actb = bp->b_actb; else sc->sc_tab.b_actb = bp->b_actb; @@ -509,6 +520,7 @@ tzdone(unit, error, resid, status) } /* ARGSUSED */ +int tzopen(dev, flags, type, p) dev_t dev; int flags, type; @@ -663,9 +675,12 @@ tzopen(dev, flags, type, p) return (0); } -tzclose(dev, flag) +int +tzclose(dev, flag, mode, p) dev_t dev; - int flag; + int flag, mode; + struct proc *p; + { register struct tz_softc *sc = &tz_softc[tzunit(dev)]; int error = 0; @@ -699,14 +714,15 @@ tzclose(dev, flag) } int -tzread(dev, uio) +tzread(dev, uio, iomode) dev_t dev; struct uio *uio; + int iomode; { +#if 0 + /*XXX*/ /* check for hardware write-protect? */ register struct tz_softc *sc = &tz_softc[tzunit(dev)]; - /*XXX*/ /* check for hardware write-protect? */ -#if 0 if (sc->sc_type == SCSI_ROM_TYPE) return (EROFS); @@ -719,13 +735,14 @@ tzread(dev, uio) } int -tzwrite(dev, uio) +tzwrite(dev, uio, iomode) dev_t dev; struct uio *uio; + int iomode; { +#if 0 register struct tz_softc *sc = &tz_softc[tzunit(dev)]; -#if 0 if (sc->sc_format_pid && sc->sc_format_pid != curproc->p_pid) return (EPERM); #endif @@ -735,14 +752,14 @@ tzwrite(dev, uio) } int -tzioctl(dev, cmd, data, flag) +tzioctl(dev, cmd, data, flag, p) dev_t dev; - int cmd; + u_long cmd; caddr_t data; int flag; + struct proc *p; { register struct tz_softc *sc = &tz_softc[tzunit(dev)]; - register struct buf *bp = &sc->sc_buf; struct mtop *mtop; struct mtget *mtget; int code, count; @@ -841,8 +858,11 @@ tzstrategy(bp) * Non-interrupt driven, non-dma dump routine. */ int -tzdump(dev) +tzdump(dev, blkno, va, size) dev_t dev; + daddr_t blkno; + caddr_t va; + size_t size; { /* Not implemented. */ return (ENXIO); diff --git a/sys/arch/pmax/dev/xcfb.c b/sys/arch/pmax/dev/xcfb.c index cebba5321fb..8efa14f43b8 100644 --- a/sys/arch/pmax/dev/xcfb.c +++ b/sys/arch/pmax/dev/xcfb.c @@ -1,4 +1,4 @@ -/* $NetBSD: xcfb.c,v 1.9 1995/10/09 01:45:26 jonathan Exp $ */ +/* $NetBSD: xcfb.c,v 1.14.4.1 1996/05/30 04:04:01 mhitch Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -80,16 +80,17 @@ * v 9.2 90/02/13 22:16:24 shirriff Exp SPRITE (DECWRL)"; */ -#include <fb.h> +#include "fb.h" -#include <xcfb.h> -#include <dtop.h> +#include "xcfb.h" +#include "dtop.h" #if NXCFB > 0 #if NDTOP == 0 xcfb needs dtop device #else #include <sys/param.h> +#include <sys/systm.h> #include <sys/time.h> #include <sys/kernel.h> #include <sys/ioctl.h> @@ -97,10 +98,12 @@ xcfb needs dtop device #include <sys/errno.h> #include <sys/proc.h> #include <sys/mman.h> +#include <sys/malloc.h> #include <vm/vm.h> #include <sys/device.h> +#include <dev/tc/tcvar.h> #include <machine/autoconf.h> #include <machine/machConst.h> #include <machine/pmioctl.h> @@ -111,9 +114,9 @@ xcfb needs dtop device #include <pmax/pmax/cons.h> #include <pmax/dev/xcfbreg.h> +#include <pmax/dev/xcfbvar.h> #include <pmax/dev/ims332.h> #include <pmax/pmax/maxine.h> -#include <pmax/pmax/pmaxtype.h> #include <pmax/dev/dtopreg.h> @@ -131,10 +134,10 @@ struct fbuaccess xcfbu; struct pmax_fbtty xcfbfb; struct fbinfo xcfbfi; /*XXX*/ -extern struct cfdriver cfb; +extern struct cfdriver cfb_cd; #define CMAP_BITS (3 * 256) /* 256 entries, 3 bytes per. */ -static u_char cmap_bits [NXCFB * CMAP_BITS]; /* One colormap per cfb... */ +static u_char cmap_bits [CMAP_BITS]; /* colormap for console... */ #define XCFB_FB_SIZE 0x100000 /* size of raster (mapped into userspace) */ @@ -176,8 +179,12 @@ extern u_short defCursor[32]; int xcfbmatch __P((struct device *, void *, void *)); void xcfbattach __P((struct device *, struct device *, void *)); -struct cfdriver xcfbcd = { - NULL, "xcfb", xcfbmatch, xcfbattach, DV_DULL, sizeof(struct device), 0 +struct cfattach xcfb_ca = { + sizeof(struct device), xcfbmatch, xcfbattach +}; + +struct cfdriver xcfb_cd = { + NULL, "xcfb", DV_DULL }; int @@ -186,19 +193,14 @@ xcfbmatch(parent, match, aux) void *match; void *aux; { - struct cfdata *cf = match; - struct confargs *ca = aux; - static int nxcfbs = 1; + /*struct cfdata *cf = match;*/ + struct tc_attach_args *ta = aux; - /* make sure that we're looking for this type of device. */ - if (!BUS_MATCHNAME(ca, "PMAG-DV ") && !BUS_MATCHNAME(ca, "xcfb")) + /* Make sure that it's an xcfb. */ + if (!TC_BUS_MATCHNAME(ta, "PMAG-DV ") && + strcmp(ta->ta_modname, "xcfb") != 0) return (0); -#ifdef notyet - /* if it can't have the one mentioned, reject it */ - if (cf->cf_unit >= nxcfbs) - return (0); -#endif return (1); } @@ -208,9 +210,9 @@ xcfbattach(parent, self, aux) struct device *self; void *aux; { - struct confargs *ca = aux; + struct tc_attach_args *ta = aux; - if (!xcfbinit(NULL, BUS_CVTADDR(ca), self->dv_unit, 0)); + if (!xcfbinit(NULL, (caddr_t)ta->ta_addr, self->dv_unit, 0)); return; /* no interrupts for XCFB */ @@ -229,10 +231,21 @@ xcfbinit(fi, base, unit, silent) int unit; int silent; { - register u_int *reset = (u_int *)IMS332_RESET_ADDRESS; - - if (fi == 0) fi = &xcfbfi; - unit = 0; /*XXX*/ /* FIXME */ + /*XXX*/ + /* + * If this device is being intialized as the console, malloc() + * is not yet up and we must use statically-allocated space. + */ + if (fi == NULL) { + fi = &xcfbfi; /* XXX */ + fi->fi_cmap_bits = (caddr_t)cmap_bits; + } else { + fi->fi_cmap_bits = malloc(CMAP_BITS, M_DEVBUF, M_NOWAIT); + if (fi->fi_cmap_bits == NULL) { + printf("cfb%d: no memory for cmap\n", unit); + return (0); + } + } /*XXX*/ /* @@ -252,7 +265,6 @@ xcfbinit(fi, base, unit, silent) fi->fi_linebytes = 1024; fi->fi_driver = &xcfb_driver; fi->fi_blanked = 0; - fi->fi_cmap_bits = (caddr_t)&cmap_bits [CMAP_BITS * unit]; /* Fill in Frame Buffer Type struct. */ fi->fi_type.fb_boardtype = PMAX_FBTYPE_XCFB; diff --git a/sys/arch/pmax/dev/xcfbvar.h b/sys/arch/pmax/dev/xcfbvar.h new file mode 100644 index 00000000000..e6261cb2cd6 --- /dev/null +++ b/sys/arch/pmax/dev/xcfbvar.h @@ -0,0 +1,6 @@ +/* + * Initialize a Personal Decstation baseboard framebuffer, + * so it can be used as a bitmapped glass-tty console device. + */ +extern int +xcfbinit __P((struct fbinfo *fi, caddr_t base, int unit, int silent)); |