xv6-cs450/trapasm.S

49 lines
914 B
ArmAsm

#define SEG_KCODE 1 // kernel code
#define SEG_KDATA 2 // kernel data+stack
#define SEG_KCPU 3 // kernel per-cpu data
# vectors.S sends all traps here.
.globl alltraps
alltraps:
# Build trap frame.
pushl %ds
pushl %es
pushl %fs
pushl %gs
pushal
# Set up data and per-cpu segments.
# Can find out KDATA from %ss.
# Assume that KCPU is KDATA+1.
movw $(SEG_KDATA<<3), %ax
movw %ss, %ax
movw %ax, %ds
movw %ax, %es
movw $(SEG_KCPU<<3), %ax
movw %ax, %fs
movw %ax, %gs
# Call trap(tf), where tf=%esp
pushl %esp
call trap
addl $4, %esp
# Return falls through to trapret...
.globl trapret
trapret:
popal
popl %gs
popl %fs
popl %es
popl %ds
addl $0x8, %esp # trapno and errcode
iret
# A forked process switches to user mode by calling
# forkret1(tf), where tf is the trap frame to use.
.globl forkret1
forkret1:
movl 4(%esp), %esp
jmp trapret