paging.S 886 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "common.h"
  2. BEGIN
  3. CLEAR
  4. STAGE2
  5. PROTECTED_MODE
  6. SETUP_PAGING_4M
  7. /* Setup a test canary value. */
  8. movl $0x1234, 0x1000
  9. /* Print the canary to make sure it is really there. */
  10. VGA_PRINT_HEX_4 0x1000
  11. /* Make page 0 point to 4KiB. */
  12. orb $0x10, page_table + 1
  13. PAGING_ON
  14. /* THIS is what we've been working for!!!
  15. * Even though we mov to 0, the paging circuit reads that as physical address 0x1000,
  16. * so the canary value 0x1234 should be modified to 0x5678.
  17. **/
  18. movl $0x5678, 0
  19. /* Turn paging back off to prevent it from messing with us.
  20. * Remember that VGA does memory accesses, so if paging is still on,
  21. * we must identity map up to it, which we have, so this is not mandatory.
  22. * */
  23. PAGING_OFF
  24. /* Print the (hopefully) modified value 0x5678. */
  25. VGA_PRINT_HEX_4 0x1000
  26. jmp .