nvdrv: stubbed Close(cmd 2)

This commit is contained in:
Frederic Meyer 2018-01-17 17:08:46 +01:00
parent d92636d424
commit 60d650cc4e
4 changed files with 26 additions and 0 deletions

View file

@ -48,6 +48,18 @@ void NVDRV::Ioctl(Kernel::HLERequestContext& ctx) {
rb.Push(nv_result); rb.Push(nv_result);
} }
void NVDRV::Close(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service, "(STUBBED) called");
IPC::RequestParser rp{ctx};
u32 fd = rp.Pop<u32>();
auto result = nvdrv->Close(fd);
IPC::RequestBuilder rb{ctx, 2};
rb.Push(result);
}
void NVDRV::Initialize(Kernel::HLERequestContext& ctx) { void NVDRV::Initialize(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service, "(STUBBED) called"); LOG_WARNING(Service, "(STUBBED) called");
IPC::RequestBuilder rb{ctx, 3}; IPC::RequestBuilder rb{ctx, 3};
@ -60,6 +72,7 @@ NVDRV::NVDRV(std::shared_ptr<Module> nvdrv, const char* name)
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, &NVDRV::Open, "Open"}, {0, &NVDRV::Open, "Open"},
{1, &NVDRV::Ioctl, "Ioctl"}, {1, &NVDRV::Ioctl, "Ioctl"},
{2, &NVDRV::Close, "Close"},
{3, &NVDRV::Initialize, "Initialize"}, {3, &NVDRV::Initialize, "Initialize"},
}; };
RegisterHandlers(functions); RegisterHandlers(functions);

View file

@ -20,6 +20,7 @@ public:
private: private:
void Open(Kernel::HLERequestContext& ctx); void Open(Kernel::HLERequestContext& ctx);
void Ioctl(Kernel::HLERequestContext& ctx); void Ioctl(Kernel::HLERequestContext& ctx);
void Close(Kernel::HLERequestContext& ctx);
void Initialize(Kernel::HLERequestContext& ctx); void Initialize(Kernel::HLERequestContext& ctx);
std::shared_ptr<Module> nvdrv; std::shared_ptr<Module> nvdrv;

View file

@ -49,5 +49,15 @@ u32 Module::Ioctl(u32 fd, u32 command, const std::vector<u8>& input, std::vector
return device->ioctl(command, input, output); return device->ioctl(command, input, output);
} }
ResultCode Module::Close(u32 fd) {
auto itr = open_files.find(fd);
ASSERT_MSG(itr != open_files.end(), "Tried to talk to an invalid device");
open_files.erase(itr);
// TODO(flerovium): return correct result code if operation failed.
return RESULT_SUCCESS;
}
} // namespace Nvidia } // namespace Nvidia
} // namespace Service } // namespace Service

View file

@ -35,6 +35,8 @@ public:
u32 Open(std::string device_name); u32 Open(std::string device_name);
/// Sends an ioctl command to the specified file descriptor. /// Sends an ioctl command to the specified file descriptor.
u32 Ioctl(u32 fd, u32 command, const std::vector<u8>& input, std::vector<u8>& output); u32 Ioctl(u32 fd, u32 command, const std::vector<u8>& input, std::vector<u8>& output);
/// Closes a device file descriptor and returns operation success.
ResultCode Close(u32 fd);
private: private:
/// Id to use for the next open file descriptor. /// Id to use for the next open file descriptor.