diff options
| author | Ac_K <Acoustik666@gmail.com> | 2019-09-10 11:55:28 +0200 |
|---|---|---|
| committer | Thomas Guillemard <me@thog.eu> | 2019-09-10 11:55:28 +0200 |
| commit | 0e93a510307c1e50a8916fadcc3f52015a6d4cc2 (patch) | |
| tree | c7d929861c0a86b02ae800e157e84b8c46460774 /Ryujinx.HLE/HOS/Services/Bcat | |
| parent | 1ff89d6482a6ec907bb983c1d2bc473bea546367 (diff) | |
bcat:u: Implement EnumerateDeliveryCacheDirectory (#768)
* bcat:u: Implement EnumerateDeliveryCacheDirectory
Basic implementation `EnumerateDeliveryCacheDirectory` call to `IDeliveryCacheStorageService` according to RE. (close #622)
I've added some comments in the whole service for when we'll implement a real bcat implementation.
For now, all games who use it isn't playable because of GPU.
* Use Array instead of List
* Add ApplicationLaunchPropertyHelper
* Fix helper
* Fix helper 2
* Fix ApplicationLaunchProperty Default
* Fix ApplicationLaunchProperty 2
* Fix folder
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Bcat')
| -rw-r--r-- | Ryujinx.HLE/HOS/Services/Bcat/IBcatService.cs | 4 | ||||
| -rw-r--r-- | Ryujinx.HLE/HOS/Services/Bcat/IDeliveryCacheStorageService.cs | 42 | ||||
| -rw-r--r-- | Ryujinx.HLE/HOS/Services/Bcat/IServiceCreator.cs | 24 | ||||
| -rw-r--r-- | Ryujinx.HLE/HOS/Services/Bcat/ResultCode.cs | 14 |
4 files changed, 78 insertions, 6 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Bcat/IBcatService.cs b/Ryujinx.HLE/HOS/Services/Bcat/IBcatService.cs index 6fdcba46..030f9110 100644 --- a/Ryujinx.HLE/HOS/Services/Bcat/IBcatService.cs +++ b/Ryujinx.HLE/HOS/Services/Bcat/IBcatService.cs @@ -1,7 +1,9 @@ +using Ryujinx.HLE.HOS.Services.Glue; + namespace Ryujinx.HLE.HOS.Services.Bcat { class IBcatService : IpcService { - public IBcatService() { } + public IBcatService(ApplicationLaunchProperty applicationLaunchProperty) { } } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Bcat/IDeliveryCacheStorageService.cs b/Ryujinx.HLE/HOS/Services/Bcat/IDeliveryCacheStorageService.cs index 5e3db998..1c9aed11 100644 --- a/Ryujinx.HLE/HOS/Services/Bcat/IDeliveryCacheStorageService.cs +++ b/Ryujinx.HLE/HOS/Services/Bcat/IDeliveryCacheStorageService.cs @@ -1,7 +1,47 @@ +using Ryujinx.HLE.HOS.Services.Glue; +using System; +using System.Text; + namespace Ryujinx.HLE.HOS.Services.Bcat { class IDeliveryCacheStorageService : IpcService { - public IDeliveryCacheStorageService() { } + private const int DeliveryCacheDirectoriesLimit = 100; + private const int DeliveryCacheDirectoryNameLength = 32; + + private string[] _deliveryCacheDirectories = new string[0]; + + public IDeliveryCacheStorageService(ServiceCtx context, ApplicationLaunchProperty applicationLaunchProperty) + { + // TODO: Read directories.meta file from the save data (loaded in IServiceCreator) in _deliveryCacheDirectories. + } + + [Command(10)] + // EnumerateDeliveryCacheDirectory() -> (u32, buffer<nn::bcat::DirectoryName, 6>) + public ResultCode EnumerateDeliveryCacheDirectory(ServiceCtx context) + { + long outputPosition = context.Request.ReceiveBuff[0].Position; + long outputSize = context.Request.ReceiveBuff[0].Size; + + for (int index = 0; index < _deliveryCacheDirectories.Length; index++) + { + if (index == DeliveryCacheDirectoriesLimit - 1) + { + break; + } + + byte[] directoryNameBuffer = Encoding.ASCII.GetBytes(_deliveryCacheDirectories[index]); + + Array.Resize(ref directoryNameBuffer, DeliveryCacheDirectoryNameLength); + + directoryNameBuffer[DeliveryCacheDirectoryNameLength - 1] = 0x00; + + context.Memory.WriteBytes(outputPosition + index * DeliveryCacheDirectoryNameLength, directoryNameBuffer); + } + + context.ResponseData.Write(_deliveryCacheDirectories.Length); + + return ResultCode.Success; + } } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Bcat/IServiceCreator.cs b/Ryujinx.HLE/HOS/Services/Bcat/IServiceCreator.cs index e2a3b352..4e9d3656 100644 --- a/Ryujinx.HLE/HOS/Services/Bcat/IServiceCreator.cs +++ b/Ryujinx.HLE/HOS/Services/Bcat/IServiceCreator.cs @@ -1,3 +1,5 @@ +using Ryujinx.HLE.HOS.Services.Glue; + namespace Ryujinx.HLE.HOS.Services.Bcat { [Service("bcat:a")] @@ -12,9 +14,16 @@ namespace Ryujinx.HLE.HOS.Services.Bcat // CreateBcatService(u64, pid) -> object<nn::bcat::detail::ipc::IBcatService> public ResultCode CreateBcatService(ServiceCtx context) { - long id = context.RequestData.ReadInt64(); + // TODO: Call arp:r GetApplicationLaunchProperty with the pid to get the TitleId. + // Add an instance of nn::bcat::detail::service::core::PassphraseManager. + // Add an instance of nn::bcat::detail::service::ServiceMemoryManager. + // Add an instance of nn::bcat::detail::service::core::TaskManager who load "bcat-sys:/" system save data and open "dc/task.bin". + // If the file don't exist, create a new one (size of 0x800) and write 2 empty struct with a size of 0x400. + + MakeObject(context, new IBcatService(ApplicationLaunchProperty.GetByPid(context))); - MakeObject(context, new IBcatService()); + // NOTE: If the IBcatService is null this error is returned, Doesn't occur in our case. + // return ResultCode.NullObject; return ResultCode.Success; } @@ -23,9 +32,16 @@ namespace Ryujinx.HLE.HOS.Services.Bcat // CreateDeliveryCacheStorageService(u64, pid) -> object<nn::bcat::detail::ipc::IDeliveryCacheStorageService> public ResultCode CreateDeliveryCacheStorageService(ServiceCtx context) { - long id = context.RequestData.ReadInt64(); + // TODO: Call arp:r GetApplicationLaunchProperty with the pid to get the TitleId. + // Add an instance of nn::bcat::detail::service::core::ApplicationStorageManager who load "bcat-dc-X:/" system save data, + // return ResultCode.NullSaveData if failed. + // Where X depend of the ApplicationLaunchProperty stored in an array (range 0-3). + // Add an instance of nn::bcat::detail::service::ServiceMemoryManager. + + MakeObject(context, new IDeliveryCacheStorageService(context, ApplicationLaunchProperty.GetByPid(context))); - MakeObject(context, new IDeliveryCacheStorageService()); + // NOTE: If the IDeliveryCacheStorageService is null this error is returned, Doesn't occur in our case. + // return ResultCode.NullObject; return ResultCode.Success; } diff --git a/Ryujinx.HLE/HOS/Services/Bcat/ResultCode.cs b/Ryujinx.HLE/HOS/Services/Bcat/ResultCode.cs new file mode 100644 index 00000000..bc13d9dd --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Bcat/ResultCode.cs @@ -0,0 +1,14 @@ +namespace Ryujinx.HLE.HOS.Services.Bcat +{ + enum ResultCode + { + ModuleId = 122, + ErrorCodeShift = 9, + + Success = 0, + + NullArgument = (2 << ErrorCodeShift) | ModuleId, + NullSaveData = (31 << ErrorCodeShift) | ModuleId, + NullObject = (91 << ErrorCodeShift) | ModuleId + } +}
\ No newline at end of file |
