svn commit: r230473 - projects/pseries/powerpc/ofw
Nathan Whitehorn
nwhitehorn at FreeBSD.org
Sun Jan 22 21:26:31 UTC 2012
Author: nwhitehorn
Date: Sun Jan 22 21:26:30 2012
New Revision: 230473
URL: http://svn.freebsd.org/changeset/base/230473
Log:
Error checking is always a good idea -- don't just assume things are like
on Apple hardware.
Modified:
projects/pseries/powerpc/ofw/ofw_syscons.c
Modified: projects/pseries/powerpc/ofw/ofw_syscons.c
==============================================================================
--- projects/pseries/powerpc/ofw/ofw_syscons.c Sun Jan 22 21:25:47 2012 (r230472)
+++ projects/pseries/powerpc/ofw/ofw_syscons.c Sun Jan 22 21:26:30 2012 (r230473)
@@ -218,6 +218,7 @@ ofwfb_configure(int flags)
ihandle_t stdout;
phandle_t node;
uint32_t fb_phys;
+ ssize_t proplen;
int depth;
int disable;
int len;
@@ -264,12 +265,21 @@ ofwfb_configure(int flags)
} else
return (0);
+ if (OF_getproplen(node, "height") != sizeof(sc->sc_height) ||
+ OF_getproplen(node, "width") != sizeof(sc->sc_width))
+ return (0);
+
sc->sc_depth = depth;
sc->sc_node = node;
sc->sc_console = 1;
+ sc->sc_stride = -1;
OF_getprop(node, "height", &sc->sc_height, sizeof(sc->sc_height));
OF_getprop(node, "width", &sc->sc_width, sizeof(sc->sc_width));
- OF_getprop(node, "linebytes", &sc->sc_stride, sizeof(sc->sc_stride));
+ proplen = OF_getprop(node, "linebytes", &sc->sc_stride,
+ sizeof(sc->sc_stride));
+ if (proplen != sizeof(sc->sc_stride) ||
+ sc->sc_stride < sc->sc_width*sc->sc_depth/4)
+ sc->sc_stride = sc->sc_width*sc->sc_depth/4;
/*
* Grab the physical address of the framebuffer, and then map it
@@ -278,6 +288,8 @@ ofwfb_configure(int flags)
*
* XXX We assume #address-cells is 1 at this point.
*/
+ if (OF_getproplen(node, "address") != sizeof(fb_phys))
+ return (0);
OF_getprop(node, "address", &fb_phys, sizeof(fb_phys));
bus_space_map(&bs_be_tag, fb_phys, sc->sc_height * sc->sc_stride,
@@ -984,7 +996,7 @@ static driver_t ofwfb_sc_driver = {
static devclass_t sc_devclass;
-DRIVER_MODULE(sc, nexus, ofwfb_sc_driver, sc_devclass, 0, 0);
+DRIVER_MODULE(ofwfb, nexus, ofwfb_sc_driver, sc_devclass, 0, 0);
/*
* Define a stub keyboard driver in case one hasn't been
More information about the svn-src-projects
mailing list