bootm.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #ifdef SHARED_RESOURCES
  36. swap_to(FLASH);
  37. #endif
  38. /* find kernel entry point */
  39. if (images->legacy_hdr_valid) {
  40. ep = image_get_ep (&images->legacy_hdr_os_copy);
  41. #if defined(CONFIG_FIT)
  42. } else if (images->fit_uname_os) {
  43. int ret = fit_image_get_entry (images->fit_hdr_os,
  44. images->fit_noffset_os, &ep);
  45. if (ret) {
  46. puts ("Can't get entry point property!\n");
  47. goto error;
  48. }
  49. #endif
  50. } else {
  51. puts ("Could not find kernel entry point!\n");
  52. goto error;
  53. }
  54. appl = (int (*)(char *))ep;
  55. printf("Starting Kernel at = %x\n", appl);
  56. cmdline = make_command_line();
  57. icache_disable();
  58. dcache_disable();
  59. (*appl) (cmdline);
  60. /* does not return */
  61. return;
  62. error:
  63. do_reset (cmdtp, flag, argc, argv);
  64. }