blob: bea11ed6dd36f997aa55bffb0c38d2258e79e693 [file] [log] [blame]
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01001/*
Mike Frysinger9171fc82008-03-30 15:46:13 -04002 * U-boot - bootm.c - misc boot helper functions
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01003 *
Mike Frysinger9171fc82008-03-30 15:46:13 -04004 * Copyright (c) 2005-2008 Analog Devices Inc.
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01005 *
6 * (C) Copyright 2000-2004
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 *
Mike Frysinger9171fc82008-03-30 15:46:13 -04009 * Licensed under the GPL-2 or later.
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010010 */
11
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010012#include <common.h>
13#include <command.h>
14#include <image.h>
Mike Frysinger9171fc82008-03-30 15:46:13 -040015#include <asm/blackfin.h>
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010016
Mike Frysinger9171fc82008-03-30 15:46:13 -040017extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010018
19#ifdef SHARED_RESOURCES
Aubrey.Li3f0606a2007-03-09 13:38:44 +080020extern void swap_to(int device_id);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010021#endif
22
Mike Frysinger9171fc82008-03-30 15:46:13 -040023static char *make_command_line(void)
24{
25 char *dest = (char *)CMD_LINE_ADDR;
26 char *bootargs = getenv("bootargs");
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010027
Mike Frysinger9171fc82008-03-30 15:46:13 -040028 if (bootargs == NULL)
29 return NULL;
30
31 strncpy(dest, bootargs, 0x1000);
32 dest[0xfff] = 0;
33 return dest;
34}
35
36void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
Marian Balakowicz8a5ea3e2008-02-27 11:01:04 +010037 bootm_headers_t *images)
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010038{
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010039 int (*appl) (char *cmdline);
40 char *cmdline;
41 ulong ep = 0;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010042
Kumar Gala75fa0022008-02-27 21:51:51 -060043 if (!images->autostart)
Mike Frysinger9171fc82008-03-30 15:46:13 -040044 return;
Kumar Gala75fa0022008-02-27 21:51:51 -060045
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010046#ifdef SHARED_RESOURCES
47 swap_to(FLASH);
48#endif
49
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010050 /* find kernel entry point */
51 if (images->legacy_hdr_valid) {
52 ep = image_get_ep (images->legacy_hdr_os);
53#if defined(CONFIG_FIT)
54 } else if (images->fit_uname_os) {
Marian Balakowiczcd7c5962008-03-12 10:33:00 +010055 int ret = fit_image_get_entry (images->fit_hdr_os,
56 images->fit_noffset_os, &ep);
57 if (ret) {
58 puts ("Can't get entry point property!\n");
59 goto error;
60 }
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010061#endif
62 } else {
63 puts ("Could not find kernel entry point!\n");
Marian Balakowiczcd7c5962008-03-12 10:33:00 +010064 goto error;
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010065 }
66 appl = (int (*)(char *))ep;
67
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010068 printf("Starting Kernel at = %x\n", appl);
69 cmdline = make_command_line();
Mike Frysinger9171fc82008-03-30 15:46:13 -040070 icache_disable();
71 dcache_disable();
Aubrey.Li3f0606a2007-03-09 13:38:44 +080072 (*appl) (cmdline);
Marian Balakowiczcd7c5962008-03-12 10:33:00 +010073 /* does not return */
74 return;
75
Mike Frysinger9171fc82008-03-30 15:46:13 -040076 error:
Marian Balakowiczcd7c5962008-03-12 10:33:00 +010077 if (images->autostart)
78 do_reset (cmdtp, flag, argc, argv);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010079}