summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nvdrv/devices/nvdevice.h25
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp7
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h25
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp3
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_vic.cpp7
-rw-r--r--src/core/hle/service/nvdrv/devices/nvmap.cpp5
-rw-r--r--src/core/hle/service/nvdrv/interface.cpp17
-rw-r--r--src/core/hle/service/nvdrv/interface.h2
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.cpp10
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.h2
10 files changed, 86 insertions, 17 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvdevice.h b/src/core/hle/service/nvdrv/devices/nvdevice.h
index b86805d26..5681599ba 100644
--- a/src/core/hle/service/nvdrv/devices/nvdevice.h
+++ b/src/core/hle/service/nvdrv/devices/nvdevice.h
@@ -24,10 +24,35 @@ public:
24 explicit nvdevice(Core::System& system) : system{system} {} 24 explicit nvdevice(Core::System& system) : system{system} {}
25 virtual ~nvdevice() = default; 25 virtual ~nvdevice() = default;
26 26
27 /**
28 * Handles an ioctl1 request.
29 * @param command The ioctl command id.
30 * @param input A buffer containing the input data for the ioctl.
31 * @param output A buffer where the output data will be written to.
32 * @returns The result code of the ioctl.
33 */
27 virtual NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, 34 virtual NvResult Ioctl1(Ioctl command, const std::vector<u8>& input,
28 std::vector<u8>& output) = 0; 35 std::vector<u8>& output) = 0;
36
37 /**
38 * Handles an ioctl2 request.
39 * @param command The ioctl command id.
40 * @param input A buffer containing the input data for the ioctl.
41 * @param inline_input A buffer containing the input data for the ioctl which has been inlined.
42 * @param output A buffer where the output data will be written to.
43 * @returns The result code of the ioctl.
44 */
29 virtual NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, 45 virtual NvResult Ioctl2(Ioctl command, const std::vector<u8>& input,
30 const std::vector<u8>& inline_input, std::vector<u8>& output) = 0; 46 const std::vector<u8>& inline_input, std::vector<u8>& output) = 0;
47
48 /**
49 * Handles an ioctl3 request.
50 * @param command The ioctl command id.
51 * @param input A buffer containing the input data for the ioctl.
52 * @param output A buffer where the output data will be written to.
53 * @param inline_output A buffer where the inlined output data will be written to.
54 * @returns The result code of the ioctl.
55 */
31 virtual NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 56 virtual NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output,
32 std::vector<u8>& inline_output) = 0; 57 std::vector<u8>& inline_output) = 0;
33 58
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 725cb7b55..6b062e10e 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
@@ -42,6 +42,8 @@ NvResult nvhost_as_gpu::Ioctl1(Ioctl command, const std::vector<u8>& input,
42 return InitalizeEx(input, output); 42 return InitalizeEx(input, output);
43 case 0x14: 43 case 0x14:
44 return Remap(input, output); 44 return Remap(input, output);
45 default:
46 break;
45 } 47 }
46 break; 48 break;
47 default: 49 default:
@@ -65,7 +67,12 @@ NvResult nvhost_as_gpu::Ioctl3(Ioctl command, const std::vector<u8>& input, std:
65 switch (command.cmd) { 67 switch (command.cmd) {
66 case 0x8: 68 case 0x8:
67 return GetVARegions(input, output, inline_output); 69 return GetVARegions(input, output, inline_output);
70 default:
71 break;
68 } 72 }
73 break;
74 default:
75 break;
69 } 76 }
70 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 77 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
71 return NvResult::NotImplemented; 78 return NvResult::NotImplemented;
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h
index e07d4d280..86ba3a4d1 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h
@@ -18,10 +18,35 @@ public:
18 explicit nvhost_nvdec_common(Core::System& system, std::shared_ptr<nvmap> nvmap_dev); 18 explicit nvhost_nvdec_common(Core::System& system, std::shared_ptr<nvmap> nvmap_dev);
19 ~nvhost_nvdec_common() override; 19 ~nvhost_nvdec_common() override;
20 20
21 /**
22 * Handles an ioctl1 request.
23 * @param command The ioctl command id.
24 * @param input A buffer containing the input data for the ioctl.
25 * @param output A buffer where the output data will be written to.
26 * @returns The result code of the ioctl.
27 */
21 virtual NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, 28 virtual NvResult Ioctl1(Ioctl command, const std::vector<u8>& input,
22 std::vector<u8>& output) = 0; 29 std::vector<u8>& output) = 0;
30
31 /**
32 * Handles an ioctl2 request.
33 * @param command The ioctl command id.
34 * @param input A buffer containing the input data for the ioctl.
35 * @param inline_input A buffer containing the input data for the ioctl which has been inlined.
36 * @param output A buffer where the output data will be written to.
37 * @returns The result code of the ioctl.
38 */
23 virtual NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, 39 virtual NvResult Ioctl2(Ioctl command, const std::vector<u8>& input,
24 const std::vector<u8>& inline_input, std::vector<u8>& output) = 0; 40 const std::vector<u8>& inline_input, std::vector<u8>& output) = 0;
41
42 /**
43 * Handles an ioctl3 request.
44 * @param command The ioctl command id.
45 * @param input A buffer containing the input data for the ioctl.
46 * @param output A buffer where the output data will be written to.
47 * @param inline_output A buffer where the inlined output data will be written to.
48 * @returns The result code of the ioctl.
49 */
25 virtual NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 50 virtual NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output,
26 std::vector<u8>& inline_output) = 0; 51 std::vector<u8>& inline_output) = 0;
27 52
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp
index 5bd2958cd..2d06955c0 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp
@@ -15,7 +15,6 @@ nvhost_nvjpg::~nvhost_nvjpg() = default;
15 15
16NvResult nvhost_nvjpg::Ioctl1(Ioctl command, const std::vector<u8>& input, 16NvResult nvhost_nvjpg::Ioctl1(Ioctl command, const std::vector<u8>& input,
17 std::vector<u8>& output) { 17 std::vector<u8>& output) {
18
19 switch (command.group) { 18 switch (command.group) {
20 case 'H': 19 case 'H':
21 switch (command.cmd) { 20 switch (command.cmd) {
@@ -25,6 +24,8 @@ NvResult nvhost_nvjpg::Ioctl1(Ioctl command, const std::vector<u8>& input,
25 break; 24 break;
26 } 25 }
27 break; 26 break;
27 default:
28 break;
28 } 29 }
29 30
30 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 31 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
index 347638490..805fe86ae 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
@@ -29,13 +29,20 @@ NvResult nvhost_vic::Ioctl1(Ioctl command, const std::vector<u8>& input, std::ve
29 return MapBuffer(input, output); 29 return MapBuffer(input, output);
30 case 0xa: 30 case 0xa:
31 return UnmapBuffer(input, output); 31 return UnmapBuffer(input, output);
32 default:
33 break;
32 } 34 }
35 break;
33 case 'H': 36 case 'H':
34 switch (command.cmd) { 37 switch (command.cmd) {
35 case 0x1: 38 case 0x1:
36 return SetNVMAPfd(input); 39 return SetNVMAPfd(input);
40 default:
41 break;
37 } 42 }
38 break; 43 break;
44 default:
45 break;
39 } 46 }
40 47
41 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 48 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp
index c3d324788..4015a2740 100644
--- a/src/core/hle/service/nvdrv/devices/nvmap.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp
@@ -35,7 +35,12 @@ NvResult nvmap::Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<
35 return IocParam(input, output); 35 return IocParam(input, output);
36 case 0xe: 36 case 0xe:
37 return IocGetId(input, output); 37 return IocGetId(input, output);
38 default:
39 break;
38 } 40 }
41 break;
42 default:
43 break;
39 } 44 }
40 45
41 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 46 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp
index e01ef676a..f6c38e853 100644
--- a/src/core/hle/service/nvdrv/interface.cpp
+++ b/src/core/hle/service/nvdrv/interface.cpp
@@ -23,7 +23,7 @@ void NVDRV::SignalGPUInterruptSyncpt(const u32 syncpoint_id, const u32 value) {
23void NVDRV::Open(Kernel::HLERequestContext& ctx) { 23void NVDRV::Open(Kernel::HLERequestContext& ctx) {
24 LOG_DEBUG(Service_NVDRV, "called"); 24 LOG_DEBUG(Service_NVDRV, "called");
25 25
26 if (!initialized) { 26 if (!is_initialized) {
27 ServiceError(ctx, NvResult::NotInitialized); 27 ServiceError(ctx, NvResult::NotInitialized);
28 LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); 28 LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
29 return; 29 return;
@@ -51,7 +51,7 @@ void NVDRV::Ioctl1(Kernel::HLERequestContext& ctx) {
51 const auto command = rp.PopRaw<Ioctl>(); 51 const auto command = rp.PopRaw<Ioctl>();
52 LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw); 52 LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw);
53 53
54 if (!initialized) { 54 if (!is_initialized) {
55 ServiceError(ctx, NvResult::NotInitialized); 55 ServiceError(ctx, NvResult::NotInitialized);
56 LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); 56 LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
57 return; 57 return;
@@ -78,7 +78,7 @@ void NVDRV::Ioctl2(Kernel::HLERequestContext& ctx) {
78 const auto command = rp.PopRaw<Ioctl>(); 78 const auto command = rp.PopRaw<Ioctl>();
79 LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw); 79 LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw);
80 80
81 if (!initialized) { 81 if (!is_initialized) {
82 ServiceError(ctx, NvResult::NotInitialized); 82 ServiceError(ctx, NvResult::NotInitialized);
83 LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); 83 LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
84 return; 84 return;
@@ -106,7 +106,7 @@ void NVDRV::Ioctl3(Kernel::HLERequestContext& ctx) {
106 const auto command = rp.PopRaw<Ioctl>(); 106 const auto command = rp.PopRaw<Ioctl>();
107 LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw); 107 LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw);
108 108
109 if (!initialized) { 109 if (!is_initialized) {
110 ServiceError(ctx, NvResult::NotInitialized); 110 ServiceError(ctx, NvResult::NotInitialized);
111 LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); 111 LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
112 return; 112 return;
@@ -132,7 +132,7 @@ void NVDRV::Ioctl3(Kernel::HLERequestContext& ctx) {
132void NVDRV::Close(Kernel::HLERequestContext& ctx) { 132void NVDRV::Close(Kernel::HLERequestContext& ctx) {
133 LOG_DEBUG(Service_NVDRV, "called"); 133 LOG_DEBUG(Service_NVDRV, "called");
134 134
135 if (!initialized) { 135 if (!is_initialized) {
136 ServiceError(ctx, NvResult::NotInitialized); 136 ServiceError(ctx, NvResult::NotInitialized);
137 LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); 137 LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
138 return; 138 return;
@@ -150,7 +150,7 @@ void NVDRV::Close(Kernel::HLERequestContext& ctx) {
150void NVDRV::Initialize(Kernel::HLERequestContext& ctx) { 150void NVDRV::Initialize(Kernel::HLERequestContext& ctx) {
151 LOG_WARNING(Service_NVDRV, "(STUBBED) called"); 151 LOG_WARNING(Service_NVDRV, "(STUBBED) called");
152 152
153 initialized = true; 153 is_initialized = true;
154 154
155 IPC::ResponseBuilder rb{ctx, 3}; 155 IPC::ResponseBuilder rb{ctx, 3};
156 rb.Push(RESULT_SUCCESS); 156 rb.Push(RESULT_SUCCESS);
@@ -163,14 +163,13 @@ void NVDRV::QueryEvent(Kernel::HLERequestContext& ctx) {
163 const auto event_id = rp.Pop<u32>() & 0x00FF; 163 const auto event_id = rp.Pop<u32>() & 0x00FF;
164 LOG_WARNING(Service_NVDRV, "(STUBBED) called, fd={:X}, event_id={:X}", fd, event_id); 164 LOG_WARNING(Service_NVDRV, "(STUBBED) called, fd={:X}, event_id={:X}", fd, event_id);
165 165
166 if (!initialized) { 166 if (!is_initialized) {
167 ServiceError(ctx, NvResult::NotInitialized); 167 ServiceError(ctx, NvResult::NotInitialized);
168 LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); 168 LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
169 return; 169 return;
170 } 170 }
171 171
172 auto nv_result = nvdrv->VerifyFd(fd); 172 const auto nv_result = nvdrv->VerifyFD(fd);
173
174 if (nv_result != NvResult::Success) { 173 if (nv_result != NvResult::Success) {
175 LOG_ERROR(Service_NVDRV, "Invalid FD specified DeviceFD={}!", fd); 174 LOG_ERROR(Service_NVDRV, "Invalid FD specified DeviceFD={}!", fd);
176 ServiceError(ctx, nv_result); 175 ServiceError(ctx, nv_result);
diff --git a/src/core/hle/service/nvdrv/interface.h b/src/core/hle/service/nvdrv/interface.h
index d7bcf2b7e..e05f905ae 100644
--- a/src/core/hle/service/nvdrv/interface.h
+++ b/src/core/hle/service/nvdrv/interface.h
@@ -39,7 +39,7 @@ private:
39 std::shared_ptr<Module> nvdrv; 39 std::shared_ptr<Module> nvdrv;
40 40
41 u64 pid{}; 41 u64 pid{};
42 bool initialized{}; 42 bool is_initialized{};
43}; 43};
44 44
45} // namespace Service::Nvidia 45} // namespace Service::Nvidia
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp
index 69a4b07ba..bdbbedd0d 100644
--- a/src/core/hle/service/nvdrv/nvdrv.cpp
+++ b/src/core/hle/service/nvdrv/nvdrv.cpp
@@ -62,7 +62,7 @@ Module::Module(Core::System& system) : syncpoint_manager{system.GPU()} {
62 62
63Module::~Module() = default; 63Module::~Module() = default;
64 64
65NvResult Module::VerifyFd(DeviceFD fd) const { 65NvResult Module::VerifyFD(DeviceFD fd) const {
66 if (fd < 0) { 66 if (fd < 0) {
67 LOG_ERROR(Service_NVDRV, "Invalid DeviceFD={}!", fd); 67 LOG_ERROR(Service_NVDRV, "Invalid DeviceFD={}!", fd);
68 return NvResult::InvalidState; 68 return NvResult::InvalidState;
@@ -97,7 +97,7 @@ NvResult Module::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input
97 return NvResult::InvalidState; 97 return NvResult::InvalidState;
98 } 98 }
99 99
100 auto itr = open_files.find(fd); 100 const auto itr = open_files.find(fd);
101 101
102 if (itr == open_files.end()) { 102 if (itr == open_files.end()) {
103 LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd); 103 LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd);
@@ -114,7 +114,7 @@ NvResult Module::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input
114 return NvResult::InvalidState; 114 return NvResult::InvalidState;
115 } 115 }
116 116
117 auto itr = open_files.find(fd); 117 const auto itr = open_files.find(fd);
118 118
119 if (itr == open_files.end()) { 119 if (itr == open_files.end()) {
120 LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd); 120 LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd);
@@ -131,7 +131,7 @@ NvResult Module::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input
131 return NvResult::InvalidState; 131 return NvResult::InvalidState;
132 } 132 }
133 133
134 auto itr = open_files.find(fd); 134 const auto itr = open_files.find(fd);
135 135
136 if (itr == open_files.end()) { 136 if (itr == open_files.end()) {
137 LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd); 137 LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd);
@@ -147,7 +147,7 @@ NvResult Module::Close(DeviceFD fd) {
147 return NvResult::InvalidState; 147 return NvResult::InvalidState;
148 } 148 }
149 149
150 auto itr = open_files.find(fd); 150 const auto itr = open_files.find(fd);
151 151
152 if (itr == open_files.end()) { 152 if (itr == open_files.end()) {
153 LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd); 153 LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd);
diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h
index 3ccc62a76..7654bb026 100644
--- a/src/core/hle/service/nvdrv/nvdrv.h
+++ b/src/core/hle/service/nvdrv/nvdrv.h
@@ -112,7 +112,7 @@ public:
112 return std::static_pointer_cast<T>(itr->second); 112 return std::static_pointer_cast<T>(itr->second);
113 } 113 }
114 114
115 NvResult VerifyFd(DeviceFD fd) const; 115 NvResult VerifyFD(DeviceFD fd) const;
116 116
117 /// Opens a device node and returns a file descriptor to it. 117 /// Opens a device node and returns a file descriptor to it.
118 DeviceFD Open(const std::string& device_name); 118 DeviceFD Open(const std::string& device_name);