abcmem.c 1.1 KB

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