The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/fb/creator.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    3  *
    4  * Copyright (c) 2003 Jake Burkholder.
    5  * Copyright (c) 2005 - 2006 Marius Strobl <marius@FreeBSD.org>
    6  * All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  */
   29 
   30 #include <sys/cdefs.h>
   31 __FBSDID("$FreeBSD$");
   32 
   33 #include <sys/param.h>
   34 #include <sys/systm.h>
   35 #include <sys/bus.h>
   36 #include <sys/conf.h>
   37 #include <sys/consio.h>
   38 #include <sys/fbio.h>
   39 #include <sys/kernel.h>
   40 #include <sys/module.h>
   41 #include <sys/resource.h>
   42 
   43 #include <dev/ofw/ofw_bus.h>
   44 #include <dev/ofw/openfirm.h>
   45 
   46 #include <machine/bus.h>
   47 #include <machine/bus_private.h>
   48 #include <machine/ofw_machdep.h>
   49 #include <machine/resource.h>
   50 #include <machine/sc_machdep.h>
   51 
   52 #include <sys/rman.h>
   53 
   54 #include <dev/fb/fbreg.h>
   55 #include <dev/fb/creatorreg.h>
   56 #include <dev/fb/gfb.h>
   57 #include <dev/syscons/syscons.h>
   58 
   59 #define CREATOR_DRIVER_NAME     "creator"
   60 
   61 struct creator_softc {
   62         video_adapter_t         sc_va;                  /* XXX must be first */
   63 
   64         phandle_t               sc_node;
   65 
   66         struct cdev             *sc_si;
   67 
   68         struct resource         *sc_reg[FFB_NREG];
   69         bus_space_tag_t         sc_bt[FFB_NREG];
   70         bus_space_handle_t      sc_bh[FFB_NREG];
   71         u_long                  sc_reg_size;
   72 
   73         u_int                   sc_height;
   74         u_int                   sc_width;
   75 
   76         u_int                   sc_xmargin;
   77         u_int                   sc_ymargin;
   78 
   79         const u_char            *sc_font;
   80 
   81         int                     sc_bg_cache;
   82         int                     sc_fg_cache;
   83         int                     sc_fifo_cache;
   84         int                     sc_fontinc_cache;
   85         int                     sc_fontw_cache;
   86         int                     sc_pmask_cache;
   87 
   88         u_int                   sc_flags;
   89 #define CREATOR_AFB             (1 << 0)
   90 #define CREATOR_CONSOLE         (1 << 1)
   91 #define CREATOR_CUREN           (1 << 2)
   92 #define CREATOR_CURINV          (1 << 3)
   93 #define CREATOR_PAC1            (1 << 4)
   94 };
   95 
   96 #define FFB_READ(sc, reg, off)                                          \
   97         bus_space_read_4((sc)->sc_bt[(reg)], (sc)->sc_bh[(reg)], (off))
   98 #define FFB_WRITE(sc, reg, off, val)                                    \
   99         bus_space_write_4((sc)->sc_bt[(reg)], (sc)->sc_bh[(reg)], (off), (val))
  100 
  101 #define C(r, g, b)      ((b << 16) | (g << 8) | (r))
  102 static const uint32_t creator_cmap[] = {
  103         C(0x00, 0x00, 0x00),            /* black */
  104         C(0x00, 0x00, 0xff),            /* blue */
  105         C(0x00, 0xff, 0x00),            /* green */
  106         C(0x00, 0xc0, 0xc0),            /* cyan */
  107         C(0xff, 0x00, 0x00),            /* red */
  108         C(0xc0, 0x00, 0xc0),            /* magenta */
  109         C(0xc0, 0xc0, 0x00),            /* brown */
  110         C(0xc0, 0xc0, 0xc0),            /* light grey */
  111         C(0x80, 0x80, 0x80),            /* dark grey */
  112         C(0x80, 0x80, 0xff),            /* light blue */
  113         C(0x80, 0xff, 0x80),            /* light green */
  114         C(0x80, 0xff, 0xff),            /* light cyan */
  115         C(0xff, 0x80, 0x80),            /* light red */
  116         C(0xff, 0x80, 0xff),            /* light magenta */
  117         C(0xff, 0xff, 0x80),            /* yellow */
  118         C(0xff, 0xff, 0xff),            /* white */
  119 };
  120 #undef C
  121 
  122 static const struct {
  123         vm_offset_t virt;
  124         vm_paddr_t phys;
  125         vm_size_t size;
  126 } creator_fb_map[] = {
  127         { FFB_VIRT_SFB8R,       FFB_PHYS_SFB8R,         FFB_SIZE_SFB8R },
  128         { FFB_VIRT_SFB8G,       FFB_PHYS_SFB8G,         FFB_SIZE_SFB8G },
  129         { FFB_VIRT_SFB8B,       FFB_PHYS_SFB8B,         FFB_SIZE_SFB8B },
  130         { FFB_VIRT_SFB8X,       FFB_PHYS_SFB8X,         FFB_SIZE_SFB8X },
  131         { FFB_VIRT_SFB32,       FFB_PHYS_SFB32,         FFB_SIZE_SFB32 },
  132         { FFB_VIRT_SFB64,       FFB_PHYS_SFB64,         FFB_SIZE_SFB64 },
  133         { FFB_VIRT_FBC,         FFB_PHYS_FBC,           FFB_SIZE_FBC },
  134         { FFB_VIRT_FBC_BM,      FFB_PHYS_FBC_BM,        FFB_SIZE_FBC_BM },
  135         { FFB_VIRT_DFB8R,       FFB_PHYS_DFB8R,         FFB_SIZE_DFB8R },
  136         { FFB_VIRT_DFB8G,       FFB_PHYS_DFB8G,         FFB_SIZE_DFB8G },
  137         { FFB_VIRT_DFB8B,       FFB_PHYS_DFB8B,         FFB_SIZE_DFB8B },
  138         { FFB_VIRT_DFB8X,       FFB_PHYS_DFB8X,         FFB_SIZE_DFB8X },
  139         { FFB_VIRT_DFB24,       FFB_PHYS_DFB24,         FFB_SIZE_DFB24 },
  140         { FFB_VIRT_DFB32,       FFB_PHYS_DFB32,         FFB_SIZE_DFB32 },
  141         { FFB_VIRT_DFB422A,     FFB_PHYS_DFB422A,       FFB_SIZE_DFB422A },
  142         { FFB_VIRT_DFB422AD,    FFB_PHYS_DFB422AD,      FFB_SIZE_DFB422AD },
  143         { FFB_VIRT_DFB24B,      FFB_PHYS_DFB24B,        FFB_SIZE_DFB24B },
  144         { FFB_VIRT_DFB422B,     FFB_PHYS_DFB422B,       FFB_SIZE_DFB422B },
  145         { FFB_VIRT_DFB422BD,    FFB_PHYS_DFB422BD,      FFB_SIZE_DFB422BD },
  146         { FFB_VIRT_SFB16Z,      FFB_PHYS_SFB16Z,        FFB_SIZE_SFB16Z },
  147         { FFB_VIRT_SFB8Z,       FFB_PHYS_SFB8Z,         FFB_SIZE_SFB8Z },
  148         { FFB_VIRT_SFB422,      FFB_PHYS_SFB422,        FFB_SIZE_SFB422 },
  149         { FFB_VIRT_SFB422D,     FFB_PHYS_SFB422D,       FFB_SIZE_SFB422D },
  150         { FFB_VIRT_FBC_KREG,    FFB_PHYS_FBC_KREG,      FFB_SIZE_FBC_KREG },
  151         { FFB_VIRT_DAC,         FFB_PHYS_DAC,           FFB_SIZE_DAC },
  152         { FFB_VIRT_PROM,        FFB_PHYS_PROM,          FFB_SIZE_PROM },
  153         { FFB_VIRT_EXP,         FFB_PHYS_EXP,           FFB_SIZE_EXP },
  154 };
  155 
  156 #define CREATOR_FB_MAP_SIZE     nitems(creator_fb_map)
  157 
  158 extern const struct gfb_font gallant12x22;
  159 
  160 static struct creator_softc creator_softc;
  161 static struct bus_space_tag creator_bst_store[FFB_FBC];
  162 
  163 static device_probe_t creator_bus_probe;
  164 static device_attach_t creator_bus_attach;
  165 
  166 static device_method_t creator_bus_methods[] = {
  167         DEVMETHOD(device_probe,         creator_bus_probe),
  168         DEVMETHOD(device_attach,        creator_bus_attach),
  169 
  170         { 0, 0 }
  171 };
  172 
  173 static devclass_t creator_devclass;
  174 
  175 DEFINE_CLASS_0(creator, creator_bus_driver, creator_bus_methods,
  176     sizeof(struct creator_softc));
  177 DRIVER_MODULE(creator, nexus, creator_bus_driver, creator_devclass, 0, 0);
  178 DRIVER_MODULE(creator, upa, creator_bus_driver, creator_devclass, 0, 0);
  179 
  180 static d_open_t creator_fb_open;
  181 static d_close_t creator_fb_close;
  182 static d_ioctl_t creator_fb_ioctl;
  183 static d_mmap_t creator_fb_mmap;
  184 
  185 static struct cdevsw creator_fb_devsw = {
  186         .d_version =    D_VERSION,
  187         .d_flags =      D_NEEDGIANT,
  188         .d_open =       creator_fb_open,
  189         .d_close =      creator_fb_close,
  190         .d_ioctl =      creator_fb_ioctl,
  191         .d_mmap =       creator_fb_mmap,
  192         .d_name =       "fb",
  193 };
  194 
  195 static void creator_cursor_enable(struct creator_softc *sc, int onoff);
  196 static void creator_cursor_install(struct creator_softc *sc);
  197 static void creator_shutdown(void *xsc);
  198 
  199 static int creator_configure(int flags);
  200 
  201 static vi_probe_t creator_probe;
  202 static vi_init_t creator_init;
  203 static vi_get_info_t creator_get_info;
  204 static vi_query_mode_t creator_query_mode;
  205 static vi_set_mode_t creator_set_mode;
  206 static vi_save_font_t creator_save_font;
  207 static vi_load_font_t creator_load_font;
  208 static vi_show_font_t creator_show_font;
  209 static vi_save_palette_t creator_save_palette;
  210 static vi_load_palette_t creator_load_palette;
  211 static vi_set_border_t creator_set_border;
  212 static vi_save_state_t creator_save_state;
  213 static vi_load_state_t creator_load_state;
  214 static vi_set_win_org_t creator_set_win_org;
  215 static vi_read_hw_cursor_t creator_read_hw_cursor;
  216 static vi_set_hw_cursor_t creator_set_hw_cursor;
  217 static vi_set_hw_cursor_shape_t creator_set_hw_cursor_shape;
  218 static vi_blank_display_t creator_blank_display;
  219 static vi_mmap_t creator_mmap;
  220 static vi_ioctl_t creator_ioctl;
  221 static vi_clear_t creator_clear;
  222 static vi_fill_rect_t creator_fill_rect;
  223 static vi_bitblt_t creator_bitblt;
  224 static vi_diag_t creator_diag;
  225 static vi_save_cursor_palette_t creator_save_cursor_palette;
  226 static vi_load_cursor_palette_t creator_load_cursor_palette;
  227 static vi_copy_t creator_copy;
  228 static vi_putp_t creator_putp;
  229 static vi_putc_t creator_putc;
  230 static vi_puts_t creator_puts;
  231 static vi_putm_t creator_putm;
  232 
  233 static video_switch_t creatorvidsw = {
  234         .probe                  = creator_probe,
  235         .init                   = creator_init,
  236         .get_info               = creator_get_info,
  237         .query_mode             = creator_query_mode,
  238         .set_mode               = creator_set_mode,
  239         .save_font              = creator_save_font,
  240         .load_font              = creator_load_font,
  241         .show_font              = creator_show_font,
  242         .save_palette           = creator_save_palette,
  243         .load_palette           = creator_load_palette,
  244         .set_border             = creator_set_border,
  245         .save_state             = creator_save_state,
  246         .load_state             = creator_load_state,
  247         .set_win_org            = creator_set_win_org,
  248         .read_hw_cursor         = creator_read_hw_cursor,
  249         .set_hw_cursor          = creator_set_hw_cursor,
  250         .set_hw_cursor_shape    = creator_set_hw_cursor_shape,
  251         .blank_display          = creator_blank_display,
  252         .mmap                   = creator_mmap,
  253         .ioctl                  = creator_ioctl,
  254         .clear                  = creator_clear,
  255         .fill_rect              = creator_fill_rect,
  256         .bitblt                 = creator_bitblt,
  257         .diag                   = creator_diag,
  258         .save_cursor_palette    = creator_save_cursor_palette,
  259         .load_cursor_palette    = creator_load_cursor_palette,
  260         .copy                   = creator_copy,
  261         .putp                   = creator_putp,
  262         .putc                   = creator_putc,
  263         .puts                   = creator_puts,
  264         .putm                   = creator_putm
  265 };
  266 
  267 VIDEO_DRIVER(creator, creatorvidsw, creator_configure);
  268 
  269 extern sc_rndr_sw_t txtrndrsw;
  270 RENDERER(creator, 0, txtrndrsw, gfb_set);
  271 
  272 RENDERER_MODULE(creator, gfb_set);
  273 
  274 static const u_char creator_mouse_pointer[64][8] __aligned(8) = {
  275         { 0x00, 0x00, },        /* ............ */
  276         { 0x80, 0x00, },        /* *........... */
  277         { 0xc0, 0x00, },        /* **.......... */
  278         { 0xe0, 0x00, },        /* ***......... */
  279         { 0xf0, 0x00, },        /* ****........ */
  280         { 0xf8, 0x00, },        /* *****....... */
  281         { 0xfc, 0x00, },        /* ******...... */
  282         { 0xfe, 0x00, },        /* *******..... */
  283         { 0xff, 0x00, },        /* ********.... */
  284         { 0xff, 0x80, },        /* *********... */
  285         { 0xfc, 0xc0, },        /* ******..**.. */
  286         { 0xdc, 0x00, },        /* **.***...... */
  287         { 0x8e, 0x00, },        /* *...***..... */
  288         { 0x0e, 0x00, },        /* ....***..... */
  289         { 0x07, 0x00, },        /* .....***.... */
  290         { 0x04, 0x00, },        /* .....*...... */
  291         { 0x00, 0x00, },        /* ............ */
  292         { 0x00, 0x00, },        /* ............ */
  293         { 0x00, 0x00, },        /* ............ */
  294         { 0x00, 0x00, },        /* ............ */
  295         { 0x00, 0x00, },        /* ............ */
  296         { 0x00, 0x00, },        /* ............ */
  297 };
  298 
  299 static inline void creator_ras_fifo_wait(struct creator_softc *sc, int n);
  300 static inline void creator_ras_setfontinc(struct creator_softc *sc, int fontinc);
  301 static inline void creator_ras_setfontw(struct creator_softc *sc, int fontw);
  302 static inline void creator_ras_setbg(struct creator_softc *sc, int bg);
  303 static inline void creator_ras_setfg(struct creator_softc *sc, int fg);
  304 static inline void creator_ras_setpmask(struct creator_softc *sc, int pmask);
  305 static inline void creator_ras_wait(struct creator_softc *sc);
  306 
  307 static inline void
  308 creator_ras_wait(struct creator_softc *sc)
  309 {
  310         int ucsr;
  311         int r;
  312 
  313         for (;;) {
  314                 ucsr = FFB_READ(sc, FFB_FBC, FFB_FBC_UCSR);
  315                 if ((ucsr & (FBC_UCSR_FB_BUSY | FBC_UCSR_RP_BUSY)) == 0)
  316                         break;
  317                 r = ucsr & (FBC_UCSR_READ_ERR | FBC_UCSR_FIFO_OVFL);
  318                 if (r != 0)
  319                         FFB_WRITE(sc, FFB_FBC, FFB_FBC_UCSR, r);
  320         }
  321 }
  322 
  323 static inline void
  324 creator_ras_fifo_wait(struct creator_softc *sc, int n)
  325 {
  326         int cache;
  327 
  328         cache = sc->sc_fifo_cache;
  329         while (cache < n)
  330                 cache = (FFB_READ(sc, FFB_FBC, FFB_FBC_UCSR) &
  331                     FBC_UCSR_FIFO_MASK) - 8;
  332         sc->sc_fifo_cache = cache - n;
  333 }
  334 
  335 static inline void
  336 creator_ras_setfontinc(struct creator_softc *sc, int fontinc)
  337 {
  338 
  339         if (fontinc == sc->sc_fontinc_cache)
  340                 return;
  341         sc->sc_fontinc_cache = fontinc;
  342         creator_ras_fifo_wait(sc, 1);
  343         FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONTINC, fontinc);
  344         creator_ras_wait(sc);
  345 }
  346 
  347 static inline void
  348 creator_ras_setfontw(struct creator_softc *sc, int fontw)
  349 {
  350 
  351         if (fontw == sc->sc_fontw_cache)
  352                 return;
  353         sc->sc_fontw_cache = fontw;
  354         creator_ras_fifo_wait(sc, 1);
  355         FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONTW, fontw);
  356         creator_ras_wait(sc);
  357 }
  358 
  359 static inline void
  360 creator_ras_setbg(struct creator_softc *sc, int bg)
  361 {
  362 
  363         if (bg == sc->sc_bg_cache)
  364                 return;
  365         sc->sc_bg_cache = bg;
  366         creator_ras_fifo_wait(sc, 1);
  367         FFB_WRITE(sc, FFB_FBC, FFB_FBC_BG, bg);
  368         creator_ras_wait(sc);
  369 }
  370 
  371 static inline void
  372 creator_ras_setfg(struct creator_softc *sc, int fg)
  373 {
  374 
  375         if (fg == sc->sc_fg_cache)
  376                 return;
  377         sc->sc_fg_cache = fg;
  378         creator_ras_fifo_wait(sc, 1);
  379         FFB_WRITE(sc, FFB_FBC, FFB_FBC_FG, fg);
  380         creator_ras_wait(sc);
  381 }
  382 
  383 static inline void
  384 creator_ras_setpmask(struct creator_softc *sc, int pmask)
  385 {
  386 
  387         if (pmask == sc->sc_pmask_cache)
  388                 return;
  389         sc->sc_pmask_cache = pmask;
  390         creator_ras_fifo_wait(sc, 1);
  391         FFB_WRITE(sc, FFB_FBC, FFB_FBC_PMASK, pmask);
  392         creator_ras_wait(sc);
  393 }
  394 
  395 /*
  396  * video driver interface
  397  */
  398 static int
  399 creator_configure(int flags)
  400 {
  401         struct creator_softc *sc;
  402         phandle_t chosen;
  403         phandle_t output;
  404         ihandle_t stdout;
  405         bus_addr_t addr;
  406         char buf[sizeof("SUNW,ffb")];
  407         int i;
  408         int space;
  409 
  410         /*
  411          * For the high-level console probing return the number of
  412          * registered adapters.
  413          */
  414         if (!(flags & VIO_PROBE_ONLY)) {
  415                 for (i = 0; vid_find_adapter(CREATOR_DRIVER_NAME, i) >= 0; i++)
  416                         ;
  417                 return (i);
  418         }
  419 
  420         /* Low-level console probing and initialization. */
  421 
  422         sc = &creator_softc;
  423         if (sc->sc_va.va_flags & V_ADP_REGISTERED)
  424                 goto found;
  425 
  426         if ((chosen = OF_finddevice("/chosen")) == -1)
  427                 return (0);
  428         if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1)
  429                 return (0);
  430         if ((output = OF_instance_to_package(stdout)) == -1)
  431                 return (0);
  432         if (OF_getprop(output, "name", buf, sizeof(buf)) == -1)
  433                 return (0);
  434         if (strcmp(buf, "SUNW,ffb") == 0 || strcmp(buf, "SUNW,afb") == 0) {
  435                 sc->sc_flags = CREATOR_CONSOLE;
  436                 if (strcmp(buf, "SUNW,afb") == 0)
  437                         sc->sc_flags |= CREATOR_AFB;
  438                 sc->sc_node = output;
  439         } else
  440                 return (0);
  441 
  442         for (i = FFB_DAC; i <= FFB_FBC; i++) {
  443                 if (OF_decode_addr(output, i, &space, &addr) != 0)
  444                         return (0);
  445                 sc->sc_bt[i] = &creator_bst_store[i - FFB_DAC];
  446                 sc->sc_bh[i] = sparc64_fake_bustag(space, addr, sc->sc_bt[i]);
  447         }
  448 
  449         if (creator_init(0, &sc->sc_va, 0) < 0)
  450                 return (0);
  451 
  452  found:
  453         /* Return number of found adapters. */
  454         return (1);
  455 }
  456 
  457 static int
  458 creator_probe(int unit, video_adapter_t **adpp, void *arg, int flags)
  459 {
  460 
  461         return (0);
  462 }
  463 
  464 static int
  465 creator_init(int unit, video_adapter_t *adp, int flags)
  466 {
  467         struct creator_softc *sc;
  468         phandle_t options;
  469         video_info_t *vi;
  470         char buf[sizeof("screen-#columns")];
  471 
  472         sc = (struct creator_softc *)adp;
  473         vi = &adp->va_info;
  474 
  475         vid_init_struct(adp, CREATOR_DRIVER_NAME, -1, unit);
  476 
  477         if (OF_getprop(sc->sc_node, "height", &sc->sc_height,
  478             sizeof(sc->sc_height)) == -1)
  479                 return (ENXIO);
  480         if (OF_getprop(sc->sc_node, "width", &sc->sc_width,
  481             sizeof(sc->sc_width)) == -1)
  482                 return (ENXIO);
  483         if ((options = OF_finddevice("/options")) == -1)
  484                 return (ENXIO);
  485         if (OF_getprop(options, "screen-#rows", buf, sizeof(buf)) == -1)
  486                 return (ENXIO);
  487         vi->vi_height = strtol(buf, NULL, 10);
  488         if (OF_getprop(options, "screen-#columns", buf, sizeof(buf)) == -1)
  489                 return (ENXIO);
  490         vi->vi_width = strtol(buf, NULL, 10);
  491         vi->vi_cwidth = gallant12x22.width;
  492         vi->vi_cheight = gallant12x22.height;
  493         vi->vi_flags = V_INFO_COLOR;
  494         vi->vi_mem_model = V_INFO_MM_OTHER;
  495 
  496         sc->sc_font = gallant12x22.data;
  497         sc->sc_xmargin = (sc->sc_width - (vi->vi_width * vi->vi_cwidth)) / 2;
  498         sc->sc_ymargin = (sc->sc_height - (vi->vi_height * vi->vi_cheight)) / 2;
  499 
  500         creator_set_mode(adp, 0);
  501 
  502         if (!(sc->sc_flags & CREATOR_AFB)) {
  503                 FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_DID);
  504                 if (((FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE) &
  505                     FFB_DAC_CFG_DID_PNUM) >> 12) != 0x236e) {
  506                         sc->sc_flags |= CREATOR_PAC1;
  507                         FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_UCTRL);
  508                         if (((FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE) &
  509                             FFB_DAC_UCTRL_MANREV) >> 8) <= 2)
  510                                 sc->sc_flags |= CREATOR_CURINV;
  511                 }
  512         }
  513 
  514         creator_blank_display(adp, V_DISPLAY_ON);
  515         creator_clear(adp);
  516 
  517         /*
  518          * Setting V_ADP_MODECHANGE serves as hack so creator_set_mode()
  519          * (which will invalidate our caches and restore our settings) is
  520          * called when the X server shuts down.  Otherwise screen corruption
  521          * happens most of the time.
  522          */
  523         adp->va_flags |= V_ADP_COLOR | V_ADP_MODECHANGE | V_ADP_BORDER |
  524             V_ADP_INITIALIZED;
  525         if (vid_register(adp) < 0)
  526                 return (ENXIO);
  527         adp->va_flags |= V_ADP_REGISTERED;
  528 
  529         return (0);
  530 }
  531 
  532 static int
  533 creator_get_info(video_adapter_t *adp, int mode, video_info_t *info)
  534 {
  535 
  536         bcopy(&adp->va_info, info, sizeof(*info));
  537         return (0);
  538 }
  539 
  540 static int
  541 creator_query_mode(video_adapter_t *adp, video_info_t *info)
  542 {
  543 
  544         return (ENODEV);
  545 }
  546 
  547 static int
  548 creator_set_mode(video_adapter_t *adp, int mode)
  549 {
  550         struct creator_softc *sc;
  551 
  552         sc = (struct creator_softc *)adp;
  553         sc->sc_bg_cache = -1;
  554         sc->sc_fg_cache = -1;
  555         sc->sc_fontinc_cache = -1;
  556         sc->sc_fontw_cache = -1;
  557         sc->sc_pmask_cache = -1;
  558 
  559         creator_ras_wait(sc);
  560         sc->sc_fifo_cache = 0;
  561         creator_ras_fifo_wait(sc, 2);
  562         FFB_WRITE(sc, FFB_FBC, FFB_FBC_PPC, FBC_PPC_VCE_DIS |
  563             FBC_PPC_TBE_OPAQUE | FBC_PPC_APE_DIS | FBC_PPC_CS_CONST);
  564         FFB_WRITE(sc, FFB_FBC, FFB_FBC_FBC, FFB_FBC_WB_A | FFB_FBC_RB_A |
  565             FFB_FBC_SB_BOTH | FFB_FBC_XE_OFF | FFB_FBC_RGBE_MASK);
  566         return (0);
  567 }
  568 
  569 static int
  570 creator_save_font(video_adapter_t *adp, int page, int size, int width,
  571     u_char *data, int c, int count)
  572 {
  573 
  574         return (ENODEV);
  575 }
  576 
  577 static int
  578 creator_load_font(video_adapter_t *adp, int page, int size, int width,
  579     u_char *data, int c, int count)
  580 {
  581 
  582         return (ENODEV);
  583 }
  584 
  585 static int
  586 creator_show_font(video_adapter_t *adp, int page)
  587 {
  588 
  589         return (ENODEV);
  590 }
  591 
  592 static int
  593 creator_save_palette(video_adapter_t *adp, u_char *palette)
  594 {
  595 
  596         return (ENODEV);
  597 }
  598 
  599 static int
  600 creator_load_palette(video_adapter_t *adp, u_char *palette)
  601 {
  602 
  603         return (ENODEV);
  604 }
  605 
  606 static int
  607 creator_set_border(video_adapter_t *adp, int border)
  608 {
  609         struct creator_softc *sc;
  610 
  611         sc = (struct creator_softc *)adp;
  612         creator_fill_rect(adp, border, 0, 0, sc->sc_width, sc->sc_ymargin);
  613         creator_fill_rect(adp, border, 0, sc->sc_height - sc->sc_ymargin,
  614             sc->sc_width, sc->sc_ymargin);
  615         creator_fill_rect(adp, border, 0, 0, sc->sc_xmargin, sc->sc_height);
  616         creator_fill_rect(adp, border, sc->sc_width - sc->sc_xmargin, 0,
  617             sc->sc_xmargin, sc->sc_height);
  618         return (0);
  619 }
  620 
  621 static int
  622 creator_save_state(video_adapter_t *adp, void *p, size_t size)
  623 {
  624 
  625         return (ENODEV);
  626 }
  627 
  628 static int
  629 creator_load_state(video_adapter_t *adp, void *p)
  630 {
  631 
  632         return (ENODEV);
  633 }
  634 
  635 static int
  636 creator_set_win_org(video_adapter_t *adp, off_t offset)
  637 {
  638 
  639         return (ENODEV);
  640 }
  641 
  642 static int
  643 creator_read_hw_cursor(video_adapter_t *adp, int *col, int *row)
  644 {
  645 
  646         *col = 0;
  647         *row = 0;
  648         return (0);
  649 }
  650 
  651 static int
  652 creator_set_hw_cursor(video_adapter_t *adp, int col, int row)
  653 {
  654 
  655         return (ENODEV);
  656 }
  657 
  658 static int
  659 creator_set_hw_cursor_shape(video_adapter_t *adp, int base, int height,
  660     int celsize, int blink)
  661 {
  662 
  663         return (ENODEV);
  664 }
  665 
  666 static int
  667 creator_blank_display(video_adapter_t *adp, int mode)
  668 {
  669         struct creator_softc *sc;
  670         uint32_t v;
  671         int i;
  672 
  673         sc = (struct creator_softc *)adp;
  674         FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_TGEN);
  675         v = FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE);
  676         switch (mode) {
  677         case V_DISPLAY_ON:
  678                 v |= FFB_DAC_CFG_TGEN_VIDE;
  679                 break;
  680         case V_DISPLAY_BLANK:
  681         case V_DISPLAY_STAND_BY:
  682         case V_DISPLAY_SUSPEND:
  683                 v &= ~FFB_DAC_CFG_TGEN_VIDE;
  684                 break;
  685         }
  686         FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_TGEN);
  687         FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE, v);
  688         for (i = 0; i < 10; i++) {
  689                 FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_TGEN);
  690                 (void)FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE);
  691         }
  692         return (0);
  693 }
  694 
  695 static int
  696 creator_mmap(video_adapter_t *adp, vm_ooffset_t offset, vm_paddr_t *paddr,
  697     int prot, vm_memattr_t *memattr)
  698 {
  699 
  700         return (EINVAL);
  701 }
  702 
  703 static int
  704 creator_ioctl(video_adapter_t *adp, u_long cmd, caddr_t data)
  705 {
  706         struct creator_softc *sc;
  707         struct fbcursor *fbc;
  708         struct fbtype *fb;
  709 
  710         sc = (struct creator_softc *)adp;
  711         switch (cmd) {
  712         case FBIOGTYPE:
  713                 fb = (struct fbtype *)data;
  714                 fb->fb_type = FBTYPE_CREATOR;
  715                 fb->fb_height = sc->sc_height;
  716                 fb->fb_width = sc->sc_width;
  717                 fb->fb_depth = fb->fb_cmsize = fb->fb_size = 0;
  718                 break;
  719         case FBIOSCURSOR:
  720                 fbc = (struct fbcursor *)data;
  721                 if (fbc->set & FB_CUR_SETCUR && fbc->enable == 0) {
  722                         creator_cursor_enable(sc, 0);
  723                         sc->sc_flags &= ~CREATOR_CUREN;
  724                 } else
  725                         return (ENODEV);
  726                 break;
  727                 break;
  728         default:
  729                 return (fb_commonioctl(adp, cmd, data));
  730         }
  731         return (0);
  732 }
  733 
  734 static int
  735 creator_clear(video_adapter_t *adp)
  736 {
  737         struct creator_softc *sc;
  738 
  739         sc = (struct creator_softc *)adp;
  740         creator_fill_rect(adp, (SC_NORM_ATTR >> 4) & 0xf, 0, 0, sc->sc_width,
  741             sc->sc_height);
  742         return (0);
  743 }
  744 
  745 static int
  746 creator_fill_rect(video_adapter_t *adp, int val, int x, int y, int cx, int cy)
  747 {
  748         struct creator_softc *sc;
  749 
  750         sc = (struct creator_softc *)adp;
  751         creator_ras_setpmask(sc, 0xffffffff);
  752         creator_ras_fifo_wait(sc, 2);
  753         FFB_WRITE(sc, FFB_FBC, FFB_FBC_ROP, FBC_ROP_NEW);
  754         FFB_WRITE(sc, FFB_FBC, FFB_FBC_DRAWOP, FBC_DRAWOP_RECTANGLE);
  755         creator_ras_setfg(sc, creator_cmap[val & 0xf]);
  756         /*
  757          * Note that at least the Elite3D cards are sensitive to the order
  758          * of operations here.
  759          */
  760         creator_ras_fifo_wait(sc, 4);
  761         FFB_WRITE(sc, FFB_FBC, FFB_FBC_BY, y);
  762         FFB_WRITE(sc, FFB_FBC, FFB_FBC_BX, x);
  763         FFB_WRITE(sc, FFB_FBC, FFB_FBC_BH, cy);
  764         FFB_WRITE(sc, FFB_FBC, FFB_FBC_BW, cx);
  765         creator_ras_wait(sc);
  766         return (0);
  767 }
  768 
  769 static int
  770 creator_bitblt(video_adapter_t *adp, ...)
  771 {
  772 
  773         return (ENODEV);
  774 }
  775 
  776 static int
  777 creator_diag(video_adapter_t *adp, int level)
  778 {
  779         video_info_t info;
  780 
  781         fb_dump_adp_info(adp->va_name, adp, level);
  782         creator_get_info(adp, 0, &info);
  783         fb_dump_mode_info(adp->va_name, adp, &info, level);
  784         return (0);
  785 }
  786 
  787 static int
  788 creator_save_cursor_palette(video_adapter_t *adp, u_char *palette)
  789 {
  790 
  791         return (ENODEV);
  792 }
  793 
  794 static int
  795 creator_load_cursor_palette(video_adapter_t *adp, u_char *palette)
  796 {
  797 
  798         return (ENODEV);
  799 }
  800 
  801 static int
  802 creator_copy(video_adapter_t *adp, vm_offset_t src, vm_offset_t dst, int n)
  803 {
  804 
  805         return (ENODEV);
  806 }
  807 
  808 static int
  809 creator_putp(video_adapter_t *adp, vm_offset_t off, u_int32_t p, u_int32_t a,
  810     int size, int bpp, int bit_ltor, int byte_ltor)
  811 {
  812 
  813         return (ENODEV);
  814 }
  815 
  816 static int
  817 creator_putc(video_adapter_t *adp, vm_offset_t off, u_int8_t c, u_int8_t a)
  818 {
  819         struct creator_softc *sc;
  820         const uint16_t *p;
  821         int row;
  822         int col;
  823         int i;
  824 
  825         sc = (struct creator_softc *)adp;
  826         row = (off / adp->va_info.vi_width) * adp->va_info.vi_cheight;
  827         col = (off % adp->va_info.vi_width) * adp->va_info.vi_cwidth;
  828         p = (const uint16_t *)sc->sc_font + (c * adp->va_info.vi_cheight);
  829         creator_ras_setfg(sc, creator_cmap[a & 0xf]);
  830         creator_ras_setbg(sc, creator_cmap[(a >> 4) & 0xf]);
  831         creator_ras_fifo_wait(sc, 1 + adp->va_info.vi_cheight);
  832         FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONTXY,
  833             ((row + sc->sc_ymargin) << 16) | (col + sc->sc_xmargin));
  834         creator_ras_setfontw(sc, adp->va_info.vi_cwidth);
  835         creator_ras_setfontinc(sc, 0x10000);
  836         for (i = 0; i < adp->va_info.vi_cheight; i++) {
  837                 FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONT, *p++ << 16);
  838         }
  839         return (0);
  840 }
  841 
  842 static int
  843 creator_puts(video_adapter_t *adp, vm_offset_t off, u_int16_t *s, int len)
  844 {
  845         int i;
  846 
  847         for (i = 0; i < len; i++) {
  848                 vidd_putc(adp, off + i, s[i] & 0xff, (s[i] & 0xff00) >> 8);
  849         }
  850 
  851         return (0);
  852 }
  853 
  854 static int
  855 creator_putm(video_adapter_t *adp, int x, int y, u_int8_t *pixel_image,
  856     u_int32_t pixel_mask, int size, int width)
  857 {
  858         struct creator_softc *sc;
  859 
  860         sc = (struct creator_softc *)adp;
  861         if (!(sc->sc_flags & CREATOR_CUREN)) {
  862                 creator_cursor_install(sc);
  863                 creator_cursor_enable(sc, 1);
  864                 sc->sc_flags |= CREATOR_CUREN;
  865         }
  866         FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2, FFB_DAC_CUR_POS);
  867         FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2,
  868             ((y + sc->sc_ymargin) << 16) | (x + sc->sc_xmargin));
  869         return (0);
  870 }
  871 
  872 /*
  873  * bus interface
  874  */
  875 static int
  876 creator_bus_probe(device_t dev)
  877 {
  878         const char *name;
  879         phandle_t node;
  880         int type;
  881 
  882         name = ofw_bus_get_name(dev);
  883         node = ofw_bus_get_node(dev);
  884         if (strcmp(name, "SUNW,ffb") == 0) {
  885                 if (OF_getprop(node, "board_type", &type, sizeof(type)) == -1)
  886                         return (ENXIO);
  887                 switch (type & 7) {
  888                 case 0x0:
  889                         device_set_desc(dev, "Creator");
  890                         break;
  891                 case 0x3:
  892                         device_set_desc(dev, "Creator3D");
  893                         break;
  894                 default:
  895                         return (ENXIO);
  896                 }
  897         } else if (strcmp(name, "SUNW,afb") == 0)
  898                 device_set_desc(dev, "Elite3D");
  899         else
  900                 return (ENXIO);
  901         return (BUS_PROBE_DEFAULT);
  902 }
  903 
  904 static int
  905 creator_bus_attach(device_t dev)
  906 {
  907         struct creator_softc *sc;
  908         video_adapter_t *adp;
  909         video_switch_t *sw;
  910         phandle_t node;
  911         int error;
  912         int rid;
  913         int unit;
  914         int i;
  915 
  916         node = ofw_bus_get_node(dev);
  917         if ((sc = (struct creator_softc *)vid_get_adapter(vid_find_adapter(
  918             CREATOR_DRIVER_NAME, 0))) != NULL && sc->sc_node == node) {
  919                 device_printf(dev, "console\n");
  920                 device_set_softc(dev, sc);
  921         } else {
  922                 sc = device_get_softc(dev);
  923                 sc->sc_node = node;
  924         }
  925         adp = &sc->sc_va;
  926 
  927         /*
  928          * Allocate resources regardless of whether we are the console
  929          * and already obtained the bus tags and handles for the FFB_DAC
  930          * and FFB_FBC register banks in creator_configure() or not so
  931          * the resources are marked as taken in the respective RMAN.
  932          * The supported cards use either 15 (Creator, Elite3D?) or 24
  933          * (Creator3D?) register banks.  We make sure that we can also
  934          * allocate the resources for at least the FFB_DAC and FFB_FBC
  935          * banks here.  We try but don't actually care whether we can
  936          * allocate more than these two resources and just limit the
  937          * range accessible via creator_fb_mmap() accordingly.
  938          */
  939         for (i = 0; i < FFB_NREG; i++) {
  940                 rid = i;
  941                 sc->sc_reg[i] = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
  942                     &rid, RF_ACTIVE);
  943                 if (sc->sc_reg[i] == NULL) {
  944                         if (i <= FFB_FBC) {
  945                                 device_printf(dev,
  946                                     "cannot allocate resources\n");
  947                                 error = ENXIO;
  948                                 goto fail;
  949                         }
  950                         break;
  951                 }
  952                 sc->sc_bt[i] = rman_get_bustag(sc->sc_reg[i]);
  953                 sc->sc_bh[i] = rman_get_bushandle(sc->sc_reg[i]);
  954         }
  955         /*
  956          * The XFree86/X.Org sunffb(4) expects to be able to access the
  957          * memory spanned by the first and the last resource as one chunk
  958          * via creator_fb_mmap(), using offsets from the first resource,
  959          * even though the backing resources are actually non-continuous.
  960          * So make sure that the memory we provide is at least backed by
  961          * increasing resources.
  962          */
  963         for (i = 1; i < FFB_NREG && sc->sc_reg[i] != NULL &&
  964             rman_get_start(sc->sc_reg[i]) > rman_get_start(sc->sc_reg[i - 1]);
  965             i++)
  966                 ;
  967         sc->sc_reg_size = rman_get_end(sc->sc_reg[i - 1]) -
  968             rman_get_start(sc->sc_reg[0]) + 1;
  969 
  970         if (!(sc->sc_flags & CREATOR_CONSOLE)) {
  971                 if ((sw = vid_get_switch(CREATOR_DRIVER_NAME)) == NULL) {
  972                         device_printf(dev, "cannot get video switch\n");
  973                         error = ENODEV;
  974                         goto fail;
  975                 }
  976                 /*
  977                  * During device configuration we don't necessarily probe
  978                  * the adapter which is the console first so we can't use
  979                  * the device unit number for the video adapter unit.  The
  980                  * worst case would be that we use the video adapter unit
  981                  * 0 twice.  As it doesn't really matter which unit number
  982                  * the corresponding video adapter has just use the next
  983                  * unused one.
  984                  */
  985                 for (i = 0; i < devclass_get_maxunit(creator_devclass); i++)
  986                         if (vid_find_adapter(CREATOR_DRIVER_NAME, i) < 0)
  987                                 break;
  988                 if (strcmp(ofw_bus_get_name(dev), "SUNW,afb") == 0)
  989                         sc->sc_flags |= CREATOR_AFB;
  990                 if ((error = sw->init(i, adp, 0)) != 0) {
  991                         device_printf(dev, "cannot initialize adapter\n");
  992                         goto fail;
  993                 }
  994         }
  995 
  996         if (bootverbose) {
  997                 if (sc->sc_flags & CREATOR_PAC1)
  998                         device_printf(dev,
  999                             "BT9068/PAC1 RAMDAC (%s cursor control)\n",
 1000                             sc->sc_flags & CREATOR_CURINV ? "inverted" :
 1001                             "normal");
 1002                 else
 1003                         device_printf(dev, "BT498/PAC2 RAMDAC\n");
 1004         }
 1005         device_printf(dev, "resolution %dx%d\n", sc->sc_width, sc->sc_height);
 1006 
 1007         unit = device_get_unit(dev);
 1008         sc->sc_si = make_dev(&creator_fb_devsw, unit, UID_ROOT, GID_WHEEL,
 1009             0600, "fb%d", unit);
 1010         sc->sc_si->si_drv1 = sc;
 1011 
 1012         EVENTHANDLER_REGISTER(shutdown_final, creator_shutdown, sc,
 1013             SHUTDOWN_PRI_DEFAULT);
 1014 
 1015         return (0);
 1016 
 1017  fail:
 1018         for (i = 0; i < FFB_NREG && sc->sc_reg[i] != NULL; i++)
 1019                 bus_release_resource(dev, SYS_RES_MEMORY,
 1020                     rman_get_rid(sc->sc_reg[i]), sc->sc_reg[i]);
 1021         return (error);
 1022 }
 1023 
 1024 /*
 1025  * /dev/fb interface
 1026  */
 1027 static int
 1028 creator_fb_open(struct cdev *dev, int flags, int mode, struct thread *td)
 1029 {
 1030 
 1031         return (0);
 1032 }
 1033 
 1034 static int
 1035 creator_fb_close(struct cdev *dev, int flags, int mode, struct thread *td)
 1036 {
 1037 
 1038         return (0);
 1039 }
 1040 
 1041 static int
 1042 creator_fb_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags,
 1043     struct thread *td)
 1044 {
 1045         struct creator_softc *sc;
 1046 
 1047         sc = dev->si_drv1;
 1048         return (creator_ioctl(&sc->sc_va, cmd, data));
 1049 }
 1050 
 1051 static int
 1052 creator_fb_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
 1053     int prot, vm_memattr_t *memattr)
 1054 {
 1055         struct creator_softc *sc;
 1056         int i;
 1057 
 1058         /*
 1059          * NB: This is a special implementation based on the /dev/fb
 1060          * requirements of the XFree86/X.Org sunffb(4).
 1061          */
 1062         sc = dev->si_drv1;
 1063         for (i = 0; i < CREATOR_FB_MAP_SIZE; i++) {
 1064                 if (offset >= creator_fb_map[i].virt &&
 1065                     offset < creator_fb_map[i].virt + creator_fb_map[i].size) {
 1066                         offset += creator_fb_map[i].phys -
 1067                             creator_fb_map[i].virt;
 1068                         if (offset >= sc->sc_reg_size)
 1069                                 return (EINVAL);
 1070                         *paddr = sc->sc_bh[0] + offset;
 1071                         return (0);
 1072                 }
 1073         }
 1074         return (EINVAL);
 1075 }
 1076 
 1077 /*
 1078  * internal functions
 1079  */
 1080 static void
 1081 creator_cursor_enable(struct creator_softc *sc, int onoff)
 1082 {
 1083         int v;
 1084 
 1085         FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2, FFB_DAC_CUR_CTRL);
 1086         if (sc->sc_flags & CREATOR_CURINV)
 1087                 v = onoff ? FFB_DAC_CUR_CTRL_P0 | FFB_DAC_CUR_CTRL_P1 : 0;
 1088         else
 1089                 v = onoff ? 0 : FFB_DAC_CUR_CTRL_P0 | FFB_DAC_CUR_CTRL_P1;
 1090         FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, v);
 1091 }
 1092 
 1093 static void
 1094 creator_cursor_install(struct creator_softc *sc)
 1095 {
 1096         int i, j;
 1097 
 1098         creator_cursor_enable(sc, 0);
 1099         FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2, FFB_DAC_CUR_COLOR1);
 1100         FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, 0xffffff);
 1101         FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, 0x0);
 1102         for (i = 0; i < 2; i++) {
 1103                 FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2,
 1104                     i ? FFB_DAC_CUR_BITMAP_P0 : FFB_DAC_CUR_BITMAP_P1);
 1105                 for (j = 0; j < 64; j++) {
 1106                         FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2,
 1107                             *(const uint32_t *)(&creator_mouse_pointer[j][0]));
 1108                         FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2,
 1109                             *(const uint32_t *)(&creator_mouse_pointer[j][4]));
 1110                 }
 1111         }
 1112 }
 1113 
 1114 static void
 1115 creator_shutdown(void *xsc)
 1116 {
 1117         struct creator_softc *sc = xsc;
 1118 
 1119         creator_cursor_enable(sc, 0);
 1120         /*
 1121          * In case this is the console set the cursor of the stdout
 1122          * instance to the start of the last line so OFW output ends
 1123          * up beneath what FreeBSD left on the screen.
 1124          */
 1125         if (sc->sc_flags & CREATOR_CONSOLE) {
 1126                 OF_interpret("stdout @ is my-self 0 to column#", 0);
 1127                 OF_interpret("stdout @ is my-self #lines 1 - to line#", 0);
 1128         }
 1129 }

Cache object: af92ef247af4fb6ea461479bed933d3f


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.