blob: 54f69a92c79a9e96fb82daedc6228f9c6e575780 [file] [log] [blame]
Wolfgang Denk97caf672006-03-12 02:12:27 +01001/*
Mike Frysinger94bae5c2008-03-30 15:46:13 -04002 * U-boot - bootm.c - misc boot helper functions
Wolfgang Denk97caf672006-03-12 02:12:27 +01003 *
Mike Frysinger94bae5c2008-03-30 15:46:13 -04004 * Copyright (c) 2005-2008 Analog Devices Inc.
Wolfgang Denk97caf672006-03-12 02:12:27 +01005 *
6 * (C) Copyright 2000-2004
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 *
Mike Frysinger94bae5c2008-03-30 15:46:13 -04009 * Licensed under the GPL-2 or later.
Wolfgang Denk97caf672006-03-12 02:12:27 +010010 */
11
Wolfgang Denk97caf672006-03-12 02:12:27 +010012#include <common.h>
13#include <command.h>
14#include <image.h>
Mike Frysinger94bae5c2008-03-30 15:46:13 -040015#include <asm/blackfin.h>
Wolfgang Denk97caf672006-03-12 02:12:27 +010016
Mike Frysinger94bae5c2008-03-30 15:46:13 -040017extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
Wolfgang Denk97caf672006-03-12 02:12:27 +010018
19#ifdef SHARED_RESOURCES
Aubrey.Li9da597f2007-03-09 13:38:44 +080020extern void swap_to(int device_id);
Wolfgang Denk97caf672006-03-12 02:12:27 +010021#endif
22
Mike Frysinger94bae5c2008-03-30 15:46:13 -040023static char *make_command_line(void)
24{
25 char *dest = (char *)CMD_LINE_ADDR;
26 char *bootargs = getenv("bootargs");
27
28 if (bootargs == NULL)
29 return NULL;
30
31 strncpy(dest, bootargs, 0x1000);
32 dest[0xfff] = 0;
33 return dest;
34}
Wolfgang Denk97caf672006-03-12 02:12:27 +010035
Mike Frysinger94bae5c2008-03-30 15:46:13 -040036void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
Marian Balakowicz61fde552008-02-27 11:01:04 +010037 bootm_headers_t *images)
Wolfgang Denk97caf672006-03-12 02:12:27 +010038{
Marian Balakowiczdbdd16a2008-02-04 08:28:09 +010039 int (*appl) (char *cmdline);
40 char *cmdline;
41 ulong ep = 0;
Wolfgang Denk97caf672006-03-12 02:12:27 +010042
43#ifdef SHARED_RESOURCES
44 swap_to(FLASH);
45#endif
46
Marian Balakowiczdbdd16a2008-02-04 08:28:09 +010047 /* find kernel entry point */
48 if (images->legacy_hdr_valid) {
Marian Balakowiczab00e022008-04-11 11:07:49 +020049 ep = image_get_ep (&images->legacy_hdr_os_copy);
Marian Balakowiczdbdd16a2008-02-04 08:28:09 +010050#if defined(CONFIG_FIT)
51 } else if (images->fit_uname_os) {
Marian Balakowiczdf8ff332008-03-12 10:33:00 +010052 int ret = fit_image_get_entry (images->fit_hdr_os,
53 images->fit_noffset_os, &ep);
54 if (ret) {
55 puts ("Can't get entry point property!\n");
56 goto error;
57 }
Marian Balakowiczdbdd16a2008-02-04 08:28:09 +010058#endif
59 } else {
60 puts ("Could not find kernel entry point!\n");
Marian Balakowiczdf8ff332008-03-12 10:33:00 +010061 goto error;
Marian Balakowiczdbdd16a2008-02-04 08:28:09 +010062 }
63 appl = (int (*)(char *))ep;
64
Wolfgang Denk97caf672006-03-12 02:12:27 +010065 printf("Starting Kernel at = %x\n", appl);
66 cmdline = make_command_line();
Mike Frysinger94bae5c2008-03-30 15:46:13 -040067 icache_disable();
68 dcache_disable();
Aubrey.Li9da597f2007-03-09 13:38:44 +080069 (*appl) (cmdline);
Marian Balakowiczdf8ff332008-03-12 10:33:00 +010070 /* does not return */
71 return;
72
Mike Frysinger94bae5c2008-03-30 15:46:13 -040073 error:
Kumar Gala026e4ac2008-08-11 09:20:53 -050074 do_reset (cmdtp, flag, argc, argv);
Wolfgang Denk97caf672006-03-12 02:12:27 +010075}