1 #define LANGUAGE_ASSEMBLY
5 #include "genesis/fdefn.h"
6 #include "genesis/closure.h"
7 #include "genesis/simple-fun.h"
8 #include "genesis/static-symbols.h"
45 * Function to transfer control into lisp.
51 #define framesize 12*4
53 .frame sp, framesize, ra
54 /* Save all the C regs. */
57 sw s8, framesize-4(sp)
58 sw s7, framesize-12(sp)
59 sw s6, framesize-16(sp)
60 sw s5, framesize-20(sp)
61 sw s4, framesize-24(sp)
62 sw s3, framesize-28(sp)
63 sw s2, framesize-32(sp)
64 sw s1, framesize-36(sp)
65 sw s0, framesize-40(sp)
67 /* Clear descriptor regs */
85 /* Start pseudo-atomic. */
91 /* No longer in foreign call. */
92 sw zero, foreign_function_call_active
94 /* Load the allocation pointer, preserving the low-bit of alloc */
95 lw reg_BSP, dynamic_space_free_pointer
96 add reg_ALLOC, reg_BSP
98 /* Load the rest of the LISP state. */
99 lw reg_BSP, current_binding_stack_pointer
100 lw reg_CSP, current_control_stack_pointer
101 lw reg_OCFP, current_control_frame_pointer
103 /* Check for interrupt */
116 lw reg_A0, 0(reg_CFP)
117 lw reg_A1, 4(reg_CFP)
118 lw reg_A2, 8(reg_CFP)
119 lw reg_A3, 12(reg_CFP)
120 lw reg_A4, 16(reg_CFP)
121 lw reg_A5, 20(reg_CFP)
124 la reg_LRA, lra + OTHER_POINTER_LOWTAG
126 /* Indirect closure */
127 lw reg_CODE, -1(reg_LEXENV)
129 /* Jump into lisp land. */
130 addu reg_LIP, reg_CODE, 6*4 - FUN_POINTER_LOWTAG
136 /* This particular KLUDGE is kept here as a reminder; for more
137 details, see irix-asm-munge.c from CMUCL's lisp directory.
138 Other examples have been deleted from later in the file in the
139 hope that they will not be needed. */
140 .globl mipsmungelra /* for our munging afterwards in irix-asm-munge */
144 .word RETURN_PC_HEADER_WIDETAG
146 /* Multiple value return spot, clear stack */
147 move reg_CSP, reg_OCFP
150 /* Set pseudo-atomic flag. */
155 /* Save LISP registers. */
156 subu reg_NL0, reg_ALLOC, 1
157 sw reg_NL0, dynamic_space_free_pointer
158 sw reg_BSP, current_binding_stack_pointer
159 sw reg_CSP, current_control_stack_pointer
160 sw reg_CFP, current_control_frame_pointer
162 /* Pass one return value back to C land. */
163 /* v0 is reg_ALLOC in this new world, so do this after saving
164 reg_ALLOC in dynamic_space_free_pointer */
167 /* Back in foreign function call */
168 sw reg_CFP, foreign_function_call_active
170 /* Check for interrupt */
181 lw s8, framesize-4(sp)
182 lw s7, framesize-12(sp)
183 lw s6, framesize-16(sp)
184 lw s5, framesize-20(sp)
185 lw s4, framesize-24(sp)
186 lw s3, framesize-28(sp)
187 lw s2, framesize-32(sp)
188 lw s1, framesize-36(sp)
189 lw s0, framesize-40(sp)
191 /* Restore C stack. */
200 * Transfering control from Lisp into C
206 /* Set up a stack frame. */
207 move reg_OCFP, reg_CFP
208 move reg_CFP, reg_CSP
209 addu reg_CSP, reg_CFP, 32
210 sw reg_OCFP, 0(reg_CFP)
211 subu reg_NL4, reg_LIP, reg_CODE
212 addu reg_NL4, OTHER_POINTER_LOWTAG
213 sw reg_NL4, 4(reg_CFP)
214 sw reg_CODE, 8(reg_CFP)
217 /* Note: the C stack is already set up. */
219 /* Set the pseudo-atomic flag. */
225 /* Save lisp state. */
226 subu t0, reg_ALLOC, 1
227 sw t0, dynamic_space_free_pointer
228 sw reg_BSP, current_binding_stack_pointer
229 sw reg_CSP, current_control_stack_pointer
230 sw reg_CFP, current_control_frame_pointer
232 /* Mark us as in C land. */
233 sw reg_CSP, foreign_function_call_active
235 /* Were we interrupted? */
244 /* Into C land we go. */
251 /* Clear unsaved descriptor regs */
266 /* Turn on pseudo-atomic. */
272 /* Mark us at in Lisp land. */
273 sw zero, foreign_function_call_active
275 /* Restore ALLOC, preserving pseudo-atomic-atomic */
276 lw a0, dynamic_space_free_pointer
279 /* Check for interrupt */
288 /* Restore LRA & CODE (they may have been GC'ed) */
289 lw reg_CODE, 8(reg_CFP)
291 subu a0, OTHER_POINTER_LOWTAG
292 addu reg_LIP, reg_CODE, a0
294 /* Reset the lisp stack. */
295 /* Note: OCFP and CFP are in saved regs. */
296 move reg_CSP, reg_CFP
297 move reg_CFP, reg_OCFP
299 /* Return to LISP. */
305 .globl start_of_tramps
309 * The undefined-function trampoline.
312 .globl undefined_tramp
317 .byte UNDEFINED_FUN_ERROR
319 .byte (0xc0 + sc_DescriptorReg)
325 * The closure trampoline.
331 lw reg_LEXENV, FDEFN_FUN_OFFSET(reg_FDEFN)
332 lw reg_L0, CLOSURE_FUN_OFFSET(reg_LEXENV)
333 addu reg_LIP, reg_L0, SIMPLE_FUN_CODE_OFFSET
343 * Function-end breakpoint magic.
349 .globl function_end_breakpoint_guts
350 fun_end_breakpoint_guts:
351 .word RETURN_PC_HEADER_WIDETAG
355 move reg_OCFP, reg_CSP
365 .globl fun_end_breakpoint_trap
366 fun_end_breakpoint_trap:
367 break trap_FunEndBreakpoint
371 .globl fun_end_breakpoint_end
372 fun_end_breakpoint_end:
375 /* FIXME: I don't think the below are actually used anywhere */
391 /* Save all the C regs. */
404 /* Should also save the floating point state. */