《操作系统》的实验代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
988 B

10 years ago
  1. #include <memlayout.h>
  2. # vectors.S sends all traps here.
  3. .text
  4. .globl __alltraps
  5. __alltraps:
  6. # push registers to build a trap frame
  7. # therefore make the stack look like a struct trapframe
  8. pushl %ds
  9. pushl %es
  10. pushl %fs
  11. pushl %gs
  12. pushal
  13. # load GD_KDATA into %ds and %es to set up data segments for kernel
  14. movl $GD_KDATA, %eax
  15. movw %ax, %ds
  16. movw %ax, %es
  17. # push %esp to pass a pointer to the trapframe as an argument to trap()
  18. pushl %esp
  19. # call trap(tf), where tf=%esp
  20. call trap
  21. # pop the pushed stack pointer
  22. popl %esp
  23. # return falls through to trapret...
  24. .globl __trapret
  25. __trapret:
  26. # restore registers from stack
  27. popal
  28. # restore %ds, %es, %fs and %gs
  29. popl %gs
  30. popl %fs
  31. popl %es
  32. popl %ds
  33. # get rid of the trap number and error code
  34. addl $0x8, %esp
  35. iret
  36. .globl forkrets
  37. forkrets:
  38. # set stack to this new process's trapframe
  39. movl 4(%esp), %esp
  40. jmp __trapret