Max OS 0.3
Loading...
Searching...
No Matches
cpu.h File Reference

Defines Central Processing Unit (CPU) structures and functions for managing CPU state and features. More...

#include <cstddef>
#include <cstdint>
#include <cpuid.h>
#include <system/gdt.h>
#include <hardwarecommunication/acpi.h>
#include <hardwarecommunication/apic.h>
#include <memory/physical.h>

Go to the source code of this file.

Classes

struct  MaxOS::system::CPUStatus
 Structure representing the CPU state during an interrupt. More...
 
struct  MaxOS::system::TaskStateSegment
 Structure representing the Task State Segment (TSS) More...
 
struct  MaxOS::system::StackFrame
 A snapshot of the a frame in the call stack. More...
 
struct  MaxOS::system::CoreBootInfo
 Information needed when booting a core. More...
 
class  MaxOS::system::Core
 Represents a CPU core in the system. More...
 
class  MaxOS::system::CPU
 Manages the CPU and its cores. More...
 

Typedefs

typedef struct PACKED MaxOS::system::CPUStatus MaxOS::system::cpu_status_t
 Alias for CPUStatus struct.
 
typedef struct PACKED MaxOS::system::TaskStateSegment MaxOS::system::tss_t
 Alias for TaskStateSegment struct.
 
typedef struct PACKED MaxOS::system::StackFrame MaxOS::system::stack_frame_t
 Alias for StackFrame struct.
 
typedef struct PACKED MaxOS::system::CoreBootInfo MaxOS::system::core_boot_info_t
 Alias for CoreBootInfo struct.
 

Enumerations

enum class  MaxOS::system::CPU_FEATURE_ECX : int32_t {
  SSE3 = 1 << 0 , PCLMUL = 1 << 1 , DTES64 = 1 << 2 , MONITOR = 1 << 3 ,
  DS_CPL = 1 << 4 , VMX = 1 << 5 , SMX = 1 << 6 , EST = 1 << 7 ,
  TM2 = 1 << 8 , SSSE3 = 1 << 9 , CID = 1 << 10 , SDBG = 1 << 11 ,
  FMA = 1 << 12 , CX16 = 1 << 13 , XTPR = 1 << 14 , PDCM = 1 << 15 ,
  PCID = 1 << 17 , DCA = 1 << 18 , SSE4_1 = 1 << 19 , SSE4_2 = 1 << 20 ,
  X2APIC = 1 << 21 , MOVBE = 1 << 22 , POPCNT = 1 << 23 , TSC = 1 << 24 ,
  AES = 1 << 25 , XSAVE = 1 << 26 , OSXSAVE = 1 << 27 , AVX = 1 << 28 ,
  F16C = 1 << 29 , RDRAND = 1 << 30 , HYPERVISOR = 1 << 31
}
 CPU features indicated by the ECX register after calling CPUID with EAX = 1. More...
 
enum class  MaxOS::system::CPU_FEATURE_EDX : int32_t {
  FPU = 1 << 0 , VME = 1 << 1 , DE = 1 << 2 , PSE = 1 << 3 ,
  TSC = 1 << 4 , MSR = 1 << 5 , PAE = 1 << 6 , MCE = 1 << 7 ,
  CX8 = 1 << 8 , APIC = 1 << 9 , SEP = 1 << 11 , MTRR = 1 << 12 ,
  PGE = 1 << 13 , MCA = 1 << 14 , CMOV = 1 << 15 , PAT = 1 << 16 ,
  PSE36 = 1 << 17 , PSN = 1 << 18 , CLFLUSH = 1 << 19 , DS = 1 << 21 ,
  ACPI = 1 << 22 , MMX = 1 << 23 , FXSR = 1 << 24 , SSE = 1 << 25 ,
  SSE2 = 1 << 26 , SS = 1 << 27 , HTT = 1 << 28 , TM = 1 << 29 ,
  IA64 = 1 << 30 , PBE = 1 << 31
}
 CPU features indicated by the EDX register after calling CPUID with EAX = 1. More...
 

Variables

constexpr size_t MaxOS::system::IO_BITMAP_SIZE = 8192
 The size of the IO bitmap to track 65536 ports.
 
