abcmem.c 1.2 KB

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