1 #define LANGUAGE_ASSEMBLY
41 * Function to transfer control into lisp.
47 #define framesize 12*4
49 .frame sp, framesize, ra
50 /* Save all the C regs. */
53 sw s8, framesize-4(sp)
54 sw s7, framesize-12(sp)
55 sw s6, framesize-16(sp)
56 sw s5, framesize-20(sp)
57 sw s4, framesize-24(sp)
58 sw s3, framesize-28(sp)
59 sw s2, framesize-32(sp)
60 sw s1, framesize-36(sp)
61 sw s0, framesize-40(sp)
63 /* Clear descriptor regs */
81 /* Start pseudo-atomic. */
87 /* No longer in foreign call. */
88 sw zero, foreign_function_call_active
90 /* Load the allocation pointer, preserving the low-bit of alloc */
91 lw reg_BSP, dynamic_space_free_pointer
92 add reg_ALLOC, reg_BSP
94 /* Load the rest of the LISP state. */
95 lw reg_BSP, current_binding_stack_pointer
96 lw reg_CSP, current_control_stack_pointer
97 lw reg_OCFP, current_control_frame_pointer
99 /* Check for interrupt */
112 lw reg_A0, 0(reg_CFP)
113 lw reg_A1, 4(reg_CFP)
114 lw reg_A2, 8(reg_CFP)
115 lw reg_A3, 12(reg_CFP)
116 lw reg_A4, 16(reg_CFP)
117 lw reg_A5, 20(reg_CFP)
120 la reg_LRA, lra + OTHER_POINTER_LOWTAG
122 /* Indirect closure */
123 lw reg_CODE, -1(reg_LEXENV)
125 /* Jump into lisp land. */
126 addu reg_LIP, reg_CODE, 6*4 - FUN_POINTER_LOWTAG
132 /* This particular KLUDGE is kept here as a reminder; for more
133 details, see irix-asm-munge.c from CMUCL's lisp directory.
134 Other examples have been deleted from later in the file in the
135 hope that they will not be needed. */
136 .globl mipsmungelra /* for our munging afterwards in irix-asm-munge */
140 .word RETURN_PC_HEADER_WIDETAG
142 /* Multiple value return spot, clear stack */
143 move reg_CSP, reg_OCFP
146 /* Set pseudo-atomic flag. */
151 /* Save LISP registers. */
152 subu reg_NL0, reg_ALLOC, 1
153 sw reg_NL0, dynamic_space_free_pointer
154 sw reg_BSP, current_binding_stack_pointer
155 sw reg_CSP, current_control_stack_pointer
156 sw reg_CFP, current_control_frame_pointer
158 /* Pass one return value back to C land. */
159 /* v0 is reg_ALLOC in this new world, so do this after saving
160 reg_ALLOC in dynamic_space_free_pointer */
163 /* Back in foreign function call */
164 sw reg_CFP, foreign_function_call_active
166 /* Check for interrupt */
177 lw s8, framesize-4(sp)
178 lw s7, framesize-12(sp)
179 lw s6, framesize-16(sp)
180 lw s5, framesize-20(sp)
181 lw s4, framesize-24(sp)
182 lw s3, framesize-28(sp)
183 lw s2, framesize-32(sp)
184 lw s1, framesize-36(sp)
185 lw s0, framesize-40(sp)
187 /* Restore C stack. */
196 * Transfering control from Lisp into C
202 /* Set up a stack frame. */
203 move reg_OCFP, reg_CFP
204 move reg_CFP, reg_CSP
205 addu reg_CSP, reg_CFP, 32
206 sw reg_OCFP, 0(reg_CFP)
207 subu reg_NL4, reg_LIP, reg_CODE
208 addu reg_NL4, OTHER_POINTER_LOWTAG
209 sw reg_NL4, 4(reg_CFP)
210 sw reg_CODE, 8(reg_CFP)
213 /* Note: the C stack is already set up. */
215 /* Set the pseudo-atomic flag. */
221 /* Save lisp state. */
222 subu t0, reg_ALLOC, 1
223 sw t0, dynamic_space_free_pointer
224 sw reg_BSP, current_binding_stack_pointer
225 sw reg_CSP, current_control_stack_pointer
226 sw reg_CFP, current_control_frame_pointer
228 /* Mark us as in C land. */
229 sw reg_CSP, foreign_function_call_active
231 /* Were we interrupted? */
240 /* Into C land we go. */
247 /* Clear unsaved descriptor regs */
262 /* Turn on pseudo-atomic. */
268 /* Mark us at in Lisp land. */
269 sw zero, foreign_function_call_active
271 /* Restore ALLOC, preserving pseudo-atomic-atomic */
272 lw a0, dynamic_space_free_pointer
275 /* Check for interrupt */
284 /* Restore LRA & CODE (they may have been GC'ed) */
285 lw reg_CODE, 8(reg_CFP)
287 subu a0, OTHER_POINTER_LOWTAG
288 addu reg_LIP, reg_CODE, a0
290 /* Reset the lisp stack. */
291 /* Note: OCFP and CFP are in saved regs. */
292 move reg_CSP, reg_CFP
293 move reg_CFP, reg_OCFP
295 /* Return to LISP. */
301 .globl start_of_tramps
305 * The undefined-function trampoline.
308 .globl undefined_tramp
313 .byte UNDEFINED_FUN_ERROR
315 .byte (0xc0 + sc_DescriptorReg)
321 * The closure trampoline.
327 lw reg_LEXENV, FDEFN_FUN_OFFSET(reg_FDEFN)
328 lw reg_L0, CLOSURE_FUN_OFFSET(reg_LEXENV)
329 addu reg_LIP, reg_L0, SIMPLE_FUN_CODE_OFFSET
339 * Function-end breakpoint magic.
345 .globl function_end_breakpoint_guts
346 fun_end_breakpoint_guts:
347 .word RETURN_PC_HEADER_WIDETAG
351 move reg_OCFP, reg_CSP
361 .globl fun_end_breakpoint_trap
362 fun_end_breakpoint_trap:
363 break trap_FunEndBreakpoint
367 .globl fun_end_breakpoint_end
368 fun_end_breakpoint_end:
371 /* FIXME: I don't think the below are actually used anywhere */
387 /* Save all the C regs. */
400 /* Should also save the floating point state. */