task.S 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. .section .text
  2. .align 4
  3. /* Disable paging mask */
  4. .set dp, 0x7FFFFFFF
  5. /* Enable paging mask */
  6. .set ep, 0x80000000
  7. .global copy_page_physical
  8. .type copy_page_physical, @function
  9. copy_page_physical:
  10. /* Preserve contents of EBX */
  11. push %ebx
  12. /* Preserve contents of EFLAGS */
  13. pushf
  14. cli
  15. /* Load source and destination addresses */
  16. mov 12(%esp), %ebx
  17. mov 16(%esp), %ecx
  18. /* Get control register and disable paging*/
  19. mov %cr0, %edx
  20. and $dp, %edx
  21. mov %edx, %cr0
  22. /* Copy 4096 bytes */
  23. mov $0x400, %edx
  24. .page_loop:
  25. /* Get word at source address */
  26. mov (%ebx), %eax
  27. /* Store it at destination address */
  28. mov %eax, (%ecx)
  29. /* Increment source and destination addresses to next word */
  30. add $4, %ebx
  31. add $4, %ecx
  32. /* One less word to copy */
  33. dec %edx
  34. jnz .page_loop
  35. /* Get control register again and enable paging */
  36. mov %cr0, %edx
  37. or $ep, %edx
  38. mov %edx, %cr0
  39. /* Restore EFLAGS */
  40. popf
  41. /* Restore EBX */
  42. pop %ebx
  43. ret
  44. /* Read EIP */
  45. .global read_eip
  46. .type read_eip, @function
  47. read_eip:
  48. mov (%esp), %eax
  49. ret