Allow context-switching within the MMU TLB miss handlers on SPARC64, and use this...
commit622023d655f886fc2e2941a376ac71de7dc6f7b1
authormcayland <mcayland@f158a5a8-5612-0410-a976-696ce0be7e32>
Sat, 2 Oct 2010 12:10:45 +0000 (2 12:10 +0000)
committermcayland <mcayland@f158a5a8-5612-0410-a976-696ce0be7e32>
Sat, 2 Oct 2010 12:10:45 +0000 (2 12:10 +0000)
treedfd7ea669965335790b0262724ef6a73a304c458
parentcf7aadb38d3075a0fff53a85bc05f73725093ec1
Allow context-switching within the MMU TLB miss handlers on SPARC64, and use this to implement MMU miss handlers in C rather
than assembler.

In order to allow OpenSolaris to boot under OpenBIOS, it is necessary to be able to invoke Forth words from within the MMU
I/D-TLB miss handlers, since Solaris 10 kernels hook into the virtual to physical address translation process via va>tte-data at
boot time. Hence this patch implements two macros: SAVE_CPU_STATE and RESTORE_CPU_STATE which enable a context switch to occur
from within these trap handlers.

Things are more complicated from within the MMU miss handlers because we can't use flushw to flush the processor registers to
stack. This is because the memory pointed to by the stack pointer may not be in the TLB either, and so we'd end up in a
recursive MMU trap. Hence we solve this by creating a static stack within OpenBIOS which is guaranteed to be locked in the TLB
and storing all of our state there.

Once the ability to switch context has been implemented, it is possible to invoke C functions as per normal from within the MMU
miss handlers. Hence as a proof of concept I've migrated the MMU miss handling code from ASM to C with a view of making the
relevant changes to invoke the relevant Forth functions at a later date.

I'd also like to say thank you to Blue Swirl who took the time to answer all my questions and generally point out the
shortcomings in my first attempts at SPARC assembler.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
git-svn-id: svn://openbios.org/openbios/trunk/openbios-devel@874 f158a5a8-5612-0410-a976-696ce0be7e32
arch/sparc64/lib.c
arch/sparc64/ofmem_sparc64.h
arch/sparc64/vectors.S