bootm.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * U-boot - bootm.c - misc boot helper functions
  3. *
  4. * Copyright (c) 2005-2008 Analog Devices Inc.
  5. *
  6. * (C) Copyright 2000-2004
  7. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  8. *
  9. * Licensed under the GPL-2 or later.
  10. */
  11. #include <common.h>
  12. #include <command.h>
  13. #include <image.h>
  14. #include <asm/blackfin.h>
  15. extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
  16. #ifdef SHARED_RESOURCES
  17. extern void swap_to(int device_id);
  18. #endif
  19. static char *make_command_line(void)
  20. {
  21. char *dest = (char *)CMD_LINE_ADDR;
  22. char *bootargs = getenv("bootargs");
  23. if (bootargs == NULL)
  24. return NULL;
  25. strncpy(dest, bootargs, 0x1000);
  26. dest[0xfff] = 0;
  27. return dest;
  28. }
  29. void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
  30. bootm_headers_t *images)
  31. {
  32. int (*appl) (char *cmdline);
  33. char *cmdline;
  34. ulong ep = 0;
  35. if (!images->autostart)
  36. return;
  37. #ifdef SHARED_RESOURCES
  38. swap_to(FLASH);
  39. #endif
  40. /* find kernel entry point */
  41. if (images->legacy_hdr_valid) {
  42. ep = image_get_ep (images->legacy_hdr_os);
  43. #if defined(CONFIG_FIT)
  44. } else if (images->fit_uname_os) {
  45. int ret = fit_image_get_entry (images->fit_hdr_os,
  46. images->fit_noffset_os, &ep);
  47. if (ret) {
  48. puts ("Can't get entry point property!\n");
  49. goto error;
  50. }
  51. #endif
  52. } else {
  53. puts ("Could not find kernel entry point!\n");
  54. goto error;
  55. }
  56. appl = (int (*)(char *))ep;
  57. printf("Starting Kernel at = %x\n", appl);
  58. cmdline = make_command_line();
  59. icache_disable();
  60. dcache_disable();
  61. (*appl) (cmdline);
  62. /* does not return */
  63. return;
  64. error:
  65. if (images->autostart)
  66. do_reset (cmdtp, flag, argc, argv);
  67. }