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

@@ -17,7 +17,7 @@
#include <stratosphere.hpp>
#include "ams_bpc.h"
namespace sts::ams {
namespace ams {
namespace {
@@ -34,7 +34,7 @@ namespace sts::ams {
}
extern ncm::TitleId StratosphereTitleId;
extern ncm::TitleId CurrentTitleId;
void WEAK ExceptionHandler(FatalErrorContext *ctx) {
R_ASSERT(amsBpcInitialize());
@@ -49,7 +49,7 @@ namespace sts::ams {
{
ams_ctx.magic = FatalErrorContext::Magic;
ams_ctx.error_desc = ctx->error_desc;
ams_ctx.title_id = static_cast<u64>(StratosphereTitleId);
ams_ctx.title_id = static_cast<u64>(CurrentTitleId);
for (size_t i = 0; i < FatalErrorContext::NumGprs; i++) {
ams_ctx.gprs[i] = ctx->cpu_gprs[i].x;
}
@@ -122,7 +122,7 @@ namespace sts::ams {
}
/* Just call the user exception handler. */
::sts::ams::ExceptionHandler(&ams_ctx);
::ams::ExceptionHandler(&ams_ctx);
}
inline NORETURN void AbortImpl() {
@@ -160,7 +160,7 @@ extern "C" {
/* Custom abort handler, so that std::abort will trigger these. */
void abort() {
sts::ams::AbortImpl();
ams::AbortImpl();
}
void *__cxa_allocate_ecxeption(size_t thrown_size) {

View File

@@ -18,12 +18,12 @@
#include <stratosphere/spl.hpp>
#include <stratosphere/spl/smc/spl_smc.hpp>
namespace sts::ams {
namespace ams::exosphere {
ApiInfo GetApiInfo() {
u64 exosphere_cfg;
if (spl::smc::GetConfig(&exosphere_cfg, 1, SplConfigItem_ExosphereApiVersion) != spl::smc::Result::Success) {
R_ASSERT(ResultExosphereNotPresent());
R_ASSERT(ResultNotPresent());
}
return ApiInfo{

View File

@@ -21,7 +21,7 @@
#include <stratosphere/pm.hpp>
#include <stratosphere/boot2.hpp>
namespace sts::boot2 {
namespace ams::boot2 {
namespace {
@@ -145,9 +145,9 @@ namespace sts::boot2 {
/* Launch, lightly validate result. */
{
const auto launch_result = pm::shell::LaunchTitle(&process_id, loc, launch_flags);
STS_ASSERT(!(svc::ResultOutOfResource::Includes(launch_result)));
STS_ASSERT(!(svc::ResultOutOfMemory::Includes(launch_result)));
STS_ASSERT(!(svc::ResultLimitReached::Includes(launch_result)));
AMS_ASSERT(!(svc::ResultOutOfResource::Includes(launch_result)));
AMS_ASSERT(!(svc::ResultOutOfMemory::Includes(launch_result)));
AMS_ASSERT(!(svc::ResultLimitReached::Includes(launch_result)));
}
if (out_process_id) {
@@ -271,7 +271,7 @@ namespace sts::boot2 {
}
/* Don't allow invalid lines. */
STS_ASSERT(name_len <= sizeof(sm::ServiceName));
AMS_ASSERT(name_len <= sizeof(sm::ServiceName));
/* Declare the service. */
R_ASSERT(sm::mitm::DeclareFutureMitm(sm::ServiceName::Encode(mitm_list + offset, name_len)));

View File

@@ -18,7 +18,7 @@
#include <stratosphere.hpp>
#include <stratosphere/cfg.hpp>
namespace sts::cfg {
namespace ams::cfg {
namespace {

View File

@@ -22,7 +22,7 @@
#include <stratosphere/pm.hpp>
#include <stratosphere/util.hpp>
namespace sts::cfg {
namespace ams::cfg {
namespace {

View File

@@ -18,7 +18,7 @@
#include <stratosphere.hpp>
#include <stratosphere/cfg.hpp>
namespace sts::cfg {
namespace ams::cfg {
namespace {

View File

@@ -19,7 +19,7 @@
#include <stratosphere/cfg.hpp>
#include <stratosphere/sm.hpp>
namespace sts::cfg {
namespace ams::cfg {
namespace {

View File

@@ -15,7 +15,7 @@
*/
#include <stratosphere.hpp>
namespace sts::dd {
namespace ams::dd {
uintptr_t QueryIoMapping(uintptr_t phys_addr, size_t size) {
u64 virtual_addr;

View File

@@ -19,7 +19,7 @@
#include <stratosphere/pm.hpp>
#include <stratosphere/hid.hpp>
namespace sts::hid {
namespace ams::hid {
namespace {

View File

@@ -16,7 +16,7 @@
#include <stratosphere.hpp>
namespace sts::hos {
namespace ams::hos {
namespace {
@@ -35,39 +35,39 @@ namespace sts::hos {
return;
}
switch (ams::GetApiInfo().GetTargetFirmware()) {
case ams::TargetFirmware_100:
switch (exosphere::GetApiInfo().GetTargetFirmware()) {
case exosphere::TargetFirmware_100:
g_hos_version = hos::Version_100;
break;
case ams::TargetFirmware_200:
case exosphere::TargetFirmware_200:
g_hos_version = hos::Version_200;
break;
case ams::TargetFirmware_300:
case exosphere::TargetFirmware_300:
g_hos_version = hos::Version_300;
break;
case ams::TargetFirmware_400:
case exosphere::TargetFirmware_400:
g_hos_version = hos::Version_400;
break;
case ams::TargetFirmware_500:
case exosphere::TargetFirmware_500:
g_hos_version = hos::Version_500;
break;
case ams::TargetFirmware_600:
case ams::TargetFirmware_620:
case exosphere::TargetFirmware_600:
case exosphere::TargetFirmware_620:
g_hos_version = hos::Version_600;
break;
case ams::TargetFirmware_700:
case exosphere::TargetFirmware_700:
g_hos_version = hos::Version_700;
break;
case ams::TargetFirmware_800:
case exosphere::TargetFirmware_800:
g_hos_version = hos::Version_800;
break;
case ams::TargetFirmware_810:
case exosphere::TargetFirmware_810:
g_hos_version = hos::Version_810;
break;
case ams::TargetFirmware_900:
case exosphere::TargetFirmware_900:
g_hos_version = hos::Version_900;
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
__atomic_store_n(&g_has_cached, true, __ATOMIC_SEQ_CST);
@@ -75,7 +75,7 @@ namespace sts::hos {
}
::sts::hos::Version GetVersion() {
::ams::hos::Version GetVersion() {
CacheValues();
return g_hos_version;
}
@@ -133,7 +133,7 @@ namespace sts::hos {
minor = 0;
micro = 0;
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
hosversionSet(MAKEHOSVERSION(major, minor, micro));
}

View File

@@ -17,7 +17,7 @@
#include <stratosphere.hpp>
#include <stratosphere/kvdb/kvdb_archive.hpp>
namespace sts::kvdb {
namespace ams::kvdb {
namespace {
@@ -90,7 +90,7 @@ namespace sts::kvdb {
Result ArchiveReader::ReadEntryCount(size_t *out) {
/* This should only be called at the start of reading stream. */
STS_ASSERT(this->offset == 0);
AMS_ASSERT(this->offset == 0);
/* Read and validate header. */
ArchiveHeader header;
@@ -103,7 +103,7 @@ namespace sts::kvdb {
Result ArchiveReader::GetEntrySize(size_t *out_key_size, size_t *out_value_size) {
/* This should only be called after ReadEntryCount. */
STS_ASSERT(this->offset != 0);
AMS_ASSERT(this->offset != 0);
/* Peek the next entry header. */
ArchiveEntryHeader header;
@@ -117,7 +117,7 @@ namespace sts::kvdb {
Result ArchiveReader::ReadEntry(void *out_key, size_t key_size, void *out_value, size_t value_size) {
/* This should only be called after ReadEntryCount. */
STS_ASSERT(this->offset != 0);
AMS_ASSERT(this->offset != 0);
/* Read the next entry header. */
ArchiveEntryHeader header;
@@ -125,8 +125,8 @@ namespace sts::kvdb {
R_TRY(header.Validate());
/* Key size and Value size must be correct. */
STS_ASSERT(key_size == header.key_size);
STS_ASSERT(value_size == header.value_size);
AMS_ASSERT(key_size == header.key_size);
AMS_ASSERT(value_size == header.value_size);
R_ASSERT(this->Read(out_key, key_size));
R_ASSERT(this->Read(out_value, value_size));
@@ -147,7 +147,7 @@ namespace sts::kvdb {
void ArchiveWriter::WriteHeader(size_t entry_count) {
/* This should only be called at start of write. */
STS_ASSERT(this->offset == 0);
AMS_ASSERT(this->offset == 0);
ArchiveHeader header = ArchiveHeader::Make(entry_count);
R_ASSERT(this->Write(&header, sizeof(header)));
@@ -155,7 +155,7 @@ namespace sts::kvdb {
void ArchiveWriter::WriteEntry(const void *key, size_t key_size, const void *value, size_t value_size) {
/* This should only be called after writing header. */
STS_ASSERT(this->offset != 0);
AMS_ASSERT(this->offset != 0);
ArchiveEntryHeader header = ArchiveEntryHeader::Make(key_size, value_size);
R_ASSERT(this->Write(&header, sizeof(header)));

View File

@@ -18,7 +18,7 @@
#include <stratosphere.hpp>
#include <stratosphere/kvdb/kvdb_file_key_value_store.hpp>
namespace sts::kvdb {
namespace ams::kvdb {
/* Cache implementation. */
void *FileKeyValueStore::Cache::Allocate(size_t size) {
@@ -57,7 +57,7 @@ namespace sts::kvdb {
this->backing_buffer_free_offset = 0;
this->count = 0;
this->entries = static_cast<decltype(this->entries)>(this->Allocate(sizeof(*this->entries) * this->capacity));
STS_ASSERT(this->entries != nullptr);
AMS_ASSERT(this->entries != nullptr);
}
std::optional<size_t> FileKeyValueStore::Cache::TryGet(void *out_value, size_t max_out_size, const void *key, size_t key_size) {
@@ -104,7 +104,7 @@ namespace sts::kvdb {
}
/* Ensure key size is small enough. */
STS_ASSERT(key_size <= MaxKeySize);
AMS_ASSERT(key_size <= MaxKeySize);
/* If we're at capacity, invalidate the cache. */
if (this->count == this->capacity) {

View File

@@ -21,7 +21,7 @@
#include "ldr_ams.h"
namespace sts::ldr::pm {
namespace ams::ldr::pm {
/* Information API. */
Result CreateProcess(Handle *out, PinId pin_id, u32 flags, Handle reslimit) {

View File

@@ -18,7 +18,7 @@
#include <stratosphere.hpp>
#include <stratosphere/map.hpp>
namespace sts::map {
namespace ams::map {
namespace {
@@ -106,7 +106,7 @@ namespace sts::map {
R_TRY(GetProcessAddressSpaceInfo(&address_space, process_handle));
if (size > address_space.aslr_size) {
return ro::ResultInsufficientAddressSpace();
return ro::ResultOutOfAddressSpace();
}
uintptr_t try_address;
@@ -129,7 +129,7 @@ namespace sts::map {
return ResultSuccess();
}
return ro::ResultInsufficientAddressSpace();;
return ro::ResultOutOfAddressSpace();
}
Result MapCodeMemoryInProcessModern(MappedCodeMemory &out_mcm, Handle process_handle, uintptr_t base_address, size_t size) {
@@ -137,7 +137,7 @@ namespace sts::map {
R_TRY(GetProcessAddressSpaceInfo(&address_space, process_handle));
if (size > address_space.aslr_size) {
return ro::ResultInsufficientAddressSpace();;
return ro::ResultOutOfAddressSpace();
}
uintptr_t try_address;
@@ -169,7 +169,7 @@ namespace sts::map {
return ResultSuccess();
}
return ro::ResultInsufficientAddressSpace();;
return ro::ResultOutOfAddressSpace();
}
}

View File

@@ -16,7 +16,7 @@
#include <stratosphere.hpp>
#include "os_inter_process_event.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
namespace {
@@ -40,7 +40,7 @@ namespace sts::os::impl {
}
Result InterProcessEvent::Initialize(bool autoclear) {
STS_ASSERT(!this->is_initialized);
AMS_ASSERT(!this->is_initialized);
Handle rh, wh;
R_TRY(CreateEventHandles(&rh, &wh));
this->Initialize(rh, true, wh, true, autoclear);
@@ -48,8 +48,8 @@ namespace sts::os::impl {
}
void InterProcessEvent::Initialize(Handle read_handle, bool manage_read_handle, Handle write_handle, bool manage_write_handle, bool autoclear) {
STS_ASSERT(!this->is_initialized);
STS_ASSERT(read_handle != INVALID_HANDLE || write_handle != INVALID_HANDLE);
AMS_ASSERT(!this->is_initialized);
AMS_ASSERT(read_handle != INVALID_HANDLE || write_handle != INVALID_HANDLE);
this->read_handle = read_handle;
this->manage_read_handle = manage_read_handle;
this->write_handle = write_handle;
@@ -59,30 +59,30 @@ namespace sts::os::impl {
}
Handle InterProcessEvent::DetachReadableHandle() {
STS_ASSERT(this->is_initialized);
AMS_ASSERT(this->is_initialized);
const Handle handle = this->read_handle;
STS_ASSERT(handle != INVALID_HANDLE);
AMS_ASSERT(handle != INVALID_HANDLE);
this->read_handle = INVALID_HANDLE;
this->manage_read_handle = false;
return handle;
}
Handle InterProcessEvent::DetachWritableHandle() {
STS_ASSERT(this->is_initialized);
AMS_ASSERT(this->is_initialized);
const Handle handle = this->write_handle;
STS_ASSERT(handle != INVALID_HANDLE);
AMS_ASSERT(handle != INVALID_HANDLE);
this->write_handle = INVALID_HANDLE;
this->manage_write_handle = false;
return handle;
}
Handle InterProcessEvent::GetReadableHandle() const {
STS_ASSERT(this->is_initialized);
AMS_ASSERT(this->is_initialized);
return this->read_handle;
}
Handle InterProcessEvent::GetWritableHandle() const {
STS_ASSERT(this->is_initialized);
AMS_ASSERT(this->is_initialized);
return this->write_handle;
}

View File

@@ -17,7 +17,7 @@
#pragma once
#include <stratosphere.hpp>
namespace sts::os::impl {
namespace ams::os::impl {
class WaitableHolderOfInterProcessEvent;

View File

@@ -16,7 +16,7 @@
#pragma once
#include <stratosphere.hpp>
namespace sts::os::impl {
namespace ams::os::impl {
class WaitableObjectList;
class WaitableManagerImpl;

View File

@@ -21,7 +21,7 @@
#include "os_waitable_holder_of_thread.hpp"
#include "os_waitable_holder_of_message_queue.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
struct WaitableHolderImpl {
union {
@@ -36,7 +36,7 @@ namespace sts::os::impl {
};
#define CHECK_HOLDER(T) \
static_assert(std::is_base_of<::sts::os::impl::WaitableHolderBase, T>::value && std::is_trivially_destructible<T>::value, #T)
static_assert(std::is_base_of<::ams::os::impl::WaitableHolderBase, T>::value && std::is_trivially_destructible<T>::value, #T)
CHECK_HOLDER(WaitableHolderOfHandle);
CHECK_HOLDER(WaitableHolderOfEvent);

View File

@@ -17,7 +17,7 @@
#include "os_waitable_holder_base.hpp"
#include "os_waitable_object_list.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
class WaitableHolderOfEvent : public WaitableHolderOfUserObject {
private:

View File

@@ -16,7 +16,7 @@
#pragma once
#include "os_waitable_holder_base.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
class WaitableHolderOfHandle : public WaitableHolderOfKernelObject {
private:

View File

@@ -17,7 +17,7 @@
#include "os_waitable_holder_base.hpp"
#include "os_inter_process_event.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
class WaitableHolderOfInterProcessEvent : public WaitableHolderOfKernelObject {
private:
@@ -31,7 +31,7 @@ namespace sts::os::impl {
}
virtual Handle GetHandle() const override {
STS_ASSERT(this->event->is_initialized);
AMS_ASSERT(this->event->is_initialized);
return this->event->GetReadableHandle();
}
};

View File

@@ -16,7 +16,7 @@
#pragma once
#include "os_waitable_holder_base.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
class WaitableHolderOfInterruptEvent : public WaitableHolderOfKernelObject {
private:
@@ -30,7 +30,7 @@ namespace sts::os::impl {
}
virtual Handle GetHandle() const override {
STS_ASSERT(this->event->is_initialized);
AMS_ASSERT(this->event->is_initialized);
return this->event->handle.Get();
}
};

View File

@@ -17,7 +17,7 @@
#include "os_waitable_holder_base.hpp"
#include "os_waitable_object_list.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
template<MessageQueueWaitKind WaitKind>
class WaitableHolderOfMessageQueue : public WaitableHolderOfUserObject {

View File

@@ -16,7 +16,7 @@
#pragma once
#include "os_waitable_holder_base.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
/* Nintendo implements this as a user wait object, operating on Thread state. */
/* Libnx doesn't have an equivalent, so we'll use the thread's handle for kernel semantics. */

View File

@@ -16,7 +16,7 @@
#include "os_waitable_manager_impl.hpp"
#include "os_waitable_object_list.hpp"
namespace sts::os::impl{
namespace ams::os::impl{
WaitableHolderBase *WaitableManagerImpl::WaitAnyImpl(bool infinite, u64 timeout) {
/* Set processing thread handle while in scope. */
@@ -64,7 +64,7 @@ namespace sts::os::impl{
index = WaitTimedOut;
} else {
index = this->WaitSynchronization(object_handles, count, min_timeout);
STS_ASSERT(index != WaitInvalid);
AMS_ASSERT(index != WaitInvalid);
}
switch (index) {
@@ -115,7 +115,7 @@ namespace sts::os::impl{
for (WaitableHolderBase &holder_base : this->waitable_list) {
if (Handle handle = holder_base.GetHandle(); handle != INVALID_HANDLE) {
STS_ASSERT(count < MaximumHandleCount);
AMS_ASSERT(count < MaximumHandleCount);
out_handles[count] = handle;
out_objects[count] = &holder_base;

View File

@@ -16,7 +16,7 @@
#pragma once
#include "os_waitable_holder_base.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
class WaitableManagerImpl {
public:

View File

@@ -17,7 +17,7 @@
#include "os_waitable_holder_base.hpp"
#include "os_waitable_manager_impl.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
class WaitableObjectList {
public:

View File

@@ -16,7 +16,7 @@
#include <stratosphere.hpp>
#include "impl/os_waitable_object_list.hpp"
namespace sts::os {
namespace ams::os {
Event::Event(bool a, bool s) : auto_clear(a), signaled(s) {
new (GetPointer(this->waitable_object_list_storage)) impl::WaitableObjectList();

View File

@@ -16,10 +16,10 @@
#include <stratosphere.hpp>
#include "impl/os_waitable_object_list.hpp"
namespace sts::os {
namespace ams::os {
Result InterruptEvent::Initialize(u32 interrupt_id, bool autoclear) {
STS_ASSERT(!this->is_initialized);
AMS_ASSERT(!this->is_initialized);
this->auto_clear = autoclear;
const auto type = this->auto_clear ? svc::InterruptType_Edge : svc::InterruptType_Level;
@@ -30,7 +30,7 @@ namespace sts::os {
}
void InterruptEvent::Finalize() {
STS_ASSERT(this->is_initialized);
AMS_ASSERT(this->is_initialized);
R_ASSERT(svcCloseHandle(this->handle.Move()));
this->auto_clear = true;
this->is_initialized = false;
@@ -46,7 +46,7 @@ namespace sts::os {
}
void InterruptEvent::Wait() {
STS_ASSERT(this->is_initialized);
AMS_ASSERT(this->is_initialized);
while (true) {
/* Continuously wait, until success. */
@@ -66,7 +66,7 @@ namespace sts::os {
}
bool InterruptEvent::TryWait() {
STS_ASSERT(this->is_initialized);
AMS_ASSERT(this->is_initialized);
if (this->auto_clear) {
/* Auto-clear. Just try to reset. */
@@ -87,7 +87,7 @@ namespace sts::os {
}
bool InterruptEvent::TimedWait(u64 ns) {
STS_ASSERT(this->is_initialized);
AMS_ASSERT(this->is_initialized);
TimeoutHelper timeout_helper(ns);
while (true) {

View File

@@ -16,7 +16,7 @@
#include <stratosphere.hpp>
#include "impl/os_waitable_object_list.hpp"
namespace sts::os {
namespace ams::os {
MessageQueue::MessageQueue(std::unique_ptr<uintptr_t[]> buf, size_t c): buffer(std::move(buf)), capacity(c) {
new (GetPointer(this->waitable_object_list_storage)) impl::WaitableObjectList();
@@ -28,7 +28,7 @@ namespace sts::os {
void MessageQueue::SendInternal(uintptr_t data) {
/* Ensure we don't corrupt the queue, but this should never happen. */
STS_ASSERT(this->count < this->capacity);
AMS_ASSERT(this->count < this->capacity);
/* Write data to tail of queue. */
this->buffer[(this->count++ + this->offset) % this->capacity] = data;
@@ -36,7 +36,7 @@ namespace sts::os {
void MessageQueue::SendNextInternal(uintptr_t data) {
/* Ensure we don't corrupt the queue, but this should never happen. */
STS_ASSERT(this->count < this->capacity);
AMS_ASSERT(this->count < this->capacity);
/* Write data to head of queue. */
this->offset = (this->offset + this->capacity - 1) % this->capacity;
@@ -46,7 +46,7 @@ namespace sts::os {
uintptr_t MessageQueue::ReceiveInternal() {
/* Ensure we don't corrupt the queue, but this should never happen. */
STS_ASSERT(this->count > 0);
AMS_ASSERT(this->count > 0);
uintptr_t data = this->buffer[this->offset];
this->offset = (this->offset + 1) % this->capacity;
@@ -56,7 +56,7 @@ namespace sts::os {
uintptr_t MessageQueue::PeekInternal() {
/* Ensure we don't corrupt the queue, but this should never happen. */
STS_ASSERT(this->count > 0);
AMS_ASSERT(this->count > 0);
return this->buffer[this->offset];
}

View File

@@ -16,7 +16,7 @@
#include <stratosphere.hpp>
#include "impl/os_waitable_holder_impl.hpp"
namespace sts::os {
namespace ams::os {
SystemEvent::SystemEvent(bool inter_process, bool autoclear) : state(SystemEventState::Uninitialized) {
if (inter_process) {
@@ -35,34 +35,34 @@ namespace sts::os {
}
Event &SystemEvent::GetEvent() {
STS_ASSERT(this->state == SystemEventState::Event);
AMS_ASSERT(this->state == SystemEventState::Event);
return GetReference(this->storage_for_event);
}
const Event &SystemEvent::GetEvent() const {
STS_ASSERT(this->state == SystemEventState::Event);
AMS_ASSERT(this->state == SystemEventState::Event);
return GetReference(this->storage_for_event);
}
impl::InterProcessEvent &SystemEvent::GetInterProcessEvent() {
STS_ASSERT(this->state == SystemEventState::InterProcessEvent);
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
return GetReference(this->storage_for_inter_process_event);
}
const impl::InterProcessEvent &SystemEvent::GetInterProcessEvent() const {
STS_ASSERT(this->state == SystemEventState::InterProcessEvent);
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
return GetReference(this->storage_for_inter_process_event);
}
Result SystemEvent::InitializeAsEvent(bool autoclear) {
STS_ASSERT(this->state == SystemEventState::Uninitialized);
AMS_ASSERT(this->state == SystemEventState::Uninitialized);
new (GetPointer(this->storage_for_event)) Event(autoclear);
this->state = SystemEventState::Event;
return ResultSuccess();
}
Result SystemEvent::InitializeAsInterProcessEvent(bool autoclear) {
STS_ASSERT(this->state == SystemEventState::Uninitialized);
AMS_ASSERT(this->state == SystemEventState::Uninitialized);
new (GetPointer(this->storage_for_inter_process_event)) impl::InterProcessEvent();
this->state = SystemEventState::InterProcessEvent;
@@ -77,7 +77,7 @@ namespace sts::os {
}
void SystemEvent::AttachHandles(Handle read_handle, bool manage_read_handle, Handle write_handle, bool manage_write_handle, bool autoclear) {
STS_ASSERT(this->state == SystemEventState::Uninitialized);
AMS_ASSERT(this->state == SystemEventState::Uninitialized);
new (GetPointer(this->storage_for_inter_process_event)) impl::InterProcessEvent();
this->state = SystemEventState::InterProcessEvent;
this->GetInterProcessEvent().Initialize(read_handle, manage_read_handle, write_handle, manage_write_handle, autoclear);
@@ -92,22 +92,22 @@ namespace sts::os {
}
Handle SystemEvent::DetachReadableHandle() {
STS_ASSERT(this->state == SystemEventState::InterProcessEvent);
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
return this->GetInterProcessEvent().DetachReadableHandle();
}
Handle SystemEvent::DetachWritableHandle() {
STS_ASSERT(this->state == SystemEventState::InterProcessEvent);
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
return this->GetInterProcessEvent().DetachWritableHandle();
}
Handle SystemEvent::GetReadableHandle() const {
STS_ASSERT(this->state == SystemEventState::InterProcessEvent);
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
return this->GetInterProcessEvent().GetReadableHandle();
}
Handle SystemEvent::GetWritableHandle() const {
STS_ASSERT(this->state == SystemEventState::InterProcessEvent);
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
return this->GetInterProcessEvent().GetWritableHandle();
}
@@ -121,7 +121,7 @@ namespace sts::os {
case SystemEventState::InterProcessEvent:
this->GetInterProcessEvent().~InterProcessEvent();
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
this->state = SystemEventState::Uninitialized;
}
@@ -135,7 +135,7 @@ namespace sts::os {
this->GetInterProcessEvent().Signal();
break;
case SystemEventState::Uninitialized:
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
@@ -148,7 +148,7 @@ namespace sts::os {
this->GetInterProcessEvent().Reset();
break;
case SystemEventState::Uninitialized:
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
void SystemEvent::Wait() {
@@ -160,7 +160,7 @@ namespace sts::os {
this->GetInterProcessEvent().Wait();
break;
case SystemEventState::Uninitialized:
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
@@ -171,7 +171,7 @@ namespace sts::os {
case SystemEventState::InterProcessEvent:
return this->GetInterProcessEvent().TryWait();
case SystemEventState::Uninitialized:
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
@@ -182,7 +182,7 @@ namespace sts::os {
case SystemEventState::InterProcessEvent:
return this->GetInterProcessEvent().TimedWait(ns);
case SystemEventState::Uninitialized:
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
}

View File

@@ -17,11 +17,11 @@
#include "impl/os_waitable_holder_impl.hpp"
#include "impl/os_waitable_manager_impl.hpp"
namespace sts::os {
namespace ams::os {
WaitableHolder::WaitableHolder(Handle handle) {
/* Don't allow invalid handles. */
STS_ASSERT(handle != INVALID_HANDLE);
AMS_ASSERT(handle != INVALID_HANDLE);
/* Initialize appropriate holder. */
new (GetPointer(this->impl_storage)) impl::WaitableHolderOfHandle(handle);
@@ -48,7 +48,7 @@ namespace sts::os {
new (GetPointer(this->impl_storage)) impl::WaitableHolderOfInterProcessEvent(&event->GetInterProcessEvent());
break;
case SystemEventState::Uninitialized:
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
/* Set user-data. */
@@ -80,7 +80,7 @@ namespace sts::os {
case MessageQueueWaitKind::ForNotEmpty:
new (GetPointer(this->impl_storage)) impl::WaitableHolderOfMessageQueueForNotEmpty(message_queue);
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
/* Set user-data. */
@@ -91,7 +91,7 @@ namespace sts::os {
auto holder_base = reinterpret_cast<impl::WaitableHolderBase *>(GetPointer(this->impl_storage));
/* Don't allow destruction of a linked waitable holder. */
STS_ASSERT(!holder_base->IsLinkedToManager());
AMS_ASSERT(!holder_base->IsLinkedToManager());
holder_base->~WaitableHolderBase();
}
@@ -100,7 +100,7 @@ namespace sts::os {
auto holder_base = reinterpret_cast<impl::WaitableHolderBase *>(GetPointer(this->impl_storage));
/* Don't allow unlinking of an unlinked holder. */
STS_ASSERT(holder_base->IsLinkedToManager());
AMS_ASSERT(holder_base->IsLinkedToManager());
holder_base->GetManager()->UnlinkWaitableHolder(*holder_base);
holder_base->SetManager(nullptr);

View File

@@ -17,7 +17,7 @@
#include "impl/os_waitable_holder_impl.hpp"
#include "impl/os_waitable_manager_impl.hpp"
namespace sts::os {
namespace ams::os {
WaitableManager::WaitableManager() {
/* Initialize storage. */
@@ -28,7 +28,7 @@ namespace sts::os {
auto &impl = GetReference(this->impl_storage);
/* Don't allow destruction of a non-empty waitable holder. */
STS_ASSERT(impl.IsEmpty());
AMS_ASSERT(impl.IsEmpty());
impl.~WaitableManagerImpl();
}
@@ -39,7 +39,7 @@ namespace sts::os {
auto &impl = GetReference(this->impl_storage);
/* Don't allow waiting on empty list. */
STS_ASSERT(!impl.IsEmpty());
AMS_ASSERT(!impl.IsEmpty());
return reinterpret_cast<WaitableHolder *>(impl.WaitAny());
}
@@ -48,7 +48,7 @@ namespace sts::os {
auto &impl = GetReference(this->impl_storage);
/* Don't allow waiting on empty list. */
STS_ASSERT(!impl.IsEmpty());
AMS_ASSERT(!impl.IsEmpty());
return reinterpret_cast<WaitableHolder *>(impl.TryWaitAny());
}
@@ -57,7 +57,7 @@ namespace sts::os {
auto &impl = GetReference(this->impl_storage);
/* Don't allow waiting on empty list. */
STS_ASSERT(!impl.IsEmpty());
AMS_ASSERT(!impl.IsEmpty());
return reinterpret_cast<WaitableHolder *>(impl.TimedWaitAny(timeout));
}
@@ -68,7 +68,7 @@ namespace sts::os {
auto holder_base = reinterpret_cast<impl::WaitableHolderBase *>(GetPointer(holder->impl_storage));
/* Don't allow double-linking a holder. */
STS_ASSERT(!holder_base->IsLinkedToManager());
AMS_ASSERT(!holder_base->IsLinkedToManager());
impl.LinkWaitableHolder(*holder_base);
holder_base->SetManager(&impl);

View File

@@ -27,7 +27,7 @@
/* IPS Patching adapted from Luma3DS (https://github.com/AuroraWright/Luma3DS/blob/master/sysmodules/loader/source/patcher.c) */
namespace sts::patcher {
namespace ams::patcher {
namespace {
@@ -101,11 +101,11 @@ namespace sts::patcher {
void ApplyIpsPatch(u8 *mapped_module, size_t mapped_size, size_t protected_size, size_t offset, bool is_ips32, FILE *f_ips) {
/* Validate offset/protected size. */
STS_ASSERT(offset <= protected_size);
AMS_ASSERT(offset <= protected_size);
u8 buffer[sizeof(Ips32TailMagic)];
while (true) {
STS_ASSERT(fread(buffer, is_ips32 ? sizeof(Ips32TailMagic) : sizeof(IpsTailMagic), 1, f_ips) == 1);
AMS_ASSERT(fread(buffer, is_ips32 ? sizeof(Ips32TailMagic) : sizeof(IpsTailMagic), 1, f_ips) == 1);
if (IsIpsTail(is_ips32, buffer)) {
break;
@@ -115,18 +115,18 @@ namespace sts::patcher {
u32 patch_offset = GetIpsPatchOffset(is_ips32, buffer);
/* Size of patch. */
STS_ASSERT(fread(buffer, 2, 1, f_ips) == 1);
AMS_ASSERT(fread(buffer, 2, 1, f_ips) == 1);
u32 patch_size = GetIpsPatchSize(is_ips32, buffer);
/* Check for RLE encoding. */
if (patch_size == 0) {
/* Size of RLE. */
STS_ASSERT(fread(buffer, 2, 1, f_ips) == 1);
AMS_ASSERT(fread(buffer, 2, 1, f_ips) == 1);
u32 rle_size = (buffer[0] << 8) | (buffer[1]);
/* Value for RLE. */
STS_ASSERT(fread(buffer, 1, 1, f_ips) == 1);
AMS_ASSERT(fread(buffer, 1, 1, f_ips) == 1);
/* Ensure we don't write to protected region. */
if (patch_offset < protected_size) {
@@ -169,7 +169,7 @@ namespace sts::patcher {
if (patch_offset + read_size > mapped_size) {
read_size = mapped_size - patch_offset;
}
STS_ASSERT(fread(mapped_module + patch_offset, read_size, 1, f_ips) == 1);
AMS_ASSERT(fread(mapped_module + patch_offset, read_size, 1, f_ips) == 1);
if (patch_size > read_size) {
fseek(f_ips, patch_size - read_size, SEEK_CUR);
}

View File

@@ -17,10 +17,10 @@
#include <stratosphere.hpp>
#include <stratosphere/pm.hpp>
namespace sts::pm::bm {
namespace ams::pm::bm {
/* Boot Mode API. */
/* Both functions should be weakly linked, so that they can be overridden by sts::boot2 as needed. */
/* Both functions should be weakly linked, so that they can be overridden by ams::boot2 as needed. */
BootMode WEAK GetBootMode() {
PmBootMode boot_mode = PmBootMode_Normal;
R_ASSERT(pmbmGetBootMode(&boot_mode));

View File

@@ -20,7 +20,7 @@
#include "pm_ams.h"
namespace sts::pm::dmnt {
namespace ams::pm::dmnt {
/* Debug Monitor API. */
Result StartProcess(os::ProcessId process_id) {

View File

@@ -20,7 +20,7 @@
#include "pm_ams.h"
namespace sts::pm::info {
namespace ams::pm::info {
namespace {

View File

@@ -18,7 +18,7 @@
#include <stratosphere.hpp>
#include <stratosphere/pm.hpp>
namespace sts::pm::shell {
namespace ams::pm::shell {
/* Shell API. */
Result WEAK LaunchTitle(os::ProcessId *out_process_id, const ncm::TitleLocation &loc, u32 launch_flags) {

View File

@@ -16,21 +16,21 @@
#include <stratosphere.hpp>
namespace sts::result {
namespace ams::result {
extern bool CallFatalOnResultAssertion;
}
namespace sts::result::impl {
namespace ams::result::impl {
NORETURN WEAK void OnResultAssertion(Result result) {
/* Assert that we should call fatal on result assertion. */
/* If we shouldn't fatal, this will std::abort(); */
/* If we should, we'll continue onwards. */
STS_ASSERT((sts::result::CallFatalOnResultAssertion));
AMS_ASSERT((ams::result::CallFatalOnResultAssertion));
/* TODO: sts::fatal:: */
/* TODO: ams::fatal:: */
fatalSimple(result.GetValue());
while (true) { /* ... */ }
}

View File

@@ -19,7 +19,7 @@
#include <stratosphere.hpp>
#include <stratosphere/rnd.hpp>
namespace sts::rnd {
namespace ams::rnd {
namespace {

View File

@@ -15,14 +15,14 @@
*/
#include <stratosphere.hpp>
namespace sts::sf::cmif {
namespace ams::sf::cmif {
ServerDomainManager::Domain::~Domain() {
while (!this->entries.empty()) {
Entry *entry = &this->entries.front();
{
std::scoped_lock lk(this->manager->entry_owner_lock);
STS_ASSERT(entry->owner == this);
AMS_ASSERT(entry->owner == this);
entry->owner = nullptr;
}
entry->object.Reset();
@@ -35,7 +35,7 @@ namespace sts::sf::cmif {
for (size_t i = 0; i < count; i++) {
Entry *entry = this->manager->entry_manager.AllocateEntry();
R_UNLESS(entry != nullptr, sf::cmif::ResultOutOfDomainEntries());
STS_ASSERT(entry->owner == nullptr);
AMS_ASSERT(entry->owner == nullptr);
out_ids[i] = this->manager->entry_manager.GetId(entry);
}
return ResultSuccess();
@@ -48,18 +48,18 @@ namespace sts::sf::cmif {
void ServerDomainManager::Domain::UnreserveIds(const DomainObjectId *ids, size_t count) {
for (size_t i = 0; i < count; i++) {
Entry *entry = this->manager->entry_manager.GetEntry(ids[i]);
STS_ASSERT(entry != nullptr);
STS_ASSERT(entry->owner == nullptr);
AMS_ASSERT(entry != nullptr);
AMS_ASSERT(entry->owner == nullptr);
this->manager->entry_manager.FreeEntry(entry);
}
}
void ServerDomainManager::Domain::RegisterObject(DomainObjectId id, ServiceObjectHolder &&obj) {
Entry *entry = this->manager->entry_manager.GetEntry(id);
STS_ASSERT(entry != nullptr);
AMS_ASSERT(entry != nullptr);
{
std::scoped_lock lk(this->manager->entry_owner_lock);
STS_ASSERT(entry->owner == nullptr);
AMS_ASSERT(entry->owner == nullptr);
entry->owner = this;
this->entries.push_back(*entry);
}
@@ -129,8 +129,8 @@ namespace sts::sf::cmif {
void ServerDomainManager::EntryManager::FreeEntry(Entry *entry) {
std::scoped_lock lk(this->lock);
STS_ASSERT(entry->owner == nullptr);
STS_ASSERT(!entry->object);
AMS_ASSERT(entry->owner == nullptr);
AMS_ASSERT(!entry->object);
this->free_list.push_front(*entry);
}
@@ -142,8 +142,8 @@ namespace sts::sf::cmif {
const auto id = ids[i];
Entry *entry = this->GetEntry(id);
if (id != InvalidDomainObjectId) {
STS_ASSERT(entry != nullptr);
STS_ASSERT(entry->owner == nullptr);
AMS_ASSERT(entry != nullptr);
AMS_ASSERT(entry->owner == nullptr);
this->free_list.erase(this->free_list.iterator_to(*entry));
}
}

View File

@@ -16,7 +16,7 @@
#include <functional>
#include <stratosphere.hpp>
namespace sts::sf::cmif {
namespace ams::sf::cmif {
Result DomainServiceObjectDispatchTable::ProcessMessage(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const {
return this->ProcessMessageImpl(ctx, static_cast<DomainServiceObject *>(ctx.srv_obj)->GetServerDomain(), in_raw_data);
@@ -133,7 +133,7 @@ namespace sts::sf::cmif {
/* Write out header. */
constexpr size_t out_header_size = sizeof(CmifDomainOutHeader);
const size_t impl_out_data_total_size = this->GetImplOutDataTotalSize();
STS_ASSERT(out_header_size + impl_out_data_total_size + sizeof(DomainObjectId) * this->GetOutObjectCount() <= raw_data.GetSize());
AMS_ASSERT(out_header_size + impl_out_data_total_size + sizeof(DomainObjectId) * this->GetOutObjectCount() <= raw_data.GetSize());
*reinterpret_cast<CmifDomainOutHeader *>(raw_data.GetPointer()) = CmifDomainOutHeader{ .num_out_objects = static_cast<u32>(this->GetOutObjectCount()), };
/* Set output raw data. */
@@ -151,7 +151,7 @@ namespace sts::sf::cmif {
/* Write out header. */
constexpr size_t out_header_size = sizeof(CmifDomainOutHeader);
const size_t impl_out_data_total_size = this->GetImplOutDataTotalSize();
STS_ASSERT(out_header_size + impl_out_data_total_size <= raw_data.GetSize());
AMS_ASSERT(out_header_size + impl_out_data_total_size <= raw_data.GetSize());
*reinterpret_cast<CmifDomainOutHeader *>(raw_data.GetPointer()) = CmifDomainOutHeader{ .num_out_objects = 0, };
/* Set output raw data. */

View File

@@ -15,7 +15,7 @@
*/
#include <stratosphere.hpp>
namespace sts::sf::cmif {
namespace ams::sf::cmif {
Result impl::ServiceDispatchTableBase::ProcessMessageImpl(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data, const ServiceCommandMeta *entries, const size_t entry_count) const {
/* Get versioning info. */
@@ -46,7 +46,7 @@ namespace sts::sf::cmif {
/* Forward forwardable results, otherwise ensure we can send result to user. */
R_TRY_CATCH(command_result) {
R_CATCH(sf::impl::ResultRequestContextChanged) { return R_CURRENT_RESULT; }
R_CATCH_ALL() { STS_ASSERT(out_header != nullptr); }
R_CATCH_ALL() { AMS_ASSERT(out_header != nullptr); }
} R_END_TRY_CATCH;
/* Write output header to raw data. */
@@ -89,11 +89,11 @@ namespace sts::sf::cmif {
/* Forward forwardable results, otherwise ensure we can send result to user. */
R_TRY_CATCH(command_result) {
R_CATCH(ams::mitm::ResultShouldForwardToSession) {
R_CATCH(sm::mitm::ResultShouldForwardToSession) {
return ctx.session->ForwardRequest(ctx);
}
R_CATCH(sf::impl::ResultRequestContextChanged) { return R_CURRENT_RESULT; }
R_CATCH_ALL() { STS_ASSERT(out_header != nullptr); }
R_CATCH_ALL() { AMS_ASSERT(out_header != nullptr); }
} R_END_TRY_CATCH;
/* Write output header to raw data. */

View File

@@ -16,7 +16,7 @@
#include <functional>
#include <stratosphere.hpp>
namespace sts::sf::cmif {
namespace ams::sf::cmif {
Result ServiceObjectHolder::ProcessMessage(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const {
const auto ProcessHandler = this->dispatch_meta->ProcessHandler;

View File

@@ -15,14 +15,14 @@
*/
#include <stratosphere.hpp>
namespace sts::sf::hipc {
namespace ams::sf::hipc {
namespace {
NX_INLINE Result ReceiveImpl(Handle session_handle, void *message_buf, size_t message_buf_size) {
s32 unused_index;
if (message_buf == armGetTls()) {
/* Consider: STS_ASSERT(message_buf_size == TlsMessageBufferSize); */
/* Consider: AMS_ASSERT(message_buf_size == TlsMessageBufferSize); */
return svcReplyAndReceive(&unused_index, &session_handle, 1, INVALID_HANDLE, U64_MAX);
} else {
return svcReplyAndReceiveWithUserBuffer(&unused_index, message_buf, message_buf_size, &session_handle, 1, INVALID_HANDLE, U64_MAX);
@@ -32,7 +32,7 @@ namespace sts::sf::hipc {
NX_INLINE Result ReplyImpl(Handle session_handle, void *message_buf, size_t message_buf_size) {
s32 unused_index;
if (message_buf == armGetTls()) {
/* Consider: STS_ASSERT(message_buf_size == TlsMessageBufferSize); */
/* Consider: AMS_ASSERT(message_buf_size == TlsMessageBufferSize); */
return svcReplyAndReceive(&unused_index, &session_handle, 0, session_handle, 0);
} else {
return svcReplyAndReceiveWithUserBuffer(&unused_index, message_buf, message_buf_size, &session_handle, 0, session_handle, 0);
@@ -73,7 +73,7 @@ namespace sts::sf::hipc {
R_CONVERT(svc::ResultSessionClosed, ResultSuccess())
} R_END_TRY_CATCH;
/* ReplyImpl should *always* return an error. */
STS_ASSERT(false);
AMS_ASSERT(false);
}
Result CreateSession(Handle *out_server_handle, Handle *out_client_handle) {

View File

@@ -15,7 +15,7 @@
*/
#include <stratosphere.hpp>
namespace sts::sf::hipc {
namespace ams::sf::hipc {
namespace impl {
@@ -71,7 +71,7 @@ namespace sts::sf::hipc {
if (this->is_mitm_session) {
/* If we're a mitm session, we need to convert the remote session to domain. */
STS_ASSERT(session->forward_service->own_handle);
AMS_ASSERT(session->forward_service->own_handle);
R_TRY(serviceConvertToDomain(session->forward_service.get()));
/* The object ID reservation cannot fail here, as that would cause desynchronization from target domain. */
@@ -94,8 +94,8 @@ namespace sts::sf::hipc {
})));
}
STS_ASSERT(object_id != cmif::InvalidDomainObjectId);
STS_ASSERT(static_cast<bool>(new_holder));
AMS_ASSERT(object_id != cmif::InvalidDomainObjectId);
AMS_ASSERT(static_cast<bool>(new_holder));
/* We succeeded! */
domain_guard.Cancel();

View File

@@ -15,7 +15,7 @@
*/
#include <stratosphere.hpp>
namespace sts::sf::hipc {
namespace ams::sf::hipc {
ServerManagerBase::ServerBase::~ServerBase() { /* Pure virtual destructor, to prevent linker errors. */ }
@@ -65,14 +65,14 @@ namespace sts::sf::hipc {
void ServerManagerBase::AddUserWaitableHolder(os::WaitableHolder *waitable) {
const auto user_data_tag = static_cast<UserDataTag>(waitable->GetUserData());
STS_ASSERT(user_data_tag != UserDataTag::Server);
STS_ASSERT(user_data_tag != UserDataTag::MitmServer);
STS_ASSERT(user_data_tag != UserDataTag::Session);
AMS_ASSERT(user_data_tag != UserDataTag::Server);
AMS_ASSERT(user_data_tag != UserDataTag::MitmServer);
AMS_ASSERT(user_data_tag != UserDataTag::Session);
this->RegisterToWaitList(waitable);
}
Result ServerManagerBase::ProcessForServer(os::WaitableHolder *holder) {
STS_ASSERT(static_cast<UserDataTag>(holder->GetUserData()) == UserDataTag::Server);
AMS_ASSERT(static_cast<UserDataTag>(holder->GetUserData()) == UserDataTag::Server);
ServerBase *server = static_cast<ServerBase *>(holder);
ON_SCOPE_EXIT { this->RegisterToWaitList(server); };
@@ -83,14 +83,14 @@ namespace sts::sf::hipc {
server->CreateSessionObjectHolder(&obj, &fsrv);
/* Not a mitm server, so we must have no forward service. */
STS_ASSERT(fsrv == nullptr);
AMS_ASSERT(fsrv == nullptr);
/* Try to accept. */
return this->AcceptSession(server->port_handle, std::move(obj));
}
Result ServerManagerBase::ProcessForMitmServer(os::WaitableHolder *holder) {
STS_ASSERT(static_cast<UserDataTag>(holder->GetUserData()) == UserDataTag::MitmServer);
AMS_ASSERT(static_cast<UserDataTag>(holder->GetUserData()) == UserDataTag::MitmServer);
ServerBase *server = static_cast<ServerBase *>(holder);
ON_SCOPE_EXIT { this->RegisterToWaitList(server); };
@@ -101,20 +101,20 @@ namespace sts::sf::hipc {
server->CreateSessionObjectHolder(&obj, &fsrv);
/* Mitm server, so we must have forward service. */
STS_ASSERT(fsrv != nullptr);
AMS_ASSERT(fsrv != nullptr);
/* Try to accept. */
return this->AcceptMitmSession(server->port_handle, std::move(obj), std::move(fsrv));
}
Result ServerManagerBase::ProcessForSession(os::WaitableHolder *holder) {
STS_ASSERT(static_cast<UserDataTag>(holder->GetUserData()) == UserDataTag::Session);
AMS_ASSERT(static_cast<UserDataTag>(holder->GetUserData()) == UserDataTag::Session);
ServerSession *session = static_cast<ServerSession *>(holder);
cmif::PointerAndSize tls_message(armGetTls(), hipc::TlsMessageBufferSize);
const cmif::PointerAndSize &saved_message = session->saved_message;
STS_ASSERT(tls_message.GetSize() == saved_message.GetSize());
AMS_ASSERT(tls_message.GetSize() == saved_message.GetSize());
if (!session->has_received) {
R_TRY(this->ReceiveRequest(session, tls_message));
session->has_received = true;
@@ -180,7 +180,7 @@ namespace sts::sf::hipc {
this->ProcessDeferredSessions();
return ResultSuccess();
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}

View File

@@ -15,7 +15,7 @@
*/
#include <stratosphere.hpp>
namespace sts::sf::hipc {
namespace ams::sf::hipc {
namespace {
@@ -40,10 +40,10 @@ namespace sts::sf::hipc {
}
Result ServerSession::ForwardRequest(const cmif::ServiceDispatchContext &ctx) const {
STS_ASSERT(this->IsMitmSession());
AMS_ASSERT(this->IsMitmSession());
/* TODO: Support non-TLS messages? */
STS_ASSERT(this->saved_message.GetPointer() != nullptr);
STS_ASSERT(this->saved_message.GetSize() == TlsMessageBufferSize);
AMS_ASSERT(this->saved_message.GetPointer() != nullptr);
AMS_ASSERT(this->saved_message.GetSize() == TlsMessageBufferSize);
/* Copy saved TLS in. */
std::memcpy(armGetTls(), this->saved_message.GetPointer(), this->saved_message.GetSize());
@@ -115,7 +115,7 @@ namespace sts::sf::hipc {
session_memory->pointer_buffer = this->GetSessionPointerBuffer(session_memory);
session_memory->saved_message = this->GetSessionSavedMessageBuffer(session_memory);
/* Validate session pointer buffer. */
STS_ASSERT(session_memory->pointer_buffer.GetSize() >= session_memory->forward_service->pointer_buffer_size);
AMS_ASSERT(session_memory->pointer_buffer.GetSize() >= session_memory->forward_service->pointer_buffer_size);
session_memory->pointer_buffer = cmif::PointerAndSize(session_memory->pointer_buffer.GetAddress(), session_memory->forward_service->pointer_buffer_size);
/* Register to wait list. */
this->RegisterSessionToWaitList(session_memory);
@@ -188,7 +188,7 @@ namespace sts::sf::hipc {
return ResultSuccess();
case hipc::ReceiveResult::NeedsRetry:
continue;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
}

View File

@@ -21,7 +21,7 @@
#include "sm_ams.h"
#include "sm_utils.hpp"
namespace sts::sm {
namespace ams::sm {
/* Ordinary SM API. */
Result GetService(Service *out, ServiceName name) {

View File

@@ -22,7 +22,7 @@
#include "smm_ams.h"
#include "sm_utils.hpp"
namespace sts::sm::manager {
namespace ams::sm::manager {
/* Manager API. */
Result RegisterProcess(os::ProcessId process_id, ncm::TitleId title_id, const void *acid, size_t acid_size, const void *aci, size_t aci_size) {

View File

@@ -21,7 +21,7 @@
#include "sm_ams.h"
#include "sm_utils.hpp"
namespace sts::sm::mitm {
namespace ams::sm::mitm {
/* Mitm API. */
Result InstallMitm(Handle *out_port, Handle *out_query, ServiceName name) {

View File

@@ -16,7 +16,7 @@
#include "sm_utils.hpp"
namespace sts::sm::impl {
namespace ams::sm::impl {
namespace {

View File

@@ -22,7 +22,7 @@
#include "sm_ams.h"
namespace sts::sm::impl {
namespace ams::sm::impl {
/* Utilities. */
os::RecursiveMutex &GetUserSessionMutex();

View File

@@ -18,7 +18,7 @@
#include <stratosphere.hpp>
#include <stratosphere/spl/smc/spl_smc.hpp>
namespace sts::spl::smc {
namespace ams::spl::smc {
Result SetConfig(SplConfigItem which, const u64 *value, size_t num_qwords) {
SecmonArgs args;
@@ -352,7 +352,7 @@ namespace sts::spl::smc {
}
Result AtmosphereWriteAddress(void *dst, const void *src, size_t size) {
STS_ASSERT(size <= sizeof(u64));
AMS_ASSERT(size <= sizeof(u64));
SecmonArgs args;
args.X[0] = static_cast<u64>(FunctionId::AtmosphereWriteAddress);

View File

@@ -17,7 +17,7 @@
#include <stratosphere.hpp>
#include <stratosphere/spl.hpp>
namespace sts::spl {
namespace ams::spl {
HardwareType GetHardwareType() {
u64 out_val = 0;
@@ -70,7 +70,7 @@ namespace sts::spl {
case HardwareType::Hoag:
case HardwareType::Iowa:
return true;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}

View File

@@ -22,7 +22,7 @@
#include "updater_files.hpp"
#include "updater_paths.hpp"
namespace sts::updater {
namespace ams::updater {
namespace {
@@ -72,7 +72,7 @@ namespace sts::updater {
return true;
case BootImageUpdateType::Mariko:
return false;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
@@ -82,7 +82,7 @@ namespace sts::updater {
return true;
case BootImageUpdateType::Mariko:
return false;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
@@ -92,7 +92,7 @@ namespace sts::updater {
return NcmContentMetaType_BootImagePackage;
case BootModeType::Safe:
return NcmContentMetaType_BootImagePackageSafe;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
@@ -139,7 +139,7 @@ namespace sts::updater {
Result GetBootImagePackageDataId(u64 *out_data_id, BootModeType mode, void *work_buffer, size_t work_buffer_size) {
/* Ensure we can read content metas. */
constexpr size_t MaxContentMetas = 0x40;
STS_ASSERT(work_buffer_size >= sizeof(NcmContentMetaKey) * MaxContentMetas);
AMS_ASSERT(work_buffer_size >= sizeof(NcmContentMetaKey) * MaxContentMetas);
/* Open NAND System meta database, list contents. */
NcmContentMetaDatabase meta_db;
@@ -156,7 +156,7 @@ namespace sts::updater {
return ResultBootImagePackageNotFound();
}
STS_ASSERT(total_entries == written_entries);
AMS_ASSERT(total_entries == written_entries);
/* Output is sorted, return the lowest valid exfat entry. */
if (total_entries > 1) {
@@ -182,7 +182,7 @@ namespace sts::updater {
return VerifyBootImagesNormal(data_id, work_buffer, work_buffer_size, boot_image_update_type);
case BootModeType::Safe:
return VerifyBootImagesSafe(data_id, work_buffer, work_buffer_size, boot_image_update_type);
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
@@ -303,7 +303,7 @@ namespace sts::updater {
return UpdateBootImagesNormal(data_id, work_buffer, work_buffer_size, boot_image_update_type);
case BootModeType::Safe:
return UpdateBootImagesSafe(data_id, work_buffer, work_buffer_size, boot_image_update_type);
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
@@ -340,7 +340,7 @@ namespace sts::updater {
}
/* Only preserve autorcm if on a unit with unpatched rcm bug. */
if (HasAutoRcmPreserve(boot_image_update_type) && !ams::IsRcmBugPatched()) {
if (HasAutoRcmPreserve(boot_image_update_type) && !exosphere::IsRcmBugPatched()) {
R_TRY(boot0_accessor.PreserveAutoRcm(bct, work, Boot0Partition::BctNormalSub));
R_TRY(boot0_accessor.Write(bct, BctSize, Boot0Partition::BctNormalSub));
R_TRY(boot0_accessor.PreserveAutoRcm(bct, work, Boot0Partition::BctNormalMain));
@@ -399,7 +399,7 @@ namespace sts::updater {
R_TRY(boot0_accessor.UpdateEks(bct, work));
}
/* Only preserve autorcm if on a unit with unpatched rcm bug. */
if (HasAutoRcmPreserve(boot_image_update_type) && !ams::IsRcmBugPatched()) {
if (HasAutoRcmPreserve(boot_image_update_type) && !exosphere::IsRcmBugPatched()) {
R_TRY(boot0_accessor.PreserveAutoRcm(bct, work, Boot0Partition::BctSafeSub));
R_TRY(boot0_accessor.Write(bct, BctSize, Boot0Partition::BctSafeSub));
R_TRY(boot0_accessor.PreserveAutoRcm(bct, work, Boot0Partition::BctSafeMain));
@@ -492,7 +492,7 @@ namespace sts::updater {
case spl::HardwareType::Hoag:
case spl::HardwareType::Iowa:
return BootImageUpdateType::Mariko;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}

View File

@@ -19,7 +19,7 @@
#include "updater_bis_management.hpp"
namespace sts::updater {
namespace ams::updater {
Result BisAccessor::Initialize() {
R_TRY(fsOpenBisStorage(&this->storage, this->partition_id));
@@ -35,18 +35,18 @@ namespace sts::updater {
}
Result BisAccessor::Read(void *dst, size_t size, u64 offset) {
STS_ASSERT((offset % SectorAlignment) == 0);
AMS_ASSERT((offset % SectorAlignment) == 0);
return fsStorageRead(&this->storage, offset, dst, size);
}
Result BisAccessor::Write(u64 offset, const void *src, size_t size) {
STS_ASSERT((offset % SectorAlignment) == 0);
AMS_ASSERT((offset % SectorAlignment) == 0);
return fsStorageWrite(&this->storage, offset, src, size);
}
Result BisAccessor::Write(u64 offset, size_t size, const char *bip_path, void *work_buffer, size_t work_buffer_size) {
STS_ASSERT((offset % SectorAlignment) == 0);
STS_ASSERT((work_buffer_size % SectorAlignment) == 0);
AMS_ASSERT((offset % SectorAlignment) == 0);
AMS_ASSERT((work_buffer_size % SectorAlignment) == 0);
FILE *bip_fp = fopen(bip_path, "rb");
if (bip_fp == NULL) {
@@ -63,7 +63,7 @@ namespace sts::updater {
return fsdevGetLastResult();
}
}
STS_ASSERT(written + read_size <= size);
AMS_ASSERT(written + read_size <= size);
size_t aligned_size = ((read_size + SectorAlignment - 1) / SectorAlignment) * SectorAlignment;
R_TRY(this->Write(offset + written, work_buffer, aligned_size));
@@ -77,8 +77,8 @@ namespace sts::updater {
}
Result BisAccessor::Clear(u64 offset, u64 size, void *work_buffer, size_t work_buffer_size) {
STS_ASSERT((offset % SectorAlignment) == 0);
STS_ASSERT((work_buffer_size % SectorAlignment) == 0);
AMS_ASSERT((offset % SectorAlignment) == 0);
AMS_ASSERT((work_buffer_size % SectorAlignment) == 0);
std::memset(work_buffer, 0, work_buffer_size);
@@ -92,8 +92,8 @@ namespace sts::updater {
}
Result BisAccessor::GetHash(void *dst, u64 offset, u64 size, u64 hash_size, void *work_buffer, size_t work_buffer_size) {
STS_ASSERT((offset % SectorAlignment) == 0);
STS_ASSERT((work_buffer_size % SectorAlignment) == 0);
AMS_ASSERT((offset % SectorAlignment) == 0);
AMS_ASSERT((work_buffer_size % SectorAlignment) == 0);
Sha256Context sha_ctx;
sha256ContextCreate(&sha_ctx);
@@ -113,12 +113,12 @@ namespace sts::updater {
size_t Boot0Accessor::GetBootloaderVersion(void *bct) {
u32 version = *reinterpret_cast<u32 *>(reinterpret_cast<uintptr_t>(bct) + BctVersionOffset);
STS_ASSERT(version <= BctVersionMax);
AMS_ASSERT(version <= BctVersionMax);
return static_cast<size_t>(version);
}
size_t Boot0Accessor::GetEksIndex(size_t bootloader_version) {
STS_ASSERT(bootloader_version <= BctVersionMax);
AMS_ASSERT(bootloader_version <= BctVersionMax);
return (bootloader_version > 0) ? bootloader_version - 1 : 0;
}

View File

@@ -19,7 +19,7 @@
#include <stratosphere.hpp>
#include <stratosphere/updater/updater_types.hpp>
namespace sts::updater {
namespace ams::updater {
class BisAccessor {
public:
@@ -138,13 +138,13 @@ namespace sts::updater {
}
}
STS_ASSERT(entry != nullptr);
AMS_ASSERT(entry != nullptr);
return entry;
}
public:
Result Read(size_t *out_size, void *dst, size_t size, EnumType which) {
const auto entry = FindEntry(which);
STS_ASSERT(size >= entry->size);
AMS_ASSERT(size >= entry->size);
R_TRY(BisAccessor::Read(dst, entry->size, entry->offset));
@@ -154,8 +154,8 @@ namespace sts::updater {
Result Write(const void *src, size_t size, EnumType which) {
const auto entry = FindEntry(which);
STS_ASSERT(size <= entry->size);
STS_ASSERT((size % BisAccessor::SectorAlignment) == 0);
AMS_ASSERT(size <= entry->size);
AMS_ASSERT((size % BisAccessor::SectorAlignment) == 0);
return BisAccessor::Write(entry->offset, src, size);
}
@@ -198,7 +198,7 @@ namespace sts::updater {
return FsBisStorageId_BootConfigAndPackage2RepairMain;
case Package2Type::RepairSub:
return FsBisStorageId_BootConfigAndPackage2RepairSub;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}

View File

@@ -19,7 +19,7 @@
#include "updater_bis_save.hpp"
namespace sts::updater {
namespace ams::updater {
size_t BisSave::GetVerificationFlagOffset(BootModeType mode) {
switch (mode) {
@@ -33,9 +33,9 @@ namespace sts::updater {
}
Result BisSave::Initialize(void *work_buffer, size_t work_buffer_size) {
STS_ASSERT(work_buffer_size >= SaveSize);
STS_ASSERT(util::IsAligned(reinterpret_cast<uintptr_t>(work_buffer), 0x1000));
STS_ASSERT(util::IsAligned(work_buffer_size, 0x200));
AMS_ASSERT(work_buffer_size >= SaveSize);
AMS_ASSERT(util::IsAligned(reinterpret_cast<uintptr_t>(work_buffer), 0x1000));
AMS_ASSERT(util::IsAligned(work_buffer_size, 0x200));
R_TRY(this->accessor.Initialize());
this->save_buffer = work_buffer;

View File

@@ -21,7 +21,7 @@
#include "updater_bis_management.hpp"
namespace sts::updater {
namespace ams::updater {
class BisSave {
public:

View File

@@ -19,7 +19,7 @@
#include "updater_files.hpp"
namespace sts::updater {
namespace ams::updater {
Result ReadFile(size_t *out_size, void *dst, size_t dst_size, const char *path) {
FILE *fp = fopen(path, "rb");

View File

@@ -19,7 +19,7 @@
#include <stratosphere.hpp>
#include <stratosphere/updater/updater_types.hpp>
namespace sts::updater {
namespace ams::updater {
/* File helpers. */
Result ReadFile(size_t *out_size, void *dst, size_t dst_size, const char *path);

View File

@@ -20,7 +20,7 @@
#include "updater_paths.hpp"
namespace sts::updater {
namespace ams::updater {
namespace {
@@ -34,7 +34,7 @@ namespace sts::updater {
constexpr const char *Package2PathA = "bip:/a/package2";
const char *ChooseCandidatePath(const char * const *candidates, size_t num_candidates) {
STS_ASSERT(num_candidates > 0);
AMS_ASSERT(num_candidates > 0);
for (size_t i = 0; i < num_candidates; i++) {
struct stat buf;
@@ -72,7 +72,7 @@ namespace sts::updater {
constexpr const char *candidates[] = {BctPathA, BctPathNx};
return ChooseCandidatePath(candidates, util::size(candidates));
}
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
@@ -88,7 +88,7 @@ namespace sts::updater {
constexpr const char *candidates[] = {Package1PathA, Package1PathNx};
return ChooseCandidatePath(candidates, util::size(candidates));
}
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
@@ -104,7 +104,7 @@ namespace sts::updater {
constexpr const char *candidates[] = {Package2PathA, Package2PathNx};
return ChooseCandidatePath(candidates, util::size(candidates));
}
STS_UNREACHABLE_DEFAULT_CASE();;
AMS_UNREACHABLE_DEFAULT_CASE();
}
}

View File

@@ -19,7 +19,7 @@
#include <stratosphere.hpp>
#include <stratosphere/updater/updater_types.hpp>
namespace sts::updater {
namespace ams::updater {
/* Path functionality. */
const char *GetBootImagePackageMountPath();

View File

@@ -20,13 +20,13 @@
#include "lz4.h"
namespace sts::util {
namespace ams::util {
/* Compression utilities. */
int CompressLZ4(void *dst, size_t dst_size, const void *src, size_t src_size) {
/* Size checks. */
STS_ASSERT(dst_size <= std::numeric_limits<int>::max());
STS_ASSERT(src_size <= std::numeric_limits<int>::max());
AMS_ASSERT(dst_size <= std::numeric_limits<int>::max());
AMS_ASSERT(src_size <= std::numeric_limits<int>::max());
/* This is just a thin wrapper around LZ4. */
return LZ4_compress_default(reinterpret_cast<const char *>(src), reinterpret_cast<char *>(dst), static_cast<int>(src_size), static_cast<int>(dst_size));
@@ -35,8 +35,8 @@ namespace sts::util {
/* Decompression utilities. */
int DecompressLZ4(void *dst, size_t dst_size, const void *src, size_t src_size) {
/* Size checks. */
STS_ASSERT(dst_size <= std::numeric_limits<int>::max());
STS_ASSERT(src_size <= std::numeric_limits<int>::max());
AMS_ASSERT(dst_size <= std::numeric_limits<int>::max());
AMS_ASSERT(src_size <= std::numeric_limits<int>::max());
/* This is just a thin wrapper around LZ4. */
return LZ4_decompress_safe(reinterpret_cast<const char *>(src), reinterpret_cast<char *>(dst), static_cast<int>(src_size), static_cast<int>(dst_size));

View File

@@ -20,7 +20,7 @@
#include "ini.h"
namespace sts::util::ini {
namespace ams::util::ini {
/* Ensure that types are the same for Handler vs ini_handler. */
static_assert(std::is_same<Handler, ::ini_handler>::value, "Bad ini::Handler definition!");
@@ -50,7 +50,7 @@ namespace sts::util::ini {
size_t try_read = std::min(size_t(num - 1), ctx->num_left);
size_t actually_read;
R_ASSERT(fsFileRead(ctx->f, ctx->offset, str, try_read, FsReadOption_None, &actually_read));
STS_ASSERT(actually_read == try_read);
AMS_ASSERT(actually_read == try_read);
/* Only "read" up to the first \n. */
size_t offset = actually_read;