lproc.s 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. /* avoid the ambiguity described in notes/movm.w. */
  15. // MOVM.S.IA.W (R13), [R13]
  16. MOVM.S (R13), [R13]
  17. ADD $4, R13
  18. /* set up a PSR for user level */
  19. MOVW $(PsrMusr), R0
  20. MOVW R0, SPSR
  21. /* save the PC on the stack */
  22. MOVW $(UTZERO+0x20), R0
  23. MOVM.DB.W [R0], (R13)
  24. /*
  25. * note that 5a's RFE is not the v6 arch. instruction (0xe89d0a00,
  26. * I think), which loads CPSR from the word after the PC at (R13),
  27. * but rather the pre-v6 simulation `MOVM.IA.S.W (R13), [R15]'
  28. * (0xe8fd8000 since MOVM is LDM in this case), which loads CPSR
  29. * not from memory but from SPSR due to `.S'.
  30. */
  31. RFE
  32. /*
  33. * here to jump to a newly forked process
  34. */
  35. TEXT forkret(SB), 1, $-4
  36. ADD $(4*15), R13 /* make r13 point to ureg->type */
  37. MOVW 8(R13), R14 /* restore link */
  38. MOVW 4(R13), R0 /* restore SPSR */
  39. MOVW R0, SPSR /* ... */
  40. MOVM.DB.S (R13), [R0-R14] /* restore registers */
  41. ADD $8, R13 /* pop past ureg->{type+psr} */
  42. RFE /* MOVM.IA.S.W (R13), [R15] */