Skip to content
Snippets Groups Projects
trapasm.S 696 B
Newer Older
rsc's avatar
rsc committed

.set SEG_KDATA_SEL, 0x10   # selector for SEG_KDATA
rsc's avatar
rsc committed

  # vectors.S sends all traps here.
rsc's avatar
rsc committed
.globl alltraps
rtm's avatar
rtm committed
alltraps:
rsc's avatar
rsc committed
  # Build trap frame.
  pushl %ds
  pushl %es
rsc's avatar
rsc committed
  pushal
  
  # Set up data segments.
  movl $SEG_KDATA_SEL, %eax
  movw %ax,%ds
  movw %ax,%es

  # Call trap(tf), where tf=%esp
  pushl %esp
  call trap
  addl $4, %esp
rsc's avatar
rsc committed
  # Return falls through to trapret...
rsc's avatar
 
rsc committed
.globl trapret
rtm's avatar
rtm committed
trapret:
  popl %es
  popl %ds
rsc's avatar
rsc committed
  addl $0x8, %esp  # trapno and errcode
rsc's avatar
rsc committed
  # A forked process switches to user mode by calling
  # forkret1(tf), where tf is the trap frame to use.
rsc's avatar
 
rsc committed
.globl forkret1
forkret1:
  movl 4(%esp), %esp
  jmp trapret