diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | 14 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl.h | 11 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvmap.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/vi/vi.cpp | 57 |
5 files changed, 68 insertions, 28 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index ee99ab280..45711d686 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | |||
| @@ -17,6 +17,8 @@ u32 nvhost_ctrl::ioctl(Ioctl command, const std::vector<u8>& input, std::vector< | |||
| 17 | switch (static_cast<IoctlCommand>(command.raw)) { | 17 | switch (static_cast<IoctlCommand>(command.raw)) { |
| 18 | case IoctlCommand::IocGetConfigCommand: | 18 | case IoctlCommand::IocGetConfigCommand: |
| 19 | return NvOsGetConfigU32(input, output); | 19 | return NvOsGetConfigU32(input, output); |
| 20 | case IoctlCommand::IocCtrlEventWaitCommand: | ||
| 21 | return IocCtrlEventWait(input, output); | ||
| 20 | } | 22 | } |
| 21 | UNIMPLEMENTED(); | 23 | UNIMPLEMENTED(); |
| 22 | return 0; | 24 | return 0; |
| @@ -45,6 +47,18 @@ u32 nvhost_ctrl::NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& | |||
| 45 | return 0; | 47 | return 0; |
| 46 | } | 48 | } |
| 47 | 49 | ||
| 50 | u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>& output) { | ||
| 51 | IocCtrlEventWaitParams params{}; | ||
| 52 | std::memcpy(¶ms, input.data(), sizeof(params)); | ||
| 53 | LOG_WARNING(Service_NVDRV, "(STUBBED) called, syncpt_id=%u threshold=%u timeout=%d", | ||
| 54 | params.syncpt_id, params.threshold, params.timeout); | ||
| 55 | |||
| 56 | // TODO(Subv): Implement actual syncpt waiting. | ||
| 57 | params.value = 0; | ||
| 58 | std::memcpy(output.data(), ¶ms, sizeof(params)); | ||
| 59 | return 0; | ||
| 60 | } | ||
| 61 | |||
| 48 | } // namespace Devices | 62 | } // namespace Devices |
| 49 | } // namespace Nvidia | 63 | } // namespace Nvidia |
| 50 | } // namespace Service | 64 | } // namespace Service |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h index fd02a5e45..0ca01aa6d 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h | |||
| @@ -31,6 +31,7 @@ private: | |||
| 31 | IocModuleRegRDWRCommand = 0xC008010E, | 31 | IocModuleRegRDWRCommand = 0xC008010E, |
| 32 | IocSyncptWaitexCommand = 0xC0100019, | 32 | IocSyncptWaitexCommand = 0xC0100019, |
| 33 | IocSyncptReadMaxCommand = 0xC008001A, | 33 | IocSyncptReadMaxCommand = 0xC008001A, |
| 34 | IocCtrlEventWaitCommand = 0xC010001D, | ||
| 34 | IocGetConfigCommand = 0xC183001B, | 35 | IocGetConfigCommand = 0xC183001B, |
| 35 | }; | 36 | }; |
| 36 | 37 | ||
| @@ -41,7 +42,17 @@ private: | |||
| 41 | }; | 42 | }; |
| 42 | static_assert(sizeof(IocGetConfigParams) == 387, "IocGetConfigParams is incorrect size"); | 43 | static_assert(sizeof(IocGetConfigParams) == 387, "IocGetConfigParams is incorrect size"); |
| 43 | 44 | ||
| 45 | struct IocCtrlEventWaitParams { | ||
| 46 | u32_le syncpt_id; | ||
| 47 | u32_le threshold; | ||
| 48 | s32_le timeout; | ||
| 49 | u32_le value; | ||
| 50 | }; | ||
| 51 | static_assert(sizeof(IocCtrlEventWaitParams) == 16, "IocCtrlEventWaitParams is incorrect size"); | ||
| 52 | |||
| 44 | u32 NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output); | 53 | u32 NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output); |
| 54 | |||
| 55 | u32 IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>& output); | ||
| 45 | }; | 56 | }; |
| 46 | 57 | ||
| 47 | } // namespace Devices | 58 | } // namespace Devices |
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp index cd8c0c605..b3842eb4c 100644 --- a/src/core/hle/service/nvdrv/devices/nvmap.cpp +++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp | |||
| @@ -103,11 +103,8 @@ u32 nvmap::IocFromId(const std::vector<u8>& input, std::vector<u8>& output) { | |||
| 103 | [&](const auto& entry) { return entry.second->id == params.id; }); | 103 | [&](const auto& entry) { return entry.second->id == params.id; }); |
| 104 | ASSERT(itr != handles.end()); | 104 | ASSERT(itr != handles.end()); |
| 105 | 105 | ||
| 106 | // Make a new handle for the object | 106 | // Return the existing handle instead of creating a new one. |
| 107 | u32 handle = next_handle++; | 107 | params.handle = itr->first; |
| 108 | handles[handle] = itr->second; | ||
| 109 | |||
| 110 | params.handle = handle; | ||
| 111 | 108 | ||
| 112 | std::memcpy(output.data(), ¶ms, sizeof(params)); | 109 | std::memcpy(output.data(), ¶ms, sizeof(params)); |
| 113 | return 0; | 110 | return 0; |
diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index e44644624..6a55ff96d 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h | |||
| @@ -17,6 +17,13 @@ namespace Devices { | |||
| 17 | class nvdevice; | 17 | class nvdevice; |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | struct IoctlFence { | ||
| 21 | u32 id; | ||
| 22 | u32 value; | ||
| 23 | }; | ||
| 24 | |||
| 25 | static_assert(sizeof(IoctlFence) == 8, "IoctlFence has wrong size"); | ||
| 26 | |||
| 20 | class Module final { | 27 | class Module final { |
| 21 | public: | 28 | public: |
| 22 | Module(); | 29 | Module(); |
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index ff5005f71..0aa621dfe 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "common/scope_exit.h" | 8 | #include "common/scope_exit.h" |
| 9 | #include "core/core_timing.h" | 9 | #include "core/core_timing.h" |
| 10 | #include "core/hle/ipc_helpers.h" | 10 | #include "core/hle/ipc_helpers.h" |
| 11 | #include "core/hle/service/nvdrv/nvdrv.h" | ||
| 11 | #include "core/hle/service/nvflinger/buffer_queue.h" | 12 | #include "core/hle/service/nvflinger/buffer_queue.h" |
| 12 | #include "core/hle/service/vi/vi.h" | 13 | #include "core/hle/service/vi/vi.h" |
| 13 | #include "core/hle/service/vi/vi_m.h" | 14 | #include "core/hle/service/vi/vi_m.h" |
| @@ -38,6 +39,7 @@ public: | |||
| 38 | 39 | ||
| 39 | template <typename T> | 40 | template <typename T> |
| 40 | T Read() { | 41 | T Read() { |
| 42 | ASSERT(read_index + sizeof(T) <= buffer.size()); | ||
| 41 | T val; | 43 | T val; |
| 42 | std::memcpy(&val, buffer.data() + read_index, sizeof(T)); | 44 | std::memcpy(&val, buffer.data() + read_index, sizeof(T)); |
| 43 | read_index += sizeof(T); | 45 | read_index += sizeof(T); |
| @@ -47,6 +49,7 @@ public: | |||
| 47 | 49 | ||
| 48 | template <typename T> | 50 | template <typename T> |
| 49 | T ReadUnaligned() { | 51 | T ReadUnaligned() { |
| 52 | ASSERT(read_index + sizeof(T) <= buffer.size()); | ||
| 50 | T val; | 53 | T val; |
| 51 | std::memcpy(&val, buffer.data() + read_index, sizeof(T)); | 54 | std::memcpy(&val, buffer.data() + read_index, sizeof(T)); |
| 52 | read_index += sizeof(T); | 55 | read_index += sizeof(T); |
| @@ -54,6 +57,7 @@ public: | |||
| 54 | } | 57 | } |
| 55 | 58 | ||
| 56 | std::vector<u8> ReadBlock(size_t length) { | 59 | std::vector<u8> ReadBlock(size_t length) { |
| 60 | ASSERT(read_index + length <= buffer.size()); | ||
| 57 | const u8* const begin = buffer.data() + read_index; | 61 | const u8* const begin = buffer.data() + read_index; |
| 58 | const u8* const end = begin + length; | 62 | const u8* const end = begin + length; |
| 59 | std::vector<u8> data(begin, end); | 63 | std::vector<u8> data(begin, end); |
| @@ -86,7 +90,18 @@ public: | |||
| 86 | write_index = Common::AlignUp(write_index, 4); | 90 | write_index = Common::AlignUp(write_index, 4); |
| 87 | } | 91 | } |
| 88 | 92 | ||
| 93 | template <typename T> | ||
| 94 | void WriteObject(const T& val) { | ||
| 95 | u32_le size = static_cast<u32>(sizeof(val)); | ||
| 96 | Write(size); | ||
| 97 | // TODO(Subv): Support file descriptors. | ||
| 98 | Write<u32_le>(0); // Fd count. | ||
| 99 | Write(val); | ||
| 100 | } | ||
| 101 | |||
| 89 | void Deserialize() { | 102 | void Deserialize() { |
| 103 | ASSERT(buffer.size() > sizeof(Header)); | ||
| 104 | |||
| 90 | Header header{}; | 105 | Header header{}; |
| 91 | std::memcpy(&header, buffer.data(), sizeof(Header)); | 106 | std::memcpy(&header, buffer.data(), sizeof(Header)); |
| 92 | 107 | ||
| @@ -262,10 +277,11 @@ public: | |||
| 262 | Data data; | 277 | Data data; |
| 263 | }; | 278 | }; |
| 264 | 279 | ||
| 265 | // TODO(bunnei): Remove this. When set to 1, games will think a fence is valid and boot further. | 280 | struct BufferProducerFence { |
| 266 | // This will break libnx and potentially other apps that more stringently check this. This is here | 281 | u32 is_valid; |
| 267 | // purely as a convenience, and should go away once we implement fences. | 282 | std::array<Nvidia::IoctlFence, 4> fences; |
| 268 | static constexpr u32 FENCE_HACK = 0; | 283 | }; |
| 284 | static_assert(sizeof(BufferProducerFence) == 36, "BufferProducerFence has wrong size"); | ||
| 269 | 285 | ||
| 270 | class IGBPDequeueBufferResponseParcel : public Parcel { | 286 | class IGBPDequeueBufferResponseParcel : public Parcel { |
| 271 | public: | 287 | public: |
| @@ -274,20 +290,16 @@ public: | |||
| 274 | 290 | ||
| 275 | protected: | 291 | protected: |
| 276 | void SerializeData() override { | 292 | void SerializeData() override { |
| 277 | // TODO(bunnei): Find out what this all means. Writing anything non-zero here breaks libnx. | 293 | // TODO(Subv): Find out how this Fence is used. |
| 278 | Write<u32>(0); | 294 | BufferProducerFence fence = {}; |
| 279 | Write<u32>(FENCE_HACK); | 295 | fence.is_valid = 1; |
| 280 | Write<u32>(0); | 296 | for (auto& fence_ : fence.fences) |
| 281 | Write<u32>(0); | 297 | fence_.id = -1; |
| 282 | Write<u32>(0); | 298 | |
| 283 | Write<u32>(0); | 299 | Write(slot); |
| 284 | Write<u32>(0); | 300 | Write<u32_le>(1); |
| 285 | Write<u32>(0); | 301 | WriteObject(fence); |
| 286 | Write<u32>(0); | 302 | Write<u32_le>(0); |
| 287 | Write<u32>(0); | ||
| 288 | Write<u32>(0); | ||
| 289 | Write<u32>(0); | ||
| 290 | Write<u32>(0); | ||
| 291 | } | 303 | } |
| 292 | 304 | ||
| 293 | u32_le slot; | 305 | u32_le slot; |
| @@ -316,11 +328,10 @@ public: | |||
| 316 | 328 | ||
| 317 | protected: | 329 | protected: |
| 318 | void SerializeData() override { | 330 | void SerializeData() override { |
| 319 | // TODO(bunnei): Find out what this all means. Writing anything non-zero here breaks libnx. | 331 | // TODO(Subv): Figure out what this value means, writing non-zero here will make libnx try |
| 320 | Write<u32_le>(0); | 332 | // to read an IGBPBuffer object from the parcel. |
| 321 | Write<u32_le>(FENCE_HACK); | 333 | Write<u32_le>(1); |
| 322 | Write<u32_le>(0); | 334 | WriteObject(buffer); |
| 323 | Write(buffer); | ||
| 324 | Write<u32_le>(0); | 335 | Write<u32_le>(0); |
| 325 | } | 336 | } |
| 326 | 337 | ||