180 |
|
isync |
181 |
|
lwarx r5,0,r3 |
182 |
|
cmpi 0,r5,0x0000 |
183 |
< |
beq 1f |
183 |
> |
bne 1f |
184 |
|
stwcx. r4,0,r3 |
185 |
|
bne- 0b |
186 |
|
1: isync |
344 |
|
lwz r0,56+19*4+18*8+4(r1) |
345 |
|
mtlr r0 |
346 |
|
addi r1,r1,56+19*4+18*8 |
347 |
+ |
RESTORE_SYSTEM_R2 |
348 |
+ |
RESTORE_SYSTEM_R13 |
349 |
|
blr |
350 |
|
|
351 |
|
|
382 |
|
mfxer r0 |
383 |
|
stw r0,16(r1) |
384 |
|
stw r2,12(r1) |
385 |
< |
stwu r1,-(24+16*4+15*8)(r1) |
384 |
< |
RESTORE_SYSTEM_R2 |
385 |
> |
stwu r1,-(56+16*4+15*8)(r1) |
386 |
|
|
387 |
|
// Save 68k registers (M68kRegisters) |
388 |
< |
stw r8,24+0*4(r1) // d[0]..d[7] |
389 |
< |
stw r9,24+1*4(r1) |
390 |
< |
stw r10,24+2*4(r1) |
391 |
< |
stw r11,24+3*4(r1) |
392 |
< |
stw r12,24+4*4(r1) |
393 |
< |
stw r13,24+5*4(r1) |
394 |
< |
stw r14,24+6*4(r1) |
395 |
< |
stw r15,24+7*4(r1) |
396 |
< |
stw r16,24+8*4(r1) // a[0]..a[7] |
397 |
< |
stw r17,24+9*4(r1) |
398 |
< |
stw r18,24+10*4(r1) |
399 |
< |
stw r19,24+11*4(r1) |
400 |
< |
stw r20,24+12*4(r1) |
401 |
< |
stw r21,24+13*4(r1) |
402 |
< |
stw r22,24+14*4(r1) |
403 |
< |
stw r3,24+15*4(r1) |
404 |
< |
stfd f0,24+16*4+0*8(r1) |
405 |
< |
stfd f1,24+16*4+1*8(r1) |
406 |
< |
stfd f2,24+16*4+2*8(r1) |
407 |
< |
stfd f3,24+16*4+3*8(r1) |
408 |
< |
stfd f4,24+16*4+4*8(r1) |
409 |
< |
stfd f5,24+16*4+5*8(r1) |
410 |
< |
stfd f6,24+16*4+6*8(r1) |
411 |
< |
stfd f7,24+16*4+7*8(r1) |
388 |
> |
stw r8,56+0*4(r1) // d[0]..d[7] |
389 |
> |
stw r9,56+1*4(r1) |
390 |
> |
stw r10,56+2*4(r1) |
391 |
> |
stw r11,56+3*4(r1) |
392 |
> |
stw r12,56+4*4(r1) |
393 |
> |
stw r13,56+5*4(r1) |
394 |
> |
stw r14,56+6*4(r1) |
395 |
> |
stw r15,56+7*4(r1) |
396 |
> |
stw r16,56+8*4(r1) // a[0]..a[7] |
397 |
> |
stw r17,56+9*4(r1) |
398 |
> |
stw r18,56+10*4(r1) |
399 |
> |
stw r19,56+11*4(r1) |
400 |
> |
stw r20,56+12*4(r1) |
401 |
> |
stw r21,56+13*4(r1) |
402 |
> |
stw r22,56+14*4(r1) |
403 |
> |
stw r3,56+15*4(r1) |
404 |
> |
stfd f0,56+16*4+0*8(r1) |
405 |
> |
stfd f1,56+16*4+1*8(r1) |
406 |
> |
stfd f2,56+16*4+2*8(r1) |
407 |
> |
stfd f3,56+16*4+3*8(r1) |
408 |
> |
stfd f4,56+16*4+4*8(r1) |
409 |
> |
stfd f5,56+16*4+5*8(r1) |
410 |
> |
stfd f6,56+16*4+6*8(r1) |
411 |
> |
stfd f7,56+16*4+7*8(r1) |
412 |
|
mffs f0 |
413 |
< |
stfd f8,24+16*4+8*8(r1) |
414 |
< |
stfd f9,24+16*4+9*8(r1) |
415 |
< |
stfd f10,24+16*4+10*8(r1) |
416 |
< |
stfd f11,24+16*4+11*8(r1) |
417 |
< |
stfd f12,24+16*4+12*8(r1) |
418 |
< |
stfd f13,24+16*4+13*8(r1) |
419 |
< |
stfd f0,24+16*4+14*8(r1) |
413 |
> |
stfd f8,56+16*4+8*8(r1) |
414 |
> |
stfd f9,56+16*4+9*8(r1) |
415 |
> |
stfd f10,56+16*4+10*8(r1) |
416 |
> |
stfd f11,56+16*4+11*8(r1) |
417 |
> |
stfd f12,56+16*4+12*8(r1) |
418 |
> |
stfd f13,56+16*4+13*8(r1) |
419 |
> |
stfd f0,56+16*4+14*8(r1) |
420 |
|
|
421 |
|
// Execute native routine |
422 |
|
RESTORE_SYSTEM_R2 |
423 |
|
RESTORE_SYSTEM_R13 |
424 |
< |
addi r3,r1,24 |
424 |
> |
addi r3,r1,56 |
425 |
|
mr r4,r24 |
426 |
|
bl C_SYMBOL_NAME(EmulOp) |
427 |
|
|
428 |
|
// Restore 68k registers (M68kRegisters) |
429 |
< |
lwz r8,24+0*4(r1) // d[0]..d[7] |
430 |
< |
lwz r9,24+1*4(r1) |
431 |
< |
lwz r10,24+2*4(r1) |
432 |
< |
lwz r11,24+3*4(r1) |
433 |
< |
lwz r12,24+4*4(r1) |
434 |
< |
lwz r13,24+5*4(r1) |
435 |
< |
lwz r14,24+6*4(r1) |
436 |
< |
lwz r15,24+7*4(r1) |
437 |
< |
lwz r16,24+8*4(r1) // a[0]..a[7] |
438 |
< |
lwz r17,24+9*4(r1) |
439 |
< |
lwz r18,24+10*4(r1) |
440 |
< |
lwz r19,24+11*4(r1) |
441 |
< |
lwz r20,24+12*4(r1) |
442 |
< |
lwz r21,24+13*4(r1) |
443 |
< |
lwz r22,24+14*4(r1) |
444 |
< |
lwz r3,24+15*4(r1) |
445 |
< |
lfd f13,24+16*4+14*8(r1) |
446 |
< |
lfd f0,24+16*4+0*8(r1) |
447 |
< |
lfd f1,24+16*4+1*8(r1) |
448 |
< |
lfd f2,24+16*4+2*8(r1) |
449 |
< |
lfd f3,24+16*4+3*8(r1) |
450 |
< |
lfd f4,24+16*4+4*8(r1) |
451 |
< |
lfd f5,24+16*4+5*8(r1) |
452 |
< |
lfd f6,24+16*4+6*8(r1) |
453 |
< |
lfd f7,24+16*4+7*8(r1) |
429 |
> |
lwz r8,56+0*4(r1) // d[0]..d[7] |
430 |
> |
lwz r9,56+1*4(r1) |
431 |
> |
lwz r10,56+2*4(r1) |
432 |
> |
lwz r11,56+3*4(r1) |
433 |
> |
lwz r12,56+4*4(r1) |
434 |
> |
lwz r13,56+5*4(r1) |
435 |
> |
lwz r14,56+6*4(r1) |
436 |
> |
lwz r15,56+7*4(r1) |
437 |
> |
lwz r16,56+8*4(r1) // a[0]..a[7] |
438 |
> |
lwz r17,56+9*4(r1) |
439 |
> |
lwz r18,56+10*4(r1) |
440 |
> |
lwz r19,56+11*4(r1) |
441 |
> |
lwz r20,56+12*4(r1) |
442 |
> |
lwz r21,56+13*4(r1) |
443 |
> |
lwz r22,56+14*4(r1) |
444 |
> |
lwz r3,56+15*4(r1) |
445 |
> |
lfd f13,56+16*4+14*8(r1) |
446 |
> |
lfd f0,56+16*4+0*8(r1) |
447 |
> |
lfd f1,56+16*4+1*8(r1) |
448 |
> |
lfd f2,56+16*4+2*8(r1) |
449 |
> |
lfd f3,56+16*4+3*8(r1) |
450 |
> |
lfd f4,56+16*4+4*8(r1) |
451 |
> |
lfd f5,56+16*4+5*8(r1) |
452 |
> |
lfd f6,56+16*4+6*8(r1) |
453 |
> |
lfd f7,56+16*4+7*8(r1) |
454 |
|
mtfsf 0xff,f13 |
455 |
< |
lfd f8,24+16*4+8*8(r1) |
456 |
< |
lfd f9,24+16*4+9*8(r1) |
457 |
< |
lfd f10,24+16*4+10*8(r1) |
458 |
< |
lfd f11,24+16*4+11*8(r1) |
459 |
< |
lfd f12,24+16*4+12*8(r1) |
460 |
< |
lfd f13,24+16*4+13*8(r1) |
455 |
> |
lfd f8,56+16*4+8*8(r1) |
456 |
> |
lfd f9,56+16*4+9*8(r1) |
457 |
> |
lfd f10,56+16*4+10*8(r1) |
458 |
> |
lfd f11,56+16*4+11*8(r1) |
459 |
> |
lfd f12,56+16*4+12*8(r1) |
460 |
> |
lfd f13,56+16*4+13*8(r1) |
461 |
|
|
462 |
|
// Delete PowerPC stack frame |
463 |
< |
lwz r2,24+16*4+15*8+12(r1) |
464 |
< |
lwz r0,24+16*4+15*8+16(r1) |
463 |
> |
lwz r2,56+16*4+15*8+12(r1) |
464 |
> |
lwz r0,56+16*4+15*8+16(r1) |
465 |
|
mtxer r0 |
466 |
< |
lwz r0,24+16*4+15*8+4(r1) |
466 |
> |
lwz r0,56+16*4+15*8+4(r1) |
467 |
|
mtcrf 0xff,r0 |
468 |
|
mr r1,r3 |
469 |
|
|
489 |
|
stw r1,XLM_EMUL_RETURN_STACK(0) |
490 |
|
|
491 |
|
// Preset registers for ROM boot routine |
492 |
< |
lis r3,0x40b0 // Pointer to ROM boot structure |
493 |
< |
ori r3,r3,0xd000 |
492 |
> |
lis r3,ASM_HA16(C_SYMBOL_NAME(ROMBase)) // Pointer to ROM boot structure: |
493 |
> |
lwz r3,ASM_LO16(C_SYMBOL_NAME(ROMBase))(r3) // r3 = ROMBase + 0x30d000 |
494 |
> |
addis r3,r3,ASM_HA16(0x30d000) |
495 |
> |
addi r3,r3,ASM_LO16(0x30d000) |
496 |
|
|
497 |
|
// 68k emulator is now active |
498 |
|
li r0,MODE_68K |
598 |
|
ASM_MACRO_END |
599 |
|
|
600 |
|
ASM_MACRO_START epilog |
598 |
– |
RESTORE_SYSTEM_R2 |
599 |
– |
RESTORE_SYSTEM_R13 |
601 |
|
lwz r0,64+4(r1) |
602 |
|
mtlr r0 |
603 |
|
addi r1,r1,64 |
604 |
+ |
RESTORE_SYSTEM_R2 |
605 |
+ |
RESTORE_SYSTEM_R13 |
606 |
|
blr |
607 |
|
ASM_MACRO_END |
608 |
|
|
711 |
|
* Native resource manager patches |
712 |
|
*/ |
713 |
|
|
714 |
< |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_resource) |
712 |
< |
C_SYMBOL_NAME(get_resource): |
714 |
> |
ASM_MACRO_START do_get_resource ASM_MACRO_ARG0_DEF |
715 |
|
// Create stack frame |
716 |
|
mflr r0 |
717 |
|
stw r0,8(r1) |
722 |
|
stw r4,56+4(r1) |
723 |
|
|
724 |
|
// Call old routine |
725 |
< |
lwz r0,XLM_GET_RESOURCE(0) |
725 |
> |
lwz r0,ASM_MACRO_ARG0(0) |
726 |
|
lwz r2,XLM_RES_LIB_TOC(0) |
727 |
|
mtctr r0 |
728 |
|
bctrl |
727 |
– |
RESTORE_SYSTEM_R2 |
729 |
|
stw r3,56+8(r1) // Save handle |
730 |
|
|
731 |
|
// Call CheckLoad |
732 |
+ |
RESTORE_SYSTEM_R2 |
733 |
+ |
RESTORE_SYSTEM_R13 |
734 |
|
lwz r3,56(r1) |
735 |
|
lha r4,56+6(r1) |
736 |
|
lwz r5,56+8(r1) |
742 |
|
mtlr r0 |
743 |
|
addi r1,r1,56+12 |
744 |
|
blr |
745 |
+ |
ASM_MACRO_END |
746 |
+ |
|
747 |
+ |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_resource) |
748 |
+ |
C_SYMBOL_NAME(get_resource): |
749 |
+ |
do_get_resource XLM_GET_RESOURCE |
750 |
|
|
751 |
|
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_1_resource) |
752 |
|
C_SYMBOL_NAME(get_1_resource): |
753 |
< |
// Create stack frame |
746 |
< |
mflr r0 |
747 |
< |
stw r0,8(r1) |
748 |
< |
stwu r1,-(56+12)(r1) |
749 |
< |
|
750 |
< |
// Save type/ID |
751 |
< |
stw r3,56(r1) |
752 |
< |
stw r4,56+4(r1) |
753 |
< |
|
754 |
< |
// Call old routine |
755 |
< |
lwz r0,XLM_GET_1_RESOURCE(0) |
756 |
< |
lwz r2,XLM_RES_LIB_TOC(0) |
757 |
< |
mtctr r0 |
758 |
< |
bctrl |
759 |
< |
RESTORE_SYSTEM_R2 |
760 |
< |
stw r3,56+8(r1) // Save handle |
761 |
< |
|
762 |
< |
// Call CheckLoad |
763 |
< |
lwz r3,56(r1) |
764 |
< |
lha r4,56+6(r1) |
765 |
< |
lwz r5,56+8(r1) |
766 |
< |
bl C_SYMBOL_NAME(check_load_invoc) |
767 |
< |
lwz r3,56+8(r1) // Restore handle |
768 |
< |
|
769 |
< |
// Return to caller |
770 |
< |
lwz r0,56+12+8(r1) |
771 |
< |
mtlr r0 |
772 |
< |
addi r1,r1,56+12 |
773 |
< |
blr |
753 |
> |
do_get_resource XLM_GET_1_RESOURCE |
754 |
|
|
755 |
|
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_ind_resource) |
756 |
|
C_SYMBOL_NAME(get_ind_resource): |
757 |
< |
// Create stack frame |
778 |
< |
mflr r0 |
779 |
< |
stw r0,8(r1) |
780 |
< |
stwu r1,-(56+12)(r1) |
781 |
< |
|
782 |
< |
// Save type/index |
783 |
< |
stw r3,56(r1) |
784 |
< |
stw r4,56+4(r1) |
785 |
< |
|
786 |
< |
// Call old routine |
787 |
< |
lwz r0,XLM_GET_IND_RESOURCE(0) |
788 |
< |
lwz r2,XLM_RES_LIB_TOC(0) |
789 |
< |
mtctr r0 |
790 |
< |
bctrl |
791 |
< |
RESTORE_SYSTEM_R2 |
792 |
< |
stw r3,56+8(r1) // Save handle |
793 |
< |
|
794 |
< |
// Call CheckLoad |
795 |
< |
lwz r3,56(r1) |
796 |
< |
lha r4,56+6(r1) |
797 |
< |
lwz r5,56+8(r1) |
798 |
< |
bl C_SYMBOL_NAME(check_load_invoc) |
799 |
< |
lwz r3,56+8(r1) // Restore handle |
800 |
< |
|
801 |
< |
// Return to caller |
802 |
< |
lwz r0,56+12+8(r1) |
803 |
< |
mtlr r0 |
804 |
< |
addi r1,r1,56+12 |
805 |
< |
blr |
757 |
> |
do_get_resource XLM_GET_IND_RESOURCE |
758 |
|
|
759 |
|
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_1_ind_resource) |
760 |
|
C_SYMBOL_NAME(get_1_ind_resource): |
761 |
< |
// Create stack frame |
810 |
< |
mflr r0 |
811 |
< |
stw r0,8(r1) |
812 |
< |
stwu r1,-(56+12)(r1) |
813 |
< |
|
814 |
< |
// Save type/index |
815 |
< |
stw r3,56(r1) |
816 |
< |
stw r4,56+4(r1) |
817 |
< |
|
818 |
< |
// Call old routine |
819 |
< |
lwz r0,XLM_GET_1_IND_RESOURCE(0) |
820 |
< |
lwz r2,XLM_RES_LIB_TOC(0) |
821 |
< |
mtctr r0 |
822 |
< |
bctrl |
823 |
< |
RESTORE_SYSTEM_R2 |
824 |
< |
stw r3,56+8(r1) // Save handle |
825 |
< |
|
826 |
< |
// Call CheckLoad |
827 |
< |
lwz r3,56(r1) |
828 |
< |
lha r4,56+6(r1) |
829 |
< |
lwz r5,56+8(r1) |
830 |
< |
bl C_SYMBOL_NAME(check_load_invoc) |
831 |
< |
lwz r3,56+8(r1) // Restore handle |
832 |
< |
|
833 |
< |
// Return to caller |
834 |
< |
lwz r0,56+12+8(r1) |
835 |
< |
mtlr r0 |
836 |
< |
addi r1,r1,56+12 |
837 |
< |
blr |
761 |
> |
do_get_resource XLM_GET_1_IND_RESOURCE |
762 |
|
|
763 |
|
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(r_get_resource) |
764 |
|
C_SYMBOL_NAME(r_get_resource): |
765 |
+ |
do_get_resource XLM_R_GET_RESOURCE |
766 |
+ |
|
767 |
+ |
ASM_MACRO_START do_get_named_resource ASM_MACRO_ARG0_DEF |
768 |
|
// Create stack frame |
769 |
|
mflr r0 |
770 |
|
stw r0,8(r1) |
775 |
|
stw r4,56+4(r1) |
776 |
|
|
777 |
|
// Call old routine |
778 |
< |
lwz r0,XLM_R_GET_RESOURCE(0) |
778 |
> |
lwz r0,ASM_MACRO_ARG0(0) |
779 |
|
lwz r2,XLM_RES_LIB_TOC(0) |
780 |
|
mtctr r0 |
781 |
|
bctrl |
855 |
– |
RESTORE_SYSTEM_R2 |
782 |
|
stw r3,56+8(r1) // Save handle |
783 |
|
|
784 |
|
// Call CheckLoad |
785 |
+ |
RESTORE_SYSTEM_R2 |
786 |
+ |
RESTORE_SYSTEM_R13 |
787 |
|
lwz r3,56(r1) |
788 |
< |
lha r4,56+6(r1) |
788 |
> |
lwz r4,56+4(r1) |
789 |
|
lwz r5,56+8(r1) |
790 |
< |
bl C_SYMBOL_NAME(check_load_invoc) |
790 |
> |
bl C_SYMBOL_NAME(named_check_load_invoc) |
791 |
|
lwz r3,56+8(r1) // Restore handle |
792 |
|
|
793 |
|
// Return to caller |
795 |
|
mtlr r0 |
796 |
|
addi r1,r1,56+12 |
797 |
|
blr |
798 |
+ |
ASM_MACRO_END |
799 |
+ |
|
800 |
+ |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_named_resource) |
801 |
+ |
C_SYMBOL_NAME(get_named_resource): |
802 |
+ |
do_get_named_resource XLM_GET_NAMED_RESOURCE |
803 |
+ |
|
804 |
+ |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_1_named_resource) |
805 |
+ |
C_SYMBOL_NAME(get_1_named_resource): |
806 |
+ |
do_get_named_resource XLM_GET_1_NAMED_RESOURCE |
807 |
|
|
808 |
|
|
809 |
|
/* |
856 |
|
|
857 |
|
|
858 |
|
/* |
859 |
< |
* Glue for glibc with TLS support which clobbers r2 |
923 |
< |
* |
924 |
< |
* The following is derived from dietlibc and only provides |
925 |
< |
* pass-through to kernel syscalls. You also lose asynchronous |
926 |
< |
* cancellation support. |
859 |
> |
* Define signal handlers with alternate stack initialization magic |
860 |
|
*/ |
861 |
|
|
862 |
< |
#if defined(__linux__) |
863 |
< |
#define __NR_getpid 20 |
864 |
< |
#define __NR__newselect 142 |
865 |
< |
|
866 |
< |
#define syscall_weak(name,wsym,sym) \ |
867 |
< |
.text; \ |
868 |
< |
.type wsym,@function; \ |
869 |
< |
.weak wsym; \ |
870 |
< |
wsym: ; \ |
871 |
< |
.type sym,@function; \ |
872 |
< |
.global sym; \ |
873 |
< |
sym: \ |
874 |
< |
li 0,__NR_##name; \ |
875 |
< |
b __unified_syscall |
876 |
< |
|
877 |
< |
#define syscall(name,sym) \ |
878 |
< |
.text; \ |
879 |
< |
.type sym,@function; \ |
880 |
< |
.global sym; \ |
881 |
< |
sym: \ |
882 |
< |
li 0,__NR_##name; \ |
883 |
< |
b __unified_syscall |
884 |
< |
|
885 |
< |
|
886 |
< |
.type __unified_syscall,@function |
887 |
< |
__unified_syscall: |
888 |
< |
sc |
889 |
< |
bnslr+ |
890 |
< |
stwu 1,-16(1) |
891 |
< |
mflr 0 |
892 |
< |
stw 0,20(1) |
893 |
< |
stw 3,12(1) |
894 |
< |
bl __errno_location |
895 |
< |
lwz 0,12(1) |
896 |
< |
stw 0,0(3) |
897 |
< |
lwz 0,20(1) |
898 |
< |
mtlr 0 |
899 |
< |
addi 1,1,16 |
900 |
< |
blr |
901 |
< |
|
902 |
< |
/* name weak symbol symbol */ |
903 |
< |
syscall( getpid, getpid) |
904 |
< |
syscall_weak( _newselect, select, __select) |
905 |
< |
#endif |
862 |
> |
#define SIG_STACK_SIZE 0x10000 |
863 |
> |
|
864 |
> |
ASM_MACRO_START do_define_signal_handler \ |
865 |
> |
ASM_MACRO_ARG0_DEF /* name */ \ |
866 |
> |
ASM_MACRO_ARG1_DEF /* stack */ \ |
867 |
> |
ASM_MACRO_ARG2_DEF /* stack id */ \ |
868 |
> |
ASM_MACRO_ARG3_DEF /* signal handler */ |
869 |
> |
|
870 |
> |
// Alternate stack lower base for this signal handler |
871 |
> |
.lcomm ASM_MACRO_ARG1,SIG_STACK_SIZE,ASM_ALIGN_2(4) |
872 |
> |
ASM_TYPE(ASM_MACRO_ARG1,@object) |
873 |
> |
|
874 |
> |
// Represents the current nest level for this signal handler |
875 |
> |
// Note that in SheepShaver, SIGUSR2 signals are blocked while |
876 |
> |
// handling other signals so, it's unlikely we ever get a nest |
877 |
> |
// level greater than 1 |
878 |
> |
.lcomm ASM_MACRO_ARG2,4,ASM_ALIGN_2(2) |
879 |
> |
ASM_TYPE(ASM_MACRO_ARG2,@object) |
880 |
> |
|
881 |
> |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(ASM_MACRO_ARG0) |
882 |
> |
C_SYMBOL_NAME(ASM_MACRO_ARG0): |
883 |
> |
// Preserve args in scratch registers |
884 |
> |
mflr r14 |
885 |
> |
mr r15,r3 |
886 |
> |
mr r16,r4 |
887 |
> |
mr r17,r5 |
888 |
> |
mr r18,r1 |
889 |
> |
|
890 |
> |
// Atomically increase stack_id |
891 |
> |
lis r19,ASM_HA16(ASM_MACRO_ARG2) |
892 |
> |
la r19,ASM_LO16(ASM_MACRO_ARG2)(r19) |
893 |
> |
li r4,1 |
894 |
> |
mr r3,r19 |
895 |
> |
bl C_SYMBOL_NAME(atomic_add) |
896 |
> |
cmpwi r3,0 |
897 |
> |
bne- 1f |
898 |
> |
|
899 |
> |
// ID was 0, we can use the local stack |
900 |
> |
lis r9,ASM_HA16(ASM_MACRO_ARG1) |
901 |
> |
lis r3,(SIG_STACK_SIZE>>16) |
902 |
> |
la r9,ASM_LO16(ASM_MACRO_ARG1)(r9) |
903 |
> |
addi r3,r3,((SIG_STACK_SIZE&0xffff)-64) |
904 |
> |
add r1,r9,r3 |
905 |
> |
|
906 |
> |
1: // Invoke signal handler |
907 |
> |
stwu r1,-16(r1) |
908 |
> |
mr r3,r15 |
909 |
> |
mr r4,r16 |
910 |
> |
mr r5,r17 |
911 |
> |
bl C_SYMBOL_NAME(ASM_MACRO_ARG3) |
912 |
> |
addi r1,r1,16 |
913 |
> |
|
914 |
> |
// Atomically decrease stack id |
915 |
> |
mr r3,r19 |
916 |
> |
li r4,-1 |
917 |
> |
bl C_SYMBOL_NAME(atomic_add) |
918 |
> |
|
919 |
> |
// Restore kernel stack and return |
920 |
> |
mtlr r14 |
921 |
> |
mr r1,r18 |
922 |
> |
blr |
923 |
> |
ASM_MACRO_END |
924 |
> |
|
925 |
> |
#define DEFINE_SIGNAL_HANDLER(NAME) \ |
926 |
> |
do_define_signal_handler \ |
927 |
> |
NAME##_handler_init ASM_MACRO_ARG_SEP \ |
928 |
> |
NAME##_stack ASM_MACRO_ARG_SEP \ |
929 |
> |
NAME##_stack_id ASM_MACRO_ARG_SEP \ |
930 |
> |
NAME##_handler |
931 |
> |
|
932 |
> |
DEFINE_SIGNAL_HANDLER(sigusr2) |