| 1 | // (c) 2020 Aaron Taylor <ataylor at subgeniuskitty dot com> |
| 2 | // See License.txt file for copyright and license details. |
| 3 | |
| 4 | #include <stdint.h> |
| 5 | #include "pdp11_register.h" |
| 6 | |
| 7 | void |
| 8 | init_mmu(void) |
| 9 | { |
| 10 | |
| 11 | /* |
| 12 | * First populate the relocation registers, all zero since we want an |
| 13 | * identity mapping, except the highest page that we remap to the physical MMIO |
| 14 | * range. |
| 15 | */ |
| 16 | SET(KISAR0,PAR_PAF,0000000); |
| 17 | SET(KISAR1,PAR_PAF,0000000); |
| 18 | SET(KISAR2,PAR_PAF,0000000); |
| 19 | SET(KISAR3,PAR_PAF,0000000); |
| 20 | SET(KISAR4,PAR_PAF,0000000); |
| 21 | SET(KISAR5,PAR_PAF,0000000); |
| 22 | SET(KISAR6,PAR_PAF,0000000); |
| 23 | SET(KISAR7,PAR_PAF,0177600); |
| 24 | |
| 25 | /* |
| 26 | * Now populate the page descriptor registers. See EK-KDJ1B-UG page 1-19 |
| 27 | * for details of each field. |
| 28 | */ |
| 29 | uint16_t data = 0; |
| 30 | SET(data,PDR_BYPASCACHE,0); |
| 31 | SET(data,PDR_PAGELEN,0177); |
| 32 | SET(data,PDR_PAGEWRITEN,0); |
| 33 | SET(data,PDR_EXPANDDIR,0); |
| 34 | SET(data,PDR_ACCESSCTRL,03); |
| 35 | |
| 36 | KISDR0 = data; |
| 37 | KISDR1 = data; |
| 38 | KISDR2 = data; |
| 39 | KISDR3 = data; |
| 40 | KISDR4 = data; |
| 41 | KISDR5 = data; |
| 42 | KISDR6 = data; |
| 43 | KISDR7 = data; |
| 44 | |
| 45 | /* |
| 46 | * Enable the MMU with a 22-bit mapping. |
| 47 | */ |
| 48 | SET(MMR3,MMR3_KRNSPLTID,0); |
| 49 | SET(MMR3,MMR3_EN_22BIT,1); |
| 50 | SET(MMR0,MMR0_EN_MMU,1); |
| 51 | } |
| 52 | |