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