Go to the documentation of this file.
18 #ifndef __LIBARCH_INTEL_CPU_H
19 #define __LIBARCH_INTEL_CPU_H
43 unsigned long long val;
44 asm volatile (
"rdtsc\n" :
"=A"(val));
51 #define cpu_reboot() \
54 io.outb(0x64, 0xfe); \
64 #define cpu_shutdown() \
67 io.outw(0xB004, 0x0 | 0x2000); \
84 asm volatile ("ltr %0\n" :: "r"(tr)); \
92 #define tlb_flush(addr) \
93 asm volatile("invlpg (%0)" ::"r" (addr) : "memory")
98 #define tlb_flush_all() \
99 asm volatile("mov %cr3, %eax\n" \
107 #define INTEL_DIVZERO 0
108 #define INTEL_DEBUGEX 1
110 #define INTEL_BREAKP 3
111 #define INTEL_OVERFLOW 4
112 #define INTEL_BOUNDS 5
113 #define INTEL_OPCODE 6
114 #define INTEL_DEVERR 7
115 #define INTEL_DOUBLEF 8
116 #define INTEL_COSEG 9
117 #define INTEL_TSSERR 10
118 #define INTEL_SEGERR 11
119 #define INTEL_STACKERR 12
120 #define INTEL_GENERR 13
121 #define INTEL_PAGEFAULT 14
122 #define INTEL_FLOATERR 16
123 #define INTEL_ALIGNERR 17
124 #define INTEL_MACHCHK 18
125 #define INTEL_SIMD 19
126 #define INTEL_VIRTERR 20
137 #define INTEL_EFLAGS_DEFAULT (1 << 1)
138 #define INTEL_EFLAGS_IRQ (1 << 9)
void writeCR3(u32 cr3) const
Write the CR3 register.
Address kernelPageDir[]
Kernel page directory.
struct Segment Segment
Segment descriptor used in the GDT.
struct IRQRegs3 IRQRegs3
Unprivileged Interrupt Registers (ring 3)
u64 timestamp()
Reads the CPU's timestamp counter.
void logState(CPUState *state) const
Log the CPU state.
struct CPURegs CPURegs
Structure represents the pusha/popa format.
void logRegister(const char *name, u32 reg) const
Log a register.
struct SegRegs SegRegs
Segmentation registers.
unsigned long Address
A memory address.
volatile u32 readCR3() const
Read the CR3 register.
TSS kernelTss
Task State Segment.
Intel's Task State Segment.
unsigned long long u64
Unsigned 64-bit number.
Structure represents the pusha/popa format.
unsigned int u32
Unsigned 32-bit number.
void logException(CPUState *state) const
Log a CPU exception.
Contains all the CPU registers.
Privileged Interrupt Registers (ring 0)
volatile u32 readCR2() const
Read the CR2 register.
Segment descriptor used in the GDT.
Unprivileged Interrupt Registers (ring 3)
struct CPUState CPUState
Contains all the CPU registers.
Segment gdt[]
Global Descriptor Table.
struct TSS TSS
Intel's Task State Segment.
struct IRQRegs0 IRQRegs0
Privileged Interrupt Registers (ring 0)