25 |
|
|
26 |
|
|
27 |
|
/* |
28 |
< |
* void *get_toc(void) - Get TOC pointer (small data pointer r13 under Linux) |
28 |
> |
* void *get_sp(void) - Get stack pointer |
29 |
|
*/ |
30 |
|
|
31 |
< |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_toc) |
32 |
< |
C_SYMBOL_NAME(get_toc): |
33 |
< |
mr r3,r13 |
31 |
> |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_sp) |
32 |
> |
C_SYMBOL_NAME(get_sp): |
33 |
> |
mr r3,r1 |
34 |
|
blr |
35 |
|
|
36 |
|
|
37 |
|
/* |
38 |
< |
* void *get_sp(void) - Get stack pointer |
38 |
> |
* void *get_r2(void) - Get r2 |
39 |
|
*/ |
40 |
|
|
41 |
< |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_sp) |
42 |
< |
C_SYMBOL_NAME(get_sp): |
43 |
< |
mr r3,r1 |
41 |
> |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_r2) |
42 |
> |
C_SYMBOL_NAME(get_r2): |
43 |
> |
mr r3,r2 |
44 |
|
blr |
45 |
|
|
46 |
|
|
47 |
|
/* |
48 |
< |
* void set_r2(uint32 val {r3}) - Set r2 |
48 |
> |
* void set_r2(void *val {r3}) - Set r2 |
49 |
|
*/ |
50 |
|
|
51 |
|
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(set_r2) |
55 |
|
|
56 |
|
|
57 |
|
/* |
58 |
+ |
* void *get_r13(void) - Get r13 (small data pointer under Linux) |
59 |
+ |
*/ |
60 |
+ |
|
61 |
+ |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_r13) |
62 |
+ |
C_SYMBOL_NAME(get_r13): |
63 |
+ |
mr r3,r13 |
64 |
+ |
blr |
65 |
+ |
|
66 |
+ |
/* |
67 |
+ |
* void set_r13(void *val {r3}) - Set r13 (small data pointer under Linux) |
68 |
+ |
*/ |
69 |
+ |
|
70 |
+ |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(set_r13) |
71 |
+ |
C_SYMBOL_NAME(set_r13): |
72 |
+ |
mr r13,r3 |
73 |
+ |
blr |
74 |
+ |
|
75 |
+ |
|
76 |
+ |
/* |
77 |
|
* void flush_icache_range(void *start {r3}, void *end {r3}) - Flush D and I cache |
78 |
|
*/ |
79 |
|
|
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 |
244 |
|
|
245 |
|
// Restore PowerPC registers |
246 |
|
lwz r1,XLM_EMUL_RETURN_STACK(0) |
247 |
+ |
RESTORE_SYSTEM_R2 |
248 |
|
lmw r13,20(r1) |
249 |
|
lfd f14,20+19*4+0*8(r1) |
250 |
|
lfd f15,20+19*4+1*8(r1) |
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) |
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 |
< |
lwz r13,XLM_TOC(0) |
423 |
< |
addi r3,r1,24 |
422 |
> |
RESTORE_SYSTEM_R2 |
423 |
> |
RESTORE_SYSTEM_R13 |
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 |
|
|
596 |
|
ASM_MACRO_END |
597 |
|
|
598 |
|
ASM_MACRO_START epilog |
576 |
– |
lwz r13,XLM_TOC(0) |
599 |
|
lwz r0,64+4(r1) |
600 |
|
mtlr r0 |
601 |
|
addi r1,r1,64 |
602 |
+ |
RESTORE_SYSTEM_R2 |
603 |
+ |
RESTORE_SYSTEM_R13 |
604 |
|
blr |
605 |
|
ASM_MACRO_END |
606 |
|
|
709 |
|
* Native resource manager patches |
710 |
|
*/ |
711 |
|
|
712 |
< |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_resource) |
689 |
< |
C_SYMBOL_NAME(get_resource): |
712 |
> |
ASM_MACRO_START do_get_resource ASM_MACRO_ARG0_DEF |
713 |
|
// Create stack frame |
714 |
|
mflr r0 |
715 |
|
stw r0,8(r1) |
720 |
|
stw r4,56+4(r1) |
721 |
|
|
722 |
|
// Call old routine |
723 |
< |
lwz r0,XLM_GET_RESOURCE(0) |
723 |
> |
lwz r0,ASM_MACRO_ARG0(0) |
724 |
|
lwz r2,XLM_RES_LIB_TOC(0) |
725 |
|
mtctr r0 |
726 |
|
bctrl |
727 |
|
stw r3,56+8(r1) // Save handle |
728 |
|
|
729 |
|
// Call CheckLoad |
730 |
+ |
RESTORE_SYSTEM_R2 |
731 |
+ |
RESTORE_SYSTEM_R13 |
732 |
|
lwz r3,56(r1) |
733 |
|
lha r4,56+6(r1) |
734 |
|
lwz r5,56+8(r1) |
740 |
|
mtlr r0 |
741 |
|
addi r1,r1,56+12 |
742 |
|
blr |
743 |
+ |
ASM_MACRO_END |
744 |
+ |
|
745 |
+ |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_resource) |
746 |
+ |
C_SYMBOL_NAME(get_resource): |
747 |
+ |
do_get_resource XLM_GET_RESOURCE |
748 |
|
|
749 |
|
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_1_resource) |
750 |
|
C_SYMBOL_NAME(get_1_resource): |
751 |
< |
// Create stack frame |
722 |
< |
mflr r0 |
723 |
< |
stw r0,8(r1) |
724 |
< |
stwu r1,-(56+12)(r1) |
725 |
< |
|
726 |
< |
// Save type/ID |
727 |
< |
stw r3,56(r1) |
728 |
< |
stw r4,56+4(r1) |
729 |
< |
|
730 |
< |
// Call old routine |
731 |
< |
lwz r0,XLM_GET_1_RESOURCE(0) |
732 |
< |
lwz r2,XLM_RES_LIB_TOC(0) |
733 |
< |
mtctr r0 |
734 |
< |
bctrl |
735 |
< |
stw r3,56+8(r1) // Save handle |
736 |
< |
|
737 |
< |
// Call CheckLoad |
738 |
< |
lwz r3,56(r1) |
739 |
< |
lha r4,56+6(r1) |
740 |
< |
lwz r5,56+8(r1) |
741 |
< |
bl C_SYMBOL_NAME(check_load_invoc) |
742 |
< |
lwz r3,56+8(r1) // Restore handle |
743 |
< |
|
744 |
< |
// Return to caller |
745 |
< |
lwz r0,56+12+8(r1) |
746 |
< |
mtlr r0 |
747 |
< |
addi r1,r1,56+12 |
748 |
< |
blr |
751 |
> |
do_get_resource XLM_GET_1_RESOURCE |
752 |
|
|
753 |
|
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_ind_resource) |
754 |
|
C_SYMBOL_NAME(get_ind_resource): |
755 |
< |
// Create stack frame |
753 |
< |
mflr r0 |
754 |
< |
stw r0,8(r1) |
755 |
< |
stwu r1,-(56+12)(r1) |
756 |
< |
|
757 |
< |
// Save type/index |
758 |
< |
stw r3,56(r1) |
759 |
< |
stw r4,56+4(r1) |
760 |
< |
|
761 |
< |
// Call old routine |
762 |
< |
lwz r0,XLM_GET_IND_RESOURCE(0) |
763 |
< |
lwz r2,XLM_RES_LIB_TOC(0) |
764 |
< |
mtctr r0 |
765 |
< |
bctrl |
766 |
< |
stw r3,56+8(r1) // Save handle |
767 |
< |
|
768 |
< |
// Call CheckLoad |
769 |
< |
lwz r3,56(r1) |
770 |
< |
lha r4,56+6(r1) |
771 |
< |
lwz r5,56+8(r1) |
772 |
< |
bl C_SYMBOL_NAME(check_load_invoc) |
773 |
< |
lwz r3,56+8(r1) // Restore handle |
774 |
< |
|
775 |
< |
// Return to caller |
776 |
< |
lwz r0,56+12+8(r1) |
777 |
< |
mtlr r0 |
778 |
< |
addi r1,r1,56+12 |
779 |
< |
blr |
755 |
> |
do_get_resource XLM_GET_IND_RESOURCE |
756 |
|
|
757 |
|
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_1_ind_resource) |
758 |
|
C_SYMBOL_NAME(get_1_ind_resource): |
759 |
< |
// Create stack frame |
784 |
< |
mflr r0 |
785 |
< |
stw r0,8(r1) |
786 |
< |
stwu r1,-(56+12)(r1) |
787 |
< |
|
788 |
< |
// Save type/index |
789 |
< |
stw r3,56(r1) |
790 |
< |
stw r4,56+4(r1) |
791 |
< |
|
792 |
< |
// Call old routine |
793 |
< |
lwz r0,XLM_GET_1_IND_RESOURCE(0) |
794 |
< |
lwz r2,XLM_RES_LIB_TOC(0) |
795 |
< |
mtctr r0 |
796 |
< |
bctrl |
797 |
< |
stw r3,56+8(r1) // Save handle |
798 |
< |
|
799 |
< |
// Call CheckLoad |
800 |
< |
lwz r3,56(r1) |
801 |
< |
lha r4,56+6(r1) |
802 |
< |
lwz r5,56+8(r1) |
803 |
< |
bl C_SYMBOL_NAME(check_load_invoc) |
804 |
< |
lwz r3,56+8(r1) // Restore handle |
805 |
< |
|
806 |
< |
// Return to caller |
807 |
< |
lwz r0,56+12+8(r1) |
808 |
< |
mtlr r0 |
809 |
< |
addi r1,r1,56+12 |
810 |
< |
blr |
759 |
> |
do_get_resource XLM_GET_1_IND_RESOURCE |
760 |
|
|
761 |
|
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(r_get_resource) |
762 |
|
C_SYMBOL_NAME(r_get_resource): |
763 |
+ |
do_get_resource XLM_R_GET_RESOURCE |
764 |
+ |
|
765 |
+ |
ASM_MACRO_START do_get_named_resource ASM_MACRO_ARG0_DEF |
766 |
|
// Create stack frame |
767 |
|
mflr r0 |
768 |
|
stw r0,8(r1) |
773 |
|
stw r4,56+4(r1) |
774 |
|
|
775 |
|
// Call old routine |
776 |
< |
lwz r0,XLM_R_GET_RESOURCE(0) |
776 |
> |
lwz r0,ASM_MACRO_ARG0(0) |
777 |
|
lwz r2,XLM_RES_LIB_TOC(0) |
778 |
|
mtctr r0 |
779 |
|
bctrl |
780 |
|
stw r3,56+8(r1) // Save handle |
781 |
|
|
782 |
|
// Call CheckLoad |
783 |
+ |
RESTORE_SYSTEM_R2 |
784 |
+ |
RESTORE_SYSTEM_R13 |
785 |
|
lwz r3,56(r1) |
786 |
< |
lha r4,56+6(r1) |
786 |
> |
lwz r4,56+4(r1) |
787 |
|
lwz r5,56+8(r1) |
788 |
< |
bl C_SYMBOL_NAME(check_load_invoc) |
788 |
> |
bl C_SYMBOL_NAME(named_check_load_invoc) |
789 |
|
lwz r3,56+8(r1) // Restore handle |
790 |
|
|
791 |
|
// Return to caller |
793 |
|
mtlr r0 |
794 |
|
addi r1,r1,56+12 |
795 |
|
blr |
796 |
+ |
ASM_MACRO_END |
797 |
+ |
|
798 |
+ |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_named_resource) |
799 |
+ |
C_SYMBOL_NAME(get_named_resource): |
800 |
+ |
do_get_named_resource XLM_GET_NAMED_RESOURCE |
801 |
+ |
|
802 |
+ |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_1_named_resource) |
803 |
+ |
C_SYMBOL_NAME(get_1_named_resource): |
804 |
+ |
do_get_named_resource XLM_GET_1_NAMED_RESOURCE |
805 |
|
|
806 |
|
|
807 |
|
/* |
851 |
|
// Enter nanokernel |
852 |
|
mtlr r3 |
853 |
|
blr |
854 |
+ |
|
855 |
+ |
|
856 |
+ |
/* |
857 |
+ |
* Define signal handlers with alternate stack initialization magic |
858 |
+ |
*/ |
859 |
+ |
|
860 |
+ |
#define SIG_STACK_SIZE 0x10000 |
861 |
+ |
|
862 |
+ |
ASM_MACRO_START do_define_signal_handler \ |
863 |
+ |
ASM_MACRO_ARG0_DEF /* name */ \ |
864 |
+ |
ASM_MACRO_ARG1_DEF /* stack */ \ |
865 |
+ |
ASM_MACRO_ARG2_DEF /* stack id */ \ |
866 |
+ |
ASM_MACRO_ARG3_DEF /* signal handler */ |
867 |
+ |
|
868 |
+ |
// Alternate stack lower base for this signal handler |
869 |
+ |
.lcomm ASM_MACRO_ARG1,SIG_STACK_SIZE,ASM_ALIGN_2(4) |
870 |
+ |
ASM_TYPE(ASM_MACRO_ARG1,@object) |
871 |
+ |
|
872 |
+ |
// Represents the current nest level for this signal handler |
873 |
+ |
// Note that in SheepShaver, SIGUSR2 signals are blocked while |
874 |
+ |
// handling other signals so, it's unlikely we ever get a nest |
875 |
+ |
// level greater than 1 |
876 |
+ |
.lcomm ASM_MACRO_ARG2,4,ASM_ALIGN_2(2) |
877 |
+ |
ASM_TYPE(ASM_MACRO_ARG2,@object) |
878 |
+ |
|
879 |
+ |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(ASM_MACRO_ARG0) |
880 |
+ |
C_SYMBOL_NAME(ASM_MACRO_ARG0): |
881 |
+ |
// Preserve args in scratch registers |
882 |
+ |
mflr r14 |
883 |
+ |
mr r15,r3 |
884 |
+ |
mr r16,r4 |
885 |
+ |
mr r17,r5 |
886 |
+ |
mr r18,r1 |
887 |
+ |
|
888 |
+ |
// Atomically increase stack_id |
889 |
+ |
lis r19,ASM_HA16(ASM_MACRO_ARG2) |
890 |
+ |
la r19,ASM_LO16(ASM_MACRO_ARG2,r19) |
891 |
+ |
li r4,1 |
892 |
+ |
mr r3,r19 |
893 |
+ |
bl C_SYMBOL_NAME(atomic_add) |
894 |
+ |
cmpwi r3,0 |
895 |
+ |
bne- 1f |
896 |
+ |
|
897 |
+ |
// ID was 0, we can use the local stack |
898 |
+ |
lis r9,ASM_HA16(ASM_MACRO_ARG1) |
899 |
+ |
lis r3,(SIG_STACK_SIZE>>16) |
900 |
+ |
la r9,ASM_LO16(ASM_MACRO_ARG1,r9) |
901 |
+ |
addi r3,r3,((SIG_STACK_SIZE&0xffff)-64) |
902 |
+ |
add r1,r9,r3 |
903 |
+ |
|
904 |
+ |
1: // Invoke signal handler |
905 |
+ |
stwu r1,-16(r1) |
906 |
+ |
mr r3,r15 |
907 |
+ |
mr r4,r16 |
908 |
+ |
mr r5,r17 |
909 |
+ |
bl C_SYMBOL_NAME(ASM_MACRO_ARG3) |
910 |
+ |
addi r1,r1,16 |
911 |
+ |
|
912 |
+ |
// Atomically decrease stack id |
913 |
+ |
mr r3,r19 |
914 |
+ |
li r4,-1 |
915 |
+ |
bl C_SYMBOL_NAME(atomic_add) |
916 |
+ |
|
917 |
+ |
// Restore kernel stack and return |
918 |
+ |
mtlr r14 |
919 |
+ |
mr r1,r18 |
920 |
+ |
blr |
921 |
+ |
ASM_MACRO_END |
922 |
+ |
|
923 |
+ |
#define DEFINE_SIGNAL_HANDLER(NAME) \ |
924 |
+ |
do_define_signal_handler \ |
925 |
+ |
NAME##_handler_init ASM_MACRO_ARG_SEP \ |
926 |
+ |
NAME##_stack ASM_MACRO_ARG_SEP \ |
927 |
+ |
NAME##_stack_id ASM_MACRO_ARG_SEP \ |
928 |
+ |
NAME##_handler |
929 |
+ |
|
930 |
+ |
DEFINE_SIGNAL_HANDLER(sigusr2) |