[+] Added ToString to CpuId

[*] Added const modifier to cpuid functions
[*] Added OnExit to planned API interface
[*] BlobReader now holds onto a handle of a ByteBuffer, allowing for shared usage -> aiding in the mitigation of allocations/second and needless heavy copy of objects
This commit is contained in:
Reece Wilson 2022-01-27 07:45:42 +00:00
parent d7c6d66fad
commit 5bc1985eca
5 changed files with 179 additions and 116 deletions

View File

@ -19,19 +19,42 @@ namespace Aurora::Console
/// Writes a log message to the console subscribers and telemetry outputs
AUKN_SYM void WriteLine(AuUInt8 level, const ConsoleMessage &msg);
/**
* @brief Overloads the ILogger backend of the AuLogXX functions
* @param defaultGlobalLogger
* @return
*/
AUKN_SYM void SetGlobalLogger(const AuSPtr<Logging::ILogger> &defaultGlobalLogger);
/**
* @brief Returns the untouched ILogger interface of the AuLogXX functions as configured by the Aurora::RuntimeStartInfo structure
* @return
*/
AUKN_SYM AuSPtr<Logging::ILogger> GetDefaultLogInterface();
/// Consider using the following function for asynchronous utf-8 processed line based input -
/// Hooks::SetCallbackAndDisableCmdProcessing(...)
/**
* @brief Async read of the underlying binary stream, unlocalized and potentially being consumed by other users.
* Consider using `Hooks::SetCallbackAndDisableCmdProcessing` for asynchronous utf-8 processed line based input
* @param buffer
* @param length
* @return
*/
AUKN_SYM AuUInt32 ReadStdIn(void *buffer, AuUInt32 length);
/// Consider using AuLog for general purpose use
/**
* @brief Synchronous binary write to the applications stdout stream. Consider using `AuLogInfo` for general purpose messaging
* @param buffer
* @param length
* @return
*/
AUKN_SYM AuUInt32 WriteStdOut(const void *buffer, AuUInt32 length);
/**
* Simulates a processed stdin line given a UTF8 string
*/
* @brief Simulates an input line from an internal logger/console interface given a UTF-8 string
* @param string
* @return
*/
AUKN_SYM bool DispatchRawLine(const AuString &string);
AUKN_SYM void OpenLateStd();

View File

