bootm_qemu_mips.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * (C) Copyright 2008
  3. * Jean-Christophe PLAGNIOL-VILLARD <jcplagniol@jcrosoft.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <command.h>
  9. #include <image.h>
  10. #include <asm/byteorder.h>
  11. #include <asm/addrspace.h>
  12. DECLARE_GLOBAL_DATA_PTR;
  13. int do_bootm_linux(int flag, int argc, char * const argv[],
  14. bootm_headers_t *images)
  15. {
  16. void (*theKernel) (int, char **, char **, int *);
  17. char *bootargs = getenv("bootargs");
  18. char *start;
  19. uint len;
  20. /* find kernel entry point */
  21. theKernel = (void (*)(int, char **, char **, int *))images->ep;
  22. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  23. debug("## Transferring control to Linux (at address %08lx) ...\n",
  24. (ulong) theKernel);
  25. gd->bd->bi_boot_params = gd->bd->bi_memstart + (16 << 20) - 256;
  26. debug("%-12s= 0x%08lX\n", "boot_params", (ulong)gd->bd->bi_boot_params);
  27. /* set Magic */
  28. *(int32_t *)(gd->bd->bi_boot_params - 4) = 0x12345678;
  29. /* set ram_size */
  30. *(int32_t *)(gd->bd->bi_boot_params - 8) = gd->ram_size;
  31. start = (char *)gd->bd->bi_boot_params;
  32. len = strlen(bootargs);
  33. strncpy(start, bootargs, len + 1);
  34. start += len;
  35. len = images->rd_end - images->rd_start;
  36. if (len > 0) {
  37. start += sprintf(start, " rd_start=0x%08X rd_size=0x%0X",
  38. (uint) UNCACHED_SDRAM(images->rd_start),
  39. (uint) len);
  40. }
  41. /* we assume that the kernel is in place */
  42. printf("\nStarting kernel ...\n\n");
  43. theKernel(0, NULL, NULL, 0);
  44. /* does not return */
  45. return 1;
  46. }