2009-05-31 01:00:38 +00:00
|
|
|
#define SEG_KCODE 1 // kernel code
|
|
|
|
#define SEG_KDATA 2 // kernel data+stack
|
|
|
|
#define SEG_KCPU 3 // kernel per-cpu data
|
2007-08-27 13:11:13 +00:00
|
|
|
|
|
|
|
# vectors.S sends all traps here.
|
2007-08-28 18:23:48 +00:00
|
|
|
.globl alltraps
|
2006-06-13 15:50:06 +00:00
|
|
|
alltraps:
|
2007-08-27 13:11:13 +00:00
|
|
|
# Build trap frame.
|
|
|
|
pushl %ds
|
|
|
|
pushl %es
|
2008-09-24 01:48:31 +00:00
|
|
|
pushl %fs
|
|
|
|
pushl %gs
|
2007-08-27 13:11:13 +00:00
|
|
|
pushal
|
|
|
|
|
2009-05-31 01:00:38 +00:00
|
|
|
# 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
|
2007-08-27 13:11:13 +00:00
|
|
|
|
|
|
|
# Call trap(tf), where tf=%esp
|
|
|
|
pushl %esp
|
|
|
|
call trap
|
2006-09-06 17:04:06 +00:00
|
|
|
addl $4, %esp
|
2006-09-06 17:27:19 +00:00
|
|
|
|
2007-08-27 13:11:13 +00:00
|
|
|
# Return falls through to trapret...
|
2006-07-16 01:15:28 +00:00
|
|
|
.globl trapret
|
2006-06-12 15:22:12 +00:00
|
|
|
trapret:
|
2006-09-06 17:04:06 +00:00
|
|
|
popal
|
2008-09-24 01:48:31 +00:00
|
|
|
popl %gs
|
|
|
|
popl %fs
|
2006-09-06 17:04:06 +00:00
|
|
|
popl %es
|
|
|
|
popl %ds
|
2007-08-27 13:11:13 +00:00
|
|
|
addl $0x8, %esp # trapno and errcode
|
2006-09-06 17:04:06 +00:00
|
|
|
iret
|
2006-06-22 01:28:57 +00:00
|
|
|
|
2007-08-27 13:11:13 +00:00
|
|
|
# A forked process switches to user mode by calling
|
|
|
|
# forkret1(tf), where tf is the trap frame to use.
|
2006-07-16 01:47:40 +00:00
|
|
|
.globl forkret1
|
|
|
|
forkret1:
|
2006-09-06 17:04:06 +00:00
|
|
|
movl 4(%esp), %esp
|
|
|
|
jmp trapret
|
2006-09-06 17:27:19 +00:00
|
|
|
|