diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/logging/backend.cpp | 3 | ||||
-rw-r--r-- | src/common/logging/log.h | 1 | ||||
-rw-r--r-- | src/core/gdbstub/gdbstub.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/ipc.h | 7 | ||||
-rw-r--r-- | src/core/hle/kernel/domain.cpp | 21 | ||||
-rw-r--r-- | src/core/hle/kernel/hle_ipc.cpp | 10 | ||||
-rw-r--r-- | src/core/hle/kernel/svc.cpp | 10 | ||||
-rw-r--r-- | src/core/hle/service/nvdrv/interface.cpp | 13 | ||||
-rw-r--r-- | src/core/hle/service/nvdrv/interface.h | 1 | ||||
-rw-r--r-- | src/core/hle/service/nvdrv/nvdrv.cpp | 10 | ||||
-rw-r--r-- | src/core/hle/service/nvdrv/nvdrv.h | 2 | ||||
-rw-r--r-- | src/yuzu_cmd/default_ini.h | 4 |
12 files changed, 71 insertions, 13 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 13f915a01..ba0acfb72 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -43,6 +43,7 @@ namespace Log { SUB(HW, LCD) \ SUB(HW, GPU) \ SUB(HW, AES) \ + CLS(IPC) \ CLS(Frontend) \ CLS(Render) \ SUB(Render, Software) \ @@ -91,8 +92,8 @@ const char* GetLevelName(Level log_level) { Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr, const char* function, const char* format, va_list args) { - using std::chrono::steady_clock; using std::chrono::duration_cast; + using std::chrono::steady_clock; static steady_clock::time_point time_origin = steady_clock::now(); diff --git a/src/common/logging/log.h b/src/common/logging/log.h index 35b5af3cb..57021037a 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h @@ -60,6 +60,7 @@ enum class Class : ClassType { HW_LCD, ///< LCD register emulation HW_GPU, ///< GPU control emulation HW_AES, ///< AES engine emulation + IPC, ///< IPC interface Frontend, ///< Emulator UI Render, ///< Emulator video output and hardware acceleration Render_Software, ///< Software renderer backend diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index dedbd4bdf..05c872d89 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp @@ -905,7 +905,7 @@ void ToggleServer(bool status) { server_enabled = status; // Start server - if (!IsConnected() && Core::System().GetInstance().IsPoweredOn()) { + if (!IsConnected() && Core::System::GetInstance().IsPoweredOn()) { Init(); } } else { diff --git a/src/core/hle/ipc.h b/src/core/hle/ipc.h index 88ba105e5..1840fac12 100644 --- a/src/core/hle/ipc.h +++ b/src/core/hle/ipc.h @@ -143,6 +143,11 @@ struct DataPayloadHeader { static_assert(sizeof(DataPayloadHeader) == 8, "DataPayloadRequest size is incorrect"); struct DomainMessageHeader { + enum class CommandType : u32_le { + SendMessage = 1, + CloseVirtualHandle = 2, + }; + union { // Used when responding to an IPC request, Server -> Client. struct { @@ -153,7 +158,7 @@ struct DomainMessageHeader { // Used when performing an IPC request, Client -> Server. struct { union { - BitField<0, 8, u32_le> command; + BitField<0, 8, CommandType> command; BitField<16, 16, u32_le> size; }; u32_le object_id; diff --git a/src/core/hle/kernel/domain.cpp b/src/core/hle/kernel/domain.cpp index 7ebb4b9c7..5035e9c08 100644 --- a/src/core/hle/kernel/domain.cpp +++ b/src/core/hle/kernel/domain.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/logging/log.h" +#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/client_port.h" #include "core/hle/kernel/domain.h" #include "core/hle/kernel/handle_table.h" @@ -36,7 +38,24 @@ ResultCode Domain::SendSyncRequest(SharedPtr<Thread> thread) { if (domain_message_header) { // If there is a DomainMessageHeader, then this is CommandType "Request" const u32 object_id{context.GetDomainMessageHeader()->object_id}; - return request_handlers[object_id - 1]->HandleSyncRequest(context); + switch (domain_message_header->command) { + case IPC::DomainMessageHeader::CommandType::SendMessage: + return request_handlers[object_id - 1]->HandleSyncRequest(context); + + case IPC::DomainMessageHeader::CommandType::CloseVirtualHandle: { + LOG_DEBUG(IPC, "CloseVirtualHandle, object_id=0x%08X", object_id); + + request_handlers[object_id - 1] = nullptr; + + IPC::RequestBuilder rb{context, 2}; + rb.Push(RESULT_SUCCESS); + + return RESULT_SUCCESS; + } + } + + LOG_CRITICAL(IPC, "Unknown domain command=%d", domain_message_header->command.Value()); + UNIMPLEMENTED(); } return request_handlers.front()->HandleSyncRequest(context); } diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index afa09b404..ac62a0d5a 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -102,13 +102,21 @@ void HLERequestContext::ParseCommandBuffer(u32_le* src_cmdbuf, bool incoming) { data_payload_header = std::make_unique<IPC::DataPayloadHeader>(rp.PopRaw<IPC::DataPayloadHeader>()); + data_payload_offset = rp.GetCurrentOffset(); + + if (domain_message_header && + domain_message_header->command == + IPC::DomainMessageHeader::CommandType::CloseVirtualHandle) { + // CloseVirtualHandle command does not have SFC* or any data + return; + } + if (incoming) { ASSERT(data_payload_header->magic == Common::MakeMagic('S', 'F', 'C', 'I')); } else { ASSERT(data_payload_header->magic == Common::MakeMagic('S', 'F', 'C', 'O')); } - data_payload_offset = rp.GetCurrentOffset(); command = rp.Pop<u32_le>(); rp.Skip(1, false); // The command is actually an u64, but we don't use the high part. } diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 088058ebc..6401af35a 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -255,9 +255,8 @@ static ResultCode CancelSynchronization(Handle thread_handle) { /// Attempts to locks a mutex, creating it if it does not already exist static ResultCode LockMutex(Handle holding_thread_handle, VAddr mutex_addr, Handle requesting_thread_handle) { - LOG_TRACE(Kernel_SVC, - "called holding_thread_handle=0x%08X, mutex_addr=0x%llx, " - "requesting_current_thread_handle=0x%08X", + LOG_TRACE(Kernel_SVC, "called holding_thread_handle=0x%08X, mutex_addr=0x%llx, " + "requesting_current_thread_handle=0x%08X", holding_thread_handle, mutex_addr, requesting_thread_handle); SharedPtr<Thread> holding_thread = g_handle_table.Get<Thread>(holding_thread_handle); @@ -547,9 +546,8 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V Core::System::GetInstance().PrepareReschedule(); - LOG_TRACE(Kernel_SVC, - "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, " - "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", + LOG_TRACE(Kernel_SVC, "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, " + "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point, name.c_str(), arg, stack_top, priority, processor_id, *out_handle); return RESULT_SUCCESS; diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp index 0670ca155..848615fa7 100644 --- a/src/core/hle/service/nvdrv/interface.cpp +++ b/src/core/hle/service/nvdrv/interface.cpp @@ -48,6 +48,18 @@ void NVDRV::Ioctl(Kernel::HLERequestContext& ctx) { rb.Push(nv_result); } +void NVDRV::Close(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called"); + + IPC::RequestParser rp{ctx}; + u32 fd = rp.Pop<u32>(); + + auto result = nvdrv->Close(fd); + + IPC::RequestBuilder rb{ctx, 2}; + rb.Push(result); +} + void NVDRV::Initialize(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service, "(STUBBED) called"); IPC::RequestBuilder rb{ctx, 3}; @@ -60,6 +72,7 @@ NVDRV::NVDRV(std::shared_ptr<Module> nvdrv, const char* name) static const FunctionInfo functions[] = { {0, &NVDRV::Open, "Open"}, {1, &NVDRV::Ioctl, "Ioctl"}, + {2, &NVDRV::Close, "Close"}, {3, &NVDRV::Initialize, "Initialize"}, }; RegisterHandlers(functions); diff --git a/src/core/hle/service/nvdrv/interface.h b/src/core/hle/service/nvdrv/interface.h index 8c95b7217..1b9aa9938 100644 --- a/src/core/hle/service/nvdrv/interface.h +++ b/src/core/hle/service/nvdrv/interface.h @@ -20,6 +20,7 @@ public: private: void Open(Kernel::HLERequestContext& ctx); void Ioctl(Kernel::HLERequestContext& ctx); + void Close(Kernel::HLERequestContext& ctx); void Initialize(Kernel::HLERequestContext& ctx); std::shared_ptr<Module> nvdrv; diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index cf525a875..9b73886bb 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp @@ -49,5 +49,15 @@ u32 Module::Ioctl(u32 fd, u32 command, const std::vector<u8>& input, std::vector return device->ioctl(command, input, output); } +ResultCode Module::Close(u32 fd) { + auto itr = open_files.find(fd); + ASSERT_MSG(itr != open_files.end(), "Tried to talk to an invalid device"); + + open_files.erase(itr); + + // TODO(flerovium): return correct result code if operation failed. + return RESULT_SUCCESS; +} + } // namespace Nvidia } // namespace Service diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index 1940ced99..e44644624 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h @@ -35,6 +35,8 @@ public: u32 Open(std::string device_name); /// Sends an ioctl command to the specified file descriptor. u32 Ioctl(u32 fd, u32 command, const std::vector<u8>& input, std::vector<u8>& output); + /// Closes a device file descriptor and returns operation success. + ResultCode Close(u32 fd); private: /// Id to use for the next open file descriptor. diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index 5a2f539b1..156f7a1a4 100644 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h @@ -124,8 +124,8 @@ custom_bottom_top = custom_bottom_right = custom_bottom_bottom = -#Whether to toggle frame limiter on or off. -# 0: Off , 1 (default): On +# Whether to toggle frame limiter on or off. +# 0: Off, 1 (default): On toggle_framelimit = # Swaps the prominent screen with the other screen. |