diff options
| author | 2019-04-28 18:57:37 -0400 | |
|---|---|---|
| committer | 2019-09-30 17:23:26 -0400 | |
| commit | 86773a7f081a8a6c71643ecdc6573b65dbf0ccd3 (patch) | |
| tree | efd050d84299e3b972549a088d1d908f98967168 /src | |
| parent | bcat: Implement IDeliveryCacheProgressService commands (diff) | |
| download | yuzu-86773a7f081a8a6c71643ecdc6573b65dbf0ccd3.tar.gz yuzu-86773a7f081a8a6c71643ecdc6573b65dbf0ccd3.tar.xz yuzu-86773a7f081a8a6c71643ecdc6573b65dbf0ccd3.zip | |
bcat: Implement cmd RequestSyncDeliveryCache and variant
Variant also supports only updating a single directory. These just both invoke backend commands.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/bcat/module.cpp | 72 |
1 files changed, 70 insertions, 2 deletions
diff --git a/src/core/hle/service/bcat/module.cpp b/src/core/hle/service/bcat/module.cpp index 1459fab11..605aa6e00 100644 --- a/src/core/hle/service/bcat/module.cpp +++ b/src/core/hle/service/bcat/module.cpp | |||
| @@ -145,8 +145,8 @@ public: | |||
| 145 | IBcatService(Backend& backend) : ServiceFramework("IBcatService"), backend(backend) { | 145 | IBcatService(Backend& backend) : ServiceFramework("IBcatService"), backend(backend) { |
| 146 | // clang-format off | 146 | // clang-format off |
| 147 | static const FunctionInfo functions[] = { | 147 | static const FunctionInfo functions[] = { |
| 148 | {10100, nullptr, "RequestSyncDeliveryCache"}, | 148 | {10100, &IBcatService::RequestSyncDeliveryCache, "RequestSyncDeliveryCache"}, |
| 149 | {10101, nullptr, "RequestSyncDeliveryCacheWithDirectoryName"}, | 149 | {10101, &IBcatService::RequestSyncDeliveryCacheWithDirectoryName, "RequestSyncDeliveryCacheWithDirectoryName"}, |
| 150 | {10200, nullptr, "CancelSyncDeliveryCacheRequest"}, | 150 | {10200, nullptr, "CancelSyncDeliveryCacheRequest"}, |
| 151 | {20100, nullptr, "RequestSyncDeliveryCacheWithApplicationId"}, | 151 | {20100, nullptr, "RequestSyncDeliveryCacheWithApplicationId"}, |
| 152 | {20101, nullptr, "RequestSyncDeliveryCacheWithApplicationIdAndDirectoryName"}, | 152 | {20101, nullptr, "RequestSyncDeliveryCacheWithApplicationIdAndDirectoryName"}, |
| @@ -162,7 +162,74 @@ public: | |||
| 162 | }; | 162 | }; |
| 163 | // clang-format on | 163 | // clang-format on |
| 164 | RegisterHandlers(functions); | 164 | RegisterHandlers(functions); |
| 165 | |||
| 166 | auto& kernel{Core::System::GetInstance().Kernel()}; | ||
| 167 | progress.at(static_cast<std::size_t>(SyncType::Normal)).event = | ||
| 168 | Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Sticky, | ||
| 169 | "BCAT::IDeliveryCacheProgressEvent"); | ||
| 170 | progress.at(static_cast<std::size_t>(SyncType::Directory)).event = | ||
| 171 | Kernel::WritableEvent::CreateEventPair( | ||
| 172 | kernel, Kernel::ResetType::OneShot, | ||
| 173 | "BCAT::IDeliveryCacheProgressEvent::DirectoryName"); | ||
| 174 | } | ||
| 175 | |||
| 176 | private: | ||
| 177 | enum class SyncType { | ||
| 178 | Normal, | ||
| 179 | Directory, | ||
| 180 | Count, | ||
| 181 | }; | ||
| 182 | |||
| 183 | std::function<void(bool)> CreateCallback(SyncType type) { | ||
| 184 | return [this, type](bool success) { | ||
| 185 | auto& pair{progress.at(static_cast<std::size_t>(type))}; | ||
| 186 | pair.impl.status = DeliveryCacheProgressImpl::Status::Complete; | ||
| 187 | pair.event.writable->Signal(); | ||
| 188 | }; | ||
| 189 | } | ||
| 190 | |||
| 191 | std::shared_ptr<IDeliveryCacheProgressService> CreateProgressService(SyncType type) { | ||
| 192 | const auto& pair{progress.at(static_cast<std::size_t>(type))}; | ||
| 193 | return std::make_shared<IDeliveryCacheProgressService>(pair.event.readable, pair.impl); | ||
| 165 | } | 194 | } |
| 195 | |||
| 196 | void RequestSyncDeliveryCache(Kernel::HLERequestContext& ctx) { | ||
| 197 | LOG_DEBUG(Service_BCAT, "called"); | ||
| 198 | |||
| 199 | backend.Synchronize({Core::CurrentProcess()->GetTitleID(), GetCurrentBuildID()}, | ||
| 200 | CreateCallback(SyncType::Normal)); | ||
| 201 | |||
| 202 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 203 | rb.Push(RESULT_SUCCESS); | ||
| 204 | rb.PushIpcInterface(CreateProgressService(SyncType::Normal)); | ||
| 205 | } | ||
| 206 | |||
| 207 | void RequestSyncDeliveryCacheWithDirectoryName(Kernel::HLERequestContext& ctx) { | ||
| 208 | IPC::RequestParser rp{ctx}; | ||
| 209 | const auto name_raw = rp.PopRaw<DirectoryName>(); | ||
| 210 | const auto name = | ||
| 211 | Common::StringFromFixedZeroTerminatedBuffer(name_raw.data(), name_raw.size()); | ||
| 212 | |||
| 213 | LOG_DEBUG(Service_BCAT, "called, name={}", name); | ||
| 214 | |||
| 215 | backend.SynchronizeDirectory({Core::CurrentProcess()->GetTitleID(), GetCurrentBuildID()}, | ||
| 216 | name, CreateCallback(SyncType::Directory)); | ||
| 217 | |||
| 218 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 219 | rb.Push(RESULT_SUCCESS); | ||
| 220 | rb.PushIpcInterface(CreateProgressService(SyncType::Directory)); | ||
| 221 | } | ||
| 222 | |||
| 223 | } | ||
| 224 | |||
| 225 | Backend& backend; | ||
| 226 | |||
| 227 | struct ProgressPair { | ||
| 228 | Kernel::EventPair event; | ||
| 229 | DeliveryCacheProgressImpl impl; | ||
| 230 | }; | ||
| 231 | |||
| 232 | std::array<ProgressPair, static_cast<std::size_t>(SyncType::Count)> progress{}; | ||
| 166 | }; | 233 | }; |
| 167 | 234 | ||
| 168 | void Module::Interface::CreateBcatService(Kernel::HLERequestContext& ctx) { | 235 | void Module::Interface::CreateBcatService(Kernel::HLERequestContext& ctx) { |
| @@ -171,6 +238,7 @@ void Module::Interface::CreateBcatService(Kernel::HLERequestContext& ctx) { | |||
| 171 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 238 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 172 | rb.Push(RESULT_SUCCESS); | 239 | rb.Push(RESULT_SUCCESS); |
| 173 | rb.PushIpcInterface<IBcatService>(*backend); | 240 | rb.PushIpcInterface<IBcatService>(*backend); |
| 241 | } | ||
| 174 | 242 | ||
| 175 | class IDeliveryCacheFileService final : public ServiceFramework<IDeliveryCacheFileService> { | 243 | class IDeliveryCacheFileService final : public ServiceFramework<IDeliveryCacheFileService> { |
| 176 | public: | 244 | public: |