romcopy.c 775 B

1234567891011121314151617181920212223242526272829303132
  1. #include "fw.h"
  2. #include "io.h"
  3. extern const char __dram_init_start[], __dram_init_end[], __dram_init_len[];
  4. extern const char __dram_bss_start[], __dram_bss_end[], __dram_bss_len[];
  5. uint32_t romcopy_time[2];
  6. IRQHANDLER(romcopy)
  7. {
  8. static unsigned int romcopy_state;
  9. switch (romcopy_state++) {
  10. case 0:
  11. /* Copy testdata */
  12. ROMCOPY_RAMADDR = (size_t)__dram_init_start;
  13. ROMCOPY_ROMADDR = __rom_offset;
  14. ROMCOPY_DATALEN = (size_t)__dram_init_len;
  15. break;
  16. case 1:
  17. /* Zero .dram.bss */
  18. romcopy_time[0] = rdtime() - time_zero;
  19. ROMCOPY_RAMADDR = (size_t)__dram_bss_start;
  20. ROMCOPY_ROMADDR = 0; /* Clear */
  21. ROMCOPY_DATALEN = (size_t)__dram_bss_len;
  22. break;
  23. default:
  24. romcopy_time[1] = rdtime() - romcopy_time[0];
  25. mask_irq(ROMCOPY_IRQ);
  26. return;
  27. }
  28. }