diff options
author | bunnei <bunneidev@gmail.com> | 2020-07-26 06:16:21 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2020-07-26 06:49:43 +0200 |
commit | 05def613980a0e3b723d0d8d38eb68511272bb72 (patch) | |
tree | a120a71115533e9f3447ca8716f46d6f4c991f89 /src/core/hle/service/nvdrv/devices/nvmap.cpp | |
parent | Merge pull request #4417 from lioncash/poll (diff) | |
download | yuzu-05def613980a0e3b723d0d8d38eb68511272bb72.tar yuzu-05def613980a0e3b723d0d8d38eb68511272bb72.tar.gz yuzu-05def613980a0e3b723d0d8d38eb68511272bb72.tar.bz2 yuzu-05def613980a0e3b723d0d8d38eb68511272bb72.tar.lz yuzu-05def613980a0e3b723d0d8d38eb68511272bb72.tar.xz yuzu-05def613980a0e3b723d0d8d38eb68511272bb72.tar.zst yuzu-05def613980a0e3b723d0d8d38eb68511272bb72.zip |
Diffstat (limited to 'src/core/hle/service/nvdrv/devices/nvmap.cpp')
-rw-r--r-- | src/core/hle/service/nvdrv/devices/nvmap.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp index 8c742316c..7228910a0 100644 --- a/src/core/hle/service/nvdrv/devices/nvmap.cpp +++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp @@ -18,7 +18,12 @@ enum { }; } -nvmap::nvmap(Core::System& system) : nvdevice(system) {} +nvmap::nvmap(Core::System& system) : nvdevice(system) { + // Handle 0 appears to be used when remapping, so we create a placeholder empty nvmap object to + // represent this. + CreateObject(0); +} + nvmap::~nvmap() = default; VAddr nvmap::GetObjectAddress(u32 handle) const { @@ -50,6 +55,21 @@ u32 nvmap::ioctl(Ioctl command, const std::vector<u8>& input, const std::vector< return 0; } +u32 nvmap::CreateObject(u32 size) { + // Create a new nvmap object and obtain a handle to it. + auto object = std::make_shared<Object>(); + object->id = next_id++; + object->size = size; + object->status = Object::Status::Created; + object->refcount = 1; + + const u32 handle = next_handle++; + + handles[handle] = std::move(object); + + return handle; +} + u32 nvmap::IocCreate(const std::vector<u8>& input, std::vector<u8>& output) { IocCreateParams params; std::memcpy(¶ms, input.data(), sizeof(params)); @@ -59,17 +79,8 @@ u32 nvmap::IocCreate(const std::vector<u8>& input, std::vector<u8>& output) { LOG_ERROR(Service_NVDRV, "Size is 0"); return static_cast<u32>(NvErrCodes::InvalidValue); } - // Create a new nvmap object and obtain a handle to it. - auto object = std::make_shared<Object>(); - object->id = next_id++; - object->size = params.size; - object->status = Object::Status::Created; - object->refcount = 1; - - u32 handle = next_handle++; - handles[handle] = std::move(object); - params.handle = handle; + params.handle = CreateObject(params.size); std::memcpy(output.data(), ¶ms, sizeof(params)); return 0; |