mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Refactor code to use tab spaces
This commit is contained in:
parent
d247dcd4a3
commit
f009f181b0
@ -22,207 +22,207 @@
|
|||||||
|
|
||||||
namespace CPU
|
namespace CPU
|
||||||
{
|
{
|
||||||
namespace x32
|
namespace x32
|
||||||
{
|
{
|
||||||
typedef union CR0
|
typedef union CR0
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/** @brief Protection Enable */
|
/** Protection Enable */
|
||||||
uint32_t PE : 1;
|
uint32_t PE : 1;
|
||||||
/** @brief Monitor Coprocessor */
|
/** Monitor Coprocessor */
|
||||||
uint32_t MP : 1;
|
uint32_t MP : 1;
|
||||||
/** @brief Emulation */
|
/** Emulation */
|
||||||
uint32_t EM : 1;
|
uint32_t EM : 1;
|
||||||
/** @brief Task Switched */
|
/** Task Switched */
|
||||||
uint32_t TS : 1;
|
uint32_t TS : 1;
|
||||||
/** @brief Extension Type */
|
/** Extension Type */
|
||||||
uint32_t ET : 1;
|
uint32_t ET : 1;
|
||||||
/** @brief Numeric Error */
|
/** Numeric Error */
|
||||||
uint32_t NE : 1;
|
uint32_t NE : 1;
|
||||||
/** @brief Reserved */
|
/** Reserved */
|
||||||
uint32_t Reserved0 : 10;
|
uint32_t Reserved0 : 10;
|
||||||
/** @brief Write Protect */
|
/** Write Protect */
|
||||||
uint32_t WP : 1;
|
uint32_t WP : 1;
|
||||||
/** @brief Reserved */
|
/** Reserved */
|
||||||
uint32_t Reserved1 : 1;
|
uint32_t Reserved1 : 1;
|
||||||
/** @brief Alignment Mask */
|
/** Alignment Mask */
|
||||||
uint32_t AM : 1;
|
uint32_t AM : 1;
|
||||||
/** @brief Reserved */
|
/** Reserved */
|
||||||
uint32_t Reserved2 : 10;
|
uint32_t Reserved2 : 10;
|
||||||
/** @brief Not Write-through */
|
/** Not Write-through */
|
||||||
uint32_t NW : 1;
|
uint32_t NW : 1;
|
||||||
/** @brief Cache Disable */
|
/** Cache Disable */
|
||||||
uint32_t CD : 1;
|
uint32_t CD : 1;
|
||||||
/** @brief Paging */
|
/** Paging */
|
||||||
uint32_t PG : 1;
|
uint32_t PG : 1;
|
||||||
};
|
};
|
||||||
uint32_t raw;
|
uint32_t raw;
|
||||||
} CR0;
|
} CR0;
|
||||||
|
|
||||||
typedef union CR2
|
typedef union CR2
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/** @brief Page Fault Linear Address */
|
/** Page Fault Linear Address */
|
||||||
uint32_t PFLA;
|
uint32_t PFLA;
|
||||||
};
|
};
|
||||||
uint32_t raw;
|
uint32_t raw;
|
||||||
} CR2;
|
} CR2;
|
||||||
|
|
||||||
typedef union CR3
|
typedef union CR3
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/** @brief Not used if bit 17 of CR4 is 1 */
|
/** Not used if bit 17 of CR4 is 1 */
|
||||||
uint32_t PWT : 1;
|
uint32_t PWT : 1;
|
||||||
/** @brief Not used if bit 17 of CR4 is 1 */
|
/** Not used if bit 17 of CR4 is 1 */
|
||||||
uint32_t PCD : 1;
|
uint32_t PCD : 1;
|
||||||
/** @brief Base of PML4T/PML5T */
|
/** Base of PML4T/PML5T */
|
||||||
uint32_t PDBR;
|
uint32_t PDBR;
|
||||||
};
|
};
|
||||||
uint32_t raw;
|
uint32_t raw;
|
||||||
} CR3;
|
} CR3;
|
||||||
|
|
||||||
typedef union CR4
|
typedef union CR4
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/** @brief Virtual-8086 Mode Extensions */
|
/** Virtual-8086 Mode Extensions */
|
||||||
uint32_t VME : 1;
|
uint32_t VME : 1;
|
||||||
/** @brief Protected-Mode Virtual Interrupts */
|
/** Protected-Mode Virtual Interrupts */
|
||||||
uint32_t PVI : 1;
|
uint32_t PVI : 1;
|
||||||
/** @brief Time Stamp Disable */
|
/** Time Stamp Disable */
|
||||||
uint32_t TSD : 1;
|
uint32_t TSD : 1;
|
||||||
/** @brief Debugging Extensions */
|
/** Debugging Extensions */
|
||||||
uint32_t DE : 1;
|
uint32_t DE : 1;
|
||||||
/** @brief Page Size Extensions */
|
/** Page Size Extensions */
|
||||||
uint32_t PSE : 1;
|
uint32_t PSE : 1;
|
||||||
/** @brief Physical Address Extension */
|
/** Physical Address Extension */
|
||||||
uint32_t PAE : 1;
|
uint32_t PAE : 1;
|
||||||
/** @brief Machine Check Enable */
|
/** Machine Check Enable */
|
||||||
uint32_t MCE : 1;
|
uint32_t MCE : 1;
|
||||||
/** @brief Page Global Enable */
|
/** Page Global Enable */
|
||||||
uint32_t PGE : 1;
|
uint32_t PGE : 1;
|
||||||
/** @brief Performance Monitoring Counter */
|
/** Performance Monitoring Counter */
|
||||||
uint32_t PCE : 1;
|
uint32_t PCE : 1;
|
||||||
/** @brief Operating System Support */
|
/** Operating System Support */
|
||||||
uint32_t OSFXSR : 1;
|
uint32_t OSFXSR : 1;
|
||||||
/** @brief Operating System Support */
|
/** Operating System Support */
|
||||||
uint32_t OSXMMEXCPT : 1;
|
uint32_t OSXMMEXCPT : 1;
|
||||||
/** @brief User-Mode Instruction Prevention */
|
/** User-Mode Instruction Prevention */
|
||||||
uint32_t UMIP : 1;
|
uint32_t UMIP : 1;
|
||||||
/** @brief Linear Address 57bit */
|
/** Linear Address 57bit */
|
||||||
uint32_t LA57 : 1;
|
uint32_t LA57 : 1;
|
||||||
/** @brief VMX Enable */
|
/** VMX Enable */
|
||||||
uint32_t VMXE : 1;
|
uint32_t VMXE : 1;
|
||||||
/** @brief SMX Enable */
|
/** SMX Enable */
|
||||||
uint32_t SMXE : 1;
|
uint32_t SMXE : 1;
|
||||||
/** @brief Reserved */
|
/** Reserved */
|
||||||
uint32_t Reserved0 : 1;
|
uint32_t Reserved0 : 1;
|
||||||
/** @brief FSGSBASE Enable */
|
/** FSGSBASE Enable */
|
||||||
uint32_t FSGSBASE : 1;
|
uint32_t FSGSBASE : 1;
|
||||||
/** @brief PCID Enable */
|
/** PCID Enable */
|
||||||
uint32_t PCIDE : 1;
|
uint32_t PCIDE : 1;
|
||||||
/** @brief XSAVE and Processor Extended States Enable */
|
/** XSAVE and Processor Extended States Enable */
|
||||||
uint32_t OSXSAVE : 1;
|
uint32_t OSXSAVE : 1;
|
||||||
/** @brief Reserved */
|
/** Reserved */
|
||||||
uint32_t Reserved1 : 1;
|
uint32_t Reserved1 : 1;
|
||||||
/** @brief SMEP Enable */
|
/** SMEP Enable */
|
||||||
uint32_t SMEP : 1;
|
uint32_t SMEP : 1;
|
||||||
/** @brief SMAP Enable */
|
/** SMAP Enable */
|
||||||
uint32_t SMAP : 1;
|
uint32_t SMAP : 1;
|
||||||
/** @brief Protection-Key Enable */
|
/** Protection-Key Enable */
|
||||||
uint32_t PKE : 1;
|
uint32_t PKE : 1;
|
||||||
/** @brief Control-flow Enforcement Technology*/
|
/** Control-flow Enforcement Technology*/
|
||||||
uint32_t CET : 1;
|
uint32_t CET : 1;
|
||||||
/* @brief Enable Protection Keys for Supervisor Mode Pages */
|
/* Enable Protection Keys for Supervisor Mode Pages */
|
||||||
uint32_t PKS : 1;
|
uint32_t PKS : 1;
|
||||||
};
|
};
|
||||||
uint32_t raw;
|
uint32_t raw;
|
||||||
} CR4;
|
} CR4;
|
||||||
#if defined(a32)
|
#if defined(a32)
|
||||||
nsa static inline CR0 readcr0()
|
nsa static inline CR0 readcr0()
|
||||||
{
|
{
|
||||||
uint32_t Result = 0;
|
uint32_t Result = 0;
|
||||||
asmv("mov %%cr0, %[Result]"
|
asmv("mov %%cr0, %[Result]"
|
||||||
: [Result] "=q"(Result));
|
: [Result] "=q"(Result));
|
||||||
return (CR0){.raw = Result};
|
return (CR0){.raw = Result};
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline CR2 readcr2()
|
nsa static inline CR2 readcr2()
|
||||||
{
|
{
|
||||||
uint32_t Result = 0;
|
uint32_t Result = 0;
|
||||||
asmv("mov %%cr2, %[Result]"
|
asmv("mov %%cr2, %[Result]"
|
||||||
: [Result] "=q"(Result));
|
: [Result] "=q"(Result));
|
||||||
return (CR2){.raw = Result};
|
return (CR2){.raw = Result};
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline CR3 readcr3()
|
nsa static inline CR3 readcr3()
|
||||||
{
|
{
|
||||||
uint32_t Result = 0;
|
uint32_t Result = 0;
|
||||||
asmv("mov %%cr3, %[Result]"
|
asmv("mov %%cr3, %[Result]"
|
||||||
: [Result] "=q"(Result));
|
: [Result] "=q"(Result));
|
||||||
return (CR3){.raw = Result};
|
return (CR3){.raw = Result};
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline CR4 readcr4()
|
nsa static inline CR4 readcr4()
|
||||||
{
|
{
|
||||||
uint32_t Result = 0;
|
uint32_t Result = 0;
|
||||||
asmv("mov %%cr4, %[Result]"
|
asmv("mov %%cr4, %[Result]"
|
||||||
: [Result] "=q"(Result));
|
: [Result] "=q"(Result));
|
||||||
return (CR4){.raw = Result};
|
return (CR4){.raw = Result};
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline CR8 readcr8()
|
nsa static inline CR8 readcr8()
|
||||||
{
|
{
|
||||||
uint32_t Result = 0;
|
uint32_t Result = 0;
|
||||||
asmv("mov %%cr8, %[Result]"
|
asmv("mov %%cr8, %[Result]"
|
||||||
: [Result] "=q"(Result));
|
: [Result] "=q"(Result));
|
||||||
return (CR8){.raw = Result};
|
return (CR8){.raw = Result};
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline void writecr0(CR0 ControlRegister)
|
nsa static inline void writecr0(CR0 ControlRegister)
|
||||||
{
|
{
|
||||||
asmv("mov %[ControlRegister], %%cr0"
|
asmv("mov %[ControlRegister], %%cr0"
|
||||||
:
|
:
|
||||||
: [ControlRegister] "q"(ControlRegister.raw)
|
: [ControlRegister] "q"(ControlRegister.raw)
|
||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline void writecr2(CR2 ControlRegister)
|
nsa static inline void writecr2(CR2 ControlRegister)
|
||||||
{
|
{
|
||||||
asmv("mov %[ControlRegister], %%cr2"
|
asmv("mov %[ControlRegister], %%cr2"
|
||||||
:
|
:
|
||||||
: [ControlRegister] "q"(ControlRegister.raw)
|
: [ControlRegister] "q"(ControlRegister.raw)
|
||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline void writecr3(CR3 ControlRegister)
|
nsa static inline void writecr3(CR3 ControlRegister)
|
||||||
{
|
{
|
||||||
asmv("mov %[ControlRegister], %%cr3"
|
asmv("mov %[ControlRegister], %%cr3"
|
||||||
:
|
:
|
||||||
: [ControlRegister] "q"(ControlRegister.raw)
|
: [ControlRegister] "q"(ControlRegister.raw)
|
||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline void writecr4(CR4 ControlRegister)
|
nsa static inline void writecr4(CR4 ControlRegister)
|
||||||
{
|
{
|
||||||
asmv("mov %[ControlRegister], %%cr4"
|
asmv("mov %[ControlRegister], %%cr4"
|
||||||
:
|
:
|
||||||
: [ControlRegister] "q"(ControlRegister.raw)
|
: [ControlRegister] "q"(ControlRegister.raw)
|
||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline void writecr8(CR8 ControlRegister)
|
nsa static inline void writecr8(CR8 ControlRegister)
|
||||||
{
|
{
|
||||||
asmv("mov %[ControlRegister], %%cr8"
|
asmv("mov %[ControlRegister], %%cr8"
|
||||||
:
|
:
|
||||||
: [ControlRegister] "q"(ControlRegister.raw)
|
: [ControlRegister] "q"(ControlRegister.raw)
|
||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !__FENNIX_KERNEL_CPU_x32_CR_H__
|
#endif // !__FENNIX_KERNEL_CPU_x32_CR_H__
|
||||||
|
@ -22,275 +22,275 @@
|
|||||||
|
|
||||||
namespace CPU
|
namespace CPU
|
||||||
{
|
{
|
||||||
namespace x64
|
namespace x64
|
||||||
{
|
{
|
||||||
typedef union CR0
|
typedef union CR0
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/** @brief Protection Enable */
|
/** Protection Enable */
|
||||||
uint64_t PE : 1;
|
uint64_t PE : 1;
|
||||||
/** @brief Monitor Coprocessor */
|
/** Monitor Coprocessor */
|
||||||
uint64_t MP : 1;
|
uint64_t MP : 1;
|
||||||
/** @brief Emulation */
|
/** Emulation */
|
||||||
uint64_t EM : 1;
|
uint64_t EM : 1;
|
||||||
/** @brief Task Switched */
|
/** Task Switched */
|
||||||
uint64_t TS : 1;
|
uint64_t TS : 1;
|
||||||
/** @brief Extension Type */
|
/** Extension Type */
|
||||||
uint64_t ET : 1;
|
uint64_t ET : 1;
|
||||||
/** @brief Numeric Error */
|
/** Numeric Error */
|
||||||
uint64_t NE : 1;
|
uint64_t NE : 1;
|
||||||
/** @brief Reserved */
|
/** Reserved */
|
||||||
uint64_t Reserved0 : 10;
|
uint64_t Reserved0 : 10;
|
||||||
/** @brief Write Protect */
|
/** Write Protect */
|
||||||
uint64_t WP : 1;
|
uint64_t WP : 1;
|
||||||
/** @brief Reserved */
|
/** Reserved */
|
||||||
uint64_t Reserved1 : 1;
|
uint64_t Reserved1 : 1;
|
||||||
/** @brief Alignment Mask */
|
/** Alignment Mask */
|
||||||
uint64_t AM : 1;
|
uint64_t AM : 1;
|
||||||
/** @brief Reserved */
|
/** Reserved */
|
||||||
uint64_t Reserved2 : 10;
|
uint64_t Reserved2 : 10;
|
||||||
/** @brief Not Write-through */
|
/** Not Write-through */
|
||||||
uint64_t NW : 1;
|
uint64_t NW : 1;
|
||||||
/** @brief Cache Disable */
|
/** Cache Disable */
|
||||||
uint64_t CD : 1;
|
uint64_t CD : 1;
|
||||||
/** @brief Paging */
|
/** Paging */
|
||||||
uint64_t PG : 1;
|
uint64_t PG : 1;
|
||||||
};
|
};
|
||||||
uint64_t raw;
|
uint64_t raw;
|
||||||
} CR0;
|
} CR0;
|
||||||
|
|
||||||
typedef union CR2
|
typedef union CR2
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/** @brief Page Fault Linear Address */
|
/** Page Fault Linear Address */
|
||||||
uint64_t PFLA;
|
uint64_t PFLA;
|
||||||
};
|
};
|
||||||
uint64_t raw;
|
uint64_t raw;
|
||||||
} CR2;
|
} CR2;
|
||||||
|
|
||||||
typedef union CR3
|
typedef union CR3
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/** @brief Not used if bit 17 of CR4 is 1 */
|
/** Not used if bit 17 of CR4 is 1 */
|
||||||
uint64_t PWT : 1;
|
uint64_t PWT : 1;
|
||||||
/** @brief Not used if bit 17 of CR4 is 1 */
|
/** Not used if bit 17 of CR4 is 1 */
|
||||||
uint64_t PCD : 1;
|
uint64_t PCD : 1;
|
||||||
/** @brief Base of PML4T/PML5T */
|
/** Base of PML4T/PML5T */
|
||||||
uint64_t PDBR;
|
uint64_t PDBR;
|
||||||
};
|
};
|
||||||
uint64_t raw;
|
uint64_t raw;
|
||||||
} CR3;
|
} CR3;
|
||||||
|
|
||||||
typedef union CR4
|
typedef union CR4
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/** @brief Virtual-8086 Mode Extensions */
|
/** Virtual-8086 Mode Extensions */
|
||||||
uint64_t VME : 1;
|
uint64_t VME : 1;
|
||||||
/** @brief Protected-Mode Virtual Interrupts */
|
/** Protected-Mode Virtual Interrupts */
|
||||||
uint64_t PVI : 1;
|
uint64_t PVI : 1;
|
||||||
/** @brief Time Stamp Disable */
|
/** Time Stamp Disable */
|
||||||
uint64_t TSD : 1;
|
uint64_t TSD : 1;
|
||||||
/** @brief Debugging Extensions */
|
/** Debugging Extensions */
|
||||||
uint64_t DE : 1;
|
uint64_t DE : 1;
|
||||||
/** @brief Page Size Extensions */
|
/** Page Size Extensions */
|
||||||
uint64_t PSE : 1;
|
uint64_t PSE : 1;
|
||||||
/** @brief Physical Address Extension */
|
/** Physical Address Extension */
|
||||||
uint64_t PAE : 1;
|
uint64_t PAE : 1;
|
||||||
/** @brief Machine Check Enable */
|
/** Machine Check Enable */
|
||||||
uint64_t MCE : 1;
|
uint64_t MCE : 1;
|
||||||
/** @brief Page Global Enable */
|
/** Page Global Enable */
|
||||||
uint64_t PGE : 1;
|
uint64_t PGE : 1;
|
||||||
/** @brief Performance Monitoring Counter */
|
/** Performance Monitoring Counter */
|
||||||
uint64_t PCE : 1;
|
uint64_t PCE : 1;
|
||||||
/** @brief FXSAVE/FXRSTOR Support */
|
/** FXSAVE/FXRSTOR Support */
|
||||||
uint64_t OSFXSR : 1;
|
uint64_t OSFXSR : 1;
|
||||||
/** @brief Unmasked Exception Support */
|
/** Unmasked Exception Support */
|
||||||
uint64_t OSXMMEXCPT : 1;
|
uint64_t OSXMMEXCPT : 1;
|
||||||
/** @brief User-Mode Instruction Prevention */
|
/** User-Mode Instruction Prevention */
|
||||||
uint64_t UMIP : 1;
|
uint64_t UMIP : 1;
|
||||||
/** @brief Linear Address 57bit */
|
/** Linear Address 57bit */
|
||||||
uint64_t LA57 : 1;
|
uint64_t LA57 : 1;
|
||||||
/** @brief VMX Enable */
|
/** VMX Enable */
|
||||||
uint64_t VMXE : 1;
|
uint64_t VMXE : 1;
|
||||||
/** @brief SMX Enable */
|
/** SMX Enable */
|
||||||
uint64_t SMXE : 1;
|
uint64_t SMXE : 1;
|
||||||
/** @brief Reserved */
|
/** Reserved */
|
||||||
uint64_t Reserved0 : 1;
|
uint64_t Reserved0 : 1;
|
||||||
/** @brief FSGSBASE Enable */
|
/** FSGSBASE Enable */
|
||||||
uint64_t FSGSBASE : 1;
|
uint64_t FSGSBASE : 1;
|
||||||
/** @brief PCID Enable */
|
/** PCID Enable */
|
||||||
uint64_t PCIDE : 1;
|
uint64_t PCIDE : 1;
|
||||||
/** @brief XSAVE and Processor Extended States Enable */
|
/** XSAVE and Processor Extended States Enable */
|
||||||
uint64_t OSXSAVE : 1;
|
uint64_t OSXSAVE : 1;
|
||||||
/** @brief Reserved */
|
/** Reserved */
|
||||||
uint64_t Reserved1 : 1;
|
uint64_t Reserved1 : 1;
|
||||||
/** @brief SMEP Enable */
|
/** SMEP Enable */
|
||||||
uint64_t SMEP : 1;
|
uint64_t SMEP : 1;
|
||||||
/** @brief SMAP Enable */
|
/** SMAP Enable */
|
||||||
uint64_t SMAP : 1;
|
uint64_t SMAP : 1;
|
||||||
/** @brief Protection-Key Enable */
|
/** Protection-Key Enable */
|
||||||
uint64_t PKE : 1;
|
uint64_t PKE : 1;
|
||||||
/** @brief Control-flow Enforcement Technology*/
|
/** Control-flow Enforcement Technology*/
|
||||||
uint32_t CET : 1;
|
uint32_t CET : 1;
|
||||||
/* @brief Enable Protection Keys for Supervisor Mode Pages */
|
/* Enable Protection Keys for Supervisor Mode Pages */
|
||||||
uint32_t PKS : 1;
|
uint32_t PKS : 1;
|
||||||
/** @brief Reserved */
|
/** Reserved */
|
||||||
uint64_t Reserved2 : 7; // TODO: This could be wrong
|
uint64_t Reserved2 : 7; // TODO: This could be wrong
|
||||||
};
|
};
|
||||||
uint64_t raw;
|
uint64_t raw;
|
||||||
} CR4;
|
} CR4;
|
||||||
|
|
||||||
typedef union CR8
|
typedef union CR8
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/** @brief Task Priority Register */
|
/** Task Priority Register */
|
||||||
uint64_t TPR : 4;
|
uint64_t TPR : 4;
|
||||||
/** @brief Reserved */
|
/** Reserved */
|
||||||
uint64_t Reserved : 60;
|
uint64_t Reserved : 60;
|
||||||
};
|
};
|
||||||
uint64_t raw;
|
uint64_t raw;
|
||||||
} CR8;
|
} CR8;
|
||||||
|
|
||||||
typedef union XCR0
|
typedef union XCR0
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
On https://wiki.osdev.org/CPU_Registers_x86#XCR0 says that the PKRU bit is 9?
|
On https://wiki.osdev.org/CPU_Registers_x86#XCR0 says that the PKRU bit is 9?
|
||||||
*/
|
*/
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/** @brief X87 FPU/MMX/SSE Support (must be 1) */
|
/** X87 FPU/MMX/SSE Support (must be 1) */
|
||||||
uint64_t X87 : 1;
|
uint64_t X87 : 1;
|
||||||
/** @brief XSAVE support for MXCSR and XMM registers */
|
/** XSAVE support for MXCSR and XMM registers */
|
||||||
uint64_t SSE : 1;
|
uint64_t SSE : 1;
|
||||||
/** @brief AVX support for YMM registers */
|
/** AVX support for YMM registers */
|
||||||
uint64_t AVX : 1;
|
uint64_t AVX : 1;
|
||||||
/** @brief MPX support for BND registers */
|
/** MPX support for BND registers */
|
||||||
uint64_t BNDREG : 1;
|
uint64_t BNDREG : 1;
|
||||||
/** @brief MPX support for BNDCFGU and BNDSTATUS registers */
|
/** MPX support for BNDCFGU and BNDSTATUS registers */
|
||||||
uint64_t BNDCSR : 1;
|
uint64_t BNDCSR : 1;
|
||||||
/** @brief AVX-512 support for opmask registers */
|
/** AVX-512 support for opmask registers */
|
||||||
uint64_t OpMask : 1;
|
uint64_t OpMask : 1;
|
||||||
/** @brief AVX-512 enabled and XSAVE support for upper halves of lower ZMM registers */
|
/** AVX-512 enabled and XSAVE support for upper halves of lower ZMM registers */
|
||||||
uint64_t ZMM_HI256 : 1;
|
uint64_t ZMM_HI256 : 1;
|
||||||
/** @brief AVX-512 enabled and XSAVE support for upper ZMM registers */
|
/** AVX-512 enabled and XSAVE support for upper ZMM registers */
|
||||||
uint64_t HI16_ZMM : 1;
|
uint64_t HI16_ZMM : 1;
|
||||||
/** @brief XSAVE support for PKRU register */
|
/** XSAVE support for PKRU register */
|
||||||
uint64_t PKRU : 1;
|
uint64_t PKRU : 1;
|
||||||
/** @brief Reserved */
|
/** Reserved */
|
||||||
uint64_t Reserved0 : 53;
|
uint64_t Reserved0 : 53;
|
||||||
/** @brief AMD lightweight profiling */
|
/** AMD lightweight profiling */
|
||||||
uint64_t LWP : 1;
|
uint64_t LWP : 1;
|
||||||
/** @brief Reserved */
|
/** Reserved */
|
||||||
uint64_t Reserved1 : 1;
|
uint64_t Reserved1 : 1;
|
||||||
};
|
};
|
||||||
uint64_t raw;
|
uint64_t raw;
|
||||||
} XCR0;
|
} XCR0;
|
||||||
|
|
||||||
#if defined(a64)
|
#if defined(a64)
|
||||||
nsa static inline CR0 readcr0()
|
nsa static inline CR0 readcr0()
|
||||||
{
|
{
|
||||||
uint64_t Result = 0;
|
uint64_t Result = 0;
|
||||||
asmv("mov %%cr0, %[Result]"
|
asmv("mov %%cr0, %[Result]"
|
||||||
: [Result] "=q"(Result));
|
: [Result] "=q"(Result));
|
||||||
return (CR0){.raw = Result};
|
return (CR0){.raw = Result};
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline CR2 readcr2()
|
nsa static inline CR2 readcr2()
|
||||||
{
|
{
|
||||||
uint64_t Result = 0;
|
uint64_t Result = 0;
|
||||||
asmv("mov %%cr2, %[Result]"
|
asmv("mov %%cr2, %[Result]"
|
||||||
: [Result] "=q"(Result));
|
: [Result] "=q"(Result));
|
||||||
return (CR2){.raw = Result};
|
return (CR2){.raw = Result};
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline CR3 readcr3()
|
nsa static inline CR3 readcr3()
|
||||||
{
|
{
|
||||||
uint64_t Result = 0;
|
uint64_t Result = 0;
|
||||||
asmv("mov %%cr3, %[Result]"
|
asmv("mov %%cr3, %[Result]"
|
||||||
: [Result] "=q"(Result));
|
: [Result] "=q"(Result));
|
||||||
return (CR3){.raw = Result};
|
return (CR3){.raw = Result};
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline CR4 readcr4()
|
nsa static inline CR4 readcr4()
|
||||||
{
|
{
|
||||||
uint64_t Result = 0;
|
uint64_t Result = 0;
|
||||||
asmv("mov %%cr4, %[Result]"
|
asmv("mov %%cr4, %[Result]"
|
||||||
: [Result] "=q"(Result));
|
: [Result] "=q"(Result));
|
||||||
return (CR4){.raw = Result};
|
return (CR4){.raw = Result};
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline CR8 readcr8()
|
nsa static inline CR8 readcr8()
|
||||||
{
|
{
|
||||||
uint64_t Result = 0;
|
uint64_t Result = 0;
|
||||||
asmv("mov %%cr8, %[Result]"
|
asmv("mov %%cr8, %[Result]"
|
||||||
: [Result] "=q"(Result));
|
: [Result] "=q"(Result));
|
||||||
return (CR8){.raw = Result};
|
return (CR8){.raw = Result};
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline XCR0 readxcr0()
|
nsa static inline XCR0 readxcr0()
|
||||||
{
|
{
|
||||||
uint64_t Result = 0;
|
uint64_t Result = 0;
|
||||||
asmv("xgetbv"
|
asmv("xgetbv"
|
||||||
: "=a"(Result)
|
: "=a"(Result)
|
||||||
: "c"(0)
|
: "c"(0)
|
||||||
: "edx");
|
: "edx");
|
||||||
return (XCR0){.raw = Result};
|
return (XCR0){.raw = Result};
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline void writecr0(CR0 ControlRegister)
|
nsa static inline void writecr0(CR0 ControlRegister)
|
||||||
{
|
{
|
||||||
asmv("mov %[ControlRegister], %%cr0"
|
asmv("mov %[ControlRegister], %%cr0"
|
||||||
:
|
:
|
||||||
: [ControlRegister] "q"(ControlRegister.raw)
|
: [ControlRegister] "q"(ControlRegister.raw)
|
||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline void writecr2(CR2 ControlRegister)
|
nsa static inline void writecr2(CR2 ControlRegister)
|
||||||
{
|
{
|
||||||
asmv("mov %[ControlRegister], %%cr2"
|
asmv("mov %[ControlRegister], %%cr2"
|
||||||
:
|
:
|
||||||
: [ControlRegister] "q"(ControlRegister.raw)
|
: [ControlRegister] "q"(ControlRegister.raw)
|
||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline void writecr3(CR3 ControlRegister)
|
nsa static inline void writecr3(CR3 ControlRegister)
|
||||||
{
|
{
|
||||||
asmv("mov %[ControlRegister], %%cr3"
|
asmv("mov %[ControlRegister], %%cr3"
|
||||||
:
|
:
|
||||||
: [ControlRegister] "q"(ControlRegister.raw)
|
: [ControlRegister] "q"(ControlRegister.raw)
|
||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline void writecr4(CR4 ControlRegister)
|
nsa static inline void writecr4(CR4 ControlRegister)
|
||||||
{
|
{
|
||||||
asmv("mov %[ControlRegister], %%cr4"
|
asmv("mov %[ControlRegister], %%cr4"
|
||||||
:
|
:
|
||||||
: [ControlRegister] "q"(ControlRegister.raw)
|
: [ControlRegister] "q"(ControlRegister.raw)
|
||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline void writecr8(CR8 ControlRegister)
|
nsa static inline void writecr8(CR8 ControlRegister)
|
||||||
{
|
{
|
||||||
asmv("mov %[ControlRegister], %%cr8"
|
asmv("mov %[ControlRegister], %%cr8"
|
||||||
:
|
:
|
||||||
: [ControlRegister] "q"(ControlRegister.raw)
|
: [ControlRegister] "q"(ControlRegister.raw)
|
||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa static inline void writexcr0(XCR0 ControlRegister)
|
nsa static inline void writexcr0(XCR0 ControlRegister)
|
||||||
{
|
{
|
||||||
asmv("xsetbv"
|
asmv("xsetbv"
|
||||||
:
|
:
|
||||||
: "a"(ControlRegister.raw), "c"(0)
|
: "a"(ControlRegister.raw), "c"(0)
|
||||||
: "edx");
|
: "edx");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !__FENNIX_KERNEL_CPU_x64_CR_H__
|
#endif // !__FENNIX_KERNEL_CPU_x64_CR_H__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user