yuzu-emu
/
yuzu
Archived
1
0
Fork 0

Addressed issues

This commit is contained in:
Chloe Marcec 2020-11-10 15:56:41 +11:00
parent 31c12de0fe
commit fc4d692c50
10 changed files with 86 additions and 17 deletions

View File

@ -24,10 +24,35 @@ public:
explicit nvdevice(Core::System& system) : system{system} {} explicit nvdevice(Core::System& system) : system{system} {}
virtual ~nvdevice() = default; virtual ~nvdevice() = default;
/**
* Handles an ioctl1 request.
* @param command The ioctl command id.
* @param input A buffer containing the input data for the ioctl.
* @param output A buffer where the output data will be written to.
* @returns The result code of the ioctl.
*/
virtual NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, virtual NvResult Ioctl1(Ioctl command, const std::vector<u8>& input,
std::vector<u8>& output) = 0; std::vector<u8>& output) = 0;
/**
* Handles an ioctl2 request.
* @param command The ioctl command id.
* @param input A buffer containing the input data for the ioctl.
* @param inline_input A buffer containing the input data for the ioctl which has been inlined.
* @param output A buffer where the output data will be written to.
* @returns The result code of the ioctl.
*/
virtual NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, virtual NvResult Ioctl2(Ioctl command, const std::vector<u8>& input,
const std::vector<u8>& inline_input, std::vector<u8>& output) = 0; const std::vector<u8>& inline_input, std::vector<u8>& output) = 0;
/**
* Handles an ioctl3 request.
* @param command The ioctl command id.
* @param input A buffer containing the input data for the ioctl.
* @param output A buffer where the output data will be written to.
* @param inline_output A buffer where the inlined output data will be written to.
* @returns The result code of the ioctl.
*/
virtual NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, virtual NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output,
std::vector<u8>& inline_output) = 0; std::vector<u8>& inline_output) = 0;

View File

@ -42,6 +42,8 @@ NvResult nvhost_as_gpu::Ioctl1(Ioctl command, const std::vector<u8>& input,
return InitalizeEx(input, output); return InitalizeEx(input, output);
case 0x14: case 0x14:
return Remap(input, output); return Remap(input, output);
default:
break;
} }
break; break;
default: default:
@ -65,7 +67,12 @@ NvResult nvhost_as_gpu::Ioctl3(Ioctl command, const std::vector<u8>& input, std:
switch (command.cmd) { switch (command.cmd) {
case 0x8: case 0x8:
return GetVARegions(input, output, inline_output); return GetVARegions(input, output, inline_output);
default:
break;
} }
break;
default:
break;
} }
UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
return NvResult::NotImplemented; return NvResult::NotImplemented;

View File

@ -18,10 +18,35 @@ public:
explicit nvhost_nvdec_common(Core::System& system, std::shared_ptr<nvmap> nvmap_dev); explicit nvhost_nvdec_common(Core::System& system, std::shared_ptr<nvmap> nvmap_dev);
~nvhost_nvdec_common() override; ~nvhost_nvdec_common() override;
/**
* Handles an ioctl1 request.
* @param command The ioctl command id.
* @param input A buffer containing the input data for the ioctl.
* @param output A buffer where the output data will be written to.
* @returns The result code of the ioctl.
*/
virtual NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, virtual NvResult Ioctl1(Ioctl command, const std::vector<u8>& input,
std::vector<u8>& output) = 0; std::vector<u8>& output) = 0;
/**
* Handles an ioctl2 request.
* @param command The ioctl command id.
* @param input A buffer containing the input data for the ioctl.
* @param inline_input A buffer containing the input data for the ioctl which has been inlined.
* @param output A buffer where the output data will be written to.
* @returns The result code of the ioctl.
*/
virtual NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, virtual NvResult Ioctl2(Ioctl command, const std::vector<u8>& input,
const std::vector<u8>& inline_input, std::vector<u8>& output) = 0; const std::vector<u8>& inline_input, std::vector<u8>& output) = 0;
/**
* Handles an ioctl3 request.
* @param command The ioctl command id.
* @param input A buffer containing the input data for the ioctl.
* @param output A buffer where the output data will be written to.
* @param inline_output A buffer where the inlined output data will be written to.
* @returns The result code of the ioctl.
*/
virtual NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, virtual NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output,
std::vector<u8>& inline_output) = 0; std::vector<u8>& inline_output) = 0;

