namespace sts -> namespace ams

namespace sts::ams -> ams::exosphere, ams::.

This is to facilitate future use of ams:: namespace code in
mesosphere, as we'll want to include ams::util, ams::result, ams::svc...
This commit is contained in:
Michael Scire 2019-10-24 02:30:10 -07:00 committed by SciresM
parent 4059dc6187
commit 8cb77ac136
397 changed files with 968 additions and 926 deletions

View file

@ -46,7 +46,7 @@ extern "C" {
void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx);
}
sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::AtmosphereMitm;
ams::ncm::TitleId __stratosphere_title_id = ams::ncm::TitleId::AtmosphereMitm;
void __libnx_exception_handler(ThreadExceptionDump *ctx) {
StratosphereCrashHandler(ctx);
@ -93,7 +93,7 @@ void __appExit(void) {
int main(int argc, char **argv)
{
consoleDebugInit(debugDevice_SVC);
sts::os::Thread initializer_thread;
ams::os::Thread initializer_thread;
LaunchAllMitmModules();

View file

@ -27,7 +27,7 @@
#include "ns_mitm/nsmitm_main.hpp"
#include "hid_mitm/hidmitm_main.hpp"
static sts::os::Thread g_module_threads[MitmModuleId_Count];
static ams::os::Thread g_module_threads[MitmModuleId_Count];
static const struct {
ThreadFunc main;

View file

@ -27,17 +27,17 @@ class BpcMitmService : public IMitmServiceObject {
RebootSystem = 1,
};
public:
BpcMitmService(std::shared_ptr<Service> s, u64 pid, sts::ncm::TitleId tid) : IMitmServiceObject(s, pid, tid) {
BpcMitmService(std::shared_ptr<Service> s, u64 pid, ams::ncm::TitleId tid) : IMitmServiceObject(s, pid, tid) {
/* ... */
}
static bool ShouldMitm(u64 pid, sts::ncm::TitleId tid) {
static bool ShouldMitm(u64 pid, ams::ncm::TitleId tid) {
/* We will mitm:
* - am, to intercept the Reboot/Power buttons in the overlay menu.
* - fatal, to simplify payload reboot logic significantly
* - applications, to allow homebrew to take advantage of the feature.
*/
return tid == sts::ncm::TitleId::Am || tid == sts::ncm::TitleId::Fatal || sts::ncm::IsApplicationTitleId(tid) || Utils::IsHblTid(static_cast<u64>(tid));
return tid == ams::ncm::TitleId::Am || tid == ams::ncm::TitleId::Fatal || ams::ncm::IsApplicationTitleId(tid) || Utils::IsHblTid(static_cast<u64>(tid));
}
static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx);

View file

@ -32,7 +32,7 @@ Result FsDirUtils::CopyFile(IFileSystem *dst_fs, IFileSystem *src_fs, const FsPa
{
FsPath dst_path;
/* TODO: Error code? N aborts here. */
STS_ASSERT(static_cast<size_t>(snprintf(dst_path.str, sizeof(dst_path.str), "%s%s", dst_parent_path.str, dir_ent->name)) < sizeof(dst_path));
AMS_ASSERT(static_cast<size_t>(snprintf(dst_path.str, sizeof(dst_path.str), "%s%s", dst_parent_path.str, dir_ent->name)) < sizeof(dst_path));
R_TRY(dst_fs->CreateFile(dst_path, file_size));
R_TRY(dst_fs->OpenFile(dst_file, dst_path, OpenMode_Write));

View file

@ -30,14 +30,14 @@ static char *GetNormalizedDirectory(const char *dir_prefix) {
/* Ensure terminating '/' */
if (normal_path[normal_path_len-1] != '/') {
STS_ASSERT(normal_path_len + 2 <= sizeof(normal_path));
AMS_ASSERT(normal_path_len + 2 <= sizeof(normal_path));
strncat(normal_path, "/", 2);
normal_path[sizeof(normal_path)-1] = 0;
normal_path_len++;
}
char *output = static_cast<char *>(std::malloc(normal_path_len + 1));
STS_ASSERT(output != nullptr);
AMS_ASSERT(output != nullptr);
std::strncpy(output, normal_path, normal_path_len + 1);
output[normal_path_len] = 0;

View file

@ -119,7 +119,7 @@ Result DirectorySaveDataFileSystem::AllocateWorkBuffer(void **out_buf, size_t *o
/* Divide size by two. */
try_size >>= 1;
STS_ASSERT(try_size > 0x200);
AMS_ASSERT(try_size > 0x200);
}
/* TODO: Return a result here? Nintendo does not, but they have other allocation failed results. */

View file

@ -37,7 +37,7 @@ class DirectorySaveDataFileSystem : public IFileSystem {
std::unique_ptr<IFileSystem> unique_fs;
std::unique_ptr<IFileSystem> proxy_save_fs;
IFileSystem *fs;
sts::os::Mutex lock;
ams::os::Mutex lock;
size_t open_writable_files = 0;
public:

View file

@ -261,7 +261,7 @@ Result FsPathUtils::Normalize(char *out, size_t max_out_size, const char *src, s
/* Assert normalized. */
bool normalized = false;
R_ASSERT(FsPathUtils::IsNormalized(&normalized, out));
STS_ASSERT(normalized);
AMS_ASSERT(normalized);
return ResultSuccess();
}

View file

@ -34,7 +34,7 @@ Result SubDirectoryFileSystem::Initialize(const char *bp) {
/* Ensure terminating '/' */
if (normal_path[normal_path_len-1] != '/') {
STS_ASSERT(normal_path_len + 2 <= sizeof(normal_path));
AMS_ASSERT(normal_path_len + 2 <= sizeof(normal_path));
strncat(normal_path, "/", 2);
normal_path[sizeof(normal_path)-1] = 0;

View file

@ -20,7 +20,7 @@
#include "fsmitm_boot0storage.hpp"
static sts::os::Mutex g_boot0_mutex;
static ams::os::Mutex g_boot0_mutex;
static u8 g_boot0_bct_buffer[Boot0Storage::BctEndOffset];
bool Boot0Storage::CanModifyBctPubks() {
@ -28,11 +28,11 @@ bool Boot0Storage::CanModifyBctPubks() {
/* RCM bug patched. */
/* Only allow NS to update the BCT pubks. */
/* AutoRCM on a patched unit will cause a brick, so homebrew should NOT be allowed to write. */
return this->title_id == sts::ncm::TitleId::Ns;
return this->title_id == ams::ncm::TitleId::Ns;
} else {
/* RCM bug unpatched. */
/* Allow homebrew but not NS to update the BCT pubks. */
return this->title_id != sts::ncm::TitleId::Ns;
return this->title_id != ams::ncm::TitleId::Ns;
}
}

View file

@ -131,12 +131,12 @@ class Boot0Storage : public SectoredProxyStorage<0x200> {
static constexpr u64 EksSize = 0x4000;
static constexpr u64 EksEnd = EksStart + EksSize;
private:
sts::ncm::TitleId title_id;
ams::ncm::TitleId title_id;
private:
bool CanModifyBctPubks();
public:
Boot0Storage(FsStorage *s, sts::ncm::TitleId t) : Base(s), title_id(t) { }
Boot0Storage(FsStorage s, sts::ncm::TitleId t) : Base(s), title_id(t) { }
Boot0Storage(FsStorage *s, ams::ncm::TitleId t) : Base(s), title_id(t) { }
Boot0Storage(FsStorage s, ams::ncm::TitleId t) : Base(s), title_id(t) { }
public:
virtual Result Read(void *_buffer, size_t size, u64 offset) override;
virtual Result Write(void *_buffer, size_t size, u64 offset) override;

View file

@ -93,7 +93,7 @@ Result LayeredRomFS::Read(void *buffer, size_t size, u64 offset) {
R_ASSERT(Utils::OpenSdFileForAtmosphere(this->title_id, ROMFS_METADATA_FILE_PATH, FS_OPEN_READ, &file));
size_t out_read;
R_ASSERT(fsFileRead(&file, (offset - cur_source->virtual_offset), (void *)((uintptr_t)buffer + read_so_far), cur_read_size, FS_READOPTION_NONE, &out_read));
STS_ASSERT(out_read == cur_read_size);
AMS_ASSERT(out_read == cur_read_size);
fsFileClose(&file);
}
break;
@ -103,7 +103,7 @@ Result LayeredRomFS::Read(void *buffer, size_t size, u64 offset) {
R_ASSERT(Utils::OpenRomFSSdFile(this->title_id, cur_source->loose_source_info.path, FS_OPEN_READ, &file));
size_t out_read;
R_ASSERT(fsFileRead(&file, (offset - cur_source->virtual_offset), (void *)((uintptr_t)buffer + read_so_far), cur_read_size, FS_READOPTION_NONE, &out_read));
STS_ASSERT(out_read == cur_read_size);
AMS_ASSERT(out_read == cur_read_size);
fsFileClose(&file);
}
break;
@ -122,7 +122,7 @@ Result LayeredRomFS::Read(void *buffer, size_t size, u64 offset) {
R_ASSERT(this->file_romfs->Read((void *)((uintptr_t)buffer + read_so_far), cur_read_size, cur_source->base_source_info.offset + (offset - cur_source->virtual_offset)));
}
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
read_so_far += cur_read_size;
offset += cur_read_size;

View file

@ -39,7 +39,7 @@ void RomFSBuildContext::VisitDirectory(FsFileSystem *filesys, RomFSBuildDirector
break;
}
STS_ASSERT(this->dir_entry.type == ENTRYTYPE_DIR || this->dir_entry.type == ENTRYTYPE_FILE);
AMS_ASSERT(this->dir_entry.type == ENTRYTYPE_DIR || this->dir_entry.type == ENTRYTYPE_FILE);
if (this->dir_entry.type == ENTRYTYPE_DIR) {
RomFSBuildDirectoryContext *child = new RomFSBuildDirectoryContext({0});
/* Set child's path. */
@ -179,7 +179,7 @@ void RomFSBuildContext::VisitDirectory(RomFSBuildDirectoryContext *parent, u32 p
void RomFSBuildContext::MergeRomStorage(IROStorage *storage, RomFSDataSource source) {
RomFSHeader header;
R_ASSERT(storage->Read(&header, sizeof(header), 0));
STS_ASSERT(header.header_size == sizeof(header));
AMS_ASSERT(header.header_size == sizeof(header));
/* Read tables. */
auto dir_table = std::make_unique<u8[]>(header.dir_table_size);

View file

@ -36,10 +36,10 @@
#include "../debug.hpp"
static sts::os::Mutex g_StorageCacheLock;
static ams::os::Mutex g_StorageCacheLock;
static std::unordered_map<u64, std::weak_ptr<IStorageInterface>> g_StorageCache;
static bool StorageCacheGetEntry(sts::ncm::TitleId title_id, std::shared_ptr<IStorageInterface> *out) {
static bool StorageCacheGetEntry(ams::ncm::TitleId title_id, std::shared_ptr<IStorageInterface> *out) {
std::scoped_lock lock(g_StorageCacheLock);
if (g_StorageCache.find(static_cast<u64>(title_id)) == g_StorageCache.end()) {
return false;
@ -53,7 +53,7 @@ static bool StorageCacheGetEntry(sts::ncm::TitleId title_id, std::shared_ptr<ISt
return false;
}
static void StorageCacheSetEntry(sts::ncm::TitleId title_id, std::shared_ptr<IStorageInterface> *ptr) {
static void StorageCacheSetEntry(ams::ncm::TitleId title_id, std::shared_ptr<IStorageInterface> *ptr) {
std::scoped_lock lock(g_StorageCacheLock);
/* Ensure we always use the cached copy if present. */
@ -145,7 +145,7 @@ Result FsMitmService::OpenFileSystemWithId(Out<std::shared_ptr<IFileSystemInterf
Result FsMitmService::OpenSdCardFileSystem(Out<std::shared_ptr<IFileSystemInterface>> out_fs) {
/* We only care about redirecting this for NS/Emummc. */
if (this->title_id != sts::ncm::TitleId::Ns) {
if (this->title_id != ams::ncm::TitleId::Ns) {
return ResultAtmosphereMitmShouldForwardToSession;
}
if (!IsEmummc()) {
@ -234,7 +234,7 @@ Result FsMitmService::OpenBisStorage(Out<std::shared_ptr<IStorageInterface>> out
FsStorage bis_storage;
R_TRY(fsOpenBisStorageFwd(this->forward_service.get(), &bis_storage, bis_partition_id));
const bool is_sysmodule = sts::ncm::IsSystemTitleId(this->title_id);
const bool is_sysmodule = ams::ncm::IsSystemTitleId(this->title_id);
const bool has_bis_write_flag = Utils::HasFlag(static_cast<u64>(this->title_id), "bis_write");
const bool has_cal0_read_flag = Utils::HasFlag(static_cast<u64>(this->title_id), "cal_read");
@ -345,7 +345,7 @@ Result FsMitmService::OpenDataStorageByDataId(Out<std::shared_ptr<IStorageInterf
/* Try to get from the cache. */
{
std::shared_ptr<IStorageInterface> cached_storage = nullptr;
bool has_cache = StorageCacheGetEntry(sts::ncm::TitleId{data_id}, &cached_storage);
bool has_cache = StorageCacheGetEntry(ams::ncm::TitleId{data_id}, &cached_storage);
if (has_cache) {
if (out_storage.IsDomain()) {
@ -374,7 +374,7 @@ Result FsMitmService::OpenDataStorageByDataId(Out<std::shared_ptr<IStorageInterf
storage_to_cache = std::make_shared<IStorageInterface>(new LayeredRomFS(std::make_shared<ReadOnlyStorageAdapter>(new ProxyStorage(data_storage)), nullptr, data_id));
}
StorageCacheSetEntry(sts::ncm::TitleId{data_id}, &storage_to_cache);
StorageCacheSetEntry(ams::ncm::TitleId{data_id}, &storage_to_cache);
out_storage.SetValue(std::move(storage_to_cache));
if (out_storage.IsDomain()) {

View file

@ -44,15 +44,15 @@ class FsMitmService : public IMitmServiceObject {
bool has_initialized = false;
bool should_override_contents;
public:
FsMitmService(std::shared_ptr<Service> s, u64 pid, sts::ncm::TitleId tid) : IMitmServiceObject(s, pid, tid) {
FsMitmService(std::shared_ptr<Service> s, u64 pid, ams::ncm::TitleId tid) : IMitmServiceObject(s, pid, tid) {
if (Utils::HasSdDisableMitMFlag(static_cast<u64>(this->title_id))) {
this->should_override_contents = false;
} else {
this->should_override_contents = (this->title_id >= sts::ncm::TitleId::ApplicationStart || Utils::HasSdMitMFlag(static_cast<u64>(this->title_id))) && Utils::HasOverrideButton(static_cast<u64>(this->title_id));
this->should_override_contents = (this->title_id >= ams::ncm::TitleId::ApplicationStart || Utils::HasSdMitMFlag(static_cast<u64>(this->title_id))) && Utils::HasOverrideButton(static_cast<u64>(this->title_id));
}
}
static bool ShouldMitm(u64 pid, sts::ncm::TitleId tid) {
static bool ShouldMitm(u64 pid, ams::ncm::TitleId tid) {
/* Don't Mitm KIPs */
if (pid < 0x50) {
return false;
@ -62,11 +62,11 @@ class FsMitmService : public IMitmServiceObject {
/* TODO: intercepting everything seems to cause issues with sleep mode, for some reason. */
/* Figure out why, and address it. */
if (tid == sts::ncm::TitleId::AppletQlaunch || tid == sts::ncm::TitleId::AppletMaintenanceMenu) {
if (tid == ams::ncm::TitleId::AppletQlaunch || tid == ams::ncm::TitleId::AppletMaintenanceMenu) {
has_launched_qlaunch = true;
}
return has_launched_qlaunch || tid == sts::ncm::TitleId::Ns || tid >= sts::ncm::TitleId::ApplicationStart || Utils::HasSdMitMFlag(static_cast<u64>(tid));
return has_launched_qlaunch || tid == ams::ncm::TitleId::Ns || tid >= ams::ncm::TitleId::ApplicationStart || Utils::HasSdMitMFlag(static_cast<u64>(tid));
}
static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx);

View file

@ -28,13 +28,13 @@ class HidMitmService : public IMitmServiceObject {
private:
bool should_set_system_ext = false;
public:
HidMitmService(std::shared_ptr<Service> s, u64 pid, sts::ncm::TitleId tid) : IMitmServiceObject(s, pid, tid) {
HidMitmService(std::shared_ptr<Service> s, u64 pid, ams::ncm::TitleId tid) : IMitmServiceObject(s, pid, tid) {
/* ... */
}
~HidMitmService();
static bool ShouldMitm(u64 pid, sts::ncm::TitleId tid) {
static bool ShouldMitm(u64 pid, ams::ncm::TitleId tid) {
/* TODO: Consider removing in Atmosphere 0.10.0/1.0.0. */
/* We will mitm:
* - hbl, to help homebrew not need to be recompiled.

View file

@ -28,11 +28,11 @@ class NsAmMitmService : public IMitmServiceObject {
GetRunningApplicationProgramId = 92,
};
public:
NsAmMitmService(std::shared_ptr<Service> s, u64 pid, sts::ncm::TitleId tid) : IMitmServiceObject(s, pid, tid) {
NsAmMitmService(std::shared_ptr<Service> s, u64 pid, ams::ncm::TitleId tid) : IMitmServiceObject(s, pid, tid) {
/* ... */
}
static bool ShouldMitm(u64 pid, sts::ncm::TitleId tid) {
static bool ShouldMitm(u64 pid, ams::ncm::TitleId tid) {
/* We will mitm:
* - web applets, to facilitate hbl web browser launching.
*/

View file

@ -67,11 +67,11 @@ class NsWebMitmService : public IMitmServiceObject {
GetDocumentInterface = 7999,
};
public:
NsWebMitmService(std::shared_ptr<Service> s, u64 pid, sts::ncm::TitleId tid) : IMitmServiceObject(s, pid, tid) {
NsWebMitmService(std::shared_ptr<Service> s, u64 pid, ams::ncm::TitleId tid) : IMitmServiceObject(s, pid, tid) {
/* ... */
}
static bool ShouldMitm(u64 pid, sts::ncm::TitleId tid) {
static bool ShouldMitm(u64 pid, ams::ncm::TitleId tid) {
/* We will mitm:
* - web applets, to facilitate hbl web browser launching.
*/

View file

@ -43,7 +43,7 @@ bool SetMitmService::IsValidLanguageCode(u64 lang_code) {
LanguageCode_SimplifiedChinese,
LanguageCode_TraditionalChinese,
};
size_t num_language_codes = sts::util::size(s_valid_language_codes);
size_t num_language_codes = ams::util::size(s_valid_language_codes);
if (GetRuntimeFirmwareVersion() < FirmwareVersion_400) {
/* 4.0.0 added simplified and traditional chinese. */
num_language_codes -= 2;
@ -67,7 +67,7 @@ Result SetMitmService::EnsureLocale() {
if (!this->got_locale) {
std::memset(&this->locale, 0xCC, sizeof(this->locale));
if (this->title_id == sts::ncm::TitleId::Ns) {
if (this->title_id == ams::ncm::TitleId::Ns) {
u64 app_pid = 0;
u64 app_tid = 0;
R_TRY(pmdmntGetApplicationPid(&app_pid));

View file

@ -27,17 +27,17 @@ class SetMitmService : public IMitmServiceObject {
GetRegionCode = 4,
};
private:
sts::os::Mutex lock;
ams::os::Mutex lock;
OverrideLocale locale;
bool got_locale;
public:
SetMitmService(std::shared_ptr<Service> s, u64 pid, sts::ncm::TitleId tid) : IMitmServiceObject(s, pid, tid) {
SetMitmService(std::shared_ptr<Service> s, u64 pid, ams::ncm::TitleId tid) : IMitmServiceObject(s, pid, tid) {
this->got_locale = false;
}
static bool ShouldMitm(u64 pid, sts::ncm::TitleId tid) {
static bool ShouldMitm(u64 pid, ams::ncm::TitleId tid) {
/* Mitm all applications. */
return tid == sts::ncm::TitleId::Ns || sts::ncm::IsApplicationTitleId(tid);
return tid == ams::ncm::TitleId::Ns || ams::ncm::IsApplicationTitleId(tid);
}
static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx);

View file

@ -19,7 +19,7 @@
#include "setsys_firmware_version.hpp"
static sts::os::Mutex g_version_mutex;
static ams::os::Mutex g_version_mutex;
static bool g_got_version = false;
static SetSysFirmwareVersion g_ams_fw_version = {0};
static SetSysFirmwareVersion g_fw_version = {0};
@ -32,7 +32,7 @@ void VersionManager::Initialize() {
}
/* Mount firmware version data archive. */
R_ASSERT(romfsMountFromDataArchive(static_cast<u64>(sts::ncm::TitleId::ArchiveSystemVersion), FsStorageId_NandSystem, "sysver"));
R_ASSERT(romfsMountFromDataArchive(static_cast<u64>(ams::ncm::TitleId::ArchiveSystemVersion), FsStorageId_NandSystem, "sysver"));
{
ON_SCOPE_EXIT { romfsUnmount("sysver"); };
@ -40,11 +40,11 @@ void VersionManager::Initialize() {
/* Firmware version file must exist. */
FILE *f = fopen("sysver:/file", "rb");
STS_ASSERT(f != NULL);
AMS_ASSERT(f != NULL);
ON_SCOPE_EXIT { fclose(f); };
/* Must be possible to read firmware version from file. */
STS_ASSERT(fread(&fw_ver, sizeof(fw_ver), 1, f) == 1);
AMS_ASSERT(fread(&fw_ver, sizeof(fw_ver), 1, f) == 1);
g_fw_version = fw_ver;
g_ams_fw_version = fw_ver;
@ -65,11 +65,11 @@ void VersionManager::Initialize() {
g_got_version = true;
}
Result VersionManager::GetFirmwareVersion(sts::ncm::TitleId title_id, SetSysFirmwareVersion *out) {
Result VersionManager::GetFirmwareVersion(ams::ncm::TitleId title_id, SetSysFirmwareVersion *out) {
VersionManager::Initialize();
/* Report atmosphere string to qlaunch, maintenance and nothing else. */
if (title_id == sts::ncm::TitleId::AppletQlaunch || title_id == sts::ncm::TitleId::AppletMaintenanceMenu) {
if (title_id == ams::ncm::TitleId::AppletQlaunch || title_id == ams::ncm::TitleId::AppletMaintenanceMenu) {
*out = g_ams_fw_version;
} else {
*out = g_fw_version;

View file

@ -21,5 +21,5 @@
class VersionManager {
public:
static void Initialize();
static Result GetFirmwareVersion(sts::ncm::TitleId title_id, SetSysFirmwareVersion *out);
static Result GetFirmwareVersion(ams::ncm::TitleId title_id, SetSysFirmwareVersion *out);
};

View file

@ -29,11 +29,11 @@ class SetSysMitmService : public IMitmServiceObject {
GetSettingsItemValue = 38,
};
public:
SetSysMitmService(std::shared_ptr<Service> s, u64 pid, sts::ncm::TitleId tid) : IMitmServiceObject(s, pid, tid) {
SetSysMitmService(std::shared_ptr<Service> s, u64 pid, ams::ncm::TitleId tid) : IMitmServiceObject(s, pid, tid) {
/* ... */
}
static bool ShouldMitm(u64 pid, sts::ncm::TitleId tid) {
static bool ShouldMitm(u64 pid, ams::ncm::TitleId tid) {
/* Mitm everything. */
return true;
}

View file

@ -35,7 +35,7 @@ struct SettingsItemValue {
std::map<std::string, SettingsItemValue> g_settings_items;
static bool g_threw_fatal = false;
static sts::os::Thread g_fatal_thread;
static ams::os::Thread g_fatal_thread;
static void FatalThreadFunc(void *arg) {
svcSleepThread(5000000000ULL);

View file

@ -31,7 +31,7 @@
static FsFileSystem g_sd_filesystem = {0};
/* Non-autoclear events for SD/HID init. */
static sts::os::Event g_sd_event(false), g_hid_event(false);
static ams::os::Event g_sd_event(false), g_hid_event(false);
static std::vector<u64> g_mitm_flagged_tids;
static std::vector<u64> g_disable_mitm_flagged_tids;
@ -55,7 +55,7 @@ static HblOverrideConfig g_hbl_override_config = {
.key_combination = KEY_R,
.override_by_default = false
},
.title_id = static_cast<u64>(sts::ncm::TitleId::AppletPhotoViewer),
.title_id = static_cast<u64>(ams::ncm::TitleId::AppletPhotoViewer),
.override_any_app = true
};
@ -88,7 +88,7 @@ void Utils::InitializeThreadFunc(void *args) {
DoWithSmSession([&]() {
Handle tmp_hnd = 0;
static const char * const required_active_services[] = {"pcv", "gpio", "pinmux", "psc:m"};
for (unsigned int i = 0; i < sts::util::size(required_active_services); i++) {
for (unsigned int i = 0; i < ams::util::size(required_active_services); i++) {
R_ASSERT(smGetServiceOriginal(&tmp_hnd, smEncodeName(required_active_services[i])));
svcCloseHandle(tmp_hnd);
}
@ -186,7 +186,7 @@ void Utils::InitializeThreadFunc(void *args) {
0x34, 0xC1, 0xA0, 0xC4, 0x82, 0x58, 0xF8, 0xB4, 0xFA, 0x9E, 0x5E, 0x6A, 0xDA, 0xFC, 0x7E, 0x4F,
};
const u32 option = (partition == 3 && sts::spl::IsRecoveryBoot()) ? 0x4 : 0x1;
const u32 option = (partition == 3 && ams::spl::IsRecoveryBoot()) ? 0x4 : 0x1;
u8 access_key[0x10];
R_ASSERT(splCryptoGenerateAesKek(BisKekSource, key_generation, option, access_key));
@ -455,13 +455,13 @@ Result Utils::SaveSdFileForAtmosphere(u64 title_id, const char *fn, void *data,
}
bool Utils::IsHblTid(u64 _tid) {
const sts::ncm::TitleId tid{_tid};
return (g_hbl_override_config.override_any_app && sts::ncm::IsApplicationTitleId(tid)) || (_tid == g_hbl_override_config.title_id);
const ams::ncm::TitleId tid{_tid};
return (g_hbl_override_config.override_any_app && ams::ncm::IsApplicationTitleId(tid)) || (_tid == g_hbl_override_config.title_id);
}
bool Utils::IsWebAppletTid(u64 _tid) {
const sts::ncm::TitleId tid{_tid};
return tid == sts::ncm::TitleId::AppletWeb || tid == sts::ncm::TitleId::AppletOfflineWeb || tid == sts::ncm::TitleId::AppletLoginShare || tid == sts::ncm::TitleId::AppletWifiWebAuth;
const ams::ncm::TitleId tid{_tid};
return tid == ams::ncm::TitleId::AppletWeb || tid == ams::ncm::TitleId::AppletOfflineWeb || tid == ams::ncm::TitleId::AppletLoginShare || tid == ams::ncm::TitleId::AppletWifiWebAuth;
}
bool Utils::HasTitleFlag(u64 tid, const char *flag) {
@ -550,7 +550,7 @@ static bool HasOverrideKey(OverrideKey *cfg) {
bool Utils::HasOverrideButton(u64 tid) {
if ((!sts::ncm::IsApplicationTitleId(sts::ncm::TitleId{tid})) || (!IsSdInitialized())) {
if ((!ams::ncm::IsApplicationTitleId(ams::ncm::TitleId{tid})) || (!IsSdInitialized())) {
/* Disable button override disable for non-applications. */
return true;
}

View file

@ -18,7 +18,7 @@
#include "boot_calibration.hpp"
#include "boot_i2c_utils.hpp"
namespace sts::boot {
namespace ams::boot {
/* Include configuration into anonymous namespace. */
namespace {

View file

@ -20,7 +20,7 @@
#include "i2c/driver/i2c_api.hpp"
namespace sts::boot {
namespace ams::boot {
class BatteryDriver {
private:

View file

@ -17,7 +17,7 @@
#include "boot_battery_icons.hpp"
#include "boot_display.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
/* Battery Display utilities. */
void ShowLowBatteryIcon();

View file

@ -20,7 +20,7 @@
#include "boot_pmic_driver.hpp"
#include "boot_rtc_driver.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {
@ -104,7 +104,7 @@ namespace sts::boot {
}
u32 GetBootReason() {
STS_ASSERT(g_detected_boot_reason);
AMS_ASSERT(g_detected_boot_reason);
return g_boot_reason;
}

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
/* Boot Reason utilities. */
void DetectBootReason();

View file

@ -14,7 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace sts::boot::bq24193 {
namespace ams::boot::bq24193 {
constexpr u8 InputSourceControl = 0x00;
constexpr u8 PowerOnConfiguration = 0x01;
@ -38,8 +38,8 @@ namespace sts::boot::bq24193 {
constexpr u32 ChargeVoltageLimitMax = 4208;
inline u8 EncodeChargeVoltageLimit(u32 voltage) {
STS_ASSERT(voltage >= ChargeVoltageLimitMin);
STS_ASSERT(voltage <= ChargeVoltageLimitMax);
AMS_ASSERT(voltage >= ChargeVoltageLimitMin);
AMS_ASSERT(voltage <= ChargeVoltageLimitMax);
voltage -= ChargeVoltageLimitMin;
voltage >>= 4;
@ -54,8 +54,8 @@ namespace sts::boot::bq24193 {
constexpr u32 FastChargeCurrentLimitMax = 4544;
inline u8 EncodeFastChargeCurrentLimit(u32 current) {
STS_ASSERT(current >= FastChargeCurrentLimitMin);
STS_ASSERT(current <= FastChargeCurrentLimitMax);
AMS_ASSERT(current >= FastChargeCurrentLimitMin);
AMS_ASSERT(current <= FastChargeCurrentLimitMax);
current -= FastChargeCurrentLimitMin;
current >>= 6;
@ -81,8 +81,8 @@ namespace sts::boot::bq24193 {
constexpr u32 PreChargeCurrentLimitMax = 2048;
inline u8 EncodePreChargeCurrentLimit(u32 current) {
STS_ASSERT(current >= PreChargeCurrentLimitMin);
STS_ASSERT(current <= PreChargeCurrentLimitMax);
AMS_ASSERT(current >= PreChargeCurrentLimitMin);
AMS_ASSERT(current <= PreChargeCurrentLimitMax);
current -= PreChargeCurrentLimitMin;
current >>= 7;
@ -97,8 +97,8 @@ namespace sts::boot::bq24193 {
constexpr u32 TerminationCurrentLimitMax = 2048;
inline u8 EncodeTerminationCurrentLimit(u32 current) {
STS_ASSERT(current >= TerminationCurrentLimitMin);
STS_ASSERT(current <= TerminationCurrentLimitMax);
AMS_ASSERT(current >= TerminationCurrentLimitMin);
AMS_ASSERT(current <= TerminationCurrentLimitMax);
current -= TerminationCurrentLimitMin;
current >>= 7;
@ -113,8 +113,8 @@ namespace sts::boot::bq24193 {
constexpr u32 MinimumSystemVoltageLimitMax = 3700;
inline u8 EncodeMinimumSystemVoltageLimit(u32 voltage) {
STS_ASSERT(voltage >= MinimumSystemVoltageLimitMin);
STS_ASSERT(voltage <= MinimumSystemVoltageLimitMax);
AMS_ASSERT(voltage >= MinimumSystemVoltageLimitMin);
AMS_ASSERT(voltage <= MinimumSystemVoltageLimitMax);
voltage -= MinimumSystemVoltageLimitMin;
voltage /= 100;

View file

@ -16,7 +16,7 @@
#include "boot_calibration.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {
@ -36,7 +36,7 @@ namespace sts::boot {
0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400
};
STS_ASSERT(data != nullptr);
AMS_ASSERT(data != nullptr);
u16 crc16 = 0x55AA;
const u8 *data_u8 = reinterpret_cast<const u8 *>(data);

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
/* Calibration utilities. */
u32 GetBatteryVersion();

View file

@ -17,7 +17,7 @@
#include "boot_change_voltage.hpp"
#include "boot_pmc_wrapper.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
void ChangeGpioVoltageTo1_8v();;

View file

@ -19,7 +19,7 @@
#include "boot_charger_driver.hpp"
namespace sts::boot {
namespace ams::boot {
Result ChargerDriver::Read(u8 addr, u8 *out) {
return ReadI2cRegister(this->i2c_session, reinterpret_cast<u8 *>(out), sizeof(*out), &addr, sizeof(addr));

View file

@ -23,7 +23,7 @@
#include "gpio/gpio_utils.hpp"
namespace sts::boot {
namespace ams::boot {
class ChargerDriver {
private:

View file

@ -23,7 +23,7 @@
#include "boot_pmic_driver.hpp"
#include "boot_power_utils.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {
@ -100,7 +100,7 @@ namespace sts::boot {
return &BatteryChargeParameters1;
case 2:
return &BatteryChargeParameters2;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
@ -280,7 +280,7 @@ namespace sts::boot {
case CheckBatteryResult::Reboot:
RebootSystem();
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
void CheckBatteryCharge();

View file

@ -18,7 +18,7 @@
#include "boot_check_clock.hpp"
#include "boot_power_utils.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
void CheckClock();

View file

@ -18,7 +18,7 @@
#include "boot_pmc_wrapper.hpp"
#include "boot_registers_pmc.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
void SetInitialClockConfiguration();

View file

@ -28,7 +28,7 @@
#include "boot_registers_pinmux.hpp"
#include "boot_registers_pmc.hpp"
namespace sts::boot {
namespace ams::boot {
/* Display configuration included into anonymous namespace. */
namespace {
@ -110,7 +110,7 @@ namespace sts::boot {
case DsiSleepOrRegisterWriteKind_Sleep:
svcSleepThread(1'000'000ul * u64(reg_writes[i].offset));
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
}

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
/* Splash Screen/Display utilities. */
void InitializeDisplay();

View file

@ -20,7 +20,7 @@
#include "gpio/gpio_utils.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
void SetFanEnabled();

View file

@ -16,7 +16,7 @@
#include "boot_i2c_utils.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {
@ -43,8 +43,8 @@ namespace sts::boot {
}
Result ReadI2cRegister(i2c::driver::Session &session, u8 *dst, size_t dst_size, const u8 *cmd, size_t cmd_size) {
STS_ASSERT(dst != nullptr && dst_size > 0);
STS_ASSERT(cmd != nullptr && cmd_size > 0);
AMS_ASSERT(dst != nullptr && dst_size > 0);
AMS_ASSERT(cmd != nullptr && cmd_size > 0);
u8 cmd_list[i2c::CommandListFormatter::MaxCommandListSize];
@ -56,8 +56,8 @@ namespace sts::boot {
}
Result WriteI2cRegister(i2c::driver::Session &session, const u8 *src, size_t src_size, const u8 *cmd, size_t cmd_size) {
STS_ASSERT(src != nullptr && src_size > 0);
STS_ASSERT(cmd != nullptr && cmd_size > 0);
AMS_ASSERT(src != nullptr && src_size > 0);
AMS_ASSERT(cmd != nullptr && cmd_size > 0);
u8 cmd_list[0x20];

View file

@ -20,7 +20,7 @@
#include "i2c/driver/i2c_api.hpp"
namespace sts::boot {
namespace ams::boot {
/* I2C Utilities. */
Result ReadI2cRegister(i2c::driver::Session &session, u8 *dst, size_t dst_size, const u8 *cmd, size_t cmd_size);

View file

@ -39,7 +39,7 @@
#include "boot_power_utils.hpp"
using namespace sts;
using namespace ams;
extern "C" {
extern u32 __start__;
@ -61,24 +61,24 @@ extern "C" {
void __libnx_exception_handler(ThreadExceptionDump *ctx);
}
namespace sts::ams {
namespace ams {
ncm::TitleId StratosphereTitleId = ncm::TitleId::Boot;
ncm::TitleId CurrentTitleId = ncm::TitleId::Boot;
void ExceptionHandler(FatalErrorContext *ctx) {
/* We're boot sysmodule, so manually reboot to fatal error. */
boot::RebootForFatalError(ctx);
}
}
namespace sts::result {
namespace result {
bool CallFatalOnResultAssertion = false;
}
}
using namespace sts;
using namespace ams;
void __libnx_exception_handler(ThreadExceptionDump *ctx) {
ams::CrashHandler(ctx);

View file

@ -21,9 +21,9 @@
#include "i2c/driver/impl/i2c_pcv.hpp"
#include "i2c/driver/impl/i2c_registers.hpp"
using namespace sts::i2c::driver::impl;
using namespace ams::i2c::driver::impl;
namespace sts::pcv {
namespace ams::pcv {
void Initialize() {
/* Don't do anything. */

View file

@ -17,7 +17,7 @@
#include <stratosphere/spl/smc/spl_smc.hpp>
#include "boot_pmc_wrapper.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {
@ -41,12 +41,12 @@ namespace sts::boot {
}
u32 ReadPmcRegister(u32 phys_addr) {
STS_ASSERT(IsValidPmcAddress(phys_addr));
AMS_ASSERT(IsValidPmcAddress(phys_addr));
return ReadWriteRegisterImpl(phys_addr, 0, 0);
}
void WritePmcRegister(u32 phys_addr, u32 value, u32 mask) {
STS_ASSERT(IsValidPmcAddress(phys_addr));
AMS_ASSERT(IsValidPmcAddress(phys_addr));
ReadWriteRegisterImpl(phys_addr, value, mask);
}

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
/* PMC Access Utilities. */
u32 ReadPmcRegister(u32 phys_addr);

View file

@ -20,7 +20,7 @@
#include "boot_i2c_utils.hpp"
#include "boot_pmic_driver.hpp"
namespace sts::boot {
namespace ams::boot {
void PmicDriver::ShutdownSystem() {
R_ASSERT(this->ShutdownSystem(false));
@ -89,7 +89,7 @@ namespace sts::boot {
/* Allow up to 5 seconds for shutdown/reboot to take place. */
svcSleepThread(5'000'000'000ul);
STS_ASSERT(false);
AMS_ASSERT(false);
}
void PmicDriver::FinalizeBattery(BatteryDriver *battery_driver) {

View file

@ -20,7 +20,7 @@
#include "boot_battery_driver.hpp"
namespace sts::boot {
namespace ams::boot {
/* Driver object. */
class PmicDriver {

View file

@ -21,7 +21,7 @@
#include "boot_power_utils.hpp"
#include "fusee-primary_bin.h"
namespace sts::boot {
namespace ams::boot {
namespace {
@ -41,7 +41,7 @@ namespace sts::boot {
/* Overwrite all of IRAM with FFs. */
for (size_t ofs = 0; ofs < IramSize; ofs += sizeof(g_work_page)) {
ams::CopyToIram(IramBase + ofs, g_work_page, sizeof(g_work_page));
exosphere::CopyToIram(IramBase + ofs, g_work_page, sizeof(g_work_page));
}
}
@ -52,7 +52,7 @@ namespace sts::boot {
/* Copy in payload. */
for (size_t ofs = 0; ofs < fusee_primary_bin_size; ofs += 0x1000) {
std::memcpy(g_work_page, &fusee_primary_bin[ofs], std::min(static_cast<size_t>(fusee_primary_bin_size - ofs), size_t(0x1000)));
ams::CopyToIram(IramPayloadBase + ofs, g_work_page, 0x1000);
exosphere::CopyToIram(IramPayloadBase + ofs, g_work_page, 0x1000);
}
@ -60,10 +60,10 @@ namespace sts::boot {
if (ctx != nullptr) {
std::memset(g_work_page, 0xCC, sizeof(g_work_page));
std::memcpy(g_work_page, ctx, sizeof(*ctx));
ams::CopyToIram(IramPayloadBase + IramPayloadMaxSize, g_work_page, sizeof(g_work_page));
exosphere::CopyToIram(IramPayloadBase + IramPayloadMaxSize, g_work_page, sizeof(g_work_page));
}
ams::ForceRebootToIramPayload();
exosphere::ForceRebootToIramPayload();
}
}

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
/* Power utilities. */
void RebootSystem();

View file

@ -20,7 +20,7 @@
#include "boot_power_utils.hpp"
#include "boot_repair_boot_images.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
void CheckAndRepairBootImages();

View file

@ -19,7 +19,7 @@
#include "boot_rtc_driver.hpp"
namespace sts::boot {
namespace ams::boot {
Result RtcDriver::ReadRtcRegister(u8 *out, u8 address) {
const u8 update_addr = 0x04;

View file

@ -20,7 +20,7 @@
#include "boot_i2c_utils.hpp"
namespace sts::boot {
namespace ams::boot {
class RtcDriver {
private:

View file

@ -18,7 +18,7 @@
#include "boot_display.hpp"
#include "boot_splash_screen.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
void ShowSplashScreen();

View file

@ -21,7 +21,7 @@
#include "boot_registers_pmc.hpp"
namespace sts::boot {
namespace ams::boot {
/* Include configuration into anonymous namespace. */
namespace {

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
void SetInitialWakePinConfiguration();

View file

@ -19,7 +19,7 @@
#include "gpio_initial_configuration.hpp"
#include "gpio_utils.hpp"
namespace sts::gpio {
namespace ams::gpio {
namespace {
@ -70,7 +70,7 @@ namespace sts::gpio {
num_configs = NumInitialConfigsIowa;
break;
/* Unknown hardware type, we can't proceed. */
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
} else {
/* Until 2.0.0, the GPIO map for Icosa was used for all hardware types. */
@ -79,7 +79,7 @@ namespace sts::gpio {
}
/* Ensure we found an appropriate config. */
STS_ASSERT(configs != nullptr);
AMS_ASSERT(configs != nullptr);
for (size_t i = 0; i < num_configs; i++) {
/* Configure the GPIO. */

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::gpio {
namespace ams::gpio {
void SetInitialConfiguration();

View file

@ -18,7 +18,7 @@
#include "gpio_utils.hpp"
namespace sts::gpio {
namespace ams::gpio {
namespace {
@ -33,7 +33,7 @@ namespace sts::gpio {
/* Helpers. */
inline u32 GetPadDescriptor(u32 gpio_pad_name) {
STS_ASSERT(gpio_pad_name < PadNameMax);
AMS_ASSERT(gpio_pad_name < PadNameMax);
return Map[gpio_pad_name];
}

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::gpio {
namespace ams::gpio {
/* GPIO Utilities. */
u32 Configure(u32 gpio_pad_name);

View file

@ -20,7 +20,7 @@
#include "i2c_api.hpp"
#include "impl/i2c_resource_manager.hpp"
namespace sts::i2c::driver {
namespace ams::i2c::driver {
namespace {
@ -70,7 +70,7 @@ namespace sts::i2c::driver {
svcSleepThread(us * 1'000ul);
}
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
return ResultSuccess();
}
@ -87,7 +87,7 @@ namespace sts::i2c::driver {
}
inline void CheckInitialized() {
STS_ASSERT(GetResourceManager().IsInitialized());
AMS_ASSERT(GetResourceManager().IsInitialized());
}
}
@ -104,7 +104,7 @@ namespace sts::i2c::driver {
/* Session management. */
void OpenSession(Session *out_session, I2cDevice device) {
CheckInitialized();
STS_ASSERT(impl::IsDeviceSupported(device));
AMS_ASSERT(impl::IsDeviceSupported(device));
const auto bus = impl::GetDeviceBus(device);
const auto slave_address = impl::GetDeviceSlaveAddress(device);
@ -123,8 +123,8 @@ namespace sts::i2c::driver {
/* Communication. */
Result Send(Session &session, const void *src, size_t size, I2cTransactionOption option) {
CheckInitialized();
STS_ASSERT(src != nullptr);
STS_ASSERT(size > 0);
AMS_ASSERT(src != nullptr);
AMS_ASSERT(size > 0);
std::scoped_lock<os::Mutex &> lk(GetResourceManager().GetTransactionMutex(impl::ConvertFromIndex(session.bus_idx)));
return GetResourceManager().GetSession(session.session_id).DoTransactionWithRetry(nullptr, src, size, option, impl::Command::Send);
@ -132,8 +132,8 @@ namespace sts::i2c::driver {
Result Receive(Session &session, void *dst, size_t size, I2cTransactionOption option) {
CheckInitialized();
STS_ASSERT(dst != nullptr);
STS_ASSERT(size > 0);
AMS_ASSERT(dst != nullptr);
AMS_ASSERT(size > 0);
std::scoped_lock<os::Mutex &> lk(GetResourceManager().GetTransactionMutex(impl::ConvertFromIndex(session.bus_idx)));
return GetResourceManager().GetSession(session.session_id).DoTransactionWithRetry(dst, nullptr, size, option, impl::Command::Receive);
@ -141,8 +141,8 @@ namespace sts::i2c::driver {
Result ExecuteCommandList(Session &session, void *dst, size_t size, const void *cmd_list, size_t cmd_list_size) {
CheckInitialized();
STS_ASSERT(dst != nullptr && size > 0);
STS_ASSERT(cmd_list != nullptr && cmd_list_size > 0);
AMS_ASSERT(dst != nullptr && size > 0);
AMS_ASSERT(cmd_list != nullptr && cmd_list_size > 0);
u8 *cur_dst = static_cast<u8 *>(dst);
const u8 *cur_cmd = static_cast<const u8 *>(cmd_list);
@ -150,7 +150,7 @@ namespace sts::i2c::driver {
while (cur_cmd < cmd_list_end) {
Command cmd = static_cast<Command>((*cur_cmd) & 3);
STS_ASSERT(cmd < Command::Count);
AMS_ASSERT(cmd < Command::Count);
R_TRY(g_cmd_handlers[static_cast<size_t>(cmd)](&cur_cmd, &cur_dst, session));
}

View file

@ -21,7 +21,7 @@
#include "../i2c_types.hpp"
#include "../i2c_command_list.hpp"
namespace sts::i2c::driver {
namespace ams::i2c::driver {
struct Session {
size_t bus_idx;

View file

@ -20,7 +20,7 @@
#include "i2c_pcv.hpp"
#include "i2c_bus_accessor.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
void BusAccessor::Open(Bus bus, SpeedMode speed_mode) {
std::scoped_lock lk(this->open_mutex);
@ -29,7 +29,7 @@ namespace sts::i2c::driver::impl {
/* Ensure we're good if this isn't our first session. */
if (this->open_sessions > 1) {
STS_ASSERT(this->speed_mode == speed_mode);
AMS_ASSERT(this->speed_mode == speed_mode);
return;
}
@ -244,7 +244,7 @@ namespace sts::i2c::driver::impl {
0x46, 0x74, 0x7C, 0x98, 0x55, 0x5F
};
const auto index = ConvertToIndex(bus);
STS_ASSERT(index < util::size(s_interrupts));
AMS_ASSERT(index < util::size(s_interrupts));
R_ASSERT(this->interrupt_event.Initialize(s_interrupts[index], false));
}
@ -282,7 +282,7 @@ namespace sts::i2c::driver::impl {
src_div = 0x02;
debounce = 0;
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
if (speed_mode == SpeedMode::HighSpeed) {

View file

@ -21,7 +21,7 @@
#include "i2c_driver_types.hpp"
#include "i2c_registers.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
class BusAccessor {
private:

View file

@ -19,7 +19,7 @@
#include "i2c_driver_types.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
namespace {
@ -88,37 +88,37 @@ namespace sts::i2c::driver::impl {
Bus GetDeviceBus(I2cDevice dev) {
const size_t dev_idx = GetDeviceIndex(dev);
STS_ASSERT(dev_idx != DeviceInvalidIndex);
AMS_ASSERT(dev_idx != DeviceInvalidIndex);
return g_device_configs[dev_idx].bus;
}
u32 GetDeviceSlaveAddress(I2cDevice dev) {
const size_t dev_idx = GetDeviceIndex(dev);
STS_ASSERT(dev_idx != DeviceInvalidIndex);
AMS_ASSERT(dev_idx != DeviceInvalidIndex);
return g_device_configs[dev_idx].slave_address;
}
AddressingMode GetDeviceAddressingMode(I2cDevice dev) {
const size_t dev_idx = GetDeviceIndex(dev);
STS_ASSERT(dev_idx != DeviceInvalidIndex);
AMS_ASSERT(dev_idx != DeviceInvalidIndex);
return g_device_configs[dev_idx].addressing_mode;
}
SpeedMode GetDeviceSpeedMode(I2cDevice dev) {
const size_t dev_idx = GetDeviceIndex(dev);
STS_ASSERT(dev_idx != DeviceInvalidIndex);
AMS_ASSERT(dev_idx != DeviceInvalidIndex);
return g_device_configs[dev_idx].speed_mode;
}
u32 GetDeviceMaxRetries(I2cDevice dev) {
const size_t dev_idx = GetDeviceIndex(dev);
STS_ASSERT(dev_idx != DeviceInvalidIndex);
AMS_ASSERT(dev_idx != DeviceInvalidIndex);
return g_device_configs[dev_idx].max_retries;
}
u64 GetDeviceRetryWaitTime(I2cDevice dev) {
const size_t dev_idx = GetDeviceIndex(dev);
STS_ASSERT(dev_idx != DeviceInvalidIndex);
AMS_ASSERT(dev_idx != DeviceInvalidIndex);
return g_device_configs[dev_idx].retry_wait_time;
}

View file

@ -20,7 +20,7 @@
#include "../../i2c_types.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
enum class Command {
Send = 0,
@ -43,7 +43,7 @@ namespace sts::i2c::driver::impl {
}
constexpr inline Bus ConvertFromIndex(size_t idx) {
STS_ASSERT(idx < static_cast<size_t>(Bus::Count));
AMS_ASSERT(idx < static_cast<size_t>(Bus::Count));
return static_cast<Bus>(idx);
}
@ -61,7 +61,7 @@ namespace sts::i2c::driver::impl {
return PcvModule_I2C5;
case Bus::I2C6:
return PcvModule_I2C6;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
@ -79,7 +79,7 @@ namespace sts::i2c::driver::impl {
return Bus::I2C5;
case PcvModule_I2C6:
return Bus::I2C6;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}

View file

@ -20,7 +20,7 @@
/* This forward declares the functionality from pcv that i2c::driver uses. */
/* This allows for overriding at compile-time (e.g., for boot sysmodule). */
namespace sts::pcv {
namespace ams::pcv {
void Initialize();
void Finalize();

View file

@ -21,7 +21,7 @@
#include "i2c_driver_types.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
struct Registers {
volatile u32 I2C_I2C_CNFG_0;

View file

@ -20,7 +20,7 @@
#include "i2c_pcv.hpp"
#include "i2c_resource_manager.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
void ResourceManager::Initialize() {
std::scoped_lock lk(this->initialize_mutex);
@ -29,7 +29,7 @@ namespace sts::i2c::driver::impl {
void ResourceManager::Finalize() {
std::scoped_lock lk(this->initialize_mutex);
STS_ASSERT(this->ref_cnt > 0);
AMS_ASSERT(this->ref_cnt > 0);
this->ref_cnt--;
if (this->ref_cnt > 0) {
return;
@ -59,11 +59,11 @@ namespace sts::i2c::driver::impl {
/* Get, open session. */
{
std::scoped_lock lk(this->session_open_mutex);
STS_ASSERT(out_session != nullptr);
STS_ASSERT(bus < Bus::Count);
AMS_ASSERT(out_session != nullptr);
AMS_ASSERT(bus < Bus::Count);
session_id = GetFreeSessionId();
STS_ASSERT(session_id != InvalidSessionId);
AMS_ASSERT(session_id != InvalidSessionId);
if ((bus == Bus::I2C2 || bus == Bus::I2C3) && (this->bus_accessors[ConvertToIndex(Bus::I2C2)].GetOpenSessions() == 0 && this->bus_accessors[ConvertToIndex(Bus::I2C3)].GetOpenSessions() == 0)) {
@ -90,7 +90,7 @@ namespace sts::i2c::driver::impl {
/* Get, open session. */
{
std::scoped_lock lk(this->session_open_mutex);
STS_ASSERT(this->sessions[session.session_id].IsOpen());
AMS_ASSERT(this->sessions[session.session_id].IsOpen());
this->sessions[session.session_id].Close();
@ -109,7 +109,7 @@ namespace sts::i2c::driver::impl {
}
void ResourceManager::SuspendBuses() {
STS_ASSERT(this->ref_cnt > 0);
AMS_ASSERT(this->ref_cnt > 0);
if (!this->suspended) {
{
@ -128,7 +128,7 @@ namespace sts::i2c::driver::impl {
}
void ResourceManager::ResumeBuses() {
STS_ASSERT(this->ref_cnt > 0);
AMS_ASSERT(this->ref_cnt > 0);
if (this->suspended) {
if (this->bus_accessors[ConvertToIndex(Bus::I2C2)].GetOpenSessions() > 0 || this->bus_accessors[ConvertToIndex(Bus::I2C3)].GetOpenSessions() > 0) {
@ -151,7 +151,7 @@ namespace sts::i2c::driver::impl {
}
void ResourceManager::SuspendPowerBus() {
STS_ASSERT(this->ref_cnt > 0);
AMS_ASSERT(this->ref_cnt > 0);
std::scoped_lock lk(this->session_open_mutex);
if (!this->power_bus_suspended) {
@ -163,7 +163,7 @@ namespace sts::i2c::driver::impl {
}
void ResourceManager::ResumePowerBus() {
STS_ASSERT(this->ref_cnt > 0);
AMS_ASSERT(this->ref_cnt > 0);
std::scoped_lock lk(this->session_open_mutex);
if (this->power_bus_suspended) {

View file

@ -23,7 +23,7 @@
#include "i2c_bus_accessor.hpp"
#include "i2c_session.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
class ResourceManager {
public:

View file

@ -19,7 +19,7 @@
#include "i2c_session.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
void Session::Open(Bus bus, u32 slave_address, AddressingMode addr_mode, SpeedMode speed_mode, BusAccessor *bus_accessor, u32 max_retries, u64 retry_wait_time) {
std::scoped_lock lk(this->bus_accessor_mutex);
@ -74,7 +74,7 @@ namespace sts::i2c::driver::impl {
case Command::Receive:
R_TRY(this->bus_accessor->Receive(reinterpret_cast<u8 *>(dst), num_bytes, option, this->addressing_mode, this->slave_address));
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
return ResultSuccess();

View file

@ -21,7 +21,7 @@
#include "i2c_driver_types.hpp"
#include "i2c_bus_accessor.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
class Session {
private:

View file

@ -20,7 +20,7 @@
#include "i2c_types.hpp"
#include "i2c_command_list.hpp"
namespace sts::i2c {
namespace ams::i2c {
namespace {

View file

@ -20,7 +20,7 @@
#include "i2c_types.hpp"
namespace sts::i2c {
namespace ams::i2c {
enum class Command {
Send = 0,
@ -43,7 +43,7 @@ namespace sts::i2c {
size_t cur_index = 0;
public:
CommandListFormatter(void *cmd_list, size_t cmd_list_size) : cmd_list(static_cast<u8 *>(cmd_list)), cmd_list_size(cmd_list_size) {
STS_ASSERT(cmd_list_size <= MaxCommandListSize);
AMS_ASSERT(cmd_list_size <= MaxCommandListSize);
}
~CommandListFormatter() {
this->cmd_list = nullptr;

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::i2c {
namespace ams::i2c {
enum class AddressingMode {
SevenBit = 0,

View file

@ -19,7 +19,7 @@
#include "pinmux_initial_configuration.hpp"
#include "pinmux_utils.hpp"
namespace sts::pinmux {
namespace ams::pinmux {
namespace {
@ -61,11 +61,11 @@ namespace sts::pinmux {
num_configs = NumInitialConfigsIowa;
break;
/* Unknown hardware type, we can't proceed. */
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
/* Ensure we found an appropriate config. */
STS_ASSERT(configs != nullptr);
AMS_ASSERT(configs != nullptr);
for (size_t i = 0; i < num_configs; i++) {
UpdatePad(configs[i].name, configs[i].val, configs[i].mask);

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::pinmux {
namespace ams::pinmux {
void SetInitialConfiguration();

View file

@ -18,7 +18,7 @@
#include "pinmux_utils.hpp"
namespace sts::pinmux {
namespace ams::pinmux {
namespace {
@ -33,12 +33,12 @@ namespace sts::pinmux {
/* Helpers. */
inline const Definition *GetDefinition(u32 pinmux_name) {
STS_ASSERT(pinmux_name < PadNameMax);
AMS_ASSERT(pinmux_name < PadNameMax);
return &Map[pinmux_name];
}
inline const DrivePadDefinition *GetDrivePadDefinition(u32 drivepad_name) {
STS_ASSERT(drivepad_name < DrivePadNameMax);
AMS_ASSERT(drivepad_name < DrivePadNameMax);
return &DrivePadMap[drivepad_name];
}
@ -104,7 +104,7 @@ namespace sts::pinmux {
u32 pinmux_val = reg::Read(pinmux_reg);
/* This PINMUX register is locked */
STS_ASSERT((pinmux_val & 0x80) == 0);
AMS_ASSERT((pinmux_val & 0x80) == 0);
u32 pm_val = (pinmux_config_val & 0x07);

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::pinmux {
namespace ams::pinmux {
/* Pinmux Utilities. */
u32 UpdatePark(u32 pinmux_name);

View file

@ -40,19 +40,19 @@ extern "C" {
void __libnx_exception_handler(ThreadExceptionDump *ctx);
}
namespace sts::ams {
namespace ams {
ncm::TitleId StratosphereTitleId = ncm::TitleId::Boot2;
ncm::TitleId CurrentTitleId = ncm::TitleId::Boot2;
}
namespace sts::result {
namespace result {
bool CallFatalOnResultAssertion = false;
}
}
using namespace sts;
using namespace ams;
void __libnx_exception_handler(ThreadExceptionDump *ctx) {
ams::CrashHandler(ctx);

View file

@ -21,7 +21,7 @@
#include "creport_crash_report.hpp"
#include "creport_utils.hpp"
namespace sts::creport {
namespace ams::creport {
namespace {
@ -116,8 +116,8 @@ namespace sts::creport {
}
void CrashReport::GetFatalContext(FatalContext *_out) const {
static_assert(sizeof(*_out) == sizeof(sts::fatal::CpuContext));
sts::fatal::CpuContext *out = reinterpret_cast<sts::fatal::CpuContext *>(_out);
static_assert(sizeof(*_out) == sizeof(ams::fatal::CpuContext));
ams::fatal::CpuContext *out = reinterpret_cast<ams::fatal::CpuContext *>(_out);
std::memset(out, 0, sizeof(*out));
/* TODO: Support generating 32-bit fatal contexts? */

View file

@ -22,7 +22,7 @@
#include "creport_threads.hpp"
#include "creport_modules.hpp"
namespace sts::creport {
namespace ams::creport {
class CrashReport {
private:

View file

@ -46,19 +46,19 @@ extern "C" {
void __libnx_exception_handler(ThreadExceptionDump *ctx);
}
namespace sts::ams {
namespace ams {
ncm::TitleId StratosphereTitleId = ncm::TitleId::Creport;
ncm::TitleId CurrentTitleId = ncm::TitleId::Creport;
}
namespace sts::result {
namespace result {
bool CallFatalOnResultAssertion = true;
}
}
using namespace sts;
using namespace ams;
void __libnx_exception_handler(ThreadExceptionDump *ctx) {
ams::CrashHandler(ctx);

View file

@ -17,7 +17,7 @@
#include "creport_modules.hpp"
#include "creport_utils.hpp"
namespace sts::creport {
namespace ams::creport {
namespace {

View file

@ -19,7 +19,7 @@
#include <stratosphere.hpp>
#include "creport_threads.hpp"
namespace sts::creport {
namespace ams::creport {
class ModuleList {
private:

View file

@ -17,7 +17,7 @@
#include "creport_threads.hpp"
#include "creport_modules.hpp"
namespace sts::creport {
namespace ams::creport {
namespace {

View file

@ -19,7 +19,7 @@
#include <stratosphere.hpp>
#include <map>
namespace sts::creport {
namespace ams::creport {
/* Forward declare ModuleList class. */
class ModuleList;

View file

@ -16,7 +16,7 @@
#include "creport_utils.hpp"
namespace sts::creport {
namespace ams::creport {
namespace {

View file

@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::creport {
namespace ams::creport {
/* Utility functions. */
void DumpMemoryHexToFile(FILE *f, const char *prefix, const void *data, size_t size);

View file

@ -18,7 +18,7 @@
#include "dmnt_cheat_service.hpp"
#include "impl/dmnt_cheat_api.hpp"
namespace sts::dmnt::cheat {
namespace ams::dmnt::cheat {
/* ========================================================================================= */
/* ==================================== Meta Commands ==================================== */

Some files were not shown because too many files have changed in this diff Show more