ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/ppc_asm.S
(Generate patch)

Comparing SheepShaver/src/Unix/ppc_asm.S (file contents):
Revision 1.6 by gbeauche, 2005-06-25T10:58:47Z vs.
Revision 1.7 by gbeauche, 2005-06-28T16:47:32Z

# Line 811 | Line 811 | C_SYMBOL_NAME(ppc_interrupt):
811          // Enter nanokernel
812          mtlr    r3
813          blr
814 +
815 +
816 + /*
817 + *  Define signal handlers with alternate stack initialization magic
818 + */
819 +
820 + #define SIG_STACK_SIZE 0x10000
821 +
822 + ASM_MACRO_START do_define_signal_handler        \
823 +        ASM_MACRO_ARG0_DEF /* name */           \
824 +        ASM_MACRO_ARG1_DEF /* stack */          \
825 +        ASM_MACRO_ARG2_DEF /* stack id */       \
826 +        ASM_MACRO_ARG3_DEF /* signal handler */
827 +
828 +        // Alternate stack lower base for this signal handler
829 +        .lcomm ASM_MACRO_ARG1,SIG_STACK_SIZE,ASM_ALIGN_2(4)
830 +        ASM_TYPE(ASM_MACRO_ARG1,@object)
831 +
832 +        // Represents the current nest level for this signal handler
833 +        // Note that in SheepShaver, SIGUSR2 signals are blocked while
834 +        // handling other signals so, it's unlikely we ever get a nest
835 +        // level greater than 1
836 +        .lcomm ASM_MACRO_ARG2,4,ASM_ALIGN_2(2)
837 +        ASM_TYPE(ASM_MACRO_ARG2,@object)
838 +
839 +        ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(ASM_MACRO_ARG0)
840 + C_SYMBOL_NAME(ASM_MACRO_ARG0):
841 +        // Preserve args in scratch registers
842 +        mflr    r14
843 +        mr      r15,r3
844 +        mr      r16,r4
845 +        mr      r17,r5
846 +        mr      r18,r1
847 +
848 +        // Atomically increase stack_id
849 +        lis     r19,ASM_HA16(ASM_MACRO_ARG2)
850 +        la      r19,ASM_LO16(ASM_MACRO_ARG2,r19)
851 +        li      r4,1
852 +        mr      r3,r19
853 +        bl      C_SYMBOL_NAME(atomic_add)
854 +        cmpwi   r3,0
855 +        bne-    1f
856 +
857 +        // ID was 0, we can use the local stack
858 +        lis     r9,ASM_HA16(ASM_MACRO_ARG1)
859 +        lis     r3,(SIG_STACK_SIZE>>16)
860 +        la      r9,ASM_LO16(ASM_MACRO_ARG1,r9)
861 +        addi    r3,r3,((SIG_STACK_SIZE&0xffff)-64)
862 +        add     r1,r9,r3
863 +
864 + 1:      // Invoke signal handler
865 +        stwu    r1,-16(r1)
866 +        mr      r3,r15
867 +        mr      r4,r16
868 +        mr      r5,r17
869 +        bl      C_SYMBOL_NAME(ASM_MACRO_ARG3)
870 +        addi    r1,r1,16
871 +
872 +        // Atomically decrease stack id
873 +        mr      r3,r19
874 +        li      r4,-1
875 +        bl      C_SYMBOL_NAME(atomic_add)
876 +
877 +        // Restore kernel stack and return
878 +        mtlr    r14
879 +        mr      r1,r18
880 +        blr
881 + ASM_MACRO_END
882 +
883 + #define DEFINE_SIGNAL_HANDLER(NAME)               \
884 +        do_define_signal_handler                  \
885 +        NAME##_handler_init     ASM_MACRO_ARG_SEP \
886 +        NAME##_stack            ASM_MACRO_ARG_SEP \
887 +        NAME##_stack_id         ASM_MACRO_ARG_SEP \
888 +        NAME##_handler
889 +
890 + DEFINE_SIGNAL_HANDLER(sigusr2)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines