blob: 1364456496731fc7c77a0f1580d578917e9e8c0c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
// Copyright 2018 yuzu emulator team
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <functional>
#include <memory>
#include <queue>
#include "common/swap.h"
#include "core/hle/kernel/event.h"
union ResultCode;
namespace Service::AM {
class IStorage;
namespace Applets {
class AppletDataBroker final {
public:
AppletDataBroker();
~AppletDataBroker();
std::unique_ptr<IStorage> PopNormalDataToGame();
std::unique_ptr<IStorage> PopNormalDataToApplet();
std::unique_ptr<IStorage> PopInteractiveDataToGame();
std::unique_ptr<IStorage> PopInteractiveDataToApplet();
void PushNormalDataFromGame(IStorage storage);
void PushNormalDataFromApplet(IStorage storage);
void PushInteractiveDataFromGame(IStorage storage);
void PushInteractiveDataFromApplet(IStorage storage);
void SignalStateChanged() const;
Kernel::SharedPtr<Kernel::Event> GetNormalDataEvent() const;
Kernel::SharedPtr<Kernel::Event> GetInteractiveDataEvent() const;
Kernel::SharedPtr<Kernel::Event> GetStateChangedEvent() const;
private:
// Queues are named from applet's perspective
std::queue<std::unique_ptr<IStorage>>
in_channel; // PopNormalDataToApplet and PushNormalDataFromGame
std::queue<std::unique_ptr<IStorage>>
out_channel; // PopNormalDataToGame and PushNormalDataFromApplet
std::queue<std::unique_ptr<IStorage>>
in_interactive_channel; // PopInteractiveDataToApplet and PushInteractiveDataFromGame
std::queue<std::unique_ptr<IStorage>>
out_interactive_channel; // PopInteractiveDataToGame and PushInteractiveDataFromApplet
Kernel::SharedPtr<Kernel::Event> state_changed_event;
Kernel::SharedPtr<Kernel::Event> pop_out_data_event; // Signaled on PushNormalDataFromApplet
Kernel::SharedPtr<Kernel::Event>
pop_interactive_out_data_event; // Signaled on PushInteractiveDataFromApplet
};
class Applet {
public:
Applet();
virtual ~Applet();
virtual void Initialize(std::shared_ptr<AppletDataBroker> broker);
virtual bool TransactionComplete() const = 0;
virtual ResultCode GetStatus() const = 0;
virtual void ExecuteInteractive() = 0;
virtual void Execute() = 0;
bool IsInitialized() const {
return initialized;
}
protected:
struct CommonArguments {
u32_le arguments_version;
u32_le size;
u32_le library_version;
u32_le theme_color;
u8 play_startup_sound;
u64_le system_tick;
};
static_assert(sizeof(CommonArguments) == 0x20, "CommonArguments has incorrect size.");
CommonArguments common_args;
std::shared_ptr<AppletDataBroker> broker;
bool initialized = false;
};
} // namespace Applets
} // namespace Service::AM
|