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 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame^] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <command.h> |
| 10 | #include <image.h> |
| 11 | #include <asm/byteorder.h> |
| 12 | #include <asm/addrspace.h> |
| 13 | |
| 14 | DECLARE_GLOBAL_DATA_PTR; |
| 15 | |
Daniel Schwierzeck | 731c402 | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 16 | int do_bootm_linux(int flag, int argc, char * const argv[], |
| 17 | bootm_headers_t *images) |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 18 | { |
Daniel Schwierzeck | 731c402 | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 19 | void (*theKernel) (int, char **, char **, int *); |
| 20 | char *bootargs = getenv("bootargs"); |
| 21 | char *start; |
| 22 | uint len; |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 23 | |
| 24 | /* find kernel entry point */ |
| 25 | theKernel = (void (*)(int, char **, char **, int *))images->ep; |
| 26 | |
Simon Glass | 0169e6b | 2012-02-13 13:51:18 +0000 | [diff] [blame] | 27 | bootstage_mark(BOOTSTAGE_ID_RUN_OS); |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 28 | |
Daniel Schwierzeck | 731c402 | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 29 | debug("## Transferring control to Linux (at address %08lx) ...\n", |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 30 | (ulong) theKernel); |
| 31 | |
| 32 | gd->bd->bi_boot_params = gd->bd->bi_memstart + (16 << 20) - 256; |
Daniel Schwierzeck | 731c402 | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 33 | 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] | 34 | |
| 35 | /* set Magic */ |
| 36 | *(int32_t *)(gd->bd->bi_boot_params - 4) = 0x12345678; |
| 37 | /* set ram_size */ |
| 38 | *(int32_t *)(gd->bd->bi_boot_params - 8) = gd->ram_size; |
| 39 | |
Daniel Schwierzeck | 731c402 | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 40 | start = (char *)gd->bd->bi_boot_params; |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 41 | |
| 42 | len = strlen(bootargs); |
| 43 | |
| 44 | strncpy(start, bootargs, len + 1); |
| 45 | |
| 46 | start += len; |
| 47 | |
| 48 | len = images->rd_end - images->rd_start; |
| 49 | if (len > 0) { |
Daniel Schwierzeck | 731c402 | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 50 | start += sprintf(start, " rd_start=0x%08X rd_size=0x%0X", |
| 51 | (uint) UNCACHED_SDRAM(images->rd_start), |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 52 | (uint) len); |
| 53 | } |
| 54 | |
| 55 | /* we assume that the kernel is in place */ |
Daniel Schwierzeck | 731c402 | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 56 | printf("\nStarting kernel ...\n\n"); |
| 57 | |
| 58 | theKernel(0, NULL, NULL, 0); |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 59 | |
Jean-Christophe PLAGNIOL-VILLARD | edc2cdc | 2008-09-08 20:54:39 +0200 | [diff] [blame] | 60 | /* does not return */ |
| 61 | return 1; |
| 62 | } |