IgrOS-Kernel 0.1.34.545
Simple C++20 Kernel for i386/x86_64
Loading...
Searching...
No Matches
igros::x86_64 Namespace Reference

x86_64 (long mode): GDT, IDT, TSS, CPUID, MSR, CPU registers More...

Classes

class  cpu
 CPU representation. More...
struct  cpuidRegs_t
 CPUID result registers. More...
class  gdt
 GDT structure. More...
class  idt
 IDT structure. More...
struct  register_t
 x86_64 task switch registers save More...
class  tss
 Task state segment: in long mode only stack pointers for privilege. More...

Enumerations

enum class  CPUID : igros_dword_t {
  VENDOR = 0x00000000_u32 , FEATURES = 0x00000001_u32 , CACHE_TLB = 0x00000002_u32 , EXTENDED_FEATURES = 0x00000007_u32 ,
  EXTENDED_MAX = 0x80000000_u32 , EXTENDED_INFO = 0x80000001_u32 , ADDRESS_SIZES = 0x80000008_u32
}
 CPUID leaves. More...
enum class  CPUID_EXT_EDX : igros_dword_t { NX = 0x00100000_u32 , PAGE_1GB = 0x04000000_u32 , LONG_MODE = 0x20000000_u32 }
 CPUID extended feature flags (leaf 80000001h, EDX). More...
enum class  MSR : igros_dword_t {
  APIC_BASE = 0x0000001B_u32 , EFER = 0xC0000080_u32 , STAR = 0xC0000081_u32 , LSTAR = 0xC0000082_u32 ,
  FMASK = 0xC0000084_u32 , FS_BASE = 0xC0000100_u32 , GS_BASE = 0xC0000101_u32 , KERNEL_GS_BASE = 0xC0000102_u32
}
 Model specific registers. More...
enum class  EFER : igros_quad_t { SCE = 0x0000000000000001_u64 , LME = 0x0000000000000100_u64 , LMA = 0x0000000000000400_u64 , NXE = 0x0000000000000800_u64 }
 EFER register bits. More...

Functions

auto cpuid (const CPUID leaf, const igros_dword_t subleaf=0_u32) noexcept -> cpuidRegs_t
 Execute CPUID (CPUID is always available in long mode; caller checks leaf is supported).
auto cpuidHasLeaf (const CPUID leaf) noexcept -> bool
 Check CPUID leaf is supported (basic and extended ranges are checked separately).
auto readMSR (const MSR reg) noexcept -> igros_quad_t
 Read MSR register (RDMSR returns EDX:EAX).
void writeMSR (const MSR reg, const igros_quad_t value) noexcept
 Write MSR register (WRMSR takes EDX:EAX).

Detailed Description

x86_64 (long mode): GDT, IDT, TSS, CPUID, MSR, CPU registers

Enumeration Type Documentation

◆ CPUID

enum class igros::x86_64::CPUID : igros_dword_t
strong

CPUID leaves.

Enumerator
VENDOR 

Max basic leaf and vendor string.

FEATURES 

Version and feature flags.

CACHE_TLB 

Cache and TLB descriptors.

EXTENDED_FEATURES 

Structured extended features (subleaf 0).

EXTENDED_MAX 

Max extended leaf.

EXTENDED_INFO 

Extended feature flags (long mode, NX, 1 GB pages).

ADDRESS_SIZES 

Physical and linear address sizes.

Definition at line 25 of file cpuid.hpp.

◆ CPUID_EXT_EDX

CPUID extended feature flags (leaf 80000001h, EDX).

Enumerator
NX 

No-execute page protection.

PAGE_1GB 

1 GB pages

LONG_MODE 

Long mode (64-bit).

Definition at line 36 of file cpuid.hpp.

◆ EFER

enum class igros::x86_64::EFER : igros_quad_t
strong

EFER register bits.

Enumerator
SCE 

SYSCALL enable.

LME 

Long mode enable.

LMA 

Long mode active.

NXE 

No-execute enable.

Definition at line 37 of file msr.hpp.

◆ MSR

enum class igros::x86_64::MSR : igros_dword_t
strong

Model specific registers.

Enumerator
APIC_BASE 

Local APIC base.

EFER 

Extended feature enable.

STAR 

SYSCALL segments.

LSTAR 

SYSCALL 64-bit entry.

FMASK 

SYSCALL RFLAGS mask.

FS_BASE 

FS segment base.

GS_BASE 

GS segment base.

KERNEL_GS_BASE 

SWAPGS target.

Definition at line 25 of file msr.hpp.

Function Documentation

◆ cpuid()

auto igros::x86_64::cpuid ( const CPUID leaf,
const igros_dword_t subleaf = 0_u32 )->cpuidRegs_t
inlinenodiscardnoexcept

Execute CPUID (CPUID is always available in long mode; caller checks leaf is supported).

Parameters
leafCPUID leaf (EAX)
subleafCPUID subleaf (ECX)
Returns
EAX, EBX, ECX and EDX values

Definition at line 56 of file cpuid.hpp.

◆ cpuidHasLeaf()

auto igros::x86_64::cpuidHasLeaf ( const CPUID leaf) ->bool
inlinenodiscardnoexcept

Check CPUID leaf is supported (basic and extended ranges are checked separately).

Parameters
leafCPUID leaf
Returns
true if leaf is within supported range

Definition at line 70 of file cpuid.hpp.

◆ readMSR()

auto igros::x86_64::readMSR ( const MSR reg) ->igros_quad_t
inlinenodiscardnoexcept

Read MSR register (RDMSR returns EDX:EAX).

Parameters
regRegister
Returns
Register value

Definition at line 49 of file msr.hpp.

◆ writeMSR()

void igros::x86_64::writeMSR ( const MSR reg,
const igros_quad_t value )
inlinenoexcept

Write MSR register (WRMSR takes EDX:EAX).

Parameters
regRegister
valueNew register value

Definition at line 59 of file msr.hpp.