Add support for colour and virtual consoles
This commit is contained in:
parent
569533352e
commit
53b4acd93d
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.macppc,v 1.71 2006/02/06 19:23:17 jmmv Exp $
|
||||
# $NetBSD: files.macppc,v 1.72 2006/02/12 21:00:46 macallan Exp $
|
||||
#
|
||||
# macppc-specific configuration info
|
||||
|
||||
|
@ -78,15 +78,15 @@ device uni_n: uni_n
|
|||
attach uni_n at mainbus
|
||||
file arch/macppc/dev/uni-n.c uni_n
|
||||
|
||||
# PCI bus support
|
||||
include "dev/pci/files.pci"
|
||||
|
||||
include "dev/wscons/files.wscons"
|
||||
include "dev/wsfont/files.wsfont"
|
||||
include "dev/rasops/files.rasops"
|
||||
include "dev/usb/files.usb"
|
||||
|
||||
device ofb: wsemuldisplaydev, rasops8
|
||||
# PCI bus support
|
||||
include "dev/pci/files.pci"
|
||||
|
||||
device ofb: wsemuldisplaydev, rasops8, vcons
|
||||
attach ofb at pci
|
||||
file arch/macppc/dev/ofb.c ofb needs-flag
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ofb.c,v 1.44 2006/02/07 02:29:28 macallan Exp $ */
|
||||
/* $NetBSD: ofb.c,v 1.45 2006/02/12 21:00:46 macallan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
||||
|
@ -28,7 +28,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ofb.c,v 1.44 2006/02/07 02:29:28 macallan Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ofb.c,v 1.45 2006/02/12 21:00:46 macallan Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/buf.h>
|
||||
|
@ -49,6 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: ofb.c,v 1.44 2006/02/07 02:29:28 macallan Exp $");
|
|||
#include <dev/wscons/wsconsio.h>
|
||||
#include <dev/wscons/wsdisplayvar.h>
|
||||
#include <dev/rasops/rasops.h>
|
||||
#include <dev/wsfont/wsfont.h>
|
||||
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <dev/ofw/ofw_pci.h>
|
||||
|
@ -59,6 +60,7 @@ __KERNEL_RCSID(0, "$NetBSD: ofb.c,v 1.44 2006/02/07 02:29:28 macallan Exp $");
|
|||
|
||||
#include <powerpc/oea/bat.h>
|
||||
|
||||
#include <dev/wscons/wsdisplay_vconsvar.h>
|
||||
#include <macppc/dev/ofbvar.h>
|
||||
|
||||
#if OFB_ENABLE_CACHE
|
||||
|
@ -73,8 +75,6 @@ static void ofbattach(struct device *, struct device *, void *);
|
|||
CFATTACH_DECL(ofb, sizeof(struct ofb_softc),
|
||||
ofbmatch, ofbattach, NULL, NULL);
|
||||
|
||||
struct ofb_devconfig ofb_console_dc;
|
||||
|
||||
struct wsscreen_descr ofb_stdscreen = {
|
||||
"std",
|
||||
0, 0, /* will be filled in -- XXX shouldn't, it's global */
|
||||
|
@ -92,31 +92,38 @@ struct wsscreen_list ofb_screenlist = {
|
|||
sizeof(_ofb_scrlist) / sizeof(struct wsscreen_descr *), _ofb_scrlist
|
||||
};
|
||||
|
||||
static int ofb_ioctl(void *, u_long, caddr_t, int, struct lwp *);
|
||||
static paddr_t ofb_mmap(void *, off_t, int);
|
||||
static int ofb_alloc_screen(void *, const struct wsscreen_descr *, void **,
|
||||
int *, int *, long *);
|
||||
static void ofb_free_screen(void *, void *);
|
||||
static int ofb_show_screen(void *, void *, int, void (*) (void *, int, int),
|
||||
void *);
|
||||
static int copy_rom_font(void);
|
||||
static int ofb_ioctl(void *, u_long, caddr_t, int, struct lwp *);
|
||||
static paddr_t ofb_mmap(void *, off_t, int);
|
||||
static int copy_rom_font(void);
|
||||
|
||||
static int ofb_init_rasops(int, struct rasops_info *);
|
||||
static void ofb_init_screen(void *, struct vcons_screen *, int, long *);
|
||||
|
||||
struct wsdisplay_accessops ofb_accessops = {
|
||||
ofb_ioctl,
|
||||
ofb_mmap,
|
||||
ofb_alloc_screen,
|
||||
ofb_free_screen,
|
||||
ofb_show_screen,
|
||||
0 /* load_font */
|
||||
NULL, /* vcons_alloc_screen */
|
||||
NULL, /* vcons_free_screen */
|
||||
NULL, /* vcons_show_screen */
|
||||
NULL /* load_font */
|
||||
};
|
||||
|
||||
static struct vcons_screen ofb_console_screen;
|
||||
static struct wsdisplay_font openfirm6x11;
|
||||
static int console_node, console_instance;
|
||||
static vaddr_t fbaddr;
|
||||
static int romfont_loaded = 0;
|
||||
|
||||
static void ofb_common_init(int, struct ofb_devconfig *);
|
||||
static int ofb_getcmap(struct ofb_softc *, struct wsdisplay_cmap *);
|
||||
static int ofb_putcmap(struct ofb_softc *, struct wsdisplay_cmap *);
|
||||
static void ofb_putpalreg(struct ofb_softc *, int, uint8_t, uint8_t,
|
||||
uint8_t);
|
||||
|
||||
int
|
||||
static int ofb_getcmap(struct ofb_softc *, struct wsdisplay_cmap *);
|
||||
static int ofb_putcmap(struct ofb_softc *, struct wsdisplay_cmap *);
|
||||
static void ofb_init_cmap(struct ofb_softc *);
|
||||
|
||||
extern const u_char rasops_cmap[768];
|
||||
|
||||
static int
|
||||
ofbmatch(struct device *parent, struct cfdata *match, void *aux)
|
||||
{
|
||||
struct pci_attach_args *pa = aux;
|
||||
|
@ -137,101 +144,98 @@ ofbattach(struct device *parent, struct device *self, void *aux)
|
|||
struct ofb_softc *sc = (struct ofb_softc *)self;
|
||||
struct pci_attach_args *pa = aux;
|
||||
struct wsemuldisplaydev_attach_args a;
|
||||
int console, node;
|
||||
struct ofb_devconfig *dc;
|
||||
struct rasops_info *ri = &ofb_console_screen.scr_ri;
|
||||
long defattr;
|
||||
int console, len;
|
||||
char devinfo[256];
|
||||
|
||||
sc->sc_memt = pa->pa_memt;
|
||||
sc->sc_iot = pa->pa_iot;
|
||||
sc->sc_pc = pa->pa_pc;
|
||||
sc->sc_pcitag = pa->pa_tag;
|
||||
sc->sc_mode = WSDISPLAYIO_MODE_EMUL;
|
||||
|
||||
pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
|
||||
printf(": %s\n", devinfo);
|
||||
|
||||
vcons_init(&sc->vd, sc, &ofb_stdscreen, &ofb_accessops);
|
||||
sc->vd.init_screen = ofb_init_screen;
|
||||
|
||||
console = ofb_is_console();
|
||||
|
||||
if (console) {
|
||||
dc = &ofb_console_dc;
|
||||
node = dc->dc_node;
|
||||
sc->nscreens = 1;
|
||||
sc->sc_node = console_node;
|
||||
sc->sc_ih = console_instance;
|
||||
vcons_init_screen(&sc->vd, &ofb_console_screen, 1, &defattr);
|
||||
SCREEN_VISIBLE((&ofb_console_screen));
|
||||
sc->vd.active = &ofb_console_screen;
|
||||
ofb_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
|
||||
printf("%s: %d x %d, %dbpp\n", self->dv_xname,
|
||||
ri->ri_width, ri->ri_height, ri->ri_depth);
|
||||
} else {
|
||||
int len;
|
||||
|
||||
dc = malloc(sizeof(struct ofb_devconfig), M_DEVBUF, M_WAITOK);
|
||||
memset(dc, 0, sizeof(struct ofb_devconfig));
|
||||
node = pcidev_to_ofdev(pa->pa_pc, pa->pa_tag);
|
||||
if (node == 0) {
|
||||
char name[64];
|
||||
sc->sc_node = pcidev_to_ofdev(pa->pa_pc, pa->pa_tag);
|
||||
if (sc->sc_node == 0) {
|
||||
printf(": ofdev not found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* XXX There are two child screens on PowerBook. */
|
||||
memset(devinfo, 0, sizeof(devinfo));
|
||||
OF_getprop(node, "device_type", devinfo, sizeof(devinfo));
|
||||
OF_getprop(sc->sc_node, "device_type", devinfo, sizeof(devinfo));
|
||||
len = strlen(devinfo);
|
||||
if (strcmp(devinfo + len - 7, "-parent") == 0)
|
||||
node = OF_child(node);
|
||||
sc->sc_node = OF_child(sc->sc_node);
|
||||
|
||||
ofb_common_init(node, dc);
|
||||
}
|
||||
sc->sc_dc = dc;
|
||||
memset(name, 0, 64);
|
||||
OF_package_to_path(sc->sc_node, name, sizeof(name));
|
||||
sc->sc_ih = OF_open(name);
|
||||
|
||||
sc->sc_pc = pa->pa_pc;
|
||||
sc->sc_pcitag = pa->pa_tag;
|
||||
|
||||
/* XXX */
|
||||
if (OF_getprop(node, "assigned-addresses", sc->sc_addrs,
|
||||
sizeof(sc->sc_addrs)) == -1) {
|
||||
node = OF_parent(node);
|
||||
OF_getprop(node, "assigned-addresses", sc->sc_addrs,
|
||||
sizeof(sc->sc_addrs));
|
||||
}
|
||||
|
||||
if (dc->dc_paddr == 0) {
|
||||
printf(": cannot map framebuffer\n");
|
||||
sc->sc_fbaddr = 0;
|
||||
if (OF_getprop(sc->sc_node, "address", &sc->sc_fbaddr, 4) != 4)
|
||||
OF_interpret("frame-buffer-adr", 1, &sc->sc_fbaddr);
|
||||
if (sc->sc_fbaddr == 0) {
|
||||
printf("%s: Unable to find the framebuffer address.\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear the screen here, instead of above, in case
|
||||
* ofb_common_init() failed to map the framebuffer.
|
||||
*/
|
||||
if (!console) {
|
||||
int i, screenbytes;
|
||||
|
||||
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) = 0xffffffff;
|
||||
/* XXX */
|
||||
if (OF_getprop(sc->sc_node, "assigned-addresses", sc->sc_addrs,
|
||||
sizeof(sc->sc_addrs)) == -1) {
|
||||
sc->sc_node = OF_parent(sc->sc_node);
|
||||
OF_getprop(sc->sc_node, "assigned-addresses", sc->sc_addrs,
|
||||
sizeof(sc->sc_addrs));
|
||||
}
|
||||
|
||||
pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
|
||||
printf(": %s\n", devinfo);
|
||||
printf("%s: %d x %d, %dbpp\n", self->dv_xname,
|
||||
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;
|
||||
ofb_init_cmap(sc);
|
||||
|
||||
a.console = console;
|
||||
a.scrdata = &ofb_screenlist;
|
||||
a.accessops = &ofb_accessops;
|
||||
a.accesscookie = sc;
|
||||
a.accesscookie = &sc->vd;
|
||||
|
||||
config_found(self, &a, wsemuldisplaydevprint);
|
||||
}
|
||||
|
||||
static void
|
||||
ofb_common_init(int node, struct ofb_devconfig *dc)
|
||||
ofb_init_screen(void *cookie, struct vcons_screen *scr,
|
||||
int existing, long *defattr)
|
||||
{
|
||||
struct rasops_info *ri = &dc->dc_ri;
|
||||
int32_t addr, width, height, linebytes, depth;
|
||||
struct ofb_softc *sc = cookie;
|
||||
struct rasops_info *ri = &scr->scr_ri;
|
||||
|
||||
dc->dc_node = node;
|
||||
if (dc->dc_ih == 0) {
|
||||
char name[64];
|
||||
|
||||
memset(name, 0, 64);
|
||||
OF_package_to_path(node, name, sizeof(name));
|
||||
dc->dc_ih = OF_open(name);
|
||||
if (scr != &ofb_console_screen) {
|
||||
ofb_init_rasops(sc->sc_node, ri);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
ofb_init_rasops(int node, struct rasops_info *ri)
|
||||
{
|
||||
int32_t width, height, linebytes, depth;
|
||||
|
||||
/* XXX /chaos/control doesn't have "width", "height", ... */
|
||||
width = height = -1;
|
||||
|
@ -243,17 +247,11 @@ ofb_common_init(int node, struct ofb_devconfig *dc)
|
|||
linebytes = width; /* XXX */
|
||||
if (OF_getprop(node, "depth", &depth, 4) != 4)
|
||||
depth = 8; /* XXX */
|
||||
if (OF_getprop(node, "address", &addr, 4) != 4)
|
||||
OF_interpret("frame-buffer-adr", 1, &addr);
|
||||
if (OF_getprop(node, "address", &fbaddr, 4) != 4)
|
||||
OF_interpret("frame-buffer-adr", 1, &fbaddr);
|
||||
|
||||
if (width == -1 || height == -1 || addr == 0 || addr == -1)
|
||||
return;
|
||||
|
||||
dc->dc_paddr = addr; /* PA of the frame buffer */
|
||||
|
||||
/* Make sure 0/0/0 is black and 255/255/255 is white. */
|
||||
OF_call_method_1("color!", dc->dc_ih, 4, 0, 0, 0, 0);
|
||||
OF_call_method_1("color!", dc->dc_ih, 4, 255, 255, 255, 255);
|
||||
if (width == -1 || height == -1 || fbaddr == 0 || fbaddr == -1)
|
||||
return FALSE;
|
||||
|
||||
/* Enable write-through cache. */
|
||||
if (ofb_enable_cache) {
|
||||
|
@ -265,12 +263,12 @@ ofb_common_init(int node, struct ofb_devconfig *dc)
|
|||
va += SEGMENT_LENGTH) {
|
||||
if (battable[va >> ADDR_SR_SHFT].batu == 0) {
|
||||
battable[va >> ADDR_SR_SHFT].batl =
|
||||
BATL(addr & 0xf0000000,
|
||||
BATL(fbaddr & 0xf0000000,
|
||||
BAT_G | BAT_W | BAT_M, BAT_PP_RW);
|
||||
battable[va >> ADDR_SR_SHFT].batu =
|
||||
BATL(va, BAT_BL_256M, BAT_Vs);
|
||||
addr &= 0x0fffffff;
|
||||
addr |= va;
|
||||
fbaddr &= 0x0fffffff;
|
||||
fbaddr |= va;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -281,16 +279,19 @@ ofb_common_init(int node, struct ofb_devconfig *dc)
|
|||
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;
|
||||
ri->ri_bits = (char *)fbaddr;
|
||||
ri->ri_flg = RI_CENTER | RI_FULLCLEAR;
|
||||
|
||||
/* If screen is smaller than 1024x768, use small font. */
|
||||
if ((width < 1024 || height < 768) && copy_rom_font() == 0) {
|
||||
if ((width < 1024 || height < 768) && (romfont_loaded)) {
|
||||
int cols, rows;
|
||||
|
||||
/*
|
||||
* XXX this assumes we're the console which may or may not
|
||||
* be the case
|
||||
*/
|
||||
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);
|
||||
|
@ -298,22 +299,17 @@ ofb_common_init(int node, struct ofb_devconfig *dc)
|
|||
ri->ri_xorigin = (width - cols * ri->ri_font->fontwidth) >> 1;
|
||||
ri->ri_yorigin = (height - rows * ri->ri_font->fontheight)
|
||||
>> 1;
|
||||
ri->ri_bits = (char *)addr + ri->ri_xorigin +
|
||||
ri->ri_bits = (char *)fbaddr + ri->ri_xorigin +
|
||||
ri->ri_stride * ri->ri_yorigin;
|
||||
} else {
|
||||
rasops_init(ri, 24, 80);
|
||||
rasops_reconfig(ri, (height - 2) / ri->ri_font->fontheight,
|
||||
((width - 2) / ri->ri_font->fontwidth) & ~7);
|
||||
/* use as much of the screen as the font permits */
|
||||
rasops_init(ri, height/8, width/8);
|
||||
ri->ri_caps = WSSCREEN_WSCOLORS;
|
||||
rasops_reconfig(ri, height / ri->ri_font->fontheight,
|
||||
width / ri->ri_font->fontwidth);
|
||||
}
|
||||
|
||||
/* 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;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -335,9 +331,10 @@ ofb_is_console()
|
|||
static int
|
||||
ofb_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct lwp *l)
|
||||
{
|
||||
struct ofb_softc *sc = v;
|
||||
struct ofb_devconfig *dc = sc->sc_dc;
|
||||
struct vcons_data *vd = v;
|
||||
struct ofb_softc *sc = vd->cookie;
|
||||
struct wsdisplay_fbinfo *wdf;
|
||||
struct vcons_screen *ms = vd->active;
|
||||
struct grfinfo *gm;
|
||||
|
||||
switch (cmd) {
|
||||
|
@ -346,12 +343,16 @@ ofb_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct lwp *l)
|
|||
return 0;
|
||||
|
||||
case WSDISPLAYIO_GINFO:
|
||||
wdf = (void *)data;
|
||||
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;
|
||||
/* we won't get here without any screen anyway */
|
||||
if (ms != NULL) {
|
||||
wdf = (void *)data;
|
||||
wdf->height = ms->scr_ri.ri_width;
|
||||
wdf->width = ms->scr_ri.ri_height;
|
||||
wdf->depth = ms->scr_ri.ri_depth;
|
||||
wdf->cmsize = 256;
|
||||
return 0;
|
||||
} else
|
||||
return ENODEV;
|
||||
|
||||
case WSDISPLAYIO_GETCMAP:
|
||||
return ofb_getcmap(sc, (struct wsdisplay_cmap *)data);
|
||||
|
@ -361,10 +362,27 @@ ofb_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct lwp *l)
|
|||
|
||||
/* XXX There are no way to know framebuffer pa from a user program. */
|
||||
case GRFIOCGINFO:
|
||||
gm = (void *)data;
|
||||
memset(gm, 0, sizeof(struct grfinfo));
|
||||
gm->gd_fbaddr = (caddr_t)dc->dc_paddr;
|
||||
gm->gd_fbrowbytes = dc->dc_ri.ri_stride;
|
||||
if (ms != NULL) {
|
||||
gm = (void *)data;
|
||||
memset(gm, 0, sizeof(struct grfinfo));
|
||||
gm->gd_fbaddr = (caddr_t)sc->sc_fbaddr;
|
||||
gm->gd_fbrowbytes = ms->scr_ri.ri_stride;
|
||||
return 0;
|
||||
} else
|
||||
return ENODEV;
|
||||
case WSDISPLAYIO_SMODE:
|
||||
{
|
||||
int new_mode = *(int*)data;
|
||||
if (new_mode != sc->sc_mode)
|
||||
{
|
||||
sc->sc_mode = new_mode;
|
||||
if (new_mode == WSDISPLAYIO_MODE_EMUL)
|
||||
{
|
||||
ofb_init_cmap(sc);
|
||||
vcons_redraw_screen(ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
/* PCI config read/write passthrough. */
|
||||
case PCI_IOC_CFGREAD:
|
||||
|
@ -378,16 +396,23 @@ ofb_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct lwp *l)
|
|||
static paddr_t
|
||||
ofb_mmap(void *v, off_t offset, int prot)
|
||||
{
|
||||
struct ofb_softc *sc = v;
|
||||
struct ofb_devconfig *dc = sc->sc_dc;
|
||||
struct rasops_info *ri = &dc->dc_ri;
|
||||
struct vcons_data *vd = v;
|
||||
struct ofb_softc *sc = vd->cookie;
|
||||
struct rasops_info *ri;
|
||||
u_int32_t *ap = sc->sc_addrs;
|
||||
struct proc *me;
|
||||
int i;
|
||||
|
||||
if (vd->active == NULL) {
|
||||
printf("%s: no active screen.\n", sc->sc_dev.dv_xname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ri = &vd->active->scr_ri;
|
||||
|
||||
/* framebuffer at offset 0 */
|
||||
if (offset >=0 && offset < (ri->ri_stride * ri->ri_height))
|
||||
return dc->dc_paddr + offset;
|
||||
return sc->sc_fbaddr + offset;
|
||||
|
||||
/*
|
||||
* restrict all other mappings to processes with superuser privileges
|
||||
|
@ -396,6 +421,7 @@ ofb_mmap(void *v, off_t offset, int prot)
|
|||
me = __curproc();
|
||||
if (me != NULL) {
|
||||
if (suser(me->p_ucred, NULL) != 0) {
|
||||
printf("%s: mmap() rejected.\n", sc->sc_dev.dv_xname);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -403,7 +429,7 @@ ofb_mmap(void *v, off_t offset, int prot)
|
|||
/* let them mmap() 0xa0000 - 0xbffff if it's not covered above */
|
||||
#ifdef OFB_FAKE_VGA_FB
|
||||
if (offset >=0xa0000 && offset < 0xbffff)
|
||||
return dc->dc_paddr + offset - 0xa0000;
|
||||
return sc->sc_fbaddr + offset - 0xa0000;
|
||||
#endif
|
||||
|
||||
/* allow to map our IO space */
|
||||
|
@ -425,50 +451,10 @@ ofb_mmap(void *v, off_t offset, int prot)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
ofb_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
|
||||
int *curxp, int *curyp, 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 = ri; /* one and only for now */
|
||||
*curxp = 0;
|
||||
*curyp = 0;
|
||||
(*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
|
||||
*attrp = defattr;
|
||||
sc->nscreens++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ofb_free_screen(void *v, void *cookie)
|
||||
{
|
||||
struct ofb_softc *sc = v;
|
||||
|
||||
if (sc->sc_dc == &ofb_console_dc)
|
||||
panic("ofb_free_screen: console");
|
||||
|
||||
sc->nscreens--;
|
||||
}
|
||||
|
||||
static int
|
||||
ofb_show_screen(void *v, void *cookie, int waitok,
|
||||
void (*cb)(void *, int, int), void *cbarg)
|
||||
{
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ofb_cnattach()
|
||||
{
|
||||
struct ofb_devconfig *dc = &ofb_console_dc;
|
||||
struct rasops_info *ri = &dc->dc_ri;
|
||||
struct rasops_info *ri = &ofb_console_screen.scr_ri;
|
||||
long defattr;
|
||||
int crow = 0;
|
||||
int chosen, stdout, node;
|
||||
|
@ -476,7 +462,8 @@ ofb_cnattach()
|
|||
chosen = OF_finddevice("/chosen");
|
||||
OF_getprop(chosen, "stdout", &stdout, sizeof(stdout));
|
||||
node = OF_instance_to_package(stdout);
|
||||
dc->dc_ih = stdout;
|
||||
console_node = node;
|
||||
console_instance = stdout;
|
||||
|
||||
/* get current cursor position */
|
||||
OF_interpret("line#", 1, &crow);
|
||||
|
@ -484,17 +471,34 @@ ofb_cnattach()
|
|||
/* move (rom monitor) cursor to the lowest line - 1 */
|
||||
OF_interpret("#lines 2 - to line#", 0);
|
||||
|
||||
ofb_common_init(node, dc);
|
||||
wsfont_init();
|
||||
if (copy_rom_font() == 0) {
|
||||
romfont_loaded = 1;
|
||||
}
|
||||
|
||||
/* set up rasops */
|
||||
ofb_init_rasops(console_node, ri);
|
||||
|
||||
/*
|
||||
* no need to clear the screen here when we're mimicing firmware
|
||||
* output anyway
|
||||
*/
|
||||
#if 0
|
||||
if (ri->ri_width >= 1024 && ri->ri_height >= 768) {
|
||||
int i, screenbytes = ri->ri_stride * ri->ri_height;
|
||||
|
||||
for (i = 0; i < screenbytes; i += sizeof(u_int32_t))
|
||||
*(u_int32_t *)(dc->dc_paddr + i) = 0xffffffff;
|
||||
*(u_int32_t *)(fbaddr + i) = 0xffffffff;
|
||||
crow = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
(*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
|
||||
ofb_stdscreen.nrows = ri->ri_rows;
|
||||
ofb_stdscreen.ncols = ri->ri_cols;
|
||||
ofb_stdscreen.textops = &ri->ri_ops;
|
||||
ofb_stdscreen.capabilities = ri->ri_caps;
|
||||
|
||||
ri->ri_ops.allocattr(ri, 0, 0, 0, &defattr);
|
||||
wsdisplay_cnattach(&ofb_stdscreen, ri, 0, crow, defattr);
|
||||
|
||||
return 0;
|
||||
|
@ -562,10 +566,9 @@ ofb_getcmap(struct ofb_softc *sc, struct wsdisplay_cmap *cm)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
ofb_putcmap(struct ofb_softc *sc, struct wsdisplay_cmap *cm)
|
||||
{
|
||||
struct ofb_devconfig *dc = sc->sc_dc;
|
||||
u_int index = cm->index;
|
||||
u_int count = cm->count;
|
||||
int i, error;
|
||||
|
@ -593,8 +596,34 @@ ofb_putcmap(struct ofb_softc *sc, struct wsdisplay_cmap *cm)
|
|||
g = &sc->sc_cmap_green[index];
|
||||
b = &sc->sc_cmap_blue[index];
|
||||
for (i = 0; i < count; i++) {
|
||||
OF_call_method_1("color!", dc->dc_ih, 4, *r, *g, *b, index);
|
||||
OF_call_method_1("color!", sc->sc_ih, 4, *r, *g, *b, index);
|
||||
r++, g++, b++, index++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ofb_putpalreg(struct ofb_softc *sc, int idx, uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
if ((idx<0) || (idx > 255))
|
||||
return;
|
||||
OF_call_method_1("color!", sc->sc_ih, 4, r, g, b, idx);
|
||||
sc->sc_cmap_red[idx] = r;
|
||||
sc->sc_cmap_green[idx] = g;
|
||||
sc->sc_cmap_blue[idx] = b;
|
||||
}
|
||||
|
||||
static void
|
||||
ofb_init_cmap(struct ofb_softc *sc)
|
||||
{
|
||||
int idx, i;
|
||||
/* mess with the palette only when we're running in 8 bit */
|
||||
if (ofb_console_screen.scr_ri.ri_depth == 8) {
|
||||
idx = 0;
|
||||
for (i = 0; i < 256; i++) {
|
||||
ofb_putpalreg(sc, i, rasops_cmap[idx],
|
||||
rasops_cmap[idx + 1], rasops_cmap[idx + 2]);
|
||||
idx += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ofbvar.h,v 1.8 2005/12/11 12:18:03 christos Exp $ */
|
||||
/* $NetBSD: ofbvar.h,v 1.9 2006/02/12 21:00:46 macallan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
||||
|
@ -27,12 +27,8 @@
|
|||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
struct ofb_devconfig {
|
||||
paddr_t dc_paddr; /* physcal address */
|
||||
int dc_node; /* phandle of this node */
|
||||
int dc_ih; /* ihandle of this node */
|
||||
struct rasops_info dc_ri;
|
||||
};
|
||||
#ifndef _OFBVAR_H_
|
||||
#define _OFBVAR_H_
|
||||
|
||||
struct ofb_softc {
|
||||
struct device sc_dev;
|
||||
|
@ -42,10 +38,15 @@ struct ofb_softc {
|
|||
bus_space_tag_t sc_memt;
|
||||
bus_space_tag_t sc_iot;
|
||||
|
||||
struct ofb_devconfig *sc_dc; /* device configuration */
|
||||
int nscreens;
|
||||
u_int32_t sc_addrs[30]; /* "assigned-addresses" storage */
|
||||
u_char sc_cmap_red[256];
|
||||
u_char sc_cmap_green[256];
|
||||
u_char sc_cmap_blue[256];
|
||||
|
||||
int sc_node, sc_ih, sc_mode;
|
||||
paddr_t sc_fbaddr;
|
||||
|
||||
struct vcons_data vd;
|
||||
};
|
||||
|
||||
#endif /* _OFBVAR_H_ */
|
||||
|
|
Loading…
Reference in New Issue