]> git.ipfire.org Git - people/ms/u-boot.git/blob - arch/mips/lib/bootm_qemu_mips.c
Add GPL-2.0+ SPDX-License-Identifier to source files
[people/ms/u-boot.git] / arch / mips / lib / bootm_qemu_mips.c
1 /*
2 * (C) Copyright 2008
3 * Jean-Christophe PLAGNIOL-VILLARD <jcplagniol@jcrosoft.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
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
16 int do_bootm_linux(int flag, int argc, char * const argv[],
17 bootm_headers_t *images)
18 {
19 void (*theKernel) (int, char **, char **, int *);
20 char *bootargs = getenv("bootargs");
21 char *start;
22 uint len;
23
24 /* find kernel entry point */
25 theKernel = (void (*)(int, char **, char **, int *))images->ep;
26
27 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
28
29 debug("## Transferring control to Linux (at address %08lx) ...\n",
30 (ulong) theKernel);
31
32 gd->bd->bi_boot_params = gd->bd->bi_memstart + (16 << 20) - 256;
33 debug("%-12s= 0x%08lX\n", "boot_params", (ulong)gd->bd->bi_boot_params);
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
40 start = (char *)gd->bd->bi_boot_params;
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) {
50 start += sprintf(start, " rd_start=0x%08X rd_size=0x%0X",
51 (uint) UNCACHED_SDRAM(images->rd_start),
52 (uint) len);
53 }
54
55 /* we assume that the kernel is in place */
56 printf("\nStarting kernel ...\n\n");
57
58 theKernel(0, NULL, NULL, 0);
59
60 /* does not return */
61 return 1;
62 }