1998-06-30 13:02:08 +04:00
|
|
|
/* $NetBSD: cfb.c,v 1.19 1998/06/30 09:02:08 drochner Exp $ */
|
1996-05-02 03:25:00 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Author: Chris G. Demetriou
|
|
|
|
*
|
|
|
|
* 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 "AS IS"
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
1997-04-08 03:39:37 +04:00
|
|
|
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
|
|
|
|
1998-06-30 13:02:08 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: cfb.c,v 1.19 1998/06/30 09:02:08 drochner Exp $");
|
1997-04-07 02:31:45 +04:00
|
|
|
|
1996-05-02 03:25:00 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/intr.h>
|
1997-04-07 10:09:00 +04:00
|
|
|
#include <machine/conf.h>
|
1996-05-02 03:25:00 +04:00
|
|
|
|
|
|
|
#include <dev/tc/tcvar.h>
|
|
|
|
#include <machine/cfbreg.h>
|
|
|
|
#include <alpha/tc/cfbvar.h>
|
|
|
|
#if 0
|
|
|
|
#include <alpha/tc/bt459reg.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <dev/rcons/raster.h>
|
1998-04-16 01:15:08 +04:00
|
|
|
#include <dev/wscons/wscons_raster.h>
|
|
|
|
#include <dev/wscons/wsdisplayvar.h>
|
1996-05-02 03:25:00 +04:00
|
|
|
#include <machine/fbio.h>
|
|
|
|
|
|
|
|
#include <machine/autoconf.h>
|
|
|
|
#include <machine/pte.h>
|
|
|
|
|
1996-12-05 04:39:27 +03:00
|
|
|
int cfbmatch __P((struct device *, struct cfdata *, void *));
|
1996-05-02 03:25:00 +04:00
|
|
|
void cfbattach __P((struct device *, struct device *, void *));
|
|
|
|
|
|
|
|
struct cfattach cfb_ca = {
|
|
|
|
sizeof(struct cfb_softc), cfbmatch, cfbattach,
|
|
|
|
};
|
|
|
|
|
|
|
|
void cfb_getdevconfig __P((tc_addr_t dense_addr, struct cfb_devconfig *dc));
|
|
|
|
struct cfb_devconfig cfb_console_dc;
|
1998-04-16 01:15:08 +04:00
|
|
|
tc_addr_t cfb_consaddr;
|
1996-05-02 03:25:00 +04:00
|
|
|
|
1998-04-16 01:15:08 +04:00
|
|
|
struct wsdisplay_emulops cfb_emulfuncs = {
|
1996-05-02 03:25:00 +04:00
|
|
|
rcons_cursor, /* could use hardware cursor; punt */
|
1998-06-30 13:02:08 +04:00
|
|
|
rcons_mapchar,
|
1998-06-21 13:51:59 +04:00
|
|
|
rcons_putchar,
|
1996-05-02 03:25:00 +04:00
|
|
|
rcons_copycols,
|
|
|
|
rcons_erasecols,
|
|
|
|
rcons_copyrows,
|
|
|
|
rcons_eraserows,
|
1998-05-15 00:49:55 +04:00
|
|
|
rcons_alloc_attr
|
1998-04-16 01:15:08 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct wsscreen_descr cfb_stdscreen = {
|
|
|
|
"std",
|
1998-05-15 00:49:55 +04:00
|
|
|
0, 0, /* will be filled in -- XXX shouldn't, it's global */
|
1998-04-16 01:15:08 +04:00
|
|
|
&cfb_emulfuncs,
|
|
|
|
0, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct wsscreen_descr *_cfb_scrlist[] = {
|
|
|
|
&cfb_stdscreen,
|
|
|
|
/* XXX other formats, graphics screen? */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wsscreen_list cfb_screenlist = {
|
|
|
|
sizeof(_cfb_scrlist) / sizeof(struct wsscreen_descr *), _cfb_scrlist
|
1996-05-02 03:25:00 +04:00
|
|
|
};
|
|
|
|
|
1996-11-19 08:23:07 +03:00
|
|
|
int cfbioctl __P((void *, u_long, caddr_t, int, struct proc *));
|
|
|
|
int cfbmmap __P((void *, off_t, int));
|
1996-05-02 03:25:00 +04:00
|
|
|
|
|
|
|
int cfbintr __P((void *));
|
1998-04-16 01:15:08 +04:00
|
|
|
static int cfb_alloc_screen __P((void *, const struct wsscreen_descr *,
|
1998-05-15 00:49:55 +04:00
|
|
|
void **, int *, int *, long *));
|
1998-04-16 01:15:08 +04:00
|
|
|
static void cfb_free_screen __P((void *, void *));
|
|
|
|
static void cfb_show_screen __P((void *, void *));
|
|
|
|
static int cfb_load_font __P((void *, void *, int, int, int, void *));
|
|
|
|
|
|
|
|
struct wsdisplay_accessops cfb_accessops = {
|
|
|
|
cfbioctl,
|
|
|
|
cfbmmap,
|
|
|
|
cfb_alloc_screen,
|
|
|
|
cfb_free_screen,
|
|
|
|
cfb_show_screen,
|
|
|
|
cfb_load_font
|
|
|
|
};
|
1996-05-02 03:25:00 +04:00
|
|
|
|
|
|
|
int
|
|
|
|
cfbmatch(parent, match, aux)
|
|
|
|
struct device *parent;
|
1996-12-05 04:39:27 +03:00
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
1996-05-02 03:25:00 +04:00
|
|
|
{
|
|
|
|
struct tc_attach_args *ta = aux;
|
|
|
|
|
|
|
|
if (strncmp("PMAG-BA ", ta->ta_modname, TC_ROM_LLEN) != 0)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
return (10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cfb_getdevconfig(dense_addr, dc)
|
|
|
|
tc_addr_t dense_addr;
|
|
|
|
struct cfb_devconfig *dc;
|
|
|
|
{
|
|
|
|
struct raster *rap;
|
|
|
|
struct rcons *rcp;
|
|
|
|
char *ramdacregp;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
dc->dc_vaddr = dense_addr;
|
1996-07-09 04:53:48 +04:00
|
|
|
dc->dc_paddr = ALPHA_K0SEG_TO_PHYS(dc->dc_vaddr); /* XXX */
|
1996-05-02 03:25:00 +04:00
|
|
|
dc->dc_size = CFB_SIZE;
|
|
|
|
|
|
|
|
ramdacregp = (char *)dc->dc_vaddr + CFB_RAMDAC_OFFSET;
|
|
|
|
|
|
|
|
dc->dc_wid = 1024;
|
|
|
|
dc->dc_ht = 864;
|
|
|
|
dc->dc_depth = 8; /* 8 plane */
|
|
|
|
dc->dc_rowbytes = dc->dc_wid * (dc->dc_depth / 8);
|
|
|
|
|
|
|
|
dc->dc_videobase = dc->dc_vaddr + CFB_FB_OFFSET;
|
|
|
|
|
|
|
|
/* Initialize the RAMDAC/colormap */
|
|
|
|
/* start XXX XXX XXX */
|
|
|
|
(*(volatile u_int32_t *)(ramdacregp + CFB_RAMDAC_ADDRLOW)) = 0;
|
|
|
|
(*(volatile u_int32_t *)(ramdacregp + CFB_RAMDAC_ADDRHIGH)) = 0;
|
|
|
|
tc_wmb();
|
|
|
|
for (i = 0; i < 256; i++) {
|
|
|
|
(*(volatile u_int32_t *)(ramdacregp + CFB_RAMDAC_CMAPDATA)) =
|
|
|
|
i ? 0xff : 0;
|
|
|
|
tc_wmb();
|
|
|
|
(*(volatile u_int32_t *)(ramdacregp + CFB_RAMDAC_CMAPDATA)) =
|
|
|
|
i ? 0xff : 0;
|
|
|
|
tc_wmb();
|
|
|
|
(*(volatile u_int32_t *)(ramdacregp + CFB_RAMDAC_CMAPDATA)) =
|
|
|
|
i ? 0xff : 0;
|
|
|
|
tc_wmb();
|
|
|
|
}
|
|
|
|
/* end XXX XXX XXX */
|
|
|
|
|
|
|
|
/* clear the screen */
|
|
|
|
for (i = 0; i < dc->dc_ht * dc->dc_rowbytes; i += sizeof(u_int32_t))
|
|
|
|
*(u_int32_t *)(dc->dc_videobase + i) = 0x00000000;
|
|
|
|
|
|
|
|
rap = &dc->dc_raster;
|
|
|
|
rap->width = dc->dc_wid;
|
|
|
|
rap->height = dc->dc_ht;
|
|
|
|
rap->depth = 8;
|
|
|
|
rap->linelongs = dc->dc_rowbytes / sizeof(u_int32_t);
|
|
|
|
rap->pixels = (u_int32_t *)dc->dc_videobase;
|
|
|
|
|
|
|
|
/* initialize the raster console blitter */
|
|
|
|
rcp = &dc->dc_rcons;
|
|
|
|
rcp->rc_sp = rap;
|
|
|
|
rcp->rc_crow = rcp->rc_ccol = -1;
|
|
|
|
rcp->rc_crowp = &rcp->rc_crow;
|
|
|
|
rcp->rc_ccolp = &rcp->rc_ccol;
|
|
|
|
rcons_init(rcp, 34, 80);
|
1998-04-16 01:15:08 +04:00
|
|
|
|
|
|
|
cfb_stdscreen.nrows = dc->dc_rcons.rc_maxrow;
|
|
|
|
cfb_stdscreen.ncols = dc->dc_rcons.rc_maxcol;
|
1996-05-02 03:25:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cfbattach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct cfb_softc *sc = (struct cfb_softc *)self;
|
|
|
|
struct tc_attach_args *ta = aux;
|
1998-04-16 01:15:08 +04:00
|
|
|
struct wsemuldisplaydev_attach_args waa;
|
1996-05-02 03:25:00 +04:00
|
|
|
int console;
|
|
|
|
|
1998-04-16 01:15:08 +04:00
|
|
|
console = (ta->ta_addr == cfb_consaddr);
|
|
|
|
if (console) {
|
1996-05-02 03:25:00 +04:00
|
|
|
sc->sc_dc = &cfb_console_dc;
|
1998-04-16 01:15:08 +04:00
|
|
|
sc->nscreens = 1;
|
|
|
|
} else {
|
1996-05-02 03:25:00 +04:00
|
|
|
sc->sc_dc = (struct cfb_devconfig *)
|
|
|
|
malloc(sizeof(struct cfb_devconfig), M_DEVBUF, M_WAITOK);
|
|
|
|
cfb_getdevconfig(ta->ta_addr, sc->sc_dc);
|
|
|
|
}
|
|
|
|
if (sc->sc_dc->dc_vaddr == NULL) {
|
1996-10-13 06:59:55 +04:00
|
|
|
printf(": couldn't map memory space; punt!\n");
|
1996-05-02 03:25:00 +04:00
|
|
|
return;
|
|
|
|
}
|
1996-10-13 06:59:55 +04:00
|
|
|
printf(": %d x %d, %dbpp\n", sc->sc_dc->dc_wid, sc->sc_dc->dc_ht,
|
1996-05-02 03:25:00 +04:00
|
|
|
sc->sc_dc->dc_depth);
|
|
|
|
|
|
|
|
/* Establish an interrupt handler, and clear any pending interrupts */
|
|
|
|
tc_intr_establish(parent, ta->ta_cookie, TC_IPL_TTY, cfbintr, sc);
|
|
|
|
*(volatile u_int32_t *)(sc->sc_dc->dc_vaddr + CFB_IREQCTRL_OFFSET) = 0;
|
|
|
|
|
|
|
|
/* initialize the raster */
|
1998-04-16 01:15:08 +04:00
|
|
|
waa.console = console;
|
|
|
|
waa.scrdata = &cfb_screenlist;
|
|
|
|
waa.accessops = &cfb_accessops;
|
|
|
|
waa.accesscookie = sc;
|
1996-11-19 08:23:07 +03:00
|
|
|
|
1998-04-16 01:15:08 +04:00
|
|
|
config_found(self, &waa, wsemuldisplaydevprint);
|
1996-05-02 03:25:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-11-19 08:23:07 +03:00
|
|
|
cfbioctl(v, cmd, data, flag, p)
|
|
|
|
void *v;
|
1996-05-02 03:25:00 +04:00
|
|
|
u_long cmd;
|
|
|
|
caddr_t data;
|
|
|
|
int flag;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1996-11-19 08:23:07 +03:00
|
|
|
struct cfb_softc *sc = v;
|
1996-05-02 03:25:00 +04:00
|
|
|
struct cfb_devconfig *dc = sc->sc_dc;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case FBIOGTYPE:
|
|
|
|
#define fbt ((struct fbtype *)data)
|
|
|
|
fbt->fb_type = FBTYPE_CFB;
|
|
|
|
fbt->fb_height = sc->sc_dc->dc_ht;
|
|
|
|
fbt->fb_width = sc->sc_dc->dc_wid;
|
|
|
|
fbt->fb_depth = sc->sc_dc->dc_depth;
|
|
|
|
fbt->fb_cmsize = 256; /* XXX ??? */
|
|
|
|
fbt->fb_size = sc->sc_dc->dc_size;
|
|
|
|
#undef fbt
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
case FBIOPUTCMAP:
|
|
|
|
return (*tgar->tgar_set_cmap)(dc, (struct fbcmap *)data);
|
|
|
|
|
|
|
|
case FBIOGETCMAP:
|
|
|
|
return (*tgar->tgar_get_cmap)(dc, (struct fbcmap *)data);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
case FBIOGATTR:
|
|
|
|
return (ENOTTY); /* XXX ? */
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
case FBIOSVIDEO:
|
|
|
|
if (*(int *)data == FBVIDEO_OFF)
|
|
|
|
cfb_blank(sc->sc_dc);
|
|
|
|
else
|
|
|
|
cfb_unblank(sc->sc_dc);
|
|
|
|
return (0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
case FBIOGVIDEO:
|
|
|
|
*(int *)data = dc->dc_blanked ? FBVIDEO_OFF : FBVIDEO_ON;
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
case FBIOSCURSOR:
|
|
|
|
return (*tgar->tgar_set_cursor)(dc, (struct fbcursor *)data);
|
|
|
|
|
|
|
|
case FBIOGCURSOR:
|
|
|
|
return (*tgar->tgar_get_cursor)(dc, (struct fbcursor *)data);
|
|
|
|
|
|
|
|
case FBIOSCURPOS:
|
|
|
|
return (*tgar->tgar_set_curpos)(dc, (struct fbcurpos *)data);
|
|
|
|
|
|
|
|
case FBIOGCURPOS:
|
|
|
|
return (*tgar->tgar_get_curpos)(dc, (struct fbcurpos *)data);
|
|
|
|
|
|
|
|
case FBIOGCURMAX:
|
|
|
|
return (*tgar->tgar_get_curmax)(dc, (struct fbcurpos *)data);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-11-19 08:23:07 +03:00
|
|
|
cfbmmap(v, offset, prot)
|
|
|
|
void *v;
|
1996-05-02 03:25:00 +04:00
|
|
|
off_t offset;
|
|
|
|
int prot;
|
|
|
|
{
|
1996-11-19 08:23:07 +03:00
|
|
|
struct cfb_softc *sc = v;
|
1996-05-02 03:25:00 +04:00
|
|
|
|
|
|
|
if (offset > CFB_SIZE)
|
|
|
|
return -1;
|
|
|
|
return alpha_btop(sc->sc_dc->dc_paddr + offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
cfbintr(v)
|
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct cfb_softc *sc = v;
|
|
|
|
|
|
|
|
*(volatile u_int32_t *)(sc->sc_dc->dc_vaddr + CFB_IREQCTRL_OFFSET) = 0;
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
1998-04-16 01:15:08 +04:00
|
|
|
int
|
1998-05-15 00:49:55 +04:00
|
|
|
cfb_alloc_screen(v, type, cookiep, curxp, curyp, attrp)
|
1998-04-16 01:15:08 +04:00
|
|
|
void *v;
|
|
|
|
const struct wsscreen_descr *type;
|
|
|
|
void **cookiep;
|
|
|
|
int *curxp, *curyp;
|
1998-05-15 00:49:55 +04:00
|
|
|
long *attrp;
|
1998-04-16 01:15:08 +04:00
|
|
|
{
|
|
|
|
struct cfb_softc *sc = v;
|
1998-05-15 00:49:55 +04:00
|
|
|
long defattr;
|
1998-04-16 01:15:08 +04:00
|
|
|
|
|
|
|
if (sc->nscreens > 0)
|
|
|
|
return (ENOMEM);
|
|
|
|
|
|
|
|
*cookiep = &sc->sc_dc->dc_rcons; /* one and only for now */
|
|
|
|
*curxp = 0;
|
|
|
|
*curyp = 0;
|
1998-05-15 00:49:55 +04:00
|
|
|
rcons_alloc_attr(&sc->sc_dc->dc_rcons, 0, 0, 0, &defattr);
|
|
|
|
*attrp = defattr;
|
1998-04-16 16:52:42 +04:00
|
|
|
sc->nscreens++;
|
1998-04-16 01:15:08 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cfb_free_screen(v, cookie)
|
|
|
|
void *v;
|
|
|
|
void *cookie;
|
|
|
|
{
|
|
|
|
struct cfb_softc *sc = v;
|
|
|
|
|
|
|
|
if (sc->sc_dc == &cfb_console_dc)
|
|
|
|
panic("cfb_free_screen: console");
|
|
|
|
|
|
|
|
sc->nscreens--;
|
|
|
|
}
|
|
|
|
|
1996-05-02 03:25:00 +04:00
|
|
|
void
|
1998-04-16 01:15:08 +04:00
|
|
|
cfb_show_screen(v, cookie)
|
|
|
|
void *v;
|
|
|
|
void *cookie;
|
1996-05-02 03:25:00 +04:00
|
|
|
{
|
1998-04-16 01:15:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
cfb_load_font(v, cookie, first, num, stride, data)
|
|
|
|
void *v;
|
|
|
|
void *cookie;
|
|
|
|
int first, num, stride;
|
|
|
|
void *data;
|
|
|
|
{
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
int
|
|
|
|
cfb_cnattach(addr)
|
|
|
|
tc_addr_t addr;
|
|
|
|
{
|
|
|
|
struct cfb_devconfig *dcp = &cfb_console_dc;
|
1998-05-15 00:49:55 +04:00
|
|
|
long defattr;
|
1998-04-16 01:15:08 +04:00
|
|
|
|
|
|
|
cfb_getdevconfig(addr, dcp);
|
|
|
|
|
1998-05-15 00:49:55 +04:00
|
|
|
rcons_alloc_attr(&dcp->dc_rcons, 0, 0, 0, &defattr);
|
|
|
|
|
1998-04-16 01:15:08 +04:00
|
|
|
wsdisplay_cnattach(&cfb_stdscreen, &dcp->dc_rcons,
|
1998-05-15 00:49:55 +04:00
|
|
|
0, 0, defattr);
|
1998-04-16 01:15:08 +04:00
|
|
|
cfb_consaddr = addr;
|
|
|
|
return(0);
|
1996-05-02 03:25:00 +04:00
|
|
|
}
|
|
|
|
#endif
|