@ -11,63 +11,65 @@ namespace Aurora::HWInfo
{
struct AUKN_SYM CpuId
{
bool SSE3();
bool PCLMULQDQ();
bool MONITOR();
bool SSSE3();
bool FMA();
bool CMPXCHG16B();
bool SSE41();
bool SSE42();
bool MOVBE();
bool POPCNT();
bool AES();
bool XSAVE();
bool OSXSAVE();
bool AVX();
bool F16C();
bool RDRAND();
bool SSE3() const;
bool PCLMULQDQ() const;
bool MONITOR() const;
bool SSSE3() const;
bool FMA() const;
bool CMPXCHG16B() const;
bool SSE41() const;
bool SSE42() const;
bool MOVBE() const;
bool POPCNT() const;
bool AES() const;
bool XSAVE() const;
bool OSXSAVE() const;
bool AVX() const;
bool F16C() const;
bool RDRAND() const;
bool MSR();
bool CX8();
bool SEP();
bool CMOV();
bool CLFSH();
bool MMX();
bool FXSR();
bool SSE();
bool SSE2();
bool MSR() const;
bool CX8() const;
bool SEP() const;
bool CMOV() const;
bool CLFSH() const;
bool MMX() const;
bool FXSR() const;
bool SSE() const;
bool SSE2() const;
bool FSGSBASE();
bool BMI1();
bool HLE();
bool AVX2();
bool BMI2();
bool ERMS();
bool INVPCID();
bool RTM();
bool AVX512F();
bool RDSEED();
bool ADX();
bool AVX512PF();
bool AVX512ER();
bool AVX512CD();
bool SHA();
bool FSGSBASE() const;
bool BMI1() const;
bool HLE() const;
bool AVX2() const;
bool BMI2() const;
bool ERMS() const;
bool INVPCID() const;
bool RTM() const;
bool AVX512F() const;
bool RDSEED() const;
bool ADX() const;
bool AVX512PF() const;
bool AVX512ER() const;
bool AVX512CD() const;
bool SHA() const;
bool PREFETCHWT1();
bool PREFETCHWT1() const;
bool LAHF();
bool LZCNT();
bool ABM();
bool SSE4a();
bool XOP();
bool TBM();
bool LAHF() const;
bool LZCNT() const;
bool ABM() const;
bool SSE4a() const;
bool XOP() const;
bool TBM() const;
bool SYSCALL();
bool MMXEXT();
bool RDTSCP();
bool _3DNOWEXT();
bool _3DNOW();
bool SYSCALL() const;
bool MMXEXT() const;
bool RDTSCP() const;
bool _3DNOWEXT() const;
bool _3DNOW() const;
AuString ToString() const;
AuString vendor;
AuString brand;

View File

@ -12,24 +12,29 @@ namespace Aurora::IO::Buffered
class BlobReader : public IStreamReader
{
public:
AU_NO_COPY_NO_MOVE(BlobReader)
AU_NO_COPY(BlobReader)
BlobReader(const Memory::ByteBuffer &buffer) : buffer_(buffer) {}
BlobReader(const AuSPtr<Memory::ByteBuffer> &buffer) : buffer_(buffer) {}
BlobReader(Memory::ByteBuffer &&buffer) : buffer_(AuMakeShared<Memory::ByteBuffer>(buffer)) {}
BlobReader(const Memory::ByteBuffer &buffer) : buffer_(AuMakeShared<Memory::ByteBuffer>(buffer)) {}
BlobReader() {}
~BlobReader() {}
virtual EStreamError Open() override
{
if (!buffer_) return EStreamError::eErrorStreamNotOpen;
if (!buffer_->operator bool()) return EStreamError::eErrorStreamNotOpen;
return EStreamError::eErrorNone;
}
virtual EStreamError Read(const Memory::MemoryViewStreamWrite &paramters) override
{
auto realEndOffset = AuMin(buffer_.size() - offset_, paramters.length);
auto realEndOffset = AuMin(buffer_->size() - offset_, paramters.length);
if (realEndOffset == 0) return EStreamError::eErrorEndOfStream;
paramters.outVariable = realEndOffset;
AuMemcpy(paramters.ptr, buffer_.data() + offset_, realEndOffset);
AuMemcpy(paramters.ptr, buffer_->data() + offset_, realEndOffset);
offset_ += realEndOffset;
return EStreamError::eErrorNone;
@ -37,11 +42,11 @@ namespace Aurora::IO::Buffered
virtual void Close() override
{
buffer_.clear();
buffer_->clear();
}
private:
Memory::ByteBuffer buffer_;
AuSPtr<Memory::ByteBuffer> buffer_;
AuUInt32 offset_ {};
};
}

View File

@ -11,7 +11,8 @@ namespace Aurora::Processes
{
AUKN_INTERFACE(ICommandFinished,
AUI_METHOD(void, OnLines, (const AuList<AuString> &, buffer)),
AUI_METHOD(void, OnBuffered, (const Memory::ByteBuffer &, buffer))
AUI_METHOD(void, OnBuffered, (const Memory::ByteBuffer &, buffer)),
AUI_METHOD(void, OnExit, (AuUInt32, exitCode))
);
struct CommandRun_s

View File

@ -57,266 +57,298 @@ namespace Aurora::HWInfo
}
#endif
bool CpuId::SSE3()
bool CpuId::SSE3() const
{
return AuTestBit(f_1_ECX, 0);
}
bool CpuId::PCLMULQDQ()
bool CpuId::PCLMULQDQ() const
{
return AuTestBit(f_1_ECX, 1);
}
bool CpuId::MONITOR()
bool CpuId::MONITOR() const
{
return AuTestBit(f_1_ECX, 3);
}
bool CpuId::SSSE3()
bool CpuId::SSSE3() const
{
return AuTestBit(f_1_ECX, 9);
}
bool CpuId::FMA()
bool CpuId::FMA() const
{
return AuTestBit(f_1_ECX, 12);
}
bool CpuId::CMPXCHG16B()
bool CpuId::CMPXCHG16B() const
{
return AuTestBit(f_1_ECX, 13);
}
bool CpuId::SSE41()
bool CpuId::SSE41() const
{
return AuTestBit(f_1_ECX, 19);
}
bool CpuId::SSE42()
bool CpuId::SSE42() const
{
return AuTestBit(f_1_ECX, 20);
}
bool CpuId::MOVBE()
bool CpuId::MOVBE() const
{
return AuTestBit(f_1_ECX, 22);
}
bool CpuId::POPCNT()
bool CpuId::POPCNT() const
{
return AuTestBit(f_1_ECX, 23);
}
bool CpuId::AES()
bool CpuId::AES() const
{
return AuTestBit(f_1_ECX, 25);
}
bool CpuId::XSAVE()
bool CpuId::XSAVE() const
{
return AuTestBit(f_1_ECX, 26);
}
bool CpuId::OSXSAVE()
bool CpuId::OSXSAVE() const
{
return AuTestBit(f_1_ECX, 27);
}
bool CpuId::AVX()
bool CpuId::AVX() const
{
return AuTestBit(f_1_ECX, 28);
}
bool CpuId::F16C()
bool CpuId::F16C() const
{
return AuTestBit(f_1_ECX, 29);
}
bool CpuId::RDRAND()
bool CpuId::RDRAND() const
{
return AuTestBit(f_1_ECX, 30);
}
bool CpuId::MSR()
bool CpuId::MSR() const
{
return AuTestBit(f_1_EDX, 5);
}
bool CpuId::CX8()
bool CpuId::CX8() const
{
return AuTestBit(f_1_EDX, 8);
}
bool CpuId::SEP()
bool CpuId::SEP() const
{
return AuTestBit(f_1_EDX, 11);
}
bool CpuId::CMOV()
bool CpuId::CMOV() const
{
return AuTestBit(f_1_EDX, 15);
}
bool CpuId::CLFSH()
bool CpuId::CLFSH() const
{
return AuTestBit(f_1_EDX, 19);
}
bool CpuId::MMX()
bool CpuId::MMX() const
{
return AuTestBit(f_1_EDX, 23);
}
bool CpuId::FXSR()
bool CpuId::FXSR() const
{
return AuTestBit(f_1_EDX, 24);
}
bool CpuId::SSE()
bool CpuId::SSE() const
{
return AuTestBit(f_1_EDX, 25);
}
bool CpuId::SSE2()
bool CpuId::SSE2() const
{
return AuTestBit(f_1_EDX, 26);
}
bool CpuId::FSGSBASE()
bool CpuId::FSGSBASE() const
{
return AuTestBit(f_7_EBX, 0);
}
bool CpuId::BMI1()
bool CpuId::BMI1() const
{
return AuTestBit(f_7_EBX, 3);
}
bool CpuId::HLE()
bool CpuId::HLE() const
{
return isIntel && AuTestBit(f_7_EBX, 4);
}
bool CpuId::AVX2()
bool CpuId::AVX2() const
{
return AuTestBit(f_7_EBX, 5);
}
bool CpuId::BMI2()
bool CpuId::BMI2() const
{
return AuTestBit(f_7_EBX, 8);
}
bool CpuId::ERMS()
bool CpuId::ERMS() const
{
return AuTestBit(f_7_EBX, 9);
}
bool CpuId::INVPCID()
bool CpuId::INVPCID() const
{
return AuTestBit(f_7_EBX, 10);
}
bool CpuId::RTM()
bool CpuId::RTM() const
{
return isIntel && AuTestBit(f_7_EBX, 11);
}
bool CpuId::AVX512F()
bool CpuId::AVX512F() const
{
return AuTestBit(f_7_EBX, 16);
}
bool CpuId::RDSEED()
bool CpuId::RDSEED() const
{
return AuTestBit(f_7_EBX, 18);
}
bool CpuId::ADX()
bool CpuId::ADX() const
{
return AuTestBit(f_7_EBX, 19);
}
bool CpuId::AVX512PF()
bool CpuId::AVX512PF() const
{
return AuTestBit(f_7_EBX, 26);
}
bool CpuId::AVX512ER()
bool CpuId::AVX512ER() const
{
return AuTestBit(f_7_EBX, 27);
}
bool CpuId::AVX512CD()
bool CpuId::AVX512CD() const
{
return AuTestBit(f_7_EBX, 28);
}
bool CpuId::SHA()
bool CpuId::SHA() const
{
return AuTestBit(f_7_EBX, 29);
}
bool CpuId::PREFETCHWT1()
bool CpuId::PREFETCHWT1() const
{
return AuTestBit(f_7_ECX, 0);
}
bool CpuId::LAHF()
bool CpuId::LAHF() const
{
return AuTestBit(f_81_ECX, 0);
}
bool CpuId::LZCNT()
bool CpuId::LZCNT() const
{
return isIntel && AuTestBit(f_81_ECX, 5);
}
bool CpuId::ABM()
bool CpuId::ABM() const
{
return isAMD && AuTestBit(f_81_ECX, 5);
}
bool CpuId::SSE4a()
bool CpuId::SSE4a() const
{
return isAMD && AuTestBit(f_81_ECX, 6);
}
bool CpuId::XOP()
bool CpuId::XOP() const
{
return isAMD && AuTestBit(f_81_ECX, 11);
}
bool CpuId::TBM()
bool CpuId::TBM() const
{
return isAMD && AuTestBit(f_81_ECX, 21);
}
bool CpuId::SYSCALL()
bool CpuId::SYSCALL() const
{
return isIntel && AuTestBit(f_81_EDX, 11);
}
bool CpuId::MMXEXT()
bool CpuId::MMXEXT() const
{
return isAMD && AuTestBit(f_81_EDX, 22);
}
bool CpuId::RDTSCP()
bool CpuId::RDTSCP() const
{
return isIntel && AuTestBit(f_81_EDX, 27);
}
bool CpuId::_3DNOWEXT()
bool CpuId::_3DNOWEXT() const
{
return isAMD && AuTestBit(f_81_EDX, 30);
}
bool CpuId::_3DNOW()
bool CpuId::_3DNOW() const
{
return isAMD && AuTestBit(f_81_EDX, 31);
}
AuString CpuId::ToString() const
{
return fmt::format(
"FMA {}\t\tFSGSBASE {}\t\tCLFSH {}\t\tERMS {}{}"
"CMPXCHG16B {}\t\tAVX512PF {}\t\tMOVBE {}\t\tRTM {}{}"
"POPCNT {}\t\tAVX512ER {}\t\tMONITOR {}\t\tLAHF {}{}"
"SSE {}\t\tAVX512CD {}\t\tF16C {}\t\tABM {}{}"
"SSE2 {}\t\tSYSCALL {}\t\tRDRAND {}\t\tXOP {}{}"
"SSE3 {}\t\tAES {}\t\tMSR {}\t\tTBM {}{}"
"SSSE3 {}\t\tRDTSCP {}\t\tCX8 {}\t\tMMXEXT {}{}"
"SSE41 {}\t\tXSAVE {}\t\tSEP {}\t\tRDSEED {}{}"
"SSE42 {}\t\tOSXSAVE {}\t\tCMOV {}\t\tPREFETCHWT1 {}{}"
"SSE4a {}\t\tSHA {}\t\tFXSR {}\t\tPCLMULQDQ {}{}"
"AVX {}\t\tAVX512F {}\t\tBMI1 {}\t\tINVPCID {}{}"
"AVX2 {}\t\tLZCNT {}\t\tHLE {}\t\t_3DNOWEXT {}{}"
"MMX {}\t\tADX {}\t\tBMI2 {}\t\t_3DNOW {}",
FMA(), FSGSBASE(), CLFSH(), ERMS(), Aurora::Locale::NewLine(),
CMPXCHG16B(), AVX512PF(), MOVBE(), RTM(), Aurora::Locale::NewLine(),
POPCNT(), AVX512ER(), MONITOR(), LAHF(), Aurora::Locale::NewLine(),
SSE(), AVX512CD(), F16C(), ABM(), Aurora::Locale::NewLine(),
SSE2(), SYSCALL(), RDRAND(), XOP(), Aurora::Locale::NewLine(),
SSE3(), AES(), MSR(), TBM(), Aurora::Locale::NewLine(),
SSSE3(), RDTSCP(), CX8(), MMXEXT(), Aurora::Locale::NewLine(),
SSE41(), XSAVE(), SEP(), RDSEED(), Aurora::Locale::NewLine(),
SSE42(), OSXSAVE(), CMOV(), PREFETCHWT1(), Aurora::Locale::NewLine(),
SSE4a(), SHA(), FXSR(), PCLMULQDQ(), Aurora::Locale::NewLine(),
AVX(), AVX512F(), BMI1(), INVPCID(), Aurora::Locale::NewLine(),
AVX2(), LZCNT(), HLE(), _3DNOWEXT(), Aurora::Locale::NewLine(),
MMX(), ADX(), BMI2(), _3DNOW()
);
}
AUKN_SYM const CpuInfo &GetCPUInfo()
{
return gCpuInfo;