summaryrefslogtreecommitdiffstats
path: root/src/core/hle
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2016-09-21 20:29:48 +0200
committerGitHub <noreply@github.com>2016-09-21 20:29:48 +0200
commitd5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a (patch)
tree8a22ca73ff838f3f0090b29a548ae81087fc90ed /src/core/hle
parentREADME: Specify master branch for Travis CI badge (diff)
parentFix Travis clang-format check (diff)
downloadyuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar
yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.gz
yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.bz2
yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.lz
yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.xz
yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.zst
yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.zip
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/applets/applet.cpp34
-rw-r--r--src/core/hle/applets/applet.h8
-rw-r--r--src/core/hle/applets/erreula.cpp16
-rw-r--r--src/core/hle/applets/erreula.h10
-rw-r--r--src/core/hle/applets/mii_selector.cpp22
-rw-r--r--src/core/hle/applets/mii_selector.h39
-rw-r--r--src/core/hle/applets/swkbd.cpp23
-rw-r--r--src/core/hle/applets/swkbd.h13
-rw-r--r--src/core/hle/config_mem.h26
-rw-r--r--src/core/hle/function_wrappers.h105
-rw-r--r--src/core/hle/hle.cpp7
-rw-r--r--src/core/hle/hle.h2
-rw-r--r--src/core/hle/kernel/address_arbiter.cpp24
-rw-r--r--src/core/hle/kernel/address_arbiter.h15
-rw-r--r--src/core/hle/kernel/client_port.cpp1
-rw-r--r--src/core/hle/kernel/client_port.h24
-rw-r--r--src/core/hle/kernel/event.cpp6
-rw-r--r--src/core/hle/kernel/event.h20
-rw-r--r--src/core/hle/kernel/kernel.cpp5
-rw-r--r--src/core/hle/kernel/kernel.h68
-rw-r--r--src/core/hle/kernel/memory.cpp25
-rw-r--r--src/core/hle/kernel/memory.h3
-rw-r--r--src/core/hle/kernel/mutex.cpp3
-rw-r--r--src/core/hle/kernel/mutex.h20
-rw-r--r--src/core/hle/kernel/process.cpp55
-rw-r--r--src/core/hle/kernel/process.h53
-rw-r--r--src/core/hle/kernel/resource_limit.cpp113
-rw-r--r--src/core/hle/kernel/resource_limit.h47
-rw-r--r--src/core/hle/kernel/semaphore.cpp3
-rw-r--r--src/core/hle/kernel/semaphore.h22
-rw-r--r--src/core/hle/kernel/server_port.cpp6
-rw-r--r--src/core/hle/kernel/server_port.h22
-rw-r--r--src/core/hle/kernel/session.cpp1
-rw-r--r--src/core/hle/kernel/session.h63
-rw-r--r--src/core/hle/kernel/shared_memory.cpp71
-rw-r--r--src/core/hle/kernel/shared_memory.h61
-rw-r--r--src/core/hle/kernel/thread.cpp110
-rw-r--r--src/core/hle/kernel/thread.h82
-rw-r--r--src/core/hle/kernel/timer.cpp18
-rw-r--r--src/core/hle/kernel/timer.h23
-rw-r--r--src/core/hle/kernel/vm_manager.cpp38
-rw-r--r--src/core/hle/kernel/vm_manager.h23
-rw-r--r--src/core/hle/result.h98
-rw-r--r--src/core/hle/service/ac_u.cpp39
-rw-r--r--src/core/hle/service/am/am.cpp58
-rw-r--r--src/core/hle/service/am/am_app.cpp16
-rw-r--r--src/core/hle/service/am/am_net.cpp110
-rw-r--r--src/core/hle/service/am/am_sys.cpp42
-rw-r--r--src/core/hle/service/am/am_u.cpp68
-rw-r--r--src/core/hle/service/apt/apt.cpp158
-rw-r--r--src/core/hle/service/apt/apt.h96
-rw-r--r--src/core/hle/service/apt/apt_a.cpp56
-rw-r--r--src/core/hle/service/apt/apt_s.cpp170
-rw-r--r--src/core/hle/service/apt/apt_u.cpp176
-rw-r--r--src/core/hle/service/apt/bcfnt/bcfnt.h1
-rw-r--r--src/core/hle/service/boss/boss.cpp5
-rw-r--r--src/core/hle/service/boss/boss_p.cpp2
-rw-r--r--src/core/hle/service/boss/boss_u.cpp8
-rw-r--r--src/core/hle/service/cam/cam.cpp76
-rw-r--r--src/core/hle/service/cam/cam.h52
-rw-r--r--src/core/hle/service/cam/cam_c.cpp4
-rw-r--r--src/core/hle/service/cam/cam_q.cpp4
-rw-r--r--src/core/hle/service/cam/cam_s.cpp4
-rw-r--r--src/core/hle/service/cam/cam_u.cpp124
-rw-r--r--src/core/hle/service/cecd/cecd.cpp10
-rw-r--r--src/core/hle/service/cecd/cecd.h10
-rw-r--r--src/core/hle/service/cecd/cecd_s.cpp4
-rw-r--r--src/core/hle/service/cecd/cecd_u.cpp6
-rw-r--r--src/core/hle/service/cfg/cfg.cpp196
-rw-r--r--src/core/hle/service/cfg/cfg.h26
-rw-r--r--src/core/hle/service/cfg/cfg_i.cpp84
-rw-r--r--src/core/hle/service/cfg/cfg_s.cpp38
-rw-r--r--src/core/hle/service/cfg/cfg_u.cpp20
-rw-r--r--src/core/hle/service/csnd_snd.cpp32
-rw-r--r--src/core/hle/service/csnd_snd.h2
-rw-r--r--src/core/hle/service/dlp/dlp.cpp5
-rw-r--r--src/core/hle/service/dlp/dlp_clnt.cpp3
-rw-r--r--src/core/hle/service/dlp/dlp_fkcl.cpp3
-rw-r--r--src/core/hle/service/dlp/dlp_srvr.cpp8
-rw-r--r--src/core/hle/service/dsp_dsp.cpp156
-rw-r--r--src/core/hle/service/dsp_dsp.h1
-rw-r--r--src/core/hle/service/err_f.cpp128
-rw-r--r--src/core/hle/service/frd/frd.cpp24
-rw-r--r--src/core/hle/service/frd/frd_a.cpp2
-rw-r--r--src/core/hle/service/frd/frd_u.cpp104
-rw-r--r--src/core/hle/service/fs/archive.cpp380
-rw-r--r--src/core/hle/service/fs/archive.h67
-rw-r--r--src/core/hle/service/fs/fs_user.cpp386
-rw-r--r--src/core/hle/service/gsp_gpu.cpp251
-rw-r--r--src/core/hle/service/gsp_gpu.h42
-rw-r--r--src/core/hle/service/gsp_lcd.cpp4
-rw-r--r--src/core/hle/service/hid/hid.cpp56
-rw-r--r--src/core/hle/service/hid/hid.h70
-rw-r--r--src/core/hle/service/hid/hid_spvr.cpp18
-rw-r--r--src/core/hle/service/hid/hid_user.cpp18
-rw-r--r--src/core/hle/service/http_c.cpp100
-rw-r--r--src/core/hle/service/ir/ir.cpp29
-rw-r--r--src/core/hle/service/ir/ir_rst.cpp8
-rw-r--r--src/core/hle/service/ir/ir_u.cpp38
-rw-r--r--src/core/hle/service/ir/ir_user.cpp50
-rw-r--r--src/core/hle/service/ldr_ro/cro_helper.cpp357
-rw-r--r--src/core/hle/service/ldr_ro/cro_helper.h146
-rw-r--r--src/core/hle/service/ldr_ro/ldr_ro.cpp215
-rw-r--r--src/core/hle/service/ldr_ro/memory_synchronizer.cpp7
-rw-r--r--src/core/hle/service/ldr_ro/memory_synchronizer.h1
-rw-r--r--src/core/hle/service/mic_u.cpp32
-rw-r--r--src/core/hle/service/ndm/ndm.cpp19
-rw-r--r--src/core/hle/service/ndm/ndm.h43
-rw-r--r--src/core/hle/service/ndm/ndm_u.cpp44
-rw-r--r--src/core/hle/service/news/news.cpp6
-rw-r--r--src/core/hle/service/news/news_s.cpp26
-rw-r--r--src/core/hle/service/news/news_u.cpp2
-rw-r--r--src/core/hle/service/nim/nim.cpp6
-rw-r--r--src/core/hle/service/nim/nim_aoc.cpp16
-rw-r--r--src/core/hle/service/nim/nim_s.cpp9
-rw-r--r--src/core/hle/service/nim/nim_u.cpp13
-rw-r--r--src/core/hle/service/nim/nim_u.h2
-rw-r--r--src/core/hle/service/ns_s.cpp30
-rw-r--r--src/core/hle/service/nwm_uds.cpp83
-rw-r--r--src/core/hle/service/pm_app.cpp24
-rw-r--r--src/core/hle/service/ptm/ptm.cpp32
-rw-r--r--src/core/hle/service/ptm/ptm.h21
-rw-r--r--src/core/hle/service/ptm/ptm_play.cpp8
-rw-r--r--src/core/hle/service/ptm/ptm_play.h6
-rw-r--r--src/core/hle/service/ptm/ptm_sysm.cpp62
-rw-r--r--src/core/hle/service/ptm/ptm_u.cpp28
-rw-r--r--src/core/hle/service/service.cpp53
-rw-r--r--src/core/hle/service/service.h13
-rw-r--r--src/core/hle/service/soc_u.cpp380
-rw-r--r--src/core/hle/service/soc_u.h1
-rw-r--r--src/core/hle/service/srv.cpp51
-rw-r--r--src/core/hle/service/ssl_c.cpp44
-rw-r--r--src/core/hle/service/y2r_u.cpp157
-rw-r--r--src/core/hle/service/y2r_u.h2
-rw-r--r--src/core/hle/shared_page.cpp8
-rw-r--r--src/core/hle/shared_page.h24
-rw-r--r--src/core/hle/svc.cpp518
137 files changed, 3997 insertions, 3568 deletions
diff --git a/src/core/hle/applets/applet.cpp b/src/core/hle/applets/applet.cpp
index ccf35fa07..4311d9897 100644
--- a/src/core/hle/applets/applet.cpp
+++ b/src/core/hle/applets/applet.cpp
@@ -6,10 +6,8 @@
#include <memory>
#include <type_traits>
#include <unordered_map>
-
#include "common/assert.h"
#include "common/common_types.h"
-
#include "core/core_timing.h"
#include "core/hle/applets/applet.h"
#include "core/hle/applets/erreula.h"
@@ -23,23 +21,24 @@
// Specializes std::hash for AppletId, so that we can use it in std::unordered_map.
// Workaround for libstdc++ bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60970
namespace std {
- template <>
- struct hash<Service::APT::AppletId> {
- typedef Service::APT::AppletId argument_type;
- typedef std::size_t result_type;
-
- result_type operator()(const argument_type& id_code) const {
- typedef std::underlying_type<argument_type>::type Type;
- return std::hash<Type>()(static_cast<Type>(id_code));
- }
- };
+template <>
+struct hash<Service::APT::AppletId> {
+ typedef Service::APT::AppletId argument_type;
+ typedef std::size_t result_type;
+
+ result_type operator()(const argument_type& id_code) const {
+ typedef std::underlying_type<argument_type>::type Type;
+ return std::hash<Type>()(static_cast<Type>(id_code));
+ }
+};
}
namespace HLE {
namespace Applets {
static std::unordered_map<Service::APT::AppletId, std::shared_ptr<Applet>> applets;
-static u32 applet_update_event = -1; ///< The CoreTiming event identifier for the Applet update callback.
+static u32 applet_update_event =
+ -1; ///< The CoreTiming event identifier for the Applet update callback.
/// The interval at which the Applet update callback will be called, 16.6ms
static const u64 applet_update_interval_us = 16666;
@@ -60,7 +59,8 @@ ResultCode Applet::Create(Service::APT::AppletId id) {
default:
LOG_ERROR(Service_APT, "Could not create applet %u", id);
// TODO(Subv): Find the right error code
- return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotSupported, ErrorLevel::Permanent);
+ return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet,
+ ErrorSummary::NotSupported, ErrorLevel::Permanent);
}
return RESULT_SUCCESS;
@@ -84,7 +84,7 @@ static void AppletUpdateEvent(u64 applet_id, int cycles_late) {
// If the applet is still running after the last update, reschedule the event
if (applet->IsRunning()) {
CoreTiming::ScheduleEvent(usToCycles(applet_update_interval_us) - cycles_late,
- applet_update_event, applet_id);
+ applet_update_event, applet_id);
} else {
// Otherwise the applet has terminated, in which case we should clean it up
applets[id] = nullptr;
@@ -96,7 +96,8 @@ ResultCode Applet::Start(const Service::APT::AppletStartupParameter& parameter)
if (result.IsError())
return result;
// Schedule the update event
- CoreTiming::ScheduleEvent(usToCycles(applet_update_interval_us), applet_update_event, static_cast<u64>(id));
+ CoreTiming::ScheduleEvent(usToCycles(applet_update_interval_us), applet_update_event,
+ static_cast<u64>(id));
return result;
}
@@ -116,6 +117,5 @@ void Init() {
void Shutdown() {
CoreTiming::RemoveEvent(applet_update_event);
}
-
}
} // namespace
diff --git a/src/core/hle/applets/applet.h b/src/core/hle/applets/applet.h
index 754c6f7db..bfdcad126 100644
--- a/src/core/hle/applets/applet.h
+++ b/src/core/hle/applets/applet.h
@@ -5,7 +5,6 @@
#pragma once
#include <memory>
-
#include "core/hle/result.h"
#include "core/hle/service/apt/apt.h"
@@ -14,8 +13,8 @@ namespace Applets {
class Applet {
public:
- virtual ~Applet() { }
- Applet(Service::APT::AppletId id) : id(id) { }
+ virtual ~Applet() {}
+ Applet(Service::APT::AppletId id) : id(id) {}
/**
* Creates an instance of the Applet subclass identified by the parameter.
@@ -64,7 +63,7 @@ protected:
*/
virtual ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) = 0;
- Service::APT::AppletId id; ///< Id of this Applet
+ Service::APT::AppletId id; ///< Id of this Applet
std::shared_ptr<std::vector<u8>> heap_memory; ///< Heap memory for this Applet
};
@@ -76,6 +75,5 @@ void Init();
/// Shuts down the HLE applets
void Shutdown();
-
}
} // namespace
diff --git a/src/core/hle/applets/erreula.cpp b/src/core/hle/applets/erreula.cpp
index 92a4b2323..14964427b 100644
--- a/src/core/hle/applets/erreula.cpp
+++ b/src/core/hle/applets/erreula.cpp
@@ -3,7 +3,6 @@
// Refer to the license.txt file included.
#include "common/string_util.h"
-
#include "core/hle/applets/erreula.h"
#include "core/hle/service/apt/apt.h"
@@ -18,7 +17,8 @@ ResultCode ErrEula::ReceiveParameter(const Service::APT::MessageParameter& param
return ResultCode(-1);
}
- // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory.
+ // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared
+ // memory.
// Create the SharedMemory that will hold the framebuffer data
Service::APT::CaptureBufferInfo capture_info;
ASSERT(sizeof(capture_info) == parameter.buffer.size());
@@ -30,9 +30,9 @@ ResultCode ErrEula::ReceiveParameter(const Service::APT::MessageParameter& param
// Allocate a heap block of the required size for this applet.
heap_memory = std::make_shared<std::vector<u8>>(capture_info.size);
// Create a SharedMemory that directly points to this heap block.
- framebuffer_memory = Kernel::SharedMemory::CreateForApplet(heap_memory, 0, heap_memory->size(),
- MemoryPermission::ReadWrite, MemoryPermission::ReadWrite,
- "ErrEula Memory");
+ framebuffer_memory = Kernel::SharedMemory::CreateForApplet(
+ heap_memory, 0, heap_memory->size(), MemoryPermission::ReadWrite,
+ MemoryPermission::ReadWrite, "ErrEula Memory");
// Send the response message with the newly created SharedMemory
Service::APT::MessageParameter result;
@@ -49,7 +49,8 @@ ResultCode ErrEula::ReceiveParameter(const Service::APT::MessageParameter& param
ResultCode ErrEula::StartImpl(const Service::APT::AppletStartupParameter& parameter) {
started = true;
- // TODO(Subv): Set the expected fields in the response buffer before resending it to the application.
+ // TODO(Subv): Set the expected fields in the response buffer before resending it to the
+ // application.
// TODO(Subv): Reverse the parameter format for the ErrEula applet
// Let the application know that we're closing
@@ -65,8 +66,7 @@ ResultCode ErrEula::StartImpl(const Service::APT::AppletStartupParameter& parame
return RESULT_SUCCESS;
}
-void ErrEula::Update() {
-}
+void ErrEula::Update() {}
} // namespace Applets
} // namespace HLE
diff --git a/src/core/hle/applets/erreula.h b/src/core/hle/applets/erreula.h
index 9fe72ae07..a7ec7ec01 100644
--- a/src/core/hle/applets/erreula.h
+++ b/src/core/hle/applets/erreula.h
@@ -12,16 +12,20 @@ namespace Applets {
class ErrEula final : public Applet {
public:
- explicit ErrEula(Service::APT::AppletId id): Applet(id) { }
+ explicit ErrEula(Service::APT::AppletId id) : Applet(id) {}
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override;
ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
void Update() override;
- bool IsRunning() const override { return started; }
+ bool IsRunning() const override {
+ return started;
+ }
/// This SharedMemory will be created when we receive the LibAppJustStarted message.
- /// It holds the framebuffer info retrieved by the application with GSPGPU::ImportDisplayCaptureInfo
+ /// It holds the framebuffer info retrieved by the application with
+ /// GSPGPU::ImportDisplayCaptureInfo
Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory;
+
private:
/// Whether this applet is currently running instead of the host application or not.
bool started = false;
diff --git a/src/core/hle/applets/mii_selector.cpp b/src/core/hle/applets/mii_selector.cpp
index 77f01d208..53a8683a4 100644
--- a/src/core/hle/applets/mii_selector.cpp
+++ b/src/core/hle/applets/mii_selector.cpp
@@ -4,16 +4,13 @@
#include <cstring>
#include <string>
-
#include "common/assert.h"
#include "common/logging/log.h"
#include "common/string_util.h"
-
#include "core/hle/applets/mii_selector.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/shared_memory.h"
#include "core/hle/result.h"
-
#include "video_core/video_core.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -29,7 +26,8 @@ ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& p
return ResultCode(-1);
}
- // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory.
+ // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared
+ // memory.
// Create the SharedMemory that will hold the framebuffer data
Service::APT::CaptureBufferInfo capture_info;
ASSERT(sizeof(capture_info) == parameter.buffer.size());
@@ -40,9 +38,9 @@ ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& p
// Allocate a heap block of the required size for this applet.
heap_memory = std::make_shared<std::vector<u8>>(capture_info.size);
// Create a SharedMemory that directly points to this heap block.
- framebuffer_memory = Kernel::SharedMemory::CreateForApplet(heap_memory, 0, heap_memory->size(),
- MemoryPermission::ReadWrite, MemoryPermission::ReadWrite,
- "MiiSelector Memory");
+ framebuffer_memory = Kernel::SharedMemory::CreateForApplet(
+ heap_memory, 0, heap_memory->size(), MemoryPermission::ReadWrite,
+ MemoryPermission::ReadWrite, "MiiSelector Memory");
// Send the response message with the newly created SharedMemory
Service::APT::MessageParameter result;
@@ -59,12 +57,14 @@ ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& p
ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& parameter) {
started = true;
- // TODO(Subv): Set the expected fields in the response buffer before resending it to the application.
+ // TODO(Subv): Set the expected fields in the response buffer before resending it to the
+ // application.
// TODO(Subv): Reverse the parameter format for the Mii Selector
memcpy(&config, parameter.buffer.data(), parameter.buffer.size());
- // TODO(Subv): Find more about this structure, result code 0 is enough to let most games continue.
+ // TODO(Subv): Find more about this structure, result code 0 is enough to let most games
+ // continue.
MiiResult result;
memset(&result, 0, sizeof(result));
result.result_code = 0;
@@ -82,8 +82,6 @@ ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& pa
return RESULT_SUCCESS;
}
-void MiiSelector::Update() {
-}
-
+void MiiSelector::Update() {}
}
} // namespace
diff --git a/src/core/hle/applets/mii_selector.h b/src/core/hle/applets/mii_selector.h
index 24e8e721d..e3ab9f0cd 100644
--- a/src/core/hle/applets/mii_selector.h
+++ b/src/core/hle/applets/mii_selector.h
@@ -4,9 +4,8 @@
#pragma once
-#include "common/common_types.h"
#include "common/common_funcs.h"
-
+#include "common/common_types.h"
#include "core/hle/applets/applet.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/shared_memory.h"
@@ -17,28 +16,30 @@ namespace HLE {
namespace Applets {
struct MiiConfig {
- u8 unk_000;
- u8 unk_001;
- u8 unk_002;
- u8 unk_003;
- u8 unk_004;
+ u8 unk_000;
+ u8 unk_001;
+ u8 unk_002;
+ u8 unk_003;
+ u8 unk_004;
INSERT_PADDING_BYTES(3);
u16 unk_008;
INSERT_PADDING_BYTES(0x82);
- u8 unk_08C;
+ u8 unk_08C;
INSERT_PADDING_BYTES(3);
u16 unk_090;
INSERT_PADDING_BYTES(2);
u32 unk_094;
u16 unk_098;
- u8 unk_09A[0x64];
- u8 unk_0FE;
- u8 unk_0FF;
+ u8 unk_09A[0x64];
+ u8 unk_0FE;
+ u8 unk_0FF;
u32 unk_100;
};
static_assert(sizeof(MiiConfig) == 0x104, "MiiConfig structure has incorrect size");
-#define ASSERT_REG_POSITION(field_name, position) static_assert(offsetof(MiiConfig, field_name) == position, "Field "#field_name" has invalid position")
+#define ASSERT_REG_POSITION(field_name, position) \
+ static_assert(offsetof(MiiConfig, field_name) == position, \
+ "Field " #field_name " has invalid position")
ASSERT_REG_POSITION(unk_008, 0x08);
ASSERT_REG_POSITION(unk_08C, 0x8C);
ASSERT_REG_POSITION(unk_090, 0x90);
@@ -55,22 +56,27 @@ struct MiiResult {
INSERT_PADDING_BYTES(2);
};
static_assert(sizeof(MiiResult) == 0x84, "MiiResult structure has incorrect size");
-#define ASSERT_REG_POSITION(field_name, position) static_assert(offsetof(MiiResult, field_name) == position, "Field "#field_name" has invalid position")
+#define ASSERT_REG_POSITION(field_name, position) \
+ static_assert(offsetof(MiiResult, field_name) == position, \
+ "Field " #field_name " has invalid position")
ASSERT_REG_POSITION(unk_0C, 0x0C);
ASSERT_REG_POSITION(unk_6C, 0x6C);
#undef ASSERT_REG_POSITION
class MiiSelector final : public Applet {
public:
- MiiSelector(Service::APT::AppletId id) : Applet(id), started(false) { }
+ MiiSelector(Service::APT::AppletId id) : Applet(id), started(false) {}
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override;
ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
void Update() override;
- bool IsRunning() const override { return started; }
+ bool IsRunning() const override {
+ return started;
+ }
/// This SharedMemory will be created when we receive the LibAppJustStarted message.
- /// It holds the framebuffer info retrieved by the application with GSPGPU::ImportDisplayCaptureInfo
+ /// It holds the framebuffer info retrieved by the application with
+ /// GSPGPU::ImportDisplayCaptureInfo
Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory;
/// Whether this applet is currently running instead of the host application or not.
@@ -78,6 +84,5 @@ public:
MiiConfig config;
};
-
}
} // namespace
diff --git a/src/core/hle/applets/swkbd.cpp b/src/core/hle/applets/swkbd.cpp
index d87bf3d57..06ddf538b 100644
--- a/src/core/hle/applets/swkbd.cpp
+++ b/src/core/hle/applets/swkbd.cpp
@@ -4,19 +4,16 @@
#include <cstring>
#include <string>
-
#include "common/assert.h"
#include "common/logging/log.h"
#include "common/string_util.h"
-
#include "core/hle/applets/swkbd.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/shared_memory.h"
-#include "core/hle/service/hid/hid.h"
-#include "core/hle/service/gsp_gpu.h"
#include "core/hle/result.h"
+#include "core/hle/service/gsp_gpu.h"
+#include "core/hle/service/hid/hid.h"
#include "core/memory.h"
-
#include "video_core/video_core.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -32,7 +29,8 @@ ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter con
return ResultCode(-1);
}
- // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory.
+ // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared
+ // memory.
// Create the SharedMemory that will hold the framebuffer data
Service::APT::CaptureBufferInfo capture_info;
ASSERT(sizeof(capture_info) == parameter.buffer.size());
@@ -43,9 +41,9 @@ ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter con
// Allocate a heap block of the required size for this applet.
heap_memory = std::make_shared<std::vector<u8>>(capture_info.size);
// Create a SharedMemory that directly points to this heap block.
- framebuffer_memory = Kernel::SharedMemory::CreateForApplet(heap_memory, 0, heap_memory->size(),
- MemoryPermission::ReadWrite, MemoryPermission::ReadWrite,
- "SoftwareKeyboard Memory");
+ framebuffer_memory = Kernel::SharedMemory::CreateForApplet(
+ heap_memory, 0, heap_memory->size(), MemoryPermission::ReadWrite,
+ MemoryPermission::ReadWrite, "SoftwareKeyboard Memory");
// Send the response message with the newly created SharedMemory
Service::APT::MessageParameter result;
@@ -60,10 +58,12 @@ ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter con
}
ResultCode SoftwareKeyboard::StartImpl(Service::APT::AppletStartupParameter const& parameter) {
- ASSERT_MSG(parameter.buffer.size() == sizeof(config), "The size of the parameter (SoftwareKeyboardConfig) is wrong");
+ ASSERT_MSG(parameter.buffer.size() == sizeof(config),
+ "The size of the parameter (SoftwareKeyboardConfig) is wrong");
memcpy(&config, parameter.buffer.data(), parameter.buffer.size());
- text_memory = boost::static_pointer_cast<Kernel::SharedMemory, Kernel::Object>(parameter.object);
+ text_memory =
+ boost::static_pointer_cast<Kernel::SharedMemory, Kernel::Object>(parameter.object);
// TODO(Subv): Verify if this is the correct behavior
memset(text_memory->GetPointer(), 0, text_memory->size);
@@ -115,6 +115,5 @@ void SoftwareKeyboard::Finalize() {
started = false;
}
-
}
} // namespace
diff --git a/src/core/hle/applets/swkbd.h b/src/core/hle/applets/swkbd.h
index cf26a8fb7..ea0b1fba9 100644
--- a/src/core/hle/applets/swkbd.h
+++ b/src/core/hle/applets/swkbd.h
@@ -4,9 +4,8 @@
#pragma once
-#include "common/common_types.h"
#include "common/common_funcs.h"
-
+#include "common/common_types.h"
#include "core/hle/applets/applet.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/shared_memory.h"
@@ -53,12 +52,14 @@ static_assert(sizeof(SoftwareKeyboardConfig) == 0x400, "Software Keyboard Config
class SoftwareKeyboard final : public Applet {
public:
- SoftwareKeyboard(Service::APT::AppletId id) : Applet(id), started(false) { }
+ SoftwareKeyboard(Service::APT::AppletId id) : Applet(id), started(false) {}
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override;
ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
void Update() override;
- bool IsRunning() const override { return started; }
+ bool IsRunning() const override {
+ return started;
+ }
/**
* Draws a keyboard to the current bottom screen framebuffer.
@@ -72,7 +73,8 @@ public:
void Finalize();
/// This SharedMemory will be created when we receive the LibAppJustStarted message.
- /// It holds the framebuffer info retrieved by the application with GSPGPU::ImportDisplayCaptureInfo
+ /// It holds the framebuffer info retrieved by the application with
+ /// GSPGPU::ImportDisplayCaptureInfo
Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory;
/// SharedMemory where the output text will be stored
@@ -84,6 +86,5 @@ public:
/// Whether this applet is currently running instead of the host application or not.
bool started;
};
-
}
} // namespace
diff --git a/src/core/hle/config_mem.h b/src/core/hle/config_mem.h
index 24a1254f2..42fa6d789 100644
--- a/src/core/hle/config_mem.h
+++ b/src/core/hle/config_mem.h
@@ -12,7 +12,6 @@
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "common/swap.h"
-
#include "core/memory.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -20,16 +19,16 @@
namespace ConfigMem {
struct ConfigMemDef {
- u8 kernel_unk; // 0
- u8 kernel_version_rev; // 1
- u8 kernel_version_min; // 2
- u8 kernel_version_maj; // 3
+ u8 kernel_unk; // 0
+ u8 kernel_version_rev; // 1
+ u8 kernel_version_min; // 2
+ u8 kernel_version_maj; // 3
u32_le update_flag; // 4
u64_le ns_tid; // 8
u32_le sys_core_ver; // 10
- u8 unit_info; // 14
- u8 boot_firm; // 15
- u8 prev_firm; // 16
+ u8 unit_info; // 14
+ u8 boot_firm; // 15
+ u8 prev_firm; // 16
INSERT_PADDING_BYTES(0x1); // 17
u32_le ctr_sdk_ver; // 18
INSERT_PADDING_BYTES(0x30 - 0x1C); // 1C
@@ -39,15 +38,16 @@ struct ConfigMemDef {
u32_le sys_mem_alloc; // 44
u32_le base_mem_alloc; // 48
INSERT_PADDING_BYTES(0x60 - 0x4C); // 4C
- u8 firm_unk; // 60
- u8 firm_version_rev; // 61
- u8 firm_version_min; // 62
- u8 firm_version_maj; // 63
+ u8 firm_unk; // 60
+ u8 firm_version_rev; // 61
+ u8 firm_version_min; // 62
+ u8 firm_version_maj; // 63
u32_le firm_sys_core_ver; // 64
u32_le firm_ctr_sdk_ver; // 68
INSERT_PADDING_BYTES(0x1000 - 0x6C); // 6C
};
-static_assert(sizeof(ConfigMemDef) == Memory::CONFIG_MEMORY_SIZE, "Config Memory structure size is wrong");
+static_assert(sizeof(ConfigMemDef) == Memory::CONFIG_MEMORY_SIZE,
+ "Config Memory structure size is wrong");
extern ConfigMemDef config_mem;
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h
index 8839ce482..8ce0f6d2b 100644
--- a/src/core/hle/function_wrappers.h
+++ b/src/core/hle/function_wrappers.h
@@ -5,16 +5,16 @@
#pragma once
#include "common/common_types.h"
-
#include "core/arm/arm_interface.h"
-#include "core/memory.h"
+#include "core/core.h"
#include "core/hle/hle.h"
#include "core/hle/result.h"
#include "core/hle/svc.h"
+#include "core/memory.h"
namespace HLE {
-#define PARAM(n) Core::g_app_core->GetReg(n)
+#define PARAM(n) Core::g_app_core->GetReg(n)
/// An invalid result code that is meant to be overwritten when a thread resumes from waiting
static const ResultCode RESULT_INVALID(0xDEADC0DE);
@@ -40,28 +40,33 @@ static inline void FuncReturn64(u64 res) {
////////////////////////////////////////////////////////////////////////////////////////////////////
// Function wrappers that return type ResultCode
-template<ResultCode func(u32, u32, u32, u32)> void Wrap() {
+template <ResultCode func(u32, u32, u32, u32)>
+void Wrap() {
FuncReturn(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)).raw);
}
-template<ResultCode func(u32*, u32, u32, u32, u32, u32)> void Wrap(){
+template <ResultCode func(u32*, u32, u32, u32, u32, u32)>
+void Wrap() {
u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)).raw;
Core::g_app_core->SetReg(1, param_1);
FuncReturn(retval);
}
-template<ResultCode func(u32*, s32, u32, u32, u32, s32)> void Wrap() {
+template <ResultCode func(u32*, s32, u32, u32, u32, s32)>
+void Wrap() {
u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)).raw;
Core::g_app_core->SetReg(1, param_1);
FuncReturn(retval);
}
-template<ResultCode func(s32*, u32*, s32, bool, s64)> void Wrap() {
+template <ResultCode func(s32*, u32*, s32, bool, s64)>
+void Wrap() {
s32 param_1 = 0;
s32 retval = func(&param_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2),
- (PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0))).raw;
+ (PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0)))
+ .raw;
if (retval != RESULT_INVALID.raw) {
Core::g_app_core->SetReg(1, (u32)param_1);
@@ -69,18 +74,22 @@ template<ResultCode func(s32*, u32*, s32, bool, s64)> void Wrap() {
}
}
-template<ResultCode func(u32, u32, u32, u32, s64)> void Wrap() {
- FuncReturn(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), (((s64)PARAM(5) << 32) | PARAM(4))).raw);
+template <ResultCode func(u32, u32, u32, u32, s64)>
+void Wrap() {
+ FuncReturn(
+ func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), (((s64)PARAM(5) << 32) | PARAM(4))).raw);
}
-template<ResultCode func(u32*)> void Wrap(){
+template <ResultCode func(u32*)>
+void Wrap() {
u32 param_1 = 0;
u32 retval = func(&param_1).raw;
Core::g_app_core->SetReg(1, param_1);
FuncReturn(retval);
}
-template<ResultCode func(u32, s64)> void Wrap() {
+template <ResultCode func(u32, s64)>
+void Wrap() {
s32 retval = func(PARAM(0), (((s64)PARAM(3) << 32) | PARAM(2))).raw;
if (retval != RESULT_INVALID.raw) {
@@ -88,7 +97,8 @@ template<ResultCode func(u32, s64)> void Wrap() {
}
}
-template<ResultCode func(MemoryInfo*, PageInfo*, u32)> void Wrap() {
+template <ResultCode func(MemoryInfo*, PageInfo*, u32)>
+void Wrap() {
MemoryInfo memory_info = {};
PageInfo page_info = {};
u32 retval = func(&memory_info, &page_info, PARAM(2)).raw;
@@ -100,7 +110,8 @@ template<ResultCode func(MemoryInfo*, PageInfo*, u32)> void Wrap() {
FuncReturn(retval);
}
-template<ResultCode func(MemoryInfo*, PageInfo*, Handle, u32)> void Wrap() {
+template <ResultCode func(MemoryInfo*, PageInfo*, Handle, u32)>
+void Wrap() {
MemoryInfo memory_info = {};
PageInfo page_info = {};
u32 retval = func(&memory_info, &page_info, PARAM(2), PARAM(3)).raw;
@@ -112,55 +123,65 @@ template<ResultCode func(MemoryInfo*, PageInfo*, Handle, u32)> void Wrap() {
FuncReturn(retval);
}
-template<ResultCode func(s32*, u32)> void Wrap(){
+template <ResultCode func(s32*, u32)>
+void Wrap() {
s32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1)).raw;
Core::g_app_core->SetReg(1, param_1);
FuncReturn(retval);
}
-template<ResultCode func(u32, s32)> void Wrap() {
+template <ResultCode func(u32, s32)>
+void Wrap() {
FuncReturn(func(PARAM(0), (s32)PARAM(1)).raw);
}
-template<ResultCode func(u32*, u32)> void Wrap(){
+template <ResultCode func(u32*, u32)>
+void Wrap() {
u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1)).raw;
Core::g_app_core->SetReg(1, param_1);
FuncReturn(retval);
}
-template<ResultCode func(u32)> void Wrap() {
+template <ResultCode func(u32)>
+void Wrap() {
FuncReturn(func(PARAM(0)).raw);
}
-template<ResultCode func(s64*, u32, u32*, u32)> void Wrap(){
- FuncReturn(func((s64*)Memory::GetPointer(PARAM(0)), PARAM(1), (u32*)Memory::GetPointer(PARAM(2)),
- (s32)PARAM(3)).raw);
+template <ResultCode func(s64*, u32, u32*, u32)>
+void Wrap() {
+ FuncReturn(func((s64*)Memory::GetPointer(PARAM(0)), PARAM(1),
+ (u32*)Memory::GetPointer(PARAM(2)), (s32)PARAM(3))
+ .raw);
}
-template<ResultCode func(u32*, const char*)> void Wrap() {
+template <ResultCode func(u32*, const char*)>
+void Wrap() {
u32 param_1 = 0;
u32 retval = func(&param_1, (char*)Memory::GetPointer(PARAM(1))).raw;
Core::g_app_core->SetReg(1, param_1);
FuncReturn(retval);
}
-template<ResultCode func(u32*, s32, s32)> void Wrap() {
+template <ResultCode func(u32*, s32, s32)>
+void Wrap() {
u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw;
Core::g_app_core->SetReg(1, param_1);
FuncReturn(retval);
}
-template<ResultCode func(s32*, u32, s32)> void Wrap() {
+template <ResultCode func(s32*, u32, s32)>
+void Wrap() {
s32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw;
Core::g_app_core->SetReg(1, param_1);
FuncReturn(retval);
}
-template<ResultCode func(s64*, u32, s32)> void Wrap() {
+template <ResultCode func(s64*, u32, s32)>
+void Wrap() {
s64 param_1 = 0;
u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw;
Core::g_app_core->SetReg(1, (u32)param_1);
@@ -168,7 +189,8 @@ template<ResultCode func(s64*, u32, s32)> void Wrap() {
FuncReturn(retval);
}
-template<ResultCode func(u32*, u32, u32, u32, u32)> void Wrap() {
+template <ResultCode func(u32*, u32, u32, u32, u32)>
+void Wrap() {
u32 param_1 = 0;
// The last parameter is passed in R0 instead of R4
u32 retval = func(&param_1, PARAM(1), PARAM(2), PARAM(3), PARAM(0)).raw;
@@ -176,13 +198,15 @@ template<ResultCode func(u32*, u32, u32, u32, u32)> void Wrap() {
FuncReturn(retval);
}
-template<ResultCode func(u32, s64, s64)> void Wrap() {
+template <ResultCode func(u32, s64, s64)>
+void Wrap() {
s64 param1 = ((u64)PARAM(3) << 32) | PARAM(2);
s64 param2 = ((u64)PARAM(4) << 32) | PARAM(1);
FuncReturn(func(PARAM(0), param1, param2).raw);
}
-template<ResultCode func(s64*, Handle, u32)> void Wrap() {
+template <ResultCode func(s64*, Handle, u32)>
+void Wrap() {
s64 param_1 = 0;
u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw;
Core::g_app_core->SetReg(1, (u32)param_1);
@@ -190,14 +214,18 @@ template<ResultCode func(s64*, Handle, u32)> void Wrap() {
FuncReturn(retval);
}
-template<ResultCode func(Handle, u32)> void Wrap() {
+template <ResultCode func(Handle, u32)>
+void Wrap() {
FuncReturn(func(PARAM(0), PARAM(1)).raw);
}
-template<ResultCode func(Handle*, Handle*, const char*, u32)> void Wrap() {
+template <ResultCode func(Handle*, Handle*, const char*, u32)>
+void Wrap() {
Handle param_1 = 0;
Handle param_2 = 0;
- u32 retval = func(&param_1, &param_2, reinterpret_cast<const char*>(Memory::GetPointer(PARAM(2))), PARAM(3)).raw;
+ u32 retval = func(&param_1, &param_2,
+ reinterpret_cast<const char*>(Memory::GetPointer(PARAM(2))), PARAM(3))
+ .raw;
// The first out parameter is moved into R2 and the second is moved into R1.
Core::g_app_core->SetReg(1, param_2);
Core::g_app_core->SetReg(2, param_1);
@@ -207,29 +235,34 @@ template<ResultCode func(Handle*, Handle*, const char*, u32)> void Wrap() {
////////////////////////////////////////////////////////////////////////////////////////////////////
// Function wrappers that return type u32
-template<u32 func()> void Wrap() {
+template <u32 func()>
+void Wrap() {
FuncReturn(func());
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Function wrappers that return type s64
-template<s64 func()> void Wrap() {
+template <s64 func()>
+void Wrap() {
FuncReturn64(func());
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// Function wrappers that return type void
-template<void func(s64)> void Wrap() {
+template <void func(s64)>
+void Wrap() {
func(((s64)PARAM(1) << 32) | PARAM(0));
}
-template<void func(const char*)> void Wrap() {
+template <void func(const char*)>
+void Wrap() {
func((char*)Memory::GetPointer(PARAM(0)));
}
-template<void func(u8)> void Wrap() {
+template <void func(u8)>
+void Wrap() {
func((u8)PARAM(0));
}
diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp
index 5c5373517..41b772163 100644
--- a/src/core/hle/hle.cpp
+++ b/src/core/hle/hle.cpp
@@ -4,7 +4,6 @@
#include "common/assert.h"
#include "common/logging/log.h"
-
#include "core/arm/arm_interface.h"
#include "core/core.h"
#include "core/hle/hle.h"
@@ -15,13 +14,13 @@
namespace {
bool reschedule; ///< If true, immediately reschedules the CPU to a new thread
-
}
namespace HLE {
-void Reschedule(const char *reason) {
- DEBUG_ASSERT_MSG(reason != nullptr && strlen(reason) < 256, "Reschedule: Invalid or too long reason.");
+void Reschedule(const char* reason) {
+ DEBUG_ASSERT_MSG(reason != nullptr && strlen(reason) < 256,
+ "Reschedule: Invalid or too long reason.");
// TODO(bunnei): It seems that games depend on some CPU execution time elapsing during HLE
// routines. This simulates that time by artificially advancing the number of CPU "ticks".
diff --git a/src/core/hle/hle.h b/src/core/hle/hle.h
index 69ac0ade6..23859e129 100644
--- a/src/core/hle/hle.h
+++ b/src/core/hle/hle.h
@@ -13,7 +13,7 @@ const Handle INVALID_HANDLE = 0;
namespace HLE {
-void Reschedule(const char *reason);
+void Reschedule(const char* reason);
bool IsReschedulePending();
void DoneRescheduling();
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp
index 5c3c47acf..37eec4c84 100644
--- a/src/core/hle/kernel/address_arbiter.cpp
+++ b/src/core/hle/kernel/address_arbiter.cpp
@@ -4,12 +4,10 @@
#include "common/common_types.h"
#include "common/logging/log.h"
-
-#include "core/memory.h"
-
#include "core/hle/hle.h"
#include "core/hle/kernel/address_arbiter.h"
#include "core/hle/kernel/thread.h"
+#include "core/memory.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// Kernel namespace
@@ -28,7 +26,7 @@ SharedPtr<AddressArbiter> AddressArbiter::Create(std::string name) {
}
ResultCode AddressArbiter::ArbitrateAddress(ArbitrationType type, VAddr address, s32 value,
- u64 nanoseconds) {
+ u64 nanoseconds) {
switch (type) {
// Signal thread(s) waiting for arbitrate address...
@@ -38,7 +36,7 @@ ResultCode AddressArbiter::ArbitrateAddress(ArbitrationType type, VAddr address,
ArbitrateAllThreads(address);
} else {
// Resume first N threads
- for(int i = 0; i < value; i++)
+ for (int i = 0; i < value; i++)
ArbitrateHighestPriorityThread(address);
}
break;
@@ -55,8 +53,7 @@ ResultCode AddressArbiter::ArbitrateAddress(ArbitrationType type, VAddr address,
GetCurrentThread()->WakeAfterDelay(nanoseconds);
}
break;
- case ArbitrationType::DecrementAndWaitIfLessThan:
- {
+ case ArbitrationType::DecrementAndWaitIfLessThan: {
s32 memory_value = Memory::Read32(address);
if (memory_value < value) {
// Only change the memory value if the thread should wait
@@ -65,8 +62,7 @@ ResultCode AddressArbiter::ArbitrateAddress(ArbitrationType type, VAddr address,
}
break;
}
- case ArbitrationType::DecrementAndWaitIfLessThanWithTimeout:
- {
+ case ArbitrationType::DecrementAndWaitIfLessThanWithTimeout: {
s32 memory_value = Memory::Read32(address);
if (memory_value < value) {
// Only change the memory value if the thread should wait
@@ -79,17 +75,19 @@ ResultCode AddressArbiter::ArbitrateAddress(ArbitrationType type, VAddr address,
default:
LOG_ERROR(Kernel, "unknown type=%d", type);
- return ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::Kernel, ErrorSummary::WrongArgument, ErrorLevel::Usage);
+ return ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::Kernel,
+ ErrorSummary::WrongArgument, ErrorLevel::Usage);
}
HLE::Reschedule(__func__);
- // The calls that use a timeout seem to always return a Timeout error even if they did not put the thread to sleep
+ // The calls that use a timeout seem to always return a Timeout error even if they did not put
+ // the thread to sleep
if (type == ArbitrationType::WaitIfLessThanWithTimeout ||
type == ArbitrationType::DecrementAndWaitIfLessThanWithTimeout) {
- return ResultCode(ErrorDescription::Timeout, ErrorModule::OS,
- ErrorSummary::StatusChanged, ErrorLevel::Info);
+ return ResultCode(ErrorDescription::Timeout, ErrorModule::OS, ErrorSummary::StatusChanged,
+ ErrorLevel::Info);
}
return RESULT_SUCCESS;
}
diff --git a/src/core/hle/kernel/address_arbiter.h b/src/core/hle/kernel/address_arbiter.h
index 8f6a1a8df..6a7af93a9 100644
--- a/src/core/hle/kernel/address_arbiter.h
+++ b/src/core/hle/kernel/address_arbiter.h
@@ -5,7 +5,6 @@
#pragma once
#include "common/common_types.h"
-
#include "core/hle/kernel/kernel.h"
// Address arbiters are an underlying kernel synchronization object that can be created/used via
@@ -36,13 +35,19 @@ public:
*/
static SharedPtr<AddressArbiter> Create(std::string name = "Unknown");
- std::string GetTypeName() const override { return "Arbiter"; }
- std::string GetName() const override { return name; }
+ std::string GetTypeName() const override {
+ return "Arbiter";
+ }
+ std::string GetName() const override {
+ return name;
+ }
static const HandleType HANDLE_TYPE = HandleType::AddressArbiter;
- HandleType GetHandleType() const override { return HANDLE_TYPE; }
+ HandleType GetHandleType() const override {
+ return HANDLE_TYPE;
+ }
- std::string name; ///< Name of address arbiter object (optional)
+ std::string name; ///< Name of address arbiter object (optional)
ResultCode ArbitrateAddress(ArbitrationType type, VAddr address, s32 value, u64 nanoseconds);
diff --git a/src/core/hle/kernel/client_port.cpp b/src/core/hle/kernel/client_port.cpp
index 444ce8d45..aedc6f989 100644
--- a/src/core/hle/kernel/client_port.cpp
+++ b/src/core/hle/kernel/client_port.cpp
@@ -3,7 +3,6 @@
// Refer to the license.txt file included.
#include "common/assert.h"
-
#include "core/hle/kernel/client_port.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/server_port.h"
diff --git a/src/core/hle/kernel/client_port.h b/src/core/hle/kernel/client_port.h
index 480b6ddae..d28147718 100644
--- a/src/core/hle/kernel/client_port.h
+++ b/src/core/hle/kernel/client_port.h
@@ -5,9 +5,7 @@
#pragma once
#include <string>
-
#include "common/common_types.h"
-
#include "core/hle/kernel/kernel.h"
namespace Kernel {
@@ -17,16 +15,22 @@ class ServerPort;
class ClientPort : public Object {
public:
friend class ServerPort;
- std::string GetTypeName() const override { return "ClientPort"; }
- std::string GetName() const override { return name; }
+ std::string GetTypeName() const override {
+ return "ClientPort";
+ }
+ std::string GetName() const override {
+ return name;
+ }
static const HandleType HANDLE_TYPE = HandleType::ClientPort;
- HandleType GetHandleType() const override { return HANDLE_TYPE; }
-
- SharedPtr<ServerPort> server_port; ///< ServerPort associated with this client port.
- u32 max_sessions; ///< Maximum number of simultaneous sessions the port can have
- u32 active_sessions; ///< Number of currently open sessions to this port
- std::string name; ///< Name of client port (optional)
+ HandleType GetHandleType() const override {
+ return HANDLE_TYPE;
+ }
+
+ SharedPtr<ServerPort> server_port; ///< ServerPort associated with this client port.
+ u32 max_sessions; ///< Maximum number of simultaneous sessions the port can have
+ u32 active_sessions; ///< Number of currently open sessions to this port
+ std::string name; ///< Name of client port (optional)
protected:
ClientPort();
diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp
index 2b7c6992a..1489c7002 100644
--- a/src/core/hle/kernel/event.cpp
+++ b/src/core/hle/kernel/event.cpp
@@ -2,14 +2,12 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
-#include <map>
#include <algorithm>
+#include <map>
#include <vector>
-
#include "common/assert.h"
-
-#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/event.h"
+#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/thread.h"
namespace Kernel {
diff --git a/src/core/hle/kernel/event.h b/src/core/hle/kernel/event.h
index 73d0da419..6fe74065d 100644
--- a/src/core/hle/kernel/event.h
+++ b/src/core/hle/kernel/event.h
@@ -5,7 +5,6 @@
#pragma once
#include "common/common_types.h"
-
#include "core/hle/kernel/kernel.h"
namespace Kernel {
@@ -16,7 +15,6 @@ enum class ResetType {
Pulse,
};
-
class Event final : public WaitObject {
public:
/**
@@ -26,16 +24,22 @@ public:
*/
static SharedPtr<Event> Create(ResetType reset_type, std::string name = "Unknown");
- std::string GetTypeName() const override { return "Event"; }
- std::string GetName() const override { return name; }
+ std::string GetTypeName() const override {
+ return "Event";
+ }
+ std::string GetName() const override {
+ return name;
+ }
static const HandleType HANDLE_TYPE = HandleType::Event;
- HandleType GetHandleType() const override { return HANDLE_TYPE; }
+ HandleType GetHandleType() const override {
+ return HANDLE_TYPE;
+ }
- ResetType reset_type; ///< Current ResetType
+ ResetType reset_type; ///< Current ResetType
- bool signaled; ///< Whether the event has already been signaled
- std::string name; ///< Name of event (optional)
+ bool signaled; ///< Whether the event has already been signaled
+ std::string name; ///< Name of event (optional)
bool ShouldWait() override;
void Acquire() override;
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 7a401a965..9a2c8ce05 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -3,10 +3,8 @@
// Refer to the license.txt file included.
#include <algorithm>
-
#include "common/assert.h"
#include "common/logging/log.h"
-
#include "core/hle/config_mem.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/memory.h"
@@ -61,7 +59,8 @@ ResultVal<Handle> HandleTable::Create(SharedPtr<Object> obj) {
// Overflow count so it fits in the 15 bits dedicated to the generation in the handle.
// CTR-OS doesn't use generation 0, so skip straight to 1.
- if (next_generation >= (1 << 15)) next_generation = 1;
+ if (next_generation >= (1 << 15))
+ next_generation = 1;
generations[slot] = generation;
objects[slot] = std::move(obj);
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index 27ba3f912..0e95f7ff0 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -4,16 +4,13 @@
#pragma once
-#include <boost/smart_ptr/intrusive_ptr.hpp>
-
#include <algorithm>
#include <array>
#include <cstddef>
#include <string>
#include <vector>
-
+#include <boost/smart_ptr/intrusive_ptr.hpp>
#include "common/common_types.h"
-
#include "core/hle/hle.h"
#include "core/hle/result.h"
@@ -23,37 +20,37 @@ class Thread;
// TODO: Verify code
const ResultCode ERR_OUT_OF_HANDLES(ErrorDescription::OutOfMemory, ErrorModule::Kernel,
- ErrorSummary::OutOfResource, ErrorLevel::Temporary);
+ ErrorSummary::OutOfResource, ErrorLevel::Temporary);
// TOOD: Verify code
const ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::Kernel,
- ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
+ ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
enum KernelHandle : Handle {
- CurrentThread = 0xFFFF8000,
- CurrentProcess = 0xFFFF8001,
+ CurrentThread = 0xFFFF8000,
+ CurrentProcess = 0xFFFF8001,
};
enum class HandleType : u32 {
- Unknown = 0,
-
- Session = 2,
- Event = 3,
- Mutex = 4,
- SharedMemory = 5,
- Redirection = 6,
- Thread = 7,
- Process = 8,
- AddressArbiter = 9,
- Semaphore = 10,
- Timer = 11,
- ResourceLimit = 12,
- CodeSet = 13,
- ClientPort = 14,
- ServerPort = 15,
+ Unknown = 0,
+
+ Session = 2,
+ Event = 3,
+ Mutex = 4,
+ SharedMemory = 5,
+ Redirection = 6,
+ Thread = 7,
+ Process = 8,
+ AddressArbiter = 9,
+ Semaphore = 10,
+ Timer = 11,
+ ResourceLimit = 12,
+ CodeSet = 13,
+ ClientPort = 14,
+ ServerPort = 15,
};
enum {
- DEFAULT_STACK_SIZE = 0x4000,
+ DEFAULT_STACK_SIZE = 0x4000,
};
class Object : NonCopyable {
@@ -61,10 +58,16 @@ public:
virtual ~Object() {}
/// Returns a unique identifier for the object. For debugging purposes only.
- unsigned int GetObjectId() const { return object_id; }
+ unsigned int GetObjectId() const {
+ return object_id;
+ }
- virtual std::string GetTypeName() const { return "[BAD KERNEL OBJECT TYPE]"; }
- virtual std::string GetName() const { return "[UNKNOWN KERNEL OBJECT]"; }
+ virtual std::string GetTypeName() const {
+ return "[BAD KERNEL OBJECT TYPE]";
+ }
+ virtual std::string GetName() const {
+ return "[UNKNOWN KERNEL OBJECT]";
+ }
virtual Kernel::HandleType GetHandleType() const = 0;
/**
@@ -122,7 +125,6 @@ using SharedPtr = boost::intrusive_ptr<T>;
/// Class that represents a Kernel object that a thread can be waiting on
class WaitObject : public Object {
public:
-
/**
* Check if the current thread should wait until the object is available
* @return True if the current thread should wait due to this object being unavailable
@@ -247,8 +249,12 @@ private:
*/
static const size_t MAX_COUNT = 4096;
- static u16 GetSlot(Handle handle) { return handle >> 15; }
- static u16 GetGeneration(Handle handle) { return handle & 0x7FFF; }
+ static u16 GetSlot(Handle handle) {
+ return handle >> 15;
+ }
+ static u16 GetGeneration(Handle handle) {
+ return handle & 0x7FFF;
+ }
/// Stores the Object referenced by the handle or null if the slot is empty.
std::array<SharedPtr<Object>, MAX_COUNT> objects;
diff --git a/src/core/hle/kernel/memory.cpp b/src/core/hle/kernel/memory.cpp
index 17ae87aef..e65fd5c41 100644
--- a/src/core/hle/kernel/memory.cpp
+++ b/src/core/hle/kernel/memory.cpp
@@ -6,12 +6,9 @@
#include <memory>
#include <utility>
#include <vector>
-
#include "audio_core/audio_core.h"
-
#include "common/common_types.h"
#include "common/logging/log.h"
-
#include "core/hle/config_mem.h"
#include "core/hle/kernel/memory.h"
#include "core/hle/kernel/vm_manager.h"
@@ -31,7 +28,7 @@ static MemoryRegionInfo memory_regions[3];
static const u32 memory_region_sizes[8][3] = {
// Old 3DS layouts
{0x04000000, 0x02C00000, 0x01400000}, // 0
- { /* This appears to be unused. */ }, // 1
+ {/* This appears to be unused. */}, // 1
{0x06000000, 0x00C00000, 0x01400000}, // 2
{0x05000000, 0x01C00000, 0x01400000}, // 3
{0x04800000, 0x02400000, 0x01400000}, // 4
@@ -95,7 +92,6 @@ MemoryRegionInfo* GetMemoryRegion(MemoryRegion region) {
UNREACHABLE();
}
}
-
}
namespace Memory {
@@ -110,9 +106,8 @@ struct MemoryArea {
// We don't declare the IO regions in here since its handled by other means.
static MemoryArea memory_areas[] = {
- {VRAM_VADDR, VRAM_SIZE, "VRAM"}, // Video memory (VRAM)
+ {VRAM_VADDR, VRAM_SIZE, "VRAM"}, // Video memory (VRAM)
};
-
}
void Init() {
@@ -125,15 +120,21 @@ void InitLegacyAddressSpace(Kernel::VMManager& address_space) {
for (MemoryArea& area : memory_areas) {
auto block = std::make_shared<std::vector<u8>>(area.size);
- address_space.MapMemoryBlock(area.base, std::move(block), 0, area.size, MemoryState::Private).Unwrap();
+ address_space
+ .MapMemoryBlock(area.base, std::move(block), 0, area.size, MemoryState::Private)
+ .Unwrap();
}
- auto cfg_mem_vma = address_space.MapBackingMemory(CONFIG_MEMORY_VADDR,
- (u8*)&ConfigMem::config_mem, CONFIG_MEMORY_SIZE, MemoryState::Shared).MoveFrom();
+ auto cfg_mem_vma = address_space
+ .MapBackingMemory(CONFIG_MEMORY_VADDR, (u8*)&ConfigMem::config_mem,
+ CONFIG_MEMORY_SIZE, MemoryState::Shared)
+ .MoveFrom();
address_space.Reprotect(cfg_mem_vma, VMAPermission::Read);
- auto shared_page_vma = address_space.MapBackingMemory(SHARED_PAGE_VADDR,
- (u8*)&SharedPage::shared_page, SHARED_PAGE_SIZE, MemoryState::Shared).MoveFrom();
+ auto shared_page_vma = address_space
+ .MapBackingMemory(SHARED_PAGE_VADDR, (u8*)&SharedPage::shared_page,
+ SHARED_PAGE_SIZE, MemoryState::Shared)
+ .MoveFrom();
address_space.Reprotect(shared_page_vma, VMAPermission::Read);
AudioCore::AddAddressSpace(address_space);
diff --git a/src/core/hle/kernel/memory.h b/src/core/hle/kernel/memory.h
index 091c1f89f..4e1856a41 100644
--- a/src/core/hle/kernel/memory.h
+++ b/src/core/hle/kernel/memory.h
@@ -5,9 +5,7 @@
#pragma once
#include <memory>
-
#include "common/common_types.h"
-
#include "core/hle/kernel/process.h"
namespace Kernel {
@@ -25,7 +23,6 @@ struct MemoryRegionInfo {
void MemoryInit(u32 mem_type);
void MemoryShutdown();
MemoryRegionInfo* GetMemoryRegion(MemoryRegion region);
-
}
namespace Memory {
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index edb97d324..736944bae 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -4,11 +4,8 @@
#include <map>
#include <vector>
-
#include <boost/range/algorithm_ext/erase.hpp>
-
#include "common/assert.h"
-
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/mutex.h"
#include "core/hle/kernel/thread.h"
diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h
index 1746360e4..53c3dc1f1 100644
--- a/src/core/hle/kernel/mutex.h
+++ b/src/core/hle/kernel/mutex.h
@@ -5,9 +5,7 @@
#pragma once
#include <string>
-
#include "common/common_types.h"
-
#include "core/hle/kernel/kernel.h"
namespace Kernel {
@@ -24,15 +22,21 @@ public:
*/
static SharedPtr<Mutex> Create(bool initial_locked, std::string name = "Unknown");
- std::string GetTypeName() const override { return "Mutex"; }
- std::string GetName() const override { return name; }
+ std::string GetTypeName() const override {
+ return "Mutex";
+ }
+ std::string GetName() const override {
+ return name;
+ }
static const HandleType HANDLE_TYPE = HandleType::Mutex;
- HandleType GetHandleType() const override { return HANDLE_TYPE; }
+ HandleType GetHandleType() const override {
+ return HANDLE_TYPE;
+ }
- int lock_count; ///< Number of times the mutex has been acquired
- std::string name; ///< Name of mutex (optional)
- SharedPtr<Thread> holding_thread; ///< Thread that has acquired the mutex
+ int lock_count; ///< Number of times the mutex has been acquired
+ std::string name; ///< Name of mutex (optional)
+ SharedPtr<Thread> holding_thread; ///< Thread that has acquired the mutex
bool ShouldWait() override;
void Acquire() override;
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp
index 69302cc82..ba80fe7f8 100644
--- a/src/core/hle/kernel/process.cpp
+++ b/src/core/hle/kernel/process.cpp
@@ -3,11 +3,9 @@
// Refer to the license.txt file included.
#include <memory>
-
#include "common/assert.h"
#include "common/common_funcs.h"
#include "common/logging/log.h"
-
#include "core/hle/kernel/memory.h"
#include "core/hle/kernel/process.h"
#include "core/hle/kernel/resource_limit.h"
@@ -60,7 +58,8 @@ void Process::ParseKernelCaps(const u32* kernel_caps, size_t len) {
while (bits && index < svc_access_mask.size()) {
svc_access_mask.set(index, bits & 1);
- ++index; bits >>= 1;
+ ++index;
+ bits >>= 1;
}
} else if ((type & 0xFF0) == 0xFE0) { // 0x00FF
// Handle table size
@@ -70,11 +69,11 @@ void Process::ParseKernelCaps(const u32* kernel_caps, size_t len) {
flags.raw = descriptor & 0xFFFF;
} else if ((type & 0xFFE) == 0xFF8) { // 0x001F
// Mapped memory range
- if (i+1 >= len || ((kernel_caps[i+1] >> 20) & 0xFFE) != 0xFF8) {
+ if (i + 1 >= len || ((kernel_caps[i + 1] >> 20) & 0xFFE) != 0xFF8) {
LOG_WARNING(Loader, "Incomplete exheader memory range descriptor ignored.");
continue;
}
- u32 end_desc = kernel_caps[i+1];
+ u32 end_desc = kernel_caps[i + 1];
++i; // Skip over the second descriptor on the next iteration
AddressMapping mapping;
@@ -107,23 +106,28 @@ void Process::ParseKernelCaps(const u32* kernel_caps, size_t len) {
void Process::Run(s32 main_thread_priority, u32 stack_size) {
memory_region = GetMemoryRegion(flags.memory_region);
- auto MapSegment = [&](CodeSet::Segment& segment, VMAPermission permissions, MemoryState memory_state) {
- auto vma = vm_manager.MapMemoryBlock(segment.addr, codeset->memory,
- segment.offset, segment.size, memory_state).Unwrap();
+ auto MapSegment = [&](CodeSet::Segment& segment, VMAPermission permissions,
+ MemoryState memory_state) {
+ auto vma = vm_manager
+ .MapMemoryBlock(segment.addr, codeset->memory, segment.offset, segment.size,
+ memory_state)
+ .Unwrap();
vm_manager.Reprotect(vma, permissions);
misc_memory_used += segment.size;
memory_region->used += segment.size;
};
// Map CodeSet segments
- MapSegment(codeset->code, VMAPermission::ReadExecute, MemoryState::Code);
- MapSegment(codeset->rodata, VMAPermission::Read, MemoryState::Code);
- MapSegment(codeset->data, VMAPermission::ReadWrite, MemoryState::Private);
+ MapSegment(codeset->code, VMAPermission::ReadExecute, MemoryState::Code);
+ MapSegment(codeset->rodata, VMAPermission::Read, MemoryState::Code);
+ MapSegment(codeset->data, VMAPermission::ReadWrite, MemoryState::Private);
// Allocate and map stack
- vm_manager.MapMemoryBlock(Memory::HEAP_VADDR_END - stack_size,
- std::make_shared<std::vector<u8>>(stack_size, 0), 0, stack_size, MemoryState::Locked
- ).Unwrap();
+ vm_manager
+ .MapMemoryBlock(Memory::HEAP_VADDR_END - stack_size,
+ std::make_shared<std::vector<u8>>(stack_size, 0), 0, stack_size,
+ MemoryState::Locked)
+ .Unwrap();
misc_memory_used += stack_size;
memory_region->used += stack_size;
@@ -143,7 +147,8 @@ VAddr Process::GetLinearHeapLimit() const {
}
ResultVal<VAddr> Process::HeapAllocate(VAddr target, u32 size, VMAPermission perms) {
- if (target < Memory::HEAP_VADDR || target + size > Memory::HEAP_VADDR_END || target + size < target) {
+ if (target < Memory::HEAP_VADDR || target + size > Memory::HEAP_VADDR_END ||
+ target + size < target) {
return ERR_INVALID_ADDRESS;
}
@@ -166,7 +171,8 @@ ResultVal<VAddr> Process::HeapAllocate(VAddr target, u32 size, VMAPermission per
}
ASSERT(heap_end - heap_start == heap_memory->size());
- CASCADE_RESULT(auto vma, vm_manager.MapMemoryBlock(target, heap_memory, target - heap_start, size, MemoryState::Private));
+ CASCADE_RESULT(auto vma, vm_manager.MapMemoryBlock(target, heap_memory, target - heap_start,
+ size, MemoryState::Private));
vm_manager.Reprotect(vma, perms);
heap_used += size;
@@ -176,7 +182,8 @@ ResultVal<VAddr> Process::HeapAllocate(VAddr target, u32 size, VMAPermission per
}
ResultCode Process::HeapFree(VAddr target, u32 size) {
- if (target < Memory::HEAP_VADDR || target + size > Memory::HEAP_VADDR_END || target + size < target) {
+ if (target < Memory::HEAP_VADDR || target + size > Memory::HEAP_VADDR_END ||
+ target + size < target) {
return ERR_INVALID_ADDRESS;
}
@@ -185,7 +192,8 @@ ResultCode Process::HeapFree(VAddr target, u32 size) {
}
ResultCode result = vm_manager.UnmapRange(target, size);
- if (result.IsError()) return result;
+ if (result.IsError())
+ return result;
heap_used -= size;
memory_region->used -= size;
@@ -203,8 +211,8 @@ ResultVal<VAddr> Process::LinearAllocate(VAddr target, u32 size, VMAPermission p
target = heap_end;
}
- if (target < GetLinearHeapBase() || target + size > GetLinearHeapLimit() ||
- target > heap_end || target + size < target) {
+ if (target < GetLinearHeapBase() || target + size > GetLinearHeapLimit() || target > heap_end ||
+ target + size < target) {
return ERR_INVALID_ADDRESS;
}
@@ -220,7 +228,8 @@ ResultVal<VAddr> Process::LinearAllocate(VAddr target, u32 size, VMAPermission p
// TODO(yuriks): As is, this lets processes map memory allocated by other processes from the
// same region. It is unknown if or how the 3DS kernel checks against this.
size_t offset = target - GetLinearHeapBase();
- CASCADE_RESULT(auto vma, vm_manager.MapMemoryBlock(target, linheap_memory, offset, size, MemoryState::Continuous));
+ CASCADE_RESULT(auto vma, vm_manager.MapMemoryBlock(target, linheap_memory, offset, size,
+ MemoryState::Continuous));
vm_manager.Reprotect(vma, perms);
linear_heap_used += size;
@@ -248,7 +257,8 @@ ResultCode Process::LinearFree(VAddr target, u32 size) {
}
ResultCode result = vm_manager.UnmapRange(target, size);
- if (result.IsError()) return result;
+ if (result.IsError())
+ return result;
linear_heap_used -= size;
memory_region->used -= size;
@@ -272,5 +282,4 @@ Kernel::Process::Process() {}
Kernel::Process::~Process() {}
SharedPtr<Process> g_current_process;
-
}
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h
index d781ef32c..b566950b0 100644
--- a/src/core/hle/kernel/process.h
+++ b/src/core/hle/kernel/process.h
@@ -8,12 +8,9 @@
#include <cstddef>
#include <memory>
#include <string>
-
#include <boost/container/static_vector.hpp>
-
#include "common/bit_field.h"
#include "common/common_types.h"
-
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/vm_manager.h"
@@ -36,15 +33,18 @@ enum class MemoryRegion : u16 {
union ProcessFlags {
u16 raw;
- BitField< 0, 1, u16> allow_debug; ///< Allows other processes to attach to and debug this process.
- BitField< 1, 1, u16> force_debug; ///< Allows this process to attach to processes even if they don't have allow_debug set.
- BitField< 2, 1, u16> allow_nonalphanum;
- BitField< 3, 1, u16> shared_page_writable; ///< Shared page is mapped with write permissions.
- BitField< 4, 1, u16> privileged_priority; ///< Can use priority levels higher than 24.
- BitField< 5, 1, u16> allow_main_args;
- BitField< 6, 1, u16> shared_device_mem;
- BitField< 7, 1, u16> runnable_on_sleep;
- BitField< 8, 4, MemoryRegion> memory_region; ///< Default region for memory allocations for this process
+ BitField<0, 1, u16>
+ allow_debug; ///< Allows other processes to attach to and debug this process.
+ BitField<1, 1, u16> force_debug; ///< Allows this process to attach to processes even if they
+ /// don't have allow_debug set.
+ BitField<2, 1, u16> allow_nonalphanum;
+ BitField<3, 1, u16> shared_page_writable; ///< Shared page is mapped with write permissions.
+ BitField<4, 1, u16> privileged_priority; ///< Can use priority levels higher than 24.
+ BitField<5, 1, u16> allow_main_args;
+ BitField<6, 1, u16> shared_device_mem;
+ BitField<7, 1, u16> runnable_on_sleep;
+ BitField<8, 4, MemoryRegion>
+ memory_region; ///< Default region for memory allocations for this process
BitField<12, 1, u16> loaded_high; ///< Application loaded high (not at 0x00100000).
};
@@ -54,11 +54,17 @@ struct MemoryRegionInfo;
struct CodeSet final : public Object {
static SharedPtr<CodeSet> Create(std::string name, u64 program_id);
- std::string GetTypeName() const override { return "CodeSet"; }
- std::string GetName() const override { return name; }
+ std::string GetTypeName() const override {
+ return "CodeSet";
+ }
+ std::string GetName() const override {
+ return name;
+ }
static const HandleType HANDLE_TYPE = HandleType::CodeSet;
- HandleType GetHandleType() const override { return HANDLE_TYPE; }
+ HandleType GetHandleType() const override {
+ return HANDLE_TYPE;
+ }
/// Name of the process
std::string name;
@@ -85,11 +91,17 @@ class Process final : public Object {
public:
static SharedPtr<Process> Create(SharedPtr<CodeSet> code_set);
- std::string GetTypeName() const override { return "Process"; }
- std::string GetName() const override { return codeset->name; }
+ std::string GetTypeName() const override {
+ return "Process";
+ }
+ std::string GetName() const override {
+ return codeset->name;
+ }
static const HandleType HANDLE_TYPE = HandleType::Process;
- HandleType GetHandleType() const override { return HANDLE_TYPE; }
+ HandleType GetHandleType() const override {
+ return HANDLE_TYPE;
+ }
static u32 next_process_id;
@@ -124,7 +136,6 @@ public:
*/
void Run(s32 main_thread_priority, u32 stack_size);
-
///////////////////////////////////////////////////////////////////////////////////////////////
// Memory Management
@@ -144,7 +155,8 @@ public:
/// The Thread Local Storage area is allocated as processes create threads,
/// each TLS area is 0x200 bytes, so one page (0x1000) is split up in 8 parts, and each part
- /// holds the TLS for a specific thread. This vector contains which parts are in use for each page as a bitmask.
+ /// holds the TLS for a specific thread. This vector contains which parts are in use for each
+ /// page as a bitmask.
/// This vector will grow as more pages are allocated for new threads.
std::vector<std::bitset<8>> tls_slots;
@@ -164,5 +176,4 @@ private:
};
extern SharedPtr<Process> g_current_process;
-
}
diff --git a/src/core/hle/kernel/resource_limit.cpp b/src/core/hle/kernel/resource_limit.cpp
index 67dde08c2..253ab7045 100644
--- a/src/core/hle/kernel/resource_limit.cpp
+++ b/src/core/hle/kernel/resource_limit.cpp
@@ -3,9 +3,7 @@
// Refer to the license.txt file included.
#include <cstring>
-
#include "common/logging/log.h"
-
#include "core/hle/kernel/resource_limit.h"
namespace Kernel {
@@ -23,70 +21,69 @@ SharedPtr<ResourceLimit> ResourceLimit::Create(std::string name) {
}
SharedPtr<ResourceLimit> ResourceLimit::GetForCategory(ResourceLimitCategory category) {
- switch (category)
- {
- case ResourceLimitCategory::APPLICATION:
- case ResourceLimitCategory::SYS_APPLET:
- case ResourceLimitCategory::LIB_APPLET:
- case ResourceLimitCategory::OTHER:
- return resource_limits[static_cast<u8>(category)];
- default:
- LOG_CRITICAL(Kernel, "Unknown resource limit category");
- UNREACHABLE();
+ switch (category) {
+ case ResourceLimitCategory::APPLICATION:
+ case ResourceLimitCategory::SYS_APPLET:
+ case ResourceLimitCategory::LIB_APPLET:
+ case ResourceLimitCategory::OTHER:
+ return resource_limits[static_cast<u8>(category)];
+ default:
+ LOG_CRITICAL(Kernel, "Unknown resource limit category");
+ UNREACHABLE();
}
}
s32 ResourceLimit::GetCurrentResourceValue(u32 resource) const {
switch (resource) {
- case COMMIT:
- return current_commit;
- case THREAD:
- return current_threads;
- case EVENT:
- return current_events;
- case MUTEX:
- return current_mutexes;
- case SEMAPHORE:
- return current_semaphores;
- case TIMER:
- return current_timers;
- case SHARED_MEMORY:
- return current_shared_mems;
- case ADDRESS_ARBITER:
- return current_address_arbiters;
- case CPU_TIME:
- return current_cpu_time;
- default:
- LOG_ERROR(Kernel, "Unknown resource type=%08X", resource);
- UNIMPLEMENTED();
- return 0;
+ case COMMIT:
+ return current_commit;
+ case THREAD:
+ return current_threads;
+ case EVENT:
+ return current_events;
+ case MUTEX:
+ return current_mutexes;
+ case SEMAPHORE:
+ return current_semaphores;
+ case TIMER:
+ return current_timers;
+ case SHARED_MEMORY:
+ return current_shared_mems;
+ case ADDRESS_ARBITER:
+ return current_address_arbiters;
+ case CPU_TIME:
+ return current_cpu_time;
+ default:
+ LOG_ERROR(Kernel, "Unknown resource type=%08X", resource);
+ UNIMPLEMENTED();
+ return 0;
}
}
s32 ResourceLimit::GetMaxResourceValue(u32 resource) const {
switch (resource) {
- case COMMIT:
- return max_commit;
- case THREAD:
- return max_threads;
- case EVENT:
- return max_events;
- case MUTEX:
- return max_mutexes;
- case SEMAPHORE:
- return max_semaphores;
- case TIMER:
- return max_timers;
- case SHARED_MEMORY:
- return max_shared_mems;
- case ADDRESS_ARBITER:
- return max_address_arbiters;
- case CPU_TIME:
- return max_cpu_time;
- default:
- LOG_ERROR(Kernel, "Unknown resource type=%08X", resource);
- UNIMPLEMENTED();
- return 0;
+ case COMMIT:
+ return max_commit;
+ case THREAD:
+ return max_threads;
+ case EVENT:
+ return max_events;
+ case MUTEX:
+ return max_mutexes;
+ case SEMAPHORE:
+ return max_semaphores;
+ case TIMER:
+ return max_timers;
+ case SHARED_MEMORY:
+ return max_shared_mems;
+ case ADDRESS_ARBITER:
+ return max_address_arbiters;
+ case CPU_TIME:
+ return max_cpu_time;
+ default:
+ LOG_ERROR(Kernel, "Unknown resource type=%08X", resource);
+ UNIMPLEMENTED();
+ return 0;
}
}
@@ -149,8 +146,6 @@ void ResourceLimitsInit() {
resource_limits[static_cast<u8>(ResourceLimitCategory::OTHER)] = resource_limit;
}
-void ResourceLimitsShutdown() {
-
-}
+void ResourceLimitsShutdown() {}
} // namespace
diff --git a/src/core/hle/kernel/resource_limit.h b/src/core/hle/kernel/resource_limit.h
index 1b8249c74..6cdfbcf8d 100644
--- a/src/core/hle/kernel/resource_limit.h
+++ b/src/core/hle/kernel/resource_limit.h
@@ -5,29 +5,28 @@
#pragma once
#include "common/common_types.h"
-
#include "core/hle/kernel/kernel.h"
namespace Kernel {
enum class ResourceLimitCategory : u8 {
APPLICATION = 0,
- SYS_APPLET = 1,
- LIB_APPLET = 2,
- OTHER = 3
+ SYS_APPLET = 1,
+ LIB_APPLET = 2,
+ OTHER = 3
};
enum ResourceTypes {
- PRIORITY = 0,
- COMMIT = 1,
- THREAD = 2,
- EVENT = 3,
- MUTEX = 4,
- SEMAPHORE = 5,
- TIMER = 6,
- SHARED_MEMORY = 7,
- ADDRESS_ARBITER = 8,
- CPU_TIME = 9,
+ PRIORITY = 0,
+ COMMIT = 1,
+ THREAD = 2,
+ EVENT = 3,
+ MUTEX = 4,
+ SEMAPHORE = 5,
+ TIMER = 6,
+ SHARED_MEMORY = 7,
+ ADDRESS_ARBITER = 8,
+ CPU_TIME = 9,
};
class ResourceLimit final : public Object {
@@ -44,11 +43,17 @@ public:
*/
static SharedPtr<ResourceLimit> GetForCategory(ResourceLimitCategory category);
- std::string GetTypeName() const override { return "ResourceLimit"; }
- std::string GetName() const override { return name; }
+ std::string GetTypeName() const override {
+ return "ResourceLimit";
+ }
+ std::string GetName() const override {
+ return name;
+ }
static const HandleType HANDLE_TYPE = HandleType::ResourceLimit;
- HandleType GetHandleType() const override { return HANDLE_TYPE; }
+ HandleType GetHandleType() const override {
+ return HANDLE_TYPE;
+ }
/**
* Gets the current value for the specified resource.
@@ -85,10 +90,12 @@ public:
/// Max CPU time that the processes in this category can utilize
s32 max_cpu_time = 0;
- // TODO(Subv): Increment these in their respective Kernel::T::Create functions, keeping in mind that
- // APPLICATION resource limits should not be affected by the objects created by service modules.
+ // TODO(Subv): Increment these in their respective Kernel::T::Create functions, keeping in mind
+ // that APPLICATION resource limits should not be affected by the objects created by service
+ // modules.
// Currently we have no way of distinguishing if a Create was called by the running application,
- // or by a service module. Approach this once we have separated the service modules into their own processes
+ // or by a service module. Approach this once we have separated the service modules into their
+ // own processes
/// Current memory that the processes in this category are using
s32 current_commit = 0;
diff --git a/src/core/hle/kernel/semaphore.cpp b/src/core/hle/kernel/semaphore.cpp
index 4b359ed07..bf7600780 100644
--- a/src/core/hle/kernel/semaphore.cpp
+++ b/src/core/hle/kernel/semaphore.cpp
@@ -3,7 +3,6 @@
// Refer to the license.txt file included.
#include "common/assert.h"
-
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/semaphore.h"
#include "core/hle/kernel/thread.h"
@@ -14,7 +13,7 @@ Semaphore::Semaphore() {}
Semaphore::~Semaphore() {}
ResultVal<SharedPtr<Semaphore>> Semaphore::Create(s32 initial_count, s32 max_count,
- std::string name) {
+ std::string name) {
if (initial_count > max_count)
return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::Kernel,
diff --git a/src/core/hle/kernel/semaphore.h b/src/core/hle/kernel/semaphore.h
index 390f5e495..e01908a25 100644
--- a/src/core/hle/kernel/semaphore.h
+++ b/src/core/hle/kernel/semaphore.h
@@ -6,9 +6,7 @@
#include <queue>
#include <string>
-
#include "common/common_types.h"
-
#include "core/hle/kernel/kernel.h"
namespace Kernel {
@@ -23,17 +21,23 @@ public:
* @return The created semaphore
*/
static ResultVal<SharedPtr<Semaphore>> Create(s32 initial_count, s32 max_count,
- std::string name = "Unknown");
+ std::string name = "Unknown");
- std::string GetTypeName() const override { return "Semaphore"; }
- std::string GetName() const override { return name; }
+ std::string GetTypeName() const override {
+ return "Semaphore";
+ }
+ std::string GetName() const override {
+ return name;
+ }
static const HandleType HANDLE_TYPE = HandleType::Semaphore;
- HandleType GetHandleType() const override { return HANDLE_TYPE; }
+ HandleType GetHandleType() const override {
+ return HANDLE_TYPE;
+ }
- s32 max_count; ///< Maximum number of simultaneous holders the semaphore can have
- s32 available_count; ///< Number of free slots left in the semaphore
- std::string name; ///< Name of semaphore (optional)
+ s32 max_count; ///< Maximum number of simultaneous holders the semaphore can have
+ s32 available_count; ///< Number of free slots left in the semaphore
+ std::string name; ///< Name of semaphore (optional)
bool ShouldWait() override;
void Acquire() override;
diff --git a/src/core/hle/kernel/server_port.cpp b/src/core/hle/kernel/server_port.cpp
index fcc684a20..8e3ec8a14 100644
--- a/src/core/hle/kernel/server_port.cpp
+++ b/src/core/hle/kernel/server_port.cpp
@@ -3,9 +3,7 @@
// Refer to the license.txt file included.
#include <tuple>
-
#include "common/assert.h"
-
#include "core/hle/kernel/client_port.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/server_port.h"
@@ -25,7 +23,9 @@ void ServerPort::Acquire() {
ASSERT_MSG(!ShouldWait(), "object unavailable!");
}
-std::tuple<SharedPtr<ServerPort>, SharedPtr<ClientPort>> ServerPort::CreatePortPair(u32 max_sessions, std::string name) {
+std::tuple<SharedPtr<ServerPort>, SharedPtr<ClientPort>> ServerPort::CreatePortPair(
+ u32 max_sessions, std::string name) {
+
SharedPtr<ServerPort> server_port(new ServerPort);
SharedPtr<ClientPort> client_port(new ClientPort);
diff --git a/src/core/hle/kernel/server_port.h b/src/core/hle/kernel/server_port.h
index e9c972ce6..fa9448ca0 100644
--- a/src/core/hle/kernel/server_port.h
+++ b/src/core/hle/kernel/server_port.h
@@ -6,9 +6,7 @@
#include <string>
#include <tuple>
-
#include "common/common_types.h"
-
#include "core/hle/kernel/kernel.h"
namespace Kernel {
@@ -23,17 +21,25 @@ public:
* @param name Optional name of the ports
* @return The created port tuple
*/
- static std::tuple<SharedPtr<ServerPort>, SharedPtr<ClientPort>> CreatePortPair(u32 max_sessions, std::string name = "UnknownPort");
+ static std::tuple<SharedPtr<ServerPort>, SharedPtr<ClientPort>> CreatePortPair(
+ u32 max_sessions, std::string name = "UnknownPort");
- std::string GetTypeName() const override { return "ServerPort"; }
- std::string GetName() const override { return name; }
+ std::string GetTypeName() const override {
+ return "ServerPort";
+ }
+ std::string GetName() const override {
+ return name;
+ }
static const HandleType HANDLE_TYPE = HandleType::ServerPort;
- HandleType GetHandleType() const override { return HANDLE_TYPE; }
+ HandleType GetHandleType() const override {
+ return HANDLE_TYPE;
+ }
- std::string name; ///< Name of port (optional)
+ std::string name; ///< Name of port (optional)
- std::vector<SharedPtr<WaitObject>> pending_sessions; ///< ServerSessions waiting to be accepted by the port
+ std::vector<SharedPtr<WaitObject>>
+ pending_sessions; ///< ServerSessions waiting to be accepted by the port
bool ShouldWait() override;
void Acquire() override;
diff --git a/src/core/hle/kernel/session.cpp b/src/core/hle/kernel/session.cpp
index 0594967f8..8a2a7e3fd 100644
--- a/src/core/hle/kernel/session.cpp
+++ b/src/core/hle/kernel/session.cpp
@@ -9,5 +9,4 @@ namespace Kernel {
Session::Session() {}
Session::~Session() {}
-
}
diff --git a/src/core/hle/kernel/session.h b/src/core/hle/kernel/session.h
index 8ec889967..ec025f732 100644
--- a/src/core/hle/kernel/session.h
+++ b/src/core/hle/kernel/session.h
@@ -5,10 +5,8 @@
#pragma once
#include <string>
-
#include "common/assert.h"
#include "common/common_types.h"
-
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/thread.h"
#include "core/hle/result.h"
@@ -19,12 +17,13 @@ namespace IPC {
enum DescriptorType : u32 {
// Buffer related desciptors types (mask : 0x0F)
StaticBuffer = 0x02,
- PXIBuffer = 0x04,
+ PXIBuffer = 0x04,
MappedBuffer = 0x08,
- // Handle related descriptors types (mask : 0x30, but need to check for buffer related descriptors first )
- CopyHandle = 0x00,
- MoveHandle = 0x10,
- CallingPid = 0x20,
+ // Handle related descriptors types (mask : 0x30, but need to check for buffer related
+ // descriptors first )
+ CopyHandle = 0x00,
+ MoveHandle = 0x10,
+ CallingPid = 0x20,
};
/**
@@ -34,24 +33,28 @@ enum DescriptorType : u32 {
* @param translate_params_size Size of the translate parameters in words. Up to 63.
* @return The created IPC header.
*
- * Normal parameters are sent directly to the process while the translate parameters might go through modifications and checks by the kernel.
+ * Normal parameters are sent directly to the process while the translate parameters might go
+ * through modifications and checks by the kernel.
* The translate parameters are described by headers generated with the IPC::*Desc functions.
*
- * @note While #normal_params is equivalent to the number of normal parameters, #translate_params_size includes the size occupied by the translate parameters headers.
+ * @note While #normal_params is equivalent to the number of normal parameters,
+ * #translate_params_size includes the size occupied by the translate parameters headers.
*/
-constexpr u32 MakeHeader(u16 command_id, unsigned int normal_params, unsigned int translate_params_size) {
- return (u32(command_id) << 16) | ((u32(normal_params) & 0x3F) << 6) | (u32(translate_params_size) & 0x3F);
+constexpr u32 MakeHeader(u16 command_id, unsigned int normal_params,
+ unsigned int translate_params_size) {
+ return (u32(command_id) << 16) | ((u32(normal_params) & 0x3F) << 6) |
+ (u32(translate_params_size) & 0x3F);
}
union Header {
u32 raw;
- BitField< 0, 6, u32> translate_params_size;
- BitField< 6, 6, u32> normal_params;
+ BitField<0, 6, u32> translate_params_size;
+ BitField<6, 6, u32> normal_params;
BitField<16, 16, u32> command_id;
};
inline Header ParseHeader(u32 header) {
- return{ header };
+ return {header};
}
constexpr u32 MoveHandleDesc(u32 num_handles = 1) {
@@ -80,27 +83,29 @@ constexpr u32 StaticBufferDesc(u32 size, u8 buffer_id) {
union StaticBufferDescInfo {
u32 raw;
- BitField< 10, 4, u32> buffer_id;
- BitField< 14, 18, u32> size;
+ BitField<10, 4, u32> buffer_id;
+ BitField<14, 18, u32> size;
};
inline StaticBufferDescInfo ParseStaticBufferDesc(const u32 desc) {
- return{ desc };
+ return {desc};
}
/**
* @brief Creates a header describing a buffer to be sent over PXI.
* @param size Size of the buffer. Max 0x00FFFFFF.
* @param buffer_id The Id of the buffer. Max 0xF.
- * @param is_read_only true if the buffer is read-only. If false, the buffer is considered to have read-write access.
+ * @param is_read_only true if the buffer is read-only. If false, the buffer is considered to have
+ * read-write access.
* @return The created PXI buffer header.
*
* The next value is a phys-address of a table located in the BASE memregion.
*/
inline u32 PXIBufferDesc(u32 size, unsigned buffer_id, bool is_read_only) {
u32 type = PXIBuffer;
- if (is_read_only) type |= 0x2;
- return type | (size << 8) | ((buffer_id & 0xF) << 4);
+ if (is_read_only)
+ type |= 0x2;
+ return type | (size << 8) | ((buffer_id & 0xF) << 4);
}
enum MappedBufferPermissions {
@@ -115,12 +120,12 @@ constexpr u32 MappedBufferDesc(u32 size, MappedBufferPermissions perms) {
union MappedBufferDescInfo {
u32 raw;
- BitField< 4, 28, u32> size;
- BitField< 1, 2, MappedBufferPermissions> perms;
+ BitField<4, 28, u32> size;
+ BitField<1, 2, MappedBufferPermissions> perms;
};
inline MappedBufferDescInfo ParseMappedBufferDesc(const u32 desc) {
- return{ desc };
+ return {desc};
}
inline DescriptorType GetDescriptorType(u32 descriptor) {
@@ -153,7 +158,8 @@ static const int kCommandHeaderOffset = 0x80; ///< Offset into command buffer of
* @return Pointer to command buffer
*/
inline u32* GetCommandBuffer(const int offset = 0) {
- return (u32*)Memory::GetPointer(GetCurrentThread()->GetTLSAddress() + kCommandHeaderOffset + offset);
+ return (u32*)Memory::GetPointer(GetCurrentThread()->GetTLSAddress() + kCommandHeaderOffset +
+ offset);
}
/**
@@ -183,10 +189,14 @@ public:
Session();
~Session() override;
- std::string GetTypeName() const override { return "Session"; }
+ std::string GetTypeName() const override {
+ return "Session";
+ }
static const HandleType HANDLE_TYPE = HandleType::Session;
- HandleType GetHandleType() const override { return HANDLE_TYPE; }
+ HandleType GetHandleType() const override {
+ return HANDLE_TYPE;
+ }
/**
* Handles a synchronous call to this session using HLE emulation. Emulated <-> emulated calls
@@ -205,5 +215,4 @@ public:
ASSERT_MSG(!ShouldWait(), "object unavailable!");
}
};
-
}
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp
index 6a22c8986..bc1560d12 100644
--- a/src/core/hle/kernel/shared_memory.cpp
+++ b/src/core/hle/kernel/shared_memory.cpp
@@ -3,20 +3,20 @@
// Refer to the license.txt file included.
#include <cstring>
-
#include "common/logging/log.h"
-
-#include "core/memory.h"
#include "core/hle/kernel/memory.h"
#include "core/hle/kernel/shared_memory.h"
+#include "core/memory.h"
namespace Kernel {
SharedMemory::SharedMemory() {}
SharedMemory::~SharedMemory() {}
-SharedPtr<SharedMemory> SharedMemory::Create(SharedPtr<Process> owner_process, u32 size, MemoryPermission permissions,
- MemoryPermission other_permissions, VAddr address, MemoryRegion region, std::string name) {
+SharedPtr<SharedMemory> SharedMemory::Create(SharedPtr<Process> owner_process, u32 size,
+ MemoryPermission permissions,
+ MemoryPermission other_permissions, VAddr address,
+ MemoryRegion region, std::string name) {
SharedPtr<SharedMemory> shared_memory(new SharedMemory);
shared_memory->owner_process = owner_process;
@@ -31,7 +31,8 @@ SharedPtr<SharedMemory> SharedMemory::Create(SharedPtr<Process> owner_process, u
MemoryRegionInfo* memory_region = GetMemoryRegion(region);
auto& linheap_memory = memory_region->linear_heap_memory;
- ASSERT_MSG(linheap_memory->size() + size <= memory_region->size, "Not enough space in region to allocate shared memory!");
+ ASSERT_MSG(linheap_memory->size() + size <= memory_region->size,
+ "Not enough space in region to allocate shared memory!");
shared_memory->backing_block = linheap_memory;
shared_memory->backing_block_offset = linheap_memory->size();
@@ -39,7 +40,8 @@ SharedPtr<SharedMemory> SharedMemory::Create(SharedPtr<Process> owner_process, u
linheap_memory->insert(linheap_memory->end(), size, 0);
memory_region->used += size;
- shared_memory->linear_heap_phys_address = Memory::FCRAM_PADDR + memory_region->base + shared_memory->backing_block_offset;
+ shared_memory->linear_heap_phys_address =
+ Memory::FCRAM_PADDR + memory_region->base + shared_memory->backing_block_offset;
// Increase the amount of used linear heap memory for the owner process.
if (shared_memory->owner_process != nullptr) {
@@ -51,18 +53,20 @@ SharedPtr<SharedMemory> SharedMemory::Create(SharedPtr<Process> owner_process, u
Kernel::g_current_process->vm_manager.RefreshMemoryBlockMappings(linheap_memory.get());
}
} else {
- // TODO(Subv): What happens if an application tries to create multiple memory blocks pointing to the same address?
+ // TODO(Subv): What happens if an application tries to create multiple memory blocks
+ // pointing to the same address?
auto& vm_manager = shared_memory->owner_process->vm_manager;
// The memory is already available and mapped in the owner process.
auto vma = vm_manager.FindVMA(address)->second;
// Copy it over to our own storage
- shared_memory->backing_block = std::make_shared<std::vector<u8>>(vma.backing_block->data() + vma.offset,
- vma.backing_block->data() + vma.offset + size);
+ shared_memory->backing_block = std::make_shared<std::vector<u8>>(
+ vma.backing_block->data() + vma.offset, vma.backing_block->data() + vma.offset + size);
shared_memory->backing_block_offset = 0;
// Unmap the existing pages
vm_manager.UnmapRange(address, size);
// Map our own block into the address space
- vm_manager.MapMemoryBlock(address, shared_memory->backing_block, 0, size, MemoryState::Shared);
+ vm_manager.MapMemoryBlock(address, shared_memory->backing_block, 0, size,
+ MemoryState::Shared);
// Reprotect the block with the new permissions
vm_manager.ReprotectRange(address, size, ConvertPermissions(permissions));
}
@@ -71,8 +75,11 @@ SharedPtr<SharedMemory> SharedMemory::Create(SharedPtr<Process> owner_process, u
return shared_memory;
}
-SharedPtr<SharedMemory> SharedMemory::CreateForApplet(std::shared_ptr<std::vector<u8>> heap_block, u32 offset, u32 size,
- MemoryPermission permissions, MemoryPermission other_permissions, std::string name) {
+SharedPtr<SharedMemory> SharedMemory::CreateForApplet(std::shared_ptr<std::vector<u8>> heap_block,
+ u32 offset, u32 size,
+ MemoryPermission permissions,
+ MemoryPermission other_permissions,
+ std::string name) {
SharedPtr<SharedMemory> shared_memory(new SharedMemory);
shared_memory->owner_process = nullptr;
@@ -88,27 +95,31 @@ SharedPtr<SharedMemory> SharedMemory::CreateForApplet(std::shared_ptr<std::vecto
}
ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermission permissions,
- MemoryPermission other_permissions) {
+ MemoryPermission other_permissions) {
- MemoryPermission own_other_permissions = target_process == owner_process ? this->permissions : this->other_permissions;
+ MemoryPermission own_other_permissions =
+ target_process == owner_process ? this->permissions : this->other_permissions;
// Automatically allocated memory blocks can only be mapped with other_permissions = DontCare
if (base_address == 0 && other_permissions != MemoryPermission::DontCare) {
- return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
+ return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS,
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage);
}
// Error out if the requested permissions don't match what the creator process allows.
if (static_cast<u32>(permissions) & ~static_cast<u32>(own_other_permissions)) {
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match",
GetObjectId(), address, name.c_str());
- return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
+ return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS,
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage);
}
// Heap-backed memory blocks can not be mapped with other_permissions = DontCare
if (base_address != 0 && other_permissions == MemoryPermission::DontCare) {
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match",
GetObjectId(), address, name.c_str());
- return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
+ return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS,
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage);
}
// Error out if the provided permissions are not compatible with what the creator process needs.
@@ -116,12 +127,14 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi
static_cast<u32>(this->permissions) & ~static_cast<u32>(other_permissions)) {
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match",
GetObjectId(), address, name.c_str());
- return ResultCode(ErrorDescription::WrongPermission, ErrorModule::OS, ErrorSummary::WrongArgument, ErrorLevel::Permanent);
+ return ResultCode(ErrorDescription::WrongPermission, ErrorModule::OS,
+ ErrorSummary::WrongArgument, ErrorLevel::Permanent);
}
// TODO(Subv): Check for the Shared Device Mem flag in the creator process.
/*if (was_created_with_shared_device_mem && address != 0) {
- return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
+ return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS,
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage);
}*/
// TODO(Subv): The same process that created a SharedMemory object
@@ -144,23 +157,29 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi
}
// Map the memory block into the target process
- auto result = target_process->vm_manager.MapMemoryBlock(target_address, backing_block, backing_block_offset, size, MemoryState::Shared);
+ auto result = target_process->vm_manager.MapMemoryBlock(
+ target_address, backing_block, backing_block_offset, size, MemoryState::Shared);
if (result.Failed()) {
- LOG_ERROR(Kernel, "cannot map id=%u, target_address=0x%08X name=%s, error mapping to virtual memory",
- GetObjectId(), target_address, name.c_str());
+ LOG_ERROR(
+ Kernel,
+ "cannot map id=%u, target_address=0x%08X name=%s, error mapping to virtual memory",
+ GetObjectId(), target_address, name.c_str());
return result.Code();
}
- return target_process->vm_manager.ReprotectRange(target_address, size, ConvertPermissions(permissions));
+ return target_process->vm_manager.ReprotectRange(target_address, size,
+ ConvertPermissions(permissions));
}
ResultCode SharedMemory::Unmap(Process* target_process, VAddr address) {
- // TODO(Subv): Verify what happens if the application tries to unmap an address that is not mapped to a SharedMemory.
+ // TODO(Subv): Verify what happens if the application tries to unmap an address that is not
+ // mapped to a SharedMemory.
return target_process->vm_manager.UnmapRange(address, size);
}
VMAPermission SharedMemory::ConvertPermissions(MemoryPermission permission) {
- u32 masked_permissions = static_cast<u32>(permission) & static_cast<u32>(MemoryPermission::ReadWriteExecute);
+ u32 masked_permissions =
+ static_cast<u32>(permission) & static_cast<u32>(MemoryPermission::ReadWriteExecute);
return static_cast<VMAPermission>(masked_permissions);
};
diff --git a/src/core/hle/kernel/shared_memory.h b/src/core/hle/kernel/shared_memory.h
index 0c404a9f8..94b335ed1 100644
--- a/src/core/hle/kernel/shared_memory.h
+++ b/src/core/hle/kernel/shared_memory.h
@@ -5,9 +5,7 @@
#pragma once
#include <string>
-
#include "common/common_types.h"
-
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/process.h"
#include "core/hle/result.h"
@@ -16,15 +14,15 @@ namespace Kernel {
/// Permissions for mapped shared memory blocks
enum class MemoryPermission : u32 {
- None = 0,
- Read = (1u << 0),
- Write = (1u << 1),
- ReadWrite = (Read | Write),
- Execute = (1u << 2),
- ReadExecute = (Read | Execute),
- WriteExecute = (Write | Execute),
+ None = 0,
+ Read = (1u << 0),
+ Write = (1u << 1),
+ ReadWrite = (Read | Write),
+ Execute = (1u << 2),
+ ReadExecute = (Read | Execute),
+ WriteExecute = (Write | Execute),
ReadWriteExecute = (Read | Write | Execute),
- DontCare = (1u << 28)
+ DontCare = (1u << 28)
};
class SharedMemory final : public Object {
@@ -34,13 +32,18 @@ public:
* @param owner_process Process that created this shared memory object.
* @param size Size of the memory block. Must be page-aligned.
* @param permissions Permission restrictions applied to the process which created the block.
- * @param other_permissions Permission restrictions applied to other processes mapping the block.
+ * @param other_permissions Permission restrictions applied to other processes mapping the
+ * block.
* @param address The address from which to map the Shared Memory.
- * @param region If the address is 0, the shared memory will be allocated in this region of the linear heap.
+ * @param region If the address is 0, the shared memory will be allocated in this region of the
+ * linear heap.
* @param name Optional object name, used for debugging purposes.
*/
- static SharedPtr<SharedMemory> Create(SharedPtr<Process> owner_process, u32 size, MemoryPermission permissions,
- MemoryPermission other_permissions, VAddr address = 0, MemoryRegion region = MemoryRegion::BASE, std::string name = "Unknown");
+ static SharedPtr<SharedMemory> Create(SharedPtr<Process> owner_process, u32 size,
+ MemoryPermission permissions,
+ MemoryPermission other_permissions, VAddr address = 0,
+ MemoryRegion region = MemoryRegion::BASE,
+ std::string name = "Unknown");
/**
* Creates a shared memory object from a block of memory managed by an HLE applet.
@@ -48,17 +51,27 @@ public:
* @param offset The offset into the heap block that the SharedMemory will map.
* @param size Size of the memory block. Must be page-aligned.
* @param permissions Permission restrictions applied to the process which created the block.
- * @param other_permissions Permission restrictions applied to other processes mapping the block.
+ * @param other_permissions Permission restrictions applied to other processes mapping the
+ * block.
* @param name Optional object name, used for debugging purposes.
*/
- static SharedPtr<SharedMemory> CreateForApplet(std::shared_ptr<std::vector<u8>> heap_block, u32 offset, u32 size,
- MemoryPermission permissions, MemoryPermission other_permissions, std::string name = "Unknown Applet");
-
- std::string GetTypeName() const override { return "SharedMemory"; }
- std::string GetName() const override { return name; }
+ static SharedPtr<SharedMemory> CreateForApplet(std::shared_ptr<std::vector<u8>> heap_block,
+ u32 offset, u32 size,
+ MemoryPermission permissions,
+ MemoryPermission other_permissions,
+ std::string name = "Unknown Applet");
+
+ std::string GetTypeName() const override {
+ return "SharedMemory";
+ }
+ std::string GetName() const override {
+ return name;
+ }
static const HandleType HANDLE_TYPE = HandleType::SharedMemory;
- HandleType GetHandleType() const override { return HANDLE_TYPE; }
+ HandleType GetHandleType() const override {
+ return HANDLE_TYPE;
+ }
/**
* Converts the specified MemoryPermission into the equivalent VMAPermission.
@@ -73,7 +86,8 @@ public:
* @param permissions Memory block map permissions (specified by SVC field)
* @param other_permissions Memory block map other permissions (specified by SVC field)
*/
- ResultCode Map(Process* target_process, VAddr address, MemoryPermission permissions, MemoryPermission other_permissions);
+ ResultCode Map(Process* target_process, VAddr address, MemoryPermission permissions,
+ MemoryPermission other_permissions);
/**
* Unmaps a shared memory block from the specified address in system memory
@@ -94,7 +108,8 @@ public:
SharedPtr<Process> owner_process;
/// Address of shared memory block in the owner process if specified.
VAddr base_address;
- /// Physical address of the shared memory block in the linear heap if no address was specified during creation.
+ /// Physical address of the shared memory block in the linear heap if no address was specified
+ /// during creation.
PAddr linear_heap_phys_address;
/// Backing memory for this shared memory block.
std::shared_ptr<std::vector<u8>> backing_block;
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index f1e5cf3cb..4486a812c 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -5,23 +5,21 @@
#include <algorithm>
#include <list>
#include <vector>
-
#include "common/assert.h"
#include "common/common_types.h"
#include "common/logging/log.h"
#include "common/math_util.h"
#include "common/thread_queue_list.h"
-
#include "core/arm/arm_interface.h"
#include "core/arm/skyeye_common/armstate.h"
#include "core/core.h"
#include "core/core_timing.h"
#include "core/hle/hle.h"
#include "core/hle/kernel/kernel.h"
-#include "core/hle/kernel/process.h"
-#include "core/hle/kernel/thread.h"
#include "core/hle/kernel/memory.h"
#include "core/hle/kernel/mutex.h"
+#include "core/hle/kernel/process.h"
+#include "core/hle/kernel/thread.h"
#include "core/hle/result.h"
#include "core/memory.h"
@@ -46,7 +44,7 @@ static Kernel::HandleTable wakeup_callback_handle_table;
static std::vector<SharedPtr<Thread>> thread_list;
// Lists only ready thread ids.
-static Common::ThreadQueueList<Thread*, THREADPRIO_LOWEST+1> ready_queue;
+static Common::ThreadQueueList<Thread*, THREADPRIO_LOWEST + 1> ready_queue;
static Thread* current_thread;
@@ -103,7 +101,7 @@ void Thread::Stop() {
// Clean up thread from ready queue
// This is only needed when the thread is termintated forcefully (SVC TerminateProcess)
- if (status == THREADSTATUS_READY){
+ if (status == THREADSTATUS_READY) {
ready_queue.remove(current_priority, this);
}
@@ -119,7 +117,8 @@ void Thread::Stop() {
// Mark the TLS slot in the thread's page as free.
u32 tls_page = (tls_address - Memory::TLS_AREA_VADDR) / Memory::PAGE_SIZE;
- u32 tls_slot = ((tls_address - Memory::TLS_AREA_VADDR) % Memory::PAGE_SIZE) / Memory::TLS_ENTRY_SIZE;
+ u32 tls_slot =
+ ((tls_address - Memory::TLS_AREA_VADDR) % Memory::PAGE_SIZE) / Memory::TLS_ENTRY_SIZE;
Kernel::g_current_process->tls_slots[tls_page].reset(tls_slot);
HLE::Reschedule(__func__);
@@ -137,7 +136,7 @@ Thread* ArbitrateHighestPriorityThread(u32 address) {
if (thread == nullptr)
continue;
- if(thread->current_priority <= priority) {
+ if (thread->current_priority <= priority) {
highest_priority_thread = thread.get();
priority = thread->current_priority;
}
@@ -170,7 +169,7 @@ static void PriorityBoostStarvedThreads() {
// on hardware. However, this is almost certainly not perfect, and the real CTR OS scheduler
// should probably be reversed to verify this.
- const u64 boost_timeout = 2000000; // Boost threads that have been ready for > this long
+ const u64 boost_timeout = 2000000; // Boost threads that have been ready for > this long
u64 delta = current_ticks - thread->last_running_ticks;
@@ -193,10 +192,12 @@ static std::tuple<u32*, u32*> GetWaitSynchTimeoutParameterRegister(Thread* threa
if ((thumb_mode && thumb_inst == 0xDF24) || (!thumb_mode && inst == 0x0F000024)) {
// svc #0x24 (WaitSynchronization1)
- return std::make_tuple(&thread->context.cpu_registers[2], &thread->context.cpu_registers[3]);
+ return std::make_tuple(&thread->context.cpu_registers[2],
+ &thread->context.cpu_registers[3]);
} else if ((thumb_mode && thumb_inst == 0xDF25) || (!thumb_mode && inst == 0x0F000025)) {
// svc #0x25 (WaitSynchronizationN)
- return std::make_tuple(&thread->context.cpu_registers[0], &thread->context.cpu_registers[4]);
+ return std::make_tuple(&thread->context.cpu_registers[0],
+ &thread->context.cpu_registers[4]);
}
UNREACHABLE();
@@ -245,7 +246,8 @@ static void SwitchContext(Thread* new_thread) {
// Load context of new thread
if (new_thread) {
- DEBUG_ASSERT_MSG(new_thread->status == THREADSTATUS_READY, "Thread must be ready to become running.");
+ DEBUG_ASSERT_MSG(new_thread->status == THREADSTATUS_READY,
+ "Thread must be ready to become running.");
// Cancel any outstanding wakeup events for this thread
CoreTiming::UnscheduleEvent(ThreadWakeupEventType, new_thread->callback_handle);
@@ -263,7 +265,7 @@ static void SwitchContext(Thread* new_thread) {
new_thread->context.pc -= thumb_mode ? 2 : 4;
// Get the register for timeout parameter
- u32* timeout_low, *timeout_high;
+ u32 *timeout_low, *timeout_high;
std::tie(timeout_low, timeout_high) = GetWaitSynchTimeoutParameterRegister(new_thread);
// Update the timeout parameter
@@ -307,7 +309,7 @@ static Thread* PopNextReadyThread() {
// Otherwise just keep going with the current thread
next = thread;
}
- } else {
+ } else {
next = ready_queue.pop_first();
}
@@ -321,7 +323,8 @@ void WaitCurrentThread_Sleep() {
HLE::Reschedule(__func__);
}
-void WaitCurrentThread_WaitSynchronization(std::vector<SharedPtr<WaitObject>> wait_objects, bool wait_set_output, bool wait_all) {
+void WaitCurrentThread_WaitSynchronization(std::vector<SharedPtr<WaitObject>> wait_objects,
+ bool wait_set_output, bool wait_all) {
Thread* thread = GetCurrentThread();
thread->wait_set_output = wait_set_output;
thread->wait_all = wait_all;
@@ -352,7 +355,8 @@ static void ThreadWakeupCallback(u64 thread_handle, int cycles_late) {
if (thread->status == THREADSTATUS_WAIT_SYNCH || thread->status == THREADSTATUS_WAIT_ARB) {
thread->SetWaitSynchronizationResult(ResultCode(ErrorDescription::Timeout, ErrorModule::OS,
- ErrorSummary::StatusChanged, ErrorLevel::Info));
+ ErrorSummary::StatusChanged,
+ ErrorLevel::Info));
if (thread->wait_set_output)
thread->SetWaitSynchronizationOutput(-1);
@@ -372,25 +376,25 @@ void Thread::WakeAfterDelay(s64 nanoseconds) {
void Thread::ResumeFromWait() {
switch (status) {
- case THREADSTATUS_WAIT_SYNCH:
- case THREADSTATUS_WAIT_ARB:
- case THREADSTATUS_WAIT_SLEEP:
- break;
-
- case THREADSTATUS_READY:
- // If the thread is waiting on multiple wait objects, it might be awoken more than once
- // before actually resuming. We can ignore subsequent wakeups if the thread status has
- // already been set to THREADSTATUS_READY.
- return;
-
- case THREADSTATUS_RUNNING:
- DEBUG_ASSERT_MSG(false, "Thread with object id %u has already resumed.", GetObjectId());
- return;
- case THREADSTATUS_DEAD:
- // This should never happen, as threads must complete before being stopped.
- DEBUG_ASSERT_MSG(false, "Thread with object id %u cannot be resumed because it's DEAD.",
- GetObjectId());
- return;
+ case THREADSTATUS_WAIT_SYNCH:
+ case THREADSTATUS_WAIT_ARB:
+ case THREADSTATUS_WAIT_SLEEP:
+ break;
+
+ case THREADSTATUS_READY:
+ // If the thread is waiting on multiple wait objects, it might be awoken more than once
+ // before actually resuming. We can ignore subsequent wakeups if the thread status has
+ // already been set to THREADSTATUS_READY.
+ return;
+
+ case THREADSTATUS_RUNNING:
+ DEBUG_ASSERT_MSG(false, "Thread with object id %u has already resumed.", GetObjectId());
+ return;
+ case THREADSTATUS_DEAD:
+ // This should never happen, as threads must complete before being stopped.
+ DEBUG_ASSERT_MSG(false, "Thread with object id %u cannot be resumed because it's DEAD.",
+ GetObjectId());
+ return;
}
ready_queue.push_back(current_priority, this);
@@ -405,7 +409,8 @@ static void DebugThreadQueue() {
if (!thread) {
LOG_DEBUG(Kernel, "Current: NO CURRENT THREAD");
} else {
- LOG_DEBUG(Kernel, "0x%02X %u (current)", thread->current_priority, GetCurrentThread()->GetObjectId());
+ LOG_DEBUG(Kernel, "0x%02X %u (current)", thread->current_priority,
+ GetCurrentThread()->GetObjectId());
}
for (auto& t : thread_list) {
@@ -448,7 +453,8 @@ std::tuple<u32, u32, bool> GetFreeThreadLocalSlot(std::vector<std::bitset<8>>& t
* @param entry_point Address of entry point for execution
* @param arg User argument for thread
*/
-static void ResetThreadContext(Core::ThreadContext& context, u32 stack_top, u32 entry_point, u32 arg) {
+static void ResetThreadContext(Core::ThreadContext& context, u32 stack_top, u32 entry_point,
+ u32 arg) {
memset(&context, 0, sizeof(Core::ThreadContext));
context.cpu_registers[0] = arg;
@@ -458,11 +464,11 @@ static void ResetThreadContext(Core::ThreadContext& context, u32 stack_top, u32
}
ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, s32 priority,
- u32 arg, s32 processor_id, VAddr stack_top) {
+ u32 arg, s32 processor_id, VAddr stack_top) {
if (priority < THREADPRIO_HIGHEST || priority > THREADPRIO_LOWEST) {
s32 new_priority = MathUtil::Clamp<s32>(priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST);
- LOG_WARNING(Kernel_SVC, "(name=%s): invalid priority=%d, clamping to %d",
- name.c_str(), priority, new_priority);
+ LOG_WARNING(Kernel_SVC, "(name=%s): invalid priority=%d, clamping to %d", name.c_str(),
+ priority, new_priority);
// TODO(bunnei): Clamping to a valid priority is not necessarily correct behavior... Confirm
// validity of this
priority = new_priority;
@@ -472,7 +478,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
LOG_ERROR(Kernel_SVC, "(name=%s): invalid entry %08x", name.c_str(), entry_point);
// TODO: Verify error
return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel,
- ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
+ ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
}
SharedPtr<Thread> thread(new Thread);
@@ -511,8 +517,10 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
auto& linheap_memory = memory_region->linear_heap_memory;
if (linheap_memory->size() + Memory::PAGE_SIZE > memory_region->size) {
- LOG_ERROR(Kernel_SVC, "Not enough space in region to allocate a new TLS page for thread");
- return ResultCode(ErrorDescription::OutOfMemory, ErrorModule::Kernel, ErrorSummary::OutOfResource, ErrorLevel::Permanent);
+ LOG_ERROR(Kernel_SVC,
+ "Not enough space in region to allocate a new TLS page for thread");
+ return ResultCode(ErrorDescription::OutOfMemory, ErrorModule::Kernel,
+ ErrorSummary::OutOfResource, ErrorLevel::Permanent);
}
u32 offset = linheap_memory->size();
@@ -537,7 +545,8 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
// Mark the slot as used
tls_slots[available_page].set(available_slot);
- thread->tls_address = Memory::TLS_AREA_VADDR + available_page * Memory::PAGE_SIZE + available_slot * Memory::TLS_ENTRY_SIZE;
+ thread->tls_address = Memory::TLS_AREA_VADDR + available_page * Memory::PAGE_SIZE +
+ available_slot * Memory::TLS_ENTRY_SIZE;
// TODO(peachum): move to ScheduleThread() when scheduler is added so selected core is used
// to initialize the context
@@ -551,10 +560,12 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
return MakeResult<SharedPtr<Thread>>(std::move(thread));
}
-// TODO(peachum): Remove this. Range checking should be done, and an appropriate error should be returned.
+// TODO(peachum): Remove this. Range checking should be done, and an appropriate error should be
+// returned.
static void ClampPriority(const Thread* thread, s32* priority) {
if (*priority < THREADPRIO_HIGHEST || *priority > THREADPRIO_LOWEST) {
- DEBUG_ASSERT_MSG(false, "Application passed an out of range priority. An error should be returned.");
+ DEBUG_ASSERT_MSG(
+ false, "Application passed an out of range priority. An error should be returned.");
s32 new_priority = MathUtil::Clamp<s32>(*priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST);
LOG_WARNING(Kernel_SVC, "(name=%s): invalid priority=%d, clamping to %d",
@@ -586,12 +597,13 @@ SharedPtr<Thread> SetupMainThread(u32 entry_point, s32 priority) {
DEBUG_ASSERT(!GetCurrentThread());
// Initialize new "main" thread
- auto thread_res = Thread::Create("main", entry_point, priority, 0,
- THREADPROCESSORID_0, Memory::HEAP_VADDR_END);
+ auto thread_res = Thread::Create("main", entry_point, priority, 0, THREADPROCESSORID_0,
+ Memory::HEAP_VADDR_END);
SharedPtr<Thread> thread = thread_res.MoveFrom();
- thread->context.fpscr = FPSCR_DEFAULT_NAN | FPSCR_FLUSH_TO_ZERO | FPSCR_ROUND_TOZERO | FPSCR_IXC; // 0x03C00010
+ thread->context.fpscr =
+ FPSCR_DEFAULT_NAN | FPSCR_FLUSH_TO_ZERO | FPSCR_ROUND_TOZERO | FPSCR_IXC; // 0x03C00010
// Run new "main" thread
SwitchContext(thread.get());
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index deab5d5a6..f63131716 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -6,40 +6,36 @@
#include <string>
#include <vector>
-
#include <boost/container/flat_set.hpp>
-
#include "common/common_types.h"
-
#include "core/core.h"
-
#include "core/hle/hle.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/result.h"
-enum ThreadPriority : s32{
- THREADPRIO_HIGHEST = 0, ///< Highest thread priority
- THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps
- THREADPRIO_DEFAULT = 48, ///< Default thread priority for userland apps
- THREADPRIO_LOWEST = 63, ///< Lowest thread priority
+enum ThreadPriority : s32 {
+ THREADPRIO_HIGHEST = 0, ///< Highest thread priority
+ THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps
+ THREADPRIO_DEFAULT = 48, ///< Default thread priority for userland apps
+ THREADPRIO_LOWEST = 63, ///< Lowest thread priority
};
enum ThreadProcessorId : s32 {
- THREADPROCESSORID_DEFAULT = -2, ///< Run thread on default core specified by exheader
- THREADPROCESSORID_ALL = -1, ///< Run thread on either core
- THREADPROCESSORID_0 = 0, ///< Run thread on core 0 (AppCore)
- THREADPROCESSORID_1 = 1, ///< Run thread on core 1 (SysCore)
- THREADPROCESSORID_MAX = 2, ///< Processor ID must be less than this
+ THREADPROCESSORID_DEFAULT = -2, ///< Run thread on default core specified by exheader
+ THREADPROCESSORID_ALL = -1, ///< Run thread on either core
+ THREADPROCESSORID_0 = 0, ///< Run thread on core 0 (AppCore)
+ THREADPROCESSORID_1 = 1, ///< Run thread on core 1 (SysCore)
+ THREADPROCESSORID_MAX = 2, ///< Processor ID must be less than this
};
enum ThreadStatus {
- THREADSTATUS_RUNNING, ///< Currently running
- THREADSTATUS_READY, ///< Ready to run
- THREADSTATUS_WAIT_ARB, ///< Waiting on an address arbiter
- THREADSTATUS_WAIT_SLEEP, ///< Waiting due to a SleepThread SVC
- THREADSTATUS_WAIT_SYNCH, ///< Waiting due to a WaitSynchronization SVC
- THREADSTATUS_DORMANT, ///< Created but not yet made ready
- THREADSTATUS_DEAD ///< Run to completion, or forcefully terminated
+ THREADSTATUS_RUNNING, ///< Currently running
+ THREADSTATUS_READY, ///< Ready to run
+ THREADSTATUS_WAIT_ARB, ///< Waiting on an address arbiter
+ THREADSTATUS_WAIT_SLEEP, ///< Waiting due to a SleepThread SVC
+ THREADSTATUS_WAIT_SYNCH, ///< Waiting due to a WaitSynchronization SVC
+ THREADSTATUS_DORMANT, ///< Created but not yet made ready
+ THREADSTATUS_DEAD ///< Run to completion, or forcefully terminated
};
namespace Kernel {
@@ -60,13 +56,19 @@ public:
* @return A shared pointer to the newly created thread
*/
static ResultVal<SharedPtr<Thread>> Create(std::string name, VAddr entry_point, s32 priority,
- u32 arg, s32 processor_id, VAddr stack_top);
+ u32 arg, s32 processor_id, VAddr stack_top);
- std::string GetName() const override { return name; }
- std::string GetTypeName() const override { return "Thread"; }
+ std::string GetName() const override {
+ return name;
+ }
+ std::string GetTypeName() const override {
+ return "Thread";
+ }
static const HandleType HANDLE_TYPE = HandleType::Thread;
- HandleType GetHandleType() const override { return HANDLE_TYPE; }
+ HandleType GetHandleType() const override {
+ return HANDLE_TYPE;
+ }
bool ShouldWait() override;
void Acquire() override;
@@ -75,7 +77,9 @@ public:
* Gets the thread's current priority
* @return The current thread's priority
*/
- s32 GetPriority() const { return current_priority; }
+ s32 GetPriority() const {
+ return current_priority;
+ }
/**
* Sets the thread's current priority
@@ -93,7 +97,9 @@ public:
* Gets the thread's thread ID
* @return The thread's ID
*/
- u32 GetThreadId() const { return thread_id; }
+ u32 GetThreadId() const {
+ return thread_id;
+ }
/**
* Resumes a thread from waiting
@@ -127,7 +133,9 @@ public:
* Returns the Thread Local Storage address of the current thread
* @returns VAddr of the thread's TLS
*/
- VAddr GetTLSAddress() const { return tls_address; }
+ VAddr GetTLSAddress() const {
+ return tls_address;
+ }
Core::ThreadContext context;
@@ -137,8 +145,8 @@ public:
u32 entry_point;
u32 stack_top;
- s32 nominal_priority; ///< Nominal thread priority, as set by the emulated application
- s32 current_priority; ///< Current thread priority, can be temporarily changed
+ s32 nominal_priority; ///< Nominal thread priority, as set by the emulated application
+ s32 current_priority; ///< Current thread priority, can be temporarily changed
u64 last_running_ticks; ///< CPU tick when thread was last running
@@ -151,11 +159,11 @@ public:
/// Mutexes currently held by this thread, which will be released when it exits.
boost::container::flat_set<SharedPtr<Mutex>> held_mutexes;
- SharedPtr<Process> owner_process; ///< Process that owns this thread
+ SharedPtr<Process> owner_process; ///< Process that owns this thread
std::vector<SharedPtr<WaitObject>> wait_objects; ///< Objects that the thread is waiting on
- VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address
- bool wait_all; ///< True if the thread is waiting on all objects before resuming
- bool wait_set_output; ///< True if the output parameter should be set on thread wakeup
+ VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address
+ bool wait_all; ///< True if the thread is waiting on all objects before resuming
+ bool wait_set_output; ///< True if the output parameter should be set on thread wakeup
std::string name;
@@ -205,10 +213,12 @@ void WaitCurrentThread_Sleep();
/**
* Waits the current thread from a WaitSynchronization call
* @param wait_objects Kernel objects that we are waiting on
- * @param wait_set_output If true, set the output parameter on thread wakeup (for WaitSynchronizationN only)
+ * @param wait_set_output If true, set the output parameter on thread wakeup (for
+ * WaitSynchronizationN only)
* @param wait_all If true, wait on all objects before resuming (for WaitSynchronizationN only)
*/
-void WaitCurrentThread_WaitSynchronization(std::vector<SharedPtr<WaitObject>> wait_objects, bool wait_set_output, bool wait_all);
+void WaitCurrentThread_WaitSynchronization(std::vector<SharedPtr<WaitObject>> wait_objects,
+ bool wait_set_output, bool wait_all);
/**
* Waits the current thread from an ArbitrateAddress call
diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp
index b8daaeede..a9f98223c 100644
--- a/src/core/hle/kernel/timer.cpp
+++ b/src/core/hle/kernel/timer.cpp
@@ -3,14 +3,12 @@
// Refer to the license.txt file included.
#include <cinttypes>
-
#include "common/assert.h"
#include "common/logging/log.h"
-
#include "core/core_timing.h"
#include "core/hle/kernel/kernel.h"
-#include "core/hle/kernel/timer.h"
#include "core/hle/kernel/thread.h"
+#include "core/hle/kernel/timer.h"
namespace Kernel {
@@ -41,7 +39,7 @@ bool Timer::ShouldWait() {
}
void Timer::Acquire() {
- ASSERT_MSG( !ShouldWait(), "object unavailable!");
+ ASSERT_MSG(!ShouldWait(), "object unavailable!");
if (reset_type == ResetType::OneShot)
signaled = false;
@@ -55,8 +53,8 @@ void Timer::Set(s64 initial, s64 interval) {
interval_delay = interval;
u64 initial_microseconds = initial / 1000;
- CoreTiming::ScheduleEvent(usToCycles(initial_microseconds),
- timer_callback_event_type, callback_handle);
+ CoreTiming::ScheduleEvent(usToCycles(initial_microseconds), timer_callback_event_type,
+ callback_handle);
HLE::Reschedule(__func__);
}
@@ -73,7 +71,8 @@ void Timer::Clear() {
/// The timer callback event, called when a timer is fired
static void TimerCallback(u64 timer_handle, int cycles_late) {
- SharedPtr<Timer> timer = timer_callback_handle_table.Get<Timer>(static_cast<Handle>(timer_handle));
+ SharedPtr<Timer> timer =
+ timer_callback_handle_table.Get<Timer>(static_cast<Handle>(timer_handle));
if (timer == nullptr) {
LOG_CRITICAL(Kernel, "Callback fired for invalid timer %08" PRIx64, timer_handle);
@@ -91,7 +90,7 @@ static void TimerCallback(u64 timer_handle, int cycles_late) {
// Reschedule the timer with the interval delay
u64 interval_microseconds = timer->interval_delay / 1000;
CoreTiming::ScheduleEvent(usToCycles(interval_microseconds) - cycles_late,
- timer_callback_event_type, timer_handle);
+ timer_callback_event_type, timer_handle);
}
}
@@ -100,7 +99,6 @@ void TimersInit() {
timer_callback_event_type = CoreTiming::RegisterEvent("TimerCallback", TimerCallback);
}
-void TimersShutdown() {
-}
+void TimersShutdown() {}
} // namespace
diff --git a/src/core/hle/kernel/timer.h b/src/core/hle/kernel/timer.h
index b1db60e8f..59a77aad3 100644
--- a/src/core/hle/kernel/timer.h
+++ b/src/core/hle/kernel/timer.h
@@ -5,7 +5,6 @@
#pragma once
#include "common/common_types.h"
-
#include "core/hle/kernel/event.h"
#include "core/hle/kernel/kernel.h"
@@ -21,19 +20,25 @@ public:
*/
static SharedPtr<Timer> Create(ResetType reset_type, std::string name = "Unknown");
- std::string GetTypeName() const override { return "Timer"; }
- std::string GetName() const override { return name; }
+ std::string GetTypeName() const override {
+ return "Timer";
+ }
+ std::string GetName() const override {
+ return name;
+ }
static const HandleType HANDLE_TYPE = HandleType::Timer;
- HandleType GetHandleType() const override { return HANDLE_TYPE; }
+ HandleType GetHandleType() const override {
+ return HANDLE_TYPE;
+ }
- ResetType reset_type; ///< The ResetType of this timer
+ ResetType reset_type; ///< The ResetType of this timer
- bool signaled; ///< Whether the timer has been signaled or not
- std::string name; ///< Name of timer (optional)
+ bool signaled; ///< Whether the timer has been signaled or not
+ std::string name; ///< Name of timer (optional)
- u64 initial_delay; ///< The delay until the timer fires for the first time
- u64 interval_delay; ///< The delay until the timer fires after the first time
+ u64 initial_delay; ///< The delay until the timer fires for the first time
+ u64 interval_delay; ///< The delay until the timer fires after the first time
bool ShouldWait() override;
void Acquire() override;
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp
index 066146cff..6dd24f846 100644
--- a/src/core/hle/kernel/vm_manager.cpp
+++ b/src/core/hle/kernel/vm_manager.cpp
@@ -3,9 +3,7 @@
// Refer to the license.txt file included.
#include <iterator>
-
#include "common/assert.h"
-
#include "core/hle/kernel/vm_manager.h"
#include "core/memory.h"
#include "core/memory_setup.h"
@@ -15,8 +13,8 @@ namespace Kernel {
static const char* GetMemoryStateName(MemoryState state) {
static const char* names[] = {
- "Free", "Reserved", "IO", "Static", "Code", "Private", "Shared", "Continuous", "Aliased",
- "Alias", "AliasCode", "Locked",
+ "Free", "Reserved", "IO", "Static", "Code", "Private",
+ "Shared", "Continuous", "Aliased", "Alias", "AliasCode", "Locked",
};
return names[(int)state];
@@ -24,13 +22,12 @@ static const char* GetMemoryStateName(MemoryState state) {
bool VirtualMemoryArea::CanBeMergedWith(const VirtualMemoryArea& next) const {
ASSERT(base + size == next.base);
- if (permissions != next.permissions ||
- meminfo_state != next.meminfo_state ||
- type != next.type) {
+ if (permissions != next.permissions || meminfo_state != next.meminfo_state ||
+ type != next.type) {
return false;
}
if (type == VMAType::AllocatedMemoryBlock &&
- (backing_block != next.backing_block || offset + size != next.offset)) {
+ (backing_block != next.backing_block || offset + size != next.offset)) {
return false;
}
if (type == VMAType::BackingMemory && backing_memory + size != next.backing_memory) {
@@ -70,7 +67,9 @@ VMManager::VMAHandle VMManager::FindVMA(VAddr target) const {
}
ResultVal<VMManager::VMAHandle> VMManager::MapMemoryBlock(VAddr target,
- std::shared_ptr<std::vector<u8>> block, size_t offset, u32 size, MemoryState state) {
+ std::shared_ptr<std::vector<u8>> block,
+ size_t offset, u32 size,
+ MemoryState state) {
ASSERT(block != nullptr);
ASSERT(offset + size <= block->size());
@@ -89,7 +88,8 @@ ResultVal<VMManager::VMAHandle> VMManager::MapMemoryBlock(VAddr target,
return MakeResult<VMAHandle>(MergeAdjacent(vma_handle));
}
-ResultVal<VMManager::VMAHandle> VMManager::MapBackingMemory(VAddr target, u8 * memory, u32 size, MemoryState state) {
+ResultVal<VMManager::VMAHandle> VMManager::MapBackingMemory(VAddr target, u8* memory, u32 size,
+ MemoryState state) {
ASSERT(memory != nullptr);
// This is the appropriately sized VMA that will turn into our allocation.
@@ -106,7 +106,9 @@ ResultVal<VMManager::VMAHandle> VMManager::MapBackingMemory(VAddr target, u8 * m
return MakeResult<VMAHandle>(MergeAdjacent(vma_handle));
}
-ResultVal<VMManager::VMAHandle> VMManager::MapMMIO(VAddr target, PAddr paddr, u32 size, MemoryState state, Memory::MMIORegionPointer mmio_handler) {
+ResultVal<VMManager::VMAHandle> VMManager::MapMMIO(VAddr target, PAddr paddr, u32 size,
+ MemoryState state,
+ Memory::MMIORegionPointer mmio_handler) {
// This is the appropriately sized VMA that will turn into our allocation.
CASCADE_RESULT(VMAIter vma_handle, CarveVMA(target, size));
VirtualMemoryArea& final_vma = vma_handle->second;
@@ -191,15 +193,16 @@ void VMManager::RefreshMemoryBlockMappings(const std::vector<u8>* block) {
void VMManager::LogLayout(Log::Level log_level) const {
for (const auto& p : vma_map) {
const VirtualMemoryArea& vma = p.second;
- LOG_GENERIC(Log::Class::Kernel, log_level, "%08X - %08X size: %8X %c%c%c %s",
- vma.base, vma.base + vma.size, vma.size,
- (u8)vma.permissions & (u8)VMAPermission::Read ? 'R' : '-',
- (u8)vma.permissions & (u8)VMAPermission::Write ? 'W' : '-',
- (u8)vma.permissions & (u8)VMAPermission::Execute ? 'X' : '-', GetMemoryStateName(vma.meminfo_state));
+ LOG_GENERIC(Log::Class::Kernel, log_level, "%08X - %08X size: %8X %c%c%c %s", vma.base,
+ vma.base + vma.size, vma.size,
+ (u8)vma.permissions & (u8)VMAPermission::Read ? 'R' : '-',
+ (u8)vma.permissions & (u8)VMAPermission::Write ? 'W' : '-',
+ (u8)vma.permissions & (u8)VMAPermission::Execute ? 'X' : '-',
+ GetMemoryStateName(vma.meminfo_state));
}
}
-VMManager::VMAIter VMManager::StripIterConstness(const VMAHandle & iter) {
+VMManager::VMAIter VMManager::StripIterConstness(const VMAHandle& iter) {
// This uses a neat C++ trick to convert a const_iterator to a regular iterator, given
// non-const access to its container.
return vma_map.erase(iter, iter); // Erases an empty range of elements
@@ -337,5 +340,4 @@ void VMManager::UpdatePageTableForVMA(const VirtualMemoryArea& vma) {
break;
}
}
-
}
diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h
index 91d40655b..9055664b2 100644
--- a/src/core/hle/kernel/vm_manager.h
+++ b/src/core/hle/kernel/vm_manager.h
@@ -7,21 +7,19 @@
#include <map>
#include <memory>
#include <vector>
-
#include "common/common_types.h"
-
#include "core/hle/result.h"
#include "core/mmio.h"
namespace Kernel {
-const ResultCode ERR_INVALID_ADDRESS{ // 0xE0E01BF5
- ErrorDescription::InvalidAddress, ErrorModule::OS,
- ErrorSummary::InvalidArgument, ErrorLevel::Usage};
+const ResultCode ERR_INVALID_ADDRESS{// 0xE0E01BF5
+ ErrorDescription::InvalidAddress, ErrorModule::OS,
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage};
-const ResultCode ERR_INVALID_ADDRESS_STATE{ // 0xE0A01BF5
- ErrorDescription::InvalidAddress, ErrorModule::OS,
- ErrorSummary::InvalidState, ErrorLevel::Usage};
+const ResultCode ERR_INVALID_ADDRESS_STATE{// 0xE0A01BF5
+ ErrorDescription::InvalidAddress, ErrorModule::OS,
+ ErrorSummary::InvalidState, ErrorLevel::Usage};
enum class VMAType : u8 {
/// VMA represents an unmapped region of the address space.
@@ -115,7 +113,8 @@ class VMManager final {
// TODO(yuriks): Make page tables switchable to support multiple VMManagers
public:
/**
- * The maximum amount of address space managed by the kernel. Addresses above this are never used.
+ * The maximum amount of address space managed by the kernel. Addresses above this are never
+ * used.
* @note This is the limit used by the New 3DS kernel. Old 3DS used 0x20000000.
*/
static const u32 MAX_ADDRESS = 0x40000000;
@@ -151,7 +150,7 @@ public:
* @param state MemoryState tag to attach to the VMA.
*/
ResultVal<VMAHandle> MapMemoryBlock(VAddr target, std::shared_ptr<std::vector<u8>> block,
- size_t offset, u32 size, MemoryState state);
+ size_t offset, u32 size, MemoryState state);
/**
* Maps an unmanaged host memory pointer at a given address.
@@ -172,7 +171,8 @@ public:
* @param state MemoryState tag to attach to the VMA.
* @param mmio_handler The handler that will implement read and write for this MMIO region.
*/
- ResultVal<VMAHandle> MapMMIO(VAddr target, PAddr paddr, u32 size, MemoryState state, Memory::MMIORegionPointer mmio_handler);
+ ResultVal<VMAHandle> MapMMIO(VAddr target, PAddr paddr, u32 size, MemoryState state,
+ Memory::MMIORegionPointer mmio_handler);
/// Unmaps a range of addresses, splitting VMAs as necessary.
ResultCode UnmapRange(VAddr target, u32 size);
@@ -228,5 +228,4 @@ private:
/// Updates the pages corresponding to this VMA so they match the VMA's attributes.
void UpdatePageTableForVMA(const VirtualMemoryArea& vma);
};
-
}
diff --git a/src/core/hle/result.h b/src/core/hle/result.h
index 268a8dad2..7f8d8e00d 100644
--- a/src/core/hle/result.h
+++ b/src/core/hle/result.h
@@ -6,7 +6,6 @@
#include <new>
#include <utility>
-
#include "common/assert.h"
#include "common/bit_field.h"
#include "common/common_funcs.h"
@@ -26,7 +25,8 @@ enum class ErrorDescription : u32 {
FS_InvalidOpenFlags = 230,
FS_NotAFile = 250,
FS_NotFormatted = 340, ///< This is used by the FS service when creating a SaveData archive
- OutofRangeOrMisalignedAddress = 513, // TODO(purpasmart): Check if this name fits its actual usage
+ OutofRangeOrMisalignedAddress =
+ 513, // TODO(purpasmart): Check if this name fits its actual usage
GPU_FirstInitialization = 519,
FS_InvalidPath = 702,
InvalidSection = 1000,
@@ -168,15 +168,15 @@ enum class ErrorSummary : u32 {
Success = 0,
NothingHappened = 1,
WouldBlock = 2,
- OutOfResource = 3, ///< There are no more kernel resources (memory, table slots) to
- ///< execute the operation.
- NotFound = 4, ///< A file or resource was not found.
+ OutOfResource = 3, ///< There are no more kernel resources (memory, table slots) to
+ ///< execute the operation.
+ NotFound = 4, ///< A file or resource was not found.
InvalidState = 5,
- NotSupported = 6, ///< The operation is not supported or not implemented.
- InvalidArgument = 7, ///< Returned when a passed argument is invalid in the current runtime
- ///< context. (Invalid handle, out-of-bounds pointer or size, etc.)
- WrongArgument = 8, ///< Returned when a passed argument is in an incorrect format for use
- ///< with the function. (E.g. Invalid enum value)
+ NotSupported = 6, ///< The operation is not supported or not implemented.
+ InvalidArgument = 7, ///< Returned when a passed argument is invalid in the current runtime
+ ///< context. (Invalid handle, out-of-bounds pointer or size, etc.)
+ WrongArgument = 8, ///< Returned when a passed argument is in an incorrect format for use
+ ///< with the function. (E.g. Invalid enum value)
Canceled = 9,
StatusChanged = 10,
Internal = 11,
@@ -208,19 +208,24 @@ union ResultCode {
BitField<21, 6, ErrorSummary> summary;
BitField<27, 5, ErrorLevel> level;
- // The last bit of `level` is checked by apps and the kernel to determine if a result code is an error
+ // The last bit of `level` is checked by apps and the kernel to determine if a result code is an
+ // error
BitField<31, 1, u32> is_error;
explicit ResultCode(u32 raw) : raw(raw) {}
- ResultCode(ErrorDescription description_, ErrorModule module_,
- ErrorSummary summary_, ErrorLevel level_) : raw(0) {
+ ResultCode(ErrorDescription description_, ErrorModule module_, ErrorSummary summary_,
+ ErrorLevel level_)
+ : raw(0) {
description.Assign(description_);
module.Assign(module_);
summary.Assign(summary_);
level.Assign(level_);
}
- ResultCode& operator=(const ResultCode& o) { raw = o.raw; return *this; }
+ ResultCode& operator=(const ResultCode& o) {
+ raw = o.raw;
+ return *this;
+ }
bool IsSuccess() const {
return is_error == 0;
@@ -246,8 +251,8 @@ const ResultCode RESULT_SUCCESS(0);
/// Might be returned instead of a dummy success for unimplemented APIs.
inline ResultCode UnimplementedFunction(ErrorModule module) {
- return ResultCode(ErrorDescription::NotImplemented, module,
- ErrorSummary::NotSupported, ErrorLevel::Permanent);
+ return ResultCode(ErrorDescription::NotImplemented, module, ErrorSummary::NotSupported,
+ ErrorLevel::Permanent);
}
/**
@@ -285,10 +290,9 @@ inline ResultCode UnimplementedFunction(ErrorModule module) {
template <typename T>
class ResultVal {
public:
- /// Constructs an empty `ResultVal` with the given error code. The code must not be a success code.
- ResultVal(ResultCode error_code = ResultCode(-1))
- : result_code(error_code)
- {
+ /// Constructs an empty `ResultVal` with the given error code. The code must not be a success
+ /// code.
+ ResultVal(ResultCode error_code = ResultCode(-1)) : result_code(error_code) {
ASSERT(error_code.IsError());
}
@@ -303,17 +307,13 @@ public:
return result;
}
- ResultVal(const ResultVal& o)
- : result_code(o.result_code)
- {
+ ResultVal(const ResultVal& o) : result_code(o.result_code) {
if (!o.empty()) {
new (&object) T(o.object);
}
}
- ResultVal(ResultVal&& o)
- : result_code(o.result_code)
- {
+ ResultVal(ResultVal&& o) : result_code(o.result_code) {
if (!o.empty()) {
new (&object) T(std::move(o.object));
}
@@ -357,19 +357,35 @@ public:
}
/// Returns true if the `ResultVal` contains an error code and no value.
- bool empty() const { return result_code.IsError(); }
+ bool empty() const {
+ return result_code.IsError();
+ }
/// Returns true if the `ResultVal` contains a return value.
- bool Succeeded() const { return result_code.IsSuccess(); }
+ bool Succeeded() const {
+ return result_code.IsSuccess();
+ }
/// Returns true if the `ResultVal` contains an error code and no value.
- bool Failed() const { return empty(); }
+ bool Failed() const {
+ return empty();
+ }
- ResultCode Code() const { return result_code; }
+ ResultCode Code() const {
+ return result_code;
+ }
- const T& operator* () const { return object; }
- T& operator* () { return object; }
- const T* operator->() const { return &object; }
- T* operator->() { return &object; }
+ const T& operator*() const {
+ return object;
+ }
+ T& operator*() {
+ return object;
+ }
+ const T* operator->() const {
+ return &object;
+ }
+ T* operator->() {
+ return &object;
+ }
/// Returns the value contained in this `ResultVal`, or the supplied default if it is missing.
template <typename U>
@@ -390,7 +406,9 @@ public:
private:
// A union is used to allocate the storage for the value, while allowing us to construct and
// destruct it at will.
- union { T object; };
+ union {
+ T object;
+ };
ResultCode result_code;
};
@@ -409,8 +427,8 @@ ResultVal<T> MakeResult(Args&&... args) {
* variable declaration. If it fails the return code is returned from the current function. Thus it
* can be used to cascade errors out, achieving something akin to exception handling.
*/
-#define CASCADE_RESULT(target, source) \
- auto CONCAT2(check_result_L, __LINE__) = source; \
- if (CONCAT2(check_result_L, __LINE__).Failed()) \
- return CONCAT2(check_result_L, __LINE__).Code(); \
- target = std::move(*CONCAT2(check_result_L, __LINE__))
+#define CASCADE_RESULT(target, source) \
+ auto CONCAT2(check_result_L, __LINE__) = source; \
+ if (CONCAT2(check_result_L, __LINE__).Failed()) \
+ return CONCAT2(check_result_L, __LINE__).Code(); \
+ target = std::move(*CONCAT2(check_result_L, __LINE__))
diff --git a/src/core/hle/service/ac_u.cpp b/src/core/hle/service/ac_u.cpp
index 5241dd3e7..12d94f37a 100644
--- a/src/core/hle/service/ac_u.cpp
+++ b/src/core/hle/service/ac_u.cpp
@@ -3,7 +3,6 @@
// Refer to the license.txt file included.
#include "common/logging/log.h"
-
#include "core/hle/kernel/event.h"
#include "core/hle/service/ac_u.h"
@@ -47,7 +46,7 @@ static void GetWifiStatus(Service::Interface* self) {
// it returns a valid result without implementing full functionality.
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- cmd_buff[2] = 0; // Connection type set to none
+ cmd_buff[2] = 0; // Connection type set to none
LOG_WARNING(Service_AC, "(STUBBED) called");
}
@@ -62,29 +61,29 @@ static void IsConnected(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- cmd_buff[2] = false; // Not connected to ac:u service
+ cmd_buff[2] = false; // Not connected to ac:u service
LOG_WARNING(Service_AC, "(STUBBED) called");
}
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010000, nullptr, "CreateDefaultConfig"},
- {0x00040006, nullptr, "ConnectAsync"},
- {0x00050002, nullptr, "GetConnectResult"},
- {0x00080004, CloseAsync, "CloseAsync"},
- {0x00090002, nullptr, "GetCloseResult"},
- {0x000A0000, nullptr, "GetLastErrorCode"},
- {0x000D0000, GetWifiStatus, "GetWifiStatus"},
- {0x000E0042, nullptr, "GetCurrentAPInfo"},
- {0x00100042, nullptr, "GetCurrentNZoneInfo"},
- {0x00110042, nullptr, "GetNZoneApNumService"},
- {0x00240042, nullptr, "AddDenyApType"},
- {0x00270002, nullptr, "GetInfraPriority"},
- {0x002D0082, nullptr, "SetRequestEulaVersion"},
- {0x00300004, nullptr, "RegisterDisconnectEvent"},
- {0x003C0042, nullptr, "GetAPSSIDList"},
- {0x003E0042, IsConnected, "IsConnected"},
- {0x00400042, nullptr, "SetClientVersion"},
+ {0x00010000, nullptr, "CreateDefaultConfig"},
+ {0x00040006, nullptr, "ConnectAsync"},
+ {0x00050002, nullptr, "GetConnectResult"},
+ {0x00080004, CloseAsync, "CloseAsync"},
+ {0x00090002, nullptr, "GetCloseResult"},
+ {0x000A0000, nullptr, "GetLastErrorCode"},
+ {0x000D0000, GetWifiStatus, "GetWifiStatus"},
+ {0x000E0042, nullptr, "GetCurrentAPInfo"},
+ {0x00100042, nullptr, "GetCurrentNZoneInfo"},
+ {0x00110042, nullptr, "GetNZoneApNumService"},
+ {0x00240042, nullptr, "AddDenyApType"},
+ {0x00270002, nullptr, "GetInfraPriority"},
+ {0x002D0082, nullptr, "SetRequestEulaVersion"},
+ {0x00300004, nullptr, "RegisterDisconnectEvent"},
+ {0x003C0042, nullptr, "GetAPSSIDList"},
+ {0x003E0042, IsConnected, "IsConnected"},
+ {0x00400042, nullptr, "SetClientVersion"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index 3f71e7f2b..f7a990d69 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -3,22 +3,20 @@
// Refer to the license.txt file included.
#include <cinttypes>
-
#include "common/logging/log.h"
-
-#include "core/hle/service/service.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/am_app.h"
#include "core/hle/service/am/am_net.h"
#include "core/hle/service/am/am_sys.h"
#include "core/hle/service/am/am_u.h"
+#include "core/hle/service/service.h"
namespace Service {
namespace AM {
-static std::array<u32, 3> am_content_count = { 0, 0, 0 };
-static std::array<u32, 3> am_titles_count = { 0, 0, 0 };
-static std::array<u32, 3> am_titles_list_count = { 0, 0, 0 };
+static std::array<u32, 3> am_content_count = {0, 0, 0};
+static std::array<u32, 3> am_titles_count = {0, 0, 0};
+static std::array<u32, 3> am_titles_list_count = {0, 0, 0};
static u32 am_ticket_count = 0;
static u32 am_ticket_list_count = 0;
@@ -29,7 +27,8 @@ void GetTitleCount(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = am_titles_count[media_type];
- LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, title_count=0x%08x", media_type, am_titles_count[media_type]);
+ LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, title_count=0x%08x", media_type,
+ am_titles_count[media_type]);
}
void FindContentInfos(Service::Interface* self) {
@@ -43,8 +42,10 @@ void FindContentInfos(Service::Interface* self) {
am_content_count[media_type] = cmd_buff[4];
cmd_buff[1] = RESULT_SUCCESS.raw;
- LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, title_id=0x%016llx, content_cound=%u, content_ids_pointer=0x%08x, content_info_pointer=0x%08x",
- media_type, title_id, am_content_count[media_type], content_ids_pointer, content_info_pointer);
+ LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, title_id=0x%016llx, content_cound=%u, "
+ "content_ids_pointer=0x%08x, content_info_pointer=0x%08x",
+ media_type, title_id, am_content_count[media_type], content_ids_pointer,
+ content_info_pointer);
}
void ListContentInfos(Service::Interface* self) {
@@ -59,8 +60,10 @@ void ListContentInfos(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = am_content_count[media_type];
- LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, content_count=%u, title_id=0x%016" PRIx64 ", start_index=0x%08x, content_info_pointer=0x%08X",
- media_type, am_content_count[media_type], title_id, start_index, content_info_pointer);
+ LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, content_count=%u, title_id=0x%016" PRIx64
+ ", start_index=0x%08x, content_info_pointer=0x%08X",
+ media_type, am_content_count[media_type], title_id, start_index,
+ content_info_pointer);
}
void DeleteContents(Service::Interface* self) {
@@ -73,8 +76,9 @@ void DeleteContents(Service::Interface* self) {
am_content_count[media_type] = cmd_buff[4];
cmd_buff[1] = RESULT_SUCCESS.raw;
- LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, title_id=0x%016" PRIx64 ", content_count=%u, content_ids_pointer=0x%08x",
- media_type, title_id, am_content_count[media_type], content_ids_pointer);
+ LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, title_id=0x%016" PRIx64
+ ", content_count=%u, content_ids_pointer=0x%08x",
+ media_type, title_id, am_content_count[media_type], content_ids_pointer);
}
void GetTitleList(Service::Interface* self) {
@@ -87,8 +91,10 @@ void GetTitleList(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = am_titles_list_count[media_type];
- LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, titles_list_count=0x%08X, title_ids_output_pointer=0x%08X",
- media_type, am_titles_list_count[media_type], title_ids_output_pointer);
+ LOG_WARNING(
+ Service_AM,
+ "(STUBBED) media_type=%u, titles_list_count=0x%08X, title_ids_output_pointer=0x%08X",
+ media_type, am_titles_list_count[media_type], title_ids_output_pointer);
}
void GetTitleInfo(Service::Interface* self) {
@@ -101,7 +107,8 @@ void GetTitleInfo(Service::Interface* self) {
am_titles_count[media_type] = cmd_buff[2];
cmd_buff[1] = RESULT_SUCCESS.raw;
- LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, total_titles=0x%08X, title_id_list_pointer=0x%08X, title_list_pointer=0x%08X",
+ LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, total_titles=0x%08X, "
+ "title_id_list_pointer=0x%08X, title_list_pointer=0x%08X",
media_type, am_titles_count[media_type], title_id_list_pointer, title_list_pointer);
}
@@ -122,8 +129,9 @@ void ListDataTitleTicketInfos(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = am_ticket_count;
- LOG_WARNING(Service_AM, "(STUBBED) ticket_count=0x%08X, title_id=0x%016" PRIx64 ", start_index=0x%08X, ticket_info_pointer=0x%08X",
- am_ticket_count, title_id, start_index, ticket_info_pointer);
+ LOG_WARNING(Service_AM, "(STUBBED) ticket_count=0x%08X, title_id=0x%016" PRIx64
+ ", start_index=0x%08X, ticket_info_pointer=0x%08X",
+ am_ticket_count, title_id, start_index, ticket_info_pointer);
}
void GetNumContentInfos(Service::Interface* self) {
@@ -140,7 +148,7 @@ void DeleteTicket(Service::Interface* self) {
u64 title_id = (static_cast<u64>(cmd_buff[2]) << 32) | cmd_buff[1];
cmd_buff[1] = RESULT_SUCCESS.raw;
- LOG_WARNING(Service_AM, "(STUBBED) called title_id=0x%016" PRIx64 "",title_id);
+ LOG_WARNING(Service_AM, "(STUBBED) called title_id=0x%016" PRIx64 "", title_id);
}
void GetTicketCount(Service::Interface* self) {
@@ -148,7 +156,7 @@ void GetTicketCount(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = am_ticket_count;
- LOG_WARNING(Service_AM, "(STUBBED) called ticket_count=0x%08x",am_ticket_count);
+ LOG_WARNING(Service_AM, "(STUBBED) called ticket_count=0x%08x", am_ticket_count);
}
void GetTicketList(Service::Interface* self) {
@@ -161,8 +169,10 @@ void GetTicketList(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = am_ticket_list_count;
- LOG_WARNING(Service_AM, "(STUBBED) ticket_list_count=0x%08x, num_of_skip=0x%08x, ticket_list_pointer=0x%08x",
- am_ticket_list_count, num_of_skip, ticket_list_pointer);
+ LOG_WARNING(
+ Service_AM,
+ "(STUBBED) ticket_list_count=0x%08x, num_of_skip=0x%08x, ticket_list_pointer=0x%08x",
+ am_ticket_list_count, num_of_skip, ticket_list_pointer);
}
void Init() {
@@ -174,9 +184,7 @@ void Init() {
AddService(new AM_U_Interface);
}
-void Shutdown() {
-
-}
+void Shutdown() {}
} // namespace AM
diff --git a/src/core/hle/service/am/am_app.cpp b/src/core/hle/service/am/am_app.cpp
index d27b3defd..bfc1ca6bd 100644
--- a/src/core/hle/service/am/am_app.cpp
+++ b/src/core/hle/service/am/am_app.cpp
@@ -9,14 +9,14 @@ namespace Service {
namespace AM {
const Interface::FunctionInfo FunctionTable[] = {
- {0x100100C0, GetNumContentInfos, "GetNumContentInfos"},
- {0x10020104, FindContentInfos, "FindContentInfos"},
- {0x10030142, ListContentInfos, "ListContentInfos"},
- {0x10040102, DeleteContents, "DeleteContents"},
- {0x10050084, GetDataTitleInfos, "GetDataTitleInfos"},
- {0x10070102, ListDataTitleTicketInfos, "ListDataTitleTicketInfos"},
- {0x100900C0, nullptr, "IsDataTitleInUse"},
- {0x100A0000, nullptr, "IsExternalTitleDatabaseInitialized"},
+ {0x100100C0, GetNumContentInfos, "GetNumContentInfos"},
+ {0x10020104, FindContentInfos, "FindContentInfos"},
+ {0x10030142, ListContentInfos, "ListContentInfos"},
+ {0x10040102, DeleteContents, "DeleteContents"},
+ {0x10050084, GetDataTitleInfos, "GetDataTitleInfos"},
+ {0x10070102, ListDataTitleTicketInfos, "ListDataTitleTicketInfos"},
+ {0x100900C0, nullptr, "IsDataTitleInUse"},
+ {0x100A0000, nullptr, "IsExternalTitleDatabaseInitialized"},
};
AM_APP_Interface::AM_APP_Interface() {
diff --git a/src/core/hle/service/am/am_net.cpp b/src/core/hle/service/am/am_net.cpp
index e75755245..3a597a34c 100644
--- a/src/core/hle/service/am/am_net.cpp
+++ b/src/core/hle/service/am/am_net.cpp
@@ -9,61 +9,61 @@ namespace Service {
namespace AM {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010040, GetTitleCount, "GetTitleCount"},
- {0x00020082, GetTitleList, "GetTitleList"},
- {0x00030084, GetTitleInfo, "GetTitleInfo"},
- {0x000400C0, nullptr, "DeleteApplicationTitle"},
- {0x000500C0, nullptr, "GetTitleProductCode"},
- {0x000600C0, nullptr, "GetTitleExtDataId"},
- {0x00070080, DeleteTicket, "DeleteTicket"},
- {0x00080000, GetTicketCount, "GetTicketCount"},
- {0x00090082, GetTicketList, "GetTicketList"},
- {0x000A0000, nullptr, "GetDeviceID"},
- {0x000D0084, nullptr, "GetPendingTitleInfo"},
- {0x000E00C0, nullptr, "DeletePendingTitle"},
- {0x00140040, nullptr, "FinalizePendingTitles"},
- {0x00150040, nullptr, "DeleteAllPendingTitles"},
- {0x00180080, nullptr, "InitializeTitleDatabase"},
- {0x00190040, nullptr, "ReloadDBS"},
- {0x001A00C0, nullptr, "GetDSiWareExportSize"},
- {0x001B0144, nullptr, "ExportDSiWare"},
- {0x001C0084, nullptr, "ImportDSiWare"},
- {0x00230080, nullptr, "TitleIDListGetTotal2"},
- {0x002400C2, nullptr, "GetTitleIDList2"},
- {0x04010080, nullptr, "InstallFIRM"},
- {0x04020040, nullptr, "StartInstallCIADB0"},
- {0x04030000, nullptr, "StartInstallCIADB1"},
- {0x04040002, nullptr, "AbortCIAInstall"},
- {0x04050002, nullptr, "CloseCIAFinalizeInstall"},
- {0x04060002, nullptr, "CloseCIA"},
- {0x040700C2, nullptr, "FinalizeTitlesInstall"},
- {0x04080042, nullptr, "GetCiaFileInfo"},
- {0x040E00C2, nullptr, "InstallTitlesFinish"},
- {0x040F0000, nullptr, "InstallNATIVEFIRM"},
- {0x041000C0, nullptr, "DeleteTitle"},
- {0x04120000, nullptr, "Initialize"},
- {0x041700C0, nullptr, "MigrateAGBtoSAV"},
- {0x08010000, nullptr, "OpenTicket"},
- {0x08020002, nullptr, "TicketAbortInstall"},
- {0x08030002, nullptr, "TicketFinalizeInstall"},
- {0x08040100, nullptr, "InstallTitleBegin"},
- {0x08050000, nullptr, "InstallTitleAbort"},
- {0x080600C0, nullptr, "InstallTitleResume"},
- {0x08070000, nullptr, "InstallTitleAbortTMD"},
- {0x08080000, nullptr, "InstallTitleFinish"},
- {0x080A0000, nullptr, "OpenTMD"},
- {0x080B0002, nullptr, "TMDAbortInstall"},
- {0x080C0042, nullptr, "TMDFinalizeInstall"},
- {0x080E0040, nullptr, "OpenContentCreate"},
- {0x080F0002, nullptr, "ContentAbortInstall"},
- {0x08100040, nullptr, "OpenContentResume"},
- {0x08120002, nullptr, "ContentFinalizeInstall"},
- {0x08130000, nullptr, "GetTotalContents"},
- {0x08140042, nullptr, "GetContentIndexes"},
- {0x08150044, nullptr, "GetContentsInfo"},
- {0x08180042, nullptr, "GetCTCert"},
- {0x08190108, nullptr, "SetCertificates"},
- {0x081B00C2, nullptr, "InstallTitlesFinish"},
+ {0x00010040, GetTitleCount, "GetTitleCount"},
+ {0x00020082, GetTitleList, "GetTitleList"},
+ {0x00030084, GetTitleInfo, "GetTitleInfo"},
+ {0x000400C0, nullptr, "DeleteApplicationTitle"},
+ {0x000500C0, nullptr, "GetTitleProductCode"},
+ {0x000600C0, nullptr, "GetTitleExtDataId"},
+ {0x00070080, DeleteTicket, "DeleteTicket"},
+ {0x00080000, GetTicketCount, "GetTicketCount"},
+ {0x00090082, GetTicketList, "GetTicketList"},
+ {0x000A0000, nullptr, "GetDeviceID"},
+ {0x000D0084, nullptr, "GetPendingTitleInfo"},
+ {0x000E00C0, nullptr, "DeletePendingTitle"},
+ {0x00140040, nullptr, "FinalizePendingTitles"},
+ {0x00150040, nullptr, "DeleteAllPendingTitles"},
+ {0x00180080, nullptr, "InitializeTitleDatabase"},
+ {0x00190040, nullptr, "ReloadDBS"},
+ {0x001A00C0, nullptr, "GetDSiWareExportSize"},
+ {0x001B0144, nullptr, "ExportDSiWare"},
+ {0x001C0084, nullptr, "ImportDSiWare"},
+ {0x00230080, nullptr, "TitleIDListGetTotal2"},
+ {0x002400C2, nullptr, "GetTitleIDList2"},
+ {0x04010080, nullptr, "InstallFIRM"},
+ {0x04020040, nullptr, "StartInstallCIADB0"},
+ {0x04030000, nullptr, "StartInstallCIADB1"},
+ {0x04040002, nullptr, "AbortCIAInstall"},
+ {0x04050002, nullptr, "CloseCIAFinalizeInstall"},
+ {0x04060002, nullptr, "CloseCIA"},
+ {0x040700C2, nullptr, "FinalizeTitlesInstall"},
+ {0x04080042, nullptr, "GetCiaFileInfo"},
+ {0x040E00C2, nullptr, "InstallTitlesFinish"},
+ {0x040F0000, nullptr, "InstallNATIVEFIRM"},
+ {0x041000C0, nullptr, "DeleteTitle"},
+ {0x04120000, nullptr, "Initialize"},
+ {0x041700C0, nullptr, "MigrateAGBtoSAV"},
+ {0x08010000, nullptr, "OpenTicket"},
+ {0x08020002, nullptr, "TicketAbortInstall"},
+ {0x08030002, nullptr, "TicketFinalizeInstall"},
+ {0x08040100, nullptr, "InstallTitleBegin"},
+ {0x08050000, nullptr, "InstallTitleAbort"},
+ {0x080600C0, nullptr, "InstallTitleResume"},
+ {0x08070000, nullptr, "InstallTitleAbortTMD"},
+ {0x08080000, nullptr, "InstallTitleFinish"},
+ {0x080A0000, nullptr, "OpenTMD"},
+ {0x080B0002, nullptr, "TMDAbortInstall"},
+ {0x080C0042, nullptr, "TMDFinalizeInstall"},
+ {0x080E0040, nullptr, "OpenContentCreate"},
+ {0x080F0002, nullptr, "ContentAbortInstall"},
+ {0x08100040, nullptr, "OpenContentResume"},
+ {0x08120002, nullptr, "ContentFinalizeInstall"},
+ {0x08130000, nullptr, "GetTotalContents"},
+ {0x08140042, nullptr, "GetContentIndexes"},
+ {0x08150044, nullptr, "GetContentsInfo"},
+ {0x08180042, nullptr, "GetCTCert"},
+ {0x08190108, nullptr, "SetCertificates"},
+ {0x081B00C2, nullptr, "InstallTitlesFinish"},
};
AM_NET_Interface::AM_NET_Interface() {
diff --git a/src/core/hle/service/am/am_sys.cpp b/src/core/hle/service/am/am_sys.cpp
index 8bad5e1c9..a2268303c 100644
--- a/src/core/hle/service/am/am_sys.cpp
+++ b/src/core/hle/service/am/am_sys.cpp
@@ -9,27 +9,27 @@ namespace Service {
namespace AM {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010040, GetTitleCount, "GetTitleCount"},
- {0x00020082, GetTitleList, "GetTitleList"},
- {0x00030084, GetTitleInfo, "GetTitleInfo"},
- {0x000400C0, nullptr, "DeleteApplicationTitle"},
- {0x000500C0, nullptr, "GetTitleProductCode"},
- {0x000600C0, nullptr, "GetTitleExtDataId"},
- {0x00070080, DeleteTicket, "DeleteTicket"},
- {0x00080000, GetTicketCount, "GetTicketCount"},
- {0x00090082, GetTicketList, "GetTicketList"},
- {0x000A0000, nullptr, "GetDeviceID"},
- {0x000D0084, nullptr, "GetPendingTitleInfo"},
- {0x000E00C0, nullptr, "DeletePendingTitle"},
- {0x00140040, nullptr, "FinalizePendingTitles"},
- {0x00150040, nullptr, "DeleteAllPendingTitles"},
- {0x00180080, nullptr, "InitializeTitleDatabase"},
- {0x00190040, nullptr, "ReloadDBS"},
- {0x001A00C0, nullptr, "GetDSiWareExportSize"},
- {0x001B0144, nullptr, "ExportDSiWare"},
- {0x001C0084, nullptr, "ImportDSiWare"},
- {0x00230080, nullptr, "GetPendingTitleCount"},
- {0x002400C2, nullptr, "GetPendingTitleList"}
+ {0x00010040, GetTitleCount, "GetTitleCount"},
+ {0x00020082, GetTitleList, "GetTitleList"},
+ {0x00030084, GetTitleInfo, "GetTitleInfo"},
+ {0x000400C0, nullptr, "DeleteApplicationTitle"},
+ {0x000500C0, nullptr, "GetTitleProductCode"},
+ {0x000600C0, nullptr, "GetTitleExtDataId"},
+ {0x00070080, DeleteTicket, "DeleteTicket"},
+ {0x00080000, GetTicketCount, "GetTicketCount"},
+ {0x00090082, GetTicketList, "GetTicketList"},
+ {0x000A0000, nullptr, "GetDeviceID"},
+ {0x000D0084, nullptr, "GetPendingTitleInfo"},
+ {0x000E00C0, nullptr, "DeletePendingTitle"},
+ {0x00140040, nullptr, "FinalizePendingTitles"},
+ {0x00150040, nullptr, "DeleteAllPendingTitles"},
+ {0x00180080, nullptr, "InitializeTitleDatabase"},
+ {0x00190040, nullptr, "ReloadDBS"},
+ {0x001A00C0, nullptr, "GetDSiWareExportSize"},
+ {0x001B0144, nullptr, "ExportDSiWare"},
+ {0x001C0084, nullptr, "ImportDSiWare"},
+ {0x00230080, nullptr, "GetPendingTitleCount"},
+ {0x002400C2, nullptr, "GetPendingTitleList"},
};
AM_SYS_Interface::AM_SYS_Interface() {
diff --git a/src/core/hle/service/am/am_u.cpp b/src/core/hle/service/am/am_u.cpp
index d583dd9e6..151b5e42b 100644
--- a/src/core/hle/service/am/am_u.cpp
+++ b/src/core/hle/service/am/am_u.cpp
@@ -9,40 +9,40 @@ namespace Service {
namespace AM {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010040, GetTitleCount, "GetTitleCount"},
- {0x00020082, GetTitleList, "GetTitleList"},
- {0x00030084, GetTitleInfo, "GetTitleInfo"},
- {0x000400C0, nullptr, "DeleteApplicationTitle"},
- {0x000500C0, nullptr, "GetTitleProductCode"},
- {0x000600C0, nullptr, "GetTitleExtDataId"},
- {0x00070080, DeleteTicket, "DeleteTicket"},
- {0x00080000, GetTicketCount, "GetTicketCount"},
- {0x00090082, GetTicketList, "GetTicketList"},
- {0x000A0000, nullptr, "GetDeviceID"},
- {0x000D0084, nullptr, "GetPendingTitleInfo"},
- {0x000E00C0, nullptr, "DeletePendingTitle"},
- {0x00140040, nullptr, "FinalizePendingTitles"},
- {0x00150040, nullptr, "DeleteAllPendingTitles"},
- {0x00180080, nullptr, "InitializeTitleDatabase"},
- {0x00190040, nullptr, "ReloadDBS"},
- {0x001A00C0, nullptr, "GetDSiWareExportSize"},
- {0x001B0144, nullptr, "ExportDSiWare"},
- {0x001C0084, nullptr, "ImportDSiWare"},
- {0x00230080, nullptr, "TitleIDListGetTotal2"},
- {0x002400C2, nullptr, "GetTitleIDList2"},
- {0x04010080, nullptr, "InstallFIRM"},
- {0x04020040, nullptr, "StartInstallCIADB0"},
- {0x04030000, nullptr, "StartInstallCIADB1"},
- {0x04040002, nullptr, "AbortCIAInstall"},
- {0x04050002, nullptr, "CloseCIAFinalizeInstall"},
- {0x04060002, nullptr, "CloseCIA"},
- {0x040700C2, nullptr, "FinalizeTitlesInstall"},
- {0x04080042, nullptr, "GetCiaFileInfo"},
- {0x040E00C2, nullptr, "InstallTitlesFinish"},
- {0x040F0000, nullptr, "InstallNATIVEFIRM"},
- {0x041000C0, nullptr, "DeleteTitle"},
- {0x04120000, nullptr, "Initialize"},
- {0x041700C0, nullptr, "MigrateAGBtoSAV"}
+ {0x00010040, GetTitleCount, "GetTitleCount"},
+ {0x00020082, GetTitleList, "GetTitleList"},
+ {0x00030084, GetTitleInfo, "GetTitleInfo"},
+ {0x000400C0, nullptr, "DeleteApplicationTitle"},
+ {0x000500C0, nullptr, "GetTitleProductCode"},
+ {0x000600C0, nullptr, "GetTitleExtDataId"},
+ {0x00070080, DeleteTicket, "DeleteTicket"},
+ {0x00080000, GetTicketCount, "GetTicketCount"},
+ {0x00090082, GetTicketList, "GetTicketList"},
+ {0x000A0000, nullptr, "GetDeviceID"},
+ {0x000D0084, nullptr, "GetPendingTitleInfo"},
+ {0x000E00C0, nullptr, "DeletePendingTitle"},
+ {0x00140040, nullptr, "FinalizePendingTitles"},
+ {0x00150040, nullptr, "DeleteAllPendingTitles"},
+ {0x00180080, nullptr, "InitializeTitleDatabase"},
+ {0x00190040, nullptr, "ReloadDBS"},
+ {0x001A00C0, nullptr, "GetDSiWareExportSize"},
+ {0x001B0144, nullptr, "ExportDSiWare"},
+ {0x001C0084, nullptr, "ImportDSiWare"},
+ {0x00230080, nullptr, "TitleIDListGetTotal2"},
+ {0x002400C2, nullptr, "GetTitleIDList2"},
+ {0x04010080, nullptr, "InstallFIRM"},
+ {0x04020040, nullptr, "StartInstallCIADB0"},
+ {0x04030000, nullptr, "StartInstallCIADB1"},
+ {0x04040002, nullptr, "AbortCIAInstall"},
+ {0x04050002, nullptr, "CloseCIAFinalizeInstall"},
+ {0x04060002, nullptr, "CloseCIA"},
+ {0x040700C2, nullptr, "FinalizeTitlesInstall"},
+ {0x04080042, nullptr, "GetCiaFileInfo"},
+ {0x040E00C2, nullptr, "InstallTitlesFinish"},
+ {0x040F0000, nullptr, "InstallNATIVEFIRM"},
+ {0x041000C0, nullptr, "DeleteTitle"},
+ {0x04120000, nullptr, "Initialize"},
+ {0x041700C0, nullptr, "MigrateAGBtoSAV"},
};
AM_U_Interface::AM_U_Interface() {
diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp
index 4d2956638..c4bd65986 100644
--- a/src/core/hle/service/apt/apt.cpp
+++ b/src/core/hle/service/apt/apt.cpp
@@ -5,9 +5,11 @@
#include "common/common_paths.h"
#include "common/file_util.h"
#include "common/logging/log.h"
-
#include "core/hle/applets/applet.h"
-#include "core/hle/service/service.h"
+#include "core/hle/kernel/event.h"
+#include "core/hle/kernel/mutex.h"
+#include "core/hle/kernel/process.h"
+#include "core/hle/kernel/shared_memory.h"
#include "core/hle/service/apt/apt.h"
#include "core/hle/service/apt/apt_a.h"
#include "core/hle/service/apt/apt_s.h"
@@ -15,11 +17,7 @@
#include "core/hle/service/apt/bcfnt/bcfnt.h"
#include "core/hle/service/fs/archive.h"
#include "core/hle/service/ptm/ptm.h"
-
-#include "core/hle/kernel/event.h"
-#include "core/hle/kernel/mutex.h"
-#include "core/hle/kernel/process.h"
-#include "core/hle/kernel/shared_memory.h"
+#include "core/hle/service/service.h"
namespace Service {
namespace APT {
@@ -30,7 +28,7 @@ static bool shared_font_relocated = false;
static Kernel::SharedPtr<Kernel::Mutex> lock;
static Kernel::SharedPtr<Kernel::Event> notification_event; ///< APT notification event
-static Kernel::SharedPtr<Kernel::Event> parameter_event; ///< APT parameter event
+static Kernel::SharedPtr<Kernel::Event> parameter_event; ///< APT parameter event
static u32 cpu_percent; ///< CPU time available to the running application
@@ -51,7 +49,7 @@ void SendParameter(const MessageParameter& parameter) {
void Initialize(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 app_id = cmd_buff[1];
- u32 flags = cmd_buff[2];
+ u32 flags = cmd_buff[2];
cmd_buff[2] = IPC::CopyHandleDesc(2);
cmd_buff[3] = Kernel::g_handle_table.Create(notification_event).MoveFrom();
@@ -75,21 +73,23 @@ void GetSharedFont(Service::Interface* self) {
if (!shared_font_mem) {
LOG_ERROR(Service_APT, "shared font file missing - go dump it from your 3ds");
cmd_buff[0] = IPC::MakeHeader(0x44, 2, 2);
- cmd_buff[1] = -1; // TODO: Find the right error code
+ cmd_buff[1] = -1; // TODO: Find the right error code
return;
}
- // The shared font has to be relocated to the new address before being passed to the application.
- VAddr target_address = Memory::PhysicalToVirtualAddress(shared_font_mem->linear_heap_phys_address);
+ // The shared font has to be relocated to the new address before being passed to the
+ // application.
+ VAddr target_address =
+ Memory::PhysicalToVirtualAddress(shared_font_mem->linear_heap_phys_address);
if (!shared_font_relocated) {
BCFNT::RelocateSharedFont(shared_font_mem, target_address);
shared_font_relocated = true;
}
cmd_buff[0] = IPC::MakeHeader(0x44, 2, 2);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- // Since the SharedMemory interface doesn't provide the address at which the memory was allocated,
- // the real APT service calculates this address by scanning the entire address space (using svcQueryMemory)
- // and searches for an allocation of the same size as the Shared Font.
+ // Since the SharedMemory interface doesn't provide the address at which the memory was
+ // allocated, the real APT service calculates this address by scanning the entire address space
+ // (using svcQueryMemory) and searches for an allocation of the same size as the Shared Font.
cmd_buff[2] = target_address;
cmd_buff[3] = IPC::CopyHandleDesc();
cmd_buff[4] = Kernel::g_handle_table.Create(shared_font_mem).MoveFrom();
@@ -112,18 +112,19 @@ void GetLockHandle(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = applet_attributes; // Applet Attributes, this value is passed to Enable.
- cmd_buff[3] = 0; // Least significant bit = power button state
+ cmd_buff[3] = 0; // Least significant bit = power button state
cmd_buff[4] = IPC::CopyHandleDesc();
cmd_buff[5] = Kernel::g_handle_table.Create(lock).MoveFrom();
- LOG_WARNING(Service_APT, "(STUBBED) called handle=0x%08X applet_attributes=0x%08X", cmd_buff[5], applet_attributes);
+ LOG_WARNING(Service_APT, "(STUBBED) called handle=0x%08X applet_attributes=0x%08X", cmd_buff[5],
+ applet_attributes);
}
void Enable(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 attributes = cmd_buff[1];
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- parameter_event->Signal(); // Let the application know that it has been started
+ parameter_event->Signal(); // Let the application know that it has been started
LOG_WARNING(Service_APT, "(STUBBED) called attributes=0x%08X", attributes);
}
@@ -133,7 +134,7 @@ void GetAppletManInfo(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = 0;
cmd_buff[3] = 0;
- cmd_buff[4] = static_cast<u32>(AppletId::HomeMenu); // Home menu AppID
+ cmd_buff[4] = static_cast<u32>(AppletId::HomeMenu); // Home menu AppID
cmd_buff[5] = static_cast<u32>(AppletId::Application); // TODO(purpasmart96): Do this correctly
LOG_WARNING(Service_APT, "(STUBBED) called unk=0x%08X", unk);
@@ -159,23 +160,24 @@ void IsRegistered(Service::Interface* self) {
void InquireNotification(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 app_id = cmd_buff[1];
- cmd_buff[1] = RESULT_SUCCESS.raw; // No error
+ cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = static_cast<u32>(SignalType::None); // Signal type
LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X", app_id);
}
void SendParameter(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- u32 src_app_id = cmd_buff[1];
- u32 dst_app_id = cmd_buff[2];
- u32 signal_type = cmd_buff[3];
- u32 buffer_size = cmd_buff[4];
- u32 value = cmd_buff[5];
- u32 handle = cmd_buff[6];
- u32 size = cmd_buff[7];
- u32 buffer = cmd_buff[8];
-
- std::shared_ptr<HLE::Applets::Applet> dest_applet = HLE::Applets::Applet::Get(static_cast<AppletId>(dst_app_id));
+ u32 src_app_id = cmd_buff[1];
+ u32 dst_app_id = cmd_buff[2];
+ u32 signal_type = cmd_buff[3];
+ u32 buffer_size = cmd_buff[4];
+ u32 value = cmd_buff[5];
+ u32 handle = cmd_buff[6];
+ u32 size = cmd_buff[7];
+ u32 buffer = cmd_buff[8];
+
+ std::shared_ptr<HLE::Applets::Applet> dest_applet =
+ HLE::Applets::Applet::Get(static_cast<AppletId>(dst_app_id));
if (dest_applet == nullptr) {
LOG_ERROR(Service_APT, "Unknown applet id=0x%08X", dst_app_id);
@@ -193,9 +195,11 @@ void SendParameter(Service::Interface* self) {
cmd_buff[1] = dest_applet->ReceiveParameter(param).raw;
- LOG_WARNING(Service_APT, "(STUBBED) called src_app_id=0x%08X, dst_app_id=0x%08X, signal_type=0x%08X,"
- "buffer_size=0x%08X, value=0x%08X, handle=0x%08X, size=0x%08X, in_param_buffer_ptr=0x%08X",
- src_app_id, dst_app_id, signal_type, buffer_size, value, handle, size, buffer);
+ LOG_WARNING(
+ Service_APT,
+ "(STUBBED) called src_app_id=0x%08X, dst_app_id=0x%08X, signal_type=0x%08X,"
+ "buffer_size=0x%08X, value=0x%08X, handle=0x%08X, size=0x%08X, in_param_buffer_ptr=0x%08X",
+ src_app_id, dst_app_id, signal_type, buffer_size, value, handle, size, buffer);
}
void ReceiveParameter(Service::Interface* self) {
@@ -206,7 +210,7 @@ void ReceiveParameter(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = next_parameter.sender_id;
- cmd_buff[3] = next_parameter.signal; // Signal type
+ cmd_buff[3] = next_parameter.signal; // Signal type
cmd_buff[4] = next_parameter.buffer.size(); // Parameter buffer size
cmd_buff[5] = 0x10;
cmd_buff[6] = 0;
@@ -228,7 +232,7 @@ void GlanceParameter(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = next_parameter.sender_id;
- cmd_buff[3] = next_parameter.signal; // Signal type
+ cmd_buff[3] = next_parameter.signal; // Signal type
cmd_buff[4] = next_parameter.buffer.size(); // Parameter buffer size
cmd_buff[5] = 0x10;
cmd_buff[6] = 0;
@@ -237,32 +241,34 @@ void GlanceParameter(Service::Interface* self) {
cmd_buff[7] = (next_parameter.buffer.size() << 14) | 2;
cmd_buff[8] = buffer;
- Memory::WriteBlock(buffer, next_parameter.buffer.data(), std::min(static_cast<size_t>(buffer_size), next_parameter.buffer.size()));
+ Memory::WriteBlock(buffer, next_parameter.buffer.data(),
+ std::min(static_cast<size_t>(buffer_size), next_parameter.buffer.size()));
LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size);
}
void CancelParameter(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- u32 flag1 = cmd_buff[1];
- u32 unk = cmd_buff[2];
- u32 flag2 = cmd_buff[3];
+ u32 flag1 = cmd_buff[1];
+ u32 unk = cmd_buff[2];
+ u32 flag2 = cmd_buff[3];
u32 app_id = cmd_buff[4];
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- cmd_buff[2] = 1; // Set to Success
+ cmd_buff[2] = 1; // Set to Success
- LOG_WARNING(Service_APT, "(STUBBED) called flag1=0x%08X, unk=0x%08X, flag2=0x%08X, app_id=0x%08X",
- flag1, unk, flag2, app_id);
+ LOG_WARNING(Service_APT,
+ "(STUBBED) called flag1=0x%08X, unk=0x%08X, flag2=0x%08X, app_id=0x%08X", flag1,
+ unk, flag2, app_id);
}
void PrepareToStartApplication(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- u32 title_info1 = cmd_buff[1];
- u32 title_info2 = cmd_buff[2];
- u32 title_info3 = cmd_buff[3];
- u32 title_info4 = cmd_buff[4];
- u32 flags = cmd_buff[5];
+ u32 title_info1 = cmd_buff[1];
+ u32 title_info2 = cmd_buff[2];
+ u32 title_info3 = cmd_buff[3];
+ u32 title_info4 = cmd_buff[4];
+ u32 flags = cmd_buff[5];
if (flags & 0x00000100) {
unknown_ns_state_field = 1;
@@ -270,25 +276,28 @@ void PrepareToStartApplication(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- LOG_WARNING(Service_APT, "(STUBBED) called title_info1=0x%08X, title_info2=0x%08X, title_info3=0x%08X,"
- "title_info4=0x%08X, flags=0x%08X", title_info1, title_info2, title_info3, title_info4, flags);
+ LOG_WARNING(Service_APT,
+ "(STUBBED) called title_info1=0x%08X, title_info2=0x%08X, title_info3=0x%08X,"
+ "title_info4=0x%08X, flags=0x%08X",
+ title_info1, title_info2, title_info3, title_info4, flags);
}
void StartApplication(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 buffer1_size = cmd_buff[1];
u32 buffer2_size = cmd_buff[2];
- u32 flag = cmd_buff[3];
- u32 size1 = cmd_buff[4];
- u32 buffer1_ptr = cmd_buff[5];
- u32 size2 = cmd_buff[6];
- u32 buffer2_ptr = cmd_buff[7];
+ u32 flag = cmd_buff[3];
+ u32 size1 = cmd_buff[4];
+ u32 buffer1_ptr = cmd_buff[5];
+ u32 size2 = cmd_buff[6];
+ u32 buffer2_ptr = cmd_buff[7];
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- LOG_WARNING(Service_APT, "(STUBBED) called buffer1_size=0x%08X, buffer2_size=0x%08X, flag=0x%08X,"
- "size1=0x%08X, buffer1_ptr=0x%08X, size2=0x%08X, buffer2_ptr=0x%08X",
- buffer1_size, buffer2_size, flag, size1, buffer1_ptr, size2, buffer2_ptr);
+ LOG_WARNING(Service_APT,
+ "(STUBBED) called buffer1_size=0x%08X, buffer2_size=0x%08X, flag=0x%08X,"
+ "size1=0x%08X, buffer1_ptr=0x%08X, size2=0x%08X, buffer2_ptr=0x%08X",
+ buffer1_size, buffer2_size, flag, size1, buffer1_ptr, size2, buffer2_ptr);
}
void AppletUtility(Service::Interface* self) {
@@ -303,14 +312,15 @@ void AppletUtility(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- LOG_WARNING(Service_APT, "(STUBBED) called command=0x%08X, buffer1_size=0x%08X, buffer2_size=0x%08X, "
- "buffer1_addr=0x%08X, buffer2_addr=0x%08X", command, buffer1_size, buffer2_size,
- buffer1_addr, buffer2_addr);
+ LOG_WARNING(Service_APT,
+ "(STUBBED) called command=0x%08X, buffer1_size=0x%08X, buffer2_size=0x%08X, "
+ "buffer1_addr=0x%08X, buffer2_addr=0x%08X",
+ command, buffer1_size, buffer2_size, buffer1_addr, buffer2_addr);
}
void SetAppCpuTimeLimit(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- u32 value = cmd_buff[1];
+ u32 value = cmd_buff[1];
cpu_percent = cmd_buff[2];
if (value != 1) {
@@ -393,7 +403,8 @@ void SetScreenCapPostPermission(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x55, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
- LOG_WARNING(Service_APT, "(STUBBED) screen_capture_post_permission=%u", screen_capture_post_permission);
+ LOG_WARNING(Service_APT, "(STUBBED) screen_capture_post_permission=%u",
+ screen_capture_post_permission);
}
void GetScreenCapPostPermission(Service::Interface* self) {
@@ -402,7 +413,8 @@ void GetScreenCapPostPermission(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x56, 2, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = static_cast<u32>(screen_capture_post_permission);
- LOG_WARNING(Service_APT, "(STUBBED) screen_capture_post_permission=%u", screen_capture_post_permission);
+ LOG_WARNING(Service_APT, "(STUBBED) screen_capture_post_permission=%u",
+ screen_capture_post_permission);
}
void GetAppletInfo(Service::Interface* self) {
@@ -418,7 +430,8 @@ void GetAppletInfo(Service::Interface* self) {
cmd_buff[7] = 0; // Applet Attributes
} else {
cmd_buff[1] = ResultCode(ErrorDescription::NotFound, ErrorModule::Applet,
- ErrorSummary::NotFound, ErrorLevel::Status).raw;
+ ErrorSummary::NotFound, ErrorLevel::Status)
+ .raw;
}
LOG_WARNING(Service_APT, "(stubbed) called appid=%u", app_id);
}
@@ -429,11 +442,15 @@ void GetStartupArgument(Service::Interface* self) {
StartupArgumentType startup_argument_type = static_cast<StartupArgumentType>(cmd_buff[2]);
if (parameter_size >= 0x300) {
- LOG_ERROR(Service_APT, "Parameter size is outside the valid range (capped to 0x300): parameter_size=0x%08x", parameter_size);
+ LOG_ERROR(
+ Service_APT,
+ "Parameter size is outside the valid range (capped to 0x300): parameter_size=0x%08x",
+ parameter_size);
return;
}
- LOG_WARNING(Service_APT,"(stubbed) called startup_argument_type=%u , parameter_size=0x%08x , parameter_value=0x%08x",
+ LOG_WARNING(Service_APT, "(stubbed) called startup_argument_type=%u , parameter_size=0x%08x , "
+ "parameter_value=0x%08x",
startup_argument_type, parameter_size, Memory::Read32(cmd_buff[41]));
cmd_buff[1] = RESULT_SUCCESS.raw;
@@ -484,8 +501,10 @@ void Init() {
if (file.IsOpen()) {
// Create shared font memory object
using Kernel::MemoryPermission;
- shared_font_mem = Kernel::SharedMemory::Create(nullptr, 0x332000, // 3272 KB
- MemoryPermission::ReadWrite, MemoryPermission::Read, 0, Kernel::MemoryRegion::SYSTEM, "APT:SharedFont");
+ shared_font_mem =
+ Kernel::SharedMemory::Create(nullptr, 0x332000, // 3272 KB
+ MemoryPermission::ReadWrite, MemoryPermission::Read, 0,
+ Kernel::MemoryRegion::SYSTEM, "APT:SharedFont");
// Read shared font data
file.ReadBytes(shared_font_mem->GetPointer(), file.GetSize());
} else {
@@ -497,7 +516,8 @@ void Init() {
cpu_percent = 0;
unknown_ns_state_field = 0;
- screen_capture_post_permission = ScreencapPostPermission::CleanThePermission; // TODO(JamePeng): verify the initial value
+ screen_capture_post_permission =
+ ScreencapPostPermission::CleanThePermission; // TODO(JamePeng): verify the initial value
// TODO(bunnei): Check if these are created in Initialize or on APT process startup.
notification_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "APT_U:Notification");
diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h
index 077a6a316..a118cda1f 100644
--- a/src/core/hle/service/apt/apt.h
+++ b/src/core/hle/service/apt/apt.h
@@ -6,7 +6,6 @@
#include "common/common_types.h"
#include "common/swap.h"
-
#include "core/hle/kernel/kernel.h"
namespace Service {
@@ -46,58 +45,58 @@ static_assert(sizeof(CaptureBufferInfo) == 0x20, "CaptureBufferInfo struct has i
/// Signals used by APT functions
enum class SignalType : u32 {
- None = 0x0,
- AppJustStarted = 0x1,
+ None = 0x0,
+ AppJustStarted = 0x1,
LibAppJustStarted = 0x2,
- LibAppFinished = 0x3,
- LibAppClosed = 0xA,
- ReturningToApp = 0xB,
- ExitingApp = 0xC,
+ LibAppFinished = 0x3,
+ LibAppClosed = 0xA,
+ ReturningToApp = 0xB,
+ ExitingApp = 0xC,
};
/// App Id's used by APT functions
enum class AppletId : u32 {
- HomeMenu = 0x101,
- AlternateMenu = 0x103,
- Camera = 0x110,
- FriendsList = 0x112,
- GameNotes = 0x113,
- InternetBrowser = 0x114,
- InstructionManual = 0x115,
- Notifications = 0x116,
- Miiverse = 0x117,
- MiiversePost = 0x118,
- AmiiboSettings = 0x119,
- SoftwareKeyboard1 = 0x201,
- Ed1 = 0x202,
- PnoteApp = 0x204,
- SnoteApp = 0x205,
- Error = 0x206,
- Mint = 0x207,
- Extrapad = 0x208,
- Memolib = 0x209,
- Application = 0x300,
- AnyLibraryApplet = 0x400,
- SoftwareKeyboard2 = 0x401,
- Ed2 = 0x402,
- PnoteApp2 = 0x404,
- SnoteApp2 = 0x405,
- Error2 = 0x406,
- Mint2 = 0x407,
- Extrapad2 = 0x408,
- Memolib2 = 0x409,
+ HomeMenu = 0x101,
+ AlternateMenu = 0x103,
+ Camera = 0x110,
+ FriendsList = 0x112,
+ GameNotes = 0x113,
+ InternetBrowser = 0x114,
+ InstructionManual = 0x115,
+ Notifications = 0x116,
+ Miiverse = 0x117,
+ MiiversePost = 0x118,
+ AmiiboSettings = 0x119,
+ SoftwareKeyboard1 = 0x201,
+ Ed1 = 0x202,
+ PnoteApp = 0x204,
+ SnoteApp = 0x205,
+ Error = 0x206,
+ Mint = 0x207,
+ Extrapad = 0x208,
+ Memolib = 0x209,
+ Application = 0x300,
+ AnyLibraryApplet = 0x400,
+ SoftwareKeyboard2 = 0x401,
+ Ed2 = 0x402,
+ PnoteApp2 = 0x404,
+ SnoteApp2 = 0x405,
+ Error2 = 0x406,
+ Mint2 = 0x407,
+ Extrapad2 = 0x408,
+ Memolib2 = 0x409,
};
enum class StartupArgumentType : u32 {
- OtherApp = 0,
- Restart = 1,
+ OtherApp = 0,
+ Restart = 1,
OtherMedia = 2,
};
enum class ScreencapPostPermission : u32 {
- CleanThePermission = 0, //TODO(JamePeng): verify what "zero" means
- NoExplicitSetting = 1,
- EnableScreenshotPostingToMiiverse = 2,
+ CleanThePermission = 0, // TODO(JamePeng): verify what "zero" means
+ NoExplicitSetting = 1,
+ EnableScreenshotPostingToMiiverse = 2,
DisableScreenshotPostingToMiiverse = 3
};
@@ -182,10 +181,11 @@ void GetAppletManInfo(Service::Interface* self);
void GetAppletInfo(Service::Interface* self);
/**
- * APT::IsRegistered service function. This returns whether the specified AppID is registered with NS yet.
- * An AppID is "registered" once the process associated with the AppID uses APT:Enable. Home Menu uses this
- * command to determine when the launched process is running and to determine when to stop using GSP etc,
- * while displaying the "Nintendo 3DS" loading screen.
+ * APT::IsRegistered service function. This returns whether the specified AppID is registered with
+ * NS yet. An AppID is "registered" once the process associated with the AppID uses APT:Enable. Home
+ * Menu uses this command to determine when the launched process is running and to determine when to
+ * stop using GSP, etc., while displaying the "Nintendo 3DS" loading screen.
+ *
* Inputs:
* 1 : AppID
* Outputs:
@@ -260,9 +260,11 @@ void GlanceParameter(Service::Interface* self);
* clears the flag which indicates that parameter data is available
* (same flag cleared by APT:ReceiveParameter).
* Inputs:
- * 1 : Flag, when non-zero NS will compare the word after this one with a field in the NS state.
+ * 1 : Flag, when non-zero NS will compare the word after this one with a field in the NS
+ * state.
* 2 : Unknown, this is the same as the first unknown field returned by APT:ReceiveParameter.
- * 3 : Flag, when non-zero NS will compare the word after this one with a field in the NS state.
+ * 3 : Flag, when non-zero NS will compare the word after this one with a field in the NS
+ * state.
* 4 : AppID
* Outputs:
* 0 : Return header
diff --git a/src/core/hle/service/apt/apt_a.cpp b/src/core/hle/service/apt/apt_a.cpp
index 6c44c491c..f27ad91b7 100644
--- a/src/core/hle/service/apt/apt_a.cpp
+++ b/src/core/hle/service/apt/apt_a.cpp
@@ -9,34 +9,34 @@ namespace Service {
namespace APT {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010040, GetLockHandle, "GetLockHandle?"},
- {0x00020080, Initialize, "Initialize?"},
- {0x00030040, Enable, "Enable?"},
- {0x00040040, nullptr, "Finalize?"},
- {0x00050040, GetAppletManInfo, "GetAppletManInfo"},
- {0x00060040, GetAppletInfo, "GetAppletInfo"},
- {0x00090040, IsRegistered, "IsRegistered"},
- {0x000B0040, InquireNotification, "InquireNotification"},
- {0x000C0104, SendParameter, "SendParameter"},
- {0x000D0080, ReceiveParameter, "ReceiveParameter"},
- {0x000E0080, GlanceParameter, "GlanceParameter"},
- {0x000F0100, CancelParameter, "CancelParameter"},
- {0x00150140, PrepareToStartApplication, "PrepareToStartApplication"},
- {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
- {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
- {0x001E0084, StartLibraryApplet, "StartLibraryApplet"},
- {0x003B0040, nullptr, "CancelLibraryApplet?"},
- {0x003E0080, nullptr, "ReplySleepQuery"},
- {0x00430040, NotifyToWait, "NotifyToWait?"},
- {0x00440000, GetSharedFont, "GetSharedFont?"},
- {0x004B00C2, AppletUtility, "AppletUtility?"},
- {0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"},
- {0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"},
- {0x00510080, GetStartupArgument, "GetStartupArgument"},
- {0x00550040, SetScreenCapPostPermission, "SetScreenCapPostPermission"},
- {0x00560000, GetScreenCapPostPermission, "GetScreenCapPostPermission"},
- {0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
- {0x01020000, CheckNew3DS, "CheckNew3DS"}
+ {0x00010040, GetLockHandle, "GetLockHandle?"},
+ {0x00020080, Initialize, "Initialize?"},
+ {0x00030040, Enable, "Enable?"},
+ {0x00040040, nullptr, "Finalize?"},
+ {0x00050040, GetAppletManInfo, "GetAppletManInfo"},
+ {0x00060040, GetAppletInfo, "GetAppletInfo"},
+ {0x00090040, IsRegistered, "IsRegistered"},
+ {0x000B0040, InquireNotification, "InquireNotification"},
+ {0x000C0104, SendParameter, "SendParameter"},
+ {0x000D0080, ReceiveParameter, "ReceiveParameter"},
+ {0x000E0080, GlanceParameter, "GlanceParameter"},
+ {0x000F0100, CancelParameter, "CancelParameter"},
+ {0x00150140, PrepareToStartApplication, "PrepareToStartApplication"},
+ {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
+ {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
+ {0x001E0084, StartLibraryApplet, "StartLibraryApplet"},
+ {0x003B0040, nullptr, "CancelLibraryApplet?"},
+ {0x003E0080, nullptr, "ReplySleepQuery"},
+ {0x00430040, NotifyToWait, "NotifyToWait?"},
+ {0x00440000, GetSharedFont, "GetSharedFont?"},
+ {0x004B00C2, AppletUtility, "AppletUtility?"},
+ {0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"},
+ {0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"},
+ {0x00510080, GetStartupArgument, "GetStartupArgument"},
+ {0x00550040, SetScreenCapPostPermission, "SetScreenCapPostPermission"},
+ {0x00560000, GetScreenCapPostPermission, "GetScreenCapPostPermission"},
+ {0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
+ {0x01020000, CheckNew3DS, "CheckNew3DS"},
};
APT_A_Interface::APT_A_Interface() {
diff --git a/src/core/hle/service/apt/apt_s.cpp b/src/core/hle/service/apt/apt_s.cpp
index c70f2201f..c4556a5de 100644
--- a/src/core/hle/service/apt/apt_s.cpp
+++ b/src/core/hle/service/apt/apt_s.cpp
@@ -9,94 +9,94 @@ namespace Service {
namespace APT {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010040, GetLockHandle, "GetLockHandle"},
- {0x00020080, Initialize, "Initialize"},
- {0x00030040, Enable, "Enable"},
- {0x00040040, nullptr, "Finalize"},
- {0x00050040, GetAppletManInfo, "GetAppletManInfo"},
- {0x00060040, GetAppletInfo, "GetAppletInfo"},
- {0x00070000, nullptr, "GetLastSignaledAppletId"},
- {0x00080000, nullptr, "CountRegisteredApplet"},
- {0x00090040, nullptr, "IsRegistered"},
- {0x000A0040, nullptr, "GetAttribute"},
- {0x000B0040, InquireNotification, "InquireNotification"},
- {0x000C0104, nullptr, "SendParameter"},
- {0x000D0080, ReceiveParameter, "ReceiveParameter"},
- {0x000E0080, GlanceParameter, "GlanceParameter"},
- {0x000F0100, nullptr, "CancelParameter"},
- {0x001000C2, nullptr, "DebugFunc"},
- {0x001100C0, nullptr, "MapProgramIdForDebug"},
- {0x00120040, nullptr, "SetHomeMenuAppletIdForDebug"},
- {0x00130000, nullptr, "GetPreparationState"},
- {0x00140040, nullptr, "SetPreparationState"},
+ {0x00010040, GetLockHandle, "GetLockHandle"},
+ {0x00020080, Initialize, "Initialize"},
+ {0x00030040, Enable, "Enable"},
+ {0x00040040, nullptr, "Finalize"},
+ {0x00050040, GetAppletManInfo, "GetAppletManInfo"},
+ {0x00060040, GetAppletInfo, "GetAppletInfo"},
+ {0x00070000, nullptr, "GetLastSignaledAppletId"},
+ {0x00080000, nullptr, "CountRegisteredApplet"},
+ {0x00090040, nullptr, "IsRegistered"},
+ {0x000A0040, nullptr, "GetAttribute"},
+ {0x000B0040, InquireNotification, "InquireNotification"},
+ {0x000C0104, nullptr, "SendParameter"},
+ {0x000D0080, ReceiveParameter, "ReceiveParameter"},
+ {0x000E0080, GlanceParameter, "GlanceParameter"},
+ {0x000F0100, nullptr, "CancelParameter"},
+ {0x001000C2, nullptr, "DebugFunc"},
+ {0x001100C0, nullptr, "MapProgramIdForDebug"},
+ {0x00120040, nullptr, "SetHomeMenuAppletIdForDebug"},
+ {0x00130000, nullptr, "GetPreparationState"},
+ {0x00140040, nullptr, "SetPreparationState"},
{0x00150140, PrepareToStartApplication, "PrepareToStartApplication"},
- {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
- {0x00170040, nullptr, "FinishPreloadingLibraryApplet"},
- {0x00180040, PrepareToStartLibraryApplet,"PrepareToStartLibraryApplet"},
- {0x00190040, nullptr, "PrepareToStartSystemApplet"},
- {0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"},
- {0x001B00C4, nullptr, "StartApplication"},
- {0x001C0000, nullptr, "WakeupApplication"},
- {0x001D0000, nullptr, "CancelApplication"},
- {0x001E0084, nullptr, "StartLibraryApplet"},
- {0x001F0084, nullptr, "StartSystemApplet"},
- {0x00200044, nullptr, "StartNewestHomeMenu"},
- {0x00210000, nullptr, "OrderToCloseApplication"},
- {0x00220040, nullptr, "PrepareToCloseApplication"},
- {0x00230040, nullptr, "PrepareToJumpToApplication"},
- {0x00240044, nullptr, "JumpToApplication"},
- {0x002500C0, nullptr, "PrepareToCloseLibraryApplet"},
- {0x00260000, nullptr, "PrepareToCloseSystemApplet"},
- {0x00270044, nullptr, "CloseApplication"},
- {0x00280044, nullptr, "CloseLibraryApplet"},
- {0x00290044, nullptr, "CloseSystemApplet"},
- {0x002A0000, nullptr, "OrderToCloseSystemApplet"},
- {0x002B0000, nullptr, "PrepareToJumpToHomeMenu"},
- {0x002C0044, nullptr, "JumpToHomeMenu"},
- {0x002D0000, nullptr, "PrepareToLeaveHomeMenu"},
- {0x002E0044, nullptr, "LeaveHomeMenu"},
- {0x002F0040, nullptr, "PrepareToLeaveResidentApplet"},
- {0x00300044, nullptr, "LeaveResidentApplet"},
- {0x00310100, nullptr, "PrepareToDoApplicationJump"},
- {0x00320084, nullptr, "DoApplicationJump"},
- {0x00330000, nullptr, "GetProgramIdOnApplicationJump"},
- {0x00340084, nullptr, "SendDeliverArg"},
- {0x00350080, nullptr, "ReceiveDeliverArg"},
- {0x00360040, nullptr, "LoadSysMenuArg"},
- {0x00370042, nullptr, "StoreSysMenuArg"},
- {0x00380040, nullptr, "PreloadResidentApplet"},
- {0x00390040, nullptr, "PrepareToStartResidentApplet"},
- {0x003A0044, nullptr, "StartResidentApplet"},
- {0x003B0040, nullptr, "CancelLibraryApplet"},
- {0x003C0042, nullptr, "SendDspSleep"},
- {0x003D0042, nullptr, "SendDspWakeUp"},
- {0x003E0080, nullptr, "ReplySleepQuery"},
- {0x003F0040, nullptr, "ReplySleepNotificationComplete"},
- {0x00400042, nullptr, "SendCaptureBufferInfo"},
- {0x00410040, nullptr, "ReceiveCaptureBufferInfo"},
- {0x00420080, nullptr, "SleepSystem"},
- {0x00430040, NotifyToWait, "NotifyToWait"},
- {0x00440000, GetSharedFont, "GetSharedFont"},
- {0x00450040, nullptr, "GetWirelessRebootInfo"},
- {0x00460104, nullptr, "Wrap"},
- {0x00470104, nullptr, "Unwrap"},
- {0x00480100, nullptr, "GetProgramInfo"},
- {0x00490180, nullptr, "Reboot"},
- {0x004A0040, nullptr, "GetCaptureInfo"},
- {0x004B00C2, AppletUtility, "AppletUtility"},
- {0x004C0000, nullptr, "SetFatalErrDispMode"},
- {0x004D0080, nullptr, "GetAppletProgramInfo"},
- {0x004E0000, nullptr, "HardwareResetAsync"},
- {0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"},
- {0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"},
- {0x00510080, GetStartupArgument, "GetStartupArgument"},
- {0x00520104, nullptr, "Wrap1"},
- {0x00530104, nullptr, "Unwrap1"},
+ {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
+ {0x00170040, nullptr, "FinishPreloadingLibraryApplet"},
+ {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
+ {0x00190040, nullptr, "PrepareToStartSystemApplet"},
+ {0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"},
+ {0x001B00C4, nullptr, "StartApplication"},
+ {0x001C0000, nullptr, "WakeupApplication"},
+ {0x001D0000, nullptr, "CancelApplication"},
+ {0x001E0084, nullptr, "StartLibraryApplet"},
+ {0x001F0084, nullptr, "StartSystemApplet"},
+ {0x00200044, nullptr, "StartNewestHomeMenu"},
+ {0x00210000, nullptr, "OrderToCloseApplication"},
+ {0x00220040, nullptr, "PrepareToCloseApplication"},
+ {0x00230040, nullptr, "PrepareToJumpToApplication"},
+ {0x00240044, nullptr, "JumpToApplication"},
+ {0x002500C0, nullptr, "PrepareToCloseLibraryApplet"},
+ {0x00260000, nullptr, "PrepareToCloseSystemApplet"},
+ {0x00270044, nullptr, "CloseApplication"},
+ {0x00280044, nullptr, "CloseLibraryApplet"},
+ {0x00290044, nullptr, "CloseSystemApplet"},
+ {0x002A0000, nullptr, "OrderToCloseSystemApplet"},
+ {0x002B0000, nullptr, "PrepareToJumpToHomeMenu"},
+ {0x002C0044, nullptr, "JumpToHomeMenu"},
+ {0x002D0000, nullptr, "PrepareToLeaveHomeMenu"},
+ {0x002E0044, nullptr, "LeaveHomeMenu"},
+ {0x002F0040, nullptr, "PrepareToLeaveResidentApplet"},
+ {0x00300044, nullptr, "LeaveResidentApplet"},
+ {0x00310100, nullptr, "PrepareToDoApplicationJump"},
+ {0x00320084, nullptr, "DoApplicationJump"},
+ {0x00330000, nullptr, "GetProgramIdOnApplicationJump"},
+ {0x00340084, nullptr, "SendDeliverArg"},
+ {0x00350080, nullptr, "ReceiveDeliverArg"},
+ {0x00360040, nullptr, "LoadSysMenuArg"},
+ {0x00370042, nullptr, "StoreSysMenuArg"},
+ {0x00380040, nullptr, "PreloadResidentApplet"},
+ {0x00390040, nullptr, "PrepareToStartResidentApplet"},
+ {0x003A0044, nullptr, "StartResidentApplet"},
+ {0x003B0040, nullptr, "CancelLibraryApplet"},
+ {0x003C0042, nullptr, "SendDspSleep"},
+ {0x003D0042, nullptr, "SendDspWakeUp"},
+ {0x003E0080, nullptr, "ReplySleepQuery"},
+ {0x003F0040, nullptr, "ReplySleepNotificationComplete"},
+ {0x00400042, nullptr, "SendCaptureBufferInfo"},
+ {0x00410040, nullptr, "ReceiveCaptureBufferInfo"},
+ {0x00420080, nullptr, "SleepSystem"},
+ {0x00430040, NotifyToWait, "NotifyToWait"},
+ {0x00440000, GetSharedFont, "GetSharedFont"},
+ {0x00450040, nullptr, "GetWirelessRebootInfo"},
+ {0x00460104, nullptr, "Wrap"},
+ {0x00470104, nullptr, "Unwrap"},
+ {0x00480100, nullptr, "GetProgramInfo"},
+ {0x00490180, nullptr, "Reboot"},
+ {0x004A0040, nullptr, "GetCaptureInfo"},
+ {0x004B00C2, AppletUtility, "AppletUtility"},
+ {0x004C0000, nullptr, "SetFatalErrDispMode"},
+ {0x004D0080, nullptr, "GetAppletProgramInfo"},
+ {0x004E0000, nullptr, "HardwareResetAsync"},
+ {0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"},
+ {0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"},
+ {0x00510080, GetStartupArgument, "GetStartupArgument"},
+ {0x00520104, nullptr, "Wrap1"},
+ {0x00530104, nullptr, "Unwrap1"},
{0x00550040, SetScreenCapPostPermission, "SetScreenCapPostPermission"},
{0x00560000, GetScreenCapPostPermission, "GetScreenCapPostPermission"},
- {0x00580002, nullptr, "GetProgramID"},
- {0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
- {0x01020000, CheckNew3DS, "CheckNew3DS"}
+ {0x00580002, nullptr, "GetProgramID"},
+ {0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
+ {0x01020000, CheckNew3DS, "CheckNew3DS"},
};
APT_S_Interface::APT_S_Interface() {
diff --git a/src/core/hle/service/apt/apt_u.cpp b/src/core/hle/service/apt/apt_u.cpp
index 7bb804ffa..d6ad42e21 100644
--- a/src/core/hle/service/apt/apt_u.cpp
+++ b/src/core/hle/service/apt/apt_u.cpp
@@ -9,94 +9,94 @@ namespace Service {
namespace APT {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010040, GetLockHandle, "GetLockHandle"},
- {0x00020080, Initialize, "Initialize"},
- {0x00030040, Enable, "Enable"},
- {0x00040040, nullptr, "Finalize"},
- {0x00050040, GetAppletManInfo, "GetAppletManInfo"},
- {0x00060040, GetAppletInfo, "GetAppletInfo"},
- {0x00070000, nullptr, "GetLastSignaledAppletId"},
- {0x00080000, nullptr, "CountRegisteredApplet"},
- {0x00090040, IsRegistered, "IsRegistered"},
- {0x000A0040, nullptr, "GetAttribute"},
- {0x000B0040, InquireNotification, "InquireNotification"},
- {0x000C0104, SendParameter, "SendParameter"},
- {0x000D0080, ReceiveParameter, "ReceiveParameter"},
- {0x000E0080, GlanceParameter, "GlanceParameter"},
- {0x000F0100, CancelParameter, "CancelParameter"},
- {0x001000C2, nullptr, "DebugFunc"},
- {0x001100C0, nullptr, "MapProgramIdForDebug"},
- {0x00120040, nullptr, "SetHomeMenuAppletIdForDebug"},
- {0x00130000, nullptr, "GetPreparationState"},
- {0x00140040, nullptr, "SetPreparationState"},
- {0x00150140, PrepareToStartApplication, "PrepareToStartApplication"},
- {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
- {0x00170040, nullptr, "FinishPreloadingLibraryApplet"},
- {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
- {0x00190040, nullptr, "PrepareToStartSystemApplet"},
- {0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"},
- {0x001B00C4, nullptr, "StartApplication"},
- {0x001C0000, nullptr, "WakeupApplication"},
- {0x001D0000, nullptr, "CancelApplication"},
- {0x001E0084, StartLibraryApplet, "StartLibraryApplet"},
- {0x001F0084, nullptr, "StartSystemApplet"},
- {0x00200044, nullptr, "StartNewestHomeMenu"},
- {0x00210000, nullptr, "OrderToCloseApplication"},
- {0x00220040, nullptr, "PrepareToCloseApplication"},
- {0x00230040, nullptr, "PrepareToJumpToApplication"},
- {0x00240044, nullptr, "JumpToApplication"},
- {0x002500C0, nullptr, "PrepareToCloseLibraryApplet"},
- {0x00260000, nullptr, "PrepareToCloseSystemApplet"},
- {0x00270044, nullptr, "CloseApplication"},
- {0x00280044, nullptr, "CloseLibraryApplet"},
- {0x00290044, nullptr, "CloseSystemApplet"},
- {0x002A0000, nullptr, "OrderToCloseSystemApplet"},
- {0x002B0000, nullptr, "PrepareToJumpToHomeMenu"},
- {0x002C0044, nullptr, "JumpToHomeMenu"},
- {0x002D0000, nullptr, "PrepareToLeaveHomeMenu"},
- {0x002E0044, nullptr, "LeaveHomeMenu"},
- {0x002F0040, nullptr, "PrepareToLeaveResidentApplet"},
- {0x00300044, nullptr, "LeaveResidentApplet"},
- {0x00310100, nullptr, "PrepareToDoApplicationJump"},
- {0x00320084, nullptr, "DoApplicationJump"},
- {0x00330000, nullptr, "GetProgramIdOnApplicationJump"},
- {0x00340084, nullptr, "SendDeliverArg"},
- {0x00350080, nullptr, "ReceiveDeliverArg"},
- {0x00360040, nullptr, "LoadSysMenuArg"},
- {0x00370042, nullptr, "StoreSysMenuArg"},
- {0x00380040, nullptr, "PreloadResidentApplet"},
- {0x00390040, nullptr, "PrepareToStartResidentApplet"},
- {0x003A0044, nullptr, "StartResidentApplet"},
- {0x003B0040, nullptr, "CancelLibraryApplet"},
- {0x003C0042, nullptr, "SendDspSleep"},
- {0x003D0042, nullptr, "SendDspWakeUp"},
- {0x003E0080, nullptr, "ReplySleepQuery"},
- {0x003F0040, nullptr, "ReplySleepNotificationComplete"},
- {0x00400042, nullptr, "SendCaptureBufferInfo"},
- {0x00410040, nullptr, "ReceiveCaptureBufferInfo"},
- {0x00420080, nullptr, "SleepSystem"},
- {0x00430040, NotifyToWait, "NotifyToWait"},
- {0x00440000, GetSharedFont, "GetSharedFont"},
- {0x00450040, nullptr, "GetWirelessRebootInfo"},
- {0x00460104, nullptr, "Wrap"},
- {0x00470104, nullptr, "Unwrap"},
- {0x00480100, nullptr, "GetProgramInfo"},
- {0x00490180, nullptr, "Reboot"},
- {0x004A0040, nullptr, "GetCaptureInfo"},
- {0x004B00C2, AppletUtility, "AppletUtility"},
- {0x004C0000, nullptr, "SetFatalErrDispMode"},
- {0x004D0080, nullptr, "GetAppletProgramInfo"},
- {0x004E0000, nullptr, "HardwareResetAsync"},
- {0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"},
- {0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"},
- {0x00510080, GetStartupArgument, "GetStartupArgument"},
- {0x00520104, nullptr, "Wrap1"},
- {0x00530104, nullptr, "Unwrap1"},
- {0x00550040, SetScreenCapPostPermission, "SetScreenCapPostPermission"},
- {0x00560000, GetScreenCapPostPermission, "GetScreenCapPostPermission"},
- {0x00580002, nullptr, "GetProgramID"},
- {0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
- {0x01020000, CheckNew3DS, "CheckNew3DS"}
+ {0x00010040, GetLockHandle, "GetLockHandle"},
+ {0x00020080, Initialize, "Initialize"},
+ {0x00030040, Enable, "Enable"},
+ {0x00040040, nullptr, "Finalize"},
+ {0x00050040, GetAppletManInfo, "GetAppletManInfo"},
+ {0x00060040, GetAppletInfo, "GetAppletInfo"},
+ {0x00070000, nullptr, "GetLastSignaledAppletId"},
+ {0x00080000, nullptr, "CountRegisteredApplet"},
+ {0x00090040, IsRegistered, "IsRegistered"},
+ {0x000A0040, nullptr, "GetAttribute"},
+ {0x000B0040, InquireNotification, "InquireNotification"},
+ {0x000C0104, SendParameter, "SendParameter"},
+ {0x000D0080, ReceiveParameter, "ReceiveParameter"},
+ {0x000E0080, GlanceParameter, "GlanceParameter"},
+ {0x000F0100, CancelParameter, "CancelParameter"},
+ {0x001000C2, nullptr, "DebugFunc"},
+ {0x001100C0, nullptr, "MapProgramIdForDebug"},
+ {0x00120040, nullptr, "SetHomeMenuAppletIdForDebug"},
+ {0x00130000, nullptr, "GetPreparationState"},
+ {0x00140040, nullptr, "SetPreparationState"},
+ {0x00150140, PrepareToStartApplication, "PrepareToStartApplication"},
+ {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
+ {0x00170040, nullptr, "FinishPreloadingLibraryApplet"},
+ {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
+ {0x00190040, nullptr, "PrepareToStartSystemApplet"},
+ {0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"},
+ {0x001B00C4, nullptr, "StartApplication"},
+ {0x001C0000, nullptr, "WakeupApplication"},
+ {0x001D0000, nullptr, "CancelApplication"},
+ {0x001E0084, StartLibraryApplet, "StartLibraryApplet"},
+ {0x001F0084, nullptr, "StartSystemApplet"},
+ {0x00200044, nullptr, "StartNewestHomeMenu"},
+ {0x00210000, nullptr, "OrderToCloseApplication"},
+ {0x00220040, nullptr, "PrepareToCloseApplication"},
+ {0x00230040, nullptr, "PrepareToJumpToApplication"},
+ {0x00240044, nullptr, "JumpToApplication"},
+ {0x002500C0, nullptr, "PrepareToCloseLibraryApplet"},
+ {0x00260000, nullptr, "PrepareToCloseSystemApplet"},
+ {0x00270044, nullptr, "CloseApplication"},
+ {0x00280044, nullptr, "CloseLibraryApplet"},
+ {0x00290044, nullptr, "CloseSystemApplet"},
+ {0x002A0000, nullptr, "OrderToCloseSystemApplet"},
+ {0x002B0000, nullptr, "PrepareToJumpToHomeMenu"},
+ {0x002C0044, nullptr, "JumpToHomeMenu"},
+ {0x002D0000, nullptr, "PrepareToLeaveHomeMenu"},
+ {0x002E0044, nullptr, "LeaveHomeMenu"},
+ {0x002F0040, nullptr, "PrepareToLeaveResidentApplet"},
+ {0x00300044, nullptr, "LeaveResidentApplet"},
+ {0x00310100, nullptr, "PrepareToDoApplicationJump"},
+ {0x00320084, nullptr, "DoApplicationJump"},
+ {0x00330000, nullptr, "GetProgramIdOnApplicationJump"},
+ {0x00340084, nullptr, "SendDeliverArg"},
+ {0x00350080, nullptr, "ReceiveDeliverArg"},
+ {0x00360040, nullptr, "LoadSysMenuArg"},
+ {0x00370042, nullptr, "StoreSysMenuArg"},
+ {0x00380040, nullptr, "PreloadResidentApplet"},
+ {0x00390040, nullptr, "PrepareToStartResidentApplet"},
+ {0x003A0044, nullptr, "StartResidentApplet"},
+ {0x003B0040, nullptr, "CancelLibraryApplet"},
+ {0x003C0042, nullptr, "SendDspSleep"},
+ {0x003D0042, nullptr, "SendDspWakeUp"},
+ {0x003E0080, nullptr, "ReplySleepQuery"},
+ {0x003F0040, nullptr, "ReplySleepNotificationComplete"},
+ {0x00400042, nullptr, "SendCaptureBufferInfo"},
+ {0x00410040, nullptr, "ReceiveCaptureBufferInfo"},
+ {0x00420080, nullptr, "SleepSystem"},
+ {0x00430040, NotifyToWait, "NotifyToWait"},
+ {0x00440000, GetSharedFont, "GetSharedFont"},
+ {0x00450040, nullptr, "GetWirelessRebootInfo"},
+ {0x00460104, nullptr, "Wrap"},
+ {0x00470104, nullptr, "Unwrap"},
+ {0x00480100, nullptr, "GetProgramInfo"},
+ {0x00490180, nullptr, "Reboot"},
+ {0x004A0040, nullptr, "GetCaptureInfo"},
+ {0x004B00C2, AppletUtility, "AppletUtility"},
+ {0x004C0000, nullptr, "SetFatalErrDispMode"},
+ {0x004D0080, nullptr, "GetAppletProgramInfo"},
+ {0x004E0000, nullptr, "HardwareResetAsync"},
+ {0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"},
+ {0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"},
+ {0x00510080, GetStartupArgument, "GetStartupArgument"},
+ {0x00520104, nullptr, "Wrap1"},
+ {0x00530104, nullptr, "Unwrap1"},
+ {0x00550040, SetScreenCapPostPermission, "SetScreenCapPostPermission"},
+ {0x00560000, GetScreenCapPostPermission, "GetScreenCapPostPermission"},
+ {0x00580002, nullptr, "GetProgramID"},
+ {0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
+ {0x01020000, CheckNew3DS, "CheckNew3DS"},
};
APT_U_Interface::APT_U_Interface() {
diff --git a/src/core/hle/service/apt/bcfnt/bcfnt.h b/src/core/hle/service/apt/bcfnt/bcfnt.h
index 8936dcf63..453bf7606 100644
--- a/src/core/hle/service/apt/bcfnt/bcfnt.h
+++ b/src/core/hle/service/apt/bcfnt/bcfnt.h
@@ -5,7 +5,6 @@
#pragma once
#include "common/swap.h"
-
#include "core/hle/kernel/shared_memory.h"
#include "core/hle/service/service.h"
diff --git a/src/core/hle/service/boss/boss.cpp b/src/core/hle/service/boss/boss.cpp
index 419ec976e..757a8c2c7 100644
--- a/src/core/hle/service/boss/boss.cpp
+++ b/src/core/hle/service/boss/boss.cpp
@@ -2,10 +2,10 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
-#include "core/hle/service/service.h"
#include "core/hle/service/boss/boss.h"
#include "core/hle/service/boss/boss_p.h"
#include "core/hle/service/boss/boss_u.h"
+#include "core/hle/service/service.h"
namespace Service {
namespace BOSS {
@@ -17,8 +17,7 @@ void Init() {
AddService(new BOSS_U_Interface);
}
-void Shutdown() {
-}
+void Shutdown() {}
} // namespace BOSS
diff --git a/src/core/hle/service/boss/boss_p.cpp b/src/core/hle/service/boss/boss_p.cpp
index c498abe4e..dfee8d055 100644
--- a/src/core/hle/service/boss/boss_p.cpp
+++ b/src/core/hle/service/boss/boss_p.cpp
@@ -11,7 +11,7 @@ namespace BOSS {
// const Interface::FunctionInfo FunctionTable[] = { };
BOSS_P_Interface::BOSS_P_Interface() {
- //Register(FunctionTable);
+ // Register(FunctionTable);
}
} // namespace BOSS
diff --git a/src/core/hle/service/boss/boss_u.cpp b/src/core/hle/service/boss/boss_u.cpp
index d59babe71..6affa23b1 100644
--- a/src/core/hle/service/boss/boss_u.cpp
+++ b/src/core/hle/service/boss/boss_u.cpp
@@ -8,10 +8,10 @@ namespace Service {
namespace BOSS {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00020100, nullptr, "GetStorageInfo"},
- {0x000C0082, nullptr, "UnregisterTask"},
- {0x001E0042, nullptr, "CancelTask"},
- {0x00330042, nullptr, "StartBgImmediate"},
+ {0x00020100, nullptr, "GetStorageInfo"},
+ {0x000C0082, nullptr, "UnregisterTask"},
+ {0x001E0042, nullptr, "CancelTask"},
+ {0x00330042, nullptr, "StartBgImmediate"},
};
BOSS_U_Interface::BOSS_U_Interface() {
diff --git a/src/core/hle/service/cam/cam.cpp b/src/core/hle/service/cam/cam.cpp
index 6edcf9610..5594aedab 100644
--- a/src/core/hle/service/cam/cam.cpp
+++ b/src/core/hle/service/cam/cam.cpp
@@ -3,7 +3,6 @@
// Refer to the license.txt file included.
#include "common/logging/log.h"
-
#include "core/hle/kernel/event.h"
#include "core/hle/service/cam/cam.h"
#include "core/hle/service/cam/cam_c.h"
@@ -71,15 +70,15 @@ void GetBufferErrorInterruptEvent(Service::Interface* self) {
}
void SetReceiving(Service::Interface* self) {
- u32* cmd_buff = Kernel::GetCommandBuffer();
+ u32* cmd_buff = Kernel::GetCommandBuffer();
- VAddr dest = cmd_buff[1];
- u8 port = cmd_buff[2] & 0xFF;
+ VAddr dest = cmd_buff[1];
+ u8 port = cmd_buff[2] & 0xFF;
u32 image_size = cmd_buff[3];
u16 trans_unit = cmd_buff[4] & 0xFFFF;
- Kernel::Event* completion_event = (Port)port == Port::Cam2 ?
- completion_event_cam2.get() : completion_event_cam1.get();
+ Kernel::Event* completion_event =
+ (Port)port == Port::Cam2 ? completion_event_cam2.get() : completion_event_cam1.get();
completion_event->Signal();
@@ -89,36 +88,36 @@ void SetReceiving(Service::Interface* self) {
cmd_buff[3] = Kernel::g_handle_table.Create(completion_event).MoveFrom();
LOG_WARNING(Service_CAM, "(STUBBED) called, addr=0x%X, port=%d, image_size=%d, trans_unit=%d",
- dest, port, image_size, trans_unit);
+ dest, port, image_size, trans_unit);
}
void SetTransferLines(Service::Interface* self) {
- u32* cmd_buff = Kernel::GetCommandBuffer();
+ u32* cmd_buff = Kernel::GetCommandBuffer();
- u8 port = cmd_buff[1] & 0xFF;
+ u8 port = cmd_buff[1] & 0xFF;
u16 transfer_lines = cmd_buff[2] & 0xFFFF;
- u16 width = cmd_buff[3] & 0xFFFF;
- u16 height = cmd_buff[4] & 0xFFFF;
+ u16 width = cmd_buff[3] & 0xFFFF;
+ u16 height = cmd_buff[4] & 0xFFFF;
cmd_buff[0] = IPC::MakeHeader(0x9, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
- LOG_WARNING(Service_CAM, "(STUBBED) called, port=%d, lines=%d, width=%d, height=%d",
- port, transfer_lines, width, height);
+ LOG_WARNING(Service_CAM, "(STUBBED) called, port=%d, lines=%d, width=%d, height=%d", port,
+ transfer_lines, width, height);
}
void GetMaxLines(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- u16 width = cmd_buff[1] & 0xFFFF;
+ u16 width = cmd_buff[1] & 0xFFFF;
u16 height = cmd_buff[2] & 0xFFFF;
cmd_buff[0] = IPC::MakeHeader(0xA, 2, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = TRANSFER_BYTES / (2 * width);
- LOG_WARNING(Service_CAM, "(STUBBED) called, width=%d, height=%d, lines = %d",
- width, height, cmd_buff[2]);
+ LOG_WARNING(Service_CAM, "(STUBBED) called, width=%d, height=%d, lines = %d", width, height,
+ cmd_buff[2]);
}
void GetTransferBytes(Service::Interface* self) {
@@ -136,7 +135,7 @@ void GetTransferBytes(Service::Interface* self) {
void SetTrimming(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- u8 port = cmd_buff[1] & 0xFF;
+ u8 port = cmd_buff[1] & 0xFF;
bool trim = (cmd_buff[2] & 0xFF) != 0;
cmd_buff[0] = IPC::MakeHeader(0xE, 1, 0);
@@ -148,17 +147,17 @@ void SetTrimming(Service::Interface* self) {
void SetTrimmingParamsCenter(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- u8 port = cmd_buff[1] & 0xFF;
+ u8 port = cmd_buff[1] & 0xFF;
s16 trimW = cmd_buff[2] & 0xFFFF;
s16 trimH = cmd_buff[3] & 0xFFFF;
- s16 camW = cmd_buff[4] & 0xFFFF;
- s16 camH = cmd_buff[5] & 0xFFFF;
+ s16 camW = cmd_buff[4] & 0xFFFF;
+ s16 camH = cmd_buff[5] & 0xFFFF;
cmd_buff[0] = IPC::MakeHeader(0x12, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_CAM, "(STUBBED) called, port=%d, trimW=%d, trimH=%d, camW=%d, camH=%d",
- port, trimW, trimH, camW, camH);
+ port, trimW, trimH, camW, camH);
}
void Activate(Service::Interface* self) {
@@ -169,36 +168,35 @@ void Activate(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x13, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
- LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d",
- cam_select);
+ LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d", cam_select);
}
void FlipImage(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u8 cam_select = cmd_buff[1] & 0xFF;
- u8 flip = cmd_buff[2] & 0xFF;
- u8 context = cmd_buff[3] & 0xFF;
+ u8 flip = cmd_buff[2] & 0xFF;
+ u8 context = cmd_buff[3] & 0xFF;
cmd_buff[0] = IPC::MakeHeader(0x1D, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
- LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d, flip=%d, context=%d",
- cam_select, flip, context);
+ LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d, flip=%d, context=%d", cam_select,
+ flip, context);
}
void SetSize(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u8 cam_select = cmd_buff[1] & 0xFF;
- u8 size = cmd_buff[2] & 0xFF;
- u8 context = cmd_buff[3] & 0xFF;
+ u8 size = cmd_buff[2] & 0xFF;
+ u8 context = cmd_buff[3] & 0xFF;
cmd_buff[0] = IPC::MakeHeader(0x1F, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
- LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d, size=%d, context=%d",
- cam_select, size, context);
+ LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d, size=%d, context=%d", cam_select,
+ size, context);
}
void SetFrameRate(Service::Interface* self) {
@@ -210,8 +208,8 @@ void SetFrameRate(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x20, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
- LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d, frame_rate=%d",
- cam_select, frame_rate);
+ LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d, frame_rate=%d", cam_select,
+ frame_rate);
}
void GetStereoCameraCalibrationData(Service::Interface* self) {
@@ -293,10 +291,14 @@ void Init() {
AddService(new CAM_S_Interface);
AddService(new CAM_U_Interface);
- completion_event_cam1 = Kernel::Event::Create(ResetType::OneShot, "CAM_U::completion_event_cam1");
- completion_event_cam2 = Kernel::Event::Create(ResetType::OneShot, "CAM_U::completion_event_cam2");
- interrupt_error_event = Kernel::Event::Create(ResetType::OneShot, "CAM_U::interrupt_error_event");
- vsync_interrupt_error_event = Kernel::Event::Create(ResetType::OneShot, "CAM_U::vsync_interrupt_error_event");
+ completion_event_cam1 =
+ Kernel::Event::Create(ResetType::OneShot, "CAM_U::completion_event_cam1");
+ completion_event_cam2 =
+ Kernel::Event::Create(ResetType::OneShot, "CAM_U::completion_event_cam2");
+ interrupt_error_event =
+ Kernel::Event::Create(ResetType::OneShot, "CAM_U::interrupt_error_event");
+ vsync_interrupt_error_event =
+ Kernel::Event::Create(ResetType::OneShot, "CAM_U::vsync_interrupt_error_event");
}
void Shutdown() {
diff --git a/src/core/hle/service/cam/cam.h b/src/core/hle/service/cam/cam.h
index 2f4923728..c9b6f8acf 100644
--- a/src/core/hle/service/cam/cam.h
+++ b/src/core/hle/service/cam/cam.h
@@ -7,19 +7,13 @@
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "common/swap.h"
-
#include "core/hle/kernel/kernel.h"
#include "core/hle/service/service.h"
namespace Service {
namespace CAM {
-enum class Port : u8 {
- None = 0,
- Cam1 = 1,
- Cam2 = 2,
- Both = Cam1 | Cam2
-};
+enum class Port : u8 { None = 0, Cam1 = 1, Cam2 = 2, Both = Cam1 | Cam2 };
enum class CameraSelect : u8 {
None = 0,
@@ -29,7 +23,7 @@ enum class CameraSelect : u8 {
In1Out1 = Out1 | In1,
Out1Out2 = Out1 | Out2,
In1Out2 = In1 | Out2,
- All = Out1 | In1 | Out2
+ All = Out1 | In1 | Out2,
};
enum class Effect : u8 {
@@ -38,21 +32,21 @@ enum class Effect : u8 {
Sepia = 2,
Negative = 3,
Negafilm = 4,
- Sepia01 = 5
+ Sepia01 = 5,
};
enum class Context : u8 {
None = 0,
A = 1,
B = 2,
- Both = A | B
+ Both = A | B,
};
enum class Flip : u8 {
None = 0,
Horizontal = 1,
Vertical = 2,
- Reverse = 3
+ Reverse = 3,
};
enum class Size : u8 {
@@ -64,7 +58,7 @@ enum class Size : u8 {
DS_LCD = 5,
DS_LCDx4 = 6,
CTR_TOP_LCD = 7,
- CTR_BOTTOM_LCD = QVGA
+ CTR_BOTTOM_LCD = QVGA,
};
enum class FrameRate : u8 {
@@ -80,13 +74,13 @@ enum class FrameRate : u8 {
Rate_30_To_5 = 9,
Rate_15_To_10 = 10,
Rate_20_To_10 = 11,
- Rate_30_To_10 = 12
+ Rate_30_To_10 = 12,
};
enum class ShutterSoundType : u8 {
Normal = 0,
Movie = 1,
- MovieEnd = 2
+ MovieEnd = 2,
};
enum class WhiteBalance : u8 {
@@ -103,7 +97,7 @@ enum class WhiteBalance : u8 {
BalanceDaylight = Balance5200K,
BalanceCloudy = Balance6000K,
BalanceHorizon = Balance6000K,
- BalanceShade = Balance7000K
+ BalanceShade = Balance7000K,
};
enum class PhotoMode : u8 {
@@ -111,7 +105,7 @@ enum class PhotoMode : u8 {
Portrait = 1,
Landscape = 2,
Nightview = 3,
- Letter0 = 4
+ Letter0 = 4,
};
enum class LensCorrection : u8 {
@@ -120,7 +114,7 @@ enum class LensCorrection : u8 {
On90 = 2,
Dark = Off,
Normal = On70,
- Bright = On90
+ Bright = On90,
};
enum class Contrast : u8 {
@@ -137,24 +131,24 @@ enum class Contrast : u8 {
Pattern11 = 11,
Low = Pattern05,
Normal = Pattern06,
- High = Pattern07
+ High = Pattern07,
};
enum class OutputFormat : u8 {
YUV422 = 0,
- RGB565 = 1
+ RGB565 = 1,
};
/// Stereo camera calibration data.
struct StereoCameraCalibrationData {
- u8 isValidRotationXY; ///< Bool indicating whether the X and Y rotation data is valid.
+ u8 isValidRotationXY; ///< Bool indicating whether the X and Y rotation data is valid.
INSERT_PADDING_BYTES(3);
- float_le scale; ///< Scale to match the left camera image with the right.
- float_le rotationZ; ///< Z axis rotation to match the left camera image with the right.
- float_le translationX; ///< X axis translation to match the left camera image with the right.
- float_le translationY; ///< Y axis translation to match the left camera image with the right.
- float_le rotationX; ///< X axis rotation to match the left camera image with the right.
- float_le rotationY; ///< Y axis rotation to match the left camera image with the right.
+ float_le scale; ///< Scale to match the left camera image with the right.
+ float_le rotationZ; ///< Z axis rotation to match the left camera image with the right.
+ float_le translationX; ///< X axis translation to match the left camera image with the right.
+ float_le translationY; ///< Y axis translation to match the left camera image with the right.
+ float_le rotationX; ///< X axis rotation to match the left camera image with the right.
+ float_le rotationY; ///< Y axis rotation to match the left camera image with the right.
float_le angleOfViewRight; ///< Right camera angle of view.
float_le angleOfViewLeft; ///< Left camera angle of view.
float_le distanceToChart; ///< Distance between cameras and measurement chart.
@@ -163,7 +157,8 @@ struct StereoCameraCalibrationData {
s16_le imageHeight; ///< Image height.
INSERT_PADDING_BYTES(16);
};
-static_assert(sizeof(StereoCameraCalibrationData) == 64, "StereoCameraCalibrationData structure size is wrong");
+static_assert(sizeof(StereoCameraCalibrationData) == 64,
+ "StereoCameraCalibrationData structure size is wrong");
struct PackageParameterCameraSelect {
CameraSelect camera;
@@ -188,7 +183,8 @@ struct PackageParameterCameraSelect {
s16 auto_white_balance_window_height;
};
-static_assert(sizeof(PackageParameterCameraSelect) == 28, "PackageParameterCameraSelect structure size is wrong");
+static_assert(sizeof(PackageParameterCameraSelect) == 28,
+ "PackageParameterCameraSelect structure size is wrong");
/**
* Unknown
diff --git a/src/core/hle/service/cam/cam_c.cpp b/src/core/hle/service/cam/cam_c.cpp
index 8fa7abc85..93b047c1a 100644
--- a/src/core/hle/service/cam/cam_c.cpp
+++ b/src/core/hle/service/cam/cam_c.cpp
@@ -8,10 +8,10 @@ namespace Service {
namespace CAM {
// Empty arrays are illegal -- commented out until an entry is added.
-//const Interface::FunctionInfo FunctionTable[] = { };
+// const Interface::FunctionInfo FunctionTable[] = { };
CAM_C_Interface::CAM_C_Interface() {
- //Register(FunctionTable);
+ // Register(FunctionTable);
}
} // namespace CAM
diff --git a/src/core/hle/service/cam/cam_q.cpp b/src/core/hle/service/cam/cam_q.cpp
index d3ba91e9d..2ba853606 100644
--- a/src/core/hle/service/cam/cam_q.cpp
+++ b/src/core/hle/service/cam/cam_q.cpp
@@ -8,10 +8,10 @@ namespace Service {
namespace CAM {
// Empty arrays are illegal -- commented out until an entry is added.
-//const Interface::FunctionInfo FunctionTable[] = { };
+// const Interface::FunctionInfo FunctionTable[] = { };
CAM_Q_Interface::CAM_Q_Interface() {
- //Register(FunctionTable);
+ // Register(FunctionTable);
}
} // namespace CAM
diff --git a/src/core/hle/service/cam/cam_s.cpp b/src/core/hle/service/cam/cam_s.cpp
index 2a13984d8..f1c6da587 100644
--- a/src/core/hle/service/cam/cam_s.cpp
+++ b/src/core/hle/service/cam/cam_s.cpp
@@ -8,10 +8,10 @@ namespace Service {
namespace CAM {
// Empty arrays are illegal -- commented out until an entry is added.
-//const Interface::FunctionInfo FunctionTable[] = { };
+// const Interface::FunctionInfo FunctionTable[] = { };
CAM_S_Interface::CAM_S_Interface() {
- //Register(FunctionTable);
+ // Register(FunctionTable);
}
} // namespace CAM
diff --git a/src/core/hle/service/cam/cam_u.cpp b/src/core/hle/service/cam/cam_u.cpp
index a1070ebb2..af2123e5b 100644
--- a/src/core/hle/service/cam/cam_u.cpp
+++ b/src/core/hle/service/cam/cam_u.cpp
@@ -9,68 +9,68 @@ namespace Service {
namespace CAM {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010040, StartCapture, "StartCapture"},
- {0x00020040, StopCapture, "StopCapture"},
- {0x00030040, nullptr, "IsBusy"},
- {0x00040040, nullptr, "ClearBuffer"},
- {0x00050040, GetVsyncInterruptEvent, "GetVsyncInterruptEvent"},
- {0x00060040, GetBufferErrorInterruptEvent, "GetBufferErrorInterruptEvent"},
- {0x00070102, SetReceiving, "SetReceiving"},
- {0x00080040, nullptr, "IsFinishedReceiving"},
- {0x00090100, SetTransferLines, "SetTransferLines"},
- {0x000A0080, GetMaxLines, "GetMaxLines"},
- {0x000B0100, nullptr, "SetTransferBytes"},
- {0x000C0040, GetTransferBytes, "GetTransferBytes"},
- {0x000D0080, nullptr, "GetMaxBytes"},
- {0x000E0080, SetTrimming, "SetTrimming"},
- {0x000F0040, nullptr, "IsTrimming"},
- {0x00100140, nullptr, "SetTrimmingParams"},
- {0x00110040, nullptr, "GetTrimmingParams"},
- {0x00120140, SetTrimmingParamsCenter, "SetTrimmingParamsCenter"},
- {0x00130040, Activate, "Activate"},
- {0x00140080, nullptr, "SwitchContext"},
- {0x00150080, nullptr, "SetExposure"},
- {0x00160080, nullptr, "SetWhiteBalance"},
- {0x00170080, nullptr, "SetWhiteBalanceWithoutBaseUp"},
- {0x00180080, nullptr, "SetSharpness"},
- {0x00190080, nullptr, "SetAutoExposure"},
- {0x001A0040, nullptr, "IsAutoExposure"},
- {0x001B0080, nullptr, "SetAutoWhiteBalance"},
- {0x001C0040, nullptr, "IsAutoWhiteBalance"},
- {0x001D00C0, FlipImage, "FlipImage"},
- {0x001E0200, nullptr, "SetDetailSize"},
- {0x001F00C0, SetSize, "SetSize"},
- {0x00200080, SetFrameRate, "SetFrameRate"},
- {0x00210080, nullptr, "SetPhotoMode"},
- {0x002200C0, nullptr, "SetEffect"},
- {0x00230080, nullptr, "SetContrast"},
- {0x00240080, nullptr, "SetLensCorrection"},
- {0x002500C0, nullptr, "SetOutputFormat"},
- {0x00260140, nullptr, "SetAutoExposureWindow"},
- {0x00270140, nullptr, "SetAutoWhiteBalanceWindow"},
- {0x00280080, nullptr, "SetNoiseFilter"},
- {0x00290080, nullptr, "SynchronizeVsyncTiming"},
- {0x002A0080, nullptr, "GetLatestVsyncTiming"},
- {0x002B0000, GetStereoCameraCalibrationData, "GetStereoCameraCalibrationData"},
- {0x002C0400, nullptr, "SetStereoCameraCalibrationData"},
- {0x002D00C0, nullptr, "WriteRegisterI2c"},
- {0x002E00C0, nullptr, "WriteMcuVariableI2c"},
- {0x002F0080, nullptr, "ReadRegisterI2cExclusive"},
- {0x00300080, nullptr, "ReadMcuVariableI2cExclusive"},
- {0x00310180, nullptr, "SetImageQualityCalibrationData"},
- {0x00320000, nullptr, "GetImageQualityCalibrationData"},
- {0x003302C0, nullptr, "SetPackageParameterWithoutContext"},
- {0x00340140, nullptr, "SetPackageParameterWithContext"},
- {0x003501C0, nullptr, "SetPackageParameterWithContextDetail"},
- {0x00360000, GetSuitableY2rStandardCoefficient, "GetSuitableY2rStandardCoefficient"},
- {0x00370202, nullptr, "PlayShutterSoundWithWave"},
- {0x00380040, PlayShutterSound, "PlayShutterSound"},
- {0x00390000, DriverInitialize, "DriverInitialize"},
- {0x003A0000, DriverFinalize, "DriverFinalize"},
- {0x003B0000, nullptr, "GetActivatedCamera"},
- {0x003C0000, nullptr, "GetSleepCamera"},
- {0x003D0040, nullptr, "SetSleepCamera"},
- {0x003E0040, nullptr, "SetBrightnessSynchronization"},
+ {0x00010040, StartCapture, "StartCapture"},
+ {0x00020040, StopCapture, "StopCapture"},
+ {0x00030040, nullptr, "IsBusy"},
+ {0x00040040, nullptr, "ClearBuffer"},
+ {0x00050040, GetVsyncInterruptEvent, "GetVsyncInterruptEvent"},
+ {0x00060040, GetBufferErrorInterruptEvent, "GetBufferErrorInterruptEvent"},
+ {0x00070102, SetReceiving, "SetReceiving"},
+ {0x00080040, nullptr, "IsFinishedReceiving"},
+ {0x00090100, SetTransferLines, "SetTransferLines"},
+ {0x000A0080, GetMaxLines, "GetMaxLines"},
+ {0x000B0100, nullptr, "SetTransferBytes"},
+ {0x000C0040, GetTransferBytes, "GetTransferBytes"},
+ {0x000D0080, nullptr, "GetMaxBytes"},
+ {0x000E0080, SetTrimming, "SetTrimming"},
+ {0x000F0040, nullptr, "IsTrimming"},
+ {0x00100140, nullptr, "SetTrimmingParams"},
+ {0x00110040, nullptr, "GetTrimmingParams"},
+ {0x00120140, SetTrimmingParamsCenter, "SetTrimmingParamsCenter"},
+ {0x00130040, Activate, "Activate"},
+ {0x00140080, nullptr, "SwitchContext"},
+ {0x00150080, nullptr, "SetExposure"},
+ {0x00160080, nullptr, "SetWhiteBalance"},
+ {0x00170080, nullptr, "SetWhiteBalanceWithoutBaseUp"},
+ {0x00180080, nullptr, "SetSharpness"},
+ {0x00190080, nullptr, "SetAutoExposure"},
+ {0x001A0040, nullptr, "IsAutoExposure"},
+ {0x001B0080, nullptr, "SetAutoWhiteBalance"},
+ {0x001C0040, nullptr, "IsAutoWhiteBalance"},
+ {0x001D00C0, FlipImage, "FlipImage"},
+ {0x001E0200, nullptr, "SetDetailSize"},
+ {0x001F00C0, SetSize, "SetSize"},
+ {0x00200080, SetFrameRate, "SetFrameRate"},
+ {0x00210080, nullptr, "SetPhotoMode"},
+ {0x002200C0, nullptr, "SetEffect"},
+ {0x00230080, nullptr, "SetContrast"},
+ {0x00240080, nullptr, "SetLensCorrection"},
+ {0x002500C0, nullptr, "SetOutputFormat"},
+ {0x00260140, nullptr, "SetAutoExposureWindow"},
+ {0x00270140, nullptr, "SetAutoWhiteBalanceWindow"},
+ {0x00280080, nullptr, "SetNoiseFilter"},
+ {0x00290080, nullptr, "SynchronizeVsyncTiming"},
+ {0x002A0080, nullptr, "GetLatestVsyncTiming"},
+ {0x002B0000, GetStereoCameraCalibrationData, "GetStereoCameraCalibrationData"},
+ {0x002C0400, nullptr, "SetStereoCameraCalibrationData"},
+ {0x002D00C0, nullptr, "WriteRegisterI2c"},
+ {0x002E00C0, nullptr, "WriteMcuVariableI2c"},
+ {0x002F0080, nullptr, "ReadRegisterI2cExclusive"},
+ {0x00300080, nullptr, "ReadMcuVariableI2cExclusive"},
+ {0x00310180, nullptr, "SetImageQualityCalibrationData"},
+ {0x00320000, nullptr, "GetImageQualityCalibrationData"},
+ {0x003302C0, nullptr, "SetPackageParameterWithoutContext"},
+ {0x00340140, nullptr, "SetPackageParameterWithContext"},
+ {0x003501C0, nullptr, "SetPackageParameterWithContextDetail"},
+ {0x00360000, GetSuitableY2rStandardCoefficient, "GetSuitableY2rStandardCoefficient"},
+ {0x00370202, nullptr, "PlayShutterSoundWithWave"},
+ {0x00380040, PlayShutterSound, "PlayShutterSound"},
+ {0x00390000, DriverInitialize, "DriverInitialize"},
+ {0x003A0000, DriverFinalize, "DriverFinalize"},
+ {0x003B0000, nullptr, "GetActivatedCamera"},
+ {0x003C0000, nullptr, "GetSleepCamera"},
+ {0x003D0040, nullptr, "SetSleepCamera"},
+ {0x003E0040, nullptr, "SetBrightnessSynchronization"},
};
CAM_U_Interface::CAM_U_Interface() {
diff --git a/src/core/hle/service/cecd/cecd.cpp b/src/core/hle/service/cecd/cecd.cpp
index 50c03495e..515b344e6 100644
--- a/src/core/hle/service/cecd/cecd.cpp
+++ b/src/core/hle/service/cecd/cecd.cpp
@@ -3,12 +3,11 @@
// Refer to the license.txt file included.
#include "common/logging/log.h"
-
#include "core/hle/kernel/event.h"
-#include "core/hle/service/service.h"
#include "core/hle/service/cecd/cecd.h"
#include "core/hle/service/cecd/cecd_s.h"
#include "core/hle/service/cecd/cecd_u.h"
+#include "core/hle/service/service.h"
namespace Service {
namespace CECD {
@@ -28,7 +27,7 @@ void GetCecStateAbbreviated(Service::Interface* self) {
void GetCecInfoEventHandle(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- cmd_buff[1] = RESULT_SUCCESS.raw; // No error
+ cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[3] = Kernel::g_handle_table.Create(cecinfo_event).MoveFrom(); // Event handle
LOG_WARNING(Service_CECD, "(STUBBED) called");
@@ -37,7 +36,7 @@ void GetCecInfoEventHandle(Service::Interface* self) {
void GetChangeStateEventHandle(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- cmd_buff[1] = RESULT_SUCCESS.raw; // No error
+ cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[3] = Kernel::g_handle_table.Create(change_state_event).MoveFrom(); // Event handle
LOG_WARNING(Service_CECD, "(STUBBED) called");
@@ -48,7 +47,8 @@ void Init() {
AddService(new CECD_U_Interface);
cecinfo_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "CECD_U::cecinfo_event");
- change_state_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "CECD_U::change_state_event");
+ change_state_event =
+ Kernel::Event::Create(Kernel::ResetType::OneShot, "CECD_U::change_state_event");
}
void Shutdown() {
diff --git a/src/core/hle/service/cecd/cecd.h b/src/core/hle/service/cecd/cecd.h
index 435611363..ea97f9266 100644
--- a/src/core/hle/service/cecd/cecd.h
+++ b/src/core/hle/service/cecd/cecd.h
@@ -11,11 +11,13 @@ class Interface;
namespace CECD {
enum class CecStateAbbreviated {
- CEC_STATE_ABBREV_IDLE = 1, ///< Corresponds to CEC_STATE_IDLE
+ CEC_STATE_ABBREV_IDLE = 1, ///< Corresponds to CEC_STATE_IDLE
CEC_STATE_ABBREV_NOT_LOCAL = 2, ///< Corresponds to CEC_STATEs *FINISH*, *POST, and OVER_BOSS
- CEC_STATE_ABBREV_SCANNING = 3, ///< Corresponds to CEC_STATE_SCANNING
- CEC_STATE_ABBREV_WLREADY = 4, ///< Corresponds to CEC_STATE_WIRELESS_READY when some unknown bool is true
- CEC_STATE_ABBREV_OTHER = 5, ///< Corresponds to CEC_STATEs besides *FINISH*, *POST, and OVER_BOSS and those listed here
+ CEC_STATE_ABBREV_SCANNING = 3, ///< Corresponds to CEC_STATE_SCANNING
+ CEC_STATE_ABBREV_WLREADY =
+ 4, ///< Corresponds to CEC_STATE_WIRELESS_READY when some unknown bool is true
+ CEC_STATE_ABBREV_OTHER = 5, ///< Corresponds to CEC_STATEs besides *FINISH*, *POST, and
+ /// OVER_BOSS and those listed here
};
/**
diff --git a/src/core/hle/service/cecd/cecd_s.cpp b/src/core/hle/service/cecd/cecd_s.cpp
index bfd821c07..7477b9320 100644
--- a/src/core/hle/service/cecd/cecd_s.cpp
+++ b/src/core/hle/service/cecd/cecd_s.cpp
@@ -8,10 +8,10 @@ namespace Service {
namespace CECD {
// Empty arrays are illegal -- commented out until an entry is added.
-//const Interface::FunctionInfo FunctionTable[] = { };
+// const Interface::FunctionInfo FunctionTable[] = { };
CECD_S_Interface::CECD_S_Interface() {
- //Register(FunctionTable);
+ // Register(FunctionTable);
}
} // namespace CECD
diff --git a/src/core/hle/service/cecd/cecd_u.cpp b/src/core/hle/service/cecd/cecd_u.cpp
index be6d4d8f6..4b747de7b 100644
--- a/src/core/hle/service/cecd/cecd_u.cpp
+++ b/src/core/hle/service/cecd/cecd_u.cpp
@@ -9,10 +9,10 @@ namespace Service {
namespace CECD {
static const Interface::FunctionInfo FunctionTable[] = {
- {0x000E0000, GetCecStateAbbreviated, "GetCecStateAbbreviated"},
- {0x000F0000, GetCecInfoEventHandle, "GetCecInfoEventHandle"},
+ {0x000E0000, GetCecStateAbbreviated, "GetCecStateAbbreviated"},
+ {0x000F0000, GetCecInfoEventHandle, "GetCecInfoEventHandle"},
{0x00100000, GetChangeStateEventHandle, "GetChangeStateEventHandle"},
- {0x00120104, nullptr, "ReadSavedData"},
+ {0x00120104, nullptr, "ReadSavedData"},
};
CECD_U_Interface::CECD_U_Interface() {
diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp
index a5dc47322..24eee6903 100644
--- a/src/core/hle/service/cfg/cfg.cpp
+++ b/src/core/hle/service/cfg/cfg.cpp
@@ -3,15 +3,12 @@
// Refer to the license.txt file included.
#include <algorithm>
-
#include "common/file_util.h"
#include "common/logging/log.h"
#include "common/string_util.h"
#include "common/swap.h"
-
#include "core/file_sys/archive_systemsavedata.h"
#include "core/file_sys/file_backend.h"
-#include "core/settings.h"
#include "core/hle/result.h"
#include "core/hle/service/cfg/cfg.h"
#include "core/hle/service/cfg/cfg_i.h"
@@ -19,6 +16,7 @@
#include "core/hle/service/cfg/cfg_u.h"
#include "core/hle/service/fs/archive.h"
#include "core/hle/service/service.h"
+#include "core/settings.h"
namespace Service {
namespace CFG {
@@ -33,25 +31,29 @@ namespace {
* contains information about the blocks in the file
*/
struct SaveFileConfig {
- u16 total_entries; ///< The total number of set entries in the config file
- u16 data_entries_offset; ///< The offset where the data for the blocks start, this is hardcoded to 0x455C as per hardware
- SaveConfigBlockEntry block_entries[CONFIG_FILE_MAX_BLOCK_ENTRIES]; ///< The block headers, the maximum possible value is 1479 as per hardware
- u32 unknown; ///< This field is unknown, possibly padding, 0 has been observed in hardware
+ u16 total_entries; ///< The total number of set entries in the config file
+ u16 data_entries_offset; ///< The offset where the data for the blocks start, this is hardcoded
+ /// to 0x455C as per hardware
+ SaveConfigBlockEntry block_entries[CONFIG_FILE_MAX_BLOCK_ENTRIES]; ///< The block headers, the
+ /// maximum possible value is
+ /// 1479 as per hardware
+ u32 unknown; ///< This field is unknown, possibly padding, 0 has been observed in hardware
};
-static_assert(sizeof(SaveFileConfig) == 0x455C, "SaveFileConfig header must be exactly 0x455C bytes");
+static_assert(sizeof(SaveFileConfig) == 0x455C,
+ "SaveFileConfig header must be exactly 0x455C bytes");
enum ConfigBlockID {
StereoCameraSettingsBlockID = 0x00050005,
- SoundOutputModeBlockID = 0x00070001,
- ConsoleUniqueIDBlockID = 0x00090001,
- UsernameBlockID = 0x000A0000,
- BirthdayBlockID = 0x000A0001,
- LanguageBlockID = 0x000A0002,
- CountryInfoBlockID = 0x000B0000,
- CountryNameBlockID = 0x000B0001,
- StateNameBlockID = 0x000B0002,
- EULAVersionBlockID = 0x000D0000,
- ConsoleModelBlockID = 0x000F0004,
+ SoundOutputModeBlockID = 0x00070001,
+ ConsoleUniqueIDBlockID = 0x00090001,
+ UsernameBlockID = 0x000A0000,
+ BirthdayBlockID = 0x000A0001,
+ LanguageBlockID = 0x000A0002,
+ CountryInfoBlockID = 0x000B0000,
+ CountryNameBlockID = 0x000B0001,
+ StateNameBlockID = 0x000B0002,
+ EULAVersionBlockID = 0x000D0000,
+ ConsoleModelBlockID = 0x000F0004,
};
struct UsernameBlock {
@@ -68,8 +70,8 @@ struct BirthdayBlock {
static_assert(sizeof(BirthdayBlock) == 2, "BirthdayBlock must be exactly 2 bytes");
struct ConsoleModelInfo {
- u8 model; ///< The console model (3DS, 2DS, etc)
- u8 unknown[3]; ///< Unknown data
+ u8 model; ///< The console model (3DS, 2DS, etc)
+ u8 unknown[3]; ///< Unknown data
};
static_assert(sizeof(ConsoleModelInfo) == 4, "ConsoleModelInfo must be exactly 4 bytes");
@@ -78,36 +80,38 @@ struct ConsoleCountryInfo {
u8 country_code; ///< The country code of the console
};
static_assert(sizeof(ConsoleCountryInfo) == 4, "ConsoleCountryInfo must be exactly 4 bytes");
-
}
static const u64 CFG_SAVE_ID = 0x00010017;
static const u64 CONSOLE_UNIQUE_ID = 0xDEADC0DE;
-static const ConsoleModelInfo CONSOLE_MODEL = { NINTENDO_3DS_XL, { 0, 0, 0 } };
+static const ConsoleModelInfo CONSOLE_MODEL = {NINTENDO_3DS_XL, {0, 0, 0}};
static const u8 CONSOLE_LANGUAGE = LANGUAGE_EN;
-static const UsernameBlock CONSOLE_USERNAME_BLOCK = { u"CITRA", 0, 0 };
-static const BirthdayBlock PROFILE_BIRTHDAY = { 3, 25 }; // March 25th, 2014
+static const UsernameBlock CONSOLE_USERNAME_BLOCK = {u"CITRA", 0, 0};
+static const BirthdayBlock PROFILE_BIRTHDAY = {3, 25}; // March 25th, 2014
static const u8 SOUND_OUTPUT_MODE = SOUND_SURROUND;
static const u8 UNITED_STATES_COUNTRY_ID = 49;
/// TODO(Subv): Find what the other bytes are
-static const ConsoleCountryInfo COUNTRY_INFO = { { 0, 0, 0 }, UNITED_STATES_COUNTRY_ID };
+static const ConsoleCountryInfo COUNTRY_INFO = {{0, 0, 0}, UNITED_STATES_COUNTRY_ID};
/**
* TODO(Subv): Find out what this actually is, these values fix some NaN uniforms in some games,
* for example Nintendo Zone
* Thanks Normmatt for providing this information
*/
-static const std::array<float, 8> STEREO_CAMERA_SETTINGS = {{
+static const std::array<float, 8> STEREO_CAMERA_SETTINGS = {
62.0f, 289.0f, 76.80000305175781f, 46.08000183105469f,
- 10.0f, 5.0f, 55.58000183105469f, 21.56999969482422f
-}};
-static_assert(sizeof(STEREO_CAMERA_SETTINGS) == 0x20, "STEREO_CAMERA_SETTINGS must be exactly 0x20 bytes");
+ 10.0f, 5.0f, 55.58000183105469f, 21.56999969482422f,
+};
+static_assert(sizeof(STEREO_CAMERA_SETTINGS) == 0x20,
+ "STEREO_CAMERA_SETTINGS must be exactly 0x20 bytes");
static const u32 CONFIG_SAVEFILE_SIZE = 0x8000;
static std::array<u8, CONFIG_SAVEFILE_SIZE> cfg_config_file_buffer;
static Service::FS::ArchiveHandle cfg_system_save_data_archive;
-static const std::vector<u8> cfg_system_savedata_id = { 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x01, 0x00 };
+static const std::vector<u8> cfg_system_savedata_id = {
+ 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x01, 0x00,
+};
void GetCountryCodeString(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
@@ -115,7 +119,9 @@ void GetCountryCodeString(Service::Interface* self) {
if (country_code_id >= country_codes.size() || 0 == country_codes[country_code_id]) {
LOG_ERROR(Service_CFG, "requested country code id=%d is invalid", country_code_id);
- cmd_buff[1] = ResultCode(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument, ErrorLevel::Permanent).raw;
+ cmd_buff[1] = ResultCode(ErrorDescription::NotFound, ErrorModule::Config,
+ ErrorSummary::WrongArgument, ErrorLevel::Permanent)
+ .raw;
return;
}
@@ -139,8 +145,11 @@ void GetCountryCodeID(Service::Interface* self) {
}
if (0 == country_code_id) {
- LOG_ERROR(Service_CFG, "requested country code name=%c%c is invalid", country_code & 0xff, country_code >> 8);
- cmd_buff[1] = ResultCode(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument, ErrorLevel::Permanent).raw;
+ LOG_ERROR(Service_CFG, "requested country code name=%c%c is invalid", country_code & 0xff,
+ country_code >> 8);
+ cmd_buff[1] = ResultCode(ErrorDescription::NotFound, ErrorModule::Config,
+ ErrorSummary::WrongArgument, ErrorLevel::Permanent)
+ .raw;
cmd_buff[2] = 0xFFFF;
return;
}
@@ -185,8 +194,8 @@ void GetSystemModel(Service::Interface* self) {
u32 data;
// TODO(Subv): Find out the correct error codes
- cmd_buff[1] = Service::CFG::GetConfigInfoBlock(0x000F0004, 4, 0x8,
- reinterpret_cast<u8*>(&data)).raw;
+ cmd_buff[1] =
+ Service::CFG::GetConfigInfoBlock(0x000F0004, 4, 0x8, reinterpret_cast<u8*>(&data)).raw;
cmd_buff[2] = data & 0xFF;
}
@@ -195,8 +204,8 @@ void GetModelNintendo2DS(Service::Interface* self) {
u32 data;
// TODO(Subv): Find out the correct error codes
- cmd_buff[1] = Service::CFG::GetConfigInfoBlock(0x000F0004, 4, 0x8,
- reinterpret_cast<u8*>(&data)).raw;
+ cmd_buff[1] =
+ Service::CFG::GetConfigInfoBlock(0x000F0004, 4, 0x8, reinterpret_cast<u8*>(&data)).raw;
u8 model = data & 0xFF;
if (model == Service::CFG::NINTENDO_2DS)
@@ -267,24 +276,29 @@ static ResultVal<void*> GetConfigInfoBlockPointer(u32 block_id, u32 size, u32 fl
// Read the header
SaveFileConfig* config = reinterpret_cast<SaveFileConfig*>(cfg_config_file_buffer.data());
- auto itr = std::find_if(std::begin(config->block_entries), std::end(config->block_entries),
- [&](const SaveConfigBlockEntry& entry) {
- return entry.block_id == block_id;
- });
+ auto itr =
+ std::find_if(std::begin(config->block_entries), std::end(config->block_entries),
+ [&](const SaveConfigBlockEntry& entry) { return entry.block_id == block_id; });
if (itr == std::end(config->block_entries)) {
- LOG_ERROR(Service_CFG, "Config block 0x%X with flags %u and size %u was not found", block_id, flag, size);
- return ResultCode(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument, ErrorLevel::Permanent);
+ LOG_ERROR(Service_CFG, "Config block 0x%X with flags %u and size %u was not found",
+ block_id, flag, size);
+ return ResultCode(ErrorDescription::NotFound, ErrorModule::Config,
+ ErrorSummary::WrongArgument, ErrorLevel::Permanent);
}
if ((itr->flags & flag) == 0) {
- LOG_ERROR(Service_CFG, "Invalid flag %u for config block 0x%X with size %u", flag, block_id, size);
- return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::Config, ErrorSummary::WrongArgument, ErrorLevel::Permanent);
+ LOG_ERROR(Service_CFG, "Invalid flag %u for config block 0x%X with size %u", flag, block_id,
+ size);
+ return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::Config,
+ ErrorSummary::WrongArgument, ErrorLevel::Permanent);
}
if (itr->size != size) {
- LOG_ERROR(Service_CFG, "Invalid size %u for config block 0x%X with flags %u", size, block_id, flag);
- return ResultCode(ErrorDescription::InvalidSize, ErrorModule::Config, ErrorSummary::WrongArgument, ErrorLevel::Permanent);
+ LOG_ERROR(Service_CFG, "Invalid size %u for config block 0x%X with flags %u", size,
+ block_id, flag);
+ return ResultCode(ErrorDescription::InvalidSize, ErrorModule::Config,
+ ErrorSummary::WrongArgument, ErrorLevel::Permanent);
}
void* pointer;
@@ -318,7 +332,7 @@ ResultCode CreateConfigInfoBlk(u32 block_id, u16 size, u16 flags, const void* da
return ResultCode(-1); // TODO(Subv): Find the right error code
// Insert the block header with offset 0 for now
- config->block_entries[config->total_entries] = { block_id, 0, size, flags };
+ config->block_entries[config->total_entries] = {block_id, 0, size, flags};
if (size > 4) {
u32 offset = config->data_entries_offset;
// Perform a search to locate the next offset for the new data
@@ -326,8 +340,7 @@ ResultCode CreateConfigInfoBlk(u32 block_id, u16 size, u16 flags, const void* da
for (int i = config->total_entries - 1; i >= 0; --i) {
// Ignore the blocks that don't have a separate data offset
if (config->block_entries[i].size > 4) {
- offset = config->block_entries[i].offset_or_data +
- config->block_entries[i].size;
+ offset = config->block_entries[i].offset_or_data + config->block_entries[i].size;
break;
}
}
@@ -336,8 +349,7 @@ ResultCode CreateConfigInfoBlk(u32 block_id, u16 size, u16 flags, const void* da
// Write the data at the new offset
memcpy(&cfg_config_file_buffer[offset], data, size);
- }
- else {
+ } else {
// The offset_or_data field in the header contains the data itself if it's 4 bytes or less
memcpy(&config->block_entries[config->total_entries].offset_or_data, data, size);
}
@@ -384,28 +396,40 @@ ResultCode FormatConfig() {
// 0x00030001 - Unknown
res = CreateConfigInfoBlk(0x00030001, 0x8, 0xE, zero_buffer);
- if (!res.IsSuccess()) return res;
+ if (!res.IsSuccess())
+ return res;
- res = CreateConfigInfoBlk(StereoCameraSettingsBlockID, sizeof(STEREO_CAMERA_SETTINGS), 0xE, STEREO_CAMERA_SETTINGS.data());
- if (!res.IsSuccess()) return res;
+ res = CreateConfigInfoBlk(StereoCameraSettingsBlockID, sizeof(STEREO_CAMERA_SETTINGS), 0xE,
+ STEREO_CAMERA_SETTINGS.data());
+ if (!res.IsSuccess())
+ return res;
- res = CreateConfigInfoBlk(SoundOutputModeBlockID, sizeof(SOUND_OUTPUT_MODE), 0xE, &SOUND_OUTPUT_MODE);
- if (!res.IsSuccess()) return res;
+ res = CreateConfigInfoBlk(SoundOutputModeBlockID, sizeof(SOUND_OUTPUT_MODE), 0xE,
+ &SOUND_OUTPUT_MODE);
+ if (!res.IsSuccess())
+ return res;
- res = CreateConfigInfoBlk(ConsoleUniqueIDBlockID, sizeof(CONSOLE_UNIQUE_ID), 0xE, &CONSOLE_UNIQUE_ID);
- if (!res.IsSuccess()) return res;
+ res = CreateConfigInfoBlk(ConsoleUniqueIDBlockID, sizeof(CONSOLE_UNIQUE_ID), 0xE,
+ &CONSOLE_UNIQUE_ID);
+ if (!res.IsSuccess())
+ return res;
- res = CreateConfigInfoBlk(UsernameBlockID, sizeof(CONSOLE_USERNAME_BLOCK), 0xE, &CONSOLE_USERNAME_BLOCK);
- if (!res.IsSuccess()) return res;
+ res = CreateConfigInfoBlk(UsernameBlockID, sizeof(CONSOLE_USERNAME_BLOCK), 0xE,
+ &CONSOLE_USERNAME_BLOCK);
+ if (!res.IsSuccess())
+ return res;
res = CreateConfigInfoBlk(BirthdayBlockID, sizeof(PROFILE_BIRTHDAY), 0xE, &PROFILE_BIRTHDAY);
- if (!res.IsSuccess()) return res;
+ if (!res.IsSuccess())
+ return res;
res = CreateConfigInfoBlk(LanguageBlockID, sizeof(CONSOLE_LANGUAGE), 0xE, &CONSOLE_LANGUAGE);
- if (!res.IsSuccess()) return res;
+ if (!res.IsSuccess())
+ return res;
res = CreateConfigInfoBlk(CountryInfoBlockID, sizeof(COUNTRY_INFO), 0xE, &COUNTRY_INFO);
- if (!res.IsSuccess()) return res;
+ if (!res.IsSuccess())
+ return res;
u16_le country_name_buffer[16][0x40] = {};
std::u16string region_name = Common::UTF8ToUTF16("Gensokyo");
@@ -413,34 +437,44 @@ ResultCode FormatConfig() {
std::copy(region_name.cbegin(), region_name.cend(), country_name_buffer[i]);
}
// 0x000B0001 - Localized names for the profile Country
- res = CreateConfigInfoBlk(CountryNameBlockID, sizeof(country_name_buffer), 0xE, country_name_buffer);
- if (!res.IsSuccess()) return res;
+ res = CreateConfigInfoBlk(CountryNameBlockID, sizeof(country_name_buffer), 0xE,
+ country_name_buffer);
+ if (!res.IsSuccess())
+ return res;
// 0x000B0002 - Localized names for the profile State/Province
- res = CreateConfigInfoBlk(StateNameBlockID, sizeof(country_name_buffer), 0xE, country_name_buffer);
- if (!res.IsSuccess()) return res;
+ res = CreateConfigInfoBlk(StateNameBlockID, sizeof(country_name_buffer), 0xE,
+ country_name_buffer);
+ if (!res.IsSuccess())
+ return res;
// 0x000B0003 - Unknown, related to country/address (zip code?)
res = CreateConfigInfoBlk(0x000B0003, 0x4, 0xE, zero_buffer);
- if (!res.IsSuccess()) return res;
+ if (!res.IsSuccess())
+ return res;
// 0x000C0000 - Unknown
res = CreateConfigInfoBlk(0x000C0000, 0xC0, 0xE, zero_buffer);
- if (!res.IsSuccess()) return res;
+ if (!res.IsSuccess())
+ return res;
// 0x000C0001 - Unknown
res = CreateConfigInfoBlk(0x000C0001, 0x14, 0xE, zero_buffer);
- if (!res.IsSuccess()) return res;
+ if (!res.IsSuccess())
+ return res;
// 0x000D0000 - Accepted EULA version
res = CreateConfigInfoBlk(EULAVersionBlockID, 0x4, 0xE, zero_buffer);
- if (!res.IsSuccess()) return res;
+ if (!res.IsSuccess())
+ return res;
res = CreateConfigInfoBlk(ConsoleModelBlockID, sizeof(CONSOLE_MODEL), 0xC, &CONSOLE_MODEL);
- if (!res.IsSuccess()) return res;
+ if (!res.IsSuccess())
+ return res;
// 0x00170000 - Unknown
res = CreateConfigInfoBlk(0x00170000, 0x4, 0xE, zero_buffer);
- if (!res.IsSuccess()) return res;
+ if (!res.IsSuccess())
+ return res;
// Save the buffer to the file
res = UpdateConfigNANDSavegame();
@@ -452,15 +486,18 @@ ResultCode FormatConfig() {
ResultCode LoadConfigNANDSaveFile() {
// Open the SystemSaveData archive 0x00010017
FileSys::Path archive_path(cfg_system_savedata_id);
- auto archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SystemSaveData, archive_path);
+ auto archive_result =
+ Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SystemSaveData, archive_path);
// If the archive didn't exist, create the files inside
if (archive_result.Code().description == ErrorDescription::FS_NotFormatted) {
// Format the archive to create the directories
- Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SystemSaveData, FileSys::ArchiveFormatInfo(), archive_path);
+ Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SystemSaveData,
+ FileSys::ArchiveFormatInfo(), archive_path);
// Open it again to get a valid archive now that the folder exists
- archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SystemSaveData, archive_path);
+ archive_result =
+ Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SystemSaveData, archive_path);
}
ASSERT_MSG(archive_result.Succeeded(), "Could not open the CFG SystemSaveData archive!");
@@ -491,8 +528,7 @@ void Init() {
LoadConfigNANDSaveFile();
}
-void Shutdown() {
-}
+void Shutdown() {}
void SetUsername(const std::u16string& name) {
ASSERT(name.size() <= 10);
@@ -515,7 +551,7 @@ std::u16string GetUsername() {
}
void SetBirthday(u8 month, u8 day) {
- BirthdayBlock block = { month, day };
+ BirthdayBlock block = {month, day};
SetConfigInfoBlock(BirthdayBlockID, sizeof(block), 4, &block);
}
diff --git a/src/core/hle/service/cfg/cfg.h b/src/core/hle/service/cfg/cfg.h
index 18f60f4ca..fb47c2aa5 100644
--- a/src/core/hle/service/cfg/cfg.h
+++ b/src/core/hle/service/cfg/cfg.h
@@ -6,7 +6,6 @@
#include <array>
#include <string>
-
#include "common/common_types.h"
union ResultCode;
@@ -40,16 +39,13 @@ enum SystemLanguage {
LANGUAGE_TW = 11
};
-enum SoundOutputMode {
- SOUND_MONO = 0,
- SOUND_STEREO = 1,
- SOUND_SURROUND = 2
-};
+enum SoundOutputMode { SOUND_MONO = 0, SOUND_STEREO = 1, SOUND_SURROUND = 2 };
/// Block header in the config savedata file
struct SaveConfigBlockEntry {
u32 block_id; ///< The id of the current block
- u32 offset_or_data; ///< This is the absolute offset to the block data if the size is greater than 4 bytes, otherwise it contains the data itself
+ u32 offset_or_data; ///< This is the absolute offset to the block data if the size is greater
+ /// than 4 bytes, otherwise it contains the data itself
u16 size; ///< The size of the block
u16 flags; ///< The flags of the block, possibly used for access control
};
@@ -82,7 +78,7 @@ static const std::array<u16, 187> country_codes = {{
C("CN"), 0, 0, 0, 0, 0, 0, 0, // 160-167
C("AE"), C("IN"), C("EG"), C("OM"), C("QA"), C("KW"), C("SA"), C("SY"), // 168-175
C("BH"), C("JO"), 0, 0, 0, 0, 0, 0, // 176-183
- C("SM"), C("VA"), C("BM") // 184-186
+ C("SM"), C("VA"), C("BM"), // 184-186
}};
/**
@@ -221,8 +217,9 @@ void FormatConfig(Service::Interface* self);
/**
* Reads a block with the specified id and flag from the Config savegame buffer
- * and writes the output to output.
- * The input size must match exactly the size of the requested block
+ * and writes the output to output. The input size must match exactly the size of the requested
+ * block.
+ *
* @param block_id The id of the block we want to read
* @param size The size of the block we want to read
* @param flag The requested block must have this flag set
@@ -233,8 +230,8 @@ ResultCode GetConfigInfoBlock(u32 block_id, u32 size, u32 flag, void* output);
/**
* Reads data from input and writes to a block with the specified id and flag
- * in the Config savegame buffer.
- * The input size must match exactly the size of the target block
+ * in the Config savegame buffer. The input size must match exactly the size of the target block.
+ *
* @param block_id The id of the block we want to write
* @param size The size of the block we want to write
* @param flag The target block must have this flag set
@@ -244,8 +241,9 @@ ResultCode GetConfigInfoBlock(u32 block_id, u32 size, u32 flag, void* output);
ResultCode SetConfigInfoBlock(u32 block_id, u32 size, u32 flag, const void* input);
/**
- * Creates a block with the specified id and writes the input data to the cfg savegame buffer in memory.
- * The config savegame file in the filesystem is not updated.
+ * Creates a block with the specified id and writes the input data to the cfg savegame buffer in
+ * memory. The config savegame file in the filesystem is not updated.
+ *
* @param block_id The id of the block we want to create
* @param size The size of the block we want to create
* @param flags The flags of the new block
diff --git a/src/core/hle/service/cfg/cfg_i.cpp b/src/core/hle/service/cfg/cfg_i.cpp
index 8b0db785f..2ff52c8b8 100644
--- a/src/core/hle/service/cfg/cfg_i.cpp
+++ b/src/core/hle/service/cfg/cfg_i.cpp
@@ -10,49 +10,49 @@ namespace CFG {
const Interface::FunctionInfo FunctionTable[] = {
// cfg common
- {0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
- {0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"},
- {0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"},
- {0x00040000, GetRegionCanadaUSA, "GetRegionCanadaUSA"},
- {0x00050000, GetSystemModel, "GetSystemModel"},
- {0x00060000, GetModelNintendo2DS, "GetModelNintendo2DS"},
- {0x00070040, nullptr, "WriteToFirstByteCfgSavegame"},
- {0x00080080, nullptr, "GoThroughTable"},
- {0x00090040, GetCountryCodeString, "GetCountryCodeString"},
- {0x000A0040, GetCountryCodeID, "GetCountryCodeID"},
+ {0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
+ {0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"},
+ {0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"},
+ {0x00040000, GetRegionCanadaUSA, "GetRegionCanadaUSA"},
+ {0x00050000, GetSystemModel, "GetSystemModel"},
+ {0x00060000, GetModelNintendo2DS, "GetModelNintendo2DS"},
+ {0x00070040, nullptr, "WriteToFirstByteCfgSavegame"},
+ {0x00080080, nullptr, "GoThroughTable"},
+ {0x00090040, GetCountryCodeString, "GetCountryCodeString"},
+ {0x000A0040, GetCountryCodeID, "GetCountryCodeID"},
// cfg:i
- {0x04010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"},
- {0x04020082, SetConfigInfoBlk4, "SetConfigInfoBlk4"},
- {0x04030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"},
- {0x04040042, nullptr, "GetLocalFriendCodeSeedData"},
- {0x04050000, nullptr, "GetLocalFriendCodeSeed"},
- {0x04060000, SecureInfoGetRegion, "SecureInfoGetRegion"},
- {0x04070000, nullptr, "SecureInfoGetByte101"},
- {0x04080042, nullptr, "SecureInfoGetSerialNo"},
- {0x04090000, nullptr, "UpdateConfigBlk00040003"},
- {0x08010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"},
- {0x08020082, SetConfigInfoBlk4, "SetConfigInfoBlk4"},
- {0x08030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"},
- {0x080400C2, nullptr, "CreateConfigInfoBlk"},
- {0x08050000, nullptr, "DeleteConfigNANDSavefile"},
- {0x08060000, FormatConfig, "FormatConfig"},
- {0x08080000, nullptr, "UpdateConfigBlk1"},
- {0x08090000, nullptr, "UpdateConfigBlk2"},
- {0x080A0000, nullptr, "UpdateConfigBlk3"},
- {0x080B0082, nullptr, "SetGetLocalFriendCodeSeedData"},
- {0x080C0042, nullptr, "SetLocalFriendCodeSeedSignature"},
- {0x080D0000, nullptr, "DeleteCreateNANDLocalFriendCodeSeed"},
- {0x080E0000, nullptr, "VerifySigLocalFriendCodeSeed"},
- {0x080F0042, nullptr, "GetLocalFriendCodeSeedData"},
- {0x08100000, nullptr, "GetLocalFriendCodeSeed"},
- {0x08110084, nullptr, "SetSecureInfo"},
- {0x08120000, nullptr, "DeleteCreateNANDSecureInfo"},
- {0x08130000, nullptr, "VerifySigSecureInfo"},
- {0x08140042, nullptr, "SecureInfoGetData"},
- {0x08150042, nullptr, "SecureInfoGetSignature"},
- {0x08160000, SecureInfoGetRegion, "SecureInfoGetRegion"},
- {0x08170000, nullptr, "SecureInfoGetByte101"},
- {0x08180042, nullptr, "SecureInfoGetSerialNo"},
+ {0x04010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"},
+ {0x04020082, SetConfigInfoBlk4, "SetConfigInfoBlk4"},
+ {0x04030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"},
+ {0x04040042, nullptr, "GetLocalFriendCodeSeedData"},
+ {0x04050000, nullptr, "GetLocalFriendCodeSeed"},
+ {0x04060000, SecureInfoGetRegion, "SecureInfoGetRegion"},
+ {0x04070000, nullptr, "SecureInfoGetByte101"},
+ {0x04080042, nullptr, "SecureInfoGetSerialNo"},
+ {0x04090000, nullptr, "UpdateConfigBlk00040003"},
+ {0x08010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"},
+ {0x08020082, SetConfigInfoBlk4, "SetConfigInfoBlk4"},
+ {0x08030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"},
+ {0x080400C2, nullptr, "CreateConfigInfoBlk"},
+ {0x08050000, nullptr, "DeleteConfigNANDSavefile"},
+ {0x08060000, FormatConfig, "FormatConfig"},
+ {0x08080000, nullptr, "UpdateConfigBlk1"},
+ {0x08090000, nullptr, "UpdateConfigBlk2"},
+ {0x080A0000, nullptr, "UpdateConfigBlk3"},
+ {0x080B0082, nullptr, "SetGetLocalFriendCodeSeedData"},
+ {0x080C0042, nullptr, "SetLocalFriendCodeSeedSignature"},
+ {0x080D0000, nullptr, "DeleteCreateNANDLocalFriendCodeSeed"},
+ {0x080E0000, nullptr, "VerifySigLocalFriendCodeSeed"},
+ {0x080F0042, nullptr, "GetLocalFriendCodeSeedData"},
+ {0x08100000, nullptr, "GetLocalFriendCodeSeed"},
+ {0x08110084, nullptr, "SetSecureInfo"},
+ {0x08120000, nullptr, "DeleteCreateNANDSecureInfo"},
+ {0x08130000, nullptr, "VerifySigSecureInfo"},
+ {0x08140042, nullptr, "SecureInfoGetData"},
+ {0x08150042, nullptr, "SecureInfoGetSignature"},
+ {0x08160000, SecureInfoGetRegion, "SecureInfoGetRegion"},
+ {0x08170000, nullptr, "SecureInfoGetByte101"},
+ {0x08180042, nullptr, "SecureInfoGetSerialNo"},
};
CFG_I_Interface::CFG_I_Interface() {
diff --git a/src/core/hle/service/cfg/cfg_s.cpp b/src/core/hle/service/cfg/cfg_s.cpp
index 12b458783..eed26dec7 100644
--- a/src/core/hle/service/cfg/cfg_s.cpp
+++ b/src/core/hle/service/cfg/cfg_s.cpp
@@ -10,26 +10,26 @@ namespace CFG {
const Interface::FunctionInfo FunctionTable[] = {
// cfg common
- {0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
- {0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"},
- {0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"},
- {0x00040000, GetRegionCanadaUSA, "GetRegionCanadaUSA"},
- {0x00050000, GetSystemModel, "GetSystemModel"},
- {0x00060000, GetModelNintendo2DS, "GetModelNintendo2DS"},
- {0x00070040, nullptr, "WriteToFirstByteCfgSavegame"},
- {0x00080080, nullptr, "GoThroughTable"},
- {0x00090040, GetCountryCodeString, "GetCountryCodeString"},
- {0x000A0040, GetCountryCodeID, "GetCountryCodeID"},
+ {0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
+ {0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"},
+ {0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"},
+ {0x00040000, GetRegionCanadaUSA, "GetRegionCanadaUSA"},
+ {0x00050000, GetSystemModel, "GetSystemModel"},
+ {0x00060000, GetModelNintendo2DS, "GetModelNintendo2DS"},
+ {0x00070040, nullptr, "WriteToFirstByteCfgSavegame"},
+ {0x00080080, nullptr, "GoThroughTable"},
+ {0x00090040, GetCountryCodeString, "GetCountryCodeString"},
+ {0x000A0040, GetCountryCodeID, "GetCountryCodeID"},
// cfg:s
- {0x04010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"},
- {0x04020082, SetConfigInfoBlk4, "SetConfigInfoBlk4"},
- {0x04030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"},
- {0x04040042, nullptr, "GetLocalFriendCodeSeedData"},
- {0x04050000, nullptr, "GetLocalFriendCodeSeed"},
- {0x04060000, nullptr, "SecureInfoGetRegion"},
- {0x04070000, nullptr, "SecureInfoGetByte101"},
- {0x04080042, nullptr, "SecureInfoGetSerialNo"},
- {0x04090000, nullptr, "UpdateConfigBlk00040003"},
+ {0x04010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"},
+ {0x04020082, SetConfigInfoBlk4, "SetConfigInfoBlk4"},
+ {0x04030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"},
+ {0x04040042, nullptr, "GetLocalFriendCodeSeedData"},
+ {0x04050000, nullptr, "GetLocalFriendCodeSeed"},
+ {0x04060000, nullptr, "SecureInfoGetRegion"},
+ {0x04070000, nullptr, "SecureInfoGetByte101"},
+ {0x04080042, nullptr, "SecureInfoGetSerialNo"},
+ {0x04090000, nullptr, "UpdateConfigBlk00040003"},
};
CFG_S_Interface::CFG_S_Interface() {
diff --git a/src/core/hle/service/cfg/cfg_u.cpp b/src/core/hle/service/cfg/cfg_u.cpp
index 606f7b2eb..f28217134 100644
--- a/src/core/hle/service/cfg/cfg_u.cpp
+++ b/src/core/hle/service/cfg/cfg_u.cpp
@@ -10,16 +10,16 @@ namespace CFG {
const Interface::FunctionInfo FunctionTable[] = {
// cfg common
- {0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
- {0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"},
- {0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"},
- {0x00040000, GetRegionCanadaUSA, "GetRegionCanadaUSA"},
- {0x00050000, GetSystemModel, "GetSystemModel"},
- {0x00060000, GetModelNintendo2DS, "GetModelNintendo2DS"},
- {0x00070040, nullptr, "WriteToFirstByteCfgSavegame"},
- {0x00080080, nullptr, "GoThroughTable"},
- {0x00090040, GetCountryCodeString, "GetCountryCodeString"},
- {0x000A0040, GetCountryCodeID, "GetCountryCodeID"},
+ {0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
+ {0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"},
+ {0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"},
+ {0x00040000, GetRegionCanadaUSA, "GetRegionCanadaUSA"},
+ {0x00050000, GetSystemModel, "GetSystemModel"},
+ {0x00060000, GetModelNintendo2DS, "GetModelNintendo2DS"},
+ {0x00070040, nullptr, "WriteToFirstByteCfgSavegame"},
+ {0x00080080, nullptr, "GoThroughTable"},
+ {0x00090040, GetCountryCodeString, "GetCountryCodeString"},
+ {0x000A0040, GetCountryCodeID, "GetCountryCodeID"},
};
CFG_U_Interface::CFG_U_Interface() {
diff --git a/src/core/hle/service/csnd_snd.cpp b/src/core/hle/service/csnd_snd.cpp
index 913c8dc09..20c759ad7 100644
--- a/src/core/hle/service/csnd_snd.cpp
+++ b/src/core/hle/service/csnd_snd.cpp
@@ -15,18 +15,18 @@
namespace CSND_SND {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010140, Initialize, "Initialize"},
- {0x00020000, Shutdown, "Shutdown"},
- {0x00030040, ExecuteType0Commands, "ExecuteType0Commands"},
- {0x00040080, nullptr, "ExecuteType1Commands"},
- {0x00050000, AcquireSoundChannels, "AcquireSoundChannels"},
- {0x00060000, nullptr, "ReleaseSoundChannels"},
- {0x00070000, nullptr, "AcquireCaptureDevice"},
- {0x00080040, nullptr, "ReleaseCaptureDevice"},
- {0x00090082, nullptr, "FlushDataCache"},
- {0x000A0082, nullptr, "StoreDataCache"},
- {0x000B0082, nullptr, "InvalidateDataCache"},
- {0x000C0000, nullptr, "Reset"},
+ {0x00010140, Initialize, "Initialize"},
+ {0x00020000, Shutdown, "Shutdown"},
+ {0x00030040, ExecuteType0Commands, "ExecuteType0Commands"},
+ {0x00040080, nullptr, "ExecuteType1Commands"},
+ {0x00050000, AcquireSoundChannels, "AcquireSoundChannels"},
+ {0x00060000, nullptr, "ReleaseSoundChannels"},
+ {0x00070000, nullptr, "AcquireCaptureDevice"},
+ {0x00080040, nullptr, "ReleaseCaptureDevice"},
+ {0x00090082, nullptr, "FlushDataCache"},
+ {0x000A0082, nullptr, "StoreDataCache"},
+ {0x000B0082, nullptr, "InvalidateDataCache"},
+ {0x000C0000, nullptr, "Reset"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -44,9 +44,9 @@ void Initialize(Service::Interface* self) {
u32 size = Common::AlignUp(cmd_buff[1], Memory::PAGE_SIZE);
using Kernel::MemoryPermission;
- shared_memory = Kernel::SharedMemory::Create(nullptr, size,
- MemoryPermission::ReadWrite, MemoryPermission::ReadWrite,
- 0, Kernel::MemoryRegion::BASE, "CSND:SharedMemory");
+ shared_memory = Kernel::SharedMemory::Create(nullptr, size, MemoryPermission::ReadWrite,
+ MemoryPermission::ReadWrite, 0,
+ Kernel::MemoryRegion::BASE, "CSND:SharedMemory");
mutex = Kernel::Mutex::Create(false);
@@ -58,7 +58,7 @@ void Initialize(Service::Interface* self) {
void ExecuteType0Commands(Service::Interface* self) {
u32* const cmd_buff = Kernel::GetCommandBuffer();
- u8* const ptr = shared_memory->GetPointer(cmd_buff[1]);
+ u8* const ptr = shared_memory->GetPointer(cmd_buff[1]);
if (shared_memory != nullptr && ptr != nullptr) {
Type0Command command;
diff --git a/src/core/hle/service/csnd_snd.h b/src/core/hle/service/csnd_snd.h
index e861f3327..a146d116b 100644
--- a/src/core/hle/service/csnd_snd.h
+++ b/src/core/hle/service/csnd_snd.h
@@ -25,7 +25,7 @@ struct Type0Command {
u32 command_id;
u32 finished;
u32 flags;
- u8 parameters[20];
+ u8 parameters[20];
};
void Initialize(Service::Interface* self);
diff --git a/src/core/hle/service/dlp/dlp.cpp b/src/core/hle/service/dlp/dlp.cpp
index 7c8db794b..8f4b67a5d 100644
--- a/src/core/hle/service/dlp/dlp.cpp
+++ b/src/core/hle/service/dlp/dlp.cpp
@@ -2,11 +2,11 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
-#include "core/hle/service/service.h"
#include "core/hle/service/dlp/dlp.h"
#include "core/hle/service/dlp/dlp_clnt.h"
#include "core/hle/service/dlp/dlp_fkcl.h"
#include "core/hle/service/dlp/dlp_srvr.h"
+#include "core/hle/service/service.h"
namespace Service {
namespace DLP {
@@ -17,8 +17,7 @@ void Init() {
AddService(new DLP_SRVR_Interface);
}
-void Shutdown() {
-}
+void Shutdown() {}
} // namespace DLP
} // namespace Service
diff --git a/src/core/hle/service/dlp/dlp_clnt.cpp b/src/core/hle/service/dlp/dlp_clnt.cpp
index 0b31d47df..56f934b3f 100644
--- a/src/core/hle/service/dlp/dlp_clnt.cpp
+++ b/src/core/hle/service/dlp/dlp_clnt.cpp
@@ -8,8 +8,7 @@ namespace Service {
namespace DLP {
const Interface::FunctionInfo FunctionTable[] = {
- {0x000100C3, nullptr, "Initialize"},
- {0x00110000, nullptr, "GetWirelessRebootPassphrase"},
+ {0x000100C3, nullptr, "Initialize"}, {0x00110000, nullptr, "GetWirelessRebootPassphrase"},
};
DLP_CLNT_Interface::DLP_CLNT_Interface() {
diff --git a/src/core/hle/service/dlp/dlp_fkcl.cpp b/src/core/hle/service/dlp/dlp_fkcl.cpp
index a845260e5..29b9d52e0 100644
--- a/src/core/hle/service/dlp/dlp_fkcl.cpp
+++ b/src/core/hle/service/dlp/dlp_fkcl.cpp
@@ -8,8 +8,7 @@ namespace Service {
namespace DLP {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010083, nullptr, "Initialize"},
- {0x000F0000, nullptr, "GetWirelessRebootPassphrase"},
+ {0x00010083, nullptr, "Initialize"}, {0x000F0000, nullptr, "GetWirelessRebootPassphrase"},
};
DLP_FKCL_Interface::DLP_FKCL_Interface() {
diff --git a/src/core/hle/service/dlp/dlp_srvr.cpp b/src/core/hle/service/dlp/dlp_srvr.cpp
index da9b30f56..49d5b8d1c 100644
--- a/src/core/hle/service/dlp/dlp_srvr.cpp
+++ b/src/core/hle/service/dlp/dlp_srvr.cpp
@@ -20,10 +20,10 @@ static void unk_0x000E0040(Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010183, nullptr, "Initialize"},
- {0x00020000, nullptr, "Finalize"},
- {0x000800C0, nullptr, "SendWirelessRebootPassphrase"},
- {0x000E0040, unk_0x000E0040, "unk_0x000E0040"},
+ {0x00010183, nullptr, "Initialize"},
+ {0x00020000, nullptr, "Finalize"},
+ {0x000800C0, nullptr, "SendWirelessRebootPassphrase"},
+ {0x000E0040, unk_0x000E0040, "unk_0x000E0040"},
};
DLP_SRVR_Interface::DLP_SRVR_Interface() {
diff --git a/src/core/hle/service/dsp_dsp.cpp b/src/core/hle/service/dsp_dsp.cpp
index c8aadd9db..a15aa3696 100644
--- a/src/core/hle/service/dsp_dsp.cpp
+++ b/src/core/hle/service/dsp_dsp.cpp
@@ -4,12 +4,9 @@
#include <algorithm>
#include <cinttypes>
-
#include "audio_core/hle/pipe.h"
-
#include "common/hash.h"
#include "common/logging/log.h"
-
#include "core/hle/kernel/event.h"
#include "core/hle/service/dsp_dsp.h"
@@ -23,9 +20,7 @@ namespace DSP_DSP {
static Kernel::SharedPtr<Kernel::Event> semaphore_event;
/// There are three types of interrupts
-enum class InterruptType {
- Zero, One, Pipe
-};
+enum class InterruptType { Zero, One, Pipe };
constexpr size_t NUM_INTERRUPT_TYPE = 3;
class InterruptEvents final {
@@ -57,9 +52,8 @@ public:
// Actual service implementation only has 6 'slots' for interrupts.
constexpr size_t max_number_of_interrupt_events = 6;
- size_t number = std::count_if(pipe.begin(), pipe.end(), [](const auto& evt) {
- return evt != nullptr;
- });
+ size_t number =
+ std::count_if(pipe.begin(), pipe.end(), [](const auto& evt) { return evt != nullptr; });
if (zero != nullptr)
number++;
@@ -105,7 +99,8 @@ static void ConvertProcessAddressFromDspDram(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0xC, 2, 0);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- // TODO(merry): There is a per-region offset missing in this calculation (that seems to be always zero).
+ // TODO(merry): There is a per-region offset missing in this calculation (that seems to be
+ // always zero).
cmd_buff[2] = (addr << 1) + (Memory::DSP_RAM_VADDR + 0x40000);
LOG_DEBUG(Service_DSP, "addr=0x%08X", addr);
@@ -126,15 +121,15 @@ static void ConvertProcessAddressFromDspDram(Service::Interface* self) {
static void LoadComponent(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- u32 size = cmd_buff[1];
- u32 prog_mask = cmd_buff[2];
- u32 data_mask = cmd_buff[3];
- u32 desc = cmd_buff[4];
- u32 buffer = cmd_buff[5];
+ u32 size = cmd_buff[1];
+ u32 prog_mask = cmd_buff[2];
+ u32 data_mask = cmd_buff[3];
+ u32 desc = cmd_buff[4];
+ u32 buffer = cmd_buff[5];
cmd_buff[0] = IPC::MakeHeader(0x11, 2, 2);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- cmd_buff[2] = 1; // Pretend that we actually loaded the DSP firmware
+ cmd_buff[2] = 1; // Pretend that we actually loaded the DSP firmware
cmd_buff[3] = desc;
cmd_buff[4] = buffer;
@@ -145,12 +140,15 @@ static void LoadComponent(Service::Interface* self) {
std::vector<u8> component_data(size);
Memory::ReadBlock(buffer, component_data.data(), component_data.size());
- LOG_INFO(Service_DSP, "Firmware hash: %#" PRIx64, Common::ComputeHash64(component_data.data(), component_data.size()));
+ LOG_INFO(Service_DSP, "Firmware hash: %#" PRIx64,
+ Common::ComputeHash64(component_data.data(), component_data.size()));
// Some versions of the firmware have the location of DSP structures listed here.
ASSERT(size > 0x37C);
- LOG_INFO(Service_DSP, "Structures hash: %#" PRIx64, Common::ComputeHash64(component_data.data() + 0x340, 60));
+ LOG_INFO(Service_DSP, "Structures hash: %#" PRIx64,
+ Common::ComputeHash64(component_data.data() + 0x340, 60));
- LOG_WARNING(Service_DSP, "(STUBBED) called size=0x%X, prog_mask=0x%08X, data_mask=0x%08X, buffer=0x%08X",
+ LOG_WARNING(Service_DSP,
+ "(STUBBED) called size=0x%X, prog_mask=0x%08X, data_mask=0x%08X, buffer=0x%08X",
size, prog_mask, data_mask, buffer);
}
@@ -187,13 +185,14 @@ static void GetSemaphoreEventHandle(Service::Interface* self) {
static void FlushDataCache(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 address = cmd_buff[1];
- u32 size = cmd_buff[2];
+ u32 size = cmd_buff[2];
u32 process = cmd_buff[4];
cmd_buff[0] = IPC::MakeHeader(0x13, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- LOG_TRACE(Service_DSP, "called address=0x%08X, size=0x%X, process=0x%08X", address, size, process);
+ LOG_TRACE(Service_DSP, "called address=0x%08X, size=0x%X, process=0x%08X", address, size,
+ process);
}
/**
@@ -224,23 +223,29 @@ static void RegisterInterruptEvents(Service::Interface* self) {
auto evt = Kernel::g_handle_table.Get<Kernel::Event>(cmd_buff[4]);
if (!evt) {
- LOG_INFO(Service_DSP, "Invalid event handle! type=%u, pipe=%u, event_handle=0x%08X", type_index, pipe_index, event_handle);
+ LOG_INFO(Service_DSP, "Invalid event handle! type=%u, pipe=%u, event_handle=0x%08X",
+ type_index, pipe_index, event_handle);
ASSERT(false); // TODO: This should really be handled at an IPC translation layer.
}
if (interrupt_events.HasTooManyEventsRegistered()) {
- LOG_INFO(Service_DSP, "Ran out of space to register interrupts (Attempted to register type=%u, pipe=%u, event_handle=0x%08X)",
+ LOG_INFO(Service_DSP, "Ran out of space to register interrupts (Attempted to register "
+ "type=%u, pipe=%u, event_handle=0x%08X)",
type_index, pipe_index, event_handle);
- cmd_buff[1] = ResultCode(ErrorDescription::InvalidResultValue, ErrorModule::DSP, ErrorSummary::OutOfResource, ErrorLevel::Status).raw;
+ cmd_buff[1] = ResultCode(ErrorDescription::InvalidResultValue, ErrorModule::DSP,
+ ErrorSummary::OutOfResource, ErrorLevel::Status)
+ .raw;
return;
}
interrupt_events.Get(type, pipe) = evt;
- LOG_INFO(Service_DSP, "Registered type=%u, pipe=%u, event_handle=0x%08X", type_index, pipe_index, event_handle);
+ LOG_INFO(Service_DSP, "Registered type=%u, pipe=%u, event_handle=0x%08X", type_index,
+ pipe_index, event_handle);
cmd_buff[1] = RESULT_SUCCESS.raw;
} else {
interrupt_events.Get(type, pipe) = nullptr;
- LOG_INFO(Service_DSP, "Unregistered interrupt=%u, channel=%u, event_handle=0x%08X", type_index, pipe_index, event_handle);
+ LOG_INFO(Service_DSP, "Unregistered interrupt=%u, channel=%u, event_handle=0x%08X",
+ type_index, pipe_index, event_handle);
cmd_buff[1] = RESULT_SUCCESS.raw;
}
}
@@ -282,13 +287,18 @@ static void WriteProcessPipe(Service::Interface* self) {
DSP::HLE::DspPipe pipe = static_cast<DSP::HLE::DspPipe>(pipe_index);
if (IPC::StaticBufferDesc(size, 1) != cmd_buff[3]) {
- LOG_ERROR(Service_DSP, "IPC static buffer descriptor failed validation (0x%X). pipe=%u, size=0x%X, buffer=0x%08X", cmd_buff[3], pipe_index, size, buffer);
+ LOG_ERROR(Service_DSP, "IPC static buffer descriptor failed validation (0x%X). pipe=%u, "
+ "size=0x%X, buffer=0x%08X",
+ cmd_buff[3], pipe_index, size, buffer);
cmd_buff[0] = IPC::MakeHeader(0, 1, 0);
- cmd_buff[1] = ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS, ErrorSummary::WrongArgument, ErrorLevel::Permanent).raw;
+ cmd_buff[1] = ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS,
+ ErrorSummary::WrongArgument, ErrorLevel::Permanent)
+ .raw;
return;
}
- ASSERT_MSG(Memory::IsValidVirtualAddress(buffer), "Invalid Buffer: pipe=%u, size=0x%X, buffer=0x%08X", pipe, size, buffer);
+ ASSERT_MSG(Memory::IsValidVirtualAddress(buffer),
+ "Invalid Buffer: pipe=%u, size=0x%X, buffer=0x%08X", pipe, size, buffer);
std::vector<u8> message(size);
for (u32 i = 0; i < size; i++) {
@@ -327,7 +337,9 @@ static void ReadPipeIfPossible(Service::Interface* self) {
DSP::HLE::DspPipe pipe = static_cast<DSP::HLE::DspPipe>(pipe_index);
- ASSERT_MSG(Memory::IsValidVirtualAddress(addr), "Invalid addr: pipe=0x%08X, unknown=0x%08X, size=0x%X, buffer=0x%08X", pipe, unknown, size, addr);
+ ASSERT_MSG(Memory::IsValidVirtualAddress(addr),
+ "Invalid addr: pipe=0x%08X, unknown=0x%08X, size=0x%X, buffer=0x%08X", pipe, unknown,
+ size, addr);
cmd_buff[0] = IPC::MakeHeader(0x10, 1, 2);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
@@ -343,7 +355,9 @@ static void ReadPipeIfPossible(Service::Interface* self) {
cmd_buff[3] = IPC::StaticBufferDesc(size, 0);
cmd_buff[4] = addr;
- LOG_DEBUG(Service_DSP, "pipe=%u, unknown=0x%08X, size=0x%X, buffer=0x%08X, return cmd_buff[2]=0x%08X", pipe_index, unknown, size, addr, cmd_buff[2]);
+ LOG_DEBUG(Service_DSP,
+ "pipe=%u, unknown=0x%08X, size=0x%X, buffer=0x%08X, return cmd_buff[2]=0x%08X",
+ pipe_index, unknown, size, addr, cmd_buff[2]);
}
/**
@@ -367,7 +381,9 @@ static void ReadPipe(Service::Interface* self) {
DSP::HLE::DspPipe pipe = static_cast<DSP::HLE::DspPipe>(pipe_index);
- ASSERT_MSG(Memory::IsValidVirtualAddress(addr), "Invalid addr: pipe=0x%08X, unknown=0x%08X, size=0x%X, buffer=0x%08X", pipe, unknown, size, addr);
+ ASSERT_MSG(Memory::IsValidVirtualAddress(addr),
+ "Invalid addr: pipe=0x%08X, unknown=0x%08X, size=0x%X, buffer=0x%08X", pipe, unknown,
+ size, addr);
if (DSP::HLE::GetPipeReadableSize(pipe) >= size) {
std::vector<u8> response = DSP::HLE::PipeRead(pipe, size);
@@ -384,7 +400,9 @@ static void ReadPipe(Service::Interface* self) {
UNREACHABLE();
}
- LOG_DEBUG(Service_DSP, "pipe=%u, unknown=0x%08X, size=0x%X, buffer=0x%08X, return cmd_buff[2]=0x%08X", pipe_index, unknown, size, addr, cmd_buff[2]);
+ LOG_DEBUG(Service_DSP,
+ "pipe=%u, unknown=0x%08X, size=0x%X, buffer=0x%08X, return cmd_buff[2]=0x%08X",
+ pipe_index, unknown, size, addr, cmd_buff[2]);
}
/**
@@ -408,7 +426,8 @@ static void GetPipeReadableSize(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = static_cast<u32>(DSP::HLE::GetPipeReadableSize(pipe));
- LOG_DEBUG(Service_DSP, "pipe=%u, unknown=0x%08X, return cmd_buff[2]=0x%08X", pipe_index, unknown, cmd_buff[2]);
+ LOG_DEBUG(Service_DSP, "pipe=%u, unknown=0x%08X, return cmd_buff[2]=0x%08X", pipe_index,
+ unknown, cmd_buff[2]);
}
/**
@@ -443,7 +462,7 @@ static void GetHeadphoneStatus(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x1F, 2, 0);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- cmd_buff[2] = 0; // Not using headphones
+ cmd_buff[2] = 0; // Not using headphones
LOG_DEBUG(Service_DSP, "called");
}
@@ -466,7 +485,8 @@ static void RecvData(Service::Interface* self) {
ASSERT_MSG(register_number == 0, "Unknown register_number %u", register_number);
- // Application reads this after requesting DSP shutdown, to verify the DSP has indeed shutdown or slept.
+ // Application reads this after requesting DSP shutdown, to verify the DSP has indeed shutdown
+ // or slept.
cmd_buff[0] = IPC::MakeHeader(0x1, 2, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
@@ -512,39 +532,39 @@ static void RecvDataIsReady(Service::Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010040, RecvData, "RecvData"},
- {0x00020040, RecvDataIsReady, "RecvDataIsReady"},
- {0x00030080, nullptr, "SendData"},
- {0x00040040, nullptr, "SendDataIsEmpty"},
- {0x000500C2, nullptr, "SendFifoEx"},
- {0x000600C0, nullptr, "RecvFifoEx"},
- {0x00070040, SetSemaphore, "SetSemaphore"},
- {0x00080000, nullptr, "GetSemaphore"},
- {0x00090040, nullptr, "ClearSemaphore"},
- {0x000A0040, nullptr, "MaskSemaphore"},
- {0x000B0000, nullptr, "CheckSemaphoreRequest"},
+ {0x00010040, RecvData, "RecvData"},
+ {0x00020040, RecvDataIsReady, "RecvDataIsReady"},
+ {0x00030080, nullptr, "SendData"},
+ {0x00040040, nullptr, "SendDataIsEmpty"},
+ {0x000500C2, nullptr, "SendFifoEx"},
+ {0x000600C0, nullptr, "RecvFifoEx"},
+ {0x00070040, SetSemaphore, "SetSemaphore"},
+ {0x00080000, nullptr, "GetSemaphore"},
+ {0x00090040, nullptr, "ClearSemaphore"},
+ {0x000A0040, nullptr, "MaskSemaphore"},
+ {0x000B0000, nullptr, "CheckSemaphoreRequest"},
{0x000C0040, ConvertProcessAddressFromDspDram, "ConvertProcessAddressFromDspDram"},
- {0x000D0082, WriteProcessPipe, "WriteProcessPipe"},
- {0x000E00C0, ReadPipe, "ReadPipe"},
- {0x000F0080, GetPipeReadableSize, "GetPipeReadableSize"},
- {0x001000C0, ReadPipeIfPossible, "ReadPipeIfPossible"},
- {0x001100C2, LoadComponent, "LoadComponent"},
- {0x00120000, nullptr, "UnloadComponent"},
- {0x00130082, FlushDataCache, "FlushDataCache"},
- {0x00140082, nullptr, "InvalidateDCache"},
- {0x00150082, RegisterInterruptEvents, "RegisterInterruptEvents"},
- {0x00160000, GetSemaphoreEventHandle, "GetSemaphoreEventHandle"},
- {0x00170040, SetSemaphoreMask, "SetSemaphoreMask"},
- {0x00180040, nullptr, "GetPhysicalAddress"},
- {0x00190040, nullptr, "GetVirtualAddress"},
- {0x001A0042, nullptr, "SetIirFilterI2S1_cmd1"},
- {0x001B0042, nullptr, "SetIirFilterI2S1_cmd2"},
- {0x001C0082, nullptr, "SetIirFilterEQ"},
- {0x001D00C0, nullptr, "ReadMultiEx_SPI2"},
- {0x001E00C2, nullptr, "WriteMultiEx_SPI2"},
- {0x001F0000, GetHeadphoneStatus, "GetHeadphoneStatus"},
- {0x00200040, nullptr, "ForceHeadphoneOut"},
- {0x00210000, nullptr, "GetIsDspOccupied"},
+ {0x000D0082, WriteProcessPipe, "WriteProcessPipe"},
+ {0x000E00C0, ReadPipe, "ReadPipe"},
+ {0x000F0080, GetPipeReadableSize, "GetPipeReadableSize"},
+ {0x001000C0, ReadPipeIfPossible, "ReadPipeIfPossible"},
+ {0x001100C2, LoadComponent, "LoadComponent"},
+ {0x00120000, nullptr, "UnloadComponent"},
+ {0x00130082, FlushDataCache, "FlushDataCache"},
+ {0x00140082, nullptr, "InvalidateDCache"},
+ {0x00150082, RegisterInterruptEvents, "RegisterInterruptEvents"},
+ {0x00160000, GetSemaphoreEventHandle, "GetSemaphoreEventHandle"},
+ {0x00170040, SetSemaphoreMask, "SetSemaphoreMask"},
+ {0x00180040, nullptr, "GetPhysicalAddress"},
+ {0x00190040, nullptr, "GetVirtualAddress"},
+ {0x001A0042, nullptr, "SetIirFilterI2S1_cmd1"},
+ {0x001B0042, nullptr, "SetIirFilterI2S1_cmd2"},
+ {0x001C0082, nullptr, "SetIirFilterEQ"},
+ {0x001D00C0, nullptr, "ReadMultiEx_SPI2"},
+ {0x001E00C2, nullptr, "WriteMultiEx_SPI2"},
+ {0x001F0000, GetHeadphoneStatus, "GetHeadphoneStatus"},
+ {0x00200040, nullptr, "ForceHeadphoneOut"},
+ {0x00210000, nullptr, "GetIsDspOccupied"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/dsp_dsp.h b/src/core/hle/service/dsp_dsp.h
index 22f6687cc..3e97da6eb 100644
--- a/src/core/hle/service/dsp_dsp.h
+++ b/src/core/hle/service/dsp_dsp.h
@@ -5,7 +5,6 @@
#pragma once
#include <string>
-
#include "core/hle/service/service.h"
namespace DSP {
diff --git a/src/core/hle/service/err_f.cpp b/src/core/hle/service/err_f.cpp
index 5f9cf6e94..3ca4f98de 100644
--- a/src/core/hle/service/err_f.cpp
+++ b/src/core/hle/service/err_f.cpp
@@ -5,7 +5,6 @@
#include "common/bit_field.h"
#include "common/common_types.h"
#include "common/logging/log.h"
-
#include "core/hle/service/err_f.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -35,70 +34,70 @@ union ErrInfo {
u8 specifier;
struct {
- u8 specifier; // 0x0
- u8 rev_high; // 0x1
- u16 rev_low; // 0x2
- RSL result_code; // 0x4
- u32 address; // 0x8
- INSERT_PADDING_BYTES(4); // 0xC
- u32 pid_low; // 0x10
- u32 pid_high; // 0x14
- u32 aid_low; // 0x18
- u32 aid_high; // 0x1C
+ u8 specifier; // 0x0
+ u8 rev_high; // 0x1
+ u16 rev_low; // 0x2
+ RSL result_code; // 0x4
+ u32 address; // 0x8
+ INSERT_PADDING_BYTES(4); // 0xC
+ u32 pid_low; // 0x10
+ u32 pid_high; // 0x14
+ u32 aid_low; // 0x18
+ u32 aid_high; // 0x1C
} errtype1;
struct {
- u8 specifier; // 0x0
- u8 rev_high; // 0x1
- u16 rev_low; // 0x2
- INSERT_PADDING_BYTES(0xC); // 0x4
- u32 pid_low; // 0x10
- u32 pid_high; // 0x14
- u32 aid_low; // 0x18
- u32 aid_high; // 0x1C
- u8 error_type; // 0x20
- INSERT_PADDING_BYTES(3); // 0x21
- u32 fault_status_reg; // 0x24
- u32 fault_addr; // 0x28
- u32 fpexc; // 0x2C
- u32 finst; // 0x30
- u32 finst2; // 0x34
- INSERT_PADDING_BYTES(0x34); // 0x38
- u32 sp; // 0x6C
- u32 pc; // 0x70
- u32 lr; // 0x74
- u32 cpsr; // 0x78
+ u8 specifier; // 0x0
+ u8 rev_high; // 0x1
+ u16 rev_low; // 0x2
+ INSERT_PADDING_BYTES(0xC); // 0x4
+ u32 pid_low; // 0x10
+ u32 pid_high; // 0x14
+ u32 aid_low; // 0x18
+ u32 aid_high; // 0x1C
+ u8 error_type; // 0x20
+ INSERT_PADDING_BYTES(3); // 0x21
+ u32 fault_status_reg; // 0x24
+ u32 fault_addr; // 0x28
+ u32 fpexc; // 0x2C
+ u32 finst; // 0x30
+ u32 finst2; // 0x34
+ INSERT_PADDING_BYTES(0x34); // 0x38
+ u32 sp; // 0x6C
+ u32 pc; // 0x70
+ u32 lr; // 0x74
+ u32 cpsr; // 0x78
} errtype3;
struct {
- u8 specifier; // 0x0
- u8 rev_high; // 0x1
- u16 rev_low; // 0x2
- RSL result_code; // 0x4
- INSERT_PADDING_BYTES(8); // 0x8
- u32 pid_low; // 0x10
- u32 pid_high; // 0x14
- u32 aid_low; // 0x18
- u32 aid_high; // 0x1C
- char debug_string1[0x2E]; // 0x20
- char debug_string2[0x2E]; // 0x4E
+ u8 specifier; // 0x0
+ u8 rev_high; // 0x1
+ u16 rev_low; // 0x2
+ RSL result_code; // 0x4
+ INSERT_PADDING_BYTES(8); // 0x8
+ u32 pid_low; // 0x10
+ u32 pid_high; // 0x14
+ u32 aid_low; // 0x18
+ u32 aid_high; // 0x1C
+ char debug_string1[0x2E]; // 0x20
+ char debug_string2[0x2E]; // 0x4E
} errtype4;
};
-enum {
- PrefetchAbort = 0,
- DataAbort = 1,
- UndefInstr = 2,
- VectorFP = 3
-};
+enum { PrefetchAbort = 0, DataAbort = 1, UndefInstr = 2, VectorFP = 3 };
static std::string GetErrInfo3Type(u8 type_code) {
switch (type_code) {
- case PrefetchAbort: return "Prefetch Abort";
- case DataAbort: return "Data Abort";
- case UndefInstr: return "Undefined Instruction";
- case VectorFP: return "Vector Floating Point";
- default: return "unknown";
+ case PrefetchAbort:
+ return "Prefetch Abort";
+ case DataAbort:
+ return "Data Abort";
+ case UndefInstr:
+ return "Undefined Instruction";
+ case VectorFP:
+ return "Vector Floating Point";
+ default:
+ return "unknown";
}
}
@@ -110,8 +109,7 @@ static void ThrowFatalError(Service::Interface* self) {
switch (errinfo->specifier) {
case ErrSpecifier0:
- case ErrSpecifier1:
- {
+ case ErrSpecifier1: {
const auto& errtype = errinfo->errtype1;
LOG_CRITICAL(Service_ERR, "PID: 0x%08X_0x%08X", errtype.pid_low, errtype.pid_high);
LOG_CRITICAL(Service_ERR, "REV: %d", errtype.rev_low | (errtype.rev_high << 16));
@@ -119,15 +117,14 @@ static void ThrowFatalError(Service::Interface* self) {
LOG_CRITICAL(Service_ERR, "ADR: 0x%08X", errtype.address);
LOG_CRITICAL(Service_ERR, "RSL: 0x%08X", errtype.result_code.raw);
- LOG_CRITICAL(Service_ERR, " Level: %u", errtype.result_code.level.Value());
+ LOG_CRITICAL(Service_ERR, " Level: %u", errtype.result_code.level.Value());
LOG_CRITICAL(Service_ERR, " Summary: %u", errtype.result_code.summary.Value());
- LOG_CRITICAL(Service_ERR, " Module: %u", errtype.result_code.module.Value());
- LOG_CRITICAL(Service_ERR, " Desc: %u", errtype.result_code.description.Value());
+ LOG_CRITICAL(Service_ERR, " Module: %u", errtype.result_code.module.Value());
+ LOG_CRITICAL(Service_ERR, " Desc: %u", errtype.result_code.description.Value());
break;
}
- case ErrSpecifier3:
- {
+ case ErrSpecifier3: {
const auto& errtype = errinfo->errtype3;
LOG_CRITICAL(Service_ERR, "PID: 0x%08X_0x%08X", errtype.pid_low, errtype.pid_high);
LOG_CRITICAL(Service_ERR, "REV: %d", errtype.rev_low | (errtype.rev_high << 16));
@@ -154,18 +151,17 @@ static void ThrowFatalError(Service::Interface* self) {
break;
}
- case ErrSpecifier4:
- {
+ case ErrSpecifier4: {
const auto& errtype = errinfo->errtype4;
LOG_CRITICAL(Service_ERR, "PID: 0x%08X_0x%08X", errtype.pid_low, errtype.pid_high);
LOG_CRITICAL(Service_ERR, "REV: %d", errtype.rev_low | (errtype.rev_high << 16));
LOG_CRITICAL(Service_ERR, "AID: 0x%08X_0x%08X", errtype.aid_low, errtype.aid_high);
LOG_CRITICAL(Service_ERR, "RSL: 0x%08X", errtype.result_code.raw);
- LOG_CRITICAL(Service_ERR, " Level: %u", errtype.result_code.level.Value());
+ LOG_CRITICAL(Service_ERR, " Level: %u", errtype.result_code.level.Value());
LOG_CRITICAL(Service_ERR, " Summary: %u", errtype.result_code.summary.Value());
- LOG_CRITICAL(Service_ERR, " Module: %u", errtype.result_code.module.Value());
- LOG_CRITICAL(Service_ERR, " Desc: %u", errtype.result_code.description.Value());
+ LOG_CRITICAL(Service_ERR, " Module: %u", errtype.result_code.module.Value());
+ LOG_CRITICAL(Service_ERR, " Desc: %u", errtype.result_code.description.Value());
LOG_CRITICAL(Service_ERR, "%s", errtype.debug_string1);
LOG_CRITICAL(Service_ERR, "%s", errtype.debug_string2);
@@ -177,7 +173,7 @@ static void ThrowFatalError(Service::Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010800, ThrowFatalError, "ThrowFatalError"}
+ {0x00010800, ThrowFatalError, "ThrowFatalError"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/frd/frd.cpp b/src/core/hle/service/frd/frd.cpp
index 29d144365..fa5080535 100644
--- a/src/core/hle/service/frd/frd.cpp
+++ b/src/core/hle/service/frd/frd.cpp
@@ -3,11 +3,10 @@
// Refer to the license.txt file included.
#include "common/string_util.h"
-
-#include "core/hle/service/service.h"
#include "core/hle/service/frd/frd.h"
#include "core/hle/service/frd/frd_a.h"
#include "core/hle/service/frd/frd_u.h"
+#include "core/hle/service/service.h"
namespace Service {
namespace FRD {
@@ -43,7 +42,7 @@ void GetFriendKeyList(Service::Interface* self) {
}
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- cmd_buff[2] = 0; // 0 friends
+ cmd_buff[2] = 0; // 0 friends
LOG_WARNING(Service_FRD, "(STUBBED) called, unknown=%d, frd_count=%d, frd_key_addr=0x%08X",
unknown, frd_count, frd_key_addr);
}
@@ -61,25 +60,27 @@ void GetFriendProfile(Service::Interface* self) {
}
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- LOG_WARNING(Service_FRD, "(STUBBED) called, count=%d, frd_key_addr=0x%08X, profiles_addr=0x%08X",
- count, frd_key_addr, profiles_addr);
+ LOG_WARNING(Service_FRD,
+ "(STUBBED) called, count=%d, frd_key_addr=0x%08X, profiles_addr=0x%08X", count,
+ frd_key_addr, profiles_addr);
}
void GetFriendAttributeFlags(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- u32 count = cmd_buff[1];
- u32 frd_key_addr = cmd_buff[3];
+ u32 count = cmd_buff[1];
+ u32 frd_key_addr = cmd_buff[3];
u32 attr_flags_addr = cmd_buff[65];
for (u32 i = 0; i < count; ++i) {
- //TODO:(mailwl) figure out AttributeFlag size and zero all buffer. Assume 1 byte
+ // TODO:(mailwl) figure out AttributeFlag size and zero all buffer. Assume 1 byte
Memory::Write8(attr_flags_addr + i, 0);
}
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- LOG_WARNING(Service_FRD, "(STUBBED) called, count=%d, frd_key_addr=0x%08X, attr_flags_addr=0x%08X",
- count, frd_key_addr, attr_flags_addr);
+ LOG_WARNING(Service_FRD,
+ "(STUBBED) called, count=%d, frd_key_addr=0x%08X, attr_flags_addr=0x%08X", count,
+ frd_key_addr, attr_flags_addr);
}
void GetMyFriendKey(Service::Interface* self) {
@@ -106,8 +107,7 @@ void Init() {
AddService(new FRD_U_Interface);
}
-void Shutdown() {
-}
+void Shutdown() {}
} // namespace FRD
diff --git a/src/core/hle/service/frd/frd_a.cpp b/src/core/hle/service/frd/frd_a.cpp
index 818d610f3..cfc37210b 100644
--- a/src/core/hle/service/frd/frd_a.cpp
+++ b/src/core/hle/service/frd/frd_a.cpp
@@ -11,7 +11,7 @@ namespace FRD {
// const Interface::FunctionInfo FunctionTable[] = { };
FRD_A_Interface::FRD_A_Interface() {
- //Register(FunctionTable);
+ // Register(FunctionTable);
}
} // namespace FRD
diff --git a/src/core/hle/service/frd/frd_u.cpp b/src/core/hle/service/frd/frd_u.cpp
index db8666416..bd1c9c16b 100644
--- a/src/core/hle/service/frd/frd_u.cpp
+++ b/src/core/hle/service/frd/frd_u.cpp
@@ -9,59 +9,59 @@ namespace Service {
namespace FRD {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010000, nullptr, "HasLoggedIn"},
- {0x00020000, nullptr, "IsOnline"},
- {0x00030000, nullptr, "Login"},
- {0x00040000, nullptr, "Logout"},
- {0x00050000, GetMyFriendKey, "GetMyFriendKey"},
- {0x00060000, nullptr, "GetMyPreference"},
- {0x00070000, nullptr, "GetMyProfile"},
- {0x00080000, GetMyPresence, "GetMyPresence"},
- {0x00090000, GetMyScreenName, "GetMyScreenName"},
- {0x000A0000, nullptr, "GetMyMii"},
- {0x000B0000, nullptr, "GetMyLocalAccountId"},
- {0x000C0000, nullptr, "GetMyPlayingGame"},
- {0x000D0000, nullptr, "GetMyFavoriteGame"},
- {0x000E0000, nullptr, "GetMyNcPrincipalId"},
- {0x000F0000, nullptr, "GetMyComment"},
- {0x00100040, nullptr, "GetMyPassword"},
- {0x00110080, GetFriendKeyList, "GetFriendKeyList"},
- {0x00120042, nullptr, "GetFriendPresence"},
- {0x00130142, nullptr, "GetFriendScreenName"},
- {0x00140044, nullptr, "GetFriendMii"},
- {0x00150042, GetFriendProfile, "GetFriendProfile"},
- {0x00160042, nullptr, "GetFriendRelationship"},
+ {0x00010000, nullptr, "HasLoggedIn"},
+ {0x00020000, nullptr, "IsOnline"},
+ {0x00030000, nullptr, "Login"},
+ {0x00040000, nullptr, "Logout"},
+ {0x00050000, GetMyFriendKey, "GetMyFriendKey"},
+ {0x00060000, nullptr, "GetMyPreference"},
+ {0x00070000, nullptr, "GetMyProfile"},
+ {0x00080000, GetMyPresence, "GetMyPresence"},
+ {0x00090000, GetMyScreenName, "GetMyScreenName"},
+ {0x000A0000, nullptr, "GetMyMii"},
+ {0x000B0000, nullptr, "GetMyLocalAccountId"},
+ {0x000C0000, nullptr, "GetMyPlayingGame"},
+ {0x000D0000, nullptr, "GetMyFavoriteGame"},
+ {0x000E0000, nullptr, "GetMyNcPrincipalId"},
+ {0x000F0000, nullptr, "GetMyComment"},
+ {0x00100040, nullptr, "GetMyPassword"},
+ {0x00110080, GetFriendKeyList, "GetFriendKeyList"},
+ {0x00120042, nullptr, "GetFriendPresence"},
+ {0x00130142, nullptr, "GetFriendScreenName"},
+ {0x00140044, nullptr, "GetFriendMii"},
+ {0x00150042, GetFriendProfile, "GetFriendProfile"},
+ {0x00160042, nullptr, "GetFriendRelationship"},
{0x00170042, GetFriendAttributeFlags, "GetFriendAttributeFlags"},
- {0x00180044, nullptr, "GetFriendPlayingGame"},
- {0x00190042, nullptr, "GetFriendFavoriteGame"},
- {0x001A00C4, nullptr, "GetFriendInfo"},
- {0x001B0080, nullptr, "IsIncludedInFriendList"},
- {0x001C0042, nullptr, "UnscrambleLocalFriendCode"},
- {0x001D0002, nullptr, "UpdateGameModeDescription"},
- {0x001E02C2, nullptr, "UpdateGameMode"},
- {0x001F0042, nullptr, "SendInvitation"},
- {0x00200002, nullptr, "AttachToEventNotification"},
- {0x00210040, nullptr, "SetNotificationMask"},
- {0x00220040, nullptr, "GetEventNotification"},
- {0x00230000, nullptr, "GetLastResponseResult"},
- {0x00240040, nullptr, "PrincipalIdToFriendCode"},
- {0x00250080, nullptr, "FriendCodeToPrincipalId"},
- {0x00260080, nullptr, "IsValidFriendCode"},
- {0x00270040, nullptr, "ResultToErrorCode"},
- {0x00280244, nullptr, "RequestGameAuthentication"},
- {0x00290000, nullptr, "GetGameAuthenticationData"},
- {0x002A0204, nullptr, "RequestServiceLocator"},
- {0x002B0000, nullptr, "GetServiceLocatorData"},
- {0x002C0002, nullptr, "DetectNatProperties"},
- {0x002D0000, nullptr, "GetNatProperties"},
- {0x002E0000, nullptr, "GetServerTimeInterval"},
- {0x002F0040, nullptr, "AllowHalfAwake"},
- {0x00300000, nullptr, "GetServerTypes"},
- {0x00310082, nullptr, "GetFriendComment"},
- {0x00320042, nullptr, "SetClientSdkVersion"},
- {0x00330000, nullptr, "GetMyApproachContext"},
- {0x00340046, nullptr, "AddFriendWithApproach"},
- {0x00350082, nullptr, "DecryptApproachContext"},
+ {0x00180044, nullptr, "GetFriendPlayingGame"},
+ {0x00190042, nullptr, "GetFriendFavoriteGame"},
+ {0x001A00C4, nullptr, "GetFriendInfo"},
+ {0x001B0080, nullptr, "IsIncludedInFriendList"},
+ {0x001C0042, nullptr, "UnscrambleLocalFriendCode"},
+ {0x001D0002, nullptr, "UpdateGameModeDescription"},
+ {0x001E02C2, nullptr, "UpdateGameMode"},
+ {0x001F0042, nullptr, "SendInvitation"},
+ {0x00200002, nullptr, "AttachToEventNotification"},
+ {0x00210040, nullptr, "SetNotificationMask"},
+ {0x00220040, nullptr, "GetEventNotification"},
+ {0x00230000, nullptr, "GetLastResponseResult"},
+ {0x00240040, nullptr, "PrincipalIdToFriendCode"},
+ {0x00250080, nullptr, "FriendCodeToPrincipalId"},
+ {0x00260080, nullptr, "IsValidFriendCode"},
+ {0x00270040, nullptr, "ResultToErrorCode"},
+ {0x00280244, nullptr, "RequestGameAuthentication"},
+ {0x00290000, nullptr, "GetGameAuthenticationData"},
+ {0x002A0204, nullptr, "RequestServiceLocator"},
+ {0x002B0000, nullptr, "GetServiceLocatorData"},
+ {0x002C0002, nullptr, "DetectNatProperties"},
+ {0x002D0000, nullptr, "GetNatProperties"},
+ {0x002E0000, nullptr, "GetServerTimeInterval"},
+ {0x002F0040, nullptr, "AllowHalfAwake"},
+ {0x00300000, nullptr, "GetServerTypes"},
+ {0x00310082, nullptr, "GetFriendComment"},
+ {0x00320042, nullptr, "SetClientSdkVersion"},
+ {0x00330000, nullptr, "GetMyApproachContext"},
+ {0x00340046, nullptr, "AddFriendWithApproach"},
+ {0x00350082, nullptr, "DecryptApproachContext"},
};
FRD_U_Interface::FRD_U_Interface() {
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp
index 4c7aaa7f2..4dc7e1e3c 100644
--- a/src/core/hle/service/fs/archive.cpp
+++ b/src/core/hle/service/fs/archive.cpp
@@ -3,19 +3,16 @@
// Refer to the license.txt file included.
#include <cstddef>
+#include <memory>
#include <system_error>
#include <type_traits>
-#include <memory>
#include <unordered_map>
#include <utility>
-
#include <boost/container/flat_map.hpp>
-
#include "common/assert.h"
#include "common/common_types.h"
#include "common/file_util.h"
#include "common/logging/log.h"
-
#include "core/file_sys/archive_backend.h"
#include "core/file_sys/archive_extsavedata.h"
#include "core/file_sys/archive_savedata.h"
@@ -25,25 +22,25 @@
#include "core/file_sys/directory_backend.h"
#include "core/file_sys/file_backend.h"
#include "core/hle/hle.h"
-#include "core/hle/service/service.h"
+#include "core/hle/result.h"
#include "core/hle/service/fs/archive.h"
#include "core/hle/service/fs/fs_user.h"
-#include "core/hle/result.h"
+#include "core/hle/service/service.h"
#include "core/memory.h"
// Specializes std::hash for ArchiveIdCode, so that we can use it in std::unordered_map.
// Workaroung for libstdc++ bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60970
namespace std {
- template <>
- struct hash<Service::FS::ArchiveIdCode> {
- typedef Service::FS::ArchiveIdCode argument_type;
- typedef std::size_t result_type;
-
- result_type operator()(const argument_type& id_code) const {
- typedef std::underlying_type<argument_type>::type Type;
- return std::hash<Type>()(static_cast<Type>(id_code));
- }
- };
+template <>
+struct hash<Service::FS::ArchiveIdCode> {
+ typedef Service::FS::ArchiveIdCode argument_type;
+ typedef std::size_t result_type;
+
+ result_type operator()(const argument_type& id_code) const {
+ typedef std::underlying_type<argument_type>::type Type;
+ return std::hash<Type>()(static_cast<Type>(id_code));
+ }
+};
}
/// TODO(Subv): Confirm length of these strings
@@ -56,39 +53,40 @@ namespace FS {
// TODO: Verify code
/// Returned when a function is passed an invalid handle.
const ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::FS,
- ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
+ ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
/// Returned when a function is passed an invalid archive handle.
const ResultCode ERR_INVALID_ARCHIVE_HANDLE(ErrorDescription::FS_ArchiveNotMounted, ErrorModule::FS,
- ErrorSummary::NotFound, ErrorLevel::Status); // 0xC8804465
+ ErrorSummary::NotFound,
+ ErrorLevel::Status); // 0xC8804465
// Command to access archive file
enum class FileCommand : u32 {
- Dummy1 = 0x000100C6,
- Control = 0x040100C4,
- OpenSubFile = 0x08010100,
- Read = 0x080200C2,
- Write = 0x08030102,
- GetSize = 0x08040000,
- SetSize = 0x08050080,
- GetAttributes = 0x08060000,
- SetAttributes = 0x08070040,
- Close = 0x08080000,
- Flush = 0x08090000,
- SetPriority = 0x080A0040,
- GetPriority = 0x080B0000,
- OpenLinkFile = 0x080C0000,
+ Dummy1 = 0x000100C6,
+ Control = 0x040100C4,
+ OpenSubFile = 0x08010100,
+ Read = 0x080200C2,
+ Write = 0x08030102,
+ GetSize = 0x08040000,
+ SetSize = 0x08050080,
+ GetAttributes = 0x08060000,
+ SetAttributes = 0x08070040,
+ Close = 0x08080000,
+ Flush = 0x08090000,
+ SetPriority = 0x080A0040,
+ GetPriority = 0x080B0000,
+ OpenLinkFile = 0x080C0000,
};
// Command to access directory
enum class DirectoryCommand : u32 {
- Dummy1 = 0x000100C6,
- Control = 0x040100C4,
- Read = 0x08010042,
- Close = 0x08020000,
+ Dummy1 = 0x000100C6,
+ Control = 0x040100C4,
+ Read = 0x08010042,
+ Close = 0x08020000,
};
-File::File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path & path)
+File::File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& path)
: path(path), priority(0), backend(std::move(backend)) {}
File::~File() {}
@@ -98,117 +96,110 @@ ResultVal<bool> File::SyncRequest() {
FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]);
switch (cmd) {
- // Read from file...
- case FileCommand::Read:
- {
- u64 offset = cmd_buff[1] | ((u64)cmd_buff[2]) << 32;
- u32 length = cmd_buff[3];
- u32 address = cmd_buff[5];
- LOG_TRACE(Service_FS, "Read %s %s: offset=0x%llx length=%d address=0x%x",
- GetTypeName().c_str(), GetName().c_str(), offset, length, address);
-
- if (offset + length > backend->GetSize()) {
- LOG_ERROR(Service_FS, "Reading from out of bounds offset=0x%llX length=0x%08X file_size=0x%llX",
- offset, length, backend->GetSize());
- }
-
- std::vector<u8> data(length);
- ResultVal<size_t> read = backend->Read(offset, data.size(), data.data());
- if (read.Failed()) {
- cmd_buff[1] = read.Code().raw;
- return read.Code();
- }
- Memory::WriteBlock(address, data.data(), *read);
- cmd_buff[2] = static_cast<u32>(*read);
- break;
+ // Read from file...
+ case FileCommand::Read: {
+ u64 offset = cmd_buff[1] | ((u64)cmd_buff[2]) << 32;
+ u32 length = cmd_buff[3];
+ u32 address = cmd_buff[5];
+ LOG_TRACE(Service_FS, "Read %s %s: offset=0x%llx length=%d address=0x%x",
+ GetTypeName().c_str(), GetName().c_str(), offset, length, address);
+
+ if (offset + length > backend->GetSize()) {
+ LOG_ERROR(Service_FS,
+ "Reading from out of bounds offset=0x%llX length=0x%08X file_size=0x%llX",
+ offset, length, backend->GetSize());
}
- // Write to file...
- case FileCommand::Write:
- {
- u64 offset = cmd_buff[1] | ((u64)cmd_buff[2]) << 32;
- u32 length = cmd_buff[3];
- u32 flush = cmd_buff[4];
- u32 address = cmd_buff[6];
- LOG_TRACE(Service_FS, "Write %s %s: offset=0x%llx length=%d address=0x%x, flush=0x%x",
- GetTypeName().c_str(), GetName().c_str(), offset, length, address, flush);
-
- std::vector<u8> data(length);
- Memory::ReadBlock(address, data.data(), data.size());
- ResultVal<size_t> written = backend->Write(offset, data.size(), flush != 0, data.data());
- if (written.Failed()) {
- cmd_buff[1] = written.Code().raw;
- return written.Code();
- }
- cmd_buff[2] = static_cast<u32>(*written);
- break;
+ std::vector<u8> data(length);
+ ResultVal<size_t> read = backend->Read(offset, data.size(), data.data());
+ if (read.Failed()) {
+ cmd_buff[1] = read.Code().raw;
+ return read.Code();
}
+ Memory::WriteBlock(address, data.data(), *read);
+ cmd_buff[2] = static_cast<u32>(*read);
+ break;
+ }
- case FileCommand::GetSize:
- {
- LOG_TRACE(Service_FS, "GetSize %s %s", GetTypeName().c_str(), GetName().c_str());
- u64 size = backend->GetSize();
- cmd_buff[2] = (u32)size;
- cmd_buff[3] = size >> 32;
- break;
+ // Write to file...
+ case FileCommand::Write: {
+ u64 offset = cmd_buff[1] | ((u64)cmd_buff[2]) << 32;
+ u32 length = cmd_buff[3];
+ u32 flush = cmd_buff[4];
+ u32 address = cmd_buff[6];
+ LOG_TRACE(Service_FS, "Write %s %s: offset=0x%llx length=%d address=0x%x, flush=0x%x",
+ GetTypeName().c_str(), GetName().c_str(), offset, length, address, flush);
+
+ std::vector<u8> data(length);
+ Memory::ReadBlock(address, data.data(), data.size());
+ ResultVal<size_t> written = backend->Write(offset, data.size(), flush != 0, data.data());
+ if (written.Failed()) {
+ cmd_buff[1] = written.Code().raw;
+ return written.Code();
}
+ cmd_buff[2] = static_cast<u32>(*written);
+ break;
+ }
- case FileCommand::SetSize:
- {
- u64 size = cmd_buff[1] | ((u64)cmd_buff[2] << 32);
- LOG_TRACE(Service_FS, "SetSize %s %s size=%llu",
- GetTypeName().c_str(), GetName().c_str(), size);
- backend->SetSize(size);
- break;
- }
+ case FileCommand::GetSize: {
+ LOG_TRACE(Service_FS, "GetSize %s %s", GetTypeName().c_str(), GetName().c_str());
+ u64 size = backend->GetSize();
+ cmd_buff[2] = (u32)size;
+ cmd_buff[3] = size >> 32;
+ break;
+ }
- case FileCommand::Close:
- {
- LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
- backend->Close();
- break;
- }
+ case FileCommand::SetSize: {
+ u64 size = cmd_buff[1] | ((u64)cmd_buff[2] << 32);
+ LOG_TRACE(Service_FS, "SetSize %s %s size=%llu", GetTypeName().c_str(), GetName().c_str(),
+ size);
+ backend->SetSize(size);
+ break;
+ }
- case FileCommand::Flush:
- {
- LOG_TRACE(Service_FS, "Flush");
- backend->Flush();
- break;
- }
+ case FileCommand::Close: {
+ LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
+ backend->Close();
+ break;
+ }
- case FileCommand::OpenLinkFile:
- {
- LOG_WARNING(Service_FS, "(STUBBED) File command OpenLinkFile %s", GetName().c_str());
- cmd_buff[3] = Kernel::g_handle_table.Create(this).ValueOr(INVALID_HANDLE);
- break;
- }
+ case FileCommand::Flush: {
+ LOG_TRACE(Service_FS, "Flush");
+ backend->Flush();
+ break;
+ }
- case FileCommand::SetPriority:
- {
- priority = cmd_buff[1];
- LOG_TRACE(Service_FS, "SetPriority %u", priority);
- break;
- }
+ case FileCommand::OpenLinkFile: {
+ LOG_WARNING(Service_FS, "(STUBBED) File command OpenLinkFile %s", GetName().c_str());
+ cmd_buff[3] = Kernel::g_handle_table.Create(this).ValueOr(INVALID_HANDLE);
+ break;
+ }
- case FileCommand::GetPriority:
- {
- cmd_buff[2] = priority;
- LOG_TRACE(Service_FS, "GetPriority");
- break;
- }
+ case FileCommand::SetPriority: {
+ priority = cmd_buff[1];
+ LOG_TRACE(Service_FS, "SetPriority %u", priority);
+ break;
+ }
+
+ case FileCommand::GetPriority: {
+ cmd_buff[2] = priority;
+ LOG_TRACE(Service_FS, "GetPriority");
+ break;
+ }
- // Unknown command...
- default:
- LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd);
- ResultCode error = UnimplementedFunction(ErrorModule::FS);
- cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that.
- return error;
+ // Unknown command...
+ default:
+ LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd);
+ ResultCode error = UnimplementedFunction(ErrorModule::FS);
+ cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that.
+ return error;
}
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
return MakeResult<bool>(false);
}
-Directory::Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, const FileSys::Path & path)
+Directory::Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend,
+ const FileSys::Path& path)
: path(path), backend(std::move(backend)) {}
Directory::~Directory() {}
@@ -218,35 +209,33 @@ ResultVal<bool> Directory::SyncRequest() {
DirectoryCommand cmd = static_cast<DirectoryCommand>(cmd_buff[0]);
switch (cmd) {
- // Read from directory...
- case DirectoryCommand::Read:
- {
- u32 count = cmd_buff[1];
- u32 address = cmd_buff[3];
- std::vector<FileSys::Entry> entries(count);
- LOG_TRACE(Service_FS, "Read %s %s: count=%d",
- GetTypeName().c_str(), GetName().c_str(), count);
-
- // Number of entries actually read
- u32 read = backend->Read(entries.size(), entries.data());
- cmd_buff[2] = read;
- Memory::WriteBlock(address, entries.data(), read * sizeof(FileSys::Entry));
- break;
- }
+ // Read from directory...
+ case DirectoryCommand::Read: {
+ u32 count = cmd_buff[1];
+ u32 address = cmd_buff[3];
+ std::vector<FileSys::Entry> entries(count);
+ LOG_TRACE(Service_FS, "Read %s %s: count=%d", GetTypeName().c_str(), GetName().c_str(),
+ count);
+
+ // Number of entries actually read
+ u32 read = backend->Read(entries.size(), entries.data());
+ cmd_buff[2] = read;
+ Memory::WriteBlock(address, entries.data(), read * sizeof(FileSys::Entry));
+ break;
+ }
- case DirectoryCommand::Close:
- {
- LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
- backend->Close();
- break;
- }
+ case DirectoryCommand::Close: {
+ LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
+ backend->Close();
+ break;
+ }
- // Unknown command...
- default:
- LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd);
- ResultCode error = UnimplementedFunction(ErrorModule::FS);
- cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that.
- return MakeResult<bool>(false);
+ // Unknown command...
+ default:
+ LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd);
+ ResultCode error = UnimplementedFunction(ErrorModule::FS);
+ cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that.
+ return MakeResult<bool>(false);
}
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
return MakeResult<bool>(false);
@@ -280,8 +269,8 @@ ResultVal<ArchiveHandle> OpenArchive(ArchiveIdCode id_code, FileSys::Path& archi
auto itr = id_code_map.find(id_code);
if (itr == id_code_map.end()) {
// TODO: Verify error against hardware
- return ResultCode(ErrorDescription::NotFound, ErrorModule::FS,
- ErrorSummary::NotFound, ErrorLevel::Permanent);
+ return ResultCode(ErrorDescription::NotFound, ErrorModule::FS, ErrorSummary::NotFound,
+ ErrorLevel::Permanent);
}
CASCADE_RESULT(std::unique_ptr<ArchiveBackend> res, itr->second->Open(archive_path));
@@ -303,19 +292,22 @@ ResultCode CloseArchive(ArchiveHandle handle) {
// TODO(yuriks): This might be what the fs:REG service is for. See the Register/Unregister calls in
// http://3dbrew.org/wiki/Filesystem_services#ProgramRegistry_service_.22fs:REG.22
-ResultCode RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory, ArchiveIdCode id_code) {
+ResultCode RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory,
+ ArchiveIdCode id_code) {
auto result = id_code_map.emplace(id_code, std::move(factory));
bool inserted = result.second;
ASSERT_MSG(inserted, "Tried to register more than one archive with same id code");
auto& archive = result.first->second;
- LOG_DEBUG(Service_FS, "Registered archive %s with id code 0x%08X", archive->GetName().c_str(), id_code);
+ LOG_DEBUG(Service_FS, "Registered archive %s with id code 0x%08X", archive->GetName().c_str(),
+ id_code);
return RESULT_SUCCESS;
}
ResultVal<Kernel::SharedPtr<File>> OpenFileFromArchive(ArchiveHandle archive_handle,
- const FileSys::Path& path, const FileSys::Mode mode) {
+ const FileSys::Path& path,
+ const FileSys::Mode mode) {
ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr)
return ERR_INVALID_ARCHIVE_HANDLE;
@@ -336,8 +328,10 @@ ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Pa
return archive->DeleteFile(path);
}
-ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const FileSys::Path& src_path,
- ArchiveHandle dest_archive_handle, const FileSys::Path& dest_path) {
+ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle,
+ const FileSys::Path& src_path,
+ ArchiveHandle dest_archive_handle,
+ const FileSys::Path& dest_path) {
ArchiveBackend* src_archive = GetArchive(src_archive_handle);
ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
if (src_archive == nullptr || dest_archive == nullptr)
@@ -368,7 +362,8 @@ ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy
ErrorSummary::Canceled, ErrorLevel::Status);
}
-ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, u64 file_size) {
+ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path,
+ u64 file_size) {
ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr)
return ERR_INVALID_ARCHIVE_HANDLE;
@@ -387,8 +382,10 @@ ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy
ErrorSummary::Canceled, ErrorLevel::Status);
}
-ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, const FileSys::Path& src_path,
- ArchiveHandle dest_archive_handle, const FileSys::Path& dest_path) {
+ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
+ const FileSys::Path& src_path,
+ ArchiveHandle dest_archive_handle,
+ const FileSys::Path& dest_path) {
ArchiveBackend* src_archive = GetArchive(src_archive_handle);
ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
if (src_archive == nullptr || dest_archive == nullptr)
@@ -409,15 +406,15 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, cons
}
ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle archive_handle,
- const FileSys::Path& path) {
+ const FileSys::Path& path) {
ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr)
return ERR_INVALID_ARCHIVE_HANDLE;
std::unique_ptr<FileSys::DirectoryBackend> backend = archive->OpenDirectory(path);
if (backend == nullptr) {
- return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS,
- ErrorSummary::NotFound, ErrorLevel::Permanent);
+ return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, ErrorSummary::NotFound,
+ ErrorLevel::Permanent);
}
auto directory = Kernel::SharedPtr<Directory>(new Directory(std::move(backend), path));
@@ -431,7 +428,8 @@ ResultVal<u64> GetFreeBytesInArchive(ArchiveHandle archive_handle) {
return MakeResult<u64>(archive->GetFreeBytes());
}
-ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo& format_info, const FileSys::Path& path) {
+ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo& format_info,
+ const FileSys::Path& path) {
auto archive_itr = id_code_map.find(id_code);
if (archive_itr == id_code_map.end()) {
return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error
@@ -440,7 +438,8 @@ ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo
return archive_itr->second->Format(path, format_info);
}
-ResultVal<FileSys::ArchiveFormatInfo> GetArchiveFormatInfo(ArchiveIdCode id_code, FileSys::Path& archive_path) {
+ResultVal<FileSys::ArchiveFormatInfo> GetArchiveFormatInfo(ArchiveIdCode id_code,
+ FileSys::Path& archive_path) {
auto archive = id_code_map.find(id_code);
if (archive == id_code_map.end()) {
return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error
@@ -449,11 +448,14 @@ ResultVal<FileSys::ArchiveFormatInfo> GetArchiveFormatInfo(ArchiveIdCode id_code
return archive->second->GetFormatInfo(archive_path);
}
-ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low, VAddr icon_buffer, u32 icon_size, const FileSys::ArchiveFormatInfo& format_info) {
+ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low, VAddr icon_buffer,
+ u32 icon_size, const FileSys::ArchiveFormatInfo& format_info) {
// Construct the binary path to the archive first
- FileSys::Path path = FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low);
+ FileSys::Path path =
+ FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low);
- auto archive = id_code_map.find(media_type == MediaType::NAND ? ArchiveIdCode::SharedExtSaveData : ArchiveIdCode::ExtSaveData);
+ auto archive = id_code_map.find(media_type == MediaType::NAND ? ArchiveIdCode::SharedExtSaveData
+ : ArchiveIdCode::ExtSaveData);
if (archive == id_code_map.end()) {
return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error
@@ -476,7 +478,8 @@ ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low, VAddr icon
ResultCode DeleteExtSaveData(MediaType media_type, u32 high, u32 low) {
// Construct the binary path to the archive first
- FileSys::Path path = FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low);
+ FileSys::Path path =
+ FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low);
std::string media_type_directory;
if (media_type == MediaType::NAND) {
@@ -489,7 +492,8 @@ ResultCode DeleteExtSaveData(MediaType media_type, u32 high, u32 low) {
}
// Delete all directories (/user, /boss) and the icon file.
- std::string base_path = FileSys::GetExtDataContainerPath(media_type_directory, media_type == MediaType::NAND);
+ std::string base_path =
+ FileSys::GetExtDataContainerPath(media_type_directory, media_type == MediaType::NAND);
std::string extsavedata_path = FileSys::GetExtSaveDataPath(base_path, path);
if (FileUtil::Exists(extsavedata_path) && !FileUtil::DeleteDirRecursively(extsavedata_path))
return ResultCode(-1); // TODO(Subv): Find the right error code
@@ -530,30 +534,36 @@ void RegisterArchiveTypes() {
if (sdmc_factory->Initialize())
RegisterArchiveType(std::move(sdmc_factory), ArchiveIdCode::SDMC);
else
- LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str());
+ LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s",
+ sdmc_directory.c_str());
// Create the SaveData archive
auto savedata_factory = std::make_unique<FileSys::ArchiveFactory_SaveData>(sdmc_directory);
RegisterArchiveType(std::move(savedata_factory), ArchiveIdCode::SaveData);
- auto extsavedata_factory = std::make_unique<FileSys::ArchiveFactory_ExtSaveData>(sdmc_directory, false);
+ auto extsavedata_factory =
+ std::make_unique<FileSys::ArchiveFactory_ExtSaveData>(sdmc_directory, false);
if (extsavedata_factory->Initialize())
RegisterArchiveType(std::move(extsavedata_factory), ArchiveIdCode::ExtSaveData);
else
- LOG_ERROR(Service_FS, "Can't instantiate ExtSaveData archive with path %s", extsavedata_factory->GetMountPoint().c_str());
+ LOG_ERROR(Service_FS, "Can't instantiate ExtSaveData archive with path %s",
+ extsavedata_factory->GetMountPoint().c_str());
- auto sharedextsavedata_factory = std::make_unique<FileSys::ArchiveFactory_ExtSaveData>(nand_directory, true);
+ auto sharedextsavedata_factory =
+ std::make_unique<FileSys::ArchiveFactory_ExtSaveData>(nand_directory, true);
if (sharedextsavedata_factory->Initialize())
RegisterArchiveType(std::move(sharedextsavedata_factory), ArchiveIdCode::SharedExtSaveData);
else
LOG_ERROR(Service_FS, "Can't instantiate SharedExtSaveData archive with path %s",
- sharedextsavedata_factory->GetMountPoint().c_str());
+ sharedextsavedata_factory->GetMountPoint().c_str());
// Create the SaveDataCheck archive, basically a small variation of the RomFS archive
- auto savedatacheck_factory = std::make_unique<FileSys::ArchiveFactory_SaveDataCheck>(nand_directory);
+ auto savedatacheck_factory =
+ std::make_unique<FileSys::ArchiveFactory_SaveDataCheck>(nand_directory);
RegisterArchiveType(std::move(savedatacheck_factory), ArchiveIdCode::SaveDataCheck);
- auto systemsavedata_factory = std::make_unique<FileSys::ArchiveFactory_SystemSaveData>(nand_directory);
+ auto systemsavedata_factory =
+ std::make_unique<FileSys::ArchiveFactory_SystemSaveData>(nand_directory);
RegisterArchiveType(std::move(systemsavedata_factory), ArchiveIdCode::SystemSaveData);
}
diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h
index f7a50a3a7..533be34a4 100644
--- a/src/core/hle/service/fs/archive.h
+++ b/src/core/hle/service/fs/archive.h
@@ -6,9 +6,7 @@
#include <memory>
#include <string>
-
#include "common/common_types.h"
-
#include "core/file_sys/archive_backend.h"
#include "core/hle/kernel/session.h"
#include "core/hle/result.h"
@@ -28,21 +26,18 @@ namespace FS {
/// Supported archive types
enum class ArchiveIdCode : u32 {
- RomFS = 0x00000003,
- SaveData = 0x00000004,
- ExtSaveData = 0x00000006,
- SharedExtSaveData = 0x00000007,
- SystemSaveData = 0x00000008,
- SDMC = 0x00000009,
- SDMCWriteOnly = 0x0000000A,
- SaveDataCheck = 0x2345678A,
+ RomFS = 0x00000003,
+ SaveData = 0x00000004,
+ ExtSaveData = 0x00000006,
+ SharedExtSaveData = 0x00000007,
+ SystemSaveData = 0x00000008,
+ SDMC = 0x00000009,
+ SDMCWriteOnly = 0x0000000A,
+ SaveDataCheck = 0x2345678A,
};
/// Media types for the archives
-enum class MediaType : u32 {
- NAND = 0,
- SDMC = 1
-};
+enum class MediaType : u32 { NAND = 0, SDMC = 1 };
typedef u64 ArchiveHandle;
@@ -51,11 +46,13 @@ public:
File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& path);
~File();
- std::string GetName() const override { return "Path: " + path.DebugStr(); }
+ std::string GetName() const override {
+ return "Path: " + path.DebugStr();
+ }
ResultVal<bool> SyncRequest() override;
FileSys::Path path; ///< Path of the file
- u32 priority; ///< Priority of the file. TODO(Subv): Find out what this means
+ u32 priority; ///< Priority of the file. TODO(Subv): Find out what this means
std::unique_ptr<FileSys::FileBackend> backend; ///< File backend interface
};
@@ -64,10 +61,12 @@ public:
Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, const FileSys::Path& path);
~Directory();
- std::string GetName() const override { return "Directory: " + path.DebugStr(); }
+ std::string GetName() const override {
+ return "Directory: " + path.DebugStr();
+ }
ResultVal<bool> SyncRequest() override;
- FileSys::Path path; ///< Path of the directory
+ FileSys::Path path; ///< Path of the directory
std::unique_ptr<FileSys::DirectoryBackend> backend; ///< File backend interface
};
@@ -90,7 +89,8 @@ ResultCode CloseArchive(ArchiveHandle handle);
* @param factory File system backend interface to the archive
* @param id_code Id code used to access this type of archive
*/
-ResultCode RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory, ArchiveIdCode id_code);
+ResultCode RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory,
+ ArchiveIdCode id_code);
/**
* Open a File from an Archive
@@ -100,7 +100,8 @@ ResultCode RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factor
* @return The opened File object as a Session
*/
ResultVal<Kernel::SharedPtr<File>> OpenFileFromArchive(ArchiveHandle archive_handle,
- const FileSys::Path& path, const FileSys::Mode mode);
+ const FileSys::Path& path,
+ const FileSys::Mode mode);
/**
* Delete a File from an Archive
@@ -118,8 +119,10 @@ ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Pa
* @param dest_path Path to the File inside of the destination Archive
* @return Whether rename succeeded
*/
-ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const FileSys::Path& src_path,
- ArchiveHandle dest_archive_handle, const FileSys::Path& dest_path);
+ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle,
+ const FileSys::Path& src_path,
+ ArchiveHandle dest_archive_handle,
+ const FileSys::Path& dest_path);
/**
* Delete a Directory from an Archive
@@ -136,7 +139,8 @@ ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy
* @param file_size The size of the new file, filled with zeroes
* @return File creation result code
*/
-ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, u64 file_size);
+ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path,
+ u64 file_size);
/**
* Create a Directory from an Archive
@@ -154,8 +158,10 @@ ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy
* @param dest_path Path to the Directory inside of the destination Archive
* @return Whether rename succeeded
*/
-ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, const FileSys::Path& src_path,
- ArchiveHandle dest_archive_handle, const FileSys::Path& dest_path);
+ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
+ const FileSys::Path& src_path,
+ ArchiveHandle dest_archive_handle,
+ const FileSys::Path& dest_path);
/**
* Open a Directory from an Archive
@@ -164,7 +170,7 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, cons
* @return The opened Directory object as a Session
*/
ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle archive_handle,
- const FileSys::Path& path);
+ const FileSys::Path& path);
/**
* Get the free space in an Archive
@@ -181,7 +187,8 @@ ResultVal<u64> GetFreeBytesInArchive(ArchiveHandle archive_handle);
* @param path The path to the archive, if relevant.
* @return ResultCode 0 on success or the corresponding code on error
*/
-ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo& format_info, const FileSys::Path& path = FileSys::Path());
+ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo& format_info,
+ const FileSys::Path& path = FileSys::Path());
/**
* Retrieves the format info about the archive of the specified type and path.
@@ -190,7 +197,8 @@ ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo
* @param archive_path The path of the archive, if relevant
* @return The format info of the archive, or the corresponding error code if failed.
*/
-ResultVal<FileSys::ArchiveFormatInfo> GetArchiveFormatInfo(ArchiveIdCode id_code, FileSys::Path& archive_path);
+ResultVal<FileSys::ArchiveFormatInfo> GetArchiveFormatInfo(ArchiveIdCode id_code,
+ FileSys::Path& archive_path);
/**
* Creates a blank SharedExtSaveData archive for the specified extdata ID
@@ -202,7 +210,8 @@ ResultVal<FileSys::ArchiveFormatInfo> GetArchiveFormatInfo(ArchiveIdCode id_code
* @param format_info Format information about the new archive
* @return ResultCode 0 on success or the corresponding code on error
*/
-ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low, VAddr icon_buffer, u32 icon_size, const FileSys::ArchiveFormatInfo& format_info);
+ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low, VAddr icon_buffer,
+ u32 icon_size, const FileSys::ArchiveFormatInfo& format_info);
/**
* Deletes the SharedExtSaveData archive for the specified extdata ID
diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp
index 937868747..94f053dc2 100644
--- a/src/core/hle/service/fs/fs_user.cpp
+++ b/src/core/hle/service/fs/fs_user.cpp
@@ -8,7 +8,6 @@
#include "common/logging/log.h"
#include "common/scope_exit.h"
#include "common/string_util.h"
-
#include "core/hle/result.h"
#include "core/hle/service/fs/archive.h"
#include "core/hle/service/fs/fs_user.h"
@@ -57,14 +56,16 @@ static void OpenFile(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
- auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
- u32 filename_size = cmd_buff[5];
- FileSys::Mode mode; mode.hex = cmd_buff[6];
- u32 attributes = cmd_buff[7]; // TODO(Link Mauve): do something with those attributes.
- u32 filename_ptr = cmd_buff[9];
+ auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
+ u32 filename_size = cmd_buff[5];
+ FileSys::Mode mode;
+ mode.hex = cmd_buff[6];
+ u32 attributes = cmd_buff[7]; // TODO(Link Mauve): do something with those attributes.
+ u32 filename_ptr = cmd_buff[9];
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
- LOG_DEBUG(Service_FS, "path=%s, mode=%d attrs=%u", file_path.DebugStr().c_str(), mode.hex, attributes);
+ LOG_DEBUG(Service_FS, "path=%s, mode=%d attrs=%u", file_path.DebugStr().c_str(), mode.hex,
+ attributes);
ResultVal<SharedPtr<File>> file_res = OpenFileFromArchive(archive_handle, file_path, mode);
cmd_buff[1] = file_res.Code().raw;
@@ -98,24 +99,27 @@ static void OpenFile(Service::Interface* self) {
static void OpenFileDirectly(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[2]);
+ auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[2]);
auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[3]);
- u32 archivename_size = cmd_buff[4];
- auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[5]);
- u32 filename_size = cmd_buff[6];
- FileSys::Mode mode; mode.hex = cmd_buff[7];
- u32 attributes = cmd_buff[8]; // TODO(Link Mauve): do something with those attributes.
- u32 archivename_ptr = cmd_buff[10];
- u32 filename_ptr = cmd_buff[12];
+ u32 archivename_size = cmd_buff[4];
+ auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[5]);
+ u32 filename_size = cmd_buff[6];
+ FileSys::Mode mode;
+ mode.hex = cmd_buff[7];
+ u32 attributes = cmd_buff[8]; // TODO(Link Mauve): do something with those attributes.
+ u32 archivename_ptr = cmd_buff[10];
+ u32 filename_ptr = cmd_buff[12];
FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr);
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
LOG_DEBUG(Service_FS, "archive_id=0x%08X archive_path=%s file_path=%s, mode=%u attributes=%d",
- archive_id, archive_path.DebugStr().c_str(), file_path.DebugStr().c_str(), mode.hex, attributes);
+ archive_id, archive_path.DebugStr().c_str(), file_path.DebugStr().c_str(), mode.hex,
+ attributes);
ResultVal<ArchiveHandle> archive_handle = OpenArchive(archive_id, archive_path);
if (archive_handle.Failed()) {
- LOG_ERROR(Service_FS, "failed to get a handle for archive archive_id=0x%08X archive_path=%s",
+ LOG_ERROR(Service_FS,
+ "failed to get a handle for archive archive_id=0x%08X archive_path=%s",
archive_id, archive_path.DebugStr().c_str());
cmd_buff[1] = archive_handle.Code().raw;
cmd_buff[3] = 0;
@@ -149,14 +153,14 @@ static void DeleteFile(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
- auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
- u32 filename_size = cmd_buff[5];
- u32 filename_ptr = cmd_buff[7];
+ auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
+ u32 filename_size = cmd_buff[5];
+ u32 filename_ptr = cmd_buff[7];
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
- LOG_DEBUG(Service_FS, "type=%d size=%d data=%s",
- filename_type, filename_size, file_path.DebugStr().c_str());
+ LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", filename_type, filename_size,
+ file_path.DebugStr().c_str());
cmd_buff[1] = DeleteFileFromArchive(archive_handle, file_path).raw;
}
@@ -181,22 +185,26 @@ static void RenameFile(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle src_archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
- auto src_filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
- u32 src_filename_size = cmd_buff[5];
- ArchiveHandle dest_archive_handle = MakeArchiveHandle(cmd_buff[6], cmd_buff[7]);;
- auto dest_filename_type = static_cast<FileSys::LowPathType>(cmd_buff[8]);
- u32 dest_filename_size = cmd_buff[9];
- u32 src_filename_ptr = cmd_buff[11];
- u32 dest_filename_ptr = cmd_buff[13];
+ auto src_filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
+ u32 src_filename_size = cmd_buff[5];
+ ArchiveHandle dest_archive_handle = MakeArchiveHandle(cmd_buff[6], cmd_buff[7]);
+ ;
+ auto dest_filename_type = static_cast<FileSys::LowPathType>(cmd_buff[8]);
+ u32 dest_filename_size = cmd_buff[9];
+ u32 src_filename_ptr = cmd_buff[11];
+ u32 dest_filename_ptr = cmd_buff[13];
FileSys::Path src_file_path(src_filename_type, src_filename_size, src_filename_ptr);
FileSys::Path dest_file_path(dest_filename_type, dest_filename_size, dest_filename_ptr);
- LOG_DEBUG(Service_FS, "src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s",
+ LOG_DEBUG(Service_FS,
+ "src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s",
src_filename_type, src_filename_size, src_file_path.DebugStr().c_str(),
dest_filename_type, dest_filename_size, dest_file_path.DebugStr().c_str());
- cmd_buff[1] = RenameFileBetweenArchives(src_archive_handle, src_file_path, dest_archive_handle, dest_file_path).raw;
+ cmd_buff[1] = RenameFileBetweenArchives(src_archive_handle, src_file_path, dest_archive_handle,
+ dest_file_path)
+ .raw;
}
/*
@@ -214,14 +222,14 @@ static void DeleteDirectory(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
- auto dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
- u32 dirname_size = cmd_buff[5];
- u32 dirname_ptr = cmd_buff[7];
+ auto dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
+ u32 dirname_size = cmd_buff[5];
+ u32 dirname_ptr = cmd_buff[7];
FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
- LOG_DEBUG(Service_FS, "type=%d size=%d data=%s",
- dirname_type, dirname_size, dir_path.DebugStr().c_str());
+ LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size,
+ dir_path.DebugStr().c_str());
cmd_buff[1] = DeleteDirectoryFromArchive(archive_handle, dir_path).raw;
}
@@ -243,14 +251,15 @@ static void CreateFile(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
- auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
- u32 filename_size = cmd_buff[5];
- u64 file_size = ((u64)cmd_buff[8] << 32) | cmd_buff[7];
- u32 filename_ptr = cmd_buff[10];
+ auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
+ u32 filename_size = cmd_buff[5];
+ u64 file_size = ((u64)cmd_buff[8] << 32) | cmd_buff[7];
+ u32 filename_ptr = cmd_buff[10];
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
- LOG_DEBUG(Service_FS, "type=%d size=%llu data=%s", filename_type, file_size, file_path.DebugStr().c_str());
+ LOG_DEBUG(Service_FS, "type=%d size=%llu data=%s", filename_type, file_size,
+ file_path.DebugStr().c_str());
cmd_buff[1] = CreateFileInArchive(archive_handle, file_path, file_size).raw;
}
@@ -276,7 +285,8 @@ static void CreateDirectory(Service::Interface* self) {
FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
- LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str());
+ LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size,
+ dir_path.DebugStr().c_str());
cmd_buff[1] = CreateDirectoryFromArchive(archive_handle, dir_path).raw;
}
@@ -301,22 +311,25 @@ static void RenameDirectory(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle src_archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
- auto src_dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
- u32 src_dirname_size = cmd_buff[5];
+ auto src_dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
+ u32 src_dirname_size = cmd_buff[5];
ArchiveHandle dest_archive_handle = MakeArchiveHandle(cmd_buff[6], cmd_buff[7]);
- auto dest_dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[8]);
- u32 dest_dirname_size = cmd_buff[9];
- u32 src_dirname_ptr = cmd_buff[11];
- u32 dest_dirname_ptr = cmd_buff[13];
+ auto dest_dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[8]);
+ u32 dest_dirname_size = cmd_buff[9];
+ u32 src_dirname_ptr = cmd_buff[11];
+ u32 dest_dirname_ptr = cmd_buff[13];
FileSys::Path src_dir_path(src_dirname_type, src_dirname_size, src_dirname_ptr);
FileSys::Path dest_dir_path(dest_dirname_type, dest_dirname_size, dest_dirname_ptr);
- LOG_DEBUG(Service_FS, "src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s",
+ LOG_DEBUG(Service_FS,
+ "src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s",
src_dirname_type, src_dirname_size, src_dir_path.DebugStr().c_str(),
dest_dirname_type, dest_dirname_size, dest_dir_path.DebugStr().c_str());
- cmd_buff[1] = RenameDirectoryBetweenArchives(src_archive_handle, src_dir_path, dest_archive_handle, dest_dir_path).raw;
+ cmd_buff[1] = RenameDirectoryBetweenArchives(src_archive_handle, src_dir_path,
+ dest_archive_handle, dest_dir_path)
+ .raw;
}
/**
@@ -342,7 +355,8 @@ static void OpenDirectory(Service::Interface* self) {
FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
- LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str());
+ LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size,
+ dir_path.DebugStr().c_str());
ResultVal<SharedPtr<Directory>> dir_res = OpenDirectoryFromArchive(archive_handle, dir_path);
cmd_buff[1] = dir_res.Code().raw;
@@ -370,13 +384,14 @@ static void OpenDirectory(Service::Interface* self) {
static void OpenArchive(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[1]);
+ auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[1]);
auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[2]);
- u32 archivename_size = cmd_buff[3];
- u32 archivename_ptr = cmd_buff[5];
+ u32 archivename_size = cmd_buff[3];
+ u32 archivename_ptr = cmd_buff[5];
FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr);
- LOG_DEBUG(Service_FS, "archive_id=0x%08X archive_path=%s", archive_id, archive_path.DebugStr().c_str());
+ LOG_DEBUG(Service_FS, "archive_id=0x%08X archive_path=%s", archive_id,
+ archive_path.DebugStr().c_str());
ResultVal<ArchiveHandle> handle = OpenArchive(archive_id, archive_path);
cmd_buff[1] = handle.Code().raw;
@@ -385,7 +400,8 @@ static void OpenArchive(Service::Interface* self) {
cmd_buff[3] = (*handle >> 32) & 0xFFFFFFFF;
} else {
cmd_buff[2] = cmd_buff[3] = 0;
- LOG_ERROR(Service_FS, "failed to get a handle for archive archive_id=0x%08X archive_path=%s",
+ LOG_ERROR(Service_FS,
+ "failed to get a handle for archive archive_id=0x%08X archive_path=%s",
archive_id, archive_path.DebugStr().c_str());
}
}
@@ -471,7 +487,8 @@ static void FormatSaveData(Service::Interface* self) {
if (archive_id != FS::ArchiveIdCode::SaveData) {
LOG_ERROR(Service_FS, "tried to format an archive different than SaveData, %u", archive_id);
cmd_buff[1] = ResultCode(ErrorDescription::FS_InvalidPath, ErrorModule::FS,
- ErrorSummary::InvalidArgument, ErrorLevel::Usage).raw;
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage)
+ .raw;
return;
}
@@ -571,18 +588,21 @@ static void CreateExtSaveData(Service::Interface* self) {
u32 icon_size = cmd_buff[9];
VAddr icon_buffer = cmd_buff[11];
- LOG_WARNING(Service_FS, "(STUBBED) savedata_high=%08X savedata_low=%08X cmd_buff[3]=%08X "
- "cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X "
- "icon_size=%08X icon_descriptor=%08X icon_buffer=%08X", save_high, save_low,
- cmd_buff[3], cmd_buff[4], cmd_buff[5], cmd_buff[6], cmd_buff[7], cmd_buff[8], icon_size,
- cmd_buff[10], icon_buffer);
+ LOG_WARNING(
+ Service_FS,
+ "(STUBBED) savedata_high=%08X savedata_low=%08X cmd_buff[3]=%08X "
+ "cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X "
+ "icon_size=%08X icon_descriptor=%08X icon_buffer=%08X",
+ save_high, save_low, cmd_buff[3], cmd_buff[4], cmd_buff[5], cmd_buff[6], cmd_buff[7],
+ cmd_buff[8], icon_size, cmd_buff[10], icon_buffer);
FileSys::ArchiveFormatInfo format_info;
format_info.number_directories = cmd_buff[5];
format_info.number_files = cmd_buff[6];
format_info.duplicate_data = false;
format_info.total_size = 0;
- cmd_buff[1] = CreateExtSaveData(media_type, save_high, save_low, icon_buffer, icon_size, format_info).raw;
+ cmd_buff[1] =
+ CreateExtSaveData(media_type, save_high, save_low, icon_buffer, icon_size, format_info).raw;
}
/**
@@ -604,7 +624,7 @@ static void DeleteExtSaveData(Service::Interface* self) {
u32 unknown = cmd_buff[4]; // TODO(Subv): Figure out what this is
LOG_WARNING(Service_FS, "(STUBBED) save_low=%08X save_high=%08X media_type=%08X unknown=%08X",
- save_low, save_high, cmd_buff[1] & 0xFF, unknown);
+ save_low, save_high, cmd_buff[1] & 0xFF, unknown);
cmd_buff[1] = DeleteExtSaveData(media_type, save_high, save_low).raw;
}
@@ -662,10 +682,13 @@ static void CreateSystemSaveData(Service::Interface* self) {
u32 savedata_high = cmd_buff[1];
u32 savedata_low = cmd_buff[2];
- LOG_WARNING(Service_FS, "(STUBBED) savedata_high=%08X savedata_low=%08X cmd_buff[3]=%08X "
- "cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X "
- "cmd_buff[9]=%08X", savedata_high, savedata_low, cmd_buff[3], cmd_buff[4], cmd_buff[5],
- cmd_buff[6], cmd_buff[7], cmd_buff[8], cmd_buff[9]);
+ LOG_WARNING(
+ Service_FS,
+ "(STUBBED) savedata_high=%08X savedata_low=%08X cmd_buff[3]=%08X "
+ "cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X "
+ "cmd_buff[9]=%08X",
+ savedata_high, savedata_low, cmd_buff[3], cmd_buff[4], cmd_buff[5], cmd_buff[6],
+ cmd_buff[7], cmd_buff[8], cmd_buff[9]);
cmd_buff[1] = CreateSystemSaveData(savedata_high, savedata_low).raw;
}
@@ -692,10 +715,13 @@ static void CreateLegacySystemSaveData(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 savedata_id = cmd_buff[1];
- LOG_WARNING(Service_FS, "(STUBBED) savedata_id=%08X cmd_buff[3]=%08X "
- "cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X "
- "cmd_buff[9]=%08X", savedata_id, cmd_buff[3], cmd_buff[4], cmd_buff[5],
- cmd_buff[6], cmd_buff[7], cmd_buff[8], cmd_buff[9]);
+ LOG_WARNING(
+ Service_FS,
+ "(STUBBED) savedata_id=%08X cmd_buff[3]=%08X "
+ "cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X "
+ "cmd_buff[9]=%08X",
+ savedata_id, cmd_buff[3], cmd_buff[4], cmd_buff[5], cmd_buff[6], cmd_buff[7], cmd_buff[8],
+ cmd_buff[9]);
cmd_buff[0] = IPC::MakeHeader(0x810, 0x1, 0);
// With this command, the SystemSaveData always has save_high = 0 (Always created in the NAND)
@@ -721,8 +747,8 @@ static void InitializeWithSdkVersion(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
- LOG_WARNING(Service_FS, "(STUBBED) called unk1=0x%08X, unk2=0x%08X, unk3=0x%08X",
- unk1, unk2, unk3);
+ LOG_WARNING(Service_FS, "(STUBBED) called unk1=0x%08X, unk2=0x%08X, unk3=0x%08X", unk1, unk2,
+ unk3);
}
/**
@@ -834,114 +860,114 @@ static void GetFormatInfo(Service::Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
- {0x000100C6, nullptr, "Dummy1"},
- {0x040100C4, nullptr, "Control"},
- {0x08010002, Initialize, "Initialize"},
- {0x080201C2, OpenFile, "OpenFile"},
- {0x08030204, OpenFileDirectly, "OpenFileDirectly"},
- {0x08040142, DeleteFile, "DeleteFile"},
- {0x08050244, RenameFile, "RenameFile"},
- {0x08060142, DeleteDirectory, "DeleteDirectory"},
- {0x08070142, nullptr, "DeleteDirectoryRecursively"},
- {0x08080202, CreateFile, "CreateFile"},
- {0x08090182, CreateDirectory, "CreateDirectory"},
- {0x080A0244, RenameDirectory, "RenameDirectory"},
- {0x080B0102, OpenDirectory, "OpenDirectory"},
- {0x080C00C2, OpenArchive, "OpenArchive"},
- {0x080D0144, nullptr, "ControlArchive"},
- {0x080E0080, CloseArchive, "CloseArchive"},
- {0x080F0180, FormatThisUserSaveData, "FormatThisUserSaveData"},
+ {0x000100C6, nullptr, "Dummy1"},
+ {0x040100C4, nullptr, "Control"},
+ {0x08010002, Initialize, "Initialize"},
+ {0x080201C2, OpenFile, "OpenFile"},
+ {0x08030204, OpenFileDirectly, "OpenFileDirectly"},
+ {0x08040142, DeleteFile, "DeleteFile"},
+ {0x08050244, RenameFile, "RenameFile"},
+ {0x08060142, DeleteDirectory, "DeleteDirectory"},
+ {0x08070142, nullptr, "DeleteDirectoryRecursively"},
+ {0x08080202, CreateFile, "CreateFile"},
+ {0x08090182, CreateDirectory, "CreateDirectory"},
+ {0x080A0244, RenameDirectory, "RenameDirectory"},
+ {0x080B0102, OpenDirectory, "OpenDirectory"},
+ {0x080C00C2, OpenArchive, "OpenArchive"},
+ {0x080D0144, nullptr, "ControlArchive"},
+ {0x080E0080, CloseArchive, "CloseArchive"},
+ {0x080F0180, FormatThisUserSaveData, "FormatThisUserSaveData"},
{0x08100200, CreateLegacySystemSaveData, "CreateLegacySystemSaveData"},
- {0x08110040, nullptr, "DeleteSystemSaveData"},
- {0x08120080, GetFreeBytes, "GetFreeBytes"},
- {0x08130000, nullptr, "GetCardType"},
- {0x08140000, nullptr, "GetSdmcArchiveResource"},
- {0x08150000, nullptr, "GetNandArchiveResource"},
- {0x08160000, nullptr, "GetSdmcFatfsError"},
- {0x08170000, IsSdmcDetected, "IsSdmcDetected"},
- {0x08180000, IsSdmcWriteable, "IsSdmcWritable"},
- {0x08190042, nullptr, "GetSdmcCid"},
- {0x081A0042, nullptr, "GetNandCid"},
- {0x081B0000, nullptr, "GetSdmcSpeedInfo"},
- {0x081C0000, nullptr, "GetNandSpeedInfo"},
- {0x081D0042, nullptr, "GetSdmcLog"},
- {0x081E0042, nullptr, "GetNandLog"},
- {0x081F0000, nullptr, "ClearSdmcLog"},
- {0x08200000, nullptr, "ClearNandLog"},
- {0x08210000, CardSlotIsInserted, "CardSlotIsInserted"},
- {0x08220000, nullptr, "CardSlotPowerOn"},
- {0x08230000, nullptr, "CardSlotPowerOff"},
- {0x08240000, nullptr, "CardSlotGetCardIFPowerStatus"},
- {0x08250040, nullptr, "CardNorDirectCommand"},
- {0x08260080, nullptr, "CardNorDirectCommandWithAddress"},
- {0x08270082, nullptr, "CardNorDirectRead"},
- {0x082800C2, nullptr, "CardNorDirectReadWithAddress"},
- {0x08290082, nullptr, "CardNorDirectWrite"},
- {0x082A00C2, nullptr, "CardNorDirectWriteWithAddress"},
- {0x082B00C2, nullptr, "CardNorDirectRead_4xIO"},
- {0x082C0082, nullptr, "CardNorDirectCpuWriteWithoutVerify"},
- {0x082D0040, nullptr, "CardNorDirectSectorEraseWithoutVerify"},
- {0x082E0040, nullptr, "GetProductInfo"},
- {0x082F0040, nullptr, "GetProgramLaunchInfo"},
- {0x08300182, nullptr, "CreateExtSaveData"},
- {0x08310180, nullptr, "CreateSharedExtSaveData"},
- {0x08320102, nullptr, "ReadExtSaveDataIcon"},
- {0x08330082, nullptr, "EnumerateExtSaveData"},
- {0x08340082, nullptr, "EnumerateSharedExtSaveData"},
- {0x08350080, nullptr, "DeleteExtSaveData"},
- {0x08360080, nullptr, "DeleteSharedExtSaveData"},
- {0x08370040, nullptr, "SetCardSpiBaudRate"},
- {0x08380040, nullptr, "SetCardSpiBusMode"},
- {0x08390000, nullptr, "SendInitializeInfoTo9"},
- {0x083A0100, nullptr, "GetSpecialContentIndex"},
- {0x083B00C2, nullptr, "GetLegacyRomHeader"},
- {0x083C00C2, nullptr, "GetLegacyBannerData"},
- {0x083D0100, nullptr, "CheckAuthorityToAccessExtSaveData"},
- {0x083E00C2, nullptr, "QueryTotalQuotaSize"},
- {0x083F00C0, nullptr, "GetExtDataBlockSize"},
- {0x08400040, nullptr, "AbnegateAccessRight"},
- {0x08410000, nullptr, "DeleteSdmcRoot"},
- {0x08420040, nullptr, "DeleteAllExtSaveDataOnNand"},
- {0x08430000, nullptr, "InitializeCtrFileSystem"},
- {0x08440000, nullptr, "CreateSeed"},
- {0x084500C2, GetFormatInfo, "GetFormatInfo"},
- {0x08460102, nullptr, "GetLegacyRomHeader2"},
- {0x08470180, nullptr, "FormatCtrCardUserSaveData"},
- {0x08480042, nullptr, "GetSdmcCtrRootPath"},
- {0x08490040, GetArchiveResource, "GetArchiveResource"},
- {0x084A0002, nullptr, "ExportIntegrityVerificationSeed"},
- {0x084B0002, nullptr, "ImportIntegrityVerificationSeed"},
- {0x084C0242, FormatSaveData, "FormatSaveData"},
- {0x084D0102, nullptr, "GetLegacySubBannerData"},
- {0x084E0342, nullptr, "UpdateSha256Context"},
- {0x084F0102, nullptr, "ReadSpecialFile"},
- {0x08500040, nullptr, "GetSpecialFileSize"},
- {0x08510242, CreateExtSaveData, "CreateExtSaveData"},
- {0x08520100, DeleteExtSaveData, "DeleteExtSaveData"},
- {0x08530142, nullptr, "ReadExtSaveDataIcon"},
- {0x085400C0, nullptr, "GetExtDataBlockSize"},
- {0x08550102, nullptr, "EnumerateExtSaveData"},
- {0x08560240, CreateSystemSaveData, "CreateSystemSaveData"},
- {0x08570080, DeleteSystemSaveData, "DeleteSystemSaveData"},
- {0x08580000, nullptr, "StartDeviceMoveAsSource"},
- {0x08590200, nullptr, "StartDeviceMoveAsDestination"},
- {0x085A00C0, nullptr, "SetArchivePriority"},
- {0x085B0080, nullptr, "GetArchivePriority"},
- {0x085C00C0, nullptr, "SetCtrCardLatencyParameter"},
- {0x085D01C0, nullptr, "SetFsCompatibilityInfo"},
- {0x085E0040, nullptr, "ResetCardCompatibilityParameter"},
- {0x085F0040, nullptr, "SwitchCleanupInvalidSaveData"},
- {0x08600042, nullptr, "EnumerateSystemSaveData"},
+ {0x08110040, nullptr, "DeleteSystemSaveData"},
+ {0x08120080, GetFreeBytes, "GetFreeBytes"},
+ {0x08130000, nullptr, "GetCardType"},
+ {0x08140000, nullptr, "GetSdmcArchiveResource"},
+ {0x08150000, nullptr, "GetNandArchiveResource"},
+ {0x08160000, nullptr, "GetSdmcFatfsError"},
+ {0x08170000, IsSdmcDetected, "IsSdmcDetected"},
+ {0x08180000, IsSdmcWriteable, "IsSdmcWritable"},
+ {0x08190042, nullptr, "GetSdmcCid"},
+ {0x081A0042, nullptr, "GetNandCid"},
+ {0x081B0000, nullptr, "GetSdmcSpeedInfo"},
+ {0x081C0000, nullptr, "GetNandSpeedInfo"},
+ {0x081D0042, nullptr, "GetSdmcLog"},
+ {0x081E0042, nullptr, "GetNandLog"},
+ {0x081F0000, nullptr, "ClearSdmcLog"},
+ {0x08200000, nullptr, "ClearNandLog"},
+ {0x08210000, CardSlotIsInserted, "CardSlotIsInserted"},
+ {0x08220000, nullptr, "CardSlotPowerOn"},
+ {0x08230000, nullptr, "CardSlotPowerOff"},
+ {0x08240000, nullptr, "CardSlotGetCardIFPowerStatus"},
+ {0x08250040, nullptr, "CardNorDirectCommand"},
+ {0x08260080, nullptr, "CardNorDirectCommandWithAddress"},
+ {0x08270082, nullptr, "CardNorDirectRead"},
+ {0x082800C2, nullptr, "CardNorDirectReadWithAddress"},
+ {0x08290082, nullptr, "CardNorDirectWrite"},
+ {0x082A00C2, nullptr, "CardNorDirectWriteWithAddress"},
+ {0x082B00C2, nullptr, "CardNorDirectRead_4xIO"},
+ {0x082C0082, nullptr, "CardNorDirectCpuWriteWithoutVerify"},
+ {0x082D0040, nullptr, "CardNorDirectSectorEraseWithoutVerify"},
+ {0x082E0040, nullptr, "GetProductInfo"},
+ {0x082F0040, nullptr, "GetProgramLaunchInfo"},
+ {0x08300182, nullptr, "CreateExtSaveData"},
+ {0x08310180, nullptr, "CreateSharedExtSaveData"},
+ {0x08320102, nullptr, "ReadExtSaveDataIcon"},
+ {0x08330082, nullptr, "EnumerateExtSaveData"},
+ {0x08340082, nullptr, "EnumerateSharedExtSaveData"},
+ {0x08350080, nullptr, "DeleteExtSaveData"},
+ {0x08360080, nullptr, "DeleteSharedExtSaveData"},
+ {0x08370040, nullptr, "SetCardSpiBaudRate"},
+ {0x08380040, nullptr, "SetCardSpiBusMode"},
+ {0x08390000, nullptr, "SendInitializeInfoTo9"},
+ {0x083A0100, nullptr, "GetSpecialContentIndex"},
+ {0x083B00C2, nullptr, "GetLegacyRomHeader"},
+ {0x083C00C2, nullptr, "GetLegacyBannerData"},
+ {0x083D0100, nullptr, "CheckAuthorityToAccessExtSaveData"},
+ {0x083E00C2, nullptr, "QueryTotalQuotaSize"},
+ {0x083F00C0, nullptr, "GetExtDataBlockSize"},
+ {0x08400040, nullptr, "AbnegateAccessRight"},
+ {0x08410000, nullptr, "DeleteSdmcRoot"},
+ {0x08420040, nullptr, "DeleteAllExtSaveDataOnNand"},
+ {0x08430000, nullptr, "InitializeCtrFileSystem"},
+ {0x08440000, nullptr, "CreateSeed"},
+ {0x084500C2, GetFormatInfo, "GetFormatInfo"},
+ {0x08460102, nullptr, "GetLegacyRomHeader2"},
+ {0x08470180, nullptr, "FormatCtrCardUserSaveData"},
+ {0x08480042, nullptr, "GetSdmcCtrRootPath"},
+ {0x08490040, GetArchiveResource, "GetArchiveResource"},
+ {0x084A0002, nullptr, "ExportIntegrityVerificationSeed"},
+ {0x084B0002, nullptr, "ImportIntegrityVerificationSeed"},
+ {0x084C0242, FormatSaveData, "FormatSaveData"},
+ {0x084D0102, nullptr, "GetLegacySubBannerData"},
+ {0x084E0342, nullptr, "UpdateSha256Context"},
+ {0x084F0102, nullptr, "ReadSpecialFile"},
+ {0x08500040, nullptr, "GetSpecialFileSize"},
+ {0x08510242, CreateExtSaveData, "CreateExtSaveData"},
+ {0x08520100, DeleteExtSaveData, "DeleteExtSaveData"},
+ {0x08530142, nullptr, "ReadExtSaveDataIcon"},
+ {0x085400C0, nullptr, "GetExtDataBlockSize"},
+ {0x08550102, nullptr, "EnumerateExtSaveData"},
+ {0x08560240, CreateSystemSaveData, "CreateSystemSaveData"},
+ {0x08570080, DeleteSystemSaveData, "DeleteSystemSaveData"},
+ {0x08580000, nullptr, "StartDeviceMoveAsSource"},
+ {0x08590200, nullptr, "StartDeviceMoveAsDestination"},
+ {0x085A00C0, nullptr, "SetArchivePriority"},
+ {0x085B0080, nullptr, "GetArchivePriority"},
+ {0x085C00C0, nullptr, "SetCtrCardLatencyParameter"},
+ {0x085D01C0, nullptr, "SetFsCompatibilityInfo"},
+ {0x085E0040, nullptr, "ResetCardCompatibilityParameter"},
+ {0x085F0040, nullptr, "SwitchCleanupInvalidSaveData"},
+ {0x08600042, nullptr, "EnumerateSystemSaveData"},
{0x08610042, InitializeWithSdkVersion, "InitializeWithSdkVersion"},
- {0x08620040, SetPriority, "SetPriority"},
- {0x08630000, GetPriority, "GetPriority"},
- {0x08640000, nullptr, "GetNandInfo"},
- {0x08650140, nullptr, "SetSaveDataSecureValue"},
- {0x086600C0, nullptr, "GetSaveDataSecureValue"},
- {0x086700C4, nullptr, "ControlSecureSave"},
- {0x08680000, nullptr, "GetMediaType"},
- {0x08690000, nullptr, "GetNandEraseCount"},
- {0x086A0082, nullptr, "ReadNandReport"}
+ {0x08620040, SetPriority, "SetPriority"},
+ {0x08630000, GetPriority, "GetPriority"},
+ {0x08640000, nullptr, "GetNandInfo"},
+ {0x08650140, nullptr, "SetSaveDataSecureValue"},
+ {0x086600C0, nullptr, "GetSaveDataSecureValue"},
+ {0x086700C4, nullptr, "ControlSecureSave"},
+ {0x08680000, nullptr, "GetMediaType"},
+ {0x08690000, nullptr, "GetNandEraseCount"},
+ {0x086A0082, nullptr, "ReadNandReport"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp
index ec565f46d..710e0e485 100644
--- a/src/core/hle/service/gsp_gpu.cpp
+++ b/src/core/hle/service/gsp_gpu.cpp
@@ -4,19 +4,16 @@
#include "common/bit_field.h"
#include "common/microprofile.h"
-
-#include "core/memory.h"
#include "core/hle/kernel/event.h"
#include "core/hle/kernel/shared_memory.h"
#include "core/hle/result.h"
-#include "core/hw/hw.h"
#include "core/hw/gpu.h"
+#include "core/hw/hw.h"
#include "core/hw/lcd.h"
-
-#include "video_core/gpu_debugger.h"
-#include "video_core/debug_utils/debug_utils.h"
-
+#include "core/memory.h"
#include "gsp_gpu.h"
+#include "video_core/debug_utils/debug_utils.h"
+#include "video_core/gpu_debugger.h"
// Main graphics debugger object - TODO: Here is probably not the best place for this
GraphicsDebugger g_debugger;
@@ -29,12 +26,15 @@ const static u32 REGS_BEGIN = 0x1EB00000;
namespace GSP_GPU {
-const ResultCode ERR_GSP_REGS_OUTOFRANGE_OR_MISALIGNED(ErrorDescription::OutofRangeOrMisalignedAddress, ErrorModule::GX,
- ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E02A01
+const ResultCode ERR_GSP_REGS_OUTOFRANGE_OR_MISALIGNED(
+ ErrorDescription::OutofRangeOrMisalignedAddress, ErrorModule::GX, ErrorSummary::InvalidArgument,
+ ErrorLevel::Usage); // 0xE0E02A01
const ResultCode ERR_GSP_REGS_MISALIGNED(ErrorDescription::MisalignedSize, ErrorModule::GX,
- ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E02BF2
+ ErrorSummary::InvalidArgument,
+ ErrorLevel::Usage); // 0xE0E02BF2
const ResultCode ERR_GSP_REGS_INVALID_SIZE(ErrorDescription::InvalidSize, ErrorModule::GX,
- ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E02BEC
+ ErrorSummary::InvalidArgument,
+ ErrorLevel::Usage); // 0xE0E02BEC
/// Event triggered when GSP interrupt has been signalled
Kernel::SharedPtr<Kernel::Event> g_interrupt_event;
@@ -73,7 +73,8 @@ static inline InterruptRelayQueue* GetInterruptRelayQueue(u32 thread_id) {
* @param data Data to be written
*/
static void WriteSingleHWReg(u32 base_address, u32 data) {
- DEBUG_ASSERT_MSG((base_address & 3) == 0 && base_address < 0x420000, "Write address out of range or misaligned");
+ DEBUG_ASSERT_MSG((base_address & 3) == 0 && base_address < 0x420000,
+ "Write address out of range or misaligned");
HW::Write<u32>(base_address + REGS_BEGIN, data);
}
@@ -90,7 +91,8 @@ static ResultCode WriteHWRegs(u32 base_address, u32 size_in_bytes, VAddr data_va
const u32 max_size_in_bytes = 0x80;
if (base_address & 3 || base_address >= 0x420000) {
- LOG_ERROR(Service_GSP, "Write address was out of range or misaligned! (address=0x%08x, size=0x%08x)",
+ LOG_ERROR(Service_GSP,
+ "Write address was out of range or misaligned! (address=0x%08x, size=0x%08x)",
base_address, size_in_bytes);
return ERR_GSP_REGS_OUTOFRANGE_OR_MISALIGNED;
} else if (size_in_bytes <= max_size_in_bytes) {
@@ -124,12 +126,14 @@ static ResultCode WriteHWRegs(u32 base_address, u32 size_in_bytes, VAddr data_va
* @param masks A pointer to the masks
* @return RESULT_SUCCESS if the parameters are valid, error code otherwise
*/
-static ResultCode WriteHWRegsWithMask(u32 base_address, u32 size_in_bytes, VAddr data_vaddr, VAddr masks_vaddr) {
+static ResultCode WriteHWRegsWithMask(u32 base_address, u32 size_in_bytes, VAddr data_vaddr,
+ VAddr masks_vaddr) {
// This magic number is verified to be done by the gsp module
const u32 max_size_in_bytes = 0x80;
if (base_address & 3 || base_address >= 0x420000) {
- LOG_ERROR(Service_GSP, "Write address was out of range or misaligned! (address=0x%08x, size=0x%08x)",
+ LOG_ERROR(Service_GSP,
+ "Write address was out of range or misaligned! (address=0x%08x, size=0x%08x)",
base_address, size_in_bytes);
return ERR_GSP_REGS_OUTOFRANGE_OR_MISALIGNED;
} else if (size_in_bytes <= max_size_in_bytes) {
@@ -214,7 +218,8 @@ static void ReadHWRegs(Service::Interface* self) {
// TODO: Return proper error codes
if (reg_addr + size >= 0x420000) {
- LOG_ERROR(Service_GSP, "Read address out of range! (address=0x%08x, size=0x%08x)", reg_addr, size);
+ LOG_ERROR(Service_GSP, "Read address out of range! (address=0x%08x, size=0x%08x)", reg_addr,
+ size);
return;
}
@@ -243,22 +248,34 @@ ResultCode SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) {
PAddr phys_address_left = Memory::VirtualToPhysicalAddress(info.address_left);
PAddr phys_address_right = Memory::VirtualToPhysicalAddress(info.address_right);
if (info.active_fb == 0) {
- WriteSingleHWReg(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left1)),
- phys_address_left);
- WriteSingleHWReg(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right1)),
- phys_address_right);
+ WriteSingleHWReg(
+ base_address +
+ 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left1)),
+ phys_address_left);
+ WriteSingleHWReg(
+ base_address +
+ 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right1)),
+ phys_address_right);
} else {
- WriteSingleHWReg(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left2)),
- phys_address_left);
- WriteSingleHWReg(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right2)),
- phys_address_right);
+ WriteSingleHWReg(
+ base_address +
+ 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left2)),
+ phys_address_left);
+ WriteSingleHWReg(
+ base_address +
+ 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right2)),
+ phys_address_right);
}
- WriteSingleHWReg(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].stride)),
+ WriteSingleHWReg(base_address +
+ 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].stride)),
info.stride);
- WriteSingleHWReg(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].color_format)),
- info.format);
- WriteSingleHWReg(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].active_fb)),
- info.shown_fb);
+ WriteSingleHWReg(
+ base_address +
+ 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].color_format)),
+ info.format);
+ WriteSingleHWReg(
+ base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].active_fb)),
+ info.shown_fb);
if (Pica::g_debug_context)
Pica::g_debug_context->OnEvent(Pica::DebugContext::Event::BufferSwapped, nullptr);
@@ -305,15 +322,15 @@ static void SetBufferSwap(Service::Interface* self) {
static void FlushDataCache(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 address = cmd_buff[1];
- u32 size = cmd_buff[2];
+ u32 size = cmd_buff[2];
u32 process = cmd_buff[4];
// TODO(purpasmart96): Verify return header on HW
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- LOG_DEBUG(Service_GSP, "(STUBBED) called address=0x%08X, size=0x%08X, process=0x%08X",
- address, size, process);
+ LOG_DEBUG(Service_GSP, "(STUBBED) called address=0x%08X, size=0x%08X, process=0x%08X", address,
+ size, process);
}
/**
@@ -356,11 +373,12 @@ static void RegisterInterruptRelayQueue(Service::Interface* self) {
// This specific code is required for a successful initialization, rather than 0
first_initialization = false;
cmd_buff[1] = ResultCode(ErrorDescription::GPU_FirstInitialization, ErrorModule::GX,
- ErrorSummary::Success, ErrorLevel::Success).raw;
+ ErrorSummary::Success, ErrorLevel::Success)
+ .raw;
} else {
cmd_buff[1] = RESULT_SUCCESS.raw;
}
- cmd_buff[2] = g_thread_id++; // Thread ID
+ cmd_buff[2] = g_thread_id++; // Thread ID
cmd_buff[4] = Kernel::g_handle_table.Create(g_shared_memory).MoveFrom(); // GSP shared memory
g_interrupt_event->Signal(); // TODO(bunnei): Is this correct?
@@ -416,7 +434,8 @@ void SignalInterrupt(InterruptId interrupt_id) {
// Update framebuffer information if requested
// TODO(yuriks): Confirm where this code should be called. It is definitely updated without
// executing any GSP commands, only waiting on the event.
- int screen_id = (interrupt_id == InterruptId::PDC0) ? 0 : (interrupt_id == InterruptId::PDC1) ? 1 : -1;
+ int screen_id =
+ (interrupt_id == InterruptId::PDC0) ? 0 : (interrupt_id == InterruptId::PDC1) ? 1 : -1;
if (screen_id != -1) {
FrameBufferUpdate* info = GetFrameBufferInfo(thread_id, screen_id);
if (info->is_dirty) {
@@ -440,25 +459,27 @@ static void ExecuteCommand(const Command& command, u32 thread_id) {
switch (command.id) {
// GX request DMA - typically used for copying memory from GSP heap to VRAM
- case CommandId::REQUEST_DMA:
- {
+ case CommandId::REQUEST_DMA: {
MICROPROFILE_SCOPE(GPU_GSP_DMA);
- // TODO: Consider attempting rasterizer-accelerated surface blit if that usage is ever possible/likely
- Memory::RasterizerFlushRegion(Memory::VirtualToPhysicalAddress(command.dma_request.source_address),
- command.dma_request.size);
- Memory::RasterizerFlushAndInvalidateRegion(Memory::VirtualToPhysicalAddress(command.dma_request.dest_address),
- command.dma_request.size);
+ // TODO: Consider attempting rasterizer-accelerated surface blit if that usage is ever
+ // possible/likely
+ Memory::RasterizerFlushRegion(
+ Memory::VirtualToPhysicalAddress(command.dma_request.source_address),
+ command.dma_request.size);
+ Memory::RasterizerFlushAndInvalidateRegion(
+ Memory::VirtualToPhysicalAddress(command.dma_request.dest_address),
+ command.dma_request.size);
// TODO(Subv): These memory accesses should not go through the application's memory mapping.
// They should go through the GSP module's memory mapping.
- Memory::CopyBlock(command.dma_request.dest_address, command.dma_request.source_address, command.dma_request.size);
+ Memory::CopyBlock(command.dma_request.dest_address, command.dma_request.source_address,
+ command.dma_request.size);
SignalInterrupt(InterruptId::DMA);
break;
}
// TODO: This will need some rework in the future. (why?)
- case CommandId::SUBMIT_GPU_CMDLIST:
- {
+ case CommandId::SUBMIT_GPU_CMDLIST: {
auto& params = command.submit_gpu_cmdlist;
if (params.do_flush) {
@@ -468,10 +489,12 @@ static void ExecuteCommand(const Command& command, u32 thread_id) {
}
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(command_processor_config.address)),
- Memory::VirtualToPhysicalAddress(params.address) >> 3);
- WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(command_processor_config.size)), params.size);
+ Memory::VirtualToPhysicalAddress(params.address) >> 3);
+ WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(command_processor_config.size)),
+ params.size);
- // TODO: Not sure if we are supposed to always write this .. seems to trigger processing though
+ // TODO: Not sure if we are supposed to always write this .. seems to trigger processing
+ // though
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(command_processor_config.trigger)), 1);
// TODO(yuriks): Figure out the meaning of the `flags` field.
@@ -481,67 +504,70 @@ static void ExecuteCommand(const Command& command, u32 thread_id) {
// It's assumed that the two "blocks" behave equivalently.
// Presumably this is done simply to allow two memory fills to run in parallel.
- case CommandId::SET_MEMORY_FILL:
- {
+ case CommandId::SET_MEMORY_FILL: {
auto& params = command.memory_fill;
if (params.start1 != 0) {
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].address_start)),
- Memory::VirtualToPhysicalAddress(params.start1) >> 3);
+ Memory::VirtualToPhysicalAddress(params.start1) >> 3);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].address_end)),
- Memory::VirtualToPhysicalAddress(params.end1) >> 3);
- WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].value_32bit)), params.value1);
- WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].control)), params.control1);
+ Memory::VirtualToPhysicalAddress(params.end1) >> 3);
+ WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].value_32bit)),
+ params.value1);
+ WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].control)),
+ params.control1);
}
if (params.start2 != 0) {
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].address_start)),
- Memory::VirtualToPhysicalAddress(params.start2) >> 3);
+ Memory::VirtualToPhysicalAddress(params.start2) >> 3);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].address_end)),
- Memory::VirtualToPhysicalAddress(params.end2) >> 3);
- WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].value_32bit)), params.value2);
- WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].control)), params.control2);
+ Memory::VirtualToPhysicalAddress(params.end2) >> 3);
+ WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].value_32bit)),
+ params.value2);
+ WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].control)),
+ params.control2);
}
break;
}
- case CommandId::SET_DISPLAY_TRANSFER:
- {
+ case CommandId::SET_DISPLAY_TRANSFER: {
auto& params = command.display_transfer;
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.input_address)),
- Memory::VirtualToPhysicalAddress(params.in_buffer_address) >> 3);
+ Memory::VirtualToPhysicalAddress(params.in_buffer_address) >> 3);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.output_address)),
- Memory::VirtualToPhysicalAddress(params.out_buffer_address) >> 3);
- WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.input_size)), params.in_buffer_size);
- WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.output_size)), params.out_buffer_size);
- WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.flags)), params.flags);
+ Memory::VirtualToPhysicalAddress(params.out_buffer_address) >> 3);
+ WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.input_size)),
+ params.in_buffer_size);
+ WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.output_size)),
+ params.out_buffer_size);
+ WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.flags)),
+ params.flags);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.trigger)), 1);
break;
}
- case CommandId::SET_TEXTURE_COPY:
- {
+ case CommandId::SET_TEXTURE_COPY: {
auto& params = command.texture_copy;
WriteGPURegister((u32)GPU_REG_INDEX(display_transfer_config.input_address),
- Memory::VirtualToPhysicalAddress(params.in_buffer_address) >> 3);
+ Memory::VirtualToPhysicalAddress(params.in_buffer_address) >> 3);
WriteGPURegister((u32)GPU_REG_INDEX(display_transfer_config.output_address),
- Memory::VirtualToPhysicalAddress(params.out_buffer_address) >> 3);
+ Memory::VirtualToPhysicalAddress(params.out_buffer_address) >> 3);
WriteGPURegister((u32)GPU_REG_INDEX(display_transfer_config.texture_copy.size),
- params.size);
+ params.size);
WriteGPURegister((u32)GPU_REG_INDEX(display_transfer_config.texture_copy.input_size),
- params.in_width_gap);
+ params.in_width_gap);
WriteGPURegister((u32)GPU_REG_INDEX(display_transfer_config.texture_copy.output_size),
- params.out_width_gap);
- WriteGPURegister((u32)GPU_REG_INDEX(display_transfer_config.flags),
- params.flags);
+ params.out_width_gap);
+ WriteGPURegister((u32)GPU_REG_INDEX(display_transfer_config.flags), params.flags);
- // NOTE: Actual GSP ORs 1 with current register instead of overwriting. Doesn't seem to matter.
+ // NOTE: Actual GSP ORs 1 with current register instead of overwriting. Doesn't seem to
+ // matter.
WriteGPURegister((u32)GPU_REG_INDEX(display_transfer_config.trigger), 1);
break;
}
- case CommandId::CACHE_FLUSH:
- {
+ case CommandId::CACHE_FLUSH: {
// NOTE: Rasterizer flushing handled elsewhere in CPU read/write and other GPU handlers
// Use command.cache_flush.regions to implement this handler
break;
@@ -552,7 +578,8 @@ static void ExecuteCommand(const Command& command, u32 thread_id) {
}
if (Pica::g_debug_context)
- Pica::g_debug_context->OnEvent(Pica::DebugContext::Event::GSPCommandProcessed, (void*)&command);
+ Pica::g_debug_context->OnEvent(Pica::DebugContext::Event::GSPCommandProcessed,
+ (void*)&command);
}
/**
@@ -575,7 +602,7 @@ static void SetLcdForceBlack(Service::Interface* self) {
// the color to black (all zero).
data.is_enabled.Assign(enable_black);
- LCD::Write(HW::VADDR_LCD + 4 * LCD_REG_INDEX(color_fill_top), data.raw); // Top LCD
+ LCD::Write(HW::VADDR_LCD + 4 * LCD_REG_INDEX(color_fill_top), data.raw); // Top LCD
LCD::Write(HW::VADDR_LCD + 4 * LCD_REG_INDEX(color_fill_bottom), data.raw); // Bottom LCD
cmd_buff[1] = RESULT_SUCCESS.raw;
@@ -679,37 +706,37 @@ static void ReleaseRight(Service::Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010082, WriteHWRegs, "WriteHWRegs"},
- {0x00020084, WriteHWRegsWithMask, "WriteHWRegsWithMask"},
- {0x00030082, nullptr, "WriteHWRegRepeat"},
- {0x00040080, ReadHWRegs, "ReadHWRegs"},
- {0x00050200, SetBufferSwap, "SetBufferSwap"},
- {0x00060082, nullptr, "SetCommandList"},
- {0x000700C2, nullptr, "RequestDma"},
- {0x00080082, FlushDataCache, "FlushDataCache"},
- {0x00090082, nullptr, "InvalidateDataCache"},
- {0x000A0044, nullptr, "RegisterInterruptEvents"},
- {0x000B0040, SetLcdForceBlack, "SetLcdForceBlack"},
- {0x000C0000, TriggerCmdReqQueue, "TriggerCmdReqQueue"},
- {0x000D0140, nullptr, "SetDisplayTransfer"},
- {0x000E0180, nullptr, "SetTextureCopy"},
- {0x000F0200, nullptr, "SetMemoryFill"},
- {0x00100040, SetAxiConfigQoSMode, "SetAxiConfigQoSMode"},
- {0x00110040, nullptr, "SetPerfLogMode"},
- {0x00120000, nullptr, "GetPerfLog"},
- {0x00130042, RegisterInterruptRelayQueue, "RegisterInterruptRelayQueue"},
+ {0x00010082, WriteHWRegs, "WriteHWRegs"},
+ {0x00020084, WriteHWRegsWithMask, "WriteHWRegsWithMask"},
+ {0x00030082, nullptr, "WriteHWRegRepeat"},
+ {0x00040080, ReadHWRegs, "ReadHWRegs"},
+ {0x00050200, SetBufferSwap, "SetBufferSwap"},
+ {0x00060082, nullptr, "SetCommandList"},
+ {0x000700C2, nullptr, "RequestDma"},
+ {0x00080082, FlushDataCache, "FlushDataCache"},
+ {0x00090082, nullptr, "InvalidateDataCache"},
+ {0x000A0044, nullptr, "RegisterInterruptEvents"},
+ {0x000B0040, SetLcdForceBlack, "SetLcdForceBlack"},
+ {0x000C0000, TriggerCmdReqQueue, "TriggerCmdReqQueue"},
+ {0x000D0140, nullptr, "SetDisplayTransfer"},
+ {0x000E0180, nullptr, "SetTextureCopy"},
+ {0x000F0200, nullptr, "SetMemoryFill"},
+ {0x00100040, SetAxiConfigQoSMode, "SetAxiConfigQoSMode"},
+ {0x00110040, nullptr, "SetPerfLogMode"},
+ {0x00120000, nullptr, "GetPerfLog"},
+ {0x00130042, RegisterInterruptRelayQueue, "RegisterInterruptRelayQueue"},
{0x00140000, UnregisterInterruptRelayQueue, "UnregisterInterruptRelayQueue"},
- {0x00150002, nullptr, "TryAcquireRight"},
- {0x00160042, AcquireRight, "AcquireRight"},
- {0x00170000, ReleaseRight, "ReleaseRight"},
- {0x00180000, ImportDisplayCaptureInfo, "ImportDisplayCaptureInfo"},
- {0x00190000, nullptr, "SaveVramSysArea"},
- {0x001A0000, nullptr, "RestoreVramSysArea"},
- {0x001B0000, nullptr, "ResetGpuCore"},
- {0x001C0040, nullptr, "SetLedForceOff"},
- {0x001D0040, nullptr, "SetTestCommand"},
- {0x001E0080, nullptr, "SetInternalPriorities"},
- {0x001F0082, nullptr, "StoreDataCache"},
+ {0x00150002, nullptr, "TryAcquireRight"},
+ {0x00160042, AcquireRight, "AcquireRight"},
+ {0x00170000, ReleaseRight, "ReleaseRight"},
+ {0x00180000, ImportDisplayCaptureInfo, "ImportDisplayCaptureInfo"},
+ {0x00190000, nullptr, "SaveVramSysArea"},
+ {0x001A0000, nullptr, "RestoreVramSysArea"},
+ {0x001B0000, nullptr, "ResetGpuCore"},
+ {0x001C0040, nullptr, "SetLedForceOff"},
+ {0x001D0040, nullptr, "SetTestCommand"},
+ {0x001E0080, nullptr, "SetInternalPriorities"},
+ {0x001F0082, nullptr, "StoreDataCache"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -721,9 +748,9 @@ Interface::Interface() {
g_interrupt_event = nullptr;
using Kernel::MemoryPermission;
- g_shared_memory = Kernel::SharedMemory::Create(nullptr, 0x1000,
- MemoryPermission::ReadWrite, MemoryPermission::ReadWrite,
- 0, Kernel::MemoryRegion::BASE, "GSP:SharedMemory");
+ g_shared_memory = Kernel::SharedMemory::Create(nullptr, 0x1000, MemoryPermission::ReadWrite,
+ MemoryPermission::ReadWrite, 0,
+ Kernel::MemoryRegion::BASE, "GSP:SharedMemory");
g_thread_id = 0;
gpu_right_acquired = false;
diff --git a/src/core/hle/service/gsp_gpu.h b/src/core/hle/service/gsp_gpu.h
index 3b4b678a3..79a72f77d 100644
--- a/src/core/hle/service/gsp_gpu.h
+++ b/src/core/hle/service/gsp_gpu.h
@@ -6,10 +6,8 @@
#include <cstddef>
#include <string>
-
#include "common/bit_field.h"
#include "common/common_types.h"
-
#include "core/hle/result.h"
#include "core/hle/service/service.h"
@@ -20,30 +18,30 @@ namespace GSP_GPU {
/// GSP interrupt ID
enum class InterruptId : u8 {
- PSC0 = 0x00,
- PSC1 = 0x01,
- PDC0 = 0x02, // Seems called every vertical screen line
- PDC1 = 0x03, // Seems called every frame
- PPF = 0x04,
- P3D = 0x05,
- DMA = 0x06,
+ PSC0 = 0x00,
+ PSC1 = 0x01,
+ PDC0 = 0x02, // Seems called every vertical screen line
+ PDC1 = 0x03, // Seems called every frame
+ PPF = 0x04,
+ P3D = 0x05,
+ DMA = 0x06,
};
/// GSP command ID
enum class CommandId : u32 {
- REQUEST_DMA = 0x00,
+ REQUEST_DMA = 0x00,
/// Submits a commandlist for execution by the GPU.
SUBMIT_GPU_CMDLIST = 0x01,
// Fills a given memory range with a particular value
- SET_MEMORY_FILL = 0x02,
+ SET_MEMORY_FILL = 0x02,
// Copies an image and optionally performs color-conversion or scaling.
// This is highly similar to the GameCube's EFB copy feature
- SET_DISPLAY_TRANSFER = 0x03,
+ SET_DISPLAY_TRANSFER = 0x03,
// Conceptionally similar to SET_DISPLAY_TRANSFER and presumable uses the same hardware path
- SET_TEXTURE_COPY = 0x04,
+ SET_TEXTURE_COPY = 0x04,
/// Flushes up to 3 cache regions in a single command.
CACHE_FLUSH = 0x05,
};
@@ -61,19 +59,18 @@ struct InterruptRelayQueue {
u32 missed_PDC0;
u32 missed_PDC1;
- InterruptId slot[0x34]; ///< Interrupt ID slots
+ InterruptId slot[0x34]; ///< Interrupt ID slots
};
-static_assert(sizeof(InterruptRelayQueue) == 0x40,
- "InterruptRelayQueue struct has incorrect size");
+static_assert(sizeof(InterruptRelayQueue) == 0x40, "InterruptRelayQueue struct has incorrect size");
struct FrameBufferInfo {
BitField<0, 1, u32> active_fb; // 0 = first, 1 = second
u32 address_left;
u32 address_right;
- u32 stride; // maps to 0x1EF00X90 ?
- u32 format; // maps to 0x1EF00X70 ?
- u32 shown_fb; // maps to 0x1EF00X78 ?
+ u32 stride; // maps to 0x1EF00X90 ?
+ u32 format; // maps to 0x1EF00X70 ?
+ u32 shown_fb; // maps to 0x1EF00X78 ?
u32 unknown;
};
static_assert(sizeof(FrameBufferInfo) == 0x1c, "Struct has incorrect size");
@@ -91,7 +88,8 @@ static_assert(sizeof(FrameBufferUpdate) == 0x40, "Struct has incorrect size");
// TODO: Not sure if this padding is correct.
// Chances are the second block is stored at offset 0x24 rather than 0x20.
#ifndef _MSC_VER
-static_assert(offsetof(FrameBufferUpdate, framebuffer_info[1]) == 0x20, "FrameBufferInfo element has incorrect alignment");
+static_assert(offsetof(FrameBufferUpdate, framebuffer_info[1]) == 0x20,
+ "FrameBufferInfo element has incorrect alignment");
#endif
/// GSP command
@@ -163,13 +161,13 @@ struct CommandBuffer {
// Current command index. This index is updated by GSP module after loading the command
// data, right before the command is processed. When this index is updated by GSP module,
// the total commands field is decreased by one as well.
- BitField<0,8,u32> index;
+ BitField<0, 8, u32> index;
// Total commands to process, must not be value 0 when GSP module handles commands. This
// must be <=15 when writing a command to shared memory. This is incremented by the
// application when writing a command to shared memory, after increasing this value
// TriggerCmdReqQueue is only used if this field is value 1.
- BitField<8,8,u32> number_commands;
+ BitField<8, 8, u32> number_commands;
};
u32 unk[7];
diff --git a/src/core/hle/service/gsp_lcd.cpp b/src/core/hle/service/gsp_lcd.cpp
index c700c21c5..b916dd759 100644
--- a/src/core/hle/service/gsp_lcd.cpp
+++ b/src/core/hle/service/gsp_lcd.cpp
@@ -10,11 +10,13 @@
namespace GSP_LCD {
const Interface::FunctionInfo FunctionTable[] = {
+ // clang-format off
{0x000F0000, nullptr, "PowerOnAllBacklights"},
{0x00100000, nullptr, "PowerOffAllBacklights"},
{0x00110040, nullptr, "PowerOnBacklight"},
{0x00120040, nullptr, "PowerOffBacklight"},
- {0x00130040, nullptr, "SetLedForceOff"}
+ {0x00130040, nullptr, "SetLedForceOff"},
+ // clang-format on
};
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index cdec11388..99baded11 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -3,19 +3,15 @@
// Refer to the license.txt file included.
#include <cmath>
-
-#include "common/logging/log.h"
#include "common/emu_window.h"
-
-#include "core/hle/service/service.h"
-#include "core/hle/service/hid/hid.h"
-#include "core/hle/service/hid/hid_spvr.h"
-#include "core/hle/service/hid/hid_user.h"
-
+#include "common/logging/log.h"
#include "core/core_timing.h"
#include "core/hle/kernel/event.h"
#include "core/hle/kernel/shared_memory.h"
-
+#include "core/hle/service/hid/hid.h"
+#include "core/hle/service/hid/hid_spvr.h"
+#include "core/hle/service/hid/hid_user.h"
+#include "core/hle/service/service.h"
#include "video_core/video_core.h"
namespace Service {
@@ -37,11 +33,13 @@ static u32 next_accelerometer_index;
static u32 next_gyroscope_index;
static int enable_accelerometer_count = 0; // positive means enabled
-static int enable_gyroscope_count = 0; // positive means enabled
+static int enable_gyroscope_count = 0; // positive means enabled
static PadState GetCirclePadDirectionState(s16 circle_pad_x, s16 circle_pad_y) {
- constexpr float TAN30 = 0.577350269, TAN60 = 1 / TAN30; // 30 degree and 60 degree are angular thresholds for directions
- constexpr int CIRCLE_PAD_THRESHOLD_SQUARE = 40 * 40; // a circle pad radius greater than 40 will trigger circle pad direction
+ // 30 degree and 60 degree are angular thresholds for directions
+ constexpr float TAN30 = 0.577350269, TAN60 = 1 / TAN30;
+ // a circle pad radius greater than 40 will trigger circle pad direction
+ constexpr int CIRCLE_PAD_THRESHOLD_SQUARE = 40 * 40;
PadState state;
state.hex = 0;
@@ -90,7 +88,7 @@ void Update() {
PadState old_state = mem->pad.entries[last_entry_index].current_state;
// Compute bitmask with 1s for bits different from the old state
- PadState changed = { { (state.hex ^ old_state.hex) } };
+ PadState changed = {{(state.hex ^ old_state.hex)}};
// Get the current Pad entry
PadDataEntry& pad_entry = mem->pad.entries[mem->pad.index];
@@ -135,11 +133,13 @@ void Update() {
// Update accelerometer
if (enable_accelerometer_count > 0) {
mem->accelerometer.index = next_accelerometer_index;
- next_accelerometer_index = (next_accelerometer_index + 1) % mem->accelerometer.entries.size();
+ next_accelerometer_index =
+ (next_accelerometer_index + 1) % mem->accelerometer.entries.size();
- AccelerometerDataEntry& accelerometer_entry = mem->accelerometer.entries[mem->accelerometer.index];
- std::tie(accelerometer_entry.x, accelerometer_entry.y, accelerometer_entry.z)
- = VideoCore::g_emu_window->GetAccelerometerState();
+ AccelerometerDataEntry& accelerometer_entry =
+ mem->accelerometer.entries[mem->accelerometer.index];
+ std::tie(accelerometer_entry.x, accelerometer_entry.y, accelerometer_entry.z) =
+ VideoCore::g_emu_window->GetAccelerometerState();
// Make up "raw" entry
// TODO(wwylele):
@@ -167,8 +167,8 @@ void Update() {
next_gyroscope_index = (next_gyroscope_index + 1) % mem->gyroscope.entries.size();
GyroscopeDataEntry& gyroscope_entry = mem->gyroscope.entries[mem->gyroscope.index];
- std::tie(gyroscope_entry.x, gyroscope_entry.y, gyroscope_entry.z)
- = VideoCore::g_emu_window->GetGyroscopeState();
+ std::tie(gyroscope_entry.x, gyroscope_entry.y, gyroscope_entry.z) =
+ VideoCore::g_emu_window->GetGyroscopeState();
// Make up "raw" entry
mem->gyroscope.raw_entry.x = gyroscope_entry.x;
@@ -188,7 +188,7 @@ void Update() {
void GetIPCHandles(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- cmd_buff[1] = 0; // No error
+ cmd_buff[1] = 0; // No error
cmd_buff[2] = 0x14000000; // IPC Command Structure translate-header
// TODO(yuriks): Return error from SendSyncRequest is this fails (part of IPC marshalling)
cmd_buff[3] = Kernel::g_handle_table.Create(Service::HID::shared_mem).MoveFrom();
@@ -259,9 +259,7 @@ void GetGyroscopeLowCalibrateParam(Service::Interface* self) {
const s16 param_unit = 6700; // an approximate value taken from hw
GyroscopeCalibrateParam param = {
- { 0, param_unit, -param_unit },
- { 0, param_unit, -param_unit },
- { 0, param_unit, -param_unit },
+ {0, param_unit, -param_unit}, {0, param_unit, -param_unit}, {0, param_unit, -param_unit},
};
memcpy(&cmd_buff[2], &param, sizeof(param));
@@ -286,9 +284,9 @@ void Init() {
AddService(new HID_SPVR_Interface);
using Kernel::MemoryPermission;
- shared_mem = SharedMemory::Create(nullptr, 0x1000,
- MemoryPermission::ReadWrite, MemoryPermission::Read,
- 0, Kernel::MemoryRegion::BASE, "HID:SharedMemory");
+ shared_mem =
+ SharedMemory::Create(nullptr, 0x1000, MemoryPermission::ReadWrite, MemoryPermission::Read,
+ 0, Kernel::MemoryRegion::BASE, "HID:SharedMemory");
next_pad_index = 0;
next_touch_index = 0;
@@ -296,9 +294,9 @@ void Init() {
// Create event handles
event_pad_or_touch_1 = Event::Create(ResetType::OneShot, "HID:EventPadOrTouch1");
event_pad_or_touch_2 = Event::Create(ResetType::OneShot, "HID:EventPadOrTouch2");
- event_accelerometer = Event::Create(ResetType::OneShot, "HID:EventAccelerometer");
- event_gyroscope = Event::Create(ResetType::OneShot, "HID:EventGyroscope");
- event_debug_pad = Event::Create(ResetType::OneShot, "HID:EventDebugPad");
+ event_accelerometer = Event::Create(ResetType::OneShot, "HID:EventAccelerometer");
+ event_gyroscope = Event::Create(ResetType::OneShot, "HID:EventGyroscope");
+ event_debug_pad = Event::Create(ResetType::OneShot, "HID:EventDebugPad");
}
void Shutdown() {
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h
index 669b1f723..7904e7355 100644
--- a/src/core/hle/service/hid/hid.h
+++ b/src/core/hle/service/hid/hid.h
@@ -5,14 +5,13 @@
#pragma once
#include <array>
-
#ifndef _MSC_VER
#include <cstddef>
#endif
-#include "core/settings.h"
#include "common/bit_field.h"
#include "common/common_funcs.h"
#include "common/common_types.h"
+#include "core/settings.h"
namespace Service {
@@ -103,7 +102,7 @@ struct SharedMem {
struct {
s64 index_reset_ticks; ///< CPU tick count for when HID module updated entry index 0
s64 index_reset_ticks_previous; ///< Previous `index_reset_ticks`
- u32 index; ///< Index of the last updated pad state entry
+ u32 index; ///< Index of the last updated pad state entry
INSERT_PADDING_WORDS(0x2);
@@ -121,7 +120,7 @@ struct SharedMem {
struct {
s64 index_reset_ticks; ///< CPU tick count for when HID module updated entry index 0
s64 index_reset_ticks_previous; ///< Previous `index_reset_ticks`
- u32 index; ///< Index of the last updated touch entry
+ u32 index; ///< Index of the last updated touch entry
INSERT_PADDING_WORDS(0x1);
@@ -135,7 +134,7 @@ struct SharedMem {
struct {
s64 index_reset_ticks; ///< CPU tick count for when HID module updated entry index 0
s64 index_reset_ticks_previous; ///< Previous `index_reset_ticks`
- u32 index; ///< Index of the last updated accelerometer entry
+ u32 index; ///< Index of the last updated accelerometer entry
INSERT_PADDING_WORDS(0x1);
@@ -149,7 +148,7 @@ struct SharedMem {
struct {
s64 index_reset_ticks; ///< CPU tick count for when HID module updated entry index 0
s64 index_reset_ticks_previous; ///< Previous `index_reset_ticks`
- u32 index; ///< Index of the last updated accelerometer entry
+ u32 index; ///< Index of the last updated accelerometer entry
INSERT_PADDING_WORDS(0x1);
@@ -176,9 +175,9 @@ struct GyroscopeCalibrateParam {
// is technically allowed since C++11. This macro should be enabled once MSVC adds
// support for that.
#ifndef _MSC_VER
-#define ASSERT_REG_POSITION(field_name, position) \
- static_assert(offsetof(SharedMem, field_name) == position * 4, \
- "Field "#field_name" has invalid position")
+#define ASSERT_REG_POSITION(field_name, position) \
+ static_assert(offsetof(SharedMem, field_name) == position * 4, \
+ "Field " #field_name " has invalid position")
ASSERT_REG_POSITION(pad.index_reset_ticks, 0x0);
ASSERT_REG_POSITION(touch.index_reset_ticks, 0x2A);
@@ -187,33 +186,33 @@ ASSERT_REG_POSITION(touch.index_reset_ticks, 0x2A);
#endif // !defined(_MSC_VER)
// Pre-defined PadStates for single button presses
-const PadState PAD_NONE = {{0}};
-const PadState PAD_A = {{1u << 0}};
-const PadState PAD_B = {{1u << 1}};
-const PadState PAD_SELECT = {{1u << 2}};
-const PadState PAD_START = {{1u << 3}};
-const PadState PAD_RIGHT = {{1u << 4}};
-const PadState PAD_LEFT = {{1u << 5}};
-const PadState PAD_UP = {{1u << 6}};
-const PadState PAD_DOWN = {{1u << 7}};
-const PadState PAD_R = {{1u << 8}};
-const PadState PAD_L = {{1u << 9}};
-const PadState PAD_X = {{1u << 10}};
-const PadState PAD_Y = {{1u << 11}};
-
-const PadState PAD_ZL = {{1u << 14}};
-const PadState PAD_ZR = {{1u << 15}};
-
-const PadState PAD_TOUCH = {{1u << 20}};
-
-const PadState PAD_C_RIGHT = {{1u << 24}};
-const PadState PAD_C_LEFT = {{1u << 25}};
-const PadState PAD_C_UP = {{1u << 26}};
-const PadState PAD_C_DOWN = {{1u << 27}};
+const PadState PAD_NONE = {{0}};
+const PadState PAD_A = {{1u << 0}};
+const PadState PAD_B = {{1u << 1}};
+const PadState PAD_SELECT = {{1u << 2}};
+const PadState PAD_START = {{1u << 3}};
+const PadState PAD_RIGHT = {{1u << 4}};
+const PadState PAD_LEFT = {{1u << 5}};
+const PadState PAD_UP = {{1u << 6}};
+const PadState PAD_DOWN = {{1u << 7}};
+const PadState PAD_R = {{1u << 8}};
+const PadState PAD_L = {{1u << 9}};
+const PadState PAD_X = {{1u << 10}};
+const PadState PAD_Y = {{1u << 11}};
+
+const PadState PAD_ZL = {{1u << 14}};
+const PadState PAD_ZR = {{1u << 15}};
+
+const PadState PAD_TOUCH = {{1u << 20}};
+
+const PadState PAD_C_RIGHT = {{1u << 24}};
+const PadState PAD_C_LEFT = {{1u << 25}};
+const PadState PAD_C_UP = {{1u << 26}};
+const PadState PAD_C_DOWN = {{1u << 27}};
const PadState PAD_CIRCLE_RIGHT = {{1u << 28}};
-const PadState PAD_CIRCLE_LEFT = {{1u << 29}};
-const PadState PAD_CIRCLE_UP = {{1u << 30}};
-const PadState PAD_CIRCLE_DOWN = {{1u << 31}};
+const PadState PAD_CIRCLE_LEFT = {{1u << 29}};
+const PadState PAD_CIRCLE_UP = {{1u << 30}};
+const PadState PAD_CIRCLE_DOWN = {{1u << 31}};
/**
* HID::GetIPCHandles service function
@@ -305,6 +304,5 @@ void Init();
/// Shutdown HID service
void Shutdown();
-
}
}
diff --git a/src/core/hle/service/hid/hid_spvr.cpp b/src/core/hle/service/hid/hid_spvr.cpp
index 046e65b11..09007e304 100644
--- a/src/core/hle/service/hid/hid_spvr.cpp
+++ b/src/core/hle/service/hid/hid_spvr.cpp
@@ -9,16 +9,16 @@ namespace Service {
namespace HID {
const Interface::FunctionInfo FunctionTable[] = {
- {0x000A0000, GetIPCHandles, "GetIPCHandles"},
- {0x000B0000, nullptr, "StartAnalogStickCalibration"},
- {0x000E0000, nullptr, "GetAnalogStickCalibrateParam"},
- {0x00110000, EnableAccelerometer, "EnableAccelerometer"},
- {0x00120000, DisableAccelerometer, "DisableAccelerometer"},
- {0x00130000, EnableGyroscopeLow, "EnableGyroscopeLow"},
- {0x00140000, DisableGyroscopeLow, "DisableGyroscopeLow"},
+ {0x000A0000, GetIPCHandles, "GetIPCHandles"},
+ {0x000B0000, nullptr, "StartAnalogStickCalibration"},
+ {0x000E0000, nullptr, "GetAnalogStickCalibrateParam"},
+ {0x00110000, EnableAccelerometer, "EnableAccelerometer"},
+ {0x00120000, DisableAccelerometer, "DisableAccelerometer"},
+ {0x00130000, EnableGyroscopeLow, "EnableGyroscopeLow"},
+ {0x00140000, DisableGyroscopeLow, "DisableGyroscopeLow"},
{0x00150000, GetGyroscopeLowRawToDpsCoefficient, "GetGyroscopeLowRawToDpsCoefficient"},
- {0x00160000, GetGyroscopeLowCalibrateParam, "GetGyroscopeLowCalibrateParam"},
- {0x00170000, GetSoundVolume, "GetSoundVolume"},
+ {0x00160000, GetGyroscopeLowCalibrateParam, "GetGyroscopeLowCalibrateParam"},
+ {0x00170000, GetSoundVolume, "GetSoundVolume"},
};
HID_SPVR_Interface::HID_SPVR_Interface() {
diff --git a/src/core/hle/service/hid/hid_user.cpp b/src/core/hle/service/hid/hid_user.cpp
index bb157b83d..42591543c 100644
--- a/src/core/hle/service/hid/hid_user.cpp
+++ b/src/core/hle/service/hid/hid_user.cpp
@@ -9,16 +9,16 @@ namespace Service {
namespace HID {
const Interface::FunctionInfo FunctionTable[] = {
- {0x000A0000, GetIPCHandles, "GetIPCHandles"},
- {0x000B0000, nullptr, "StartAnalogStickCalibration"},
- {0x000E0000, nullptr, "GetAnalogStickCalibrateParam"},
- {0x00110000, EnableAccelerometer, "EnableAccelerometer"},
- {0x00120000, DisableAccelerometer, "DisableAccelerometer"},
- {0x00130000, EnableGyroscopeLow, "EnableGyroscopeLow"},
- {0x00140000, DisableGyroscopeLow, "DisableGyroscopeLow"},
+ {0x000A0000, GetIPCHandles, "GetIPCHandles"},
+ {0x000B0000, nullptr, "StartAnalogStickCalibration"},
+ {0x000E0000, nullptr, "GetAnalogStickCalibrateParam"},
+ {0x00110000, EnableAccelerometer, "EnableAccelerometer"},
+ {0x00120000, DisableAccelerometer, "DisableAccelerometer"},
+ {0x00130000, EnableGyroscopeLow, "EnableGyroscopeLow"},
+ {0x00140000, DisableGyroscopeLow, "DisableGyroscopeLow"},
{0x00150000, GetGyroscopeLowRawToDpsCoefficient, "GetGyroscopeLowRawToDpsCoefficient"},
- {0x00160000, GetGyroscopeLowCalibrateParam, "GetGyroscopeLowCalibrateParam"},
- {0x00170000, GetSoundVolume, "GetSoundVolume"},
+ {0x00160000, GetGyroscopeLowCalibrateParam, "GetGyroscopeLowCalibrateParam"},
+ {0x00170000, GetSoundVolume, "GetSoundVolume"},
};
HID_U_Interface::HID_U_Interface() {
diff --git a/src/core/hle/service/http_c.cpp b/src/core/hle/service/http_c.cpp
index 0855ab227..3cf62a4b8 100644
--- a/src/core/hle/service/http_c.cpp
+++ b/src/core/hle/service/http_c.cpp
@@ -10,56 +10,56 @@
namespace HTTP_C {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010044, nullptr, "Initialize"},
- {0x00020082, nullptr, "CreateContext"},
- {0x00030040, nullptr, "CloseContext"},
- {0x00040040, nullptr, "CancelConnection"},
- {0x00050040, nullptr, "GetRequestState"},
- {0x00060040, nullptr, "GetDownloadSizeState"},
- {0x00070040, nullptr, "GetRequestError"},
- {0x00080042, nullptr, "InitializeConnectionSession"},
- {0x00090040, nullptr, "BeginRequest"},
- {0x000A0040, nullptr, "BeginRequestAsync"},
- {0x000B0082, nullptr, "ReceiveData"},
- {0x000C0102, nullptr, "ReceiveDataTimeout"},
- {0x000D0146, nullptr, "SetProxy"},
- {0x000E0040, nullptr, "SetProxyDefault"},
- {0x000F00C4, nullptr, "SetBasicAuthorization"},
- {0x00100080, nullptr, "SetSocketBufferSize"},
- {0x001100C4, nullptr, "AddRequestHeader"},
- {0x001200C4, nullptr, "AddPostDataAscii"},
- {0x001300C4, nullptr, "AddPostDataBinary"},
- {0x00140082, nullptr, "AddPostDataRaw"},
- {0x00150080, nullptr, "SetPostDataType"},
- {0x001600C4, nullptr, "SendPostDataAscii"},
- {0x00170144, nullptr, "SendPostDataAsciiTimeout"},
- {0x001800C4, nullptr, "SendPostDataBinary"},
- {0x00190144, nullptr, "SendPostDataBinaryTimeout"},
- {0x001A0082, nullptr, "SendPostDataRaw"},
- {0x001B0102, nullptr, "SendPOSTDataRawTimeout"},
- {0x001C0080, nullptr, "SetPostDataEncoding"},
- {0x001D0040, nullptr, "NotifyFinishSendPostData"},
- {0x001E00C4, nullptr, "GetResponseHeader"},
- {0x001F0144, nullptr, "GetResponseHeaderTimeout"},
- {0x00200082, nullptr, "GetResponseData"},
- {0x00210102, nullptr, "GetResponseDataTimeout"},
- {0x00220040, nullptr, "GetResponseStatusCode"},
- {0x002300C0, nullptr, "GetResponseStatusCodeTimeout"},
- {0x00240082, nullptr, "AddTrustedRootCA"},
- {0x00250080, nullptr, "AddDefaultCert"},
- {0x00260080, nullptr, "SelectRootCertChain"},
- {0x002700C4, nullptr, "SetClientCert"},
- {0x002B0080, nullptr, "SetSSLOpt"},
- {0x002C0080, nullptr, "SetSSLClearOpt"},
- {0x002D0000, nullptr, "CreateRootCertChain"},
- {0x002E0040, nullptr, "DestroyRootCertChain"},
- {0x002F0082, nullptr, "RootCertChainAddCert"},
- {0x00300080, nullptr, "RootCertChainAddDefaultCert"},
- {0x00350186, nullptr, "SetDefaultProxy"},
- {0x00360000, nullptr, "ClearDNSCache"},
- {0x00370080, nullptr, "SetKeepAlive"},
- {0x003800C0, nullptr, "SetPostDataTypeSize"},
- {0x00390000, nullptr, "Finalize"},
+ {0x00010044, nullptr, "Initialize"},
+ {0x00020082, nullptr, "CreateContext"},
+ {0x00030040, nullptr, "CloseContext"},
+ {0x00040040, nullptr, "CancelConnection"},
+ {0x00050040, nullptr, "GetRequestState"},
+ {0x00060040, nullptr, "GetDownloadSizeState"},
+ {0x00070040, nullptr, "GetRequestError"},
+ {0x00080042, nullptr, "InitializeConnectionSession"},
+ {0x00090040, nullptr, "BeginRequest"},
+ {0x000A0040, nullptr, "BeginRequestAsync"},
+ {0x000B0082, nullptr, "ReceiveData"},
+ {0x000C0102, nullptr, "ReceiveDataTimeout"},
+ {0x000D0146, nullptr, "SetProxy"},
+ {0x000E0040, nullptr, "SetProxyDefault"},
+ {0x000F00C4, nullptr, "SetBasicAuthorization"},
+ {0x00100080, nullptr, "SetSocketBufferSize"},
+ {0x001100C4, nullptr, "AddRequestHeader"},
+ {0x001200C4, nullptr, "AddPostDataAscii"},
+ {0x001300C4, nullptr, "AddPostDataBinary"},
+ {0x00140082, nullptr, "AddPostDataRaw"},
+ {0x00150080, nullptr, "SetPostDataType"},
+ {0x001600C4, nullptr, "SendPostDataAscii"},
+ {0x00170144, nullptr, "SendPostDataAsciiTimeout"},
+ {0x001800C4, nullptr, "SendPostDataBinary"},
+ {0x00190144, nullptr, "SendPostDataBinaryTimeout"},
+ {0x001A0082, nullptr, "SendPostDataRaw"},
+ {0x001B0102, nullptr, "SendPOSTDataRawTimeout"},
+ {0x001C0080, nullptr, "SetPostDataEncoding"},
+ {0x001D0040, nullptr, "NotifyFinishSendPostData"},
+ {0x001E00C4, nullptr, "GetResponseHeader"},
+ {0x001F0144, nullptr, "GetResponseHeaderTimeout"},
+ {0x00200082, nullptr, "GetResponseData"},
+ {0x00210102, nullptr, "GetResponseDataTimeout"},
+ {0x00220040, nullptr, "GetResponseStatusCode"},
+ {0x002300C0, nullptr, "GetResponseStatusCodeTimeout"},
+ {0x00240082, nullptr, "AddTrustedRootCA"},
+ {0x00250080, nullptr, "AddDefaultCert"},
+ {0x00260080, nullptr, "SelectRootCertChain"},
+ {0x002700C4, nullptr, "SetClientCert"},
+ {0x002B0080, nullptr, "SetSSLOpt"},
+ {0x002C0080, nullptr, "SetSSLClearOpt"},
+ {0x002D0000, nullptr, "CreateRootCertChain"},
+ {0x002E0040, nullptr, "DestroyRootCertChain"},
+ {0x002F0082, nullptr, "RootCertChainAddCert"},
+ {0x00300080, nullptr, "RootCertChainAddDefaultCert"},
+ {0x00350186, nullptr, "SetDefaultProxy"},
+ {0x00360000, nullptr, "ClearDNSCache"},
+ {0x00370080, nullptr, "SetKeepAlive"},
+ {0x003800C0, nullptr, "SetPostDataTypeSize"},
+ {0x00390000, nullptr, "Finalize"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/ir/ir.cpp b/src/core/hle/service/ir/ir.cpp
index 079a87e48..4d6639ded 100644
--- a/src/core/hle/service/ir/ir.cpp
+++ b/src/core/hle/service/ir/ir.cpp
@@ -4,12 +4,11 @@
#include "core/hle/kernel/event.h"
#include "core/hle/kernel/shared_memory.h"
-
-#include "core/hle/service/service.h"
#include "core/hle/service/ir/ir.h"
#include "core/hle/service/ir/ir_rst.h"
#include "core/hle/service/ir/ir_u.h"
#include "core/hle/service/ir/ir_user.h"
+#include "core/hle/service/service.h"
namespace Service {
namespace IR {
@@ -32,14 +31,14 @@ void InitializeIrNopShared(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 transfer_buff_size = cmd_buff[1];
- u32 recv_buff_size = cmd_buff[2];
- u32 unk1 = cmd_buff[3];
- u32 send_buff_size = cmd_buff[4];
- u32 unk2 = cmd_buff[5];
- u8 baud_rate = cmd_buff[6] & 0xFF;
- Handle handle = cmd_buff[8];
-
- if(Kernel::g_handle_table.IsValid(handle)) {
+ u32 recv_buff_size = cmd_buff[2];
+ u32 unk1 = cmd_buff[3];
+ u32 send_buff_size = cmd_buff[4];
+ u32 unk2 = cmd_buff[5];
+ u8 baud_rate = cmd_buff[6] & 0xFF;
+ Handle handle = cmd_buff[8];
+
+ if (Kernel::g_handle_table.IsValid(handle)) {
transfer_shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(handle);
transfer_shared_memory->name = "IR:TransferSharedMemory";
}
@@ -47,7 +46,7 @@ void InitializeIrNopShared(Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_IR, "(STUBBED) called, transfer_buff_size=%d, recv_buff_size=%d, "
- "unk1=%d, send_buff_size=%d, unk2=%d, baud_rate=%u, handle=0x%08X",
+ "unk1=%d, send_buff_size=%d, unk2=%d, baud_rate=%u, handle=0x%08X",
transfer_buff_size, recv_buff_size, unk1, send_buff_size, unk2, baud_rate, handle);
}
@@ -94,13 +93,13 @@ void Init() {
AddService(new IR_User_Interface);
using Kernel::MemoryPermission;
- shared_memory = SharedMemory::Create(nullptr, 0x1000,
- Kernel::MemoryPermission::ReadWrite, Kernel::MemoryPermission::ReadWrite,
- 0, Kernel::MemoryRegion::BASE, "IR:SharedMemory");
+ shared_memory = SharedMemory::Create(nullptr, 0x1000, Kernel::MemoryPermission::ReadWrite,
+ Kernel::MemoryPermission::ReadWrite, 0,
+ Kernel::MemoryRegion::BASE, "IR:SharedMemory");
transfer_shared_memory = nullptr;
// Create event handle(s)
- handle_event = Event::Create(ResetType::OneShot, "IR:HandleEvent");
+ handle_event = Event::Create(ResetType::OneShot, "IR:HandleEvent");
conn_status_event = Event::Create(ResetType::OneShot, "IR:ConnectionStatusEvent");
}
diff --git a/src/core/hle/service/ir/ir_rst.cpp b/src/core/hle/service/ir/ir_rst.cpp
index c0300f109..1f10ebd3d 100644
--- a/src/core/hle/service/ir/ir_rst.cpp
+++ b/src/core/hle/service/ir/ir_rst.cpp
@@ -9,10 +9,10 @@ namespace Service {
namespace IR {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010000, GetHandles, "GetHandles"},
- {0x00020080, nullptr, "Initialize"},
- {0x00030000, nullptr, "Shutdown"},
- {0x00090000, nullptr, "WriteToTwoFields"},
+ {0x00010000, GetHandles, "GetHandles"},
+ {0x00020080, nullptr, "Initialize"},
+ {0x00030000, nullptr, "Shutdown"},
+ {0x00090000, nullptr, "WriteToTwoFields"},
};
IR_RST_Interface::IR_RST_Interface() {
diff --git a/src/core/hle/service/ir/ir_u.cpp b/src/core/hle/service/ir/ir_u.cpp
index 96f76cb83..429615f31 100644
--- a/src/core/hle/service/ir/ir_u.cpp
+++ b/src/core/hle/service/ir/ir_u.cpp
@@ -8,24 +8,26 @@ namespace Service {
namespace IR {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010000, nullptr, "Initialize"},
- {0x00020000, nullptr, "Shutdown"},
- {0x00030042, nullptr, "StartSendTransfer"},
- {0x00040000, nullptr, "WaitSendTransfer"},
- {0x000500C2, nullptr, "StartRecvTransfer"},
- {0x00060000, nullptr, "WaitRecvTransfer"},
- {0x00070080, nullptr, "GetRecvTransferCount"},
- {0x00080000, nullptr, "GetSendState"},
- {0x00090040, nullptr, "SetBitRate"},
- {0x000A0000, nullptr, "GetBitRate"},
- {0x000B0040, nullptr, "SetIRLEDState"},
- {0x000C0000, nullptr, "GetIRLEDRecvState"},
- {0x000D0000, nullptr, "GetSendFinishedEvent"},
- {0x000E0000, nullptr, "GetRecvFinishedEvent"},
- {0x000F0000, nullptr, "GetTransferState"},
- {0x00100000, nullptr, "GetErrorStatus"},
- {0x00110040, nullptr, "SetSleepModeActive"},
- {0x00120040, nullptr, "SetSleepModeState"},
+ // clang-format off
+ {0x00010000, nullptr, "Initialize"},
+ {0x00020000, nullptr, "Shutdown"},
+ {0x00030042, nullptr, "StartSendTransfer"},
+ {0x00040000, nullptr, "WaitSendTransfer"},
+ {0x000500C2, nullptr, "StartRecvTransfer"},
+ {0x00060000, nullptr, "WaitRecvTransfer"},
+ {0x00070080, nullptr, "GetRecvTransferCount"},
+ {0x00080000, nullptr, "GetSendState"},
+ {0x00090040, nullptr, "SetBitRate"},
+ {0x000A0000, nullptr, "GetBitRate"},
+ {0x000B0040, nullptr, "SetIRLEDState"},
+ {0x000C0000, nullptr, "GetIRLEDRecvState"},
+ {0x000D0000, nullptr, "GetSendFinishedEvent"},
+ {0x000E0000, nullptr, "GetRecvFinishedEvent"},
+ {0x000F0000, nullptr, "GetTransferState"},
+ {0x00100000, nullptr, "GetErrorStatus"},
+ {0x00110040, nullptr, "SetSleepModeActive"},
+ {0x00120040, nullptr, "SetSleepModeState"},
+ // clang-format off
};
IR_U_Interface::IR_U_Interface() {
diff --git a/src/core/hle/service/ir/ir_user.cpp b/src/core/hle/service/ir/ir_user.cpp
index 06a601029..6cff1d544 100644
--- a/src/core/hle/service/ir/ir_user.cpp
+++ b/src/core/hle/service/ir/ir_user.cpp
@@ -9,32 +9,32 @@ namespace Service {
namespace IR {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010182, nullptr, "InitializeIrNop"},
- {0x00020000, FinalizeIrNop, "FinalizeIrNop"},
- {0x00030000, nullptr, "ClearReceiveBuffer"},
- {0x00040000, nullptr, "ClearSendBuffer"},
- {0x000500C0, nullptr, "WaitConnection"},
- {0x00060040, RequireConnection, "RequireConnection"},
- {0x000702C0, nullptr, "AutoConnection"},
- {0x00080000, nullptr, "AnyConnection"},
- {0x00090000, Disconnect, "Disconnect"},
- {0x000A0000, nullptr, "GetReceiveEvent"},
- {0x000B0000, nullptr, "GetSendEvent"},
+ {0x00010182, nullptr, "InitializeIrNop"},
+ {0x00020000, FinalizeIrNop, "FinalizeIrNop"},
+ {0x00030000, nullptr, "ClearReceiveBuffer"},
+ {0x00040000, nullptr, "ClearSendBuffer"},
+ {0x000500C0, nullptr, "WaitConnection"},
+ {0x00060040, RequireConnection, "RequireConnection"},
+ {0x000702C0, nullptr, "AutoConnection"},
+ {0x00080000, nullptr, "AnyConnection"},
+ {0x00090000, Disconnect, "Disconnect"},
+ {0x000A0000, nullptr, "GetReceiveEvent"},
+ {0x000B0000, nullptr, "GetSendEvent"},
{0x000C0000, GetConnectionStatusEvent, "GetConnectionStatusEvent"},
- {0x000D0042, nullptr, "SendIrNop"},
- {0x000E0042, nullptr, "SendIrNopLarge"},
- {0x000F0040, nullptr, "ReceiveIrnop"},
- {0x00100042, nullptr, "ReceiveIrnopLarge"},
- {0x00110040, nullptr, "GetLatestReceiveErrorResult"},
- {0x00120040, nullptr, "GetLatestSendErrorResult"},
- {0x00130000, nullptr, "GetConnectionStatus"},
- {0x00140000, nullptr, "GetTryingToConnectStatus"},
- {0x00150000, nullptr, "GetReceiveSizeFreeAndUsed"},
- {0x00160000, nullptr, "GetSendSizeFreeAndUsed"},
- {0x00170000, nullptr, "GetConnectionRole"},
- {0x00180182, InitializeIrNopShared, "InitializeIrNopShared"},
- {0x00190040, nullptr, "ReleaseReceivedData"},
- {0x001A0040, nullptr, "SetOwnMachineId"},
+ {0x000D0042, nullptr, "SendIrNop"},
+ {0x000E0042, nullptr, "SendIrNopLarge"},
+ {0x000F0040, nullptr, "ReceiveIrnop"},
+ {0x00100042, nullptr, "ReceiveIrnopLarge"},
+ {0x00110040, nullptr, "GetLatestReceiveErrorResult"},
+ {0x00120040, nullptr, "GetLatestSendErrorResult"},
+ {0x00130000, nullptr, "GetConnectionStatus"},
+ {0x00140000, nullptr, "GetTryingToConnectStatus"},
+ {0x00150000, nullptr, "GetReceiveSizeFreeAndUsed"},
+ {0x00160000, nullptr, "GetSendSizeFreeAndUsed"},
+ {0x00170000, nullptr, "GetConnectionRole"},
+ {0x00180182, InitializeIrNopShared, "InitializeIrNopShared"},
+ {0x00190040, nullptr, "ReleaseReceivedData"},
+ {0x001A0040, nullptr, "SetOwnMachineId"},
};
IR_User_Interface::IR_User_Interface() {
diff --git a/src/core/hle/service/ldr_ro/cro_helper.cpp b/src/core/hle/service/ldr_ro/cro_helper.cpp
index 3d2a613ee..b7d250312 100644
--- a/src/core/hle/service/ldr_ro/cro_helper.cpp
+++ b/src/core/hle/service/ldr_ro/cro_helper.cpp
@@ -5,7 +5,6 @@
#include "common/alignment.h"
#include "common/logging/log.h"
#include "common/scope_exit.h"
-
#include "core/hle/service/ldr_ro/cro_helper.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -14,37 +13,30 @@
namespace LDR_RO {
static const ResultCode ERROR_BUFFER_TOO_SMALL = // 0xE0E12C1F
- ResultCode(static_cast<ErrorDescription>(31), ErrorModule::RO, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
+ ResultCode(static_cast<ErrorDescription>(31), ErrorModule::RO, ErrorSummary::InvalidArgument,
+ ErrorLevel::Usage);
static ResultCode CROFormatError(u32 description) {
- return ResultCode(static_cast<ErrorDescription>(description), ErrorModule::RO, ErrorSummary::WrongArgument, ErrorLevel::Permanent);
+ return ResultCode(static_cast<ErrorDescription>(description), ErrorModule::RO,
+ ErrorSummary::WrongArgument, ErrorLevel::Permanent);
}
-const std::array<int, 17> CROHelper::ENTRY_SIZE {{
+const std::array<int, 17> CROHelper::ENTRY_SIZE{{
1, // code
1, // data
1, // module name
- sizeof(SegmentEntry),
- sizeof(ExportNamedSymbolEntry),
- sizeof(ExportIndexedSymbolEntry),
+ sizeof(SegmentEntry), sizeof(ExportNamedSymbolEntry), sizeof(ExportIndexedSymbolEntry),
1, // export strings
- sizeof(ExportTreeEntry),
- sizeof(ImportModuleEntry),
- sizeof(ExternalRelocationEntry),
- sizeof(ImportNamedSymbolEntry),
- sizeof(ImportIndexedSymbolEntry),
+ sizeof(ExportTreeEntry), sizeof(ImportModuleEntry), sizeof(ExternalRelocationEntry),
+ sizeof(ImportNamedSymbolEntry), sizeof(ImportIndexedSymbolEntry),
sizeof(ImportAnonymousSymbolEntry),
1, // import strings
- sizeof(StaticAnonymousSymbolEntry),
- sizeof(InternalRelocationEntry),
- sizeof(StaticRelocationEntry)
+ sizeof(StaticAnonymousSymbolEntry), sizeof(InternalRelocationEntry),
+ sizeof(StaticRelocationEntry),
}};
-const std::array<CROHelper::HeaderField, 4> CROHelper::FIX_BARRIERS {{
- Fix0Barrier,
- Fix1Barrier,
- Fix2Barrier,
- Fix3Barrier
+const std::array<CROHelper::HeaderField, 4> CROHelper::FIX_BARRIERS{{
+ Fix0Barrier, Fix1Barrier, Fix2Barrier, Fix3Barrier,
}};
VAddr CROHelper::SegmentTagToAddress(SegmentTag segment_tag) const {
@@ -63,7 +55,7 @@ VAddr CROHelper::SegmentTagToAddress(SegmentTag segment_tag) const {
}
ResultCode CROHelper::ApplyRelocation(VAddr target_address, RelocationType relocation_type,
- u32 addend, u32 symbol_address, u32 target_future_address) {
+ u32 addend, u32 symbol_address, u32 target_future_address) {
switch (relocation_type) {
case RelocationType::Nothing:
@@ -124,7 +116,8 @@ ResultCode CROHelper::ApplyRelocationBatch(VAddr batch, u32 symbol_address, bool
return CROFormatError(0x12);
}
- ResultCode result = ApplyRelocation(relocation_target, relocation.type, relocation.addend, symbol_address, relocation_target);
+ ResultCode result = ApplyRelocation(relocation_target, relocation.type, relocation.addend,
+ symbol_address, relocation_target);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation %08X", result.raw);
return result;
@@ -167,7 +160,7 @@ VAddr CROHelper::FindExportNamedSymbol(const std::string& name) const {
if (test_byte >= len) {
next.raw = entry.left.raw;
- } else if((name[test_byte] >> test_bit_in_byte) & 1) {
+ } else if ((name[test_byte] >> test_bit_in_byte) & 1) {
next.raw = entry.right.raw;
} else {
next.raw = entry.left.raw;
@@ -213,24 +206,12 @@ ResultCode CROHelper::RebaseHeader(u32 cro_size) {
// verifies that all offsets are in the correct order
constexpr std::array<HeaderField, 18> OFFSET_ORDER = {{
- CodeOffset,
- ModuleNameOffset,
- SegmentTableOffset,
- ExportNamedSymbolTableOffset,
- ExportTreeTableOffset,
- ExportIndexedSymbolTableOffset,
- ExportStringsOffset,
- ImportModuleTableOffset,
- ExternalRelocationTableOffset,
- ImportNamedSymbolTableOffset,
- ImportIndexedSymbolTableOffset,
- ImportAnonymousSymbolTableOffset,
- ImportStringsOffset,
- StaticAnonymousSymbolTableOffset,
- InternalRelocationTableOffset,
- StaticRelocationTableOffset,
- DataOffset,
- FileSize
+ CodeOffset, ModuleNameOffset, SegmentTableOffset, ExportNamedSymbolTableOffset,
+ ExportTreeTableOffset, ExportIndexedSymbolTableOffset, ExportStringsOffset,
+ ImportModuleTableOffset, ExternalRelocationTableOffset, ImportNamedSymbolTableOffset,
+ ImportIndexedSymbolTableOffset, ImportAnonymousSymbolTableOffset, ImportStringsOffset,
+ StaticAnonymousSymbolTableOffset, InternalRelocationTableOffset,
+ StaticRelocationTableOffset, DataOffset, FileSize,
}};
u32 prev_offset = GetField(OFFSET_ORDER[0]);
@@ -266,9 +247,9 @@ ResultCode CROHelper::RebaseHeader(u32 cro_size) {
return RESULT_SUCCESS;
}
-ResultVal<VAddr> CROHelper::RebaseSegmentTable(u32 cro_size,
- VAddr data_segment_address, u32 data_segment_size,
- VAddr bss_segment_address, u32 bss_segment_size) {
+ResultVal<VAddr> CROHelper::RebaseSegmentTable(u32 cro_size, VAddr data_segment_address,
+ u32 data_segment_size, VAddr bss_segment_address,
+ u32 bss_segment_size) {
u32 prev_data_segment = 0;
u32 segment_num = GetField(SegmentNum);
@@ -309,8 +290,8 @@ ResultCode CROHelper::RebaseExportNamedSymbolTable() {
if (entry.name_offset != 0) {
entry.name_offset += module_address;
- if (entry.name_offset < export_strings_offset
- || entry.name_offset >= export_strings_end) {
+ if (entry.name_offset < export_strings_offset ||
+ entry.name_offset >= export_strings_end) {
return CROFormatError(0x11);
}
}
@@ -337,9 +318,13 @@ ResultCode CROHelper::RebaseImportModuleTable() {
VAddr import_strings_offset = GetField(ImportStringsOffset);
VAddr import_strings_end = import_strings_offset + GetField(ImportStringsSize);
VAddr import_indexed_symbol_table_offset = GetField(ImportIndexedSymbolTableOffset);
- VAddr index_import_table_end = import_indexed_symbol_table_offset + GetField(ImportIndexedSymbolNum) * sizeof(ImportIndexedSymbolEntry);
+ VAddr index_import_table_end =
+ import_indexed_symbol_table_offset +
+ GetField(ImportIndexedSymbolNum) * sizeof(ImportIndexedSymbolEntry);
VAddr import_anonymous_symbol_table_offset = GetField(ImportAnonymousSymbolTableOffset);
- VAddr offset_import_table_end = import_anonymous_symbol_table_offset + GetField(ImportAnonymousSymbolNum) * sizeof(ImportAnonymousSymbolEntry);
+ VAddr offset_import_table_end =
+ import_anonymous_symbol_table_offset +
+ GetField(ImportAnonymousSymbolNum) * sizeof(ImportAnonymousSymbolEntry);
u32 module_num = GetField(ImportModuleNum);
for (u32 i = 0; i < module_num; ++i) {
@@ -348,24 +333,24 @@ ResultCode CROHelper::RebaseImportModuleTable() {
if (entry.name_offset != 0) {
entry.name_offset += module_address;
- if (entry.name_offset < import_strings_offset
- || entry.name_offset >= import_strings_end) {
+ if (entry.name_offset < import_strings_offset ||
+ entry.name_offset >= import_strings_end) {
return CROFormatError(0x18);
}
}
if (entry.import_indexed_symbol_table_offset != 0) {
entry.import_indexed_symbol_table_offset += module_address;
- if (entry.import_indexed_symbol_table_offset < import_indexed_symbol_table_offset
- || entry.import_indexed_symbol_table_offset > index_import_table_end) {
+ if (entry.import_indexed_symbol_table_offset < import_indexed_symbol_table_offset ||
+ entry.import_indexed_symbol_table_offset > index_import_table_end) {
return CROFormatError(0x18);
}
}
if (entry.import_anonymous_symbol_table_offset != 0) {
entry.import_anonymous_symbol_table_offset += module_address;
- if (entry.import_anonymous_symbol_table_offset < import_anonymous_symbol_table_offset
- || entry.import_anonymous_symbol_table_offset > offset_import_table_end) {
+ if (entry.import_anonymous_symbol_table_offset < import_anonymous_symbol_table_offset ||
+ entry.import_anonymous_symbol_table_offset > offset_import_table_end) {
return CROFormatError(0x18);
}
}
@@ -379,25 +364,27 @@ ResultCode CROHelper::RebaseImportNamedSymbolTable() {
VAddr import_strings_offset = GetField(ImportStringsOffset);
VAddr import_strings_end = import_strings_offset + GetField(ImportStringsSize);
VAddr external_relocation_table_offset = GetField(ExternalRelocationTableOffset);
- VAddr external_relocation_table_end = external_relocation_table_offset + GetField(ExternalRelocationNum) * sizeof(ExternalRelocationEntry);
+ VAddr external_relocation_table_end =
+ external_relocation_table_offset +
+ GetField(ExternalRelocationNum) * sizeof(ExternalRelocationEntry);
u32 num = GetField(ImportNamedSymbolNum);
- for (u32 i = 0; i < num ; ++i) {
+ for (u32 i = 0; i < num; ++i) {
ImportNamedSymbolEntry entry;
GetEntry(i, entry);
if (entry.name_offset != 0) {
entry.name_offset += module_address;
- if (entry.name_offset < import_strings_offset
- || entry.name_offset >= import_strings_end) {
+ if (entry.name_offset < import_strings_offset ||
+ entry.name_offset >= import_strings_end) {
return CROFormatError(0x1B);
}
}
if (entry.relocation_batch_offset != 0) {
entry.relocation_batch_offset += module_address;
- if (entry.relocation_batch_offset < external_relocation_table_offset
- || entry.relocation_batch_offset > external_relocation_table_end) {
+ if (entry.relocation_batch_offset < external_relocation_table_offset ||
+ entry.relocation_batch_offset > external_relocation_table_end) {
return CROFormatError(0x1B);
}
}
@@ -409,17 +396,19 @@ ResultCode CROHelper::RebaseImportNamedSymbolTable() {
ResultCode CROHelper::RebaseImportIndexedSymbolTable() {
VAddr external_relocation_table_offset = GetField(ExternalRelocationTableOffset);
- VAddr external_relocation_table_end = external_relocation_table_offset + GetField(ExternalRelocationNum) * sizeof(ExternalRelocationEntry);
+ VAddr external_relocation_table_end =
+ external_relocation_table_offset +
+ GetField(ExternalRelocationNum) * sizeof(ExternalRelocationEntry);
u32 num = GetField(ImportIndexedSymbolNum);
- for (u32 i = 0; i < num ; ++i) {
+ for (u32 i = 0; i < num; ++i) {
ImportIndexedSymbolEntry entry;
GetEntry(i, entry);
if (entry.relocation_batch_offset != 0) {
entry.relocation_batch_offset += module_address;
- if (entry.relocation_batch_offset < external_relocation_table_offset
- || entry.relocation_batch_offset > external_relocation_table_end) {
+ if (entry.relocation_batch_offset < external_relocation_table_offset ||
+ entry.relocation_batch_offset > external_relocation_table_end) {
return CROFormatError(0x14);
}
}
@@ -431,17 +420,19 @@ ResultCode CROHelper::RebaseImportIndexedSymbolTable() {
ResultCode CROHelper::RebaseImportAnonymousSymbolTable() {
VAddr external_relocation_table_offset = GetField(ExternalRelocationTableOffset);
- VAddr external_relocation_table_end = external_relocation_table_offset + GetField(ExternalRelocationNum) * sizeof(ExternalRelocationEntry);
+ VAddr external_relocation_table_end =
+ external_relocation_table_offset +
+ GetField(ExternalRelocationNum) * sizeof(ExternalRelocationEntry);
u32 num = GetField(ImportAnonymousSymbolNum);
- for (u32 i = 0; i < num ; ++i) {
+ for (u32 i = 0; i < num; ++i) {
ImportAnonymousSymbolEntry entry;
GetEntry(i, entry);
if (entry.relocation_batch_offset != 0) {
entry.relocation_batch_offset += module_address;
- if (entry.relocation_batch_offset < external_relocation_table_offset
- || entry.relocation_batch_offset > external_relocation_table_end) {
+ if (entry.relocation_batch_offset < external_relocation_table_offset ||
+ entry.relocation_batch_offset > external_relocation_table_end) {
return CROFormatError(0x17);
}
}
@@ -475,7 +466,8 @@ ResultCode CROHelper::ResetExternalRelocations() {
return CROFormatError(0x12);
}
- ResultCode result = ApplyRelocation(relocation_target, relocation.type, relocation.addend, unresolved_symbol, relocation_target);
+ ResultCode result = ApplyRelocation(relocation_target, relocation.type, relocation.addend,
+ unresolved_symbol, relocation_target);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation %08X", result.raw);
return result;
@@ -528,23 +520,27 @@ ResultCode CROHelper::ClearExternalRelocations() {
ResultCode CROHelper::ApplyStaticAnonymousSymbolToCRS(VAddr crs_address) {
VAddr static_relocation_table_offset = GetField(StaticRelocationTableOffset);
- VAddr static_relocation_table_end = static_relocation_table_offset + GetField(StaticRelocationNum) * sizeof(StaticRelocationEntry);
+ VAddr static_relocation_table_end =
+ static_relocation_table_offset +
+ GetField(StaticRelocationNum) * sizeof(StaticRelocationEntry);
CROHelper crs(crs_address);
u32 offset_export_num = GetField(StaticAnonymousSymbolNum);
- LOG_INFO(Service_LDR, "CRO \"%s\" exports %d static anonymous symbols", ModuleName().data(), offset_export_num);
+ LOG_INFO(Service_LDR, "CRO \"%s\" exports %d static anonymous symbols", ModuleName().data(),
+ offset_export_num);
for (u32 i = 0; i < offset_export_num; ++i) {
StaticAnonymousSymbolEntry entry;
GetEntry(i, entry);
u32 batch_address = entry.relocation_batch_offset + module_address;
- if (batch_address < static_relocation_table_offset
- || batch_address > static_relocation_table_end) {
+ if (batch_address < static_relocation_table_offset ||
+ batch_address > static_relocation_table_end) {
return CROFormatError(0x16);
}
u32 symbol_address = SegmentTagToAddress(entry.symbol_position);
- LOG_TRACE(Service_LDR, "CRO \"%s\" exports 0x%08X to the static module", ModuleName().data(), symbol_address);
+ LOG_TRACE(Service_LDR, "CRO \"%s\" exports 0x%08X to the static module",
+ ModuleName().data(), symbol_address);
ResultCode result = crs.ApplyRelocationBatch(batch_address, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
@@ -571,7 +567,8 @@ ResultCode CROHelper::ApplyInternalRelocations(u32 old_data_segment_address) {
if (target_segment.type == SegmentType::Data) {
// If the relocation is to the .data segment, we need to relocate it in the old buffer
- target_address = old_data_segment_address + relocation.target_position.offset_into_segment;
+ target_address =
+ old_data_segment_address + relocation.target_position.offset_into_segment;
} else {
target_address = target_addressB;
}
@@ -582,8 +579,10 @@ ResultCode CROHelper::ApplyInternalRelocations(u32 old_data_segment_address) {
SegmentEntry symbol_segment;
GetEntry(relocation.symbol_segment, symbol_segment);
- LOG_TRACE(Service_LDR, "Internally relocates 0x%08X with 0x%08X", target_address, symbol_segment.offset);
- ResultCode result = ApplyRelocation(target_address, relocation.type, relocation.addend, symbol_segment.offset, target_addressB);
+ LOG_TRACE(Service_LDR, "Internally relocates 0x%08X with 0x%08X", target_address,
+ symbol_segment.offset);
+ ResultCode result = ApplyRelocation(target_address, relocation.type, relocation.addend,
+ symbol_segment.offset, target_addressB);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation %08X", result.raw);
return result;
@@ -734,25 +733,29 @@ ResultCode CROHelper::ApplyImportNamedSymbol(VAddr crs_address) {
Memory::ReadBlock(relocation_addr, &relocation_entry, sizeof(ExternalRelocationEntry));
if (!relocation_entry.is_batch_resolved) {
- ResultCode result = ForEachAutoLinkCRO(crs_address, [&](CROHelper source) -> ResultVal<bool> {
- std::string symbol_name = Memory::ReadCString(entry.name_offset, import_strings_size);
- u32 symbol_address = source.FindExportNamedSymbol(symbol_name);
-
- if (symbol_address != 0) {
- LOG_TRACE(Service_LDR, "CRO \"%s\" imports \"%s\" from \"%s\"",
- ModuleName().data(), symbol_name.data(), source.ModuleName().data());
-
- ResultCode result = ApplyRelocationBatch(relocation_addr, symbol_address);
- if (result.IsError()) {
- LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
- return result;
+ ResultCode result =
+ ForEachAutoLinkCRO(crs_address, [&](CROHelper source) -> ResultVal<bool> {
+ std::string symbol_name =
+ Memory::ReadCString(entry.name_offset, import_strings_size);
+ u32 symbol_address = source.FindExportNamedSymbol(symbol_name);
+
+ if (symbol_address != 0) {
+ LOG_TRACE(Service_LDR, "CRO \"%s\" imports \"%s\" from \"%s\"",
+ ModuleName().data(), symbol_name.data(),
+ source.ModuleName().data());
+
+ ResultCode result = ApplyRelocationBatch(relocation_addr, symbol_address);
+ if (result.IsError()) {
+ LOG_ERROR(Service_LDR, "Error applying relocation batch %08X",
+ result.raw);
+ return result;
+ }
+
+ return MakeResult<bool>(false);
}
- return MakeResult<bool>(false);
- }
-
- return MakeResult<bool>(true);
- });
+ return MakeResult<bool>(true);
+ });
if (result.IsError()) {
return result;
}
@@ -777,7 +780,6 @@ ResultCode CROHelper::ResetImportNamedSymbol() {
LOG_ERROR(Service_LDR, "Error reseting relocation batch %08X", result.raw);
return result;
}
-
}
return RESULT_SUCCESS;
}
@@ -831,40 +833,47 @@ ResultCode CROHelper::ApplyModuleImport(VAddr crs_address) {
GetEntry(i, entry);
std::string want_cro_name = Memory::ReadCString(entry.name_offset, import_strings_size);
- ResultCode result = ForEachAutoLinkCRO(crs_address, [&](CROHelper source) -> ResultVal<bool> {
- if (want_cro_name == source.ModuleName()) {
- LOG_INFO(Service_LDR, "CRO \"%s\" imports %d indexed symbols from \"%s\"",
- ModuleName().data(), entry.import_indexed_symbol_num, source.ModuleName().data());
- for (u32 j = 0; j < entry.import_indexed_symbol_num; ++j) {
- ImportIndexedSymbolEntry im;
- entry.GetImportIndexedSymbolEntry(j, im);
- ExportIndexedSymbolEntry ex;
- source.GetEntry(im.index, ex);
- u32 symbol_address = source.SegmentTagToAddress(ex.symbol_position);
- LOG_TRACE(Service_LDR, " Imports 0x%08X", symbol_address);
- ResultCode result = ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
- if (result.IsError()) {
- LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
- return result;
+ ResultCode result =
+ ForEachAutoLinkCRO(crs_address, [&](CROHelper source) -> ResultVal<bool> {
+ if (want_cro_name == source.ModuleName()) {
+ LOG_INFO(Service_LDR, "CRO \"%s\" imports %d indexed symbols from \"%s\"",
+ ModuleName().data(), entry.import_indexed_symbol_num,
+ source.ModuleName().data());
+ for (u32 j = 0; j < entry.import_indexed_symbol_num; ++j) {
+ ImportIndexedSymbolEntry im;
+ entry.GetImportIndexedSymbolEntry(j, im);
+ ExportIndexedSymbolEntry ex;
+ source.GetEntry(im.index, ex);
+ u32 symbol_address = source.SegmentTagToAddress(ex.symbol_position);
+ LOG_TRACE(Service_LDR, " Imports 0x%08X", symbol_address);
+ ResultCode result =
+ ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
+ if (result.IsError()) {
+ LOG_ERROR(Service_LDR, "Error applying relocation batch %08X",
+ result.raw);
+ return result;
+ }
}
- }
- LOG_INFO(Service_LDR, "CRO \"%s\" imports %d anonymous symbols from \"%s\"",
- ModuleName().data(), entry.import_anonymous_symbol_num, source.ModuleName().data());
- for (u32 j = 0; j < entry.import_anonymous_symbol_num; ++j) {
- ImportAnonymousSymbolEntry im;
- entry.GetImportAnonymousSymbolEntry(j, im);
- u32 symbol_address = source.SegmentTagToAddress(im.symbol_position);
- LOG_TRACE(Service_LDR, " Imports 0x%08X", symbol_address);
- ResultCode result = ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
- if (result.IsError()) {
- LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
- return result;
+ LOG_INFO(Service_LDR, "CRO \"%s\" imports %d anonymous symbols from \"%s\"",
+ ModuleName().data(), entry.import_anonymous_symbol_num,
+ source.ModuleName().data());
+ for (u32 j = 0; j < entry.import_anonymous_symbol_num; ++j) {
+ ImportAnonymousSymbolEntry im;
+ entry.GetImportAnonymousSymbolEntry(j, im);
+ u32 symbol_address = source.SegmentTagToAddress(im.symbol_position);
+ LOG_TRACE(Service_LDR, " Imports 0x%08X", symbol_address);
+ ResultCode result =
+ ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
+ if (result.IsError()) {
+ LOG_ERROR(Service_LDR, "Error applying relocation batch %08X",
+ result.raw);
+ return result;
+ }
}
+ return MakeResult<bool>(false);
}
- return MakeResult<bool>(false);
- }
- return MakeResult<bool>(true);
- });
+ return MakeResult<bool>(true);
+ });
if (result.IsError()) {
return result;
}
@@ -873,8 +882,8 @@ ResultCode CROHelper::ApplyModuleImport(VAddr crs_address) {
}
ResultCode CROHelper::ApplyExportNamedSymbol(CROHelper target) {
- LOG_DEBUG(Service_LDR, "CRO \"%s\" exports named symbols to \"%s\"",
- ModuleName().data(), target.ModuleName().data());
+ LOG_DEBUG(Service_LDR, "CRO \"%s\" exports named symbols to \"%s\"", ModuleName().data(),
+ target.ModuleName().data());
u32 target_import_strings_size = target.GetField(ImportStringsSize);
u32 target_symbol_import_num = target.GetField(ImportNamedSymbolNum);
for (u32 i = 0; i < target_symbol_import_num; ++i) {
@@ -885,7 +894,8 @@ ResultCode CROHelper::ApplyExportNamedSymbol(CROHelper target) {
Memory::ReadBlock(relocation_addr, &relocation_entry, sizeof(ExternalRelocationEntry));
if (!relocation_entry.is_batch_resolved) {
- std::string symbol_name = Memory::ReadCString(entry.name_offset, target_import_strings_size);
+ std::string symbol_name =
+ Memory::ReadCString(entry.name_offset, target_import_strings_size);
u32 symbol_address = FindExportNamedSymbol(symbol_name);
if (symbol_address != 0) {
LOG_TRACE(Service_LDR, " exports symbol \"%s\"", symbol_name.data());
@@ -901,8 +911,8 @@ ResultCode CROHelper::ApplyExportNamedSymbol(CROHelper target) {
}
ResultCode CROHelper::ResetExportNamedSymbol(CROHelper target) {
- LOG_DEBUG(Service_LDR, "CRO \"%s\" unexports named symbols to \"%s\"",
- ModuleName().data(), target.ModuleName().data());
+ LOG_DEBUG(Service_LDR, "CRO \"%s\" unexports named symbols to \"%s\"", ModuleName().data(),
+ target.ModuleName().data());
u32 unresolved_symbol = target.GetOnUnresolvedAddress();
u32 target_import_strings_size = target.GetField(ImportStringsSize);
u32 target_symbol_import_num = target.GetField(ImportNamedSymbolNum);
@@ -914,11 +924,13 @@ ResultCode CROHelper::ResetExportNamedSymbol(CROHelper target) {
Memory::ReadBlock(relocation_addr, &relocation_entry, sizeof(ExternalRelocationEntry));
if (relocation_entry.is_batch_resolved) {
- std::string symbol_name = Memory::ReadCString(entry.name_offset, target_import_strings_size);
+ std::string symbol_name =
+ Memory::ReadCString(entry.name_offset, target_import_strings_size);
u32 symbol_address = FindExportNamedSymbol(symbol_name);
if (symbol_address != 0) {
LOG_TRACE(Service_LDR, " unexports symbol \"%s\"", symbol_name.data());
- ResultCode result = target.ApplyRelocationBatch(relocation_addr, unresolved_symbol, true);
+ ResultCode result =
+ target.ApplyRelocationBatch(relocation_addr, unresolved_symbol, true);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
return result;
@@ -940,8 +952,8 @@ ResultCode CROHelper::ApplyModuleExport(CROHelper target) {
if (Memory::ReadCString(entry.name_offset, target_import_string_size) != module_name)
continue;
- LOG_INFO(Service_LDR, "CRO \"%s\" exports %d indexed symbols to \"%s\"",
- module_name.data(), entry.import_indexed_symbol_num, target.ModuleName().data());
+ LOG_INFO(Service_LDR, "CRO \"%s\" exports %d indexed symbols to \"%s\"", module_name.data(),
+ entry.import_indexed_symbol_num, target.ModuleName().data());
for (u32 j = 0; j < entry.import_indexed_symbol_num; ++j) {
ImportIndexedSymbolEntry im;
entry.GetImportIndexedSymbolEntry(j, im);
@@ -949,7 +961,8 @@ ResultCode CROHelper::ApplyModuleExport(CROHelper target) {
GetEntry(im.index, ex);
u32 symbol_address = SegmentTagToAddress(ex.symbol_position);
LOG_TRACE(Service_LDR, " exports symbol 0x%08X", symbol_address);
- ResultCode result = target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
+ ResultCode result =
+ target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
return result;
@@ -957,13 +970,14 @@ ResultCode CROHelper::ApplyModuleExport(CROHelper target) {
}
LOG_INFO(Service_LDR, "CRO \"%s\" exports %d anonymous symbols to \"%s\"",
- module_name.data(), entry.import_anonymous_symbol_num, target.ModuleName().data());
+ module_name.data(), entry.import_anonymous_symbol_num, target.ModuleName().data());
for (u32 j = 0; j < entry.import_anonymous_symbol_num; ++j) {
ImportAnonymousSymbolEntry im;
entry.GetImportAnonymousSymbolEntry(j, im);
u32 symbol_address = SegmentTagToAddress(im.symbol_position);
LOG_TRACE(Service_LDR, " exports symbol 0x%08X", symbol_address);
- ResultCode result = target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
+ ResultCode result =
+ target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
return result;
@@ -987,12 +1001,13 @@ ResultCode CROHelper::ResetModuleExport(CROHelper target) {
if (Memory::ReadCString(entry.name_offset, target_import_string_size) != module_name)
continue;
- LOG_DEBUG(Service_LDR, "CRO \"%s\" unexports indexed symbols to \"%s\"",
- module_name.data(), target.ModuleName().data());
+ LOG_DEBUG(Service_LDR, "CRO \"%s\" unexports indexed symbols to \"%s\"", module_name.data(),
+ target.ModuleName().data());
for (u32 j = 0; j < entry.import_indexed_symbol_num; ++j) {
ImportIndexedSymbolEntry im;
entry.GetImportIndexedSymbolEntry(j, im);
- ResultCode result = target.ApplyRelocationBatch(im.relocation_batch_offset, unresolved_symbol, true);
+ ResultCode result =
+ target.ApplyRelocationBatch(im.relocation_batch_offset, unresolved_symbol, true);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
return result;
@@ -1000,11 +1015,12 @@ ResultCode CROHelper::ResetModuleExport(CROHelper target) {
}
LOG_DEBUG(Service_LDR, "CRO \"%s\" unexports anonymous symbols to \"%s\"",
- module_name.data(), target.ModuleName().data());
+ module_name.data(), target.ModuleName().data());
for (u32 j = 0; j < entry.import_anonymous_symbol_num; ++j) {
ImportAnonymousSymbolEntry im;
entry.GetImportAnonymousSymbolEntry(j, im);
- ResultCode result = target.ApplyRelocationBatch(im.relocation_batch_offset, unresolved_symbol, true);
+ ResultCode result =
+ target.ApplyRelocationBatch(im.relocation_batch_offset, unresolved_symbol, true);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
return result;
@@ -1025,25 +1041,27 @@ ResultCode CROHelper::ApplyExitRelocations(VAddr crs_address) {
ExternalRelocationEntry relocation_entry;
Memory::ReadBlock(relocation_addr, &relocation_entry, sizeof(ExternalRelocationEntry));
- if (Memory::ReadCString(entry.name_offset, import_strings_size) == "__aeabi_atexit"){
- ResultCode result = ForEachAutoLinkCRO(crs_address, [&](CROHelper source) -> ResultVal<bool> {
- u32 symbol_address = source.FindExportNamedSymbol("nnroAeabiAtexit_");
+ if (Memory::ReadCString(entry.name_offset, import_strings_size) == "__aeabi_atexit") {
+ ResultCode result =
+ ForEachAutoLinkCRO(crs_address, [&](CROHelper source) -> ResultVal<bool> {
+ u32 symbol_address = source.FindExportNamedSymbol("nnroAeabiAtexit_");
- if (symbol_address != 0) {
- LOG_DEBUG(Service_LDR, "CRO \"%s\" import exit function from \"%s\"",
- ModuleName().data(), source.ModuleName().data());
+ if (symbol_address != 0) {
+ LOG_DEBUG(Service_LDR, "CRO \"%s\" import exit function from \"%s\"",
+ ModuleName().data(), source.ModuleName().data());
- ResultCode result = ApplyRelocationBatch(relocation_addr, symbol_address);
- if (result.IsError()) {
- LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
- return result;
- }
+ ResultCode result = ApplyRelocationBatch(relocation_addr, symbol_address);
+ if (result.IsError()) {
+ LOG_ERROR(Service_LDR, "Error applying relocation batch %08X",
+ result.raw);
+ return result;
+ }
- return MakeResult<bool>(false);
- }
+ return MakeResult<bool>(false);
+ }
- return MakeResult<bool>(true);
- });
+ return MakeResult<bool>(true);
+ });
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying exit relocation %08X", result.raw);
return result;
@@ -1070,9 +1088,9 @@ static ResultCode VerifyStringTableLength(VAddr address, u32 size) {
return RESULT_SUCCESS;
}
-ResultCode CROHelper::Rebase(VAddr crs_address, u32 cro_size,
- VAddr data_segment_addresss, u32 data_segment_size,
- VAddr bss_segment_address, u32 bss_segment_size, bool is_crs) {
+ResultCode CROHelper::Rebase(VAddr crs_address, u32 cro_size, VAddr data_segment_addresss,
+ u32 data_segment_size, VAddr bss_segment_address, u32 bss_segment_size,
+ bool is_crs) {
ResultCode result = RebaseHeader(cro_size);
if (result.IsError()) {
@@ -1088,9 +1106,8 @@ ResultCode CROHelper::Rebase(VAddr crs_address, u32 cro_size,
u32 prev_data_segment_address = 0;
if (!is_crs) {
- auto result_val = RebaseSegmentTable(cro_size,
- data_segment_addresss, data_segment_size,
- bss_segment_address, bss_segment_size);
+ auto result_val = RebaseSegmentTable(cro_size, data_segment_addresss, data_segment_size,
+ bss_segment_address, bss_segment_size);
if (result_val.Failed()) {
LOG_ERROR(Service_LDR, "Error rebasing segment table %08X", result_val.Code().raw);
return result_val.Code();
@@ -1374,7 +1391,8 @@ void CROHelper::Unregister(VAddr crs_address) {
CROHelper next_head(crs.NextModule()), previous_head(crs.PreviousModule());
CROHelper next(NextModule()), previous(PreviousModule());
- if (module_address == next_head.module_address || module_address == previous_head.module_address) {
+ if (module_address == next_head.module_address ||
+ module_address == previous_head.module_address) {
// removing head
if (next.module_address) {
// the next is new head
@@ -1400,7 +1418,8 @@ void CROHelper::Unregister(VAddr crs_address) {
// let head's previous point to the new tail
if (next_head.module_address && next_head.PreviousModule() == module_address) {
next_head.SetPreviousModule(previous.module_address);
- } else if (previous_head.module_address && previous_head.PreviousModule() == module_address) {
+ } else if (previous_head.module_address &&
+ previous_head.PreviousModule() == module_address) {
previous_head.SetPreviousModule(previous.module_address);
} else {
UNREACHABLE();
@@ -1419,9 +1438,9 @@ u32 CROHelper::GetFixEnd(u32 fix_level) const {
u32 entry_size_i = 2;
int field = ModuleNameOffset;
while (true) {
- end = std::max<u32>(end,
- GetField(static_cast<HeaderField>(field)) +
- GetField(static_cast<HeaderField>(field + 1)) * ENTRY_SIZE[entry_size_i]);
+ end = std::max<u32>(end, GetField(static_cast<HeaderField>(field)) +
+ GetField(static_cast<HeaderField>(field + 1)) *
+ ENTRY_SIZE[entry_size_i]);
++entry_size_i;
field += 2;
diff --git a/src/core/hle/service/ldr_ro/cro_helper.h b/src/core/hle/service/ldr_ro/cro_helper.h
index 34e357afd..6a0d0d3bf 100644
--- a/src/core/hle/service/ldr_ro/cro_helper.h
+++ b/src/core/hle/service/ldr_ro/cro_helper.h
@@ -6,12 +6,10 @@
#include <array>
#include <tuple>
-
#include "common/common_types.h"
#include "common/swap.h"
-
-#include "core/memory.h"
#include "core/hle/result.h"
+#include "core/memory.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace LDR_RO
@@ -21,14 +19,17 @@ namespace LDR_RO {
// GCC versions < 5.0 do not implement std::is_trivially_copyable.
// Excluding MSVC because it has weird behaviour for std::is_trivially_copyable.
#if (__GNUC__ >= 5) || defined(__clang__)
- #define ASSERT_CRO_STRUCT(name, size) \
- static_assert(std::is_standard_layout<name>::value, "CRO structure " #name " doesn't use standard layout"); \
- static_assert(std::is_trivially_copyable<name>::value, "CRO structure " #name " isn't trivially copyable"); \
- static_assert(sizeof(name) == (size), "Unexpected struct size for CRO structure " #name)
+#define ASSERT_CRO_STRUCT(name, size) \
+ static_assert(std::is_standard_layout<name>::value, \
+ "CRO structure " #name " doesn't use standard layout"); \
+ static_assert(std::is_trivially_copyable<name>::value, \
+ "CRO structure " #name " isn't trivially copyable"); \
+ static_assert(sizeof(name) == (size), "Unexpected struct size for CRO structure " #name)
#else
- #define ASSERT_CRO_STRUCT(name, size) \
- static_assert(std::is_standard_layout<name>::value, "CRO structure " #name " doesn't use standard layout"); \
- static_assert(sizeof(name) == (size), "Unexpected struct size for CRO structure " #name)
+#define ASSERT_CRO_STRUCT(name, size) \
+ static_assert(std::is_standard_layout<name>::value, \
+ "CRO structure " #name " doesn't use standard layout"); \
+ static_assert(sizeof(name) == (size), "Unexpected struct size for CRO structure " #name)
#endif
static constexpr u32 CRO_HEADER_SIZE = 0x138;
@@ -37,8 +38,7 @@ static constexpr u32 CRO_HASH_SIZE = 0x80;
/// Represents a loaded module (CRO) with interfaces manipulating it.
class CROHelper final {
public:
- explicit CROHelper(VAddr cro_address) : module_address(cro_address) {
- }
+ explicit CROHelper(VAddr cro_address) : module_address(cro_address) {}
std::string ModuleName() const {
return Memory::ReadCString(GetField(ModuleNameOffset), GetField(ModuleNameSize));
@@ -59,9 +59,9 @@ public:
* @param is_crs true if the module itself is the static module
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
*/
- ResultCode Rebase(VAddr crs_address, u32 cro_size,
- VAddr data_segment_addresss, u32 data_segment_size,
- VAddr bss_segment_address, u32 bss_segment_size, bool is_crs);
+ ResultCode Rebase(VAddr crs_address, u32 cro_size, VAddr data_segment_addresss,
+ u32 data_segment_size, VAddr bss_segment_address, u32 bss_segment_size,
+ bool is_crs);
/**
* Unrebases the module.
@@ -148,8 +148,9 @@ private:
const VAddr module_address; ///< the virtual address of this module
/**
- * Each item in this enum represents a u32 field in the header begin from address+0x80, successively.
- * We don't directly use a struct here, to avoid GetPointer, reinterpret_cast, or Read/WriteBlock repeatedly.
+ * Each item in this enum represents a u32 field in the header begin from address+0x80,
+ * successively. We don't directly use a struct here, to avoid GetPointer, reinterpret_cast, or
+ * Read/WriteBlock repeatedly.
*/
enum HeaderField {
Magic = 0,
@@ -208,18 +209,20 @@ private:
Fix2Barrier = ImportModuleTableOffset,
Fix1Barrier = StaticAnonymousSymbolTableOffset,
};
- static_assert(Fix0Barrier == (CRO_HEADER_SIZE - CRO_HASH_SIZE) / 4, "CRO Header fields are wrong!");
+ static_assert(Fix0Barrier == (CRO_HEADER_SIZE - CRO_HASH_SIZE) / 4,
+ "CRO Header fields are wrong!");
enum class SegmentType : u32 {
- Code = 0,
+ Code = 0,
ROData = 1,
- Data = 2,
- BSS = 3,
+ Data = 2,
+ BSS = 3,
};
/**
* Identifies a program location inside of a segment.
- * Required to refer to program locations because individual segments may be relocated independently of each other.
+ * Required to refer to program locations because individual segments may be relocated
+ * independently of each other.
*/
union SegmentTag {
u32_le raw;
@@ -282,7 +285,7 @@ private:
/// Identifies an indexed symbol imported from another module.
struct ImportIndexedSymbolEntry {
- u32_le index; // index of an ExportIndexedSymbolEntry in the exporting module
+ u32_le index; // index of an ExportIndexedSymbolEntry in the exporting module
u32_le relocation_batch_offset; // pointing to a relocation batch in ExternalRelocationTable
static constexpr HeaderField TABLE_OFFSET_FIELD = ImportIndexedSymbolTableOffset;
@@ -291,8 +294,8 @@ private:
/// Identifies an anonymous symbol imported from another module.
struct ImportAnonymousSymbolEntry {
- SegmentTag symbol_position; // in the exporting segment
- u32_le relocation_batch_offset; // pointing to a relocation batch in ExternalRelocationTable
+ SegmentTag symbol_position; // in the exporting segment
+ u32_le relocation_batch_offset; // pointing to a relocation batch in ExternalRelocationTable
static constexpr HeaderField TABLE_OFFSET_FIELD = ImportAnonymousSymbolTableOffset;
};
@@ -300,42 +303,47 @@ private:
/// Information of a imported module and symbols imported from it.
struct ImportModuleEntry {
- u32_le name_offset; // pointing to a substring in ImportStrings
- u32_le import_indexed_symbol_table_offset; // pointing to a subtable in ImportIndexedSymbolTable
+ u32_le name_offset; // pointing to a substring in ImportStrings
+ u32_le import_indexed_symbol_table_offset; // pointing to a subtable in
+ // ImportIndexedSymbolTable
u32_le import_indexed_symbol_num;
- u32_le import_anonymous_symbol_table_offset; // pointing to a subtable in ImportAnonymousSymbolTable
+ u32_le import_anonymous_symbol_table_offset; // pointing to a subtable in
+ // ImportAnonymousSymbolTable
u32_le import_anonymous_symbol_num;
static constexpr HeaderField TABLE_OFFSET_FIELD = ImportModuleTableOffset;
void GetImportIndexedSymbolEntry(u32 index, ImportIndexedSymbolEntry& entry) {
- Memory::ReadBlock(import_indexed_symbol_table_offset + index * sizeof(ImportIndexedSymbolEntry),
- &entry, sizeof(ImportIndexedSymbolEntry));
+ Memory::ReadBlock(import_indexed_symbol_table_offset +
+ index * sizeof(ImportIndexedSymbolEntry),
+ &entry, sizeof(ImportIndexedSymbolEntry));
}
void GetImportAnonymousSymbolEntry(u32 index, ImportAnonymousSymbolEntry& entry) {
- Memory::ReadBlock(import_anonymous_symbol_table_offset + index * sizeof(ImportAnonymousSymbolEntry),
- &entry, sizeof(ImportAnonymousSymbolEntry));
+ Memory::ReadBlock(import_anonymous_symbol_table_offset +
+ index * sizeof(ImportAnonymousSymbolEntry),
+ &entry, sizeof(ImportAnonymousSymbolEntry));
}
};
ASSERT_CRO_STRUCT(ImportModuleEntry, 20);
enum class RelocationType : u8 {
- Nothing = 0,
- AbsoluteAddress = 2,
- RelativeAddress = 3,
- ThumbBranch = 10,
- ArmBranch = 28,
- ModifyArmBranch = 29,
- AbsoluteAddress2 = 38,
+ Nothing = 0,
+ AbsoluteAddress = 2,
+ RelativeAddress = 3,
+ ThumbBranch = 10,
+ ArmBranch = 28,
+ ModifyArmBranch = 29,
+ AbsoluteAddress2 = 38,
AlignedRelativeAddress = 42,
};
struct RelocationEntry {
- SegmentTag target_position; // to self's segment as an ExternalRelocationEntry; to static module segment as a StaticRelocationEntry
+ SegmentTag target_position; // to self's segment as an ExternalRelocationEntry; to static
+ // module segment as a StaticRelocationEntry
RelocationType type;
u8 is_batch_end;
- u8 is_batch_resolved; // set at a batch beginning if the batch is resolved
+ u8 is_batch_resolved; // set at a batch beginning if the batch is resolved
INSERT_PADDING_BYTES(1);
u32_le addend;
};
@@ -366,8 +374,8 @@ private:
/// Identifies a special static anonymous symbol (no game is known using this).
struct StaticAnonymousSymbolEntry {
- SegmentTag symbol_position; // to self's segment
- u32_le relocation_batch_offset; // pointing to a relocation batch in StaticRelocationTable
+ SegmentTag symbol_position; // to self's segment
+ u32_le relocation_batch_offset; // pointing to a relocation batch in StaticRelocationTable
static constexpr HeaderField TABLE_OFFSET_FIELD = StaticAnonymousSymbolTableOffset;
};
@@ -446,12 +454,15 @@ private:
}
/**
- * A helper function iterating over all registered auto-link modules, including the static module.
+ * A helper function iterating over all registered auto-link modules, including the static
+ * module.
* @param crs_address the virtual address of the static module
* @param func a function object to operate on a module. It accepts one parameter
- * CROHelper and returns ResultVal<bool>. It should return true to continue the iteration,
+ * CROHelper and returns ResultVal<bool>. It should return true to continue the
+ * iteration,
* false to stop the iteration, or an error code (which will also stop the iteration).
- * @returns ResultCode indicating the result of the operation, RESULT_SUCCESS if all iteration success,
+ * @returns ResultCode indicating the result of the operation, RESULT_SUCCESS if all iteration
+ * success,
* otherwise error code of the last iteration.
*/
template <typename FunctionObject>
@@ -477,8 +488,8 @@ private:
* Usually equals to target_address, but will be different for a target in .data segment
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
*/
- ResultCode ApplyRelocation(VAddr target_address, RelocationType relocation_type,
- u32 addend, u32 symbol_address, u32 target_future_address);
+ ResultCode ApplyRelocation(VAddr target_address, RelocationType relocation_type, u32 addend,
+ u32 symbol_address, u32 target_future_address);
/**
* Clears a relocation to zero
@@ -492,7 +503,8 @@ private:
* Applies or resets a batch of relocations
* @param batch the virtual address of the first relocation in the batch
* @param symbol_address the symbol address to be relocated with
- * @param reset false to set the batch to resolved state, true to reset the batch to unresolved state
+ * @param reset false to set the batch to resolved state, true to reset the batch to unresolved
+ * state
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
*/
ResultCode ApplyRelocationBatch(VAddr batch, u32 symbol_address, bool reset = false);
@@ -507,7 +519,8 @@ private:
/**
* Rebases offsets in module header according to module address.
* @param cro_size the size of the CRO file
- * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error code.
+ * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
+ * code.
*/
ResultCode RebaseHeader(u32 cro_size);
@@ -520,43 +533,49 @@ private:
* @param bss_segment_size the buffer size for .bss segment
* @returns ResultVal<VAddr> with the virtual address of .data segment in CRO.
*/
- ResultVal<VAddr> RebaseSegmentTable(u32 cro_size,
- VAddr data_segment_address, u32 data_segment_size,
- VAddr bss_segment_address, u32 bss_segment_size);
+ ResultVal<VAddr> RebaseSegmentTable(u32 cro_size, VAddr data_segment_address,
+ u32 data_segment_size, VAddr bss_segment_address,
+ u32 bss_segment_size);
/**
* Rebases offsets in exported named symbol table according to module address.
- * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error code.
+ * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
+ * code.
*/
ResultCode RebaseExportNamedSymbolTable();
/**
* Verifies indices in export tree table.
- * @returns ResultCode RESULT_SUCCESS if all indices are verified as valid, otherwise error code.
+ * @returns ResultCode RESULT_SUCCESS if all indices are verified as valid, otherwise error
+ * code.
*/
ResultCode VerifyExportTreeTable() const;
/**
* Rebases offsets in exported module table according to module address.
- * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error code.
+ * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
+ * code.
*/
ResultCode RebaseImportModuleTable();
/**
* Rebases offsets in imported named symbol table according to module address.
- * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error code.
+ * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
+ * code.
*/
ResultCode RebaseImportNamedSymbolTable();
/**
* Rebases offsets in imported indexed symbol table according to module address.
- * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error code.
+ * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
+ * code.
*/
ResultCode RebaseImportIndexedSymbolTable();
/**
* Rebases offsets in imported anonymous symbol table according to module address.
- * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error code.
+ * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
+ * code.
*/
ResultCode RebaseImportAnonymousSymbolTable();
@@ -621,7 +640,8 @@ private:
void UnrebaseHeader();
/**
- * Looks up all imported named symbols of this module in all registered auto-link modules, and resolves them if found.
+ * Looks up all imported named symbols of this module in all registered auto-link modules, and
+ * resolves them if found.
* @param crs_address the virtual address of the static module
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
*/
@@ -646,7 +666,8 @@ private:
ResultCode ResetImportAnonymousSymbol();
/**
- * Finds registered auto-link modules that this module imports, and resolves indexed and anonymous symbols exported by them.
+ * Finds registered auto-link modules that this module imports, and resolves indexed and
+ * anonymous symbols exported by them.
* @param crs_address the virtual address of the static module
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
*/
@@ -667,7 +688,8 @@ private:
ResultCode ResetExportNamedSymbol(CROHelper target);
/**
- * Resolves imported indexed and anonymous symbols in the target module which imports this module.
+ * Resolves imported indexed and anonymous symbols in the target module which imports this
+ * module.
* @param target the module to resolve.
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
*/
diff --git a/src/core/hle/service/ldr_ro/ldr_ro.cpp b/src/core/hle/service/ldr_ro/ldr_ro.cpp
index 8ba73ea8d..ec183d1f5 100644
--- a/src/core/hle/service/ldr_ro/ldr_ro.cpp
+++ b/src/core/hle/service/ldr_ro/ldr_ro.cpp
@@ -5,7 +5,6 @@
#include "common/alignment.h"
#include "common/common_types.h"
#include "common/logging/log.h"
-
#include "core/arm/arm_interface.h"
#include "core/hle/kernel/process.h"
#include "core/hle/kernel/vm_manager.h"
@@ -18,24 +17,33 @@
namespace LDR_RO {
-static const ResultCode ERROR_ALREADY_INITIALIZED = // 0xD9612FF9
- ResultCode(ErrorDescription::AlreadyInitialized, ErrorModule::RO, ErrorSummary::Internal, ErrorLevel::Permanent);
-static const ResultCode ERROR_NOT_INITIALIZED = // 0xD9612FF8
- ResultCode(ErrorDescription::NotInitialized, ErrorModule::RO, ErrorSummary::Internal, ErrorLevel::Permanent);
-static const ResultCode ERROR_BUFFER_TOO_SMALL = // 0xE0E12C1F
- ResultCode(static_cast<ErrorDescription>(31), ErrorModule::RO, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
-static const ResultCode ERROR_MISALIGNED_ADDRESS = // 0xD9012FF1
- ResultCode(ErrorDescription::MisalignedAddress, ErrorModule::RO, ErrorSummary::WrongArgument, ErrorLevel::Permanent);
-static const ResultCode ERROR_MISALIGNED_SIZE = // 0xD9012FF2
- ResultCode(ErrorDescription::MisalignedSize, ErrorModule::RO, ErrorSummary::WrongArgument, ErrorLevel::Permanent);
-static const ResultCode ERROR_ILLEGAL_ADDRESS = // 0xE1612C0F
- ResultCode(static_cast<ErrorDescription>(15), ErrorModule::RO, ErrorSummary::Internal, ErrorLevel::Usage);
-static const ResultCode ERROR_INVALID_MEMORY_STATE = // 0xD8A12C08
- ResultCode(static_cast<ErrorDescription>(8), ErrorModule::RO, ErrorSummary::InvalidState, ErrorLevel::Permanent);
-static const ResultCode ERROR_NOT_LOADED = // 0xD8A12C0D
- ResultCode(static_cast<ErrorDescription>(13), ErrorModule::RO, ErrorSummary::InvalidState, ErrorLevel::Permanent);
-static const ResultCode ERROR_INVALID_DESCRIPTOR = // 0xD9001830
- ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS, ErrorSummary::WrongArgument, ErrorLevel::Permanent);
+static const ResultCode ERROR_ALREADY_INITIALIZED = // 0xD9612FF9
+ ResultCode(ErrorDescription::AlreadyInitialized, ErrorModule::RO, ErrorSummary::Internal,
+ ErrorLevel::Permanent);
+static const ResultCode ERROR_NOT_INITIALIZED = // 0xD9612FF8
+ ResultCode(ErrorDescription::NotInitialized, ErrorModule::RO, ErrorSummary::Internal,
+ ErrorLevel::Permanent);
+static const ResultCode ERROR_BUFFER_TOO_SMALL = // 0xE0E12C1F
+ ResultCode(static_cast<ErrorDescription>(31), ErrorModule::RO, ErrorSummary::InvalidArgument,
+ ErrorLevel::Usage);
+static const ResultCode ERROR_MISALIGNED_ADDRESS = // 0xD9012FF1
+ ResultCode(ErrorDescription::MisalignedAddress, ErrorModule::RO, ErrorSummary::WrongArgument,
+ ErrorLevel::Permanent);
+static const ResultCode ERROR_MISALIGNED_SIZE = // 0xD9012FF2
+ ResultCode(ErrorDescription::MisalignedSize, ErrorModule::RO, ErrorSummary::WrongArgument,
+ ErrorLevel::Permanent);
+static const ResultCode ERROR_ILLEGAL_ADDRESS = // 0xE1612C0F
+ ResultCode(static_cast<ErrorDescription>(15), ErrorModule::RO, ErrorSummary::Internal,
+ ErrorLevel::Usage);
+static const ResultCode ERROR_INVALID_MEMORY_STATE = // 0xD8A12C08
+ ResultCode(static_cast<ErrorDescription>(8), ErrorModule::RO, ErrorSummary::InvalidState,
+ ErrorLevel::Permanent);
+static const ResultCode ERROR_NOT_LOADED = // 0xD8A12C0D
+ ResultCode(static_cast<ErrorDescription>(13), ErrorModule::RO, ErrorSummary::InvalidState,
+ ErrorLevel::Permanent);
+static const ResultCode ERROR_INVALID_DESCRIPTOR = // 0xD9001830
+ ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS,
+ ErrorSummary::WrongArgument, ErrorLevel::Permanent);
static MemorySynchronizer memory_synchronizer;
@@ -44,10 +52,10 @@ static VAddr loaded_crs; ///< the virtual address of the static module
static bool VerifyBufferState(VAddr buffer_ptr, u32 size) {
auto vma = Kernel::g_current_process->vm_manager.FindVMA(buffer_ptr);
- return vma != Kernel::g_current_process->vm_manager.vma_map.end()
- && vma->second.base + vma->second.size >= buffer_ptr + size
- && vma->second.permissions == Kernel::VMAPermission::ReadWrite
- && vma->second.meminfo_state == Kernel::MemoryState::Private;
+ return vma != Kernel::g_current_process->vm_manager.vma_map.end() &&
+ vma->second.base + vma->second.size >= buffer_ptr + size &&
+ vma->second.permissions == Kernel::VMAPermission::ReadWrite &&
+ vma->second.meminfo_state == Kernel::MemoryState::Private;
}
/**
@@ -66,13 +74,14 @@ static bool VerifyBufferState(VAddr buffer_ptr, u32 size) {
static void Initialize(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
VAddr crs_buffer_ptr = cmd_buff[1];
- u32 crs_size = cmd_buff[2];
- VAddr crs_address = cmd_buff[3];
- u32 descriptor = cmd_buff[4];
- u32 process = cmd_buff[5];
+ u32 crs_size = cmd_buff[2];
+ VAddr crs_address = cmd_buff[3];
+ u32 descriptor = cmd_buff[4];
+ u32 process = cmd_buff[5];
- LOG_DEBUG(Service_LDR, "called, crs_buffer_ptr=0x%08X, crs_address=0x%08X, crs_size=0x%X, descriptor=0x%08X, process=0x%08X",
- crs_buffer_ptr, crs_address, crs_size, descriptor, process);
+ LOG_DEBUG(Service_LDR, "called, crs_buffer_ptr=0x%08X, crs_address=0x%08X, crs_size=0x%X, "
+ "descriptor=0x%08X, process=0x%08X",
+ crs_buffer_ptr, crs_address, crs_size, descriptor, process);
if (descriptor != 0) {
LOG_ERROR(Service_LDR, "IPC handle descriptor failed validation (0x%X)", descriptor);
@@ -119,7 +128,8 @@ static void Initialize(Service::Interface* self) {
return;
}
- if (crs_address < Memory::PROCESS_IMAGE_VADDR || crs_address + crs_size > Memory::PROCESS_IMAGE_VADDR_END) {
+ if (crs_address < Memory::PROCESS_IMAGE_VADDR ||
+ crs_address + crs_size > Memory::PROCESS_IMAGE_VADDR_END) {
LOG_ERROR(Service_LDR, "CRS mapping address is not in the process image region");
cmd_buff[1] = ERROR_ILLEGAL_ADDRESS.raw;
return;
@@ -131,14 +141,17 @@ static void Initialize(Service::Interface* self) {
// TODO(wwylele): should be memory aliasing
std::shared_ptr<std::vector<u8>> crs_mem = std::make_shared<std::vector<u8>>(crs_size);
Memory::ReadBlock(crs_buffer_ptr, crs_mem->data(), crs_size);
- result = Kernel::g_current_process->vm_manager.MapMemoryBlock(crs_address, crs_mem, 0, crs_size, Kernel::MemoryState::Code).Code();
+ result = Kernel::g_current_process->vm_manager
+ .MapMemoryBlock(crs_address, crs_mem, 0, crs_size, Kernel::MemoryState::Code)
+ .Code();
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error mapping memory block %08X", result.raw);
cmd_buff[1] = result.raw;
return;
}
- result = Kernel::g_current_process->vm_manager.ReprotectRange(crs_address, crs_size, Kernel::VMAPermission::Read);
+ result = Kernel::g_current_process->vm_manager.ReprotectRange(crs_address, crs_size,
+ Kernel::VMAPermission::Read);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error reprotecting memory block %08X", result.raw);
cmd_buff[1] = result.raw;
@@ -186,9 +199,9 @@ static void Initialize(Service::Interface* self) {
static void LoadCRR(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 crr_buffer_ptr = cmd_buff[1];
- u32 crr_size = cmd_buff[2];
- u32 descriptor = cmd_buff[3];
- u32 process = cmd_buff[4];
+ u32 crr_size = cmd_buff[2];
+ u32 descriptor = cmd_buff[3];
+ u32 process = cmd_buff[4];
if (descriptor != 0) {
LOG_ERROR(Service_LDR, "IPC handle descriptor failed validation (0x%X)", descriptor);
@@ -200,7 +213,8 @@ static void LoadCRR(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(2, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- LOG_WARNING(Service_LDR, "(STUBBED) called, crr_buffer_ptr=0x%08X, crr_size=0x%08X, descriptor=0x%08X, process=0x%08X",
+ LOG_WARNING(Service_LDR, "(STUBBED) called, crr_buffer_ptr=0x%08X, crr_size=0x%08X, "
+ "descriptor=0x%08X, process=0x%08X",
crr_buffer_ptr, crr_size, descriptor, process);
}
@@ -218,8 +232,8 @@ static void LoadCRR(Service::Interface* self) {
static void UnloadCRR(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 crr_buffer_ptr = cmd_buff[1];
- u32 descriptor = cmd_buff[2];
- u32 process = cmd_buff[3];
+ u32 descriptor = cmd_buff[2];
+ u32 process = cmd_buff[3];
if (descriptor != 0) {
LOG_ERROR(Service_LDR, "IPC handle descriptor failed validation (0x%X)", descriptor);
@@ -231,7 +245,8 @@ static void UnloadCRR(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(3, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- LOG_WARNING(Service_LDR, "(STUBBED) called, crr_buffer_ptr=0x%08X, descriptor=0x%08X, process=0x%08X",
+ LOG_WARNING(Service_LDR,
+ "(STUBBED) called, crr_buffer_ptr=0x%08X, descriptor=0x%08X, process=0x%08X",
crr_buffer_ptr, descriptor, process);
}
@@ -263,27 +278,28 @@ static void UnloadCRR(Service::Interface* self) {
*/
static void LoadCRO(Service::Interface* self, bool link_on_load_bug_fix) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- VAddr cro_buffer_ptr = cmd_buff[1];
- VAddr cro_address = cmd_buff[2];
- u32 cro_size = cmd_buff[3];
+ VAddr cro_buffer_ptr = cmd_buff[1];
+ VAddr cro_address = cmd_buff[2];
+ u32 cro_size = cmd_buff[3];
VAddr data_segment_address = cmd_buff[4];
- u32 zero = cmd_buff[5];
- u32 data_segment_size = cmd_buff[6];
- u32 bss_segment_address = cmd_buff[7];
- u32 bss_segment_size = cmd_buff[8];
- bool auto_link = (cmd_buff[9] & 0xFF) != 0;
- u32 fix_level = cmd_buff[10];
- VAddr crr_address = cmd_buff[11];
- u32 descriptor = cmd_buff[12];
- u32 process = cmd_buff[13];
-
- LOG_DEBUG(Service_LDR, "called (%s), cro_buffer_ptr=0x%08X, cro_address=0x%08X, cro_size=0x%X, "
- "data_segment_address=0x%08X, zero=%d, data_segment_size=0x%X, bss_segment_address=0x%08X, bss_segment_size=0x%X, "
- "auto_link=%s, fix_level=%d, crr_address=0x%08X, descriptor=0x%08X, process=0x%08X",
- link_on_load_bug_fix ? "new" : "old", cro_buffer_ptr, cro_address, cro_size,
- data_segment_address, zero, data_segment_size, bss_segment_address, bss_segment_size,
- auto_link ? "true" : "false", fix_level, crr_address, descriptor, process
- );
+ u32 zero = cmd_buff[5];
+ u32 data_segment_size = cmd_buff[6];
+ u32 bss_segment_address = cmd_buff[7];
+ u32 bss_segment_size = cmd_buff[8];
+ bool auto_link = (cmd_buff[9] & 0xFF) != 0;
+ u32 fix_level = cmd_buff[10];
+ VAddr crr_address = cmd_buff[11];
+ u32 descriptor = cmd_buff[12];
+ u32 process = cmd_buff[13];
+
+ LOG_DEBUG(Service_LDR,
+ "called (%s), cro_buffer_ptr=0x%08X, cro_address=0x%08X, cro_size=0x%X, "
+ "data_segment_address=0x%08X, zero=%d, data_segment_size=0x%X, "
+ "bss_segment_address=0x%08X, bss_segment_size=0x%X, "
+ "auto_link=%s, fix_level=%d, crr_address=0x%08X, descriptor=0x%08X, process=0x%08X",
+ link_on_load_bug_fix ? "new" : "old", cro_buffer_ptr, cro_address, cro_size,
+ data_segment_address, zero, data_segment_size, bss_segment_address, bss_segment_size,
+ auto_link ? "true" : "false", fix_level, crr_address, descriptor, process);
if (descriptor != 0) {
LOG_ERROR(Service_LDR, "IPC handle descriptor failed validation (0x%X)", descriptor);
@@ -330,8 +346,8 @@ static void LoadCRO(Service::Interface* self, bool link_on_load_bug_fix) {
return;
}
- if (cro_address < Memory::PROCESS_IMAGE_VADDR
- || cro_address + cro_size > Memory::PROCESS_IMAGE_VADDR_END) {
+ if (cro_address < Memory::PROCESS_IMAGE_VADDR ||
+ cro_address + cro_size > Memory::PROCESS_IMAGE_VADDR_END) {
LOG_ERROR(Service_LDR, "CRO mapping address is not in the process image region");
cmd_buff[1] = ERROR_ILLEGAL_ADDRESS.raw;
return;
@@ -339,7 +355,9 @@ static void LoadCRO(Service::Interface* self, bool link_on_load_bug_fix) {
if (zero) {
LOG_ERROR(Service_LDR, "Zero is not zero %d", zero);
- cmd_buff[1] = ResultCode(static_cast<ErrorDescription>(29), ErrorModule::RO, ErrorSummary::Internal, ErrorLevel::Usage).raw;
+ cmd_buff[1] = ResultCode(static_cast<ErrorDescription>(29), ErrorModule::RO,
+ ErrorSummary::Internal, ErrorLevel::Usage)
+ .raw;
return;
}
@@ -349,14 +367,17 @@ static void LoadCRO(Service::Interface* self, bool link_on_load_bug_fix) {
// TODO(wwylele): should be memory aliasing
std::shared_ptr<std::vector<u8>> cro_mem = std::make_shared<std::vector<u8>>(cro_size);
Memory::ReadBlock(cro_buffer_ptr, cro_mem->data(), cro_size);
- result = Kernel::g_current_process->vm_manager.MapMemoryBlock(cro_address, cro_mem, 0, cro_size, Kernel::MemoryState::Code).Code();
+ result = Kernel::g_current_process->vm_manager
+ .MapMemoryBlock(cro_address, cro_mem, 0, cro_size, Kernel::MemoryState::Code)
+ .Code();
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error mapping memory block %08X", result.raw);
cmd_buff[1] = result.raw;
return;
}
- result = Kernel::g_current_process->vm_manager.ReprotectRange(cro_address, cro_size, Kernel::VMAPermission::Read);
+ result = Kernel::g_current_process->vm_manager.ReprotectRange(cro_address, cro_size,
+ Kernel::VMAPermission::Read);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error reprotecting memory block %08X", result.raw);
Kernel::g_current_process->vm_manager.UnmapRange(cro_address, cro_size);
@@ -384,7 +405,8 @@ static void LoadCRO(Service::Interface* self, bool link_on_load_bug_fix) {
return;
}
- result = cro.Rebase(loaded_crs, cro_size, data_segment_address, data_segment_size, bss_segment_address, bss_segment_size, false);
+ result = cro.Rebase(loaded_crs, cro_size, data_segment_address, data_segment_size,
+ bss_segment_address, bss_segment_size, false);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error rebasing CRO %08X", result.raw);
Kernel::g_current_process->vm_manager.UnmapRange(cro_address, cro_size);
@@ -409,7 +431,8 @@ static void LoadCRO(Service::Interface* self, bool link_on_load_bug_fix) {
// TODO(wwylele): verify the behaviour when buffer_ptr == address
if (cro_buffer_ptr != cro_address) {
if (fix_size != cro_size) {
- result = Kernel::g_current_process->vm_manager.UnmapRange(cro_address + fix_size, cro_size - fix_size);
+ result = Kernel::g_current_process->vm_manager.UnmapRange(cro_address + fix_size,
+ cro_size - fix_size);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error unmapping memory block %08X", result.raw);
Kernel::g_current_process->vm_manager.UnmapRange(cro_address, cro_size);
@@ -426,7 +449,8 @@ static void LoadCRO(Service::Interface* self, bool link_on_load_bug_fix) {
u32 exe_size;
std::tie(exe_begin, exe_size) = cro.GetExecutablePages();
if (exe_begin) {
- result = Kernel::g_current_process->vm_manager.ReprotectRange(exe_begin, exe_size, Kernel::VMAPermission::ReadExecute);
+ result = Kernel::g_current_process->vm_manager.ReprotectRange(
+ exe_begin, exe_size, Kernel::VMAPermission::ReadExecute);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error reprotecting memory block %08X", result.raw);
Kernel::g_current_process->vm_manager.UnmapRange(cro_address, fix_size);
@@ -437,8 +461,8 @@ static void LoadCRO(Service::Interface* self, bool link_on_load_bug_fix) {
Core::g_app_core->ClearInstructionCache();
- LOG_INFO(Service_LDR, "CRO \"%s\" loaded at 0x%08X, fixed_end=0x%08X",
- cro.ModuleName().data(), cro_address, cro_address+fix_size);
+ LOG_INFO(Service_LDR, "CRO \"%s\" loaded at 0x%08X, fixed_end=0x%08X", cro.ModuleName().data(),
+ cro_address, cro_address + fix_size);
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = fix_size;
@@ -464,14 +488,15 @@ static void LoadCRO(Service::Interface* self) {
*/
static void UnloadCRO(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- VAddr cro_address = cmd_buff[1];
- u32 zero = cmd_buff[2];
- VAddr cro_buffer_ptr = cmd_buff[3];
- u32 descriptor = cmd_buff[4];
- u32 process = cmd_buff[5];
+ VAddr cro_address = cmd_buff[1];
+ u32 zero = cmd_buff[2];
+ VAddr cro_buffer_ptr = cmd_buff[3];
+ u32 descriptor = cmd_buff[4];
+ u32 process = cmd_buff[5];
- LOG_DEBUG(Service_LDR, "called, cro_address=0x%08X, zero=%d, cro_buffer_ptr=0x%08X, descriptor=0x%08X, process=0x%08X",
- cro_address, zero, cro_buffer_ptr, descriptor, process);
+ LOG_DEBUG(Service_LDR, "called, cro_address=0x%08X, zero=%d, cro_buffer_ptr=0x%08X, "
+ "descriptor=0x%08X, process=0x%08X",
+ cro_address, zero, cro_buffer_ptr, descriptor, process);
if (descriptor != 0) {
LOG_ERROR(Service_LDR, "IPC handle descriptor failed validation (0x%X)", descriptor);
@@ -558,11 +583,11 @@ static void UnloadCRO(Service::Interface* self) {
static void LinkCRO(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
VAddr cro_address = cmd_buff[1];
- u32 descriptor = cmd_buff[2];
- u32 process = cmd_buff[3];
+ u32 descriptor = cmd_buff[2];
+ u32 process = cmd_buff[3];
LOG_DEBUG(Service_LDR, "called, cro_address=0x%08X, descriptor=0x%08X, process=0x%08X",
- cro_address, descriptor, process);
+ cro_address, descriptor, process);
if (descriptor != 0) {
LOG_ERROR(Service_LDR, "IPC handle descriptor failed validation (0x%X)", descriptor);
@@ -620,11 +645,11 @@ static void LinkCRO(Service::Interface* self) {
static void UnlinkCRO(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
VAddr cro_address = cmd_buff[1];
- u32 descriptor = cmd_buff[2];
- u32 process = cmd_buff[3];
+ u32 descriptor = cmd_buff[2];
+ u32 process = cmd_buff[3];
LOG_DEBUG(Service_LDR, "called, cro_address=0x%08X, descriptor=0x%08X, process=0x%08X",
- cro_address, descriptor, process);
+ cro_address, descriptor, process);
if (descriptor != 0) {
LOG_ERROR(Service_LDR, "IPC handle descriptor failed validation (0x%X)", descriptor);
@@ -682,11 +707,11 @@ static void UnlinkCRO(Service::Interface* self) {
static void Shutdown(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
VAddr crs_buffer_ptr = cmd_buff[1];
- u32 descriptor = cmd_buff[2];
- u32 process = cmd_buff[3];
+ u32 descriptor = cmd_buff[2];
+ u32 process = cmd_buff[3];
LOG_DEBUG(Service_LDR, "called, crs_buffer_ptr=0x%08X, descriptor=0x%08X, process=0x%08X",
- crs_buffer_ptr, descriptor, process);
+ crs_buffer_ptr, descriptor, process);
if (descriptor != 0) {
LOG_ERROR(Service_LDR, "IPC handle descriptor failed validation (0x%X)", descriptor);
@@ -724,15 +749,17 @@ static void Shutdown(Service::Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
- {0x000100C2, Initialize, "Initialize"},
- {0x00020082, LoadCRR, "LoadCRR"},
- {0x00030042, UnloadCRR, "UnloadCRR"},
- {0x000402C2, LoadCRO<false>, "LoadCRO"},
- {0x000500C2, UnloadCRO, "UnloadCRO"},
- {0x00060042, LinkCRO, "LinkCRO"},
- {0x00070042, UnlinkCRO, "UnlinkCRO"},
- {0x00080042, Shutdown, "Shutdown"},
- {0x000902C2, LoadCRO<true>, "LoadCRO_New"},
+ // clang-format off
+ {0x000100C2, Initialize, "Initialize"},
+ {0x00020082, LoadCRR, "LoadCRR"},
+ {0x00030042, UnloadCRR, "UnloadCRR"},
+ {0x000402C2, LoadCRO<false>, "LoadCRO"},
+ {0x000500C2, UnloadCRO, "UnloadCRO"},
+ {0x00060042, LinkCRO, "LinkCRO"},
+ {0x00070042, UnlinkCRO, "UnlinkCRO"},
+ {0x00080042, Shutdown, "Shutdown"},
+ {0x000902C2, LoadCRO<true>, "LoadCRO_New"},
+ // clang-format on
};
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/ldr_ro/memory_synchronizer.cpp b/src/core/hle/service/ldr_ro/memory_synchronizer.cpp
index 4402876e6..989887264 100644
--- a/src/core/hle/service/ldr_ro/memory_synchronizer.cpp
+++ b/src/core/hle/service/ldr_ro/memory_synchronizer.cpp
@@ -3,9 +3,7 @@
// Refer to the license.txt file included.
#include <algorithm>
-
#include "common/assert.h"
-
#include "core/hle/service/ldr_ro/memory_synchronizer.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -14,9 +12,8 @@
namespace LDR_RO {
auto MemorySynchronizer::FindMemoryBlock(VAddr mapping, VAddr original) {
- auto block = std::find_if(memory_blocks.begin(), memory_blocks.end(), [=](MemoryBlock& b){
- return b.original == original;
- });
+ auto block = std::find_if(memory_blocks.begin(), memory_blocks.end(),
+ [=](MemoryBlock& b) { return b.original == original; });
ASSERT(block->mapping == mapping);
return block;
}
diff --git a/src/core/hle/service/ldr_ro/memory_synchronizer.h b/src/core/hle/service/ldr_ro/memory_synchronizer.h
index 92f267912..883ee4acf 100644
--- a/src/core/hle/service/ldr_ro/memory_synchronizer.h
+++ b/src/core/hle/service/ldr_ro/memory_synchronizer.h
@@ -5,7 +5,6 @@
#pragma once
#include <vector>
-
#include "core/memory.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/mic_u.cpp b/src/core/hle/service/mic_u.cpp
index f792bc9cd..edd1ea97b 100644
--- a/src/core/hle/service/mic_u.cpp
+++ b/src/core/hle/service/mic_u.cpp
@@ -10,22 +10,22 @@
namespace MIC_U {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010042, nullptr, "MapSharedMem"},
- {0x00020000, nullptr, "UnmapSharedMem"},
- {0x00030140, nullptr, "Initialize"},
- {0x00040040, nullptr, "AdjustSampling"},
- {0x00050000, nullptr, "StopSampling"},
- {0x00060000, nullptr, "IsSampling"},
- {0x00070000, nullptr, "GetEventHandle"},
- {0x00080040, nullptr, "SetGain"},
- {0x00090000, nullptr, "GetGain"},
- {0x000A0040, nullptr, "SetPower"},
- {0x000B0000, nullptr, "GetPower"},
- {0x000C0042, nullptr, "size"},
- {0x000D0040, nullptr, "SetClamp"},
- {0x000E0000, nullptr, "GetClamp"},
- {0x000F0040, nullptr, "SetAllowShellClosed"},
- {0x00100040, nullptr, "unknown_input2"},
+ {0x00010042, nullptr, "MapSharedMem"},
+ {0x00020000, nullptr, "UnmapSharedMem"},
+ {0x00030140, nullptr, "Initialize"},
+ {0x00040040, nullptr, "AdjustSampling"},
+ {0x00050000, nullptr, "StopSampling"},
+ {0x00060000, nullptr, "IsSampling"},
+ {0x00070000, nullptr, "GetEventHandle"},
+ {0x00080040, nullptr, "SetGain"},
+ {0x00090000, nullptr, "GetGain"},
+ {0x000A0040, nullptr, "SetPower"},
+ {0x000B0000, nullptr, "GetPower"},
+ {0x000C0042, nullptr, "size"},
+ {0x000D0040, nullptr, "SetClamp"},
+ {0x000E0000, nullptr, "GetClamp"},
+ {0x000F0040, nullptr, "SetAllowShellClosed"},
+ {0x00100040, nullptr, "unknown_input2"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/ndm/ndm.cpp b/src/core/hle/service/ndm/ndm.cpp
index bc9c3413d..5eb97f0d3 100644
--- a/src/core/hle/service/ndm/ndm.cpp
+++ b/src/core/hle/service/ndm/ndm.cpp
@@ -4,21 +4,23 @@
#include "common/common_types.h"
#include "common/logging/log.h"
-#include "core/hle/service/service.h"
#include "core/hle/service/ndm/ndm.h"
#include "core/hle/service/ndm/ndm_u.h"
+#include "core/hle/service/service.h"
namespace Service {
namespace NDM {
enum : u32 {
DEFAULT_RETRY_INTERVAL = 10,
- DEFAULT_SCAN_INTERVAL = 30
+ DEFAULT_SCAN_INTERVAL = 30,
};
static DaemonMask daemon_bit_mask = DaemonMask::Default;
static DaemonMask default_daemon_bit_mask = DaemonMask::Default;
-static std::array<DaemonStatus, 4> daemon_status = { DaemonStatus::Idle, DaemonStatus::Idle, DaemonStatus::Idle, DaemonStatus::Idle };
+static std::array<DaemonStatus, 4> daemon_status = {
+ DaemonStatus::Idle, DaemonStatus::Idle, DaemonStatus::Idle, DaemonStatus::Idle,
+};
static ExclusiveState exclusive_state = ExclusiveState::None;
static u32 scan_interval = DEFAULT_SCAN_INTERVAL;
static u32 retry_interval = DEFAULT_RETRY_INTERVAL;
@@ -72,7 +74,8 @@ void UnlockState(Service::Interface* self) {
void SuspendDaemons(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 bit_mask = cmd_buff[1] & 0xF;
- daemon_bit_mask = static_cast<DaemonMask>(static_cast<u32>(default_daemon_bit_mask) & ~bit_mask);
+ daemon_bit_mask =
+ static_cast<DaemonMask>(static_cast<u32>(default_daemon_bit_mask) & ~bit_mask);
for (size_t index = 0; index < daemon_status.size(); ++index) {
if (bit_mask & (1 << index)) {
daemon_status[index] = DaemonStatus::Suspended;
@@ -228,9 +231,7 @@ void Init() {
AddService(new NDM_U_Interface);
}
-void Shutdown() {
-
-}
+void Shutdown() {}
-}// namespace NDM
-}// namespace Service
+} // namespace NDM
+} // namespace Service
diff --git a/src/core/hle/service/ndm/ndm.h b/src/core/hle/service/ndm/ndm.h
index 5c2b968dc..979e7fcf1 100644
--- a/src/core/hle/service/ndm/ndm.h
+++ b/src/core/hle/service/ndm/ndm.h
@@ -13,35 +13,30 @@ class Interface;
namespace NDM {
enum class Daemon : u32 {
- Cec = 0,
- Boss = 1,
- Nim = 2,
- Friend = 3
+ Cec = 0,
+ Boss = 1,
+ Nim = 2,
+ Friend = 3,
};
enum class DaemonMask : u32 {
- None = 0,
- Cec = (1 << static_cast<u32>(Daemon::Cec)),
- Boss = (1 << static_cast<u32>(Daemon::Boss)),
- Nim = (1 << static_cast<u32>(Daemon::Nim)),
- Friend = (1 << static_cast<u32>(Daemon::Friend)),
+ None = 0,
+ Cec = (1 << static_cast<u32>(Daemon::Cec)),
+ Boss = (1 << static_cast<u32>(Daemon::Boss)),
+ Nim = (1 << static_cast<u32>(Daemon::Nim)),
+ Friend = (1 << static_cast<u32>(Daemon::Friend)),
Default = Cec | Friend,
- All = Cec | Boss | Nim | Friend
+ All = Cec | Boss | Nim | Friend,
};
-enum class DaemonStatus : u32 {
- Busy = 0,
- Idle = 1,
- Suspending = 2,
- Suspended = 3
-};
+enum class DaemonStatus : u32 { Busy = 0, Idle = 1, Suspending = 2, Suspended = 3 };
enum class ExclusiveState : u32 {
- None = 0,
- Infrastructure = 1,
+ None = 0,
+ Infrastructure = 1,
LocalCommunications = 2,
- Streetpass = 3,
- StreetpassData = 4,
+ Streetpass = 3,
+ StreetpassData = 4,
};
/**
@@ -205,7 +200,6 @@ void SetRetryInterval(Service::Interface* self);
*/
void GetRetryInterval(Service::Interface* self);
-
/**
* NDM::OverrideDefaultDaemons service function
* Inputs:
@@ -233,7 +227,8 @@ void ResetDefaultDaemons(Service::Interface* self);
* 1 : Result, 0 on success, otherwise error code
* 2 : Daemon bit mask
* Note:
- * Gets the current default daemon bit mask. The default value is (DAEMONMASK_CEC | DAEMONMASK_FRIENDS)
+ * Gets the current default daemon bit mask. The default value is (DAEMONMASK_CEC |
+ * DAEMONMASK_FRIENDS)
*/
void GetDefaultDaemons(Service::Interface* self);
@@ -252,5 +247,5 @@ void Init();
/// Shutdown NDM service
void Shutdown();
-}// namespace NDM
-}// namespace Service
+} // namespace NDM
+} // namespace Service
diff --git a/src/core/hle/service/ndm/ndm_u.cpp b/src/core/hle/service/ndm/ndm_u.cpp
index 3ff0744ee..f5c7a341a 100644
--- a/src/core/hle/service/ndm/ndm_u.cpp
+++ b/src/core/hle/service/ndm/ndm_u.cpp
@@ -9,28 +9,28 @@ namespace Service {
namespace NDM {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010042, EnterExclusiveState, "EnterExclusiveState"},
- {0x00020002, LeaveExclusiveState, "LeaveExclusiveState"},
- {0x00030000, QueryExclusiveMode, "QueryExclusiveMode"},
- {0x00040002, LockState, "LockState"},
- {0x00050002, UnlockState, "UnlockState"},
- {0x00060040, SuspendDaemons, "SuspendDaemons"},
- {0x00070040, ResumeDaemons, "ResumeDaemons"},
- {0x00080040, SuspendScheduler, "SuspendScheduler"},
- {0x00090000, ResumeScheduler, "ResumeScheduler"},
- {0x000A0000, nullptr, "GetCurrentState"},
- {0x000B0000, nullptr, "GetTargetState"},
- {0x000C0000, nullptr, "<Stubbed>"},
- {0x000D0040, QueryStatus, "QueryStatus"},
- {0x000E0040, GetDaemonDisableCount, "GetDaemonDisableCount"},
- {0x000F0000, GetSchedulerDisableCount,"GetSchedulerDisableCount"},
- {0x00100040, SetScanInterval, "SetScanInterval"},
- {0x00110000, GetScanInterval, "GetScanInterval"},
- {0x00120040, SetRetryInterval, "SetRetryInterval"},
- {0x00130000, GetRetryInterval, "GetRetryInterval"},
- {0x00140040, OverrideDefaultDaemons, "OverrideDefaultDaemons"},
- {0x00150000, ResetDefaultDaemons, "ResetDefaultDaemons"},
- {0x00160000, GetDefaultDaemons, "GetDefaultDaemons"},
+ {0x00010042, EnterExclusiveState, "EnterExclusiveState"},
+ {0x00020002, LeaveExclusiveState, "LeaveExclusiveState"},
+ {0x00030000, QueryExclusiveMode, "QueryExclusiveMode"},
+ {0x00040002, LockState, "LockState"},
+ {0x00050002, UnlockState, "UnlockState"},
+ {0x00060040, SuspendDaemons, "SuspendDaemons"},
+ {0x00070040, ResumeDaemons, "ResumeDaemons"},
+ {0x00080040, SuspendScheduler, "SuspendScheduler"},
+ {0x00090000, ResumeScheduler, "ResumeScheduler"},
+ {0x000A0000, nullptr, "GetCurrentState"},
+ {0x000B0000, nullptr, "GetTargetState"},
+ {0x000C0000, nullptr, "<Stubbed>"},
+ {0x000D0040, QueryStatus, "QueryStatus"},
+ {0x000E0040, GetDaemonDisableCount, "GetDaemonDisableCount"},
+ {0x000F0000, GetSchedulerDisableCount, "GetSchedulerDisableCount"},
+ {0x00100040, SetScanInterval, "SetScanInterval"},
+ {0x00110000, GetScanInterval, "GetScanInterval"},
+ {0x00120040, SetRetryInterval, "SetRetryInterval"},
+ {0x00130000, GetRetryInterval, "GetRetryInterval"},
+ {0x00140040, OverrideDefaultDaemons, "OverrideDefaultDaemons"},
+ {0x00150000, ResetDefaultDaemons, "ResetDefaultDaemons"},
+ {0x00160000, GetDefaultDaemons, "GetDefaultDaemons"},
{0x00170000, ClearHalfAwakeMacFilter, "ClearHalfAwakeMacFilter"},
};
diff --git a/src/core/hle/service/news/news.cpp b/src/core/hle/service/news/news.cpp
index b3f500694..8b70ec45b 100644
--- a/src/core/hle/service/news/news.cpp
+++ b/src/core/hle/service/news/news.cpp
@@ -3,11 +3,10 @@
// Refer to the license.txt file included.
#include "common/logging/log.h"
-
-#include "core/hle/service/service.h"
#include "core/hle/service/news/news.h"
#include "core/hle/service/news/news_s.h"
#include "core/hle/service/news/news_u.h"
+#include "core/hle/service/service.h"
namespace Service {
namespace NEWS {
@@ -19,8 +18,7 @@ void Init() {
AddService(new NEWS_U_Interface);
}
-void Shutdown() {
-}
+void Shutdown() {}
} // namespace NEWS
diff --git a/src/core/hle/service/news/news_s.cpp b/src/core/hle/service/news/news_s.cpp
index 39b5a50f8..dda3d0f6a 100644
--- a/src/core/hle/service/news/news_s.cpp
+++ b/src/core/hle/service/news/news_s.cpp
@@ -9,19 +9,19 @@ namespace Service {
namespace NEWS {
const Interface::FunctionInfo FunctionTable[] = {
- {0x000100C6, nullptr, "AddNotification"},
- {0x00050000, nullptr, "GetTotalNotifications"},
- {0x00060042, nullptr, "SetNewsDBHeader"},
- {0x00070082, nullptr, "SetNotificationHeader"},
- {0x00080082, nullptr, "SetNotificationMessage"},
- {0x00090082, nullptr, "SetNotificationImage"},
- {0x000A0042, nullptr, "GetNewsDBHeader"},
- {0x000B0082, nullptr, "GetNotificationHeader"},
- {0x000C0082, nullptr, "GetNotificationMessage"},
- {0x000D0082, nullptr, "GetNotificationImage"},
- {0x000E0040, nullptr, "SetInfoLEDPattern"},
- {0x00120082, nullptr, "GetNotificationHeaderOther"},
- {0x00130000, nullptr, "WriteNewsDBSavedata"},
+ {0x000100C6, nullptr, "AddNotification"},
+ {0x00050000, nullptr, "GetTotalNotifications"},
+ {0x00060042, nullptr, "SetNewsDBHeader"},
+ {0x00070082, nullptr, "SetNotificationHeader"},
+ {0x00080082, nullptr, "SetNotificationMessage"},
+ {0x00090082, nullptr, "SetNotificationImage"},
+ {0x000A0042, nullptr, "GetNewsDBHeader"},
+ {0x000B0082, nullptr, "GetNotificationHeader"},
+ {0x000C0082, nullptr, "GetNotificationMessage"},
+ {0x000D0082, nullptr, "GetNotificationImage"},
+ {0x000E0040, nullptr, "SetInfoLEDPattern"},
+ {0x00120082, nullptr, "GetNotificationHeaderOther"},
+ {0x00130000, nullptr, "WriteNewsDBSavedata"},
};
NEWS_S_Interface::NEWS_S_Interface() {
diff --git a/src/core/hle/service/news/news_u.cpp b/src/core/hle/service/news/news_u.cpp
index 6b75cc24e..a07e466de 100644
--- a/src/core/hle/service/news/news_u.cpp
+++ b/src/core/hle/service/news/news_u.cpp
@@ -8,7 +8,7 @@ namespace Service {
namespace NEWS {
const Interface::FunctionInfo FunctionTable[] = {
- {0x000100C6, nullptr, "AddNotification"},
+ {0x000100C6, nullptr, "AddNotification"},
};
NEWS_U_Interface::NEWS_U_Interface() {
diff --git a/src/core/hle/service/nim/nim.cpp b/src/core/hle/service/nim/nim.cpp
index ed42464ce..0be94322c 100644
--- a/src/core/hle/service/nim/nim.cpp
+++ b/src/core/hle/service/nim/nim.cpp
@@ -4,12 +4,11 @@
#include "common/common_types.h"
#include "common/logging/log.h"
-
-#include "core/hle/service/service.h"
#include "core/hle/service/nim/nim.h"
#include "core/hle/service/nim/nim_aoc.h"
#include "core/hle/service/nim/nim_s.h"
#include "core/hle/service/nim/nim_u.h"
+#include "core/hle/service/service.h"
namespace Service {
namespace NIM {
@@ -31,8 +30,7 @@ void Init() {
AddService(new NIM_U_Interface);
}
-void Shutdown() {
-}
+void Shutdown() {}
} // namespace NIM
diff --git a/src/core/hle/service/nim/nim_aoc.cpp b/src/core/hle/service/nim/nim_aoc.cpp
index 4a4818d57..2d0fb6fc4 100644
--- a/src/core/hle/service/nim/nim_aoc.cpp
+++ b/src/core/hle/service/nim/nim_aoc.cpp
@@ -8,14 +8,14 @@ namespace Service {
namespace NIM {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00030042, nullptr, "SetApplicationId"},
- {0x00040042, nullptr, "SetTin"},
- {0x000902D0, nullptr, "ListContentSetsEx"},
- {0x00180000, nullptr, "GetBalance"},
- {0x001D0000, nullptr, "GetCustomerSupportCode"},
- {0x00210000, nullptr, "Initialize"},
- {0x00240282, nullptr, "CalculateContentsRequiredSize"},
- {0x00250000, nullptr, "RefreshServerTime"},
+ {0x00030042, nullptr, "SetApplicationId"},
+ {0x00040042, nullptr, "SetTin"},
+ {0x000902D0, nullptr, "ListContentSetsEx"},
+ {0x00180000, nullptr, "GetBalance"},
+ {0x001D0000, nullptr, "GetCustomerSupportCode"},
+ {0x00210000, nullptr, "Initialize"},
+ {0x00240282, nullptr, "CalculateContentsRequiredSize"},
+ {0x00250000, nullptr, "RefreshServerTime"},
};
NIM_AOC_Interface::NIM_AOC_Interface() {
diff --git a/src/core/hle/service/nim/nim_s.cpp b/src/core/hle/service/nim/nim_s.cpp
index dcaa0255a..e2ba693c9 100644
--- a/src/core/hle/service/nim/nim_s.cpp
+++ b/src/core/hle/service/nim/nim_s.cpp
@@ -8,10 +8,10 @@ namespace Service {
namespace NIM {
const Interface::FunctionInfo FunctionTable[] = {
- {0x000A0000, nullptr, "CheckSysupdateAvailableSOAP"},
- {0x0016020A, nullptr, "ListTitles"},
- {0x002D0042, nullptr, "DownloadTickets"},
- {0x00420240, nullptr, "StartDownload"},
+ {0x000A0000, nullptr, "CheckSysupdateAvailableSOAP"},
+ {0x0016020A, nullptr, "ListTitles"},
+ {0x002D0042, nullptr, "DownloadTickets"},
+ {0x00420240, nullptr, "StartDownload"},
};
NIM_S_Interface::NIM_S_Interface() {
@@ -20,4 +20,3 @@ NIM_S_Interface::NIM_S_Interface() {
} // namespace NIM
} // namespace Service
-
diff --git a/src/core/hle/service/nim/nim_u.cpp b/src/core/hle/service/nim/nim_u.cpp
index eae45ebc0..7e07d02e8 100644
--- a/src/core/hle/service/nim/nim_u.cpp
+++ b/src/core/hle/service/nim/nim_u.cpp
@@ -9,12 +9,12 @@ namespace Service {
namespace NIM {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010000, nullptr, "StartSysUpdate"},
- {0x00020000, nullptr, "GetUpdateDownloadProgress"},
- {0x00040000, nullptr, "FinishTitlesInstall"},
- {0x00050000, nullptr, "CheckForSysUpdateEvent"},
- {0x00090000, CheckSysUpdateAvailable, "CheckSysUpdateAvailable"},
- {0x000A0000, nullptr, "GetState"},
+ {0x00010000, nullptr, "StartSysUpdate"},
+ {0x00020000, nullptr, "GetUpdateDownloadProgress"},
+ {0x00040000, nullptr, "FinishTitlesInstall"},
+ {0x00050000, nullptr, "CheckForSysUpdateEvent"},
+ {0x00090000, CheckSysUpdateAvailable, "CheckSysUpdateAvailable"},
+ {0x000A0000, nullptr, "GetState"},
};
NIM_U_Interface::NIM_U_Interface() {
@@ -23,4 +23,3 @@ NIM_U_Interface::NIM_U_Interface() {
} // namespace NIM
} // namespace Service
-
diff --git a/src/core/hle/service/nim/nim_u.h b/src/core/hle/service/nim/nim_u.h
index bc89dc0f3..c4b74985a 100644
--- a/src/core/hle/service/nim/nim_u.h
+++ b/src/core/hle/service/nim/nim_u.h
@@ -1,6 +1,6 @@
// Copyright 2015 Citra Emulator Project
// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included..
+// Refer to the license.txt file included.
#pragma once
diff --git a/src/core/hle/service/ns_s.cpp b/src/core/hle/service/ns_s.cpp
index 072918d62..6693f7c08 100644
--- a/src/core/hle/service/ns_s.cpp
+++ b/src/core/hle/service/ns_s.cpp
@@ -10,21 +10,21 @@
namespace NS_S {
const Interface::FunctionInfo FunctionTable[] = {
- {0x000100C0, nullptr, "LaunchFIRM"},
- {0x000200C0, nullptr, "LaunchTitle"},
- {0x00030000, nullptr, "TerminateApplication"},
- {0x00040040, nullptr, "TerminateProcess"},
- {0x000500C0, nullptr, "LaunchApplicationFIRM"},
- {0x00060042, nullptr, "SetFIRMParams4A0"},
- {0x00070042, nullptr, "CardUpdateInitialize"},
- {0x00080000, nullptr, "CardUpdateShutdown"},
- {0x000D0140, nullptr, "SetTWLBannerHMAC"},
- {0x000E0000, nullptr, "ShutdownAsync"},
- {0x00100180, nullptr, "RebootSystem"},
- {0x00110100, nullptr, "TerminateTitle"},
- {0x001200C0, nullptr, "SetApplicationCpuTimeLimit"},
- {0x00150140, nullptr, "LaunchApplication"},
- {0x00160000, nullptr, "RebootSystemClean"},
+ {0x000100C0, nullptr, "LaunchFIRM"},
+ {0x000200C0, nullptr, "LaunchTitle"},
+ {0x00030000, nullptr, "TerminateApplication"},
+ {0x00040040, nullptr, "TerminateProcess"},
+ {0x000500C0, nullptr, "LaunchApplicationFIRM"},
+ {0x00060042, nullptr, "SetFIRMParams4A0"},
+ {0x00070042, nullptr, "CardUpdateInitialize"},
+ {0x00080000, nullptr, "CardUpdateShutdown"},
+ {0x000D0140, nullptr, "SetTWLBannerHMAC"},
+ {0x000E0000, nullptr, "ShutdownAsync"},
+ {0x00100180, nullptr, "RebootSystem"},
+ {0x00110100, nullptr, "TerminateTitle"},
+ {0x001200C0, nullptr, "SetApplicationCpuTimeLimit"},
+ {0x00150140, nullptr, "LaunchApplication"},
+ {0x00160000, nullptr, "RebootSystemClean"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/nwm_uds.cpp b/src/core/hle/service/nwm_uds.cpp
index ae4640409..27e829209 100644
--- a/src/core/hle/service/nwm_uds.cpp
+++ b/src/core/hle/service/nwm_uds.cpp
@@ -4,7 +4,6 @@
#include "common/common_types.h"
#include "common/logging/log.h"
-
#include "core/hle/kernel/event.h"
#include "core/hle/service/nwm_uds.h"
@@ -54,22 +53,23 @@ static void Shutdown(Service::Interface* self) {
static void RecvBeaconBroadcastData(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 out_buffer_size = cmd_buff[1];
- u32 unk1 = cmd_buff[2];
- u32 unk2 = cmd_buff[3];
- u32 mac_address = cmd_buff[4];
+ u32 unk1 = cmd_buff[2];
+ u32 unk2 = cmd_buff[3];
+ u32 mac_address = cmd_buff[4];
- u32 unk3 = cmd_buff[6];
+ u32 unk3 = cmd_buff[6];
- u32 wlan_comm_id = cmd_buff[15];
- u32 ctr_gen_id = cmd_buff[16];
- u32 value = cmd_buff[17];
- u32 input_handle = cmd_buff[18];
+ u32 wlan_comm_id = cmd_buff[15];
+ u32 ctr_gen_id = cmd_buff[16];
+ u32 value = cmd_buff[17];
+ u32 input_handle = cmd_buff[18];
u32 new_buffer_size = cmd_buff[19];
- u32 out_buffer_ptr = cmd_buff[20];
+ u32 out_buffer_ptr = cmd_buff[20];
cmd_buff[1] = RESULT_SUCCESS.raw;
- LOG_WARNING(Service_NWM, "(STUBBED) called out_buffer_size=0x%08X, unk1=0x%08X, unk2=0x%08X,"
+ LOG_WARNING(Service_NWM,
+ "(STUBBED) called out_buffer_size=0x%08X, unk1=0x%08X, unk2=0x%08X,"
"mac_address=0x%08X, unk3=0x%08X, wlan_comm_id=0x%08X, ctr_gen_id=0x%08X,"
"value=%u, input_handle=0x%08X, new_buffer_size=0x%08X, out_buffer_ptr=0x%08X",
out_buffer_size, unk1, unk2, mac_address, unk3, wlan_comm_id, ctr_gen_id, value,
@@ -92,46 +92,47 @@ static void RecvBeaconBroadcastData(Service::Interface* self) {
*/
static void Initialize(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- u32 unk1 = cmd_buff[1];
- u32 unk2 = cmd_buff[12];
- u32 value = cmd_buff[13];
+ u32 unk1 = cmd_buff[1];
+ u32 unk2 = cmd_buff[12];
+ u32 value = cmd_buff[13];
u32 handle = cmd_buff[14];
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = 0;
- cmd_buff[3] = Kernel::g_handle_table.Create(handle_event).MoveFrom(); //TODO(purpasmart): Verify if this is a event handle
+ cmd_buff[3] = Kernel::g_handle_table.Create(handle_event)
+ .MoveFrom(); // TODO(purpasmart): Verify if this is a event handle
LOG_WARNING(Service_NWM, "(STUBBED) called unk1=0x%08X, unk2=0x%08X, value=%u, handle=0x%08X",
unk1, unk2, value, handle);
}
const Interface::FunctionInfo FunctionTable[] = {
- {0x00020000, nullptr, "Scrap"},
- {0x00030000, Shutdown, "Shutdown"},
- {0x00040402, nullptr, "CreateNetwork"},
- {0x00050040, nullptr, "EjectClient"},
- {0x00060000, nullptr, "EjectSpectator"},
- {0x00070080, nullptr, "UpdateNetworkAttribute"},
- {0x00080000, nullptr, "DestroyNetwork"},
- {0x000A0000, nullptr, "DisconnectNetwork"},
- {0x000B0000, nullptr, "GetConnectionStatus"},
- {0x000D0040, nullptr, "GetNodeInformation"},
- {0x000F0404, RecvBeaconBroadcastData, "RecvBeaconBroadcastData"},
- {0x00100042, nullptr, "SetBeaconAdditionalData"},
- {0x00110040, nullptr, "GetApplicationData"},
- {0x00120100, nullptr, "Bind"},
- {0x00130040, nullptr, "Unbind"},
- {0x001400C0, nullptr, "RecvBroadcastDataFrame"},
- {0x00150080, nullptr, "SetMaxSendDelay"},
- {0x00170182, nullptr, "SendTo"},
- {0x001A0000, nullptr, "GetChannel"},
- {0x001B0302, Initialize, "Initialize"},
- {0x001D0044, nullptr, "BeginHostingNetwork"},
- {0x001E0084, nullptr, "ConnectToNetwork"},
- {0x001F0006, nullptr, "DecryptBeaconData"},
- {0x00200040, nullptr, "Flush"},
- {0x00210080, nullptr, "SetProbeResponseParam"},
- {0x00220402, nullptr, "ScanOnConnection"},
+ {0x00020000, nullptr, "Scrap"},
+ {0x00030000, Shutdown, "Shutdown"},
+ {0x00040402, nullptr, "CreateNetwork"},
+ {0x00050040, nullptr, "EjectClient"},
+ {0x00060000, nullptr, "EjectSpectator"},
+ {0x00070080, nullptr, "UpdateNetworkAttribute"},
+ {0x00080000, nullptr, "DestroyNetwork"},
+ {0x000A0000, nullptr, "DisconnectNetwork"},
+ {0x000B0000, nullptr, "GetConnectionStatus"},
+ {0x000D0040, nullptr, "GetNodeInformation"},
+ {0x000F0404, RecvBeaconBroadcastData, "RecvBeaconBroadcastData"},
+ {0x00100042, nullptr, "SetBeaconAdditionalData"},
+ {0x00110040, nullptr, "GetApplicationData"},
+ {0x00120100, nullptr, "Bind"},
+ {0x00130040, nullptr, "Unbind"},
+ {0x001400C0, nullptr, "RecvBroadcastDataFrame"},
+ {0x00150080, nullptr, "SetMaxSendDelay"},
+ {0x00170182, nullptr, "SendTo"},
+ {0x001A0000, nullptr, "GetChannel"},
+ {0x001B0302, Initialize, "Initialize"},
+ {0x001D0044, nullptr, "BeginHostingNetwork"},
+ {0x001E0084, nullptr, "ConnectToNetwork"},
+ {0x001F0006, nullptr, "DecryptBeaconData"},
+ {0x00200040, nullptr, "Flush"},
+ {0x00210080, nullptr, "SetProbeResponseParam"},
+ {0x00220402, nullptr, "ScanOnConnection"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/pm_app.cpp b/src/core/hle/service/pm_app.cpp
index 05d01bc48..7d91694f6 100644
--- a/src/core/hle/service/pm_app.cpp
+++ b/src/core/hle/service/pm_app.cpp
@@ -10,18 +10,18 @@
namespace PM_APP {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010140, nullptr, "LaunchTitle"},
- {0x00020082, nullptr, "LaunchFIRMSetParams"},
- {0x00030080, nullptr, "TerminateProcesse"},
- {0x00040100, nullptr, "TerminateProcessTID"},
- {0x000500C0, nullptr, "TerminateProcessTID_unknown"},
- {0x00070042, nullptr, "GetFIRMLaunchParams"},
- {0x00080100, nullptr, "GetTitleExheaderFlags"},
- {0x00090042, nullptr, "SetFIRMLaunchParams"},
- {0x000A0140, nullptr, "SetResourceLimit"},
- {0x000B0140, nullptr, "GetResourceLimitMax"},
- {0x000C0080, nullptr, "UnregisterProcess"},
- {0x000D0240, nullptr, "LaunchTitleUpdate"},
+ {0x00010140, nullptr, "LaunchTitle"},
+ {0x00020082, nullptr, "LaunchFIRMSetParams"},
+ {0x00030080, nullptr, "TerminateProcesse"},
+ {0x00040100, nullptr, "TerminateProcessTID"},
+ {0x000500C0, nullptr, "TerminateProcessTID_unknown"},
+ {0x00070042, nullptr, "GetFIRMLaunchParams"},
+ {0x00080100, nullptr, "GetTitleExheaderFlags"},
+ {0x00090042, nullptr, "SetFIRMLaunchParams"},
+ {0x000A0140, nullptr, "SetResourceLimit"},
+ {0x000B0140, nullptr, "GetResourceLimitMax"},
+ {0x000C0080, nullptr, "UnregisterProcess"},
+ {0x000D0240, nullptr, "LaunchTitleUpdate"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp
index e2c17d93b..6e6b63329 100644
--- a/src/core/hle/service/ptm/ptm.cpp
+++ b/src/core/hle/service/ptm/ptm.cpp
@@ -3,7 +3,6 @@
// Refer to the license.txt file included.
#include "common/logging/log.h"
-#include "core/settings.h"
#include "core/file_sys/file_backend.h"
#include "core/hle/service/fs/archive.h"
#include "core/hle/service/ptm/ptm.h"
@@ -11,12 +10,13 @@
#include "core/hle/service/ptm/ptm_sysm.h"
#include "core/hle/service/ptm/ptm_u.h"
#include "core/hle/service/service.h"
+#include "core/settings.h"
namespace Service {
namespace PTM {
/// Values for the default gamecoin.dat file
-static const GameCoin default_game_coin = { 0x4F00, 42, 0, 0, 0, 2014, 12, 29 };
+static const GameCoin default_game_coin = {0x4F00, 42, 0, 0, 0, 2014, 12, 29};
/// Id of the SharedExtData archive used by the PTM process
static const std::vector<u8> ptm_shared_extdata_id = {0, 0, 0, 0, 0x0B, 0, 0, 0xF0, 0, 0, 0, 0};
@@ -51,7 +51,8 @@ void GetBatteryLevel(Service::Interface* self) {
// it returns a valid result without implementing full functionality.
cmd_buff[1] = RESULT_SUCCESS.raw;
- cmd_buff[2] = static_cast<u32>(ChargeLevels::CompletelyFull); // Set to a completely full battery
+ cmd_buff[2] =
+ static_cast<u32>(ChargeLevels::CompletelyFull); // Set to a completely full battery
LOG_WARNING(Service_PTM, "(STUBBED) called");
}
@@ -94,7 +95,8 @@ void CheckNew3DS(Service::Interface* self) {
const bool is_new_3ds = Settings::values.is_new_3ds;
if (is_new_3ds) {
- LOG_CRITICAL(Service_PTM, "The option 'is_new_3ds' is enabled as part of the 'System' settings. Citra does not fully support New 3DS emulation yet!");
+ LOG_CRITICAL(Service_PTM, "The option 'is_new_3ds' is enabled as part of the 'System' "
+ "settings. Citra does not fully support New 3DS emulation yet!");
}
cmd_buff[1] = RESULT_SUCCESS.raw;
@@ -111,15 +113,19 @@ void Init() {
shell_open = true;
battery_is_charging = true;
- // Open the SharedExtSaveData archive 0xF000000B and create the gamecoin.dat file if it doesn't exist
+ // Open the SharedExtSaveData archive 0xF000000B and create the gamecoin.dat file if it doesn't
+ // exist
FileSys::Path archive_path(ptm_shared_extdata_id);
- auto archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
+ auto archive_result =
+ Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
// If the archive didn't exist, create the files inside
if (archive_result.Code().description == ErrorDescription::FS_NotFormatted) {
// Format the archive to create the directories
- Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, FileSys::ArchiveFormatInfo(), archive_path);
+ Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SharedExtSaveData,
+ FileSys::ArchiveFormatInfo(), archive_path);
// Open it again to get a valid archive now that the folder exists
- archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
+ archive_result =
+ Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
ASSERT_MSG(archive_result.Succeeded(), "Could not open the PTM SharedExtSaveData archive!");
FileSys::Path gamecoin_path("gamecoin.dat");
@@ -127,18 +133,18 @@ void Init() {
open_mode.write_flag.Assign(1);
open_mode.create_flag.Assign(1);
// Open the file and write the default gamecoin information
- auto gamecoin_result = Service::FS::OpenFileFromArchive(*archive_result, gamecoin_path, open_mode);
+ auto gamecoin_result =
+ Service::FS::OpenFileFromArchive(*archive_result, gamecoin_path, open_mode);
if (gamecoin_result.Succeeded()) {
auto gamecoin = gamecoin_result.MoveFrom();
- gamecoin->backend->Write(0, sizeof(GameCoin), 1, reinterpret_cast<const u8*>(&default_game_coin));
+ gamecoin->backend->Write(0, sizeof(GameCoin), 1,
+ reinterpret_cast<const u8*>(&default_game_coin));
gamecoin->backend->Close();
}
}
}
-void Shutdown() {
-
-}
+void Shutdown() {}
} // namespace PTM
} // namespace Service
diff --git a/src/core/hle/service/ptm/ptm.h b/src/core/hle/service/ptm/ptm.h
index 7ef8877c7..6e163a6f9 100644
--- a/src/core/hle/service/ptm/ptm.h
+++ b/src/core/hle/service/ptm/ptm.h
@@ -14,23 +14,24 @@ namespace PTM {
/// Charge levels used by PTM functions
enum class ChargeLevels : u32 {
- CriticalBattery = 1,
- LowBattery = 2,
- HalfFull = 3,
- MostlyFull = 4,
- CompletelyFull = 5,
+ CriticalBattery = 1,
+ LowBattery = 2,
+ HalfFull = 3,
+ MostlyFull = 4,
+ CompletelyFull = 5,
};
/**
* Represents the gamecoin file structure in the SharedExtData archive
- * More information in 3dbrew (http://www.3dbrew.org/wiki/Extdata#Shared_Extdata_0xf000000b_gamecoin.dat)
+ * More information in 3dbrew
+ * (http://www.3dbrew.org/wiki/Extdata#Shared_Extdata_0xf000000b_gamecoin.dat)
*/
struct GameCoin {
- u32 magic; ///< Magic number: 0x4F00
- u16 total_coins; ///< Total Play Coins
+ u32 magic; ///< Magic number: 0x4F00
+ u16 total_coins; ///< Total Play Coins
u16 total_coins_on_date; ///< Total Play Coins obtained on the date stored below.
- u32 step_count; ///< Total step count at the time a new Play Coin was obtained.
- u32 last_step_count; ///< Step count for the day the last Play Coin was obtained
+ u32 step_count; ///< Total step count at the time a new Play Coin was obtained.
+ u32 last_step_count; ///< Step count for the day the last Play Coin was obtained
u16 year;
u8 month;
u8 day;
diff --git a/src/core/hle/service/ptm/ptm_play.cpp b/src/core/hle/service/ptm/ptm_play.cpp
index ca5dd0403..2e0c6e1a3 100644
--- a/src/core/hle/service/ptm/ptm_play.cpp
+++ b/src/core/hle/service/ptm/ptm_play.cpp
@@ -8,10 +8,10 @@ namespace Service {
namespace PTM {
const Interface::FunctionInfo FunctionTable[] = {
- {0x08070082, nullptr, "GetPlayHistory"},
- {0x08080000, nullptr, "GetPlayHistoryStart"},
- {0x08090000, nullptr, "GetPlayHistoryLength"},
- {0x080B0080, nullptr, "CalcPlayHistoryStart"},
+ {0x08070082, nullptr, "GetPlayHistory"},
+ {0x08080000, nullptr, "GetPlayHistoryStart"},
+ {0x08090000, nullptr, "GetPlayHistoryLength"},
+ {0x080B0080, nullptr, "CalcPlayHistoryStart"},
};
PTM_Play_Interface::PTM_Play_Interface() {
diff --git a/src/core/hle/service/ptm/ptm_play.h b/src/core/hle/service/ptm/ptm_play.h
index e5c3e04df..47f229581 100644
--- a/src/core/hle/service/ptm/ptm_play.h
+++ b/src/core/hle/service/ptm/ptm_play.h
@@ -13,9 +13,9 @@ class PTM_Play_Interface : public Service::Interface {
public:
PTM_Play_Interface();
-std::string GetPortName() const override {
- return "ptm:play";
-}
+ std::string GetPortName() const override {
+ return "ptm:play";
+ }
};
} // namespace PTM
diff --git a/src/core/hle/service/ptm/ptm_sysm.cpp b/src/core/hle/service/ptm/ptm_sysm.cpp
index cc4ef1101..693158dbf 100644
--- a/src/core/hle/service/ptm/ptm_sysm.cpp
+++ b/src/core/hle/service/ptm/ptm_sysm.cpp
@@ -9,37 +9,37 @@ namespace Service {
namespace PTM {
const Interface::FunctionInfo FunctionTable[] = {
- {0x040100C0, nullptr, "SetRtcAlarmEx"},
- {0x04020042, nullptr, "ReplySleepQuery"},
- {0x04030042, nullptr, "NotifySleepPreparationComplete"},
- {0x04040102, nullptr, "SetWakeupTrigger"},
- {0x04050000, nullptr, "GetAwakeReason"},
- {0x04060000, nullptr, "RequestSleep"},
- {0x040700C0, nullptr, "ShutdownAsync"},
- {0x04080000, nullptr, "Awake"},
- {0x04090080, nullptr, "RebootAsync"},
- {0x040A0000, CheckNew3DS, "CheckNew3DS"},
- {0x08010640, nullptr, "SetInfoLEDPattern"},
- {0x08020040, nullptr, "SetInfoLEDPatternHeader"},
- {0x08030000, nullptr, "GetInfoLEDStatus"},
- {0x08040040, nullptr, "SetBatteryEmptyLEDPattern"},
- {0x08050000, nullptr, "ClearStepHistory"},
- {0x080600C2, nullptr, "SetStepHistory"},
- {0x08070082, nullptr, "GetPlayHistory"},
- {0x08080000, nullptr, "GetPlayHistoryStart"},
- {0x08090000, nullptr, "GetPlayHistoryLength"},
- {0x080A0000, nullptr, "ClearPlayHistory"},
- {0x080B0080, nullptr, "CalcPlayHistoryStart"},
- {0x080C0080, nullptr, "SetUserTime"},
- {0x080D0000, nullptr, "InvalidateSystemTime"},
- {0x080E0140, nullptr, "NotifyPlayEvent"},
- {0x080F0000, IsLegacyPowerOff, "IsLegacyPowerOff"},
- {0x08100000, nullptr, "ClearLegacyPowerOff"},
- {0x08110000, GetShellState, "GetShellState"},
- {0x08120000, nullptr, "IsShutdownByBatteryEmpty"},
- {0x08130000, nullptr, "FormatSavedata"},
- {0x08140000, nullptr, "GetLegacyJumpProhibitedFlag"},
- {0x08180040, nullptr, "ConfigureNew3DSCPU"},
+ {0x040100C0, nullptr, "SetRtcAlarmEx"},
+ {0x04020042, nullptr, "ReplySleepQuery"},
+ {0x04030042, nullptr, "NotifySleepPreparationComplete"},
+ {0x04040102, nullptr, "SetWakeupTrigger"},
+ {0x04050000, nullptr, "GetAwakeReason"},
+ {0x04060000, nullptr, "RequestSleep"},
+ {0x040700C0, nullptr, "ShutdownAsync"},
+ {0x04080000, nullptr, "Awake"},
+ {0x04090080, nullptr, "RebootAsync"},
+ {0x040A0000, CheckNew3DS, "CheckNew3DS"},
+ {0x08010640, nullptr, "SetInfoLEDPattern"},
+ {0x08020040, nullptr, "SetInfoLEDPatternHeader"},
+ {0x08030000, nullptr, "GetInfoLEDStatus"},
+ {0x08040040, nullptr, "SetBatteryEmptyLEDPattern"},
+ {0x08050000, nullptr, "ClearStepHistory"},
+ {0x080600C2, nullptr, "SetStepHistory"},
+ {0x08070082, nullptr, "GetPlayHistory"},
+ {0x08080000, nullptr, "GetPlayHistoryStart"},
+ {0x08090000, nullptr, "GetPlayHistoryLength"},
+ {0x080A0000, nullptr, "ClearPlayHistory"},
+ {0x080B0080, nullptr, "CalcPlayHistoryStart"},
+ {0x080C0080, nullptr, "SetUserTime"},
+ {0x080D0000, nullptr, "InvalidateSystemTime"},
+ {0x080E0140, nullptr, "NotifyPlayEvent"},
+ {0x080F0000, IsLegacyPowerOff, "IsLegacyPowerOff"},
+ {0x08100000, nullptr, "ClearLegacyPowerOff"},
+ {0x08110000, GetShellState, "GetShellState"},
+ {0x08120000, nullptr, "IsShutdownByBatteryEmpty"},
+ {0x08130000, nullptr, "FormatSavedata"},
+ {0x08140000, nullptr, "GetLegacyJumpProhibitedFlag"},
+ {0x08180040, nullptr, "ConfigureNew3DSCPU"},
};
PTM_Sysm_Interface::PTM_Sysm_Interface() {
diff --git a/src/core/hle/service/ptm/ptm_u.cpp b/src/core/hle/service/ptm/ptm_u.cpp
index 17e764866..65e868393 100644
--- a/src/core/hle/service/ptm/ptm_u.cpp
+++ b/src/core/hle/service/ptm/ptm_u.cpp
@@ -9,21 +9,21 @@ namespace Service {
namespace PTM {
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010002, nullptr, "RegisterAlarmClient"},
- {0x00020080, nullptr, "SetRtcAlarm"},
- {0x00030000, nullptr, "GetRtcAlarm"},
- {0x00040000, nullptr, "CancelRtcAlarm"},
- {0x00050000, GetAdapterState, "GetAdapterState"},
- {0x00060000, GetShellState, "GetShellState"},
- {0x00070000, GetBatteryLevel, "GetBatteryLevel"},
+ {0x00010002, nullptr, "RegisterAlarmClient"},
+ {0x00020080, nullptr, "SetRtcAlarm"},
+ {0x00030000, nullptr, "GetRtcAlarm"},
+ {0x00040000, nullptr, "CancelRtcAlarm"},
+ {0x00050000, GetAdapterState, "GetAdapterState"},
+ {0x00060000, GetShellState, "GetShellState"},
+ {0x00070000, GetBatteryLevel, "GetBatteryLevel"},
{0x00080000, GetBatteryChargeState, "GetBatteryChargeState"},
- {0x00090000, nullptr, "GetPedometerState"},
- {0x000A0042, nullptr, "GetStepHistoryEntry"},
- {0x000B00C2, nullptr, "GetStepHistory"},
- {0x000C0000, GetTotalStepCount, "GetTotalStepCount"},
- {0x000D0040, nullptr, "SetPedometerRecordingMode"},
- {0x000E0000, nullptr, "GetPedometerRecordingMode"},
- {0x000F0084, nullptr, "GetStepHistoryAll"},
+ {0x00090000, nullptr, "GetPedometerState"},
+ {0x000A0042, nullptr, "GetStepHistoryEntry"},
+ {0x000B00C2, nullptr, "GetStepHistory"},
+ {0x000C0000, GetTotalStepCount, "GetTotalStepCount"},
+ {0x000D0040, nullptr, "SetPedometerRecordingMode"},
+ {0x000E0000, nullptr, "GetPedometerRecordingMode"},
+ {0x000F0084, nullptr, "GetStepHistoryAll"},
};
PTM_U_Interface::PTM_U_Interface() {
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 5b8440b77..ca7eeac8a 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -4,42 +4,40 @@
#include "common/logging/log.h"
#include "common/string_util.h"
-
-#include "core/hle/service/service.h"
#include "core/hle/service/ac_u.h"
#include "core/hle/service/act_a.h"
#include "core/hle/service/act_u.h"
-#include "core/hle/service/csnd_snd.h"
-#include "core/hle/service/dsp_dsp.h"
-#include "core/hle/service/err_f.h"
-#include "core/hle/service/gsp_gpu.h"
-#include "core/hle/service/gsp_lcd.h"
-#include "core/hle/service/http_c.h"
-#include "core/hle/service/mic_u.h"
-#include "core/hle/service/ns_s.h"
-#include "core/hle/service/nwm_uds.h"
-#include "core/hle/service/pm_app.h"
-#include "core/hle/service/soc_u.h"
-#include "core/hle/service/srv.h"
-#include "core/hle/service/ssl_c.h"
-#include "core/hle/service/y2r_u.h"
-
#include "core/hle/service/am/am.h"
#include "core/hle/service/apt/apt.h"
#include "core/hle/service/boss/boss.h"
#include "core/hle/service/cam/cam.h"
#include "core/hle/service/cecd/cecd.h"
+#include "core/hle/service/cfg/cfg.h"
+#include "core/hle/service/csnd_snd.h"
#include "core/hle/service/dlp/dlp.h"
+#include "core/hle/service/dsp_dsp.h"
+#include "core/hle/service/err_f.h"
#include "core/hle/service/frd/frd.h"
#include "core/hle/service/fs/archive.h"
-#include "core/hle/service/cfg/cfg.h"
+#include "core/hle/service/gsp_gpu.h"
+#include "core/hle/service/gsp_lcd.h"
#include "core/hle/service/hid/hid.h"
+#include "core/hle/service/http_c.h"
#include "core/hle/service/ir/ir.h"
#include "core/hle/service/ldr_ro/ldr_ro.h"
+#include "core/hle/service/mic_u.h"
#include "core/hle/service/ndm/ndm.h"
#include "core/hle/service/news/news.h"
#include "core/hle/service/nim/nim.h"
+#include "core/hle/service/ns_s.h"
+#include "core/hle/service/nwm_uds.h"
+#include "core/hle/service/pm_app.h"
#include "core/hle/service/ptm/ptm.h"
+#include "core/hle/service/service.h"
+#include "core/hle/service/soc_u.h"
+#include "core/hle/service/srv.h"
+#include "core/hle/service/ssl_c.h"
+#include "core/hle/service/y2r_u.h"
namespace Service {
@@ -50,11 +48,13 @@ std::unordered_map<std::string, Kernel::SharedPtr<Interface>> g_srv_services;
* Creates a function string for logging, complete with the name (or header code, depending
* on what's passed in) the port name, and all the cmd_buff arguments.
*/
-static std::string MakeFunctionString(const char* name, const char* port_name, const u32* cmd_buff) {
+static std::string MakeFunctionString(const char* name, const char* port_name,
+ const u32* cmd_buff) {
// Number of params == bits 0-5 + bits 6-11
int num_params = (cmd_buff[0] & 0x3F) + ((cmd_buff[0] >> 6) & 0x3F);
- std::string function_string = Common::StringFromFormat("function '%s': port=%s", name, port_name);
+ std::string function_string =
+ Common::StringFromFormat("function '%s': port=%s", name, port_name);
for (int i = 1; i <= num_params; ++i) {
function_string += Common::StringFromFormat(", cmd_buff[%i]=0x%X", i, cmd_buff[i]);
}
@@ -66,14 +66,19 @@ ResultVal<bool> Interface::SyncRequest() {
auto itr = m_functions.find(cmd_buff[0]);
if (itr == m_functions.end() || itr->second.func == nullptr) {
- std::string function_name = (itr == m_functions.end()) ? Common::StringFromFormat("0x%08X", cmd_buff[0]) : itr->second.name;
- LOG_ERROR(Service, "unknown / unimplemented %s", MakeFunctionString(function_name.c_str(), GetPortName().c_str(), cmd_buff).c_str());
+ std::string function_name = (itr == m_functions.end())
+ ? Common::StringFromFormat("0x%08X", cmd_buff[0])
+ : itr->second.name;
+ LOG_ERROR(
+ Service, "unknown / unimplemented %s",
+ MakeFunctionString(function_name.c_str(), GetPortName().c_str(), cmd_buff).c_str());
// TODO(bunnei): Hack - ignore error
cmd_buff[1] = 0;
return MakeResult<bool>(false);
}
- LOG_TRACE(Service, "%s", MakeFunctionString(itr->second.name, GetPortName().c_str(), cmd_buff).c_str());
+ LOG_TRACE(Service, "%s",
+ MakeFunctionString(itr->second.name, GetPortName().c_str(), cmd_buff).c_str());
itr->second.func(this);
@@ -163,6 +168,4 @@ void Shutdown() {
g_kernel_named_ports.clear();
LOG_DEBUG(Service, "shutdown OK");
}
-
-
}
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index f31135212..39b5ffaae 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -7,11 +7,8 @@
#include <cstddef>
#include <string>
#include <unordered_map>
-
#include <boost/container/flat_map.hpp>
-
#include "common/common_types.h"
-
#include "core/hle/kernel/session.h"
#include "core/hle/result.h"
@@ -28,13 +25,15 @@ class Interface : public Kernel::Session {
// just something that encapsulates a session and acts as a helper to implement service
// processes.
public:
- std::string GetName() const override { return GetPortName(); }
+ std::string GetName() const override {
+ return GetPortName();
+ }
typedef void (*Function)(Interface*);
struct FunctionInfo {
- u32 id;
- Function func;
+ u32 id;
+ Function func;
const char* name;
};
@@ -49,7 +48,6 @@ public:
ResultVal<bool> SyncRequest() override;
protected:
-
/**
* Registers the functions in the service
*/
@@ -62,7 +60,6 @@ protected:
private:
boost::container::flat_map<u32, FunctionInfo> m_functions;
-
};
/// Initialize ServiceManager
diff --git a/src/core/hle/service/soc_u.cpp b/src/core/hle/service/soc_u.cpp
index 9b285567b..4279b67fb 100644
--- a/src/core/hle/service/soc_u.cpp
+++ b/src/core/hle/service/soc_u.cpp
@@ -6,53 +6,51 @@
#include <cstring>
#include <unordered_map>
#include <vector>
-
#include "common/assert.h"
#include "common/bit_field.h"
#include "common/common_types.h"
#include "common/logging/log.h"
#include "common/scope_exit.h"
-
#include "core/hle/kernel/session.h"
#include "core/hle/result.h"
#include "core/hle/service/soc_u.h"
#include "core/memory.h"
#ifdef _WIN32
- #include <winsock2.h>
- #include <ws2tcpip.h>
-
- // MinGW does not define several errno constants
- #ifndef _MSC_VER
- #define EBADMSG 104
- #define ENODATA 120
- #define ENOMSG 122
- #define ENOSR 124
- #define ENOSTR 125
- #define ETIME 137
- #define EIDRM 2001
- #define ENOLINK 2002
- #endif // _MSC_VER
+#include <winsock2.h>
+#include <ws2tcpip.h>
+
+// MinGW does not define several errno constants
+#ifndef _MSC_VER
+#define EBADMSG 104
+#define ENODATA 120
+#define ENOMSG 122
+#define ENOSR 124
+#define ENOSTR 125
+#define ETIME 137
+#define EIDRM 2001
+#define ENOLINK 2002
+#endif // _MSC_VER
#else
- #include <cerrno>
- #include <fcntl.h>
- #include <netinet/in.h>
- #include <netdb.h>
- #include <poll.h>
- #include <sys/socket.h>
- #include <unistd.h>
+#include <cerrno>
+#include <fcntl.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <poll.h>
+#include <sys/socket.h>
+#include <unistd.h>
#endif
#ifdef _WIN32
-# define WSAEAGAIN WSAEWOULDBLOCK
-# define WSAEMULTIHOP -1 // Invalid dummy value
-# define ERRNO(x) WSA##x
-# define GET_ERRNO WSAGetLastError()
-# define poll(x, y, z) WSAPoll(x, y, z);
+#define WSAEAGAIN WSAEWOULDBLOCK
+#define WSAEMULTIHOP -1 // Invalid dummy value
+#define ERRNO(x) WSA##x
+#define GET_ERRNO WSAGetLastError()
+#define poll(x, y, z) WSAPoll(x, y, z);
#else
-# define ERRNO(x) x
-# define GET_ERRNO errno
-# define closesocket(x) close(x)
+#define ERRNO(x) x
+#define GET_ERRNO errno
+#define closesocket(x) close(x)
#endif
static const s32 SOCKET_ERROR_VALUE = -1;
@@ -63,83 +61,83 @@ static const s32 SOCKET_ERROR_VALUE = -1;
namespace SOC_U {
/// Holds the translation from system network errors to 3DS network errors
-static const std::unordered_map<int, int> error_map = { {
- { E2BIG, 1 },
- { ERRNO(EACCES), 2 },
- { ERRNO(EADDRINUSE), 3 },
- { ERRNO(EADDRNOTAVAIL), 4 },
- { ERRNO(EAFNOSUPPORT), 5 },
- { ERRNO(EAGAIN), 6 },
- { ERRNO(EALREADY), 7 },
- { ERRNO(EBADF), 8 },
- { EBADMSG, 9 },
- { EBUSY, 10 },
- { ECANCELED, 11 },
- { ECHILD, 12 },
- { ERRNO(ECONNABORTED), 13 },
- { ERRNO(ECONNREFUSED), 14 },
- { ERRNO(ECONNRESET), 15 },
- { EDEADLK, 16 },
- { ERRNO(EDESTADDRREQ), 17 },
- { EDOM, 18 },
- { ERRNO(EDQUOT), 19 },
- { EEXIST, 20 },
- { ERRNO(EFAULT), 21 },
- { EFBIG, 22 },
- { ERRNO(EHOSTUNREACH), 23 },
- { EIDRM, 24 },
- { EILSEQ, 25 },
- { ERRNO(EINPROGRESS), 26 },
- { ERRNO(EINTR), 27 },
- { ERRNO(EINVAL), 28 },
- { EIO, 29 },
- { ERRNO(EISCONN), 30 },
- { EISDIR, 31 },
- { ERRNO(ELOOP), 32 },
- { ERRNO(EMFILE), 33 },
- { EMLINK, 34 },
- { ERRNO(EMSGSIZE), 35 },
- { ERRNO(EMULTIHOP), 36 },
- { ERRNO(ENAMETOOLONG), 37 },
- { ERRNO(ENETDOWN), 38 },
- { ERRNO(ENETRESET), 39 },
- { ERRNO(ENETUNREACH), 40 },
- { ENFILE, 41 },
- { ERRNO(ENOBUFS), 42 },
- { ENODATA, 43 },
- { ENODEV, 44 },
- { ENOENT, 45 },
- { ENOEXEC, 46 },
- { ENOLCK, 47 },
- { ENOLINK, 48 },
- { ENOMEM, 49 },
- { ENOMSG, 50 },
- { ERRNO(ENOPROTOOPT), 51 },
- { ENOSPC, 52 },
- { ENOSR, 53 },
- { ENOSTR, 54 },
- { ENOSYS, 55 },
- { ERRNO(ENOTCONN), 56 },
- { ENOTDIR, 57 },
- { ERRNO(ENOTEMPTY), 58 },
- { ERRNO(ENOTSOCK), 59 },
- { ENOTSUP, 60 },
- { ENOTTY, 61 },
- { ENXIO, 62 },
- { ERRNO(EOPNOTSUPP), 63 },
- { EOVERFLOW, 64 },
- { EPERM, 65 },
- { EPIPE, 66 },
- { EPROTO, 67 },
- { ERRNO(EPROTONOSUPPORT), 68 },
- { ERRNO(EPROTOTYPE), 69 },
- { ERANGE, 70 },
- { EROFS, 71 },
- { ESPIPE, 72 },
- { ESRCH, 73 },
- { ERRNO(ESTALE), 74 },
- { ETIME, 75 },
- { ERRNO(ETIMEDOUT), 76 }
+static const std::unordered_map<int, int> error_map = {{
+ {E2BIG, 1},
+ {ERRNO(EACCES), 2},
+ {ERRNO(EADDRINUSE), 3},
+ {ERRNO(EADDRNOTAVAIL), 4},
+ {ERRNO(EAFNOSUPPORT), 5},
+ {ERRNO(EAGAIN), 6},
+ {ERRNO(EALREADY), 7},
+ {ERRNO(EBADF), 8},
+ {EBADMSG, 9},
+ {EBUSY, 10},
+ {ECANCELED, 11},
+ {ECHILD, 12},
+ {ERRNO(ECONNABORTED), 13},
+ {ERRNO(ECONNREFUSED), 14},
+ {ERRNO(ECONNRESET), 15},
+ {EDEADLK, 16},
+ {ERRNO(EDESTADDRREQ), 17},
+ {EDOM, 18},
+ {ERRNO(EDQUOT), 19},
+ {EEXIST, 20},
+ {ERRNO(EFAULT), 21},
+ {EFBIG, 22},
+ {ERRNO(EHOSTUNREACH), 23},
+ {EIDRM, 24},
+ {EILSEQ, 25},
+ {ERRNO(EINPROGRESS), 26},
+ {ERRNO(EINTR), 27},
+ {ERRNO(EINVAL), 28},
+ {EIO, 29},
+ {ERRNO(EISCONN), 30},
+ {EISDIR, 31},
+ {ERRNO(ELOOP), 32},
+ {ERRNO(EMFILE), 33},
+ {EMLINK, 34},
+ {ERRNO(EMSGSIZE), 35},
+ {ERRNO(EMULTIHOP), 36},
+ {ERRNO(ENAMETOOLONG), 37},
+ {ERRNO(ENETDOWN), 38},
+ {ERRNO(ENETRESET), 39},
+ {ERRNO(ENETUNREACH), 40},
+ {ENFILE, 41},
+ {ERRNO(ENOBUFS), 42},
+ {ENODATA, 43},
+ {ENODEV, 44},
+ {ENOENT, 45},
+ {ENOEXEC, 46},
+ {ENOLCK, 47},
+ {ENOLINK, 48},
+ {ENOMEM, 49},
+ {ENOMSG, 50},
+ {ERRNO(ENOPROTOOPT), 51},
+ {ENOSPC, 52},
+ {ENOSR, 53},
+ {ENOSTR, 54},
+ {ENOSYS, 55},
+ {ERRNO(ENOTCONN), 56},
+ {ENOTDIR, 57},
+ {ERRNO(ENOTEMPTY), 58},
+ {ERRNO(ENOTSOCK), 59},
+ {ENOTSUP, 60},
+ {ENOTTY, 61},
+ {ENXIO, 62},
+ {ERRNO(EOPNOTSUPP), 63},
+ {EOVERFLOW, 64},
+ {EPERM, 65},
+ {EPIPE, 66},
+ {EPROTO, 67},
+ {ERRNO(EPROTONOSUPPORT), 68},
+ {ERRNO(EPROTOTYPE), 69},
+ {ERANGE, 70},
+ {EROFS, 71},
+ {ESPIPE, 72},
+ {ESRCH, 73},
+ {ERRNO(ESTALE), 74},
+ {ETIME, 75},
+ {ERRNO(ETIMEDOUT), 76},
}};
/// Converts a network error from platform-specific to 3ds-specific
@@ -153,21 +151,21 @@ static int TranslateError(int error) {
/// Holds the translation from system network socket options to 3DS network socket options
/// Note: -1 = No effect/unavailable
-static const std::unordered_map<int, int> sockopt_map = { {
- { 0x0004, SO_REUSEADDR },
- { 0x0080, -1 },
- { 0x0100, -1 },
- { 0x1001, SO_SNDBUF },
- { 0x1002, SO_RCVBUF },
- { 0x1003, -1 },
+static const std::unordered_map<int, int> sockopt_map = {{
+ {0x0004, SO_REUSEADDR},
+ {0x0080, -1},
+ {0x0100, -1},
+ {0x1001, SO_SNDBUF},
+ {0x1002, SO_RCVBUF},
+ {0x1003, -1},
#ifdef _WIN32
/// Unsupported in WinSock2
- { 0x1004, -1 },
+ {0x1004, -1},
#else
- { 0x1004, SO_RCVLOWAT },
+ {0x1004, SO_RCVLOWAT},
#endif
- { 0x1008, SO_TYPE },
- { 0x1009, SO_ERROR },
+ {0x1008, SO_TYPE},
+ {0x1009, SO_ERROR},
}};
/// Converts a socket option from 3ds-specific to platform-specific
@@ -203,7 +201,8 @@ struct CTRPollFD {
return *this;
}
- /// Translates the resulting events of a Poll operation from platform-specific to 3ds specific
+ /// Translates the resulting events of a Poll operation from platform-specific to 3ds
+ /// specific
static Events TranslateTo3DS(u32 input_event) {
Events ev = {};
if (input_event & POLLIN)
@@ -221,7 +220,8 @@ struct CTRPollFD {
return ev;
}
- /// Translates the resulting events of a Poll operation from 3ds specific to platform specific
+ /// Translates the resulting events of a Poll operation from 3ds specific to platform
+ /// specific
static u32 TranslateToPlatform(Events input_event) {
u32 ret = 0;
if (input_event.pollin)
@@ -239,7 +239,7 @@ struct CTRPollFD {
return ret;
}
};
- Events events; ///< Events to poll for (input)
+ Events events; ///< Events to poll for (input)
Events revents; ///< Events received (output)
/// Converts a platform-specific pollfd to a 3ds specific structure
@@ -265,17 +265,17 @@ struct CTRPollFD {
union CTRSockAddr {
/// Structure to represent a raw sockaddr
struct {
- u8 len; ///< The length of the entire structure, only the set fields count
- u8 sa_family; ///< The address family of the sockaddr
+ u8 len; ///< The length of the entire structure, only the set fields count
+ u8 sa_family; ///< The address family of the sockaddr
u8 sa_data[0x1A]; ///< The extra data, this varies, depending on the address family
} raw;
/// Structure to represent the 3ds' sockaddr_in structure
struct CTRSockAddrIn {
- u8 len; ///< The length of the entire structure
+ u8 len; ///< The length of the entire structure
u8 sin_family; ///< The address family of the sockaddr_in
- u16 sin_port; ///< The port associated with this sockaddr_in
- u32 sin_addr; ///< The actual address of the sockaddr_in
+ u16 sin_port; ///< The port associated with this sockaddr_in
+ u32 sin_addr; ///< The actual address of the sockaddr_in
} in;
/// Convert a 3DS CTRSockAddr to a platform-specific sockaddr
@@ -286,8 +286,7 @@ union CTRSockAddr {
// We can not guarantee ABI compatibility between platforms so we copy the fields manually
switch (result.sa_family) {
- case AF_INET:
- {
+ case AF_INET: {
sockaddr_in* result_in = reinterpret_cast<sockaddr_in*>(&result);
result_in->sin_port = ctr_addr.in.sin_port;
result_in->sin_addr.s_addr = ctr_addr.in.sin_addr;
@@ -307,8 +306,7 @@ union CTRSockAddr {
result.raw.sa_family = static_cast<u8>(addr.sa_family);
// We can not guarantee ABI compatibility between platforms so we copy the fields manually
switch (result.raw.sa_family) {
- case AF_INET:
- {
+ case AF_INET: {
sockaddr_in const* addr_in = reinterpret_cast<sockaddr_in const*>(&addr);
result.raw.len = sizeof(CTRSockAddrIn);
result.in.sin_port = addr_in->sin_port;
@@ -341,24 +339,27 @@ static void Socket(Service::Interface* self) {
// Only 0 is allowed according to 3dbrew, using 0 will let the OS decide which protocol to use
if (protocol != 0) {
- cmd_buffer[1] = UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
+ cmd_buffer[1] =
+ UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
return;
}
if (domain != AF_INET) {
- cmd_buffer[1] = UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
+ cmd_buffer[1] =
+ UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
return;
}
if (type != SOCK_DGRAM && type != SOCK_STREAM) {
- cmd_buffer[1] = UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
+ cmd_buffer[1] =
+ UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
return;
}
u32 socket_handle = static_cast<u32>(::socket(domain, type, protocol));
if ((s32)socket_handle != SOCKET_ERROR_VALUE)
- open_sockets[socket_handle] = { socket_handle, true };
+ open_sockets[socket_handle] = {socket_handle, true};
int result = 0;
if ((s32)socket_handle == SOCKET_ERROR_VALUE)
@@ -406,8 +407,8 @@ static void Fcntl(Service::Interface* self) {
int result = 0;
u32 posix_ret = 0; // TODO: Check what hardware returns for F_SETFL (unspecified by POSIX)
SCOPE_EXIT({
- cmd_buffer[1] = result;
- cmd_buffer[2] = posix_ret;
+ cmd_buffer[1] = result;
+ cmd_buffer[2] = posix_ret;
});
if (ctr_cmd == 3) { // F_GETFL
@@ -493,7 +494,7 @@ static void Accept(Service::Interface* self) {
u32 ret = static_cast<u32>(::accept(socket_handle, &addr, &addr_len));
if ((s32)ret != SOCKET_ERROR_VALUE)
- open_sockets[ret] = { ret, true };
+ open_sockets[ret] = {ret, true};
int result = 0;
if ((s32)ret == SOCKET_ERROR_VALUE) {
@@ -573,9 +574,11 @@ static void SendTo(Service::Interface* self) {
int ret = -1;
if (addr_len > 0) {
sockaddr dest_addr = CTRSockAddr::ToPlatform(ctr_dest_addr);
- ret = ::sendto(socket_handle, reinterpret_cast<const char*>(input_buff.data()), len, flags, &dest_addr, sizeof(dest_addr));
+ ret = ::sendto(socket_handle, reinterpret_cast<const char*>(input_buff.data()), len, flags,
+ &dest_addr, sizeof(dest_addr));
} else {
- ret = ::sendto(socket_handle, reinterpret_cast<const char*>(input_buff.data()), len, flags, nullptr, 0);
+ ret = ::sendto(socket_handle, reinterpret_cast<const char*>(input_buff.data()), len, flags,
+ nullptr, 0);
}
int result = 0;
@@ -596,8 +599,7 @@ static void RecvFrom(Service::Interface* self) {
u32 flags = cmd_buffer[3];
socklen_t addr_len = static_cast<socklen_t>(cmd_buffer[4]);
- struct
- {
+ struct {
u32 output_buffer_descriptor;
u32 output_buffer_addr;
u32 address_buffer_descriptor;
@@ -619,11 +621,13 @@ static void RecvFrom(Service::Interface* self) {
std::vector<u8> output_buff(len);
sockaddr src_addr;
socklen_t src_addr_len = sizeof(src_addr);
- int ret = ::recvfrom(socket_handle, reinterpret_cast<char*>(output_buff.data()), len, flags, &src_addr, &src_addr_len);
+ int ret = ::recvfrom(socket_handle, reinterpret_cast<char*>(output_buff.data()), len, flags,
+ &src_addr, &src_addr_len);
if (ret >= 0 && buffer_parameters.output_src_address_buffer != 0 && src_addr_len > 0) {
CTRSockAddr ctr_src_addr = CTRSockAddr::FromPlatform(src_addr);
- Memory::WriteBlock(buffer_parameters.output_src_address_buffer, &ctr_src_addr, sizeof(ctr_src_addr));
+ Memory::WriteBlock(buffer_parameters.output_src_address_buffer, &ctr_src_addr,
+ sizeof(ctr_src_addr));
}
int result = 0;
@@ -633,7 +637,8 @@ static void RecvFrom(Service::Interface* self) {
total_received = 0;
} else {
// Write only the data we received to avoid overwriting parts of the buffer with zeros
- Memory::WriteBlock(buffer_parameters.output_buffer_addr, output_buff.data(), total_received);
+ Memory::WriteBlock(buffer_parameters.output_buffer_addr, output_buff.data(),
+ total_received);
}
cmd_buffer[1] = result;
@@ -648,7 +653,8 @@ static void Poll(Service::Interface* self) {
VAddr input_fds_addr = cmd_buffer[6];
VAddr output_fds_addr = cmd_buffer[0x104 >> 2];
- if (!Memory::IsValidVirtualAddress(input_fds_addr) || !Memory::IsValidVirtualAddress(output_fds_addr)) {
+ if (!Memory::IsValidVirtualAddress(input_fds_addr) ||
+ !Memory::IsValidVirtualAddress(output_fds_addr)) {
cmd_buffer[1] = -1; // TODO(Subv): Find correct error code.
return;
}
@@ -656,7 +662,8 @@ static void Poll(Service::Interface* self) {
std::vector<CTRPollFD> ctr_fds(nfds);
Memory::ReadBlock(input_fds_addr, ctr_fds.data(), nfds * sizeof(CTRPollFD));
- // The 3ds_pollfd and the pollfd structures may be different (Windows/Linux have different sizes)
+ // The 3ds_pollfd and the pollfd structures may be different (Windows/Linux have different
+ // sizes)
// so we have to copy the data
std::vector<pollfd> platform_pollfd(nfds);
std::transform(ctr_fds.begin(), ctr_fds.end(), platform_pollfd.begin(), CTRPollFD::ToPlatform);
@@ -664,7 +671,8 @@ static void Poll(Service::Interface* self) {
const int ret = ::poll(platform_pollfd.data(), nfds, timeout);
// Now update the output pollfd structure
- std::transform(platform_pollfd.begin(), platform_pollfd.end(), ctr_fds.begin(), CTRPollFD::FromPlatform);
+ std::transform(platform_pollfd.begin(), platform_pollfd.end(), ctr_fds.begin(),
+ CTRPollFD::FromPlatform);
Memory::WriteBlock(output_fds_addr, ctr_fds.data(), nfds * sizeof(CTRPollFD));
@@ -775,7 +783,7 @@ static void Connect(Service::Interface* self) {
}
static void InitializeSockets(Service::Interface* self) {
- // TODO(Subv): Implement
+// TODO(Subv): Implement
#ifdef _WIN32
WSADATA data;
WSAStartup(MAKEWORD(2, 2), &data);
@@ -808,7 +816,7 @@ static void GetSockOpt(Service::Interface* self) {
int ret = -1;
int err = 0;
- if(optname < 0) {
+ if (optname < 0) {
#ifdef _WIN32
err = WSAEINVAL;
#else
@@ -818,7 +826,7 @@ static void GetSockOpt(Service::Interface* self) {
// 0x100 = static buffer offset (bytes)
// + 0x4 = 2nd pointer (u32) position
// >> 2 = convert to u32 offset instead of byte offset (cmd_buffer = u32*)
- char* optval = reinterpret_cast<char *>(Memory::GetPointer(cmd_buffer[0x104 >> 2]));
+ char* optval = reinterpret_cast<char*>(Memory::GetPointer(cmd_buffer[0x104 >> 2]));
ret = ::getsockopt(socket_handle, level, optname, optval, &optlen);
err = 0;
@@ -842,7 +850,7 @@ static void SetSockOpt(Service::Interface* self) {
int ret = -1;
int err = 0;
- if(optname < 0) {
+ if (optname < 0) {
#ifdef _WIN32
err = WSAEINVAL;
#else
@@ -850,7 +858,7 @@ static void SetSockOpt(Service::Interface* self) {
#endif
} else {
socklen_t optlen = static_cast<socklen_t>(cmd_buffer[4]);
- const char* optval = reinterpret_cast<const char *>(Memory::GetPointer(cmd_buffer[8]));
+ const char* optval = reinterpret_cast<const char*>(Memory::GetPointer(cmd_buffer[8]));
ret = static_cast<u32>(::setsockopt(socket_handle, level, optname, optval, optlen));
err = 0;
@@ -865,39 +873,39 @@ static void SetSockOpt(Service::Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010044, InitializeSockets, "InitializeSockets"},
- {0x000200C2, Socket, "Socket"},
- {0x00030082, Listen, "Listen"},
- {0x00040082, Accept, "Accept"},
- {0x00050084, Bind, "Bind"},
- {0x00060084, Connect, "Connect"},
- {0x00070104, nullptr, "recvfrom_other"},
- {0x00080102, RecvFrom, "RecvFrom"},
- {0x00090106, nullptr, "sendto_other"},
- {0x000A0106, SendTo, "SendTo"},
- {0x000B0042, Close, "Close"},
- {0x000C0082, Shutdown, "Shutdown"},
- {0x000D0082, nullptr, "GetHostByName"},
- {0x000E00C2, nullptr, "GetHostByAddr"},
- {0x000F0106, nullptr, "GetAddrInfo"},
- {0x00100102, nullptr, "GetNameInfo"},
- {0x00110102, GetSockOpt, "GetSockOpt"},
- {0x00120104, SetSockOpt, "SetSockOpt"},
- {0x001300C2, Fcntl, "Fcntl"},
- {0x00140084, Poll, "Poll"},
- {0x00150042, nullptr, "SockAtMark"},
- {0x00160000, GetHostId, "GetHostId"},
- {0x00170082, GetSockName, "GetSockName"},
- {0x00180082, GetPeerName, "GetPeerName"},
- {0x00190000, ShutdownSockets, "ShutdownSockets"},
- {0x001A00C0, nullptr, "GetNetworkOpt"},
- {0x001B0040, nullptr, "ICMPSocket"},
- {0x001C0104, nullptr, "ICMPPing"},
- {0x001D0040, nullptr, "ICMPCancel"},
- {0x001E0040, nullptr, "ICMPClose"},
- {0x001F0040, nullptr, "GetResolverInfo"},
- {0x00210002, nullptr, "CloseSockets"},
- {0x00230040, nullptr, "AddGlobalSocket"},
+ {0x00010044, InitializeSockets, "InitializeSockets"},
+ {0x000200C2, Socket, "Socket"},
+ {0x00030082, Listen, "Listen"},
+ {0x00040082, Accept, "Accept"},
+ {0x00050084, Bind, "Bind"},
+ {0x00060084, Connect, "Connect"},
+ {0x00070104, nullptr, "recvfrom_other"},
+ {0x00080102, RecvFrom, "RecvFrom"},
+ {0x00090106, nullptr, "sendto_other"},
+ {0x000A0106, SendTo, "SendTo"},
+ {0x000B0042, Close, "Close"},
+ {0x000C0082, Shutdown, "Shutdown"},
+ {0x000D0082, nullptr, "GetHostByName"},
+ {0x000E00C2, nullptr, "GetHostByAddr"},
+ {0x000F0106, nullptr, "GetAddrInfo"},
+ {0x00100102, nullptr, "GetNameInfo"},
+ {0x00110102, GetSockOpt, "GetSockOpt"},
+ {0x00120104, SetSockOpt, "SetSockOpt"},
+ {0x001300C2, Fcntl, "Fcntl"},
+ {0x00140084, Poll, "Poll"},
+ {0x00150042, nullptr, "SockAtMark"},
+ {0x00160000, GetHostId, "GetHostId"},
+ {0x00170082, GetSockName, "GetSockName"},
+ {0x00180082, GetPeerName, "GetPeerName"},
+ {0x00190000, ShutdownSockets, "ShutdownSockets"},
+ {0x001A00C0, nullptr, "GetNetworkOpt"},
+ {0x001B0040, nullptr, "ICMPSocket"},
+ {0x001C0104, nullptr, "ICMPPing"},
+ {0x001D0040, nullptr, "ICMPCancel"},
+ {0x001E0040, nullptr, "ICMPClose"},
+ {0x001F0040, nullptr, "GetResolverInfo"},
+ {0x00210002, nullptr, "CloseSockets"},
+ {0x00230040, nullptr, "AddGlobalSocket"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/soc_u.h b/src/core/hle/service/soc_u.h
index a091f597c..8d02ed30f 100644
--- a/src/core/hle/service/soc_u.h
+++ b/src/core/hle/service/soc_u.h
@@ -5,7 +5,6 @@
#pragma once
#include <string>
-
#include "core/hle/service/service.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp
index 3c05f836b..b25be413a 100644
--- a/src/core/hle/service/srv.cpp
+++ b/src/core/hle/service/srv.cpp
@@ -4,9 +4,8 @@
#include "common/common_types.h"
#include "common/logging/log.h"
-
-#include "core/hle/service/srv.h"
#include "core/hle/kernel/event.h"
+#include "core/hle/service/srv.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace SRV
@@ -28,13 +27,14 @@ static void RegisterClient(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
if (cmd_buff[1] != IPC::CallingPidDesc()) {
- cmd_buff[0] = IPC::MakeHeader(0x0, 0x1, 0); //0x40
+ cmd_buff[0] = IPC::MakeHeader(0x0, 0x1, 0); // 0x40
cmd_buff[1] = ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS,
- ErrorSummary::WrongArgument, ErrorLevel::Permanent).raw;
+ ErrorSummary::WrongArgument, ErrorLevel::Permanent)
+ .raw;
return;
}
- cmd_buff[0] = IPC::MakeHeader(0x1, 0x1, 0); //0x10040
- cmd_buff[1] = RESULT_SUCCESS.raw; // No error
+ cmd_buff[0] = IPC::MakeHeader(0x1, 0x1, 0); // 0x10040
+ cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_SRV, "(STUBBED) called");
}
@@ -56,7 +56,7 @@ static void EnableNotification(Service::Interface* self) {
event_handle->Clear();
cmd_buff[0] = IPC::MakeHeader(0x2, 0x1, 0x2); // 0x20042
- cmd_buff[1] = RESULT_SUCCESS.raw; // No error
+ cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = IPC::CopyHandleDesc(1);
cmd_buff[3] = Kernel::g_handle_table.Create(event_handle).MoveFrom();
LOG_WARNING(Service_SRV, "(STUBBED) called");
@@ -105,7 +105,7 @@ static void Subscribe(Service::Interface* self) {
u32 notification_id = cmd_buff[1];
cmd_buff[0] = IPC::MakeHeader(0x9, 0x1, 0); // 0x90040
- cmd_buff[1] = RESULT_SUCCESS.raw; // No error
+ cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_SRV, "(STUBBED) called, notification_id=0x%X", notification_id);
}
@@ -124,7 +124,7 @@ static void Unsubscribe(Service::Interface* self) {
u32 notification_id = cmd_buff[1];
cmd_buff[0] = IPC::MakeHeader(0xA, 0x1, 0); // 0xA0040
- cmd_buff[1] = RESULT_SUCCESS.raw; // No error
+ cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_SRV, "(STUBBED) called, notification_id=0x%X", notification_id);
}
@@ -145,25 +145,26 @@ static void PublishToSubscriber(Service::Interface* self) {
u8 flags = cmd_buff[2] & 0xFF;
cmd_buff[0] = IPC::MakeHeader(0xC, 0x1, 0); // 0xC0040
- cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- LOG_WARNING(Service_SRV, "(STUBBED) called, notification_id=0x%X, flags=%u", notification_id, flags);
+ cmd_buff[1] = RESULT_SUCCESS.raw; // No error
+ LOG_WARNING(Service_SRV, "(STUBBED) called, notification_id=0x%X, flags=%u", notification_id,
+ flags);
}
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010002, RegisterClient, "RegisterClient"},
- {0x00020000, EnableNotification, "EnableNotification"},
- {0x00030100, nullptr, "RegisterService"},
- {0x000400C0, nullptr, "UnregisterService"},
- {0x00050100, GetServiceHandle, "GetServiceHandle"},
- {0x000600C2, nullptr, "RegisterPort"},
- {0x000700C0, nullptr, "UnregisterPort"},
- {0x00080100, nullptr, "GetPort"},
- {0x00090040, Subscribe, "Subscribe"},
- {0x000A0040, Unsubscribe, "Unsubscribe"},
- {0x000B0000, nullptr, "ReceiveNotification"},
- {0x000C0080, PublishToSubscriber, "PublishToSubscriber"},
- {0x000D0040, nullptr, "PublishAndGetSubscriber"},
- {0x000E00C0, nullptr, "IsServiceRegistered"},
+ {0x00010002, RegisterClient, "RegisterClient"},
+ {0x00020000, EnableNotification, "EnableNotification"},
+ {0x00030100, nullptr, "RegisterService"},
+ {0x000400C0, nullptr, "UnregisterService"},
+ {0x00050100, GetServiceHandle, "GetServiceHandle"},
+ {0x000600C2, nullptr, "RegisterPort"},
+ {0x000700C0, nullptr, "UnregisterPort"},
+ {0x00080100, nullptr, "GetPort"},
+ {0x00090040, Subscribe, "Subscribe"},
+ {0x000A0040, Unsubscribe, "Unsubscribe"},
+ {0x000B0000, nullptr, "ReceiveNotification"},
+ {0x000C0080, PublishToSubscriber, "PublishToSubscriber"},
+ {0x000D0040, nullptr, "PublishAndGetSubscriber"},
+ {0x000E00C0, nullptr, "IsServiceRegistered"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/ssl_c.cpp b/src/core/hle/service/ssl_c.cpp
index a8aff1abf..abab1d271 100644
--- a/src/core/hle/service/ssl_c.cpp
+++ b/src/core/hle/service/ssl_c.cpp
@@ -3,7 +3,6 @@
// Refer to the license.txt file included.
#include <random>
-
#include "common/common_types.h"
#include "core/hle/service/ssl_c.h"
@@ -37,7 +36,8 @@ static void GenerateRandomData(Service::Interface* self) {
u32 i = 0;
while (i < size) {
if ((i % 4) == 0) {
- // The random number generator returns 4 bytes worth of data, so generate new random data when i == 0 and when i is divisible by 4
+ // The random number generator returns 4 bytes worth of data, so generate new random
+ // data when i == 0 and when i is divisible by 4
data = rand_gen();
}
@@ -59,26 +59,26 @@ static void GenerateRandomData(Service::Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010002, Initialize, "Initialize"},
- {0x000200C2, nullptr, "CreateContext"},
- {0x00030000, nullptr, "CreateRootCertChain"},
- {0x00040040, nullptr, "DestroyRootCertChain"},
- {0x00050082, nullptr, "AddTrustedRootCA"},
- {0x00060080, nullptr, "RootCertChainAddDefaultCert"},
- {0x00070080, nullptr, "RootCertChainRemoveCert"},
- {0x000E0040, nullptr, "OpenDefaultClientCertContext"},
- {0x000F0040, nullptr, "CloseClientCertContext"},
- {0x00110042, GenerateRandomData, "GenerateRandomData"},
- {0x00120042, nullptr, "InitializeConnectionSession"},
- {0x00130040, nullptr, "StartConnection"},
- {0x00140040, nullptr, "StartConnectionGetOut"},
- {0x00150082, nullptr, "Read"},
- {0x00170082, nullptr, "Write"},
- {0x00180080, nullptr, "ContextSetRootCertChain"},
- {0x00190080, nullptr, "ContextSetClientCert"},
- {0x001B0080, nullptr, "ContextClearOpt"},
- {0x001E0040, nullptr, "DestroyContext"},
- {0x001F0082, nullptr, "ContextInitSharedmem"}
+ {0x00010002, Initialize, "Initialize"},
+ {0x000200C2, nullptr, "CreateContext"},
+ {0x00030000, nullptr, "CreateRootCertChain"},
+ {0x00040040, nullptr, "DestroyRootCertChain"},
+ {0x00050082, nullptr, "AddTrustedRootCA"},
+ {0x00060080, nullptr, "RootCertChainAddDefaultCert"},
+ {0x00070080, nullptr, "RootCertChainRemoveCert"},
+ {0x000E0040, nullptr, "OpenDefaultClientCertContext"},
+ {0x000F0040, nullptr, "CloseClientCertContext"},
+ {0x00110042, GenerateRandomData, "GenerateRandomData"},
+ {0x00120042, nullptr, "InitializeConnectionSession"},
+ {0x00130040, nullptr, "StartConnection"},
+ {0x00140040, nullptr, "StartConnectionGetOut"},
+ {0x00150082, nullptr, "Read"},
+ {0x00170082, nullptr, "Write"},
+ {0x00180080, nullptr, "ContextSetRootCertChain"},
+ {0x00190080, nullptr, "ContextSetClientCert"},
+ {0x001B0080, nullptr, "ContextClearOpt"},
+ {0x001E0040, nullptr, "DestroyContext"},
+ {0x001F0082, nullptr, "ContextInitSharedmem"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/y2r_u.cpp b/src/core/hle/service/y2r_u.cpp
index d16578f87..097e09d28 100644
--- a/src/core/hle/service/y2r_u.cpp
+++ b/src/core/hle/service/y2r_u.cpp
@@ -3,11 +3,9 @@
// Refer to the license.txt file included.
#include <cstring>
-
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "common/logging/log.h"
-
#include "core/hle/kernel/event.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/service/y2r_u.h"
@@ -39,16 +37,16 @@ static u32 transfer_end_interrupt_enabled = 0;
static u32 spacial_dithering_enabled = 0;
static const CoefficientSet standard_coefficients[4] = {
- {{ 0x100, 0x166, 0xB6, 0x58, 0x1C5, -0x166F, 0x10EE, -0x1C5B }}, // ITU_Rec601
- {{ 0x100, 0x193, 0x77, 0x2F, 0x1DB, -0x1933, 0xA7C, -0x1D51 }}, // ITU_Rec709
- {{ 0x12A, 0x198, 0xD0, 0x64, 0x204, -0x1BDE, 0x10F2, -0x229B }}, // ITU_Rec601_Scaling
- {{ 0x12A, 0x1CA, 0x88, 0x36, 0x21C, -0x1F04, 0x99C, -0x2421 }}, // ITU_Rec709_Scaling
+ {{0x100, 0x166, 0xB6, 0x58, 0x1C5, -0x166F, 0x10EE, -0x1C5B}}, // ITU_Rec601
+ {{0x100, 0x193, 0x77, 0x2F, 0x1DB, -0x1933, 0xA7C, -0x1D51}}, // ITU_Rec709
+ {{0x12A, 0x198, 0xD0, 0x64, 0x204, -0x1BDE, 0x10F2, -0x229B}}, // ITU_Rec601_Scaling
+ {{0x12A, 0x1CA, 0x88, 0x36, 0x21C, -0x1F04, 0x99C, -0x2421}}, // ITU_Rec709_Scaling
};
ResultCode ConversionConfiguration::SetInputLineWidth(u16 width) {
if (width == 0 || width > 1024 || width % 8 != 0) {
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::CAM,
- ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD
}
// Note: The hardware uses the register value 0 to represent a width of 1024, so for a width of
@@ -61,7 +59,7 @@ ResultCode ConversionConfiguration::SetInputLineWidth(u16 width) {
ResultCode ConversionConfiguration::SetInputLines(u16 lines) {
if (lines == 0 || lines > 1024) {
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::CAM,
- ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD
}
// Note: In what appears to be a bug, the `camera` module does not set the hardware register at
@@ -73,11 +71,12 @@ ResultCode ConversionConfiguration::SetInputLines(u16 lines) {
return RESULT_SUCCESS;
}
-ResultCode ConversionConfiguration::SetStandardCoefficient(StandardCoefficient standard_coefficient) {
+ResultCode ConversionConfiguration::SetStandardCoefficient(
+ StandardCoefficient standard_coefficient) {
size_t index = static_cast<size_t>(standard_coefficient);
if (index >= ARRAY_SIZE(standard_coefficients)) {
return ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::CAM,
- ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053ED
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053ED
}
std::memcpy(coefficients.data(), standard_coefficients[index].data(), sizeof(coefficients));
@@ -294,8 +293,10 @@ static void SetSendingY(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x10, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
- LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, src_process_handle=0x%08X",
- conversion.src_Y.image_size, conversion.src_Y.transfer_unit, conversion.src_Y.gap, cmd_buff[6]);
+ LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, "
+ "src_process_handle=0x%08X",
+ conversion.src_Y.image_size, conversion.src_Y.transfer_unit, conversion.src_Y.gap,
+ cmd_buff[6]);
}
static void SetSendingU(Service::Interface* self) {
@@ -309,8 +310,10 @@ static void SetSendingU(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x11, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
- LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, src_process_handle=0x%08X",
- conversion.src_U.image_size, conversion.src_U.transfer_unit, conversion.src_U.gap, cmd_buff[6]);
+ LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, "
+ "src_process_handle=0x%08X",
+ conversion.src_U.image_size, conversion.src_U.transfer_unit, conversion.src_U.gap,
+ cmd_buff[6]);
}
static void SetSendingV(Service::Interface* self) {
@@ -324,8 +327,10 @@ static void SetSendingV(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x12, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
- LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, src_process_handle=0x%08X",
- conversion.src_V.image_size, conversion.src_V.transfer_unit, conversion.src_V.gap, cmd_buff[6]);
+ LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, "
+ "src_process_handle=0x%08X",
+ conversion.src_V.image_size, conversion.src_V.transfer_unit, conversion.src_V.gap,
+ cmd_buff[6]);
}
static void SetSendingYUYV(Service::Interface* self) {
@@ -339,8 +344,10 @@ static void SetSendingYUYV(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x13, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
- LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, src_process_handle=0x%08X",
- conversion.src_YUYV.image_size, conversion.src_YUYV.transfer_unit, conversion.src_YUYV.gap, cmd_buff[6]);
+ LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, "
+ "src_process_handle=0x%08X",
+ conversion.src_YUYV.image_size, conversion.src_YUYV.transfer_unit,
+ conversion.src_YUYV.gap, cmd_buff[6]);
}
/**
@@ -418,8 +425,10 @@ static void SetReceiving(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x18, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
- LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, dst_process_handle=0x%08X",
- conversion.dst.image_size, conversion.dst.transfer_unit, conversion.dst.gap, cmd_buff[6]);
+ LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, "
+ "dst_process_handle=0x%08X",
+ conversion.dst.image_size, conversion.dst.transfer_unit, conversion.dst.gap,
+ cmd_buff[6]);
}
/**
@@ -486,8 +495,8 @@ static void SetCoefficient(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_DEBUG(Service_Y2R, "called coefficients=[%hX, %hX, %hX, %hX, %hX, %hX, %hX, %hX]",
- coefficients[0], coefficients[1], coefficients[2], coefficients[3],
- coefficients[4], coefficients[5], coefficients[6], coefficients[7]);
+ coefficients[0], coefficients[1], coefficients[2], coefficients[3], coefficients[4],
+ coefficients[5], coefficients[6], coefficients[7]);
}
static void GetCoefficient(Service::Interface* self) {
@@ -575,8 +584,10 @@ static void StartConversion(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
// dst_image_size would seem to be perfect for this, but it doesn't include the gap :(
- u32 total_output_size = conversion.input_lines * (conversion.dst.transfer_unit + conversion.dst.gap);
- Memory::RasterizerFlushAndInvalidateRegion(Memory::VirtualToPhysicalAddress(conversion.dst.address), total_output_size);
+ u32 total_output_size =
+ conversion.input_lines * (conversion.dst.transfer_unit + conversion.dst.gap);
+ Memory::RasterizerFlushAndInvalidateRegion(
+ Memory::VirtualToPhysicalAddress(conversion.dst.address), total_output_size);
HW::Y2R::PerformConversion(conversion);
@@ -648,10 +659,13 @@ cleanup:
cmd_buff[0] = IPC::MakeHeader(0x29, 1, 0);
cmd_buff[1] = result.raw;
- LOG_DEBUG(Service_Y2R, "called input_format=%hhu output_format=%hhu rotation=%hhu block_alignment=%hhu "
- "input_line_width=%hu input_lines=%hu standard_coefficient=%hhu reserved=%hhu alpha=%hX",
- params->input_format, params->output_format, params->rotation, params->block_alignment,
- params->input_line_width, params->input_lines, params->standard_coefficient, params->padding, params->alpha);
+ LOG_DEBUG(
+ Service_Y2R,
+ "called input_format=%hhu output_format=%hhu rotation=%hhu block_alignment=%hhu "
+ "input_line_width=%hu input_lines=%hu standard_coefficient=%hhu reserved=%hhu alpha=%hX",
+ params->input_format, params->output_format, params->rotation, params->block_alignment,
+ params->input_line_width, params->input_lines, params->standard_coefficient,
+ params->padding, params->alpha);
}
static void PingProcess(Service::Interface* self) {
@@ -699,7 +713,6 @@ static void DriverFinalize(Service::Interface* self) {
LOG_DEBUG(Service_Y2R, "called");
}
-
static void GetPackageParameter(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
@@ -711,51 +724,51 @@ static void GetPackageParameter(Service::Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
- {0x00010040, SetInputFormat, "SetInputFormat"},
- {0x00020000, GetInputFormat, "GetInputFormat"},
- {0x00030040, SetOutputFormat, "SetOutputFormat"},
- {0x00040000, GetOutputFormat, "GetOutputFormat"},
- {0x00050040, SetRotation, "SetRotation"},
- {0x00060000, GetRotation, "GetRotation"},
- {0x00070040, SetBlockAlignment, "SetBlockAlignment"},
- {0x00080000, GetBlockAlignment, "GetBlockAlignment"},
- {0x00090040, SetSpacialDithering, "SetSpacialDithering"},
- {0x000A0000, GetSpacialDithering, "GetSpacialDithering"},
- {0x000B0040, SetTemporalDithering, "SetTemporalDithering"},
- {0x000C0000, GetTemporalDithering, "GetTemporalDithering"},
+ {0x00010040, SetInputFormat, "SetInputFormat"},
+ {0x00020000, GetInputFormat, "GetInputFormat"},
+ {0x00030040, SetOutputFormat, "SetOutputFormat"},
+ {0x00040000, GetOutputFormat, "GetOutputFormat"},
+ {0x00050040, SetRotation, "SetRotation"},
+ {0x00060000, GetRotation, "GetRotation"},
+ {0x00070040, SetBlockAlignment, "SetBlockAlignment"},
+ {0x00080000, GetBlockAlignment, "GetBlockAlignment"},
+ {0x00090040, SetSpacialDithering, "SetSpacialDithering"},
+ {0x000A0000, GetSpacialDithering, "GetSpacialDithering"},
+ {0x000B0040, SetTemporalDithering, "SetTemporalDithering"},
+ {0x000C0000, GetTemporalDithering, "GetTemporalDithering"},
{0x000D0040, SetTransferEndInterrupt, "SetTransferEndInterrupt"},
{0x000E0000, GetTransferEndInterrupt, "GetTransferEndInterrupt"},
- {0x000F0000, GetTransferEndEvent, "GetTransferEndEvent"},
- {0x00100102, SetSendingY, "SetSendingY"},
- {0x00110102, SetSendingU, "SetSendingU"},
- {0x00120102, SetSendingV, "SetSendingV"},
- {0x00130102, SetSendingYUYV, "SetSendingYUYV"},
- {0x00140000, IsFinishedSendingYuv, "IsFinishedSendingYuv"},
- {0x00150000, IsFinishedSendingY, "IsFinishedSendingY"},
- {0x00160000, IsFinishedSendingU, "IsFinishedSendingU"},
- {0x00170000, IsFinishedSendingV, "IsFinishedSendingV"},
- {0x00180102, SetReceiving, "SetReceiving"},
- {0x00190000, IsFinishedReceiving, "IsFinishedReceiving"},
- {0x001A0040, SetInputLineWidth, "SetInputLineWidth"},
- {0x001B0000, GetInputLineWidth, "GetInputLineWidth"},
- {0x001C0040, SetInputLines, "SetInputLines"},
- {0x001D0000, GetInputLines, "GetInputLines"},
- {0x001E0100, SetCoefficient, "SetCoefficient"},
- {0x001F0000, GetCoefficient, "GetCoefficient"},
- {0x00200040, SetStandardCoefficient, "SetStandardCoefficient"},
- {0x00210040, GetStandardCoefficient, "GetStandardCoefficient"},
- {0x00220040, SetAlpha, "SetAlpha"},
- {0x00230000, GetAlpha, "GetAlpha"},
- {0x00240200, SetDitheringWeightParams,"SetDitheringWeightParams"},
- {0x00250000, GetDitheringWeightParams,"GetDitheringWeightParams"},
- {0x00260000, StartConversion, "StartConversion"},
- {0x00270000, StopConversion, "StopConversion"},
- {0x00280000, IsBusyConversion, "IsBusyConversion"},
- {0x002901C0, SetPackageParameter, "SetPackageParameter"},
- {0x002A0000, PingProcess, "PingProcess"},
- {0x002B0000, DriverInitialize, "DriverInitialize"},
- {0x002C0000, DriverFinalize, "DriverFinalize"},
- {0x002D0000, GetPackageParameter, "GetPackageParameter"},
+ {0x000F0000, GetTransferEndEvent, "GetTransferEndEvent"},
+ {0x00100102, SetSendingY, "SetSendingY"},
+ {0x00110102, SetSendingU, "SetSendingU"},
+ {0x00120102, SetSendingV, "SetSendingV"},
+ {0x00130102, SetSendingYUYV, "SetSendingYUYV"},
+ {0x00140000, IsFinishedSendingYuv, "IsFinishedSendingYuv"},
+ {0x00150000, IsFinishedSendingY, "IsFinishedSendingY"},
+ {0x00160000, IsFinishedSendingU, "IsFinishedSendingU"},
+ {0x00170000, IsFinishedSendingV, "IsFinishedSendingV"},
+ {0x00180102, SetReceiving, "SetReceiving"},
+ {0x00190000, IsFinishedReceiving, "IsFinishedReceiving"},
+ {0x001A0040, SetInputLineWidth, "SetInputLineWidth"},
+ {0x001B0000, GetInputLineWidth, "GetInputLineWidth"},
+ {0x001C0040, SetInputLines, "SetInputLines"},
+ {0x001D0000, GetInputLines, "GetInputLines"},
+ {0x001E0100, SetCoefficient, "SetCoefficient"},
+ {0x001F0000, GetCoefficient, "GetCoefficient"},
+ {0x00200040, SetStandardCoefficient, "SetStandardCoefficient"},
+ {0x00210040, GetStandardCoefficient, "GetStandardCoefficient"},
+ {0x00220040, SetAlpha, "SetAlpha"},
+ {0x00230000, GetAlpha, "GetAlpha"},
+ {0x00240200, SetDitheringWeightParams, "SetDitheringWeightParams"},
+ {0x00250000, GetDitheringWeightParams, "GetDitheringWeightParams"},
+ {0x00260000, StartConversion, "StartConversion"},
+ {0x00270000, StopConversion, "StopConversion"},
+ {0x00280000, IsBusyConversion, "IsBusyConversion"},
+ {0x002901C0, SetPackageParameter, "SetPackageParameter"},
+ {0x002A0000, PingProcess, "PingProcess"},
+ {0x002B0000, DriverInitialize, "DriverInitialize"},
+ {0x002C0000, DriverFinalize, "DriverFinalize"},
+ {0x002D0000, GetPackageParameter, "GetPackageParameter"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/y2r_u.h b/src/core/hle/service/y2r_u.h
index 95fa2fdb7..1b47b5322 100644
--- a/src/core/hle/service/y2r_u.h
+++ b/src/core/hle/service/y2r_u.h
@@ -6,9 +6,7 @@
#include <array>
#include <string>
-
#include "common/common_types.h"
-
#include "core/hle/result.h"
#include "core/hle/service/service.h"
diff --git a/src/core/hle/shared_page.cpp b/src/core/hle/shared_page.cpp
index 4d9272923..d0d92487d 100644
--- a/src/core/hle/shared_page.cpp
+++ b/src/core/hle/shared_page.cpp
@@ -5,7 +5,6 @@
#include <chrono>
#include <cstring>
#include <ctime>
-
#include "core/core_timing.h"
#include "core/hle/shared_page.h"
@@ -52,8 +51,8 @@ static u64 GetSystemTime() {
}
static void UpdateTimeCallback(u64 userdata, int cycles_late) {
- DateTime& date_time = shared_page.date_time_counter % 2 ?
- shared_page.date_time_0 : shared_page.date_time_1;
+ DateTime& date_time =
+ shared_page.date_time_counter % 2 ? shared_page.date_time_0 : shared_page.date_time_1;
date_time.date_time = GetSystemTime();
date_time.update_tick = CoreTiming::GetTicks();
@@ -74,7 +73,8 @@ void Init() {
// Some games wait until this value becomes 0x1, before asking running_hw
shared_page.unknown_value = 0x1;
- update_time_event = CoreTiming::RegisterEvent("SharedPage::UpdateTimeCallback", UpdateTimeCallback);
+ update_time_event =
+ CoreTiming::RegisterEvent("SharedPage::UpdateTimeCallback", UpdateTimeCallback);
CoreTiming::ScheduleEvent(0, update_time_event);
}
diff --git a/src/core/hle/shared_page.h b/src/core/hle/shared_page.h
index cd9246726..106e47efc 100644
--- a/src/core/hle/shared_page.h
+++ b/src/core/hle/shared_page.h
@@ -13,7 +13,6 @@
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "common/swap.h"
-
#include "core/memory.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -32,27 +31,28 @@ static_assert(sizeof(DateTime) == 0x20, "Datetime size is wrong");
struct SharedPageDef {
// Most of these names are taken from the 3dbrew page linked above.
- u32_le date_time_counter; // 0
- u8 running_hw; // 4
+ u32_le date_time_counter; // 0
+ u8 running_hw; // 4
/// "Microcontroller hardware info"
- u8 mcu_hw_info; // 5
+ u8 mcu_hw_info; // 5
INSERT_PADDING_BYTES(0x20 - 0x6); // 6
DateTime date_time_0; // 20
DateTime date_time_1; // 40
- u8 wifi_macaddr[6]; // 60
- u8 wifi_link_level; // 66
- u8 wifi_unknown2; // 67
+ u8 wifi_macaddr[6]; // 60
+ u8 wifi_link_level; // 66
+ u8 wifi_unknown2; // 67
INSERT_PADDING_BYTES(0x80 - 0x68); // 68
float_le sliderstate_3d; // 80
- u8 ledstate_3d; // 84
+ u8 ledstate_3d; // 84
INSERT_PADDING_BYTES(1); // 85
- u8 unknown_value; // 86
+ u8 unknown_value; // 86
INSERT_PADDING_BYTES(0xA0 - 0x87); // 87
- u64_le menu_title_id; // A0
- u64_le active_menu_title_id; // A8
+ u64_le menu_title_id; // A0
+ u64_le active_menu_title_id; // A8
INSERT_PADDING_BYTES(0x1000 - 0xB0); // B0
};
-static_assert(sizeof(SharedPageDef) == Memory::SHARED_PAGE_SIZE, "Shared page structure size is wrong");
+static_assert(sizeof(SharedPageDef) == Memory::SHARED_PAGE_SIZE,
+ "Shared page structure size is wrong");
extern SharedPageDef shared_page;
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 5d71d5619..02b397eba 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -3,16 +3,14 @@
// Refer to the license.txt file included.
#include <map>
-
#include "common/logging/log.h"
#include "common/microprofile.h"
#include "common/scope_exit.h"
#include "common/string_util.h"
#include "common/symbols.h"
-
-#include "core/core_timing.h"
#include "core/arm/arm_interface.h"
-
+#include "core/core_timing.h"
+#include "core/hle/function_wrappers.h"
#include "core/hle/kernel/address_arbiter.h"
#include "core/hle/kernel/client_port.h"
#include "core/hle/kernel/event.h"
@@ -26,8 +24,6 @@
#include "core/hle/kernel/thread.h"
#include "core/hle/kernel/timer.h"
#include "core/hle/kernel/vm_manager.h"
-
-#include "core/hle/function_wrappers.h"
#include "core/hle/result.h"
#include "core/hle/service/service.h"
@@ -40,43 +36,46 @@ using Kernel::ERR_INVALID_HANDLE;
namespace SVC {
const ResultCode ERR_NOT_FOUND(ErrorDescription::NotFound, ErrorModule::Kernel,
- ErrorSummary::NotFound, ErrorLevel::Permanent); // 0xD88007FA
+ ErrorSummary::NotFound, ErrorLevel::Permanent); // 0xD88007FA
const ResultCode ERR_PORT_NAME_TOO_LONG(ErrorDescription(30), ErrorModule::OS,
- ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E0181E
-
-const ResultCode ERR_MISALIGNED_ADDRESS{ // 0xE0E01BF1
- ErrorDescription::MisalignedAddress, ErrorModule::OS,
- ErrorSummary::InvalidArgument, ErrorLevel::Usage};
-const ResultCode ERR_MISALIGNED_SIZE{ // 0xE0E01BF2
- ErrorDescription::MisalignedSize, ErrorModule::OS,
- ErrorSummary::InvalidArgument, ErrorLevel::Usage};
-const ResultCode ERR_INVALID_COMBINATION{ // 0xE0E01BEE
- ErrorDescription::InvalidCombination, ErrorModule::OS,
- ErrorSummary::InvalidArgument, ErrorLevel::Usage};
+ ErrorSummary::InvalidArgument,
+ ErrorLevel::Usage); // 0xE0E0181E
+
+const ResultCode ERR_MISALIGNED_ADDRESS{// 0xE0E01BF1
+ ErrorDescription::MisalignedAddress, ErrorModule::OS,
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage};
+const ResultCode ERR_MISALIGNED_SIZE{// 0xE0E01BF2
+ ErrorDescription::MisalignedSize, ErrorModule::OS,
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage};
+const ResultCode ERR_INVALID_COMBINATION{// 0xE0E01BEE
+ ErrorDescription::InvalidCombination, ErrorModule::OS,
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage};
enum ControlMemoryOperation {
- MEMOP_FREE = 1,
+ MEMOP_FREE = 1,
MEMOP_RESERVE = 2, // This operation seems to be unsupported in the kernel
- MEMOP_COMMIT = 3,
- MEMOP_MAP = 4,
- MEMOP_UNMAP = 5,
+ MEMOP_COMMIT = 3,
+ MEMOP_MAP = 4,
+ MEMOP_UNMAP = 5,
MEMOP_PROTECT = 6,
MEMOP_OPERATION_MASK = 0xFF,
- MEMOP_REGION_APP = 0x100,
+ MEMOP_REGION_APP = 0x100,
MEMOP_REGION_SYSTEM = 0x200,
- MEMOP_REGION_BASE = 0x300,
- MEMOP_REGION_MASK = 0xF00,
+ MEMOP_REGION_BASE = 0x300,
+ MEMOP_REGION_MASK = 0xF00,
MEMOP_LINEAR = 0x10000,
};
/// Map application or GSP heap memory
-static ResultCode ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) {
+static ResultCode ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1, u32 size,
+ u32 permissions) {
using namespace Kernel;
- LOG_DEBUG(Kernel_SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=0x%X, permissions=0x%08X",
- operation, addr0, addr1, size, permissions);
+ LOG_DEBUG(Kernel_SVC,
+ "called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=0x%X, permissions=0x%08X",
+ operation, addr0, addr1, size, permissions);
if ((addr0 & Memory::PAGE_MASK) != 0 || (addr1 & Memory::PAGE_MASK) != 0) {
return ERR_MISALIGNED_ADDRESS;
@@ -89,7 +88,8 @@ static ResultCode ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 add
operation &= ~MEMOP_REGION_MASK;
if (region != 0) {
- LOG_WARNING(Kernel_SVC, "ControlMemory with specified region not supported, region=%X", region);
+ LOG_WARNING(Kernel_SVC, "ControlMemory with specified region not supported, region=%X",
+ region);
}
if ((permissions & (u32)MemoryPermission::ReadWrite) != permissions) {
@@ -100,15 +100,17 @@ static ResultCode ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 add
auto& process = *g_current_process;
switch (operation & MEMOP_OPERATION_MASK) {
- case MEMOP_FREE:
- {
- // TODO(Subv): What happens if an application tries to FREE a block of memory that has a SharedMemory pointing to it?
+ case MEMOP_FREE: {
+ // TODO(Subv): What happens if an application tries to FREE a block of memory that has a
+ // SharedMemory pointing to it?
if (addr0 >= Memory::HEAP_VADDR && addr0 < Memory::HEAP_VADDR_END) {
ResultCode result = process.HeapFree(addr0, size);
- if (result.IsError()) return result;
+ if (result.IsError())
+ return result;
} else if (addr0 >= process.GetLinearHeapBase() && addr0 < process.GetLinearHeapLimit()) {
ResultCode result = process.LinearFree(addr0, size);
- if (result.IsError()) return result;
+ if (result.IsError())
+ return result;
} else {
return ERR_INVALID_ADDRESS;
}
@@ -116,8 +118,7 @@ static ResultCode ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 add
break;
}
- case MEMOP_COMMIT:
- {
+ case MEMOP_COMMIT: {
if (operation & MEMOP_LINEAR) {
CASCADE_RESULT(*out_addr, process.LinearAllocate(addr0, size, vma_permissions));
} else {
@@ -126,23 +127,26 @@ static ResultCode ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 add
break;
}
- case MEMOP_MAP: // TODO: This is just a hack to avoid regressions until memory aliasing is implemented
- {
- CASCADE_RESULT(*out_addr, process.HeapAllocate(addr0, size, vma_permissions));
- break;
- }
+ case MEMOP_MAP: // TODO: This is just a hack to avoid regressions until memory aliasing is
+ // implemented
+ {
+ CASCADE_RESULT(*out_addr, process.HeapAllocate(addr0, size, vma_permissions));
+ break;
+ }
- case MEMOP_UNMAP: // TODO: This is just a hack to avoid regressions until memory aliasing is implemented
- {
- ResultCode result = process.HeapFree(addr0, size);
- if (result.IsError()) return result;
- break;
- }
+ case MEMOP_UNMAP: // TODO: This is just a hack to avoid regressions until memory aliasing is
+ // implemented
+ {
+ ResultCode result = process.HeapFree(addr0, size);
+ if (result.IsError())
+ return result;
+ break;
+ }
- case MEMOP_PROTECT:
- {
+ case MEMOP_PROTECT: {
ResultCode result = process.vm_manager.ReprotectRange(addr0, size, vma_permissions);
- if (result.IsError()) return result;
+ if (result.IsError())
+ return result;
break;
}
@@ -161,8 +165,9 @@ static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 o
using Kernel::SharedMemory;
using Kernel::MemoryPermission;
- LOG_TRACE(Kernel_SVC, "called memblock=0x%08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d",
- handle, addr, permissions, other_permissions);
+ LOG_TRACE(Kernel_SVC,
+ "called memblock=0x%08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d",
+ handle, addr, permissions, other_permissions);
SharedPtr<SharedMemory> shared_memory = Kernel::g_handle_table.Get<SharedMemory>(handle);
if (shared_memory == nullptr)
@@ -179,12 +184,13 @@ static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 o
case MemoryPermission::ReadWriteExecute:
case MemoryPermission::DontCare:
return shared_memory->Map(Kernel::g_current_process.get(), addr, permissions_type,
- static_cast<MemoryPermission>(other_permissions));
+ static_cast<MemoryPermission>(other_permissions));
default:
LOG_ERROR(Kernel_SVC, "unknown permissions=0x%08X", permissions);
}
- return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
+ return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS,
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage);
}
static ResultCode UnmapMemoryBlock(Handle handle, u32 addr) {
@@ -249,7 +255,7 @@ static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) {
return ERR_INVALID_HANDLE;
LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle,
- object->GetTypeName().c_str(), object->GetName().c_str(), nano_seconds);
+ object->GetTypeName().c_str(), object->GetName().c_str(), nano_seconds);
HLE::Reschedule(__func__);
@@ -257,7 +263,7 @@ static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) {
if (object->ShouldWait()) {
object->AddWaitingThread(thread);
- Kernel::WaitCurrentThread_WaitSynchronization({ object }, false, false);
+ Kernel::WaitCurrentThread_WaitSynchronization({object}, false, false);
// Create an event to wake the thread up after the specified nanosecond delay has passed
thread->WakeAfterDelay(nano_seconds);
@@ -272,7 +278,8 @@ static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) {
}
/// Wait for the given handles to synchronize, timeout after the specified nanoseconds
-static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count, bool wait_all, s64 nano_seconds) {
+static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count, bool wait_all,
+ s64 nano_seconds) {
bool wait_thread = !wait_all;
int handle_index = 0;
Kernel::Thread* thread = Kernel::GetCurrentThread();
@@ -281,7 +288,8 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
// Check if 'handles' is invalid
if (handles == nullptr)
- return ResultCode(ErrorDescription::InvalidPointer, ErrorModule::Kernel, ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
+ return ResultCode(ErrorDescription::InvalidPointer, ErrorModule::Kernel,
+ ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
// NOTE: on real hardware, there is no nullptr check for 'out' (tested with firmware 4.4). If
// this happens, the running application will crash.
@@ -289,7 +297,8 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
// Check if 'handle_count' is invalid
if (handle_count < 0)
- return ResultCode(ErrorDescription::OutOfRange, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
+ return ResultCode(ErrorDescription::OutOfRange, ErrorModule::OS,
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage);
// If 'handle_count' is non-zero, iterate through each handle and wait the current thread if
// necessary
@@ -329,7 +338,9 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
}
}
- SCOPE_EXIT({HLE::Reschedule("WaitSynchronizationN");}); // Reschedule after putting the threads to sleep.
+ SCOPE_EXIT({
+ HLE::Reschedule("WaitSynchronizationN");
+ }); // Reschedule after putting the threads to sleep.
// If thread should wait, then set its state to waiting
if (wait_thread) {
@@ -386,18 +397,19 @@ static ResultCode CreateAddressArbiter(Handle* out_handle) {
}
/// Arbitrate address
-static ResultCode ArbitrateAddress(Handle handle, u32 address, u32 type, u32 value, s64 nanoseconds) {
+static ResultCode ArbitrateAddress(Handle handle, u32 address, u32 type, u32 value,
+ s64 nanoseconds) {
using Kernel::AddressArbiter;
LOG_TRACE(Kernel_SVC, "called handle=0x%08X, address=0x%08X, type=0x%08X, value=0x%08X", handle,
- address, type, value);
+ address, type, value);
SharedPtr<AddressArbiter> arbiter = Kernel::g_handle_table.Get<AddressArbiter>(handle);
if (arbiter == nullptr)
return ERR_INVALID_HANDLE;
- auto res = arbiter->ArbitrateAddress(static_cast<Kernel::ArbitrationType>(type),
- address, value, nanoseconds);
+ auto res = arbiter->ArbitrateAddress(static_cast<Kernel::ArbitrationType>(type), address, value,
+ nanoseconds);
return res;
}
@@ -406,10 +418,18 @@ static void Break(u8 break_reason) {
LOG_CRITICAL(Debug_Emulated, "Emulated program broke execution!");
std::string reason_str;
switch (break_reason) {
- case 0: reason_str = "PANIC"; break;
- case 1: reason_str = "ASSERT"; break;
- case 2: reason_str = "USER"; break;
- default: reason_str = "UNKNOWN"; break;
+ case 0:
+ reason_str = "PANIC";
+ break;
+ case 1:
+ reason_str = "ASSERT";
+ break;
+ case 2:
+ reason_str = "USER";
+ break;
+ default:
+ reason_str = "UNKNOWN";
+ break;
}
LOG_CRITICAL(Debug_Emulated, "Break reason: %s", reason_str.c_str());
}
@@ -423,7 +443,8 @@ static void OutputDebugString(const char* string) {
static ResultCode GetResourceLimit(Handle* resource_limit, Handle process_handle) {
LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle);
- SharedPtr<Kernel::Process> process = Kernel::g_handle_table.Get<Kernel::Process>(process_handle);
+ SharedPtr<Kernel::Process> process =
+ Kernel::g_handle_table.Get<Kernel::Process>(process_handle);
if (process == nullptr)
return ERR_INVALID_HANDLE;
@@ -433,12 +454,13 @@ static ResultCode GetResourceLimit(Handle* resource_limit, Handle process_handle
}
/// Get resource limit current values
-static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_limit_handle, u32* names,
- u32 name_count) {
+static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_limit_handle,
+ u32* names, u32 name_count) {
LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%p, name_count=%d",
- resource_limit_handle, names, name_count);
+ resource_limit_handle, names, name_count);
- SharedPtr<Kernel::ResourceLimit> resource_limit = Kernel::g_handle_table.Get<Kernel::ResourceLimit>(resource_limit_handle);
+ SharedPtr<Kernel::ResourceLimit> resource_limit =
+ Kernel::g_handle_table.Get<Kernel::ResourceLimit>(resource_limit_handle);
if (resource_limit == nullptr)
return ERR_INVALID_HANDLE;
@@ -450,11 +472,12 @@ static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_lim
/// Get resource limit max values
static ResultCode GetResourceLimitLimitValues(s64* values, Handle resource_limit_handle, u32* names,
- u32 name_count) {
+ u32 name_count) {
LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%p, name_count=%d",
- resource_limit_handle, names, name_count);
+ resource_limit_handle, names, name_count);
- SharedPtr<Kernel::ResourceLimit> resource_limit = Kernel::g_handle_table.Get<Kernel::ResourceLimit>(resource_limit_handle);
+ SharedPtr<Kernel::ResourceLimit> resource_limit =
+ Kernel::g_handle_table.Get<Kernel::ResourceLimit>(resource_limit_handle);
if (resource_limit == nullptr)
return ERR_INVALID_HANDLE;
@@ -465,7 +488,8 @@ static ResultCode GetResourceLimitLimitValues(s64* values, Handle resource_limit
}
/// Creates a new thread
-static ResultCode CreateThread(Handle* out_handle, s32 priority, u32 entry_point, u32 arg, u32 stack_top, s32 processor_id) {
+static ResultCode CreateThread(Handle* out_handle, s32 priority, u32 entry_point, u32 arg,
+ u32 stack_top, s32 processor_id) {
using Kernel::Thread;
std::string name;
@@ -499,20 +523,23 @@ static ResultCode CreateThread(Handle* out_handle, s32 priority, u32 entry_point
}
if (processor_id == THREADPROCESSORID_1 || processor_id == THREADPROCESSORID_ALL ||
- (processor_id == THREADPROCESSORID_DEFAULT && Kernel::g_current_process->ideal_processor == THREADPROCESSORID_1)) {
- LOG_WARNING(Kernel_SVC, "Newly created thread is allowed to be run in the SysCore, unimplemented.");
+ (processor_id == THREADPROCESSORID_DEFAULT &&
+ Kernel::g_current_process->ideal_processor == THREADPROCESSORID_1)) {
+ LOG_WARNING(Kernel_SVC,
+ "Newly created thread is allowed to be run in the SysCore, unimplemented.");
}
- CASCADE_RESULT(SharedPtr<Thread> thread, Kernel::Thread::Create(
- name, entry_point, priority, arg, processor_id, stack_top));
+ CASCADE_RESULT(SharedPtr<Thread> thread, Kernel::Thread::Create(name, entry_point, priority,
+ arg, processor_id, stack_top));
- thread->context.fpscr = FPSCR_DEFAULT_NAN | FPSCR_FLUSH_TO_ZERO | FPSCR_ROUND_TOZERO; // 0x03C00000
+ thread->context.fpscr =
+ FPSCR_DEFAULT_NAN | FPSCR_FLUSH_TO_ZERO | FPSCR_ROUND_TOZERO; // 0x03C00000
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(thread)));
LOG_TRACE(Kernel_SVC, "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, "
- "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point,
- name.c_str(), arg, stack_top, priority, processor_id, *out_handle);
+ "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X",
+ entry_point, name.c_str(), arg, stack_top, priority, processor_id, *out_handle);
return RESULT_SUCCESS;
}
@@ -552,7 +579,7 @@ static ResultCode CreateMutex(Handle* out_handle, u32 initial_locked) {
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(mutex)));
LOG_TRACE(Kernel_SVC, "called initial_locked=%s : created handle=0x%08X",
- initial_locked ? "true" : "false", *out_handle);
+ initial_locked ? "true" : "false", *out_handle);
return RESULT_SUCCESS;
}
@@ -576,7 +603,8 @@ static ResultCode ReleaseMutex(Handle handle) {
static ResultCode GetProcessId(u32* process_id, Handle process_handle) {
LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle);
- const SharedPtr<Kernel::Process> process = Kernel::g_handle_table.Get<Kernel::Process>(process_handle);
+ const SharedPtr<Kernel::Process> process =
+ Kernel::g_handle_table.Get<Kernel::Process>(process_handle);
if (process == nullptr)
return ERR_INVALID_HANDLE;
@@ -588,7 +616,8 @@ static ResultCode GetProcessId(u32* process_id, Handle process_handle) {
static ResultCode GetProcessIdOfThread(u32* process_id, Handle thread_handle) {
LOG_TRACE(Kernel_SVC, "called thread=0x%08X", thread_handle);
- const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(thread_handle);
+ const SharedPtr<Kernel::Thread> thread =
+ Kernel::g_handle_table.Get<Kernel::Thread>(thread_handle);
if (thread == nullptr)
return ERR_INVALID_HANDLE;
@@ -620,7 +649,7 @@ static ResultCode CreateSemaphore(Handle* out_handle, s32 initial_count, s32 max
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(semaphore)));
LOG_TRACE(Kernel_SVC, "called initial_count=%d, max_count=%d, created handle=0x%08X",
- initial_count, max_count, *out_handle);
+ initial_count, max_count, *out_handle);
return RESULT_SUCCESS;
}
@@ -640,7 +669,8 @@ static ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count)
}
/// Query process memory
-static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_info, Handle process_handle, u32 addr) {
+static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_info,
+ Handle process_handle, u32 addr) {
using Kernel::Process;
Kernel::SharedPtr<Process> process = Kernel::g_handle_table.Get<Process>(process_handle);
if (process == nullptr)
@@ -649,7 +679,8 @@ static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_inf
auto vma = process->vm_manager.FindVMA(addr);
if (vma == Kernel::g_current_process->vm_manager.vma_map.end())
- return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
+ return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::OS,
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage);
memory_info->base_address = vma->second.base;
memory_info->permission = static_cast<u32>(vma->second.permissions);
@@ -673,8 +704,8 @@ static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) {
SharedPtr<Event> evt = Event::Create(static_cast<Kernel::ResetType>(reset_type));
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(evt)));
- LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X",
- reset_type, *out_handle);
+ LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type,
+ *out_handle);
return RESULT_SUCCESS;
}
@@ -719,8 +750,8 @@ static ResultCode CreateTimer(Handle* out_handle, u32 reset_type) {
SharedPtr<Timer> timer = Timer::Create(static_cast<Kernel::ResetType>(reset_type));
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(timer)));
- LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X",
- reset_type, *out_handle);
+ LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type,
+ *out_handle);
return RESULT_SUCCESS;
}
@@ -783,17 +814,19 @@ static void SleepThread(s64 nanoseconds) {
static s64 GetSystemTick() {
s64 result = CoreTiming::GetTicks();
// Advance time to defeat dumb games (like Cubic Ninja) that busy-wait for the frame to end.
- Core::g_app_core->AddTicks(150); // Measured time between two calls on a 9.2 o3DS with Ninjhax 1.1b
+ Core::g_app_core->AddTicks(
+ 150); // Measured time between two calls on a 9.2 o3DS with Ninjhax 1.1b
return result;
}
/// Creates a memory block at the specified address with the specified permissions and size
static ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32 my_permission,
- u32 other_permission) {
+ u32 other_permission) {
using Kernel::SharedMemory;
if (size % Memory::PAGE_SIZE != 0)
- return ResultCode(ErrorDescription::MisalignedSize, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
+ return ResultCode(ErrorDescription::MisalignedSize, ErrorModule::OS,
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage);
SharedPtr<SharedMemory> shared_memory = nullptr;
@@ -818,25 +851,29 @@ static ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
if (addr < Memory::PROCESS_IMAGE_VADDR || addr + size > Memory::SHARED_MEMORY_VADDR_END) {
- return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
+ return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::OS,
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage);
}
// When trying to create a memory block with address = 0,
// if the process has the Shared Device Memory flag in the exheader,
- // then we have to allocate from the same region as the caller process instead of the BASE region.
+ // then we have to allocate from the same region as the caller process instead of the BASE
+ // region.
Kernel::MemoryRegion region = Kernel::MemoryRegion::BASE;
if (addr == 0 && Kernel::g_current_process->flags.shared_device_mem)
region = Kernel::g_current_process->flags.memory_region;
- shared_memory = SharedMemory::Create(Kernel::g_current_process, size,
- static_cast<MemoryPermission>(my_permission), static_cast<MemoryPermission>(other_permission), addr, region);
+ shared_memory = SharedMemory::Create(
+ Kernel::g_current_process, size, static_cast<MemoryPermission>(my_permission),
+ static_cast<MemoryPermission>(other_permission), addr, region);
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(shared_memory)));
LOG_WARNING(Kernel_SVC, "called addr=0x%08X", addr);
return RESULT_SUCCESS;
}
-static ResultCode CreatePort(Handle* server_port, Handle* client_port, const char* name, u32 max_sessions) {
+static ResultCode CreatePort(Handle* server_port, Handle* client_port, const char* name,
+ u32 max_sessions) {
// TODO(Subv): Implement named ports.
ASSERT_MSG(name == nullptr, "Named ports are currently unimplemented");
@@ -845,9 +882,12 @@ static ResultCode CreatePort(Handle* server_port, Handle* client_port, const cha
using Kernel::SharedPtr;
auto ports = ServerPort::CreatePortPair(max_sessions);
- CASCADE_RESULT(*client_port, Kernel::g_handle_table.Create(std::move(std::get<SharedPtr<ClientPort>>(ports))));
- // Note: The 3DS kernel also leaks the client port handle if the server port handle fails to be created.
- CASCADE_RESULT(*server_port, Kernel::g_handle_table.Create(std::move(std::get<SharedPtr<ServerPort>>(ports))));
+ CASCADE_RESULT(*client_port, Kernel::g_handle_table.Create(
+ std::move(std::get<SharedPtr<ClientPort>>(ports))));
+ // Note: The 3DS kernel also leaks the client port handle if the server port handle fails to be
+ // created.
+ CASCADE_RESULT(*server_port, Kernel::g_handle_table.Create(
+ std::move(std::get<SharedPtr<ServerPort>>(ports))));
LOG_TRACE(Kernel_SVC, "called max_sessions=%u", max_sessions);
return RESULT_SUCCESS;
@@ -862,9 +902,9 @@ static ResultCode GetSystemInfo(s64* out, u32 type, s32 param) {
case SystemInfoType::REGION_MEMORY_USAGE:
switch ((SystemInfoMemUsageRegion)param) {
case SystemInfoMemUsageRegion::ALL:
- *out = Kernel::GetMemoryRegion(Kernel::MemoryRegion::APPLICATION)->used
- + Kernel::GetMemoryRegion(Kernel::MemoryRegion::SYSTEM)->used
- + Kernel::GetMemoryRegion(Kernel::MemoryRegion::BASE)->used;
+ *out = Kernel::GetMemoryRegion(Kernel::MemoryRegion::APPLICATION)->used +
+ Kernel::GetMemoryRegion(Kernel::MemoryRegion::SYSTEM)->used +
+ Kernel::GetMemoryRegion(Kernel::MemoryRegion::BASE)->used;
break;
case SystemInfoMemUsageRegion::APPLICATION:
*out = Kernel::GetMemoryRegion(Kernel::MemoryRegion::APPLICATION)->used;
@@ -912,7 +952,7 @@ static ResultCode GetProcessInfo(s64* out, Handle process_handle, u32 type) {
// TODO(yuriks): Type 0 returns a slightly higher number than type 2, but I'm not sure
// what's the difference between them.
*out = process->heap_used + process->linear_heap_used + process->misc_memory_used;
- if(*out % Memory::PAGE_SIZE != 0) {
+ if (*out % Memory::PAGE_SIZE != 0) {
LOG_ERROR(Kernel_SVC, "called, memory size not page-aligned");
return ERR_MISALIGNED_SIZE;
}
@@ -935,12 +975,12 @@ static ResultCode GetProcessInfo(s64* out, Handle process_handle, u32 type) {
if (type >= 21 && type <= 23) {
return ResultCode( // 0xE0E01BF4
- ErrorDescription::NotImplemented, ErrorModule::OS,
- ErrorSummary::InvalidArgument, ErrorLevel::Usage);
+ ErrorDescription::NotImplemented, ErrorModule::OS, ErrorSummary::InvalidArgument,
+ ErrorLevel::Usage);
} else {
return ResultCode( // 0xD8E007ED
- ErrorDescription::InvalidEnumValue, ErrorModule::Kernel,
- ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
+ ErrorDescription::InvalidEnumValue, ErrorModule::Kernel,
+ ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
}
break;
}
@@ -949,142 +989,142 @@ static ResultCode GetProcessInfo(s64* out, Handle process_handle, u32 type) {
}
namespace {
- struct FunctionDef {
- using Func = void();
+struct FunctionDef {
+ using Func = void();
- u32 id;
- Func* func;
- const char* name;
- };
+ u32 id;
+ Func* func;
+ const char* name;
+};
}
static const FunctionDef SVC_Table[] = {
- {0x00, nullptr, "Unknown"},
- {0x01, HLE::Wrap<ControlMemory>, "ControlMemory"},
- {0x02, HLE::Wrap<QueryMemory>, "QueryMemory"},
- {0x03, nullptr, "ExitProcess"},
- {0x04, nullptr, "GetProcessAffinityMask"},
- {0x05, nullptr, "SetProcessAffinityMask"},
- {0x06, nullptr, "GetProcessIdealProcessor"},
- {0x07, nullptr, "SetProcessIdealProcessor"},
- {0x08, HLE::Wrap<CreateThread>, "CreateThread"},
- {0x09, ExitThread, "ExitThread"},
- {0x0A, HLE::Wrap<SleepThread>, "SleepThread"},
- {0x0B, HLE::Wrap<GetThreadPriority>, "GetThreadPriority"},
- {0x0C, HLE::Wrap<SetThreadPriority>, "SetThreadPriority"},
- {0x0D, nullptr, "GetThreadAffinityMask"},
- {0x0E, nullptr, "SetThreadAffinityMask"},
- {0x0F, nullptr, "GetThreadIdealProcessor"},
- {0x10, nullptr, "SetThreadIdealProcessor"},
- {0x11, nullptr, "GetCurrentProcessorNumber"},
- {0x12, nullptr, "Run"},
- {0x13, HLE::Wrap<CreateMutex>, "CreateMutex"},
- {0x14, HLE::Wrap<ReleaseMutex>, "ReleaseMutex"},
- {0x15, HLE::Wrap<CreateSemaphore>, "CreateSemaphore"},
- {0x16, HLE::Wrap<ReleaseSemaphore>, "ReleaseSemaphore"},
- {0x17, HLE::Wrap<CreateEvent>, "CreateEvent"},
- {0x18, HLE::Wrap<SignalEvent>, "SignalEvent"},
- {0x19, HLE::Wrap<ClearEvent>, "ClearEvent"},
- {0x1A, HLE::Wrap<CreateTimer>, "CreateTimer"},
- {0x1B, HLE::Wrap<SetTimer>, "SetTimer"},
- {0x1C, HLE::Wrap<CancelTimer>, "CancelTimer"},
- {0x1D, HLE::Wrap<ClearTimer>, "ClearTimer"},
- {0x1E, HLE::Wrap<CreateMemoryBlock>, "CreateMemoryBlock"},
- {0x1F, HLE::Wrap<MapMemoryBlock>, "MapMemoryBlock"},
- {0x20, HLE::Wrap<UnmapMemoryBlock>, "UnmapMemoryBlock"},
+ {0x00, nullptr, "Unknown"},
+ {0x01, HLE::Wrap<ControlMemory>, "ControlMemory"},
+ {0x02, HLE::Wrap<QueryMemory>, "QueryMemory"},
+ {0x03, nullptr, "ExitProcess"},
+ {0x04, nullptr, "GetProcessAffinityMask"},
+ {0x05, nullptr, "SetProcessAffinityMask"},
+ {0x06, nullptr, "GetProcessIdealProcessor"},
+ {0x07, nullptr, "SetProcessIdealProcessor"},
+ {0x08, HLE::Wrap<CreateThread>, "CreateThread"},
+ {0x09, ExitThread, "ExitThread"},
+ {0x0A, HLE::Wrap<SleepThread>, "SleepThread"},
+ {0x0B, HLE::Wrap<GetThreadPriority>, "GetThreadPriority"},
+ {0x0C, HLE::Wrap<SetThreadPriority>, "SetThreadPriority"},
+ {0x0D, nullptr, "GetThreadAffinityMask"},
+ {0x0E, nullptr, "SetThreadAffinityMask"},
+ {0x0F, nullptr, "GetThreadIdealProcessor"},
+ {0x10, nullptr, "SetThreadIdealProcessor"},
+ {0x11, nullptr, "GetCurrentProcessorNumber"},
+ {0x12, nullptr, "Run"},
+ {0x13, HLE::Wrap<CreateMutex>, "CreateMutex"},
+ {0x14, HLE::Wrap<ReleaseMutex>, "ReleaseMutex"},
+ {0x15, HLE::Wrap<CreateSemaphore>, "CreateSemaphore"},
+ {0x16, HLE::Wrap<ReleaseSemaphore>, "ReleaseSemaphore"},
+ {0x17, HLE::Wrap<CreateEvent>, "CreateEvent"},
+ {0x18, HLE::Wrap<SignalEvent>, "SignalEvent"},
+ {0x19, HLE::Wrap<ClearEvent>, "ClearEvent"},
+ {0x1A, HLE::Wrap<CreateTimer>, "CreateTimer"},
+ {0x1B, HLE::Wrap<SetTimer>, "SetTimer"},
+ {0x1C, HLE::Wrap<CancelTimer>, "CancelTimer"},
+ {0x1D, HLE::Wrap<ClearTimer>, "ClearTimer"},
+ {0x1E, HLE::Wrap<CreateMemoryBlock>, "CreateMemoryBlock"},
+ {0x1F, HLE::Wrap<MapMemoryBlock>, "MapMemoryBlock"},
+ {0x20, HLE::Wrap<UnmapMemoryBlock>, "UnmapMemoryBlock"},
{0x21, HLE::Wrap<CreateAddressArbiter>, "CreateAddressArbiter"},
- {0x22, HLE::Wrap<ArbitrateAddress>, "ArbitrateAddress"},
- {0x23, HLE::Wrap<CloseHandle>, "CloseHandle"},
+ {0x22, HLE::Wrap<ArbitrateAddress>, "ArbitrateAddress"},
+ {0x23, HLE::Wrap<CloseHandle>, "CloseHandle"},
{0x24, HLE::Wrap<WaitSynchronization1>, "WaitSynchronization1"},
{0x25, HLE::Wrap<WaitSynchronizationN>, "WaitSynchronizationN"},
- {0x26, nullptr, "SignalAndWait"},
- {0x27, HLE::Wrap<DuplicateHandle>, "DuplicateHandle"},
- {0x28, HLE::Wrap<GetSystemTick>, "GetSystemTick"},
- {0x29, nullptr, "GetHandleInfo"},
- {0x2A, HLE::Wrap<GetSystemInfo>, "GetSystemInfo"},
- {0x2B, HLE::Wrap<GetProcessInfo>, "GetProcessInfo"},
- {0x2C, nullptr, "GetThreadInfo"},
- {0x2D, HLE::Wrap<ConnectToPort>, "ConnectToPort"},
- {0x2E, nullptr, "SendSyncRequest1"},
- {0x2F, nullptr, "SendSyncRequest2"},
- {0x30, nullptr, "SendSyncRequest3"},
- {0x31, nullptr, "SendSyncRequest4"},
- {0x32, HLE::Wrap<SendSyncRequest>, "SendSyncRequest"},
- {0x33, nullptr, "OpenProcess"},
- {0x34, nullptr, "OpenThread"},
- {0x35, HLE::Wrap<GetProcessId>, "GetProcessId"},
+ {0x26, nullptr, "SignalAndWait"},
+ {0x27, HLE::Wrap<DuplicateHandle>, "DuplicateHandle"},
+ {0x28, HLE::Wrap<GetSystemTick>, "GetSystemTick"},
+ {0x29, nullptr, "GetHandleInfo"},
+ {0x2A, HLE::Wrap<GetSystemInfo>, "GetSystemInfo"},
+ {0x2B, HLE::Wrap<GetProcessInfo>, "GetProcessInfo"},
+ {0x2C, nullptr, "GetThreadInfo"},
+ {0x2D, HLE::Wrap<ConnectToPort>, "ConnectToPort"},
+ {0x2E, nullptr, "SendSyncRequest1"},
+ {0x2F, nullptr, "SendSyncRequest2"},
+ {0x30, nullptr, "SendSyncRequest3"},
+ {0x31, nullptr, "SendSyncRequest4"},
+ {0x32, HLE::Wrap<SendSyncRequest>, "SendSyncRequest"},
+ {0x33, nullptr, "OpenProcess"},
+ {0x34, nullptr, "OpenThread"},
+ {0x35, HLE::Wrap<GetProcessId>, "GetProcessId"},
{0x36, HLE::Wrap<GetProcessIdOfThread>, "GetProcessIdOfThread"},
- {0x37, HLE::Wrap<GetThreadId>, "GetThreadId"},
- {0x38, HLE::Wrap<GetResourceLimit>, "GetResourceLimit"},
+ {0x37, HLE::Wrap<GetThreadId>, "GetThreadId"},
+ {0x38, HLE::Wrap<GetResourceLimit>, "GetResourceLimit"},
{0x39, HLE::Wrap<GetResourceLimitLimitValues>, "GetResourceLimitLimitValues"},
{0x3A, HLE::Wrap<GetResourceLimitCurrentValues>, "GetResourceLimitCurrentValues"},
- {0x3B, nullptr, "GetThreadContext"},
- {0x3C, HLE::Wrap<Break>, "Break"},
- {0x3D, HLE::Wrap<OutputDebugString>, "OutputDebugString"},
- {0x3E, nullptr, "ControlPerformanceCounter"},
- {0x3F, nullptr, "Unknown"},
- {0x40, nullptr, "Unknown"},
- {0x41, nullptr, "Unknown"},
- {0x42, nullptr, "Unknown"},
- {0x43, nullptr, "Unknown"},
- {0x44, nullptr, "Unknown"},
- {0x45, nullptr, "Unknown"},
- {0x46, nullptr, "Unknown"},
- {0x47, HLE::Wrap<CreatePort>, "CreatePort"},
- {0x48, nullptr, "CreateSessionToPort"},
- {0x49, nullptr, "CreateSession"},
- {0x4A, nullptr, "AcceptSession"},
- {0x4B, nullptr, "ReplyAndReceive1"},
- {0x4C, nullptr, "ReplyAndReceive2"},
- {0x4D, nullptr, "ReplyAndReceive3"},
- {0x4E, nullptr, "ReplyAndReceive4"},
- {0x4F, nullptr, "ReplyAndReceive"},
- {0x50, nullptr, "BindInterrupt"},
- {0x51, nullptr, "UnbindInterrupt"},
- {0x52, nullptr, "InvalidateProcessDataCache"},
- {0x53, nullptr, "StoreProcessDataCache"},
- {0x54, nullptr, "FlushProcessDataCache"},
- {0x55, nullptr, "StartInterProcessDma"},
- {0x56, nullptr, "StopDma"},
- {0x57, nullptr, "GetDmaState"},
- {0x58, nullptr, "RestartDma"},
- {0x59, nullptr, "Unknown"},
- {0x5A, nullptr, "Unknown"},
- {0x5B, nullptr, "Unknown"},
- {0x5C, nullptr, "Unknown"},
- {0x5D, nullptr, "Unknown"},
- {0x5E, nullptr, "Unknown"},
- {0x5F, nullptr, "Unknown"},
- {0x60, nullptr, "DebugActiveProcess"},
- {0x61, nullptr, "BreakDebugProcess"},
- {0x62, nullptr, "TerminateDebugProcess"},
- {0x63, nullptr, "GetProcessDebugEvent"},
- {0x64, nullptr, "ContinueDebugEvent"},
- {0x65, nullptr, "GetProcessList"},
- {0x66, nullptr, "GetThreadList"},
- {0x67, nullptr, "GetDebugThreadContext"},
- {0x68, nullptr, "SetDebugThreadContext"},
- {0x69, nullptr, "QueryDebugProcessMemory"},
- {0x6A, nullptr, "ReadProcessMemory"},
- {0x6B, nullptr, "WriteProcessMemory"},
- {0x6C, nullptr, "SetHardwareBreakPoint"},
- {0x6D, nullptr, "GetDebugThreadParam"},
- {0x6E, nullptr, "Unknown"},
- {0x6F, nullptr, "Unknown"},
- {0x70, nullptr, "ControlProcessMemory"},
- {0x71, nullptr, "MapProcessMemory"},
- {0x72, nullptr, "UnmapProcessMemory"},
- {0x73, nullptr, "CreateCodeSet"},
- {0x74, nullptr, "RandomStub"},
- {0x75, nullptr, "CreateProcess"},
- {0x76, nullptr, "TerminateProcess"},
- {0x77, nullptr, "SetProcessResourceLimits"},
- {0x78, nullptr, "CreateResourceLimit"},
- {0x79, nullptr, "SetResourceLimitValues"},
- {0x7A, nullptr, "AddCodeSegment"},
- {0x7B, nullptr, "Backdoor"},
- {0x7C, nullptr, "KernelSetState"},
- {0x7D, HLE::Wrap<QueryProcessMemory>, "QueryProcessMemory"},
+ {0x3B, nullptr, "GetThreadContext"},
+ {0x3C, HLE::Wrap<Break>, "Break"},
+ {0x3D, HLE::Wrap<OutputDebugString>, "OutputDebugString"},
+ {0x3E, nullptr, "ControlPerformanceCounter"},
+ {0x3F, nullptr, "Unknown"},
+ {0x40, nullptr, "Unknown"},
+ {0x41, nullptr, "Unknown"},
+ {0x42, nullptr, "Unknown"},
+ {0x43, nullptr, "Unknown"},
+ {0x44, nullptr, "Unknown"},
+ {0x45, nullptr, "Unknown"},
+ {0x46, nullptr, "Unknown"},
+ {0x47, HLE::Wrap<CreatePort>, "CreatePort"},
+ {0x48, nullptr, "CreateSessionToPort"},
+ {0x49, nullptr, "CreateSession"},
+ {0x4A, nullptr, "AcceptSession"},
+ {0x4B, nullptr, "ReplyAndReceive1"},
+ {0x4C, nullptr, "ReplyAndReceive2"},
+ {0x4D, nullptr, "ReplyAndReceive3"},
+ {0x4E, nullptr, "ReplyAndReceive4"},
+ {0x4F, nullptr, "ReplyAndReceive"},
+ {0x50, nullptr, "BindInterrupt"},
+ {0x51, nullptr, "UnbindInterrupt"},
+ {0x52, nullptr, "InvalidateProcessDataCache"},
+ {0x53, nullptr, "StoreProcessDataCache"},
+ {0x54, nullptr, "FlushProcessDataCache"},
+ {0x55, nullptr, "StartInterProcessDma"},
+ {0x56, nullptr, "StopDma"},
+ {0x57, nullptr, "GetDmaState"},
+ {0x58, nullptr, "RestartDma"},
+ {0x59, nullptr, "Unknown"},
+ {0x5A, nullptr, "Unknown"},
+ {0x5B, nullptr, "Unknown"},
+ {0x5C, nullptr, "Unknown"},
+ {0x5D, nullptr, "Unknown"},
+ {0x5E, nullptr, "Unknown"},
+ {0x5F, nullptr, "Unknown"},
+ {0x60, nullptr, "DebugActiveProcess"},
+ {0x61, nullptr, "BreakDebugProcess"},
+ {0x62, nullptr, "TerminateDebugProcess"},
+ {0x63, nullptr, "GetProcessDebugEvent"},
+ {0x64, nullptr, "ContinueDebugEvent"},
+ {0x65, nullptr, "GetProcessList"},
+ {0x66, nullptr, "GetThreadList"},
+ {0x67, nullptr, "GetDebugThreadContext"},
+ {0x68, nullptr, "SetDebugThreadContext"},
+ {0x69, nullptr, "QueryDebugProcessMemory"},
+ {0x6A, nullptr, "ReadProcessMemory"},
+ {0x6B, nullptr, "WriteProcessMemory"},
+ {0x6C, nullptr, "SetHardwareBreakPoint"},
+ {0x6D, nullptr, "GetDebugThreadParam"},
+ {0x6E, nullptr, "Unknown"},
+ {0x6F, nullptr, "Unknown"},
+ {0x70, nullptr, "ControlProcessMemory"},
+ {0x71, nullptr, "MapProcessMemory"},
+ {0x72, nullptr, "UnmapProcessMemory"},
+ {0x73, nullptr, "CreateCodeSet"},
+ {0x74, nullptr, "RandomStub"},
+ {0x75, nullptr, "CreateProcess"},
+ {0x76, nullptr, "TerminateProcess"},
+ {0x77, nullptr, "SetProcessResourceLimits"},
+ {0x78, nullptr, "CreateResourceLimit"},
+ {0x79, nullptr, "SetResourceLimitValues"},
+ {0x7A, nullptr, "AddCodeSegment"},
+ {0x7B, nullptr, "Backdoor"},
+ {0x7C, nullptr, "KernelSetState"},
+ {0x7D, HLE::Wrap<QueryProcessMemory>, "QueryProcessMemory"},
};
static const FunctionDef* GetSVCInfo(u32 func_num) {