Date: Wed, 13 Oct 2010 02:10:56 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r213758 - in user/nwhitehorn/ps3: dev/ofw powerpc/aim Message-ID: <201010130210.o9D2Auhs069189@svn.freebsd.org>
index | next in thread | raw e-mail
Author: nwhitehorn Date: Wed Oct 13 02:10:56 2010 New Revision: 213758 URL: http://svn.freebsd.org/changeset/base/213758 Log: Make the generic OF layer do the right thing (all OF client interface routines return errors) if no OF client interface module is installed instead of calling NULL functions. Modified: user/nwhitehorn/ps3/dev/ofw/openfirm.c user/nwhitehorn/ps3/powerpc/aim/mmu_oea64.c Modified: user/nwhitehorn/ps3/dev/ofw/openfirm.c ============================================================================== --- user/nwhitehorn/ps3/dev/ofw/openfirm.c Wed Oct 13 02:09:06 2010 (r213757) +++ user/nwhitehorn/ps3/dev/ofw/openfirm.c Wed Oct 13 02:10:56 2010 (r213758) @@ -76,7 +76,7 @@ MALLOC_DEFINE(M_OFWPROP, "openfirm", "Op static ihandle_t stdout; -static ofw_def_t *ofw_def_impl; +static ofw_def_t *ofw_def_impl = NULL; static ofw_t ofw_obj; static struct ofw_kobj ofw_kernel_obj; static struct kobj_ops ofw_kernel_kops; @@ -118,6 +118,9 @@ OF_init(void *cookie) phandle_t chosen; int rv; + if (ofw_def_impl == NULL) + return (-1); + ofw_obj = &ofw_kernel_obj; /* * Take care of compiling the selected class, and @@ -156,6 +159,9 @@ int OF_test(const char *name) { + if (ofw_def_impl == NULL) + return (-1); + return (OFW_TEST(ofw_obj, name)); } @@ -167,6 +173,9 @@ OF_interpret(const char *cmd, int nretur int i = 0; int status; + if (ofw_def_impl == NULL) + return (-1); + status = OFW_INTERPRET(ofw_obj, cmd, nreturns, slots); if (status == -1) return (status); @@ -188,6 +197,9 @@ phandle_t OF_peer(phandle_t node) { + if (ofw_def_impl == NULL) + return (0); + return (OFW_PEER(ofw_obj, node)); } @@ -196,6 +208,9 @@ phandle_t OF_child(phandle_t node) { + if (ofw_def_impl == NULL) + return (0); + return (OFW_CHILD(ofw_obj, node)); } @@ -204,6 +219,9 @@ phandle_t OF_parent(phandle_t node) { + if (ofw_def_impl == NULL) + return (0); + return (OFW_PARENT(ofw_obj, node)); } @@ -212,6 +230,9 @@ phandle_t OF_instance_to_package(ihandle_t instance) { + if (ofw_def_impl == NULL) + return (-1); + return (OFW_INSTANCE_TO_PACKAGE(ofw_obj, instance)); } @@ -220,6 +241,9 @@ ssize_t OF_getproplen(phandle_t package, const char *propname) { + if (ofw_def_impl == NULL) + return (-1); + return (OFW_GETPROPLEN(ofw_obj, package, propname)); } @@ -228,6 +252,9 @@ ssize_t OF_getprop(phandle_t package, const char *propname, void *buf, size_t buflen) { + if (ofw_def_impl == NULL) + return (-1); + return (OFW_GETPROP(ofw_obj, package, propname, buf, buflen)); } @@ -276,6 +303,9 @@ int OF_nextprop(phandle_t package, const char *previous, char *buf, size_t size) { + if (ofw_def_impl == NULL) + return (-1); + return (OFW_NEXTPROP(ofw_obj, package, previous, buf, size)); } @@ -284,6 +314,9 @@ int OF_setprop(phandle_t package, const char *propname, const void *buf, size_t len) { + if (ofw_def_impl == NULL) + return (-1); + return (OFW_SETPROP(ofw_obj, package, propname, buf,len)); } @@ -292,6 +325,9 @@ ssize_t OF_canon(const char *device, char *buf, size_t len) { + if (ofw_def_impl == NULL) + return (-1); + return (OFW_CANON(ofw_obj, device, buf, len)); } @@ -300,6 +336,9 @@ phandle_t OF_finddevice(const char *device) { + if (ofw_def_impl == NULL) + return (-1); + return (OFW_FINDDEVICE(ofw_obj, device)); } @@ -308,6 +347,9 @@ ssize_t OF_instance_to_path(ihandle_t instance, char *buf, size_t len) { + if (ofw_def_impl == NULL) + return (-1); + return (OFW_INSTANCE_TO_PATH(ofw_obj, instance, buf, len)); } @@ -316,6 +358,9 @@ ssize_t OF_package_to_path(phandle_t package, char *buf, size_t len) { + if (ofw_def_impl == NULL) + return (-1); + return (OFW_PACKAGE_TO_PATH(ofw_obj, package, buf, len)); } @@ -328,7 +373,7 @@ OF_call_method(const char *method, ihand cell_t args_n_results[12]; int n, status; - if (nargs > 6) + if (nargs > 6 || ofw_def_impl == NULL) return (-1); va_start(ap, nreturns); for (n = 0; n < nargs; n++) @@ -354,6 +399,9 @@ ihandle_t OF_open(const char *device) { + if (ofw_def_impl == NULL) + return (0); + return (OFW_OPEN(ofw_obj, device)); } @@ -362,6 +410,9 @@ void OF_close(ihandle_t instance) { + if (ofw_def_impl == NULL) + return; + OFW_CLOSE(ofw_obj, instance); } @@ -370,6 +421,9 @@ ssize_t OF_read(ihandle_t instance, void *addr, size_t len) { + if (ofw_def_impl == NULL) + return (-1); + return (OFW_READ(ofw_obj, instance, addr, len)); } @@ -378,6 +432,9 @@ ssize_t OF_write(ihandle_t instance, const void *addr, size_t len) { + if (ofw_def_impl == NULL) + return (-1); + return (OFW_WRITE(ofw_obj, instance, addr, len)); } @@ -386,6 +443,9 @@ int OF_seek(ihandle_t instance, uint64_t pos) { + if (ofw_def_impl == NULL) + return (-1); + return (OFW_SEEK(ofw_obj, instance, pos)); } @@ -398,6 +458,9 @@ void * OF_claim(void *virt, size_t size, u_int align) { + if (ofw_def_impl == NULL) + return ((void *)-1); + return (OFW_CLAIM(ofw_obj, virt, size, align)); } @@ -406,6 +469,9 @@ void OF_release(void *virt, size_t size) { + if (ofw_def_impl == NULL) + return; + OFW_RELEASE(ofw_obj, virt, size); } @@ -418,6 +484,9 @@ void OF_enter() { + if (ofw_def_impl == NULL) + return; + OFW_ENTER(ofw_obj); } @@ -425,6 +494,8 @@ OF_enter() void OF_exit() { + if (ofw_def_impl == NULL) + panic("OF_exit: Open Firmware not available"); /* Should not return */ OFW_EXIT(ofw_obj); Modified: user/nwhitehorn/ps3/powerpc/aim/mmu_oea64.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/aim/mmu_oea64.c Wed Oct 13 02:09:06 2010 (r213757) +++ user/nwhitehorn/ps3/powerpc/aim/mmu_oea64.c Wed Oct 13 02:10:56 2010 (r213758) @@ -1134,7 +1134,9 @@ moea64_late_bootstrap(mmu_t mmup, vm_off * mode. */ - if (!ofw_real_mode) { + chosen = OF_finddevice("/chosen"); + + if (chosen != -1 && OF_getprop(chosen, "mmu", &mmui, 4) != -1) { #ifndef __powerpc64__ moea64_pinit(mmup, &ofw_pmap);help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010130210.o9D2Auhs069189>
