summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp16
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h9
2 files changed, 25 insertions, 0 deletions
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 39bd2a45b..f2529a12e 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
@@ -46,6 +46,8 @@ u32 nvhost_as_gpu::ioctl(Ioctl command, const std::vector<u8>& input, const std:
46 return GetVARegions(input, output); 46 return GetVARegions(input, output);
47 case IoctlCommand::IocUnmapBufferCommand: 47 case IoctlCommand::IocUnmapBufferCommand:
48 return UnmapBuffer(input, output); 48 return UnmapBuffer(input, output);
49 case IoctlCommand::IocFreeSpaceCommand:
50 return FreeSpace(input, output);
49 default: 51 default:
50 break; 52 break;
51 } 53 }
@@ -91,6 +93,20 @@ u32 nvhost_as_gpu::AllocateSpace(const std::vector<u8>& input, std::vector<u8>&
91 return result; 93 return result;
92} 94}
93 95
96u32 nvhost_as_gpu::FreeSpace(const std::vector<u8>& input, std::vector<u8>& output) {
97 IoctlFreeSpace params{};
98 std::memcpy(&params, input.data(), input.size());
99
100 LOG_DEBUG(Service_NVDRV, "called, offset={:X}, pages={:X}, page_size={:X}", params.offset,
101 params.pages, params.page_size);
102
103 system.GPU().MemoryManager().Unmap(params.offset,
104 static_cast<std::size_t>(params.pages) * params.page_size);
105
106 std::memcpy(output.data(), &params, output.size());
107 return NvErrCodes::Success;
108}
109
94u32 nvhost_as_gpu::Remap(const std::vector<u8>& input, std::vector<u8>& output) { 110u32 nvhost_as_gpu::Remap(const std::vector<u8>& input, std::vector<u8>& output) {
95 const auto num_entries = input.size() / sizeof(IoctlRemapEntry); 111 const auto num_entries = input.size() / sizeof(IoctlRemapEntry);
96 112
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 9a0cdff0c..fcdb40d93 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h
@@ -82,6 +82,7 @@ private:
82 IocBindChannelCommand = 0x40044101, 82 IocBindChannelCommand = 0x40044101,
83 IocGetVaRegionsCommand = 0xC0404108, 83 IocGetVaRegionsCommand = 0xC0404108,
84 IocUnmapBufferCommand = 0xC0084105, 84 IocUnmapBufferCommand = 0xC0084105,
85 IocFreeSpaceCommand = 0xC0104103,
85 }; 86 };
86 87
87 struct IoctlInitalizeEx { 88 struct IoctlInitalizeEx {
@@ -107,6 +108,13 @@ private:
107 }; 108 };
108 static_assert(sizeof(IoctlAllocSpace) == 24, "IoctlInitalizeEx is incorrect size"); 109 static_assert(sizeof(IoctlAllocSpace) == 24, "IoctlInitalizeEx is incorrect size");
109 110
111 struct IoctlFreeSpace {
112 u64_le offset;
113 u32_le pages;
114 u32_le page_size;
115 };
116 static_assert(sizeof(IoctlFreeSpace) == 16, "IoctlFreeSpace is incorrect size");
117
110 struct IoctlRemapEntry { 118 struct IoctlRemapEntry {
111 u16_le flags; 119 u16_le flags;
112 u16_le kind; 120 u16_le kind;
@@ -162,6 +170,7 @@ private:
162 u32 Remap(const std::vector<u8>& input, std::vector<u8>& output); 170 u32 Remap(const std::vector<u8>& input, std::vector<u8>& output);
163 u32 MapBufferEx(const std::vector<u8>& input, std::vector<u8>& output); 171 u32 MapBufferEx(const std::vector<u8>& input, std::vector<u8>& output);
164 u32 UnmapBuffer(const std::vector<u8>& input, std::vector<u8>& output); 172 u32 UnmapBuffer(const std::vector<u8>& input, std::vector<u8>& output);
173 u32 FreeSpace(const std::vector<u8>& input, std::vector<u8>& output);
165 u32 BindChannel(const std::vector<u8>& input, std::vector<u8>& output); 174 u32 BindChannel(const std::vector<u8>& input, std::vector<u8>& output);
166 u32 GetVARegions(const std::vector<u8>& input, std::vector<u8>& output); 175 u32 GetVARegions(const std::vector<u8>& input, std::vector<u8>& output);
167 176