Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 1 | /* |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 2 | * U-boot - bootm.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 | |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 17 | extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 18 | |
| 19 | #ifdef SHARED_RESOURCES |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 20 | extern void swap_to(int device_id); |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 21 | #endif |
| 22 | |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 23 | static char *make_command_line(void) |
| 24 | { |
| 25 | char *dest = (char *)CMD_LINE_ADDR; |
| 26 | char *bootargs = getenv("bootargs"); |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 27 | |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 28 | if (bootargs == NULL) |
| 29 | return NULL; |
| 30 | |
| 31 | strncpy(dest, bootargs, 0x1000); |
| 32 | dest[0xfff] = 0; |
| 33 | return dest; |
| 34 | } |
| 35 | |
| 36 | void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 37 | bootm_headers_t *images) |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 38 | { |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 39 | int (*appl) (char *cmdline); |
| 40 | char *cmdline; |
| 41 | ulong ep = 0; |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 42 | |
Kumar Gala | 75fa002 | 2008-02-27 21:51:51 -0600 | [diff] [blame] | 43 | if (!images->autostart) |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 44 | return; |
Kumar Gala | 75fa002 | 2008-02-27 21:51:51 -0600 | [diff] [blame] | 45 | |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 46 | #ifdef SHARED_RESOURCES |
| 47 | swap_to(FLASH); |
| 48 | #endif |
| 49 | |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 50 | /* find kernel entry point */ |
| 51 | if (images->legacy_hdr_valid) { |
Marian Balakowicz | cb1c489 | 2008-04-11 11:07:49 +0200 | [diff] [blame] | 52 | ep = image_get_ep (&images->legacy_hdr_os_copy); |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 53 | #if defined(CONFIG_FIT) |
| 54 | } else if (images->fit_uname_os) { |
Marian Balakowicz | cd7c596 | 2008-03-12 10:33:00 +0100 | [diff] [blame] | 55 | int ret = fit_image_get_entry (images->fit_hdr_os, |
| 56 | images->fit_noffset_os, &ep); |
| 57 | if (ret) { |
| 58 | puts ("Can't get entry point property!\n"); |
| 59 | goto error; |
| 60 | } |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 61 | #endif |
| 62 | } else { |
| 63 | puts ("Could not find kernel entry point!\n"); |
Marian Balakowicz | cd7c596 | 2008-03-12 10:33:00 +0100 | [diff] [blame] | 64 | goto error; |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 65 | } |
| 66 | appl = (int (*)(char *))ep; |
| 67 | |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 68 | printf("Starting Kernel at = %x\n", appl); |
| 69 | cmdline = make_command_line(); |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 70 | icache_disable(); |
| 71 | dcache_disable(); |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 72 | (*appl) (cmdline); |
Marian Balakowicz | cd7c596 | 2008-03-12 10:33:00 +0100 | [diff] [blame] | 73 | /* does not return */ |
| 74 | return; |
| 75 | |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 76 | error: |
Marian Balakowicz | cd7c596 | 2008-03-12 10:33:00 +0100 | [diff] [blame] | 77 | if (images->autostart) |
| 78 | do_reset (cmdtp, flag, argc, argv); |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 79 | } |