- mr r4,r30
- bl EXT(syscall_trace)
- lwz r0,saver0(r30) ; Get the system call selector */
- neg r31,r0 ; Make system call number positive and put in r31
- lis r29,hi16(EXT(mach_trap_count)) ; High part of valid trap number
- ori r29,r29,lo16(EXT(mach_trap_count)) ; Low part of valid trap number
- lis r28,hi16(EXT(mach_trap_table)) ; High part of trap table
- lwz r29,0(r29) ; Get the first invalid system call number
- ori r28,r28,lo16(EXT(mach_trap_table)) ; Low part of trap table
-
- cmplw r31,r29 ; See if we have a valid system call number
- slwi r31,r31,MACH_TRAP_OFFSET_POW2 ; Get offset into table
-
- bge- .L_call_server_syscall_exception ; System call number of bogus
-
- add r31,r31,r28 ; Point to the system call entry
- lis r28,hi16(EXT(kern_invalid)) ; Get the high invalid routine address
- lwz r0,MACH_TRAP_FUNCTION(r31) ; Grab the system call routine address
- ori r28,r28,lo16(EXT(kern_invalid)) ; Get the low part of the invalid routine address
- lwz r29,MACH_TRAP_ARGC(r31) ; Get the number of arguments in the call
- cmplw r0,r28 ; Is this an invalid entry?
- beq- .L_call_server_syscall_exception ; Yes, it is invalid...
-
-/* get arg count. If argc > 8 then not all args were in regs,
- * so we must perform copyin.
- */
- cmpwi cr0,r29,8 ; Do we have more than 8 arguments?
- ble+ .L_syscall_got_args ; Nope, no copy in needed...
-
-/* argc > 8 - perform a copyin */
-/* if the syscall came from kernel space, we can just copy */
-
- lwz r0,savesrr1(r30) ; Pick up exception time MSR
- andi. r0,r0,MASK(MSR_PR) ; Check the priv bit
- bne+ .L_syscall_arg_copyin ; We are not priviliged...
-
-/* we came from a privilaged task, just do a copy */
-/* get user's stack pointer */
-
- lwz r28,saver1(r30) ; Get the stack pointer
-
- subi r29,r29,8 ; Get the number of arguments to copy
-
- addi r28,r28,COPYIN_ARG0_OFFSET-4 ; Point to source - 4
- addi r27,r1,FM_ARG0-4 ; Point to sink - 4
-
-.L_syscall_copy_word_loop:
- addic. r29,r29,-1 ; Count down the number of arguments left
- lwz r0,4(r28) ; Pick up the argument from the stack
- addi r28,r28,4 ; Point to the next source
- stw r0,4(r27) ; Store the argument
- addi r27,r27,4 ; Point to the next sink
- bne+ .L_syscall_copy_word_loop ; Move all arguments...
- b .L_syscall_got_args ; Go call it now...
-
-
-/* we came from a user task, pay the price of a real copyin */
-/* set recovery point */
-
- .align 5
-
-.L_syscall_arg_copyin:
- lwz r8,ACT_VMMAP(r13) ; Get the vm_map for this activation
- lis r28,hi16(.L_syscall_copyin_recover)
- lwz r8,VMMAP_PMAP(r8) ; Get the pmap
- ori r28,r28,lo16(.L_syscall_copyin_recover)
- addi r8,r8,PMAP_SEGS ; Point to the pmap SR slots
- stw r28,THREAD_RECOVER(r16) ; R16 still holds thread ptr
-
-/* We can manipulate the COPYIN segment register quite easily
- * here, but we've also got to make sure we don't go over a
- * segment boundary - hence some mess.
- * Registers from 12-29 are free for our use.
- */
-
-
- lwz r28,saver1(r30) ; Get the stack pointer
- subi r29,r29,8 ; Get the number of arguments to copy
- addi r28,r28,COPYIN_ARG0_OFFSET ; Set source in user land
-
-/* set up SR_COPYIN to allow us to copy, we may need to loop
- * around if we change segments. We know that this previously
- * pointed to user space, so the sid doesn't need setting.
- */
-
- rlwinm r7,r28,6,26,29 ; Get index to the segment slot
-
-.L_syscall_copyin_seg_loop:
- lwzx r10,r8,r7 ; Get the source SR value
- rlwinm r26,r28,0,4,31 ; Clear the segment number from source address
- mtsr SR_COPYIN,r10 ; Set the copyin SR
- isync
-
- oris r26,r26,(SR_COPYIN_NUM << (28-16)) ; Insert the copyin segment number into source address
-
- addi r27,r1,FM_ARG0-4 ; Point to area - 4 where we will store the arguments
+ lwz r10,ACT_TASK(r13) ; Get our task
+ lwz r0,saver0+4(r30)
+ lis r8,hi16(EXT(kdebug_enable)) ; Get top of kdebug_enable
+ lis r28,hi16(EXT(mach_trap_table)) ; Get address of table
+ ori r8,r8,lo16(EXT(kdebug_enable)) ; Get bottom of kdebug_enable
+ lwz r8,0(r8) ; Get kdebug_enable
+
+ lwz r7,TASK_SYSCALLS_MACH(r10) ; Get the current count
+ neg r31,r0 ; Make this positive
+ slwi r27,r31,MACH_TRAP_OFFSET_POW2 ; Convert index to offset
+ ori r28,r28,lo16(EXT(mach_trap_table)) ; Get address of table
+ 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