sys.s 835 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. .code32
  2. .text
  3. .global asm_switch_pd
  4. .type asm_switch_pd @function
  5. asm_switch_pd:
  6. movl 4(%esp), %eax
  7. shll $12, %eax
  8. movl %eax, %cr3
  9. ret
  10. .global current_pd
  11. .type current_pd @function
  12. current_pd:
  13. movl %cr3, %eax
  14. ret
  15. .section .text.kinit
  16. .global asm_enable_paging
  17. .type asm_enable_paging @function
  18. asm_enable_paging:
  19. cli
  20. // page directory address
  21. movl 4(%esp), %eax
  22. movl %eax, %cr3
  23. movl %cr0, %eax
  24. // SET PE, WP, PG
  25. orl $0x80010001, %eax
  26. movl %eax, %cr0
  27. ret
  28. .global asm_load_gdt
  29. .type asm_load_gdt @function
  30. asm_load_gdt:
  31. cli
  32. leal 6(%esp), %eax
  33. lgdt (%eax)
  34. ljmp $0x08, $_asm_load_gdt_fin
  35. _asm_load_gdt_fin:
  36. ret
  37. .global asm_load_tr
  38. .type asm_load_tr @function
  39. asm_load_tr:
  40. cli
  41. movl 4(%esp), %eax
  42. orl $0, %eax
  43. ltr %ax
  44. ret