return (void *) ((uintptr_t) va & ~PGMASK);
}
+/* Base address of the 1:1 physical-to-virtual mapping. Physical
+ memory is mapped starting at this virtual address. Thus,
+ physical address 0 is accessible at PHYS_BASE, physical
+ address address 0x1234 at (uint8_t *) PHYS_BASE + 0x1234, and
+ so on.
+
+ This address also marks the end of user programs' address
+ space. Up to this point in memory, user programs are allowed
+ to map whatever they like. At this point and above, the
+ virtual address space belongs to the kernel. */
#define PHYS_BASE ((void *) LOADER_PHYS_BASE)
/* Returns kernel virtual address at which physical address PADDR
#define PF_U 0x4 /* 0: kernel, 1: user process. */
/* Page fault handler. This is a skeleton that must be filled in
- to implement virtual memory.
+ to implement virtual memory. Some solutions to project 2 may
+ also require modifying this code.
At entry, the address that faulted is in CR2 (Control Register
2) and information about the fault, formatted as described in