Skip to content

Commit

Permalink
[...] Largely overhaul init and SMC
Browse files Browse the repository at this point in the history
(again)
  • Loading branch information
Vali0004 committed Mar 6, 2025
1 parent 62570a4 commit 1679a42
Show file tree
Hide file tree
Showing 36 changed files with 1,886 additions and 1,757 deletions.
140 changes: 72 additions & 68 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
}
},
{
"name": "windows-msvc-base",
"name": "windows-gcc-base",
"hidden": true,
"generator": "Visual Studio 17 2022",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/install/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc.exe",
"CMAKE_CXX_COMPILER": "g++.exe"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
Expand All @@ -41,6 +45,18 @@
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x86-clang-debug",
"displayName": "x86-Clang-Debug",
"inherits": "windows-clang-base",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x64-clang-release",
"displayName": "x64-Clang-Release",
Expand All @@ -49,6 +65,14 @@
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x86-clang-release",
"displayName": "x86-Clang-Release",
"inherits": "x86-clang-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x64-clang-relwithdebinfo",
"displayName": "x64-Clang-RelWithDebInfo",
Expand All @@ -58,9 +82,17 @@
}
},
{
"name": "x64-msvc-debug",
"displayName": "x64-MSVC-Debug",
"inherits": "windows-msvc-base",
"name": "x86-Clang-relwithdebinfo",
"displayName": "x86-Clang-RelWithDebInfo",
"inherits": "x86-clang-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "x64-gcc-debug",
"displayName": "x64-GCC-Debug",
"inherits": "windows-gcc-base",
"architecture": {
"value": "x64",
"strategy": "external"
Expand All @@ -70,73 +102,45 @@
}
},
{
"name": "x64-msvc-release",
"displayName": "x64-MSVC-Release",
"inherits": "x64-msvc-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x64-msvc-relwithdebinfo",
"displayName": "x64-MSVC-RelWithDebInfo",
"inherits": "x64-msvc-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "x86-msvc-debug",
"displayName": "x86-MSVC-Debug",
"inherits": "windows-msvc-base",
"name": "x86-gcc-debug",
"displayName": "x86-GCC-Debug",
"inherits": "windows-gcc-base",
"architecture": {
"value": "Win32",
"strategy": "set"
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x86-msvc-release",
"displayName": "x86-MSVC-Release",
"inherits": "x86-msvc-debug",
"name": "x64-gcc-release",
"displayName": "x64-GCC-Release",
"inherits": "x64-gcc-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x86-msvc-relwithdebinfo",
"displayName": "x86-MSVC-RelWithDebInfo",
"inherits": "x86-msvc-debug",
"name": "x86-gcc-release",
"displayName": "x86-GCC-Release",
"inherits": "x86-gcc-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "x86-clang-debug",
"displayName": "x86-Clang-Debug",
"inherits": "windows-clang-base",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x86-clang-release",
"displayName": "x86-Clang-Release",
"inherits": "x86-clang-debug",
"name": "x64-gcc-relwithdebinfo",
"displayName": "x64-GCC-RelWithDebInfo",
"inherits": "x64-gcc-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "x86-Clang-relwithdebinfo",
"displayName": "x86-Clang-RelWithDebInfo",
"inherits": "x86-clang-debug",
"name": "x86-gcc-relwithdebinfo",
"displayName": "x86-GCC-RelWithDebInfo",
"inherits": "x86-gcc-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
Expand Down Expand Up @@ -170,22 +174,6 @@
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x64-linux-release",
"displayName": "x64-Linux-Release",
"inherits": "x64-linux-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x64-linux-relwithdebinfo",
"displayName": "x64-Linux-RelWithDebInfo",
"inherits": "x64-linux-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "x86-linux-debug",
"displayName": "x86-Linux-Debug",
Expand All @@ -198,6 +186,14 @@
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x64-linux-release",
"displayName": "x64-Linux-Release",
"inherits": "x64-linux-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x86-linux-release",
"displayName": "x86-Linux-Release",
Expand All @@ -206,6 +202,14 @@
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x64-linux-relwithdebinfo",
"displayName": "x64-Linux-RelWithDebInfo",
"inherits": "x64-linux-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "x86-linux-relwithdebinfo",
"displayName": "x86-Linux-RelWithDebInfo",
Expand Down
4 changes: 2 additions & 2 deletions Xenon/Base/Arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#pragma once

#if defined(__x86_64__) || defined(_M_X64)
#if defined(__x86_64__) || defined(_M_X64) || defined(_M_X86)
#define ARCH_X86_64 1
#elif defined(__aarch64__) || defined(_M_ARM64)
#define ARCH_ARM64 1
#endif
#endif
69 changes: 27 additions & 42 deletions Xenon/Base/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,29 @@ std::filesystem::path find_fs_path_or(const basic_value<TC> &v, const K &ky,

namespace Config {

std::string* COMPort() {
com = "\\\\.\\COM" + std::to_string(comPort);
return &com;
}

bool fullscreenMode() { return isFullscreen; }

bool vsync() { return vsyncEnabled; }

bool gpuThreadEnabled() { return gpuRenderThreadEnabled; }

bool quitOnWindowClosure() { return shouldQuitOnWindowClosure; }

Base::Log::Level getCurrentLogLevel() { return currentLogLevel; }

bool logAdvanced() { return islogAdvanced; }

int smcCurrentAvPack() { return smcAvPackType; }

int smcPowerOnType() { return smcPowerOnReason; }
std::string& COMPort() { return com = "\\\\.\\COM" + std::to_string(comPort); }
bool useBackupUART() { return useBackupUart; }

u64 HW_INIT_SKIP1() { return SKIP_HW_INIT_1; }

u64 HW_INIT_SKIP2() { return SKIP_HW_INIT_2; }

s32 windowWidth() { return screenWidth; }

s32 windowHeight() { return screenHeight; }

s32 internalWindowWidth() { return internalWidth; }

s32 internalWindowHeight() { return internalHeight; }

std::string fusesPath() { return fusesTxtPath; }

std::string oneBlPath() { return oneBlBinPath; }

std::string nandPath() { return nandBinPath; }

std::string oddImagePath() { return oddDiscImagePath; }

// s32 getGpuId() {
Expand All @@ -78,6 +62,16 @@ void loadConfig(const std::filesystem::path &path) {
std::ifstream configFile{ path };
std::error_code error;
if (!std::filesystem::exists(path, error) && !configFile.is_open()) {
#ifdef _WIN32
std::string pathPrefix{};
#else
// TODO(Vali0004): Pull if Linux or MacOS
std::string pathPrefix{ getenv("HOME") };
fusesTxtPath.insert(0, pathPrefix.c_str());
oneBlBinPath.insert(0, pathPrefix.c_str());
nandBinPath.insert(0, pathPrefix.c_str());
oddDiscImagePath.insert(0, pathPrefix.c_str());
#endif
saveConfig(path);
return;
}
Expand All @@ -96,26 +90,29 @@ void loadConfig(const std::filesystem::path &path) {
if (data.contains("General")) {
const toml::value &general = data.at("General");
gpuRenderThreadEnabled =
toml::find_or<bool>(general, "GPURenderThreadEnabled", false);
isFullscreen = toml::find_or<bool>(general, "Fullscreen", false);
vsyncEnabled = toml::find_or<bool>(general, "VSync", false);
toml::find_or<bool>(general, "GPURenderThreadEnabled", gpuRenderThreadEnabled);
isFullscreen = toml::find_or<bool>(general, "Fullscreen", isFullscreen);
vsyncEnabled = toml::find_or<bool>(general, "VSync", vsyncEnabled);
shouldQuitOnWindowClosure =
toml::find_or<bool>(general, "QuitOnWindowClosure", false);
currentLogLevel = (Base::Log::Level)find_or<int>(general, "LogLevel", false);
islogAdvanced = toml::find_or<bool>(general, "logAdvanced", false);
toml::find_or<bool>(general, "QuitOnWindowClosure", shouldQuitOnWindowClosure);
int logLevel = static_cast<int>(currentLogLevel);
logLevel = toml::find_or<int&>(general, "LogLevel", logLevel);
currentLogLevel = static_cast<Base::Log::Level>(logLevel);
islogAdvanced = toml::find_or<bool>(general, "logAdvanced", islogAdvanced);
}

if (data.contains("SMC")) {
const toml::value &smc = data.at("SMC");
comPort = toml::find_or<int>(smc, "COMPort", false);
smcAvPackType = toml::find_or<int>(smc, "SMCAvPackType", false);
smcPowerOnReason = toml::find_or<int>(smc, "SMCPowerOnType", false);
comPort = toml::find_or<int&>(smc, "COMPort", comPort);
smcAvPackType = toml::find_or<int&>(smc, "SMCAvPackType", smcAvPackType);
smcPowerOnReason = toml::find_or<int&>(smc, "SMCPowerOnType", smcPowerOnReason);
useBackupUart = toml::find_or<bool>(smc, "UseBackupUART", useBackupUart);
}

if (data.contains("PowerPC")) {
const toml::value &powerpc = data.at("PowerPC");
SKIP_HW_INIT_1 = toml::find_or<u64>(powerpc, "HW_INIT_SKIP1", false);
SKIP_HW_INIT_2 = toml::find_or<u64>(powerpc, "HW_INIT_SKIP2", false);
SKIP_HW_INIT_1 = toml::find_or<u64&>(powerpc, "HW_INIT_SKIP1", SKIP_HW_INIT_1);
SKIP_HW_INIT_2 = toml::find_or<u64&>(powerpc, "HW_INIT_SKIP2", SKIP_HW_INIT_2);
}

if (data.contains("GPU")) {
Expand All @@ -124,7 +121,7 @@ void loadConfig(const std::filesystem::path &path) {
screenHeight = toml::find_or<int&>(gpu, "screenHeight", screenHeight);
internalWidth = toml::find_or<int&>(gpu, "internalWidth", internalWidth);
internalHeight = toml::find_or<int&>(gpu, "internalHeight", internalHeight);
// gpuId = toml::find_or<int&>(gpu, "gpuId", -1);
// gpuId = toml::find_or<int&>(gpu, "gpuId", gpuId);
}

if (data.contains("Paths")) {
Expand All @@ -147,7 +144,6 @@ void loadConfig(const std::filesystem::path &path) {
}

void saveConfig(const std::filesystem::path &path) {
bool firstTimeConfig{};
toml::value data;

std::error_code error;
Expand All @@ -163,7 +159,6 @@ void saveConfig(const std::filesystem::path &path) {
if (error) {
LOG_ERROR(Config, "Filesystem error: {}", error.message());
}
firstTimeConfig = true;
LOG_INFO(Config, "Config not found. Saving new configuration file: {}", path.string());
}

Expand Down Expand Up @@ -229,16 +224,6 @@ void saveConfig(const std::filesystem::path &path) {
data["GPU"]["internalHeight"] = internalHeight;
//data["GPU"]["gpuId"] = gpuId;

#ifdef _WIN32
std::string pathPrefix{};
#else
// TODO(Vali0004): Pull if Linux or MacOS
std::string pathPrefix{ getenv("HOME") };
fusesTxtPath.insert(0, pathPrefix.c_str());
oneBlBinPath.insert(0, pathPrefix.c_str());
nandBinPath.insert(0, pathPrefix.c_str());
oddDiscImagePath.insert(0, pathPrefix.c_str());
#endif
// Paths.
data["Paths"]["Fuses"] = fusesTxtPath;
data["Paths"]["OneBL"] = oneBlBinPath;
Expand Down
Loading

0 comments on commit 1679a42

Please sign in to comment.