Changes

652 bytes added ,  00:06, 2 February 2016
no edit summary
Line 31: Line 31:  
     MOV            R11, #0x1F
 
     MOV            R11, #0x1F
 
     MSR            CPSR_c, R11      ; Switch to system mode and disable FIQ/IRQ
 
     MSR            CPSR_c, R11      ; Switch to system mode and disable FIQ/IRQ
 +
 +
    LDR            R9, [R8,#0x48]    ; Added in 5.5.0: Check for invalid stack
 +
    CMP            SP, R9
 +
    BLCS            bad_stack
 +
    LDR            R11, [R8,#0x4C]
 +
    SUB            R9, R9, R11
 +
    CMP            SP, R9
 +
    BCC            bad_stack
 +
 
     LDR            R8, [R8,#0x44]
 
     LDR            R8, [R8,#0x44]
 
     LDR            R11, =syscall_stack_arg_counts
 
     LDR            R11, =syscall_stack_arg_counts
Line 71: Line 80:  
     BL              debug_print  ; Illegal Instruction:tid=%d,pid=%d,pc=0x%08x,sp=0x%08x
 
     BL              debug_print  ; Illegal Instruction:tid=%d,pid=%d,pc=0x%08x,sp=0x%08x
 
     B              schedule_yield
 
     B              schedule_yield
 
+
bad_stack
 +
    BL      disable_interrupts
 +
    LDR    R0, =current_thread_ctx_addr
 +
    LDR    R0, [R0]
 +
    MOV    LR, #6              ; STATE_FAULTED
 +
    STR    LR, [R0,#0x50]
 +
    MOV    R1, SP
 +
    MOV    R2, R10
 +
    LDR    SP, =debug_args_addr
 +
    BL      debug_print_bad_stack ; Bad stack upon making system call:tid=%d,pid=%d,sp=0x%08x,sysCallNum=%d\n
 +
    B      schedule_yield
 
Syscalls are invoked by way of the invalid instruction handler; syscalls take the form 0xE7F000F0 | (syscall_num << 8). (E.g. E7F000F0 is syscall 0, E7F036F0 is syscall 0x36, etc.).<br>
 
Syscalls are invoked by way of the invalid instruction handler; syscalls take the form 0xE7F000F0 | (syscall_num << 8). (E.g. E7F000F0 is syscall 0, E7F036F0 is syscall 0x36, etc.).<br>
 
The IOSU has 0x94 available syscalls with 5.3.2 (the number of installed syscalls can vary between system versions).
 
The IOSU has 0x94 available syscalls with 5.3.2 (the number of installed syscalls can vary between system versions).