diff options
author | rtm <rtm> | 2006-08-29 19:06:37 +0000 |
---|---|---|
committer | rtm <rtm> | 2006-08-29 19:06:37 +0000 |
commit | dfcc5b997ce9c313b9ac0e7d8da39c4416b472a8 (patch) | |
tree | 2d6c4e47bad6cfe7436896068a5872ace545a974 /mmu.h | |
parent | d7ce6545e7179e9a4b950838c354b485e3f3fdb8 (diff) | |
download | xv6-labs-dfcc5b997ce9c313b9ac0e7d8da39c4416b472a8.tar.gz xv6-labs-dfcc5b997ce9c313b9ac0e7d8da39c4416b472a8.tar.bz2 xv6-labs-dfcc5b997ce9c313b9ac0e7d8da39c4416b472a8.zip |
prune unneeded panics and debug output
Diffstat (limited to 'mmu.h')
-rw-r--r-- | mmu.h | 73 |
1 files changed, 7 insertions, 66 deletions
@@ -1,15 +1,8 @@ /* - * This file contains definitions for the x86 memory management unit (MMU), - * including paging- and segmentation-related data structures and constants, - * the %cr0, %cr4, and %eflags registers, and traps. + * This file contains definitions for the x86 memory management unit (MMU). + * from JOS. */ -/* - * Register flags and fundamental constants. - */ - -#define PGSIZE 4096 // bytes mapped by a page - // Eflags register #define FL_CF 0x00000001 // Carry Flag #define FL_PF 0x00000004 // Parity Flag @@ -33,33 +26,7 @@ #define FL_VIP 0x00100000 // Virtual Interrupt Pending #define FL_ID 0x00200000 // ID flag -// Page fault error codes -#define FEC_PR 0x1 // Page fault caused by protection violation -#define FEC_WR 0x2 // Page fault caused by a write -#define FEC_U 0x4 // Page fault occured while in user mode - -/* - * - * Segmentation data structures and constants. - * - */ - -#ifdef __ASSEMBLER__ - -/* - * Macros to build GDT entries in assembly. - */ -#define SEG_NULL \ - .word 0, 0; \ - .byte 0, 0, 0, 0 -#define SEG(type,base,lim) \ - .word (((lim) >> 12) & 0xffff), ((base) & 0xffff); \ - .byte (((base) >> 16) & 0xff), (0x90 | (type)), \ - (0xC0 | (((lim) >> 28) & 0xf)), (((base) >> 24) & 0xff) - -#else // not __ASSEMBLER__ - -// Segment Descriptors +// Segment Descriptor struct segdesc { uint lim_15_0 : 16; // Low bits of segment limit uint base_15_0 : 16; // Low bits of segment base address @@ -75,22 +42,21 @@ struct segdesc { uint g : 1; // Granularity: limit scaled by 4K when set uint base_31_24 : 8; // High bits of segment base address }; + // Null segment #define SEG_NULL (struct segdesc){ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } -// Segment that is loadable but faults when used -#define SEG_FAULT (struct segdesc){ 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0 } + // Normal segment #define SEG(type, base, lim, dpl) (struct segdesc) \ { ((lim) >> 12) & 0xffff, (base) & 0xffff, ((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, (base) & 0xffff, ((base) >> 16) & 0xff, \ type, 1, dpl, 1, (uint) (lim) >> 16, 0, 0, 1, 0, \ (uint) (base) >> 24 } -#endif /* !__ASSEMBLER__ */ - // Application segment type bits #define STA_X 0x8 // Executable segment #define STA_E 0x4 // Expand down (non-executable segments) @@ -113,16 +79,7 @@ struct segdesc { #define STS_IG32 0xE // 32-bit Interrupt Gate #define STS_TG32 0xF // 32-bit Trap Gate - -/* - * - * Traps. - * - */ - -#ifndef __ASSEMBLER__ - -// Task state segment format (as described by the Pentium architecture book) +// Task state segment format struct taskstate { uint link; // Old ts selector uint esp0; // Stack pointers and segment selectors @@ -197,19 +154,3 @@ struct gatedesc { (gate).off_31_16 = (uint) (off) >> 16; \ } -// Set up a call gate descriptor. -#define SETCALLGATE(gate, ss, off, d) \ -{ \ - (gate).off_15_0 = (uint) (off) & 0xffff; \ - (gate).ss = (ss); \ - (gate).args = 0; \ - (gate).rsv1 = 0; \ - (gate).type = STS_CG32; \ - (gate).s = 0; \ - (gate).dpl = (d); \ - (gate).p = 1; \ - (gate).off_31_16 = (uint) (off) >> 16; \ -} - -#endif /* !__ASSEMBLER__ */ - |