diff options
Diffstat (limited to 'arch/xtensa/kernel/entry.S')
-rw-r--r-- | arch/xtensa/kernel/entry.S | 311 |
1 files changed, 140 insertions, 171 deletions
diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S index 7e6236073397..90bfc1dbc13d 100644 --- a/arch/xtensa/kernel/entry.S +++ b/arch/xtensa/kernel/entry.S | |||
@@ -112,8 +112,8 @@ ENTRY(user_exception) | |||
112 | 112 | ||
113 | /* Save a2, a3, and depc, restore excsave_1 and set SP. */ | 113 | /* Save a2, a3, and depc, restore excsave_1 and set SP. */ |
114 | 114 | ||
115 | xsr a3, EXCSAVE_1 | 115 | xsr a3, excsave1 |
116 | rsr a0, DEPC | 116 | rsr a0, depc |
117 | s32i a1, a2, PT_AREG1 | 117 | s32i a1, a2, PT_AREG1 |
118 | s32i a0, a2, PT_AREG2 | 118 | s32i a0, a2, PT_AREG2 |
119 | s32i a3, a2, PT_AREG3 | 119 | s32i a3, a2, PT_AREG3 |
@@ -125,16 +125,16 @@ _user_exception: | |||
125 | /* Save SAR and turn off single stepping */ | 125 | /* Save SAR and turn off single stepping */ |
126 | 126 | ||
127 | movi a2, 0 | 127 | movi a2, 0 |
128 | rsr a3, SAR | 128 | rsr a3, sar |
129 | xsr a2, ICOUNTLEVEL | 129 | xsr a2, icountlevel |
130 | s32i a3, a1, PT_SAR | 130 | s32i a3, a1, PT_SAR |
131 | s32i a2, a1, PT_ICOUNTLEVEL | 131 | s32i a2, a1, PT_ICOUNTLEVEL |
132 | 132 | ||
133 | /* Rotate ws so that the current windowbase is at bit0. */ | 133 | /* Rotate ws so that the current windowbase is at bit0. */ |
134 | /* Assume ws = xxwww1yyyy. Rotate ws right, so that a2 = yyyyxxwww1 */ | 134 | /* Assume ws = xxwww1yyyy. Rotate ws right, so that a2 = yyyyxxwww1 */ |
135 | 135 | ||
136 | rsr a2, WINDOWBASE | 136 | rsr a2, windowbase |
137 | rsr a3, WINDOWSTART | 137 | rsr a3, windowstart |
138 | ssr a2 | 138 | ssr a2 |
139 | s32i a2, a1, PT_WINDOWBASE | 139 | s32i a2, a1, PT_WINDOWBASE |
140 | s32i a3, a1, PT_WINDOWSTART | 140 | s32i a3, a1, PT_WINDOWSTART |
@@ -205,12 +205,12 @@ _user_exception: | |||
205 | 205 | ||
206 | /* WINDOWBASE still in SAR! */ | 206 | /* WINDOWBASE still in SAR! */ |
207 | 207 | ||
208 | rsr a2, SAR # original WINDOWBASE | 208 | rsr a2, sar # original WINDOWBASE |
209 | movi a3, 1 | 209 | movi a3, 1 |
210 | ssl a2 | 210 | ssl a2 |
211 | sll a3, a3 | 211 | sll a3, a3 |
212 | wsr a3, WINDOWSTART # set corresponding WINDOWSTART bit | 212 | wsr a3, windowstart # set corresponding WINDOWSTART bit |
213 | wsr a2, WINDOWBASE # and WINDOWSTART | 213 | wsr a2, windowbase # and WINDOWSTART |
214 | rsync | 214 | rsync |
215 | 215 | ||
216 | /* We are back to the original stack pointer (a1) */ | 216 | /* We are back to the original stack pointer (a1) */ |
@@ -252,8 +252,8 @@ ENTRY(kernel_exception) | |||
252 | 252 | ||
253 | /* Save a0, a2, a3, DEPC and set SP. */ | 253 | /* Save a0, a2, a3, DEPC and set SP. */ |
254 | 254 | ||
255 | xsr a3, EXCSAVE_1 # restore a3, excsave_1 | 255 | xsr a3, excsave1 # restore a3, excsave_1 |
256 | rsr a0, DEPC # get a2 | 256 | rsr a0, depc # get a2 |
257 | s32i a1, a2, PT_AREG1 | 257 | s32i a1, a2, PT_AREG1 |
258 | s32i a0, a2, PT_AREG2 | 258 | s32i a0, a2, PT_AREG2 |
259 | s32i a3, a2, PT_AREG3 | 259 | s32i a3, a2, PT_AREG3 |
@@ -265,16 +265,16 @@ _kernel_exception: | |||
265 | /* Save SAR and turn off single stepping */ | 265 | /* Save SAR and turn off single stepping */ |
266 | 266 | ||
267 | movi a2, 0 | 267 | movi a2, 0 |
268 | rsr a3, SAR | 268 | rsr a3, sar |
269 | xsr a2, ICOUNTLEVEL | 269 | xsr a2, icountlevel |
270 | s32i a3, a1, PT_SAR | 270 | s32i a3, a1, PT_SAR |
271 | s32i a2, a1, PT_ICOUNTLEVEL | 271 | s32i a2, a1, PT_ICOUNTLEVEL |
272 | 272 | ||
273 | /* Rotate ws so that the current windowbase is at bit0. */ | 273 | /* Rotate ws so that the current windowbase is at bit0. */ |
274 | /* Assume ws = xxwww1yyyy. Rotate ws right, so that a2 = yyyyxxwww1 */ | 274 | /* Assume ws = xxwww1yyyy. Rotate ws right, so that a2 = yyyyxxwww1 */ |
275 | 275 | ||
276 | rsr a2, WINDOWBASE # don't need to save these, we only | 276 | rsr a2, windowbase # don't need to save these, we only |
277 | rsr a3, WINDOWSTART # need shifted windowstart: windowmask | 277 | rsr a3, windowstart # need shifted windowstart: windowmask |
278 | ssr a2 | 278 | ssr a2 |
279 | slli a2, a3, 32-WSBITS | 279 | slli a2, a3, 32-WSBITS |
280 | src a2, a3, a2 | 280 | src a2, a3, a2 |
@@ -323,24 +323,24 @@ common_exception: | |||
323 | 323 | ||
324 | /* Save some registers, disable loops and clear the syscall flag. */ | 324 | /* Save some registers, disable loops and clear the syscall flag. */ |
325 | 325 | ||
326 | rsr a2, DEBUGCAUSE | 326 | rsr a2, debugcause |
327 | rsr a3, EPC_1 | 327 | rsr a3, epc1 |
328 | s32i a2, a1, PT_DEBUGCAUSE | 328 | s32i a2, a1, PT_DEBUGCAUSE |
329 | s32i a3, a1, PT_PC | 329 | s32i a3, a1, PT_PC |
330 | 330 | ||
331 | movi a2, -1 | 331 | movi a2, -1 |
332 | rsr a3, EXCVADDR | 332 | rsr a3, excvaddr |
333 | s32i a2, a1, PT_SYSCALL | 333 | s32i a2, a1, PT_SYSCALL |
334 | movi a2, 0 | 334 | movi a2, 0 |
335 | s32i a3, a1, PT_EXCVADDR | 335 | s32i a3, a1, PT_EXCVADDR |
336 | xsr a2, LCOUNT | 336 | xsr a2, lcount |
337 | s32i a2, a1, PT_LCOUNT | 337 | s32i a2, a1, PT_LCOUNT |
338 | 338 | ||
339 | /* It is now save to restore the EXC_TABLE_FIXUP variable. */ | 339 | /* It is now save to restore the EXC_TABLE_FIXUP variable. */ |
340 | 340 | ||
341 | rsr a0, EXCCAUSE | 341 | rsr a0, exccause |
342 | movi a3, 0 | 342 | movi a3, 0 |
343 | rsr a2, EXCSAVE_1 | 343 | rsr a2, excsave1 |
344 | s32i a0, a1, PT_EXCCAUSE | 344 | s32i a0, a1, PT_EXCCAUSE |
345 | s32i a3, a2, EXC_TABLE_FIXUP | 345 | s32i a3, a2, EXC_TABLE_FIXUP |
346 | 346 | ||
@@ -352,22 +352,22 @@ common_exception: | |||
352 | * (interrupts disabled) and if this exception is not an interrupt. | 352 | * (interrupts disabled) and if this exception is not an interrupt. |
353 | */ | 353 | */ |
354 | 354 | ||
355 | rsr a3, PS | 355 | rsr a3, ps |
356 | addi a0, a0, -4 | 356 | addi a0, a0, -4 |
357 | movi a2, 1 | 357 | movi a2, 1 |
358 | extui a3, a3, 0, 1 # a3 = PS.INTLEVEL[0] | 358 | extui a3, a3, 0, 1 # a3 = PS.INTLEVEL[0] |
359 | moveqz a3, a2, a0 # a3 = 1 iff interrupt exception | 359 | moveqz a3, a2, a0 # a3 = 1 iff interrupt exception |
360 | movi a2, 1 << PS_WOE_BIT | 360 | movi a2, 1 << PS_WOE_BIT |
361 | or a3, a3, a2 | 361 | or a3, a3, a2 |
362 | rsr a0, EXCCAUSE | 362 | rsr a0, exccause |
363 | xsr a3, PS | 363 | xsr a3, ps |
364 | 364 | ||
365 | s32i a3, a1, PT_PS # save ps | 365 | s32i a3, a1, PT_PS # save ps |
366 | 366 | ||
367 | /* Save LBEG, LEND */ | 367 | /* Save lbeg, lend */ |
368 | 368 | ||
369 | rsr a2, LBEG | 369 | rsr a2, lbeg |
370 | rsr a3, LEND | 370 | rsr a3, lend |
371 | s32i a2, a1, PT_LBEG | 371 | s32i a2, a1, PT_LBEG |
372 | s32i a3, a1, PT_LEND | 372 | s32i a3, a1, PT_LEND |
373 | 373 | ||
@@ -432,7 +432,7 @@ common_exception_return: | |||
432 | 432 | ||
433 | load_xtregs_opt a1 a2 a4 a5 a6 a7 PT_XTREGS_OPT | 433 | load_xtregs_opt a1 a2 a4 a5 a6 a7 PT_XTREGS_OPT |
434 | 434 | ||
435 | wsr a3, PS /* disable interrupts */ | 435 | wsr a3, ps /* disable interrupts */ |
436 | 436 | ||
437 | _bbci.l a3, PS_UM_BIT, kernel_exception_exit | 437 | _bbci.l a3, PS_UM_BIT, kernel_exception_exit |
438 | 438 | ||
@@ -444,12 +444,12 @@ user_exception_exit: | |||
444 | 444 | ||
445 | l32i a2, a1, PT_WINDOWBASE | 445 | l32i a2, a1, PT_WINDOWBASE |
446 | l32i a3, a1, PT_WINDOWSTART | 446 | l32i a3, a1, PT_WINDOWSTART |
447 | wsr a1, DEPC # use DEPC as temp storage | 447 | wsr a1, depc # use DEPC as temp storage |
448 | wsr a3, WINDOWSTART # restore WINDOWSTART | 448 | wsr a3, windowstart # restore WINDOWSTART |
449 | ssr a2 # preserve user's WB in the SAR | 449 | ssr a2 # preserve user's WB in the SAR |
450 | wsr a2, WINDOWBASE # switch to user's saved WB | 450 | wsr a2, windowbase # switch to user's saved WB |
451 | rsync | 451 | rsync |
452 | rsr a1, DEPC # restore stack pointer | 452 | rsr a1, depc # restore stack pointer |
453 | l32i a2, a1, PT_WMASK # register frames saved (in bits 4...9) | 453 | l32i a2, a1, PT_WMASK # register frames saved (in bits 4...9) |
454 | rotw -1 # we restore a4..a7 | 454 | rotw -1 # we restore a4..a7 |
455 | _bltui a6, 16, 1f # only have to restore current window? | 455 | _bltui a6, 16, 1f # only have to restore current window? |
@@ -475,8 +475,8 @@ user_exception_exit: | |||
475 | 475 | ||
476 | /* Clear unrestored registers (don't leak anything to user-land */ | 476 | /* Clear unrestored registers (don't leak anything to user-land */ |
477 | 477 | ||
478 | 1: rsr a0, WINDOWBASE | 478 | 1: rsr a0, windowbase |
479 | rsr a3, SAR | 479 | rsr a3, sar |
480 | sub a3, a0, a3 | 480 | sub a3, a0, a3 |
481 | beqz a3, 2f | 481 | beqz a3, 2f |
482 | extui a3, a3, 0, WBBITS | 482 | extui a3, a3, 0, WBBITS |
@@ -556,7 +556,7 @@ kernel_exception_exit: | |||
556 | 556 | ||
557 | /* Test WINDOWSTART now. If spilled, do the movsp */ | 557 | /* Test WINDOWSTART now. If spilled, do the movsp */ |
558 | 558 | ||
559 | rsr a3, WINDOWSTART | 559 | rsr a3, windowstart |
560 | addi a0, a3, -1 | 560 | addi a0, a3, -1 |
561 | and a3, a3, a0 | 561 | and a3, a3, a0 |
562 | _bnez a3, common_exception_exit | 562 | _bnez a3, common_exception_exit |
@@ -604,24 +604,24 @@ common_exception_exit: | |||
604 | 604 | ||
605 | 1: l32i a2, a1, PT_PC | 605 | 1: l32i a2, a1, PT_PC |
606 | l32i a3, a1, PT_SAR | 606 | l32i a3, a1, PT_SAR |
607 | wsr a2, EPC_1 | 607 | wsr a2, epc1 |
608 | wsr a3, SAR | 608 | wsr a3, sar |
609 | 609 | ||
610 | /* Restore LBEG, LEND, LCOUNT */ | 610 | /* Restore LBEG, LEND, LCOUNT */ |
611 | 611 | ||
612 | l32i a2, a1, PT_LBEG | 612 | l32i a2, a1, PT_LBEG |
613 | l32i a3, a1, PT_LEND | 613 | l32i a3, a1, PT_LEND |
614 | wsr a2, LBEG | 614 | wsr a2, lbeg |
615 | l32i a2, a1, PT_LCOUNT | 615 | l32i a2, a1, PT_LCOUNT |
616 | wsr a3, LEND | 616 | wsr a3, lend |
617 | wsr a2, LCOUNT | 617 | wsr a2, lcount |
618 | 618 | ||
619 | /* We control single stepping through the ICOUNTLEVEL register. */ | 619 | /* We control single stepping through the ICOUNTLEVEL register. */ |
620 | 620 | ||
621 | l32i a2, a1, PT_ICOUNTLEVEL | 621 | l32i a2, a1, PT_ICOUNTLEVEL |
622 | movi a3, -2 | 622 | movi a3, -2 |
623 | wsr a2, ICOUNTLEVEL | 623 | wsr a2, icountlevel |
624 | wsr a3, ICOUNT | 624 | wsr a3, icount |
625 | 625 | ||
626 | /* Check if it was double exception. */ | 626 | /* Check if it was double exception. */ |
627 | 627 | ||
@@ -636,7 +636,7 @@ common_exception_exit: | |||
636 | l32i a1, a1, PT_AREG1 | 636 | l32i a1, a1, PT_AREG1 |
637 | rfe | 637 | rfe |
638 | 638 | ||
639 | 1: wsr a0, DEPC | 639 | 1: wsr a0, depc |
640 | l32i a0, a1, PT_AREG0 | 640 | l32i a0, a1, PT_AREG0 |
641 | l32i a1, a1, PT_AREG1 | 641 | l32i a1, a1, PT_AREG1 |
642 | rfde | 642 | rfde |
@@ -651,25 +651,25 @@ common_exception_exit: | |||
651 | 651 | ||
652 | ENTRY(debug_exception) | 652 | ENTRY(debug_exception) |
653 | 653 | ||
654 | rsr a0, EPS + XCHAL_DEBUGLEVEL | 654 | rsr a0, SREG_EPS + XCHAL_DEBUGLEVEL |
655 | bbsi.l a0, PS_EXCM_BIT, 1f # exception mode | 655 | bbsi.l a0, PS_EXCM_BIT, 1f # exception mode |
656 | 656 | ||
657 | /* Set EPC_1 and EXCCAUSE */ | 657 | /* Set EPC1 and EXCCAUSE */ |
658 | 658 | ||
659 | wsr a2, DEPC # save a2 temporarily | 659 | wsr a2, depc # save a2 temporarily |
660 | rsr a2, EPC + XCHAL_DEBUGLEVEL | 660 | rsr a2, SREG_EPC + XCHAL_DEBUGLEVEL |
661 | wsr a2, EPC_1 | 661 | wsr a2, epc1 |
662 | 662 | ||
663 | movi a2, EXCCAUSE_MAPPED_DEBUG | 663 | movi a2, EXCCAUSE_MAPPED_DEBUG |
664 | wsr a2, EXCCAUSE | 664 | wsr a2, exccause |
665 | 665 | ||
666 | /* Restore PS to the value before the debug exc but with PS.EXCM set.*/ | 666 | /* Restore PS to the value before the debug exc but with PS.EXCM set.*/ |
667 | 667 | ||
668 | movi a2, 1 << PS_EXCM_BIT | 668 | movi a2, 1 << PS_EXCM_BIT |
669 | or a2, a0, a2 | 669 | or a2, a0, a2 |
670 | movi a0, debug_exception # restore a3, debug jump vector | 670 | movi a0, debug_exception # restore a3, debug jump vector |
671 | wsr a2, PS | 671 | wsr a2, ps |
672 | xsr a0, EXCSAVE + XCHAL_DEBUGLEVEL | 672 | xsr a0, SREG_EXCSAVE + XCHAL_DEBUGLEVEL |
673 | 673 | ||
674 | /* Switch to kernel/user stack, restore jump vector, and save a0 */ | 674 | /* Switch to kernel/user stack, restore jump vector, and save a0 */ |
675 | 675 | ||
@@ -680,19 +680,19 @@ ENTRY(debug_exception) | |||
680 | movi a0, 0 | 680 | movi a0, 0 |
681 | s32i a1, a2, PT_AREG1 | 681 | s32i a1, a2, PT_AREG1 |
682 | s32i a0, a2, PT_DEPC # mark it as a regular exception | 682 | s32i a0, a2, PT_DEPC # mark it as a regular exception |
683 | xsr a0, DEPC | 683 | xsr a0, depc |
684 | s32i a3, a2, PT_AREG3 | 684 | s32i a3, a2, PT_AREG3 |
685 | s32i a0, a2, PT_AREG2 | 685 | s32i a0, a2, PT_AREG2 |
686 | mov a1, a2 | 686 | mov a1, a2 |
687 | j _kernel_exception | 687 | j _kernel_exception |
688 | 688 | ||
689 | 2: rsr a2, EXCSAVE_1 | 689 | 2: rsr a2, excsave1 |
690 | l32i a2, a2, EXC_TABLE_KSTK # load kernel stack pointer | 690 | l32i a2, a2, EXC_TABLE_KSTK # load kernel stack pointer |
691 | s32i a0, a2, PT_AREG0 | 691 | s32i a0, a2, PT_AREG0 |
692 | movi a0, 0 | 692 | movi a0, 0 |
693 | s32i a1, a2, PT_AREG1 | 693 | s32i a1, a2, PT_AREG1 |
694 | s32i a0, a2, PT_DEPC | 694 | s32i a0, a2, PT_DEPC |
695 | xsr a0, DEPC | 695 | xsr a0, depc |
696 | s32i a3, a2, PT_AREG3 | 696 | s32i a3, a2, PT_AREG3 |
697 | s32i a0, a2, PT_AREG2 | 697 | s32i a0, a2, PT_AREG2 |
698 | mov a1, a2 | 698 | mov a1, a2 |
@@ -732,12 +732,12 @@ ENTRY(unrecoverable_exception) | |||
732 | movi a0, 1 | 732 | movi a0, 1 |
733 | movi a1, 0 | 733 | movi a1, 0 |
734 | 734 | ||
735 | wsr a0, WINDOWSTART | 735 | wsr a0, windowstart |
736 | wsr a1, WINDOWBASE | 736 | wsr a1, windowbase |
737 | rsync | 737 | rsync |
738 | 738 | ||
739 | movi a1, (1 << PS_WOE_BIT) | 1 | 739 | movi a1, (1 << PS_WOE_BIT) | 1 |
740 | wsr a1, PS | 740 | wsr a1, ps |
741 | rsync | 741 | rsync |
742 | 742 | ||
743 | movi a1, init_task | 743 | movi a1, init_task |
@@ -793,7 +793,7 @@ ENTRY(fast_alloca) | |||
793 | l32i a0, a2, PT_DEPC | 793 | l32i a0, a2, PT_DEPC |
794 | _bgeui a0, VALID_DOUBLE_EXCEPTION_ADDRESS, .Lunhandled_double | 794 | _bgeui a0, VALID_DOUBLE_EXCEPTION_ADDRESS, .Lunhandled_double |
795 | 795 | ||
796 | rsr a0, DEPC # get a2 | 796 | rsr a0, depc # get a2 |
797 | s32i a4, a2, PT_AREG4 # save a4 and | 797 | s32i a4, a2, PT_AREG4 # save a4 and |
798 | s32i a0, a2, PT_AREG2 # a2 to stack | 798 | s32i a0, a2, PT_AREG2 # a2 to stack |
799 | 799 | ||
@@ -804,8 +804,8 @@ ENTRY(fast_alloca) | |||
804 | 804 | ||
805 | /* Restore a3, excsave_1 */ | 805 | /* Restore a3, excsave_1 */ |
806 | 806 | ||
807 | xsr a3, EXCSAVE_1 # make sure excsave_1 is valid for dbl. | 807 | xsr a3, excsave1 # make sure excsave_1 is valid for dbl. |
808 | rsr a4, EPC_1 # get exception address | 808 | rsr a4, epc1 # get exception address |
809 | s32i a3, a2, PT_AREG3 # save a3 to stack | 809 | s32i a3, a2, PT_AREG3 # save a3 to stack |
810 | 810 | ||
811 | #ifdef ALLOCA_EXCEPTION_IN_IRAM | 811 | #ifdef ALLOCA_EXCEPTION_IN_IRAM |
@@ -820,7 +820,7 @@ ENTRY(fast_alloca) | |||
820 | jx a3 | 820 | jx a3 |
821 | 821 | ||
822 | .Lunhandled_double: | 822 | .Lunhandled_double: |
823 | wsr a0, EXCSAVE_1 | 823 | wsr a0, excsave1 |
824 | movi a0, unrecoverable_exception | 824 | movi a0, unrecoverable_exception |
825 | callx0 a0 | 825 | callx0 a0 |
826 | 826 | ||
@@ -852,7 +852,7 @@ ENTRY(fast_alloca) | |||
852 | #endif | 852 | #endif |
853 | addi a4, a4, 3 # step over movsp | 853 | addi a4, a4, 3 # step over movsp |
854 | _EXTUI_MOVSP_DST(a0) # extract destination register | 854 | _EXTUI_MOVSP_DST(a0) # extract destination register |
855 | wsr a4, EPC_1 # save new epc_1 | 855 | wsr a4, epc1 # save new epc_1 |
856 | 856 | ||
857 | _bnei a0, 1, 1f # no 'movsp a1, ax': jump | 857 | _bnei a0, 1, 1f # no 'movsp a1, ax': jump |
858 | 858 | ||
@@ -953,14 +953,14 @@ ENTRY(fast_syscall_kernel) | |||
953 | 953 | ||
954 | /* Skip syscall. */ | 954 | /* Skip syscall. */ |
955 | 955 | ||
956 | rsr a0, EPC_1 | 956 | rsr a0, epc1 |
957 | addi a0, a0, 3 | 957 | addi a0, a0, 3 |
958 | wsr a0, EPC_1 | 958 | wsr a0, epc1 |
959 | 959 | ||
960 | l32i a0, a2, PT_DEPC | 960 | l32i a0, a2, PT_DEPC |
961 | bgeui a0, VALID_DOUBLE_EXCEPTION_ADDRESS, fast_syscall_unrecoverable | 961 | bgeui a0, VALID_DOUBLE_EXCEPTION_ADDRESS, fast_syscall_unrecoverable |
962 | 962 | ||
963 | rsr a0, DEPC # get syscall-nr | 963 | rsr a0, depc # get syscall-nr |
964 | _beqz a0, fast_syscall_spill_registers | 964 | _beqz a0, fast_syscall_spill_registers |
965 | _beqi a0, __NR_xtensa, fast_syscall_xtensa | 965 | _beqi a0, __NR_xtensa, fast_syscall_xtensa |
966 | 966 | ||
@@ -970,14 +970,14 @@ ENTRY(fast_syscall_user) | |||
970 | 970 | ||
971 | /* Skip syscall. */ | 971 | /* Skip syscall. */ |
972 | 972 | ||
973 | rsr a0, EPC_1 | 973 | rsr a0, epc1 |
974 | addi a0, a0, 3 | 974 | addi a0, a0, 3 |
975 | wsr a0, EPC_1 | 975 | wsr a0, epc1 |
976 | 976 | ||
977 | l32i a0, a2, PT_DEPC | 977 | l32i a0, a2, PT_DEPC |
978 | bgeui a0, VALID_DOUBLE_EXCEPTION_ADDRESS, fast_syscall_unrecoverable | 978 | bgeui a0, VALID_DOUBLE_EXCEPTION_ADDRESS, fast_syscall_unrecoverable |
979 | 979 | ||
980 | rsr a0, DEPC # get syscall-nr | 980 | rsr a0, depc # get syscall-nr |
981 | _beqz a0, fast_syscall_spill_registers | 981 | _beqz a0, fast_syscall_spill_registers |
982 | _beqi a0, __NR_xtensa, fast_syscall_xtensa | 982 | _beqi a0, __NR_xtensa, fast_syscall_xtensa |
983 | 983 | ||
@@ -988,10 +988,10 @@ ENTRY(fast_syscall_unrecoverable) | |||
988 | /* Restore all states. */ | 988 | /* Restore all states. */ |
989 | 989 | ||
990 | l32i a0, a2, PT_AREG0 # restore a0 | 990 | l32i a0, a2, PT_AREG0 # restore a0 |
991 | xsr a2, DEPC # restore a2, depc | 991 | xsr a2, depc # restore a2, depc |
992 | rsr a3, EXCSAVE_1 | 992 | rsr a3, excsave1 |
993 | 993 | ||
994 | wsr a0, EXCSAVE_1 | 994 | wsr a0, excsave1 |
995 | movi a0, unrecoverable_exception | 995 | movi a0, unrecoverable_exception |
996 | callx0 a0 | 996 | callx0 a0 |
997 | 997 | ||
@@ -1047,7 +1047,7 @@ ENTRY(fast_syscall_unrecoverable) | |||
1047 | 1047 | ||
1048 | ENTRY(fast_syscall_xtensa) | 1048 | ENTRY(fast_syscall_xtensa) |
1049 | 1049 | ||
1050 | xsr a3, EXCSAVE_1 # restore a3, excsave1 | 1050 | xsr a3, excsave1 # restore a3, excsave1 |
1051 | 1051 | ||
1052 | s32i a7, a2, PT_AREG7 # we need an additional register | 1052 | s32i a7, a2, PT_AREG7 # we need an additional register |
1053 | movi a7, 4 # sizeof(unsigned int) | 1053 | movi a7, 4 # sizeof(unsigned int) |
@@ -1124,13 +1124,13 @@ ENTRY(fast_syscall_spill_registers) | |||
1124 | 1124 | ||
1125 | movi a0, fast_syscall_spill_registers_fixup | 1125 | movi a0, fast_syscall_spill_registers_fixup |
1126 | s32i a0, a3, EXC_TABLE_FIXUP | 1126 | s32i a0, a3, EXC_TABLE_FIXUP |
1127 | rsr a0, WINDOWBASE | 1127 | rsr a0, windowbase |
1128 | s32i a0, a3, EXC_TABLE_PARAM | 1128 | s32i a0, a3, EXC_TABLE_PARAM |
1129 | 1129 | ||
1130 | /* Save a3 and SAR on stack. */ | 1130 | /* Save a3 and SAR on stack. */ |
1131 | 1131 | ||
1132 | rsr a0, SAR | 1132 | rsr a0, sar |
1133 | xsr a3, EXCSAVE_1 # restore a3 and excsave_1 | 1133 | xsr a3, excsave1 # restore a3 and excsave_1 |
1134 | s32i a3, a2, PT_AREG3 | 1134 | s32i a3, a2, PT_AREG3 |
1135 | s32i a4, a2, PT_AREG4 | 1135 | s32i a4, a2, PT_AREG4 |
1136 | s32i a0, a2, PT_AREG5 # store SAR to PT_AREG5 | 1136 | s32i a0, a2, PT_AREG5 # store SAR to PT_AREG5 |
@@ -1148,7 +1148,7 @@ ENTRY(fast_syscall_spill_registers) | |||
1148 | l32i a3, a2, PT_AREG5 | 1148 | l32i a3, a2, PT_AREG5 |
1149 | l32i a4, a2, PT_AREG4 | 1149 | l32i a4, a2, PT_AREG4 |
1150 | l32i a0, a2, PT_AREG0 | 1150 | l32i a0, a2, PT_AREG0 |
1151 | wsr a3, SAR | 1151 | wsr a3, sar |
1152 | l32i a3, a2, PT_AREG3 | 1152 | l32i a3, a2, PT_AREG3 |
1153 | 1153 | ||
1154 | /* Restore clobbered registers. */ | 1154 | /* Restore clobbered registers. */ |
@@ -1173,8 +1173,8 @@ ENTRY(fast_syscall_spill_registers) | |||
1173 | 1173 | ||
1174 | fast_syscall_spill_registers_fixup: | 1174 | fast_syscall_spill_registers_fixup: |
1175 | 1175 | ||
1176 | rsr a2, WINDOWBASE # get current windowbase (a2 is saved) | 1176 | rsr a2, windowbase # get current windowbase (a2 is saved) |
1177 | xsr a0, DEPC # restore depc and a0 | 1177 | xsr a0, depc # restore depc and a0 |
1178 | ssl a2 # set shift (32 - WB) | 1178 | ssl a2 # set shift (32 - WB) |
1179 | 1179 | ||
1180 | /* We need to make sure the current registers (a0-a3) are preserved. | 1180 | /* We need to make sure the current registers (a0-a3) are preserved. |
@@ -1182,12 +1182,12 @@ fast_syscall_spill_registers_fixup: | |||
1182 | * in WS, so that the exception handlers save them to the task stack. | 1182 | * in WS, so that the exception handlers save them to the task stack. |
1183 | */ | 1183 | */ |
1184 | 1184 | ||
1185 | rsr a3, EXCSAVE_1 # get spill-mask | 1185 | rsr a3, excsave1 # get spill-mask |
1186 | slli a2, a3, 1 # shift left by one | 1186 | slli a2, a3, 1 # shift left by one |
1187 | 1187 | ||
1188 | slli a3, a2, 32-WSBITS | 1188 | slli a3, a2, 32-WSBITS |
1189 | src a2, a2, a3 # a1 = xxwww1yyxxxwww1yy...... | 1189 | src a2, a2, a3 # a1 = xxwww1yyxxxwww1yy...... |
1190 | wsr a2, WINDOWSTART # set corrected windowstart | 1190 | wsr a2, windowstart # set corrected windowstart |
1191 | 1191 | ||
1192 | movi a3, exc_table | 1192 | movi a3, exc_table |
1193 | l32i a2, a3, EXC_TABLE_DOUBLE_SAVE # restore a2 | 1193 | l32i a2, a3, EXC_TABLE_DOUBLE_SAVE # restore a2 |
@@ -1201,7 +1201,7 @@ fast_syscall_spill_registers_fixup: | |||
1201 | * excsave_1: a3 | 1201 | * excsave_1: a3 |
1202 | */ | 1202 | */ |
1203 | 1203 | ||
1204 | wsr a3, WINDOWBASE | 1204 | wsr a3, windowbase |
1205 | rsync | 1205 | rsync |
1206 | 1206 | ||
1207 | /* We are now in the original frame when we entered _spill_registers: | 1207 | /* We are now in the original frame when we entered _spill_registers: |
@@ -1227,7 +1227,7 @@ fast_syscall_spill_registers_fixup: | |||
1227 | /* Jump to the exception handler. */ | 1227 | /* Jump to the exception handler. */ |
1228 | 1228 | ||
1229 | movi a3, exc_table | 1229 | movi a3, exc_table |
1230 | rsr a0, EXCCAUSE | 1230 | rsr a0, exccause |
1231 | addx4 a0, a0, a3 # find entry in table | 1231 | addx4 a0, a0, a3 # find entry in table |
1232 | l32i a0, a0, EXC_TABLE_FAST_USER # load handler | 1232 | l32i a0, a0, EXC_TABLE_FAST_USER # load handler |
1233 | jx a0 | 1233 | jx a0 |
@@ -1236,28 +1236,28 @@ fast_syscall_spill_registers_fixup_return: | |||
1236 | 1236 | ||
1237 | /* When we return here, all registers have been restored (a2: DEPC) */ | 1237 | /* When we return here, all registers have been restored (a2: DEPC) */ |
1238 | 1238 | ||
1239 | wsr a2, DEPC # exception address | 1239 | wsr a2, depc # exception address |
1240 | 1240 | ||
1241 | /* Restore fixup handler. */ | 1241 | /* Restore fixup handler. */ |
1242 | 1242 | ||
1243 | xsr a3, EXCSAVE_1 | 1243 | xsr a3, excsave1 |
1244 | movi a2, fast_syscall_spill_registers_fixup | 1244 | movi a2, fast_syscall_spill_registers_fixup |
1245 | s32i a2, a3, EXC_TABLE_FIXUP | 1245 | s32i a2, a3, EXC_TABLE_FIXUP |
1246 | rsr a2, WINDOWBASE | 1246 | rsr a2, windowbase |
1247 | s32i a2, a3, EXC_TABLE_PARAM | 1247 | s32i a2, a3, EXC_TABLE_PARAM |
1248 | l32i a2, a3, EXC_TABLE_KSTK | 1248 | l32i a2, a3, EXC_TABLE_KSTK |
1249 | 1249 | ||
1250 | /* Load WB at the time the exception occurred. */ | 1250 | /* Load WB at the time the exception occurred. */ |
1251 | 1251 | ||
1252 | rsr a3, SAR # WB is still in SAR | 1252 | rsr a3, sar # WB is still in SAR |
1253 | neg a3, a3 | 1253 | neg a3, a3 |
1254 | wsr a3, WINDOWBASE | 1254 | wsr a3, windowbase |
1255 | rsync | 1255 | rsync |
1256 | 1256 | ||
1257 | /* Restore a3 and return. */ | 1257 | /* Restore a3 and return. */ |
1258 | 1258 | ||
1259 | movi a3, exc_table | 1259 | movi a3, exc_table |
1260 | xsr a3, EXCSAVE_1 | 1260 | xsr a3, excsave1 |
1261 | 1261 | ||
1262 | rfde | 1262 | rfde |
1263 | 1263 | ||
@@ -1283,8 +1283,8 @@ ENTRY(_spill_registers) | |||
1283 | * Rotate ws right so that a4 = yyxxxwww1. | 1283 | * Rotate ws right so that a4 = yyxxxwww1. |
1284 | */ | 1284 | */ |
1285 | 1285 | ||
1286 | rsr a4, WINDOWBASE | 1286 | rsr a4, windowbase |
1287 | rsr a3, WINDOWSTART # a3 = xxxwww1yy | 1287 | rsr a3, windowstart # a3 = xxxwww1yy |
1288 | ssr a4 # holds WB | 1288 | ssr a4 # holds WB |
1289 | slli a4, a3, WSBITS | 1289 | slli a4, a3, WSBITS |
1290 | or a3, a3, a4 # a3 = xxxwww1yyxxxwww1yy | 1290 | or a3, a3, a4 # a3 = xxxwww1yyxxxwww1yy |
@@ -1302,7 +1302,7 @@ ENTRY(_spill_registers) | |||
1302 | 1302 | ||
1303 | /* Skip empty frames - get 'oldest' WINDOWSTART-bit. */ | 1303 | /* Skip empty frames - get 'oldest' WINDOWSTART-bit. */ |
1304 | 1304 | ||
1305 | wsr a3, WINDOWSTART # save shifted windowstart | 1305 | wsr a3, windowstart # save shifted windowstart |
1306 | neg a4, a3 | 1306 | neg a4, a3 |
1307 | and a3, a4, a3 # first bit set from right: 000010000 | 1307 | and a3, a4, a3 # first bit set from right: 000010000 |
1308 | 1308 | ||
@@ -1311,12 +1311,12 @@ ENTRY(_spill_registers) | |||
1311 | sub a4, a3, a4 # WSBITS-a4:number of 0-bits from right | 1311 | sub a4, a3, a4 # WSBITS-a4:number of 0-bits from right |
1312 | ssr a4 # save in SAR for later. | 1312 | ssr a4 # save in SAR for later. |
1313 | 1313 | ||
1314 | rsr a3, WINDOWBASE | 1314 | rsr a3, windowbase |
1315 | add a3, a3, a4 | 1315 | add a3, a3, a4 |
1316 | wsr a3, WINDOWBASE | 1316 | wsr a3, windowbase |
1317 | rsync | 1317 | rsync |
1318 | 1318 | ||
1319 | rsr a3, WINDOWSTART | 1319 | rsr a3, windowstart |
1320 | srl a3, a3 # shift windowstart | 1320 | srl a3, a3 # shift windowstart |
1321 | 1321 | ||
1322 | /* WB is now just one frame below the oldest frame in the register | 1322 | /* WB is now just one frame below the oldest frame in the register |
@@ -1364,11 +1364,11 @@ ENTRY(_spill_registers) | |||
1364 | .Lexit: /* Done. Do the final rotation, set WS, and return. */ | 1364 | .Lexit: /* Done. Do the final rotation, set WS, and return. */ |
1365 | 1365 | ||
1366 | rotw 1 | 1366 | rotw 1 |
1367 | rsr a3, WINDOWBASE | 1367 | rsr a3, windowbase |
1368 | ssl a3 | 1368 | ssl a3 |
1369 | movi a3, 1 | 1369 | movi a3, 1 |
1370 | sll a3, a3 | 1370 | sll a3, a3 |
1371 | wsr a3, WINDOWSTART | 1371 | wsr a3, windowstart |
1372 | ret | 1372 | ret |
1373 | 1373 | ||
1374 | .Lc4: s32e a4, a9, -16 | 1374 | .Lc4: s32e a4, a9, -16 |
@@ -1429,7 +1429,7 @@ ENTRY(_spill_registers) | |||
1429 | * however, this condition is unrecoverable in kernel space. | 1429 | * however, this condition is unrecoverable in kernel space. |
1430 | */ | 1430 | */ |
1431 | 1431 | ||
1432 | rsr a0, PS | 1432 | rsr a0, ps |
1433 | _bbci.l a0, PS_UM_BIT, 1f | 1433 | _bbci.l a0, PS_UM_BIT, 1f |
1434 | 1434 | ||
1435 | /* User space: Setup a dummy frame and kill application. | 1435 | /* User space: Setup a dummy frame and kill application. |
@@ -1439,18 +1439,18 @@ ENTRY(_spill_registers) | |||
1439 | movi a0, 1 | 1439 | movi a0, 1 |
1440 | movi a1, 0 | 1440 | movi a1, 0 |
1441 | 1441 | ||
1442 | wsr a0, WINDOWSTART | 1442 | wsr a0, windowstart |
1443 | wsr a1, WINDOWBASE | 1443 | wsr a1, windowbase |
1444 | rsync | 1444 | rsync |
1445 | 1445 | ||
1446 | movi a0, 0 | 1446 | movi a0, 0 |
1447 | 1447 | ||
1448 | movi a3, exc_table | 1448 | movi a3, exc_table |
1449 | l32i a1, a3, EXC_TABLE_KSTK | 1449 | l32i a1, a3, EXC_TABLE_KSTK |
1450 | wsr a3, EXCSAVE_1 | 1450 | wsr a3, excsave1 |
1451 | 1451 | ||
1452 | movi a4, (1 << PS_WOE_BIT) | 1 | 1452 | movi a4, (1 << PS_WOE_BIT) | 1 |
1453 | wsr a4, PS | 1453 | wsr a4, ps |
1454 | rsync | 1454 | rsync |
1455 | 1455 | ||
1456 | movi a6, SIGSEGV | 1456 | movi a6, SIGSEGV |
@@ -1459,7 +1459,7 @@ ENTRY(_spill_registers) | |||
1459 | 1459 | ||
1460 | 1: /* Kernel space: PANIC! */ | 1460 | 1: /* Kernel space: PANIC! */ |
1461 | 1461 | ||
1462 | wsr a0, EXCSAVE_1 | 1462 | wsr a0, excsave1 |
1463 | movi a0, unrecoverable_exception | 1463 | movi a0, unrecoverable_exception |
1464 | callx0 a0 # should not return | 1464 | callx0 a0 # should not return |
1465 | 1: j 1b | 1465 | 1: j 1b |
@@ -1524,7 +1524,7 @@ ENTRY(fast_second_level_miss) | |||
1524 | 1524 | ||
1525 | /* We deliberately destroy a3 that holds the exception table. */ | 1525 | /* We deliberately destroy a3 that holds the exception table. */ |
1526 | 1526 | ||
1527 | 8: rsr a3, EXCVADDR # fault address | 1527 | 8: rsr a3, excvaddr # fault address |
1528 | _PGD_OFFSET(a0, a3, a1) | 1528 | _PGD_OFFSET(a0, a3, a1) |
1529 | l32i a0, a0, 0 # read pmdval | 1529 | l32i a0, a0, 0 # read pmdval |
1530 | beqz a0, 2f | 1530 | beqz a0, 2f |
@@ -1542,7 +1542,7 @@ ENTRY(fast_second_level_miss) | |||
1542 | * pteval = ((pmdval - PAGE_OFFSET) & PAGE_MASK) | PAGE_DIRECTORY | 1542 | * pteval = ((pmdval - PAGE_OFFSET) & PAGE_MASK) | PAGE_DIRECTORY |
1543 | */ | 1543 | */ |
1544 | 1544 | ||
1545 | movi a1, -PAGE_OFFSET | 1545 | movi a1, (-PAGE_OFFSET) & 0xffffffff |
1546 | add a0, a0, a1 # pmdval - PAGE_OFFSET | 1546 | add a0, a0, a1 # pmdval - PAGE_OFFSET |
1547 | extui a1, a0, 0, PAGE_SHIFT # ... & PAGE_MASK | 1547 | extui a1, a0, 0, PAGE_SHIFT # ... & PAGE_MASK |
1548 | xor a0, a0, a1 | 1548 | xor a0, a0, a1 |
@@ -1561,7 +1561,7 @@ ENTRY(fast_second_level_miss) | |||
1561 | */ | 1561 | */ |
1562 | 1562 | ||
1563 | extui a3, a3, 28, 2 # addr. bit 28 and 29 0,1,2,3 | 1563 | extui a3, a3, 28, 2 # addr. bit 28 and 29 0,1,2,3 |
1564 | rsr a1, PTEVADDR | 1564 | rsr a1, ptevaddr |
1565 | addx2 a3, a3, a3 # -> 0,3,6,9 | 1565 | addx2 a3, a3, a3 # -> 0,3,6,9 |
1566 | srli a1, a1, PAGE_SHIFT | 1566 | srli a1, a1, PAGE_SHIFT |
1567 | extui a3, a3, 2, 2 # -> 0,0,1,2 | 1567 | extui a3, a3, 2, 2 # -> 0,0,1,2 |
@@ -1583,18 +1583,18 @@ ENTRY(fast_second_level_miss) | |||
1583 | l32i a0, a2, PT_AREG0 | 1583 | l32i a0, a2, PT_AREG0 |
1584 | l32i a1, a2, PT_AREG1 | 1584 | l32i a1, a2, PT_AREG1 |
1585 | l32i a2, a2, PT_DEPC | 1585 | l32i a2, a2, PT_DEPC |
1586 | xsr a3, EXCSAVE_1 | 1586 | xsr a3, excsave1 |
1587 | 1587 | ||
1588 | bgeui a2, VALID_DOUBLE_EXCEPTION_ADDRESS, 1f | 1588 | bgeui a2, VALID_DOUBLE_EXCEPTION_ADDRESS, 1f |
1589 | 1589 | ||
1590 | /* Restore excsave1 and return. */ | 1590 | /* Restore excsave1 and return. */ |
1591 | 1591 | ||
1592 | rsr a2, DEPC | 1592 | rsr a2, depc |
1593 | rfe | 1593 | rfe |
1594 | 1594 | ||
1595 | /* Return from double exception. */ | 1595 | /* Return from double exception. */ |
1596 | 1596 | ||
1597 | 1: xsr a2, DEPC | 1597 | 1: xsr a2, depc |
1598 | esync | 1598 | esync |
1599 | rfde | 1599 | rfde |
1600 | 1600 | ||
@@ -1618,7 +1618,7 @@ ENTRY(fast_second_level_miss) | |||
1618 | /* Make sure the exception originated in the special functions */ | 1618 | /* Make sure the exception originated in the special functions */ |
1619 | 1619 | ||
1620 | movi a0, __tlbtemp_mapping_start | 1620 | movi a0, __tlbtemp_mapping_start |
1621 | rsr a3, EPC_1 | 1621 | rsr a3, epc1 |
1622 | bltu a3, a0, 2f | 1622 | bltu a3, a0, 2f |
1623 | movi a0, __tlbtemp_mapping_end | 1623 | movi a0, __tlbtemp_mapping_end |
1624 | bgeu a3, a0, 2f | 1624 | bgeu a3, a0, 2f |
@@ -1626,7 +1626,7 @@ ENTRY(fast_second_level_miss) | |||
1626 | /* Check if excvaddr was in one of the TLBTEMP_BASE areas. */ | 1626 | /* Check if excvaddr was in one of the TLBTEMP_BASE areas. */ |
1627 | 1627 | ||
1628 | movi a3, TLBTEMP_BASE_1 | 1628 | movi a3, TLBTEMP_BASE_1 |
1629 | rsr a0, EXCVADDR | 1629 | rsr a0, excvaddr |
1630 | bltu a0, a3, 2f | 1630 | bltu a0, a3, 2f |
1631 | 1631 | ||
1632 | addi a1, a0, -(2 << (DCACHE_ALIAS_ORDER + PAGE_SHIFT)) | 1632 | addi a1, a0, -(2 << (DCACHE_ALIAS_ORDER + PAGE_SHIFT)) |
@@ -1635,7 +1635,7 @@ ENTRY(fast_second_level_miss) | |||
1635 | /* Check if we have to restore an ITLB mapping. */ | 1635 | /* Check if we have to restore an ITLB mapping. */ |
1636 | 1636 | ||
1637 | movi a1, __tlbtemp_mapping_itlb | 1637 | movi a1, __tlbtemp_mapping_itlb |
1638 | rsr a3, EPC_1 | 1638 | rsr a3, epc1 |
1639 | sub a3, a3, a1 | 1639 | sub a3, a3, a1 |
1640 | 1640 | ||
1641 | /* Calculate VPN */ | 1641 | /* Calculate VPN */ |
@@ -1671,13 +1671,13 @@ ENTRY(fast_second_level_miss) | |||
1671 | 2: /* Invalid PGD, default exception handling */ | 1671 | 2: /* Invalid PGD, default exception handling */ |
1672 | 1672 | ||
1673 | movi a3, exc_table | 1673 | movi a3, exc_table |
1674 | rsr a1, DEPC | 1674 | rsr a1, depc |
1675 | xsr a3, EXCSAVE_1 | 1675 | xsr a3, excsave1 |
1676 | s32i a1, a2, PT_AREG2 | 1676 | s32i a1, a2, PT_AREG2 |
1677 | s32i a3, a2, PT_AREG3 | 1677 | s32i a3, a2, PT_AREG3 |
1678 | mov a1, a2 | 1678 | mov a1, a2 |
1679 | 1679 | ||
1680 | rsr a2, PS | 1680 | rsr a2, ps |
1681 | bbsi.l a2, PS_UM_BIT, 1f | 1681 | bbsi.l a2, PS_UM_BIT, 1f |
1682 | j _kernel_exception | 1682 | j _kernel_exception |
1683 | 1: j _user_exception | 1683 | 1: j _user_exception |
@@ -1712,7 +1712,7 @@ ENTRY(fast_store_prohibited) | |||
1712 | l32i a0, a1, TASK_MM # tsk->mm | 1712 | l32i a0, a1, TASK_MM # tsk->mm |
1713 | beqz a0, 9f | 1713 | beqz a0, 9f |
1714 | 1714 | ||
1715 | 8: rsr a1, EXCVADDR # fault address | 1715 | 8: rsr a1, excvaddr # fault address |
1716 | _PGD_OFFSET(a0, a1, a4) | 1716 | _PGD_OFFSET(a0, a1, a4) |
1717 | l32i a0, a0, 0 | 1717 | l32i a0, a0, 0 |
1718 | beqz a0, 2f | 1718 | beqz a0, 2f |
@@ -1725,7 +1725,7 @@ ENTRY(fast_store_prohibited) | |||
1725 | 1725 | ||
1726 | movi a1, _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_HW_WRITE | 1726 | movi a1, _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_HW_WRITE |
1727 | or a4, a4, a1 | 1727 | or a4, a4, a1 |
1728 | rsr a1, EXCVADDR | 1728 | rsr a1, excvaddr |
1729 | s32i a4, a0, 0 | 1729 | s32i a4, a0, 0 |
1730 | 1730 | ||
1731 | /* We need to flush the cache if we have page coloring. */ | 1731 | /* We need to flush the cache if we have page coloring. */ |
@@ -1749,15 +1749,15 @@ ENTRY(fast_store_prohibited) | |||
1749 | 1749 | ||
1750 | /* Restore excsave1 and a3. */ | 1750 | /* Restore excsave1 and a3. */ |
1751 | 1751 | ||
1752 | xsr a3, EXCSAVE_1 | 1752 | xsr a3, excsave1 |
1753 | bgeui a2, VALID_DOUBLE_EXCEPTION_ADDRESS, 1f | 1753 | bgeui a2, VALID_DOUBLE_EXCEPTION_ADDRESS, 1f |
1754 | 1754 | ||
1755 | rsr a2, DEPC | 1755 | rsr a2, depc |
1756 | rfe | 1756 | rfe |
1757 | 1757 | ||
1758 | /* Double exception. Restore FIXUP handler and return. */ | 1758 | /* Double exception. Restore FIXUP handler and return. */ |
1759 | 1759 | ||
1760 | 1: xsr a2, DEPC | 1760 | 1: xsr a2, depc |
1761 | esync | 1761 | esync |
1762 | rfde | 1762 | rfde |
1763 | 1763 | ||
@@ -1766,14 +1766,14 @@ ENTRY(fast_store_prohibited) | |||
1766 | 1766 | ||
1767 | 2: /* If there was a problem, handle fault in C */ | 1767 | 2: /* If there was a problem, handle fault in C */ |
1768 | 1768 | ||
1769 | rsr a4, DEPC # still holds a2 | 1769 | rsr a4, depc # still holds a2 |
1770 | xsr a3, EXCSAVE_1 | 1770 | xsr a3, excsave1 |
1771 | s32i a4, a2, PT_AREG2 | 1771 | s32i a4, a2, PT_AREG2 |
1772 | s32i a3, a2, PT_AREG3 | 1772 | s32i a3, a2, PT_AREG3 |
1773 | l32i a4, a2, PT_AREG4 | 1773 | l32i a4, a2, PT_AREG4 |
1774 | mov a1, a2 | 1774 | mov a1, a2 |
1775 | 1775 | ||
1776 | rsr a2, PS | 1776 | rsr a2, ps |
1777 | bbsi.l a2, PS_UM_BIT, 1f | 1777 | bbsi.l a2, PS_UM_BIT, 1f |
1778 | j _kernel_exception | 1778 | j _kernel_exception |
1779 | 1: j _user_exception | 1779 | 1: j _user_exception |
@@ -1833,50 +1833,6 @@ ENTRY(system_call) | |||
1833 | 1833 | ||
1834 | 1834 | ||
1835 | /* | 1835 | /* |
1836 | * Create a kernel thread | ||
1837 | * | ||
1838 | * int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags) | ||
1839 | * a2 a2 a3 a4 | ||
1840 | */ | ||
1841 | |||
1842 | ENTRY(kernel_thread) | ||
1843 | entry a1, 16 | ||
1844 | |||
1845 | mov a5, a2 # preserve fn over syscall | ||
1846 | mov a7, a3 # preserve args over syscall | ||
1847 | |||
1848 | movi a3, _CLONE_VM | _CLONE_UNTRACED | ||
1849 | movi a2, __NR_clone | ||
1850 | or a6, a4, a3 # arg0: flags | ||
1851 | mov a3, a1 # arg1: sp | ||
1852 | syscall | ||
1853 | |||
1854 | beq a3, a1, 1f # branch if parent | ||
1855 | mov a6, a7 # args | ||
1856 | callx4 a5 # fn(args) | ||
1857 | |||
1858 | movi a2, __NR_exit | ||
1859 | syscall # return value of fn(args) still in a6 | ||
1860 | |||
1861 | 1: retw | ||
1862 | |||
1863 | /* | ||
1864 | * Do a system call from kernel instead of calling sys_execve, so we end up | ||
1865 | * with proper pt_regs. | ||
1866 | * | ||
1867 | * int kernel_execve(const char *fname, char *const argv[], charg *const envp[]) | ||
1868 | * a2 a2 a3 a4 | ||
1869 | */ | ||
1870 | |||
1871 | ENTRY(kernel_execve) | ||
1872 | entry a1, 16 | ||
1873 | mov a6, a2 # arg0 is in a6 | ||
1874 | movi a2, __NR_execve | ||
1875 | syscall | ||
1876 | |||
1877 | retw | ||
1878 | |||
1879 | /* | ||
1880 | * Task switch. | 1836 | * Task switch. |
1881 | * | 1837 | * |
1882 | * struct task* _switch_to (struct task* prev, struct task* next) | 1838 | * struct task* _switch_to (struct task* prev, struct task* next) |
@@ -1901,8 +1857,8 @@ ENTRY(_switch_to) | |||
1901 | /* Disable ints while we manipulate the stack pointer. */ | 1857 | /* Disable ints while we manipulate the stack pointer. */ |
1902 | 1858 | ||
1903 | movi a14, (1 << PS_EXCM_BIT) | LOCKLEVEL | 1859 | movi a14, (1 << PS_EXCM_BIT) | LOCKLEVEL |
1904 | xsr a14, PS | 1860 | xsr a14, ps |
1905 | rsr a3, EXCSAVE_1 | 1861 | rsr a3, excsave1 |
1906 | rsync | 1862 | rsync |
1907 | s32i a3, a3, EXC_TABLE_FIXUP /* enter critical section */ | 1863 | s32i a3, a3, EXC_TABLE_FIXUP /* enter critical section */ |
1908 | 1864 | ||
@@ -1910,7 +1866,7 @@ ENTRY(_switch_to) | |||
1910 | 1866 | ||
1911 | #if (XTENSA_HAVE_COPROCESSORS || XTENSA_HAVE_IO_PORTS) | 1867 | #if (XTENSA_HAVE_COPROCESSORS || XTENSA_HAVE_IO_PORTS) |
1912 | l32i a3, a5, THREAD_CPENABLE | 1868 | l32i a3, a5, THREAD_CPENABLE |
1913 | xsr a3, CPENABLE | 1869 | xsr a3, cpenable |
1914 | s32i a3, a4, THREAD_CPENABLE | 1870 | s32i a3, a4, THREAD_CPENABLE |
1915 | #endif | 1871 | #endif |
1916 | 1872 | ||
@@ -1924,7 +1880,7 @@ ENTRY(_switch_to) | |||
1924 | * we return from kernel space. | 1880 | * we return from kernel space. |
1925 | */ | 1881 | */ |
1926 | 1882 | ||
1927 | rsr a3, EXCSAVE_1 # exc_table | 1883 | rsr a3, excsave1 # exc_table |
1928 | movi a6, 0 | 1884 | movi a6, 0 |
1929 | addi a7, a5, PT_REGS_OFFSET | 1885 | addi a7, a5, PT_REGS_OFFSET |
1930 | s32i a6, a3, EXC_TABLE_FIXUP | 1886 | s32i a6, a3, EXC_TABLE_FIXUP |
@@ -1937,7 +1893,7 @@ ENTRY(_switch_to) | |||
1937 | 1893 | ||
1938 | load_xtregs_user a5 a6 a8 a9 a10 a11 THREAD_XTREGS_USER | 1894 | load_xtregs_user a5 a6 a8 a9 a10 a11 THREAD_XTREGS_USER |
1939 | 1895 | ||
1940 | wsr a14, PS | 1896 | wsr a14, ps |
1941 | mov a2, a12 # return 'prev' | 1897 | mov a2, a12 # return 'prev' |
1942 | rsync | 1898 | rsync |
1943 | 1899 | ||
@@ -1958,3 +1914,16 @@ ENTRY(ret_from_fork) | |||
1958 | 1914 | ||
1959 | j common_exception_return | 1915 | j common_exception_return |
1960 | 1916 | ||
1917 | /* | ||
1918 | * Kernel thread creation helper | ||
1919 | * On entry, set up by copy_thread: a2 = thread_fn, a3 = thread_fn arg | ||
1920 | * left from _switch_to: a6 = prev | ||
1921 | */ | ||
1922 | ENTRY(ret_from_kernel_thread) | ||
1923 | |||
1924 | call4 schedule_tail | ||
1925 | mov a6, a3 | ||
1926 | callx4 a2 | ||
1927 | j common_exception_return | ||
1928 | |||
1929 | ENDPROC(ret_from_kernel_thread) | ||