summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2008-02-20 19:01:54 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2008-02-20 19:01:54 +0100
commitf95ec8a32dd811f314329da11ad0ae583233f43a (patch)
tree693ae6e150446d06cd430142898a91c8346f772d /arch
parente912912a48c6aa127ef6fa79b6e1c41310c19840 (diff)
downloadbarebox-f95ec8a32dd811f314329da11ad0ae583233f43a.tar.gz
barebox-f95ec8a32dd811f314329da11ad0ae583233f43a.tar.xz
- Add functions to register image handlers for booting uImages
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/lib/armlinux.c48
-rw-r--r--arch/ppc/lib/ppclinux.c46
2 files changed, 64 insertions, 30 deletions
diff --git a/arch/arm/lib/armlinux.c b/arch/arm/lib/armlinux.c
index c66560f250..f5dd4854a5 100644
--- a/arch/arm/lib/armlinux.c
+++ b/arch/arm/lib/armlinux.c
@@ -28,6 +28,7 @@
#include <environment.h>
#include <image.h>
#include <zlib.h>
+#include <init.h>
#include <asm/byteorder.h>
#include <asm/global_data.h>
@@ -107,12 +108,13 @@ void __setup_serial_tag(struct tag **tmp);
# define SHOW_BOOT_PROGRESS(arg)
#endif
+static int arm_architecture = CONFIG_ARCH_NUMBER;
int
-do_bootm_linux(struct image_handle *os_handle, struct image_handle *initrd)
+do_bootm_linux(struct image_data *data)
{
void (*theKernel)(int zero, int arch, uint params);
- image_header_t *os_header = &os_handle->header;
+ image_header_t *os_header = &data->os->header;
const char *commandline = getenv ("bootargs");
if (os_header->ih_type == IH_TYPE_MULTI) {
@@ -120,11 +122,11 @@ do_bootm_linux(struct image_handle *os_handle, struct image_handle *initrd)
return -1;
}
- printf("commandline: %s\n", commandline);
+ printf("commandline: %s\n"
+ "arch_number: %d\n", commandline, arm_architecture);
theKernel = (void (*)(int, int, uint))ntohl((unsigned long)(os_header->ih_ep));
- /* FIXME: replace by pr_debug */
debug ("## Transferring control to Linux (at address %08lx) ...\n",
(ulong) theKernel);
@@ -140,25 +142,45 @@ do_bootm_linux(struct image_handle *os_handle, struct image_handle *initrd)
setup_videolfb_tag((gd_t *) gd);
setup_end_tag();
- if (relocate_image(os_handle, (void *)ntohl(os_header->ih_load)))
+ if (relocate_image(data->os, (void *)ntohl(os_header->ih_load)))
return -1;
/* we assume that the kernel is in place */
printf ("\nStarting kernel ...\n\n");
-#ifdef CONFIG_USB_DEVICE
- {
- extern void udc_disconnect(void);
- udc_disconnect();
- }
-#endif
-
cleanup_before_linux();
- theKernel (0, CONFIG_ARCH_NUMBER, CONFIG_BOOT_PARAMS);
+ theKernel (0, arm_architecture, CONFIG_BOOT_PARAMS);
return -1;
}
+static int image_handle_cmdline_parse(struct image_data *data, int opt,
+ char *optarg)
+{
+ switch (opt) {
+ case 'a':
+ arm_architecture = simple_strtoul(optarg, NULL, 0);
+ return 0;
+ default:
+ return 1;
+ }
+}
+
+static struct image_handler handler = {
+ .cmdline_options = "a:",
+ .cmdline_parse = image_handle_cmdline_parse,
+ .help_string = " -a <arch> use architecture number <arch>",
+
+ .bootm = do_bootm_linux,
+ .image_type = IH_OS_LINUX,
+};
+
+static int armlinux_register_image_handler(void)
+{
+ return register_image_handler(&handler);
+}
+
+late_initcall(armlinux_register_image_handler);
void
__setup_start_tag(void)
diff --git a/arch/ppc/lib/ppclinux.c b/arch/ppc/lib/ppclinux.c
index ba1a2fd8f9..7c944a3ea0 100644
--- a/arch/ppc/lib/ppclinux.c
+++ b/arch/ppc/lib/ppclinux.c
@@ -4,9 +4,11 @@
#include <command.h>
#include <watchdog.h>
#include <image.h>
+#include <init.h>
#include <environment.h>
#include <asm/global_data.h>
#include <asm/bitops.h>
+#include <boot.h>
#include <errno.h>
#include <fs.h>
@@ -16,8 +18,7 @@
extern bd_t *bd;
#define SHOW_BOOT_PROGRESS(x)
-int
-do_bootm_linux(struct image_handle *os_handle, struct image_handle *initrd_handle, const char *oftree)
+static int do_bootm_linux(struct image_data *idata)
{
ulong sp;
ulong initrd_end = 0;
@@ -31,7 +32,7 @@ do_bootm_linux(struct image_handle *os_handle, struct image_handle *initrd_handl
#ifdef CONFIG_OF_FLAT_TREE
char *of_flat_tree = NULL;
#endif
- image_header_t *os_header = &os_handle->header;
+ image_header_t *os_header = &idata->os->header;
image_header_t *initrd_header = NULL;
void *os_data = NULL;
void *initrd_data = NULL;
@@ -39,14 +40,14 @@ do_bootm_linux(struct image_handle *os_handle, struct image_handle *initrd_handl
struct image_handle *oftree_handle;
unsigned long os_len, initrd_len;
- if (initrd_handle)
- initrd_header = &initrd_handle->header;
+ if (idata->initrd)
+ initrd_header = &idata->initrd->header;
- printf("entering %s: os_header: %p initrd_header: %p oftree: %p\n",
- __FUNCTION__, os_header, initrd_header, oftree);
+ printf("entering %s: os_header: %p initrd_header: %p oftree: %s\n",
+ __FUNCTION__, os_header, initrd_header, idata->oftree);
if (os_header->ih_type == IH_TYPE_MULTI) {
- unsigned long *data = (unsigned long *)(os_handle->data);
+ unsigned long *data = (unsigned long *)(idata->os->data);
unsigned long len1 = 0, len2 = 0;
if (!*data) {
@@ -88,25 +89,25 @@ do_bootm_linux(struct image_handle *os_handle, struct image_handle *initrd_handl
initrd_len = len1;
}
} else {
- os_data = os_handle->data;
+ os_data = idata->os->data;
printf("set os_data to %p\n", os_data);
}
- if (initrd_handle)
- initrd_data = initrd_handle->data;
+ if (idata->initrd)
+ initrd_data = idata->initrd->data;
#ifdef CONFIG_OF_FLAT_TREE
- if (oftree) {
+ if (idata->oftree) {
/* The oftree can be given either as an uboot image or as a
* binary blob. First try to read it as an image.
*/
- oftree_handle = map_image(oftree, 1);
+ oftree_handle = map_image(idata->oftree, 1);
if (oftree_handle) {
of_data = oftree_handle->data;
} else {
- of_data = read_file(oftree, 0);
+ of_data = read_file(idata->oftree, 0);
if (!of_data) {
- printf("could not read %s: %s\n", oftree, errno_str());
+ printf("could not read %s: %s\n", idata->oftree, errno_str());
return -1;
}
}
@@ -201,7 +202,7 @@ do_bootm_linux(struct image_handle *os_handle, struct image_handle *initrd_handl
kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))ntohl(os_header->ih_ep); /* FIXME */
- if (relocate_image(os_handle, (void *)ntohl(os_header->ih_load)))
+ if (relocate_image(idata->os, (void *)ntohl(os_header->ih_load)))
return -1;
#if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500)
@@ -254,7 +255,6 @@ do_bootm_linux(struct image_handle *os_handle, struct image_handle *initrd_handl
*/
ft_setup(of_flat_tree, kbd, (long)initrd_data, initrd_end);
ft_cpu_setup(of_flat_tree, kbd);
- ft_dump_blob(of_flat_tree);
(*kernel) ((bd_t *)of_flat_tree, (ulong)kernel, 0, 0, 0);
#endif
@@ -264,3 +264,15 @@ do_bootm_linux(struct image_handle *os_handle, struct image_handle *initrd_handl
return -1;
}
+static struct image_handler handler = {
+ .bootm = do_bootm_linux,
+ .image_type = IH_OS_LINUX,
+};
+
+static int ppclinux_register_image_handler(void)
+{
+ return register_image_handler(&handler);
+}
+
+late_initcall(ppclinux_register_image_handler);
+