Index: dev/fb/creator_vt.c =================================================================== --- dev/fb/creator_vt.c (revision 0) +++ dev/fb/creator_vt.c (working copy) @@ -0,0 +1,159 @@ +/*- + * Copyright (c) 2014 Nathan Whitehorn + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include "creatorreg.h" + +static vd_probe_t creatorfb_probe; +static vd_init_t creatorfb_init; + +static const struct vt_driver vt_creatorfb_driver = { + .vd_name = "creatorfb", + .vd_probe = creatorfb_probe, + .vd_init = creatorfb_init, + .vd_blank = vt_fb_blank, + .vd_bitbltchr = vt_fb_bitbltchr, + .vd_maskbitbltchr = vt_fb_maskbitbltchr, + .vd_fb_ioctl = vt_fb_ioctl, + .vd_fb_mmap = vt_fb_mmap, + .vd_priority = VD_PRIORITY_SPECIFIC +}; + +static struct fb_info creatorfb_conssoftc; +VT_DRIVER_DECLARE(vt_creatorfb, vt_creatorfb_driver); + +static int +creatorfb_probe(struct vt_device *vd) +{ + phandle_t chosen, node; + ihandle_t stdout; + char type[64], name[64]; + + chosen = OF_finddevice("/chosen"); + OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)); + node = OF_instance_to_package(stdout); + if (node == -1) { + /* + * The "/chosen/stdout" does not exist try + * using "screen" directly. + */ + node = OF_finddevice("screen"); + } + OF_getprop(node, "device_type", type, sizeof(type)); + if (strcmp(type, "display") != 0) + return (CN_DEAD); + + OF_getprop(node, "name", name, sizeof(name)); + if (strcmp(name, "SUNW,ffb") != 0 && strcmp(name, "SUNW,afb") != 0) + return (CN_DEAD); + + /* Looks OK... */ + return (CN_INTERNAL); +} + +static int +creatorfb_init(struct vt_device *vd) +{ + struct fb_info *sc; + phandle_t chosen; + phandle_t node; + ihandle_t handle; + uint32_t height, width; + static struct bus_space_tag ofwfb_memt[1]; + char type[64], name[64]; + bus_addr_t phys; + int space; + + /* Initialize softc */ + vd->vd_softc = sc = &creatorfb_conssoftc; + + chosen = OF_finddevice("/chosen"); + OF_getprop(chosen, "stdout", &handle, sizeof(ihandle_t)); + node = OF_instance_to_package(handle); + if (node == -1) { + /* + * The "/chosen/stdout" does not exist try + * using "screen" directly. + */ + node = OF_finddevice("screen"); + handle = OF_open("screen"); + } + OF_getprop(node, "device_type", type, sizeof(type)); + if (strcmp(type, "display") != 0) + return (CN_DEAD); + + OF_getprop(node, "name", name, sizeof(name)); + if (strcmp(name, "SUNW,ffb") != 0 && strcmp(name, "SUNW,afb") != 0) + return (CN_DEAD); + + /* Make sure we have needed properties */ + if (OF_getproplen(node, "height") != sizeof(height) || + OF_getproplen(node, "width") != sizeof(width)) + return (CN_DEAD); + + OF_getprop(node, "height", &height, sizeof(height)); + OF_getprop(node, "width", &width, sizeof(width)); + + sc->fb_height = height; + sc->fb_width = width; + sc->fb_bpp = sc->fb_depth = 32; + sc->fb_stride = 8192; /* Fixed */ + sc->fb_size = sc->fb_height * sc->fb_stride; + + /* Map linear framebuffer */ + if (OF_decode_addr(node, FFB_DFB24, &space, &phys) != 0) + return (CN_DEAD); + sc->fb_vbase = sparc64_fake_bustag(space, phys, &ofwfb_memt[0]); + sc->fb_pbase = phys; + + /* 32-bit VGA palette */ + vt_generate_vga_palette(sc->fb_cmap, COLOR_FORMAT_RGB, 255, 0, 255, 8, + 255, 16); + + fb_probe(sc); + vt_fb_init(vd); + + /* Clear the screen. */ + vt_fb_blank(vd, TC_BLACK); + + return (CN_INTERNAL); +} + Property changes on: dev/fb/creator_vt.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: conf/files.sparc64 =================================================================== --- conf/files.sparc64 (revision 269205) +++ conf/files.sparc64 (working copy) @@ -60,6 +60,8 @@ dev/syscons/scvtb.c optional sc dev/uart/uart_cpu_sparc64.c optional uart dev/uart/uart_kbd_sun.c optional uart sc | vt dev/vt/hw/ofwfb/ofwfb.c optional vt +dev/fb/creator_vt.c optional vt kern/kern_clocksource.c standard kern/subr_dummy_vdso_tc.c standard kern/syscalls.c optional ktr