···77#include <asm/irqflags-arcv2.h>88#include <asm/thread_info.h> /* For THREAD_SIZE */991010+/*1111+ * Interrupt/Exception stack layout (pt_regs) for ARCv21212+ * (End of struct aligned to end of page [unless nested])1313+ *1414+ * INTERRUPT EXCEPTION1515+ *1616+ * manual --------------------- manual1717+ * | orig_r0 |1818+ * | event/ECR |1919+ * | bta |2020+ * | user_r25 |2121+ * | gp |2222+ * | fp |2323+ * | sp |2424+ * | r12 |2525+ * | r30 |2626+ * | r58 |2727+ * | r59 |2828+ * hw autosave ---------------------2929+ * optional | r0 |3030+ * | r1 |3131+ * ~ ~3232+ * | r9 |3333+ * | r10 |3434+ * | r11 |3535+ * | blink |3636+ * | lpe |3737+ * | lps |3838+ * | lpc |3939+ * | ei base |4040+ * | ldi base |4141+ * | jli base |4242+ * ---------------------4343+ * hw autosave | pc / eret |4444+ * mandatory | stat32 / erstatus |4545+ * ---------------------4646+ */4747+1048/*------------------------------------------------------------------------*/1149.macro INTERRUPT_PROLOGUE called_from1212-1313- ; Before jumping to Interrupt Vector, hardware micro-ops did following:5050+ ; (A) Before jumping to Interrupt Vector, hardware micro-ops did following:1451 ; 1. SP auto-switched to kernel mode stack1515- ; 2. STATUS32.Z flag set to U mode at time of interrupt (U:1, K:0)1616- ; 3. Auto saved: r0-r11, blink, LPE,LPS,LPC, JLI,LDI,EI, PC, STAT325252+ ; 2. STATUS32.Z flag set if in U mode at time of interrupt (U:1,K:0)5353+ ; 3. Auto save: (mandatory) Push PC and STAT32 on stack5454+ ; hardware does even if CONFIG_ARC_IRQ_NO_AUTOSAVE5555+ ; 4. Auto save: (optional) r0-r11, blink, LPE,LPS,LPC, JLI,LDI,EI1756 ;1818- ; Now manually save: r12, sp, fp, gp, r255757+ ; (B) Manually saved some regs: r12,r25,r30, sp,fp,gp, ACCL pair19582059#ifdef CONFIG_ARC_IRQ_NO_AUTOSAVE2160.ifnc \called_from, exception···9657 ; - U mode: retrieve it from AUX_USER_SP9758 ; - K mode: add the offset from current SP where H/w starts auto push9859 ;9999- ; Utilize the fact that Z bit is set if Intr taken in U mode6060+ ; 1. Utilize the fact that Z bit is set if Intr taken in U mode6161+ ; 2. Upon entry SP is always saved (for any inspection, unwinding etc),6262+ ; but on return, restored only if U mode6363+10064 mov.nz r9, sp101101- add.nz r9, r9, SZ_PT_REGS - PT_sp - 46565+ add.nz r9, r9, SZ_PT_REGS - PT_sp - 4 ; K mode SP10266 bnz 1f10367104104- lr r9, [AUX_USER_SP]6868+ lr r9, [AUX_USER_SP] ; U mode SP105691:106106- PUSH r9 ; SP7070+ PUSH r9 ; SP (pt_regs->sp)1077110872 PUSH fp10973 PUSH gp···12785/*------------------------------------------------------------------------*/12886.macro INTERRUPT_EPILOGUE called_from129878888+ ; INPUT: r0 has STAT32 of calling context8989+ ; INPUT: Z flag set if returning to K mode13090.ifnc \called_from, exception13191 add sp, sp, 12 ; skip BTA/ECR/orig_r0 placeholderss13292.endif···14298 POP gp14399 POP fp144100145145- ; Don't touch AUX_USER_SP if returning to K mode (Z bit set)146146- ; (Z bit set on K mode is inverse of INTERRUPT_PROLOGUE)147147- add.z sp, sp, 4101101+ ; Restore SP (into AUX_USER_SP) only if returning to U mode102102+ ; - for K mode, it will be implicitly restored as stack is unwound103103+ ; - Z flag set on K is inverse of what hardware does on interrupt entry104104+ ; but that doesn't really matter148105 bz 1f149106150107 POPAX AUX_USER_SP···190145/*------------------------------------------------------------------------*/191146.macro EXCEPTION_PROLOGUE192147193193- ; Before jumping to Exception Vector, hardware micro-ops did following:148148+ ; (A) Before jumping to Exception Vector, hardware micro-ops did following:194149 ; 1. SP auto-switched to kernel mode stack195195- ; 2. STATUS32.Z flag set to U mode at time of interrupt (U:1,K:0)150150+ ; 2. STATUS32.Z flag set if in U mode at time of exception (U:1,K:0)196151 ;197197- ; Now manually save the complete reg file152152+ ; (B) Manually save the complete reg file below198153199154 PUSH r9 ; freeup a register: slot of erstatus200155···240195 PUSHAX ecr ; r9 contains ECR, expected by EV_Trap241196242197 PUSH r0 ; orig_r0198198+ ; OUTPUT: r9 has ECR243199.endm244200245201/*------------------------------------------------------------------------*/246202.macro EXCEPTION_EPILOGUE247203248248- ; Assumes r0 has PT_status32204204+ ; INPUT: r0 has STAT32 of calling context249205 btst r0, STATUS_U_BIT ; Z flag set if K, used in INTERRUPT_EPILOGUE250206251207 add sp, sp, 8 ; orig_r0/ECR don't need restoring