diff options
| author | 2018-01-21 14:59:50 -0800 | |
|---|---|---|
| committer | 2018-01-21 17:59:50 -0500 | |
| commit | eeb3b5eed7645bee468b9d19325cb29877d62e82 (patch) | |
| tree | f79ce7893a6d6c0a8eb3984edded9887660323ac /src/core | |
| parent | Merge pull request #128 from Subv/parcel_query (diff) | |
| download | yuzu-eeb3b5eed7645bee468b9d19325cb29877d62e82.tar.gz yuzu-eeb3b5eed7645bee468b9d19325cb29877d62e82.tar.xz yuzu-eeb3b5eed7645bee468b9d19325cb29877d62e82.zip | |
Added nvmemp, Added /dev/nvhost-ctrl, SetClientPID now stores pid (#114)
* Added nvmemp, Added /dev/nvhost-ctrl, SetClientPID now stores pid
* used clang-format-3.9 instead
* lowercase pid
* Moved nvmemp handlers to cpp
* Removed unnecessary logging for NvOsGetConfigU32. Cleaned up log and changed to LOG_DEBUG
* using std::arrays instead of c arrays
* nvhost get config now uses std::array completely
* added pid logging back
* updated cmakelist
* missing includes
* added array, removed memcpy
* clang-format6.0
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | 46 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl.h | 48 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/interface.cpp | 9 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/interface.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvmemp.cpp | 31 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvmemp.h | 23 |
8 files changed, 162 insertions, 5 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 433e7e596..38fef5525 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -110,12 +110,16 @@ add_library(core STATIC | |||
| 110 | hle/service/nvdrv/devices/nvdisp_disp0.h | 110 | hle/service/nvdrv/devices/nvdisp_disp0.h |
| 111 | hle/service/nvdrv/devices/nvhost_as_gpu.cpp | 111 | hle/service/nvdrv/devices/nvhost_as_gpu.cpp |
| 112 | hle/service/nvdrv/devices/nvhost_as_gpu.h | 112 | hle/service/nvdrv/devices/nvhost_as_gpu.h |
| 113 | hle/service/nvdrv/devices/nvhost_ctrl.cpp | ||
| 114 | hle/service/nvdrv/devices/nvhost_ctrl.h | ||
| 113 | hle/service/nvdrv/devices/nvmap.cpp | 115 | hle/service/nvdrv/devices/nvmap.cpp |
| 114 | hle/service/nvdrv/devices/nvmap.h | 116 | hle/service/nvdrv/devices/nvmap.h |
| 115 | hle/service/nvdrv/interface.cpp | 117 | hle/service/nvdrv/interface.cpp |
| 116 | hle/service/nvdrv/interface.h | 118 | hle/service/nvdrv/interface.h |
| 117 | hle/service/nvdrv/nvdrv.cpp | 119 | hle/service/nvdrv/nvdrv.cpp |
| 118 | hle/service/nvdrv/nvdrv.h | 120 | hle/service/nvdrv/nvdrv.h |
| 121 | hle/service/nvdrv/nvmemp.cpp | ||
| 122 | hle/service/nvdrv/nvmemp.h | ||
| 119 | hle/service/pctl/pctl.cpp | 123 | hle/service/pctl/pctl.cpp |
| 120 | hle/service/pctl/pctl.h | 124 | hle/service/pctl/pctl.h |
| 121 | hle/service/pctl/pctl_a.cpp | 125 | hle/service/pctl/pctl_a.cpp |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp new file mode 100644 index 000000000..2078f2187 --- /dev/null +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/assert.h" | ||
| 6 | #include "common/logging/log.h" | ||
| 7 | #include "core/hle/service/nvdrv/devices/nvhost_ctrl.h" | ||
| 8 | |||
| 9 | namespace Service { | ||
| 10 | namespace Nvidia { | ||
| 11 | namespace Devices { | ||
| 12 | |||
| 13 | u32 nvhost_ctrl::ioctl(u32 command, const std::vector<u8>& input, std::vector<u8>& output) { | ||
| 14 | LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%lx, output_size=0x%lx", command, | ||
| 15 | input.size(), output.size()); | ||
| 16 | |||
| 17 | switch (command) { | ||
| 18 | case IocGetConfigCommand: | ||
| 19 | return NvOsGetConfigU32(input, output); | ||
| 20 | } | ||
| 21 | UNIMPLEMENTED(); | ||
| 22 | return 0; | ||
| 23 | } | ||
| 24 | |||
| 25 | u32 nvhost_ctrl::NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output) { | ||
| 26 | IocGetConfigParams params; | ||
| 27 | std::memcpy(¶ms, input.data(), sizeof(params)); | ||
| 28 | LOG_DEBUG(Service_NVDRV, "called, setting=%s!%s", params.domain_str.data(), | ||
| 29 | params.param_str.data()); | ||
| 30 | |||
| 31 | if (!strcmp(params.domain_str.data(), "nv")) { | ||
| 32 | if (!strcmp(params.param_str.data(), "NV_MEMORY_PROFILER")) { | ||
| 33 | params.config_str[0] = '1'; | ||
| 34 | } else { | ||
| 35 | UNIMPLEMENTED(); | ||
| 36 | } | ||
| 37 | } else { | ||
| 38 | UNIMPLEMENTED(); | ||
| 39 | } | ||
| 40 | std::memcpy(output.data(), ¶ms, sizeof(params)); | ||
| 41 | return 0; | ||
| 42 | } | ||
| 43 | |||
| 44 | } // namespace Devices | ||
| 45 | } // namespace Nvidia | ||
| 46 | } // namespace Service | ||
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h new file mode 100644 index 000000000..abce35e17 --- /dev/null +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <array> | ||
| 8 | #include <cstdlib> | ||
| 9 | #include <cstring> | ||
| 10 | #include <vector> | ||
| 11 | #include "common/common_types.h" | ||
| 12 | #include "core/hle/service/nvdrv/devices/nvdevice.h" | ||
| 13 | |||
| 14 | namespace Service { | ||
| 15 | namespace Nvidia { | ||
| 16 | namespace Devices { | ||
| 17 | |||
| 18 | class nvhost_ctrl final : public nvdevice { | ||
| 19 | public: | ||
| 20 | nvhost_ctrl() = default; | ||
| 21 | ~nvhost_ctrl() override = default; | ||
| 22 | |||
| 23 | u32 ioctl(u32 command, const std::vector<u8>& input, std::vector<u8>& output) override; | ||
| 24 | |||
| 25 | private: | ||
| 26 | enum IoctlCommands { | ||
| 27 | IocSyncptReadCommand = 0xC0080014, | ||
| 28 | IocSyncptIncrCommand = 0x40040015, | ||
| 29 | IocSyncptWaitCommand = 0xC00C0016, | ||
| 30 | IocModuleMutexCommand = 0x40080017, | ||
| 31 | IocModuleRegRDWRCommand = 0xC008010E, | ||
| 32 | IocSyncptWaitexCommand = 0xC0100019, | ||
| 33 | IocSyncptReadMaxCommand = 0xC008001A, | ||
| 34 | IocGetConfigCommand = 0xC183001B, | ||
| 35 | }; | ||
| 36 | |||
| 37 | struct IocGetConfigParams { | ||
| 38 | std::array<char, 0x41> domain_str; | ||
| 39 | std::array<char, 0x41> param_str; | ||
| 40 | std::array<char, 0x101> config_str; | ||
| 41 | }; | ||
| 42 | |||
| 43 | u32 NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output); | ||
| 44 | }; | ||
| 45 | |||
| 46 | } // namespace Devices | ||
| 47 | } // namespace Nvidia | ||
| 48 | } // namespace Service | ||
diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp index 417455200..0181d1b4f 100644 --- a/src/core/hle/service/nvdrv/interface.cpp +++ b/src/core/hle/service/nvdrv/interface.cpp | |||
| @@ -69,13 +69,12 @@ void NVDRV::Initialize(Kernel::HLERequestContext& ctx) { | |||
| 69 | 69 | ||
| 70 | void NVDRV::SetClientPID(Kernel::HLERequestContext& ctx) { | 70 | void NVDRV::SetClientPID(Kernel::HLERequestContext& ctx) { |
| 71 | IPC::RequestParser rp{ctx}; | 71 | IPC::RequestParser rp{ctx}; |
| 72 | u64 pid = rp.Pop<u64>(); | 72 | pid = rp.Pop<u64>(); |
| 73 | u64 unk = rp.Pop<u64>(); | ||
| 74 | 73 | ||
| 75 | LOG_WARNING(Service, "(STUBBED) called, pid=0x%llx, unk=0x%llx", pid, unk); | 74 | LOG_INFO(Service, "called, pid=0x%lx", pid); |
| 76 | 75 | IPC::RequestBuilder rb{ctx, 3}; | |
| 77 | IPC::RequestBuilder rb{ctx, 2}; | ||
| 78 | rb.Push(RESULT_SUCCESS); | 76 | rb.Push(RESULT_SUCCESS); |
| 77 | rb.Push<u32>(0); | ||
| 79 | } | 78 | } |
| 80 | 79 | ||
| 81 | NVDRV::NVDRV(std::shared_ptr<Module> nvdrv, const char* name) | 80 | NVDRV::NVDRV(std::shared_ptr<Module> nvdrv, const char* name) |
diff --git a/src/core/hle/service/nvdrv/interface.h b/src/core/hle/service/nvdrv/interface.h index 2283f358e..f96f2bd29 100644 --- a/src/core/hle/service/nvdrv/interface.h +++ b/src/core/hle/service/nvdrv/interface.h | |||
| @@ -25,6 +25,8 @@ private: | |||
| 25 | void SetClientPID(Kernel::HLERequestContext& ctx); | 25 | void SetClientPID(Kernel::HLERequestContext& ctx); |
| 26 | 26 | ||
| 27 | std::shared_ptr<Module> nvdrv; | 27 | std::shared_ptr<Module> nvdrv; |
| 28 | |||
| 29 | u64 pid{}; | ||
| 28 | }; | 30 | }; |
| 29 | 31 | ||
| 30 | } // namespace Nvidia | 32 | } // namespace Nvidia |
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index 9d3013c16..141ddaedd 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp | |||
| @@ -6,9 +6,11 @@ | |||
| 6 | #include "core/hle/service/nvdrv/devices/nvdevice.h" | 6 | #include "core/hle/service/nvdrv/devices/nvdevice.h" |
| 7 | #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" | 7 | #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" |
| 8 | #include "core/hle/service/nvdrv/devices/nvhost_as_gpu.h" | 8 | #include "core/hle/service/nvdrv/devices/nvhost_as_gpu.h" |
| 9 | #include "core/hle/service/nvdrv/devices/nvhost_ctrl.h" | ||
| 9 | #include "core/hle/service/nvdrv/devices/nvmap.h" | 10 | #include "core/hle/service/nvdrv/devices/nvmap.h" |
| 10 | #include "core/hle/service/nvdrv/interface.h" | 11 | #include "core/hle/service/nvdrv/interface.h" |
| 11 | #include "core/hle/service/nvdrv/nvdrv.h" | 12 | #include "core/hle/service/nvdrv/nvdrv.h" |
| 13 | #include "core/hle/service/nvdrv/nvmemp.h" | ||
| 12 | 14 | ||
| 13 | namespace Service { | 15 | namespace Service { |
| 14 | namespace Nvidia { | 16 | namespace Nvidia { |
| @@ -19,6 +21,7 @@ void InstallInterfaces(SM::ServiceManager& service_manager) { | |||
| 19 | auto module_ = std::make_shared<Module>(); | 21 | auto module_ = std::make_shared<Module>(); |
| 20 | std::make_shared<NVDRV>(module_, "nvdrv")->InstallAsService(service_manager); | 22 | std::make_shared<NVDRV>(module_, "nvdrv")->InstallAsService(service_manager); |
| 21 | std::make_shared<NVDRV>(module_, "nvdrv:a")->InstallAsService(service_manager); | 23 | std::make_shared<NVDRV>(module_, "nvdrv:a")->InstallAsService(service_manager); |
| 24 | std::make_shared<NVMEMP>()->InstallAsService(service_manager); | ||
| 22 | nvdrv = module_; | 25 | nvdrv = module_; |
| 23 | } | 26 | } |
| 24 | 27 | ||
| @@ -27,6 +30,7 @@ Module::Module() { | |||
| 27 | devices["/dev/nvhost-as-gpu"] = std::make_shared<Devices::nvhost_as_gpu>(); | 30 | devices["/dev/nvhost-as-gpu"] = std::make_shared<Devices::nvhost_as_gpu>(); |
| 28 | devices["/dev/nvmap"] = nvmap_dev; | 31 | devices["/dev/nvmap"] = nvmap_dev; |
| 29 | devices["/dev/nvdisp_disp0"] = std::make_shared<Devices::nvdisp_disp0>(nvmap_dev); | 32 | devices["/dev/nvdisp_disp0"] = std::make_shared<Devices::nvdisp_disp0>(nvmap_dev); |
| 33 | devices["/dev/nvhost-ctrl"] = std::make_shared<Devices::nvhost_ctrl>(); | ||
| 30 | } | 34 | } |
| 31 | 35 | ||
| 32 | u32 Module::Open(std::string device_name) { | 36 | u32 Module::Open(std::string device_name) { |
diff --git a/src/core/hle/service/nvdrv/nvmemp.cpp b/src/core/hle/service/nvdrv/nvmemp.cpp new file mode 100644 index 000000000..5a13732c7 --- /dev/null +++ b/src/core/hle/service/nvdrv/nvmemp.cpp | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/assert.h" | ||
| 6 | #include "common/logging/log.h" | ||
| 7 | #include "core/hle/ipc_helpers.h" | ||
| 8 | #include "core/hle/service/nvdrv/nvdrv.h" | ||
| 9 | #include "core/hle/service/nvdrv/nvmemp.h" | ||
| 10 | |||
| 11 | namespace Service { | ||
| 12 | namespace Nvidia { | ||
| 13 | |||
| 14 | NVMEMP::NVMEMP() : ServiceFramework("nvmemp") { | ||
| 15 | static const FunctionInfo functions[] = { | ||
| 16 | {0, &NVMEMP::Unknown0, "Unknown0"}, | ||
| 17 | {1, &NVMEMP::Unknown1, "Unknown1"}, | ||
| 18 | }; | ||
| 19 | RegisterHandlers(functions); | ||
| 20 | } | ||
| 21 | |||
| 22 | void NVMEMP::Unknown0(Kernel::HLERequestContext& ctx) { | ||
| 23 | UNIMPLEMENTED(); | ||
| 24 | } | ||
| 25 | |||
| 26 | void NVMEMP::Unknown1(Kernel::HLERequestContext& ctx) { | ||
| 27 | UNIMPLEMENTED(); | ||
| 28 | } | ||
| 29 | |||
| 30 | } // namespace Nvidia | ||
| 31 | } // namespace Service | ||
diff --git a/src/core/hle/service/nvdrv/nvmemp.h b/src/core/hle/service/nvdrv/nvmemp.h new file mode 100644 index 000000000..a6b5fbb82 --- /dev/null +++ b/src/core/hle/service/nvdrv/nvmemp.h | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | namespace Service { | ||
| 10 | namespace Nvidia { | ||
| 11 | |||
| 12 | class NVMEMP final : public ServiceFramework<NVMEMP> { | ||
| 13 | public: | ||
| 14 | NVMEMP(); | ||
| 15 | ~NVMEMP() = default; | ||
| 16 | |||
| 17 | private: | ||
| 18 | void Unknown0(Kernel::HLERequestContext& ctx); | ||
| 19 | void Unknown1(Kernel::HLERequestContext& ctx); | ||
| 20 | }; | ||
| 21 | |||
| 22 | } // namespace Nvidia | ||
| 23 | } // namespace Service | ||