Added code to initialize MMU on J11 CPU.
authorAaron Taylor <ataylor@subgeniuskitty.com>
Sat, 2 Jan 2021 10:02:45 +0000 (02:02 -0800)
committerAaron Taylor <ataylor@subgeniuskitty.com>
Sat, 2 Jan 2021 10:02:45 +0000 (02:02 -0800)
pdp11_mmu.c [new file with mode: 0644]
pdp11_mmu.h [new file with mode: 0644]

diff --git a/pdp11_mmu.c b/pdp11_mmu.c
new file mode 100644 (file)
index 0000000..3fc8674
--- /dev/null
@@ -0,0 +1,52 @@
+// (c) 2020 Aaron Taylor <ataylor at subgeniuskitty dot com>
+// See License.txt file for copyright and license details.
+
+#include <stdint.h>
+#include "pdp11_register.h"
+
+void
+init_mmu(void)
+{
+
+       /*
+     * First populate the relocation registers, all zero since we want an
+     * identity mapping, except the highest page that we remap to the physical MMIO
+     * range.
+     */
+    SET(KISAR0,PAR_PAF,0000000);
+    SET(KISAR1,PAR_PAF,0000000);
+    SET(KISAR2,PAR_PAF,0000000);
+    SET(KISAR3,PAR_PAF,0000000);
+    SET(KISAR4,PAR_PAF,0000000);
+    SET(KISAR5,PAR_PAF,0000000);
+    SET(KISAR6,PAR_PAF,0000000);
+    SET(KISAR7,PAR_PAF,0177600);
+
+       /*
+        * Now populate the page descriptor registers. See EK-KDJ1B-UG page 1-19
+        * for details of each field.
+     */
+    uint16_t data = 0;
+    SET(data,PDR_BYPASCACHE,0);
+    SET(data,PDR_PAGELEN,0177);
+    SET(data,PDR_PAGEWRITEN,0);
+    SET(data,PDR_EXPANDDIR,0);
+    SET(data,PDR_ACCESSCTRL,03);
+
+    KISDR0 = data;
+    KISDR1 = data;
+    KISDR2 = data;
+    KISDR3 = data;
+    KISDR4 = data;
+    KISDR5 = data;
+    KISDR6 = data;
+    KISDR7 = data;
+
+       /*
+        * Enable the MMU with a 22-bit mapping.
+        */
+       SET(MMR3,MMR3_KRNSPLTID,0);
+    SET(MMR3,MMR3_EN_22BIT,1);
+    SET(MMR0,MMR0_EN_MMU,1);
+}
+
diff --git a/pdp11_mmu.h b/pdp11_mmu.h
new file mode 100644 (file)
index 0000000..9280850
--- /dev/null
@@ -0,0 +1,15 @@
+// (c) 2020 Aaron Taylor <ataylor at subgeniuskitty dot com>
+// See License.txt file for copyright and license details.
+
+#ifndef SGK_PDP11_MMU_H
+#define SGK_PDP11_MMU_H
+
+/*
+ * Initializes the MMU with a 22-bit kernel-mode I-space map that relocates the
+ * MMIO page to the physical MMIO region at the top of the physical address
+ * space while leaving the lower 56kB identity mapped. Assumes the CPU is
+ * already running in kernel mode with MMU hardware disabled.
+ */
+void init_mmu(void);
+
+#endif // SGK_PDP11_MMU_H