aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arc/include
diff options
context:
space:
mode:
authorVineet Gupta <vgupta@synopsys.com>2013-05-28 03:54:43 -0400
committerVineet Gupta <vgupta@synopsys.com>2013-06-22 09:53:23 -0400
commit3ebedbb2fdf730b7e5e2417dbd37faee6304bfb5 (patch)
treec902fc923c5094ca614b389399c3b9ebb2ee90be /arch/arc/include
parent16f9afe651e8197fb7ce6df0990d8e2ad779e1af (diff)
ARC: Increase readability of entry handlers
* use artificial PUSH/POP contructs for CORE Reg save/restore to stack * use artificial PUSHAX/POPAX contructs for Auxiliary Space regs * macro'ize multiple copies of callee-reg-save/restore (SAVE_R13_TO_R24) * use BIC insn for inverse-and operation Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Diffstat (limited to 'arch/arc/include')
-rw-r--r--arch/arc/include/asm/entry.h394
1 files changed, 182 insertions, 212 deletions
diff --git a/arch/arc/include/asm/entry.h b/arch/arc/include/asm/entry.h
index 820202af21a5..5191945f3d39 100644
--- a/arch/arc/include/asm/entry.h
+++ b/arch/arc/include/asm/entry.h
@@ -50,150 +50,155 @@
50 * Eff Addr for load = [reg2] 50 * Eff Addr for load = [reg2]
51 */ 51 */
52 52
53.macro PUSH reg
54 st.a \reg, [sp, -4]
55.endm
56
57.macro PUSHAX aux
58 lr r9, [\aux]
59 PUSH r9
60.endm
61
62.macro POP reg
63 ld.ab \reg, [sp, 4]
64.endm
65
66.macro POPAX aux
67 POP r9
68 sr r9, [\aux]
69.endm
70
53/*-------------------------------------------------------------- 71/*--------------------------------------------------------------
54 * Save caller saved registers (scratch registers) ( r0 - r12 ) 72 * Helpers to save/restore Scratch Regs:
55 * Registers are pushed / popped in the order defined in struct ptregs 73 * used by Interrupt/Exception Prologue/Epilogue
56 * in asm/ptrace.h
57 *-------------------------------------------------------------*/ 74 *-------------------------------------------------------------*/
58.macro SAVE_CALLER_SAVED 75.macro SAVE_R0_TO_R12
59 st.a r0, [sp, -4] 76 PUSH r0
60 st.a r1, [sp, -4] 77 PUSH r1
61 st.a r2, [sp, -4] 78 PUSH r2
62 st.a r3, [sp, -4] 79 PUSH r3
63 st.a r4, [sp, -4] 80 PUSH r4
64 st.a r5, [sp, -4] 81 PUSH r5
65 st.a r6, [sp, -4] 82 PUSH r6
66 st.a r7, [sp, -4] 83 PUSH r7
67 st.a r8, [sp, -4] 84 PUSH r8
68 st.a r9, [sp, -4] 85 PUSH r9
69 st.a r10, [sp, -4] 86 PUSH r10
70 st.a r11, [sp, -4] 87 PUSH r11
71 st.a r12, [sp, -4] 88 PUSH r12
89.endm
90
91.macro RESTORE_R12_TO_R0
92 POP r12
93 POP r11
94 POP r10
95 POP r9
96 POP r8
97 POP r7
98 POP r6
99 POP r5
100 POP r4
101 POP r3
102 POP r2
103 POP r1
104 POP r0
72.endm 105.endm
73 106
74/*-------------------------------------------------------------- 107/*--------------------------------------------------------------
75 * Restore caller saved registers (scratch registers) 108 * Helpers to save/restore callee-saved regs:
109 * used by several macros below
76 *-------------------------------------------------------------*/ 110 *-------------------------------------------------------------*/
77.macro RESTORE_CALLER_SAVED 111.macro SAVE_R13_TO_R24
78 ld.ab r12, [sp, 4] 112 PUSH r13
79 ld.ab r11, [sp, 4] 113 PUSH r14
80 ld.ab r10, [sp, 4] 114 PUSH r15
81 ld.ab r9, [sp, 4] 115 PUSH r16
82 ld.ab r8, [sp, 4] 116 PUSH r17
83 ld.ab r7, [sp, 4] 117 PUSH r18
84 ld.ab r6, [sp, 4] 118 PUSH r19
85 ld.ab r5, [sp, 4] 119 PUSH r20
86 ld.ab r4, [sp, 4] 120 PUSH r21
87 ld.ab r3, [sp, 4] 121 PUSH r22
88 ld.ab r2, [sp, 4] 122 PUSH r23
89 ld.ab r1, [sp, 4] 123 PUSH r24
90 ld.ab r0, [sp, 4] 124.endm
125
126.macro RESTORE_R24_TO_R13
127 POP r24
128 POP r23
129 POP r22
130 POP r21
131 POP r20
132 POP r19
133 POP r18
134 POP r17
135 POP r16
136 POP r15
137 POP r14
138 POP r13
91.endm 139.endm
92 140
93 141
94/*-------------------------------------------------------------- 142/*--------------------------------------------------------------
95 * Save callee saved registers (non scratch registers) ( r13 - r25 ) 143 * Collect User Mode callee regs as struct callee_regs - needed by
96 * on kernel stack. 144 * fork/do_signal/unaligned-access-emulation.
97 * User mode callee regs need to be saved in case of 145 * (By default only scratch regs are saved on entry to kernel)
98 * -fork and friends for replicating from parent to child 146 *
99 * -before going into do_signal( ) for ptrace/core-dump 147 * Special handling for r25 if used for caching Task Pointer.
100 * Special case handling is required for r25 in case it is used by kernel 148 * It would have been saved in task->thread.user_r25 already, but to keep
101 * for caching task ptr. Low level exception/ISR save user mode r25 149 * the interface same it is copied into regular r25 placeholder in
102 * into task->thread.user_r25. So it needs to be retrieved from there and 150 * struct callee_regs.
103 * saved into kernel stack with rest of callee reg-file
104 *-------------------------------------------------------------*/ 151 *-------------------------------------------------------------*/
105.macro SAVE_CALLEE_SAVED_USER 152.macro SAVE_CALLEE_SAVED_USER
106 st.a r13, [sp, -4] 153
107 st.a r14, [sp, -4] 154 SAVE_R13_TO_R24
108 st.a r15, [sp, -4]
109 st.a r16, [sp, -4]
110 st.a r17, [sp, -4]
111 st.a r18, [sp, -4]
112 st.a r19, [sp, -4]
113 st.a r20, [sp, -4]
114 st.a r21, [sp, -4]
115 st.a r22, [sp, -4]
116 st.a r23, [sp, -4]
117 st.a r24, [sp, -4]
118 155
119#ifdef CONFIG_ARC_CURR_IN_REG 156#ifdef CONFIG_ARC_CURR_IN_REG
120 ; Retrieve orig r25 and save it on stack 157 ; Retrieve orig r25 and save it on stack
121 ld r12, [r25, TASK_THREAD + THREAD_USER_R25] 158 ld r12, [r25, TASK_THREAD + THREAD_USER_R25]
122 st.a r12, [sp, -4] 159 st.a r12, [sp, -4]
123#else 160#else
124 st.a r25, [sp, -4] 161 PUSH r25
125#endif 162#endif
126 163
127.endm 164.endm
128 165
129/*-------------------------------------------------------------- 166/*--------------------------------------------------------------
130 * Save callee saved registers (non scratch registers) ( r13 - r25 ) 167 * Save kernel Mode callee regs at the time of Contect Switch.
131 * kernel mode callee regs needed to be saved in case of context switch 168 *
132 * If r25 is used for caching task pointer then that need not be saved 169 * Special handling for r25 if used for caching Task Pointer.
133 * as it can be re-created from current task global 170 * Kernel simply skips saving it since it will be loaded with
171 * incoming task pointer anyways
134 *-------------------------------------------------------------*/ 172 *-------------------------------------------------------------*/
135.macro SAVE_CALLEE_SAVED_KERNEL 173.macro SAVE_CALLEE_SAVED_KERNEL
136 st.a r13, [sp, -4] 174
137 st.a r14, [sp, -4] 175 SAVE_R13_TO_R24
138 st.a r15, [sp, -4] 176
139 st.a r16, [sp, -4]
140 st.a r17, [sp, -4]
141 st.a r18, [sp, -4]
142 st.a r19, [sp, -4]
143 st.a r20, [sp, -4]
144 st.a r21, [sp, -4]
145 st.a r22, [sp, -4]
146 st.a r23, [sp, -4]
147 st.a r24, [sp, -4]
148#ifdef CONFIG_ARC_CURR_IN_REG 177#ifdef CONFIG_ARC_CURR_IN_REG
149 sub sp, sp, 4 178 sub sp, sp, 4
150#else 179#else
151 st.a r25, [sp, -4] 180 PUSH r25
152#endif 181#endif
153.endm 182.endm
154 183
155/*-------------------------------------------------------------- 184/*--------------------------------------------------------------
156 * RESTORE_CALLEE_SAVED_KERNEL: 185 * Opposite of SAVE_CALLEE_SAVED_KERNEL
157 * Loads callee (non scratch) Reg File by popping from Kernel mode stack.
158 * This is reverse of SAVE_CALLEE_SAVED,
159 *
160 * NOTE:
161 * Ideally this shd only be called in switch_to for loading
162 * switched-IN task's CALLEE Reg File.
163 * For all other cases RESTORE_CALLEE_SAVED_FAST must be used
164 * which simply pops the stack w/o touching regs.
165 *-------------------------------------------------------------*/ 186 *-------------------------------------------------------------*/
166.macro RESTORE_CALLEE_SAVED_KERNEL 187.macro RESTORE_CALLEE_SAVED_KERNEL
167 188
168#ifdef CONFIG_ARC_CURR_IN_REG 189#ifdef CONFIG_ARC_CURR_IN_REG
169 add sp, sp, 4 /* skip usual r25 placeholder */ 190 add sp, sp, 4 /* skip usual r25 placeholder */
170#else 191#else
171 ld.ab r25, [sp, 4] 192 POP r25
172#endif 193#endif
173 ld.ab r24, [sp, 4] 194 RESTORE_R24_TO_R13
174 ld.ab r23, [sp, 4]
175 ld.ab r22, [sp, 4]
176 ld.ab r21, [sp, 4]
177 ld.ab r20, [sp, 4]
178 ld.ab r19, [sp, 4]
179 ld.ab r18, [sp, 4]
180 ld.ab r17, [sp, 4]
181 ld.ab r16, [sp, 4]
182 ld.ab r15, [sp, 4]
183 ld.ab r14, [sp, 4]
184 ld.ab r13, [sp, 4]
185
186.endm 195.endm
187 196
188/*-------------------------------------------------------------- 197/*--------------------------------------------------------------
189 * RESTORE_CALLEE_SAVED_USER: 198 * Opposite of SAVE_CALLEE_SAVED_USER
190 * This is called after do_signal where tracer might have changed callee regs 199 *
191 * thus we need to restore the reg file. 200 * ptrace tracer or unaligned-access fixup might have changed a user mode
192 * Special case handling is required for r25 in case it is used by kernel 201 * callee reg which is saved back to usual r25 storage location
193 * for caching task ptr. Ptrace would have modified on-kernel-stack value of
194 * r25, which needs to be shoved back into task->thread.user_r25 where from
195 * Low level exception/ISR return code will retrieve to populate with rest of
196 * callee reg-file.
197 *-------------------------------------------------------------*/ 202 *-------------------------------------------------------------*/
198.macro RESTORE_CALLEE_SAVED_USER 203.macro RESTORE_CALLEE_SAVED_USER
199 204
@@ -201,21 +206,9 @@
201 ld.ab r12, [sp, 4] 206 ld.ab r12, [sp, 4]
202 st r12, [r25, TASK_THREAD + THREAD_USER_R25] 207 st r12, [r25, TASK_THREAD + THREAD_USER_R25]
203#else 208#else
204 ld.ab r25, [sp, 4] 209 POP r25
205#endif 210#endif
206 211 RESTORE_R24_TO_R13
207 ld.ab r24, [sp, 4]
208 ld.ab r23, [sp, 4]
209 ld.ab r22, [sp, 4]
210 ld.ab r21, [sp, 4]
211 ld.ab r20, [sp, 4]
212 ld.ab r19, [sp, 4]
213 ld.ab r18, [sp, 4]
214 ld.ab r17, [sp, 4]
215 ld.ab r16, [sp, 4]
216 ld.ab r15, [sp, 4]
217 ld.ab r14, [sp, 4]
218 ld.ab r13, [sp, 4]
219.endm 212.endm
220 213
221/*-------------------------------------------------------------- 214/*--------------------------------------------------------------
@@ -357,7 +350,7 @@
357 * @reg [OUT] &thread_info of "current" 350 * @reg [OUT] &thread_info of "current"
358 */ 351 */
359.macro GET_CURR_THR_INFO_FROM_SP reg 352.macro GET_CURR_THR_INFO_FROM_SP reg
360 and \reg, sp, ~(THREAD_SIZE - 1) 353 bic \reg, sp, (THREAD_SIZE - 1)
361.endm 354.endm
362 355
363/* 356/*
@@ -409,21 +402,16 @@
409 /* Restore r9 used to code the early prologue */ 402 /* Restore r9 used to code the early prologue */
410 EXCPN_PROLOG_RESTORE_REG r9 403 EXCPN_PROLOG_RESTORE_REG r9
411 404
412 SAVE_CALLER_SAVED 405 SAVE_R0_TO_R12
413 st.a r26, [sp, -4] /* gp */ 406 PUSH gp
414 st.a fp, [sp, -4] 407 PUSH fp
415 st.a blink, [sp, -4] 408 PUSH blink
416 lr r9, [eret] 409 PUSHAX eret
417 st.a r9, [sp, -4] 410 PUSHAX erstatus
418 lr r9, [erstatus] 411 PUSH lp_count
419 st.a r9, [sp, -4] 412 PUSHAX lp_end
420 st.a lp_count, [sp, -4] 413 PUSHAX lp_start
421 lr r9, [lp_end] 414 PUSHAX erbta
422 st.a r9, [sp, -4]
423 lr r9, [lp_start]
424 st.a r9, [sp, -4]
425 lr r9, [erbta]
426 st.a r9, [sp, -4]
427.endm 415.endm
428 416
429/*-------------------------------------------------------------- 417/*--------------------------------------------------------------
@@ -463,22 +451,19 @@
463 * by hardware and that is not good. 451 * by hardware and that is not good.
464 *-------------------------------------------------------------*/ 452 *-------------------------------------------------------------*/
465.macro RESTORE_ALL_SYS 453.macro RESTORE_ALL_SYS
466 ld.ab r9, [sp, 4] 454 POPAX erbta
467 sr r9, [erbta] 455 POPAX lp_start
468 ld.ab r9, [sp, 4] 456 POPAX lp_end
469 sr r9, [lp_start] 457
470 ld.ab r9, [sp, 4] 458 POP r9
471 sr r9, [lp_end] 459 mov lp_count, r9 ;LD to lp_count is not allowed
472 ld.ab r9, [sp, 4] 460
473 mov lp_count, r9 461 POPAX erstatus
474 ld.ab r9, [sp, 4] 462 POPAX eret
475 sr r9, [erstatus] 463 POP blink
476 ld.ab r9, [sp, 4] 464 POP fp
477 sr r9, [eret] 465 POP gp
478 ld.ab blink, [sp, 4] 466 RESTORE_R12_TO_R0
479 ld.ab fp, [sp, 4]
480 ld.ab r26, [sp, 4] /* gp */
481 RESTORE_CALLER_SAVED
482 467
483 ld sp, [sp] /* restore original sp */ 468 ld sp, [sp] /* restore original sp */
484 /* orig_r0 and orig_r8 skipped automatically */ 469 /* orig_r0 and orig_r8 skipped automatically */
@@ -490,9 +475,7 @@
490 *-------------------------------------------------------------*/ 475 *-------------------------------------------------------------*/
491.macro SAVE_ALL_INT1 476.macro SAVE_ALL_INT1
492 477
493 /* restore original r9 , saved in int1_saved_reg 478 /* restore original r9 to be saved as part of reg-file */
494 * It will be saved on stack in macro: SAVE_CALLER_SAVED
495 */
496#ifdef CONFIG_SMP 479#ifdef CONFIG_SMP
497 lr r9, [ARC_REG_SCRATCH_DATA0] 480 lr r9, [ARC_REG_SCRATCH_DATA0]
498#else 481#else
@@ -502,20 +485,17 @@
502 /* now we are ready to save the remaining context :) */ 485 /* now we are ready to save the remaining context :) */
503 st orig_r8_IS_IRQ1, [sp, 8] /* Event Type */ 486 st orig_r8_IS_IRQ1, [sp, 8] /* Event Type */
504 st 0, [sp, 4] /* orig_r0 , N/A for IRQ */ 487 st 0, [sp, 4] /* orig_r0 , N/A for IRQ */
505 SAVE_CALLER_SAVED 488
506 st.a r26, [sp, -4] /* gp */ 489 SAVE_R0_TO_R12
507 st.a fp, [sp, -4] 490 PUSH gp
508 st.a blink, [sp, -4] 491 PUSH fp
509 st.a ilink1, [sp, -4] 492 PUSH blink
510 lr r9, [status32_l1] 493 PUSH ilink1
511 st.a r9, [sp, -4] 494 PUSHAX status32_l1
512 st.a lp_count, [sp, -4] 495 PUSH lp_count
513 lr r9, [lp_end] 496 PUSHAX lp_end
514 st.a r9, [sp, -4] 497 PUSHAX lp_start
515 lr r9, [lp_start] 498 PUSHAX bta_l1
516 st.a r9, [sp, -4]
517 lr r9, [bta_l1]
518 st.a r9, [sp, -4]
519.endm 499.endm
520 500
521.macro SAVE_ALL_INT2 501.macro SAVE_ALL_INT2
@@ -530,20 +510,17 @@
530 /* now we are ready to save the remaining context :) */ 510 /* now we are ready to save the remaining context :) */
531 st orig_r8_IS_IRQ2, [sp, 8] /* Event Type */ 511 st orig_r8_IS_IRQ2, [sp, 8] /* Event Type */
532 st 0, [sp, 4] /* orig_r0 , N/A for IRQ */ 512 st 0, [sp, 4] /* orig_r0 , N/A for IRQ */
533 SAVE_CALLER_SAVED 513
534 st.a r26, [sp, -4] /* gp */ 514 SAVE_R0_TO_R12
535 st.a fp, [sp, -4] 515 PUSH gp
536 st.a blink, [sp, -4] 516 PUSH fp
537 st.a ilink2, [sp, -4] 517 PUSH blink
538 lr r9, [status32_l2] 518 PUSH ilink2
539 st.a r9, [sp, -4] 519 PUSHAX status32_l2
540 st.a lp_count, [sp, -4] 520 PUSH lp_count
541 lr r9, [lp_end] 521 PUSHAX lp_end
542 st.a r9, [sp, -4] 522 PUSHAX lp_start
543 lr r9, [lp_start] 523 PUSHAX bta_l2
544 st.a r9, [sp, -4]
545 lr r9, [bta_l2]
546 st.a r9, [sp, -4]
547.endm 524.endm
548 525
549/*-------------------------------------------------------------- 526/*--------------------------------------------------------------
@@ -557,48 +534,41 @@
557 *-------------------------------------------------------------*/ 534 *-------------------------------------------------------------*/
558 535
559.macro RESTORE_ALL_INT1 536.macro RESTORE_ALL_INT1
560 ld.ab r9, [sp, 4] /* Actual reg file */ 537 POPAX bta_l1
561 sr r9, [bta_l1] 538 POPAX lp_start
562 ld.ab r9, [sp, 4] 539 POPAX lp_end
563 sr r9, [lp_start] 540
564 ld.ab r9, [sp, 4] 541 POP r9
565 sr r9, [lp_end] 542 mov lp_count, r9 ;LD to lp_count is not allowed
566 ld.ab r9, [sp, 4] 543
567 mov lp_count, r9 544 POPAX status32_l1
568 ld.ab r9, [sp, 4] 545 POP ilink1
569 sr r9, [status32_l1] 546 POP blink
570 ld.ab r9, [sp, 4] 547 POP fp
571 mov ilink1, r9 548 POP gp
572 ld.ab blink, [sp, 4] 549 RESTORE_R12_TO_R0
573 ld.ab fp, [sp, 4]
574 ld.ab r26, [sp, 4] /* gp */
575 RESTORE_CALLER_SAVED
576 550
577 ld sp, [sp] /* restore original sp */ 551 ld sp, [sp] /* restore original sp */
578 /* orig_r0 and orig_r8 skipped automatically */ 552 /* orig_r0 and orig_r8 skipped automatically */
579.endm 553.endm
580 554
581.macro RESTORE_ALL_INT2 555.macro RESTORE_ALL_INT2
582 ld.ab r9, [sp, 4] 556 POPAX bta_l2
583 sr r9, [bta_l2] 557 POPAX lp_start
584 ld.ab r9, [sp, 4] 558 POPAX lp_end
585 sr r9, [lp_start] 559
586 ld.ab r9, [sp, 4] 560 POP r9
587 sr r9, [lp_end] 561 mov lp_count, r9 ;LD to lp_count is not allowed
588 ld.ab r9, [sp, 4] 562
589 mov lp_count, r9 563 POPAX status32_l2
590 ld.ab r9, [sp, 4] 564 POP ilink2
591 sr r9, [status32_l2] 565 POP blink
592 ld.ab r9, [sp, 4] 566 POP fp
593 mov ilink2, r9 567 POP gp
594 ld.ab blink, [sp, 4] 568 RESTORE_R12_TO_R0
595 ld.ab fp, [sp, 4]
596 ld.ab r26, [sp, 4] /* gp */
597 RESTORE_CALLER_SAVED
598 569
599 ld sp, [sp] /* restore original sp */ 570 ld sp, [sp] /* restore original sp */
600 /* orig_r0 and orig_r8 skipped automatically */ 571 /* orig_r0 and orig_r8 skipped automatically */
601
602.endm 572.endm
603 573
604 574