abcmem.c 963 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "fw.h"
  2. #include "io.h"
  3. #include "abcio.h"
  4. #include "sys.h"
  5. /* Configure ABC memory map */
  6. struct abc_mem_init {
  7. unsigned int addr;
  8. uint16_t len;
  9. uint8_t flags;
  10. const char *data; /* May not be const, but... */
  11. };
  12. #define RD (ABCMEMMAP_RD >> 24)
  13. #define WR (ABCMEMMAP_WR >> 24)
  14. extern const char rom_ufddos80[];
  15. static char __dram_bss abc80_extmem[16 << 10];
  16. static const struct abc_mem_init mem_init[] = {
  17. { 0x5800, 2 << 10, RD, rom_ufddos80 },
  18. { 0x8000, 16 << 10, RD|WR, abc80_extmem },
  19. { -1U, 0, 0, NULL }
  20. };
  21. void abc_init_memmap(void)
  22. {
  23. volatile uint32_t *pg = &ABCMEMMAP_PAGE(0);
  24. const struct abc_mem_init *next = &mem_init[0];
  25. for (unsigned int addr = 0; addr < 0x10000; addr += 512) {
  26. if (addr >= next->addr + next->len)
  27. next++;
  28. if (addr < next->addr) {
  29. *pg++ = 0;
  30. } else {
  31. *pg++ = ((size_t)(next->data + (addr - next->addr))
  32. & SDRAM_MASK) | (next->flags << 24);
  33. }
  34. }
  35. }