diff options
Diffstat (limited to '')
| -rw-r--r-- | src/core/hle/service/nvdrv/core/nvmap.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/core/nvmap.h | 1 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvmap.cpp | 28 |
3 files changed, 18 insertions, 15 deletions
diff --git a/src/core/hle/service/nvdrv/core/nvmap.cpp b/src/core/hle/service/nvdrv/core/nvmap.cpp index 281381cc4..1126daeb5 100644 --- a/src/core/hle/service/nvdrv/core/nvmap.cpp +++ b/src/core/hle/service/nvdrv/core/nvmap.cpp | |||
| @@ -11,7 +11,9 @@ | |||
| 11 | using Core::Memory::YUZU_PAGESIZE; | 11 | using Core::Memory::YUZU_PAGESIZE; |
| 12 | 12 | ||
| 13 | namespace Service::Nvidia::NvCore { | 13 | namespace Service::Nvidia::NvCore { |
| 14 | NvMap::Handle::Handle(u64 size, Id id) : size(size), aligned_size(size), orig_size(size), id(id) {} | 14 | NvMap::Handle::Handle(u64 size, Id id) : size(size), aligned_size(size), orig_size(size), id(id) { |
| 15 | flags.raw = 0; | ||
| 16 | } | ||
| 15 | 17 | ||
| 16 | NvResult NvMap::Handle::Alloc(Flags pFlags, u32 pAlign, u8 pKind, u64 pAddress) { | 18 | NvResult NvMap::Handle::Alloc(Flags pFlags, u32 pAlign, u8 pKind, u64 pAddress) { |
| 17 | std::scoped_lock lock(mutex); | 19 | std::scoped_lock lock(mutex); |
diff --git a/src/core/hle/service/nvdrv/core/nvmap.h b/src/core/hle/service/nvdrv/core/nvmap.h index 994c70e6f..5e6c73589 100644 --- a/src/core/hle/service/nvdrv/core/nvmap.h +++ b/src/core/hle/service/nvdrv/core/nvmap.h | |||
| @@ -44,6 +44,7 @@ public: | |||
| 44 | std::optional<typename std::list<std::shared_ptr<Handle>>::iterator> unmap_queue_entry{}; | 44 | std::optional<typename std::list<std::shared_ptr<Handle>>::iterator> unmap_queue_entry{}; |
| 45 | 45 | ||
| 46 | union Flags { | 46 | union Flags { |
| 47 | u32 raw; | ||
| 47 | BitField<0, 1, u32> map_uncached; //!< If the handle should be mapped as uncached | 48 | BitField<0, 1, u32> map_uncached; //!< If the handle should be mapped as uncached |
| 48 | BitField<2, 1, u32> keep_uncached_after_free; //!< Only applicable when the handle was | 49 | BitField<2, 1, u32> keep_uncached_after_free; //!< Only applicable when the handle was |
| 49 | //!< allocated with a fixed address | 50 | //!< allocated with a fixed address |
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp index 2aee68f5c..57f58055d 100644 --- a/src/core/hle/service/nvdrv/devices/nvmap.cpp +++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp | |||
| @@ -82,7 +82,7 @@ std::shared_ptr<NvCore::NvMap::Handle> nvmap::GetObject(u32 handle) const { | |||
| 82 | NvResult nvmap::IocCreate(const std::vector<u8>& input, std::vector<u8>& output) { | 82 | NvResult nvmap::IocCreate(const std::vector<u8>& input, std::vector<u8>& output) { |
| 83 | IocCreateParams params; | 83 | IocCreateParams params; |
| 84 | std::memcpy(¶ms, input.data(), sizeof(params)); | 84 | std::memcpy(¶ms, input.data(), sizeof(params)); |
| 85 | LOG_WARNING(Service_NVDRV, "called, size=0x{:08X}", params.size); | 85 | LOG_DEBUG(Service_NVDRV, "called, size=0x{:08X}", params.size); |
| 86 | 86 | ||
| 87 | std::shared_ptr<NvCore::NvMap::Handle> handle_description{}; | 87 | std::shared_ptr<NvCore::NvMap::Handle> handle_description{}; |
| 88 | auto result = | 88 | auto result = |
| @@ -102,7 +102,7 @@ NvResult nvmap::IocCreate(const std::vector<u8>& input, std::vector<u8>& output) | |||
| 102 | NvResult nvmap::IocAlloc(const std::vector<u8>& input, std::vector<u8>& output) { | 102 | NvResult nvmap::IocAlloc(const std::vector<u8>& input, std::vector<u8>& output) { |
| 103 | IocAllocParams params; | 103 | IocAllocParams params; |
| 104 | std::memcpy(¶ms, input.data(), sizeof(params)); | 104 | std::memcpy(¶ms, input.data(), sizeof(params)); |
| 105 | LOG_WARNING(Service_NVDRV, "called, addr={:X}", params.address); | 105 | LOG_DEBUG(Service_NVDRV, "called, addr={:X}", params.address); |
| 106 | 106 | ||
| 107 | if (!params.handle) { | 107 | if (!params.handle) { |
| 108 | LOG_CRITICAL(Service_NVDRV, "Handle is 0"); | 108 | LOG_CRITICAL(Service_NVDRV, "Handle is 0"); |
| @@ -144,7 +144,7 @@ NvResult nvmap::IocGetId(const std::vector<u8>& input, std::vector<u8>& output) | |||
| 144 | IocGetIdParams params; | 144 | IocGetIdParams params; |
| 145 | std::memcpy(¶ms, input.data(), sizeof(params)); | 145 | std::memcpy(¶ms, input.data(), sizeof(params)); |
| 146 | 146 | ||
| 147 | LOG_WARNING(Service_NVDRV, "called"); | 147 | LOG_DEBUG(Service_NVDRV, "called"); |
| 148 | 148 | ||
| 149 | // See the comment in FromId for extra info on this function | 149 | // See the comment in FromId for extra info on this function |
| 150 | if (!params.handle) { | 150 | if (!params.handle) { |
| @@ -168,26 +168,26 @@ NvResult nvmap::IocFromId(const std::vector<u8>& input, std::vector<u8>& output) | |||
| 168 | IocFromIdParams params; | 168 | IocFromIdParams params; |
| 169 | std::memcpy(¶ms, input.data(), sizeof(params)); | 169 | std::memcpy(¶ms, input.data(), sizeof(params)); |
| 170 | 170 | ||
| 171 | LOG_WARNING(Service_NVDRV, "called, id:{}"); | 171 | LOG_DEBUG(Service_NVDRV, "called, id:{}"); |
| 172 | 172 | ||
| 173 | // Handles and IDs are always the same value in nvmap however IDs can be used globally given the | 173 | // Handles and IDs are always the same value in nvmap however IDs can be used globally given the |
| 174 | // right permissions. | 174 | // right permissions. |
| 175 | // Since we don't plan on ever supporting multiprocess we can skip implementing handle refs and | 175 | // Since we don't plan on ever supporting multiprocess we can skip implementing handle refs and |
| 176 | // so this function just does simple validation and passes through the handle id. | 176 | // so this function just does simple validation and passes through the handle id. |
| 177 | if (!params.id) { | 177 | if (!params.id) { |
| 178 | LOG_CRITICAL(Service_NVDRV, "Error!"); | 178 | LOG_CRITICAL(Service_NVDRV, "Zero Id is invalid!"); |
| 179 | return NvResult::BadValue; | 179 | return NvResult::BadValue; |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | auto handle_description{file.GetHandle(params.id)}; | 182 | auto handle_description{file.GetHandle(params.id)}; |
| 183 | if (!handle_description) { | 183 | if (!handle_description) { |
| 184 | LOG_CRITICAL(Service_NVDRV, "Error!"); | 184 | LOG_CRITICAL(Service_NVDRV, "Unregistered handle!"); |
| 185 | return NvResult::BadValue; | 185 | return NvResult::BadValue; |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | auto result = handle_description->Duplicate(false); | 188 | auto result = handle_description->Duplicate(false); |
| 189 | if (result != NvResult::Success) { | 189 | if (result != NvResult::Success) { |
| 190 | LOG_CRITICAL(Service_NVDRV, "Error!"); | 190 | LOG_CRITICAL(Service_NVDRV, "Could not duplicate handle!"); |
| 191 | return result; | 191 | return result; |
| 192 | } | 192 | } |
| 193 | params.handle = handle_description->id; | 193 | params.handle = handle_description->id; |
| @@ -201,16 +201,16 @@ NvResult nvmap::IocParam(const std::vector<u8>& input, std::vector<u8>& output) | |||
| 201 | IocParamParams params; | 201 | IocParamParams params; |
| 202 | std::memcpy(¶ms, input.data(), sizeof(params)); | 202 | std::memcpy(¶ms, input.data(), sizeof(params)); |
| 203 | 203 | ||
| 204 | LOG_WARNING(Service_NVDRV, "called type={}", params.param); | 204 | LOG_DEBUG(Service_NVDRV, "called type={}", params.param); |
| 205 | 205 | ||
| 206 | if (!params.handle) { | 206 | if (!params.handle) { |
| 207 | LOG_CRITICAL(Service_NVDRV, "Error!"); | 207 | LOG_CRITICAL(Service_NVDRV, "Invalid handle!"); |
| 208 | return NvResult::BadValue; | 208 | return NvResult::BadValue; |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | auto handle_description{file.GetHandle(params.handle)}; | 211 | auto handle_description{file.GetHandle(params.handle)}; |
| 212 | if (!handle_description) { | 212 | if (!handle_description) { |
| 213 | LOG_CRITICAL(Service_NVDRV, "Error!"); | 213 | LOG_CRITICAL(Service_NVDRV, "Not registered handle!"); |
| 214 | return NvResult::BadValue; | 214 | return NvResult::BadValue; |
| 215 | } | 215 | } |
| 216 | 216 | ||
| @@ -228,7 +228,7 @@ NvResult nvmap::IocParam(const std::vector<u8>& input, std::vector<u8>& output) | |||
| 228 | if (handle_description->allocated) | 228 | if (handle_description->allocated) |
| 229 | params.result = 0x40000000; | 229 | params.result = 0x40000000; |
| 230 | else | 230 | else |
| 231 | params.result = 0x40000000; | 231 | params.result = 0; |
| 232 | break; | 232 | break; |
| 233 | case HandleParameterType::Kind: | 233 | case HandleParameterType::Kind: |
| 234 | params.result = handle_description->kind; | 234 | params.result = handle_description->kind; |
| @@ -248,7 +248,7 @@ NvResult nvmap::IocFree(const std::vector<u8>& input, std::vector<u8>& output) { | |||
| 248 | IocFreeParams params; | 248 | IocFreeParams params; |
| 249 | std::memcpy(¶ms, input.data(), sizeof(params)); | 249 | std::memcpy(¶ms, input.data(), sizeof(params)); |
| 250 | 250 | ||
| 251 | LOG_WARNING(Service_NVDRV, "called"); | 251 | LOG_DEBUG(Service_NVDRV, "called"); |
| 252 | 252 | ||
| 253 | if (!params.handle) { | 253 | if (!params.handle) { |
| 254 | LOG_CRITICAL(Service_NVDRV, "Handle null freed?"); | 254 | LOG_CRITICAL(Service_NVDRV, "Handle null freed?"); |
| @@ -258,10 +258,10 @@ NvResult nvmap::IocFree(const std::vector<u8>& input, std::vector<u8>& output) { | |||
| 258 | if (auto freeInfo{file.FreeHandle(params.handle, false)}) { | 258 | if (auto freeInfo{file.FreeHandle(params.handle, false)}) { |
| 259 | params.address = freeInfo->address; | 259 | params.address = freeInfo->address; |
| 260 | params.size = static_cast<u32>(freeInfo->size); | 260 | params.size = static_cast<u32>(freeInfo->size); |
| 261 | params.flags = NvCore::NvMap::Handle::Flags{.map_uncached = freeInfo->was_uncached}; | 261 | params.flags.raw = 0; |
| 262 | params.flags.map_uncached = freeInfo->was_uncached; | ||
| 262 | } else { | 263 | } else { |
| 263 | // This is possible when there's internel dups or other duplicates. | 264 | // This is possible when there's internel dups or other duplicates. |
| 264 | LOG_CRITICAL(Service_NVDRV, "Not freed"); | ||
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | std::memcpy(output.data(), ¶ms, sizeof(params)); | 267 | std::memcpy(output.data(), ¶ms, sizeof(params)); |