mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-23 13:31:51 +01:00
Refactor all logger calls
This commit is contained in:
parent
769e6c933d
commit
5cd1f01690
@ -7,7 +7,6 @@
|
|||||||
#include <android/asset_manager_jni.h>
|
#include <android/asset_manager_jni.h>
|
||||||
#include <sys/system_properties.h>
|
#include <sys/system_properties.h>
|
||||||
#include "skyline/common.h"
|
#include "skyline/common.h"
|
||||||
#include "skyline/common/logger.h"
|
|
||||||
#include "skyline/common/language.h"
|
#include "skyline/common/language.h"
|
||||||
#include "skyline/common/signal.h"
|
#include "skyline/common/signal.h"
|
||||||
#include "skyline/common/settings.h"
|
#include "skyline/common/settings.h"
|
||||||
@ -113,15 +112,15 @@ extern "C" JNIEXPORT void Java_emu_skyline_EmulationActivity_executeApplication(
|
|||||||
InputWeak = os->state.input;
|
InputWeak = os->state.input;
|
||||||
jvmManager->InitializeControllers();
|
jvmManager->InitializeControllers();
|
||||||
|
|
||||||
logger->InfoNoPrefix("Launching ROM {}", skyline::JniString(env, romUriJstring));
|
skyline::Logger::InfoNoPrefix("Launching ROM {}", skyline::JniString(env, romUriJstring));
|
||||||
|
|
||||||
os->Execute(romFd, static_cast<skyline::loader::RomFormat>(romType));
|
os->Execute(romFd, static_cast<skyline::loader::RomFormat>(romType));
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
logger->ErrorNoPrefix("An uncaught exception has occurred: {}", e.what());
|
skyline::Logger::ErrorNoPrefix("An uncaught exception has occurred: {}", e.what());
|
||||||
} catch (const skyline::signal::SignalException &e) {
|
} catch (const skyline::signal::SignalException &e) {
|
||||||
logger->ErrorNoPrefix("An uncaught exception has occurred: {}", e.what());
|
skyline::Logger::ErrorNoPrefix("An uncaught exception has occurred: {}", e.what());
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
logger->ErrorNoPrefix("An unknown uncaught exception has occurred");
|
skyline::Logger::ErrorNoPrefix("An unknown uncaught exception has occurred");
|
||||||
}
|
}
|
||||||
|
|
||||||
perfetto::TrackEvent::Flush();
|
perfetto::TrackEvent::Flush();
|
||||||
@ -129,7 +128,7 @@ extern "C" JNIEXPORT void Java_emu_skyline_EmulationActivity_executeApplication(
|
|||||||
InputWeak.reset();
|
InputWeak.reset();
|
||||||
|
|
||||||
auto end{std::chrono::steady_clock::now()};
|
auto end{std::chrono::steady_clock::now()};
|
||||||
logger->Write(skyline::Logger::LogLevel::Info, fmt::format("Emulation has ended in {}ms", std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()));
|
skyline::Logger::Write(skyline::Logger::LogLevel::Info, fmt::format("Emulation has ended in {}ms", std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()));
|
||||||
|
|
||||||
skyline::Logger::EmulationContext.Finalize();
|
skyline::Logger::EmulationContext.Finalize();
|
||||||
close(romFd);
|
close(romFd);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <boost/container/small_vector.hpp>
|
#include <boost/container/small_vector.hpp>
|
||||||
#include <common/span.h>
|
#include <common/span.h>
|
||||||
#include <common/result.h>
|
#include <common/result.h>
|
||||||
|
#include <common/logger.h>
|
||||||
|
|
||||||
namespace skyline {
|
namespace skyline {
|
||||||
class Settings;
|
class Settings;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Copyright © 2021 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
// Copyright © 2021 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
||||||
|
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
|
#include "utils.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
||||||
namespace skyline {
|
namespace skyline {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include "common.h"
|
#include "base.h"
|
||||||
|
|
||||||
namespace skyline {
|
namespace skyline {
|
||||||
/**
|
/**
|
||||||
|
@ -22,11 +22,11 @@ namespace skyline::gpu {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto instanceLayers{context.enumerateInstanceLayerProperties()};
|
auto instanceLayers{context.enumerateInstanceLayerProperties()};
|
||||||
if (state.logger->configLevel >= Logger::LogLevel::Debug) {
|
if (Logger::configLevel >= Logger::LogLevel::Debug) {
|
||||||
std::string layers;
|
std::string layers;
|
||||||
for (const auto &instanceLayer : instanceLayers)
|
for (const auto &instanceLayer : instanceLayers)
|
||||||
layers += util::Format("\n* {} (Sv{}.{}.{}, Iv{}.{}.{}) - {}", instanceLayer.layerName, VK_VERSION_MAJOR(instanceLayer.specVersion), VK_VERSION_MINOR(instanceLayer.specVersion), VK_VERSION_PATCH(instanceLayer.specVersion), VK_VERSION_MAJOR(instanceLayer.implementationVersion), VK_VERSION_MINOR(instanceLayer.implementationVersion), VK_VERSION_PATCH(instanceLayer.implementationVersion), instanceLayer.description);
|
layers += util::Format("\n* {} (Sv{}.{}.{}, Iv{}.{}.{}) - {}", instanceLayer.layerName, VK_VERSION_MAJOR(instanceLayer.specVersion), VK_VERSION_MINOR(instanceLayer.specVersion), VK_VERSION_PATCH(instanceLayer.specVersion), VK_VERSION_MAJOR(instanceLayer.implementationVersion), VK_VERSION_MINOR(instanceLayer.implementationVersion), VK_VERSION_PATCH(instanceLayer.implementationVersion), instanceLayer.description);
|
||||||
state.logger->Debug("Vulkan Layers:{}", layers);
|
Logger::Debug("Vulkan Layers:{}", layers);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &requiredLayer : requiredLayers) {
|
for (const auto &requiredLayer : requiredLayers) {
|
||||||
@ -43,11 +43,11 @@ namespace skyline::gpu {
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto instanceExtensions{context.enumerateInstanceExtensionProperties()};
|
auto instanceExtensions{context.enumerateInstanceExtensionProperties()};
|
||||||
if (state.logger->configLevel >= Logger::LogLevel::Debug) {
|
if (Logger::configLevel >= Logger::LogLevel::Debug) {
|
||||||
std::string extensions;
|
std::string extensions;
|
||||||
for (const auto &instanceExtension : instanceExtensions)
|
for (const auto &instanceExtension : instanceExtensions)
|
||||||
extensions += util::Format("\n* {} (v{}.{}.{})", instanceExtension.extensionName, VK_VERSION_MAJOR(instanceExtension.specVersion), VK_VERSION_MINOR(instanceExtension.specVersion), VK_VERSION_PATCH(instanceExtension.specVersion));
|
extensions += util::Format("\n* {} (v{}.{}.{})", instanceExtension.extensionName, VK_VERSION_MAJOR(instanceExtension.specVersion), VK_VERSION_MINOR(instanceExtension.specVersion), VK_VERSION_PATCH(instanceExtension.specVersion));
|
||||||
state.logger->Debug("Vulkan Instance Extensions:{}", extensions);
|
Logger::Debug("Vulkan Instance Extensions:{}", extensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &requiredExtension : requiredInstanceExtensions) {
|
for (const auto &requiredExtension : requiredInstanceExtensions) {
|
||||||
@ -66,15 +66,14 @@ namespace skyline::gpu {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
vk::raii::DebugReportCallbackEXT GPU::CreateDebugReportCallback(const DeviceState &state, const vk::raii::Instance &instance) {
|
vk::raii::DebugReportCallbackEXT GPU::CreateDebugReportCallback(const vk::raii::Instance &instance) {
|
||||||
return vk::raii::DebugReportCallbackEXT(instance, vk::DebugReportCallbackCreateInfoEXT{
|
return vk::raii::DebugReportCallbackEXT(instance, vk::DebugReportCallbackCreateInfoEXT{
|
||||||
.flags = vk::DebugReportFlagBitsEXT::eError | vk::DebugReportFlagBitsEXT::eWarning | vk::DebugReportFlagBitsEXT::ePerformanceWarning | vk::DebugReportFlagBitsEXT::eInformation | vk::DebugReportFlagBitsEXT::eDebug,
|
.flags = vk::DebugReportFlagBitsEXT::eError | vk::DebugReportFlagBitsEXT::eWarning | vk::DebugReportFlagBitsEXT::ePerformanceWarning | vk::DebugReportFlagBitsEXT::eInformation | vk::DebugReportFlagBitsEXT::eDebug,
|
||||||
.pfnCallback = reinterpret_cast<PFN_vkDebugReportCallbackEXT>(&DebugCallback),
|
.pfnCallback = reinterpret_cast<PFN_vkDebugReportCallbackEXT>(&DebugCallback),
|
||||||
.pUserData = state.logger.get(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
VkBool32 GPU::DebugCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char *layerPrefix, const char *message, Logger *logger) {
|
VkBool32 GPU::DebugCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char *layerPrefix, const char *message) {
|
||||||
constexpr std::array<Logger::LogLevel, 5> severityLookup{
|
constexpr std::array<Logger::LogLevel, 5> severityLookup{
|
||||||
Logger::LogLevel::Info, // VK_DEBUG_REPORT_INFORMATION_BIT_EXT
|
Logger::LogLevel::Info, // VK_DEBUG_REPORT_INFORMATION_BIT_EXT
|
||||||
Logger::LogLevel::Warn, // VK_DEBUG_REPORT_WARNING_BIT_EXT
|
Logger::LogLevel::Warn, // VK_DEBUG_REPORT_WARNING_BIT_EXT
|
||||||
@ -111,16 +110,16 @@ namespace skyline::gpu {
|
|||||||
#undef IGNORE_TYPE
|
#undef IGNORE_TYPE
|
||||||
}
|
}
|
||||||
|
|
||||||
logger->Write(severityLookup.at(static_cast<size_t>(std::countr_zero(static_cast<u32>(flags)))), util::Format("Vk{}:{}[0x{:X}]:I{}:L{}: {}", layerPrefix, vk::to_string(vk::DebugReportObjectTypeEXT(objectType)), object, messageCode, location, message));
|
Logger::Write(severityLookup.at(static_cast<size_t>(std::countr_zero(static_cast<u32>(flags)))), util::Format("Vk{}:{}[0x{:X}]:I{}:L{}: {}", layerPrefix, vk::to_string(vk::DebugReportObjectTypeEXT(objectType)), object, messageCode, location, message));
|
||||||
|
|
||||||
return VK_FALSE;
|
return VK_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
vk::raii::PhysicalDevice GPU::CreatePhysicalDevice(const DeviceState &state, const vk::raii::Instance &instance) {
|
vk::raii::PhysicalDevice GPU::CreatePhysicalDevice(const vk::raii::Instance &instance) {
|
||||||
return std::move(vk::raii::PhysicalDevices(instance).front()); // We just select the first device as we aren't expecting multiple GPUs
|
return std::move(vk::raii::PhysicalDevices(instance).front()); // We just select the first device as we aren't expecting multiple GPUs
|
||||||
}
|
}
|
||||||
|
|
||||||
vk::raii::Device GPU::CreateDevice(const DeviceState &state, const vk::raii::PhysicalDevice &physicalDevice, typeof(vk::DeviceQueueCreateInfo::queueCount) &vkQueueFamilyIndex) {
|
vk::raii::Device GPU::CreateDevice(const vk::raii::PhysicalDevice &physicalDevice, typeof(vk::DeviceQueueCreateInfo::queueCount) &vkQueueFamilyIndex) {
|
||||||
auto properties{physicalDevice.getProperties()}; // We should check for required properties here, if/when we have them
|
auto properties{physicalDevice.getProperties()}; // We should check for required properties here, if/when we have them
|
||||||
|
|
||||||
// auto features{physicalDevice.getFeatures()}; // Same as above
|
// auto features{physicalDevice.getFeatures()}; // Same as above
|
||||||
@ -154,7 +153,7 @@ namespace skyline::gpu {
|
|||||||
throw exception("Cannot find a queue family with both eGraphics and eCompute bits set");
|
throw exception("Cannot find a queue family with both eGraphics and eCompute bits set");
|
||||||
}()};
|
}()};
|
||||||
|
|
||||||
if (state.logger->configLevel >= Logger::LogLevel::Info) {
|
if (Logger::configLevel >= Logger::LogLevel::Info) {
|
||||||
std::string extensionString;
|
std::string extensionString;
|
||||||
for (const auto &extension : deviceExtensions)
|
for (const auto &extension : deviceExtensions)
|
||||||
extensionString += util::Format("\n* {} (v{}.{}.{})", extension.extensionName, VK_VERSION_MAJOR(extension.specVersion), VK_VERSION_MINOR(extension.specVersion), VK_VERSION_PATCH(extension.specVersion));
|
extensionString += util::Format("\n* {} (v{}.{}.{})", extension.extensionName, VK_VERSION_MAJOR(extension.specVersion), VK_VERSION_MINOR(extension.specVersion), VK_VERSION_PATCH(extension.specVersion));
|
||||||
@ -164,7 +163,7 @@ namespace skyline::gpu {
|
|||||||
for (const auto &queueFamily : queueFamilies)
|
for (const auto &queueFamily : queueFamilies)
|
||||||
queueString += util::Format("\n* {}x{}{}{}{}{}: TSB{} MIG({}x{}x{}){}", queueFamily.queueCount, queueFamily.queueFlags & vk::QueueFlagBits::eGraphics ? 'G' : '-', queueFamily.queueFlags & vk::QueueFlagBits::eCompute ? 'C' : '-', queueFamily.queueFlags & vk::QueueFlagBits::eTransfer ? 'T' : '-', queueFamily.queueFlags & vk::QueueFlagBits::eSparseBinding ? 'S' : '-', queueFamily.queueFlags & vk::QueueFlagBits::eProtected ? 'P' : '-', queueFamily.timestampValidBits, queueFamily.minImageTransferGranularity.width, queueFamily.minImageTransferGranularity.height, queueFamily.minImageTransferGranularity.depth, familyIndex++ == vkQueueFamilyIndex ? " <--" : "");
|
queueString += util::Format("\n* {}x{}{}{}{}{}: TSB{} MIG({}x{}x{}){}", queueFamily.queueCount, queueFamily.queueFlags & vk::QueueFlagBits::eGraphics ? 'G' : '-', queueFamily.queueFlags & vk::QueueFlagBits::eCompute ? 'C' : '-', queueFamily.queueFlags & vk::QueueFlagBits::eTransfer ? 'T' : '-', queueFamily.queueFlags & vk::QueueFlagBits::eSparseBinding ? 'S' : '-', queueFamily.queueFlags & vk::QueueFlagBits::eProtected ? 'P' : '-', queueFamily.timestampValidBits, queueFamily.minImageTransferGranularity.width, queueFamily.minImageTransferGranularity.height, queueFamily.minImageTransferGranularity.depth, familyIndex++ == vkQueueFamilyIndex ? " <--" : "");
|
||||||
|
|
||||||
state.logger->Info("Vulkan Device:\nName: {}\nType: {}\nVulkan Version: {}.{}.{}\nDriver Version: {}.{}.{}\nQueues:{}\nExtensions:{}", properties.deviceName, vk::to_string(properties.deviceType), VK_VERSION_MAJOR(properties.apiVersion), VK_VERSION_MINOR(properties.apiVersion), VK_VERSION_PATCH(properties.apiVersion), VK_VERSION_MAJOR(properties.driverVersion), VK_VERSION_MINOR(properties.driverVersion), VK_VERSION_PATCH(properties.driverVersion), queueString, extensionString);
|
Logger::Info("Vulkan Device:\nName: {}\nType: {}\nVulkan Version: {}.{}.{}\nDriver Version: {}.{}.{}\nQueues:{}\nExtensions:{}", properties.deviceName, vk::to_string(properties.deviceType), VK_VERSION_MAJOR(properties.apiVersion), VK_VERSION_MINOR(properties.apiVersion), VK_VERSION_PATCH(properties.apiVersion), VK_VERSION_MAJOR(properties.driverVersion), VK_VERSION_MINOR(properties.driverVersion), VK_VERSION_PATCH(properties.driverVersion), queueString, extensionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
return vk::raii::Device(physicalDevice, vk::DeviceCreateInfo{
|
return vk::raii::Device(physicalDevice, vk::DeviceCreateInfo{
|
||||||
@ -175,5 +174,5 @@ namespace skyline::gpu {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
GPU::GPU(const DeviceState &state) : vkInstance(CreateInstance(state, vkContext)), vkDebugReportCallback(CreateDebugReportCallback(state, vkInstance)), vkPhysicalDevice(CreatePhysicalDevice(state, vkInstance)), vkDevice(CreateDevice(state, vkPhysicalDevice, vkQueueFamilyIndex)), vkQueue(vkDevice, vkQueueFamilyIndex, 0), memory(*this), scheduler(*this), presentation(state, *this), texture(*this) {}
|
GPU::GPU(const DeviceState &state) : vkInstance(CreateInstance(state, vkContext)), vkDebugReportCallback(CreateDebugReportCallback(vkInstance)), vkPhysicalDevice(CreatePhysicalDevice(vkInstance)), vkDevice(CreateDevice(vkPhysicalDevice, vkQueueFamilyIndex)), vkQueue(vkDevice, vkQueueFamilyIndex, 0), memory(*this), scheduler(*this), presentation(state, *this), texture(*this) {}
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,13 @@ namespace skyline::gpu {
|
|||||||
private:
|
private:
|
||||||
static vk::raii::Instance CreateInstance(const DeviceState &state, const vk::raii::Context &context);
|
static vk::raii::Instance CreateInstance(const DeviceState &state, const vk::raii::Context &context);
|
||||||
|
|
||||||
static vk::raii::DebugReportCallbackEXT CreateDebugReportCallback(const DeviceState &state, const vk::raii::Instance &instance);
|
static vk::raii::DebugReportCallbackEXT CreateDebugReportCallback(const vk::raii::Instance &instance);
|
||||||
|
|
||||||
static VKAPI_ATTR VkBool32 VKAPI_CALL DebugCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char *layerPrefix, const char *message, Logger *logger);
|
static VKAPI_ATTR VkBool32 VKAPI_CALL DebugCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char *layerPrefix, const char *message);
|
||||||
|
|
||||||
static vk::raii::PhysicalDevice CreatePhysicalDevice(const DeviceState &state, const vk::raii::Instance &instance);
|
static vk::raii::PhysicalDevice CreatePhysicalDevice(const vk::raii::Instance &instance);
|
||||||
|
|
||||||
static vk::raii::Device CreateDevice(const DeviceState &state, const vk::raii::PhysicalDevice &physicalDevice, typeof(vk::DeviceQueueCreateInfo::queueCount)& queueConfiguration);
|
static vk::raii::Device CreateDevice(const vk::raii::PhysicalDevice &physicalDevice, typeof(vk::DeviceQueueCreateInfo::queueCount)& queueConfiguration);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr u32 VkApiVersion{VK_API_VERSION_1_1}; //!< The version of core Vulkan that we require
|
static constexpr u32 VkApiVersion{VK_API_VERSION_1_1}; //!< The version of core Vulkan that we require
|
||||||
|
@ -72,13 +72,13 @@ namespace skyline::gpu {
|
|||||||
AChoreographer_postFrameCallback64(AChoreographer_getInstance(), reinterpret_cast<AChoreographer_frameCallback64>(&ChoreographerCallback), this);
|
AChoreographer_postFrameCallback64(AChoreographer_getInstance(), reinterpret_cast<AChoreographer_frameCallback64>(&ChoreographerCallback), this);
|
||||||
while (ALooper_pollAll(-1, nullptr, nullptr, nullptr) == ALOOPER_POLL_WAKE && !choreographerStop); // Will block and process callbacks till ALooper_wake() is called with choreographerStop set
|
while (ALooper_pollAll(-1, nullptr, nullptr, nullptr) == ALOOPER_POLL_WAKE && !choreographerStop); // Will block and process callbacks till ALooper_wake() is called with choreographerStop set
|
||||||
} catch (const signal::SignalException &e) {
|
} catch (const signal::SignalException &e) {
|
||||||
state.logger->Error("{}\nStack Trace:{}", e.what(), state.loader->GetStackTrace(e.frames));
|
Logger::Error("{}\nStack Trace:{}", e.what(), state.loader->GetStackTrace(e.frames));
|
||||||
if (state.process)
|
if (state.process)
|
||||||
state.process->Kill(false);
|
state.process->Kill(false);
|
||||||
else
|
else
|
||||||
std::rethrow_exception(std::current_exception());
|
std::rethrow_exception(std::current_exception());
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
state.logger->Error(e.what());
|
Logger::Error(e.what());
|
||||||
if (state.process)
|
if (state.process)
|
||||||
state.process->Kill(false);
|
state.process->Kill(false);
|
||||||
else
|
else
|
||||||
|
@ -29,7 +29,7 @@ namespace skyline::kernel::ipc {
|
|||||||
auto bufX{reinterpret_cast<BufferDescriptorX *>(pointer)};
|
auto bufX{reinterpret_cast<BufferDescriptorX *>(pointer)};
|
||||||
if (bufX->Pointer()) {
|
if (bufX->Pointer()) {
|
||||||
inputBuf.emplace_back(bufX->Pointer(), static_cast<u16>(bufX->size));
|
inputBuf.emplace_back(bufX->Pointer(), static_cast<u16>(bufX->size));
|
||||||
state.logger->Verbose("Buf X #{}: 0x{:X}, 0x{:X}, #{}", index, bufX->Pointer(), static_cast<u16>(bufX->size), static_cast<u16>(bufX->Counter()));
|
Logger::Verbose("Buf X #{}: 0x{:X}, 0x{:X}, #{}", index, bufX->Pointer(), static_cast<u16>(bufX->size), static_cast<u16>(bufX->Counter()));
|
||||||
}
|
}
|
||||||
pointer += sizeof(BufferDescriptorX);
|
pointer += sizeof(BufferDescriptorX);
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ namespace skyline::kernel::ipc {
|
|||||||
auto bufA{reinterpret_cast<BufferDescriptorABW *>(pointer)};
|
auto bufA{reinterpret_cast<BufferDescriptorABW *>(pointer)};
|
||||||
if (bufA->Pointer()) {
|
if (bufA->Pointer()) {
|
||||||
inputBuf.emplace_back(bufA->Pointer(), bufA->Size());
|
inputBuf.emplace_back(bufA->Pointer(), bufA->Size());
|
||||||
state.logger->Verbose("Buf A #{}: 0x{:X}, 0x{:X}", index, bufA->Pointer(), static_cast<u64>(bufA->Size()));
|
Logger::Verbose("Buf A #{}: 0x{:X}, 0x{:X}", index, bufA->Pointer(), static_cast<u64>(bufA->Size()));
|
||||||
}
|
}
|
||||||
pointer += sizeof(BufferDescriptorABW);
|
pointer += sizeof(BufferDescriptorABW);
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ namespace skyline::kernel::ipc {
|
|||||||
auto bufB{reinterpret_cast<BufferDescriptorABW *>(pointer)};
|
auto bufB{reinterpret_cast<BufferDescriptorABW *>(pointer)};
|
||||||
if (bufB->Pointer()) {
|
if (bufB->Pointer()) {
|
||||||
outputBuf.emplace_back(bufB->Pointer(), bufB->Size());
|
outputBuf.emplace_back(bufB->Pointer(), bufB->Size());
|
||||||
state.logger->Verbose("Buf B #{}: 0x{:X}, 0x{:X}", index, bufB->Pointer(), static_cast<u64>(bufB->Size()));
|
Logger::Verbose("Buf B #{}: 0x{:X}, 0x{:X}", index, bufB->Pointer(), static_cast<u64>(bufB->Size()));
|
||||||
}
|
}
|
||||||
pointer += sizeof(BufferDescriptorABW);
|
pointer += sizeof(BufferDescriptorABW);
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ namespace skyline::kernel::ipc {
|
|||||||
if (bufW->Pointer()) {
|
if (bufW->Pointer()) {
|
||||||
outputBuf.emplace_back(bufW->Pointer(), bufW->Size());
|
outputBuf.emplace_back(bufW->Pointer(), bufW->Size());
|
||||||
outputBuf.emplace_back(bufW->Pointer(), bufW->Size());
|
outputBuf.emplace_back(bufW->Pointer(), bufW->Size());
|
||||||
state.logger->Verbose("Buf W #{}: 0x{:X}, 0x{:X}", index, bufW->Pointer(), static_cast<u16>(bufW->Size()));
|
Logger::Verbose("Buf W #{}: 0x{:X}, 0x{:X}", index, bufW->Pointer(), static_cast<u16>(bufW->Size()));
|
||||||
}
|
}
|
||||||
pointer += sizeof(BufferDescriptorABW);
|
pointer += sizeof(BufferDescriptorABW);
|
||||||
}
|
}
|
||||||
@ -94,33 +94,33 @@ namespace skyline::kernel::ipc {
|
|||||||
payloadOffset = cmdArg;
|
payloadOffset = cmdArg;
|
||||||
|
|
||||||
if (payload->magic != util::MakeMagic<u32>("SFCI") && (header->type != CommandType::Control && header->type != CommandType::ControlWithContext && header->type != CommandType::Close) && (!domain || domain->command != DomainCommand::CloseVHandle)) // SFCI is the magic in received IPC messages
|
if (payload->magic != util::MakeMagic<u32>("SFCI") && (header->type != CommandType::Control && header->type != CommandType::ControlWithContext && header->type != CommandType::Close) && (!domain || domain->command != DomainCommand::CloseVHandle)) // SFCI is the magic in received IPC messages
|
||||||
state.logger->Debug("Unexpected Magic in PayloadHeader: 0x{:X}", static_cast<u32>(payload->magic));
|
Logger::Debug("Unexpected Magic in PayloadHeader: 0x{:X}", static_cast<u32>(payload->magic));
|
||||||
|
|
||||||
|
|
||||||
if (header->cFlag == BufferCFlag::SingleDescriptor) {
|
if (header->cFlag == BufferCFlag::SingleDescriptor) {
|
||||||
auto bufC{reinterpret_cast<BufferDescriptorC *>(bufCPointer)};
|
auto bufC{reinterpret_cast<BufferDescriptorC *>(bufCPointer)};
|
||||||
if (bufC->address) {
|
if (bufC->address) {
|
||||||
outputBuf.emplace_back(bufC->Pointer(), static_cast<u16>(bufC->size));
|
outputBuf.emplace_back(bufC->Pointer(), static_cast<u16>(bufC->size));
|
||||||
state.logger->Verbose("Buf C: 0x{:X}, 0x{:X}", bufC->Pointer(), static_cast<u16>(bufC->size));
|
Logger::Verbose("Buf C: 0x{:X}, 0x{:X}", bufC->Pointer(), static_cast<u16>(bufC->size));
|
||||||
}
|
}
|
||||||
} else if (header->cFlag > BufferCFlag::SingleDescriptor) {
|
} else if (header->cFlag > BufferCFlag::SingleDescriptor) {
|
||||||
for (u8 index{}; (static_cast<u8>(header->cFlag) - 2) > index; index++) { // (cFlag - 2) C descriptors are present
|
for (u8 index{}; (static_cast<u8>(header->cFlag) - 2) > index; index++) { // (cFlag - 2) C descriptors are present
|
||||||
auto bufC{reinterpret_cast<BufferDescriptorC *>(bufCPointer)};
|
auto bufC{reinterpret_cast<BufferDescriptorC *>(bufCPointer)};
|
||||||
if (bufC->address) {
|
if (bufC->address) {
|
||||||
outputBuf.emplace_back(bufC->Pointer(), static_cast<u16>(bufC->size));
|
outputBuf.emplace_back(bufC->Pointer(), static_cast<u16>(bufC->size));
|
||||||
state.logger->Verbose("Buf C #{}: 0x{:X}, 0x{:X}", index, bufC->Pointer(), static_cast<u16>(bufC->size));
|
Logger::Verbose("Buf C #{}: 0x{:X}, 0x{:X}", index, bufC->Pointer(), static_cast<u16>(bufC->size));
|
||||||
}
|
}
|
||||||
bufCPointer += sizeof(BufferDescriptorC);
|
bufCPointer += sizeof(BufferDescriptorC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header->type == CommandType::Request || header->type == CommandType::RequestWithContext) {
|
if (header->type == CommandType::Request || header->type == CommandType::RequestWithContext) {
|
||||||
state.logger->Verbose("Header: Input No: {}, Output No: {}, Raw Size: {}", inputBuf.size(), outputBuf.size(), static_cast<u64>(cmdArgSz));
|
Logger::Verbose("Header: Input No: {}, Output No: {}, Raw Size: {}", inputBuf.size(), outputBuf.size(), static_cast<u64>(cmdArgSz));
|
||||||
if (header->handleDesc)
|
if (header->handleDesc)
|
||||||
state.logger->Verbose("Handle Descriptor: Send PID: {}, Copy Count: {}, Move Count: {}", static_cast<bool>(handleDesc->sendPid), static_cast<u32>(handleDesc->copyCount), static_cast<u32>(handleDesc->moveCount));
|
Logger::Verbose("Handle Descriptor: Send PID: {}, Copy Count: {}, Move Count: {}", static_cast<bool>(handleDesc->sendPid), static_cast<u32>(handleDesc->copyCount), static_cast<u32>(handleDesc->moveCount));
|
||||||
if (isDomain)
|
if (isDomain)
|
||||||
state.logger->Verbose("Domain Header: Command: {}, Input Object Count: {}, Object ID: 0x{:X}", domain->command, domain->inputCount, domain->objectId);
|
Logger::Verbose("Domain Header: Command: {}, Input Object Count: {}, Object ID: 0x{:X}", domain->command, domain->inputCount, domain->objectId);
|
||||||
state.logger->Verbose("Command ID: 0x{:X}", static_cast<u32>(payload->value));
|
Logger::Verbose("Command ID: 0x{:X}", static_cast<u32>(payload->value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,6 +181,6 @@ namespace skyline::kernel::ipc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state.logger->Verbose("Output: Raw Size: {}, Result: 0x{:X}, Copy Handles: {}, Move Handles: {}", static_cast<u32>(header->rawSize), static_cast<u32>(payloadHeader->value), copyHandles.size(), moveHandles.size());
|
Logger::Verbose("Output: Raw Size: {}, Result: 0x{:X}, Copy Handles: {}, Move Handles: {}", static_cast<u32>(header->rawSize), static_cast<u32>(payloadHeader->value), copyHandles.size(), moveHandles.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ namespace skyline::kernel {
|
|||||||
if (size > code.size)
|
if (size > code.size)
|
||||||
throw exception("Code region ({}) is smaller than mapped code size ({})", code.size, size);
|
throw exception("Code region ({}) is smaller than mapped code size ({})", code.size, size);
|
||||||
|
|
||||||
state.logger->Debug("Region Map:\nVMM Base: 0x{:X}\nCode Region: 0x{:X} - 0x{:X} (Size: 0x{:X})\nAlias Region: 0x{:X} - 0x{:X} (Size: 0x{:X})\nHeap Region: 0x{:X} - 0x{:X} (Size: 0x{:X})\nStack Region: 0x{:X} - 0x{:X} (Size: 0x{:X})\nTLS/IO Region: 0x{:X} - 0x{:X} (Size: 0x{:X})", base.address, code.address, code.address + code.size, code.size, alias.address, alias.address + alias.size, alias.size, heap.address, heap
|
Logger::Debug("Region Map:\nVMM Base: 0x{:X}\nCode Region: 0x{:X} - 0x{:X} (Size: 0x{:X})\nAlias Region: 0x{:X} - 0x{:X} (Size: 0x{:X})\nHeap Region: 0x{:X} - 0x{:X} (Size: 0x{:X})\nStack Region: 0x{:X} - 0x{:X} (Size: 0x{:X})\nTLS/IO Region: 0x{:X} - 0x{:X} (Size: 0x{:X})", base.address, code.address, code.address + code.size, code.size, alias.address, alias.address + alias.size, alias.size, heap.address, heap
|
||||||
.address + heap.size, heap.size, stack.address, stack.address + stack.size, stack.size, tlsIo.address, tlsIo.address + tlsIo.size, tlsIo.size);
|
.address + heap.size, heap.size, stack.address, stack.address + stack.size, stack.size, tlsIo.address, tlsIo.address + tlsIo.size, tlsIo.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,14 +70,14 @@ namespace skyline::kernel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (optimalCore != currentCore)
|
if (optimalCore != currentCore)
|
||||||
state.logger->Debug("Load Balancing T{}: C{} -> C{}", thread->id, currentCore->id, optimalCore->id);
|
Logger::Debug("Load Balancing T{}: C{} -> C{}", thread->id, currentCore->id, optimalCore->id);
|
||||||
else
|
else
|
||||||
state.logger->Debug("Load Balancing T{}: C{} (Late)", thread->id, currentCore->id);
|
Logger::Debug("Load Balancing T{}: C{} (Late)", thread->id, currentCore->id);
|
||||||
|
|
||||||
return *optimalCore;
|
return *optimalCore;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.logger->Debug("Load Balancing T{}: C{} (Early)", thread->id, currentCore->id);
|
Logger::Debug("Load Balancing T{}: C{} (Early)", thread->id, currentCore->id);
|
||||||
|
|
||||||
return *currentCore;
|
return *currentCore;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ namespace skyline::kernel::svc {
|
|||||||
state.ctx->gpr.w0 = result::InvalidSize;
|
state.ctx->gpr.w0 = result::InvalidSize;
|
||||||
state.ctx->gpr.x1 = 0;
|
state.ctx->gpr.x1 = 0;
|
||||||
|
|
||||||
state.logger->Warn("'size' not divisible by 2MB: {}", size);
|
Logger::Warn("'size' not divisible by 2MB: {}", size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,21 +27,21 @@ namespace skyline::kernel::svc {
|
|||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
state.ctx->gpr.x1 = reinterpret_cast<u64>(heap->ptr);
|
state.ctx->gpr.x1 = reinterpret_cast<u64>(heap->ptr);
|
||||||
|
|
||||||
state.logger->Debug("Allocated at 0x{:X} - 0x{:X} (0x{:X} bytes)", heap->ptr, heap->ptr + heap->size, heap->size);
|
Logger::Debug("Allocated at 0x{:X} - 0x{:X} (0x{:X} bytes)", heap->ptr, heap->ptr + heap->size, heap->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetMemoryAttribute(const DeviceState &state) {
|
void SetMemoryAttribute(const DeviceState &state) {
|
||||||
auto pointer{reinterpret_cast<u8 *>(state.ctx->gpr.x0)};
|
auto pointer{reinterpret_cast<u8 *>(state.ctx->gpr.x0)};
|
||||||
if (!util::IsPageAligned(pointer)) {
|
if (!util::IsPageAligned(pointer)) {
|
||||||
state.ctx->gpr.w0 = result::InvalidAddress;
|
state.ctx->gpr.w0 = result::InvalidAddress;
|
||||||
state.logger->Warn("'pointer' not page aligned: 0x{:X}", pointer);
|
Logger::Warn("'pointer' not page aligned: 0x{:X}", pointer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size{state.ctx->gpr.x1};
|
size_t size{state.ctx->gpr.x1};
|
||||||
if (!util::IsPageAligned(size)) {
|
if (!util::IsPageAligned(size)) {
|
||||||
state.ctx->gpr.w0 = result::InvalidSize;
|
state.ctx->gpr.w0 = result::InvalidSize;
|
||||||
state.logger->Warn("'size' {}: 0x{:X}", size ? "not page aligned" : "is zero", size);
|
Logger::Warn("'size' {}: 0x{:X}", size ? "not page aligned" : "is zero", size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,20 +51,20 @@ namespace skyline::kernel::svc {
|
|||||||
auto maskedValue{mask.value | value.value};
|
auto maskedValue{mask.value | value.value};
|
||||||
if (maskedValue != mask.value || !mask.isUncached || mask.isDeviceShared || mask.isBorrowed || mask.isIpcLocked) {
|
if (maskedValue != mask.value || !mask.isUncached || mask.isDeviceShared || mask.isBorrowed || mask.isIpcLocked) {
|
||||||
state.ctx->gpr.w0 = result::InvalidCombination;
|
state.ctx->gpr.w0 = result::InvalidCombination;
|
||||||
state.logger->Warn("'mask' invalid: 0x{:X}, 0x{:X}", mask.value, value.value);
|
Logger::Warn("'mask' invalid: 0x{:X}, 0x{:X}", mask.value, value.value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto chunk{state.process->memory.Get(pointer)};
|
auto chunk{state.process->memory.Get(pointer)};
|
||||||
if (!chunk) {
|
if (!chunk) {
|
||||||
state.ctx->gpr.w0 = result::InvalidAddress;
|
state.ctx->gpr.w0 = result::InvalidAddress;
|
||||||
state.logger->Warn("Cannot find memory region: 0x{:X}", pointer);
|
Logger::Warn("Cannot find memory region: 0x{:X}", pointer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!chunk->state.attributeChangeAllowed) {
|
if (!chunk->state.attributeChangeAllowed) {
|
||||||
state.ctx->gpr.w0 = result::InvalidState;
|
state.ctx->gpr.w0 = result::InvalidState;
|
||||||
state.logger->Warn("Attribute change not allowed for chunk: 0x{:X}", pointer);
|
Logger::Warn("Attribute change not allowed for chunk: 0x{:X}", pointer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ namespace skyline::kernel::svc {
|
|||||||
newChunk.attributes.isUncached = value.isUncached;
|
newChunk.attributes.isUncached = value.isUncached;
|
||||||
state.process->memory.InsertChunk(newChunk);
|
state.process->memory.InsertChunk(newChunk);
|
||||||
|
|
||||||
state.logger->Debug("Set CPU caching to {} at 0x{:X} - 0x{:X} (0x{:X} bytes)", !static_cast<bool>(value.isUncached), pointer, pointer + size, size);
|
Logger::Debug("Set CPU caching to {} at 0x{:X} - 0x{:X} (0x{:X} bytes)", !static_cast<bool>(value.isUncached), pointer, pointer + size, size);
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,32 +85,32 @@ namespace skyline::kernel::svc {
|
|||||||
|
|
||||||
if (!util::IsPageAligned(destination) || !util::IsPageAligned(source)) {
|
if (!util::IsPageAligned(destination) || !util::IsPageAligned(source)) {
|
||||||
state.ctx->gpr.w0 = result::InvalidAddress;
|
state.ctx->gpr.w0 = result::InvalidAddress;
|
||||||
state.logger->Warn("Addresses not page aligned: Source: 0x{:X}, Destination: 0x{:X} (Size: 0x{:X} bytes)", source, destination, size);
|
Logger::Warn("Addresses not page aligned: Source: 0x{:X}, Destination: 0x{:X} (Size: 0x{:X} bytes)", source, destination, size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!util::IsPageAligned(size)) {
|
if (!util::IsPageAligned(size)) {
|
||||||
state.ctx->gpr.w0 = result::InvalidSize;
|
state.ctx->gpr.w0 = result::InvalidSize;
|
||||||
state.logger->Warn("'size' {}: 0x{:X}", size ? "not page aligned" : "is zero", size);
|
Logger::Warn("'size' {}: 0x{:X}", size ? "not page aligned" : "is zero", size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto stack{state.process->memory.stack};
|
auto stack{state.process->memory.stack};
|
||||||
if (!stack.IsInside(destination)) {
|
if (!stack.IsInside(destination)) {
|
||||||
state.ctx->gpr.w0 = result::InvalidMemoryRegion;
|
state.ctx->gpr.w0 = result::InvalidMemoryRegion;
|
||||||
state.logger->Warn("Destination not within stack region: Source: 0x{:X}, Destination: 0x{:X} (Size: 0x{:X} bytes)", source, destination, size);
|
Logger::Warn("Destination not within stack region: Source: 0x{:X}, Destination: 0x{:X} (Size: 0x{:X} bytes)", source, destination, size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto chunk{state.process->memory.Get(source)};
|
auto chunk{state.process->memory.Get(source)};
|
||||||
if (!chunk) {
|
if (!chunk) {
|
||||||
state.ctx->gpr.w0 = result::InvalidAddress;
|
state.ctx->gpr.w0 = result::InvalidAddress;
|
||||||
state.logger->Warn("Source has no descriptor: Source: 0x{:X}, Destination: 0x{:X} (Size: 0x{:X} bytes)", source, destination, size);
|
Logger::Warn("Source has no descriptor: Source: 0x{:X}, Destination: 0x{:X} (Size: 0x{:X} bytes)", source, destination, size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!chunk->state.mapAllowed) {
|
if (!chunk->state.mapAllowed) {
|
||||||
state.ctx->gpr.w0 = result::InvalidState;
|
state.ctx->gpr.w0 = result::InvalidState;
|
||||||
state.logger->Warn("Source doesn't allow usage of svcMapMemory: Source: 0x{:X}, Destination: 0x{:X}, Size: 0x{:X}, MemoryState: 0x{:X}", source, destination, size, chunk->state.value);
|
Logger::Warn("Source doesn't allow usage of svcMapMemory: Source: 0x{:X}, Destination: 0x{:X}, Size: 0x{:X}, MemoryState: 0x{:X}", source, destination, size, chunk->state.value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ namespace skyline::kernel::svc {
|
|||||||
throw exception("svcMapMemory: Cannot find memory object in handle table for address 0x{:X}", source);
|
throw exception("svcMapMemory: Cannot find memory object in handle table for address 0x{:X}", source);
|
||||||
object->item->UpdatePermission(source, size, {false, false, false});
|
object->item->UpdatePermission(source, size, {false, false, false});
|
||||||
|
|
||||||
state.logger->Debug("Mapped range 0x{:X} - 0x{:X} to 0x{:X} - 0x{:X} (Size: 0x{:X} bytes)", source, source + size, destination, destination + size, size);
|
Logger::Debug("Mapped range 0x{:X} - 0x{:X} to 0x{:X} - 0x{:X} (Size: 0x{:X} bytes)", source, source + size, destination, destination + size, size);
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,20 +133,20 @@ namespace skyline::kernel::svc {
|
|||||||
|
|
||||||
if (!util::IsPageAligned(destination) || !util::IsPageAligned(source)) {
|
if (!util::IsPageAligned(destination) || !util::IsPageAligned(source)) {
|
||||||
state.ctx->gpr.w0 = result::InvalidAddress;
|
state.ctx->gpr.w0 = result::InvalidAddress;
|
||||||
state.logger->Warn("Addresses not page aligned: Source: 0x{:X}, Destination: 0x{:X} (Size: 0x{:X} bytes)", source, destination, size);
|
Logger::Warn("Addresses not page aligned: Source: 0x{:X}, Destination: 0x{:X} (Size: 0x{:X} bytes)", source, destination, size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!util::IsPageAligned(size)) {
|
if (!util::IsPageAligned(size)) {
|
||||||
state.ctx->gpr.w0 = result::InvalidSize;
|
state.ctx->gpr.w0 = result::InvalidSize;
|
||||||
state.logger->Warn("'size' {}: 0x{:X}", size ? "not page aligned" : "is zero", size);
|
Logger::Warn("'size' {}: 0x{:X}", size ? "not page aligned" : "is zero", size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto stack{state.process->memory.stack};
|
auto stack{state.process->memory.stack};
|
||||||
if (!stack.IsInside(source)) {
|
if (!stack.IsInside(source)) {
|
||||||
state.ctx->gpr.w0 = result::InvalidMemoryRegion;
|
state.ctx->gpr.w0 = result::InvalidMemoryRegion;
|
||||||
state.logger->Warn("Source not within stack region: Source: 0x{:X}, Destination: 0x{:X} (Size: 0x{:X} bytes)", source, destination, size);
|
Logger::Warn("Source not within stack region: Source: 0x{:X}, Destination: 0x{:X} (Size: 0x{:X} bytes)", source, destination, size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,13 +154,13 @@ namespace skyline::kernel::svc {
|
|||||||
auto destChunk{state.process->memory.Get(destination)};
|
auto destChunk{state.process->memory.Get(destination)};
|
||||||
if (!sourceChunk || !destChunk) {
|
if (!sourceChunk || !destChunk) {
|
||||||
state.ctx->gpr.w0 = result::InvalidAddress;
|
state.ctx->gpr.w0 = result::InvalidAddress;
|
||||||
state.logger->Warn("Addresses have no descriptor: Source: 0x{:X}, Destination: 0x{:X} (Size: 0x{:X} bytes)", source, destination, size);
|
Logger::Warn("Addresses have no descriptor: Source: 0x{:X}, Destination: 0x{:X} (Size: 0x{:X} bytes)", source, destination, size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!destChunk->state.mapAllowed) {
|
if (!destChunk->state.mapAllowed) {
|
||||||
state.ctx->gpr.w0 = result::InvalidState;
|
state.ctx->gpr.w0 = result::InvalidState;
|
||||||
state.logger->Warn("Destination doesn't allow usage of svcMapMemory: Source: 0x{:X}, Destination: 0x{:X} (Size: 0x{:X} bytes) 0x{:X}", source, destination, size, destChunk->state.value);
|
Logger::Warn("Destination doesn't allow usage of svcMapMemory: Source: 0x{:X}, Destination: 0x{:X} (Size: 0x{:X} bytes) 0x{:X}", source, destination, size, destChunk->state.value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ namespace skyline::kernel::svc {
|
|||||||
|
|
||||||
state.process->CloseHandle(sourceObject->handle);
|
state.process->CloseHandle(sourceObject->handle);
|
||||||
|
|
||||||
state.logger->Debug("Unmapped range 0x{:X} - 0x{:X} to 0x{:X} - 0x{:X} (Size: 0x{:X} bytes)", source, source + size, destination, destination + size, size);
|
Logger::Debug("Unmapped range 0x{:X} - 0x{:X} to 0x{:X} - 0x{:X} (Size: 0x{:X} bytes)", source, source + size, destination, destination + size, size);
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ namespace skyline::kernel::svc {
|
|||||||
.ipcRefCount = 0,
|
.ipcRefCount = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
state.logger->Debug("Address: 0x{:X}, Region Start: 0x{:X}, Size: 0x{:X}, Type: 0x{:X}, Is Uncached: {}, Permissions: {}{}{}", pointer, memInfo.address, memInfo.size, memInfo.type, static_cast<bool>(chunk->attributes.isUncached), chunk->permission.r ? 'R' : '-', chunk->permission.w ? 'W' : '-', chunk->permission.x ? 'X' : '-');
|
Logger::Debug("Address: 0x{:X}, Region Start: 0x{:X}, Size: 0x{:X}, Type: 0x{:X}, Is Uncached: {}, Permissions: {}{}{}", pointer, memInfo.address, memInfo.size, memInfo.type, static_cast<bool>(chunk->attributes.isUncached), chunk->permission.r ? 'R' : '-', chunk->permission.w ? 'W' : '-', chunk->permission.x ? 'X' : '-');
|
||||||
} else {
|
} else {
|
||||||
auto addressSpaceEnd{reinterpret_cast<u64>(state.process->memory.addressSpace.address + state.process->memory.addressSpace.size)};
|
auto addressSpaceEnd{reinterpret_cast<u64>(state.process->memory.addressSpace.address + state.process->memory.addressSpace.size)};
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ namespace skyline::kernel::svc {
|
|||||||
.type = static_cast<u32>(memory::MemoryType::Reserved),
|
.type = static_cast<u32>(memory::MemoryType::Reserved),
|
||||||
};
|
};
|
||||||
|
|
||||||
state.logger->Debug("Trying to query memory outside of the application's address space: 0x{:X}", pointer);
|
Logger::Debug("Trying to query memory outside of the application's address space: 0x{:X}", pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
*reinterpret_cast<memory::MemoryInfo *>(state.ctx->gpr.x0) = memInfo;
|
*reinterpret_cast<memory::MemoryInfo *>(state.ctx->gpr.x0) = memInfo;
|
||||||
@ -218,7 +218,7 @@ namespace skyline::kernel::svc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ExitProcess(const DeviceState &state) {
|
void ExitProcess(const DeviceState &state) {
|
||||||
state.logger->Debug("Exiting process");
|
Logger::Debug("Exiting process");
|
||||||
throw nce::NCE::ExitException(true);
|
throw nce::NCE::ExitException(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,13 +236,13 @@ namespace skyline::kernel::svc {
|
|||||||
idealCore = (idealCore == IdealCoreUseProcessValue) ? static_cast<i32>(state.process->npdm.meta.idealCore) : idealCore;
|
idealCore = (idealCore == IdealCoreUseProcessValue) ? static_cast<i32>(state.process->npdm.meta.idealCore) : idealCore;
|
||||||
if (idealCore < 0 || idealCore >= constant::CoreCount) {
|
if (idealCore < 0 || idealCore >= constant::CoreCount) {
|
||||||
state.ctx->gpr.w0 = result::InvalidCoreId;
|
state.ctx->gpr.w0 = result::InvalidCoreId;
|
||||||
state.logger->Warn("'idealCore' invalid: {}", idealCore);
|
Logger::Warn("'idealCore' invalid: {}", idealCore);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!state.process->npdm.threadInfo.priority.Valid(priority)) {
|
if (!state.process->npdm.threadInfo.priority.Valid(priority)) {
|
||||||
state.ctx->gpr.w0 = result::InvalidPriority;
|
state.ctx->gpr.w0 = result::InvalidPriority;
|
||||||
state.logger->Warn("'priority' invalid: {}", priority);
|
Logger::Warn("'priority' invalid: {}", priority);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,12 +252,12 @@ namespace skyline::kernel::svc {
|
|||||||
|
|
||||||
auto thread{state.process->CreateThread(entry, entryArgument, stackTop, priority, static_cast<u8>(idealCore))};
|
auto thread{state.process->CreateThread(entry, entryArgument, stackTop, priority, static_cast<u8>(idealCore))};
|
||||||
if (thread) {
|
if (thread) {
|
||||||
state.logger->Debug("Created thread #{} with handle 0x{:X} (Entry Point: 0x{:X}, Argument: 0x{:X}, Stack Pointer: 0x{:X}, Priority: {}, Ideal Core: {})", thread->id, thread->handle, entry, entryArgument, stackTop, priority, idealCore);
|
Logger::Debug("Created thread #{} with handle 0x{:X} (Entry Point: 0x{:X}, Argument: 0x{:X}, Stack Pointer: 0x{:X}, Priority: {}, Ideal Core: {})", thread->id, thread->handle, entry, entryArgument, stackTop, priority, idealCore);
|
||||||
|
|
||||||
state.ctx->gpr.w1 = thread->handle;
|
state.ctx->gpr.w1 = thread->handle;
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
} else {
|
} else {
|
||||||
state.logger->Debug("Cannot create thread (Entry Point: 0x{:X}, Argument: 0x{:X}, Stack Pointer: 0x{:X}, Priority: {}, Ideal Core: {})", entry, entryArgument, stackTop, priority, idealCore);
|
Logger::Debug("Cannot create thread (Entry Point: 0x{:X}, Argument: 0x{:X}, Stack Pointer: 0x{:X}, Priority: {}, Ideal Core: {})", entry, entryArgument, stackTop, priority, idealCore);
|
||||||
state.ctx->gpr.w1 = 0;
|
state.ctx->gpr.w1 = 0;
|
||||||
state.ctx->gpr.w0 = result::OutOfResource;
|
state.ctx->gpr.w0 = result::OutOfResource;
|
||||||
}
|
}
|
||||||
@ -267,17 +267,17 @@ namespace skyline::kernel::svc {
|
|||||||
KHandle handle{state.ctx->gpr.w0};
|
KHandle handle{state.ctx->gpr.w0};
|
||||||
try {
|
try {
|
||||||
auto thread{state.process->GetHandle<type::KThread>(handle)};
|
auto thread{state.process->GetHandle<type::KThread>(handle)};
|
||||||
state.logger->Debug("Starting thread #{}: 0x{:X}", thread->id, handle);
|
Logger::Debug("Starting thread #{}: 0x{:X}", thread->id, handle);
|
||||||
thread->Start();
|
thread->Start();
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
} catch (const std::out_of_range &) {
|
} catch (const std::out_of_range &) {
|
||||||
state.logger->Warn("'handle' invalid: 0x{:X}", handle);
|
Logger::Warn("'handle' invalid: 0x{:X}", handle);
|
||||||
state.ctx->gpr.w0 = result::InvalidHandle;
|
state.ctx->gpr.w0 = result::InvalidHandle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExitThread(const DeviceState &state) {
|
void ExitThread(const DeviceState &state) {
|
||||||
state.logger->Debug("Exiting current thread");
|
Logger::Debug("Exiting current thread");
|
||||||
throw nce::NCE::ExitException(false);
|
throw nce::NCE::ExitException(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ namespace skyline::kernel::svc {
|
|||||||
|
|
||||||
i64 in{static_cast<i64>(state.ctx->gpr.x0)};
|
i64 in{static_cast<i64>(state.ctx->gpr.x0)};
|
||||||
if (in > 0) {
|
if (in > 0) {
|
||||||
state.logger->Debug("Sleeping for {}ns", in);
|
Logger::Debug("Sleeping for {}ns", in);
|
||||||
TRACE_EVENT("kernel", "SleepThread", "duration", in);
|
TRACE_EVENT("kernel", "SleepThread", "duration", in);
|
||||||
|
|
||||||
struct timespec spec{
|
struct timespec spec{
|
||||||
@ -301,7 +301,7 @@ namespace skyline::kernel::svc {
|
|||||||
} else {
|
} else {
|
||||||
switch (in) {
|
switch (in) {
|
||||||
case yieldWithCoreMigration: {
|
case yieldWithCoreMigration: {
|
||||||
state.logger->Debug("Waking any appropriate parked threads and yielding");
|
Logger::Debug("Waking any appropriate parked threads and yielding");
|
||||||
TRACE_EVENT("kernel", "YieldWithCoreMigration");
|
TRACE_EVENT("kernel", "YieldWithCoreMigration");
|
||||||
state.scheduler->WakeParkedThread();
|
state.scheduler->WakeParkedThread();
|
||||||
state.scheduler->Rotate();
|
state.scheduler->Rotate();
|
||||||
@ -310,7 +310,7 @@ namespace skyline::kernel::svc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case yieldWithoutCoreMigration: {
|
case yieldWithoutCoreMigration: {
|
||||||
state.logger->Debug("Cooperative yield");
|
Logger::Debug("Cooperative yield");
|
||||||
TRACE_EVENT("kernel", "YieldWithoutCoreMigration");
|
TRACE_EVENT("kernel", "YieldWithoutCoreMigration");
|
||||||
state.scheduler->Rotate();
|
state.scheduler->Rotate();
|
||||||
state.scheduler->WaitSchedule();
|
state.scheduler->WaitSchedule();
|
||||||
@ -318,7 +318,7 @@ namespace skyline::kernel::svc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case yieldToAnyThread: {
|
case yieldToAnyThread: {
|
||||||
state.logger->Debug("Parking current thread");
|
Logger::Debug("Parking current thread");
|
||||||
TRACE_EVENT("kernel", "YieldToAnyThread");
|
TRACE_EVENT("kernel", "YieldToAnyThread");
|
||||||
state.scheduler->ParkThread();
|
state.scheduler->ParkThread();
|
||||||
state.scheduler->WaitSchedule(false);
|
state.scheduler->WaitSchedule(false);
|
||||||
@ -336,12 +336,12 @@ namespace skyline::kernel::svc {
|
|||||||
try {
|
try {
|
||||||
auto thread{state.process->GetHandle<type::KThread>(handle)};
|
auto thread{state.process->GetHandle<type::KThread>(handle)};
|
||||||
i8 priority{thread->priority};
|
i8 priority{thread->priority};
|
||||||
state.logger->Debug("Retrieving thread #{}'s priority: {}", thread->id, priority);
|
Logger::Debug("Retrieving thread #{}'s priority: {}", thread->id, priority);
|
||||||
|
|
||||||
state.ctx->gpr.w1 = static_cast<u32>(priority);
|
state.ctx->gpr.w1 = static_cast<u32>(priority);
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
} catch (const std::out_of_range &) {
|
} catch (const std::out_of_range &) {
|
||||||
state.logger->Warn("'handle' invalid: 0x{:X}", handle);
|
Logger::Warn("'handle' invalid: 0x{:X}", handle);
|
||||||
state.ctx->gpr.w0 = result::InvalidHandle;
|
state.ctx->gpr.w0 = result::InvalidHandle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -350,13 +350,13 @@ namespace skyline::kernel::svc {
|
|||||||
KHandle handle{state.ctx->gpr.w0};
|
KHandle handle{state.ctx->gpr.w0};
|
||||||
i8 priority{static_cast<i8>(state.ctx->gpr.w1)};
|
i8 priority{static_cast<i8>(state.ctx->gpr.w1)};
|
||||||
if (!state.process->npdm.threadInfo.priority.Valid(priority)) {
|
if (!state.process->npdm.threadInfo.priority.Valid(priority)) {
|
||||||
state.logger->Warn("'priority' invalid: 0x{:X}", priority);
|
Logger::Warn("'priority' invalid: 0x{:X}", priority);
|
||||||
state.ctx->gpr.w0 = result::InvalidPriority;
|
state.ctx->gpr.w0 = result::InvalidPriority;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
auto thread{state.process->GetHandle<type::KThread>(handle)};
|
auto thread{state.process->GetHandle<type::KThread>(handle)};
|
||||||
state.logger->Debug("Setting thread #{}'s priority to {}", thread->id, priority);
|
Logger::Debug("Setting thread #{}'s priority to {}", thread->id, priority);
|
||||||
if (thread->priority != priority) {
|
if (thread->priority != priority) {
|
||||||
thread->basePriority = priority;
|
thread->basePriority = priority;
|
||||||
i8 newPriority{};
|
i8 newPriority{};
|
||||||
@ -371,7 +371,7 @@ namespace skyline::kernel::svc {
|
|||||||
}
|
}
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
} catch (const std::out_of_range &) {
|
} catch (const std::out_of_range &) {
|
||||||
state.logger->Warn("'handle' invalid: 0x{:X}", handle);
|
Logger::Warn("'handle' invalid: 0x{:X}", handle);
|
||||||
state.ctx->gpr.w0 = result::InvalidHandle;
|
state.ctx->gpr.w0 = result::InvalidHandle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -382,13 +382,13 @@ namespace skyline::kernel::svc {
|
|||||||
auto thread{state.process->GetHandle<type::KThread>(handle)};
|
auto thread{state.process->GetHandle<type::KThread>(handle)};
|
||||||
auto idealCore{thread->idealCore};
|
auto idealCore{thread->idealCore};
|
||||||
auto affinityMask{thread->affinityMask};
|
auto affinityMask{thread->affinityMask};
|
||||||
state.logger->Debug("Getting thread #{}'s Ideal Core ({}) + Affinity Mask ({})", thread->id, idealCore, affinityMask);
|
Logger::Debug("Getting thread #{}'s Ideal Core ({}) + Affinity Mask ({})", thread->id, idealCore, affinityMask);
|
||||||
|
|
||||||
state.ctx->gpr.x2 = affinityMask.to_ullong();
|
state.ctx->gpr.x2 = affinityMask.to_ullong();
|
||||||
state.ctx->gpr.w1 = static_cast<u32>(idealCore);
|
state.ctx->gpr.w1 = static_cast<u32>(idealCore);
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
} catch (const std::out_of_range &) {
|
} catch (const std::out_of_range &) {
|
||||||
state.logger->Warn("'handle' invalid: 0x{:X}", handle);
|
Logger::Warn("'handle' invalid: 0x{:X}", handle);
|
||||||
state.ctx->gpr.w0 = result::InvalidHandle;
|
state.ctx->gpr.w0 = result::InvalidHandle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -411,25 +411,25 @@ namespace skyline::kernel::svc {
|
|||||||
|
|
||||||
auto processMask{state.process->npdm.threadInfo.coreMask};
|
auto processMask{state.process->npdm.threadInfo.coreMask};
|
||||||
if ((processMask | affinityMask) != processMask) {
|
if ((processMask | affinityMask) != processMask) {
|
||||||
state.logger->Warn("'affinityMask' invalid: {} (Process Mask: {})", affinityMask, processMask);
|
Logger::Warn("'affinityMask' invalid: {} (Process Mask: {})", affinityMask, processMask);
|
||||||
state.ctx->gpr.w0 = result::InvalidCoreId;
|
state.ctx->gpr.w0 = result::InvalidCoreId;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (affinityMask.none() || !affinityMask.test(static_cast<size_t>(idealCore))) {
|
if (affinityMask.none() || !affinityMask.test(static_cast<size_t>(idealCore))) {
|
||||||
state.logger->Warn("'affinityMask' invalid: {} (Ideal Core: {})", affinityMask, idealCore);
|
Logger::Warn("'affinityMask' invalid: {} (Ideal Core: {})", affinityMask, idealCore);
|
||||||
state.ctx->gpr.w0 = result::InvalidCombination;
|
state.ctx->gpr.w0 = result::InvalidCombination;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.logger->Debug("Setting thread #{}'s Ideal Core ({}) + Affinity Mask ({})", thread->id, idealCore, affinityMask);
|
Logger::Debug("Setting thread #{}'s Ideal Core ({}) + Affinity Mask ({})", thread->id, idealCore, affinityMask);
|
||||||
|
|
||||||
std::lock_guard guard(thread->coreMigrationMutex);
|
std::lock_guard guard(thread->coreMigrationMutex);
|
||||||
thread->idealCore = static_cast<u8>(idealCore);
|
thread->idealCore = static_cast<u8>(idealCore);
|
||||||
thread->affinityMask = affinityMask;
|
thread->affinityMask = affinityMask;
|
||||||
|
|
||||||
if (!affinityMask.test(static_cast<size_t>(thread->coreId)) && thread->coreId != constant::ParkedCoreId) {
|
if (!affinityMask.test(static_cast<size_t>(thread->coreId)) && thread->coreId != constant::ParkedCoreId) {
|
||||||
state.logger->Debug("Migrating thread #{} to Ideal Core C{} -> C{}", thread->id, thread->coreId, idealCore);
|
Logger::Debug("Migrating thread #{} to Ideal Core C{} -> C{}", thread->id, thread->coreId, idealCore);
|
||||||
|
|
||||||
if (thread == state.thread) {
|
if (thread == state.thread) {
|
||||||
state.scheduler->RemoveThread();
|
state.scheduler->RemoveThread();
|
||||||
@ -445,7 +445,7 @@ namespace skyline::kernel::svc {
|
|||||||
|
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
} catch (const std::out_of_range &) {
|
} catch (const std::out_of_range &) {
|
||||||
state.logger->Warn("'handle' invalid: 0x{:X}", handle);
|
Logger::Warn("'handle' invalid: 0x{:X}", handle);
|
||||||
state.ctx->gpr.w0 = result::InvalidHandle;
|
state.ctx->gpr.w0 = result::InvalidHandle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -453,7 +453,7 @@ namespace skyline::kernel::svc {
|
|||||||
void GetCurrentProcessorNumber(const DeviceState &state) {
|
void GetCurrentProcessorNumber(const DeviceState &state) {
|
||||||
std::lock_guard guard(state.thread->coreMigrationMutex);
|
std::lock_guard guard(state.thread->coreMigrationMutex);
|
||||||
u8 coreId{state.thread->coreId};
|
u8 coreId{state.thread->coreId};
|
||||||
state.logger->Debug("C{}", coreId);
|
Logger::Debug("C{}", coreId);
|
||||||
state.ctx->gpr.w0 = coreId;
|
state.ctx->gpr.w0 = coreId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,10 +462,10 @@ namespace skyline::kernel::svc {
|
|||||||
TRACE_EVENT_FMT("kernel", "ClearEvent 0x{:X}", handle);
|
TRACE_EVENT_FMT("kernel", "ClearEvent 0x{:X}", handle);
|
||||||
try {
|
try {
|
||||||
std::static_pointer_cast<type::KEvent>(state.process->GetHandle(handle))->ResetSignal();
|
std::static_pointer_cast<type::KEvent>(state.process->GetHandle(handle))->ResetSignal();
|
||||||
state.logger->Debug("Clearing 0x{:X}", handle);
|
Logger::Debug("Clearing 0x{:X}", handle);
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
} catch (const std::out_of_range &) {
|
} catch (const std::out_of_range &) {
|
||||||
state.logger->Warn("'handle' invalid: 0x{:X}", handle);
|
Logger::Warn("'handle' invalid: 0x{:X}", handle);
|
||||||
state.ctx->gpr.w0 = result::InvalidHandle;
|
state.ctx->gpr.w0 = result::InvalidHandle;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -479,31 +479,31 @@ namespace skyline::kernel::svc {
|
|||||||
|
|
||||||
if (!util::IsPageAligned(pointer)) {
|
if (!util::IsPageAligned(pointer)) {
|
||||||
state.ctx->gpr.w0 = result::InvalidAddress;
|
state.ctx->gpr.w0 = result::InvalidAddress;
|
||||||
state.logger->Warn("'pointer' not page aligned: 0x{:X}", pointer);
|
Logger::Warn("'pointer' not page aligned: 0x{:X}", pointer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size{state.ctx->gpr.x2};
|
size_t size{state.ctx->gpr.x2};
|
||||||
if (!util::IsPageAligned(size)) {
|
if (!util::IsPageAligned(size)) {
|
||||||
state.ctx->gpr.w0 = result::InvalidSize;
|
state.ctx->gpr.w0 = result::InvalidSize;
|
||||||
state.logger->Warn("'size' {}: 0x{:X}", size ? "not page aligned" : "is zero", size);
|
Logger::Warn("'size' {}: 0x{:X}", size ? "not page aligned" : "is zero", size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memory::Permission permission(static_cast<u8>(state.ctx->gpr.w3));
|
memory::Permission permission(static_cast<u8>(state.ctx->gpr.w3));
|
||||||
if ((permission.w && !permission.r) || (permission.x && !permission.r)) {
|
if ((permission.w && !permission.r) || (permission.x && !permission.r)) {
|
||||||
state.logger->Warn("'permission' invalid: {}{}{}", permission.r ? 'R' : '-', permission.w ? 'W' : '-', permission.x ? 'X' : '-');
|
Logger::Warn("'permission' invalid: {}{}{}", permission.r ? 'R' : '-', permission.w ? 'W' : '-', permission.x ? 'X' : '-');
|
||||||
state.ctx->gpr.w0 = result::InvalidNewMemoryPermission;
|
state.ctx->gpr.w0 = result::InvalidNewMemoryPermission;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.logger->Debug("Mapping shared memory (0x{:X}) at 0x{:X} - 0x{:X} (0x{:X} bytes) ({}{}{})", handle, pointer, pointer + size, size, permission.r ? 'R' : '-', permission.w ? 'W' : '-', permission.x ? 'X' : '-');
|
Logger::Debug("Mapping shared memory (0x{:X}) at 0x{:X} - 0x{:X} (0x{:X} bytes) ({}{}{})", handle, pointer, pointer + size, size, permission.r ? 'R' : '-', permission.w ? 'W' : '-', permission.x ? 'X' : '-');
|
||||||
|
|
||||||
object->Map(pointer, size, permission);
|
object->Map(pointer, size, permission);
|
||||||
|
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
} catch (const std::out_of_range &) {
|
} catch (const std::out_of_range &) {
|
||||||
state.logger->Warn("'handle' invalid: 0x{:X}", static_cast<u32>(state.ctx->gpr.w0));
|
Logger::Warn("'handle' invalid: 0x{:X}", static_cast<u32>(state.ctx->gpr.w0));
|
||||||
state.ctx->gpr.w0 = result::InvalidHandle;
|
state.ctx->gpr.w0 = result::InvalidHandle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -516,24 +516,24 @@ namespace skyline::kernel::svc {
|
|||||||
|
|
||||||
if (!util::IsPageAligned(pointer)) {
|
if (!util::IsPageAligned(pointer)) {
|
||||||
state.ctx->gpr.w0 = result::InvalidAddress;
|
state.ctx->gpr.w0 = result::InvalidAddress;
|
||||||
state.logger->Warn("'pointer' not page aligned: 0x{:X}", pointer);
|
Logger::Warn("'pointer' not page aligned: 0x{:X}", pointer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size{state.ctx->gpr.x2};
|
size_t size{state.ctx->gpr.x2};
|
||||||
if (!util::IsPageAligned(size)) {
|
if (!util::IsPageAligned(size)) {
|
||||||
state.ctx->gpr.w0 = result::InvalidSize;
|
state.ctx->gpr.w0 = result::InvalidSize;
|
||||||
state.logger->Warn("'size' {}: 0x{:X}", size ? "not page aligned" : "is zero", size);
|
Logger::Warn("'size' {}: 0x{:X}", size ? "not page aligned" : "is zero", size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.logger->Debug("Unmapping shared memory (0x{:X}) at 0x{:X} - 0x{:X} (0x{:X} bytes)", handle, pointer, pointer + size, size);
|
Logger::Debug("Unmapping shared memory (0x{:X}) at 0x{:X} - 0x{:X} (0x{:X} bytes)", handle, pointer, pointer + size, size);
|
||||||
|
|
||||||
object->Unmap(pointer, size);
|
object->Unmap(pointer, size);
|
||||||
|
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
} catch (const std::out_of_range &) {
|
} catch (const std::out_of_range &) {
|
||||||
state.logger->Warn("'handle' invalid: 0x{:X}", static_cast<u32>(state.ctx->gpr.w0));
|
Logger::Warn("'handle' invalid: 0x{:X}", static_cast<u32>(state.ctx->gpr.w0));
|
||||||
state.ctx->gpr.w0 = result::InvalidHandle;
|
state.ctx->gpr.w0 = result::InvalidHandle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -542,26 +542,26 @@ namespace skyline::kernel::svc {
|
|||||||
auto pointer{reinterpret_cast<u8 *>(state.ctx->gpr.x1)};
|
auto pointer{reinterpret_cast<u8 *>(state.ctx->gpr.x1)};
|
||||||
if (!util::IsPageAligned(pointer)) {
|
if (!util::IsPageAligned(pointer)) {
|
||||||
state.ctx->gpr.w0 = result::InvalidAddress;
|
state.ctx->gpr.w0 = result::InvalidAddress;
|
||||||
state.logger->Warn("'pointer' not page aligned: 0x{:X}", pointer);
|
Logger::Warn("'pointer' not page aligned: 0x{:X}", pointer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size{state.ctx->gpr.x2};
|
size_t size{state.ctx->gpr.x2};
|
||||||
if (!util::IsPageAligned(size)) {
|
if (!util::IsPageAligned(size)) {
|
||||||
state.ctx->gpr.w0 = result::InvalidSize;
|
state.ctx->gpr.w0 = result::InvalidSize;
|
||||||
state.logger->Warn("'size' {}: 0x{:X}", size ? "not page aligned" : "is zero", size);
|
Logger::Warn("'size' {}: 0x{:X}", size ? "not page aligned" : "is zero", size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memory::Permission permission(static_cast<u8>(state.ctx->gpr.w3));
|
memory::Permission permission(static_cast<u8>(state.ctx->gpr.w3));
|
||||||
if ((permission.w && !permission.r) || (permission.x && !permission.r)) {
|
if ((permission.w && !permission.r) || (permission.x && !permission.r)) {
|
||||||
state.logger->Warn("'permission' invalid: {}{}{}", permission.r ? 'R' : '-', permission.w ? 'W' : '-', permission.x ? 'X' : '-');
|
Logger::Warn("'permission' invalid: {}{}{}", permission.r ? 'R' : '-', permission.w ? 'W' : '-', permission.x ? 'X' : '-');
|
||||||
state.ctx->gpr.w0 = result::InvalidNewMemoryPermission;
|
state.ctx->gpr.w0 = result::InvalidNewMemoryPermission;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto tmem{state.process->NewHandle<type::KTransferMemory>(pointer, size, permission, permission.raw ? memory::states::TransferMemory : memory::states::TransferMemoryIsolated)};
|
auto tmem{state.process->NewHandle<type::KTransferMemory>(pointer, size, permission, permission.raw ? memory::states::TransferMemory : memory::states::TransferMemoryIsolated)};
|
||||||
state.logger->Debug("Creating transfer memory (0x{:X}) at 0x{:X} - 0x{:X} (0x{:X} bytes) ({}{}{})", tmem.handle, pointer, pointer + size, size, permission.r ? 'R' : '-', permission.w ? 'W' : '-', permission.x ? 'X' : '-');
|
Logger::Debug("Creating transfer memory (0x{:X}) at 0x{:X} - 0x{:X} (0x{:X} bytes) ({}{}{})", tmem.handle, pointer, pointer + size, size, permission.r ? 'R' : '-', permission.w ? 'W' : '-', permission.x ? 'X' : '-');
|
||||||
|
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
state.ctx->gpr.w1 = tmem.handle;
|
state.ctx->gpr.w1 = tmem.handle;
|
||||||
@ -571,10 +571,10 @@ namespace skyline::kernel::svc {
|
|||||||
KHandle handle{static_cast<KHandle>(state.ctx->gpr.w0)};
|
KHandle handle{static_cast<KHandle>(state.ctx->gpr.w0)};
|
||||||
try {
|
try {
|
||||||
state.process->CloseHandle(handle);
|
state.process->CloseHandle(handle);
|
||||||
state.logger->Debug("Closing 0x{:X}", handle);
|
Logger::Debug("Closing 0x{:X}", handle);
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
} catch (const std::out_of_range &) {
|
} catch (const std::out_of_range &) {
|
||||||
state.logger->Warn("'handle' invalid: 0x{:X}", handle);
|
Logger::Warn("'handle' invalid: 0x{:X}", handle);
|
||||||
state.ctx->gpr.w0 = result::InvalidHandle;
|
state.ctx->gpr.w0 = result::InvalidHandle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -591,16 +591,16 @@ namespace skyline::kernel::svc {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
state.logger->Warn("'handle' type invalid: 0x{:X} ({})", handle, object->objectType);
|
Logger::Warn("'handle' type invalid: 0x{:X} ({})", handle, object->objectType);
|
||||||
state.ctx->gpr.w0 = result::InvalidHandle;
|
state.ctx->gpr.w0 = result::InvalidHandle;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state.logger->Debug("Resetting 0x{:X}", handle);
|
Logger::Debug("Resetting 0x{:X}", handle);
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
} catch (const std::out_of_range &) {
|
} catch (const std::out_of_range &) {
|
||||||
state.logger->Warn("'handle' invalid: 0x{:X}", handle);
|
Logger::Warn("'handle' invalid: 0x{:X}", handle);
|
||||||
state.ctx->gpr.w0 = result::InvalidHandle;
|
state.ctx->gpr.w0 = result::InvalidHandle;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -630,7 +630,7 @@ namespace skyline::kernel::svc {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
state.logger->Debug("An invalid handle was supplied: 0x{:X}", handle);
|
Logger::Debug("An invalid handle was supplied: 0x{:X}", handle);
|
||||||
state.ctx->gpr.w0 = result::InvalidHandle;
|
state.ctx->gpr.w0 = result::InvalidHandle;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -639,12 +639,12 @@ namespace skyline::kernel::svc {
|
|||||||
|
|
||||||
i64 timeout{static_cast<i64>(state.ctx->gpr.x3)};
|
i64 timeout{static_cast<i64>(state.ctx->gpr.x3)};
|
||||||
if (waitHandles.size() == 1) {
|
if (waitHandles.size() == 1) {
|
||||||
state.logger->Debug("Waiting on 0x{:X} for {}ns", waitHandles[0], timeout);
|
Logger::Debug("Waiting on 0x{:X} for {}ns", waitHandles[0], timeout);
|
||||||
} else if (Logger::LogLevel::Debug <= state.logger->configLevel) {
|
} else if (Logger::LogLevel::Debug <= Logger::configLevel) {
|
||||||
std::string handleString;
|
std::string handleString;
|
||||||
for (const auto &handle : waitHandles)
|
for (const auto &handle : waitHandles)
|
||||||
handleString += fmt::format("* 0x{:X}\n", handle);
|
handleString += fmt::format("* 0x{:X}\n", handle);
|
||||||
state.logger->Debug("Waiting on handles:\n{}Timeout: {}ns", handleString, timeout);
|
Logger::Debug("Waiting on handles:\n{}Timeout: {}ns", handleString, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE_EVENT_FMT("kernel", waitHandles.size() == 1 ? "WaitSynchronization 0x{:X}" : "WaitSynchronizationMultiple 0x{:X}", waitHandles[0]);
|
TRACE_EVENT_FMT("kernel", waitHandles.size() == 1 ? "WaitSynchronization 0x{:X}" : "WaitSynchronizationMultiple 0x{:X}", waitHandles[0]);
|
||||||
@ -659,7 +659,7 @@ namespace skyline::kernel::svc {
|
|||||||
u32 index{};
|
u32 index{};
|
||||||
for (const auto &object : objectTable) {
|
for (const auto &object : objectTable) {
|
||||||
if (object->signalled) {
|
if (object->signalled) {
|
||||||
state.logger->Debug("Signalled 0x{:X}", waitHandles[index]);
|
Logger::Debug("Signalled 0x{:X}", waitHandles[index]);
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
state.ctx->gpr.w1 = index;
|
state.ctx->gpr.w1 = index;
|
||||||
return;
|
return;
|
||||||
@ -668,7 +668,7 @@ namespace skyline::kernel::svc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (timeout == 0) {
|
if (timeout == 0) {
|
||||||
state.logger->Debug("No handle is currently signalled");
|
Logger::Debug("No handle is currently signalled");
|
||||||
state.ctx->gpr.w0 = result::TimedOut;
|
state.ctx->gpr.w0 = result::TimedOut;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -707,15 +707,15 @@ namespace skyline::kernel::svc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wakeObject) {
|
if (wakeObject) {
|
||||||
state.logger->Debug("Signalled 0x{:X}", waitHandles[wakeIndex]);
|
Logger::Debug("Signalled 0x{:X}", waitHandles[wakeIndex]);
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
state.ctx->gpr.w1 = wakeIndex;
|
state.ctx->gpr.w1 = wakeIndex;
|
||||||
} else if (state.thread->cancelSync) {
|
} else if (state.thread->cancelSync) {
|
||||||
state.thread->cancelSync = false;
|
state.thread->cancelSync = false;
|
||||||
state.logger->Debug("Wait has been cancelled");
|
Logger::Debug("Wait has been cancelled");
|
||||||
state.ctx->gpr.w0 = result::Cancelled;
|
state.ctx->gpr.w0 = result::Cancelled;
|
||||||
} else {
|
} else {
|
||||||
state.logger->Debug("Wait has timed out");
|
Logger::Debug("Wait has timed out");
|
||||||
state.ctx->gpr.w0 = result::TimedOut;
|
state.ctx->gpr.w0 = result::TimedOut;
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
state.scheduler->InsertThread(state.thread);
|
state.scheduler->InsertThread(state.thread);
|
||||||
@ -734,7 +734,7 @@ namespace skyline::kernel::svc {
|
|||||||
}
|
}
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
} catch (const std::out_of_range &) {
|
} catch (const std::out_of_range &) {
|
||||||
state.logger->Warn("'handle' invalid: 0x{:X}", static_cast<u32>(state.ctx->gpr.w0));
|
Logger::Warn("'handle' invalid: 0x{:X}", static_cast<u32>(state.ctx->gpr.w0));
|
||||||
state.ctx->gpr.w0 = result::InvalidHandle;
|
state.ctx->gpr.w0 = result::InvalidHandle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -742,22 +742,22 @@ namespace skyline::kernel::svc {
|
|||||||
void ArbitrateLock(const DeviceState &state) {
|
void ArbitrateLock(const DeviceState &state) {
|
||||||
auto mutex{reinterpret_cast<u32 *>(state.ctx->gpr.x1)};
|
auto mutex{reinterpret_cast<u32 *>(state.ctx->gpr.x1)};
|
||||||
if (!util::IsWordAligned(mutex)) {
|
if (!util::IsWordAligned(mutex)) {
|
||||||
state.logger->Warn("'mutex' not word aligned: 0x{:X}", mutex);
|
Logger::Warn("'mutex' not word aligned: 0x{:X}", mutex);
|
||||||
state.ctx->gpr.w0 = result::InvalidAddress;
|
state.ctx->gpr.w0 = result::InvalidAddress;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.logger->Debug("Locking 0x{:X}", mutex);
|
Logger::Debug("Locking 0x{:X}", mutex);
|
||||||
|
|
||||||
KHandle ownerHandle{state.ctx->gpr.w0};
|
KHandle ownerHandle{state.ctx->gpr.w0};
|
||||||
KHandle requesterHandle{state.ctx->gpr.w2};
|
KHandle requesterHandle{state.ctx->gpr.w2};
|
||||||
auto result{state.process->MutexLock(mutex, ownerHandle, requesterHandle)};
|
auto result{state.process->MutexLock(mutex, ownerHandle, requesterHandle)};
|
||||||
if (result == Result{})
|
if (result == Result{})
|
||||||
state.logger->Debug("Locked 0x{:X}", mutex);
|
Logger::Debug("Locked 0x{:X}", mutex);
|
||||||
else if (result == result::InvalidCurrentMemory)
|
else if (result == result::InvalidCurrentMemory)
|
||||||
result = Result{}; // If the mutex value isn't expected then it's still successful
|
result = Result{}; // If the mutex value isn't expected then it's still successful
|
||||||
else if (result == result::InvalidHandle)
|
else if (result == result::InvalidHandle)
|
||||||
state.logger->Warn("'ownerHandle' invalid: 0x{:X} (0x{:X})", ownerHandle, mutex);
|
Logger::Warn("'ownerHandle' invalid: 0x{:X} (0x{:X})", ownerHandle, mutex);
|
||||||
|
|
||||||
state.ctx->gpr.w0 = result;
|
state.ctx->gpr.w0 = result;
|
||||||
}
|
}
|
||||||
@ -765,14 +765,14 @@ namespace skyline::kernel::svc {
|
|||||||
void ArbitrateUnlock(const DeviceState &state) {
|
void ArbitrateUnlock(const DeviceState &state) {
|
||||||
auto mutex{reinterpret_cast<u32 *>(state.ctx->gpr.x0)};
|
auto mutex{reinterpret_cast<u32 *>(state.ctx->gpr.x0)};
|
||||||
if (!util::IsWordAligned(mutex)) {
|
if (!util::IsWordAligned(mutex)) {
|
||||||
state.logger->Warn("'mutex' not word aligned: 0x{:X}", mutex);
|
Logger::Warn("'mutex' not word aligned: 0x{:X}", mutex);
|
||||||
state.ctx->gpr.w0 = result::InvalidAddress;
|
state.ctx->gpr.w0 = result::InvalidAddress;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.logger->Debug("Unlocking 0x{:X}", mutex);
|
Logger::Debug("Unlocking 0x{:X}", mutex);
|
||||||
state.process->MutexUnlock(mutex);
|
state.process->MutexUnlock(mutex);
|
||||||
state.logger->Debug("Unlocked 0x{:X}", mutex);
|
Logger::Debug("Unlocked 0x{:X}", mutex);
|
||||||
|
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
}
|
}
|
||||||
@ -780,7 +780,7 @@ namespace skyline::kernel::svc {
|
|||||||
void WaitProcessWideKeyAtomic(const DeviceState &state) {
|
void WaitProcessWideKeyAtomic(const DeviceState &state) {
|
||||||
auto mutex{reinterpret_cast<u32 *>(state.ctx->gpr.x0)};
|
auto mutex{reinterpret_cast<u32 *>(state.ctx->gpr.x0)};
|
||||||
if (!util::IsWordAligned(mutex)) {
|
if (!util::IsWordAligned(mutex)) {
|
||||||
state.logger->Warn("'mutex' not word aligned: 0x{:X}", mutex);
|
Logger::Warn("'mutex' not word aligned: 0x{:X}", mutex);
|
||||||
state.ctx->gpr.w0 = result::InvalidAddress;
|
state.ctx->gpr.w0 = result::InvalidAddress;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -789,13 +789,13 @@ namespace skyline::kernel::svc {
|
|||||||
KHandle requesterHandle{state.ctx->gpr.w2};
|
KHandle requesterHandle{state.ctx->gpr.w2};
|
||||||
|
|
||||||
i64 timeout{static_cast<i64>(state.ctx->gpr.x3)};
|
i64 timeout{static_cast<i64>(state.ctx->gpr.x3)};
|
||||||
state.logger->Debug("Waiting on 0x{:X} with 0x{:X} for {}ns", conditional, mutex, timeout);
|
Logger::Debug("Waiting on 0x{:X} with 0x{:X} for {}ns", conditional, mutex, timeout);
|
||||||
|
|
||||||
auto result{state.process->ConditionalVariableWait(conditional, mutex, requesterHandle, timeout)};
|
auto result{state.process->ConditionalVariableWait(conditional, mutex, requesterHandle, timeout)};
|
||||||
if (result == Result{})
|
if (result == Result{})
|
||||||
state.logger->Debug("Waited for 0x{:X} and reacquired 0x{:X}", conditional, mutex);
|
Logger::Debug("Waited for 0x{:X} and reacquired 0x{:X}", conditional, mutex);
|
||||||
else if (result == result::TimedOut)
|
else if (result == result::TimedOut)
|
||||||
state.logger->Debug("Wait on 0x{:X} has timed out after {}ns", conditional, timeout);
|
Logger::Debug("Wait on 0x{:X} has timed out after {}ns", conditional, timeout);
|
||||||
state.ctx->gpr.w0 = result;
|
state.ctx->gpr.w0 = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -803,7 +803,7 @@ namespace skyline::kernel::svc {
|
|||||||
auto conditional{reinterpret_cast<u32 *>(state.ctx->gpr.x0)};
|
auto conditional{reinterpret_cast<u32 *>(state.ctx->gpr.x0)};
|
||||||
i32 count{static_cast<i32>(state.ctx->gpr.w1)};
|
i32 count{static_cast<i32>(state.ctx->gpr.w1)};
|
||||||
|
|
||||||
state.logger->Debug("Signalling 0x{:X} for {} waiters", conditional, count);
|
Logger::Debug("Signalling 0x{:X} for {} waiters", conditional, count);
|
||||||
state.process->ConditionalVariableSignal(conditional, count);
|
state.process->ConditionalVariableSignal(conditional, count);
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
}
|
}
|
||||||
@ -829,12 +829,12 @@ namespace skyline::kernel::svc {
|
|||||||
if (port.compare("sm:") >= 0) {
|
if (port.compare("sm:") >= 0) {
|
||||||
handle = state.process->NewHandle<type::KSession>(std::static_pointer_cast<service::BaseService>(state.os->serviceManager.smUserInterface)).handle;
|
handle = state.process->NewHandle<type::KSession>(std::static_pointer_cast<service::BaseService>(state.os->serviceManager.smUserInterface)).handle;
|
||||||
} else {
|
} else {
|
||||||
state.logger->Warn("Connecting to invalid port: '{}'", port);
|
Logger::Warn("Connecting to invalid port: '{}'", port);
|
||||||
state.ctx->gpr.w0 = result::NotFound;
|
state.ctx->gpr.w0 = result::NotFound;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.logger->Debug("Connecting to port '{}' at 0x{:X}", port, handle);
|
Logger::Debug("Connecting to port '{}' at 0x{:X}", port, handle);
|
||||||
|
|
||||||
state.ctx->gpr.w1 = handle;
|
state.ctx->gpr.w1 = handle;
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
@ -850,7 +850,7 @@ namespace skyline::kernel::svc {
|
|||||||
KHandle handle{state.ctx->gpr.w1};
|
KHandle handle{state.ctx->gpr.w1};
|
||||||
size_t tid{state.process->GetHandle<type::KThread>(handle)->id};
|
size_t tid{state.process->GetHandle<type::KThread>(handle)->id};
|
||||||
|
|
||||||
state.logger->Debug("Handle: 0x{:X}, TID: {}", handle, tid);
|
Logger::Debug("Handle: 0x{:X}, TID: {}", handle, tid);
|
||||||
|
|
||||||
state.ctx->gpr.x1 = tid;
|
state.ctx->gpr.x1 = tid;
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
@ -859,9 +859,9 @@ namespace skyline::kernel::svc {
|
|||||||
void Break(const DeviceState &state) {
|
void Break(const DeviceState &state) {
|
||||||
auto reason{state.ctx->gpr.x0};
|
auto reason{state.ctx->gpr.x0};
|
||||||
if (reason & (1ULL << 31)) {
|
if (reason & (1ULL << 31)) {
|
||||||
state.logger->Debug("Debugger is being engaged ({})", reason);
|
Logger::Debug("Debugger is being engaged ({})", reason);
|
||||||
} else {
|
} else {
|
||||||
state.logger->Error("Exit Stack Trace ({}){}", reason, state.loader->GetStackTrace());
|
Logger::Error("Exit Stack Trace ({}){}", reason, state.loader->GetStackTrace());
|
||||||
if (state.thread->id)
|
if (state.thread->id)
|
||||||
state.process->Kill(false);
|
state.process->Kill(false);
|
||||||
std::longjmp(state.thread->originalCtx, true);
|
std::longjmp(state.thread->originalCtx, true);
|
||||||
@ -874,7 +874,7 @@ namespace skyline::kernel::svc {
|
|||||||
if (string.back() == '\n')
|
if (string.back() == '\n')
|
||||||
string.remove_suffix(1);
|
string.remove_suffix(1);
|
||||||
|
|
||||||
state.logger->Info("{}", string);
|
Logger::Info("{}", string);
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1001,12 +1001,12 @@ namespace skyline::kernel::svc {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
state.logger->Warn("Unimplemented case ID0: {}, ID1: {}", static_cast<u32>(info), id1);
|
Logger::Warn("Unimplemented case ID0: {}, ID1: {}", static_cast<u32>(info), id1);
|
||||||
state.ctx->gpr.w0 = result::InvalidEnumValue;
|
state.ctx->gpr.w0 = result::InvalidEnumValue;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.logger->Debug("ID0: {}, ID1: {}, Out: 0x{:X}", static_cast<u32>(info), id1, out);
|
Logger::Debug("ID0: {}, ID1: {}, Out: 0x{:X}", static_cast<u32>(info), id1, out);
|
||||||
|
|
||||||
state.ctx->gpr.x1 = out;
|
state.ctx->gpr.x1 = out;
|
||||||
state.ctx->gpr.w0 = Result{};
|
state.ctx->gpr.w0 = Result{};
|
||||||
@ -1088,7 +1088,7 @@ namespace skyline::kernel::svc {
|
|||||||
void WaitForAddress(const DeviceState &state) {
|
void WaitForAddress(const DeviceState &state) {
|
||||||
auto address{reinterpret_cast<u32 *>(state.ctx->gpr.x0)};
|
auto address{reinterpret_cast<u32 *>(state.ctx->gpr.x0)};
|
||||||
if (!util::IsWordAligned(address)) [[unlikely]] {
|
if (!util::IsWordAligned(address)) [[unlikely]] {
|
||||||
state.logger->Warn("'address' not word aligned: 0x{:X}", address);
|
Logger::Warn("'address' not word aligned: 0x{:X}", address);
|
||||||
state.ctx->gpr.w0 = result::InvalidAddress;
|
state.ctx->gpr.w0 = result::InvalidAddress;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1104,14 +1104,14 @@ namespace skyline::kernel::svc {
|
|||||||
Result result;
|
Result result;
|
||||||
switch (arbitrationType) {
|
switch (arbitrationType) {
|
||||||
case ArbitrationType::WaitIfLessThan:
|
case ArbitrationType::WaitIfLessThan:
|
||||||
state.logger->Debug("Waiting on 0x{:X} if less than {} for {}ns", address, value, timeout);
|
Logger::Debug("Waiting on 0x{:X} if less than {} for {}ns", address, value, timeout);
|
||||||
result = state.process->WaitForAddress(address, value, timeout, [](u32 *address, u32 value) {
|
result = state.process->WaitForAddress(address, value, timeout, [](u32 *address, u32 value) {
|
||||||
return *address < value;
|
return *address < value;
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ArbitrationType::DecrementAndWaitIfLessThan:
|
case ArbitrationType::DecrementAndWaitIfLessThan:
|
||||||
state.logger->Debug("Waiting on and decrementing 0x{:X} if less than {} for {}ns", address, value, timeout);
|
Logger::Debug("Waiting on and decrementing 0x{:X} if less than {} for {}ns", address, value, timeout);
|
||||||
result = state.process->WaitForAddress(address, value, timeout, [](u32 *address, u32 value) {
|
result = state.process->WaitForAddress(address, value, timeout, [](u32 *address, u32 value) {
|
||||||
u32 userValue{__atomic_load_n(address, __ATOMIC_SEQ_CST)};
|
u32 userValue{__atomic_load_n(address, __ATOMIC_SEQ_CST)};
|
||||||
do {
|
do {
|
||||||
@ -1123,7 +1123,7 @@ namespace skyline::kernel::svc {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ArbitrationType::WaitIfEqual:
|
case ArbitrationType::WaitIfEqual:
|
||||||
state.logger->Debug("Waiting on 0x{:X} if equal to {} for {}ns", address, value, timeout);
|
Logger::Debug("Waiting on 0x{:X} if equal to {} for {}ns", address, value, timeout);
|
||||||
result = state.process->WaitForAddress(address, value, timeout, [](u32 *address, u32 value) {
|
result = state.process->WaitForAddress(address, value, timeout, [](u32 *address, u32 value) {
|
||||||
return *address == value;
|
return *address == value;
|
||||||
});
|
});
|
||||||
@ -1131,18 +1131,18 @@ namespace skyline::kernel::svc {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
[[unlikely]]
|
[[unlikely]]
|
||||||
state.logger->Error("'arbitrationType' invalid: {}", arbitrationType);
|
Logger::Error("'arbitrationType' invalid: {}", arbitrationType);
|
||||||
state.ctx->gpr.w0 = result::InvalidEnumValue;
|
state.ctx->gpr.w0 = result::InvalidEnumValue;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == Result{})
|
if (result == Result{})
|
||||||
[[likely]]
|
[[likely]]
|
||||||
state.logger->Debug("Waited on 0x{:X} successfully", address);
|
Logger::Debug("Waited on 0x{:X} successfully", address);
|
||||||
else if (result == result::TimedOut)
|
else if (result == result::TimedOut)
|
||||||
state.logger->Debug("Wait on 0x{:X} has timed out after {}ns", address, timeout);
|
Logger::Debug("Wait on 0x{:X} has timed out after {}ns", address, timeout);
|
||||||
else if (result == result::InvalidState)
|
else if (result == result::InvalidState)
|
||||||
state.logger->Debug("The value at 0x{:X} did not satisfy the arbitration condition", address);
|
Logger::Debug("The value at 0x{:X} did not satisfy the arbitration condition", address);
|
||||||
|
|
||||||
state.ctx->gpr.w0 = result;
|
state.ctx->gpr.w0 = result;
|
||||||
}
|
}
|
||||||
@ -1150,7 +1150,7 @@ namespace skyline::kernel::svc {
|
|||||||
void SignalToAddress(const DeviceState &state) {
|
void SignalToAddress(const DeviceState &state) {
|
||||||
auto address{reinterpret_cast<u32 *>(state.ctx->gpr.x0)};
|
auto address{reinterpret_cast<u32 *>(state.ctx->gpr.x0)};
|
||||||
if (!util::IsWordAligned(address)) [[unlikely]] {
|
if (!util::IsWordAligned(address)) [[unlikely]] {
|
||||||
state.logger->Warn("'address' not word aligned: 0x{:X}", address);
|
Logger::Warn("'address' not word aligned: 0x{:X}", address);
|
||||||
state.ctx->gpr.w0 = result::InvalidAddress;
|
state.ctx->gpr.w0 = result::InvalidAddress;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1166,19 +1166,19 @@ namespace skyline::kernel::svc {
|
|||||||
Result result;
|
Result result;
|
||||||
switch (signalType) {
|
switch (signalType) {
|
||||||
case SignalType::Signal:
|
case SignalType::Signal:
|
||||||
state.logger->Debug("Signalling 0x{:X} for {} waiters", address, count);
|
Logger::Debug("Signalling 0x{:X} for {} waiters", address, count);
|
||||||
result = state.process->SignalToAddress(address, value, count);
|
result = state.process->SignalToAddress(address, value, count);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SignalType::SignalAndIncrementIfEqual:
|
case SignalType::SignalAndIncrementIfEqual:
|
||||||
state.logger->Debug("Signalling 0x{:X} and incrementing if equal to {} for {} waiters", address, value, count);
|
Logger::Debug("Signalling 0x{:X} and incrementing if equal to {} for {} waiters", address, value, count);
|
||||||
result = state.process->SignalToAddress(address, value, count, [](u32 *address, u32 value, u32) {
|
result = state.process->SignalToAddress(address, value, count, [](u32 *address, u32 value, u32) {
|
||||||
return __atomic_compare_exchange_n(address, &value, value + 1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
|
return __atomic_compare_exchange_n(address, &value, value + 1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SignalType::SignalAndModifyBasedOnWaitingThreadCountIfEqual:
|
case SignalType::SignalAndModifyBasedOnWaitingThreadCountIfEqual:
|
||||||
state.logger->Debug("Signalling 0x{:X} and setting to waiting thread count if equal to {} for {} waiters", address, value, count);
|
Logger::Debug("Signalling 0x{:X} and setting to waiting thread count if equal to {} for {} waiters", address, value, count);
|
||||||
result = state.process->SignalToAddress(address, value, count, [](u32 *address, u32 value, u32 waiterCount) {
|
result = state.process->SignalToAddress(address, value, count, [](u32 *address, u32 value, u32 waiterCount) {
|
||||||
return __atomic_compare_exchange_n(address, &value, waiterCount, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
|
return __atomic_compare_exchange_n(address, &value, waiterCount, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
|
||||||
});
|
});
|
||||||
@ -1186,16 +1186,16 @@ namespace skyline::kernel::svc {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
[[unlikely]]
|
[[unlikely]]
|
||||||
state.logger->Error("'signalType' invalid: {}", signalType);
|
Logger::Error("'signalType' invalid: {}", signalType);
|
||||||
state.ctx->gpr.w0 = result::InvalidEnumValue;
|
state.ctx->gpr.w0 = result::InvalidEnumValue;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == Result{})
|
if (result == Result{})
|
||||||
[[likely]]
|
[[likely]]
|
||||||
state.logger->Debug("Signalled 0x{:X} for {} successfully", address, count);
|
Logger::Debug("Signalled 0x{:X} for {} successfully", address, count);
|
||||||
else if (result == result::InvalidState)
|
else if (result == result::InvalidState)
|
||||||
state.logger->Debug("The value at 0x{:X} did not satisfy the mutation condition", address);
|
Logger::Debug("The value at 0x{:X} did not satisfy the mutation condition", address);
|
||||||
|
|
||||||
state.ctx->gpr.w0 = result;
|
state.ctx->gpr.w0 = result;
|
||||||
}
|
}
|
||||||
|
@ -102,9 +102,9 @@ namespace skyline::kernel::type {
|
|||||||
constexpr memory::Permission UnborrowPermission{true, true, false};
|
constexpr memory::Permission UnborrowPermission{true, true, false};
|
||||||
|
|
||||||
if (mmap(guest.ptr, guest.size, UnborrowPermission.Get(), MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0) == MAP_FAILED)
|
if (mmap(guest.ptr, guest.size, UnborrowPermission.Get(), MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0) == MAP_FAILED)
|
||||||
state.logger->Warn("An error occurred while remapping transfer memory as anonymous memory in guest: {}", strerror(errno));
|
Logger::Warn("An error occurred while remapping transfer memory as anonymous memory in guest: {}", strerror(errno));
|
||||||
else if (!host.Valid())
|
else if (!host.Valid())
|
||||||
state.logger->Warn("Expected host mapping of transfer memory to be valid during KTransferMemory destruction");
|
Logger::Warn("Expected host mapping of transfer memory to be valid during KTransferMemory destruction");
|
||||||
|
|
||||||
std::memcpy(guest.ptr, host.ptr, host.size);
|
std::memcpy(guest.ptr, host.ptr, host.size);
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ namespace skyline::kernel::type {
|
|||||||
std::array<char, 16> threadName;
|
std::array<char, 16> threadName;
|
||||||
pthread_getname_np(pthread, threadName.data(), threadName.size());
|
pthread_getname_np(pthread, threadName.data(), threadName.size());
|
||||||
pthread_setname_np(pthread, fmt::format("HOS-{}", id).c_str());
|
pthread_setname_np(pthread, fmt::format("HOS-{}", id).c_str());
|
||||||
state.logger->UpdateTag();
|
Logger::UpdateTag();
|
||||||
|
|
||||||
if (!ctx.tpidrroEl0)
|
if (!ctx.tpidrroEl0)
|
||||||
ctx.tpidrroEl0 = parent->AllocateTlsSlot();
|
ctx.tpidrroEl0 = parent->AllocateTlsSlot();
|
||||||
@ -61,7 +61,7 @@ namespace skyline::kernel::type {
|
|||||||
|
|
||||||
if (threadName[0] != 'H' || threadName[1] != 'O' || threadName[2] != 'S' || threadName[3] != '-') {
|
if (threadName[0] != 'H' || threadName[1] != 'O' || threadName[2] != 'S' || threadName[3] != '-') {
|
||||||
pthread_setname_np(pthread, threadName.data());
|
pthread_setname_np(pthread, threadName.data());
|
||||||
state.logger->UpdateTag();
|
Logger::UpdateTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -176,7 +176,7 @@ namespace skyline::kernel::type {
|
|||||||
|
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
state.logger->Error(e.what());
|
Logger::Error(e.what());
|
||||||
if (id) {
|
if (id) {
|
||||||
signal::BlockSignal({SIGINT});
|
signal::BlockSignal({SIGINT});
|
||||||
state.process->Kill(false);
|
state.process->Kill(false);
|
||||||
@ -185,7 +185,7 @@ namespace skyline::kernel::type {
|
|||||||
std::longjmp(originalCtx, true);
|
std::longjmp(originalCtx, true);
|
||||||
} catch (const signal::SignalException &e) {
|
} catch (const signal::SignalException &e) {
|
||||||
if (e.signal != SIGINT) {
|
if (e.signal != SIGINT) {
|
||||||
state.logger->Error(e.what());
|
Logger::Error(e.what());
|
||||||
if (id) {
|
if (id) {
|
||||||
signal::BlockSignal({SIGINT});
|
signal::BlockSignal({SIGINT});
|
||||||
state.process->Kill(false);
|
state.process->Kill(false);
|
||||||
|
@ -27,16 +27,16 @@ namespace skyline::loader {
|
|||||||
auto size{patch.size + textSize + roSize + dataSize};
|
auto size{patch.size + textSize + roSize + dataSize};
|
||||||
|
|
||||||
process->NewHandle<kernel::type::KPrivateMemory>(base, patch.size, memory::Permission{false, false, false}, memory::states::Reserved); // ---
|
process->NewHandle<kernel::type::KPrivateMemory>(base, patch.size, memory::Permission{false, false, false}, memory::states::Reserved); // ---
|
||||||
state.logger->Debug("Successfully mapped section .patch @ 0x{:X}, Size = 0x{:X}", base, patch.size);
|
Logger::Debug("Successfully mapped section .patch @ 0x{:X}, Size = 0x{:X}", base, patch.size);
|
||||||
|
|
||||||
process->NewHandle<kernel::type::KPrivateMemory>(base + patch.size + executable.text.offset, textSize, memory::Permission{true, false, true}, memory::states::CodeStatic); // R-X
|
process->NewHandle<kernel::type::KPrivateMemory>(base + patch.size + executable.text.offset, textSize, memory::Permission{true, false, true}, memory::states::CodeStatic); // R-X
|
||||||
state.logger->Debug("Successfully mapped section .text @ 0x{:X}, Size = 0x{:X}", base + patch.size + executable.text.offset, textSize);
|
Logger::Debug("Successfully mapped section .text @ 0x{:X}, Size = 0x{:X}", base + patch.size + executable.text.offset, textSize);
|
||||||
|
|
||||||
process->NewHandle<kernel::type::KPrivateMemory>(base + patch.size + executable.ro.offset, roSize, memory::Permission{true, false, false}, memory::states::CodeStatic); // R--
|
process->NewHandle<kernel::type::KPrivateMemory>(base + patch.size + executable.ro.offset, roSize, memory::Permission{true, false, false}, memory::states::CodeStatic); // R--
|
||||||
state.logger->Debug("Successfully mapped section .rodata @ 0x{:X}, Size = 0x{:X}", base + patch.size + executable.ro.offset, roSize);
|
Logger::Debug("Successfully mapped section .rodata @ 0x{:X}, Size = 0x{:X}", base + patch.size + executable.ro.offset, roSize);
|
||||||
|
|
||||||
process->NewHandle<kernel::type::KPrivateMemory>(base + patch.size + executable.data.offset, dataSize, memory::Permission{true, true, false}, memory::states::CodeMutable); // RW-
|
process->NewHandle<kernel::type::KPrivateMemory>(base + patch.size + executable.data.offset, dataSize, memory::Permission{true, true, false}, memory::states::CodeMutable); // RW-
|
||||||
state.logger->Debug("Successfully mapped section .data + .bss @ 0x{:X}, Size = 0x{:X}", base + patch.size + executable.data.offset, dataSize);
|
Logger::Debug("Successfully mapped section .data + .bss @ 0x{:X}, Size = 0x{:X}", base + patch.size + executable.data.offset, dataSize);
|
||||||
|
|
||||||
state.nce->PatchCode(executable.text.contents, reinterpret_cast<u32 *>(base), patch.size, patch.offsets);
|
state.nce->PatchCode(executable.text.contents, reinterpret_cast<u32 *>(base), patch.size, patch.offsets);
|
||||||
std::memcpy(base + patch.size + executable.text.offset, executable.text.contents.data(), textSize);
|
std::memcpy(base + patch.size + executable.text.offset, executable.text.contents.data(), textSize);
|
||||||
|
@ -28,7 +28,7 @@ namespace skyline::loader {
|
|||||||
u8 *base{loadInfo.base};
|
u8 *base{loadInfo.base};
|
||||||
void *entry{loadInfo.entry};
|
void *entry{loadInfo.entry};
|
||||||
|
|
||||||
state.logger->Info("Loaded 'rtld.nso' at 0x{:X} (.text @ 0x{:X})", base, entry);
|
Logger::Info("Loaded 'rtld.nso' at 0x{:X} (.text @ 0x{:X})", base, entry);
|
||||||
|
|
||||||
for (const auto &nso : {"main", "subsdk0", "subsdk1", "subsdk2", "subsdk3", "subsdk4", "subsdk5", "subsdk6", "subsdk7", "sdk"}) {
|
for (const auto &nso : {"main", "subsdk0", "subsdk1", "subsdk2", "subsdk3", "subsdk4", "subsdk5", "subsdk6", "subsdk7", "sdk"}) {
|
||||||
if (exeFs->FileExists(nso))
|
if (exeFs->FileExists(nso))
|
||||||
@ -37,7 +37,7 @@ namespace skyline::loader {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
loadInfo = NsoLoader::LoadNso(loader, nsoFile, process, state, offset, nso + std::string(".nso"));
|
loadInfo = NsoLoader::LoadNso(loader, nsoFile, process, state, offset, nso + std::string(".nso"));
|
||||||
state.logger->Info("Loaded '{}.nso' at 0x{:X} (.text @ 0x{:X})", nso, base + offset, loadInfo.entry);
|
Logger::Info("Loaded '{}.nso' at 0x{:X} (.text @ 0x{:X})", nso, base + offset, loadInfo.entry);
|
||||||
offset += loadInfo.size;
|
offset += loadInfo.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ namespace skyline::loader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *NcaLoader::LoadProcessData(const std::shared_ptr<kernel::type::KProcess> &process, const DeviceState &state) {
|
void *NcaLoader::LoadProcessData(const std::shared_ptr<kernel::type::KProcess> &process, const DeviceState &state) {
|
||||||
process->npdm = vfs::NPDM(nca.exeFs->OpenFile("main.npdm"), state);
|
process->npdm = vfs::NPDM(nca.exeFs->OpenFile("main.npdm"));
|
||||||
return LoadExeFs(this, nca.exeFs, process, state);
|
return LoadExeFs(this, nca.exeFs, process, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ namespace skyline::loader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *NspLoader::LoadProcessData(const std::shared_ptr<kernel::type::KProcess> &process, const DeviceState &state) {
|
void *NspLoader::LoadProcessData(const std::shared_ptr<kernel::type::KProcess> &process, const DeviceState &state) {
|
||||||
process->npdm = vfs::NPDM(programNca->exeFs->OpenFile("main.npdm"), state);
|
process->npdm = vfs::NPDM(programNca->exeFs->OpenFile("main.npdm"));
|
||||||
return NcaLoader::LoadExeFs(this, programNca->exeFs, process, state);
|
return NcaLoader::LoadExeFs(this, programNca->exeFs, process, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ namespace skyline::loader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *XciLoader::LoadProcessData(const std::shared_ptr<kernel::type::KProcess> &process, const DeviceState &state) {
|
void *XciLoader::LoadProcessData(const std::shared_ptr<kernel::type::KProcess> &process, const DeviceState &state) {
|
||||||
process->npdm = vfs::NPDM(programNca->exeFs->OpenFile("main.npdm"), state);
|
process->npdm = vfs::NPDM(programNca->exeFs->OpenFile("main.npdm"));
|
||||||
return NcaLoader::LoadExeFs(this, programNca->exeFs, process, state);
|
return NcaLoader::LoadExeFs(this, programNca->exeFs, process, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ namespace skyline::nce {
|
|||||||
}
|
}
|
||||||
} catch (const signal::SignalException &e) {
|
} catch (const signal::SignalException &e) {
|
||||||
if (e.signal != SIGINT) {
|
if (e.signal != SIGINT) {
|
||||||
state.logger->ErrorNoPrefix("{} (SVC: {})\nStack Trace:{}", e.what(), svc.name, state.loader->GetStackTrace(e.frames));
|
Logger::ErrorNoPrefix("{} (SVC: {})\nStack Trace:{}", e.what(), svc.name, state.loader->GetStackTrace(e.frames));
|
||||||
if (state.thread->id) {
|
if (state.thread->id) {
|
||||||
signal::BlockSignal({SIGINT});
|
signal::BlockSignal({SIGINT});
|
||||||
state.process->Kill(false);
|
state.process->Kill(false);
|
||||||
@ -56,9 +56,9 @@ namespace skyline::nce {
|
|||||||
std::longjmp(state.thread->originalCtx, true);
|
std::longjmp(state.thread->originalCtx, true);
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
if (svc)
|
if (svc)
|
||||||
state.logger->ErrorNoPrefix("{} (SVC: {})\nStack Trace:{}", e.what(), svc.name, state.loader->GetStackTrace());
|
Logger::ErrorNoPrefix("{} (SVC: {})\nStack Trace:{}", e.what(), svc.name, state.loader->GetStackTrace());
|
||||||
else
|
else
|
||||||
state.logger->ErrorNoPrefix("{} (SVC: 0x{:X})\nStack Trace:{}", e.what(), svcId, state.loader->GetStackTrace());
|
Logger::ErrorNoPrefix("{} (SVC: 0x{:X})\nStack Trace:{}", e.what(), svcId, state.loader->GetStackTrace());
|
||||||
|
|
||||||
if (state.thread->id) {
|
if (state.thread->id) {
|
||||||
signal::BlockSignal({SIGINT});
|
signal::BlockSignal({SIGINT});
|
||||||
@ -87,7 +87,7 @@ namespace skyline::nce {
|
|||||||
for (u8 index{}; index < (sizeof(mcontext_t::regs) / sizeof(u64)); index += 2)
|
for (u8 index{}; index < (sizeof(mcontext_t::regs) / sizeof(u64)); index += 2)
|
||||||
cpuContext += fmt::format("\n X{:<2}: 0x{:<16X} X{:<2}: 0x{:X}", index, mctx.regs[index], index + 1, mctx.regs[index + 1]);
|
cpuContext += fmt::format("\n X{:<2}: 0x{:<16X} X{:<2}: 0x{:X}", index, mctx.regs[index], index + 1, mctx.regs[index + 1]);
|
||||||
|
|
||||||
state.logger->Error("Thread #{} has crashed due to signal: {}\nStack Trace:{}\nCPU Context:{}", state.thread->id, strsignal(signal), trace, cpuContext);
|
Logger::Error("Thread #{} has crashed due to signal: {}\nStack Trace:{}\nCPU Context:{}", state.thread->id, strsignal(signal), trace, cpuContext);
|
||||||
|
|
||||||
if (state.thread->id) {
|
if (state.thread->id) {
|
||||||
signal::BlockSignal({SIGINT});
|
signal::BlockSignal({SIGINT});
|
||||||
|
@ -54,7 +54,7 @@ namespace skyline::kernel {
|
|||||||
process->InitializeHeapTls();
|
process->InitializeHeapTls();
|
||||||
auto thread{process->CreateThread(entry)};
|
auto thread{process->CreateThread(entry)};
|
||||||
if (thread) {
|
if (thread) {
|
||||||
state.logger->Debug("Starting main HOS thread");
|
Logger::Debug("Starting main HOS thread");
|
||||||
thread->Start(true);
|
thread->Start(true);
|
||||||
process->Kill(true, true, true);
|
process->Kill(true, true, true);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace skyline::service::am {
|
|||||||
stateChangeEvent->Signal();
|
stateChangeEvent->Signal();
|
||||||
|
|
||||||
KHandle handle{state.process->InsertItem(stateChangeEvent)};
|
KHandle handle{state.process->InsertItem(stateChangeEvent)};
|
||||||
state.logger->Debug("Applet State Change Event Handle: 0x{:X}", handle);
|
Logger::Debug("Applet State Change Event Handle: 0x{:X}", handle);
|
||||||
|
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
return {};
|
return {};
|
||||||
|
@ -103,7 +103,7 @@ namespace skyline::service::am {
|
|||||||
if (width > MaximumFbWidth || height > MaximumFbHeight || !util::IsAligned(transferMemorySize, RequiredFbAlignment))
|
if (width > MaximumFbWidth || height > MaximumFbHeight || !util::IsAligned(transferMemorySize, RequiredFbAlignment))
|
||||||
return result::InvalidParameters;
|
return result::InvalidParameters;
|
||||||
|
|
||||||
state.logger->Debug("Dimensions: ({}, {}) Transfer Memory Size: {}", width, height, transferMemorySize);
|
Logger::Debug("Dimensions: ({}, {}) Transfer Memory Size: {}", width, height, transferMemorySize);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -122,19 +122,19 @@ namespace skyline::service::am {
|
|||||||
if (y < 0 || x < 0 || width < 1 || height < 1)
|
if (y < 0 || x < 0 || width < 1 || height < 1)
|
||||||
return result::InvalidParameters;
|
return result::InvalidParameters;
|
||||||
|
|
||||||
state.logger->Debug("Position: ({}, {}) Dimensions: ({}, {}) Origin mode: {}", x, y, width, height, static_cast<i32>(originMode));
|
Logger::Debug("Position: ({}, {}) Dimensions: ({}, {}) Origin mode: {}", x, y, width, height, static_cast<i32>(originMode));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Result IApplicationFunctions::SetApplicationCopyrightVisibility(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IApplicationFunctions::SetApplicationCopyrightVisibility(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
u8 visiblity{request.Pop<u8>()};
|
u8 visiblity{request.Pop<u8>()};
|
||||||
state.logger->Debug("Visiblity: {}", visiblity);
|
Logger::Debug("Visiblity: {}", visiblity);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Result IApplicationFunctions::GetGpuErrorDetectedSystemEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IApplicationFunctions::GetGpuErrorDetectedSystemEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto handle{state.process->InsertItem(gpuErrorEvent)};
|
auto handle{state.process->InsertItem(gpuErrorEvent)};
|
||||||
state.logger->Debug("GPU Error Event Handle: 0x{:X}", handle);
|
Logger::Debug("GPU Error Event Handle: 0x{:X}", handle);
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,13 @@ namespace skyline::service::am {
|
|||||||
|
|
||||||
ICommonStateGetter::ICommonStateGetter(const DeviceState &state, ServiceManager &manager) : messageEvent(std::make_shared<type::KEvent>(state, false)), BaseService(state, manager) {
|
ICommonStateGetter::ICommonStateGetter(const DeviceState &state, ServiceManager &manager) : messageEvent(std::make_shared<type::KEvent>(state, false)), BaseService(state, manager) {
|
||||||
operationMode = static_cast<OperationMode>(state.settings->operationMode);
|
operationMode = static_cast<OperationMode>(state.settings->operationMode);
|
||||||
state.logger->Info("Switch to mode: {}", static_cast<bool>(operationMode) ? "Docked" : "Handheld");
|
Logger::Info("Switch to mode: {}", static_cast<bool>(operationMode) ? "Docked" : "Handheld");
|
||||||
QueueMessage(Message::FocusStateChange);
|
QueueMessage(Message::FocusStateChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ICommonStateGetter::GetEventHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result ICommonStateGetter::GetEventHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto handle{state.process->InsertItem(messageEvent)};
|
auto handle{state.process->InsertItem(messageEvent)};
|
||||||
state.logger->Debug("Applet Event Handle: 0x{:X}", handle);
|
Logger::Debug("Applet Event Handle: 0x{:X}", handle);
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ namespace skyline::service::am {
|
|||||||
libraryAppletLaunchableEvent->Signal();
|
libraryAppletLaunchableEvent->Signal();
|
||||||
|
|
||||||
KHandle handle{state.process->InsertItem(libraryAppletLaunchableEvent)};
|
KHandle handle{state.process->InsertItem(libraryAppletLaunchableEvent)};
|
||||||
state.logger->Debug("Library Applet Launchable Event Handle: 0x{:X}", handle);
|
Logger::Debug("Library Applet Launchable Event Handle: 0x{:X}", handle);
|
||||||
|
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
return {};
|
return {};
|
||||||
@ -57,7 +57,7 @@ namespace skyline::service::am {
|
|||||||
|
|
||||||
Result ISelfController::CreateManagedDisplayLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result ISelfController::CreateManagedDisplayLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto layerId{hosbinder->CreateLayer(hosbinder::DisplayId::Default)};
|
auto layerId{hosbinder->CreateLayer(hosbinder::DisplayId::Default)};
|
||||||
state.logger->Debug("Creating Managed Layer #{} on 'Default' Display", layerId);
|
Logger::Debug("Creating Managed Layer #{} on 'Default' Display", layerId);
|
||||||
response.Push(layerId);
|
response.Push(layerId);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ namespace skyline::service::am {
|
|||||||
|
|
||||||
Result ISelfController::GetAccumulatedSuspendedTickChangedEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result ISelfController::GetAccumulatedSuspendedTickChangedEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto handle{state.process->InsertItem(accumulatedSuspendedTickChangedEvent)};
|
auto handle{state.process->InsertItem(accumulatedSuspendedTickChangedEvent)};
|
||||||
state.logger->Debug("Accumulated Suspended Tick Event Handle: 0x{:X}", handle);
|
Logger::Debug("Accumulated Suspended Tick Event Handle: 0x{:X}", handle);
|
||||||
|
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
return {};
|
return {};
|
||||||
|
@ -10,7 +10,7 @@ namespace skyline::service::apm {
|
|||||||
auto mode{request.Pop<u32>()};
|
auto mode{request.Pop<u32>()};
|
||||||
auto config{request.Pop<u32>()};
|
auto config{request.Pop<u32>()};
|
||||||
performanceConfig.at(mode) = config;
|
performanceConfig.at(mode) = config;
|
||||||
state.logger->Info("Performance configuration set to 0x{:X} ({})", config, mode ? "Docked" : "Handheld");
|
Logger::Info("Performance configuration set to 0x{:X} ({})", config, mode ? "Docked" : "Handheld");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ namespace skyline::service::audio {
|
|||||||
|
|
||||||
Result IAudioDevice::QueryAudioDeviceSystemEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IAudioDevice::QueryAudioDeviceSystemEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto handle{state.process->InsertItem(systemEvent)};
|
auto handle{state.process->InsertItem(systemEvent)};
|
||||||
state.logger->Debug("Audio Device System Event Handle: 0x{:X}", handle);
|
Logger::Debug("Audio Device System Event Handle: 0x{:X}", handle);
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,13 @@ namespace skyline::service::audio {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result IAudioOut::StartAudioOut(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IAudioOut::StartAudioOut(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
state.logger->Debug("Start playback");
|
Logger::Debug("Start playback");
|
||||||
track->Start();
|
track->Start();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Result IAudioOut::StopAudioOut(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IAudioOut::StopAudioOut(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
state.logger->Debug("Stop playback");
|
Logger::Debug("Stop playback");
|
||||||
track->Stop();
|
track->Stop();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ namespace skyline::service::audio {
|
|||||||
} &data{request.inputBuf.at(0).as<Data>()};
|
} &data{request.inputBuf.at(0).as<Data>()};
|
||||||
auto tag{request.Pop<u64>()};
|
auto tag{request.Pop<u64>()};
|
||||||
|
|
||||||
state.logger->Debug("Appending buffer at 0x{:X}, Size: 0x{:X}", data.sampleBuffer, data.sampleSize);
|
Logger::Debug("Appending buffer at 0x{:X}, Size: 0x{:X}", data.sampleBuffer, data.sampleSize);
|
||||||
|
|
||||||
span samples(data.sampleBuffer, data.sampleSize / sizeof(i16));
|
span samples(data.sampleBuffer, data.sampleSize / sizeof(i16));
|
||||||
if (sampleRate != constant::SampleRate) {
|
if (sampleRate != constant::SampleRate) {
|
||||||
@ -59,7 +59,7 @@ namespace skyline::service::audio {
|
|||||||
|
|
||||||
Result IAudioOut::RegisterBufferEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IAudioOut::RegisterBufferEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto handle{state.process->InsertItem(releaseEvent)};
|
auto handle{state.process->InsertItem(releaseEvent)};
|
||||||
state.logger->Debug("Buffer Release Event Handle: 0x{:X}", handle);
|
Logger::Debug("Buffer Release Event Handle: 0x{:X}", handle);
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ namespace skyline::service::audio {
|
|||||||
auto sampleRate{request.Pop<u32>()};
|
auto sampleRate{request.Pop<u32>()};
|
||||||
auto channelCount{static_cast<u16>(request.Pop<u32>())};
|
auto channelCount{static_cast<u16>(request.Pop<u32>())};
|
||||||
|
|
||||||
state.logger->Debug("Opening an IAudioOut with sample rate: {}, channel count: {}", sampleRate, channelCount);
|
Logger::Debug("Opening an IAudioOut with sample rate: {}, channel count: {}", sampleRate, channelCount);
|
||||||
|
|
||||||
sampleRate = sampleRate ? sampleRate : constant::SampleRate;
|
sampleRate = sampleRate ? sampleRate : constant::SampleRate;
|
||||||
channelCount = channelCount ? channelCount : constant::ChannelCount;
|
channelCount = channelCount ? channelCount : constant::ChannelCount;
|
||||||
|
@ -173,7 +173,7 @@ namespace skyline::service::audio::IAudioRenderer {
|
|||||||
|
|
||||||
Result IAudioRenderer::QuerySystemEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IAudioRenderer::QuerySystemEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto handle{state.process->InsertItem(systemEvent)};
|
auto handle{state.process->InsertItem(systemEvent)};
|
||||||
state.logger->Debug("System Event Handle: 0x{:X}", handle);
|
Logger::Debug("System Event Handle: 0x{:X}", handle);
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace skyline::service::audio {
|
|||||||
Result IAudioRendererManager::OpenAudioRenderer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IAudioRendererManager::OpenAudioRenderer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
IAudioRenderer::AudioRendererParameters params{request.Pop<IAudioRenderer::AudioRendererParameters>()};
|
IAudioRenderer::AudioRendererParameters params{request.Pop<IAudioRenderer::AudioRendererParameters>()};
|
||||||
|
|
||||||
state.logger->Debug("Opening a rev {} IAudioRenderer with sample rate: {}, voice count: {}, effect count: {}", IAudioRenderer::ExtractVersionFromRevision(params.revision), params.sampleRate, params.voiceCount, params.effectCount);
|
Logger::Debug("Opening a rev {} IAudioRenderer with sample rate: {}, voice count: {}, effect count: {}", IAudioRenderer::ExtractVersionFromRevision(params.revision), params.sampleRate, params.voiceCount, params.effectCount);
|
||||||
|
|
||||||
manager.RegisterService(std::make_shared<IAudioRenderer::IAudioRenderer>(state, manager, params), session, response);
|
manager.RegisterService(std::make_shared<IAudioRenderer::IAudioRenderer>(state, manager, params), session, response);
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ namespace skyline::service::audio {
|
|||||||
|
|
||||||
size = util::AlignUp(size, 0x1000);
|
size = util::AlignUp(size, 0x1000);
|
||||||
|
|
||||||
state.logger->Debug("Work buffer size: 0x{:X}", size);
|
Logger::Debug("Work buffer size: 0x{:X}", size);
|
||||||
response.Push<u64>(size);
|
response.Push<u64>(size);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,9 @@ namespace skyline::service {
|
|||||||
ServiceFunctionDescriptor function;
|
ServiceFunctionDescriptor function;
|
||||||
try {
|
try {
|
||||||
function = GetServiceFunction(request.payload->value);
|
function = GetServiceFunction(request.payload->value);
|
||||||
state.logger->DebugNoPrefix("Service: {}", function.name);
|
Logger::DebugNoPrefix("Service: {}", function.name);
|
||||||
} catch (const std::out_of_range &) {
|
} catch (const std::out_of_range &) {
|
||||||
state.logger->Warn("Cannot find function in service '{0}': 0x{1:X} ({1})", GetName(), static_cast<u32>(request.payload->value));
|
Logger::Warn("Cannot find function in service '{0}': 0x{1:X} ({1})", GetName(), static_cast<u32>(request.payload->value));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
TRACE_EVENT("service", perfetto::StaticString{function.name});
|
TRACE_EVENT("service", perfetto::StaticString{function.name});
|
||||||
|
@ -19,7 +19,7 @@ namespace skyline::service::codec {
|
|||||||
u32 workBufferSize{request.Pop<u32>()};
|
u32 workBufferSize{request.Pop<u32>()};
|
||||||
KHandle workBuffer{request.copyHandles.at(0)};
|
KHandle workBuffer{request.copyHandles.at(0)};
|
||||||
|
|
||||||
state.logger->Debug("Creating Opus decoder: Sample rate: {}, Channel count: {}, Work buffer handle: 0x{:X} (Size: 0x{:X})", sampleRate, channelCount, workBuffer, workBufferSize);
|
Logger::Debug("Creating Opus decoder: Sample rate: {}, Channel count: {}, Work buffer handle: 0x{:X} (Size: 0x{:X})", sampleRate, channelCount, workBuffer, workBufferSize);
|
||||||
|
|
||||||
manager.RegisterService(std::make_shared<IHardwareOpusDecoder>(state, manager, sampleRate, channelCount, workBufferSize, workBuffer), session, response);
|
manager.RegisterService(std::make_shared<IHardwareOpusDecoder>(state, manager, sampleRate, channelCount, workBufferSize, workBuffer), session, response);
|
||||||
return {};
|
return {};
|
||||||
|
@ -11,7 +11,7 @@ namespace skyline::service::friends {
|
|||||||
|
|
||||||
Result INotificationService::GetEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result INotificationService::GetEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
KHandle handle{state.process->InsertItem(notificationEvent)};
|
KHandle handle{state.process->InsertItem(notificationEvent)};
|
||||||
state.logger->Debug("Friend Notification Event Handle: 0x{:X}", handle);
|
Logger::Debug("Friend Notification Event Handle: 0x{:X}", handle);
|
||||||
|
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
return {};
|
return {};
|
||||||
|
@ -16,12 +16,12 @@ namespace skyline::service::fssrv {
|
|||||||
auto size{request.Pop<i64>()};
|
auto size{request.Pop<i64>()};
|
||||||
|
|
||||||
if (offset < 0) {
|
if (offset < 0) {
|
||||||
state.logger->Warn("Trying to read a file with a negative offset");
|
Logger::Warn("Trying to read a file with a negative offset");
|
||||||
return result::InvalidOffset;
|
return result::InvalidOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size < 0) {
|
if (size < 0) {
|
||||||
state.logger->Warn("Trying to read a file with a negative size");
|
Logger::Warn("Trying to read a file with a negative size");
|
||||||
return result::InvalidSize;
|
return result::InvalidSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,22 +36,22 @@ namespace skyline::service::fssrv {
|
|||||||
auto size{request.Pop<i64>()};
|
auto size{request.Pop<i64>()};
|
||||||
|
|
||||||
if (offset < 0) {
|
if (offset < 0) {
|
||||||
state.logger->Warn("Trying to write to a file with a negative offset");
|
Logger::Warn("Trying to write to a file with a negative offset");
|
||||||
return result::InvalidOffset;
|
return result::InvalidOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size < 0) {
|
if (size < 0) {
|
||||||
state.logger->Warn("Trying to write to a file with a negative size");
|
Logger::Warn("Trying to write to a file with a negative size");
|
||||||
return result::InvalidSize;
|
return result::InvalidSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.inputBuf.at(0).size() < size) {
|
if (request.inputBuf.at(0).size() < size) {
|
||||||
state.logger->Warn("The input buffer is not large enough to fit the requested size");
|
Logger::Warn("The input buffer is not large enough to fit the requested size");
|
||||||
return result::InvalidSize;
|
return result::InvalidSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (backing->Write(request.inputBuf.at(0), static_cast<size_t>(offset)) != size) {
|
if (backing->Write(request.inputBuf.at(0), static_cast<size_t>(offset)) != size) {
|
||||||
state.logger->Warn("Failed to write all data to the backing");
|
Logger::Warn("Failed to write all data to the backing");
|
||||||
return result::UnexpectedFailure;
|
return result::UnexpectedFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,12 +12,12 @@ namespace skyline::service::fssrv {
|
|||||||
auto size{request.Pop<i64>()};
|
auto size{request.Pop<i64>()};
|
||||||
|
|
||||||
if (offset < 0) {
|
if (offset < 0) {
|
||||||
state.logger->Warn("Trying to read a file with a negative offset");
|
Logger::Warn("Trying to read a file with a negative offset");
|
||||||
return result::InvalidOffset;
|
return result::InvalidOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size < 0) {
|
if (size < 0) {
|
||||||
state.logger->Warn("Trying to read a file with a negative size");
|
Logger::Warn("Trying to read a file with a negative size");
|
||||||
return result::InvalidSize;
|
return result::InvalidSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ namespace skyline::service::glue {
|
|||||||
|
|
||||||
Result ITimeZoneService::GetDeviceLocationNameOperationEventReadableHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result ITimeZoneService::GetDeviceLocationNameOperationEventReadableHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto handle{state.process->InsertItem(locationNameUpdateEvent)};
|
auto handle{state.process->InsertItem(locationNameUpdateEvent)};
|
||||||
state.logger->Debug("Location Name Update Event Handle: 0x{:X}", handle);
|
Logger::Debug("Location Name Update Event Handle: 0x{:X}", handle);
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ namespace skyline::service::hid {
|
|||||||
|
|
||||||
Result IAppletResource::GetSharedMemoryHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IAppletResource::GetSharedMemoryHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto handle{state.process->InsertItem<type::KSharedMemory>(state.input->kHid)};
|
auto handle{state.process->InsertItem<type::KSharedMemory>(state.input->kHid)};
|
||||||
state.logger->Debug("HID Shared Memory Handle: 0x{:X}", handle);
|
Logger::Debug("HID Shared Memory Handle: 0x{:X}", handle);
|
||||||
|
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
return {};
|
return {};
|
||||||
|
@ -31,7 +31,7 @@ namespace skyline::service::hid {
|
|||||||
state.input->npad.styles = styleSet;
|
state.input->npad.styles = styleSet;
|
||||||
state.input->npad.Update();
|
state.input->npad.Update();
|
||||||
|
|
||||||
state.logger->Debug("Controller Support:\nPro-Controller: {}\nJoy-Con: Handheld: {}, Dual: {}, L: {}, R: {}\nGameCube: {}\nPokeBall: {}\nNES: {}, NES Handheld: {}, SNES: {}", static_cast<bool>(styleSet.proController), static_cast<bool>(styleSet.joyconHandheld), static_cast<bool>(styleSet.joyconDual), static_cast<bool>(styleSet.joyconLeft), static_cast<bool>
|
Logger::Debug("Controller Support:\nPro-Controller: {}\nJoy-Con: Handheld: {}, Dual: {}, L: {}, R: {}\nGameCube: {}\nPokeBall: {}\nNES: {}, NES Handheld: {}, SNES: {}", static_cast<bool>(styleSet.proController), static_cast<bool>(styleSet.joyconHandheld), static_cast<bool>(styleSet.joyconDual), static_cast<bool>(styleSet.joyconLeft), static_cast<bool>
|
||||||
(styleSet.joyconRight), static_cast<bool>(styleSet.gamecube), static_cast<bool>(styleSet.palma), static_cast<bool>(styleSet.nes), static_cast<bool>(styleSet.nesHandheld), static_cast<bool>(styleSet.snes));
|
(styleSet.joyconRight), static_cast<bool>(styleSet.gamecube), static_cast<bool>(styleSet.palma), static_cast<bool>(styleSet.nes), static_cast<bool>(styleSet.nesHandheld), static_cast<bool>(styleSet.snes));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ namespace skyline::service::hid {
|
|||||||
auto id{request.Pop<NpadId>()};
|
auto id{request.Pop<NpadId>()};
|
||||||
auto handle{state.process->InsertItem(state.input->npad.at(id).updateEvent)};
|
auto handle{state.process->InsertItem(state.input->npad.at(id).updateEvent)};
|
||||||
|
|
||||||
state.logger->Debug("Npad {} Style Set Update Event Handle: 0x{:X}", id, handle);
|
Logger::Debug("Npad {} Style Set Update Event Handle: 0x{:X}", id, handle);
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ namespace skyline::service::hid {
|
|||||||
auto &device{state.input->npad.at(handle.id)};
|
auto &device{state.input->npad.at(handle.id)};
|
||||||
if (device.type == handle.GetType()) {
|
if (device.type == handle.GetType()) {
|
||||||
const auto &value{request.Pop<NpadVibrationValue>()};
|
const auto &value{request.Pop<NpadVibrationValue>()};
|
||||||
state.logger->Debug("Vibration - Handle: 0x{:02X} (0b{:05b}), Vibration: {:.2f}@{:.2f}Hz, {:.2f}@{:.2f}Hz", static_cast<u8>(handle.id), static_cast<u8>(handle.type), value.amplitudeLow, value.frequencyLow, value.amplitudeHigh, value.frequencyHigh);
|
Logger::Debug("Vibration - Handle: 0x{:02X} (0b{:05b}), Vibration: {:.2f}@{:.2f}Hz, {:.2f}@{:.2f}Hz", static_cast<u8>(handle.id), static_cast<u8>(handle.type), value.amplitudeLow, value.frequencyLow, value.amplitudeHigh, value.frequencyHigh);
|
||||||
device.VibrateSingle(handle.isRight, value);
|
device.VibrateSingle(handle.isRight, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,13 +165,13 @@ namespace skyline::service::hid {
|
|||||||
auto &device{state.input->npad.at(handle.id)};
|
auto &device{state.input->npad.at(handle.id)};
|
||||||
if (device.type == handle.GetType()) {
|
if (device.type == handle.GetType()) {
|
||||||
if (i + 1 != handles.size() && handles[i + 1].id == handle.id && handles[i + 1].isRight && !handle.isRight) {
|
if (i + 1 != handles.size() && handles[i + 1].id == handle.id && handles[i + 1].isRight && !handle.isRight) {
|
||||||
state.logger->Debug("Vibration #{}&{} - Handle: 0x{:02X} (0b{:05b}), Vibration: {:.2f}@{:.2f}Hz, {:.2f}@{:.2f}Hz - {:.2f}@{:.2f}Hz, {:.2f}@{:.2f}Hz", i, i + 1, static_cast<u8>(handle.id), static_cast<u8>(handle.type), values[i].amplitudeLow, values[i].frequencyLow, values[i].amplitudeHigh, values[i].frequencyHigh, values[i + 1].amplitudeLow, values[i + 1].frequencyLow, values[i + 1]
|
Logger::Debug("Vibration #{}&{} - Handle: 0x{:02X} (0b{:05b}), Vibration: {:.2f}@{:.2f}Hz, {:.2f}@{:.2f}Hz - {:.2f}@{:.2f}Hz, {:.2f}@{:.2f}Hz", i, i + 1, static_cast<u8>(handle.id), static_cast<u8>(handle.type), values[i].amplitudeLow, values[i].frequencyLow, values[i].amplitudeHigh, values[i].frequencyHigh, values[i + 1].amplitudeLow, values[i + 1].frequencyLow, values[i + 1]
|
||||||
.amplitudeHigh, values[i + 1].frequencyHigh);
|
.amplitudeHigh, values[i + 1].frequencyHigh);
|
||||||
device.Vibrate(values[i], values[i + 1]);
|
device.Vibrate(values[i], values[i + 1]);
|
||||||
i++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
const auto &value{values[i]};
|
const auto &value{values[i]};
|
||||||
state.logger->Debug("Vibration #{} - Handle: 0x{:02X} (0b{:05b}), Vibration: {:.2f}@{:.2f}Hz, {:.2f}@{:.2f}Hz", i, static_cast<u8>(handle.id), static_cast<u8>(handle.type), value.amplitudeLow, value.frequencyLow, value.amplitudeHigh, value.frequencyHigh);
|
Logger::Debug("Vibration #{} - Handle: 0x{:02X} (0b{:05b}), Vibration: {:.2f}@{:.2f}Hz, {:.2f}@{:.2f}Hz", i, static_cast<u8>(handle.id), static_cast<u8>(handle.type), value.amplitudeLow, value.frequencyLow, value.amplitudeHigh, value.frequencyHigh);
|
||||||
device.VibrateSingle(handle.isRight, value);
|
device.VibrateSingle(handle.isRight, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ namespace skyline::service::hosbinder {
|
|||||||
AndroidStatus GraphicBufferProducer::RequestBuffer(i32 slot, GraphicBuffer *&buffer) {
|
AndroidStatus GraphicBufferProducer::RequestBuffer(i32 slot, GraphicBuffer *&buffer) {
|
||||||
std::scoped_lock lock(mutex);
|
std::scoped_lock lock(mutex);
|
||||||
if (slot < 0 || slot >= queue.size()) [[unlikely]] {
|
if (slot < 0 || slot >= queue.size()) [[unlikely]] {
|
||||||
state.logger->Warn("#{} was out of range", slot);
|
Logger::Warn("#{} was out of range", slot);
|
||||||
return AndroidStatus::BadValue;
|
return AndroidStatus::BadValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,20 +38,20 @@ namespace skyline::service::hosbinder {
|
|||||||
bufferSlot.wasBufferRequested = true;
|
bufferSlot.wasBufferRequested = true;
|
||||||
buffer = bufferSlot.graphicBuffer.get();
|
buffer = bufferSlot.graphicBuffer.get();
|
||||||
|
|
||||||
state.logger->Debug("#{}", slot);
|
Logger::Debug("#{}", slot);
|
||||||
return AndroidStatus::Ok;
|
return AndroidStatus::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidStatus GraphicBufferProducer::SetBufferCount(i32 count) {
|
AndroidStatus GraphicBufferProducer::SetBufferCount(i32 count) {
|
||||||
std::scoped_lock lock(mutex);
|
std::scoped_lock lock(mutex);
|
||||||
if (count >= MaxSlotCount) [[unlikely]] {
|
if (count >= MaxSlotCount) [[unlikely]] {
|
||||||
state.logger->Warn("Setting buffer count too high: {} (Max: {})", count, MaxSlotCount);
|
Logger::Warn("Setting buffer count too high: {} (Max: {})", count, MaxSlotCount);
|
||||||
return AndroidStatus::BadValue;
|
return AndroidStatus::BadValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it{queue.begin()}; it != queue.end(); it++) {
|
for (auto it{queue.begin()}; it != queue.end(); it++) {
|
||||||
if (it->state == BufferState::Dequeued) {
|
if (it->state == BufferState::Dequeued) {
|
||||||
state.logger->Warn("Cannot set buffer count as #{} is dequeued", std::distance(queue.begin(), it));
|
Logger::Warn("Cannot set buffer count as #{} is dequeued", std::distance(queue.begin(), it));
|
||||||
return AndroidStatus::BadValue;
|
return AndroidStatus::BadValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ namespace skyline::service::hosbinder {
|
|||||||
slot.graphicBuffer = nullptr;
|
slot.graphicBuffer = nullptr;
|
||||||
}
|
}
|
||||||
} else if (preallocatedBufferCount < count) {
|
} else if (preallocatedBufferCount < count) {
|
||||||
state.logger->Warn("Setting the active slot count ({}) higher than the amount of slots with preallocated buffers ({})", count, preallocatedBufferCount);
|
Logger::Warn("Setting the active slot count ({}) higher than the amount of slots with preallocated buffers ({})", count, preallocatedBufferCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
activeSlotCount = static_cast<u8>(count);
|
activeSlotCount = static_cast<u8>(count);
|
||||||
@ -85,7 +85,7 @@ namespace skyline::service::hosbinder {
|
|||||||
|
|
||||||
AndroidStatus GraphicBufferProducer::DequeueBuffer(bool async, u32 width, u32 height, AndroidPixelFormat format, u32 usage, i32 &slot, std::optional<AndroidFence> &fence) {
|
AndroidStatus GraphicBufferProducer::DequeueBuffer(bool async, u32 width, u32 height, AndroidPixelFormat format, u32 usage, i32 &slot, std::optional<AndroidFence> &fence) {
|
||||||
if ((width && !height) || (!width && height)) {
|
if ((width && !height) || (!width && height)) {
|
||||||
state.logger->Warn("Dimensions {}x{} should be uniformly zero or non-zero", width, height);
|
Logger::Warn("Dimensions {}x{} should be uniformly zero or non-zero", width, height);
|
||||||
return AndroidStatus::BadValue;
|
return AndroidStatus::BadValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,14 +114,14 @@ namespace skyline::service::hosbinder {
|
|||||||
} else if (async) {
|
} else if (async) {
|
||||||
return AndroidStatus::WouldBlock;
|
return AndroidStatus::WouldBlock;
|
||||||
} else if (dequeuedSlotCount == queue.size()) {
|
} else if (dequeuedSlotCount == queue.size()) {
|
||||||
state.logger->Warn("Client attempting to dequeue more buffers when all buffers are dequeued by the client: {}", dequeuedSlotCount);
|
Logger::Warn("Client attempting to dequeue more buffers when all buffers are dequeued by the client: {}", dequeuedSlotCount);
|
||||||
return AndroidStatus::InvalidOperation;
|
return AndroidStatus::InvalidOperation;
|
||||||
} else {
|
} else {
|
||||||
size_t index{};
|
size_t index{};
|
||||||
std::string bufferString;
|
std::string bufferString;
|
||||||
for (auto &bufferSlot : queue)
|
for (auto &bufferSlot : queue)
|
||||||
bufferString += util::Format("\n#{} - State: {}, Has Graphic Buffer: {}, Frame Number: {}", ++index, ToString(bufferSlot.state), bufferSlot.graphicBuffer != nullptr, bufferSlot.frameNumber);
|
bufferString += util::Format("\n#{} - State: {}, Has Graphic Buffer: {}, Frame Number: {}", ++index, ToString(bufferSlot.state), bufferSlot.graphicBuffer != nullptr, bufferSlot.frameNumber);
|
||||||
state.logger->Warn("Cannot find any free buffers to dequeue:{}", bufferString);
|
Logger::Warn("Cannot find any free buffers to dequeue:{}", bufferString);
|
||||||
return AndroidStatus::InvalidOperation;
|
return AndroidStatus::InvalidOperation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ namespace skyline::service::hosbinder {
|
|||||||
auto &handle{buffer->graphicBuffer->graphicHandle};
|
auto &handle{buffer->graphicBuffer->graphicHandle};
|
||||||
auto &surface{handle.surfaces.front()};
|
auto &surface{handle.surfaces.front()};
|
||||||
if (handle.format != format || surface.width != width || surface.height != height || (buffer->graphicBuffer->usage & usage) != usage) {
|
if (handle.format != format || surface.width != width || surface.height != height || (buffer->graphicBuffer->usage & usage) != usage) {
|
||||||
state.logger->Warn("Buffer which has been dequeued isn't compatible with the supplied parameters: Dimensions: {}x{}={}x{}, Format: {}={}, Usage: 0x{:X}=0x{:X}", width, height, surface.width, surface.height, ToString(format), ToString(buffer->graphicBuffer->format), usage, buffer->graphicBuffer->usage);
|
Logger::Warn("Buffer which has been dequeued isn't compatible with the supplied parameters: Dimensions: {}x{}={}x{}, Format: {}={}, Usage: 0x{:X}=0x{:X}", width, height, surface.width, surface.height, ToString(format), ToString(buffer->graphicBuffer->format), usage, buffer->graphicBuffer->usage);
|
||||||
// Nintendo doesn't deallocate the slot which was picked in here and reallocate it as a compatible buffer
|
// Nintendo doesn't deallocate the slot which was picked in here and reallocate it as a compatible buffer
|
||||||
// This is related to the comment above, Nintendo only allocates buffers on the client side
|
// This is related to the comment above, Nintendo only allocates buffers on the client side
|
||||||
return AndroidStatus::NoInit;
|
return AndroidStatus::NoInit;
|
||||||
@ -146,23 +146,23 @@ namespace skyline::service::hosbinder {
|
|||||||
buffer->state = BufferState::Dequeued;
|
buffer->state = BufferState::Dequeued;
|
||||||
fence = AndroidFence{}; // We just let the presentation engine return a buffer which is ready to be written into, there is no need for further synchronization
|
fence = AndroidFence{}; // We just let the presentation engine return a buffer which is ready to be written into, there is no need for further synchronization
|
||||||
|
|
||||||
state.logger->Debug("#{} - Dimensions: {}x{}, Format: {}, Usage: 0x{:X}, Is Async: {}", slot, width, height, ToString(format), usage, async);
|
Logger::Debug("#{} - Dimensions: {}x{}, Format: {}, Usage: 0x{:X}, Is Async: {}", slot, width, height, ToString(format), usage, async);
|
||||||
return AndroidStatus::Ok;
|
return AndroidStatus::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidStatus GraphicBufferProducer::DetachBuffer(i32 slot) {
|
AndroidStatus GraphicBufferProducer::DetachBuffer(i32 slot) {
|
||||||
std::scoped_lock lock(mutex);
|
std::scoped_lock lock(mutex);
|
||||||
if (slot < 0 || slot >= queue.size()) [[unlikely]] {
|
if (slot < 0 || slot >= queue.size()) [[unlikely]] {
|
||||||
state.logger->Warn("#{} was out of range", slot);
|
Logger::Warn("#{} was out of range", slot);
|
||||||
return AndroidStatus::BadValue;
|
return AndroidStatus::BadValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &bufferSlot{queue[static_cast<size_t>(slot)]};
|
auto &bufferSlot{queue[static_cast<size_t>(slot)]};
|
||||||
if (bufferSlot.state != BufferState::Dequeued) [[unlikely]] {
|
if (bufferSlot.state != BufferState::Dequeued) [[unlikely]] {
|
||||||
state.logger->Warn("#{} was '{}' instead of being dequeued", slot, ToString(bufferSlot.state));
|
Logger::Warn("#{} was '{}' instead of being dequeued", slot, ToString(bufferSlot.state));
|
||||||
return AndroidStatus::BadValue;
|
return AndroidStatus::BadValue;
|
||||||
} else if (!bufferSlot.wasBufferRequested) [[unlikely]] {
|
} else if (!bufferSlot.wasBufferRequested) [[unlikely]] {
|
||||||
state.logger->Warn("#{} was detached prior to being requested", slot);
|
Logger::Warn("#{} was detached prior to being requested", slot);
|
||||||
return AndroidStatus::BadValue;
|
return AndroidStatus::BadValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ namespace skyline::service::hosbinder {
|
|||||||
|
|
||||||
bufferEvent->Signal();
|
bufferEvent->Signal();
|
||||||
|
|
||||||
state.logger->Debug("#{}", slot);
|
Logger::Debug("#{}", slot);
|
||||||
return AndroidStatus::Ok;
|
return AndroidStatus::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ namespace skyline::service::hosbinder {
|
|||||||
|
|
||||||
bufferEvent->Signal();
|
bufferEvent->Signal();
|
||||||
|
|
||||||
state.logger->Debug("#{}", std::distance(queue.begin(), bufferSlot));
|
Logger::Debug("#{}", std::distance(queue.begin(), bufferSlot));
|
||||||
return AndroidStatus::Ok;
|
return AndroidStatus::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ namespace skyline::service::hosbinder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bufferSlot == queue.end()) {
|
if (bufferSlot == queue.end()) {
|
||||||
state.logger->Warn("Could not find any free slots to attach the graphic buffer to");
|
Logger::Warn("Could not find any free slots to attach the graphic buffer to");
|
||||||
return AndroidStatus::NoMemory;
|
return AndroidStatus::NoMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ namespace skyline::service::hosbinder {
|
|||||||
preallocatedBufferCount = static_cast<u8>(std::count_if(queue.begin(), queue.end(), [](const auto &slot) { return slot.graphicBuffer && slot.isPreallocated; }));
|
preallocatedBufferCount = static_cast<u8>(std::count_if(queue.begin(), queue.end(), [](const auto &slot) { return slot.graphicBuffer && slot.isPreallocated; }));
|
||||||
activeSlotCount = static_cast<u8>(std::count_if(queue.begin(), queue.end(), [](const auto &slot) { return slot.graphicBuffer != nullptr; }));
|
activeSlotCount = static_cast<u8>(std::count_if(queue.begin(), queue.end(), [](const auto &slot) { return slot.graphicBuffer != nullptr; }));
|
||||||
|
|
||||||
state.logger->Debug("#{} - Dimensions: {}x{} [Stride: {}], Format: {}, Layout: {}, {}: {}, Usage: 0x{:X}, NvMap {}: {}, Buffer Start/End: 0x{:X} -> 0x{:X}", slot, surface.width, surface.height, handle.stride, ToString(handle.format), ToString(surface.layout), surface.layout == NvSurfaceLayout::Blocklinear ? "Block Height" : "Pitch", surface.layout == NvSurfaceLayout::Blocklinear ? 1U << surface.blockHeightLog2 : surface.pitch, graphicBuffer.usage, surface.nvmapHandle ? "Handle" : "ID", surface.nvmapHandle ? surface.nvmapHandle : handle.nvmapId, surface.offset, surface.offset + surface.size);
|
Logger::Debug("#{} - Dimensions: {}x{} [Stride: {}], Format: {}, Layout: {}, {}: {}, Usage: 0x{:X}, NvMap {}: {}, Buffer Start/End: 0x{:X} -> 0x{:X}", slot, surface.width, surface.height, handle.stride, ToString(handle.format), ToString(surface.layout), surface.layout == NvSurfaceLayout::Blocklinear ? "Block Height" : "Pitch", surface.layout == NvSurfaceLayout::Blocklinear ? 1U << surface.blockHeightLog2 : surface.pitch, graphicBuffer.usage, surface.nvmapHandle ? "Handle" : "ID", surface.nvmapHandle ? surface.nvmapHandle : handle.nvmapId, surface.offset, surface.offset + surface.size);
|
||||||
return AndroidStatus::Ok;
|
return AndroidStatus::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,28 +263,28 @@ namespace skyline::service::hosbinder {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
state.logger->Warn("{} is not a valid scaling mode", static_cast<u32>(scalingMode));
|
Logger::Warn("{} is not a valid scaling mode", static_cast<u32>(scalingMode));
|
||||||
return AndroidStatus::BadValue;
|
return AndroidStatus::BadValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::scoped_lock lock(mutex);
|
std::scoped_lock lock(mutex);
|
||||||
if (slot < 0 || slot >= queue.size()) [[unlikely]] {
|
if (slot < 0 || slot >= queue.size()) [[unlikely]] {
|
||||||
state.logger->Warn("#{} was out of range", slot);
|
Logger::Warn("#{} was out of range", slot);
|
||||||
return AndroidStatus::BadValue;
|
return AndroidStatus::BadValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &buffer{queue[static_cast<size_t>(slot)]};
|
auto &buffer{queue[static_cast<size_t>(slot)]};
|
||||||
if (buffer.state != BufferState::Dequeued) [[unlikely]] {
|
if (buffer.state != BufferState::Dequeued) [[unlikely]] {
|
||||||
state.logger->Warn("#{} was '{}' instead of being dequeued", slot, ToString(buffer.state));
|
Logger::Warn("#{} was '{}' instead of being dequeued", slot, ToString(buffer.state));
|
||||||
return AndroidStatus::BadValue;
|
return AndroidStatus::BadValue;
|
||||||
} else if (!buffer.wasBufferRequested) [[unlikely]] {
|
} else if (!buffer.wasBufferRequested) [[unlikely]] {
|
||||||
state.logger->Warn("#{} was queued prior to being requested", slot);
|
Logger::Warn("#{} was queued prior to being requested", slot);
|
||||||
buffer.wasBufferRequested = true; // Switch ignores this and doesn't return an error, certain homebrew ends up depending on this behavior
|
buffer.wasBufferRequested = true; // Switch ignores this and doesn't return an error, certain homebrew ends up depending on this behavior
|
||||||
}
|
}
|
||||||
|
|
||||||
auto graphicBuffer{*buffer.graphicBuffer};
|
auto graphicBuffer{*buffer.graphicBuffer};
|
||||||
if (graphicBuffer.width < (crop.right - crop.left) || graphicBuffer.height < (crop.bottom - crop.top)) [[unlikely]] {
|
if (graphicBuffer.width < (crop.right - crop.left) || graphicBuffer.height < (crop.bottom - crop.top)) [[unlikely]] {
|
||||||
state.logger->Warn("Crop was out of range for surface buffer: ({}-{})x({}-{}) > {}x{}", crop.left, crop.right, crop.top, crop.bottom, graphicBuffer.width, graphicBuffer.height);
|
Logger::Warn("Crop was out of range for surface buffer: ({}-{})x({}-{}) > {}x{}", crop.left, crop.right, crop.top, crop.bottom, graphicBuffer.width, graphicBuffer.height);
|
||||||
return AndroidStatus::BadValue;
|
return AndroidStatus::BadValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,20 +400,20 @@ namespace skyline::service::hosbinder {
|
|||||||
transformHint = state.gpu->presentation.GetTransformHint();
|
transformHint = state.gpu->presentation.GetTransformHint();
|
||||||
pendingBufferCount = GetPendingBufferCount();
|
pendingBufferCount = GetPendingBufferCount();
|
||||||
|
|
||||||
state.logger->Debug("#{} - {}Timestamp: {}, Crop: ({}-{})x({}-{}), Scale Mode: {}, Transform: {} [Sticky: {}], Swap Interval: {}, Is Async: {}", slot, isAutoTimestamp ? "Auto " : "", timestamp, crop.left, crop.right, crop.top, crop.bottom, ToString(scalingMode), ToString(transform), ToString(stickyTransform), swapInterval, async);
|
Logger::Debug("#{} - {}Timestamp: {}, Crop: ({}-{})x({}-{}), Scale Mode: {}, Transform: {} [Sticky: {}], Swap Interval: {}, Is Async: {}", slot, isAutoTimestamp ? "Auto " : "", timestamp, crop.left, crop.right, crop.top, crop.bottom, ToString(scalingMode), ToString(transform), ToString(stickyTransform), swapInterval, async);
|
||||||
return AndroidStatus::Ok;
|
return AndroidStatus::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicBufferProducer::CancelBuffer(i32 slot, const AndroidFence &fence) {
|
void GraphicBufferProducer::CancelBuffer(i32 slot, const AndroidFence &fence) {
|
||||||
std::scoped_lock lock(mutex);
|
std::scoped_lock lock(mutex);
|
||||||
if (slot < 0 || slot >= queue.size()) [[unlikely]] {
|
if (slot < 0 || slot >= queue.size()) [[unlikely]] {
|
||||||
state.logger->Warn("#{} was out of range", slot);
|
Logger::Warn("#{} was out of range", slot);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &buffer{queue[static_cast<size_t>(slot)]};
|
auto &buffer{queue[static_cast<size_t>(slot)]};
|
||||||
if (buffer.state != BufferState::Dequeued) [[unlikely]] {
|
if (buffer.state != BufferState::Dequeued) [[unlikely]] {
|
||||||
state.logger->Warn("#{} is not owned by the producer as it is '{}' instead of being dequeued", slot, ToString(buffer.state));
|
Logger::Warn("#{} is not owned by the producer as it is '{}' instead of being dequeued", slot, ToString(buffer.state));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,7 +423,7 @@ namespace skyline::service::hosbinder {
|
|||||||
buffer.frameNumber = 0;
|
buffer.frameNumber = 0;
|
||||||
bufferEvent->Signal();
|
bufferEvent->Signal();
|
||||||
|
|
||||||
state.logger->Debug("#{}", slot);
|
Logger::Debug("#{}", slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidStatus GraphicBufferProducer::Query(NativeWindowQuery query, u32 &out) {
|
AndroidStatus GraphicBufferProducer::Query(NativeWindowQuery query, u32 &out) {
|
||||||
@ -467,18 +467,18 @@ namespace skyline::service::hosbinder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
state.logger->Warn("Query not supported: {}", static_cast<u32>(query));
|
Logger::Warn("Query not supported: {}", static_cast<u32>(query));
|
||||||
return AndroidStatus::BadValue;
|
return AndroidStatus::BadValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.logger->Debug("{}: {}", ToString(query), out);
|
Logger::Debug("{}: {}", ToString(query), out);
|
||||||
return AndroidStatus::Ok;
|
return AndroidStatus::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidStatus GraphicBufferProducer::Connect(NativeWindowApi api, bool producerControlledByApp, u32 &width, u32 &height, NativeWindowTransform &transformHint, u32 &pendingBufferCount) {
|
AndroidStatus GraphicBufferProducer::Connect(NativeWindowApi api, bool producerControlledByApp, u32 &width, u32 &height, NativeWindowTransform &transformHint, u32 &pendingBufferCount) {
|
||||||
std::scoped_lock lock(mutex);
|
std::scoped_lock lock(mutex);
|
||||||
if (connectedApi != NativeWindowApi::None) [[unlikely]] {
|
if (connectedApi != NativeWindowApi::None) [[unlikely]] {
|
||||||
state.logger->Warn("Already connected to API '{}' while connection to '{}' is requested", ToString(connectedApi), ToString(api));
|
Logger::Warn("Already connected to API '{}' while connection to '{}' is requested", ToString(connectedApi), ToString(api));
|
||||||
return AndroidStatus::BadValue;
|
return AndroidStatus::BadValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,7 +490,7 @@ namespace skyline::service::hosbinder {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
state.logger->Warn("Unknown API: {}", static_cast<u32>(api));
|
Logger::Warn("Unknown API: {}", static_cast<u32>(api));
|
||||||
return AndroidStatus::BadValue;
|
return AndroidStatus::BadValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ namespace skyline::service::hosbinder {
|
|||||||
transformHint = state.gpu->presentation.GetTransformHint();
|
transformHint = state.gpu->presentation.GetTransformHint();
|
||||||
pendingBufferCount = GetPendingBufferCount();
|
pendingBufferCount = GetPendingBufferCount();
|
||||||
|
|
||||||
state.logger->Debug("API: {}, Producer Controlled By App: {}, Default Dimensions: {}x{}, Transform Hint: {}, Pending Buffer Count: {}", ToString(api), producerControlledByApp, width, height, ToString(transformHint), pendingBufferCount);
|
Logger::Debug("API: {}, Producer Controlled By App: {}, Default Dimensions: {}x{}, Transform Hint: {}, Pending Buffer Count: {}", ToString(api), producerControlledByApp, width, height, ToString(transformHint), pendingBufferCount);
|
||||||
return AndroidStatus::Ok;
|
return AndroidStatus::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,12 +515,12 @@ namespace skyline::service::hosbinder {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
state.logger->Warn("Unknown API: {}", static_cast<u32>(api));
|
Logger::Warn("Unknown API: {}", static_cast<u32>(api));
|
||||||
return AndroidStatus::BadValue;
|
return AndroidStatus::BadValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (api != connectedApi) {
|
if (api != connectedApi) {
|
||||||
state.logger->Warn("Disconnecting from API '{}' while connected to '{}'", ToString(api), ToString(connectedApi));
|
Logger::Warn("Disconnecting from API '{}' while connected to '{}'", ToString(api), ToString(connectedApi));
|
||||||
return AndroidStatus::BadValue;
|
return AndroidStatus::BadValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,14 +533,14 @@ namespace skyline::service::hosbinder {
|
|||||||
slot.graphicBuffer = nullptr;
|
slot.graphicBuffer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.logger->Debug("API: {}", ToString(api));
|
Logger::Debug("API: {}", ToString(api));
|
||||||
return AndroidStatus::Ok;
|
return AndroidStatus::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidStatus GraphicBufferProducer::SetPreallocatedBuffer(i32 slot, const GraphicBuffer *graphicBuffer) {
|
AndroidStatus GraphicBufferProducer::SetPreallocatedBuffer(i32 slot, const GraphicBuffer *graphicBuffer) {
|
||||||
std::scoped_lock lock(mutex);
|
std::scoped_lock lock(mutex);
|
||||||
if (slot < 0 || slot >= MaxSlotCount) [[unlikely]] {
|
if (slot < 0 || slot >= MaxSlotCount) [[unlikely]] {
|
||||||
state.logger->Warn("#{} was out of range", slot);
|
Logger::Warn("#{} was out of range", slot);
|
||||||
return AndroidStatus::BadValue;
|
return AndroidStatus::BadValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,9 +573,9 @@ namespace skyline::service::hosbinder {
|
|||||||
else if (surface.layout == NvSurfaceLayout::Tiled)
|
else if (surface.layout == NvSurfaceLayout::Tiled)
|
||||||
throw exception("Legacy 16Bx16 tiled surfaces are not supported");
|
throw exception("Legacy 16Bx16 tiled surfaces are not supported");
|
||||||
|
|
||||||
state.logger->Debug("#{} - Dimensions: {}x{} [Stride: {}], Format: {}, Layout: {}, {}: {}, Usage: 0x{:X}, NvMap {}: {}, Buffer Start/End: 0x{:X} -> 0x{:X}", slot, surface.width, surface.height, handle.stride, ToString(handle.format), ToString(surface.layout), surface.layout == NvSurfaceLayout::Blocklinear ? "Block Height" : "Pitch", surface.layout == NvSurfaceLayout::Blocklinear ? 1U << surface.blockHeightLog2 : surface.pitch, graphicBuffer->usage, surface.nvmapHandle ? "Handle" : "ID", surface.nvmapHandle ? surface.nvmapHandle : handle.nvmapId, surface.offset, surface.offset + surface.size);
|
Logger::Debug("#{} - Dimensions: {}x{} [Stride: {}], Format: {}, Layout: {}, {}: {}, Usage: 0x{:X}, NvMap {}: {}, Buffer Start/End: 0x{:X} -> 0x{:X}", slot, surface.width, surface.height, handle.stride, ToString(handle.format), ToString(surface.layout), surface.layout == NvSurfaceLayout::Blocklinear ? "Block Height" : "Pitch", surface.layout == NvSurfaceLayout::Blocklinear ? 1U << surface.blockHeightLog2 : surface.pitch, graphicBuffer->usage, surface.nvmapHandle ? "Handle" : "ID", surface.nvmapHandle ? surface.nvmapHandle : handle.nvmapId, surface.offset, surface.offset + surface.size);
|
||||||
} else {
|
} else {
|
||||||
state.logger->Debug("#{} - No GraphicBuffer", slot);
|
Logger::Debug("#{} - No GraphicBuffer", slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
preallocatedBufferCount = static_cast<u8>(std::count_if(queue.begin(), queue.end(), [](const BufferSlot &slot) { return slot.graphicBuffer && slot.isPreallocated; }));
|
preallocatedBufferCount = static_cast<u8>(std::count_if(queue.begin(), queue.end(), [](const BufferSlot &slot) { return slot.graphicBuffer && slot.isPreallocated; }));
|
||||||
|
@ -45,7 +45,7 @@ namespace skyline::service::hosbinder {
|
|||||||
layerStrongReferenceCount = value;
|
layerStrongReferenceCount = value;
|
||||||
|
|
||||||
if (layerStrongReferenceCount < 0) {
|
if (layerStrongReferenceCount < 0) {
|
||||||
state.logger->Warn("Strong reference count is lower than 0: {} + {} = {}", (layerStrongReferenceCount - value), value, layerStrongReferenceCount);
|
Logger::Warn("Strong reference count is lower than 0: {} + {} = {}", (layerStrongReferenceCount - value), value, layerStrongReferenceCount);
|
||||||
layerStrongReferenceCount = 0;
|
layerStrongReferenceCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ namespace skyline::service::hosbinder {
|
|||||||
layerWeakReferenceCount += value;
|
layerWeakReferenceCount += value;
|
||||||
|
|
||||||
if (layerWeakReferenceCount < 0) {
|
if (layerWeakReferenceCount < 0) {
|
||||||
state.logger->Warn("Weak reference count is lower than 0: {} + {} = {}", (layerWeakReferenceCount - value), value, layerWeakReferenceCount);
|
Logger::Warn("Weak reference count is lower than 0: {} + {} = {}", (layerWeakReferenceCount - value), value, layerWeakReferenceCount);
|
||||||
layerWeakReferenceCount = 0;
|
layerWeakReferenceCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ namespace skyline::service::hosbinder {
|
|||||||
layer.reset();
|
layer.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
state.logger->Debug("Reference Change: {} {} reference (S{} W{})", value, isStrong ? "strong" : "weak", layerStrongReferenceCount, layerWeakReferenceCount);
|
Logger::Debug("Reference Change: {} {} reference (S{} W{})", value, isStrong ? "strong" : "weak", layerStrongReferenceCount, layerWeakReferenceCount);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ namespace skyline::service::hosbinder {
|
|||||||
throw exception("Getting unknown handle from binder object: 0x{:X}", handleId);
|
throw exception("Getting unknown handle from binder object: 0x{:X}", handleId);
|
||||||
|
|
||||||
KHandle handle{state.process->InsertItem(layer->bufferEvent)};
|
KHandle handle{state.process->InsertItem(layer->bufferEvent)};
|
||||||
state.logger->Debug("Display Buffer Event Handle: 0x{:X}", handle);
|
Logger::Debug("Display Buffer Event Handle: 0x{:X}", handle);
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
@ -122,7 +122,7 @@ namespace skyline::service::lm {
|
|||||||
if (logMessage.dropCount)
|
if (logMessage.dropCount)
|
||||||
message << " (Dropped Messages: " << logMessage.time << ')';
|
message << " (Dropped Messages: " << logMessage.time << ')';
|
||||||
|
|
||||||
state.logger->Write(hostLevel, message.str());
|
Logger::Write(hostLevel, message.str());
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -53,13 +53,13 @@ namespace skyline::service::mmnv {
|
|||||||
for (auto &req : requests) {
|
for (auto &req : requests) {
|
||||||
if (req && req->module == module) {
|
if (req && req->module == module) {
|
||||||
req->freqHz = freqHz;
|
req->freqHz = freqHz;
|
||||||
state.logger->Debug("Set frequency for module {}: {} Hz", static_cast<u32>(module), freqHz);
|
Logger::Debug("Set frequency for module {}: {} Hz", static_cast<u32>(module), freqHz);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This doesn't return any errors in HOS
|
// This doesn't return any errors in HOS
|
||||||
state.logger->Warn("Tried to set frequency to {} Hz for unregistered module {}", freqHz, static_cast<u32>(module));
|
Logger::Warn("Tried to set frequency to {} Hz for unregistered module {}", freqHz, static_cast<u32>(module));
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -70,14 +70,14 @@ namespace skyline::service::mmnv {
|
|||||||
std::lock_guard lock(requestsMutex);
|
std::lock_guard lock(requestsMutex);
|
||||||
for (auto &req : requests) {
|
for (auto &req : requests) {
|
||||||
if (req && req->module == module) {
|
if (req && req->module == module) {
|
||||||
state.logger->Debug("Get frequency for module {}: {} Hz", static_cast<u32>(module), req->freqHz);
|
Logger::Debug("Get frequency for module {}: {} Hz", static_cast<u32>(module), req->freqHz);
|
||||||
response.Push<u32>(req->freqHz);
|
response.Push<u32>(req->freqHz);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This doesn't return any errors in HOS
|
// This doesn't return any errors in HOS
|
||||||
state.logger->Warn("Tried to get frequency of unregistered module {}", static_cast<u32>(module));
|
Logger::Warn("Tried to get frequency of unregistered module {}", static_cast<u32>(module));
|
||||||
response.Push<u32>(0);
|
response.Push<u32>(0);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -114,13 +114,13 @@ namespace skyline::service::mmnv {
|
|||||||
auto &req{requests[id]};
|
auto &req{requests[id]};
|
||||||
if (req) {
|
if (req) {
|
||||||
req->freqHz = freqHz;
|
req->freqHz = freqHz;
|
||||||
state.logger->Debug("Set frequency for request {}: {} Hz", id, freqHz);
|
Logger::Debug("Set frequency for request {}: {} Hz", id, freqHz);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This doesn't return any errors in HOS
|
// This doesn't return any errors in HOS
|
||||||
state.logger->Warn("Tried to set frequency for unregistered request {}", id);
|
Logger::Warn("Tried to set frequency for unregistered request {}", id);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,14 +131,14 @@ namespace skyline::service::mmnv {
|
|||||||
if (id < requests.size()) {
|
if (id < requests.size()) {
|
||||||
auto &req{requests[id]};
|
auto &req{requests[id]};
|
||||||
if (req) {
|
if (req) {
|
||||||
state.logger->Debug("Get frequency for request {}: {} Hz", id, req->freqHz);
|
Logger::Debug("Get frequency for request {}: {} Hz", id, req->freqHz);
|
||||||
response.Push<u32>(req->freqHz);
|
response.Push<u32>(req->freqHz);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This doesn't return any errors in HOS
|
// This doesn't return any errors in HOS
|
||||||
state.logger->Warn("Tried to get frequency of unregistered request {}", id);
|
Logger::Warn("Tried to get frequency of unregistered request {}", id);
|
||||||
response.Push<u32>(0);
|
response.Push<u32>(0);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,11 @@ namespace skyline::service::nifm {
|
|||||||
|
|
||||||
Result IRequest::GetSystemEventReadableHandles(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IRequest::GetSystemEventReadableHandles(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto handle{state.process->InsertItem(event0)};
|
auto handle{state.process->InsertItem(event0)};
|
||||||
state.logger->Debug("Request Event 0 Handle: 0x{:X}", handle);
|
Logger::Debug("Request Event 0 Handle: 0x{:X}", handle);
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
|
|
||||||
handle = state.process->InsertItem(event1);
|
handle = state.process->InsertItem(event1);
|
||||||
state.logger->Debug("Request Event 1 Handle: 0x{:X}", handle);
|
Logger::Debug("Request Event 1 Handle: 0x{:X}", handle);
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#define NVRESULT(x) [&response, this](NvResult err) { \
|
#define NVRESULT(x) [&response, this](NvResult err) { \
|
||||||
if (err != NvResult::Success) \
|
if (err != NvResult::Success) \
|
||||||
state.logger->Debug("IOCTL Failed: 0x{:X}", err); \
|
Logger::Debug("IOCTL Failed: 0x{:X}", err); \
|
||||||
\
|
\
|
||||||
response.Push<NvResult>(err); \
|
response.Push<NvResult>(err); \
|
||||||
return Result{}; \
|
return Result{}; \
|
||||||
@ -73,7 +73,7 @@ namespace skyline::service::nvdrv {
|
|||||||
|
|
||||||
Result INvDrvServices::Close(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result INvDrvServices::Close(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto fd{request.Pop<FileDescriptor>()};
|
auto fd{request.Pop<FileDescriptor>()};
|
||||||
state.logger->Debug("Closing NVDRV device ({})", fd);
|
Logger::Debug("Closing NVDRV device ({})", fd);
|
||||||
|
|
||||||
driver.CloseDevice(fd);
|
driver.CloseDevice(fd);
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ namespace skyline::service::nvdrv {
|
|||||||
if (event != nullptr) {
|
if (event != nullptr) {
|
||||||
auto handle{state.process->InsertItem<type::KEvent>(event)};
|
auto handle{state.process->InsertItem<type::KEvent>(event)};
|
||||||
|
|
||||||
state.logger->Debug("FD: {}, Event ID: {}, Handle: 0x{:X}", fd, eventId, handle);
|
Logger::Debug("FD: {}, Event ID: {}, Handle: 0x{:X}", fd, eventId, handle);
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
|
|
||||||
return NVRESULT(NvResult::Success);
|
return NVRESULT(NvResult::Success);
|
||||||
|
@ -164,7 +164,7 @@ namespace skyline::service::nvdrv::core {
|
|||||||
|
|
||||||
std::scoped_lock lock(handleDesc->mutex);
|
std::scoped_lock lock(handleDesc->mutex);
|
||||||
if (--handleDesc->pins < 0) {
|
if (--handleDesc->pins < 0) {
|
||||||
state.logger->Warn("Pin count imbalance detected!");
|
Logger::Warn("Pin count imbalance detected!");
|
||||||
} else if (!handleDesc->pins) {
|
} else if (!handleDesc->pins) {
|
||||||
std::scoped_lock queueLock(unmapQueueLock);
|
std::scoped_lock queueLock(unmapQueueLock);
|
||||||
|
|
||||||
@ -184,10 +184,10 @@ namespace skyline::service::nvdrv::core {
|
|||||||
|
|
||||||
if (internalSession) {
|
if (internalSession) {
|
||||||
if (--handleDesc->internalDupes < 0)
|
if (--handleDesc->internalDupes < 0)
|
||||||
state.logger->Warn("Internal duplicate count imbalance detected!");
|
Logger::Warn("Internal duplicate count imbalance detected!");
|
||||||
} else {
|
} else {
|
||||||
if (--handleDesc->dupes < 0) {
|
if (--handleDesc->dupes < 0) {
|
||||||
state.logger->Warn("User duplicate count imbalance detected!");
|
Logger::Warn("User duplicate count imbalance detected!");
|
||||||
} else if (handleDesc->dupes == 0) {
|
} else if (handleDesc->dupes == 0) {
|
||||||
// Force unmap the handle
|
// Force unmap the handle
|
||||||
if (handleDesc->pinVirtAddress) {
|
if (handleDesc->pinVirtAddress) {
|
||||||
@ -200,11 +200,11 @@ namespace skyline::service::nvdrv::core {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to remove the shared ptr to the handle from the map, if nothing else is using the handle
|
// Try to remove the shared ptr to the handle from the map, if nothing else is using the handle
|
||||||
// then it will now be freed when `handleDesc` goes out of scope
|
// then it will now be freed when `h` goes out of scope
|
||||||
if (TryRemoveHandle(*handleDesc))
|
if (TryRemoveHandle(*handleDesc))
|
||||||
state.logger->Debug("Removed nvmap handle: {}", handle);
|
Logger::Debug("Removed nvmap handle: {}", handle);
|
||||||
else
|
else
|
||||||
state.logger->Debug("Tried to free nvmap handle: {} but didn't as it still has duplicates", handle);
|
Logger::Debug("Tried to free nvmap handle: {} but didn't as it still has duplicates", handle);
|
||||||
|
|
||||||
freeInfo = {
|
freeInfo = {
|
||||||
.address = handleDesc->address,
|
.address = handleDesc->address,
|
||||||
@ -217,7 +217,7 @@ namespace skyline::service::nvdrv::core {
|
|||||||
|
|
||||||
// Handle hasn't been freed from memory, set address to 0 to mark that the handle wasn't freed
|
// Handle hasn't been freed from memory, set address to 0 to mark that the handle wasn't freed
|
||||||
if (!hWeak.expired()) {
|
if (!hWeak.expired()) {
|
||||||
state.logger->Debug("nvmap handle: {} wasn't freed as it is still in use", handle);
|
Logger::Debug("nvmap handle: {} wasn't freed as it is still in use", handle);
|
||||||
freeInfo.address = 0;
|
freeInfo.address = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,14 +32,14 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
std::scoped_lock channelLock(gpuCh.channelMutex);
|
std::scoped_lock channelLock(gpuCh.channelMutex);
|
||||||
|
|
||||||
if (gpuCh.asCtx) {
|
if (gpuCh.asCtx) {
|
||||||
state.logger->Warn("Attempting to bind multiple ASes to a single GPU channel");
|
Logger::Warn("Attempting to bind multiple ASes to a single GPU channel");
|
||||||
return PosixResult::InvalidArgument;
|
return PosixResult::InvalidArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpuCh.asCtx = asCtx;
|
gpuCh.asCtx = asCtx;
|
||||||
gpuCh.asAllocator = vm.smallPageAllocator;
|
gpuCh.asAllocator = vm.smallPageAllocator;
|
||||||
} catch (const std::out_of_range &e) {
|
} catch (const std::out_of_range &e) {
|
||||||
state.logger->Warn("Attempting to bind AS to an invalid channel: {}", channelFd);
|
Logger::Warn("Attempting to bind AS to an invalid channel: {}", channelFd);
|
||||||
return PosixResult::InvalidArgument;
|
return PosixResult::InvalidArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PosixResult AsGpu::AllocSpace(In<u32> pages, In<u32> pageSize, In<MappingFlags> flags, InOut<u64> offset) {
|
PosixResult AsGpu::AllocSpace(In<u32> pages, In<u32> pageSize, In<MappingFlags> flags, InOut<u64> offset) {
|
||||||
state.logger->Debug("pages: 0x{:X}, pageSize: 0x{:X}, flags: ( fixed: {}, sparse: {} ), offset: 0x{:X}",
|
Logger::Debug("pages: 0x{:X}, pageSize: 0x{:X}, flags: ( fixed: {}, sparse: {} ), offset: 0x{:X}",
|
||||||
pages, pageSize, flags.fixed, flags.sparse, offset);
|
pages, pageSize, flags.fixed, flags.sparse, offset);
|
||||||
|
|
||||||
std::scoped_lock lock(mutex);
|
std::scoped_lock lock(mutex);
|
||||||
@ -108,7 +108,7 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PosixResult AsGpu::FreeSpace(In<u64> offset, In<u32> pages, In<u32> pageSize) {
|
PosixResult AsGpu::FreeSpace(In<u64> offset, In<u32> pages, In<u32> pageSize) {
|
||||||
state.logger->Debug("offset: 0x{:X}, pages: 0x{:X}, pageSize: 0x{:X}", offset, pages, pageSize);
|
Logger::Debug("offset: 0x{:X}, pages: 0x{:X}, pageSize: 0x{:X}", offset, pages, pageSize);
|
||||||
|
|
||||||
std::scoped_lock lock(mutex);
|
std::scoped_lock lock(mutex);
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PosixResult AsGpu::UnmapBuffer(In<u64> offset) {
|
PosixResult AsGpu::UnmapBuffer(In<u64> offset) {
|
||||||
state.logger->Debug("offset: 0x{:X}", offset);
|
Logger::Debug("offset: 0x{:X}", offset);
|
||||||
|
|
||||||
std::scoped_lock lock(mutex);
|
std::scoped_lock lock(mutex);
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
|
|
||||||
mappingMap.erase(offset);
|
mappingMap.erase(offset);
|
||||||
} catch (const std::out_of_range &e) {
|
} catch (const std::out_of_range &e) {
|
||||||
state.logger->Warn("Couldn't find region to unmap at 0x{:X}", offset);
|
Logger::Warn("Couldn't find region to unmap at 0x{:X}", offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
@ -176,7 +176,7 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
PosixResult AsGpu::MapBufferEx(In<MappingFlags> flags, In<u32> kind,
|
PosixResult AsGpu::MapBufferEx(In<MappingFlags> flags, In<u32> kind,
|
||||||
In<core::NvMap::Handle::Id> handle, In<u64> bufferOffset,
|
In<core::NvMap::Handle::Id> handle, In<u64> bufferOffset,
|
||||||
In<u64> mappingSize, InOut<u64> offset) {
|
In<u64> mappingSize, InOut<u64> offset) {
|
||||||
state.logger->Debug("flags: ( fixed: {}, remap: {} ), kind: {}, handle: {}, bufferOffset: 0x{:X}, mappingSize: 0x{:X}, offset: 0x{:X}",
|
Logger::Debug("flags: ( fixed: {}, remap: {} ), kind: {}, handle: {}, bufferOffset: 0x{:X}, mappingSize: 0x{:X}, offset: 0x{:X}",
|
||||||
flags.fixed, flags.remap, kind, handle, bufferOffset, mappingSize, offset);
|
flags.fixed, flags.remap, kind, handle, bufferOffset, mappingSize, offset);
|
||||||
|
|
||||||
std::scoped_lock lock(mutex);
|
std::scoped_lock lock(mutex);
|
||||||
@ -190,7 +190,7 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
auto mapping{mappingMap.at(offset)};
|
auto mapping{mappingMap.at(offset)};
|
||||||
|
|
||||||
if (mapping->size < mappingSize) {
|
if (mapping->size < mappingSize) {
|
||||||
state.logger->Warn("Cannot remap a partially mapped GPU address space region: 0x{:X}", offset);
|
Logger::Warn("Cannot remap a partially mapped GPU address space region: 0x{:X}", offset);
|
||||||
return PosixResult::InvalidArgument;
|
return PosixResult::InvalidArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
|
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
} catch (const std::out_of_range &e) {
|
} catch (const std::out_of_range &e) {
|
||||||
state.logger->Warn("Cannot remap an unmapped GPU address space region: 0x{:X}", offset);
|
Logger::Warn("Cannot remap an unmapped GPU address space region: 0x{:X}", offset);
|
||||||
return PosixResult::InvalidArgument;
|
return PosixResult::InvalidArgument;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,7 +248,7 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
mappingMap[offset] = mapping;
|
mappingMap[offset] = mapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.logger->Debug("Mapped to 0x{:X}", offset);
|
Logger::Debug("Mapped to 0x{:X}", offset);
|
||||||
|
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
}
|
}
|
||||||
@ -288,17 +288,17 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
if (vm.initialised)
|
if (vm.initialised)
|
||||||
throw exception("Cannot initialise an address space twice!");
|
throw exception("Cannot initialise an address space twice!");
|
||||||
|
|
||||||
state.logger->Debug("bigPageSize: 0x{:X}, asFd: {}, flags: 0x{:X}, vaRangeStart: 0x{:X}, vaRangeEnd: 0x{:X}, vaRangeSplit: 0x{:X}",
|
Logger::Debug("bigPageSize: 0x{:X}, asFd: {}, flags: 0x{:X}, vaRangeStart: 0x{:X}, vaRangeEnd: 0x{:X}, vaRangeSplit: 0x{:X}",
|
||||||
bigPageSize, asFd, flags, vaRangeStart, vaRangeEnd, vaRangeSplit);
|
bigPageSize, asFd, flags, vaRangeStart, vaRangeEnd, vaRangeSplit);
|
||||||
|
|
||||||
if (bigPageSize) {
|
if (bigPageSize) {
|
||||||
if (!std::has_single_bit(bigPageSize)) {
|
if (!std::has_single_bit(bigPageSize)) {
|
||||||
state.logger->Error("Non power-of-2 big page size: 0x{:X}!", bigPageSize);
|
Logger::Error("Non power-of-2 big page size: 0x{:X}!", bigPageSize);
|
||||||
return PosixResult::InvalidArgument;
|
return PosixResult::InvalidArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(bigPageSize & VM::SupportedBigPageSizes)) {
|
if (!(bigPageSize & VM::SupportedBigPageSizes)) {
|
||||||
state.logger->Error("Unsupported big page size: 0x{:X}!", bigPageSize);
|
Logger::Error("Unsupported big page size: 0x{:X}!", bigPageSize);
|
||||||
return PosixResult::InvalidArgument;
|
return PosixResult::InvalidArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,12 +342,12 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
auto alloc{allocationMap.upper_bound(virtAddr)};
|
auto alloc{allocationMap.upper_bound(virtAddr)};
|
||||||
|
|
||||||
if (alloc-- == allocationMap.begin() || (virtAddr - alloc->first) + size > alloc->second.size) {
|
if (alloc-- == allocationMap.begin() || (virtAddr - alloc->first) + size > alloc->second.size) {
|
||||||
state.logger->Warn("Cannot remap into an unallocated region!");
|
Logger::Warn("Cannot remap into an unallocated region!");
|
||||||
return PosixResult::InvalidArgument;
|
return PosixResult::InvalidArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!alloc->second.sparse) {
|
if (!alloc->second.sparse) {
|
||||||
state.logger->Warn("Cannot remap a non-sparse mapping!");
|
Logger::Warn("Cannot remap a non-sparse mapping!");
|
||||||
return PosixResult::InvalidArgument;
|
return PosixResult::InvalidArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PosixResult Ctrl::SyncpointWaitEventImpl(In<Fence> fence, In<i32> timeout, InOut<SyncpointEventValue> value, bool allocate) {
|
PosixResult Ctrl::SyncpointWaitEventImpl(In<Fence> fence, In<i32> timeout, InOut<SyncpointEventValue> value, bool allocate) {
|
||||||
state.logger->Debug("fence: ( id: {}, threshold: {} ), timeout: {}, value: {}, allocate: {}",
|
Logger::Debug("fence: ( id: {}, threshold: {} ), timeout: {}, value: {}, allocate: {}",
|
||||||
fence.id, fence.threshold, timeout, value.val, allocate);
|
fence.id, fence.threshold, timeout, value.val, allocate);
|
||||||
|
|
||||||
if (fence.id >= soc::host1x::SyncpointCount)
|
if (fence.id >= soc::host1x::SyncpointCount)
|
||||||
@ -80,7 +80,7 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
if (fence.threshold == 0) {
|
if (fence.threshold == 0) {
|
||||||
// oss-nvjpg waits on syncpoint 0 during initialisation without reserving it, this is technically valid with a zero threshold but could also be a sign of a bug on our side in other cases, hence the warn
|
// oss-nvjpg waits on syncpoint 0 during initialisation without reserving it, this is technically valid with a zero threshold but could also be a sign of a bug on our side in other cases, hence the warn
|
||||||
if (!core.syncpointManager.IsSyncpointAllocated(fence.id))
|
if (!core.syncpointManager.IsSyncpointAllocated(fence.id))
|
||||||
state.logger->Warn("Tried to wait on an unreserved syncpoint with no threshold");
|
Logger::Warn("Tried to wait on an unreserved syncpoint with no threshold");
|
||||||
|
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
return PosixResult::InvalidArgument;
|
return PosixResult::InvalidArgument;
|
||||||
|
|
||||||
if (!event->IsInUse()) {
|
if (!event->IsInUse()) {
|
||||||
state.logger->Debug("Waiting on syncpoint event: {} with fence: ({}, {})", slot, fence.id, fence.threshold);
|
Logger::Debug("Waiting on syncpoint event: {} with fence: ({}, {})", slot, fence.id, fence.threshold);
|
||||||
event->RegisterWaiter(state.soc->host1x, fence);
|
event->RegisterWaiter(state.soc->host1x, fence);
|
||||||
|
|
||||||
value.val = 0;
|
value.val = 0;
|
||||||
@ -159,7 +159,7 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PosixResult Ctrl::SyncpointClearEventWait(In<SyncpointEventValue> value) {
|
PosixResult Ctrl::SyncpointClearEventWait(In<SyncpointEventValue> value) {
|
||||||
state.logger->Debug("slot: {}", value.slot);
|
Logger::Debug("slot: {}", value.slot);
|
||||||
|
|
||||||
u16 slot{value.slot};
|
u16 slot{value.slot};
|
||||||
if (slot >= SyncpointEventCount)
|
if (slot >= SyncpointEventCount)
|
||||||
@ -172,7 +172,7 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
return PosixResult::InvalidArgument;
|
return PosixResult::InvalidArgument;
|
||||||
|
|
||||||
if (event->state.exchange(SyncpointEvent::State::Cancelling) == SyncpointEvent::State::Waiting) {
|
if (event->state.exchange(SyncpointEvent::State::Cancelling) == SyncpointEvent::State::Waiting) {
|
||||||
state.logger->Debug("Cancelling waiting syncpoint event: {}", slot);
|
Logger::Debug("Cancelling waiting syncpoint event: {}", slot);
|
||||||
event->Cancel(state.soc->host1x);
|
event->Cancel(state.soc->host1x);
|
||||||
core.syncpointManager.UpdateMin(event->fence.id);
|
core.syncpointManager.UpdateMin(event->fence.id);
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PosixResult Ctrl::SyncpointAllocateEvent(In<u32> slot) {
|
PosixResult Ctrl::SyncpointAllocateEvent(In<u32> slot) {
|
||||||
state.logger->Debug("slot: {}", slot);
|
Logger::Debug("slot: {}", slot);
|
||||||
|
|
||||||
if (slot >= SyncpointEventCount)
|
if (slot >= SyncpointEventCount)
|
||||||
return PosixResult::InvalidArgument;
|
return PosixResult::InvalidArgument;
|
||||||
@ -210,14 +210,14 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PosixResult Ctrl::SyncpointFreeEvent(In<u32> slot) {
|
PosixResult Ctrl::SyncpointFreeEvent(In<u32> slot) {
|
||||||
state.logger->Debug("slot: {}", slot);
|
Logger::Debug("slot: {}", slot);
|
||||||
|
|
||||||
std::lock_guard lock(syncpointEventMutex);
|
std::lock_guard lock(syncpointEventMutex);
|
||||||
return SyncpointFreeEventLocked(slot);
|
return SyncpointFreeEventLocked(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
PosixResult Ctrl::SyncpointFreeEventBatch(In<u64> bitmask) {
|
PosixResult Ctrl::SyncpointFreeEventBatch(In<u64> bitmask) {
|
||||||
state.logger->Debug("bitmask: 0x{:X}", bitmask);
|
Logger::Debug("bitmask: 0x{:X}", bitmask);
|
||||||
|
|
||||||
auto err{PosixResult::Success};
|
auto err{PosixResult::Success};
|
||||||
|
|
||||||
|
@ -66,12 +66,12 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PosixResult GpuChannel::SetNvmapFd(In<FileDescriptor> fd) {
|
PosixResult GpuChannel::SetNvmapFd(In<FileDescriptor> fd) {
|
||||||
state.logger->Debug("fd: {}", fd);
|
Logger::Debug("fd: {}", fd);
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PosixResult GpuChannel::SetTimeout(In<u32> timeout) {
|
PosixResult GpuChannel::SetTimeout(In<u32> timeout) {
|
||||||
state.logger->Debug("timeout: {}", timeout);
|
Logger::Debug("timeout: {}", timeout);
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
InOut<SubmitGpfifoFlags> flags,
|
InOut<SubmitGpfifoFlags> flags,
|
||||||
InOut<Fence> fence,
|
InOut<Fence> fence,
|
||||||
span<soc::gm20b::GpEntry> gpEntries) {
|
span<soc::gm20b::GpEntry> gpEntries) {
|
||||||
state.logger->Debug("userAddress: 0x{:X}, numEntries: {},"
|
Logger::Debug("userAddress: 0x{:X}, numEntries: {},"
|
||||||
"flags ( fenceWait: {}, fenceIncrement: {}, hwFormat: {}, suppressWfi: {}, incrementWithValue: {}),"
|
"flags ( fenceWait: {}, fenceIncrement: {}, hwFormat: {}, suppressWfi: {}, incrementWithValue: {}),"
|
||||||
"fence ( id: {}, threshold: {} )",
|
"fence ( id: {}, threshold: {} )",
|
||||||
userAddress, numEntries,
|
userAddress, numEntries,
|
||||||
@ -137,36 +137,36 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PosixResult GpuChannel::AllocObjCtx(In<u32> classId, In<u32> flags, Out<u64> objId) {
|
PosixResult GpuChannel::AllocObjCtx(In<u32> classId, In<u32> flags, Out<u64> objId) {
|
||||||
state.logger->Debug("classId: 0x{:X}, flags: 0x{:X}", classId, flags);
|
Logger::Debug("classId: 0x{:X}, flags: 0x{:X}", classId, flags);
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PosixResult GpuChannel::ZcullBind(In<u64> gpuVa, In<u32> mode) {
|
PosixResult GpuChannel::ZcullBind(In<u64> gpuVa, In<u32> mode) {
|
||||||
state.logger->Debug("gpuVa: 0x{:X}, mode: {}", gpuVa, mode);
|
Logger::Debug("gpuVa: 0x{:X}, mode: {}", gpuVa, mode);
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PosixResult GpuChannel::SetErrorNotifier(In<u64> offset, In<u64> size, In<u32> mem) {
|
PosixResult GpuChannel::SetErrorNotifier(In<u64> offset, In<u64> size, In<u32> mem) {
|
||||||
state.logger->Debug("offset: 0x{:X}, size: 0x{:X}, mem: 0x{:X}", offset, size, mem);
|
Logger::Debug("offset: 0x{:X}, size: 0x{:X}, mem: 0x{:X}", offset, size, mem);
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PosixResult GpuChannel::SetPriority(In<u32> priority) {
|
PosixResult GpuChannel::SetPriority(In<u32> priority) {
|
||||||
state.logger->Debug("priority: {}", priority);
|
Logger::Debug("priority: {}", priority);
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PosixResult GpuChannel::AllocGpfifoEx2(In<u32> numEntries, In<u32> numJobs, In<u32> flags, Out<Fence> fence) {
|
PosixResult GpuChannel::AllocGpfifoEx2(In<u32> numEntries, In<u32> numJobs, In<u32> flags, Out<Fence> fence) {
|
||||||
state.logger->Debug("numEntries: {}, numJobs: {}, flags: 0x{:X}", numEntries, numJobs, flags);
|
Logger::Debug("numEntries: {}, numJobs: {}, flags: 0x{:X}", numEntries, numJobs, flags);
|
||||||
|
|
||||||
std::scoped_lock lock(channelMutex);
|
std::scoped_lock lock(channelMutex);
|
||||||
if (!asCtx || !asAllocator) {
|
if (!asCtx || !asAllocator) {
|
||||||
state.logger->Warn("Trying to allocate a channel without a bound address space");
|
Logger::Warn("Trying to allocate a channel without a bound address space");
|
||||||
return PosixResult::InvalidArgument;
|
return PosixResult::InvalidArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channelCtx) {
|
if (channelCtx) {
|
||||||
state.logger->Warn("Trying to allocate a channel twice!");
|
Logger::Warn("Trying to allocate a channel twice!");
|
||||||
return PosixResult::FileExists;
|
return PosixResult::FileExists;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,12 +192,12 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PosixResult GpuChannel::SetTimeslice(In<u32> timeslice) {
|
PosixResult GpuChannel::SetTimeslice(In<u32> timeslice) {
|
||||||
state.logger->Debug("timeslice: {}", timeslice);
|
Logger::Debug("timeslice: {}", timeslice);
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PosixResult GpuChannel::SetUserData(In<u64> userData) {
|
PosixResult GpuChannel::SetUserData(In<u64> userData) {
|
||||||
state.logger->Debug("userData: 0x{:X}", userData);
|
Logger::Debug("userData: 0x{:X}", userData);
|
||||||
channelUserData = userData;
|
channelUserData = userData;
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
}
|
}
|
||||||
|
@ -17,14 +17,14 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PosixResult Host1xChannel::SetNvmapFd(In<FileDescriptor> fd) {
|
PosixResult Host1xChannel::SetNvmapFd(In<FileDescriptor> fd) {
|
||||||
state.logger->Debug("fd: {}", fd);
|
Logger::Debug("fd: {}", fd);
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PosixResult Host1xChannel::Submit(span<SubmitCmdBuf> cmdBufs,
|
PosixResult Host1xChannel::Submit(span<SubmitCmdBuf> cmdBufs,
|
||||||
span<SubmitReloc> relocs, span<u32> relocShifts,
|
span<SubmitReloc> relocs, span<u32> relocShifts,
|
||||||
span<SubmitSyncpointIncr> syncpointIncrs, span<u32> fenceThresholds) {
|
span<SubmitSyncpointIncr> syncpointIncrs, span<u32> fenceThresholds) {
|
||||||
state.logger->Debug("numCmdBufs: {}, numRelocs: {}, numSyncpointIncrs: {}, numFenceThresholds: {}",
|
Logger::Debug("numCmdBufs: {}, numRelocs: {}, numSyncpointIncrs: {}, numFenceThresholds: {}",
|
||||||
cmdBufs.size(), relocs.size(), syncpointIncrs.size(), fenceThresholds.size());
|
cmdBufs.size(), relocs.size(), syncpointIncrs.size(), fenceThresholds.size());
|
||||||
|
|
||||||
if (fenceThresholds.size() > syncpointIncrs.size())
|
if (fenceThresholds.size() > syncpointIncrs.size())
|
||||||
@ -49,7 +49,7 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
throw exception("Invalid handle passed for a command buffer!");
|
throw exception("Invalid handle passed for a command buffer!");
|
||||||
|
|
||||||
u64 gatherAddress{handleDesc->address + cmdBuf.offset};
|
u64 gatherAddress{handleDesc->address + cmdBuf.offset};
|
||||||
state.logger->Debug("Submit gather, CPU address: 0x{:X}, words: 0x{:X}", gatherAddress, cmdBuf.words);
|
Logger::Debug("Submit gather, CPU address: 0x{:X}, words: 0x{:X}", gatherAddress, cmdBuf.words);
|
||||||
|
|
||||||
span gather(reinterpret_cast<u32 *>(gatherAddress), cmdBuf.words);
|
span gather(reinterpret_cast<u32 *>(gatherAddress), cmdBuf.words);
|
||||||
state.soc->host1x.channels[static_cast<size_t>(channelType)].Push(gather);
|
state.soc->host1x.channels[static_cast<size_t>(channelType)].Push(gather);
|
||||||
@ -59,7 +59,7 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PosixResult Host1xChannel::GetSyncpoint(In<u32> channelSyncpointIdx, Out<u32> syncpointId) {
|
PosixResult Host1xChannel::GetSyncpoint(In<u32> channelSyncpointIdx, Out<u32> syncpointId) {
|
||||||
state.logger->Debug("channelSyncpointIdx: {}", channelSyncpointIdx);
|
Logger::Debug("channelSyncpointIdx: {}", channelSyncpointIdx);
|
||||||
|
|
||||||
if (channelSyncpointIdx > 0)
|
if (channelSyncpointIdx > 0)
|
||||||
throw exception("Multiple channel syncpoints are unimplemented!");
|
throw exception("Multiple channel syncpoints are unimplemented!");
|
||||||
@ -68,39 +68,39 @@ namespace skyline::service::nvdrv::device::nvhost {
|
|||||||
if (!id)
|
if (!id)
|
||||||
throw exception("Requested syncpoint for a channel with none specified!");
|
throw exception("Requested syncpoint for a channel with none specified!");
|
||||||
|
|
||||||
state.logger->Debug("syncpointId: {}", id);
|
Logger::Debug("syncpointId: {}", id);
|
||||||
syncpointId = id;
|
syncpointId = id;
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PosixResult Host1xChannel::GetWaitBase(In<core::ChannelType> pChannelType, Out<u32> waitBase) {
|
PosixResult Host1xChannel::GetWaitBase(In<core::ChannelType> pChannelType, Out<u32> waitBase) {
|
||||||
state.logger->Debug("channelType: {}", static_cast<u32>(pChannelType));
|
Logger::Debug("channelType: {}", static_cast<u32>(pChannelType));
|
||||||
waitBase = 0;
|
waitBase = 0;
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PosixResult Host1xChannel::SetSubmitTimeout(In<u32> timeout) {
|
PosixResult Host1xChannel::SetSubmitTimeout(In<u32> timeout) {
|
||||||
state.logger->Debug("timeout: {}", timeout);
|
Logger::Debug("timeout: {}", timeout);
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PosixResult Host1xChannel::MapBuffer(u8 compressed, span<BufferHandle> handles) {
|
PosixResult Host1xChannel::MapBuffer(u8 compressed, span<BufferHandle> handles) {
|
||||||
state.logger->Debug("compressed: {}", compressed);
|
Logger::Debug("compressed: {}", compressed);
|
||||||
|
|
||||||
for (auto &bufferHandle : handles) {
|
for (auto &bufferHandle : handles) {
|
||||||
bufferHandle.address = core.nvMap.PinHandle(bufferHandle.handle);
|
bufferHandle.address = core.nvMap.PinHandle(bufferHandle.handle);
|
||||||
state.logger->Debug("handle: {}, address: 0x{:X}", bufferHandle.handle, bufferHandle.address);
|
Logger::Debug("handle: {}, address: 0x{:X}", bufferHandle.handle, bufferHandle.address);
|
||||||
}
|
}
|
||||||
|
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PosixResult Host1xChannel::UnmapBuffer(u8 compressed, span<BufferHandle> handles) {
|
PosixResult Host1xChannel::UnmapBuffer(u8 compressed, span<BufferHandle> handles) {
|
||||||
state.logger->Debug("compressed: {}", compressed);
|
Logger::Debug("compressed: {}", compressed);
|
||||||
|
|
||||||
for (auto &bufferHandle : handles) {
|
for (auto &bufferHandle : handles) {
|
||||||
core.nvMap.UnpinHandle(bufferHandle.handle);
|
core.nvMap.UnpinHandle(bufferHandle.handle);
|
||||||
state.logger->Debug("handle: {}", bufferHandle.handle);
|
Logger::Debug("handle: {}", bufferHandle.handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
|
@ -13,14 +13,14 @@ namespace skyline::service::nvdrv::device {
|
|||||||
if (handleDesc) {
|
if (handleDesc) {
|
||||||
(*handleDesc)->origSize = size; // Orig size is the unaligned size
|
(*handleDesc)->origSize = size; // Orig size is the unaligned size
|
||||||
handle = (*handleDesc)->id;
|
handle = (*handleDesc)->id;
|
||||||
state.logger->Debug("handle: {}, size: 0x{:X}", (*handleDesc)->id, size);
|
Logger::Debug("handle: {}, size: 0x{:X}", (*handleDesc)->id, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return handleDesc;
|
return handleDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
PosixResult NvMap::FromId(In<NvMapCore::Handle::Id> id, Out<NvMapCore::Handle::Id> handle) {
|
PosixResult NvMap::FromId(In<NvMapCore::Handle::Id> id, Out<NvMapCore::Handle::Id> handle) {
|
||||||
state.logger->Debug("id: {}", id);
|
Logger::Debug("id: {}", id);
|
||||||
|
|
||||||
// Handles and IDs are always the same value in nvmap however IDs can be used globally given the right permissions.
|
// Handles and IDs are always the same value in nvmap however IDs can be used globally given the right permissions.
|
||||||
// Since we don't plan on ever supporting multiprocess we can skip implementing handle refs and so this function just does simple validation and passes through the handle id.
|
// Since we don't plan on ever supporting multiprocess we can skip implementing handle refs and so this function just does simple validation and passes through the handle id.
|
||||||
@ -41,7 +41,7 @@ namespace skyline::service::nvdrv::device {
|
|||||||
PosixResult NvMap::Alloc(In<NvMapCore::Handle::Id> handle,
|
PosixResult NvMap::Alloc(In<NvMapCore::Handle::Id> handle,
|
||||||
In<u32> heapMask, In<NvMapCore::Handle::Flags> flags,
|
In<u32> heapMask, In<NvMapCore::Handle::Flags> flags,
|
||||||
InOut<u32> align, In<u8> kind, In<u64> address) {
|
InOut<u32> align, In<u8> kind, In<u64> address) {
|
||||||
state.logger->Debug("handle: {}, flags: ( mapUncached: {}, keepUncachedAfterFree: {} ), align: 0x{:X}, kind: {}, address: 0x{:X}",
|
Logger::Debug("handle: {}, flags: ( mapUncached: {}, keepUncachedAfterFree: {} ), align: 0x{:X}, kind: {}, address: 0x{:X}",
|
||||||
handle, flags.mapUncached, flags.keepUncachedAfterFree, align, kind, address);
|
handle, flags.mapUncached, flags.keepUncachedAfterFree, align, kind, address);
|
||||||
|
|
||||||
if (!handle) [[unlikely]]
|
if (!handle) [[unlikely]]
|
||||||
@ -64,7 +64,7 @@ namespace skyline::service::nvdrv::device {
|
|||||||
PosixResult NvMap::Free(In<NvMapCore::Handle::Id> handle,
|
PosixResult NvMap::Free(In<NvMapCore::Handle::Id> handle,
|
||||||
Out<u64> address, Out<u32> size,
|
Out<u64> address, Out<u32> size,
|
||||||
Out<NvMapCore::Handle::Flags> flags) {
|
Out<NvMapCore::Handle::Flags> flags) {
|
||||||
state.logger->Debug("handle: {}", handle);
|
Logger::Debug("handle: {}", handle);
|
||||||
|
|
||||||
if (!handle) [[unlikely]]
|
if (!handle) [[unlikely]]
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
@ -74,14 +74,14 @@ namespace skyline::service::nvdrv::device {
|
|||||||
size = static_cast<u32>(freeInfo->size);
|
size = static_cast<u32>(freeInfo->size);
|
||||||
flags = NvMapCore::Handle::Flags{ .mapUncached = freeInfo->wasUncached };
|
flags = NvMapCore::Handle::Flags{ .mapUncached = freeInfo->wasUncached };
|
||||||
} else {
|
} else {
|
||||||
state.logger->Debug("Handle not freed");
|
Logger::Debug("Handle not freed");
|
||||||
}
|
}
|
||||||
|
|
||||||
return PosixResult::Success;
|
return PosixResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PosixResult NvMap::Param(In<NvMapCore::Handle::Id> handle, In<HandleParameterType> param, Out<u32> result) {
|
PosixResult NvMap::Param(In<NvMapCore::Handle::Id> handle, In<HandleParameterType> param, Out<u32> result) {
|
||||||
state.logger->Debug("handle: {}, param: {}", handle, param);
|
Logger::Debug("handle: {}, param: {}", handle, param);
|
||||||
|
|
||||||
if (!handle)
|
if (!handle)
|
||||||
return PosixResult::InvalidArgument;
|
return PosixResult::InvalidArgument;
|
||||||
@ -119,7 +119,7 @@ namespace skyline::service::nvdrv::device {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PosixResult NvMap::GetId(Out<NvMapCore::Handle::Id> id, In<NvMapCore::Handle::Id> handle) {
|
PosixResult NvMap::GetId(Out<NvMapCore::Handle::Id> id, In<NvMapCore::Handle::Id> handle) {
|
||||||
state.logger->Debug("handle: {}", handle);
|
Logger::Debug("handle: {}", handle);
|
||||||
|
|
||||||
// See the comment in FromId for extra info on this function
|
// See the comment in FromId for extra info on this function
|
||||||
if (!handle) [[unlikely]]
|
if (!handle) [[unlikely]]
|
||||||
|
@ -13,7 +13,7 @@ namespace skyline::service::nvdrv {
|
|||||||
Driver::Driver(const DeviceState &state) : state(state), core(state) {}
|
Driver::Driver(const DeviceState &state) : state(state), core(state) {}
|
||||||
|
|
||||||
NvResult Driver::OpenDevice(std::string_view path, FileDescriptor fd, const SessionContext &ctx) {
|
NvResult Driver::OpenDevice(std::string_view path, FileDescriptor fd, const SessionContext &ctx) {
|
||||||
state.logger->Debug("Opening NvDrv device ({}): {}", fd, path);
|
Logger::Debug("Opening NvDrv device ({}): {}", fd, path);
|
||||||
auto pathHash{util::Hash(path)};
|
auto pathHash{util::Hash(path)};
|
||||||
|
|
||||||
#define DEVICE_SWITCH(cases) \
|
#define DEVICE_SWITCH(cases) \
|
||||||
@ -84,7 +84,7 @@ namespace skyline::service::nvdrv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NvResult Driver::Ioctl(FileDescriptor fd, IoctlDescriptor cmd, span<u8> buffer) {
|
NvResult Driver::Ioctl(FileDescriptor fd, IoctlDescriptor cmd, span<u8> buffer) {
|
||||||
state.logger->Debug("fd: {}, cmd: 0x{:X}, device: {}", fd, cmd.raw, devices.at(fd)->GetName());
|
Logger::Debug("fd: {}, cmd: 0x{:X}, device: {}", fd, cmd.raw, devices.at(fd)->GetName());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::shared_lock lock(deviceMutex);
|
std::shared_lock lock(deviceMutex);
|
||||||
@ -95,7 +95,7 @@ namespace skyline::service::nvdrv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NvResult Driver::Ioctl2(FileDescriptor fd, IoctlDescriptor cmd, span<u8> buffer, span<u8> inlineBuffer) {
|
NvResult Driver::Ioctl2(FileDescriptor fd, IoctlDescriptor cmd, span<u8> buffer, span<u8> inlineBuffer) {
|
||||||
state.logger->Debug("fd: {}, cmd: 0x{:X}, device: {}", fd, cmd.raw, devices.at(fd)->GetName());
|
Logger::Debug("fd: {}, cmd: 0x{:X}, device: {}", fd, cmd.raw, devices.at(fd)->GetName());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::shared_lock lock(deviceMutex);
|
std::shared_lock lock(deviceMutex);
|
||||||
@ -106,7 +106,7 @@ namespace skyline::service::nvdrv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NvResult Driver::Ioctl3(FileDescriptor fd, IoctlDescriptor cmd, span<u8> buffer, span<u8> inlineBuffer) {
|
NvResult Driver::Ioctl3(FileDescriptor fd, IoctlDescriptor cmd, span<u8> buffer, span<u8> inlineBuffer) {
|
||||||
state.logger->Debug("fd: {}, cmd: 0x{:X}, device: {}", fd, cmd.raw, devices.at(fd)->GetName());
|
Logger::Debug("fd: {}, cmd: 0x{:X}, device: {}", fd, cmd.raw, devices.at(fd)->GetName());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::shared_lock lock(deviceMutex);
|
std::shared_lock lock(deviceMutex);
|
||||||
@ -121,12 +121,12 @@ namespace skyline::service::nvdrv {
|
|||||||
std::unique_lock lock(deviceMutex);
|
std::unique_lock lock(deviceMutex);
|
||||||
devices.erase(fd);
|
devices.erase(fd);
|
||||||
} catch (const std::out_of_range &) {
|
} catch (const std::out_of_range &) {
|
||||||
state.logger->Warn("Trying to close invalid fd: {}");
|
Logger::Warn("Trying to close invalid fd: {}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<kernel::type::KEvent> Driver::QueryEvent(FileDescriptor fd, u32 eventId) {
|
std::shared_ptr<kernel::type::KEvent> Driver::QueryEvent(FileDescriptor fd, u32 eventId) {
|
||||||
state.logger->Debug("fd: {}, eventId: 0x{:X}, device: {}", fd, eventId, devices.at(fd)->GetName());
|
Logger::Debug("fd: {}, eventId: 0x{:X}, device: {}", fd, eventId, devices.at(fd)->GetName());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::shared_lock lock(deviceMutex);
|
std::shared_lock lock(deviceMutex);
|
||||||
|
@ -120,7 +120,7 @@ namespace skyline::service {
|
|||||||
handle = state.process->NewHandle<type::KSession>(serviceObject).handle;
|
handle = state.process->NewHandle<type::KSession>(serviceObject).handle;
|
||||||
response.moveHandles.push_back(handle);
|
response.moveHandles.push_back(handle);
|
||||||
}
|
}
|
||||||
state.logger->Debug("Service has been created: \"{}\" (0x{:X})", serviceObject->GetName(), handle);
|
Logger::Debug("Service has been created: \"{}\" (0x{:X})", serviceObject->GetName(), handle);
|
||||||
return serviceObject;
|
return serviceObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ namespace skyline::service {
|
|||||||
response.moveHandles.push_back(handle);
|
response.moveHandles.push_back(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
state.logger->Debug("Service has been registered: \"{}\" (0x{:X})", serviceObject->GetName(), handle);
|
Logger::Debug("Service has been registered: \"{}\" (0x{:X})", serviceObject->GetName(), handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceManager::CloseSession(KHandle handle) {
|
void ServiceManager::CloseSession(KHandle handle) {
|
||||||
@ -161,8 +161,8 @@ namespace skyline::service {
|
|||||||
void ServiceManager::SyncRequestHandler(KHandle handle) {
|
void ServiceManager::SyncRequestHandler(KHandle handle) {
|
||||||
TRACE_EVENT("kernel", "ServiceManager::SyncRequestHandler");
|
TRACE_EVENT("kernel", "ServiceManager::SyncRequestHandler");
|
||||||
auto session{state.process->GetHandle<type::KSession>(handle)};
|
auto session{state.process->GetHandle<type::KSession>(handle)};
|
||||||
state.logger->Verbose("----IPC Start----");
|
Logger::Verbose("----IPC Start----");
|
||||||
state.logger->Verbose("Handle is 0x{:X}", handle);
|
Logger::Verbose("Handle is 0x{:X}", handle);
|
||||||
|
|
||||||
if (session->isOpen) {
|
if (session->isOpen) {
|
||||||
ipc::IpcRequest request(session->isDomain, state);
|
ipc::IpcRequest request(session->isDomain, state);
|
||||||
@ -199,7 +199,7 @@ namespace skyline::service {
|
|||||||
|
|
||||||
case ipc::CommandType::Control:
|
case ipc::CommandType::Control:
|
||||||
case ipc::CommandType::ControlWithContext:
|
case ipc::CommandType::ControlWithContext:
|
||||||
state.logger->Debug("Control IPC Message: 0x{:X}", request.payload->value);
|
Logger::Debug("Control IPC Message: 0x{:X}", request.payload->value);
|
||||||
switch (static_cast<ipc::ControlCommand>(request.payload->value)) {
|
switch (static_cast<ipc::ControlCommand>(request.payload->value)) {
|
||||||
case ipc::ControlCommand::ConvertCurrentObjectToDomain:
|
case ipc::ControlCommand::ConvertCurrentObjectToDomain:
|
||||||
response.Push(session->ConvertDomain());
|
response.Push(session->ConvertDomain());
|
||||||
@ -221,15 +221,15 @@ namespace skyline::service {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ipc::CommandType::Close:
|
case ipc::CommandType::Close:
|
||||||
state.logger->Debug("Closing Session");
|
Logger::Debug("Closing Session");
|
||||||
CloseSession(handle);
|
CloseSession(handle);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw exception("Unimplemented IPC message type: {}", static_cast<u16>(request.header->type));
|
throw exception("Unimplemented IPC message type: {}", static_cast<u16>(request.header->type));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
state.logger->Warn("svcSendSyncRequest called on closed handle: 0x{:X}", handle);
|
Logger::Warn("svcSendSyncRequest called on closed handle: 0x{:X}", handle);
|
||||||
}
|
}
|
||||||
state.logger->Verbose("====IPC End====");
|
Logger::Verbose("====IPC End====");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ namespace skyline::service::sm {
|
|||||||
return {};
|
return {};
|
||||||
} catch (std::out_of_range &) {
|
} catch (std::out_of_range &) {
|
||||||
std::string_view stringName(span(reinterpret_cast<char *>(&name), sizeof(u64)).as_string(true));
|
std::string_view stringName(span(reinterpret_cast<char *>(&name), sizeof(u64)).as_string(true));
|
||||||
state.logger->Warn("Service has not been implemented: \"{}\"", stringName);
|
Logger::Warn("Service has not been implemented: \"{}\"", stringName);
|
||||||
return result::InvalidServiceName;
|
return result::InvalidServiceName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ namespace skyline::service::timesrv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto handle{state.process->InsertItem(operationEvent)};
|
auto handle{state.process->InsertItem(operationEvent)};
|
||||||
state.logger->Debug("ISystemClock Operation Event Handle: 0x{:X}", handle);
|
Logger::Debug("ISystemClock Operation Event Handle: 0x{:X}", handle);
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -42,14 +42,14 @@ namespace skyline::service::visrv {
|
|||||||
|
|
||||||
Result IApplicationDisplayService::OpenDisplay(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IApplicationDisplayService::OpenDisplay(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto displayName(request.PopString());
|
auto displayName(request.PopString());
|
||||||
state.logger->Debug("Opening display: {}", displayName);
|
Logger::Debug("Opening display: {}", displayName);
|
||||||
response.Push(hosbinder->OpenDisplay(displayName));
|
response.Push(hosbinder->OpenDisplay(displayName));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Result IApplicationDisplayService::CloseDisplay(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IApplicationDisplayService::CloseDisplay(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto displayId{request.Pop<hosbinder::DisplayId>()};
|
auto displayId{request.Pop<hosbinder::DisplayId>()};
|
||||||
state.logger->Debug("Closing display: {}", hosbinder::ToString(displayId));
|
Logger::Debug("Closing display: {}", hosbinder::ToString(displayId));
|
||||||
hosbinder->CloseDisplay(displayId);
|
hosbinder->CloseDisplay(displayId);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ namespace skyline::service::visrv {
|
|||||||
Result IApplicationDisplayService::OpenLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IApplicationDisplayService::OpenLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto displayName{request.PopString(0x40)};
|
auto displayName{request.PopString(0x40)};
|
||||||
auto layerId{request.Pop<u64>()};
|
auto layerId{request.Pop<u64>()};
|
||||||
state.logger->Debug("Opening layer #{} on display: {}", layerId, displayName);
|
Logger::Debug("Opening layer #{} on display: {}", layerId, displayName);
|
||||||
|
|
||||||
auto displayId{hosbinder->OpenDisplay(displayName)};
|
auto displayId{hosbinder->OpenDisplay(displayName)};
|
||||||
auto parcel{hosbinder->OpenLayer(displayId, layerId)};
|
auto parcel{hosbinder->OpenLayer(displayId, layerId)};
|
||||||
@ -68,7 +68,7 @@ namespace skyline::service::visrv {
|
|||||||
|
|
||||||
Result IApplicationDisplayService::CloseLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IApplicationDisplayService::CloseLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
u64 layerId{request.Pop<u64>()};
|
u64 layerId{request.Pop<u64>()};
|
||||||
state.logger->Debug("Closing layer #{}", layerId);
|
Logger::Debug("Closing layer #{}", layerId);
|
||||||
hosbinder->CloseLayer(layerId);
|
hosbinder->CloseLayer(layerId);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -76,13 +76,13 @@ namespace skyline::service::visrv {
|
|||||||
Result IApplicationDisplayService::SetLayerScalingMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IApplicationDisplayService::SetLayerScalingMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto scalingMode{request.Pop<u64>()};
|
auto scalingMode{request.Pop<u64>()};
|
||||||
auto layerId{request.Pop<u64>()};
|
auto layerId{request.Pop<u64>()};
|
||||||
state.logger->Debug("Setting Layer Scaling mode to '{}' for layer {}", scalingMode, layerId);
|
Logger::Debug("Setting Layer Scaling mode to '{}' for layer {}", scalingMode, layerId);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Result IApplicationDisplayService::GetDisplayVsyncEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IApplicationDisplayService::GetDisplayVsyncEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
KHandle handle{state.process->InsertItem(state.gpu->presentation.vsyncEvent)};
|
KHandle handle{state.process->InsertItem(state.gpu->presentation.vsyncEvent)};
|
||||||
state.logger->Debug("V-Sync Event Handle: 0x{:X}", handle);
|
Logger::Debug("V-Sync Event Handle: 0x{:X}", handle);
|
||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace skyline::service::visrv {
|
|||||||
auto layerId{hosbinder->CreateLayer(displayId)};
|
auto layerId{hosbinder->CreateLayer(displayId)};
|
||||||
response.Push(layerId);
|
response.Push(layerId);
|
||||||
|
|
||||||
state.logger->Debug("Creating Stray Layer #{} on Display: {}", layerId, hosbinder::ToString(displayId));
|
Logger::Debug("Creating Stray Layer #{} on Display: {}", layerId, hosbinder::ToString(displayId));
|
||||||
|
|
||||||
auto parcel{hosbinder->OpenLayer(displayId, layerId)};
|
auto parcel{hosbinder->OpenLayer(displayId, layerId)};
|
||||||
response.Push<u64>(parcel.WriteParcel(request.outputBuf.at(0)));
|
response.Push<u64>(parcel.WriteParcel(request.outputBuf.at(0)));
|
||||||
@ -25,7 +25,7 @@ namespace skyline::service::visrv {
|
|||||||
|
|
||||||
Result IDisplayService::DestroyStrayLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IDisplayService::DestroyStrayLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto layerId{request.Pop<u64>()};
|
auto layerId{request.Pop<u64>()};
|
||||||
state.logger->Debug("Destroying Stray Layer #{}", layerId);
|
Logger::Debug("Destroying Stray Layer #{}", layerId);
|
||||||
|
|
||||||
hosbinder->CloseLayer(layerId);
|
hosbinder->CloseLayer(layerId);
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ namespace skyline::service::visrv {
|
|||||||
auto displayId{request.Pop<hosbinder::DisplayId>()};
|
auto displayId{request.Pop<hosbinder::DisplayId>()};
|
||||||
|
|
||||||
auto layerId{hosbinder->CreateLayer(displayId)};
|
auto layerId{hosbinder->CreateLayer(displayId)};
|
||||||
state.logger->Debug("Creating Managed Layer #{} on Display: {}", layerId, hosbinder::ToString(displayId));
|
Logger::Debug("Creating Managed Layer #{} on Display: {}", layerId, hosbinder::ToString(displayId));
|
||||||
response.Push(layerId);
|
response.Push(layerId);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
@ -20,7 +20,7 @@ namespace skyline::service::visrv {
|
|||||||
|
|
||||||
Result IManagerDisplayService::DestroyManagedLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IManagerDisplayService::DestroyManagedLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto layerId{request.Pop<u64>()};
|
auto layerId{request.Pop<u64>()};
|
||||||
state.logger->Debug("Destroying Managed Layer #{}", layerId);
|
Logger::Debug("Destroying Managed Layer #{}", layerId);
|
||||||
hosbinder->DestroyLayer(layerId);
|
hosbinder->DestroyLayer(layerId);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ namespace skyline::soc::gm20b {
|
|||||||
* @brief Calls an engine method with the given parameters
|
* @brief Calls an engine method with the given parameters
|
||||||
*/
|
*/
|
||||||
void CallMethod(u32 method, u32 argument, bool lastCall) {
|
void CallMethod(u32 method, u32 argument, bool lastCall) {
|
||||||
state.logger->Warn("Called method in unimplemented engine: 0x{:X} args: 0x{:X}", method, argument);
|
Logger::Warn("Called method in unimplemented engine: 0x{:X} args: 0x{:X}", method, argument);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace skyline::soc::gm20b::engine {
|
|||||||
GPFIFO::GPFIFO(const DeviceState &state, ChannelContext &channelCtx) : Engine(state), channelCtx(channelCtx) {}
|
GPFIFO::GPFIFO(const DeviceState &state, ChannelContext &channelCtx) : Engine(state), channelCtx(channelCtx) {}
|
||||||
|
|
||||||
void GPFIFO::CallMethod(u32 method, u32 argument, bool lastCall) {
|
void GPFIFO::CallMethod(u32 method, u32 argument, bool lastCall) {
|
||||||
state.logger->Debug("Called method in GPFIFO: 0x{:X} args: 0x{:X}", method, argument);
|
Logger::Debug("Called method in GPFIFO: 0x{:X} args: 0x{:X}", method, argument);
|
||||||
|
|
||||||
registers.raw[method] = argument;
|
registers.raw[method] = argument;
|
||||||
|
|
||||||
@ -27,11 +27,11 @@ namespace skyline::soc::gm20b::engine {
|
|||||||
switch (method) {
|
switch (method) {
|
||||||
GPFIFO_STRUCT_CASE(syncpoint, action, {
|
GPFIFO_STRUCT_CASE(syncpoint, action, {
|
||||||
if (action.operation == Registers::SyncpointOperation::Incr) {
|
if (action.operation == Registers::SyncpointOperation::Incr) {
|
||||||
state.logger->Debug("Increment syncpoint: {}", +action.index);
|
Logger::Debug("Increment syncpoint: {}", +action.index);
|
||||||
channelCtx.executor.Execute();
|
channelCtx.executor.Execute();
|
||||||
state.soc->host1x.syncpoints.at(action.index).Increment();
|
state.soc->host1x.syncpoints.at(action.index).Increment();
|
||||||
} else if (action.operation == Registers::SyncpointOperation::Wait) {
|
} else if (action.operation == Registers::SyncpointOperation::Wait) {
|
||||||
state.logger->Debug("Wait syncpoint: {}, thresh: {}", +action.index, registers.syncpoint.payload);
|
Logger::Debug("Wait syncpoint: {}, thresh: {}", +action.index, registers.syncpoint.payload);
|
||||||
|
|
||||||
// Wait forever for another channel to increment
|
// Wait forever for another channel to increment
|
||||||
state.soc->host1x.syncpoints.at(action.index).Wait(registers.syncpoint.payload, std::chrono::steady_clock::duration::max());
|
state.soc->host1x.syncpoints.at(action.index).Wait(registers.syncpoint.payload, std::chrono::steady_clock::duration::max());
|
||||||
|
@ -76,7 +76,7 @@ namespace skyline::soc::gm20b::engine::maxwell3d {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Maxwell3D::CallMethod(u32 method, u32 argument, bool lastCall) {
|
void Maxwell3D::CallMethod(u32 method, u32 argument, bool lastCall) {
|
||||||
state.logger->Debug("Called method in Maxwell 3D: 0x{:X} args: 0x{:X}", method, argument);
|
Logger::Debug("Called method in Maxwell 3D: 0x{:X} args: 0x{:X}", method, argument);
|
||||||
|
|
||||||
// Methods that are greater than the register size are for macro control
|
// Methods that are greater than the register size are for macro control
|
||||||
if (method >= RegisterCount) [[unlikely]] {
|
if (method >= RegisterCount) [[unlikely]] {
|
||||||
@ -248,7 +248,7 @@ namespace skyline::soc::gm20b::engine::maxwell3d {
|
|||||||
})
|
})
|
||||||
|
|
||||||
MAXWELL3D_CASE(syncpointAction, {
|
MAXWELL3D_CASE(syncpointAction, {
|
||||||
state.logger->Debug("Increment syncpoint: {}", static_cast<u16>(syncpointAction.id));
|
Logger::Debug("Increment syncpoint: {}", static_cast<u16>(syncpointAction.id));
|
||||||
channelCtx.executor.Execute();
|
channelCtx.executor.Execute();
|
||||||
state.soc->host1x.syncpoints.at(syncpointAction.id).Increment();
|
state.soc->host1x.syncpoints.at(syncpointAction.id).Increment();
|
||||||
})
|
})
|
||||||
@ -270,14 +270,14 @@ namespace skyline::soc::gm20b::engine::maxwell3d {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
state.logger->Warn("Unsupported semaphore counter type: 0x{:X}", static_cast<u8>(info.counterType));
|
Logger::Warn("Unsupported semaphore counter type: 0x{:X}", static_cast<u8>(info.counterType));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
state.logger->Warn("Unsupported semaphore operation: 0x{:X}", static_cast<u8>(info.op));
|
Logger::Warn("Unsupported semaphore operation: 0x{:X}", static_cast<u8>(info.op));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -73,7 +73,7 @@ namespace skyline::soc::gm20b {
|
|||||||
constexpr u32 TwoDSubChannel{3};
|
constexpr u32 TwoDSubChannel{3};
|
||||||
constexpr u32 CopySubChannel{4}; // HW forces a memory flush on a switch from this subchannel to others
|
constexpr u32 CopySubChannel{4}; // HW forces a memory flush on a switch from this subchannel to others
|
||||||
|
|
||||||
state.logger->Debug("Called GPU method - method: 0x{:X} argument: 0x{:X} subchannel: 0x{:X} last: {}", method, argument, subChannel, lastCall);
|
Logger::Debug("Called GPU method - method: 0x{:X} argument: 0x{:X} subchannel: 0x{:X} last: {}", method, argument, subChannel, lastCall);
|
||||||
|
|
||||||
if (method < engine::GPFIFO::RegisterCount) {
|
if (method < engine::GPFIFO::RegisterCount) {
|
||||||
gpfifoEngine.CallMethod(method, argument, lastCall);
|
gpfifoEngine.CallMethod(method, argument, lastCall);
|
||||||
@ -107,7 +107,7 @@ namespace skyline::soc::gm20b {
|
|||||||
case GpEntry::Opcode::Nop:
|
case GpEntry::Opcode::Nop:
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
state.logger->Warn("Unsupported GpEntry control opcode used: {}", static_cast<u8>(gpEntry.opcode));
|
Logger::Warn("Unsupported GpEntry control opcode used: {}", static_cast<u8>(gpEntry.opcode));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,17 +220,17 @@ namespace skyline::soc::gm20b {
|
|||||||
signal::SetSignalHandler({SIGINT, SIGILL, SIGTRAP, SIGBUS, SIGFPE, SIGSEGV}, signal::ExceptionalSignalHandler);
|
signal::SetSignalHandler({SIGINT, SIGILL, SIGTRAP, SIGBUS, SIGFPE, SIGSEGV}, signal::ExceptionalSignalHandler);
|
||||||
|
|
||||||
gpEntries.Process([this](GpEntry gpEntry) {
|
gpEntries.Process([this](GpEntry gpEntry) {
|
||||||
state.logger->Debug("Processing pushbuffer: 0x{:X}, Size: 0x{:X}", gpEntry.Address(), +gpEntry.size);
|
Logger::Debug("Processing pushbuffer: 0x{:X}, Size: 0x{:X}", gpEntry.Address(), +gpEntry.size);
|
||||||
Process(gpEntry);
|
Process(gpEntry);
|
||||||
});
|
});
|
||||||
} catch (const signal::SignalException &e) {
|
} catch (const signal::SignalException &e) {
|
||||||
if (e.signal != SIGINT) {
|
if (e.signal != SIGINT) {
|
||||||
state.logger->Error("{}\nStack Trace:{}", e.what(), state.loader->GetStackTrace(e.frames));
|
Logger::Error("{}\nStack Trace:{}", e.what(), state.loader->GetStackTrace(e.frames));
|
||||||
signal::BlockSignal({SIGINT});
|
signal::BlockSignal({SIGINT});
|
||||||
state.process->Kill(false);
|
state.process->Kill(false);
|
||||||
}
|
}
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
state.logger->Error(e.what());
|
Logger::Error(e.what());
|
||||||
signal::BlockSignal({SIGINT});
|
signal::BlockSignal({SIGINT});
|
||||||
state.process->Kill(false);
|
state.process->Kill(false);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include "host1x.h"
|
#include "host1x.h"
|
||||||
|
|
||||||
namespace skyline::soc::host1x {
|
namespace skyline::soc::host1x {
|
||||||
Host1xClass::Host1xClass(const DeviceState &state, SyncpointSet &syncpoints) : state(state), syncpoints(syncpoints) {}
|
Host1xClass::Host1xClass(SyncpointSet &syncpoints) : syncpoints(syncpoints) {}
|
||||||
|
|
||||||
void Host1xClass::CallMethod(u32 method, u32 argument) {
|
void Host1xClass::CallMethod(u32 method, u32 argument) {
|
||||||
constexpr static u32 LoadSyncpointPayload32MethodId{0x4E}; //!< See '14.3.2.12 32-Bit Sync Point Comparison Methods' in TRM
|
constexpr static u32 LoadSyncpointPayload32MethodId{0x4E}; //!< See '14.3.2.12 32-Bit Sync Point Comparison Methods' in TRM
|
||||||
@ -17,7 +17,7 @@ namespace skyline::soc::host1x {
|
|||||||
IncrementSyncpointMethod incrSyncpoint{.raw = argument};
|
IncrementSyncpointMethod incrSyncpoint{.raw = argument};
|
||||||
|
|
||||||
// incrSyncpoint.condition doesn't matter for Host1x class increments
|
// incrSyncpoint.condition doesn't matter for Host1x class increments
|
||||||
state.logger->Debug("Increment syncpoint: {}", incrSyncpoint.index);
|
Logger::Debug("Increment syncpoint: {}", incrSyncpoint.index);
|
||||||
syncpoints.at(incrSyncpoint.index).Increment();
|
syncpoints.at(incrSyncpoint.index).Increment();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -28,14 +28,14 @@ namespace skyline::soc::host1x {
|
|||||||
|
|
||||||
case WaitSyncpoint32MethodId: {
|
case WaitSyncpoint32MethodId: {
|
||||||
u32 syncpointId{static_cast<u8>(argument)};
|
u32 syncpointId{static_cast<u8>(argument)};
|
||||||
state.logger->Debug("Wait syncpoint: {}, thresh: {}", syncpointId, syncpointPayload);
|
Logger::Debug("Wait syncpoint: {}, thresh: {}", syncpointId, syncpointPayload);
|
||||||
|
|
||||||
syncpoints.at(syncpointId).Wait(syncpointPayload, std::chrono::steady_clock::duration::max());
|
syncpoints.at(syncpointId).Wait(syncpointPayload, std::chrono::steady_clock::duration::max());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
state.logger->Error("Unknown host1x class method called: 0x{:X}", method);
|
Logger::Error("Unknown host1x class method called: 0x{:X}", method);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,11 @@ namespace skyline::soc::host1x {
|
|||||||
*/
|
*/
|
||||||
class Host1xClass {
|
class Host1xClass {
|
||||||
private:
|
private:
|
||||||
const DeviceState &state;
|
|
||||||
SyncpointSet &syncpoints;
|
SyncpointSet &syncpoints;
|
||||||
u32 syncpointPayload{}; //!< Holds the current payload for the 32-bit syncpoint comparison methods
|
u32 syncpointPayload{}; //!< Holds the current payload for the 32-bit syncpoint comparison methods
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Host1xClass(const DeviceState &state, SyncpointSet &syncpoints);
|
Host1xClass(SyncpointSet &syncpoints);
|
||||||
|
|
||||||
void CallMethod(u32 method, u32 argument);
|
void CallMethod(u32 method, u32 argument);
|
||||||
};
|
};
|
||||||
|
@ -4,11 +4,10 @@
|
|||||||
#include "nvdec.h"
|
#include "nvdec.h"
|
||||||
|
|
||||||
namespace skyline::soc::host1x {
|
namespace skyline::soc::host1x {
|
||||||
NvDecClass::NvDecClass(const DeviceState &state, std::function<void()> opDoneCallback)
|
NvDecClass::NvDecClass(std::function<void()> opDoneCallback)
|
||||||
: state(state),
|
: opDoneCallback(std::move(opDoneCallback)) {}
|
||||||
opDoneCallback(std::move(opDoneCallback)) {}
|
|
||||||
|
|
||||||
void NvDecClass::CallMethod(u32 method, u32 argument) {
|
void NvDecClass::CallMethod(u32 method, u32 argument) {
|
||||||
state.logger->Warn("Unknown NVDEC class method called: 0x{:X} argument: 0x{:X}", method, argument);
|
Logger::Warn("Unknown NVDEC class method called: 0x{:X} argument: 0x{:X}", method, argument);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,10 @@ namespace skyline::soc::host1x {
|
|||||||
*/
|
*/
|
||||||
class NvDecClass {
|
class NvDecClass {
|
||||||
private:
|
private:
|
||||||
const DeviceState &state;
|
|
||||||
std::function<void()> opDoneCallback;
|
std::function<void()> opDoneCallback;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NvDecClass(const DeviceState &state, std::function<void()> opDoneCallback);
|
NvDecClass(std::function<void()> opDoneCallback);
|
||||||
|
|
||||||
void CallMethod(u32 method, u32 argument);
|
void CallMethod(u32 method, u32 argument);
|
||||||
};
|
};
|
||||||
|
@ -4,11 +4,10 @@
|
|||||||
#include "vic.h"
|
#include "vic.h"
|
||||||
|
|
||||||
namespace skyline::soc::host1x {
|
namespace skyline::soc::host1x {
|
||||||
VicClass::VicClass(const DeviceState &state, std::function<void()> opDoneCallback)
|
VicClass::VicClass(std::function<void()> opDoneCallback)
|
||||||
: state(state),
|
: opDoneCallback(std::move(opDoneCallback)) {}
|
||||||
opDoneCallback(std::move(opDoneCallback)) {}
|
|
||||||
|
|
||||||
void VicClass::CallMethod(u32 method, u32 argument) {
|
void VicClass::CallMethod(u32 method, u32 argument) {
|
||||||
state.logger->Warn("Unknown VIC class method called: 0x{:X} argument: 0x{:X}", method, argument);
|
Logger::Warn("Unknown VIC class method called: 0x{:X} argument: 0x{:X}", method, argument);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,10 @@ namespace skyline::soc::host1x {
|
|||||||
*/
|
*/
|
||||||
class VicClass {
|
class VicClass {
|
||||||
private:
|
private:
|
||||||
const DeviceState &state;
|
|
||||||
std::function<void()> opDoneCallback;
|
std::function<void()> opDoneCallback;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VicClass(const DeviceState &state, std::function<void()> opDoneCallback);
|
VicClass(std::function<void()> opDoneCallback);
|
||||||
|
|
||||||
void CallMethod(u32 method, u32 argument);
|
void CallMethod(u32 method, u32 argument);
|
||||||
};
|
};
|
||||||
|
@ -44,10 +44,10 @@ namespace skyline::soc::host1x {
|
|||||||
};
|
};
|
||||||
static_assert(sizeof(ChannelCommandFifoMethodHeader) == sizeof(u32));
|
static_assert(sizeof(ChannelCommandFifoMethodHeader) == sizeof(u32));
|
||||||
|
|
||||||
ChannelCommandFifo::ChannelCommandFifo(const DeviceState &state, SyncpointSet &syncpoints) : state(state), gatherQueue(GatherQueueSize), host1XClass(state, syncpoints), nvDecClass(state, syncpoints), vicClass(state, syncpoints) {}
|
ChannelCommandFifo::ChannelCommandFifo(const DeviceState &state, SyncpointSet &syncpoints) : state(state), gatherQueue(GatherQueueSize), host1XClass(syncpoints), nvDecClass(syncpoints), vicClass(syncpoints) {}
|
||||||
|
|
||||||
void ChannelCommandFifo::Send(ClassId targetClass, u32 method, u32 argument) {
|
void ChannelCommandFifo::Send(ClassId targetClass, u32 method, u32 argument) {
|
||||||
state.logger->Verbose("Calling method in class: 0x{:X}, method: 0x{:X}, argument: 0x{:X}", targetClass, method, argument);
|
Logger::Verbose("Calling method in class: 0x{:X}, method: 0x{:X}, argument: 0x{:X}", targetClass, method, argument);
|
||||||
|
|
||||||
switch (targetClass) {
|
switch (targetClass) {
|
||||||
case ClassId::Host1x:
|
case ClassId::Host1x:
|
||||||
@ -60,7 +60,7 @@ namespace skyline::soc::host1x {
|
|||||||
vicClass.CallMethod(method, argument);
|
vicClass.CallMethod(method, argument);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
state.logger->Error("Sending method to unimplemented class: 0x{:X}", targetClass);
|
Logger::Error("Sending method to unimplemented class: 0x{:X}", targetClass);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,17 +118,17 @@ namespace skyline::soc::host1x {
|
|||||||
signal::SetSignalHandler({SIGINT, SIGILL, SIGTRAP, SIGBUS, SIGFPE, SIGSEGV}, signal::ExceptionalSignalHandler);
|
signal::SetSignalHandler({SIGINT, SIGILL, SIGTRAP, SIGBUS, SIGFPE, SIGSEGV}, signal::ExceptionalSignalHandler);
|
||||||
|
|
||||||
gatherQueue.Process([this](span<u32> gather) {
|
gatherQueue.Process([this](span<u32> gather) {
|
||||||
state.logger->Debug("Processing pushbuffer: 0x{:X}, size: 0x{:X}", gather.data(), gather.size());
|
Logger::Debug("Processing pushbuffer: 0x{:X}, size: 0x{:X}", gather.data(), gather.size());
|
||||||
Process(gather);
|
Process(gather);
|
||||||
});
|
});
|
||||||
} catch (const signal::SignalException &e) {
|
} catch (const signal::SignalException &e) {
|
||||||
if (e.signal != SIGINT) {
|
if (e.signal != SIGINT) {
|
||||||
state.logger->Error("{}\nStack Trace:{}", e.what(), state.loader->GetStackTrace(e.frames));
|
Logger::Error("{}\nStack Trace:{}", e.what(), state.loader->GetStackTrace(e.frames));
|
||||||
signal::BlockSignal({SIGINT});
|
signal::BlockSignal({SIGINT});
|
||||||
state.process->Kill(false);
|
state.process->Kill(false);
|
||||||
}
|
}
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
state.logger->Error(e.what());
|
Logger::Error(e.what());
|
||||||
signal::BlockSignal({SIGINT});
|
signal::BlockSignal({SIGINT});
|
||||||
state.process->Kill(false);
|
state.process->Kill(false);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ namespace skyline::soc::host1x {
|
|||||||
template<typename ClassType>
|
template<typename ClassType>
|
||||||
class TegraHostInterface {
|
class TegraHostInterface {
|
||||||
private:
|
private:
|
||||||
const DeviceState &state;
|
|
||||||
SyncpointSet &syncpoints;
|
SyncpointSet &syncpoints;
|
||||||
ClassType deviceClass; //!< The device class behind the THI, such as NVDEC or VIC
|
ClassType deviceClass; //!< The device class behind the THI, such as NVDEC or VIC
|
||||||
|
|
||||||
@ -31,15 +30,14 @@ namespace skyline::soc::host1x {
|
|||||||
u32 syncpointId{incrQueue.front()};
|
u32 syncpointId{incrQueue.front()};
|
||||||
incrQueue.pop();
|
incrQueue.pop();
|
||||||
|
|
||||||
state.logger->Debug("Increment syncpoint: {}", syncpointId);
|
Logger::Debug("Increment syncpoint: {}", syncpointId);
|
||||||
syncpoints.at(syncpointId).Increment();
|
syncpoints.at(syncpointId).Increment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TegraHostInterface(const DeviceState &state, SyncpointSet &syncpoints)
|
TegraHostInterface(SyncpointSet &syncpoints)
|
||||||
: state(state),
|
: deviceClass([&] { SubmitPendingIncrs(); }),
|
||||||
deviceClass(state, [&] { SubmitPendingIncrs(); }),
|
|
||||||
syncpoints(syncpoints) {}
|
syncpoints(syncpoints) {}
|
||||||
|
|
||||||
void CallMethod(u32 method, u32 argument) {
|
void CallMethod(u32 method, u32 argument) {
|
||||||
@ -52,16 +50,16 @@ namespace skyline::soc::host1x {
|
|||||||
|
|
||||||
switch (incrSyncpoint.condition) {
|
switch (incrSyncpoint.condition) {
|
||||||
case IncrementSyncpointMethod::Condition::Immediate:
|
case IncrementSyncpointMethod::Condition::Immediate:
|
||||||
state.logger->Debug("Increment syncpoint: {}", incrSyncpoint.index);
|
Logger::Debug("Increment syncpoint: {}", incrSyncpoint.index);
|
||||||
syncpoints.at(incrSyncpoint.index).Increment();
|
syncpoints.at(incrSyncpoint.index).Increment();
|
||||||
break;
|
break;
|
||||||
case IncrementSyncpointMethod::Condition::OpDone:
|
case IncrementSyncpointMethod::Condition::OpDone:
|
||||||
state.logger->Debug("Queue syncpoint for OpDone: {}", incrSyncpoint.index);
|
Logger::Debug("Queue syncpoint for OpDone: {}", incrSyncpoint.index);
|
||||||
incrQueue.push(incrSyncpoint.index);
|
incrQueue.push(incrSyncpoint.index);
|
||||||
|
|
||||||
SubmitPendingIncrs(); // FIXME: immediately submit the incrs as classes are not yet implemented
|
SubmitPendingIncrs(); // FIXME: immediately submit the incrs as classes are not yet implemented
|
||||||
default:
|
default:
|
||||||
state.logger->Warn("Unimplemented syncpoint condition: {}", static_cast<u8>(incrSyncpoint.condition));
|
Logger::Warn("Unimplemented syncpoint condition: {}", static_cast<u8>(incrSyncpoint.condition));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -73,7 +71,7 @@ namespace skyline::soc::host1x {
|
|||||||
deviceClass.CallMethod(storedMethod, argument);
|
deviceClass.CallMethod(storedMethod, argument);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
state.logger->Error("Unknown THI method called: 0x{:X}, argument: 0x{:X}", method, argument);
|
Logger::Error("Unknown THI method called: 0x{:X}, argument: 0x{:X}", method, argument);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ namespace skyline::vfs {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
NPDM::NPDM(const std::shared_ptr<vfs::Backing> &backing, const DeviceState &state) {
|
NPDM::NPDM(const std::shared_ptr<vfs::Backing> &backing) {
|
||||||
meta = backing->Read<NpdmMeta>();
|
meta = backing->Read<NpdmMeta>();
|
||||||
if (meta.magic != MetaMagic)
|
if (meta.magic != MetaMagic)
|
||||||
throw exception("NPDM Meta Magic isn't correct: 0x{:X} (\"META\" = 0x{:X})", meta.magic, MetaMagic);
|
throw exception("NPDM Meta Magic isn't correct: 0x{:X} (\"META\" = 0x{:X})", meta.magic, MetaMagic);
|
||||||
@ -77,6 +77,6 @@ namespace skyline::vfs {
|
|||||||
if (!threadInfo.coreMask.test(meta.idealCore))
|
if (!threadInfo.coreMask.test(meta.idealCore))
|
||||||
throw exception("NPDM Ideal Core isn't valid: {} ({})", meta.idealCore, threadInfo.coreMask);
|
throw exception("NPDM Ideal Core isn't valid: {} ({})", meta.idealCore, threadInfo.coreMask);
|
||||||
|
|
||||||
state.logger->Debug("NPDM Metadata:\nTitle: ID: {:X}, Version: {}\nMain Thread: Priority: {}, Stack Size: 0x{:X}\nScheduler: Ideal Core: {}, Core Mask: {}, Priority: {} - {}\nKernel Version: v{}.{}", aci0.programId, meta.version, meta.mainThreadPriority, meta.mainThreadStackSize, meta.idealCore, threadInfo.coreMask, threadInfo.priority.min, threadInfo.priority.max, kernelVersion.majorVersion, kernelVersion.minorVersion);
|
Logger::Debug("NPDM Metadata:\nTitle: ID: {:X}, Version: {}\nMain Thread: Priority: {}, Stack Size: 0x{:X}\nScheduler: Ideal Core: {}, Core Mask: {}, Priority: {} - {}\nKernel Version: v{}.{}", aci0.programId, meta.version, meta.mainThreadPriority, meta.mainThreadStackSize, meta.idealCore, threadInfo.coreMask, threadInfo.priority.min, threadInfo.priority.max, kernelVersion.majorVersion, kernelVersion.minorVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ namespace skyline {
|
|||||||
public:
|
public:
|
||||||
NPDM();
|
NPDM();
|
||||||
|
|
||||||
NPDM(const std::shared_ptr<vfs::Backing> &backing, const DeviceState &state);
|
NPDM(const std::shared_ptr<vfs::Backing> &backing);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user