Subversion Repositories HelenOS

Compare Revisions

Regard whitespace Rev 2606 → Rev 2607

/trunk/kernel/arch/mips32/include/stack.h
38,6 → 38,14
#define STACK_ITEM_SIZE 4
#define STACK_ALIGNMENT 8
 
#define STACK_ARG0 0
#define STACK_ARG1 4
#define STACK_ARG2 8
#define STACK_ARG3 12
#define STACK_ARG4 16
#define STACK_ARG5 20
#define STACK_ARG6 24
 
#endif
 
/** @}
/trunk/kernel/arch/mips32/src/start.S
30,6 → 30,7
#include <arch/mm/page.h>
#include <arch/asm/boot.h>
#include <arch/context_offset.h>
#include <arch/stack.h>
.text
 
229,8 → 230,6
j exception_handler
nop
 
exception_handler:
KERNEL_STACK_TO_K0
sub $k0, REGISTER_SPACE
256,8 → 255,20
# The $sp is automatically restored to former value
eret
 
# it seems that mips reserves some space on stack for varfuncs???
#define SS_ARG4 16
## Syscall entry
#
# Registers:
#
# @param v0 Syscall number.
# @param a0 1st argument.
# @param a1 2nd argument.
# @param a2 3rd argument.
# @param a3 4th argument.
# @param t0 5th argument.
# @param t1 6th argument.
#
# @return The return value will be stored in v0.
#
#define SS_SP EOFFSET_SP
#define SS_STATUS EOFFSET_STATUS
#define SS_EPC EOFFSET_EPC
264,39 → 275,44
#define SS_K1 EOFFSET_K1
syscall_shortcut:
# We have a lot of space on the stack, with free use
mfc0 $t1, $epc
mfc0 $t0, $status
sw $t1,SS_EPC($sp) # Save EPC
sw $k1,SS_K1($sp) # Save k1, which is not saved during context switch
mfc0 $t3, $epc
mfc0 $t2, $status
sw $t3, SS_EPC($sp) # Save EPC
sw $k1, SS_K1($sp) # Save k1 not saved on context switch
and $t2, $t0, REG_SAVE_MASK # Save only KSU,EXL,ERL,IE
li $t3, ~(0x1f)
and $t0, $t0, $t3 # Clear KSU,EXL,ERL
ori $t0, $t0, 0x1 # Set IE
and $t4, $t2, REG_SAVE_MASK # Save only KSU, EXL, ERL, IE
li $t5, ~(0x1f)
and $t2, $t2, $t5 # Clear KSU, EXL, ERL
ori $t2, $t2, 0x1 # Set IE
 
sw $t2,SS_STATUS($sp)
mtc0 $t0, $status
sw $t4, SS_STATUS($sp)
mtc0 $t2, $status
 
# CALL Syscall handler
#
# Call the higher level system call handler
# We are going to reuse part of the unused exception stack frame
#
sw $t0, STACK_ARG4($sp) # save the 5th argument on the stack
sw $t1, STACK_ARG5($sp) # save the 6th argument on the stack
jal syscall_handler
sw $v0, SS_ARG4($sp) # save v0 - arg4 to stack
sw $v0, STACK_ARG6($sp) # save the syscall number on the stack
 
# restore status
mfc0 $t0, $status
lw $t1,SS_STATUS($sp)
mfc0 $t2, $status
lw $t3, SS_STATUS($sp)
 
# Change back to EXL=1(from last exception), otherwise
# an interrupt could rewrite the CP0-EPC
li $t2, ~REG_SAVE_MASK # Mask UM,EXL,ERL,IE
and $t0, $t0, $t2
or $t0, $t0, $t1 # Copy UM,EXL,ERL,IE from saved status
mtc0 $t0, $status
li $t4, ~REG_SAVE_MASK # Mask UM, EXL, ERL, IE
and $t2, $t2, $t4
or $t2, $t2, $t3 # Copy saved UM, EXL, ERL, IE
mtc0 $t2, $status
# restore epc+4
lw $t0,SS_EPC($sp)
lw $t2, SS_EPC($sp)
lw $k1,SS_K1($sp)
addi $t0, $t0, 4
mtc0 $t0, $epc
addi $t2, $t2, 4
mtc0 $t2, $epc
lw $sp,SS_SP($sp) # restore sp