2
0

abcmem.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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_nvram[2 << 10]; /* Not really NV... */
  16. static char __dram_bss abc80_extmem[16 << 10];
  17. static const struct abc_mem_init mem_init[] = {
  18. { 0x5000, 2 << 10, RD|WR, abc80_nvram },
  19. { 0x6000, 4 << 10, RD, rom_ufddos80 },
  20. { 0x8000, 16 << 10, RD|WR, abc80_extmem },
  21. { -1U, 0, 0, NULL }
  22. };
  23. void abc_init_memmap(void)
  24. {
  25. volatile uint32_t *pg = &ABCMEMMAP_PAGE(0);
  26. const struct abc_mem_init *next = &mem_init[0];
  27. for (unsigned int addr = 0; addr < 0x10000; addr += 512) {
  28. if (addr >= next->addr + next->len)
  29. next++;
  30. if (addr < next->addr) {
  31. *pg++ = 0;
  32. } else {
  33. *pg++ = ((size_t)(next->data + (addr - next->addr))
  34. & SDRAM_MASK) | (next->flags << 24);
  35. }
  36. }
  37. }