SPARC: reduce z_thread_entry_wrapper

Transfer the entry point and initial parameters in the callee_saved
struct rather than on the stack. This saves 48 byte stack per thread
and simplifies the logic.

Signed-off-by: Julius Barendt <julius.barendt@gaisler.com>
diff --git a/arch/sparc/core/switch.S b/arch/sparc/core/switch.S
index 7ad25b8..a9cfa2b 100644
--- a/arch/sparc/core/switch.S
+++ b/arch/sparc/core/switch.S
@@ -150,9 +150,9 @@
 
 SECTION_FUNC(TEXT, z_thread_entry_wrapper)
 	mov	%g0, %o7
-	ld	[%sp + 0x40], %o0
-	ld	[%sp + 0x44], %o1
-	ld	[%sp + 0x48], %o2
-	ld	[%sp + 0x4C], %o3
+	mov	%i0, %o0
+	mov	%i1, %o1
+	mov	%i2, %o2
+	mov	%i3, %o3
 	call	z_thread_entry
 	 nop
diff --git a/arch/sparc/core/thread.c b/arch/sparc/core/thread.c
index a8e629a..e56d9f8 100644
--- a/arch/sparc/core/thread.c
+++ b/arch/sparc/core/thread.c
@@ -20,11 +20,6 @@
  */
 struct init_stack_frame {
 	uint32_t window_save_area[16];
-	k_thread_entry_t entry_point;
-	void *arg1;
-	void *arg2;
-	void *arg3;
-	uint32_t pad[8];
 };
 
 #if defined(CONFIG_FPU_SHARING)
@@ -42,12 +37,10 @@
 	/* Initial stack frame data, stored at base of the stack */
 	iframe = Z_STACK_PTR_TO_FRAME(struct init_stack_frame, stack_ptr);
 
-	iframe->entry_point = entry;
-	iframe->arg1 = p1;
-	iframe->arg2 = p2;
-	iframe->arg3 = p3;
-
-	/* Put values for debugging purposes */
+	thread->callee_saved.i0 = (uint32_t) entry;
+	thread->callee_saved.i1 = (uint32_t) p1;
+	thread->callee_saved.i2 = (uint32_t) p2;
+	thread->callee_saved.i3 = (uint32_t) p3;
 	thread->callee_saved.i6 = 0;                    /* frame pointer */
 	thread->callee_saved.o6 = (uint32_t) iframe;    /* stack pointer */
 	thread->callee_saved.o7 = (uint32_t) z_thread_entry_wrapper - 8;