service/apt: Add and implement more service commands. (#6721)

* service/apt: Add and implement more service commands.

* service/apt: Implement power button.

* Address review comments and fix GetApplicationRunningMode bug.
This commit is contained in:
Steveice10 2023-07-29 00:26:16 -07:00 committed by GitHub
parent 51996c54f0
commit bb364d9bc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 939 additions and 221 deletions

View file

@ -97,11 +97,44 @@ union CoreVersion {
BitField<24, 8, u32> major;
};
/// Common memory memory modes.
enum class MemoryMode : u8 {
Prod = 0, ///< 64MB app memory
Dev1 = 2, ///< 96MB app memory
Dev2 = 3, ///< 80MB app memory
Dev3 = 4, ///< 72MB app memory
Dev4 = 5, ///< 32MB app memory
};
/// New 3DS memory modes.
enum class New3dsMemoryMode : u8 {
Legacy = 0, ///< Use Old 3DS system mode.
NewProd = 1, ///< 124MB app memory
NewDev1 = 2, ///< 178MB app memory
NewDev2 = 3, ///< 124MB app memory
};
/// Structure containing N3DS hardware capability flags.
struct New3dsHwCapabilities {
bool enable_l2_cache; ///< Whether extra L2 cache should be enabled.
bool enable_804MHz_cpu; ///< Whether the CPU should run at 804MHz.
New3dsMemoryMode memory_mode; ///< The New 3DS memory mode.
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& enable_l2_cache;
ar& enable_804MHz_cpu;
ar& memory_mode;
}
friend class boost::serialization::access;
};
class KernelSystem {
public:
explicit KernelSystem(Memory::MemorySystem& memory, Core::Timing& timing,
std::function<void()> prepare_reschedule_callback, u32 system_mode,
u32 num_cores, u8 n3ds_mode);
std::function<void()> prepare_reschedule_callback, MemoryMode memory_mode,
u32 num_cores, const New3dsHwCapabilities& n3ds_hw_caps);
~KernelSystem();
using PortPair = std::pair<std::shared_ptr<ServerPort>, std::shared_ptr<ClientPort>>;
@ -279,6 +312,14 @@ public:
void ResetThreadIDs();
MemoryMode GetMemoryMode() const {
return memory_mode;
}
const New3dsHwCapabilities& GetNew3dsHwCapabilities() const {
return n3ds_hw_caps;
}
/// Map of named ports managed by the kernel, which can be retrieved using the ConnectToPort
std::unordered_map<std::string, std::shared_ptr<ClientPort>> named_ports;
@ -289,7 +330,7 @@ public:
Core::Timing& timing;
private:
void MemoryInit(u32 mem_type, u8 n3ds_mode);
void MemoryInit(MemoryMode memory_mode, New3dsMemoryMode n3ds_mode);
std::function<void()> prepare_reschedule_callback;
@ -324,6 +365,9 @@ private:
u32 next_thread_id;
MemoryMode memory_mode;
New3dsHwCapabilities n3ds_hw_caps;
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version);