View File

@ -15,7 +15,6 @@ nvhost_nvjpg::~nvhost_nvjpg() = default;
NvResult nvhost_nvjpg::Ioctl1(Ioctl command, const std::vector<u8>& input, NvResult nvhost_nvjpg::Ioctl1(Ioctl command, const std::vector<u8>& input,
std::vector<u8>& output) { std::vector<u8>& output) {
switch (command.group) { switch (command.group) {
case 'H': case 'H':
switch (command.cmd) { switch (command.cmd) {
@ -25,6 +24,8 @@ NvResult nvhost_nvjpg::Ioctl1(Ioctl command, const std::vector<u8>& input,
break; break;
} }
break; break;
default:
break;
} }
UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);

View File

@ -29,13 +29,20 @@ NvResult nvhost_vic::Ioctl1(Ioctl command, const std::vector<u8>& input, std::ve
return MapBuffer(input, output); return MapBuffer(input, output);
case 0xa: case 0xa:
return UnmapBuffer(input, output); return UnmapBuffer(input, output);
default:
break;
} }
break;
case 'H': case 'H':
switch (command.cmd) { switch (command.cmd) {
case 0x1: case 0x1:
return SetNVMAPfd(input); return SetNVMAPfd(input);
default:
break;
} }
break; break;
default:
break;
} }
UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);

View File

@ -35,7 +35,12 @@ NvResult nvmap::Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<
return IocParam(input, output); return IocParam(input, output);
case 0xe: case 0xe:
return IocGetId(input, output); return IocGetId(input, output);
default:
break;
} }
break;
default:
break;
} }
UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);

View File

