mirror of
https://github.com/PabloMK7/citra.git
synced 2025-09-11 13:20:04 +00:00
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:
parent
51996c54f0
commit
bb364d9bc0
31 changed files with 939 additions and 221 deletions
|
@ -13,6 +13,7 @@
|
|||
#include "common/common_types.h"
|
||||
#include "common/file_util.h"
|
||||
#include "core/file_sys/romfs_reader.h"
|
||||
#include "core/hle/kernel/kernel.h"
|
||||
#include "core/hle/kernel/object.h"
|
||||
|
||||
namespace Kernel {
|
||||
|
@ -99,23 +100,36 @@ public:
|
|||
virtual ResultStatus Load(std::shared_ptr<Kernel::Process>& process) = 0;
|
||||
|
||||
/**
|
||||
* Loads the system mode that this application needs.
|
||||
* This function defaults to 2 (96MB allocated to the application) if it can't read the
|
||||
* Loads the core version (FIRM title ID low) that this application needs.
|
||||
* This function defaults to 0x2 (NATIVE_FIRM) if it can't read the
|
||||
* information.
|
||||
* @returns A pair with the optional system mode, and the status.
|
||||
* @returns A pair with the optional core version, and the status.
|
||||
*/
|
||||
virtual std::pair<std::optional<u32>, ResultStatus> LoadKernelSystemMode() {
|
||||
// 96MB allocated to the application.
|
||||
return std::make_pair(2, ResultStatus::Success);
|
||||
virtual std::pair<std::optional<u32>, ResultStatus> LoadCoreVersion() {
|
||||
return std::make_pair(0x2, ResultStatus::Success);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the N3ds mode that this application uses.
|
||||
* It defaults to 0 (O3DS default) if it can't read the information.
|
||||
* @returns A pair with the optional N3ds mode, and the status.
|
||||
* Loads the memory mode that this application needs.
|
||||
* This function defaults to Dev1 (96MB allocated to the application) if it can't read the
|
||||
* information.
|
||||
* @returns A pair with the optional memory mode, and the status.
|
||||
*/
|
||||
virtual std::pair<std::optional<u8>, ResultStatus> LoadKernelN3dsMode() {
|
||||
return std::make_pair(u8(0), ResultStatus::Success);
|
||||
virtual std::pair<std::optional<Kernel::MemoryMode>, ResultStatus> LoadKernelMemoryMode() {
|
||||
// 96MB allocated to the application.
|
||||
return std::make_pair(Kernel::MemoryMode::Dev1, ResultStatus::Success);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the N3DS hardware capabilities that this application uses.
|
||||
* It defaults to all disabled (O3DS) if it can't read the information.
|
||||
* @returns A pair with the optional N3DS hardware capabilities, and the status.
|
||||
*/
|
||||
virtual std::pair<std::optional<Kernel::New3dsHwCapabilities>, ResultStatus>
|
||||
LoadNew3dsHwCapabilities() {
|
||||
return std::make_pair(
|
||||
Kernel::New3dsHwCapabilities{false, false, Kernel::New3dsMemoryMode::Legacy},
|
||||
ResultStatus::Success);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "core/core.h"
|
||||
#include "core/file_sys/ncch_container.h"
|
||||
#include "core/file_sys/title_metadata.h"
|
||||
#include "core/hle/kernel/kernel.h"
|
||||
#include "core/hle/kernel/process.h"
|
||||
#include "core/hle/kernel/resource_limit.h"
|
||||
#include "core/hle/service/am/am.h"
|
||||
|
@ -47,7 +48,7 @@ FileType AppLoader_NCCH::IdentifyType(FileUtil::IOFile& file) {
|
|||
return FileType::Error;
|
||||
}
|
||||
|
||||
std::pair<std::optional<u32>, ResultStatus> AppLoader_NCCH::LoadKernelSystemMode() {
|
||||
std::pair<std::optional<u32>, ResultStatus> AppLoader_NCCH::LoadCoreVersion() {
|
||||
if (!is_loaded) {
|
||||
ResultStatus res = base_ncch.Load();
|
||||
if (res != ResultStatus::Success) {
|
||||
|
@ -55,12 +56,12 @@ std::pair<std::optional<u32>, ResultStatus> AppLoader_NCCH::LoadKernelSystemMode
|
|||
}
|
||||
}
|
||||
|
||||
// Set the system mode as the one from the exheader.
|
||||
return std::make_pair(overlay_ncch->exheader_header.arm11_system_local_caps.system_mode.Value(),
|
||||
ResultStatus::Success);
|
||||
// Provide the core version from the exheader.
|
||||
auto& ncch_caps = overlay_ncch->exheader_header.arm11_system_local_caps;
|
||||
return std::make_pair(ncch_caps.core_version, ResultStatus::Success);
|
||||
}
|
||||
|
||||
std::pair<std::optional<u8>, ResultStatus> AppLoader_NCCH::LoadKernelN3dsMode() {
|
||||
std::pair<std::optional<Kernel::MemoryMode>, ResultStatus> AppLoader_NCCH::LoadKernelMemoryMode() {
|
||||
if (!is_loaded) {
|
||||
ResultStatus res = base_ncch.Load();
|
||||
if (res != ResultStatus::Success) {
|
||||
|
@ -68,9 +69,29 @@ std::pair<std::optional<u8>, ResultStatus> AppLoader_NCCH::LoadKernelN3dsMode()
|
|||
}
|
||||
}
|
||||
|
||||
// Set the system mode as the one from the exheader.
|
||||
return std::make_pair(overlay_ncch->exheader_header.arm11_system_local_caps.n3ds_mode,
|
||||
ResultStatus::Success);
|
||||
// Provide the memory mode from the exheader.
|
||||
auto& ncch_caps = overlay_ncch->exheader_header.arm11_system_local_caps;
|
||||
auto mode = static_cast<Kernel::MemoryMode>(ncch_caps.system_mode.Value());
|
||||
return std::make_pair(mode, ResultStatus::Success);
|
||||
}
|
||||
|
||||
std::pair<std::optional<Kernel::New3dsHwCapabilities>, ResultStatus>
|
||||
AppLoader_NCCH::LoadNew3dsHwCapabilities() {
|
||||
if (!is_loaded) {
|
||||
ResultStatus res = base_ncch.Load();
|
||||
if (res != ResultStatus::Success) {
|
||||
return std::make_pair(std::nullopt, res);
|
||||
}
|
||||
}
|
||||
|
||||
// Provide the capabilities from the exheader.
|
||||
auto& ncch_caps = overlay_ncch->exheader_header.arm11_system_local_caps;
|
||||
auto caps = Kernel::New3dsHwCapabilities{
|
||||
ncch_caps.enable_l2_cache != 0,
|
||||
ncch_caps.enable_804MHz_cpu != 0,
|
||||
static_cast<Kernel::New3dsMemoryMode>(ncch_caps.n3ds_mode),
|
||||
};
|
||||
return std::make_pair(std::move(caps), ResultStatus::Success);
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NCCH::LoadExec(std::shared_ptr<Kernel::Process>& process) {
|
||||
|
|
|
@ -32,13 +32,16 @@ public:
|
|||
|
||||
ResultStatus Load(std::shared_ptr<Kernel::Process>& process) override;
|
||||
|
||||
std::pair<std::optional<u32>, ResultStatus> LoadCoreVersion() override;
|
||||
|
||||
/**
|
||||
* Loads the Exheader and returns the system mode for this application.
|
||||
* @returns A pair with the optional system mode, and and the status.
|
||||
*/
|
||||
std::pair<std::optional<u32>, ResultStatus> LoadKernelSystemMode() override;
|
||||
std::pair<std::optional<Kernel::MemoryMode>, ResultStatus> LoadKernelMemoryMode() override;
|
||||
|
||||
std::pair<std::optional<u8>, ResultStatus> LoadKernelN3dsMode() override;
|
||||
std::pair<std::optional<Kernel::New3dsHwCapabilities>, ResultStatus> LoadNew3dsHwCapabilities()
|
||||
override;
|
||||
|
||||
ResultStatus IsExecutable(bool& out_executable) override;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue