summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nvdrv/interface.cpp13
-rw-r--r--src/core/hle/service/nvdrv/interface.h1
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.cpp10
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.h2
4 files changed, 26 insertions, 0 deletions
diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp
index 0670ca155..848615fa7 100644
--- a/src/core/hle/service/nvdrv/interface.cpp
+++ b/src/core/hle/service/nvdrv/interface.cpp
@@ -48,6 +48,18 @@ void NVDRV::Ioctl(Kernel::HLERequestContext& ctx) {
48 rb.Push(nv_result); 48 rb.Push(nv_result);
49} 49}
50 50
51void NVDRV::Close(Kernel::HLERequestContext& ctx) {
52 LOG_WARNING(Service, "(STUBBED) called");
53
54 IPC::RequestParser rp{ctx};
55 u32 fd = rp.Pop<u32>();
56
57 auto result = nvdrv->Close(fd);
58
59 IPC::RequestBuilder rb{ctx, 2};
60 rb.Push(result);
61}
62
51void NVDRV::Initialize(Kernel::HLERequestContext& ctx) { 63void NVDRV::Initialize(Kernel::HLERequestContext& ctx) {
52 LOG_WARNING(Service, "(STUBBED) called"); 64 LOG_WARNING(Service, "(STUBBED) called");
53 IPC::RequestBuilder rb{ctx, 3}; 65 IPC::RequestBuilder rb{ctx, 3};
@@ -60,6 +72,7 @@ NVDRV::NVDRV(std::shared_ptr<Module> nvdrv, const char* name)
60 static const FunctionInfo functions[] = { 72 static const FunctionInfo functions[] = {
61 {0, &NVDRV::Open, "Open"}, 73 {0, &NVDRV::Open, "Open"},
62 {1, &NVDRV::Ioctl, "Ioctl"}, 74 {1, &NVDRV::Ioctl, "Ioctl"},
75 {2, &NVDRV::Close, "Close"},
63 {3, &NVDRV::Initialize, "Initialize"}, 76 {3, &NVDRV::Initialize, "Initialize"},
64 }; 77 };
65 RegisterHandlers(functions); 78 RegisterHandlers(functions);
diff --git a/src/core/hle/service/nvdrv/interface.h b/src/core/hle/service/nvdrv/interface.h
index 8c95b7217..1b9aa9938 100644
--- a/src/core/hle/service/nvdrv/interface.h
+++ b/src/core/hle/service/nvdrv/interface.h
@@ -20,6 +20,7 @@ public:
20private: 20private:
21 void Open(Kernel::HLERequestContext& ctx); 21 void Open(Kernel::HLERequestContext& ctx);
22 void Ioctl(Kernel::HLERequestContext& ctx); 22 void Ioctl(Kernel::HLERequestContext& ctx);
23 void Close(Kernel::HLERequestContext& ctx);
23 void Initialize(Kernel::HLERequestContext& ctx); 24 void Initialize(Kernel::HLERequestContext& ctx);
24 25
25 std::shared_ptr<Module> nvdrv; 26 std::shared_ptr<Module> nvdrv;
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp
index cf525a875..9b73886bb 100644
--- a/src/core/hle/service/nvdrv/nvdrv.cpp
+++ b/src/core/hle/service/nvdrv/nvdrv.cpp
@@ -49,5 +49,15 @@ u32 Module::Ioctl(u32 fd, u32 command, const std::vector<u8>& input, std::vector
49 return device->ioctl(command, input, output); 49 return device->ioctl(command, input, output);
50} 50}
51 51
52ResultCode Module::Close(u32 fd) {
53 auto itr = open_files.find(fd);
54 ASSERT_MSG(itr != open_files.end(), "Tried to talk to an invalid device");
55
56 open_files.erase(itr);
57
58 // TODO(flerovium): return correct result code if operation failed.
59 return RESULT_SUCCESS;
60}
61
52} // namespace Nvidia 62} // namespace Nvidia
53} // namespace Service 63} // namespace Service
diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h
index 1940ced99..e44644624 100644
--- a/src/core/hle/service/nvdrv/nvdrv.h
+++ b/src/core/hle/service/nvdrv/nvdrv.h
@@ -35,6 +35,8 @@ public:
35 u32 Open(std::string device_name); 35 u32 Open(std::string device_name);
36 /// Sends an ioctl command to the specified file descriptor. 36 /// Sends an ioctl command to the specified file descriptor.
37 u32 Ioctl(u32 fd, u32 command, const std::vector<u8>& input, std::vector<u8>& output); 37 u32 Ioctl(u32 fd, u32 command, const std::vector<u8>& input, std::vector<u8>& output);
38 /// Closes a device file descriptor and returns operation success.
39 ResultCode Close(u32 fd);
38 40
39private: 41private:
40 /// Id to use for the next open file descriptor. 42 /// Id to use for the next open file descriptor.