runtest.c 730 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Load and switch to test image
  3. */
  4. #include "fw.h"
  5. #include "irq.h"
  6. #include "io.h"
  7. #include "sys.h"
  8. extern const char __dram_start[];
  9. extern const char __dram_test_start[], __dram_test_end[], __dram_test_size[];
  10. extern no_return __start_test(void);
  11. static inline void disable_abcmem(void)
  12. {
  13. volatile uint32_t *pg = &ABCMEMMAP_PAGE(0);
  14. for (unsigned int addr = 0; addr < 0x10000; addr += 512)
  15. *pg++ = 0;
  16. }
  17. void __dram_text run_test_image(void)
  18. {
  19. disable_abcmem();
  20. disable_irqs();
  21. ROMCOPY_RAMADDR = (size_t)__dram_test_start;
  22. ROMCOPY_ROMADDR = __rom_offset + (__dram_test_start - __dram_start);
  23. ROMCOPY_DATALEN = (size_t)__dram_test_size;
  24. waitfor(ROMCOPY_IRQ);
  25. __start_test();
  26. }