added 3 changesets to branch 'refs/remotes/mmu_man-github/sam460ex' old head: acc4e245de592de1897b78b16f1f4dffbda07249 new head: 4c50a9bcfd5f92310d3a3493381c9042f6ef5df8 overview: https://github.com/mmuman/haiku/compare/acc4e24...4c50a9b ---------------------------------------------------------------------------- aa9d092: U-Boot: implement of_get_next_device() in the OF wrapper 05e6505: U-Boot: cleanup 4c50a9b: U-Boot: move of_init() call before cpu_init() So we can use the OF wrapper there as well and copy code verbatim from the OF platform. [ François Revol <revol@xxxxxxx> ] ---------------------------------------------------------------------------- 2 files changed, 33 insertions(+), 4 deletions(-) src/system/boot/platform/u-boot/start.cpp | 6 ++-- .../kernel/platform/u-boot/openfirmware.cpp | 31 +++++++++++++++++++- ############################################################################ Commit: aa9d092029e1a8e2ee21f04cd321e8c3368f6deb Author: François Revol <revol@xxxxxxx> Date: Mon Feb 18 01:40:16 2013 UTC U-Boot: implement of_get_next_device() in the OF wrapper ---------------------------------------------------------------------------- diff --git a/src/system/kernel/platform/u-boot/openfirmware.cpp b/src/system/kernel/platform/u-boot/openfirmware.cpp index 9a56ce9..cdf2d27 100644 --- a/src/system/kernel/platform/u-boot/openfirmware.cpp +++ b/src/system/kernel/platform/u-boot/openfirmware.cpp @@ -112,7 +112,38 @@ status_t of_get_next_device(int *_cookie, int root, const char *type, char *path, size_t pathSize) { - return B_ERROR; + int next; + int err; + + int startoffset = *_cookie ? *_cookie : -1; +// if (startoffset < 0 && root != 0) +// startoffset = root; + + // iterate by property value + next = fdt_node_offset_by_prop_value(gFDT, startoffset, "device_type", + type, strlen(type) + 1); + TRACE(("of_get_next_device(c:%d, %d, '%s', %p, %zd) soffset=%d next=%d\n", + *_cookie, root, type, path, pathSize, startoffset, fdt2of(next))); + if (next < 0) + return B_ENTRY_NOT_FOUND; + + // make sure root is the parent + int parent = next; + while (root && parent) { + parent = fdt_parent_offset(gFDT, parent); + if (parent == root) + break; + if (parent <= 0) + return B_ENTRY_NOT_FOUND; + } + + *_cookie = next; + + err = fdt_get_path(gFDT, next, path, pathSize); + if (err < 0) + return B_ERROR; + + return B_OK; } ############################################################################ Commit: 05e65058fed7b28b90560bf20fb4fe4ae149ed14 Author: François Revol <revol@xxxxxxx> Date: Mon Feb 18 01:41:16 2013 UTC U-Boot: cleanup ---------------------------------------------------------------------------- diff --git a/src/system/kernel/platform/u-boot/openfirmware.cpp b/src/system/kernel/platform/u-boot/openfirmware.cpp index cdf2d27..5fb8f2c 100644 --- a/src/system/kernel/platform/u-boot/openfirmware.cpp +++ b/src/system/kernel/platform/u-boot/openfirmware.cpp @@ -116,8 +116,6 @@ of_get_next_device(int *_cookie, int root, const char *type, char *path, int err; int startoffset = *_cookie ? *_cookie : -1; -// if (startoffset < 0 && root != 0) -// startoffset = root; // iterate by property value next = fdt_node_offset_by_prop_value(gFDT, startoffset, "device_type", ############################################################################ Commit: 4c50a9bcfd5f92310d3a3493381c9042f6ef5df8 Author: François Revol <revol@xxxxxxx> Date: Mon Feb 18 01:42:03 2013 UTC U-Boot: move of_init() call before cpu_init() So we can use the OF wrapper there as well and copy code verbatim from the OF platform. ---------------------------------------------------------------------------- diff --git a/src/system/boot/platform/u-boot/start.cpp b/src/system/boot/platform/u-boot/start.cpp index 1bcc0d3..15838eb 100644 --- a/src/system/boot/platform/u-boot/start.cpp +++ b/src/system/boot/platform/u-boot/start.cpp @@ -191,6 +191,9 @@ start_raw(int argc, const char **argv) serial_init(gFDT); console_init(); + // initialize the OpenFirmware wrapper + of_init(NULL); + cpu_init(); if (args.platform.fdt_data) { @@ -223,9 +226,6 @@ start_raw(int argc, const char **argv) args.platform.boot_tgz_data, args.platform.boot_tgz_size); } } - - // also initialize the OpenFirmware wrapper - of_init(NULL); } // if we get passed a uimage, try to find the second blob