Author: mcayland Date: Fri May 23 14:01:40 2014 New Revision: 1300 URL: http://tracker.coreboot.org/trac/openbios/changeset/1300
Log: SPARC64: reduce client interface stack usage
Currently the client interface entrypoint uses the existing client stack to save state before invoking the main C implementation function. Unfortunately some clients such as OpenBSD have a very small stack available which can be exhausted by internal OpenBIOS calls.
Reduce the stack space required by just saving the globals onto the existing stack and instead switching to a separate stack when invoking the OpenBIOS client interface.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Modified: trunk/openbios-devel/arch/sparc64/call-client.S
Modified: trunk/openbios-devel/arch/sparc64/call-client.S ============================================================================== --- trunk/openbios-devel/arch/sparc64/call-client.S Fri May 23 13:58:09 2014 (r1299) +++ trunk/openbios-devel/arch/sparc64/call-client.S Fri May 23 14:01:40 2014 (r1300) @@ -2,8 +2,12 @@
.data .align 8 -client_globals: - .skip 64 + + .skip 16384 +openbios_stack: + +client_stack: + .xword 0
.text .align 4 @@ -19,26 +23,47 @@ sparc64_of_client_interface: /* make sure caller's windows are on caller's stack */ flushw - save %sp, -248, %sp - stx %g1, [%sp + 2047 + 192 + 0] - stx %g2, [%sp + 2047 + 192 + 8] - stx %g3, [%sp + 2047 + 192 + 16] - stx %g4, [%sp + 2047 + 192 + 24] - stx %g5, [%sp + 2047 + 192 + 32] - stx %g6, [%sp + 2047 + 192 + 40] - stx %g7, [%sp + 2047 + 192 + 48] + + /* Save globals on callers stack */ + add %sp, -56, %sp + + stx %g1, [%sp + 2047 + 0] + stx %g2, [%sp + 2047 + 8] + stx %g3, [%sp + 2047 + 16] + stx %g4, [%sp + 2047 + 24] + stx %g5, [%sp + 2047 + 32] + stx %g6, [%sp + 2047 + 40] + stx %g7, [%sp + 2047 + 48] + + /* Save existing stack and move to openbios stack */ + setx client_stack, %g6, %g7 + stx %sp, [%g7] + setx openbios_stack - 2047 - 192, %g6, %g7 + mov %g7, %sp + + /* Call client inteface */ + save %sp, -192, %sp
call of_client_interface mov %i0, %o0 - mov %o0, %i0
- ldx [%sp + 2047 + 192 + 0], %g1 - ldx [%sp + 2047 + 192 + 8], %g2 - ldx [%sp + 2047 + 192 + 16], %g3 - ldx [%sp + 2047 + 192 + 24], %g4 - ldx [%sp + 2047 + 192 + 32], %g5 - ldx [%sp + 2047 + 192 + 40], %g6 - ldx [%sp + 2047 + 192 + 48], %g7 - return %i7+8 - nop + mov %o0, %i0 + restore %sp, 192, %sp + + /* Restore stack */ + setx client_stack, %g6, %g7 + ldx [%g7], %sp + + /* Restore globals */ + ldx [%sp + 2047 + 0], %g1 + ldx [%sp + 2047 + 8], %g2 + ldx [%sp + 2047 + 16], %g3 + ldx [%sp + 2047 + 24], %g4 + ldx [%sp + 2047 + 32], %g5 + ldx [%sp + 2047 + 40], %g6 + ldx [%sp + 2047 + 48], %g7
+ add %sp, 56, %sp + + jmp %o7+8 + nop