summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp49
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h27
2 files changed, 49 insertions, 27 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 6b062e10e..485ac5f50 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
@@ -39,7 +39,7 @@ NvResult nvhost_as_gpu::Ioctl1(Ioctl command, const std::vector<u8>& input,
39 case 0x8: 39 case 0x8:
40 return GetVARegions(input, output); 40 return GetVARegions(input, output);
41 case 0x9: 41 case 0x9:
42 return InitalizeEx(input, output); 42 return AllocAsEx(input, output);
43 case 0x14: 43 case 0x14:
44 return Remap(input, output); 44 return Remap(input, output);
45 default: 45 default:
@@ -78,11 +78,16 @@ NvResult nvhost_as_gpu::Ioctl3(Ioctl command, const std::vector<u8>& input, std:
78 return NvResult::NotImplemented; 78 return NvResult::NotImplemented;
79} 79}
80 80
81NvResult nvhost_as_gpu::InitalizeEx(const std::vector<u8>& input, std::vector<u8>& output) { 81NvResult nvhost_as_gpu::AllocAsEx(const std::vector<u8>& input, std::vector<u8>& output) {
82 IoctlInitalizeEx params{}; 82 IoctlAllocAsEx params{};
83 std::memcpy(&params, input.data(), input.size()); 83 std::memcpy(&params, input.data(), input.size());
84 84
85 LOG_WARNING(Service_NVDRV, "(STUBBED) called, big_page_size=0x{:X}", params.big_page_size); 85 LOG_WARNING(Service_NVDRV, "(STUBBED) called, big_page_size=0x{:X}", params.big_page_size);
86 if (params.big_page_size == 0) {
87 params.big_page_size = DEFAULT_BIG_PAGE_SIZE;
88 }
89
90 big_page_size = params.big_page_size;
86 91
87 return NvResult::Success; 92 return NvResult::Success;
88} 93}
@@ -276,13 +281,18 @@ NvResult nvhost_as_gpu::GetVARegions(const std::vector<u8>& input, std::vector<u
276 params.buf_size); 281 params.buf_size);
277 282
278 params.buf_size = 0x30; 283 params.buf_size = 0x30;
279 params.regions[0].offset = 0x04000000;
280 params.regions[0].page_size = 0x1000;
281 params.regions[0].pages = 0x3fbfff;
282 284
283 params.regions[1].offset = 0x04000000; 285 params.small = IoctlVaRegion{
284 params.regions[1].page_size = 0x10000; 286 .offset = 0x04000000,
285 params.regions[1].pages = 0x1bffff; 287 .page_size = DEFAULT_SMALL_PAGE_SIZE,
288 .pages = 0x3fbfff,
289 };
290
291 params.big = IoctlVaRegion{
292 .offset = 0x04000000,
293 .page_size = big_page_size,
294 .pages = 0x1bffff,
295 };
286 296
287 // TODO(ogniK): This probably can stay stubbed but should add support way way later 297 // TODO(ogniK): This probably can stay stubbed but should add support way way later
288 298
@@ -299,18 +309,25 @@ NvResult nvhost_as_gpu::GetVARegions(const std::vector<u8>& input, std::vector<u
299 params.buf_size); 309 params.buf_size);
300 310
301 params.buf_size = 0x30; 311 params.buf_size = 0x30;
302 params.regions[0].offset = 0x04000000;
303 params.regions[0].page_size = 0x1000;
304 params.regions[0].pages = 0x3fbfff;
305 312
306 params.regions[1].offset = 0x04000000; 313 params.small = IoctlVaRegion{
307 params.regions[1].page_size = 0x10000; 314 .offset = 0x04000000,
308 params.regions[1].pages = 0x1bffff; 315 .page_size = 0x1000,
316 .pages = 0x3fbfff,
317 };
318
319 params.big = IoctlVaRegion{
320 .offset = 0x04000000,
321 .page_size = big_page_size,
322 .pages = 0x1bffff,
323 };
309 324
310 // TODO(ogniK): This probably can stay stubbed but should add support way way later 325 // TODO(ogniK): This probably can stay stubbed but should add support way way later
311 326
312 std::memcpy(output.data(), &params, output.size()); 327 std::memcpy(output.data(), &params, output.size());
313 std::memcpy(inline_output.data(), &params.regions, inline_output.size()); 328 std::memcpy(inline_output.data(), &params.small, sizeof(IoctlVaRegion));
329 std::memcpy(inline_output.data() + sizeof(IoctlVaRegion), &params.big, sizeof(IoctlVaRegion));
330
314 return NvResult::Success; 331 return NvResult::Success;
315} 332}
316 333
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..9ee60e060 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 @@
16 16
17namespace Service::Nvidia::Devices { 17namespace Service::Nvidia::Devices {
18 18
19constexpr u32 DEFAULT_BIG_PAGE_SIZE = 1 << 16;
20constexpr u32 DEFAULT_SMALL_PAGE_SIZE = 1 << 12;
21
19class nvmap; 22class nvmap;
20 23
21enum class AddressSpaceFlags : u32 { 24enum class AddressSpaceFlags : u32 {
@@ -76,16 +79,16 @@ private:
76 bool is_allocated{}; 79 bool is_allocated{};
77 }; 80 };
78 81
79 struct IoctlInitalizeEx { 82 struct IoctlAllocAsEx {
80 u32_le big_page_size{}; // depends on GPU's available_big_page_sizes; 0=default 83 u32_le flags{}; // usually passes 1
81 s32_le as_fd{}; // ignored; passes 0 84 s32_le as_fd{}; // ignored; passes 0
82 u32_le flags{}; // passes 0 85 u32_le big_page_size{};
83 u32_le reserved{}; // ignored; passes 0 86 u32_le reserved{}; // ignored; passes 0
84 u64_le unk0{}; 87 u64_le va_range_start{};
85 u64_le unk1{}; 88 u64_le va_range_end{};
86 u64_le unk2{}; 89 u64_le va_range_split{};
87 }; 90 };
88 static_assert(sizeof(IoctlInitalizeEx) == 40, "IoctlInitalizeEx is incorrect size"); 91 static_assert(sizeof(IoctlAllocAsEx) == 40, "IoctlAllocAsEx is incorrect size");
89 92
90 struct IoctlAllocSpace { 93 struct IoctlAllocSpace {
91 u32_le pages{}; 94 u32_le pages{};
@@ -149,14 +152,16 @@ private:
149 u64_le buf_addr{}; // (contained output user ptr on linux, ignored) 152 u64_le buf_addr{}; // (contained output user ptr on linux, ignored)
150 u32_le buf_size{}; // forced to 2*sizeof(struct va_region) 153 u32_le buf_size{}; // forced to 2*sizeof(struct va_region)
151 u32_le reserved{}; 154 u32_le reserved{};
152 IoctlVaRegion regions[2]{}; 155 IoctlVaRegion small{};
156 IoctlVaRegion big{};
153 }; 157 };
154 static_assert(sizeof(IoctlGetVaRegions) == 16 + sizeof(IoctlVaRegion) * 2, 158 static_assert(sizeof(IoctlGetVaRegions) == 16 + sizeof(IoctlVaRegion) * 2,
155 "IoctlGetVaRegions is incorrect size"); 159 "IoctlGetVaRegions is incorrect size");
156 160
157 s32 channel{}; 161 s32 channel{};
162 u32 big_page_size{DEFAULT_BIG_PAGE_SIZE};
158 163
159 NvResult InitalizeEx(const std::vector<u8>& input, std::vector<u8>& output); 164 NvResult AllocAsEx(const std::vector<u8>& input, std::vector<u8>& output);
160 NvResult AllocateSpace(const std::vector<u8>& input, std::vector<u8>& output); 165 NvResult AllocateSpace(const std::vector<u8>& input, std::vector<u8>& output);
161 NvResult Remap(const std::vector<u8>& input, std::vector<u8>& output); 166 NvResult Remap(const std::vector<u8>& input, std::vector<u8>& output);
162 NvResult MapBufferEx(const std::vector<u8>& input, std::vector<u8>& output); 167 NvResult MapBufferEx(const std::vector<u8>& input, std::vector<u8>& output);