Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Release 1.0
[palacios.git] / misc / test_vm / include / geekos / cpu.h
1 #ifndef _cpu
2 #define _cpu
3
4
5 // EFLAGS register
6
7 #define EFLAGS_CF         (1<<0)  // carry out
8 // next bit reserved and must be 1
9 #define EFLAGS_PF         (1<<2)  // ?
10 // next bit reserved and must be zero 
11 #define EFLAGS_AF         (1<<4)  // ?
12 // next bit reserved and must be zero 
13 #define EFLAGS_ZF         (1<<6)  // zero
14 #define EFLAGS_SF         (1<<7)  // sign
15 #define EFLAGS_TF         (1<<8)  // Trap flag
16 #define EFLAGS_IF         (1<<9)  // Interrupt Enable
17 #define EFLAGS_DF         (1<<10) // ?
18 #define EFLAGS_OF         (1<<11) // overflow
19 #define EFLAGS_IOPL_LO    (1<<12) // IO privilege level low bit
20 #define EFLAGS_IOPL_HI    (1<<13) // IO privilege level low bit
21 #define EFLAGS_NT         (1<<14) // Nested Task
22 // next bit reserved and must be zero 
23 #define EFLAGS_RF         (1<<16) // Resume Flag
24 #define EFLAGS_VM         (1<<17) // V8086 mode
25 #define EFLAGS_AC         (1<<18) // Alignment Check
26 #define EFLAGS_VIF        (1<<19) // Virtual interrupt flag
27 #define EFLAGS_VIP        (1<<20) // Virtual interrupt pending
28 #define EFLAGS_ID         (1<<21) // identification flag
29 // remaining bits reserved and must be zero 
30
31 // Helpers for EFLAGS
32 #define IOPL(r) ( ( (r) & (EFLAGS_IOPL_LO | EFLAGS_IOPL_HI)) >> 12 )
33
34
35
36 // CR0 register
37
38 #define CR0_PE            (1<<0)  // protection enabled (protected mode)
39 #define CR0_MP            (1<<1)  // monitor coprocessor exists?
40 #define CR0_EM            (1<<2)  // Emulation (set = no FPU)
41 #define CR0_TS            (1<<3)  // Task switched (enable = avoid FPU/SSE context save on HW task switch)
42 #define CR0_ET            (1<<4)  // extension type (FPU on 386/486, reserved afterward)
43 #define CR0_NE            (1<<5)  // numeric error enable (FPU) (PC-style = disabled)
44 // next group of bits are reserved
45 #define CR0_WP            (1<<16) // write protect (disallow supervisor access to user pages)
46 // next bit is reserved
47 #define CR0_AM            (1<<17) // alignment mask
48 // next group of bits are reserved
49 #define CR0_NW            (1<<29) // not write through
50 #define CR0_CD            (1<<30) // cache disable
51 #define CR0_PG            (1<<31) // paging enable
52
53 // CR1
54 //
55 // All of CR1 is reserved
56
57
58 // CR2
59 //
60 // CR2 is the linear address of a page fault (output only)
61 // only useful in a page fault context
62 //
63
64 // CR3
65 //
66 // CR3 is the page table base register and friends
67 //
68 #define CR3_PWT           (1<<3)  // page-level writes transparent 
69 #define CR3_PCD           (1<<4)  // page-level cache disable  (avoid caching the first level page table)
70
71 #define CR3_PAGE_DIRECTORY_BASE_ADDRESS(reg) ((reg)&0xfffff000)
72
73 // CR4
74 //
75
76 #define CR4_VME           (1<<0)  // V8086 mode extensions (set = inter/except handling extensions on)
77 #define CR4_PVI           (1<<1)  // Protected mode virtual interrupts (VIF)
78 #define CR4_TSD           (1<<2)  // Time stamp disable (disallow rdstc for ring>0)
79 #define CR4_DE            (1<<3)  // Debugging extensions (debug registers)
80 #define CR4_PSE           (1<<4)  // Page size extensions (allow 4 MB pages)
81 #define CR4_PAE           (1<<5)  // Physical Address Extensions (36+ bit addressing (PAE + IA32e)
82 #define CR4_MCE           (1<<6)  // Machine Check enable (allow generation of MC exception)
83 #define CR4_PGE           (1<<7)  // Page global enable (allow global pages)
84 #define CR4_PCE           (1<<8)  // Performance counter enable (allow access to any ring)
85 #define CR4_OSFXSR        (1<<9)  // OS Support for FXSAVE/RSTOR (fast FPU/SSE context instructions)
86 #define CR4_OSMMEXCEPT    (1<<10)  // OS Support for unmasked SIMD FP exceptions (SSE)
87 // next two bits reserved and set to zero
88 #define CR4_VMXE          (1<<13)  // Allow the VMX instruction
89 // rest of the bits reserved and set to zero
90
91
92
93
94
95
96 #endif