diff options
author | Michal Simek <monstr@monstr.eu> | 2010-06-22 07:27:43 -0400 |
---|---|---|
committer | Michal Simek <monstr@monstr.eu> | 2010-08-04 04:22:42 -0400 |
commit | 36f6095419b100479bd3ffabcafe4dac8d918734 (patch) | |
tree | b52030bce7137879b50a362805363be2e5edcb65 /arch | |
parent | a4a94dbf20fa2e119cf89615ef21230f9b2f8913 (diff) |
microblaze: Save and restore r3/r4 in SAVE/RESTORE_REGS macros
Save and restore R3/R4 registers in macros. This change
help to cleanup entry.S.
In ret_from_trap function we are saving returning value from
syscall to pt_regs on stack that's why we don't need to save and
restore these values before kernel functions (schedule, do_signal).
Signed-off-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/microblaze/kernel/entry.S | 48 |
1 files changed, 8 insertions, 40 deletions
diff --git a/arch/microblaze/kernel/entry.S b/arch/microblaze/kernel/entry.S index d40a59f9db4b..8f90ce7ecb6c 100644 --- a/arch/microblaze/kernel/entry.S +++ b/arch/microblaze/kernel/entry.S | |||
@@ -194,6 +194,8 @@ | |||
194 | 194 | ||
195 | #define SAVE_REGS \ | 195 | #define SAVE_REGS \ |
196 | swi r2, r1, PTO+PT_R2; /* Save SDA */ \ | 196 | swi r2, r1, PTO+PT_R2; /* Save SDA */ \ |
197 | swi r3, r1, PTO+PT_R3; \ | ||
198 | swi r4, r1, PTO+PT_R4; \ | ||
197 | swi r5, r1, PTO+PT_R5; \ | 199 | swi r5, r1, PTO+PT_R5; \ |
198 | swi r6, r1, PTO+PT_R6; \ | 200 | swi r6, r1, PTO+PT_R6; \ |
199 | swi r7, r1, PTO+PT_R7; \ | 201 | swi r7, r1, PTO+PT_R7; \ |
@@ -228,6 +230,8 @@ | |||
228 | mts rmsr , r11; \ | 230 | mts rmsr , r11; \ |
229 | nop; \ | 231 | nop; \ |
230 | lwi r2, r1, PTO+PT_R2; /* restore SDA */ \ | 232 | lwi r2, r1, PTO+PT_R2; /* restore SDA */ \ |
233 | lwi r3, r1, PTO+PT_R3; \ | ||
234 | lwi r4, r1, PTO+PT_R4; \ | ||
231 | lwi r5, r1, PTO+PT_R5; \ | 235 | lwi r5, r1, PTO+PT_R5; \ |
232 | lwi r6, r1, PTO+PT_R6; \ | 236 | lwi r6, r1, PTO+PT_R6; \ |
233 | lwi r7, r1, PTO+PT_R7; \ | 237 | lwi r7, r1, PTO+PT_R7; \ |
@@ -379,13 +383,12 @@ C_ENTRY(_user_exception): | |||
379 | /* We re-enable BIP bit before state restore */ | 383 | /* We re-enable BIP bit before state restore */ |
380 | C_ENTRY(ret_from_trap): | 384 | C_ENTRY(ret_from_trap): |
381 | set_bip; /* Ints masked for state restore*/ | 385 | set_bip; /* Ints masked for state restore*/ |
382 | lwi r11, r1, PTO+PT_MODE; | ||
383 | /* See if returning to kernel mode, if so, skip resched &c. */ | ||
384 | bnei r11, 2f; | ||
385 | |||
386 | swi r3, r1, PTO + PT_R3 | 386 | swi r3, r1, PTO + PT_R3 |
387 | swi r4, r1, PTO + PT_R4 | 387 | swi r4, r1, PTO + PT_R4 |
388 | 388 | ||
389 | lwi r11, r1, PTO+PT_MODE; | ||
390 | /* See if returning to kernel mode, if so, skip resched &c. */ | ||
391 | bnei r11, 2f; | ||
389 | /* We're returning to user mode, so check for various conditions that | 392 | /* We're returning to user mode, so check for various conditions that |
390 | * trigger rescheduling. */ | 393 | * trigger rescheduling. */ |
391 | /* FIXME: Restructure all these flag checks. */ | 394 | /* FIXME: Restructure all these flag checks. */ |
@@ -422,9 +425,6 @@ C_ENTRY(ret_from_trap): | |||
422 | 425 | ||
423 | /* Finally, return to user state. */ | 426 | /* Finally, return to user state. */ |
424 | 1: | 427 | 1: |
425 | lwi r3, r1, PTO + PT_R3; /* restore syscall result */ | ||
426 | lwi r4, r1, PTO + PT_R4; | ||
427 | |||
428 | swi r0, r0, PER_CPU(KM); /* Now officially in user state. */ | 428 | swi r0, r0, PER_CPU(KM); /* Now officially in user state. */ |
429 | swi CURRENT_TASK, r0, PER_CPU(CURRENT_SAVE); /* save current */ | 429 | swi CURRENT_TASK, r0, PER_CPU(CURRENT_SAVE); /* save current */ |
430 | VM_OFF; | 430 | VM_OFF; |
@@ -522,10 +522,6 @@ C_ENTRY(sys_rt_sigreturn_wrapper): | |||
522 | swi r11, r1, (PT_R1-PT_SIZE); /* Save original SP. */ \ | 522 | swi r11, r1, (PT_R1-PT_SIZE); /* Save original SP. */ \ |
523 | lwi r11, r0, TOPHYS(r0_ram + PTO + PT_R11); /* restore r11 */\ | 523 | lwi r11, r0, TOPHYS(r0_ram + PTO + PT_R11); /* restore r11 */\ |
524 | addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */\ | 524 | addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */\ |
525 | /* store return registers separately because \ | ||
526 | * this macros is use for others exceptions */ \ | ||
527 | swi r3, r1, PTO + PT_R3; \ | ||
528 | swi r4, r1, PTO + PT_R4; \ | ||
529 | SAVE_REGS \ | 525 | SAVE_REGS \ |
530 | /* PC, before IRQ/trap - this is one instruction above */ \ | 526 | /* PC, before IRQ/trap - this is one instruction above */ \ |
531 | swi r17, r1, PTO+PT_PC; \ | 527 | swi r17, r1, PTO+PT_PC; \ |
@@ -543,10 +539,6 @@ C_ENTRY(sys_rt_sigreturn_wrapper): | |||
543 | tophys(r1,r1); \ | 539 | tophys(r1,r1); \ |
544 | \ | 540 | \ |
545 | addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */\ | 541 | addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */\ |
546 | /* store return registers separately because this macros \ | ||
547 | * is use for others exceptions */ \ | ||
548 | swi r3, r1, PTO + PT_R3; \ | ||
549 | swi r4, r1, PTO + PT_R4; \ | ||
550 | SAVE_REGS \ | 542 | SAVE_REGS \ |
551 | /* PC, before IRQ/trap - this is one instruction above FIXME*/ \ | 543 | /* PC, before IRQ/trap - this is one instruction above FIXME*/ \ |
552 | swi r17, r1, PTO+PT_PC; \ | 544 | swi r17, r1, PTO+PT_PC; \ |
@@ -689,9 +681,7 @@ C_ENTRY(ret_from_exc): | |||
689 | * traps), but signal handlers may want to examine or change the | 681 | * traps), but signal handlers may want to examine or change the |
690 | * complete register state. Here we save anything not saved by | 682 | * complete register state. Here we save anything not saved by |
691 | * the normal entry sequence, so that it may be safely restored | 683 | * the normal entry sequence, so that it may be safely restored |
692 | * (in a possibly modified form) after do_signal returns. | 684 | * (in a possibly modified form) after do_signal returns. */ |
693 | * store return registers separately because this macros is use | ||
694 | * for others exceptions */ | ||
695 | la r5, r1, PTO; /* Arg 1: struct pt_regs *regs */ | 685 | la r5, r1, PTO; /* Arg 1: struct pt_regs *regs */ |
696 | addi r7, r0, 0; /* Arg 3: int in_syscall */ | 686 | addi r7, r0, 0; /* Arg 3: int in_syscall */ |
697 | bralid r15, do_signal; /* Handle any signals */ | 687 | bralid r15, do_signal; /* Handle any signals */ |
@@ -703,8 +693,6 @@ C_ENTRY(ret_from_exc): | |||
703 | VM_OFF; | 693 | VM_OFF; |
704 | tophys(r1,r1); | 694 | tophys(r1,r1); |
705 | 695 | ||
706 | lwi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */ | ||
707 | lwi r4, r1, PTO+PT_R4; | ||
708 | RESTORE_REGS; | 696 | RESTORE_REGS; |
709 | addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ | 697 | addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ |
710 | 698 | ||
@@ -713,8 +701,6 @@ C_ENTRY(ret_from_exc): | |||
713 | /* Return to kernel state. */ | 701 | /* Return to kernel state. */ |
714 | 2: VM_OFF; | 702 | 2: VM_OFF; |
715 | tophys(r1,r1); | 703 | tophys(r1,r1); |
716 | lwi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */ | ||
717 | lwi r4, r1, PTO+PT_R4; | ||
718 | RESTORE_REGS; | 704 | RESTORE_REGS; |
719 | addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ | 705 | addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ |
720 | 706 | ||
@@ -753,10 +739,6 @@ C_ENTRY(_interrupt): | |||
753 | /* save registers */ | 739 | /* save registers */ |
754 | /* MS: Make room on the stack -> activation record */ | 740 | /* MS: Make room on the stack -> activation record */ |
755 | addik r1, r1, -STATE_SAVE_SIZE; | 741 | addik r1, r1, -STATE_SAVE_SIZE; |
756 | /* MS: store return registers separately because | ||
757 | * this macros is use for others exceptions */ | ||
758 | swi r3, r1, PTO + PT_R3; | ||
759 | swi r4, r1, PTO + PT_R4; | ||
760 | SAVE_REGS | 742 | SAVE_REGS |
761 | /* MS: store mode */ | 743 | /* MS: store mode */ |
762 | addi r11, r0, 1; /* MS: Was in kernel-mode. */ | 744 | addi r11, r0, 1; /* MS: Was in kernel-mode. */ |
@@ -776,8 +758,6 @@ C_ENTRY(_interrupt): | |||
776 | tophys(r1,r1); | 758 | tophys(r1,r1); |
777 | /* save registers */ | 759 | /* save registers */ |
778 | addik r1, r1, -STATE_SAVE_SIZE; | 760 | addik r1, r1, -STATE_SAVE_SIZE; |
779 | swi r3, r1, PTO+PT_R3; | ||
780 | swi r4, r1, PTO+PT_R4; | ||
781 | SAVE_REGS | 761 | SAVE_REGS |
782 | /* calculate mode */ | 762 | /* calculate mode */ |
783 | swi r0, r1, PTO + PT_MODE; | 763 | swi r0, r1, PTO + PT_MODE; |
@@ -829,8 +809,6 @@ no_intr_resched: | |||
829 | swi CURRENT_TASK, r0, PER_CPU(CURRENT_SAVE); | 809 | swi CURRENT_TASK, r0, PER_CPU(CURRENT_SAVE); |
830 | VM_OFF; | 810 | VM_OFF; |
831 | tophys(r1,r1); | 811 | tophys(r1,r1); |
832 | lwi r3, r1, PTO + PT_R3; /* MS: restore saved r3, r4 registers */ | ||
833 | lwi r4, r1, PTO + PT_R4; | ||
834 | RESTORE_REGS | 812 | RESTORE_REGS |
835 | addik r1, r1, STATE_SAVE_SIZE /* MS: Clean up stack space. */ | 813 | addik r1, r1, STATE_SAVE_SIZE /* MS: Clean up stack space. */ |
836 | lwi r1, r1, PT_R1 - PT_SIZE; | 814 | lwi r1, r1, PT_R1 - PT_SIZE; |
@@ -859,8 +837,6 @@ restore: | |||
859 | #endif | 837 | #endif |
860 | VM_OFF /* MS: turn off MMU */ | 838 | VM_OFF /* MS: turn off MMU */ |
861 | tophys(r1,r1) | 839 | tophys(r1,r1) |
862 | lwi r3, r1, PTO + PT_R3; /* MS: restore saved r3, r4 registers */ | ||
863 | lwi r4, r1, PTO + PT_R4; | ||
864 | RESTORE_REGS | 840 | RESTORE_REGS |
865 | addik r1, r1, STATE_SAVE_SIZE /* MS: Clean up stack space. */ | 841 | addik r1, r1, STATE_SAVE_SIZE /* MS: Clean up stack space. */ |
866 | tovirt(r1,r1); | 842 | tovirt(r1,r1); |
@@ -893,8 +869,6 @@ C_ENTRY(_debug_exception): | |||
893 | lwi r11, r0, TOPHYS(r0_ram + PTO + PT_R11); /* restore r11 */ | 869 | lwi r11, r0, TOPHYS(r0_ram + PTO + PT_R11); /* restore r11 */ |
894 | 870 | ||
895 | addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */ | 871 | addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */ |
896 | swi r3, r1, PTO + PT_R3; | ||
897 | swi r4, r1, PTO + PT_R4; | ||
898 | SAVE_REGS; | 872 | SAVE_REGS; |
899 | 873 | ||
900 | addi r11, r0, 1; /* Was in kernel-mode. */ | 874 | addi r11, r0, 1; /* Was in kernel-mode. */ |
@@ -910,8 +884,6 @@ C_ENTRY(_debug_exception): | |||
910 | tophys(r1,r1); | 884 | tophys(r1,r1); |
911 | 885 | ||
912 | addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */ | 886 | addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */ |
913 | swi r3, r1, PTO + PT_R3; | ||
914 | swi r4, r1, PTO + PT_R4; | ||
915 | SAVE_REGS; | 887 | SAVE_REGS; |
916 | 888 | ||
917 | swi r0, r1, PTO+PT_MODE; /* Was in user-mode. */ | 889 | swi r0, r1, PTO+PT_MODE; /* Was in user-mode. */ |
@@ -979,8 +951,6 @@ dbtrap_call: rtbd r11, 0; | |||
979 | VM_OFF; | 951 | VM_OFF; |
980 | tophys(r1,r1); | 952 | tophys(r1,r1); |
981 | 953 | ||
982 | lwi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */ | ||
983 | lwi r4, r1, PTO+PT_R4; | ||
984 | RESTORE_REGS | 954 | RESTORE_REGS |
985 | addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ | 955 | addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ |
986 | 956 | ||
@@ -992,8 +962,6 @@ dbtrap_call: rtbd r11, 0; | |||
992 | /* Return to kernel state. */ | 962 | /* Return to kernel state. */ |
993 | 2: VM_OFF; | 963 | 2: VM_OFF; |
994 | tophys(r1,r1); | 964 | tophys(r1,r1); |
995 | lwi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */ | ||
996 | lwi r4, r1, PTO+PT_R4; | ||
997 | RESTORE_REGS | 965 | RESTORE_REGS |
998 | addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ | 966 | addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ |
999 | 967 | ||