From b5592b4d2f0ea5f536b206979f829038c55d7ade Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 31 Aug 2010 16:47:50 -0400 Subject: Start PDE defs on new page --- mmu.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'mmu.h') diff --git a/mmu.h b/mmu.h index db40f25..0975efd 100644 --- a/mmu.h +++ b/mmu.h @@ -62,8 +62,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 +76,7 @@ struct segdesc { #define STS_IG32 0xE // 32-bit Interrupt Gate #define STS_TG32 0xF // 32-bit Trap Gate - +//PAGEBREAK! // A linear address 'la' has a three-part structure as follows: // // +--------10------+-------10-------+---------12----------+ -- cgit v1.2.3 From 7914ab721436d3c21623010dfab2dc326bf49279 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 31 Aug 2010 16:54:50 -0400 Subject: Page breaking of mmu.h --- mmu.h | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'mmu.h') diff --git a/mmu.h b/mmu.h index 0975efd..475eae8 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, \ @@ -76,7 +89,6 @@ struct segdesc { #define STS_IG32 0xE // 32-bit Interrupt Gate #define STS_TG32 0xF // 32-bit Trap Gate -//PAGEBREAK! // A linear address 'la' has a three-part structure as follows: // // +--------10------+-------10-------+---------12----------+ @@ -128,21 +140,6 @@ struct segdesc { 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 -- cgit v1.2.3 From 1a81e38b17144624415d252a521fd5a06079d681 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 11 Jan 2011 13:01:13 -0500 Subject: make new code like old code Variable declarations at top of function, separate from initialization. Use == 0 instead of ! for checking pointers. Consistent spacing around {, *, casts. Declare 0-parameter functions as (void) not (). Integer valued functions return -1 on failure, 0 on success. --- mmu.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'mmu.h') diff --git a/mmu.h b/mmu.h index 475eae8..2d88a52 100644 --- a/mmu.h +++ b/mmu.h @@ -98,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 @@ -136,7 +136,7 @@ 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; @@ -205,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; \ @@ -213,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; \ } -- cgit v1.2.3