cmd_bootldr.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * U-boot - bootldr.c
  3. *
  4. * Copyright (c) 2005-2008 Analog Devices Inc.
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * Licensed under the GPL-2 or later.
  10. */
  11. #include <config.h>
  12. #include <common.h>
  13. #include <command.h>
  14. #include <asm/blackfin.h>
  15. #include <asm/mach-common/bits/bootrom.h>
  16. /*
  17. * the bootldr command loads an address, checks to see if there
  18. * is a Boot stream that the on-chip BOOTROM can understand,
  19. * and loads it via the BOOTROM Callback. It is possible
  20. * to also add booting from SPI, or TWI, but this function does
  21. * not currently support that.
  22. */
  23. int do_bootldr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  24. {
  25. void *addr;
  26. uint32_t *data;
  27. /* Get the address */
  28. if (argc < 2)
  29. addr = (void *)load_addr;
  30. else
  31. addr = (void *)simple_strtoul(argv[1], NULL, 16);
  32. /* Check if it is a LDR file */
  33. data = addr;
  34. #if defined(__ADSPBF54x__) || defined(__ADSPBF52x__)
  35. if ((*data & 0xFF000000) == 0xAD000000 && data[2] == 0x00000000) {
  36. #else
  37. if (*data == 0xFF800060 || *data == 0xFF800040 || *data == 0xFF800020) {
  38. #endif
  39. /* We want to boot from FLASH or SDRAM */
  40. printf("## Booting ldr image at 0x%p ...\n", addr);
  41. icache_disable();
  42. dcache_disable();
  43. __asm__(
  44. "jump (%1);"
  45. :
  46. : "q7" (addr), "a" (_BOOTROM_MEMBOOT));
  47. } else
  48. printf("## No ldr image at address 0x%p\n", addr);
  49. return 0;
  50. }
  51. U_BOOT_CMD(bootldr, 2, 0, do_bootldr,
  52. "bootldr - boot ldr image from memory\n",
  53. "[addr]\n"
  54. " - boot ldr image stored in memory\n");