Add commands that scans for the FreeBSD loader and run it if found.
FreeBSD has two loader: ubldr which is an ELF binary and ubldr.bin which
is a PIE binary.

Signed-off-by: Emmanuel Vadot <m...@bidouilliste.com>
---
 include/config_distro_bootcmd.h | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 9ecaf38..0f5d385 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -153,6 +153,36 @@
 #define SCAN_DEV_FOR_EFI
 #endif
 
+#ifdef CONFIG_FREEBSD
+#define BOOTENV_SHARED_FREEBSD                                            \
+       "boot_freebsd_binary="                                            \
+               "load ${devtype} ${devnum}:${distro_bootpart} "           \
+                       "${kernel_addr_r} ubldr.bin; "                    \
+               "go ${kernel_addr_r}\0"                                   \
+       \
+       "boot_freebsd_elf="                                               \
+               "load ${devtype} ${devnum}:${distro_bootpart} "           \
+                       "${kernel_addr_r} ubldr; "                        \
+               "bootelf ${kernel_addr_r}\0"                              \
+       \
+       "scan_dev_for_freebsd="                                           \
+               "if test -e ${devtype} ${devnum}:${distro_bootpart} "     \
+                                       "ubldr.bin; then "                \
+                               "echo Found FreeBSD U-Boot Loader (bin);" \
+                               "run boot_freebsd_binary; "               \
+                               "echo FREEBSD FAILED: continuing...; "    \
+               "elif test -e ${devtype} ${devnum}:${distro_bootpart} "   \
+                                       "ubldr; then "                    \
+                               "echo Found FreeBSD U-Boot Loader (elf);" \
+                               "run boot_freebsd_elf; "                  \
+                               "echo FREEBSD FAILED: continuing...; "    \
+               "fi;\0"
+#define SCAN_DEV_FOR_FREEBSD "run scan_dev_for_freebsd;"
+#else
+#define BOOTENV_SHARED_FREEBSD
+#define SCAN_DEV_FOR_FREEBSD
+#endif
+
 #ifdef CONFIG_CMD_SATA
 #define BOOTENV_SHARED_SATA    BOOTENV_SHARED_BLKDEV(sata)
 #define BOOTENV_DEV_SATA       BOOTENV_DEV_BLKDEV
@@ -326,6 +356,7 @@
        BOOTENV_SHARED_IDE \
        BOOTENV_SHARED_UBIFS \
        BOOTENV_SHARED_EFI \
+       BOOTENV_SHARED_FREEBSD \
        "boot_prefixes=/ /boot/\0" \
        "boot_scripts=boot.scr.uimg boot.scr\0" \
        "boot_script_dhcp=boot.scr.uimg\0" \
@@ -369,6 +400,7 @@
                        "run scan_dev_for_scripts; "                      \
                "done;"                                                   \
                SCAN_DEV_FOR_EFI                                          \
+               SCAN_DEV_FOR_FREEBSD                                      \
                "\0"                                                      \
        \
        "scan_dev_for_boot_part="                                         \
-- 
2.9.2

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to