1*e97519a6Srsc#define SEG_KCODE 1 // kernel code 2*e97519a6Srsc#define SEG_KDATA 2 // kernel data+stack 3*e97519a6Srsc#define SEG_KCPU 3 // kernel per-cpu data 4e1872bb1Srsc 5e1872bb1Srsc # vectors.S sends all traps here. 6c1b100e9Srsc.globl alltraps 7e1872bb1Srscalltraps: 8e1872bb1Srsc # Build trap frame. 9e1872bb1Srsc pushl %ds 10e1872bb1Srsc pushl %es 11c7317d4dSkolya pushl %fs 12c7317d4dSkolya pushl %gs 13e1872bb1Srsc pushal 14e1872bb1Srsc 15*e97519a6Srsc # Set up data and per-cpu segments. 16*e97519a6Srsc # Can find out KDATA from %ss. 17*e97519a6Srsc # Assume that KCPU is KDATA+1. 18*e97519a6Srsc movw $(SEG_KDATA<<3), %ax 19*e97519a6Srsc movw %ss, %ax 20e1872bb1Srsc movw %ax, %ds 21e1872bb1Srsc movw %ax, %es 22*e97519a6Srsc movw $(SEG_KCPU<<3), %ax 23*e97519a6Srsc movw %ax, %fs 24*e97519a6Srsc movw %ax, %gs 25e1872bb1Srsc 26e1872bb1Srsc # Call trap(tf), where tf=%esp 27e1872bb1Srsc pushl %esp 28e1872bb1Srsc call trap 29e1872bb1Srsc addl $4, %esp 30e1872bb1Srsc 31e1872bb1Srsc # Return falls through to trapret... 3265bd8e13Srsc.globl trapret 3355e95b16Srtmtrapret: 3455e95b16Srtm popal 35c7317d4dSkolya popl %gs 36c7317d4dSkolya popl %fs 3755e95b16Srtm popl %es 3855e95b16Srtm popl %ds 39e1872bb1Srsc addl $0x8, %esp # trapno and errcode 4055e95b16Srtm iret 4121a88fd4Skaashoek 42e1872bb1Srsc # A forked process switches to user mode by calling 43e1872bb1Srsc # forkret1(tf), where tf is the trap frame to use. 44856e1fc1Srsc.globl forkret1 45856e1fc1Srscforkret1: 46856e1fc1Srsc movl 4(%esp), %esp 4765bd8e13Srsc jmp trapret 4821a88fd4Skaashoek 49