1996-02-15 22:13:08 +03:00
|
|
|
/* $NetBSD: xcfb.c,v 1.12 1996/02/15 19:13:11 jonathan Exp $ */
|
1994-10-27 00:08:38 +03:00
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
/*-
|
1994-05-27 12:39:00 +04:00
|
|
|
* Copyright (c) 1992, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-10-12 06:22:19 +03:00
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Ralph Campbell and Rick Macklem.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1994-10-27 00:08:38 +03:00
|
|
|
* @(#)xcfb.c 8.1 (Berkeley) 6/10/93
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Mach Operating System
|
|
|
|
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify and distribute this software and its
|
|
|
|
* documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation.
|
|
|
|
*
|
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
|
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
|
|
|
|
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* Carnegie Mellon requests users of this software to return to
|
|
|
|
*
|
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
* School of Computer Science
|
|
|
|
* Carnegie Mellon University
|
|
|
|
* Pittsburgh PA 15213-3890
|
|
|
|
*
|
|
|
|
* any improvements or extensions that they make and grant Carnegie the
|
|
|
|
* rights to redistribute these changes.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* devGraphics.c --
|
|
|
|
*
|
|
|
|
* This file contains machine-dependent routines for the graphics device.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1989 Digital Equipment Corporation.
|
|
|
|
* 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 appears in all copies.
|
|
|
|
* Digital Equipment Corporation makes no representations about the
|
|
|
|
* suitability of this software for any purpose. It is provided "as is"
|
|
|
|
* without express or implied warranty.
|
|
|
|
*
|
1994-05-27 12:39:00 +04:00
|
|
|
* from: Header: /sprite/src/kernel/dev/ds3100.md/RCS/devGraphics.c,
|
|
|
|
* v 9.2 90/02/13 22:16:24 shirriff Exp SPRITE (DECWRL)";
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
|
|
|
|
1996-02-02 21:05:36 +03:00
|
|
|
#include "fb.h"
|
1995-09-11 11:45:36 +04:00
|
|
|
|
1996-02-02 21:05:36 +03:00
|
|
|
#include "xcfb.h"
|
|
|
|
#include "dtop.h"
|
1993-10-12 06:22:19 +03:00
|
|
|
#if NXCFB > 0
|
|
|
|
#if NDTOP == 0
|
|
|
|
xcfb needs dtop device
|
|
|
|
#else
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/mman.h>
|
1996-02-15 22:13:08 +03:00
|
|
|
#include <sys/malloc.h>
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
#include <vm/vm.h>
|
|
|
|
|
1995-08-10 08:21:35 +04:00
|
|
|
#include <sys/device.h>
|
1996-01-30 01:52:15 +03:00
|
|
|
#include <dev/tc/tcvar.h>
|
1995-08-10 08:21:35 +04:00
|
|
|
#include <machine/autoconf.h>
|
1993-10-12 06:22:19 +03:00
|
|
|
#include <machine/machConst.h>
|
|
|
|
#include <machine/pmioctl.h>
|
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
#include <machine/fbio.h>
|
|
|
|
#include <machine/fbvar.h>
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
#include <pmax/pmax/cons.h>
|
|
|
|
|
|
|
|
#include <pmax/dev/xcfbreg.h>
|
1995-09-11 11:45:36 +04:00
|
|
|
#include <pmax/dev/ims332.h>
|
|
|
|
#include <pmax/pmax/maxine.h>
|
|
|
|
#include <pmax/pmax/pmaxtype.h>
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
#include <pmax/dev/dtopreg.h>
|
1995-09-11 11:45:36 +04:00
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
#include <pmax/dev/fbreg.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These need to be mapped into user space.
|
|
|
|
*/
|
|
|
|
struct fbuaccess xcfbu;
|
1995-09-11 11:45:36 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* rcons methods and globals.
|
|
|
|
*/
|
|
|
|
struct pmax_fbtty xcfbfb;
|
|
|
|
|
|
|
|
struct fbinfo xcfbfi; /*XXX*/
|
|
|
|
extern struct cfdriver cfb;
|
|
|
|
|
|
|
|
#define CMAP_BITS (3 * 256) /* 256 entries, 3 bytes per. */
|
1996-02-15 22:13:08 +03:00
|
|
|
static u_char cmap_bits [CMAP_BITS]; /* colormap for console... */
|
1995-09-11 11:45:36 +04:00
|
|
|
|
|
|
|
#define XCFB_FB_SIZE 0x100000 /* size of raster (mapped into userspace) */
|
|
|
|
|
|
|
|
|
|
|
|
struct fbdriver xcfb_driver = {
|
|
|
|
ims332_video_on,
|
|
|
|
ims332_video_off,
|
|
|
|
ims332InitColorMap,
|
|
|
|
ims332GetColorMap,
|
|
|
|
ims332LoadColorMap,
|
|
|
|
ims332PosCursor,
|
|
|
|
ims332LoadCursor,
|
|
|
|
ims332CursorColor
|
|
|
|
};
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Forward references.
|
|
|
|
*/
|
1995-09-11 11:45:36 +04:00
|
|
|
extern void fbScreenInit __P((struct fbinfo *fi));
|
|
|
|
|
|
|
|
|
|
|
|
void genKbdEvent(), genMouseEvent(), genMouseButtons();
|
|
|
|
|
1994-05-27 12:39:00 +04:00
|
|
|
extern void dtopKBDPutc();
|
1993-10-12 06:22:19 +03:00
|
|
|
extern void (*dtopDivertXInput)();
|
|
|
|
extern void (*dtopMouseEvent)();
|
|
|
|
extern void (*dtopMouseButtons)();
|
|
|
|
extern int pmax_boardtype;
|
|
|
|
extern u_short defCursor[32];
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
1995-08-10 08:21:35 +04:00
|
|
|
* Autoconfiguration data for config.new.
|
|
|
|
* Use static-sized softc until config.old and old autoconfig
|
|
|
|
* code is completely gone.
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
1995-08-10 08:21:35 +04:00
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
xcfbmatch(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
void *match;
|
|
|
|
void *aux;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
1995-08-10 08:21:35 +04:00
|
|
|
struct cfdata *cf = match;
|
|
|
|
struct confargs *ca = aux;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1996-01-30 01:52:15 +03:00
|
|
|
/* Make sure that it's an xcfb. */
|
|
|
|
if (!TC_BUS_MATCHNAME(ca, "PMAG-DV ") &&
|
|
|
|
strcmp(ca->ca_name, "xcfb") != 0)
|
1993-10-12 06:22:19 +03:00
|
|
|
return (0);
|
1995-08-10 08:21:35 +04:00
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
1995-08-10 08:21:35 +04:00
|
|
|
void
|
|
|
|
xcfbattach(parent, self, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct device *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct confargs *ca = aux;
|
|
|
|
|
1996-01-30 01:52:15 +03:00
|
|
|
if (!xcfbinit(NULL, ca->ca_addr, self->dv_unit, 0));
|
1995-08-10 08:21:35 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* no interrupts for XCFB */
|
1995-09-11 11:45:36 +04:00
|
|
|
/*BUS_INTR_ESTABLISH(ca, xcfbintr, self->dv_unit);*/
|
1995-08-10 08:21:35 +04:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialization
|
|
|
|
*/
|
|
|
|
int
|
1995-09-20 09:19:54 +04:00
|
|
|
xcfbinit(fi, base, unit, silent)
|
|
|
|
struct fbinfo *fi;
|
1995-09-11 11:45:36 +04:00
|
|
|
caddr_t base;
|
|
|
|
int unit;
|
|
|
|
int silent;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
|
|
|
register u_int *reset = (u_int *)IMS332_RESET_ADDRESS;
|
|
|
|
|
1996-02-15 22:13:08 +03:00
|
|
|
/*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 0x%x\n", unit);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/*XXX*/
|
1993-10-12 06:22:19 +03:00
|
|
|
/*
|
|
|
|
* Or Cached? A comment in the Mach driver suggests that the X server
|
|
|
|
* runs faster in cached address space, but the X server is going
|
|
|
|
* to blow away the data cache whenever it updates the screen, so..
|
|
|
|
*/
|
1995-09-11 11:45:36 +04:00
|
|
|
base = (char *) MACH_PHYS_TO_UNCACHED(XINE_PHYS_CFB_START);
|
|
|
|
|
|
|
|
/* Fill in main frame buffer info struct. */
|
|
|
|
fi->fi_unit = unit;
|
|
|
|
fi->fi_pixels = (caddr_t)(base + VRAM_OFFSET);
|
|
|
|
fi->fi_pixelsize = 1024 * 768;
|
|
|
|
fi->fi_base = (caddr_t)IMS332_RESET_ADDRESS;
|
|
|
|
fi->fi_vdac = (caddr_t)IMS332_ADDRESS;
|
|
|
|
fi->fi_size = 0x100000;
|
|
|
|
fi->fi_linebytes = 1024;
|
|
|
|
fi->fi_driver = &xcfb_driver;
|
|
|
|
fi->fi_blanked = 0;
|
|
|
|
|
|
|
|
/* Fill in Frame Buffer Type struct. */
|
1995-09-20 09:19:54 +04:00
|
|
|
fi->fi_type.fb_boardtype = PMAX_FBTYPE_XCFB;
|
1995-09-11 11:45:36 +04:00
|
|
|
fi->fi_type.fb_width = 1024;
|
|
|
|
fi->fi_type.fb_height = 768;
|
|
|
|
fi->fi_type.fb_depth = 8;
|
|
|
|
fi->fi_type.fb_cmsize = 256;
|
|
|
|
fi->fi_type.fb_size = XCFB_FB_SIZE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* qvss/pm-style mmap()ed event queue compatibility glue
|
|
|
|
*/
|
1993-10-12 06:22:19 +03:00
|
|
|
/*
|
1994-05-27 12:39:00 +04:00
|
|
|
* Must be in Uncached space since the fbuaccess structure is
|
|
|
|
* mapped into the user's address space uncached.
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
1995-09-11 11:45:36 +04:00
|
|
|
fi->fi_fbu = (struct fbuaccess *)
|
1993-10-12 06:22:19 +03:00
|
|
|
MACH_PHYS_TO_UNCACHED(MACH_CACHED_TO_PHYS(&xcfbu));
|
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/* This is glass-tty state but it's in the shared structure. Ick. */
|
|
|
|
fi->fi_fbu->scrInfo.max_row = 50;
|
|
|
|
fi->fi_fbu->scrInfo.max_col = 80;
|
|
|
|
|
|
|
|
init_pmaxfbu(fi);
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
/*
|
1995-09-11 11:45:36 +04:00
|
|
|
* Initialize old-style pmax glass-tty screen info.
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
1995-09-11 11:45:36 +04:00
|
|
|
fi->fi_glasstty = &xcfbfb;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/*XXX*/
|
|
|
|
/* dimensions translated -15 pixels, for sprite origin? */
|
|
|
|
fi->fi_fbu->scrInfo.max_cur_x = 1008;
|
|
|
|
fi->fi_fbu->scrInfo.max_cur_y = 752;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
fi->fi_fbu->scrInfo.min_cur_x = -15;
|
|
|
|
fi->fi_fbu->scrInfo.min_cur_y = -15;
|
|
|
|
|
|
|
|
/* Initialize the RAMDAC. */
|
|
|
|
ims332init (fi);
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
|
1995-09-20 09:19:54 +04:00
|
|
|
/* Connect serial device(s) */
|
|
|
|
if (tb_kbdmouseconfig(fi)) {
|
|
|
|
printf(" (mouse/keyboard config failed)");
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
/*
|
1995-09-11 11:45:36 +04:00
|
|
|
* Connect to the raster-console pseudo-driver
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
1995-09-11 11:45:36 +04:00
|
|
|
fbconnect("PMAG-DV", fi, silent);
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
#ifdef fpinitialized
|
|
|
|
fp->initialized = 1;
|
|
|
|
#endif
|
|
|
|
return (1);
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* NDTOP */
|
|
|
|
#endif /* NXCFB */
|