diff options
| author | Alexey Gavrilov <rebovas@yahoo.com> | 2024-03-08 12:24:02 +0700 |
|---|---|---|
| committer | Alexey Gavrilov <rebovas@yahoo.com> | 2024-03-08 12:24:02 +0700 |
| commit | fa4729c08f02a5c2c958da5142a9b4fef99a4b4f (patch) | |
| tree | d5f23cdcbc6af79eb9b789d57086c8e3c9ec9c79 /arch | |
| parent | 301dc22ee57b7c46cb033358170ffad615fef6ab (diff) | |
Cpuinfo refactor
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/x86/cpuinfo/Cpuinfo.cpp | 34 | ||||
| -rw-r--r-- | arch/x86/cpuinfo/Cpuinfo.h | 3 |
2 files changed, 9 insertions, 28 deletions
diff --git a/arch/x86/cpuinfo/Cpuinfo.cpp b/arch/x86/cpuinfo/Cpuinfo.cpp index c6c551e..4db7c84 100644 --- a/arch/x86/cpuinfo/Cpuinfo.cpp +++ b/arch/x86/cpuinfo/Cpuinfo.cpp @@ -1,4 +1,5 @@ #include "Cpuinfo.h" +#include "MemoryOperations.h" inline Cpuinfo::cpuidFunctionIndex operator++(Cpuinfo::cpuidFunctionIndex& command) @@ -52,12 +53,8 @@ Cpuinfo::Cpuinfo() currentCpuType = processorType::NotRead; serialNumber = 0; - // Write memset!!! - // memset(internalInfoDescriptors, 0, sizeof(uint8) * amountDescriptors) - - // Rewrite it! Create method memset() - for(uint8 i = 0; i < vendorStringSize; i++) vendorString[i] = '\0'; - for(uint8 i = 0; i < brandStringSize; i++) brandString[i] = '\0'; + MemoryOperations::set(vendorString, '\0', vendorStringSize); + MemoryOperations::set(brandString, '\0', brandStringSize); dataFilling(Cpuinfo::BasicInfo, Cpuinfo::ExtendedCpuidEnd); }; @@ -87,15 +84,7 @@ void Cpuinfo::setBasicData() uint32 vendorStringInt[3] = {ebx, edx, ecx}; - // Rewrite it! Create method memcpy() - for(int i = 0; i < 3; i++) - { - uint8 upperCharIndex = i * 4 + 3; - vendorString[upperCharIndex--] = vendorStringInt[i] >> 24; - vendorString[upperCharIndex--] = vendorStringInt[i] >> 16; - vendorString[upperCharIndex--] = vendorStringInt[i] >> 8; - vendorString[upperCharIndex--] = vendorStringInt[i]; - } + MemoryOperations::copy(vendorStringInt, vendorString, sizeof(uint32) * 3); }; void Cpuinfo::setVersionData() @@ -182,16 +171,7 @@ void Cpuinfo::setBrandString(brandStringPart part) uint8 partUint = uint8(part); uint32 regs[4] = {eax, ebx, ecx, edx}; - // memCpy()!!! - for(uint8 regIndex = 0; regIndex < 4; regIndex++) - { - uint32 reg = regs[regIndex]; - for(uint8 bytesInRegister = 0; bytesInRegister < 4; bytesInRegister++) - { - brandString[partUint++] = reg; - reg >>= 8; - } - } + MemoryOperations::copy(regs, &brandString[partUint], sizeof(uint32) * 4); } }; @@ -355,9 +335,9 @@ uint32 Cpuinfo::getMaxFunctionIndexExtended() return maximumInputValueExtended; }; -uint8* Cpuinfo::getBrandString() +const char* Cpuinfo::getBrandString() { - return brandString; + return (const char*)brandString; }; uint8* Cpuinfo::getInternalDescriptors() diff --git a/arch/x86/cpuinfo/Cpuinfo.h b/arch/x86/cpuinfo/Cpuinfo.h index 4baa76f..6adce11 100644 --- a/arch/x86/cpuinfo/Cpuinfo.h +++ b/arch/x86/cpuinfo/Cpuinfo.h @@ -1,6 +1,7 @@ #ifndef CPUID_H #define CPUID_H #include <types.h> +#include <MemoryOperations.h> #ifdef __cplusplus @@ -358,7 +359,7 @@ class Cpuinfo uint8 getStepping(); uint8 getMaxFunctionIndex(); uint32 getMaxFunctionIndexExtended(); - uint8* getBrandString(); + const char* getBrandString(); uint8* getInternalDescriptors(); }; #endif |
