summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Zach Hilman2019-04-28 18:46:46 -0400
committerGravatar Zach Hilman2019-09-30 17:21:53 -0400
commit2c0b75a7448ab3878d159548858b397e1bcc305b (patch)
tree75dcee9d42250068541f9a448a1a255a7c7e025a /src/core
parentsettings: Add option to set BCAT backend (diff)
downloadyuzu-2c0b75a7448ab3878d159548858b397e1bcc305b.tar.gz
yuzu-2c0b75a7448ab3878d159548858b397e1bcc305b.tar.xz
yuzu-2c0b75a7448ab3878d159548858b397e1bcc305b.zip
bcat: Add backend class to generify the functions of BCAT
Provides the most abstract simplified functions of BCAT as functions. Also includes a NullBackend class which is just a no-op.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/service/bcat/backend/backend.cpp47
-rw-r--r--src/core/hle/service/bcat/backend/backend.h53
2 files changed, 100 insertions, 0 deletions
diff --git a/src/core/hle/service/bcat/backend/backend.cpp b/src/core/hle/service/bcat/backend/backend.cpp
new file mode 100644
index 000000000..aefa2208d
--- /dev/null
+++ b/src/core/hle/service/bcat/backend/backend.cpp
@@ -0,0 +1,47 @@
1// Copyright 2019 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "common/hex_util.h"
6#include "common/logging/log.h"
7#include "core/hle/service/bcat/backend/backend.h"
8
9namespace Service::BCAT {
10
11Backend::Backend(DirectoryGetter getter) : dir_getter(std::move(getter)) {}
12
13Backend::~Backend() = default;
14
15NullBackend::NullBackend(const DirectoryGetter& getter) : Backend(std::move(getter)) {}
16
17NullBackend::~NullBackend() = default;
18
19bool NullBackend::Synchronize(TitleIDVersion title, CompletionCallback callback) {
20 LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, build_id={:016X}", title.title_id,
21 title.build_id);
22
23 callback(true);
24 return true;
25}
26
27bool NullBackend::SynchronizeDirectory(TitleIDVersion title, std::string name,
28 CompletionCallback callback) {
29 LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, build_id={:016X}, name={}", title.title_id,
30 title.build_id, name);
31
32 callback(true);
33 return true;
34}
35
36bool NullBackend::Clear(u64 title_id) {
37 LOG_DEBUG(Service_BCAT, "called, title_id={:016X}");
38
39 return true;
40}
41
42void NullBackend::SetPassphrase(u64 title_id, const Passphrase& passphrase) {
43 LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, passphrase = {}", title_id,
44 Common::HexArrayToString(passphrase));
45}
46
47} // namespace Service::BCAT
diff --git a/src/core/hle/service/bcat/backend/backend.h b/src/core/hle/service/bcat/backend/backend.h
new file mode 100644
index 000000000..2e9511f3f
--- /dev/null
+++ b/src/core/hle/service/bcat/backend/backend.h
@@ -0,0 +1,53 @@
1// Copyright 2019 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 <functional>
8#include "common/common_types.h"
9#include "core/file_sys/vfs_types.h"
10
11namespace Service::BCAT {
12
13using CompletionCallback = std::function<void(bool)>;
14using DirectoryGetter = std::function<FileSys::VirtualDir(u64)>;
15using Passphrase = std::array<u8, 0x20>;
16
17struct TitleIDVersion {
18 u64 title_id;
19 u64 build_id;
20};
21
22class Backend {
23public:
24 explicit Backend(DirectoryGetter getter);
25 virtual ~Backend();
26
27 virtual bool Synchronize(TitleIDVersion title, CompletionCallback callback) = 0;
28 virtual bool SynchronizeDirectory(TitleIDVersion title, std::string name,
29 CompletionCallback callback) = 0;
30
31 virtual bool Clear(u64 title_id) = 0;
32
33 virtual void SetPassphrase(u64 title_id, const Passphrase& passphrase) = 0;
34
35protected:
36 DirectoryGetter dir_getter;
37};
38
39class NullBackend : public Backend {
40public:
41 explicit NullBackend(const DirectoryGetter& getter);
42 ~NullBackend() override;
43
44 bool Synchronize(TitleIDVersion title, CompletionCallback callback) override;
45 bool SynchronizeDirectory(TitleIDVersion title, std::string name,
46 CompletionCallback callback) override;
47
48 bool Clear(u64 title_id) override;
49
50 void SetPassphrase(u64 title_id, const Passphrase& passphrase) override;
51};
52
53} // namespace Service::BCAT