blob: 537be2bd1e91928b5fc580a1a5a038208e0a2164 [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
Mike Frysinger9171fc82008-03-30 15:46:13 -040021static char *make_command_line(void)
22{
Mike Frysinger36cd52a2008-08-07 15:24:59 -040023 char *dest = (char *)CONFIG_LINUX_CMDLINE_ADDR;
Mike Frysinger9171fc82008-03-30 15:46:13 -040024 char *bootargs = getenv("bootargs");
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010025
Mike Frysinger9171fc82008-03-30 15:46:13 -040026 if (bootargs == NULL)
27 return NULL;
28
Mike Frysinger36cd52a2008-08-07 15:24:59 -040029 strncpy(dest, bootargs, CONFIG_LINUX_CMDLINE_SIZE);
30 dest[CONFIG_LINUX_CMDLINE_SIZE - 1] = 0;
Mike Frysinger9171fc82008-03-30 15:46:13 -040031 return dest;
32}
33
Mike Frysingerb1e94352008-10-11 21:44:00 -040034extern ulong bfin_poweron_retx;
35
Kumar Gala40d7e992008-08-15 08:24:45 -050036int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010037{
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010038 int (*appl) (char *cmdline);
39 char *cmdline;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010040
Kumar Gala49c3a862008-10-21 17:25:45 -050041 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
42 return 1;
43
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010044#ifdef SHARED_RESOURCES
45 swap_to(FLASH);
46#endif
47
Kumar Galac160a952008-08-15 08:24:36 -050048 appl = (int (*)(char *))images->ep;
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010049
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010050 printf("Starting Kernel at = %x\n", appl);
51 cmdline = make_command_line();
Mike Frysinger9171fc82008-03-30 15:46:13 -040052 icache_disable();
53 dcache_disable();
Mike Frysingerb1e94352008-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 Balakowiczcd7c5962008-03-12 10:33:00 +010060 /* does not return */
Jean-Christophe PLAGNIOL-VILLARDa3a08c02008-09-10 22:48:09 +020061
Kumar Gala40d7e992008-08-15 08:24:45 -050062 return 1;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010063}