Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2008 |
| 3 | * Jean-Christophe PLAGNIOL-VILLARD <jcplagniol@jcrosoft.com> |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <command.h> |
| 26 | #include <image.h> |
| 27 | #include <asm/byteorder.h> |
| 28 | #include <asm/addrspace.h> |
| 29 | |
| 30 | DECLARE_GLOBAL_DATA_PTR; |
| 31 | |
Daniel Schwierzeck | 731c402 | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 32 | int do_bootm_linux(int flag, int argc, char * const argv[], |
| 33 | bootm_headers_t *images) |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 34 | { |
Daniel Schwierzeck | 731c402 | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 35 | void (*theKernel) (int, char **, char **, int *); |
| 36 | char *bootargs = getenv("bootargs"); |
| 37 | char *start; |
| 38 | uint len; |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 39 | |
| 40 | /* find kernel entry point */ |
| 41 | theKernel = (void (*)(int, char **, char **, int *))images->ep; |
| 42 | |
Simon Glass | 0169e6b | 2012-02-13 13:51:18 +0000 | [diff] [blame] | 43 | bootstage_mark(BOOTSTAGE_ID_RUN_OS); |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 44 | |
Daniel Schwierzeck | 731c402 | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 45 | debug("## Transferring control to Linux (at address %08lx) ...\n", |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 46 | (ulong) theKernel); |
| 47 | |
| 48 | gd->bd->bi_boot_params = gd->bd->bi_memstart + (16 << 20) - 256; |
Daniel Schwierzeck | 731c402 | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 49 | debug("%-12s= 0x%08lX\n", "boot_params", (ulong)gd->bd->bi_boot_params); |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 50 | |
| 51 | /* set Magic */ |
| 52 | *(int32_t *)(gd->bd->bi_boot_params - 4) = 0x12345678; |
| 53 | /* set ram_size */ |
| 54 | *(int32_t *)(gd->bd->bi_boot_params - 8) = gd->ram_size; |
| 55 | |
Daniel Schwierzeck | 731c402 | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 56 | start = (char *)gd->bd->bi_boot_params; |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 57 | |
| 58 | len = strlen(bootargs); |
| 59 | |
| 60 | strncpy(start, bootargs, len + 1); |
| 61 | |
| 62 | start += len; |
| 63 | |
| 64 | len = images->rd_end - images->rd_start; |
| 65 | if (len > 0) { |
Daniel Schwierzeck | 731c402 | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 66 | start += sprintf(start, " rd_start=0x%08X rd_size=0x%0X", |
| 67 | (uint) UNCACHED_SDRAM(images->rd_start), |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 68 | (uint) len); |
| 69 | } |
| 70 | |
| 71 | /* we assume that the kernel is in place */ |
Daniel Schwierzeck | 731c402 | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 72 | printf("\nStarting kernel ...\n\n"); |
| 73 | |
| 74 | theKernel(0, NULL, NULL, 0); |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 75 | |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 76 | /* does not return */ |
| 77 | return 1; |
| 78 | } |