2
0

abcmem.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. con_puts("abc_init_memmap\n");
  29. con_flush();
  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. con_printf("abc_memmap: 0x%04x -> %p (len 0x%04x, attr %d)\n",
  37. next->addr, next->data, next->len, next->flags);
  38. *pg++ = ((size_t)(next->data + (addr - next->addr))
  39. & SDRAM_MASK) | (next->flags << 24);
  40. }
  41. }
  42. }