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.10 by asvitkine, 2009-08-18T18:26:11Z

# 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 490 | Line 489 | C_SYMBOL_NAME(jump_to_rom):
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
# Line 763 | Line 764 | C_SYMBOL_NAME(get_1_ind_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)
771 +        stwu    r1,-(56+12)(r1)
772 +
773 +        // Save type/ID
774 +        stw     r3,56(r1)
775 +        stw     r4,56+4(r1)
776 +
777 +        // Call old routine
778 +        lwz     r0,ASM_MACRO_ARG0(0)
779 +        lwz     r2,XLM_RES_LIB_TOC(0)
780 +        mtctr   r0
781 +        bctrl
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 +        lwz     r4,56+4(r1)
789 +        lwz     r5,56+8(r1)
790 +        bl      C_SYMBOL_NAME(named_check_load_invoc)
791 +        lwz     r3,56+8(r1)             // Restore handle
792 +
793 +        // Return to caller
794 +        lwz     r0,56+12+8(r1)
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   /*
810   *  void ppc_interrupt(uint32 entry{r3}, uint32 kernel_data{r4}) - Execute PPC interrupt
# Line 811 | Line 853 | C_SYMBOL_NAME(ppc_interrupt):
853          // Enter nanokernel
854          mtlr    r3
855          blr
856 +
857 +
858 + /*
859 + *  Define signal handlers with alternate stack initialization magic
860 + */
861 +
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)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines