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.4 by gbeauche, 2005-06-24T22:58:55Z vs.
Revision 1.9 by gbeauche, 2006-05-03T22:11:49Z

# Line 180 | Line 180 | C_SYMBOL_NAME(test_and_set):
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    
# Line 245 | Line 245 | C_SYMBOL_NAME(jump_to_rom):
245          // Restore PowerPC registers
246          lwz     r1,XLM_EMUL_RETURN_STACK(0)
247          RESTORE_SYSTEM_R2
248        RESTORE_SYSTEM_R13
248          lmw     r13,20(r1)
249          lfd     f14,20+19*4+0*8(r1)
250          lfd     f15,20+19*4+1*8(r1)
# Line 710 | Line 709 | C_SYMBOL_NAME(call_macos7):
709   *  Native resource manager patches
710   */
711  
712 < ASM_MACRO_START do_get_resource XLM_OLD_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)
# Line 721 | Line 720 | ASM_MACRO_START        do_get_resource XLM_OLD_
720          stw     r4,56+4(r1)
721  
722          // Call old routine
723 <        lwz     r0,\XLM_OLD_GET_RESOURCE(0)
723 >        lwz     r0,ASM_MACRO_ARG0(0)
724          lwz     r2,XLM_RES_LIB_TOC(0)
725          mtctr   r0
726          bctrl
# Line 763 | Line 762 | C_SYMBOL_NAME(get_1_ind_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)
769 +        stwu    r1,-(56+12)(r1)
770 +
771 +        // Save type/ID
772 +        stw     r3,56(r1)
773 +        stw     r4,56+4(r1)
774 +
775 +        // Call old routine
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 +        lwz     r4,56+4(r1)
787 +        lwz     r5,56+8(r1)
788 +        bl      C_SYMBOL_NAME(named_check_load_invoc)
789 +        lwz     r3,56+8(r1)             // Restore handle
790 +
791 +        // Return to caller
792 +        lwz     r0,56+12+8(r1)
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   /*
808   *  void ppc_interrupt(uint32 entry{r3}, uint32 kernel_data{r4}) - Execute PPC interrupt
# Line 811 | Line 851 | C_SYMBOL_NAME(ppc_interrupt):
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)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines