-;
-; NOTE: We do not support more than 8 parameters for PPC. The only
-; system call to use more than 8 is mach_msg_overwrite_trap and it
-; uses 9. We pass a 0 in as number 9.
-;
- lwz r8,ACT_TASK(r13) ; Get our task
- lis r29,hi16(EXT(kern_invalid)) ; Get high half of invalid syscall function
- ori r29,r29,lo16(EXT(kern_invalid)) ; Get low half of invalid syscall function
- lwz r7,TASK_SYSCALLS_MACH(r8) ; Get the current count
- lis r10,hi16(EXT(c_syscalls_mach)) ; Get top half of counter address
- lwz r3,saver3+4(r30) ; Restore r3
- addi r7,r7,1 ; Bump it
- cmp cr0,r0,r29 ; Check if this is an invalid system call
- ori r10,r10,lo16(EXT(c_syscalls_mach)) ; Get low half of counter address
- beq- .L_call_server_syscall_exception ; We have a bad one...
- stw r7,TASK_SYSCALLS_MACH(r8) ; Save count
- lwz r4,saver4+4(r30) ; Restore r4
- lwz r9,0(r10) ; Get counter
- mtctr r0 ; Set the function call address
- lwz r5,saver5+4(r30) ; Restore r5
- lwz r6,saver6+4(r30) ; Restore r6
- addi r9,r9,1 ; Add 1
- lwz r7,saver7+4(r30) ; Restore r7
- li r0,0 ; Clear this out
- lwz r8,saver8+4(r30) ; Restore r8
- stw r9,0(r10) ; Save it back
- lwz r9,saver9+4(r30) ; Restore r9
- lwz r10,saver10+4(r30) ; Restore r10
- stw r0,FM_ARG0(r1) ; Clear that 9th parameter just in case some fool uses it
- bctrl ; perform the actual syscall
-
- lis r10,hi16(EXT(kdebug_enable)) ; Get top of kdebug_enable
- ori r10,r10,lo16(EXT(kdebug_enable)) ; Get bottom of kdebug_enable
- lwz r10,0(r10) ; Get kdebug_enable
- cmplwi r10,0 ; Is kdebug_enable false?
-
- beq++ .L_syscall_return ; No tracing...
- mr r4,r30 ; Pass in the savearea
- bl EXT(syscall_trace_end) ; Trace the exit of the system call
+ lwz r7,TASK_SYSCALLS_MACH(r10) ; Get the current count
+ neg r31,r0 ; Make this positive
+ mr r3,r31 ; save it
+ slwi r27,r3,4 ; multiply by 16
+ slwi r3,r3,2 ; and the original by 4
+ ori r28,r28,lo16(EXT(mach_trap_table)) ; Get address of table
+ add r27,r27,r3 ; for a total of 20x (5 words/entry)
+ addi r7,r7,1 ; Bump TASK_SYSCALLS_MACH count
+ cmplwi r8,0 ; Is kdebug_enable non-zero
+ stw r7,TASK_SYSCALLS_MACH(r10) ; Save count
+ bne-- ksystrace ; yes, tracing enabled
+
+ cmplwi r31,MACH_TRAP_TABLE_COUNT ; Is this syscall in the table?
+ add r31,r27,r28 ; Point right to the syscall table entry
+
+ bge-- .L_call_server_syscall_exception ; The syscall number is invalid
+
+ lwz r0,savesrr1(r30) ; Get the saved srr1
+ rlwinm. r0,r0,0,MSR_SF_BIT,MSR_SF_BIT ; Test for 64 bit caller
+ lwz r0,MACH_TRAP_ARG_MUNGE32(r31) ; Pick up the 32 bit munge function address
+ beq-- .L_kernel_syscall_munge
+ lwz r0,MACH_TRAP_ARG_MUNGE64(r31) ; Pick up the 64 bit munge function address
+
+.L_kernel_syscall_munge:
+ cmplwi r0,0 ; test for null munger
+ mtctr r0 ; Set the function call address
+ addi r3,r30,saver3 ; Pointer to args from save area
+ addi r4,r1,FM_ARG0+ARG_SIZE ; Pointer for munged args
+ beq-- .L_kernel_syscall_trapcall ; null munger - skip to trap call
+ bctrl ; Call the munge function
+
+.L_kernel_syscall_trapcall:
+ lwz r0,MACH_TRAP_FUNCTION(r31) ; Pick up the function address
+ mtctr r0 ; Set the function call address
+ addi r3,r1,FM_ARG0+ARG_SIZE ; Pointer to munged args
+
+#if FPFLOOD
+ stfd f31,emfp31(r25) ; (TEST/DEBUG)
+#endif