Changeset View
Standalone View
sys/dev/vt/hw/ofwfb/ofwfb.c
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | ofwfb_probe(struct vt_device *vd) | ||||
if (disabled) | if (disabled) | ||||
return (CN_DEAD); | return (CN_DEAD); | ||||
chosen = OF_finddevice("/chosen"); | chosen = OF_finddevice("/chosen"); | ||||
if (chosen == -1) | if (chosen == -1) | ||||
return (CN_DEAD); | return (CN_DEAD); | ||||
node = -1; | node = -1; | ||||
if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == | if (OF_getencprop(chosen, "stdout", &stdout, sizeof(stdout)) == | ||||
bdragon: I don't think this is correct for the case where it is an ihandle instead of a path. | |||||
Done Inline ActionsI've tested your suggested changes on LE. Both Talos and QEMU work fine when using OF_getencprop with stdout. Is there anything else that should be done to make this work without using OF_getencprop? luporl: I've tested your suggested changes on LE.
They worked on Talos but not on QEMU, where the… | |||||
Done Inline ActionsDebugging OF_instance_to_package(stdout) I found out the problem is that stdout ihandle is compared to phandles at OF_child_xref_phandle(), and those phandles are obtained with OF_getencprop(), so there is a clear mismatch here. If we can't use OF_getencprop() for /chosen/stdout, to avoid breaking "live" OF, then we need to byte swap the ihandle before treating it as a phandle. The call to OF_node_from_xref() at ofw_fdt_instance_to_package() seems a good place. luporl: Debugging `OF_instance_to_package(stdout)` I found out the problem is that stdout ihandle is… | |||||
Done Inline ActionsI've tested this change again, with the now working PPC LE loader, and the result is the same: ofwfb doesn't work unless OF_getencprop() is used. Changing OF_child_xref_phandle() behavior to not swap phandles is risky, because existing code already relies on it. We also have dumped and compared BE and LE FDTs and confirmed they are ok. Because of the reasons above, I think it is better to just use OF_getencprop(). It won't break PPC64BE "live" OF and IIUC "live" OF on PPC64LE doesn't make much sense, since PPC64LE either runs on hardware or with SLOF, that doesn't support several "live" OF features. What do you think? luporl: I've tested this change again, with the now working PPC LE loader, and the result is the same… | |||||
sizeof(stdout)) | sizeof(stdout)) | ||||
node = OF_instance_to_package(stdout); | node = OF_instance_to_package(stdout); | ||||
if (node == -1) | if (node == -1) | ||||
if (OF_getprop(chosen, "stdout-path", buf, sizeof(buf)) > 0) | if (OF_getprop(chosen, "stdout-path", buf, sizeof(buf)) > 0) | ||||
node = OF_finddevice(buf); | node = OF_finddevice(buf); | ||||
if (node == -1) { | if (node == -1) { | ||||
/* | /* | ||||
* The "/chosen/stdout" does not exist try | * The "/chosen/stdout" does not exist try | ||||
▲ Show 20 Lines • Show All 261 Lines • ▼ Show 20 Lines | |||||
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 buf[64]; | char buf[64]; | ||||
phandle_t chosen; | phandle_t chosen; | ||||
phandle_t node; | phandle_t node; | ||||
uint32_t depth, height, width, stride; | pcell_t depth, height, width, stride; | ||||
uint32_t vendor_id = 0; | uint32_t vendor_id = 0; | ||||
cell_t adr[2]; | cell_t adr[2]; | ||||
uint64_t user_phys; | uint64_t user_phys; | ||||
bus_addr_t fb_phys; | bus_addr_t fb_phys; | ||||
bus_size_t fb_phys_size; | bus_size_t fb_phys_size; | ||||
int i, j, len; | int i, j, len; | ||||
/* Initialize softc */ | /* Initialize softc */ | ||||
vd->vd_softc = sc = &ofwfb_conssoftc; | vd->vd_softc = sc = &ofwfb_conssoftc; | ||||
node = -1; | node = -1; | ||||
chosen = OF_finddevice("/chosen"); | chosen = OF_finddevice("/chosen"); | ||||
if (OF_getprop(chosen, "stdout", &sc->sc_handle, | if (OF_getencprop(chosen, "stdout", &sc->sc_handle, | ||||
Not Done Inline ActionsSame here. ihandles (as used when you are dealing with a "live" OF instead of a FDT) are one of the things that need to be preserved as-is, otherwise the logic of swapping them back and forth gets pretty confusing. bdragon: Same here. ihandles (as used when you are dealing with a "live" OF instead of a FDT) are one of… | |||||
sizeof(ihandle_t)) == sizeof(ihandle_t)) | sizeof(ihandle_t)) == sizeof(ihandle_t)) | ||||
node = OF_instance_to_package(sc->sc_handle); | node = OF_instance_to_package(sc->sc_handle); | ||||
if (node == -1) | if (node == -1) | ||||
/* Try "/chosen/stdout-path" now */ | /* Try "/chosen/stdout-path" now */ | ||||
if (OF_getprop(chosen, "stdout-path", buf, sizeof(buf)) > 0) { | if (OF_getprop(chosen, "stdout-path", buf, sizeof(buf)) > 0) { | ||||
node = OF_finddevice(buf); | node = OF_finddevice(buf); | ||||
if (node != -1) | if (node != -1) | ||||
sc->sc_handle = OF_open(buf); | sc->sc_handle = OF_open(buf); | ||||
Show All 32 Lines | ofwfb_init(struct vt_device *vd) | ||||
/* Make sure we have needed properties */ | /* Make sure we have needed properties */ | ||||
if (OF_getproplen(node, "height") != sizeof(height) || | if (OF_getproplen(node, "height") != sizeof(height) || | ||||
OF_getproplen(node, "width") != sizeof(width) || | OF_getproplen(node, "width") != sizeof(width) || | ||||
OF_getproplen(node, "depth") != sizeof(depth)) | OF_getproplen(node, "depth") != sizeof(depth)) | ||||
return (CN_DEAD); | return (CN_DEAD); | ||||
/* Only support 8 and 32-bit framebuffers */ | /* Only support 8 and 32-bit framebuffers */ | ||||
OF_getprop(node, "depth", &depth, sizeof(depth)); | OF_getencprop(node, "depth", &depth, sizeof(depth)); | ||||
if (depth != 8 && depth != 32) | if (depth != 8 && depth != 32) | ||||
return (CN_DEAD); | return (CN_DEAD); | ||||
sc->fb.fb_bpp = sc->fb.fb_depth = depth; | sc->fb.fb_bpp = sc->fb.fb_depth = depth; | ||||
OF_getprop(node, "height", &height, sizeof(height)); | OF_getencprop(node, "height", &height, sizeof(height)); | ||||
OF_getprop(node, "width", &width, sizeof(width)); | OF_getencprop(node, "width", &width, sizeof(width)); | ||||
if (OF_getprop(node, "linebytes", &stride, sizeof(stride)) != | if (OF_getencprop(node, "linebytes", &stride, sizeof(stride)) != | ||||
sizeof(stride)) | sizeof(stride)) | ||||
stride = width*depth/8; | stride = width*depth/8; | ||||
sc->fb.fb_height = height; | sc->fb.fb_height = height; | ||||
sc->fb.fb_width = width; | sc->fb.fb_width = width; | ||||
sc->fb.fb_stride = stride; | sc->fb.fb_stride = stride; | ||||
sc->fb.fb_size = sc->fb.fb_height * sc->fb.fb_stride; | sc->fb.fb_size = sc->fb.fb_height * sc->fb.fb_stride; | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | #if defined(__powerpc__) | ||||
struct ofw_pci_register pciaddrs[8]; | struct ofw_pci_register pciaddrs[8]; | ||||
int num_pciaddrs = 0; | int num_pciaddrs = 0; | ||||
/* | /* | ||||
* Get the PCI addresses of the adapter, if present. The node | * Get the PCI addresses of the adapter, if present. The node | ||||
* may be the child of the PCI device: in that case, try the | * may be the child of the PCI device: in that case, try the | ||||
* parent for the assigned-addresses property. | * parent for the assigned-addresses property. | ||||
*/ | */ | ||||
len = OF_getprop(node, "assigned-addresses", pciaddrs, | len = OF_getencprop(node, "assigned-addresses", | ||||
sizeof(pciaddrs)); | (pcell_t *)pciaddrs, sizeof(pciaddrs)); | ||||
if (len == -1) { | if (len == -1) { | ||||
len = OF_getprop(OF_parent(node), "assigned-addresses", | len = OF_getencprop(OF_parent(node), "assigned-addresses", | ||||
pciaddrs, sizeof(pciaddrs)); | (pcell_t *)pciaddrs, sizeof(pciaddrs)); | ||||
} | } | ||||
if (len == -1) | if (len == -1) | ||||
len = 0; | len = 0; | ||||
num_pciaddrs = len / sizeof(struct ofw_pci_register); | num_pciaddrs = len / sizeof(struct ofw_pci_register); | ||||
j = num_pciaddrs; | j = num_pciaddrs; | ||||
for (i = 0; i < num_pciaddrs; i++) { | for (i = 0; i < num_pciaddrs; i++) { | ||||
/* If it is too small, not the framebuffer */ | /* If it is too small, not the framebuffer */ | ||||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |
I don't think this is correct for the case where it is an ihandle instead of a path.