2018-01-13 22:22:39 +01:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2018-01-09 16:41:13 +01:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "common/assert.h"
|
|
|
|
#include "common/logging/log.h"
|
|
|
|
#include "core/hle/service/nvdrv/devices/nvhost_as_gpu.h"
|
2018-02-08 03:31:06 +01:00
|
|
|
#include "core/hle/service/nvdrv/devices/nvmap.h"
|
2018-01-09 16:41:13 +01:00
|
|
|
|
|
|
|
namespace Service {
|
2018-01-15 23:39:00 +01:00
|
|
|
namespace Nvidia {
|
2018-01-09 16:41:13 +01:00
|
|
|
namespace Devices {
|
|
|
|
|
Extra nvdrv support (#162)
* FinishInitalize needed for 3.0.1+ games
* nvdrv:s and nvdrv:t both use NVDRV
* Most settings return 0 on hardware, disabled NV_MEMORY_PROFILER for now.
NVN_THROUGH_OPENGL & NVRM_GPU_PREVENT_USE are a few interesting settings to look at. Carefully choosing settings can help with drawing graphics later on
* Initial /dev/nvhost-gpu support
* ZCullBind
* Stubbed SetErrorNotifier
* Fixed SetErrorNotifier log, Added SetChannelPriority
* Allocate GPFIFO Ex2, Allocate Obj Ctx, Submit GPFIFO
* oops
* Fixed up naming/structs/enums. Used vector instead of array for "gpfifo_entry"
* Added missing fixes
* /dev/nvhost-ctrl-gpu
* unneeded struct
* Forgot u32 in enum class
* Automatic descriptor swapping for ioctls, fixed nvgpu_gpu_get_tpc_masks_args being incorrect size
* nvdrv#QueryEvent
* Renamed logs for nvdrv
* Refactor ioctl so nv_result isn't needed
* /dev/nvhost-as-gpu
* Fixed Log service naming, CtxObjects now u32, renamed all structs, added static_asserts to structs, used INSERT_PADDING_WORDS instead of u32s
* nvdevices now uses "Ioctl" union,
* IoctlGpfifoEntry now uses bit field
* final changes
2018-02-06 03:19:31 +01:00
|
|
|
u32 nvhost_as_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) {
|
|
|
|
LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%llx, output_size=0x%llx",
|
|
|
|
command, input.size(), output.size());
|
|
|
|
|
|
|
|
switch (static_cast<IoctlCommand>(command.raw)) {
|
|
|
|
case IoctlCommand::IocInitalizeExCommand:
|
|
|
|
return InitalizeEx(input, output);
|
|
|
|
case IoctlCommand::IocAllocateSpaceCommand:
|
|
|
|
return AllocateSpace(input, output);
|
|
|
|
case IoctlCommand::IocMapBufferExCommand:
|
|
|
|
return MapBufferEx(input, output);
|
|
|
|
case IoctlCommand::IocBindChannelCommand:
|
|
|
|
return BindChannel(input, output);
|
|
|
|
case IoctlCommand::IocGetVaRegionsCommand:
|
|
|
|
return GetVARegions(input, output);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 nvhost_as_gpu::InitalizeEx(const std::vector<u8>& input, std::vector<u8>& output) {
|
|
|
|
IoctlInitalizeEx params{};
|
|
|
|
std::memcpy(¶ms, input.data(), input.size());
|
|
|
|
LOG_WARNING(Service_NVDRV, "(STUBBED) called, big_page_size=0x%x", params.big_page_size);
|
|
|
|
std::memcpy(output.data(), ¶ms, output.size());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 nvhost_as_gpu::AllocateSpace(const std::vector<u8>& input, std::vector<u8>& output) {
|
|
|
|
IoctlAllocSpace params{};
|
|
|
|
std::memcpy(¶ms, input.data(), input.size());
|
|
|
|
LOG_WARNING(Service_NVDRV, "(STUBBED) called, pages=%x, page_size=%x, flags=%x", params.pages,
|
|
|
|
params.page_size, params.flags);
|
|
|
|
params.offset = 0xdeadbeef; // TODO(ogniK): Actually allocate space and give a real offset
|
|
|
|
std::memcpy(output.data(), ¶ms, output.size());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8>& output) {
|
|
|
|
IoctlMapBufferEx params{};
|
|
|
|
std::memcpy(¶ms, input.data(), input.size());
|
|
|
|
|
|
|
|
LOG_WARNING(Service_NVDRV,
|
|
|
|
"(STUBBED) called, flags=%x, nvmap_handle=%x, buffer_offset=%lx, mapping_size=%lx, "
|
|
|
|
"offset=%lx",
|
|
|
|
params.flags, params.nvmap_handle, params.buffer_offset, params.mapping_size,
|
|
|
|
params.offset);
|
|
|
|
params.offset = 0x0; // TODO(ogniK): Actually map and give a real offset
|
|
|
|
std::memcpy(output.data(), ¶ms, output.size());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 nvhost_as_gpu::BindChannel(const std::vector<u8>& input, std::vector<u8>& output) {
|
|
|
|
IoctlBindChannel params{};
|
|
|
|
std::memcpy(¶ms, input.data(), input.size());
|
|
|
|
LOG_DEBUG(Service_NVDRV, "called, fd=%x", params.fd);
|
|
|
|
channel = params.fd;
|
|
|
|
std::memcpy(output.data(), ¶ms, output.size());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 nvhost_as_gpu::GetVARegions(const std::vector<u8>& input, std::vector<u8>& output) {
|
|
|
|
IoctlGetVaRegions params{};
|
|
|
|
std::memcpy(¶ms, input.data(), input.size());
|
|
|
|
LOG_WARNING(Service_NVDRV, "(STUBBED) called, buf_addr=%lx, buf_size=%x", params.buf_addr,
|
|
|
|
params.buf_size);
|
|
|
|
|
|
|
|
params.buf_size = 0x30;
|
|
|
|
params.regions[0].offset = 0x04000000;
|
|
|
|
params.regions[0].page_size = 0x1000;
|
|
|
|
params.regions[0].pages = 0x3fbfff;
|
|
|
|
|
|
|
|
params.regions[1].offset = 0x04000000;
|
|
|
|
params.regions[1].page_size = 0x10000;
|
|
|
|
params.regions[1].pages = 0x1bffff;
|
|
|
|
// TODO(ogniK): This probably can stay stubbed but should add support way way later
|
|
|
|
std::memcpy(output.data(), ¶ms, output.size());
|
2018-01-09 16:41:13 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Devices
|
2018-01-15 23:39:00 +01:00
|
|
|
} // namespace Nvidia
|
2018-01-09 16:41:13 +01:00
|
|
|
} // namespace Service
|