From 44af623113eb560a46363788b3a9ac19e79ac2b7 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Sun, 3 Oct 2010 20:28:27 +0000 Subject: [PATCH] Implement va>tte-data defer word for the MMU TLB miss handlers. As used by OpenSolaris. This enables OpenSolaris boot to proceed further by allowing the kernel to correctly manage its own TLB misses. Signed-off-by: Mark Cave-Ayland git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@886 f158a5a8-5612-0410-a976-696ce0be7e32 --- arch/sparc64/init.fs | 7 ++++++ arch/sparc64/lib.c | 59 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 58 insertions(+), 8 deletions(-) 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++; }