diff options
Diffstat (limited to 'src/core')
26 files changed, 253 insertions, 121 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 780008b08..5b6c7792e 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -68,9 +68,9 @@ struct KernelCore::Impl { InitializePhysicalCores(); InitializeSystemResourceLimit(kernel, system); InitializeMemoryLayout(); - InitializePreemption(kernel); InitializeSchedulers(); InitializeSuspendThreads(); + InitializePreemption(kernel); } void InitializeCores() { diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 8e1fe9438..d91237cba 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -295,7 +295,7 @@ ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nv {80, nullptr, "SetWirelessPriorityMode"}, {90, &ISelfController::GetAccumulatedSuspendedTickValue, "GetAccumulatedSuspendedTickValue"}, {91, &ISelfController::GetAccumulatedSuspendedTickChangedEvent, "GetAccumulatedSuspendedTickChangedEvent"}, - {100, nullptr, "SetAlbumImageTakenNotificationEnabled"}, + {100, &ISelfController::SetAlbumImageTakenNotificationEnabled, "SetAlbumImageTakenNotificationEnabled"}, {110, nullptr, "SetApplicationAlbumUserData"}, {1000, nullptr, "GetDebugStorageChannel"}, }; @@ -560,6 +560,21 @@ void ISelfController::GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequest rb.PushCopyObjects(accumulated_suspended_tick_changed_event->GetReadableEvent()); } +void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + + // This service call sets an internal flag whether a notification is shown when an image is + // captured. Currently we do not support capturing images via the capture button, so this can be + // stubbed for now. + const bool album_image_taken_notification_enabled = rp.Pop<bool>(); + + LOG_WARNING(Service_AM, "(STUBBED) called. album_image_taken_notification_enabled={}", + album_image_taken_notification_enabled); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); +} + AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel) { on_new_message = Kernel::KEvent::Create(kernel, "AMMessageQueue:OnMessageReceived"); on_new_message->Initialize(); diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 6911f0d6e..f6a453ab7 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -146,6 +146,7 @@ private: void IsAutoSleepDisabled(Kernel::HLERequestContext& ctx); void GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx); void GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx); + void SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestContext& ctx); enum class ScreenshotPermission : u32 { Inherit = 0, diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp index 72a877d68..0a6621ef2 100644 --- a/src/core/hle/service/friend/friend.cpp +++ b/src/core/hle/service/friend/friend.cpp @@ -133,7 +133,7 @@ private: void GetBlockedUserListIds(Kernel::HLERequestContext& ctx) { // This is safe to stub, as there should be no adverse consequences from reporting no // blocked users. - LOG_WARNING(Service_ACC, "(STUBBED) called"); + LOG_WARNING(Service_Friend, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(RESULT_SUCCESS); rb.Push<u32>(0); // Indicates there are no blocked users @@ -141,14 +141,14 @@ private: void DeclareCloseOnlinePlaySession(Kernel::HLERequestContext& ctx) { // Stub used by Splatoon 2 - LOG_WARNING(Service_ACC, "(STUBBED) called"); + LOG_WARNING(Service_Friend, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); } void UpdateUserPresence(Kernel::HLERequestContext& ctx) { // Stub used by Retro City Rampage - LOG_WARNING(Service_ACC, "(STUBBED) called"); + LOG_WARNING(Service_Friend, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); } @@ -159,7 +159,7 @@ private: const auto uuid = rp.PopRaw<Common::UUID>(); [[maybe_unused]] const auto filter = rp.PopRaw<SizedFriendFilter>(); const auto pid = rp.Pop<u64>(); - LOG_WARNING(Service_ACC, "(STUBBED) called, offset={}, uuid={}, pid={}", friend_offset, + LOG_WARNING(Service_Friend, "(STUBBED) called, offset={}, uuid={}, pid={}", friend_offset, uuid.Format(), pid); IPC::ResponseBuilder rb{ctx, 3}; @@ -191,7 +191,7 @@ public: private: void GetEvent(Kernel::HLERequestContext& ctx) { - LOG_DEBUG(Service_ACC, "called"); + LOG_DEBUG(Service_Friend, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); @@ -199,7 +199,7 @@ private: } void Clear(Kernel::HLERequestContext& ctx) { - LOG_DEBUG(Service_ACC, "called"); + LOG_DEBUG(Service_Friend, "called"); while (!notifications.empty()) { notifications.pop(); } @@ -210,10 +210,10 @@ private: } void Pop(Kernel::HLERequestContext& ctx) { - LOG_DEBUG(Service_ACC, "called"); + LOG_DEBUG(Service_Friend, "called"); if (notifications.empty()) { - LOG_ERROR(Service_ACC, "No notifications in queue!"); + LOG_ERROR(Service_Friend, "No notifications in queue!"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ERR_NO_NOTIFICATIONS); return; @@ -231,7 +231,8 @@ private: break; default: // HOS seems not have an error case for an unknown notification - LOG_WARNING(Service_ACC, "Unknown notification {:08X}", notification.notification_type); + LOG_WARNING(Service_Friend, "Unknown notification {:08X}", + notification.notification_type); break; } @@ -269,14 +270,14 @@ void Module::Interface::CreateFriendService(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); rb.PushIpcInterface<IFriendService>(system); - LOG_DEBUG(Service_ACC, "called"); + LOG_DEBUG(Service_Friend, "called"); } void Module::Interface::CreateNotificationService(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; auto uuid = rp.PopRaw<Common::UUID>(); - LOG_DEBUG(Service_ACC, "called, uuid={}", uuid.Format()); + LOG_DEBUG(Service_Friend, "called, uuid={}", uuid.Format()); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp index e7063f8ef..93c43a203 100644 --- a/src/core/hle/service/hid/controllers/gesture.cpp +++ b/src/core/hle/service/hid/controllers/gesture.cpp @@ -4,6 +4,7 @@ #include <cstring> #include "common/common_types.h" +#include "common/logging/log.h" #include "core/core_timing.h" #include "core/frontend/emu_window.h" #include "core/hle/service/hid/controllers/gesture.h" @@ -19,9 +20,9 @@ Controller_Gesture::~Controller_Gesture() = default; void Controller_Gesture::OnInit() { for (std::size_t id = 0; id < MAX_FINGERS; ++id) { - mouse_finger_id[id] = MAX_FINGERS; - keyboard_finger_id[id] = MAX_FINGERS; - udp_finger_id[id] = MAX_FINGERS; + mouse_finger_id[id] = MAX_POINTS; + keyboard_finger_id[id] = MAX_POINTS; + udp_finger_id[id] = MAX_POINTS; } } @@ -142,6 +143,10 @@ std::optional<std::size_t> Controller_Gesture::GetUnusedFingerID() const { std::size_t Controller_Gesture::UpdateTouchInputEvent( const std::tuple<float, float, bool>& touch_input, std::size_t finger_id) { const auto& [x, y, pressed] = touch_input; + if (finger_id > MAX_POINTS) { + LOG_ERROR(Service_HID, "Invalid finger id {}", finger_id); + return MAX_POINTS; + } if (pressed) { if (finger_id == MAX_POINTS) { const auto first_free_id = GetUnusedFingerID(); diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index 5219f2dad..be60492a4 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp @@ -5,6 +5,7 @@ #include <algorithm> #include <cstring> #include "common/common_types.h" +#include "common/logging/log.h" #include "core/core_timing.h" #include "core/frontend/emu_window.h" #include "core/frontend/input.h" @@ -118,6 +119,10 @@ std::optional<std::size_t> Controller_Touchscreen::GetUnusedFingerID() const { std::size_t Controller_Touchscreen::UpdateTouchInputEvent( const std::tuple<float, float, bool>& touch_input, std::size_t finger_id) { const auto& [x, y, pressed] = touch_input; + if (finger_id > MAX_FINGERS) { + LOG_ERROR(Service_HID, "Invalid finger id {}", finger_id); + return MAX_FINGERS; + } if (pressed) { Attributes attribute{}; if (finger_id == MAX_FINGERS) { diff --git a/src/core/hle/service/nvdrv/devices/nvdevice.h b/src/core/hle/service/nvdrv/devices/nvdevice.h index 5681599ba..b37f023df 100644 --- a/src/core/hle/service/nvdrv/devices/nvdevice.h +++ b/src/core/hle/service/nvdrv/devices/nvdevice.h @@ -31,7 +31,7 @@ public: * @param output A buffer where the output data will be written to. * @returns The result code of the ioctl. */ - virtual NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, + virtual NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) = 0; /** @@ -42,7 +42,7 @@ public: * @param output A buffer where the output data will be written to. * @returns The result code of the ioctl. */ - virtual NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, + virtual NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) = 0; /** @@ -53,8 +53,20 @@ public: * @param inline_output A buffer where the inlined output data will be written to. * @returns The result code of the ioctl. */ - virtual NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_output) = 0; + virtual NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_output) = 0; + + /** + * Called once a device is openned + * @param fd The device fd + */ + virtual void OnOpen(DeviceFD fd) = 0; + + /** + * Called once a device is closed + * @param fd The device fd + */ + virtual void OnClose(DeviceFD fd) = 0; protected: Core::System& system; diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp index ce615c758..5ab7e39b0 100644 --- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp +++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp @@ -18,24 +18,27 @@ nvdisp_disp0::nvdisp_disp0(Core::System& system, std::shared_ptr<nvmap> nvmap_de : nvdevice(system), nvmap_dev(std::move(nvmap_dev)) {} nvdisp_disp0 ::~nvdisp_disp0() = default; -NvResult nvdisp_disp0::Ioctl1(Ioctl command, const std::vector<u8>& input, +NvResult nvdisp_disp0::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); return NvResult::NotImplemented; } -NvResult nvdisp_disp0::Ioctl2(Ioctl command, const std::vector<u8>& input, +NvResult nvdisp_disp0::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) { UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); return NvResult::NotImplemented; } -NvResult nvdisp_disp0::Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_output) { +NvResult nvdisp_disp0::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_output) { UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); return NvResult::NotImplemented; } +void nvdisp_disp0::OnOpen(DeviceFD fd) {} +void nvdisp_disp0::OnClose(DeviceFD fd) {} + void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u32 height, u32 stride, NVFlinger::BufferQueue::BufferTransformFlags transform, const Common::Rectangle<int>& crop_rect) { diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h index 55a33b7e4..59c9b6101 100644 --- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h +++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h @@ -20,11 +20,15 @@ public: explicit nvdisp_disp0(Core::System& system, std::shared_ptr<nvmap> nvmap_dev); ~nvdisp_disp0() override; - NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; - NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, + NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output) override; + NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) override; - NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_output) override; + NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_output) override; + + void OnOpen(DeviceFD fd) override; + void OnClose(DeviceFD fd) override; /// Performs a screen flip, drawing the buffer pointed to by the handle. void flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u32 height, u32 stride, diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp index 6b062e10e..f7b3dc317 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp @@ -21,7 +21,7 @@ nvhost_as_gpu::nvhost_as_gpu(Core::System& system, std::shared_ptr<nvmap> nvmap_ : nvdevice(system), nvmap_dev(std::move(nvmap_dev)) {} nvhost_as_gpu::~nvhost_as_gpu() = default; -NvResult nvhost_as_gpu::Ioctl1(Ioctl command, const std::vector<u8>& input, +NvResult nvhost_as_gpu::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { switch (command.group) { case 'A': @@ -39,7 +39,7 @@ NvResult nvhost_as_gpu::Ioctl1(Ioctl command, const std::vector<u8>& input, case 0x8: return GetVARegions(input, output); case 0x9: - return InitalizeEx(input, output); + return AllocAsEx(input, output); case 0x14: return Remap(input, output); default: @@ -54,14 +54,14 @@ NvResult nvhost_as_gpu::Ioctl1(Ioctl command, const std::vector<u8>& input, return NvResult::NotImplemented; } -NvResult nvhost_as_gpu::Ioctl2(Ioctl command, const std::vector<u8>& input, +NvResult nvhost_as_gpu::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) { UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); return NvResult::NotImplemented; } -NvResult nvhost_as_gpu::Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_output) { +NvResult nvhost_as_gpu::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_output) { switch (command.group) { case 'A': switch (command.cmd) { @@ -78,11 +78,19 @@ NvResult nvhost_as_gpu::Ioctl3(Ioctl command, const std::vector<u8>& input, std: return NvResult::NotImplemented; } -NvResult nvhost_as_gpu::InitalizeEx(const std::vector<u8>& input, std::vector<u8>& output) { - IoctlInitalizeEx params{}; +void nvhost_as_gpu::OnOpen(DeviceFD fd) {} +void nvhost_as_gpu::OnClose(DeviceFD fd) {} + +NvResult nvhost_as_gpu::AllocAsEx(const std::vector<u8>& input, std::vector<u8>& output) { + IoctlAllocAsEx params{}; std::memcpy(¶ms, input.data(), input.size()); LOG_WARNING(Service_NVDRV, "(STUBBED) called, big_page_size=0x{:X}", params.big_page_size); + if (params.big_page_size == 0) { + params.big_page_size = DEFAULT_BIG_PAGE_SIZE; + } + + big_page_size = params.big_page_size; return NvResult::Success; } @@ -276,13 +284,18 @@ NvResult nvhost_as_gpu::GetVARegions(const std::vector<u8>& input, std::vector<u params.buf_size); params.buf_size = 0x30; - params.regions[0].offset = 0x04000000; - params.regions[0].page_size = 0x1000; - params.regions[0].pages = 0x3fbfff; - params.regions[1].offset = 0x04000000; - params.regions[1].page_size = 0x10000; - params.regions[1].pages = 0x1bffff; + params.small = IoctlVaRegion{ + .offset = 0x04000000, + .page_size = DEFAULT_SMALL_PAGE_SIZE, + .pages = 0x3fbfff, + }; + + params.big = IoctlVaRegion{ + .offset = 0x04000000, + .page_size = big_page_size, + .pages = 0x1bffff, + }; // TODO(ogniK): This probably can stay stubbed but should add support way way later @@ -299,18 +312,25 @@ NvResult nvhost_as_gpu::GetVARegions(const std::vector<u8>& input, std::vector<u params.buf_size); params.buf_size = 0x30; - params.regions[0].offset = 0x04000000; - params.regions[0].page_size = 0x1000; - params.regions[0].pages = 0x3fbfff; - params.regions[1].offset = 0x04000000; - params.regions[1].page_size = 0x10000; - params.regions[1].pages = 0x1bffff; + params.small = IoctlVaRegion{ + .offset = 0x04000000, + .page_size = 0x1000, + .pages = 0x3fbfff, + }; + + params.big = IoctlVaRegion{ + .offset = 0x04000000, + .page_size = big_page_size, + .pages = 0x1bffff, + }; // TODO(ogniK): This probably can stay stubbed but should add support way way later std::memcpy(output.data(), ¶ms, output.size()); - std::memcpy(inline_output.data(), ¶ms.regions, inline_output.size()); + std::memcpy(inline_output.data(), ¶ms.small, sizeof(IoctlVaRegion)); + std::memcpy(inline_output.data() + sizeof(IoctlVaRegion), ¶ms.big, sizeof(IoctlVaRegion)); + return NvResult::Success; } diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h index 08035fa0e..d86a9cab6 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h @@ -16,6 +16,9 @@ namespace Service::Nvidia::Devices { +constexpr u32 DEFAULT_BIG_PAGE_SIZE = 1 << 16; +constexpr u32 DEFAULT_SMALL_PAGE_SIZE = 1 << 12; + class nvmap; enum class AddressSpaceFlags : u32 { @@ -30,11 +33,15 @@ public: explicit nvhost_as_gpu(Core::System& system, std::shared_ptr<nvmap> nvmap_dev); ~nvhost_as_gpu() override; - NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; - NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, + NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output) override; + NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) override; - NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_output) override; + NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_output) override; + + void OnOpen(DeviceFD fd) override; + void OnClose(DeviceFD fd) override; private: class BufferMap final { @@ -76,16 +83,16 @@ private: bool is_allocated{}; }; - struct IoctlInitalizeEx { - u32_le big_page_size{}; // depends on GPU's available_big_page_sizes; 0=default - s32_le as_fd{}; // ignored; passes 0 - u32_le flags{}; // passes 0 - u32_le reserved{}; // ignored; passes 0 - u64_le unk0{}; - u64_le unk1{}; - u64_le unk2{}; + struct IoctlAllocAsEx { + u32_le flags{}; // usually passes 1 + s32_le as_fd{}; // ignored; passes 0 + u32_le big_page_size{}; + u32_le reserved{}; // ignored; passes 0 + u64_le va_range_start{}; + u64_le va_range_end{}; + u64_le va_range_split{}; }; - static_assert(sizeof(IoctlInitalizeEx) == 40, "IoctlInitalizeEx is incorrect size"); + static_assert(sizeof(IoctlAllocAsEx) == 40, "IoctlAllocAsEx is incorrect size"); struct IoctlAllocSpace { u32_le pages{}; @@ -149,14 +156,16 @@ private: u64_le buf_addr{}; // (contained output user ptr on linux, ignored) u32_le buf_size{}; // forced to 2*sizeof(struct va_region) u32_le reserved{}; - IoctlVaRegion regions[2]{}; + IoctlVaRegion small{}; + IoctlVaRegion big{}; }; static_assert(sizeof(IoctlGetVaRegions) == 16 + sizeof(IoctlVaRegion) * 2, "IoctlGetVaRegions is incorrect size"); s32 channel{}; + u32 big_page_size{DEFAULT_BIG_PAGE_SIZE}; - NvResult InitalizeEx(const std::vector<u8>& input, std::vector<u8>& output); + NvResult AllocAsEx(const std::vector<u8>& input, std::vector<u8>& output); NvResult AllocateSpace(const std::vector<u8>& input, std::vector<u8>& output); NvResult Remap(const std::vector<u8>& input, std::vector<u8>& output); NvResult MapBufferEx(const std::vector<u8>& input, std::vector<u8>& output); diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index f6129ef10..9f00d5cb0 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp @@ -20,7 +20,8 @@ nvhost_ctrl::nvhost_ctrl(Core::System& system, EventInterface& events_interface, : nvdevice(system), events_interface{events_interface}, syncpoint_manager{syncpoint_manager} {} nvhost_ctrl::~nvhost_ctrl() = default; -NvResult nvhost_ctrl::Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { +NvResult nvhost_ctrl::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output) { switch (command.group) { case 0x0: switch (command.cmd) { @@ -46,18 +47,21 @@ NvResult nvhost_ctrl::Ioctl1(Ioctl command, const std::vector<u8>& input, std::v return NvResult::NotImplemented; } -NvResult nvhost_ctrl::Ioctl2(Ioctl command, const std::vector<u8>& input, +NvResult nvhost_ctrl::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) { UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); return NvResult::NotImplemented; } -NvResult nvhost_ctrl::Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_outpu) { +NvResult nvhost_ctrl::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_outpu) { UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); return NvResult::NotImplemented; } +void nvhost_ctrl::OnOpen(DeviceFD fd) {} +void nvhost_ctrl::OnClose(DeviceFD fd) {} + NvResult nvhost_ctrl::NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output) { IocGetConfigParams params{}; std::memcpy(¶ms, input.data(), sizeof(params)); diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h index c5aa1362a..9178789c3 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h @@ -18,11 +18,15 @@ public: SyncpointManager& syncpoint_manager); ~nvhost_ctrl() override; - NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; - NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, + NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output) override; + NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) override; - NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_output) override; + NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_output) override; + + void OnOpen(DeviceFD fd) override; + void OnClose(DeviceFD fd) override; private: struct IocSyncptReadParams { diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp index 0320d3ae2..933d42f3f 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp @@ -15,7 +15,7 @@ namespace Service::Nvidia::Devices { nvhost_ctrl_gpu::nvhost_ctrl_gpu(Core::System& system) : nvdevice(system) {} nvhost_ctrl_gpu::~nvhost_ctrl_gpu() = default; -NvResult nvhost_ctrl_gpu::Ioctl1(Ioctl command, const std::vector<u8>& input, +NvResult nvhost_ctrl_gpu::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { switch (command.group) { case 'G': @@ -47,13 +47,13 @@ NvResult nvhost_ctrl_gpu::Ioctl1(Ioctl command, const std::vector<u8>& input, return NvResult::NotImplemented; } -NvResult nvhost_ctrl_gpu::Ioctl2(Ioctl command, const std::vector<u8>& input, +NvResult nvhost_ctrl_gpu::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) { UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); return NvResult::NotImplemented; } -NvResult nvhost_ctrl_gpu::Ioctl3(Ioctl command, const std::vector<u8>& input, +NvResult nvhost_ctrl_gpu::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, std::vector<u8>& inline_output) { switch (command.group) { case 'G': @@ -73,6 +73,9 @@ NvResult nvhost_ctrl_gpu::Ioctl3(Ioctl command, const std::vector<u8>& input, return NvResult::NotImplemented; } +void nvhost_ctrl_gpu::OnOpen(DeviceFD fd) {} +void nvhost_ctrl_gpu::OnClose(DeviceFD fd) {} + NvResult nvhost_ctrl_gpu::GetCharacteristics(const std::vector<u8>& input, std::vector<u8>& output) { LOG_DEBUG(Service_NVDRV, "called"); diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h index 137b88238..f98aa841a 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h @@ -16,11 +16,15 @@ public: explicit nvhost_ctrl_gpu(Core::System& system); ~nvhost_ctrl_gpu() override; - NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; - NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, + NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output) override; + NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) override; - NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_output) override; + NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_output) override; + + void OnOpen(DeviceFD fd) override; + void OnClose(DeviceFD fd) override; private: struct IoctlGpuCharacteristics { diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp index af8b3d9f1..e83aaa798 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp @@ -23,7 +23,8 @@ nvhost_gpu::nvhost_gpu(Core::System& system, std::shared_ptr<nvmap> nvmap_dev, nvhost_gpu::~nvhost_gpu() = default; -NvResult nvhost_gpu::Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { +NvResult nvhost_gpu::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output) { switch (command.group) { case 0x0: switch (command.cmd) { @@ -74,7 +75,7 @@ NvResult nvhost_gpu::Ioctl1(Ioctl command, const std::vector<u8>& input, std::ve return NvResult::NotImplemented; }; -NvResult nvhost_gpu::Ioctl2(Ioctl command, const std::vector<u8>& input, +NvResult nvhost_gpu::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) { switch (command.group) { case 'H': @@ -88,12 +89,15 @@ NvResult nvhost_gpu::Ioctl2(Ioctl command, const std::vector<u8>& input, return NvResult::NotImplemented; } -NvResult nvhost_gpu::Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_output) { +NvResult nvhost_gpu::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_output) { UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); return NvResult::NotImplemented; } +void nvhost_gpu::OnOpen(DeviceFD fd) {} +void nvhost_gpu::OnClose(DeviceFD fd) {} + NvResult nvhost_gpu::SetNVMAPfd(const std::vector<u8>& input, std::vector<u8>& output) { IoctlSetNvmapFD params{}; std::memcpy(¶ms, input.data(), input.size()); diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h index e0298b4fe..12a1a1133 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h @@ -26,11 +26,15 @@ public: SyncpointManager& syncpoint_manager); ~nvhost_gpu() override; - NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; - NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, + NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output) override; + NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) override; - NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_output) override; + NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_output) override; + + void OnOpen(DeviceFD fd) override; + void OnClose(DeviceFD fd) override; private: enum class CtxObjects : u32_le { diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp index ecba1dba1..c8031970b 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp @@ -16,7 +16,7 @@ nvhost_nvdec::nvhost_nvdec(Core::System& system, std::shared_ptr<nvmap> nvmap_de : nvhost_nvdec_common(system, std::move(nvmap_dev), syncpoint_manager) {} nvhost_nvdec::~nvhost_nvdec() = default; -NvResult nvhost_nvdec::Ioctl1(Ioctl command, const std::vector<u8>& input, +NvResult nvhost_nvdec::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { switch (command.group) { case 0x0: @@ -57,16 +57,19 @@ NvResult nvhost_nvdec::Ioctl1(Ioctl command, const std::vector<u8>& input, return NvResult::NotImplemented; } -NvResult nvhost_nvdec::Ioctl2(Ioctl command, const std::vector<u8>& input, +NvResult nvhost_nvdec::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) { UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); return NvResult::NotImplemented; } -NvResult nvhost_nvdec::Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_output) { +NvResult nvhost_nvdec::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_output) { UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); return NvResult::NotImplemented; } +void nvhost_nvdec::OnOpen(DeviceFD fd) {} +void nvhost_nvdec::OnClose(DeviceFD fd) {} + } // namespace Service::Nvidia::Devices diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h index 77ef53cdd..6c38a8c24 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h @@ -15,11 +15,15 @@ public: SyncpointManager& syncpoint_manager); ~nvhost_nvdec() override; - NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; - NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, + NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output) override; + NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) override; - NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_output) override; + NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_output) override; + + void OnOpen(DeviceFD fd) override; + void OnClose(DeviceFD fd) override; }; } // namespace Service::Nvidia::Devices diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp index 2d06955c0..0a9c35c01 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp @@ -13,7 +13,7 @@ namespace Service::Nvidia::Devices { nvhost_nvjpg::nvhost_nvjpg(Core::System& system) : nvdevice(system) {} nvhost_nvjpg::~nvhost_nvjpg() = default; -NvResult nvhost_nvjpg::Ioctl1(Ioctl command, const std::vector<u8>& input, +NvResult nvhost_nvjpg::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { switch (command.group) { case 'H': @@ -32,18 +32,21 @@ NvResult nvhost_nvjpg::Ioctl1(Ioctl command, const std::vector<u8>& input, return NvResult::NotImplemented; } -NvResult nvhost_nvjpg::Ioctl2(Ioctl command, const std::vector<u8>& input, +NvResult nvhost_nvjpg::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) { UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); return NvResult::NotImplemented; } -NvResult nvhost_nvjpg::Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_output) { +NvResult nvhost_nvjpg::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_output) { UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); return NvResult::NotImplemented; } +void nvhost_nvjpg::OnOpen(DeviceFD fd) {} +void nvhost_nvjpg::OnClose(DeviceFD fd) {} + NvResult nvhost_nvjpg::SetNVMAPfd(const std::vector<u8>& input, std::vector<u8>& output) { IoctlSetNvmapFD params{}; std::memcpy(¶ms, input.data(), input.size()); diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h index 43948d18d..1f97b642f 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h @@ -16,11 +16,15 @@ public: explicit nvhost_nvjpg(Core::System& system); ~nvhost_nvjpg() override; - NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; - NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, + NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output) override; + NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) override; - NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_output) override; + NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_output) override; + + void OnOpen(DeviceFD fd) override; + void OnClose(DeviceFD fd) override; private: struct IoctlSetNvmapFD { diff --git a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp index 70849a9bd..0421fb956 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp @@ -16,7 +16,8 @@ nvhost_vic::nvhost_vic(Core::System& system, std::shared_ptr<nvmap> nvmap_dev, nvhost_vic::~nvhost_vic() = default; -NvResult nvhost_vic::Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { +NvResult nvhost_vic::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output) { switch (command.group) { case 0x0: switch (command.cmd) { @@ -55,16 +56,19 @@ NvResult nvhost_vic::Ioctl1(Ioctl command, const std::vector<u8>& input, std::ve return NvResult::NotImplemented; } -NvResult nvhost_vic::Ioctl2(Ioctl command, const std::vector<u8>& input, +NvResult nvhost_vic::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) { UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); return NvResult::NotImplemented; } -NvResult nvhost_vic::Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_output) { +NvResult nvhost_vic::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_output) { UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); return NvResult::NotImplemented; } +void nvhost_vic::OnOpen(DeviceFD fd) {} +void nvhost_vic::OnClose(DeviceFD fd) {} + } // namespace Service::Nvidia::Devices diff --git a/src/core/hle/service/nvdrv/devices/nvhost_vic.h b/src/core/hle/service/nvdrv/devices/nvhost_vic.h index f401c61fa..cebefad71 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_vic.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.h @@ -14,10 +14,14 @@ public: SyncpointManager& syncpoint_manager); ~nvhost_vic(); - NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; - NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, + NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output) override; + NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) override; - NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_output) override; + NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_output) override; + + void OnOpen(DeviceFD fd) override; + void OnClose(DeviceFD fd) override; }; } // namespace Service::Nvidia::Devices diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp index 4015a2740..dd1355522 100644 --- a/src/core/hle/service/nvdrv/devices/nvmap.cpp +++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp @@ -19,7 +19,8 @@ nvmap::nvmap(Core::System& system) : nvdevice(system) { nvmap::~nvmap() = default; -NvResult nvmap::Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { +NvResult nvmap::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output) { switch (command.group) { case 0x1: switch (command.cmd) { @@ -47,18 +48,21 @@ NvResult nvmap::Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector< return NvResult::NotImplemented; } -NvResult nvmap::Ioctl2(Ioctl command, const std::vector<u8>& input, +NvResult nvmap::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) { UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); return NvResult::NotImplemented; } -NvResult nvmap::Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_output) { +NvResult nvmap::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_output) { UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); return NvResult::NotImplemented; } +void nvmap::OnOpen(DeviceFD fd) {} +void nvmap::OnClose(DeviceFD fd) {} + VAddr nvmap::GetObjectAddress(u32 handle) const { auto object = GetObject(handle); ASSERT(object); diff --git a/src/core/hle/service/nvdrv/devices/nvmap.h b/src/core/hle/service/nvdrv/devices/nvmap.h index 4484bd79f..208875845 100644 --- a/src/core/hle/service/nvdrv/devices/nvmap.h +++ b/src/core/hle/service/nvdrv/devices/nvmap.h @@ -19,11 +19,15 @@ public: explicit nvmap(Core::System& system); ~nvmap() override; - NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; - NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, + NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output) override; + NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, const std::vector<u8>& inline_input, std::vector<u8>& output) override; - NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, - std::vector<u8>& inline_output) override; + NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, + std::vector<u8>& output, std::vector<u8>& inline_output) override; + + void OnOpen(DeviceFD fd) override; + void OnClose(DeviceFD fd) override; /// Returns the allocated address of an nvmap object given its handle. VAddr GetObjectAddress(u32 handle) const; diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index abba80112..ede77858a 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp @@ -89,6 +89,8 @@ DeviceFD Module::Open(const std::string& device_name) { auto device = devices[device_name]; const DeviceFD fd = next_fd++; + device->OnOpen(fd); + open_files[fd] = std::move(device); return fd; @@ -108,7 +110,7 @@ NvResult Module::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input return NvResult::NotImplemented; } - return itr->second->Ioctl1(command, input, output); + return itr->second->Ioctl1(fd, command, input, output); } NvResult Module::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, @@ -125,7 +127,7 @@ NvResult Module::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input return NvResult::NotImplemented; } - return itr->second->Ioctl2(command, input, inline_input, output); + return itr->second->Ioctl2(fd, command, input, inline_input, output); } NvResult Module::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, @@ -142,7 +144,7 @@ NvResult Module::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input return NvResult::NotImplemented; } - return itr->second->Ioctl3(command, input, output, inline_output); + return itr->second->Ioctl3(fd, command, input, output, inline_output); } NvResult Module::Close(DeviceFD fd) { @@ -158,6 +160,8 @@ NvResult Module::Close(DeviceFD fd) { return NvResult::NotImplemented; } + itr->second->OnClose(fd); + open_files.erase(itr); return NvResult::Success; |