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 pushl %fs 12 pushl %gs 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 %gs 30 popl %fs 31 popl %es 32 popl %ds 33 addl $0x8, %esp # trapno and errcode 34 iret 35 36 # A forked process switches to user mode by calling 37 # forkret1(tf), where tf is the trap frame to use. 38.globl forkret1 39forkret1: 40 movl 4(%esp), %esp 41 jmp trapret 42 43