Date: Sat, 3 Jul 2010 21:02:11 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r209674 - user/nwhitehorn/ps3/dev/ofw Message-ID: <201007032102.o63L2Bl3024578@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: nwhitehorn Date: Sat Jul 3 21:02:11 2010 New Revision: 209674 URL: http://svn.freebsd.org/changeset/base/209674 Log: "Fix" some things in ofw_fdt for 64-bit systems. The basic problem is that this code uses pointers into the device tree as package handles, but the PPC OF spec has package handles as 32-bit quantities. Maybe offsets into the DT blob could be used instead? In any case, this change is fine on powerpc64/aim, since device trees will always be loaded at boot time and thus are guaranteed to be in 32-bit accessible memory. Also, kill some dependence on things in /dev/fdt, which are unimplemented (and unnecessary) for the time being. Modified: user/nwhitehorn/ps3/dev/ofw/ofw_fdt.c Modified: user/nwhitehorn/ps3/dev/ofw/ofw_fdt.c ============================================================================== --- user/nwhitehorn/ps3/dev/ofw/ofw_fdt.c Sat Jul 3 20:48:43 2010 (r209673) +++ user/nwhitehorn/ps3/dev/ofw/ofw_fdt.c Sat Jul 3 21:02:11 2010 (r209674) @@ -39,7 +39,9 @@ __FBSDID("$FreeBSD$"); #include <machine/stdarg.h> +#ifndef __powerpc__ #include <dev/fdt/fdt_common.h> +#endif #include <dev/ofw/ofwvar.h> #include <dev/ofw/openfirm.h> @@ -120,11 +122,11 @@ fdt_phandle_offset(phandle_t p) dt_struct = (const char *)fdtp + fdt_off_dt_struct(fdtp); - if (((const char *)p < dt_struct) || - (const char *)p > (dt_struct + fdt_size_dt_struct(fdtp))) + if (((const char *)(uintptr_t)p < dt_struct) || + (const char *)(uintptr_t)p > (dt_struct + fdt_size_dt_struct(fdtp))) return (-1); - offset = (const char *)p - dt_struct; + offset = (const char *)(uintptr_t)p - dt_struct; if (offset < 0) return (-1); @@ -141,7 +143,8 @@ ofw_fdt_peer(ofw_t ofw, phandle_t node) if (node == 0) { /* Find root node */ offset = fdt_path_offset(fdtp, "/"); - p = (phandle_t)fdt_offset_ptr(fdtp, offset, sizeof(p)); + p = (phandle_t)(uintptr_t)fdt_offset_ptr(fdtp, + offset, sizeof(p)); return (p); } @@ -156,7 +159,8 @@ ofw_fdt_peer(ofw_t ofw, phandle_t node) if (depth < 0) return (0); if (depth == 1) { - p = (phandle_t)fdt_offset_ptr(fdtp, offset, sizeof(p)); + p = (phandle_t)(uintptr_t)fdt_offset_ptr(fdtp, + offset, sizeof(p)); return (p); } } @@ -181,7 +185,8 @@ ofw_fdt_child(ofw_t ofw, phandle_t node) if (depth < 0) return (0); if (depth == 1) { - p = (phandle_t)fdt_offset_ptr(fdtp, offset, sizeof(p)); + p = (phandle_t)(uintptr_t)fdt_offset_ptr(fdtp, + offset, sizeof(p)); return (p); } } @@ -201,7 +206,8 @@ ofw_fdt_parent(ofw_t ofw, phandle_t node return (0); paroffset = fdt_parent_offset(fdtp, offset); - p = (phandle_t)fdt_offset_ptr(fdtp, paroffset, sizeof(phandle_t)); + p = (phandle_t)(uintptr_t)fdt_offset_ptr(fdtp, paroffset, + sizeof(phandle_t)); return (p); } @@ -223,7 +229,8 @@ ofw_fdt_instance_to_package(ofw_t ofw, i if (offset < 0) return (0); - p = (phandle_t)fdt_offset_ptr(fdtp, offset, sizeof(phandle_t)); + p = (phandle_t)(uintptr_t)fdt_offset_ptr(fdtp, offset, + sizeof(phandle_t)); return (p); } @@ -326,7 +333,7 @@ ofw_fdt_nextprop(ofw_t ofw, phandle_t pa size_t size) { const struct fdt_property *prop; - int offset, rv; + long offset, rv; offset = fdt_phandle_offset(package); if (offset < 0) @@ -343,7 +350,7 @@ ofw_fdt_nextprop(ofw_t ofw, phandle_t pa if (prop == NULL) return (0); - offset = fdt_phandle_offset((phandle_t)prop); + offset = fdt_phandle_offset((phandle_t)(uintptr_t)prop); rv = fdt_nextprop(offset, buf, size); return (rv); } @@ -379,7 +386,7 @@ ofw_fdt_finddevice(ofw_t ofw, const char offset = fdt_path_offset(fdtp, device); - p = (phandle_t)fdt_offset_ptr(fdtp, offset, sizeof(p)); + p = (phandle_t)(uintptr_t)fdt_offset_ptr(fdtp, offset, sizeof(p)); return (p); } @@ -403,6 +410,7 @@ ofw_fdt_package_to_path(ofw_t ofw, phand static int ofw_fdt_fixup(ofw_t ofw) { +#ifndef __powerpc64__ #define FDT_MODEL_LEN 80 char model[FDT_MODEL_LEN]; phandle_t root; @@ -430,6 +438,7 @@ ofw_fdt_fixup(ofw_t ofw) if (fdt_fixup_table[i].handler != NULL) (*fdt_fixup_table[i].handler)(root); } +#endif return (0); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007032102.o63L2Bl3024578>