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 --- openbios-devel/arch/sparc64/call-client.S | 67 ++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 21 deletions(-)
diff --git a/openbios-devel/arch/sparc64/call-client.S b/openbios-devel/arch/sparc64/call-client.S index d15f177..18de704 100644 --- a/openbios-devel/arch/sparc64/call-client.S +++ b/openbios-devel/arch/sparc64/call-client.S @@ -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 @@ client_globals: 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