@ -23,7 +23,7 @@ void NVDRV::SignalGPUInterruptSyncpt(const u32 syncpoint_id, const u32 value) {
void NVDRV::Open(Kernel::HLERequestContext& ctx) { void NVDRV::Open(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_NVDRV, "called"); LOG_DEBUG(Service_NVDRV, "called");
if (!initialized) { if (!is_initialized) {
ServiceError(ctx, NvResult::NotInitialized); ServiceError(ctx, NvResult::NotInitialized);
LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
return; return;
@ -51,7 +51,7 @@ void NVDRV::Ioctl1(Kernel::HLERequestContext& ctx) {
const auto command = rp.PopRaw<Ioctl>(); const auto command = rp.PopRaw<Ioctl>();
LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw); LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw);
if (!initialized) { if (!is_initialized) {
ServiceError(ctx, NvResult::NotInitialized); ServiceError(ctx, NvResult::NotInitialized);
LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
return; return;
@ -78,7 +78,7 @@ void NVDRV::Ioctl2(Kernel::HLERequestContext& ctx) {
const auto command = rp.PopRaw<Ioctl>(); const auto command = rp.PopRaw<Ioctl>();
LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw); LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw);
if (!initialized) { if (!is_initialized) {
ServiceError(ctx, NvResult::NotInitialized); ServiceError(ctx, NvResult::NotInitialized);
LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
return; return;
@ -106,7 +106,7 @@ void NVDRV::Ioctl3(Kernel::HLERequestContext& ctx) {
const auto command = rp.PopRaw<Ioctl>(); const auto command = rp.PopRaw<Ioctl>();
LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw); LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw);
if (!initialized) { if (!is_initialized) {
ServiceError(ctx, NvResult::NotInitialized); ServiceError(ctx, NvResult::NotInitialized);
LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
return; return;
@ -132,7 +132,7 @@ void NVDRV::Ioctl3(Kernel::HLERequestContext& ctx) {
void NVDRV::Close(Kernel::HLERequestContext& ctx) { void NVDRV::Close(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_NVDRV, "called"); LOG_DEBUG(Service_NVDRV, "called");
if (!initialized) { if (!is_initialized) {
ServiceError(ctx, NvResult::NotInitialized); ServiceError(ctx, NvResult::NotInitialized);
LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
return; return;
@ -150,7 +150,7 @@ void NVDRV::Close(Kernel::HLERequestContext& ctx) {
void NVDRV::Initialize(Kernel::HLERequestContext& ctx) { void NVDRV::Initialize(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_NVDRV, "(STUBBED) called"); LOG_WARNING(Service_NVDRV, "(STUBBED) called");
initialized = true; is_initialized = true;
IPC::ResponseBuilder rb{ctx, 3}; IPC::ResponseBuilder rb{ctx, 3};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
@ -163,14 +163,13 @@ void NVDRV::QueryEvent(Kernel::HLERequestContext& ctx) {
const auto event_id = rp.Pop<u32>() & 0x00FF; const auto event_id = rp.Pop<u32>() & 0x00FF;
LOG_WARNING(Service_NVDRV, "(STUBBED) called, fd={:X}, event_id={:X}", fd, event_id); LOG_WARNING(Service_NVDRV, "(STUBBED) called, fd={:X}, event_id={:X}", fd, event_id);
if (!initialized) { if (!is_initialized) {
ServiceError(ctx, NvResult::NotInitialized); ServiceError(ctx, NvResult::NotInitialized);
LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
return; return;
} }
auto nv_result = nvdrv->VerifyFd(fd); const auto nv_result = nvdrv->VerifyFD(fd);
if (nv_result != NvResult::Success) { if (nv_result != NvResult::Success) {
LOG_ERROR(Service_NVDRV, "Invalid FD specified DeviceFD={}!", fd); LOG_ERROR(Service_NVDRV, "Invalid FD specified DeviceFD={}!", fd);
ServiceError(ctx, nv_result); ServiceError(ctx, nv_result);

View File

@ -39,7 +39,7 @@ private:
std::shared_ptr<Module> nvdrv; std::shared_ptr<Module> nvdrv;
u64 pid{}; u64 pid{};
bool initialized{}; bool is_initialized{};
}; };
} // namespace Service::Nvidia } // namespace Service::Nvidia

View File

@ -62,7 +62,7 @@ Module::Module(Core::System& system) : syncpoint_manager{system.GPU()} {
Module::~Module() = default; Module::~Module() = default;
NvResult Module::VerifyFd(DeviceFD fd) const { NvResult Module::VerifyFD(DeviceFD fd) const {
if (fd < 0) { if (fd < 0) {
LOG_ERROR(Service_NVDRV, "Invalid DeviceFD={}!", fd); LOG_ERROR(Service_NVDRV, "Invalid DeviceFD={}!", fd);
return NvResult::InvalidState; return NvResult::InvalidState;
@ -97,7 +97,7 @@ NvResult Module::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input
return NvResult::InvalidState; return NvResult::InvalidState;
} }
auto itr = open_files.find(fd); const auto itr = open_files.find(fd);
if (itr == open_files.end()) { if (itr == open_files.end()) {
LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd); 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
return NvResult::InvalidState; return NvResult::InvalidState;
} }
auto itr = open_files.find(fd); const auto itr = open_files.find(fd);
if (itr == open_files.end()) { if (itr == open_files.end()) {
LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd); 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
return NvResult::InvalidState; return NvResult::InvalidState;
} }
auto itr = open_files.find(fd); const auto itr = open_files.find(fd);
if (itr == open_files.end()) { if (itr == open_files.end()) {
LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd); LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd);
@ -147,7 +147,7 @@ NvResult Module::Close(DeviceFD fd) {
return NvResult::InvalidState; return NvResult::InvalidState;
} }
auto itr = open_files.find(fd); const auto itr = open_files.find(fd);
if (itr == open_files.end()) { if (itr == open_files.end()) {
LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd); LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd);

View File

@ -112,7 +112,7 @@ public:
return std::static_pointer_cast<T>(itr->second); return std::static_pointer_cast<T>(itr->second);
} }
NvResult VerifyFd(DeviceFD fd) const; NvResult VerifyFD(DeviceFD fd) const;
/// Opens a device node and returns a file descriptor to it. /// Opens a device node and returns a file descriptor to it.
DeviceFD Open(const std::string& device_name); DeviceFD Open(const std::string& device_name);