constexpr size_t MaxOS::system::BOOT_STACK_SIZE = 16384
 The size of the stack allocated for booting a core (should align with the startup assembly code for the kernel)
 

Detailed Description

Defines Central Processing Unit (CPU) structures and functions for managing CPU state and features.

Date
17th January 2024
Author
Max Tyson

Definition in file cpu.h.

Enumeration Type Documentation

◆ CPU_FEATURE_ECX

enum class MaxOS::system::CPU_FEATURE_ECX : int32_t
strong

CPU features indicated by the ECX register after calling CPUID with EAX = 1.

See also
https://wiki.osdev.org/CPUID as the original author

Definition at line 103 of file cpu.h.

103 : int32_t {
104 SSE3 = 1 << 0,
105 PCLMUL = 1 << 1,
106 DTES64 = 1 << 2,
107 MONITOR = 1 << 3,
108 DS_CPL = 1 << 4,
109 VMX = 1 << 5,
110 SMX = 1 << 6,
111 EST = 1 << 7,
112 TM2 = 1 << 8,
113 SSSE3 = 1 << 9,
114 CID = 1 << 10,
115 SDBG = 1 << 11,
116 FMA = 1 << 12,
117 CX16 = 1 << 13,
118 XTPR = 1 << 14,
119 PDCM = 1 << 15,
120 PCID = 1 << 17,
121 DCA = 1 << 18,
122 SSE4_1 = 1 << 19,
123 SSE4_2 = 1 << 20,
124 X2APIC = 1 << 21,
125 MOVBE = 1 << 22,
126 POPCNT = 1 << 23,
127 TSC = 1 << 24,
128 AES = 1 << 25,
129 XSAVE = 1 << 26,
130 OSXSAVE = 1 << 27,
131 AVX = 1 << 28,
132 F16C = 1 << 29,
133 RDRAND = 1 << 30,
134 HYPERVISOR = 1 << 31,
135 };

◆ CPU_FEATURE_EDX

enum class MaxOS::system::CPU_FEATURE_EDX : int32_t
strong

CPU features indicated by the EDX register after calling CPUID with EAX = 1.

See also
https://wiki.osdev.org/CPUID as the original author

Definition at line 143 of file cpu.h.

143 : int32_t {
144 FPU = 1 << 0,
145 VME = 1 << 1,
146 DE = 1 << 2,
147 PSE = 1 << 3,
148 TSC = 1 << 4,
149 MSR = 1 << 5,
150 PAE = 1 << 6,
151 MCE = 1 << 7,
152 CX8 = 1 << 8,
153 APIC = 1 << 9,
154 SEP = 1 << 11,
155 MTRR = 1 << 12,
156 PGE = 1 << 13,
157 MCA = 1 << 14,
158 CMOV = 1 << 15,
159 PAT = 1 << 16,
160 PSE36 = 1 << 17,
161 PSN = 1 << 18,
162 CLFLUSH = 1 << 19,
163 DS = 1 << 21,
164 ACPI = 1 << 22,
165 MMX = 1 << 23,
166 FXSR = 1 << 24,
167 SSE = 1 << 25,
168 SSE2 = 1 << 26,
169 SS = 1 << 27,
170 HTT = 1 << 28,
171 TM = 1 << 29,
172 IA64 = 1 << 30,
173 PBE = 1 << 31
174 };

Variable Documentation

◆ BOOT_STACK_SIZE

constexpr size_t MaxOS::system::BOOT_STACK_SIZE = 16384
constexpr

The size of the stack allocated for booting a core (should align with the startup assembly code for the kernel)

Definition at line 208 of file cpu.h.

Referenced by MaxOS::system::Core::Core(), MaxOS::system::Core::init_tss(), and MaxOS::system::Core::wake_up().

◆ IO_BITMAP_SIZE

constexpr size_t MaxOS::system::IO_BITMAP_SIZE = 8192
constexpr

The size of the IO bitmap to track 65536 ports.

Definition at line 67 of file cpu.h.

Referenced by MaxOS::system::Core::init_tss().