diff options
| author | 2018-08-11 10:35:47 +1000 | |
|---|---|---|
| committer | 2018-08-11 10:35:47 +1000 | |
| commit | b76ddb7647cbb390cce4143d91a1db171b0fa503 (patch) | |
| tree | a6e2e334e82b035923c41458150604dd5fb31d65 /src/core/hle | |
| parent | Added IsUserRegistrationRequestPermitted (diff) | |
| parent | Merge pull request #1007 from MerryMage/dynarmic (diff) | |
| download | yuzu-b76ddb7647cbb390cce4143d91a1db171b0fa503.tar.gz yuzu-b76ddb7647cbb390cce4143d91a1db171b0fa503.tar.xz yuzu-b76ddb7647cbb390cce4143d91a1db171b0fa503.zip | |
Merge remote-tracking branch 'origin/master' into better-account
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/kernel/hle_ipc.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/hle_ipc.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/acc/acc.cpp | 23 | ||||
| -rw-r--r-- | src/core/hle/service/am/am.cpp | 9 | ||||
| -rw-r--r-- | src/core/hle/service/am/am.h | 1 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/filesystem.cpp | 16 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/filesystem.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/fsp_srv.cpp | 9 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv.h | 8 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/buffer_queue.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/buffer_queue.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/nvflinger.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/nvflinger.h | 9 | ||||
| -rw-r--r-- | src/core/hle/service/service.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/service/service.h | 7 |
17 files changed, 78 insertions, 36 deletions
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 5dd1b68d7..82a3fb5a8 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp | |||
| @@ -201,7 +201,7 @@ ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(u32_le* src_cmdb | |||
| 201 | return RESULT_SUCCESS; | 201 | return RESULT_SUCCESS; |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(Thread& thread) { | 204 | ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(const Thread& thread) { |
| 205 | std::array<u32, IPC::COMMAND_BUFFER_LENGTH> dst_cmdbuf; | 205 | std::array<u32, IPC::COMMAND_BUFFER_LENGTH> dst_cmdbuf; |
| 206 | Memory::ReadBlock(*thread.owner_process, thread.GetTLSAddress(), dst_cmdbuf.data(), | 206 | Memory::ReadBlock(*thread.owner_process, thread.GetTLSAddress(), dst_cmdbuf.data(), |
| 207 | dst_cmdbuf.size() * sizeof(u32)); | 207 | dst_cmdbuf.size() * sizeof(u32)); |
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 9ce52db24..f0d07f1b6 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h | |||
| @@ -132,7 +132,7 @@ public: | |||
| 132 | ResultCode PopulateFromIncomingCommandBuffer(u32_le* src_cmdbuf, Process& src_process, | 132 | ResultCode PopulateFromIncomingCommandBuffer(u32_le* src_cmdbuf, Process& src_process, |
| 133 | HandleTable& src_table); | 133 | HandleTable& src_table); |
| 134 | /// Writes data from this context back to the requesting process/thread. | 134 | /// Writes data from this context back to the requesting process/thread. |
| 135 | ResultCode WriteToOutgoingCommandBuffer(Thread& thread); | 135 | ResultCode WriteToOutgoingCommandBuffer(const Thread& thread); |
| 136 | 136 | ||
| 137 | u32_le GetCommand() const { | 137 | u32_le GetCommand() const { |
| 138 | return command; | 138 | return command; |
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 0a6cac5b7..e74379a24 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp | |||
| @@ -38,7 +38,7 @@ public: | |||
| 38 | {0, &IProfile::Get, "Get"}, | 38 | {0, &IProfile::Get, "Get"}, |
| 39 | {1, &IProfile::GetBase, "GetBase"}, | 39 | {1, &IProfile::GetBase, "GetBase"}, |
| 40 | {10, nullptr, "GetImageSize"}, | 40 | {10, nullptr, "GetImageSize"}, |
| 41 | {11, nullptr, "LoadImage"}, | 41 | {11, &IProfile::LoadImage, "LoadImage"}, |
| 42 | }; | 42 | }; |
| 43 | RegisterHandlers(functions); | 43 | RegisterHandlers(functions); |
| 44 | } | 44 | } |
| @@ -72,6 +72,27 @@ private: | |||
| 72 | } | 72 | } |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | void LoadImage(Kernel::HLERequestContext& ctx) { | ||
| 76 | LOG_WARNING(Service_ACC, "(STUBBED) called"); | ||
| 77 | // smallest jpeg https://github.com/mathiasbynens/small/blob/master/jpeg.jpg | ||
| 78 | // TODO(mailwl): load actual profile image from disk, width 256px, max size 0x20000 | ||
| 79 | const u32 jpeg_size = 107; | ||
| 80 | static const std::array<u8, jpeg_size> jpeg{ | ||
| 81 | 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, | ||
| 82 | 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, | ||
| 83 | 0x08, 0x06, 0x06, 0x05, 0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, | ||
| 84 | 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e, 0x0b, 0x09, 0x09, 0x0d, 0x11, 0x0d, 0x0e, 0x0f, | ||
| 85 | 0x10, 0x10, 0x11, 0x10, 0x0a, 0x0c, 0x12, 0x13, 0x12, 0x10, 0x13, 0x0f, 0x10, 0x10, | ||
| 86 | 0x10, 0xff, 0xc9, 0x00, 0x0b, 0x08, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x11, 0x00, | ||
| 87 | 0xff, 0xcc, 0x00, 0x06, 0x00, 0x10, 0x10, 0x05, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01, | ||
| 88 | 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9, | ||
| 89 | }; | ||
| 90 | ctx.WriteBuffer(jpeg.data(), jpeg_size); | ||
| 91 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 92 | rb.Push(RESULT_SUCCESS); | ||
| 93 | rb.Push<u32>(jpeg_size); | ||
| 94 | } | ||
| 95 | |||
| 75 | ProfileManager& profile_manager; | 96 | ProfileManager& profile_manager; |
| 76 | UUID user_id; ///< The user id this profile refers to. | 97 | UUID user_id; ///< The user id this profile refers to. |
| 77 | }; | 98 | }; |
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 9404d6b8c..762763463 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -136,7 +136,7 @@ ISelfController::ISelfController(std::shared_ptr<NVFlinger::NVFlinger> nvflinger | |||
| 136 | {16, &ISelfController::SetOutOfFocusSuspendingEnabled, "SetOutOfFocusSuspendingEnabled"}, | 136 | {16, &ISelfController::SetOutOfFocusSuspendingEnabled, "SetOutOfFocusSuspendingEnabled"}, |
| 137 | {17, nullptr, "SetControllerFirmwareUpdateSection"}, | 137 | {17, nullptr, "SetControllerFirmwareUpdateSection"}, |
| 138 | {18, nullptr, "SetRequiresCaptureButtonShortPressedMessage"}, | 138 | {18, nullptr, "SetRequiresCaptureButtonShortPressedMessage"}, |
| 139 | {19, nullptr, "SetScreenShotImageOrientation"}, | 139 | {19, &ISelfController::SetScreenShotImageOrientation, "SetScreenShotImageOrientation"}, |
| 140 | {20, nullptr, "SetDesirableKeyboardLayout"}, | 140 | {20, nullptr, "SetDesirableKeyboardLayout"}, |
| 141 | {40, &ISelfController::CreateManagedDisplayLayer, "CreateManagedDisplayLayer"}, | 141 | {40, &ISelfController::CreateManagedDisplayLayer, "CreateManagedDisplayLayer"}, |
| 142 | {41, nullptr, "IsSystemBufferSharingEnabled"}, | 142 | {41, nullptr, "IsSystemBufferSharingEnabled"}, |
| @@ -254,6 +254,13 @@ void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& | |||
| 254 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 254 | LOG_WARNING(Service_AM, "(STUBBED) called"); |
| 255 | } | 255 | } |
| 256 | 256 | ||
| 257 | void ISelfController::SetScreenShotImageOrientation(Kernel::HLERequestContext& ctx) { | ||
| 258 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 259 | rb.Push(RESULT_SUCCESS); | ||
| 260 | |||
| 261 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 262 | } | ||
| 263 | |||
| 257 | void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx) { | 264 | void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx) { |
| 258 | // TODO(Subv): Find out how AM determines the display to use, for now just create the layer | 265 | // TODO(Subv): Find out how AM determines the display to use, for now just create the layer |
| 259 | // in the Default display. | 266 | // in the Default display. |
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 8f4f98346..862f338ac 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h | |||
| @@ -83,6 +83,7 @@ private: | |||
| 83 | void LockExit(Kernel::HLERequestContext& ctx); | 83 | void LockExit(Kernel::HLERequestContext& ctx); |
| 84 | void UnlockExit(Kernel::HLERequestContext& ctx); | 84 | void UnlockExit(Kernel::HLERequestContext& ctx); |
| 85 | void GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx); | 85 | void GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx); |
| 86 | void SetScreenShotImageOrientation(Kernel::HLERequestContext& ctx); | ||
| 86 | void CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx); | 87 | void CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx); |
| 87 | void SetScreenShotPermission(Kernel::HLERequestContext& ctx); | 88 | void SetScreenShotPermission(Kernel::HLERequestContext& ctx); |
| 88 | void SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx); | 89 | void SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx); |
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index e17d637e4..5e416cde2 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp | |||
| @@ -59,7 +59,7 @@ ResultCode VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 | |||
| 59 | ResultCode VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) const { | 59 | ResultCode VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) const { |
| 60 | std::string path(FileUtil::SanitizePath(path_)); | 60 | std::string path(FileUtil::SanitizePath(path_)); |
| 61 | auto dir = GetDirectoryRelativeWrapped(backing, FileUtil::GetParentPath(path)); | 61 | auto dir = GetDirectoryRelativeWrapped(backing, FileUtil::GetParentPath(path)); |
| 62 | if (path == "/" || path == "\\") { | 62 | if (path.empty()) { |
| 63 | // TODO(DarkLordZach): Why do games call this and what should it do? Works as is but... | 63 | // TODO(DarkLordZach): Why do games call this and what should it do? Works as is but... |
| 64 | return RESULT_SUCCESS; | 64 | return RESULT_SUCCESS; |
| 65 | } | 65 | } |
| @@ -281,15 +281,15 @@ ResultVal<FileSys::VirtualDir> OpenSDMC() { | |||
| 281 | return sdmc_factory->Open(); | 281 | return sdmc_factory->Open(); |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | void RegisterFileSystems() { | 284 | void RegisterFileSystems(const FileSys::VirtualFilesystem& vfs) { |
| 285 | romfs_factory = nullptr; | 285 | romfs_factory = nullptr; |
| 286 | save_data_factory = nullptr; | 286 | save_data_factory = nullptr; |
| 287 | sdmc_factory = nullptr; | 287 | sdmc_factory = nullptr; |
| 288 | 288 | ||
| 289 | auto nand_directory = std::make_shared<FileSys::RealVfsDirectory>( | 289 | auto nand_directory = vfs->OpenDirectory(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir), |
| 290 | FileUtil::GetUserPath(FileUtil::UserPath::NANDDir), FileSys::Mode::ReadWrite); | 290 | FileSys::Mode::ReadWrite); |
| 291 | auto sd_directory = std::make_shared<FileSys::RealVfsDirectory>( | 291 | auto sd_directory = vfs->OpenDirectory(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir), |
| 292 | FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir), FileSys::Mode::ReadWrite); | 292 | FileSys::Mode::ReadWrite); |
| 293 | 293 | ||
| 294 | auto savedata = std::make_unique<FileSys::SaveDataFactory>(std::move(nand_directory)); | 294 | auto savedata = std::make_unique<FileSys::SaveDataFactory>(std::move(nand_directory)); |
| 295 | save_data_factory = std::move(savedata); | 295 | save_data_factory = std::move(savedata); |
| @@ -298,8 +298,8 @@ void RegisterFileSystems() { | |||
| 298 | sdmc_factory = std::move(sdcard); | 298 | sdmc_factory = std::move(sdcard); |
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | void InstallInterfaces(SM::ServiceManager& service_manager) { | 301 | void InstallInterfaces(SM::ServiceManager& service_manager, const FileSys::VirtualFilesystem& vfs) { |
| 302 | RegisterFileSystems(); | 302 | RegisterFileSystems(vfs); |
| 303 | std::make_shared<FSP_LDR>()->InstallAsService(service_manager); | 303 | std::make_shared<FSP_LDR>()->InstallAsService(service_manager); |
| 304 | std::make_shared<FSP_PR>()->InstallAsService(service_manager); | 304 | std::make_shared<FSP_PR>()->InstallAsService(service_manager); |
| 305 | std::make_shared<FSP_SRV>()->InstallAsService(service_manager); | 305 | std::make_shared<FSP_SRV>()->InstallAsService(service_manager); |
diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h index d4483daa5..462c13f20 100644 --- a/src/core/hle/service/filesystem/filesystem.h +++ b/src/core/hle/service/filesystem/filesystem.h | |||
| @@ -36,7 +36,7 @@ ResultVal<FileSys::VirtualDir> OpenSDMC(); | |||
| 36 | // ResultVal<std::unique_ptr<FileSys::FileSystemBackend>> OpenBIS(); | 36 | // ResultVal<std::unique_ptr<FileSys::FileSystemBackend>> OpenBIS(); |
| 37 | 37 | ||
| 38 | /// Registers all Filesystem services with the specified service manager. | 38 | /// Registers all Filesystem services with the specified service manager. |
| 39 | void InstallInterfaces(SM::ServiceManager& service_manager); | 39 | void InstallInterfaces(SM::ServiceManager& service_manager, const FileSys::VirtualFilesystem& vfs); |
| 40 | 40 | ||
| 41 | // A class that wraps a VfsDirectory with methods that return ResultVal and ResultCode instead of | 41 | // A class that wraps a VfsDirectory with methods that return ResultVal and ResultCode instead of |
| 42 | // pointers and booleans. This makes using a VfsDirectory with switch services much easier and | 42 | // pointers and booleans. This makes using a VfsDirectory with switch services much easier and |
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index e7ffb6bd1..1470f9017 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp | |||
| @@ -193,13 +193,10 @@ private: | |||
| 193 | template <typename T> | 193 | template <typename T> |
| 194 | static void BuildEntryIndex(std::vector<FileSys::Entry>& entries, const std::vector<T>& new_data, | 194 | static void BuildEntryIndex(std::vector<FileSys::Entry>& entries, const std::vector<T>& new_data, |
| 195 | FileSys::EntryType type) { | 195 | FileSys::EntryType type) { |
| 196 | entries.reserve(entries.size() + new_data.size()); | ||
| 197 | |||
| 196 | for (const auto& new_entry : new_data) { | 198 | for (const auto& new_entry : new_data) { |
| 197 | FileSys::Entry entry; | 199 | entries.emplace_back(new_entry->GetName(), type, new_entry->GetSize()); |
| 198 | entry.filename[0] = '\0'; | ||
| 199 | std::strncat(entry.filename, new_entry->GetName().c_str(), FileSys::FILENAME_LENGTH - 1); | ||
| 200 | entry.type = type; | ||
| 201 | entry.file_size = new_entry->GetSize(); | ||
| 202 | entries.emplace_back(std::move(entry)); | ||
| 203 | } | 200 | } |
| 204 | } | 201 | } |
| 205 | 202 | ||
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp index 116dabedb..4cdf7f613 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp | |||
| @@ -147,7 +147,7 @@ u32 nvhost_gpu::SubmitGPFIFO(const std::vector<u8>& input, std::vector<u8>& outp | |||
| 147 | } | 147 | } |
| 148 | params.fence_out.id = 0; | 148 | params.fence_out.id = 0; |
| 149 | params.fence_out.value = 0; | 149 | params.fence_out.value = 0; |
| 150 | std::memcpy(output.data(), ¶ms, output.size()); | 150 | std::memcpy(output.data(), ¶ms, sizeof(IoctlSubmitGpfifo)); |
| 151 | return 0; | 151 | return 0; |
| 152 | } | 152 | } |
| 153 | 153 | ||
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index e8b30921a..427f4b574 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp | |||
| @@ -16,19 +16,18 @@ | |||
| 16 | #include "core/hle/service/nvdrv/interface.h" | 16 | #include "core/hle/service/nvdrv/interface.h" |
| 17 | #include "core/hle/service/nvdrv/nvdrv.h" | 17 | #include "core/hle/service/nvdrv/nvdrv.h" |
| 18 | #include "core/hle/service/nvdrv/nvmemp.h" | 18 | #include "core/hle/service/nvdrv/nvmemp.h" |
| 19 | #include "core/hle/service/nvflinger/nvflinger.h" | ||
| 19 | 20 | ||
| 20 | namespace Service::Nvidia { | 21 | namespace Service::Nvidia { |
| 21 | 22 | ||
| 22 | std::weak_ptr<Module> nvdrv; | 23 | void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger) { |
| 23 | |||
| 24 | void InstallInterfaces(SM::ServiceManager& service_manager) { | ||
| 25 | auto module_ = std::make_shared<Module>(); | 24 | auto module_ = std::make_shared<Module>(); |
| 26 | std::make_shared<NVDRV>(module_, "nvdrv")->InstallAsService(service_manager); | 25 | std::make_shared<NVDRV>(module_, "nvdrv")->InstallAsService(service_manager); |
| 27 | std::make_shared<NVDRV>(module_, "nvdrv:a")->InstallAsService(service_manager); | 26 | std::make_shared<NVDRV>(module_, "nvdrv:a")->InstallAsService(service_manager); |
| 28 | std::make_shared<NVDRV>(module_, "nvdrv:s")->InstallAsService(service_manager); | 27 | std::make_shared<NVDRV>(module_, "nvdrv:s")->InstallAsService(service_manager); |
| 29 | std::make_shared<NVDRV>(module_, "nvdrv:t")->InstallAsService(service_manager); | 28 | std::make_shared<NVDRV>(module_, "nvdrv:t")->InstallAsService(service_manager); |
| 30 | std::make_shared<NVMEMP>()->InstallAsService(service_manager); | 29 | std::make_shared<NVMEMP>()->InstallAsService(service_manager); |
| 31 | nvdrv = module_; | 30 | nvflinger.SetNVDrvInstance(module_); |
| 32 | } | 31 | } |
| 33 | 32 | ||
| 34 | Module::Module() { | 33 | Module::Module() { |
diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index 184f3c9fc..99eb1128a 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h | |||
| @@ -10,6 +10,10 @@ | |||
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "core/hle/service/service.h" | 11 | #include "core/hle/service/service.h" |
| 12 | 12 | ||
| 13 | namespace Service::NVFlinger { | ||
| 14 | class NVFlinger; | ||
| 15 | } | ||
| 16 | |||
| 13 | namespace Service::Nvidia { | 17 | namespace Service::Nvidia { |
| 14 | 18 | ||
| 15 | namespace Devices { | 19 | namespace Devices { |
| @@ -56,8 +60,6 @@ private: | |||
| 56 | }; | 60 | }; |
| 57 | 61 | ||
| 58 | /// Registers all NVDRV services with the specified service manager. | 62 | /// Registers all NVDRV services with the specified service manager. |
| 59 | void InstallInterfaces(SM::ServiceManager& service_manager); | 63 | void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger); |
| 60 | |||
| 61 | extern std::weak_ptr<Module> nvdrv; | ||
| 62 | 64 | ||
| 63 | } // namespace Service::Nvidia | 65 | } // namespace Service::Nvidia |
diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp index adf180509..ef5713a71 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.cpp +++ b/src/core/hle/service/nvflinger/buffer_queue.cpp | |||
| @@ -16,7 +16,7 @@ BufferQueue::BufferQueue(u32 id, u64 layer_id) : id(id), layer_id(layer_id) { | |||
| 16 | Kernel::Event::Create(Kernel::ResetType::Sticky, "BufferQueue NativeHandle"); | 16 | Kernel::Event::Create(Kernel::ResetType::Sticky, "BufferQueue NativeHandle"); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | void BufferQueue::SetPreallocatedBuffer(u32 slot, IGBPBuffer& igbp_buffer) { | 19 | void BufferQueue::SetPreallocatedBuffer(u32 slot, const IGBPBuffer& igbp_buffer) { |
| 20 | Buffer buffer{}; | 20 | Buffer buffer{}; |
| 21 | buffer.slot = slot; | 21 | buffer.slot = slot; |
| 22 | buffer.igbp_buffer = igbp_buffer; | 22 | buffer.igbp_buffer = igbp_buffer; |
diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index 004170538..f86e1056c 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h | |||
| @@ -72,7 +72,7 @@ public: | |||
| 72 | MathUtil::Rectangle<int> crop_rect; | 72 | MathUtil::Rectangle<int> crop_rect; |
| 73 | }; | 73 | }; |
| 74 | 74 | ||
| 75 | void SetPreallocatedBuffer(u32 slot, IGBPBuffer& buffer); | 75 | void SetPreallocatedBuffer(u32 slot, const IGBPBuffer& igbp_buffer); |
| 76 | boost::optional<u32> DequeueBuffer(u32 width, u32 height); | 76 | boost::optional<u32> DequeueBuffer(u32 width, u32 height); |
| 77 | const IGBPBuffer& RequestBuffer(u32 slot) const; | 77 | const IGBPBuffer& RequestBuffer(u32 slot) const; |
| 78 | void QueueBuffer(u32 slot, BufferTransformFlags transform, | 78 | void QueueBuffer(u32 slot, BufferTransformFlags transform, |
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index 570aa8493..a26a5f812 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp | |||
| @@ -46,6 +46,10 @@ NVFlinger::~NVFlinger() { | |||
| 46 | CoreTiming::UnscheduleEvent(composition_event, 0); | 46 | CoreTiming::UnscheduleEvent(composition_event, 0); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) { | ||
| 50 | nvdrv = std::move(instance); | ||
| 51 | } | ||
| 52 | |||
| 49 | u64 NVFlinger::OpenDisplay(std::string_view name) { | 53 | u64 NVFlinger::OpenDisplay(std::string_view name) { |
| 50 | LOG_WARNING(Service, "Opening display {}", name); | 54 | LOG_WARNING(Service, "Opening display {}", name); |
| 51 | 55 | ||
| @@ -141,9 +145,6 @@ void NVFlinger::Compose() { | |||
| 141 | auto& igbp_buffer = buffer->igbp_buffer; | 145 | auto& igbp_buffer = buffer->igbp_buffer; |
| 142 | 146 | ||
| 143 | // Now send the buffer to the GPU for drawing. | 147 | // Now send the buffer to the GPU for drawing. |
| 144 | auto nvdrv = Nvidia::nvdrv.lock(); | ||
| 145 | ASSERT(nvdrv); | ||
| 146 | |||
| 147 | // TODO(Subv): Support more than just disp0. The display device selection is probably based | 148 | // TODO(Subv): Support more than just disp0. The display device selection is probably based |
| 148 | // on which display we're drawing (Default, Internal, External, etc) | 149 | // on which display we're drawing (Default, Internal, External, etc) |
| 149 | auto nvdisp = nvdrv->GetDevice<Nvidia::Devices::nvdisp_disp0>("/dev/nvdisp_disp0"); | 150 | auto nvdisp = nvdrv->GetDevice<Nvidia::Devices::nvdisp_disp0>("/dev/nvdisp_disp0"); |
diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index 5374df175..f7112949f 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h | |||
| @@ -16,6 +16,10 @@ namespace CoreTiming { | |||
| 16 | struct EventType; | 16 | struct EventType; |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | namespace Service::Nvidia { | ||
| 20 | class Module; | ||
| 21 | } | ||
| 22 | |||
| 19 | namespace Service::NVFlinger { | 23 | namespace Service::NVFlinger { |
| 20 | 24 | ||
| 21 | class BufferQueue; | 25 | class BufferQueue; |
| @@ -44,6 +48,9 @@ public: | |||
| 44 | NVFlinger(); | 48 | NVFlinger(); |
| 45 | ~NVFlinger(); | 49 | ~NVFlinger(); |
| 46 | 50 | ||
| 51 | /// Sets the NVDrv module instance to use to send buffers to the GPU. | ||
| 52 | void SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance); | ||
| 53 | |||
| 47 | /// Opens the specified display and returns the id. | 54 | /// Opens the specified display and returns the id. |
| 48 | u64 OpenDisplay(std::string_view name); | 55 | u64 OpenDisplay(std::string_view name); |
| 49 | 56 | ||
| @@ -70,6 +77,8 @@ private: | |||
| 70 | /// Returns the layer identified by the specified id in the desired display. | 77 | /// Returns the layer identified by the specified id in the desired display. |
| 71 | Layer& GetLayer(u64 display_id, u64 layer_id); | 78 | Layer& GetLayer(u64 display_id, u64 layer_id); |
| 72 | 79 | ||
| 80 | std::shared_ptr<Nvidia::Module> nvdrv; | ||
| 81 | |||
| 73 | std::vector<Display> displays; | 82 | std::vector<Display> displays; |
| 74 | std::vector<std::shared_ptr<BufferQueue>> buffer_queues; | 83 | std::vector<std::shared_ptr<BufferQueue>> buffer_queues; |
| 75 | 84 | ||
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 889cdd41a..11951adaf 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -198,7 +198,7 @@ void AddNamedPort(std::string name, SharedPtr<ClientPort> port) { | |||
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | /// Initialize ServiceManager | 200 | /// Initialize ServiceManager |
| 201 | void Init(std::shared_ptr<SM::ServiceManager>& sm) { | 201 | void Init(std::shared_ptr<SM::ServiceManager>& sm, const FileSys::VirtualFilesystem& rfs) { |
| 202 | // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it | 202 | // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it |
| 203 | // here and pass it into the respective InstallInterfaces functions. | 203 | // here and pass it into the respective InstallInterfaces functions. |
| 204 | auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>(); | 204 | auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>(); |
| @@ -221,7 +221,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) { | |||
| 221 | EUPLD::InstallInterfaces(*sm); | 221 | EUPLD::InstallInterfaces(*sm); |
| 222 | Fatal::InstallInterfaces(*sm); | 222 | Fatal::InstallInterfaces(*sm); |
| 223 | FGM::InstallInterfaces(*sm); | 223 | FGM::InstallInterfaces(*sm); |
| 224 | FileSystem::InstallInterfaces(*sm); | 224 | FileSystem::InstallInterfaces(*sm, rfs); |
| 225 | Friend::InstallInterfaces(*sm); | 225 | Friend::InstallInterfaces(*sm); |
| 226 | GRC::InstallInterfaces(*sm); | 226 | GRC::InstallInterfaces(*sm); |
| 227 | HID::InstallInterfaces(*sm); | 227 | HID::InstallInterfaces(*sm); |
| @@ -238,7 +238,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) { | |||
| 238 | NIFM::InstallInterfaces(*sm); | 238 | NIFM::InstallInterfaces(*sm); |
| 239 | NIM::InstallInterfaces(*sm); | 239 | NIM::InstallInterfaces(*sm); |
| 240 | NS::InstallInterfaces(*sm); | 240 | NS::InstallInterfaces(*sm); |
| 241 | Nvidia::InstallInterfaces(*sm); | 241 | Nvidia::InstallInterfaces(*sm, *nv_flinger); |
| 242 | PCIe::InstallInterfaces(*sm); | 242 | PCIe::InstallInterfaces(*sm); |
| 243 | PCTL::InstallInterfaces(*sm); | 243 | PCTL::InstallInterfaces(*sm); |
| 244 | PCV::InstallInterfaces(*sm); | 244 | PCV::InstallInterfaces(*sm); |
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 046c5e18d..8a294c0f2 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h | |||
| @@ -22,6 +22,10 @@ class ServerSession; | |||
| 22 | class HLERequestContext; | 22 | class HLERequestContext; |
| 23 | } // namespace Kernel | 23 | } // namespace Kernel |
| 24 | 24 | ||
| 25 | namespace FileSys { | ||
| 26 | struct VfsFilesystem; | ||
| 27 | } | ||
| 28 | |||
| 25 | namespace Service { | 29 | namespace Service { |
| 26 | 30 | ||
| 27 | namespace SM { | 31 | namespace SM { |
| @@ -177,7 +181,8 @@ private: | |||
| 177 | }; | 181 | }; |
| 178 | 182 | ||
| 179 | /// Initialize ServiceManager | 183 | /// Initialize ServiceManager |
| 180 | void Init(std::shared_ptr<SM::ServiceManager>& sm); | 184 | void Init(std::shared_ptr<SM::ServiceManager>& sm, |
| 185 | const std::shared_ptr<FileSys::VfsFilesystem>& vfs); | ||
| 181 | 186 | ||
| 182 | /// Shutdown ServiceManager | 187 | /// Shutdown ServiceManager |
| 183 | void Shutdown(); | 188 | void Shutdown(); |