summaryrefslogtreecommitdiff
path: root/mmu.h
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2011-07-27 20:49:45 -0400
committerFrans Kaashoek <[email protected]>2011-07-27 20:49:45 -0400
commitdccb915282854476ce47752df6631dcce3b8f661 (patch)
treea84aa8ed35618f99c3d7e8cdd466d22ae7bad597 /mmu.h
parent9acdfe0d04f3fcf95c6e392e08afb45bdfe16c20 (diff)
parent13a96baefc0ff5d8262c4bc8c797bee4b157443c (diff)
downloadxv6-labs-dccb915282854476ce47752df6631dcce3b8f661.tar.gz
xv6-labs-dccb915282854476ce47752df6631dcce3b8f661.tar.bz2
xv6-labs-dccb915282854476ce47752df6631dcce3b8f661.zip
Merge commit 'origin/master' into page
Diffstat (limited to 'mmu.h')
-rw-r--r--mmu.h47
1 files changed, 21 insertions, 26 deletions
diff --git a/mmu.h b/mmu.h
index db40f25..2d88a52 100644
--- a/mmu.h
+++ b/mmu.h
@@ -24,6 +24,20 @@
#define FL_VIP 0x00100000 // Virtual Interrupt Pending
#define FL_ID 0x00200000 // ID flag
+// Control Register flags
+#define CR0_PE 0x00000001 // Protection Enable
+#define CR0_MP 0x00000002 // Monitor coProcessor
+#define CR0_EM 0x00000004 // Emulation
+#define CR0_TS 0x00000008 // Task Switched
+#define CR0_ET 0x00000010 // Extension Type
+#define CR0_NE 0x00000020 // Numeric Errror
+#define CR0_WP 0x00010000 // Write Protect
+#define CR0_AM 0x00040000 // Alignment Mask
+#define CR0_NW 0x20000000 // Not Writethrough
+#define CR0_CD 0x40000000 // Cache Disable
+#define CR0_PG 0x80000000 // Paging
+
+//PAGEBREAK!
// Segment Descriptor
struct segdesc {
uint lim_15_0 : 16; // Low bits of segment limit
@@ -46,7 +60,6 @@ struct segdesc {
{ ((lim) >> 12) & 0xffff, (uint)(base) & 0xffff, \
((uint)(base) >> 16) & 0xff, type, 1, dpl, 1, \
(uint)(lim) >> 28, 0, 0, 1, 1, (uint)(base) >> 24 }
-
#define SEG16(type, base, lim, dpl) (struct segdesc) \
{ (lim) & 0xffff, (uint)(base) & 0xffff, \
((uint)(base) >> 16) & 0xff, type, 1, dpl, 1, \
@@ -62,8 +75,6 @@ struct segdesc {
#define STA_R 0x2 // Readable (executable segments)
#define STA_A 0x1 // Accessed
-//
-
// System segment type bits
#define STS_T16A 0x1 // Available 16-bit TSS
#define STS_LDT 0x2 // Local Descriptor Table
@@ -78,7 +89,6 @@ struct segdesc {
#define STS_IG32 0xE // 32-bit Interrupt Gate
#define STS_TG32 0xF // 32-bit Trap Gate
-
// A linear address 'la' has a three-part structure as follows:
//
// +--------10------+-------10-------+---------12----------+
@@ -88,18 +98,18 @@ struct segdesc {
// \--- PDX(la) --/ \--- PTX(la) --/
// page directory index
-#define PDX(la) ((((uint) (la)) >> PDXSHIFT) & 0x3FF)
+#define PDX(la) (((uint)(la) >> PDXSHIFT) & 0x3FF)
// page table index
-#define PTX(la) ((((uint) (la)) >> PTXSHIFT) & 0x3FF)
+#define PTX(la) (((uint)(la) >> PTXSHIFT) & 0x3FF)
// construct linear address from indexes and offset
-#define PGADDR(d, t, o) ((uint) ((d) << PDXSHIFT | (t) << PTXSHIFT | (o)))
+#define PGADDR(d, t, o) ((uint)((d) << PDXSHIFT | (t) << PTXSHIFT | (o)))
// turn a kernel linear address into a physical address.
// all of the kernel data structures have linear and
// physical addresses that are equal.
-#define PADDR(a) ((uint) a)
+#define PADDR(a) ((uint)(a))
// Page directory and page table constants.
#define NPDENTRIES 1024 // page directory entries per page directory
@@ -126,25 +136,10 @@ struct segdesc {
#define PTE_MBZ 0x180 // Bits must be zero
// Address in page table or page directory entry
-#define PTE_ADDR(pte) ((uint) (pte) & ~0xFFF)
+#define PTE_ADDR(pte) ((uint)(pte) & ~0xFFF)
typedef uint pte_t;
-// Control Register flags
-#define CR0_PE 0x00000001 // Protection Enable
-#define CR0_MP 0x00000002 // Monitor coProcessor
-#define CR0_EM 0x00000004 // Emulation
-#define CR0_TS 0x00000008 // Task Switched
-#define CR0_ET 0x00000010 // Extension Type
-#define CR0_NE 0x00000020 // Numeric Errror
-#define CR0_WP 0x00010000 // Write Protect
-#define CR0_AM 0x00040000 // Alignment Mask
-#define CR0_NW 0x20000000 // Not Writethrough
-#define CR0_CD 0x40000000 // Cache Disable
-#define CR0_PG 0x80000000 // Paging
-
-
-// PAGEBREAK: 40
// Task state segment format
struct taskstate {
uint link; // Old ts selector
@@ -210,7 +205,7 @@ struct gatedesc {
// this interrupt/trap gate explicitly using an int instruction.
#define SETGATE(gate, istrap, sel, off, d) \
{ \
- (gate).off_15_0 = (uint) (off) & 0xffff; \
+ (gate).off_15_0 = (uint)(off) & 0xffff; \
(gate).cs = (sel); \
(gate).args = 0; \
(gate).rsv1 = 0; \
@@ -218,6 +213,6 @@ struct gatedesc {
(gate).s = 0; \
(gate).dpl = (d); \
(gate).p = 1; \
- (gate).off_31_16 = (uint) (off) >> 16; \
+ (gate).off_31_16 = (uint)(off) >> 16; \
}