diff options
author | Jason Wright <jason@cvs.openbsd.org> | 2002-01-04 05:42:31 +0000 |
---|---|---|
committer | Jason Wright <jason@cvs.openbsd.org> | 2002-01-04 05:42:31 +0000 |
commit | 6df9b8722aaf6d6411d1357bc7699f54357d1668 (patch) | |
tree | 468b8d6797fbf5b8345caedebcbf20a37bf40b72 /sys/dev/sbus/cgthree.c | |
parent | 945b15d842d3620e042ad2ba86ca5b90b19a8592 (diff) |
mmap functionality for cgthee (mostly from NetBSD)
Diffstat (limited to 'sys/dev/sbus/cgthree.c')
-rw-r--r-- | sys/dev/sbus/cgthree.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/sys/dev/sbus/cgthree.c b/sys/dev/sbus/cgthree.c index bf5718d5921..d0f2087d046 100644 --- a/sys/dev/sbus/cgthree.c +++ b/sys/dev/sbus/cgthree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cgthree.c,v 1.2 2001/12/05 05:34:22 jason Exp $ */ +/* $OpenBSD: cgthree.c,v 1.3 2002/01/04 05:42:30 jason Exp $ */ /* * Copyright (c) 2001 Jason L. Wright (jason@thought.net) @@ -59,6 +59,8 @@ struct cgthree_softc { struct device sc_dev; struct sbusdev sc_sd; bus_space_tag_t sc_bustag; + bus_addr_t sc_paddr; + bus_type_t sc_btype; bus_space_handle_t sc_ctrl_regs; bus_space_handle_t sc_vid_regs; int sc_nscreens; @@ -149,6 +151,8 @@ cgthreeattach(parent, self, aux) long defattr; sc->sc_bustag = sa->sa_bustag; + sc->sc_btype = (bus_type_t)sa->sa_slot; + sc->sc_paddr = sbus_bus_addr(sa->sa_bustag, sa->sa_slot, sa->sa_offset); if (sa->sa_nreg != 1) { printf(": expected %d registers, got %d\n", 1, sa->sa_nreg); @@ -330,19 +334,38 @@ cgthree_show_screen(v, cookie, waitok, cb, cbarg) return (0); } +#define START (128 * 1024 + 128 * 1024) +#define NOOVERLAY (0x04000000) + paddr_t cgthree_mmap(v, offset, prot) void *v; off_t offset; int prot; { -#if 0 struct cgthree_softc *sc = v; -#endif + bus_space_handle_t bh; if (offset & PGOFSET) return (-1); - return (-1); + if (offset < 0) + return (-1); + if ((u_int)offset >= NOOVERLAY) + offset -= NOOVERLAY; + else if ((u_int)offset >= START) + offset -= START; + else + offset = 0; + + if (offset >= sc->sc_linebytes * sc->sc_height) + return (-1); + + if (bus_space_mmap(sc->sc_bustag, sc->sc_btype, + sc->sc_paddr + CGTHREE_VID_OFFSET + offset, + BUS_SPACE_MAP_LINEAR, &bh)) + return (-1); + + return ((paddr_t)bh); } static int |