Created
October 12, 2013 06:15
-
-
Save tsutsui/6946415 to your computer and use it in GitHub Desktop.
A patch that makes NetBSD/x68k kernel use the transparent translation register (%tt0) to map all I/O device space.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: include/cpu.h | |
=================================================================== | |
RCS file: /cvsroot/src/sys/arch/x68k/include/cpu.h,v | |
retrieving revision 1.56 | |
diff -u -p -r1.56 cpu.h | |
--- include/cpu.h 2 Feb 2012 16:59:43 -0000 1.56 | |
+++ include/cpu.h 12 Oct 2013 06:04:11 -0000 | |
@@ -152,8 +152,13 @@ int badbaddr(volatile void*); | |
* ``intiolimit'' (defined in locore.s). Since it is always mapped, | |
* conversion between physical and kernel virtual addresses is easy. | |
*/ | |
+#ifdef USE_TTMAPIO | |
+#define IIOV(pa) ((u_int)(pa) | 0x7F000000) | |
+#define IIOP(va) ((u_int)(va) & ~0x7F000000) | |
+#else | |
#define IIOV(pa) ((u_int)(pa) - INTIOBASE + (u_int)intiobase) | |
#define IIOP(va) ((u_int)(va) - (u_int)intiobase + INTIOBASE) | |
+#endif | |
#define IIOPOFF(pa) ((int)(pa)-INTIOBASE) | |
#define IIOMAPSIZE btoc(INTIOTOP-INTIOBASE) /* 4mb */ | |
Index: include/vmparam.h | |
=================================================================== | |
RCS file: /cvsroot/src/sys/arch/x68k/include/vmparam.h,v | |
retrieving revision 1.35 | |
diff -u -p -r1.35 vmparam.h | |
--- include/vmparam.h 21 Jan 2012 20:19:55 -0000 1.35 | |
+++ include/vmparam.h 12 Oct 2013 06:04:11 -0000 | |
@@ -101,7 +101,11 @@ | |
#define VM_MAXUSER_ADDRESS ((vaddr_t)0xFFF00000) | |
#define VM_MAX_ADDRESS ((vaddr_t)0xFFF00000) | |
#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0) | |
+#ifdef USE_TTMAPIO | |
+#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)(0x7F000000-PAGE_SIZE*NPTEPG)) | |
+#else | |
#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)(0-PAGE_SIZE*NPTEPG)) | |
+#endif | |
/* virtual sizes (bytes) for various kernel submaps */ | |
#define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE) | |
Index: x68k/locore.s | |
=================================================================== | |
RCS file: /cvsroot/src/sys/arch/x68k/x68k/locore.s,v | |
retrieving revision 1.110 | |
diff -u -p -r1.110 locore.s | |
--- x68k/locore.s 19 May 2012 08:29:32 -0000 1.110 | |
+++ x68k/locore.s 12 Oct 2013 06:04:12 -0000 | |
@@ -828,10 +828,16 @@ Lstploaddone: | |
movb #0x01,0x01800003 | set "SUPER" bit | |
Ljupiterdone: | |
#endif /* JUPITER */ | |
+#ifdef USE_TTMAPIO | |
+ RELOC(proto040tt0,%a0) | |
+ movl %a0@,%d0 | map 0x7f000000 region via %tt0 | |
+#else | |
moveq #0,%d0 | ensure TT regs are disabled | |
+#endif | |
.long 0x4e7b0004 | movc d0,itt0 | |
- .long 0x4e7b0005 | movc d0,itt1 | |
.long 0x4e7b0006 | movc d0,dtt0 | |
+ moveq #0,%d0 | ensure TT1 reg is disabled | |
+ .long 0x4e7b0005 | movc d0,itt1 | |
.long 0x4e7b0007 | movc d0,dtt1 | |
.word 0xf4d8 | cinva bc | |
.word 0xf518 | pflusha | |
@@ -856,6 +862,10 @@ Lnot060cache: | |
movc %d0,%cacr | turn on both caches | |
jmp Lenab1 | |
Lmotommu2: | |
+#ifdef USE_TTMAPIO | |
+ RELOC(protott0,%a0) | |
+ .long 0xf0100800 | pmove %a0@,%tt0 | |
+#endif | |
pflusha | |
#if PGSHIFT == 13 | |
movl #0x82d08b00,%sp@- | value to load TC with | |
@@ -1133,6 +1143,14 @@ GLOBAL(fputype) | |
GLOBAL(protorp) | |
.long 0,0 | prototype root pointer | |
+#ifdef USE_TTMAPIO | |
+GLOBAL(protott0) | |
+ .long 0x7f008543 | prototype transparent translation register 0 | |
+ | |
+GLOBAL(proto040tt0) | |
+ .long 0x7f00a040 | prototype transparent translation register 0 | |
+#endif | |
+ | |
GLOBAL(intiobase) | |
.long 0 | KVA of base of internal IO space | |
Index: x68k/pmap_bootstrap.c | |
=================================================================== | |
RCS file: /cvsroot/src/sys/arch/x68k/x68k/pmap_bootstrap.c,v | |
retrieving revision 1.59 | |
diff -u -p -r1.59 pmap_bootstrap.c | |
--- x68k/pmap_bootstrap.c 25 Feb 2012 02:43:08 -0000 1.59 | |
+++ x68k/pmap_bootstrap.c 12 Oct 2013 06:04:12 -0000 | |
@@ -163,6 +163,10 @@ pmap_bootstrap(paddr_t nextpa, paddr_t f | |
* Portions of the last segment of KVA space (0xFFC00000 - | |
* 0xFFFFFFFF) are mapped for the kernel page tables. | |
* | |
+ * In USE_TTMAPIO case, SYSMAP_VA is before 0x7F000000 and the | |
+ * last region (0x7F000000 - 0x7FFFFFFF) is used for %tt0 mapping, | |
+ * so the last segment of KVA space is at 0x7EC00000 - 0x7EFFFFFF. | |
+ * | |
* XXX cramming two levels of mapping into the single "segment" | |
* table on the 68040 is intended as a temporary hack to get things | |
* working. The 224mb of address space that this allows will most | |
@@ -211,19 +215,20 @@ pmap_bootstrap(paddr_t nextpa, paddr_t f | |
protoste += (SG4_LEV2SIZE * sizeof(st_entry_t)); | |
} | |
/* | |
- * Initialize the final level 1 descriptor to map the next | |
- * block of level 2 descriptors for Sysptmap. | |
+ * Initialize the level 1 descriptor corresponding to | |
+ * SYSMAP_VA to map the the last block of level 2 descriptors | |
+ * for Sysptmap. | |
*/ | |
ste = (st_entry_t *)kstpa; | |
- ste = &ste[SG4_LEV1SIZE - 1]; | |
+ ste = &ste[SYSMAP_VA >> SG4_SHIFT1]; | |
*ste = protoste; | |
/* | |
- * Now initialize the final portion of that block of | |
+ * Now initialize the portion of the block of | |
* descriptors to map Sysmap. | |
*/ | |
i = SG4_LEV1SIZE + (nl1desc * SG4_LEV2SIZE); | |
ste = (st_entry_t *)kstpa; | |
- ste = &ste[i + SG4_LEV2SIZE - (NPTEPG / SG4_LEV3SIZE)]; | |
+ ste = &ste[i + ((SYSMAP_VA & SG4_MASK2) >> SG4_SHIFT2)]; | |
este = &ste[NPTEPG / SG4_LEV3SIZE]; | |
protoste = kptmpa | SG_U | SG_RW | SG_V; | |
while (ste < este) { | |
@@ -267,7 +272,7 @@ pmap_bootstrap(paddr_t nextpa, paddr_t f | |
*pte++ = PG_NV; | |
} | |
/* | |
- * Initialize the last one to point to Sysptmap. | |
+ * Initialize the last one to point to SYSMAP_VA. | |
*/ | |
pte = (pt_entry_t *)kptmpa; | |
pte = &pte[SYSMAP_VA >> SEGSHIFT]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment