lproc.s 949 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "mem.h"
  2. #include "arm.h"
  3. /*
  4. * This is the first jump from kernel to user mode.
  5. * Fake a return from interrupt.
  6. *
  7. * Enter with R0 containing the user stack pointer.
  8. * UTZERO + 0x20 is always the entry point.
  9. *
  10. */
  11. TEXT touser(SB), 1, $-4
  12. /* store the user stack pointer into the USR_r13 */
  13. MOVM.DB.W [R0], (R13)
  14. MOVM.S.IA.W (R13), [R13]
  15. /* set up a PSR for user level */
  16. MOVW $(PsrMusr), R0
  17. MOVW R0, SPSR
  18. /* save the PC on the stack */
  19. MOVW $(UTZERO+0x20), R0
  20. MOVM.DB.W [R0], (R13)
  21. /* return from interrupt */
  22. RFE /* MOVM.IA.S.W (R13), [R15] */
  23. /*
  24. * here to jump to a newly forked process
  25. */
  26. TEXT forkret(SB), 1, $-4
  27. ADD $(4*15), R13 /* make r13 point to ureg->type */
  28. MOVW 8(R13), R14 /* restore link */
  29. MOVW 4(R13), R0 /* restore SPSR */
  30. MOVW R0, SPSR /* ... */
  31. MOVM.DB.S (R13), [R0-R14] /* restore registers */
  32. ADD $8, R13 /* pop past ureg->{type+psr} */
  33. RFE /* MOVM.IA.S.W (R13), [R15] */