blob: 910ab73638b0d63d19a31224ff9fd672fef23d1a [file] [log] [blame]
Jean-Christophe PLAGNIOL-VILLARD1de1fa42008-09-08 20:54:39 +02001/*
2 * (C) Copyright 2008
3 * Jean-Christophe PLAGNIOL-VILLARD <jcplagniol@jcrosoft.com>
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Jean-Christophe PLAGNIOL-VILLARD1de1fa42008-09-08 20:54:39 +02006 */
7
8#include <common.h>
9#include <command.h>
10#include <image.h>
11#include <asm/byteorder.h>
12#include <asm/addrspace.h>
13
14DECLARE_GLOBAL_DATA_PTR;
15
Daniel Schwierzecked530102012-06-03 23:46:04 +020016int do_bootm_linux(int flag, int argc, char * const argv[],
17 bootm_headers_t *images)
Jean-Christophe PLAGNIOL-VILLARD1de1fa42008-09-08 20:54:39 +020018{
Daniel Schwierzecked530102012-06-03 23:46:04 +020019 void (*theKernel) (int, char **, char **, int *);
20 char *bootargs = getenv("bootargs");
21 char *start;
22 uint len;
Jean-Christophe PLAGNIOL-VILLARD1de1fa42008-09-08 20:54:39 +020023
24 /* find kernel entry point */
25 theKernel = (void (*)(int, char **, char **, int *))images->ep;
26
Simon Glass770605e2012-02-13 13:51:18 +000027 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
Jean-Christophe PLAGNIOL-VILLARD1de1fa42008-09-08 20:54:39 +020028
Daniel Schwierzecked530102012-06-03 23:46:04 +020029 debug("## Transferring control to Linux (at address %08lx) ...\n",
Jean-Christophe PLAGNIOL-VILLARD1de1fa42008-09-08 20:54:39 +020030 (ulong) theKernel);
31
32 gd->bd->bi_boot_params = gd->bd->bi_memstart + (16 << 20) - 256;
Daniel Schwierzecked530102012-06-03 23:46:04 +020033 debug("%-12s= 0x%08lX\n", "boot_params", (ulong)gd->bd->bi_boot_params);
Jean-Christophe PLAGNIOL-VILLARD1de1fa42008-09-08 20:54:39 +020034
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 Schwierzecked530102012-06-03 23:46:04 +020040 start = (char *)gd->bd->bi_boot_params;
Jean-Christophe PLAGNIOL-VILLARD1de1fa42008-09-08 20:54:39 +020041
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 Schwierzecked530102012-06-03 23:46:04 +020050 start += sprintf(start, " rd_start=0x%08X rd_size=0x%0X",
51 (uint) UNCACHED_SDRAM(images->rd_start),
Jean-Christophe PLAGNIOL-VILLARD1de1fa42008-09-08 20:54:39 +020052 (uint) len);
53 }
54
55 /* we assume that the kernel is in place */
Daniel Schwierzecked530102012-06-03 23:46:04 +020056 printf("\nStarting kernel ...\n\n");
Jean-Christophe PLAGNIOL-VILLARD1de1fa42008-09-08 20:54:39 +020057
Daniel Schwierzecked530102012-06-03 23:46:04 +020058 theKernel(0, NULL, NULL, 0);
59
Jean-Christophe PLAGNIOL-VILLARD1de1fa42008-09-08 20:54:39 +020060 /* does not return */
61 return 1;
62}