18#ifndef __LIBARCH_INTEL_CPU_H
19#define __LIBARCH_INTEL_CPU_H
43 unsigned long long val;
44 asm volatile (
"rdtsc\n" :
"=A"(val));
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
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
126#define INTEL_VIRTERR 20
137#define INTEL_EFLAGS_DEFAULT (1 << 1)
138#define INTEL_EFLAGS_IRQ (1 << 9)
volatile u32 readCR3() const
Read the CR3 register.
void writeCR3(u32 cr3) const
Write the CR3 register.
void logState(CPUState *state) const
Log the CPU state.
void logRegister(const char *name, u32 reg) const
Log a register.
void logException(CPUState *state) const
Log a CPU exception.
volatile u32 readCR2() const
Read the CR2 register.
u64 timestamp()
Reads the CPU's timestamp counter.
Address kernelPageDir[]
Kernel page directory.
TSS kernelTss
Task State Segment.
Segment gdt[]
Global Descriptor Table.
unsigned int u32
Unsigned 32-bit number.
unsigned long Address
A memory address.
unsigned long long u64
Unsigned 64-bit number.
Structure represents the pusha/popa format.
Contains all the CPU registers.
Privileged Interrupt Registers (ring 0)
Unprivileged Interrupt Registers (ring 3)
Segment descriptor used in the GDT.
Intel's Task State Segment.