blob: 47e27de3057cc67bad7091e18d934364080237cf [file] [log] [blame]
Wolfgang Denk97caf672006-03-12 02:12:27 +01001/*
Mike Frysinger8cf07522008-08-07 15:27:52 -04002 * U-boot - boot.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
Wolfgang Denk97caf672006-03-12 02:12:27 +010017#ifdef SHARED_RESOURCES
Aubrey.Li9da597f2007-03-09 13:38:44 +080018extern void swap_to(int device_id);
Wolfgang Denk97caf672006-03-12 02:12:27 +010019#endif
20
Mike Frysinger94bae5c2008-03-30 15:46:13 -040021static char *make_command_line(void)
22{
Mike Frysingerc94fde22008-08-07 15:24:59 -040023 char *dest = (char *)CONFIG_LINUX_CMDLINE_ADDR;
Mike Frysinger94bae5c2008-03-30 15:46:13 -040024 char *bootargs = getenv("bootargs");
25
26 if (bootargs == NULL)
27 return NULL;
28
Mike Frysingerc94fde22008-08-07 15:24:59 -040029 strncpy(dest, bootargs, CONFIG_LINUX_CMDLINE_SIZE);
30 dest[CONFIG_LINUX_CMDLINE_SIZE - 1] = 0;
Mike Frysinger94bae5c2008-03-30 15:46:13 -040031 return dest;
32}
Wolfgang Denk97caf672006-03-12 02:12:27 +010033
Kumar Gala48626aa2008-08-15 08:24:45 -050034int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
Wolfgang Denk97caf672006-03-12 02:12:27 +010035{
Marian Balakowiczdbdd16a2008-02-04 08:28:09 +010036 int (*appl) (char *cmdline);
37 char *cmdline;
Wolfgang Denk97caf672006-03-12 02:12:27 +010038
Kumar Gala18178bc2008-10-21 17:25:45 -050039 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
40 return 1;
41
Wolfgang Denk97caf672006-03-12 02:12:27 +010042#ifdef SHARED_RESOURCES
43 swap_to(FLASH);
44#endif
45
Kumar Gala93467bc2008-08-15 08:24:36 -050046 appl = (int (*)(char *))images->ep;
Marian Balakowiczdbdd16a2008-02-04 08:28:09 +010047
Wolfgang Denk97caf672006-03-12 02:12:27 +010048 printf("Starting Kernel at = %x\n", appl);
49 cmdline = make_command_line();
Mike Frysinger94bae5c2008-03-30 15:46:13 -040050 icache_disable();
51 dcache_disable();
Aubrey.Li9da597f2007-03-09 13:38:44 +080052 (*appl) (cmdline);
Marian Balakowiczdf8ff332008-03-12 10:33:00 +010053 /* does not return */
Jean-Christophe PLAGNIOL-VILLARD7ed7a272008-09-10 22:48:09 +020054
Kumar Gala48626aa2008-08-15 08:24:45 -050055 return 1;
Wolfgang Denk97caf672006-03-12 02:12:27 +010056}