/*** Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: Main.cpp Date: 2022-2-18 Author: Reece ***/ #include static void PrintSoftwareSpecs() { const auto &platformInfo = AuSwInfo::GetPlatformInfo(); AuLogInfo("OS: {} (kernel: {})", platformInfo.kUserlandBrand->c_str(), platformInfo.kKernelString->c_str()); AuLogInfo("Kernel Version: {}.{}.{}", platformInfo.uKernelMajor, platformInfo.uKernelMinor, platformInfo.uKernelPatch); AuLogInfo("Userland Version: {}.{}.{}", platformInfo.uUserlandMajor, platformInfo.uUserlandMinor, platformInfo.uUserlandPatch); AuLogInfo("OS Build String: {}", platformInfo.kBuildString->c_str()); AuLogInfo("IsEnterprise? {}", platformInfo.bIsEnterprise); AuLogInfo("IsServer? {}", platformInfo.bIsServer); AuLogInfo(""); } static void PrintCPUSpecs() { const auto &cpuInfo = AuHwInfo::GetCPUInfo(); AuLogInfo("CpuInfo {} / {} / {} [sockets/cores/threads] ", cpuInfo.uSocket, cpuInfo.uCores, cpuInfo.uThreads); AuLogInfo("Package: {} by {} (arch: {})", cpuInfo.cpuId.brand, cpuInfo.cpuId.vendor, AuBuild::EArchitectureToString(cpuInfo.cpuArch)); AuLogInfo("All CPUs: {} ({}) ", cpuInfo.maskAllCores.ToString(), cpuInfo.coreTopology.size()); AuLogInfo("E-Cores: {} ", cpuInfo.maskECores.ToString()); AuLogInfo("P-Cores: {} ", cpuInfo.maskPCores.ToString()); for (const auto &cpu : cpuInfo.coreTopology) { AuLogInfo("Core: {}", cpu.ToString()); } AuLogInfo("CPUID: \n{}", cpuInfo.cpuId.ToString()); AuLogInfo(""); } static void PrintRamSpecs() { auto val = AuHwInfo::GetMemStatProcessBlamed().value_or(AuHwInfo::RamStat {}); AuLogInfo("RamInfo Private Allocation: {}/{}", val.qwUsed, val.qwAvailable); val = AuHwInfo::GetMemStatProcess().value_or(AuHwInfo::RamStat {}); AuLogInfo("RamInfo Address Space: {}/{}", val.qwUsed, val.qwAvailable); val = AuHwInfo::GetMemStatSystem().value_or(AuHwInfo::RamStat {}); AuLogInfo("RamInfo System Commit Charge: {}/{}", val.qwUsed, val.qwAvailable); AuLogInfo(" if high compared to phys, expand page file"); val = AuHwInfo::GetMemStatStartup().value_or(AuHwInfo::RamStat {}); AuLogInfo("RamInfo Startup Commit: {}/{}", val.qwUsed, val.qwAvailable); val = AuHwInfo::GetMemStatPhysical().value_or(AuHwInfo::RamStat {}); AuLogInfo("RamInfo Physical RAM: {}/{}", val.qwUsed, val.qwAvailable); AuLogInfo(""); } static void DumpAddressSpace() { auto cur = AuProcess::GetSection(reinterpret_cast(DumpAddressSpace)); if (!cur.has_value()) { return; } auto section = cur.value_or(AuProcess::Section {}); auto temp = section.moduleMeta.lock(); AuLogInfo("Hello from:"); AuLogInfo(" Module: {} ({}) @ 0x{:x} (0x{:x})", temp->moduleMeta->moduleName, temp->moduleMeta->modulePath, temp->moduleMeta->moduleBase, temp->moduleMeta->origVa); AuLogInfo(" Section: {} 0x{:x} (0x{:x}), file offset: 0x{:x}, size 0x{:x}. nx: {} write: {} read: {}", section.name, section.baseVa, section.origVa, section.fsOff, section.size, section.pt.NX, section.pt.writable, section.pt.readable); AuLogInfo(""); AuSPtr moduleMeta; for (const auto &mod : AuProcess::DumpExecutableAll()) { auto temp = mod.moduleMeta.lock(); if (temp != moduleMeta && temp) { moduleMeta = temp; AuLogInfo("Module: {} ({}) @ 0x{:x} (0x{:x})", temp->moduleMeta->moduleName, temp->moduleMeta->modulePath, temp->moduleMeta->moduleBase, temp->moduleMeta->origVa); } else if (!temp) { AuLogInfo("Module unknown"); } AuLogInfo(" Section: {} 0x{:x} (0x{:x}), file offset: 0x{:x}, size 0x{:x}. nx: {} write: {} read: {}", mod.name, mod.baseVa, mod.origVa, mod.fsOff, mod.size, mod.pt.NX, mod.pt.writable, mod.pt.readable); } AuLogInfo(""); } void RunTests() { Aurora::RuntimeStartInfo info; info.console.fio.enableLogging = false; Aurora::RuntimeStart(info); PrintSoftwareSpecs(); PrintRamSpecs(); PrintCPUSpecs(); DumpAddressSpace(); }