#define TMP_REG r12 #if defined(__CMODEL_SMALL__) #define PUSH_REG(reg) \ sspi reg,TMP_REG @\ addi TMP_REG,1 #define POP_REG(reg) \ lspi reg,TMP_REG @\ addi TMP_REG,1 #define LOAD_TEMP_SP \ movi r12,__irq_stack-14 #define ADD_TEMP_SP(val) \ addi r12,(val) #define PUSH_SP #define SET_SP \ movi r14,__irq_stack-14 #define POP_SP \ lspi r14,r13 #elif defined(__CMODEL_MEDIUM__) #define PUSH_REG(reg) \ sspi reg,TMP_REG @\ addi TMP_REG,1 @\ addic r13,0 #define POP_REG(reg) \ lspi reg,TMP_REG @\ addi TMP_REG,1 @\ addic r13,0 #define LOAD_TEMP_SP \ movi r12,_lo(__irq_stack-14) @\ movi r13,_hi(__irq_stack-14) #define ADD_TEMP_SP(val) \ addi r12,_lo(val) @\ addic r13,_hi(val) #define PUSH_SP \ sspi r8,r12 @\ addi r12,1 @\ sspi r9,r12 #define SET_SP \ movi r8,_lo(__irq_stack-14) @\ movi r9,_hi(__irq_stack-14) #define POP_SP \ lspi r8,r12 @\ addi r12,1 @\ lspi r9,r12 #elif defined(__CMODEL_LARGE__) /* Saves a register to stack. Assumes the page pointers are setup already */ #define PUSH_REG(reg) \ sspi reg,TMP_REG @\ addi TMP_REG,1 @\ addic r13,0 @\ addic r14,0 @\ addic r15,0 #define POP_REG(reg) \ lspi reg,TMP_REG @\ addi TMP_REG,1 @\ addic r13,0 @\ addic r14,0 @\ addic r15,0 #define LOAD_TEMP_SP \ movi r12,_lo(__irq_stack-14) @\ movi r13,_hi(__irq_stack-14) @\ movi r14,_higher(__irq_stack-14) @\ movi r15,_highest(__irq_stack-14) #define ADD_TEMP_SP(val) \ addi r12,_lo(val) @\ addic r13,_hi(val) @\ addic r14,_higher(val) @\ addic r15,_highest(val) #define PUSH_SP \ sspi r24,r12 @\ addi r12,1 @\ sspi r25,r12 @\ addi r12,1 @\ sspi r26,r12 @\ addi r12,1 @\ sspi r27,r12 #define SET_SP \ movi r24,_lo(__irq_stack-14) @\ movi r25,_hi(__irq_stack-14) @\ movi r26,_higher(__irq_stack-14) @\ movi r27,_highest(__irq_stack-14) #define POP_SP \ lspi r24,r12 @\ addi r12,1 @\ lspi r25,r12 @\ addi r12,1 @\ lspi r26,r12 @\ addi r12,1 @\ lspi r27,r12 #endif .section .text .global __irq_wrapper .type __irq_wrapper, @function __irq_wrapper: ssp r12,0 ssp r13,1 ssp r14,2 ssp r15,3 LOAD_TEMP_SP # Only save the non-preserved registers (The rest are going to be # saved by the prologue of __IRQ and whatever it calls) sspi r0,r12 addi r12,1 sspi r1,r12 addi r12,1 sspi r2,r12 addi r12,1 sspi r3,r12 ADD_TEMP_SP(1) sspi r4,r12 addi r12,1 sspi r5,r12 addi r12,1 sspi r6,r12 addi r12,1 sspi r7,r12 ADD_TEMP_SP(1) #ifndef __SIXTEEN_REGS__ #ifndef __CMODEL_LARGE__ sspi r28,r12 addi r12,1 sspi r29,r12 addi r12,1 sspi r30,r12 addi r12,1 sspi r31,r12 ADD_TEMP_SP(1) #endif #endif PUSH_SP #ifndef __CMODEL_MEDIUM__ #ifdef __CMODEL_LARGE__ ADD_TEMP_SP(1) #endif sspi r10,r12 ADD_TEMP_SP(1) sspi r11,r12 #endif SET_SP call __IRQ LOAD_TEMP_SP lspi r0,r12 addi r12,1 lspi r1,r12 addi r12,1 lspi r2,r12 addi r12,1 lspi r3,r12 ADD_TEMP_SP(1) lspi r4,r12 addi r12,1 lspi r5,r12 addi r12,1 lspi r6,r12 addi r12,1 lspi r7,r12 ADD_TEMP_SP(1) #ifndef __CMODEL_LARGE__ lspi r28,r12 addi r12,1 lspi r29,r12 addi r12,1 lspi r30,r12 addi r12,1 lspi r31,r12 ADD_TEMP_SP(1) #endif POP_SP #ifndef __CMODEL_MEDIUM__ #ifdef __CMODEL_LARGE__ ADD_TEMP_SP(1) #endif lspi r10,r12 ADD_TEMP_SP(1) lspi r11,r12 #endif lsp r12,0 lsp r13,1 lsp r14,2 lsp r15,3 iret .section .irq_stack,"aw",@nobits .align 2 #ifdef __CMODEL_SMALL__ .space 0x20 #else .space 0x100 #endif __irq_stack: .previous .section .sp_imm,"aw" .align 2 __irq_save: .byte 0x00 .byte 0x00 .byte 0x00 .byte 0x00