Changeset View
Standalone View
sys/dev/vt/hw/ofwfb/ofwfb.c
Show All 26 Lines | |||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/module.h> | |||||
#include <sys/fbio.h> | #include <sys/fbio.h> | ||||
#include <dev/vt/vt.h> | #include <dev/vt/vt.h> | ||||
#include <dev/vt/hw/fb/vt_fb.h> | #include <dev/vt/hw/fb/vt_fb.h> | ||||
#include <dev/vt/colors/vt_termcolors.h> | #include <dev/vt/colors/vt_termcolors.h> | ||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/pmap.h> | #include <vm/pmap.h> | ||||
Show All 38 Lines | |||||
static unsigned char ofw_colors[16] = { | static unsigned char ofw_colors[16] = { | ||||
/* See "16-color Text Extension" Open Firmware document, page 4 */ | /* See "16-color Text Extension" Open Firmware document, page 4 */ | ||||
0, 4, 2, 6, 1, 5, 3, 7, | 0, 4, 2, 6, 1, 5, 3, 7, | ||||
8, 12, 10, 14, 9, 13, 11, 15 | 8, 12, 10, 14, 9, 13, 11, 15 | ||||
}; | }; | ||||
static struct ofwfb_softc ofwfb_conssoftc; | static struct ofwfb_softc ofwfb_conssoftc; | ||||
VT_DRIVER_DECLARE(vt_ofwfb, vt_ofwfb_driver); | VT_DRIVER_DECLARE(vt_ofwfb, vt_ofwfb_driver); | ||||
nwhitehorn: No way for these to be the same driver? | |||||
Not Done Inline ActionsI think they could be the same. I mentioned this on IRC just a few minutes ago. If I move the /chosen handling code into the ofwfb_probe function instead, that might suffice, so that it's not looking for /chosen properties in the ofwfb_init(). jhibbits: I think they could be the same. I mentioned this on IRC just a few minutes ago. If I move the… | |||||
static int | static int | ||||
ofwfb_probe(struct vt_device *vd) | ofwfb_probe(struct vt_device *vd) | ||||
{ | { | ||||
struct ofwfb_softc *sc; | |||||
phandle_t chosen, node; | phandle_t chosen, node; | ||||
ihandle_t stdout; | ihandle_t stdout; | ||||
char type[64]; | char type[64]; | ||||
chosen = OF_finddevice("/chosen"); | chosen = OF_finddevice("/chosen"); | ||||
if (chosen == -1) | if (chosen == -1) | ||||
return (CN_DEAD); | return (CN_DEAD); | ||||
sc = &ofwfb_conssoftc; | |||||
node = -1; | node = -1; | ||||
if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == | if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == | ||||
sizeof(stdout)) | sizeof(stdout)) | ||||
node = OF_instance_to_package(stdout); | node = OF_instance_to_package(stdout); | ||||
if (node == -1) { | if (node == -1) { | ||||
/* | /* | ||||
* The "/chosen/stdout" does not exist try | * The "/chosen/stdout" does not exist try | ||||
* using "screen" directly. | * using "screen" directly. | ||||
*/ | */ | ||||
node = OF_finddevice("screen"); | node = OF_finddevice("screen"); | ||||
if (node == -1) | |||||
return (CN_DEAD); | |||||
stdout = OF_open("screen"); | |||||
nwhitehornUnsubmitted Not Done Inline ActionsIs this tested on Apple hardware? nwhitehorn: Is this tested on Apple hardware? | |||||
} | } | ||||
OF_getprop(node, "device_type", type, sizeof(type)); | OF_getprop(node, "device_type", type, sizeof(type)); | ||||
if (strcmp(type, "display") != 0) | if (strcmp(type, "display") != 0) | ||||
return (CN_DEAD); | return (CN_DEAD); | ||||
sc->sc_handle = stdout; | |||||
sc->sc_node = node; | |||||
/* Looks OK... */ | /* Looks OK... */ | ||||
return (CN_INTERNAL); | return (CN_INTERNAL); | ||||
} | } | ||||
static void | static void | ||||
ofwfb_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw, | ofwfb_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw, | ||||
const uint8_t *pattern, const uint8_t *mask, | const uint8_t *pattern, const uint8_t *mask, | ||||
unsigned int width, unsigned int height, | unsigned int width, unsigned int height, | ||||
▲ Show 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | break; | ||||
} | } | ||||
} | } | ||||
static int | static int | ||||
ofwfb_init(struct vt_device *vd) | ofwfb_init(struct vt_device *vd) | ||||
{ | { | ||||
struct ofwfb_softc *sc; | struct ofwfb_softc *sc; | ||||
char type[64]; | char type[64]; | ||||
phandle_t chosen; | |||||
phandle_t node; | phandle_t node; | ||||
uint32_t depth, height, width, stride; | uint32_t depth, height, width, stride; | ||||
uint32_t fb_phys; | uint32_t fb_phys; | ||||
int i, len; | int i, len; | ||||
#ifdef __sparc64__ | #ifdef __sparc64__ | ||||
static struct bus_space_tag ofwfb_memt[1]; | static struct bus_space_tag ofwfb_memt[1]; | ||||
bus_addr_t phys; | bus_addr_t phys; | ||||
int space; | int space; | ||||
#endif | #endif | ||||
/* Initialize softc */ | /* Initialize softc */ | ||||
vd->vd_softc = sc = &ofwfb_conssoftc; | vd->vd_softc = sc = &ofwfb_conssoftc; | ||||
chosen = OF_finddevice("/chosen"); | node = sc->sc_node; | ||||
OF_getprop(chosen, "stdout", &sc->sc_handle, sizeof(ihandle_t)); | |||||
node = OF_instance_to_package(sc->sc_handle); | |||||
if (node == -1) { | |||||
/* | |||||
* The "/chosen/stdout" does not exist try | |||||
* using "screen" directly. | |||||
*/ | |||||
node = OF_finddevice("screen"); | |||||
sc->sc_handle = OF_open("screen"); | |||||
} | |||||
OF_getprop(node, "device_type", type, sizeof(type)); | OF_getprop(node, "device_type", type, sizeof(type)); | ||||
if (strcmp(type, "display") != 0) | if (strcmp(type, "display") != 0) | ||||
return (CN_DEAD); | return (CN_DEAD); | ||||
/* Keep track of the OF node */ | |||||
sc->sc_node = node; | |||||
/* | /* | ||||
* Try to use a 32-bit framebuffer if possible. This may be | * Try to use a 32-bit framebuffer if possible. This may be | ||||
* unimplemented and fail. That's fine -- it just means we are | * unimplemented and fail. That's fine -- it just means we are | ||||
* stuck with the defaults. | * stuck with the defaults. | ||||
*/ | */ | ||||
OF_call_method("set-depth", sc->sc_handle, 1, 1, (cell_t)32, &i); | OF_call_method("set-depth", sc->sc_handle, 1, 1, (cell_t)32, &i); | ||||
/* Make sure we have needed properties */ | /* Make sure we have needed properties */ | ||||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | if (!(cpu_features & PPC_FEATURE_BOOKE) && !(mfmsr() & PSL_DR)) | ||||
sc->fb.fb_flags |= FB_FLAG_NOWRITE; | sc->fb.fb_flags |= FB_FLAG_NOWRITE; | ||||
#endif | #endif | ||||
ofwfb_initialize(vd); | ofwfb_initialize(vd); | ||||
vt_fb_init(vd); | vt_fb_init(vd); | ||||
return (CN_INTERNAL); | return (CN_INTERNAL); | ||||
} | } | ||||
static void | |||||
ofwfb_dev_identify(driver_t *driver, device_t parent) | |||||
{ | |||||
/* Try to guess if we need a device attachment. */ | |||||
if (ofwfb_conssoftc.sc_node > 0) | |||||
return; | |||||
Not Done Inline ActionsIt seems a bit weird to have a newbus device appear only if it's *not* the console. nwhitehorn: It seems a bit weird to have a newbus device appear only if it's *not* the console. | |||||
Not Done Inline ActionsIf it's not the system console, but has all the makings of a video console. jhibbits: If it's not the system console, but has all the makings of a video console. | |||||
Not Done Inline ActionsSo? Don't you always want a newbus device, even if it is the console (like uart)? nwhitehorn: So? Don't you always want a newbus device, even if it is the console (like uart)? | |||||
Not Done Inline ActionsNewbus should always have a node if the hardware is there... console or not is something else and should have no influence on this choice. imp: Newbus should always have a node if the hardware is there... console or not is something else… | |||||
if (device_find_child(parent, "fb", -1) != NULL) | |||||
return; | |||||
Not Done Inline ActionsHow does this interact with drm consoles? I guess the probe bits compete later on? How about module loading of drm consoles? nwhitehorn: How does this interact with drm consoles? I guess the probe bits compete later on? How about… | |||||
Not Done Inline ActionsNot sure. I don't have anything that can really use drm console right now. Maybe 'fb' device name is wrong for this. jhibbits: Not sure. I don't have anything that can really use drm console right now. Maybe 'fb' device… | |||||
device_add_child(parent, "fb", -1); | |||||
} | |||||
static int | |||||
ofwfb_dev_probe(device_t dev) | |||||
{ | |||||
phandle_t node; | |||||
device_t check; | |||||
check = dev; | |||||
node = ofw_bus_get_node(check); | |||||
/* This may be a fake child of an OF node. */ | |||||
if (node == -1) { | |||||
/* Check the parent. */ | |||||
check = device_get_parent(check); | |||||
node = ofw_bus_get_node(check); | |||||
if (node == -1) | |||||
return (ENXIO); | |||||
} | |||||
if (strcmp(ofw_bus_get_type(check), "display")) | |||||
return (ENXIO); | |||||
device_set_desc(dev, "Open Firmware video console"); | |||||
Done Inline Actions"Open Firmware" usually has a space in it. nwhitehorn: "Open Firmware" usually has a space in it. | |||||
Not Done Inline ActionsOops. I'll blame my chrome keyboard's tendency to forget I hit space. jhibbits: Oops. I'll blame my chrome keyboard's tendency to forget I hit space. | |||||
return (BUS_PROBE_DEFAULT); | |||||
} | |||||
static int | |||||
ofwfb_dev_attach(device_t dev) | |||||
{ | |||||
struct ofwfb_softc *sc = &ofwfb_conssoftc; | |||||
phandle_t node; | |||||
device_set_softc(dev, sc); | |||||
node = ofw_bus_get_node(dev); | |||||
/* This may be a fake child of an OF node. */ | |||||
if (node == -1) { | |||||
/* Check the parent. */ | |||||
node = ofw_bus_get_node(device_get_parent(dev)); | |||||
if (node == -1) | |||||
return (ENXIO); | |||||
} | |||||
sc->sc_node = node; | |||||
vt_allocate(&vt_ofwfb_driver, &sc->fb); | |||||
return (0); | |||||
} | |||||
static device_method_t ofwfb_dev_methods[] = { | |||||
DEVMETHOD(device_identify, ofwfb_dev_identify), | |||||
DEVMETHOD(device_probe, ofwfb_dev_probe), | |||||
DEVMETHOD(device_attach, ofwfb_dev_attach), | |||||
DEVMETHOD_END | |||||
}; | |||||
static driver_t ofwfb_dev_driver = { | |||||
"fb", | |||||
ofwfb_dev_methods, | |||||
0 /* Don't allocate a softc, one will be provided. */ | |||||
}; | |||||
static devclass_t ofwfb_dev_devclass; | |||||
DRIVER_MODULE(fb, vgapci, ofwfb_dev_driver, ofwfb_dev_devclass, 0, 0); |
No way for these to be the same driver?