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 <cpuid.h>
#include <cstddef>
#include <cstdint>
#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::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 100 of file cpu.h.

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

◆ 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 140 of file cpu.h.

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

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 205 of file cpu.h.

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