blob: fd4c82e9c80871714d5cb5cd2cd926d76030fb58 [file] [log] [blame]
Wolfgang Denk97caf672006-03-12 02:12:27 +01001/*
Bin Meng75574052016-02-05 19:30:11 -08002 * 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
Simon Glassf059d0a2013-07-10 23:08:09 -070045 if (flag & BOOTM_STATE_OS_PREP)
46 return 0;
Kumar Gala18178bc2008-10-21 17:25:45 -050047 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
48 return 1;
49
Wolfgang Denk97caf672006-03-12 02:12:27 +010050#ifdef SHARED_RESOURCES
51 swap_to(FLASH);
52#endif
53
Michael Hennerichae712d82009-08-07 02:47:54 +000054#ifdef CONFIG_VIDEO
55 /* maybe this should be standardized and moved to bootm ... */
56 video_stop();
57#endif
58
Kumar Gala93467bc2008-08-15 08:24:36 -050059 appl = (int (*)(char *))images->ep;
Marian Balakowiczdbdd16a2008-02-04 08:28:09 +010060
Mike Frysinger9d016142008-10-12 06:02:55 -040061 printf("Starting Kernel at = %p\n", appl);
Wolfgang Denk97caf672006-03-12 02:12:27 +010062 cmdline = make_command_line();
Mike Frysinger94bae5c2008-03-30 15:46:13 -040063 icache_disable();
64 dcache_disable();
Mike Frysingerc396f3b2008-10-11 21:44:00 -040065 asm __volatile__(
66 "RETX = %[retx];"
67 "CALL (%0);"
68 :
69 : "p"(appl), "q0"(cmdline), [retx] "d"(bfin_poweron_retx)
70 );
Marian Balakowiczdf8ff332008-03-12 10:33:00 +010071 /* does not return */
Jean-Christophe PLAGNIOL-VILLARD7ed7a272008-09-10 22:48:09 +020072
Kumar Gala48626aa2008-08-15 08:24:45 -050073 return 1;
Wolfgang Denk97caf672006-03-12 02:12:27 +010074}