diff --git a/arch/sparc64/init.fs b/arch/sparc64/init.fs index 9e3d44d..a1cadc1 100644 --- a/arch/sparc64/init.fs +++ b/arch/sparc64/init.fs @@ -1,3 +1,10 @@ +\ va>tte-data defer MMU virtual to physical address hook for Solaris +\ We need to make sure this is in the global wordlist +active-package 0 active-package! +defer va>tte-data +0 to va>tte-data +active-package! + :noname ." Type 'help' for detailed information" cr \ ." boot secondary slave cdrom: " cr diff --git a/arch/sparc64/lib.c b/arch/sparc64/lib.c index 1153f04..b56494d 100644 --- a/arch/sparc64/lib.c +++ b/arch/sparc64/lib.c @@ -16,6 +16,8 @@ #include "ofmem_sparc64.h" +static ucell *va2ttedata = 0; + /* Format a string and print it on the screen, just like the libc * function printf. */ @@ -228,10 +230,28 @@ dtlb_miss_handler(void) faultva >>= 13; faultva <<= 13; - /* Search the ofmem linked list for this virtual address */ - PUSH(faultva); - pgmap_fetch(); - tte_data = POP(); + /* If a valid va>tte-data routine has been set, invoke that Forth xt instead */ + if (va2ttedata && *va2ttedata != 0) { + + /* va>tte-data ( addr cnum -- false | tte-data true ) */ + PUSH(faultva); + PUSH(0); + enterforth(*va2ttedata); + + /* Check the result first... */ + tte_data = POP(); + if (!tte_data) { + bug(); + } else { + /* Grab the real data */ + tte_data = POP(); + } + } else { + /* Search the ofmem linked list for this virtual address */ + PUSH(faultva); + pgmap_fetch(); + tte_data = POP(); + } if (tte_data) { /* Update MMU */ @@ -240,6 +260,7 @@ dtlb_miss_handler(void) /* If we got here, there was no translation so fail */ bug(); } + } static void @@ -298,10 +319,28 @@ itlb_miss_handler(void) faultva >>= 13; faultva <<= 13; - /* Search the ofmem linked list for this virtual address */ - PUSH(faultva); - pgmap_fetch(); - tte_data = POP(); + /* If a valid va>tte-data routine has been set, invoke that Forth xt instead */ + if (va2ttedata && *va2ttedata != 0) { + + /* va>tte-data ( addr cnum -- false | tte-data true ) */ + PUSH(faultva); + PUSH(0); + enterforth(*va2ttedata); + + /* Check the result first... */ + tte_data = POP(); + if (!tte_data) { + bug(); + } else { + /* Grab the real data */ + tte_data = POP(); + } + } else { + /* Search the ofmem linked list for this virtual address */ + PUSH(faultva); + pgmap_fetch(); + tte_data = POP(); + } if (tte_data) { /* Update MMU */ @@ -617,4 +656,8 @@ void ob_mmu_init(const char *cpuname, uint64_t ram_size) PUSH(0); fword("active-package!"); bind_func("pgmap@", pgmap_fetch); + + /* Find address of va2ttedata defer word contents for MMU miss handlers */ + va2ttedata = (ucell *)findword("va>tte-data"); + va2ttedata++; }