Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 1 | /* |
Mike Frysinger | 81b799a | 2008-08-07 15:27:52 -0400 | [diff] [blame] | 2 | * U-boot - boot.c - misc boot helper functions |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 3 | * |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 4 | * Copyright (c) 2005-2008 Analog Devices Inc. |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 5 | * |
| 6 | * (C) Copyright 2000-2004 |
| 7 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 8 | * |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 9 | * Licensed under the GPL-2 or later. |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 10 | */ |
| 11 | |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 12 | #include <common.h> |
| 13 | #include <command.h> |
| 14 | #include <image.h> |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 15 | #include <asm/blackfin.h> |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 16 | |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 17 | #ifdef SHARED_RESOURCES |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 18 | extern void swap_to(int device_id); |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 19 | #endif |
| 20 | |
Michael Hennerich | 5fc564e | 2009-08-07 02:47:54 +0000 | [diff] [blame] | 21 | #ifdef CONFIG_VIDEO |
| 22 | extern void video_stop(void); |
| 23 | #endif |
| 24 | |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 25 | static char *make_command_line(void) |
| 26 | { |
Mike Frysinger | 36cd52a | 2008-08-07 15:24:59 -0400 | [diff] [blame] | 27 | char *dest = (char *)CONFIG_LINUX_CMDLINE_ADDR; |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 28 | char *bootargs = getenv("bootargs"); |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 29 | |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 30 | if (bootargs == NULL) |
| 31 | return NULL; |
| 32 | |
Mike Frysinger | 36cd52a | 2008-08-07 15:24:59 -0400 | [diff] [blame] | 33 | strncpy(dest, bootargs, CONFIG_LINUX_CMDLINE_SIZE); |
| 34 | dest[CONFIG_LINUX_CMDLINE_SIZE - 1] = 0; |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 35 | return dest; |
| 36 | } |
| 37 | |
Mike Frysinger | b1e9435 | 2008-10-11 21:44:00 -0400 | [diff] [blame] | 38 | extern ulong bfin_poweron_retx; |
| 39 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 40 | int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images) |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 41 | { |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 42 | int (*appl) (char *cmdline); |
| 43 | char *cmdline; |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 44 | |
Simon Glass | 7af26b1 | 2013-07-10 23:08:09 -0700 | [diff] [blame] | 45 | if (flag & BOOTM_STATE_OS_PREP) |
| 46 | return 0; |
Kumar Gala | 49c3a86 | 2008-10-21 17:25:45 -0500 | [diff] [blame] | 47 | if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) |
| 48 | return 1; |
| 49 | |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 50 | #ifdef SHARED_RESOURCES |
| 51 | swap_to(FLASH); |
| 52 | #endif |
| 53 | |
Michael Hennerich | 5fc564e | 2009-08-07 02:47:54 +0000 | [diff] [blame] | 54 | #ifdef CONFIG_VIDEO |
| 55 | /* maybe this should be standardized and moved to bootm ... */ |
| 56 | video_stop(); |
| 57 | #endif |
| 58 | |
Kumar Gala | c160a95 | 2008-08-15 08:24:36 -0500 | [diff] [blame] | 59 | appl = (int (*)(char *))images->ep; |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 60 | |
Mike Frysinger | fe033ad | 2008-10-12 06:02:55 -0400 | [diff] [blame] | 61 | printf("Starting Kernel at = %p\n", appl); |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 62 | cmdline = make_command_line(); |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 63 | icache_disable(); |
| 64 | dcache_disable(); |
Mike Frysinger | b1e9435 | 2008-10-11 21:44:00 -0400 | [diff] [blame] | 65 | asm __volatile__( |
| 66 | "RETX = %[retx];" |
| 67 | "CALL (%0);" |
| 68 | : |
| 69 | : "p"(appl), "q0"(cmdline), [retx] "d"(bfin_poweron_retx) |
| 70 | ); |
Marian Balakowicz | cd7c596 | 2008-03-12 10:33:00 +0100 | [diff] [blame] | 71 | /* does not return */ |
Jean-Christophe PLAGNIOL-VILLARD | a3a08c0 | 2008-09-10 22:48:09 +0200 | [diff] [blame] | 72 | |
Kumar Gala | 40d7e99 | 2008-08-15 08:24:45 -0500 | [diff] [blame] | 73 | return 1; |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 74 | } |