Move user exception support into userprog.
[pintos-anon] / src / threads / loader.S
index 8e5eeb722e1051c7b94df7f3b7ff1ce8f8b51268..4e4fbb4c3e162ace5f0c0d6d1477a92d99e49bbd 100644 (file)
@@ -1,5 +1,5 @@
-#include "mmu.h"
 #include "loader.h"
+#include "mmu.h"
        
 ##############################################################################
 # Kernel loader.
 # first byte of the kernel, where start.S is linked.
 ##############################################################################
        
+/* Flags in control register 0 */
+#define CR0_PE 0x00000001      /* Protection Enable. */
+#define CR0_EM 0x00000004      /* (Floating-point) Emulation. */
+#define CR0_PG 0x80000000      /* Paging. */
+#define CR0_WP 0x00010000      /* Write-Protect enable in kernel mode. */
+
 .globl start                           # Entry point   
 start: .code16                         # This runs in real mode
        cli                             # Disable interrupts
@@ -159,9 +165,9 @@ read_sector:
        addl $0x1000, %eax
        loop 1b
 
-       # Turn on paging.
+       # Turn on paging and kernel write-protect.
        movl %cr0, %eax
-       orl $CR0_PG, %eax
+       orl $CR0_PG | CR0_WP, %eax
        movl %eax, %cr0
        jmp 1f
 1: