Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/ps/GameSetup/HWDetect.cpp
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
static void ReportGLLimits(const ScriptInterface& scriptInterface, JS::HandleValue settings); | static void ReportGLLimits(const ScriptInterface& scriptInterface, JS::HandleValue settings); | ||||
#if ARCH_X86_X64 | #if ARCH_X86_X64 | ||||
void ConvertCaches(const ScriptInterface& scriptInterface, x86_x64::IdxCache idxCache, JS::MutableHandleValue ret) | void ConvertCaches(const ScriptInterface& scriptInterface, x86_x64::IdxCache idxCache, JS::MutableHandleValue ret) | ||||
{ | { | ||||
JSContext* cx = scriptInterface.GetContext(); | JSContext* cx = scriptInterface.GetContext(); | ||||
JSAutoRequest rq(cx); | JSAutoRequest rq(cx); | ||||
scriptInterface.Eval("[]", ret); | scriptInterface.CreateArray(ret); | ||||
for (size_t idxLevel = 0; idxLevel < x86_x64::Cache::maxLevels; ++idxLevel) | for (size_t idxLevel = 0; idxLevel < x86_x64::Cache::maxLevels; ++idxLevel) | ||||
{ | { | ||||
const x86_x64::Cache* pcache = x86_x64::Caches(idxCache+idxLevel); | const x86_x64::Cache* pcache = x86_x64::Caches(idxCache+idxLevel); | ||||
if (pcache->m_Type == x86_x64::Cache::kNull || pcache->m_NumEntries == 0) | if (pcache->m_Type == x86_x64::Cache::kNull || pcache->m_NumEntries == 0) | ||||
continue; | continue; | ||||
JS::RootedValue cache(cx); | JS::RootedValue cache(cx); | ||||
scriptInterface.Eval("({})", &cache); | |||||
scriptInterface.SetProperty(cache, "type", static_cast<u32>(pcache->m_Type)); | scriptInterface.CreateObject( | ||||
scriptInterface.SetProperty(cache, "level", static_cast<u32>(pcache->m_Level)); | &cache, | ||||
scriptInterface.SetProperty(cache, "associativity", static_cast<u32>(pcache->m_Associativity)); | "type", static_cast<u32>(pcache->m_Type), | ||||
scriptInterface.SetProperty(cache, "linesize", static_cast<u32>(pcache->m_EntrySize)); | "level", static_cast<u32>(pcache->m_Level), | ||||
scriptInterface.SetProperty(cache, "sharedby", static_cast<u32>(pcache->m_SharedBy)); | "associativity", static_cast<u32>(pcache->m_Associativity), | ||||
scriptInterface.SetProperty(cache, "totalsize",static_cast<u32>(pcache->TotalSize())); | "linesize", static_cast<u32>(pcache->m_EntrySize), | ||||
"sharedby", static_cast<u32>(pcache->m_SharedBy), | |||||
"totalsize", static_cast<u32>(pcache->TotalSize())); | |||||
scriptInterface.SetPropertyInt(ret, idxLevel, cache); | scriptInterface.SetPropertyInt(ret, idxLevel, cache); | ||||
} | } | ||||
} | } | ||||
void ConvertTLBs(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret) | void ConvertTLBs(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret) | ||||
{ | { | ||||
JSContext* cx = scriptInterface.GetContext(); | JSContext* cx = scriptInterface.GetContext(); | ||||
JSAutoRequest rq(cx); | JSAutoRequest rq(cx); | ||||
scriptInterface.Eval("[]", ret); | scriptInterface.CreateArray(ret); | ||||
for(size_t i = 0; ; i++) | for(size_t i = 0; ; i++) | ||||
{ | { | ||||
const x86_x64::Cache* ptlb = x86_x64::Caches(x86_x64::TLB+i); | const x86_x64::Cache* ptlb = x86_x64::Caches(x86_x64::TLB+i); | ||||
if (!ptlb) | if (!ptlb) | ||||
break; | break; | ||||
JS::RootedValue tlb(cx); | JS::RootedValue tlb(cx); | ||||
scriptInterface.Eval("({})", &tlb); | |||||
scriptInterface.SetProperty(tlb, "type", static_cast<u32>(ptlb->m_Type)); | scriptInterface.CreateObject( | ||||
scriptInterface.SetProperty(tlb, "level", static_cast<u32>(ptlb->m_Level)); | &tlb, | ||||
scriptInterface.SetProperty(tlb, "associativity", static_cast<u32>(ptlb->m_Associativity)); | "type", static_cast<u32>(ptlb->m_Type), | ||||
scriptInterface.SetProperty(tlb, "pagesize", static_cast<u32>(ptlb->m_EntrySize)); | "level", static_cast<u32>(ptlb->m_Level), | ||||
scriptInterface.SetProperty(tlb, "entries", static_cast<u32>(ptlb->m_NumEntries)); | "associativity", static_cast<u32>(ptlb->m_Associativity), | ||||
"pagesize", static_cast<u32>(ptlb->m_EntrySize), | |||||
"entries", static_cast<u32>(ptlb->m_NumEntries)); | |||||
scriptInterface.SetPropertyInt(ret, i, tlb); | scriptInterface.SetPropertyInt(ret, i, tlb); | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
// The Set* functions will override the default behaviour, unless the user | // The Set* functions will override the default behaviour, unless the user | ||||
// has explicitly set a config variable to override that. | // has explicitly set a config variable to override that. | ||||
// (TODO: This is an ugly abuse of the config system) | // (TODO: This is an ugly abuse of the config system) | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | void RunHardwareDetection() | ||||
std::string code = file.DecodeUTF8(); // assume it's UTF-8 | std::string code = file.DecodeUTF8(); // assume it's UTF-8 | ||||
scriptInterface.LoadScript(scriptName, code); | scriptInterface.LoadScript(scriptName, code); | ||||
// Collect all the settings we'll pass to the script: | // Collect all the settings we'll pass to the script: | ||||
// (We'll use this same data for the opt-in online reporting system, so it | // (We'll use this same data for the opt-in online reporting system, so it | ||||
// includes some fields that aren't directly useful for the hwdetect script) | // includes some fields that aren't directly useful for the hwdetect script) | ||||
JS::RootedValue settings(cx); | JS::RootedValue settings(cx); | ||||
scriptInterface.Eval("({})", &settings); | scriptInterface.CreateObject(&settings); | ||||
scriptInterface.SetProperty(settings, "os_unix", OS_UNIX); | scriptInterface.SetProperty(settings, "os_unix", OS_UNIX); | ||||
scriptInterface.SetProperty(settings, "os_bsd", OS_BSD); | scriptInterface.SetProperty(settings, "os_bsd", OS_BSD); | ||||
scriptInterface.SetProperty(settings, "os_linux", OS_LINUX); | scriptInterface.SetProperty(settings, "os_linux", OS_LINUX); | ||||
scriptInterface.SetProperty(settings, "os_android", OS_ANDROID); | scriptInterface.SetProperty(settings, "os_android", OS_ANDROID); | ||||
scriptInterface.SetProperty(settings, "os_macosx", OS_MACOSX); | scriptInterface.SetProperty(settings, "os_macosx", OS_MACOSX); | ||||
scriptInterface.SetProperty(settings, "os_win", OS_WIN); | scriptInterface.SetProperty(settings, "os_win", OS_WIN); | ||||
▲ Show 20 Lines • Show All 518 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator