blob: 951d5b0d02732cfadaf8a741016d5a289514bf39 [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
Mike Frysingerc396f3b2008-10-11 21:44:00 -040034extern ulong bfin_poweron_retx;
35
Kumar Gala48626aa2008-08-15 08:24:45 -050036int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
Wolfgang Denk97caf672006-03-12 02:12:27 +010037{
Marian Balakowiczdbdd16a2008-02-04 08:28:09 +010038 int (*appl) (char *cmdline);
39 char *cmdline;
Wolfgang Denk97caf672006-03-12 02:12:27 +010040
Kumar Gala18178bc2008-10-21 17:25:45 -050041 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
42 return 1;
43
Wolfgang Denk97caf672006-03-12 02:12:27 +010044#ifdef SHARED_RESOURCES
45 swap_to(FLASH);
46#endif
47
Kumar Gala93467bc2008-08-15 08:24:36 -050048 appl = (int (*)(char *))images->ep;
Marian Balakowiczdbdd16a2008-02-04 08:28:09 +010049
Mike Frysinger9d016142008-10-12 06:02:55 -040050 printf("Starting Kernel at = %p\n", appl);
Wolfgang Denk97caf672006-03-12 02:12:27 +010051 cmdline = make_command_line();
Mike Frysinger94bae5c2008-03-30 15:46:13 -040052 icache_disable();
53 dcache_disable();
Mike Frysingerc396f3b2008-10-11 21:44:00 -040054 asm __volatile__(
55 "RETX = %[retx];"
56 "CALL (%0);"
57 :
58 : "p"(appl), "q0"(cmdline), [retx] "d"(bfin_poweron_retx)
59 );
Marian Balakowiczdf8ff332008-03-12 10:33:00 +010060 /* does not return */
Jean-Christophe PLAGNIOL-VILLARD7ed7a272008-09-10 22:48:09 +020061
Kumar Gala48626aa2008-08-15 08:24:45 -050062 return 1;
Wolfgang Denk97caf672006-03-12 02:12:27 +010063}