blob: 768a8826b55c1ac94814f9a56b7033efddf9bd9d [file] [log] [blame]
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01001/*
Mike Frysinger81b799a2008-08-07 15:27:52 -04002 * U-boot - boot.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
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010017#ifdef SHARED_RESOURCES
Aubrey.Li3f0606a2007-03-09 13:38:44 +080018extern void swap_to(int device_id);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010019#endif
20
Michael Hennerich5fc564e2009-08-07 02:47:54 +000021#ifdef CONFIG_VIDEO
22extern void video_stop(void);
23#endif
24
Mike Frysinger9171fc82008-03-30 15:46:13 -040025static char *make_command_line(void)
26{
Mike Frysinger36cd52a2008-08-07 15:24:59 -040027 char *dest = (char *)CONFIG_LINUX_CMDLINE_ADDR;
Mike Frysinger9171fc82008-03-30 15:46:13 -040028 char *bootargs = getenv("bootargs");
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010029
Mike Frysinger9171fc82008-03-30 15:46:13 -040030 if (bootargs == NULL)
31 return NULL;
32
Mike Frysinger36cd52a2008-08-07 15:24:59 -040033 strncpy(dest, bootargs, CONFIG_LINUX_CMDLINE_SIZE);
34 dest[CONFIG_LINUX_CMDLINE_SIZE - 1] = 0;
Mike Frysinger9171fc82008-03-30 15:46:13 -040035 return dest;
36}
37
Mike Frysingerb1e94352008-10-11 21:44:00 -040038extern ulong bfin_poweron_retx;
39
Wolfgang Denk54841ab2010-06-28 22:00:46 +020040int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images)
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010041{
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010042 int (*appl) (char *cmdline);
43 char *cmdline;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010044
Kumar Gala49c3a862008-10-21 17:25:45 -050045 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
46 return 1;
47
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010048#ifdef SHARED_RESOURCES
49 swap_to(FLASH);
50#endif
51
Michael Hennerich5fc564e2009-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 Galac160a952008-08-15 08:24:36 -050057 appl = (int (*)(char *))images->ep;
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010058
Mike Frysingerfe033ad2008-10-12 06:02:55 -040059 printf("Starting Kernel at = %p\n", appl);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010060 cmdline = make_command_line();
Mike Frysinger9171fc82008-03-30 15:46:13 -040061 icache_disable();
62 dcache_disable();
Mike Frysingerb1e94352008-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 Balakowiczcd7c5962008-03-12 10:33:00 +010069 /* does not return */
Jean-Christophe PLAGNIOL-VILLARDa3a08c02008-09-10 22:48:09 +020070
Kumar Gala40d7e992008-08-15 08:24:45 -050071 return 1;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010072}