abcmem.c 1.3 KB

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