blob: 768a8826b55c1ac94814f9a56b7033efddf9bd9d [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
Michael Hennerichae712d82009-08-07 02:47:54 +000021#ifdef CONFIG_VIDEO
22extern void video_stop(void);
23#endif
24
Mike Frysinger94bae5c2008-03-30 15:46:13 -040025static char *make_command_line(void)
26{
Mike Frysingerc94fde22008-08-07 15:24:59 -040027 char *dest = (char *)CONFIG_LINUX_CMDLINE_ADDR;
Mike Frysinger94bae5c2008-03-30 15:46:13 -040028 char *bootargs = getenv("bootargs");
29
30 if (bootargs == NULL)
31 return NULL;
32
Mike Frysingerc94fde22008-08-07 15:24:59 -040033 strncpy(dest, bootargs, CONFIG_LINUX_CMDLINE_SIZE);
34 dest[CONFIG_LINUX_CMDLINE_SIZE - 1] = 0;
Mike Frysinger94bae5c2008-03-30 15:46:13 -040035 return dest;
36}
Wolfgang Denk97caf672006-03-12 02:12:27 +010037
Mike Frysingerc396f3b2008-10-11 21:44:00 -040038extern ulong bfin_poweron_retx;
39
Wolfgang Denk6262d0212010-06-28 22:00:46 +020040int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images)
Wolfgang Denk97caf672006-03-12 02:12:27 +010041{
Marian Balakowiczdbdd16a2008-02-04 08:28:09 +010042 int (*appl) (char *cmdline);
43 char *cmdline;
Wolfgang Denk97caf672006-03-12 02:12:27 +010044
Kumar Gala18178bc2008-10-21 17:25:45 -050045 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
46 return 1;
47
Wolfgang Denk97caf672006-03-12 02:12:27 +010048#ifdef SHARED_RESOURCES
49 swap_to(FLASH);
50#endif
51
Michael Hennerichae712d82009-08-07 02:47:54 +000052#ifdef CONFIG_VIDEO
53 /* maybe this should be standardized and moved to bootm ... */
54 video_stop();
55#endif
56
Kumar Gala93467bc2008-08-15 08:24:36 -050057 appl = (int (*)(char *))images->ep;
Marian Balakowiczdbdd16a2008-02-04 08:28:09 +010058
Mike Frysinger9d016142008-10-12 06:02:55 -040059 printf("Starting Kernel at = %p\n", appl);
Wolfgang Denk97caf672006-03-12 02:12:27 +010060 cmdline = make_command_line();
Mike Frysinger94bae5c2008-03-30 15:46:13 -040061 icache_disable();
62 dcache_disable();
Mike Frysingerc396f3b2008-10-11 21:44:00 -040063 asm __volatile__(
64 "RETX = %[retx];"
65 "CALL (%0);"
66 :
67 : "p"(appl), "q0"(cmdline), [retx] "d"(bfin_poweron_retx)
68 );
Marian Balakowiczdf8ff332008-03-12 10:33:00 +010069 /* does not return */
Jean-Christophe PLAGNIOL-VILLARD7ed7a272008-09-10 22:48:09 +020070
Kumar Gala48626aa2008-08-15 08:24:45 -050071 return 1;
Wolfgang Denk97caf672006-03-12 02:12:27 +010072}