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

@@ -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);