1.text 2.globl trap 3.globl trapret1 4.globl alltraps 5 6.set SEG_KDATA_SEL 0x10 # selector for SEG_KDATA 7 8 # vectors.S sends all traps here. 9alltraps: 10 # Build trap frame. 11 pushl %ds 12 pushl %es 13 pushal 14 15 # Set up data segments. 16 movl $SEG_KDATA_SEL, %eax 17 movw %ax,%ds 18 movw %ax,%es 19 20 # Call trap(tf), where tf=%esp 21 pushl %esp 22 call trap 23 addl $4, %esp 24 25 # Return falls through to trapret... 26.globl trapret 27trapret: 28 popal 29 popl %es 30 popl %ds 31 addl $0x8, %esp # trapno and errcode 32 iret 33 34 # A forked process switches to user mode by calling 35 # forkret1(tf), where tf is the trap frame to use. 36.globl forkret1 37forkret1: 38 movl 4(%esp), %esp 39 jmp trapret 40 41