Path: blob/master/arch/blackfin/include/asm/context.S
15126 views
/*1* Copyright 2007-2009 Analog Devices Inc.2*3* Licensed under the GPL-2 or later.4*/56/*7* NOTE! The single-stepping code assumes that all interrupt handlers8* start by saving SYSCFG on the stack with their first instruction.9*/1011/*12* Code to save processor context.13* We even save the register which are preserved by a function call14* - r4, r5, r6, r7, p3, p4, p515*/16.macro save_context_with_interrupts17[--sp] = SYSCFG;1819[--sp] = P0; /*orig_p0*/20[--sp] = R0; /*orig_r0*/2122[--sp] = ( R7:0, P5:0 );23[--sp] = fp;24[--sp] = usp;2526[--sp] = i0;27[--sp] = i1;28[--sp] = i2;29[--sp] = i3;3031[--sp] = m0;32[--sp] = m1;33[--sp] = m2;34[--sp] = m3;3536[--sp] = l0;37[--sp] = l1;38[--sp] = l2;39[--sp] = l3;4041[--sp] = b0;42[--sp] = b1;43[--sp] = b2;44[--sp] = b3;45[--sp] = a0.x;46[--sp] = a0.w;47[--sp] = a1.x;48[--sp] = a1.w;4950[--sp] = LC0;51[--sp] = LC1;52[--sp] = LT0;53[--sp] = LT1;54[--sp] = LB0;55[--sp] = LB1;5657[--sp] = ASTAT;5859[--sp] = r0; /* Skip reserved */60[--sp] = RETS;61r0 = RETI;62[--sp] = r0;63[--sp] = RETX;64[--sp] = RETN;65[--sp] = RETE;66[--sp] = SEQSTAT;67[--sp] = r0; /* Skip IPEND as well. */68/* Switch to other method of keeping interrupts disabled. */69#ifdef CONFIG_DEBUG_HWERR70r0 = 0x3f;71sti r0;72#else73cli r0;74#endif75#ifdef CONFIG_TRACE_IRQFLAGS76sp += -12;77call _trace_hardirqs_off;78sp += 12;79#endif80[--sp] = RETI; /*orig_pc*/81/* Clear all L registers. */82r0 = 0 (x);83l0 = r0;84l1 = r0;85l2 = r0;86l3 = r0;87.endm8889.macro save_context_syscall90[--sp] = SYSCFG;9192[--sp] = P0; /*orig_p0*/93[--sp] = R0; /*orig_r0*/94[--sp] = ( R7:0, P5:0 );95[--sp] = fp;96[--sp] = usp;9798[--sp] = i0;99[--sp] = i1;100[--sp] = i2;101[--sp] = i3;102103[--sp] = m0;104[--sp] = m1;105[--sp] = m2;106[--sp] = m3;107108[--sp] = l0;109[--sp] = l1;110[--sp] = l2;111[--sp] = l3;112113[--sp] = b0;114[--sp] = b1;115[--sp] = b2;116[--sp] = b3;117[--sp] = a0.x;118[--sp] = a0.w;119[--sp] = a1.x;120[--sp] = a1.w;121122[--sp] = LC0;123[--sp] = LC1;124[--sp] = LT0;125[--sp] = LT1;126[--sp] = LB0;127[--sp] = LB1;128129[--sp] = ASTAT;130131[--sp] = r0; /* Skip reserved */132[--sp] = RETS;133r0 = RETI;134[--sp] = r0;135[--sp] = RETX;136[--sp] = RETN;137[--sp] = RETE;138[--sp] = SEQSTAT;139[--sp] = r0; /* Skip IPEND as well. */140[--sp] = RETI; /*orig_pc*/141/* Clear all L registers. */142r0 = 0 (x);143l0 = r0;144l1 = r0;145l2 = r0;146l3 = r0;147.endm148149.macro save_context_no_interrupts150[--sp] = SYSCFG;151[--sp] = P0; /* orig_p0 */152[--sp] = R0; /* orig_r0 */153[--sp] = ( R7:0, P5:0 );154[--sp] = fp;155[--sp] = usp;156157[--sp] = i0;158[--sp] = i1;159[--sp] = i2;160[--sp] = i3;161162[--sp] = m0;163[--sp] = m1;164[--sp] = m2;165[--sp] = m3;166167[--sp] = l0;168[--sp] = l1;169[--sp] = l2;170[--sp] = l3;171172[--sp] = b0;173[--sp] = b1;174[--sp] = b2;175[--sp] = b3;176[--sp] = a0.x;177[--sp] = a0.w;178[--sp] = a1.x;179[--sp] = a1.w;180181[--sp] = LC0;182[--sp] = LC1;183[--sp] = LT0;184[--sp] = LT1;185[--sp] = LB0;186[--sp] = LB1;187188[--sp] = ASTAT;189190#ifdef CONFIG_KGDB191fp = 0(Z);192r1 = sp;193r1 += 60;194r1 += 60;195r1 += 60;196[--sp] = r1;197#else198[--sp] = r0; /* Skip reserved */199#endif200[--sp] = RETS;201r0 = RETI;202[--sp] = r0;203[--sp] = RETX;204[--sp] = RETN;205[--sp] = RETE;206[--sp] = SEQSTAT;207#ifdef CONFIG_DEBUG_KERNEL208p1.l = lo(IPEND);209p1.h = hi(IPEND);210r1 = [p1];211[--sp] = r1;212#else213[--sp] = r0; /* Skip IPEND as well. */214#endif215[--sp] = r0; /*orig_pc*/216/* Clear all L registers. */217r0 = 0 (x);218l0 = r0;219l1 = r0;220l2 = r0;221l3 = r0;222.endm223224.macro restore_context_no_interrupts225sp += 4; /* Skip orig_pc */226sp += 4; /* Skip IPEND */227SEQSTAT = [sp++];228RETE = [sp++];229RETN = [sp++];230RETX = [sp++];231r0 = [sp++];232RETI = r0; /* Restore RETI indirectly when in exception */233RETS = [sp++];234235sp += 4; /* Skip Reserved */236237ASTAT = [sp++];238239LB1 = [sp++];240LB0 = [sp++];241LT1 = [sp++];242LT0 = [sp++];243LC1 = [sp++];244LC0 = [sp++];245246a1.w = [sp++];247a1.x = [sp++];248a0.w = [sp++];249a0.x = [sp++];250b3 = [sp++];251b2 = [sp++];252b1 = [sp++];253b0 = [sp++];254255l3 = [sp++];256l2 = [sp++];257l1 = [sp++];258l0 = [sp++];259260m3 = [sp++];261m2 = [sp++];262m1 = [sp++];263m0 = [sp++];264265i3 = [sp++];266i2 = [sp++];267i1 = [sp++];268i0 = [sp++];269270sp += 4;271fp = [sp++];272273( R7 : 0, P5 : 0) = [ SP ++ ];274sp += 8; /* Skip orig_r0/orig_p0 */275SYSCFG = [sp++];276.endm277278.macro restore_context_with_interrupts279sp += 4; /* Skip orig_pc */280sp += 4; /* Skip IPEND */281SEQSTAT = [sp++];282RETE = [sp++];283RETN = [sp++];284RETX = [sp++];285RETI = [sp++];286287#ifdef CONFIG_TRACE_IRQFLAGS288sp += -12;289call _trace_hardirqs_on;290sp += 12;291#endif292293RETS = [sp++];294295#ifdef CONFIG_SMP296GET_PDA(p0, r0);297r0 = [p0 + PDA_IRQFLAGS];298#else299p0.h = _bfin_irq_flags;300p0.l = _bfin_irq_flags;301r0 = [p0];302#endif303sti r0;304305sp += 4; /* Skip Reserved */306307ASTAT = [sp++];308309LB1 = [sp++];310LB0 = [sp++];311LT1 = [sp++];312LT0 = [sp++];313LC1 = [sp++];314LC0 = [sp++];315316a1.w = [sp++];317a1.x = [sp++];318a0.w = [sp++];319a0.x = [sp++];320b3 = [sp++];321b2 = [sp++];322b1 = [sp++];323b0 = [sp++];324325l3 = [sp++];326l2 = [sp++];327l1 = [sp++];328l0 = [sp++];329330m3 = [sp++];331m2 = [sp++];332m1 = [sp++];333m0 = [sp++];334335i3 = [sp++];336i2 = [sp++];337i1 = [sp++];338i0 = [sp++];339340sp += 4;341fp = [sp++];342343( R7 : 0, P5 : 0) = [ SP ++ ];344sp += 8; /* Skip orig_r0/orig_p0 */345csync;346SYSCFG = [sp++];347csync;348.endm349350.macro save_context_cplb351[--sp] = (R7:0, P5:0);352[--sp] = fp;353354[--sp] = a0.x;355[--sp] = a0.w;356[--sp] = a1.x;357[--sp] = a1.w;358359[--sp] = LC0;360[--sp] = LC1;361[--sp] = LT0;362[--sp] = LT1;363[--sp] = LB0;364[--sp] = LB1;365366[--sp] = RETS;367.endm368369.macro restore_context_cplb370RETS = [sp++];371372LB1 = [sp++];373LB0 = [sp++];374LT1 = [sp++];375LT0 = [sp++];376LC1 = [sp++];377LC0 = [sp++];378379a1.w = [sp++];380a1.x = [sp++];381a0.w = [sp++];382a0.x = [sp++];383384fp = [sp++];385386(R7:0, P5:0) = [SP++];387.endm388389.macro pseudo_long_call func:req, scratch:req390#ifdef CONFIG_ROMKERNEL391\scratch\().l = \func;392\scratch\().h = \func;393call (\scratch);394#else395call \func;396#endif397.endm398399400