bootm_qemu_mips.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #include <common.h>
  24. #include <command.h>
  25. #include <image.h>
  26. #include <asm/byteorder.h>
  27. #include <asm/addrspace.h>
  28. DECLARE_GLOBAL_DATA_PTR;
  29. int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
  30. {
  31. void (*theKernel) (int, char **, char **, int *);
  32. char *bootargs = getenv ("bootargs");
  33. char *start;
  34. uint len;
  35. /* find kernel entry point */
  36. theKernel = (void (*)(int, char **, char **, int *))images->ep;
  37. show_boot_progress (15);
  38. debug ("## Transferring control to Linux (at address %08lx) ...\n",
  39. (ulong) theKernel);
  40. gd->bd->bi_boot_params = gd->bd->bi_memstart + (16 << 20) - 256;
  41. debug ("%-12s= 0x%08lX\n", "boot_params", (ulong)gd->bd->bi_boot_params);
  42. /* set Magic */
  43. *(int32_t *)(gd->bd->bi_boot_params - 4) = 0x12345678;
  44. /* set ram_size */
  45. *(int32_t *)(gd->bd->bi_boot_params - 8) = gd->ram_size;
  46. start = (char*)gd->bd->bi_boot_params;
  47. len = strlen(bootargs);
  48. strncpy(start, bootargs, len + 1);
  49. start += len;
  50. len = images->rd_end - images->rd_start;
  51. if (len > 0) {
  52. start += sprintf(start," rd_start=0x%08X rd_size=0x%0X",
  53. (uint) UNCACHED_SDRAM (images->rd_start),
  54. (uint) len);
  55. }
  56. /* we assume that the kernel is in place */
  57. printf ("\nStarting kernel ...\n\n");
  58. theKernel (0, NULL, NULL, 0);
  59. /* does not return */
  60. return 1;
  61. }