implemented fxsr

This commit is contained in:
Alex 2022-11-06 04:55:01 +02:00
parent 3d947c2a03
commit 776f6d71b0
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
3 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,11 @@
[bits 64]
[global _amd64_fxsave]
_amd64_fxsave:
fxsave [rdi]
ret
[global _amd64_fxrstor]
_amd64_fxrstor:
fxrstor [rdi]
ret

View File

@ -0,0 +1,11 @@
[bits 64]
[global _i386_fxsave]
_i386_fxsave:
fxsave [edi]
ret
[global _i386_fxrstor]
_i386_fxrstor:
fxrstor [edi]
ret

View File

@ -5,6 +5,11 @@
#include <cstring> #include <cstring>
extern "C" void _amd64_fxsave(char *Buffer);
extern "C" void _amd64_fxrstor(char *Buffer);
extern "C" void _i386_fxsave(char *Buffer);
extern "C" void _i386_fxrstor(char *Buffer);
#define x86_CPUID_VENDOR_OLDAMD "AMDisbetter!" /* Early engineering samples of AMD K5 processor */ #define x86_CPUID_VENDOR_OLDAMD "AMDisbetter!" /* Early engineering samples of AMD K5 processor */
#define x86_CPUID_VENDOR_AMD "AuthenticAMD" #define x86_CPUID_VENDOR_AMD "AuthenticAMD"
#define x86_CPUID_VENDOR_INTEL "GenuineIntel" #define x86_CPUID_VENDOR_INTEL "GenuineIntel"
@ -1580,6 +1585,7 @@ namespace CPU
__attribute__((no_stack_protector)) static inline void fxsave(char *FXSaveArea) __attribute__((no_stack_protector)) static inline void fxsave(char *FXSaveArea)
{ {
#if defined(__amd64__) #if defined(__amd64__)
_amd64_fxsave(FXSaveArea);
// asmv("fxsaveq (%0)" // asmv("fxsaveq (%0)"
// : // :
// : "r"(FXSaveArea) // : "r"(FXSaveArea)
@ -1590,6 +1596,7 @@ namespace CPU
__attribute__((no_stack_protector)) static inline void fxrstor(char *FXRstorArea) __attribute__((no_stack_protector)) static inline void fxrstor(char *FXRstorArea)
{ {
#if defined(__amd64__) #if defined(__amd64__)
_amd64_fxrstor(FXRstorArea);
// asmv("fxrstorq (%0)" // asmv("fxrstorq (%0)"
// : // :
// : "r"(FXRstorArea) // : "r"(FXRstorArea)