Skip to content

Instantly share code, notes, and snippets.

@kallisti5
Created March 5, 2015 03:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kallisti5/6e186b8b5abb0489925f to your computer and use it in GitHub Desktop.
Save kallisti5/6e186b8b5abb0489925f to your computer and use it in GitHub Desktop.
Adding a Haiku target to u-boot
diff --git a/src/system/boot/platform/u-boot/arch/arm/shell.S b/src/system/boot/platform/u-boot/arch/arm/shell.S
index 813a689..80bc280 100644
--- a/src/system/boot/platform/u-boot/arch/arm/shell.S
+++ b/src/system/boot/platform/u-boot/arch/arm/shell.S
@@ -38,6 +38,13 @@ SYMBOL(_start_linux):
b _start_common
SYMBOL_END(_start_linux)
+/*
+ * called from bootm with haiku loader compatible args
+ */
+SYMBOL(_start_haiku):
+ mov r4,#3
+ b _start_common
+SYMBOL_END(_start_haiku)
SYMBOL(_start_common):
@@ -73,6 +80,8 @@ SYMBOL(_start_common):
beq start_netbsd
cmp r4,#2
beq start_linux
+ cmp r4,#3
+ beq start_haiku
mov pc,lr
SYMBOL_END(_start_common)
diff --git a/src/system/boot/platform/u-boot/start.cpp b/src/system/boot/platform/u-boot/start.cpp
index e23cfb3..cb6bd50 100644
--- a/src/system/boot/platform/u-boot/start.cpp
+++ b/src/system/boot/platform/u-boot/start.cpp
@@ -128,6 +128,17 @@ platform_exit(void)
extern "C" int
+start_haiku(void* fdt)
+{
+ // TODO: Do we want more than just the FDT location?
+
+ // Once Haiku support in u-boot is the norm, we should
+ // likely only keep netbsd and haiku
+ return start_get(0, NULL, NULL, fdt);
+}
+
+
+extern "C" int
start_netbsd(struct board_info *bd, struct image_header *image,
const char *consdev, const char *cmdline)
{
diff --git a/common/bootm_os.c b/common/bootm_os.c
index 72477f0..8dee1e6 100644
--- a/common/bootm_os.c
+++ b/common/bootm_os.c
@@ -133,6 +133,40 @@ static int do_bootm_netbsd(int flag, int argc, char * const argv[],
}
#endif /* CONFIG_BOOTM_NETBSD*/
+#ifdef CONFIG_BOOTM_HAIKU
+static int do_bootm_haiku(int flag, int argc, char * const argv[],
+ bootm_headers_t *images)
+{
+ char *ftLoc;
+ void (*loader)(void *fdt_addr);
+
+ if (flag != BOOTM_STATE_OS_GO)
+ return 0;
+
+ loader = (void (*)(void *fdt_addr))images->ep;
+
+ if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len)
+ ftLoc = images->ft_addr;
+ else {
+ printf("## Warn: FDT not provided!\n");
+ ftLoc = NULL;
+ }
+
+ printf("## Transferring control to Haiku loader (at address %08lx) ...\n",
+ (ulong)loader);
+
+ bootstage_mark(BOOTSTAGE_ID_RUN_OS);
+
+ /*
+ * Haiku Loader Parameters:
+ * arg[0]: pointer to fdt
+ */
+ (*loader)(ftLoc);
+
+ return 1;
+}
+#endif /* CONFIG_BOOTM_HAIKU */
+
#ifdef CONFIG_LYNXKDI
static int do_bootm_lynxkdi(int flag, int argc, char * const argv[],
bootm_headers_t *images)
@@ -432,6 +466,9 @@ static int do_bootm_openrtos(int flag, int argc, char * const argv[],
static boot_os_fn *boot_os[] = {
[IH_OS_U_BOOT] = do_bootm_standalone,
+#ifdef CONFIG_BOOTM_HAIKU
+ [IH_OS_HAIKU] = do_bootm_haiku,
+#endif
#ifdef CONFIG_BOOTM_LINUX
[IH_OS_LINUX] = do_bootm_linux,
#endif
diff --git a/common/image.c b/common/image.c
index a911aa9..fc29559 100644
--- a/common/image.c
+++ b/common/image.c
@@ -91,6 +91,7 @@ static const table_entry_t uimage_arch[] = {
static const table_entry_t uimage_os[] = {
{ IH_OS_INVALID, NULL, "Invalid OS", },
+ { IH_OS_HAIKU, "haiku", "Haiku", },
{ IH_OS_LINUX, "linux", "Linux", },
#if defined(CONFIG_LYNXKDI) || defined(USE_HOSTCC)
{ IH_OS_LYNXOS, "lynxos", "LynxOS", },
diff --git a/include/config_defaults.h b/include/config_defaults.h
index ad08c1d..e5ba208 100644
--- a/include/config_defaults.h
+++ b/include/config_defaults.h
@@ -10,6 +10,7 @@
#define _CONFIG_DEFAULTS_H_
/* Support bootm-ing different OSes */
+#define CONFIG_BOOTM_HAIKU 1
#define CONFIG_BOOTM_LINUX 1
#define CONFIG_BOOTM_NETBSD 1
#define CONFIG_BOOTM_PLAN9 1
diff --git a/include/image.h b/include/image.h
index 0e6af00..a774490 100644
--- a/include/image.h
+++ b/include/image.h
@@ -153,6 +153,7 @@ struct lmb;
#define IH_OS_OSE 22 /* OSE */
#define IH_OS_PLAN9 23 /* Plan 9 */
#define IH_OS_OPENRTOS 24 /* OpenRTOS */
+#define IH_OS_HAIKU 25 /* Haiku */
/*
* CPU Architecture Codes (supported by Linux)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment