Changeset 346 for soft/giet_vm/giet_kernel/giet.s
- Timestamp:
- Jun 29, 2014, 12:21:53 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_kernel/giet.s
r301 r346 41 41 * - $3 is used to store the syscall address 42 42 * - $4, $5, $6, $7 contain the arguments values. 43 * - The return address (EPC) and the SRare saved in the stack.43 * - The return address (EPC) and the (SR) are saved in the stack. 44 44 * - Interrupts are enabled before branching to the syscall. 45 45 * - All syscalls must return to the syscall handler. 46 46 * - $2, $3, $4, $5, $6, $7 as well as $26 & $27 can be modified. 47 47 * 48 * In case of undefined system call, an error message displays the value of EPC49 * on the TTY corresponding to the processor, and the user program is killed.48 * In case of undefined system call, an error message displays 49 * the value of EPC on the kernel TTY, and the user program is killed. 50 50 */ 51 51 … … 55 55 56 56 _sys_handler: 57 addiu $29, $29, -24 /* 2 slots for SR&EPC, 4 slots for args passing */ 58 mfc0 $27, $14 /* load EPC */ 59 addiu $27, $27, 4 /* increment EPC for return address */ 60 sw $27, 20($29) /* save it in the stack */ 57 addiu $29, $29, -24 /* 2 slots for SR & EPC, 4 slots for args */ 58 mfc0 $27, $14 /* $27 <= EPC */ 59 addiu $27, $27, 4 /* increment EPC for return address */ 60 sw $27, 20($29) /* save EPC in the stack */ 61 mfc0 $27, $12 /* $27 <= SR */ 62 sw $27, 16($29) /* save SR in the stack */ 61 63 62 andi $26, $2, 0x3F /* $26 <= syscall index (i < 64) */ 63 sll $26, $26, 2 /* $26 <= index * 4 */ 64 la $27, _syscall_vector /* $27 <= &_syscall_vector[0] */ 65 addu $27, $27, $26 /* $27 <= &_syscall_vector[i] */ 66 lw $3, 0($27) /* $3 <= syscall address */ 64 andi $26, $2, 0x3F /* $26 <= syscall index (i < 64) */ 65 sll $26, $26, 2 /* $26 <= index * 4 */ 66 la $27, _syscall_vector /* $27 <= &_syscall_vector[0] */ 67 addu $27, $27, $26 /* $27 <= &_syscall_vector[i] */ 68 lw $3, 0($27) /* $3 <= syscall address */ 69 li $27, 0xFFFFFFED /* Mask for UM & EXL bits */ 70 mfc0 $26, $12 /* $26 <= SR */ 71 and $26, $26, $27 /* UM = 0 / EXL = 0 */ 72 mtc0 $26, $12 /* interrupt enabled */ 73 jalr $3 /* jump to the proper syscall */ 67 74 68 li $27, 0xFFFFFFED /* Mask for UM & EXL bits */ 69 mfc0 $26, $12 /* $26 <= SR */ 70 and $26, $26, $27 /* UM = 0 / EXL = 0 */ 71 mtc0 $26, $12 /* interrupt enabled */ 72 jalr $3 /* jump to the proper syscall */ 73 74 mfc0 $26, $12 /* load SR */ 75 ori $26, $26, 0x2 /* set EXL bit */ 76 mtc0 $26, $12 77 78 lw $26, 20($29) /* load EPC from stack */ 79 mtc0 $26, $14 /* restore EPC */ 80 addiu $29, $29, 24 /* restore stack pointer */ 81 eret /* exit GIET */ 75 mtc0 $0, $12 /* SR <= 0 : interrupt disabled */ 76 lw $26, 16($29) /* $26 <= SR from stack */ 77 mtc0 $26, $12 /* restore SR */ 78 lw $26, 20($29) /* $26 <= EPC from stack */ 79 mtc0 $26, $14 /* restore EPC */ 80 addiu $29, $29, 24 /* restore stack pointer */ 81 eret /* exit GIET */ 82 82 83 83 .endfunc
Note: See TracChangeset
for help on using the changeset viewer.