diff options
| author | tsubai <tsubai@NetBSD.org> | 2000-02-09 13:08:35 +0000 |
|---|---|---|
| committer | tsubai <tsubai@NetBSD.org> | 2000-02-09 13:08:35 +0000 |
| commit | dcb9f03bd3cdf4a40a7b60c8ad89722cdbd2bfe4 (patch) | |
| tree | 67d3195660a868bb47a70f9a576adb14ce89ebfb /sys/arch/macppc/dev | |
| parent | e92b285eafc2fd1f95e317a1d2a4f0467f0fb583 (diff) | |
Use dev/rasops instead of dev/rcons.
Diffstat (limited to 'sys/arch/macppc/dev')
| -rw-r--r-- | sys/arch/macppc/dev/ofb.c | 230 | ||||
| -rw-r--r-- | sys/arch/macppc/dev/ofbvar.h | 11 |
2 files changed, 125 insertions, 116 deletions
diff --git a/sys/arch/macppc/dev/ofb.c b/sys/arch/macppc/dev/ofb.c index c7685d436ff..c61cb3194e1 100644 --- a/sys/arch/macppc/dev/ofb.c +++ b/sys/arch/macppc/dev/ofb.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofb.c,v 1.10 1999/12/06 19:25:58 drochner Exp $ */ +/* $NetBSD: ofb.c,v 1.11 2000/02/09 13:08:36 tsubai Exp $ */ /* * Copyright (c) 1995, 1996 Carnegie-Mellon University. @@ -36,14 +36,15 @@ #include <sys/malloc.h> #include <sys/systm.h> +#include <vm/vm.h> + #include <dev/pci/pcidevs.h> #include <dev/pci/pcireg.h> #include <dev/pci/pcivar.h> -#include <dev/rcons/raster.h> #include <dev/wscons/wsconsio.h> -#include <dev/wscons/wscons_raster.h> #include <dev/wscons/wsdisplayvar.h> +#include <dev/rasops/rasops.h> #include <machine/bus.h> #include <machine/grfioctl.h> @@ -60,21 +61,10 @@ struct cfattach ofb_ca = { struct ofb_devconfig ofb_console_dc; -struct wsdisplay_emulops ofb_emulops = { - rcons_cursor, /* could use hardware cursor; punt */ - rcons_mapchar, - rcons_putchar, - rcons_copycols, - rcons_erasecols, - rcons_copyrows, - rcons_eraserows, - rcons_alloc_attr -}; - struct wsscreen_descr ofb_stdscreen = { "std", 0, 0, /* will be filled in -- XXX shouldn't, it's global */ - &ofb_emulops, + 0, 0, 0, WSSCREEN_REVERSE }; @@ -105,7 +95,11 @@ struct wsdisplay_accessops ofb_accessops = { 0 /* load_font */ }; +static struct wsdisplay_font openfirm6x11; + static void ofb_common_init __P((int, struct ofb_devconfig *)); +static int ofb_getcmap __P((struct ofb_softc *, struct wsdisplay_cmap *)); +static int ofb_putcmap __P((struct ofb_softc *, struct wsdisplay_cmap *)); int ofbmatch(parent, match, aux) @@ -115,9 +109,8 @@ ofbmatch(parent, match, aux) { struct pci_attach_args *pa = aux; - /* /chaos/control */ if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_APPLE && - PCI_PRODUCT(pa->pa_id) == 3) + PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_CONTROL) return 1; if (PCI_CLASS(pa->pa_class) == PCI_CLASS_DISPLAY) @@ -155,12 +148,9 @@ ofbattach(parent, self, aux) } ofb_common_init(node, dc); - /* Set colormap to black on white. */ - OF_call_method_1("color!", dc->dc_ih, 4, 0, 0, 0, 0xff); - OF_call_method_1("color!", dc->dc_ih, 4, 255, 255, 255, 0); - screenbytes = dc->dc_height * dc->dc_linebytes; + screenbytes = dc->dc_ri.ri_stride * dc->dc_ri.ri_height; for (i = 0; i < screenbytes; i += sizeof(u_int32_t)) - *(u_int32_t *)(dc->dc_paddr + i) = 0; + *(u_int32_t *)(dc->dc_paddr + i) = 0xffffffff; } sc->sc_dc = dc; @@ -172,7 +162,12 @@ ofbattach(parent, self, aux) pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo); printf(": %s\n", devinfo); printf("%s: %d x %d, %dbpp\n", self->dv_xname, - dc->dc_raster.width, dc->dc_raster.height, dc->dc_raster.depth); + dc->dc_ri.ri_width, dc->dc_ri.ri_height, dc->dc_ri.ri_depth); + + sc->sc_cmap_red[0] = sc->sc_cmap_green[0] = sc->sc_cmap_blue[0] = 0; + sc->sc_cmap_red[15] = sc->sc_cmap_red[255] = 0xff; + sc->sc_cmap_green[15] = sc->sc_cmap_green[255] = 0xff; + sc->sc_cmap_blue[15] = sc->sc_cmap_blue[255] = 0xff; a.console = console; a.scrdata = &ofb_screenlist; @@ -187,10 +182,8 @@ ofb_common_init(node, dc) int node; struct ofb_devconfig *dc; { - struct raster *rap; - struct rcons *rcp; - int i; - int addr, width, height, linebytes, depth; + struct rasops_info *ri = &dc->dc_ri; + int32_t addr, width, height, linebytes, depth; if (dc->dc_ih == 0) { char name[64]; @@ -202,49 +195,59 @@ ofb_common_init(node, dc) /* XXX /chaos/control doesn't have "width", "height", ... */ width = height = -1; - if (OF_getprop(node, "width", &width, sizeof(width)) != 4) + if (OF_getprop(node, "width", &width, 4) != 4) OF_interpret("screen-width", 1, &width); - if (OF_getprop(node, "height", &height, sizeof(height)) != 4) + if (OF_getprop(node, "height", &height, 4) != 4) OF_interpret("screen-height", 1, &height); - if (OF_getprop(node, "linebytes", &linebytes, sizeof(linebytes)) != 4) + if (OF_getprop(node, "linebytes", &linebytes, 4) != 4) linebytes = width; /* XXX */ - if (OF_getprop(node, "depth", &depth, sizeof(depth)) != 4) + if (OF_getprop(node, "depth", &depth, 4) != 4) depth = 8; /* XXX */ - if (width == -1 || height == -1) - return; + if (OF_getprop(node, "address", &addr, 4) != 4) + OF_interpret("frame-buffer-adr", 1, &addr); - OF_interpret("frame-buffer-adr", 1, &addr); - if (addr == 0 || addr == -1) + if (width == -1 || height == -1 || addr == 0 || addr == -1) return; - dc->dc_paddr = addr; /* PA of the frame buffer */ - - /* initialize the raster */ - rap = &dc->dc_raster; - rap->width = width; - rap->height = height; - rap->depth = depth; - rap->linelongs = linebytes / sizeof(u_int32_t); - rap->pixels = (u_int32_t *)addr; - - /* 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, 128, 128); - /* If screen is smaller than 1024x768, use small font. */ - if ((width < 1024 || height < 768) && copy_rom_font() == 0) { - rcp->rc_xorigin = 2; - rcp->rc_yorigin = 4; + dc->dc_paddr = addr; /* PA of the frame buffer */ - OF_interpret("#lines", 1, &dc->dc_rcons.rc_maxrow); - OF_interpret("#columns", 1, &dc->dc_rcons.rc_maxcol); - } + /* change 0xff/0xff/0xff to white */ + OF_call_method_1("color!", dc->dc_ih, 4, 255, 255, 255, 255); - ofb_stdscreen.nrows = dc->dc_rcons.rc_maxrow; - ofb_stdscreen.ncols = dc->dc_rcons.rc_maxcol; + /* initialize rasops */ + ri->ri_width = width; + ri->ri_height = height; + ri->ri_depth = depth; + ri->ri_stride = linebytes; + ri->ri_bits = (char *)addr; + ri->ri_flg = RI_FORCEMONO | RI_FULLCLEAR | RI_CENTER; + + /* If screen is smaller than 1024x768, use small font. */ + if ((width < 1024 || height < 768) && copy_rom_font() == 0) { + int cols, rows; + + OF_interpret("#lines", 1, &rows); + OF_interpret("#columns", 1, &cols); + + ri->ri_font = &openfirm6x11; + ri->ri_wsfcookie = -1; /* not using wsfont */ + rasops_init(ri, rows, cols); + + ri->ri_xorigin = 2; + ri->ri_yorigin = 3; + ri->ri_bits = (char *)addr + ri->ri_xorigin + + ri->ri_stride * ri->ri_yorigin; + } else + rasops_init(ri, height/22, (width/12) & ~7); /* XXX 12x22 */ + + /* black on white */ + ri->ri_devcmap[0] = 0xffffffff; /* bg */ + ri->ri_devcmap[1] = 0; /* fg */ + + ofb_stdscreen.nrows = ri->ri_rows; + ofb_stdscreen.ncols = ri->ri_cols; + ofb_stdscreen.textops = &ri->ri_ops; + ofb_stdscreen.capabilities = ri->ri_caps; } int @@ -283,21 +286,24 @@ ofb_ioctl(v, cmd, data, flag, p) case WSDISPLAYIO_GINFO: wdf = (void *)data; - wdf->height = sc->sc_dc->dc_raster.height; - wdf->width = sc->sc_dc->dc_raster.width; - wdf->depth = sc->sc_dc->dc_raster.depth; + wdf->height = dc->dc_ri.ri_height; + wdf->width = dc->dc_ri.ri_width; + wdf->depth = dc->dc_ri.ri_depth; wdf->cmsize = 256; return 0; + case WSDISPLAYIO_GETCMAP: + return ofb_getcmap(sc, (struct wsdisplay_cmap *)data); + case WSDISPLAYIO_PUTCMAP: - return putcmap(sc, data); + return ofb_putcmap(sc, (struct wsdisplay_cmap *)data); /* XXX There are no way to know framebuffer pa from a user program. */ case GRFIOCGINFO: gm = (void *)data; bzero(gm, sizeof(struct grfinfo)); - gm->gd_fbaddr = (caddr_t)sc->sc_dc->dc_paddr; - gm->gd_fbrowbytes = sc->sc_dc->dc_linebytes; + gm->gd_fbaddr = (caddr_t)dc->dc_paddr; + gm->gd_fbrowbytes = dc->dc_ri.ri_stride; return 0; } return -1; @@ -311,8 +317,9 @@ ofb_mmap(v, offset, prot) { struct ofb_softc *sc = v; struct ofb_devconfig *dc = sc->sc_dc; + struct rasops_info *ri = &dc->dc_ri; - if (offset >= (dc->dc_linebytes * dc->dc_height) || offset < 0) + if (offset >= (ri->ri_stride * ri->ri_height) || offset < 0) return -1; return dc->dc_paddr + offset; @@ -327,15 +334,16 @@ ofb_alloc_screen(v, type, cookiep, curxp, curyp, attrp) long *attrp; { struct ofb_softc *sc = v; + struct rasops_info *ri = &sc->sc_dc->dc_ri; long defattr; if (sc->nscreens > 0) return (ENOMEM); - *cookiep = &sc->sc_dc->dc_rcons; /* one and only for now */ + *cookiep = ri; /* one and only for now */ *curxp = 0; *curyp = 0; - rcons_alloc_attr(&sc->sc_dc->dc_rcons, 0, 0, 0, &defattr); + (*ri->ri_ops.alloc_attr)(ri, 0, 0, 0, &defattr); *attrp = defattr; sc->nscreens++; return 0; @@ -370,41 +378,34 @@ int ofb_cnattach() { struct ofb_devconfig *dc = &ofb_console_dc; + struct rasops_info *ri = &dc->dc_ri; long defattr; - int crow = 0, i, screenbytes; + int crow = 0; int chosen, stdout, node; - char cmd[32]; chosen = OF_finddevice("/chosen"); OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)); node = OF_instance_to_package(stdout); dc->dc_ih = stdout; - ofb_common_init(node, dc); - screenbytes = dc->dc_height * dc->dc_linebytes; - - /* Set colormap to black on white. */ - OF_call_method_1("color!", dc->dc_ih, 4, 0, 0, 0, 0xff); - OF_call_method_1("color!", dc->dc_ih, 4, 255, 255, 255, 0xf0); - for (i = 0; i < screenbytes; i += sizeof(u_int32_t)) - *(u_int32_t *)(dc->dc_paddr + i) ^= 0xffffffff; - OF_call_method_1("color!", dc->dc_ih, 4, 255, 255, 255, 0); - /* get current cursor position */ OF_interpret("line#", 1, &crow); - /* move (rom monitor) cursor to the lowest line */ - sprintf(cmd, "%x to line#", ofb_stdscreen.nrows - 1); - OF_interpret(cmd, 0); + /* move (rom monitor) cursor to the lowest line - 1 */ + OF_interpret("#lines 2 - to line#", 0); + + ofb_common_init(node, dc); + + if (ri->ri_width >= 1024 && ri->ri_height >= 768) { + int i, screenbytes = ri->ri_stride * ri->ri_height; - if (dc->dc_width >= 1024 && dc->dc_height >= 768) { for (i = 0; i < screenbytes; i += sizeof(u_int32_t)) - *(u_int32_t *)(dc->dc_paddr + i) = 0; + *(u_int32_t *)(dc->dc_paddr + i) = 0xffffffff; crow = 0; } - rcons_alloc_attr(&dc->dc_rcons, 0, 0, 0, &defattr); - wsdisplay_cnattach(&ofb_stdscreen, &dc->dc_rcons, 0, crow, defattr); + (*ri->ri_ops.alloc_attr)(ri, 0, 0, 0, &defattr); + wsdisplay_cnattach(&ofb_stdscreen, ri, 0, crow, defattr); return 0; } @@ -412,13 +413,10 @@ ofb_cnattach() int copy_rom_font() { - int i, j; u_char *romfont; int char_width, char_height; int chosen, mmu, m, e; - extern struct raster_font gallant19; /* XXX */ - /* Get ROM FONT address. */ OF_interpret("font-adr", 1, &romfont); if (romfont == NULL) @@ -437,29 +435,47 @@ copy_rom_font() OF_interpret("char-width", 1, &char_width); OF_interpret("char-height", 1, &char_height); - /* XXX but we cannot use malloc here... */ - gallant19.width = char_width; - gallant19.height = char_height; - gallant19.ascent = 0; + openfirm6x11.name = "Open Firmware"; + openfirm6x11.firstchar = 32; + openfirm6x11.numchars = 96; + openfirm6x11.encoding = WSDISPLAY_FONTENC_ISO; + openfirm6x11.fontwidth = char_width; + openfirm6x11.fontheight = char_height; + openfirm6x11.stride = 1; + openfirm6x11.bitorder = WSDISPLAY_FONTORDER_L2R; + openfirm6x11.byteorder = WSDISPLAY_FONTORDER_L2R; + openfirm6x11.data = romfont; - for (i = 32; i < 128; i++) { - u_int *p; + return 0; +} - if (gallant19.chars[i].r == NULL) - continue; +int +ofb_getcmap(sc, cm) + struct ofb_softc *sc; + struct wsdisplay_cmap *cm; +{ + u_int index = cm->index; + u_int count = cm->count; + int error; - gallant19.chars[i].r->width = char_width; - gallant19.chars[i].r->height = char_height; - p = gallant19.chars[i].r->pixels; + if (index >= 256 || count > 256 || index + count > 256) + return EINVAL; + + error = copyout(&sc->sc_cmap_red[index], cm->red, count); + if (error) + return error; + error = copyout(&sc->sc_cmap_green[index], cm->green, count); + if (error) + return error; + error = copyout(&sc->sc_cmap_blue[index], cm->blue, count); + if (error) + return error; - for (j = 0; j < char_height; j++) - *p++ = romfont[(i - 32) * char_height + j] << 24; - } return 0; } int -putcmap(sc, cm) +ofb_putcmap(sc, cm) struct ofb_softc *sc; struct wsdisplay_cmap *cm; { diff --git a/sys/arch/macppc/dev/ofbvar.h b/sys/arch/macppc/dev/ofbvar.h index 017267e741b..9aef0a4a98d 100644 --- a/sys/arch/macppc/dev/ofbvar.h +++ b/sys/arch/macppc/dev/ofbvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: ofbvar.h,v 1.1 1998/10/14 12:15:13 tsubai Exp $ */ +/* $NetBSD: ofbvar.h,v 1.2 2000/02/09 13:08:36 tsubai Exp $ */ /* * Copyright (c) 1995, 1996 Carnegie-Mellon University. @@ -31,16 +31,9 @@ struct ofb_devconfig { paddr_t dc_paddr; /* physcal address */ int dc_ih; /* ihandle of this node */ - struct raster dc_raster; /* raster description */ - struct rcons dc_rcons; /* raster blitter control info */ + struct rasops_info dc_ri; }; -#define dc_width dc_raster.width -#define dc_height dc_raster.height -#define dc_depth dc_raster.depth -#define dc_linebytes dc_raster.linelongs * sizeof(u_int32_t) - - struct ofb_softc { struct device sc_dev; |
