mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
ams: revamp assertion system
This commit is contained in:
parent
9572fb2ce3
commit
40400aee1f
168 changed files with 1014 additions and 696 deletions
|
@ -22,11 +22,11 @@ namespace ams::kern {
|
|||
|
||||
}
|
||||
|
||||
#if 1
|
||||
#if 1 || defined(AMS_BUILD_FOR_AUDITING)
|
||||
#define MESOSPHERE_BUILD_FOR_AUDITING
|
||||
#endif
|
||||
|
||||
#ifdef MESOSPHERE_BUILD_FOR_AUDITING
|
||||
#if defined(MESOSPHERE_BUILD_FOR_AUDITING) || defined(AMS_BUILD_FOR_DEBUGGING)
|
||||
#define MESOSPHERE_BUILD_FOR_DEBUGGING
|
||||
#endif
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace ams {
|
|||
const u32 build_version = exosphere::GetVersion(ATMOSPHERE_RELEASE_VERSION);
|
||||
|
||||
if (runtime_version < build_version) {
|
||||
R_ASSERT(exosphere::ResultVersionMismatch());
|
||||
R_ABORT_UNLESS(exosphere::ResultVersionMismatch());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace ams::dd {
|
|||
|
||||
inline uintptr_t GetIoMapping(uintptr_t phys_addr, size_t size) {
|
||||
const uintptr_t io_mapping = QueryIoMapping(phys_addr, size);
|
||||
AMS_ASSERT(io_mapping);
|
||||
AMS_ABORT_UNLESS(io_mapping);
|
||||
return io_mapping;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace ams::fssystem {
|
|||
/* Iteration API */
|
||||
template<typename OnEnterDir, typename OnExitDir, typename OnFile>
|
||||
Result IterateDirectoryRecursively(fs::fsa::IFileSystem *fs, const char *root_path, char *work_path, size_t work_path_size, fs::DirectoryEntry *dir_ent_buf, OnEnterDir on_enter_dir, OnExitDir on_exit_dir, OnFile on_file) {
|
||||
AMS_ASSERT(work_path_size >= fs::EntryNameLengthMax + 1);
|
||||
AMS_ABORT_UNLESS(work_path_size >= fs::EntryNameLengthMax + 1);
|
||||
|
||||
/* Get size of the root path. */
|
||||
size_t root_path_len = strnlen(root_path, fs::EntryNameLengthMax + 1);
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace ams::kvdb {
|
|||
|
||||
Result Initialize(size_t size) {
|
||||
/* Check that we're not already initialized. */
|
||||
AMS_ASSERT(this->buffer == nullptr);
|
||||
AMS_ABORT_UNLESS(this->buffer == nullptr);
|
||||
|
||||
/* Allocate a buffer. */
|
||||
this->buffer = static_cast<u8 *>(std::malloc(size));
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace ams::kvdb {
|
|||
private:
|
||||
/* Utility. */
|
||||
static inline void CheckLength(size_t len) {
|
||||
AMS_ASSERT(len < N);
|
||||
AMS_ABORT_UNLESS(len < N);
|
||||
}
|
||||
public:
|
||||
/* Constructors. */
|
||||
|
@ -109,8 +109,8 @@ namespace ams::kvdb {
|
|||
/* Substring utilities. */
|
||||
void GetSubstring(char *dst, size_t dst_size, size_t offset, size_t length) const {
|
||||
/* Make sure output buffer can hold the substring. */
|
||||
AMS_ASSERT(offset + length <= GetLength());
|
||||
AMS_ASSERT(dst_size > length);
|
||||
AMS_ABORT_UNLESS(offset + length <= GetLength());
|
||||
AMS_ABORT_UNLESS(dst_size > length);
|
||||
/* Copy substring to dst. */
|
||||
std::strncpy(dst, this->buffer + offset, length);
|
||||
dst[length] = 0;
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace ams::kvdb {
|
|||
}
|
||||
private:
|
||||
void RemoveIndex(size_t i) {
|
||||
AMS_ASSERT(i < this->GetCount());
|
||||
AMS_ABORT_UNLESS(i < this->GetCount());
|
||||
std::memmove(this->keys + i, this->keys + i + 1, sizeof(*this->keys) * (this->GetCount() - (i + 1)));
|
||||
this->DecrementCount();
|
||||
}
|
||||
|
@ -71,8 +71,8 @@ namespace ams::kvdb {
|
|||
|
||||
Result Initialize(const char *path, void *buf, size_t size) {
|
||||
/* Only initialize once, and ensure we have sufficient memory. */
|
||||
AMS_ASSERT(this->keys == nullptr);
|
||||
AMS_ASSERT(size >= BufferSize);
|
||||
AMS_ABORT_UNLESS(this->keys == nullptr);
|
||||
AMS_ABORT_UNLESS(size >= BufferSize);
|
||||
|
||||
/* Setup member variables. */
|
||||
this->keys = static_cast<Key *>(buf);
|
||||
|
@ -127,23 +127,23 @@ namespace ams::kvdb {
|
|||
}
|
||||
|
||||
Key Get(size_t i) const {
|
||||
AMS_ASSERT(i < this->GetCount());
|
||||
AMS_ABORT_UNLESS(i < this->GetCount());
|
||||
return this->keys[i];
|
||||
}
|
||||
|
||||
Key Peek() const {
|
||||
AMS_ASSERT(!this->IsEmpty());
|
||||
AMS_ABORT_UNLESS(!this->IsEmpty());
|
||||
return this->Get(0);
|
||||
}
|
||||
|
||||
void Push(const Key &key) {
|
||||
AMS_ASSERT(!this->IsFull());
|
||||
AMS_ABORT_UNLESS(!this->IsFull());
|
||||
this->keys[this->GetCount()] = key;
|
||||
this->IncrementCount();
|
||||
}
|
||||
|
||||
Key Pop() {
|
||||
AMS_ASSERT(!this->IsEmpty());
|
||||
AMS_ABORT_UNLESS(!this->IsEmpty());
|
||||
this->RemoveIndex(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace ams::kvdb {
|
|||
static_assert(std::is_pod<Value>::value && !std::is_pointer<Value>::value, "Invalid FileKeyValueStore Value!");
|
||||
size_t size = 0;
|
||||
R_TRY(this->Get(&size, out_value, sizeof(Value), key));
|
||||
AMS_ASSERT(size >= sizeof(Value));
|
||||
AMS_ABORT_UNLESS(size >= sizeof(Value));
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace ams::kvdb {
|
|||
Value *GetValuePointer() {
|
||||
/* Size check. Note: Nintendo does not size check. */
|
||||
if constexpr (!std::is_same<Value, void>::value) {
|
||||
AMS_ASSERT(sizeof(Value) <= this->value_size);
|
||||
AMS_ABORT_UNLESS(sizeof(Value) <= this->value_size);
|
||||
/* Ensure we only get pod. */
|
||||
static_assert(std::is_pod<Value>::value, "KeyValueStore Values must be pod");
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ namespace ams::kvdb {
|
|||
const Value *GetValuePointer() const {
|
||||
/* Size check. Note: Nintendo does not size check. */
|
||||
if constexpr (!std::is_same<Value, void>::value) {
|
||||
AMS_ASSERT(sizeof(Value) <= this->value_size);
|
||||
AMS_ABORT_UNLESS(sizeof(Value) <= this->value_size);
|
||||
/* Ensure we only get pod. */
|
||||
static_assert(std::is_pod<Value>::value, "KeyValueStore Values must be pod");
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace ams::map {
|
|||
|
||||
~AutoCloseMap() {
|
||||
if (this->process_handle != INVALID_HANDLE && R_SUCCEEDED(this->result)) {
|
||||
R_ASSERT(svcUnmapProcessMemory(this->mapped_address, this->process_handle, this->base_address, this->size));
|
||||
R_ABORT_UNLESS(svcUnmapProcessMemory(this->mapped_address, this->process_handle, this->base_address, this->size));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ namespace ams::map {
|
|||
|
||||
~MappedCodeMemory() {
|
||||
if (this->process_handle != INVALID_HANDLE && R_SUCCEEDED(this->result) && this->size > 0) {
|
||||
R_ASSERT(svcUnmapProcessCodeMemory(this->process_handle, this->dst_address, this->src_address, this->size));
|
||||
R_ABORT_UNLESS(svcUnmapProcessCodeMemory(this->process_handle, this->dst_address, this->src_address, this->size));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace ams::os {
|
|||
|
||||
NX_INLINE os::ProcessId GetProcessId(::Handle process_handle) {
|
||||
os::ProcessId process_id;
|
||||
R_ASSERT(TryGetProcessId(&process_id, process_handle));
|
||||
R_ABORT_UNLESS(TryGetProcessId(&process_id, process_handle));
|
||||
return process_id;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace ams::os {
|
|||
}
|
||||
|
||||
void Wait(::Mutex *m) {
|
||||
R_ASSERT(condvarWait(&this->cv, m));
|
||||
R_ABORT_UNLESS(condvarWait(&this->cv, m));
|
||||
}
|
||||
|
||||
ConditionVariableStatus TimedWait(os::Mutex *m, u64 timeout) {
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace ams::os {
|
|||
ManagedHandle(Handle h) : hnd(h) { /* ... */ }
|
||||
~ManagedHandle() {
|
||||
if (this->hnd != INVALID_HANDLE) {
|
||||
R_ASSERT(svcCloseHandle(this->hnd));
|
||||
R_ABORT_UNLESS(svcCloseHandle(this->hnd));
|
||||
this->hnd = INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace ams::os {
|
|||
constexpr StaticThread() : stack_mem{}, thr{} { /* ... */ }
|
||||
|
||||
constexpr StaticThread(ThreadFunc entry, void *arg, int prio, int cpuid = -2) : StaticThread() {
|
||||
R_ASSERT(this->Initialize(entry, arg, prio, cpuid));
|
||||
R_ABORT_UNLESS(this->Initialize(entry, arg, prio, cpuid));
|
||||
}
|
||||
|
||||
Result Initialize(ThreadFunc entry, void *arg, int prio, int cpuid = -2) {
|
||||
|
@ -103,7 +103,7 @@ namespace ams::os {
|
|||
|
||||
NX_INLINE u32 GetCurrentThreadPriority() {
|
||||
u32 prio;
|
||||
R_ASSERT(svcGetThreadPriority(&prio, CUR_THREAD_HANDLE));
|
||||
R_ABORT_UNLESS(svcGetThreadPriority(&prio, CUR_THREAD_HANDLE));
|
||||
return prio;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace ams::ro {
|
|||
|
||||
ModuleType GetType() const {
|
||||
const ModuleType type = static_cast<ModuleType>(this->type);
|
||||
AMS_ASSERT(type < ModuleType::Count);
|
||||
AMS_ABORT_UNLESS(type < ModuleType::Count);
|
||||
return type;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace ams::sf::cmif {
|
|||
|
||||
inline DomainObjectId GetId(Entry *e) {
|
||||
const size_t index = e - this->entries;
|
||||
AMS_ASSERT(index < this->num_entries);
|
||||
AMS_ABORT_UNLESS(index < this->num_entries);
|
||||
return DomainObjectId{ u32(index + 1) };
|
||||
}
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ namespace ams::sf::cmif {
|
|||
ServerMessageRuntimeMetadata impl_metadata;
|
||||
public:
|
||||
DomainServiceObjectProcessor(ServerDomainBase *d, DomainObjectId *in_obj_ids, size_t num_in_objs) : domain(d), in_object_ids(in_obj_ids), num_in_objects(num_in_objs) {
|
||||
AMS_ASSERT(this->domain != nullptr);
|
||||
AMS_ASSERT(this->in_object_ids != nullptr);
|
||||
AMS_ABORT_UNLESS(this->domain != nullptr);
|
||||
AMS_ABORT_UNLESS(this->in_object_ids != nullptr);
|
||||
this->impl_processor = nullptr;
|
||||
this->out_object_ids = nullptr;
|
||||
this->impl_metadata = {};
|
||||
|
|
|
@ -83,11 +83,11 @@ namespace ams::sf::hipc {
|
|||
virtual ~Server() override {
|
||||
if (this->service_managed) {
|
||||
if constexpr (IsMitmServer) {
|
||||
R_ASSERT(sm::mitm::UninstallMitm(this->service_name));
|
||||
R_ABORT_UNLESS(sm::mitm::UninstallMitm(this->service_name));
|
||||
} else {
|
||||
R_ASSERT(sm::UnregisterService(this->service_name));
|
||||
R_ABORT_UNLESS(sm::UnregisterService(this->service_name));
|
||||
}
|
||||
R_ASSERT(svcCloseHandle(this->port_handle));
|
||||
R_ABORT_UNLESS(svcCloseHandle(this->port_handle));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ namespace ams::sf::hipc {
|
|||
|
||||
/* Get mitm forward session. */
|
||||
sm::MitmProcessInfo client_info;
|
||||
R_ASSERT(sm::mitm::AcknowledgeSession(forward_service.get(), &client_info, this->service_name));
|
||||
R_ABORT_UNLESS(sm::mitm::AcknowledgeSession(forward_service.get(), &client_info, this->service_name));
|
||||
|
||||
*out_obj = std::move(cmif::ServiceObjectHolder(std::move(MakeShared(std::shared_ptr<::Service>(forward_service), client_info))));
|
||||
*out_fsrv = std::move(forward_service);
|
||||
|
@ -149,7 +149,7 @@ namespace ams::sf::hipc {
|
|||
void RegisterServerImpl(Handle port_handle, sm::ServiceName service_name, bool managed, cmif::ServiceObjectHolder &&static_holder) {
|
||||
/* Allocate server memory. */
|
||||
auto *server = this->AllocateServer();
|
||||
AMS_ASSERT(server != nullptr);
|
||||
AMS_ABORT_UNLESS(server != nullptr);
|
||||
new (server) Server<ServiceImpl, MakeShared>(port_handle, service_name, managed, std::forward<cmif::ServiceObjectHolder>(static_holder));
|
||||
|
||||
if constexpr (!ServiceObjectTraits<ServiceImpl>::IsMitmServiceObject) {
|
||||
|
@ -273,13 +273,13 @@ namespace ams::sf::hipc {
|
|||
private:
|
||||
constexpr inline size_t GetServerIndex(const ServerBase *server) const {
|
||||
const size_t i = server - GetPointer(this->server_storages[0]);
|
||||
AMS_ASSERT(i < MaxServers);
|
||||
AMS_ABORT_UNLESS(i < MaxServers);
|
||||
return i;
|
||||
}
|
||||
|
||||
constexpr inline size_t GetSessionIndex(const ServerSession *session) const {
|
||||
const size_t i = session - GetPointer(this->session_storages[0]);
|
||||
AMS_ASSERT(i < MaxSessions);
|
||||
AMS_ABORT_UNLESS(i < MaxSessions);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ namespace ams::sf::hipc {
|
|||
virtual void FreeSession(ServerSession *session) override final {
|
||||
std::scoped_lock lk(this->resource_mutex);
|
||||
const size_t index = this->GetSessionIndex(session);
|
||||
AMS_ASSERT(this->session_allocated[index]);
|
||||
AMS_ABORT_UNLESS(this->session_allocated[index]);
|
||||
this->session_allocated[index] = false;
|
||||
}
|
||||
|
||||
|
@ -319,7 +319,7 @@ namespace ams::sf::hipc {
|
|||
virtual void DestroyServer(ServerBase *server) override final {
|
||||
std::scoped_lock lk(this->resource_mutex);
|
||||
const size_t index = this->GetServerIndex(server);
|
||||
AMS_ASSERT(this->server_allocated[index]);
|
||||
AMS_ABORT_UNLESS(this->server_allocated[index]);
|
||||
server->~ServerBase();
|
||||
this->server_allocated[index] = false;
|
||||
}
|
||||
|
@ -339,8 +339,8 @@ namespace ams::sf::hipc {
|
|||
std::scoped_lock lk(this->resource_mutex);
|
||||
DomainStorage *ptr = static_cast<DomainStorage *>(domain);
|
||||
const size_t index = ptr - this->domain_storages;
|
||||
AMS_ASSERT(index < ManagerOptions::MaxDomains);
|
||||
AMS_ASSERT(this->domain_allocated[index]);
|
||||
AMS_ABORT_UNLESS(index < ManagerOptions::MaxDomains);
|
||||
AMS_ABORT_UNLESS(this->domain_allocated[index]);
|
||||
this->domain_allocated[index] = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,14 +58,14 @@ namespace ams::sf::hipc {
|
|||
this->is_closed = false;
|
||||
this->has_received = false;
|
||||
this->forward_service = nullptr;
|
||||
AMS_ASSERT(!this->IsMitmSession());
|
||||
AMS_ABORT_UNLESS(!this->IsMitmSession());
|
||||
}
|
||||
|
||||
ServerSession(Handle h, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) : WaitableHolder(h), srv_obj_holder(std::move(obj)), session_handle(h) {
|
||||
this->is_closed = false;
|
||||
this->has_received = false;
|
||||
this->forward_service = std::move(fsrv);
|
||||
AMS_ASSERT(this->IsMitmSession());
|
||||
AMS_ABORT_UNLESS(this->IsMitmSession());
|
||||
}
|
||||
|
||||
bool IsMitmSession() const {
|
||||
|
|
|
@ -797,8 +797,8 @@ namespace ams::sf::impl {
|
|||
return;
|
||||
}
|
||||
Handle server_handle, client_handle;
|
||||
R_ASSERT(sf::hipc::CreateSession(&server_handle, &client_handle));
|
||||
R_ASSERT(manager->RegisterSession(server_handle, std::move(object)));
|
||||
R_ABORT_UNLESS(sf::hipc::CreateSession(&server_handle, &client_handle));
|
||||
R_ABORT_UNLESS(manager->RegisterSession(server_handle, std::move(object)));
|
||||
response.move_handles[Index] = client_handle;
|
||||
}
|
||||
|
||||
|
@ -1013,7 +1013,7 @@ namespace ams::sf::impl {
|
|||
/* Fake buffer. This is either InData or OutData, but serializing over buffers. */
|
||||
constexpr auto Attributes = CommandMeta::BufferAttributes[Info.buffer_index];
|
||||
if constexpr (Attributes & SfBufferAttr_In) {
|
||||
/* TODO: AMS_ASSERT()? N does not bother. */
|
||||
/* TODO: AMS_ABORT_UNLESS()? N does not bother. */
|
||||
return *reinterpret_cast<const T *>(buffers[Info.buffer_index].GetAddress());
|
||||
} else if constexpr (Attributes & SfBufferAttr_Out) {
|
||||
return T(buffers[Info.buffer_index]);
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace ams::sf {
|
|||
public:
|
||||
constexpr Out(uintptr_t p) : ptr(reinterpret_cast<T *>(p)) { /* ... */ }
|
||||
constexpr Out(T *p) : ptr(p) { /* ... */ }
|
||||
constexpr Out(const cmif::PointerAndSize &pas) : ptr(reinterpret_cast<T *>(pas.GetAddress())) { /* TODO: Is AMS_ASSERT(pas.GetSize() >= sizeof(T)); necessary? */ }
|
||||
constexpr Out(const cmif::PointerAndSize &pas) : ptr(reinterpret_cast<T *>(pas.GetAddress())) { /* TODO: Is AMS_ABORT_UNLESS(pas.GetSize() >= sizeof(T)); necessary? */ }
|
||||
|
||||
void SetValue(const T& value) const {
|
||||
*this->ptr = value;
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace ams::sm {
|
|||
}
|
||||
|
||||
Result Initialize() {
|
||||
AMS_ASSERT(!this->has_initialized);
|
||||
AMS_ABORT_UNLESS(!this->has_initialized);
|
||||
|
||||
sm::DoWithSession([&]() {
|
||||
this->result = Initializer();
|
||||
|
@ -73,7 +73,7 @@ namespace ams::sm {
|
|||
}
|
||||
|
||||
void Finalize() {
|
||||
AMS_ASSERT(this->has_initialized);
|
||||
AMS_ABORT_UNLESS(this->has_initialized);
|
||||
Finalizer();
|
||||
this->has_initialized = false;
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace ams::emummc {
|
|||
} *paths = reinterpret_cast<decltype(paths)>(&path_storage);
|
||||
|
||||
/* Retrieve paths from secure monitor. */
|
||||
AMS_ASSERT(spl::smc::AtmosphereGetEmummcConfig(&g_exo_config, paths, 0) == spl::smc::Result::Success);
|
||||
AMS_ABORT_UNLESS(spl::smc::AtmosphereGetEmummcConfig(&g_exo_config, paths, 0) == spl::smc::Result::Success);
|
||||
|
||||
const Storage storage = static_cast<Storage>(g_exo_config.base_cfg.type);
|
||||
g_is_emummc = g_exo_config.base_cfg.magic == StorageMagic && storage != Storage_Emmc;
|
||||
|
|
|
@ -37,8 +37,8 @@ namespace ams {
|
|||
extern ncm::ProgramId CurrentProgramId;
|
||||
|
||||
void WEAK_SYMBOL ExceptionHandler(FatalErrorContext *ctx) {
|
||||
R_ASSERT(amsBpcInitialize());
|
||||
R_ASSERT(amsBpcRebootToFatalError(ctx));
|
||||
R_ABORT_UNLESS(amsBpcInitialize());
|
||||
R_ABORT_UNLESS(amsBpcRebootToFatalError(ctx));
|
||||
while (1) { /* ... */ }
|
||||
}
|
||||
|
||||
|
|
|
@ -23,22 +23,22 @@ namespace ams::exosphere {
|
|||
ApiInfo GetApiInfo() {
|
||||
u64 exosphere_cfg;
|
||||
if (spl::smc::GetConfig(&exosphere_cfg, 1, SplConfigItem_ExosphereApiVersion) != spl::smc::Result::Success) {
|
||||
R_ASSERT(ResultNotPresent());
|
||||
R_ABORT_UNLESS(ResultNotPresent());
|
||||
}
|
||||
|
||||
return ApiInfo{ util::BitPack64(exosphere_cfg) };
|
||||
}
|
||||
|
||||
void ForceRebootToRcm() {
|
||||
R_ASSERT(spl::smc::ConvertResult(spl::smc::SetConfig(SplConfigItem_ExosphereNeedsReboot, 1)));
|
||||
R_ABORT_UNLESS(spl::smc::ConvertResult(spl::smc::SetConfig(SplConfigItem_ExosphereNeedsReboot, 1)));
|
||||
}
|
||||
|
||||
void ForceRebootToIramPayload() {
|
||||
R_ASSERT(spl::smc::ConvertResult(spl::smc::SetConfig(SplConfigItem_ExosphereNeedsReboot, 2)));
|
||||
R_ABORT_UNLESS(spl::smc::ConvertResult(spl::smc::SetConfig(SplConfigItem_ExosphereNeedsReboot, 2)));
|
||||
}
|
||||
|
||||
void ForceShutdown() {
|
||||
R_ASSERT(spl::smc::ConvertResult(spl::smc::SetConfig(SplConfigItem_ExosphereNeedsShutdown, 1)));
|
||||
R_ABORT_UNLESS(spl::smc::ConvertResult(spl::smc::SetConfig(SplConfigItem_ExosphereNeedsShutdown, 1)));
|
||||
}
|
||||
|
||||
void CopyToIram(uintptr_t iram_dst, const void *dram_src, size_t size) {
|
||||
|
@ -62,7 +62,7 @@ namespace ams::exosphere {
|
|||
|
||||
bool IsRcmBugPatched() {
|
||||
bool rcm_bug_patched;
|
||||
R_ASSERT(GetRcmBugPatched(&rcm_bug_patched));
|
||||
R_ABORT_UNLESS(GetRcmBugPatched(&rcm_bug_patched));
|
||||
return rcm_bug_patched;
|
||||
}
|
||||
|
||||
|
|
|
@ -140,9 +140,9 @@ namespace ams::boot2 {
|
|||
/* Launch, lightly validate result. */
|
||||
{
|
||||
const auto launch_result = pm::shell::LaunchProgram(&process_id, loc, launch_flags);
|
||||
AMS_ASSERT(!(svc::ResultOutOfResource::Includes(launch_result)));
|
||||
AMS_ASSERT(!(svc::ResultOutOfMemory::Includes(launch_result)));
|
||||
AMS_ASSERT(!(svc::ResultLimitReached::Includes(launch_result)));
|
||||
AMS_ABORT_UNLESS(!(svc::ResultOutOfResource::Includes(launch_result)));
|
||||
AMS_ABORT_UNLESS(!(svc::ResultOutOfMemory::Includes(launch_result)));
|
||||
AMS_ABORT_UNLESS(!(svc::ResultLimitReached::Includes(launch_result)));
|
||||
}
|
||||
|
||||
if (out_process_id) {
|
||||
|
@ -265,10 +265,10 @@ namespace ams::boot2 {
|
|||
}
|
||||
|
||||
/* Don't allow invalid lines. */
|
||||
AMS_ASSERT(name_len <= sizeof(sm::ServiceName));
|
||||
AMS_ABORT_UNLESS(name_len <= sizeof(sm::ServiceName));
|
||||
|
||||
/* Declare the service. */
|
||||
R_ASSERT(sm::mitm::DeclareFutureMitm(sm::ServiceName::Encode(mitm_list + offset, name_len)));
|
||||
R_ABORT_UNLESS(sm::mitm::DeclareFutureMitm(sm::ServiceName::Encode(mitm_list + offset, name_len)));
|
||||
|
||||
/* Advance to the next line. */
|
||||
offset += name_len;
|
||||
|
@ -296,7 +296,7 @@ namespace ams::boot2 {
|
|||
/* This code is normally run by PM. */
|
||||
|
||||
/* Wait until fs.mitm has installed itself. We want this to happen as early as possible. */
|
||||
R_ASSERT(sm::mitm::WaitMitm(sm::ServiceName::Encode("fsp-srv")));
|
||||
R_ABORT_UNLESS(sm::mitm::WaitMitm(sm::ServiceName::Encode("fsp-srv")));
|
||||
|
||||
/* Launch programs required to mount the SD card. */
|
||||
LaunchList(PreSdCardLaunchPrograms, NumPreSdCardLaunchPrograms);
|
||||
|
@ -305,11 +305,11 @@ namespace ams::boot2 {
|
|||
cfg::WaitSdCardRequiredServicesReady();
|
||||
|
||||
/* Wait for other atmosphere mitm modules to initialize. */
|
||||
R_ASSERT(sm::mitm::WaitMitm(sm::ServiceName::Encode("set:sys")));
|
||||
R_ABORT_UNLESS(sm::mitm::WaitMitm(sm::ServiceName::Encode("set:sys")));
|
||||
if (hos::GetVersion() >= hos::Version_200) {
|
||||
R_ASSERT(sm::mitm::WaitMitm(sm::ServiceName::Encode("bpc")));
|
||||
R_ABORT_UNLESS(sm::mitm::WaitMitm(sm::ServiceName::Encode("bpc")));
|
||||
} else {
|
||||
R_ASSERT(sm::mitm::WaitMitm(sm::ServiceName::Encode("bpc:c")));
|
||||
R_ABORT_UNLESS(sm::mitm::WaitMitm(sm::ServiceName::Encode("bpc:c")));
|
||||
}
|
||||
|
||||
/* Launch Atmosphere boot2, using NcmStorageId_None to force SD card boot. */
|
||||
|
|
|
@ -84,8 +84,6 @@ namespace ams::cfg {
|
|||
.override_any_app = true,
|
||||
};
|
||||
|
||||
bool g_loaded_override_config = false;
|
||||
|
||||
char g_hbl_sd_path[0x100] = "/atmosphere/hbl.nsp";
|
||||
|
||||
/* Helpers. */
|
||||
|
|
|
@ -35,12 +35,12 @@ namespace ams::cfg {
|
|||
os::ProcessId min = os::InvalidProcessId, max = os::InvalidProcessId;
|
||||
if (hos::GetVersion() >= hos::Version_500) {
|
||||
/* On 5.0.0+, we can get precise limits from svcGetSystemInfo. */
|
||||
R_ASSERT(svcGetSystemInfo(reinterpret_cast<u64 *>(&min), SystemInfoType_InitialProcessIdRange, INVALID_HANDLE, InitialProcessIdRangeInfo_Minimum));
|
||||
R_ASSERT(svcGetSystemInfo(reinterpret_cast<u64 *>(&max), SystemInfoType_InitialProcessIdRange, INVALID_HANDLE, InitialProcessIdRangeInfo_Maximum));
|
||||
R_ABORT_UNLESS(svcGetSystemInfo(reinterpret_cast<u64 *>(&min), SystemInfoType_InitialProcessIdRange, INVALID_HANDLE, InitialProcessIdRangeInfo_Minimum));
|
||||
R_ABORT_UNLESS(svcGetSystemInfo(reinterpret_cast<u64 *>(&max), SystemInfoType_InitialProcessIdRange, INVALID_HANDLE, InitialProcessIdRangeInfo_Maximum));
|
||||
} else if (hos::GetVersion() >= hos::Version_400) {
|
||||
/* On 4.0.0-4.1.0, we can get the precise limits from normal svcGetInfo. */
|
||||
R_ASSERT(svcGetInfo(reinterpret_cast<u64 *>(&min), InfoType_InitialProcessIdRange, INVALID_HANDLE, InitialProcessIdRangeInfo_Minimum));
|
||||
R_ASSERT(svcGetInfo(reinterpret_cast<u64 *>(&max), InfoType_InitialProcessIdRange, INVALID_HANDLE, InitialProcessIdRangeInfo_Maximum));
|
||||
R_ABORT_UNLESS(svcGetInfo(reinterpret_cast<u64 *>(&min), InfoType_InitialProcessIdRange, INVALID_HANDLE, InitialProcessIdRangeInfo_Minimum));
|
||||
R_ABORT_UNLESS(svcGetInfo(reinterpret_cast<u64 *>(&max), InfoType_InitialProcessIdRange, INVALID_HANDLE, InitialProcessIdRangeInfo_Maximum));
|
||||
} else {
|
||||
/* On < 4.0.0, we just use hardcoded extents. */
|
||||
min = InitialProcessIdMinDeprecated;
|
||||
|
|
|
@ -49,20 +49,20 @@ namespace ams::cfg {
|
|||
|
||||
void WaitSdCardServicesReadyImpl() {
|
||||
for (size_t i = 0; i < NumRequiredServicesForSdCardAccess; i++) {
|
||||
R_ASSERT(sm::WaitService(RequiredServicesForSdCardAccess[i]));
|
||||
R_ABORT_UNLESS(sm::WaitService(RequiredServicesForSdCardAccess[i]));
|
||||
}
|
||||
}
|
||||
|
||||
Result TryInitializeSdCard() {
|
||||
R_TRY(CheckSdCardServicesReady());
|
||||
R_ASSERT(fsOpenSdCardFileSystem(&g_sd_card_filesystem));
|
||||
R_ABORT_UNLESS(fsOpenSdCardFileSystem(&g_sd_card_filesystem));
|
||||
g_sd_card_initialized = true;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
void InitializeSdCard() {
|
||||
WaitSdCardServicesReadyImpl();
|
||||
R_ASSERT(fsOpenSdCardFileSystem(&g_sd_card_filesystem));
|
||||
R_ABORT_UNLESS(fsOpenSdCardFileSystem(&g_sd_card_filesystem));
|
||||
g_sd_card_initialized = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace ams::dd {
|
|||
|
||||
inline u32 ReadWriteRegisterImpl(uintptr_t phys_addr, u32 value, u32 mask) {
|
||||
u32 out_value;
|
||||
R_ASSERT(svcReadWriteRegister(&out_value, phys_addr, mask, value));
|
||||
R_ABORT_UNLESS(svcReadWriteRegister(&out_value, phys_addr, mask, value));
|
||||
return out_value;
|
||||
}
|
||||
|
||||
|
|
135
libraries/libstratosphere/source/diag/diag_assertion_impl.cpp
Normal file
135
libraries/libstratosphere/source/diag/diag_assertion_impl.cpp
Normal file
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams {
|
||||
|
||||
extern ncm::ProgramId CurrentProgramId;
|
||||
|
||||
}
|
||||
|
||||
namespace ams::diag {
|
||||
|
||||
namespace {
|
||||
|
||||
inline NORETURN void AbortWithValue(u64 debug) {
|
||||
/* Just perform a data abort. */
|
||||
register u64 addr __asm__("x27") = FatalErrorContext::StdAbortMagicAddress;
|
||||
register u64 val __asm__("x28") = FatalErrorContext::StdAbortMagicValue;
|
||||
while (true) {
|
||||
__asm__ __volatile__ (
|
||||
"mov x0, %[debug]\n"
|
||||
"str %[val], [%[addr]]\n"
|
||||
:
|
||||
: [debug]"r"(debug), [val]"r"(val), [addr]"r"(addr)
|
||||
: "x0"
|
||||
);
|
||||
}
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void DebugLog(const char *format, ...) __attribute__((format(printf, 1, 2)));
|
||||
|
||||
#ifdef AMS_ENABLE_DEBUG_PRINT
|
||||
os::Mutex g_debug_log_lock;
|
||||
char g_debug_buffer[0x400];
|
||||
|
||||
void DebugLogImpl(const char *format, ::std::va_list vl) {
|
||||
std::scoped_lock lk(g_debug_log_lock);
|
||||
|
||||
std::vsnprintf(g_debug_buffer, sizeof(g_debug_buffer), format, vl);
|
||||
|
||||
svc::OutputDebugString(g_debug_buffer, strlen(g_debug_buffer));
|
||||
}
|
||||
|
||||
void DebugLog(const char *format, ...) __attribute__((format(printf, 1, 2))) {
|
||||
::std::va_list vl;
|
||||
va_start(vl, format);
|
||||
DebugLogImpl(format, vl);
|
||||
va_end(vl);
|
||||
}
|
||||
|
||||
#else
|
||||
void DebugLog(const char *format, ...) { /* ... */ }
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
NORETURN WEAK_SYMBOL void AssertionFailureImpl(const char *file, int line, const char *func, const char *expr, u64 value, const char *format, ...) {
|
||||
DebugLog("%016lx: Assertion Failure\n", static_cast<u64>(ams::CurrentProgramId));
|
||||
DebugLog(" Location: %s:%d\n", file, line);
|
||||
DebugLog(" Function: %s\n", func);
|
||||
DebugLog(" Expression: %s\n", expr);
|
||||
DebugLog(" Value: %016lx\n", value);
|
||||
DebugLog("\n");
|
||||
#ifdef AMS_ENABLE_DEBUG_PRINT
|
||||
{
|
||||
::std::va_list vl;
|
||||
va_start(vl, format);
|
||||
DebugLogImpl(format, vl);
|
||||
va_end(vl);
|
||||
}
|
||||
#endif
|
||||
DebugLog("\n");
|
||||
|
||||
AbortWithValue(value);
|
||||
}
|
||||
|
||||
NORETURN WEAK_SYMBOL void AssertionFailureImpl(const char *file, int line, const char *func, const char *expr, u64 value) {
|
||||
DebugLog("%016lx: Assertion Failure\n", static_cast<u64>(ams::CurrentProgramId));
|
||||
DebugLog(" Location: %s:%d\n", file, line);
|
||||
DebugLog(" Function: %s\n", func);
|
||||
DebugLog(" Expression: %s\n", expr);
|
||||
DebugLog(" Value: %016lx\n", value);
|
||||
DebugLog("\n");
|
||||
DebugLog("\n");
|
||||
|
||||
AbortWithValue(value);
|
||||
}
|
||||
|
||||
NORETURN WEAK_SYMBOL void AbortImpl(const char *file, int line, const char *func, const char *expr, u64 value, const char *format, ...) {
|
||||
DebugLog("%016lx: Abort Called\n", static_cast<u64>(ams::CurrentProgramId));
|
||||
DebugLog(" Location: %s:%d\n", file, line);
|
||||
DebugLog(" Function: %s\n", func);
|
||||
DebugLog(" Expression: %s\n", expr);
|
||||
DebugLog(" Value: %016lx\n", value);
|
||||
DebugLog("\n");
|
||||
#ifdef AMS_ENABLE_DEBUG_PRINT
|
||||
{
|
||||
::std::va_list vl;
|
||||
va_start(vl, format);
|
||||
DebugLogImpl(format, vl);
|
||||
va_end(vl);
|
||||
}
|
||||
#endif
|
||||
DebugLog("\n");
|
||||
|
||||
AbortWithValue(value);
|
||||
}
|
||||
|
||||
NORETURN WEAK_SYMBOL void AbortImpl(const char *file, int line, const char *func, const char *expr, u64 value) {
|
||||
DebugLog("%016lx: Abort Called\n", static_cast<u64>(ams::CurrentProgramId));
|
||||
DebugLog(" Location: %s:%d\n", file, line);
|
||||
DebugLog(" Function: %s\n", func);
|
||||
DebugLog(" Expression: %s\n", expr);
|
||||
DebugLog(" Value: %016lx\n", value);
|
||||
DebugLog("\n");
|
||||
DebugLog("\n");
|
||||
|
||||
AbortWithValue(value);
|
||||
}
|
||||
|
||||
}
|
|
@ -71,8 +71,8 @@ namespace ams::fs {
|
|||
if (IsCurrentDirectory(&src[i])) {
|
||||
skip_next_sep = true;
|
||||
} else if (IsParentDirectory(&src[i])) {
|
||||
AMS_ASSERT(IsSeparator(out[0]));
|
||||
AMS_ASSERT(IsSeparator(out[len - 1]));
|
||||
AMS_ABORT_UNLESS(IsSeparator(out[0]));
|
||||
AMS_ABORT_UNLESS(IsSeparator(out[len - 1]));
|
||||
R_UNLESS(len != 1, fs::ResultDirectoryUnobtainable());
|
||||
|
||||
/* Walk up a directory. */
|
||||
|
@ -120,7 +120,7 @@ namespace ams::fs {
|
|||
|
||||
/* Assert normalized. */
|
||||
bool normalized = false;
|
||||
AMS_ASSERT(unc_preserved || (R_SUCCEEDED(IsNormalized(&normalized, out)) && normalized));
|
||||
AMS_ABORT_UNLESS(unc_preserved || (R_SUCCEEDED(IsNormalized(&normalized, out)) && normalized));
|
||||
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
@ -216,8 +216,8 @@ namespace ams::fs {
|
|||
}
|
||||
|
||||
bool PathTool::IsSubPath(const char *lhs, const char *rhs) {
|
||||
AMS_ASSERT(lhs != nullptr);
|
||||
AMS_ASSERT(rhs != nullptr);
|
||||
AMS_ABORT_UNLESS(lhs != nullptr);
|
||||
AMS_ABORT_UNLESS(rhs != nullptr);
|
||||
|
||||
/* Special case certain paths. */
|
||||
if (IsSeparator(lhs[0]) && !IsSeparator(lhs[1]) && IsSeparator(rhs[0]) && IsSeparator(rhs[1])) {
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace ams::fssrv::impl {
|
|||
}
|
||||
|
||||
void FileInterfaceAdapter::InvalidateCache() {
|
||||
AMS_ASSERT(this->parent_filesystem->IsDeepRetryEnabled());
|
||||
AMS_ABORT_UNLESS(this->parent_filesystem->IsDeepRetryEnabled());
|
||||
std::scoped_lock<os::ReadWriteLock> scoped_write_lock(this->parent_filesystem->GetReadWriteLockForCacheInvalidation());
|
||||
this->base_file->OperateRange(nullptr, 0, fs::OperationId::InvalidateCache, 0, std::numeric_limits<s64>::max(), nullptr, 0);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ namespace ams::fssrv::impl {
|
|||
|
||||
bool FileSystemInterfaceAdapter::IsAccessFailureDetectionObserved() const {
|
||||
/* TODO: This calls into fssrv::FileSystemProxyImpl, which we don't have yet. */
|
||||
AMS_ASSERT(false);
|
||||
AMS_ABORT_UNLESS(false);
|
||||
}
|
||||
|
||||
std::optional<std::shared_lock<os::ReadWriteLock>> FileSystemInterfaceAdapter::AcquireCacheInvalidationReadLock() {
|
||||
|
@ -238,7 +238,7 @@ namespace ams::fssrv::impl {
|
|||
std::unique_lock<fssystem::SemaphoreAdapter> open_count_semaphore;
|
||||
if (this->open_count_limited) {
|
||||
/* TODO: This calls into fssrv::FileSystemProxyImpl, which we don't have yet. */
|
||||
AMS_ASSERT(false);
|
||||
AMS_ABORT_UNLESS(false);
|
||||
}
|
||||
|
||||
PathNormalizer normalizer(path.str);
|
||||
|
@ -267,7 +267,7 @@ namespace ams::fssrv::impl {
|
|||
std::unique_lock<fssystem::SemaphoreAdapter> open_count_semaphore;
|
||||
if (this->open_count_limited) {
|
||||
/* TODO: This calls into fssrv::FileSystemProxyImpl, which we don't have yet. */
|
||||
AMS_ASSERT(false);
|
||||
AMS_ABORT_UNLESS(false);
|
||||
}
|
||||
|
||||
PathNormalizer normalizer(path.str);
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace ams::fssystem {
|
|||
{
|
||||
this->before_dir = nullptr;
|
||||
this->after_dir = nullptr;
|
||||
R_ASSERT(this->Initialize(before, after));
|
||||
R_ABORT_UNLESS(this->Initialize(before, after));
|
||||
}
|
||||
|
||||
DirectoryRedirectionFileSystem::DirectoryRedirectionFileSystem(std::unique_ptr<fs::fsa::IFileSystem> fs, const char *before, const char *after, bool unc)
|
||||
|
@ -30,7 +30,7 @@ namespace ams::fssystem {
|
|||
{
|
||||
this->before_dir = nullptr;
|
||||
this->after_dir = nullptr;
|
||||
R_ASSERT(this->Initialize(before, after));
|
||||
R_ABORT_UNLESS(this->Initialize(before, after));
|
||||
}
|
||||
|
||||
DirectoryRedirectionFileSystem::~DirectoryRedirectionFileSystem() {
|
||||
|
@ -57,7 +57,7 @@ namespace ams::fssystem {
|
|||
|
||||
/* Ensure terminating '/' */
|
||||
if (!PathTool::IsSeparator(normalized_path[normalized_path_len - 1])) {
|
||||
AMS_ASSERT(normalized_path_len + 2 <= sizeof(normalized_path));
|
||||
AMS_ABORT_UNLESS(normalized_path_len + 2 <= sizeof(normalized_path));
|
||||
normalized_path[normalized_path_len] = StringTraits::DirectorySeparator;
|
||||
normalized_path[normalized_path_len + 1] = StringTraits::NullTerminator;
|
||||
|
||||
|
@ -67,7 +67,7 @@ namespace ams::fssystem {
|
|||
/* Allocate new path. */
|
||||
const size_t size = normalized_path_len + 1;
|
||||
char *new_dir = static_cast<char *>(std::malloc(size));
|
||||
AMS_ASSERT(new_dir != nullptr);
|
||||
AMS_ABORT_UNLESS(new_dir != nullptr);
|
||||
/* TODO: custom ResultAllocationFailure? */
|
||||
|
||||
/* Copy path in. */
|
||||
|
|
|
@ -134,7 +134,7 @@ namespace ams::fssystem {
|
|||
|
||||
/* TODO: Return a result here? Nintendo does not, but they have other allocation failed results. */
|
||||
/* Consider returning ResultFsAllocationFailureInDirectorySaveDataFileSystem? */
|
||||
AMS_ASSERT(false);
|
||||
AMS_ABORT_UNLESS(false);
|
||||
}
|
||||
|
||||
Result DirectorySaveDataFileSystem::SynchronizeDirectory(const char *dst, const char *src) {
|
||||
|
@ -173,7 +173,7 @@ namespace ams::fssystem {
|
|||
this->open_writable_files--;
|
||||
|
||||
/* Nintendo does not check this, but I think it's sensible to do so. */
|
||||
AMS_ASSERT(this->open_writable_files >= 0);
|
||||
AMS_ABORT_UNLESS(this->open_writable_files >= 0);
|
||||
}
|
||||
|
||||
Result DirectorySaveDataFileSystem::CopySaveFromFileSystem(fs::fsa::IFileSystem *save_fs) {
|
||||
|
|
|
@ -21,14 +21,14 @@ namespace ams::fssystem {
|
|||
: PathResolutionFileSystem(fs, unc)
|
||||
{
|
||||
this->base_path = nullptr;
|
||||
R_ASSERT(this->Initialize(bp));
|
||||
R_ABORT_UNLESS(this->Initialize(bp));
|
||||
}
|
||||
|
||||
SubDirectoryFileSystem::SubDirectoryFileSystem(std::unique_ptr<fs::fsa::IFileSystem> fs, const char *bp, bool unc)
|
||||
: PathResolutionFileSystem(std::move(fs), unc)
|
||||
{
|
||||
this->base_path = nullptr;
|
||||
R_ASSERT(this->Initialize(bp));
|
||||
R_ABORT_UNLESS(this->Initialize(bp));
|
||||
}
|
||||
|
||||
SubDirectoryFileSystem::~SubDirectoryFileSystem() {
|
||||
|
@ -48,7 +48,7 @@ namespace ams::fssystem {
|
|||
|
||||
/* Ensure terminating '/' */
|
||||
if (!PathTool::IsSeparator(normalized_path[normalized_path_len - 1])) {
|
||||
AMS_ASSERT(normalized_path_len + 2 <= sizeof(normalized_path));
|
||||
AMS_ABORT_UNLESS(normalized_path_len + 2 <= sizeof(normalized_path));
|
||||
normalized_path[normalized_path_len] = StringTraits::DirectorySeparator;
|
||||
normalized_path[normalized_path_len + 1] = StringTraits::NullTerminator;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace ams::fssystem {
|
|||
char dst_path[fs::EntryNameLengthMax + 1];
|
||||
const size_t original_size = static_cast<size_t>(std::snprintf(dst_path, sizeof(dst_path), "%s%s", dst_parent_path, entry->name));
|
||||
/* TODO: Error code? N aborts here. */
|
||||
AMS_ASSERT(original_size < sizeof(dst_path));
|
||||
AMS_ABORT_UNLESS(original_size < sizeof(dst_path));
|
||||
|
||||
R_TRY(dst_fs->CreateFile(dst_path, entry->file_size));
|
||||
R_TRY(dst_fs->OpenFile(&dst_file, dst_path, fs::OpenMode_Write));
|
||||
|
@ -64,7 +64,7 @@ namespace ams::fssystem {
|
|||
Result CopyDirectoryRecursively(fs::fsa::IFileSystem *dst_fs, fs::fsa::IFileSystem *src_fs, const char *dst_path, const char *src_path, void *work_buf, size_t work_buf_size) {
|
||||
char dst_path_buf[fs::EntryNameLengthMax + 1];
|
||||
const size_t original_size = static_cast<size_t>(std::snprintf(dst_path_buf, sizeof(dst_path_buf), "%s", dst_path));
|
||||
AMS_ASSERT(original_size < sizeof(dst_path_buf));
|
||||
AMS_ABORT_UNLESS(original_size < sizeof(dst_path_buf));
|
||||
|
||||
return IterateDirectoryRecursively(src_fs, src_path,
|
||||
[&](const char *path, const fs::DirectoryEntry &entry) -> Result { /* On Enter Directory */
|
||||
|
|
|
@ -25,10 +25,10 @@ namespace ams::hid {
|
|||
|
||||
/* Helper. */
|
||||
void InitializeHid() {
|
||||
R_ASSERT(smInitialize());
|
||||
R_ABORT_UNLESS(smInitialize());
|
||||
ON_SCOPE_EXIT { smExit(); };
|
||||
{
|
||||
R_ASSERT(hidInitialize());
|
||||
R_ABORT_UNLESS(hidInitialize());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace ams::kvdb {
|
|||
|
||||
Result ArchiveReader::ReadEntryCount(size_t *out) {
|
||||
/* This should only be called at the start of reading stream. */
|
||||
AMS_ASSERT(this->offset == 0);
|
||||
AMS_ABORT_UNLESS(this->offset == 0);
|
||||
|
||||
/* Read and validate header. */
|
||||
ArchiveHeader header;
|
||||
|
@ -97,7 +97,7 @@ namespace ams::kvdb {
|
|||
|
||||
Result ArchiveReader::GetEntrySize(size_t *out_key_size, size_t *out_value_size) {
|
||||
/* This should only be called after ReadEntryCount. */
|
||||
AMS_ASSERT(this->offset != 0);
|
||||
AMS_ABORT_UNLESS(this->offset != 0);
|
||||
|
||||
/* Peek the next entry header. */
|
||||
ArchiveEntryHeader header;
|
||||
|
@ -111,7 +111,7 @@ namespace ams::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. */
|
||||
AMS_ASSERT(this->offset != 0);
|
||||
AMS_ABORT_UNLESS(this->offset != 0);
|
||||
|
||||
/* Read the next entry header. */
|
||||
ArchiveEntryHeader header;
|
||||
|
@ -119,11 +119,11 @@ namespace ams::kvdb {
|
|||
R_TRY(header.Validate());
|
||||
|
||||
/* Key size and Value size must be correct. */
|
||||
AMS_ASSERT(key_size == header.key_size);
|
||||
AMS_ASSERT(value_size == header.value_size);
|
||||
AMS_ABORT_UNLESS(key_size == header.key_size);
|
||||
AMS_ABORT_UNLESS(value_size == header.value_size);
|
||||
|
||||
R_ASSERT(this->Read(out_key, key_size));
|
||||
R_ASSERT(this->Read(out_value, value_size));
|
||||
R_ABORT_UNLESS(this->Read(out_key, key_size));
|
||||
R_ABORT_UNLESS(this->Read(out_value, value_size));
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
|
@ -140,20 +140,20 @@ namespace ams::kvdb {
|
|||
|
||||
void ArchiveWriter::WriteHeader(size_t entry_count) {
|
||||
/* This should only be called at start of write. */
|
||||
AMS_ASSERT(this->offset == 0);
|
||||
AMS_ABORT_UNLESS(this->offset == 0);
|
||||
|
||||
ArchiveHeader header = ArchiveHeader::Make(entry_count);
|
||||
R_ASSERT(this->Write(&header, sizeof(header)));
|
||||
R_ABORT_UNLESS(this->Write(&header, sizeof(header)));
|
||||
}
|
||||
|
||||
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. */
|
||||
AMS_ASSERT(this->offset != 0);
|
||||
AMS_ABORT_UNLESS(this->offset != 0);
|
||||
|
||||
ArchiveEntryHeader header = ArchiveEntryHeader::Make(key_size, value_size);
|
||||
R_ASSERT(this->Write(&header, sizeof(header)));
|
||||
R_ASSERT(this->Write(key, key_size));
|
||||
R_ASSERT(this->Write(value, value_size));
|
||||
R_ABORT_UNLESS(this->Write(&header, sizeof(header)));
|
||||
R_ABORT_UNLESS(this->Write(key, key_size));
|
||||
R_ABORT_UNLESS(this->Write(value, value_size));
|
||||
}
|
||||
|
||||
/* Size helper functionality. */
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace ams::kvdb {
|
|||
this->backing_buffer_free_offset = 0;
|
||||
this->count = 0;
|
||||
this->entries = static_cast<decltype(this->entries)>(this->Allocate(sizeof(*this->entries) * this->capacity));
|
||||
AMS_ASSERT(this->entries != nullptr);
|
||||
AMS_ABORT_UNLESS(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) {
|
||||
|
@ -100,7 +100,7 @@ namespace ams::kvdb {
|
|||
}
|
||||
|
||||
/* Ensure key size is small enough. */
|
||||
AMS_ASSERT(key_size <= MaxKeySize);
|
||||
AMS_ABORT_UNLESS(key_size <= MaxKeySize);
|
||||
|
||||
/* If we're at capacity, invalidate the cache. */
|
||||
if (this->count == this->capacity) {
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace ams::map {
|
|||
R_UNLESS(cur_base != address_space.alias_end, svc::ResultOutOfMemory());
|
||||
cur_base = address_space.alias_end;
|
||||
} else {
|
||||
R_ASSERT(svcQueryMemory(&mem_info, &page_info, cur_base));
|
||||
R_ABORT_UNLESS(svcQueryMemory(&mem_info, &page_info, cur_base));
|
||||
if (mem_info.type == 0 && mem_info.addr - cur_base + mem_info.size >= size) {
|
||||
*out_address = cur_base;
|
||||
return ResultSuccess();
|
||||
|
@ -205,9 +205,9 @@ namespace ams::map {
|
|||
|
||||
/* Nintendo doesn't validate SVC return values at all. */
|
||||
/* TODO: Should we allow these to fail? */
|
||||
R_ASSERT(svcQueryProcessMemory(&mem_info, &page_info, process_handle, address - 1));
|
||||
R_ABORT_UNLESS(svcQueryProcessMemory(&mem_info, &page_info, process_handle, address - 1));
|
||||
if (mem_info.type == MemType_Unmapped && address - GuardRegionSize >= mem_info.addr) {
|
||||
R_ASSERT(svcQueryProcessMemory(&mem_info, &page_info, process_handle, address + size));
|
||||
R_ABORT_UNLESS(svcQueryProcessMemory(&mem_info, &page_info, process_handle, address + size));
|
||||
return mem_info.type == MemType_Unmapped && address + size + GuardRegionSize <= mem_info.addr + mem_info.size;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
InterProcessEvent::InterProcessEvent(bool autoclear) : is_initialized(false) {
|
||||
R_ASSERT(this->Initialize(autoclear));
|
||||
R_ABORT_UNLESS(this->Initialize(autoclear));
|
||||
}
|
||||
|
||||
InterProcessEvent::~InterProcessEvent() {
|
||||
|
@ -39,7 +39,7 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
Result InterProcessEvent::Initialize(bool autoclear) {
|
||||
AMS_ASSERT(!this->is_initialized);
|
||||
AMS_ABORT_UNLESS(!this->is_initialized);
|
||||
Handle rh, wh;
|
||||
R_TRY(CreateEventHandles(&rh, &wh));
|
||||
this->Initialize(rh, true, wh, true, autoclear);
|
||||
|
@ -47,8 +47,8 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
void InterProcessEvent::Initialize(Handle read_handle, bool manage_read_handle, Handle write_handle, bool manage_write_handle, bool autoclear) {
|
||||
AMS_ASSERT(!this->is_initialized);
|
||||
AMS_ASSERT(read_handle != INVALID_HANDLE || write_handle != INVALID_HANDLE);
|
||||
AMS_ABORT_UNLESS(!this->is_initialized);
|
||||
AMS_ABORT_UNLESS(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;
|
||||
|
@ -58,40 +58,40 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
Handle InterProcessEvent::DetachReadableHandle() {
|
||||
AMS_ASSERT(this->is_initialized);
|
||||
AMS_ABORT_UNLESS(this->is_initialized);
|
||||
const Handle handle = this->read_handle;
|
||||
AMS_ASSERT(handle != INVALID_HANDLE);
|
||||
AMS_ABORT_UNLESS(handle != INVALID_HANDLE);
|
||||
this->read_handle = INVALID_HANDLE;
|
||||
this->manage_read_handle = false;
|
||||
return handle;
|
||||
}
|
||||
|
||||
Handle InterProcessEvent::DetachWritableHandle() {
|
||||
AMS_ASSERT(this->is_initialized);
|
||||
AMS_ABORT_UNLESS(this->is_initialized);
|
||||
const Handle handle = this->write_handle;
|
||||
AMS_ASSERT(handle != INVALID_HANDLE);
|
||||
AMS_ABORT_UNLESS(handle != INVALID_HANDLE);
|
||||
this->write_handle = INVALID_HANDLE;
|
||||
this->manage_write_handle = false;
|
||||
return handle;
|
||||
}
|
||||
|
||||
Handle InterProcessEvent::GetReadableHandle() const {
|
||||
AMS_ASSERT(this->is_initialized);
|
||||
AMS_ABORT_UNLESS(this->is_initialized);
|
||||
return this->read_handle;
|
||||
}
|
||||
|
||||
Handle InterProcessEvent::GetWritableHandle() const {
|
||||
AMS_ASSERT(this->is_initialized);
|
||||
AMS_ABORT_UNLESS(this->is_initialized);
|
||||
return this->write_handle;
|
||||
}
|
||||
|
||||
void InterProcessEvent::Finalize() {
|
||||
if (this->is_initialized) {
|
||||
if (this->manage_read_handle && this->read_handle != INVALID_HANDLE) {
|
||||
R_ASSERT(svcCloseHandle(this->read_handle));
|
||||
R_ABORT_UNLESS(svcCloseHandle(this->read_handle));
|
||||
}
|
||||
if (this->manage_write_handle && this->write_handle != INVALID_HANDLE) {
|
||||
R_ASSERT(svcCloseHandle(this->write_handle));
|
||||
R_ABORT_UNLESS(svcCloseHandle(this->write_handle));
|
||||
}
|
||||
}
|
||||
this->read_handle = INVALID_HANDLE;
|
||||
|
@ -102,7 +102,7 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
void InterProcessEvent::Signal() {
|
||||
R_ASSERT(svcSignalEvent(this->GetWritableHandle()));
|
||||
R_ABORT_UNLESS(svcSignalEvent(this->GetWritableHandle()));
|
||||
}
|
||||
|
||||
void InterProcessEvent::Reset() {
|
||||
|
@ -110,7 +110,7 @@ namespace ams::os::impl {
|
|||
if (handle == INVALID_HANDLE) {
|
||||
handle = this->GetWritableHandle();
|
||||
}
|
||||
R_ASSERT(svcClearEvent(handle));
|
||||
R_ABORT_UNLESS(svcClearEvent(handle));
|
||||
}
|
||||
|
||||
void InterProcessEvent::Wait() {
|
||||
|
|
|
@ -25,8 +25,8 @@ namespace ams::os::impl {
|
|||
/* Nintendo does not check the result of these invocations, but we will for safety. */
|
||||
/* Nintendo uses entropy values 0, 1 to seed the public TinyMT random, and values */
|
||||
/* 2, 3 to seed os::detail::RngManager's private TinyMT random. */
|
||||
R_ASSERT(svcGetInfo(reinterpret_cast<u64 *>(&seed[0]), InfoType_RandomEntropy, INVALID_HANDLE, 0));
|
||||
R_ASSERT(svcGetInfo(reinterpret_cast<u64 *>(&seed[2]), InfoType_RandomEntropy, INVALID_HANDLE, 1));
|
||||
R_ABORT_UNLESS(svcGetInfo(reinterpret_cast<u64 *>(&seed[0]), InfoType_RandomEntropy, INVALID_HANDLE, 0));
|
||||
R_ABORT_UNLESS(svcGetInfo(reinterpret_cast<u64 *>(&seed[2]), InfoType_RandomEntropy, INVALID_HANDLE, 1));
|
||||
|
||||
mt->Initialize(seed, util::size(seed));
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
virtual Handle GetHandle() const override {
|
||||
AMS_ASSERT(this->event->is_initialized);
|
||||
AMS_ABORT_UNLESS(this->event->is_initialized);
|
||||
return this->event->GetReadableHandle();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
virtual Handle GetHandle() const override {
|
||||
AMS_ASSERT(this->event->is_initialized);
|
||||
AMS_ABORT_UNLESS(this->event->is_initialized);
|
||||
return this->event->handle.Get();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace ams::os::impl{
|
|||
index = WaitTimedOut;
|
||||
} else {
|
||||
index = this->WaitSynchronization(object_handles, count, min_timeout);
|
||||
AMS_ASSERT(index != WaitInvalid);
|
||||
AMS_ABORT_UNLESS(index != WaitInvalid);
|
||||
}
|
||||
|
||||
switch (index) {
|
||||
|
@ -115,7 +115,7 @@ namespace ams::os::impl{
|
|||
|
||||
for (WaitableHolderBase &holder_base : this->waitable_list) {
|
||||
if (Handle handle = holder_base.GetHandle(); handle != INVALID_HANDLE) {
|
||||
AMS_ASSERT(count < MaximumHandleCount);
|
||||
AMS_ABORT_UNLESS(count < MaximumHandleCount);
|
||||
|
||||
out_handles[count] = handle;
|
||||
out_objects[count] = &holder_base;
|
||||
|
@ -170,7 +170,7 @@ namespace ams::os::impl{
|
|||
|
||||
if (this->signaled_holder == nullptr) {
|
||||
this->signaled_holder = holder_base;
|
||||
R_ASSERT(svcCancelSynchronization(this->waiting_thread_handle));
|
||||
R_ABORT_UNLESS(svcCancelSynchronization(this->waiting_thread_handle));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
namespace ams::os {
|
||||
|
||||
Result InterruptEvent::Initialize(u32 interrupt_id, bool autoclear) {
|
||||
AMS_ASSERT(!this->is_initialized);
|
||||
AMS_ABORT_UNLESS(!this->is_initialized);
|
||||
this->auto_clear = autoclear;
|
||||
|
||||
const auto type = this->auto_clear ? svc::InterruptType_Edge : svc::InterruptType_Level;
|
||||
|
@ -29,23 +29,23 @@ namespace ams::os {
|
|||
}
|
||||
|
||||
void InterruptEvent::Finalize() {
|
||||
AMS_ASSERT(this->is_initialized);
|
||||
R_ASSERT(svcCloseHandle(this->handle.Move()));
|
||||
AMS_ABORT_UNLESS(this->is_initialized);
|
||||
R_ABORT_UNLESS(svcCloseHandle(this->handle.Move()));
|
||||
this->auto_clear = true;
|
||||
this->is_initialized = false;
|
||||
}
|
||||
|
||||
InterruptEvent::InterruptEvent(u32 interrupt_id, bool autoclear) {
|
||||
this->is_initialized = false;
|
||||
R_ASSERT(this->Initialize(interrupt_id, autoclear));
|
||||
R_ABORT_UNLESS(this->Initialize(interrupt_id, autoclear));
|
||||
}
|
||||
|
||||
void InterruptEvent::Reset() {
|
||||
R_ASSERT(svcClearEvent(this->handle.Get()));
|
||||
R_ABORT_UNLESS(svcClearEvent(this->handle.Get()));
|
||||
}
|
||||
|
||||
void InterruptEvent::Wait() {
|
||||
AMS_ASSERT(this->is_initialized);
|
||||
AMS_ABORT_UNLESS(this->is_initialized);
|
||||
|
||||
while (true) {
|
||||
/* Continuously wait, until success. */
|
||||
|
@ -65,7 +65,7 @@ namespace ams::os {
|
|||
}
|
||||
|
||||
bool InterruptEvent::TryWait() {
|
||||
AMS_ASSERT(this->is_initialized);
|
||||
AMS_ABORT_UNLESS(this->is_initialized);
|
||||
|
||||
if (this->auto_clear) {
|
||||
/* Auto-clear. Just try to reset. */
|
||||
|
@ -86,7 +86,7 @@ namespace ams::os {
|
|||
}
|
||||
|
||||
bool InterruptEvent::TimedWait(u64 ns) {
|
||||
AMS_ASSERT(this->is_initialized);
|
||||
AMS_ABORT_UNLESS(this->is_initialized);
|
||||
|
||||
TimeoutHelper timeout_helper(ns);
|
||||
while (true) {
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace ams::os {
|
|||
|
||||
void MessageQueue::SendInternal(uintptr_t data) {
|
||||
/* Ensure we don't corrupt the queue, but this should never happen. */
|
||||
AMS_ASSERT(this->count < this->capacity);
|
||||
AMS_ABORT_UNLESS(this->count < this->capacity);
|
||||
|
||||
/* Write data to tail of queue. */
|
||||
this->buffer[(this->count++ + this->offset) % this->capacity] = data;
|
||||
|
@ -37,7 +37,7 @@ namespace ams::os {
|
|||
|
||||
void MessageQueue::SendNextInternal(uintptr_t data) {
|
||||
/* Ensure we don't corrupt the queue, but this should never happen. */
|
||||
AMS_ASSERT(this->count < this->capacity);
|
||||
AMS_ABORT_UNLESS(this->count < this->capacity);
|
||||
|
||||
/* Write data to head of queue. */
|
||||
this->offset = (this->offset + this->capacity - 1) % this->capacity;
|
||||
|
@ -47,7 +47,7 @@ namespace ams::os {
|
|||
|
||||
uintptr_t MessageQueue::ReceiveInternal() {
|
||||
/* Ensure we don't corrupt the queue, but this should never happen. */
|
||||
AMS_ASSERT(this->count > 0);
|
||||
AMS_ABORT_UNLESS(this->count > 0);
|
||||
|
||||
uintptr_t data = this->buffer[this->offset];
|
||||
this->offset = (this->offset + 1) % this->capacity;
|
||||
|
@ -57,7 +57,7 @@ namespace ams::os {
|
|||
|
||||
inline uintptr_t MessageQueue::PeekInternal() {
|
||||
/* Ensure we don't corrupt the queue, but this should never happen. */
|
||||
AMS_ASSERT(this->count > 0);
|
||||
AMS_ABORT_UNLESS(this->count > 0);
|
||||
|
||||
return this->buffer[this->offset];
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace ams::os {
|
|||
void Semaphore::Release() {
|
||||
std::scoped_lock lk(this->mutex);
|
||||
|
||||
AMS_ASSERT(this->count + 1 <= this->max_count);
|
||||
AMS_ABORT_UNLESS(this->count + 1 <= this->max_count);
|
||||
this->count++;
|
||||
|
||||
this->condvar.Signal();
|
||||
|
@ -75,7 +75,7 @@ namespace ams::os {
|
|||
void Semaphore::Release(int count) {
|
||||
std::scoped_lock lk(this->mutex);
|
||||
|
||||
AMS_ASSERT(this->count + count <= this->max_count);
|
||||
AMS_ABORT_UNLESS(this->count + count <= this->max_count);
|
||||
this->count += count;
|
||||
|
||||
this->condvar.Broadcast();
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace ams::os {
|
|||
|
||||
SystemEvent::SystemEvent(bool inter_process, bool autoclear) : state(SystemEventState::Uninitialized) {
|
||||
if (inter_process) {
|
||||
R_ASSERT(this->InitializeAsInterProcessEvent(autoclear));
|
||||
R_ABORT_UNLESS(this->InitializeAsInterProcessEvent(autoclear));
|
||||
} else {
|
||||
R_ASSERT(this->InitializeAsEvent(autoclear));
|
||||
R_ABORT_UNLESS(this->InitializeAsEvent(autoclear));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,34 +35,34 @@ namespace ams::os {
|
|||
}
|
||||
|
||||
Event &SystemEvent::GetEvent() {
|
||||
AMS_ASSERT(this->state == SystemEventState::Event);
|
||||
AMS_ABORT_UNLESS(this->state == SystemEventState::Event);
|
||||
return GetReference(this->storage_for_event);
|
||||
}
|
||||
|
||||
const Event &SystemEvent::GetEvent() const {
|
||||
AMS_ASSERT(this->state == SystemEventState::Event);
|
||||
AMS_ABORT_UNLESS(this->state == SystemEventState::Event);
|
||||
return GetReference(this->storage_for_event);
|
||||
}
|
||||
|
||||
impl::InterProcessEvent &SystemEvent::GetInterProcessEvent() {
|
||||
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
|
||||
AMS_ABORT_UNLESS(this->state == SystemEventState::InterProcessEvent);
|
||||
return GetReference(this->storage_for_inter_process_event);
|
||||
}
|
||||
|
||||
const impl::InterProcessEvent &SystemEvent::GetInterProcessEvent() const {
|
||||
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
|
||||
AMS_ABORT_UNLESS(this->state == SystemEventState::InterProcessEvent);
|
||||
return GetReference(this->storage_for_inter_process_event);
|
||||
}
|
||||
|
||||
Result SystemEvent::InitializeAsEvent(bool autoclear) {
|
||||
AMS_ASSERT(this->state == SystemEventState::Uninitialized);
|
||||
AMS_ABORT_UNLESS(this->state == SystemEventState::Uninitialized);
|
||||
new (GetPointer(this->storage_for_event)) Event(autoclear);
|
||||
this->state = SystemEventState::Event;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result SystemEvent::InitializeAsInterProcessEvent(bool autoclear) {
|
||||
AMS_ASSERT(this->state == SystemEventState::Uninitialized);
|
||||
AMS_ABORT_UNLESS(this->state == SystemEventState::Uninitialized);
|
||||
new (GetPointer(this->storage_for_inter_process_event)) impl::InterProcessEvent();
|
||||
this->state = SystemEventState::InterProcessEvent;
|
||||
|
||||
|
@ -77,7 +77,7 @@ namespace ams::os {
|
|||
}
|
||||
|
||||
void SystemEvent::AttachHandles(Handle read_handle, bool manage_read_handle, Handle write_handle, bool manage_write_handle, bool autoclear) {
|
||||
AMS_ASSERT(this->state == SystemEventState::Uninitialized);
|
||||
AMS_ABORT_UNLESS(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 ams::os {
|
|||
}
|
||||
|
||||
Handle SystemEvent::DetachReadableHandle() {
|
||||
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
|
||||
AMS_ABORT_UNLESS(this->state == SystemEventState::InterProcessEvent);
|
||||
return this->GetInterProcessEvent().DetachReadableHandle();
|
||||
}
|
||||
|
||||
Handle SystemEvent::DetachWritableHandle() {
|
||||
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
|
||||
AMS_ABORT_UNLESS(this->state == SystemEventState::InterProcessEvent);
|
||||
return this->GetInterProcessEvent().DetachWritableHandle();
|
||||
}
|
||||
|
||||
Handle SystemEvent::GetReadableHandle() const {
|
||||
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
|
||||
AMS_ABORT_UNLESS(this->state == SystemEventState::InterProcessEvent);
|
||||
return this->GetInterProcessEvent().GetReadableHandle();
|
||||
}
|
||||
|
||||
Handle SystemEvent::GetWritableHandle() const {
|
||||
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
|
||||
AMS_ABORT_UNLESS(this->state == SystemEventState::InterProcessEvent);
|
||||
return this->GetInterProcessEvent().GetWritableHandle();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace ams::os {
|
|||
|
||||
WaitableHolder::WaitableHolder(Handle handle) {
|
||||
/* Don't allow invalid handles. */
|
||||
AMS_ASSERT(handle != INVALID_HANDLE);
|
||||
AMS_ABORT_UNLESS(handle != INVALID_HANDLE);
|
||||
|
||||
/* Initialize appropriate holder. */
|
||||
new (GetPointer(this->impl_storage)) impl::WaitableHolderOfHandle(handle);
|
||||
|
@ -98,7 +98,7 @@ namespace ams::os {
|
|||
auto holder_base = reinterpret_cast<impl::WaitableHolderBase *>(GetPointer(this->impl_storage));
|
||||
|
||||
/* Don't allow destruction of a linked waitable holder. */
|
||||
AMS_ASSERT(!holder_base->IsLinkedToManager());
|
||||
AMS_ABORT_UNLESS(!holder_base->IsLinkedToManager());
|
||||
|
||||
holder_base->~WaitableHolderBase();
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ namespace ams::os {
|
|||
auto holder_base = reinterpret_cast<impl::WaitableHolderBase *>(GetPointer(this->impl_storage));
|
||||
|
||||
/* Don't allow unlinking of an unlinked holder. */
|
||||
AMS_ASSERT(holder_base->IsLinkedToManager());
|
||||
AMS_ABORT_UNLESS(holder_base->IsLinkedToManager());
|
||||
|
||||
holder_base->GetManager()->UnlinkWaitableHolder(*holder_base);
|
||||
holder_base->SetManager(nullptr);
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace ams::os {
|
|||
auto &impl = GetReference(this->impl_storage);
|
||||
|
||||
/* Don't allow destruction of a non-empty waitable holder. */
|
||||
AMS_ASSERT(impl.IsEmpty());
|
||||
AMS_ABORT_UNLESS(impl.IsEmpty());
|
||||
|
||||
impl.~WaitableManagerImpl();
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ namespace ams::os {
|
|||
auto &impl = GetReference(this->impl_storage);
|
||||
|
||||
/* Don't allow waiting on empty list. */
|
||||
AMS_ASSERT(!impl.IsEmpty());
|
||||
AMS_ABORT_UNLESS(!impl.IsEmpty());
|
||||
|
||||
return reinterpret_cast<WaitableHolder *>(impl.WaitAny());
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ namespace ams::os {
|
|||
auto &impl = GetReference(this->impl_storage);
|
||||
|
||||
/* Don't allow waiting on empty list. */
|
||||
AMS_ASSERT(!impl.IsEmpty());
|
||||
AMS_ABORT_UNLESS(!impl.IsEmpty());
|
||||
|
||||
return reinterpret_cast<WaitableHolder *>(impl.TryWaitAny());
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ namespace ams::os {
|
|||
auto &impl = GetReference(this->impl_storage);
|
||||
|
||||
/* Don't allow waiting on empty list. */
|
||||
AMS_ASSERT(!impl.IsEmpty());
|
||||
AMS_ABORT_UNLESS(!impl.IsEmpty());
|
||||
|
||||
return reinterpret_cast<WaitableHolder *>(impl.TimedWaitAny(timeout));
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ namespace ams::os {
|
|||
auto holder_base = reinterpret_cast<impl::WaitableHolderBase *>(GetPointer(holder->impl_storage));
|
||||
|
||||
/* Don't allow double-linking a holder. */
|
||||
AMS_ASSERT(!holder_base->IsLinkedToManager());
|
||||
AMS_ABORT_UNLESS(!holder_base->IsLinkedToManager());
|
||||
|
||||
impl.LinkWaitableHolder(*holder_base);
|
||||
holder_base->SetManager(&impl);
|
||||
|
|
|
@ -92,11 +92,11 @@ namespace ams::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. */
|
||||
AMS_ASSERT(offset <= protected_size);
|
||||
AMS_ABORT_UNLESS(offset <= protected_size);
|
||||
|
||||
u8 buffer[sizeof(Ips32TailMagic)];
|
||||
while (true) {
|
||||
AMS_ASSERT(fread(buffer, is_ips32 ? sizeof(Ips32TailMagic) : sizeof(IpsTailMagic), 1, f_ips) == 1);
|
||||
AMS_ABORT_UNLESS(fread(buffer, is_ips32 ? sizeof(Ips32TailMagic) : sizeof(IpsTailMagic), 1, f_ips) == 1);
|
||||
|
||||
if (IsIpsTail(is_ips32, buffer)) {
|
||||
break;
|
||||
|
@ -106,18 +106,18 @@ namespace ams::patcher {
|
|||
u32 patch_offset = GetIpsPatchOffset(is_ips32, buffer);
|
||||
|
||||
/* Size of patch. */
|
||||
AMS_ASSERT(fread(buffer, 2, 1, f_ips) == 1);
|
||||
AMS_ABORT_UNLESS(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. */
|
||||
AMS_ASSERT(fread(buffer, 2, 1, f_ips) == 1);
|
||||
AMS_ABORT_UNLESS(fread(buffer, 2, 1, f_ips) == 1);
|
||||
|
||||
u32 rle_size = (buffer[0] << 8) | (buffer[1]);
|
||||
|
||||
/* Value for RLE. */
|
||||
AMS_ASSERT(fread(buffer, 1, 1, f_ips) == 1);
|
||||
AMS_ABORT_UNLESS(fread(buffer, 1, 1, f_ips) == 1);
|
||||
|
||||
/* Ensure we don't write to protected region. */
|
||||
if (patch_offset < protected_size) {
|
||||
|
@ -160,7 +160,7 @@ namespace ams::patcher {
|
|||
if (patch_offset + read_size > mapped_size) {
|
||||
read_size = mapped_size - patch_offset;
|
||||
}
|
||||
AMS_ASSERT(fread(mapped_module + patch_offset, read_size, 1, f_ips) == 1);
|
||||
AMS_ABORT_UNLESS(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);
|
||||
}
|
||||
|
|
|
@ -21,12 +21,12 @@ namespace ams::pm::bm {
|
|||
/* Both functions should be weakly linked, so that they can be overridden by ams::boot2 as needed. */
|
||||
BootMode WEAK_SYMBOL GetBootMode() {
|
||||
PmBootMode boot_mode = PmBootMode_Normal;
|
||||
R_ASSERT(pmbmGetBootMode(&boot_mode));
|
||||
R_ABORT_UNLESS(pmbmGetBootMode(&boot_mode));
|
||||
return static_cast<BootMode>(boot_mode);
|
||||
}
|
||||
|
||||
void WEAK_SYMBOL SetMaintenanceBoot() {
|
||||
R_ASSERT(pmbmSetMaintenanceBoot());
|
||||
R_ABORT_UNLESS(pmbmSetMaintenanceBoot());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace ams::pm::info {
|
|||
|
||||
bool HasLaunchedProgram(ncm::ProgramId program_id) {
|
||||
bool has_launched = false;
|
||||
R_ASSERT(HasLaunchedProgram(&has_launched, program_id));
|
||||
R_ABORT_UNLESS(HasLaunchedProgram(&has_launched, program_id));
|
||||
return has_launched;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,15 +23,38 @@ namespace ams::result {
|
|||
|
||||
namespace ams::result::impl {
|
||||
|
||||
NORETURN WEAK_SYMBOL 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. */
|
||||
AMS_ASSERT((ams::result::CallFatalOnResultAssertion));
|
||||
NORETURN WEAK_SYMBOL void OnResultAbort(const char *file, int line, const char *func, const char *expr, Result result) {
|
||||
/* Assert that we should call fatal on result assertion. */
|
||||
/* If we shouldn't fatal, this will abort(); */
|
||||
/* If we should, we'll continue onwards. */
|
||||
if (!ams::result::CallFatalOnResultAssertion) {
|
||||
::ams::diag::AbortImpl(file, line, func, expr, result.GetValue(), "Result Abort: %203d-%04d", result.GetModule(), result.GetDescription());
|
||||
}
|
||||
|
||||
/* TODO: ams::fatal:: */
|
||||
fatalThrow(result.GetValue());
|
||||
while (true) { /* ... */ }
|
||||
}
|
||||
/* TODO: ams::fatal:: */
|
||||
fatalThrow(result.GetValue());
|
||||
while (true) { /* ... */ }
|
||||
}
|
||||
|
||||
NORETURN WEAK_SYMBOL void OnResultAbort(Result result) {
|
||||
OnResultAbort("", 0, "", "", result);
|
||||
}
|
||||
|
||||
NORETURN WEAK_SYMBOL void OnResultAssertion(const char *file, int line, const char *func, const char *expr, Result result) {
|
||||
/* Assert that we should call fatal on result assertion. */
|
||||
/* If we shouldn't fatal, this will assert(); */
|
||||
/* If we should, we'll continue onwards. */
|
||||
if (!ams::result::CallFatalOnResultAssertion) {
|
||||
::ams::diag::AssertionFailureImpl(file, line, func, expr, result.GetValue(), "Result Assertion: %203d-%04d", result.GetModule(), result.GetDescription());
|
||||
}
|
||||
|
||||
/* TODO: ams::fatal:: */
|
||||
fatalThrow(result.GetValue());
|
||||
while (true) { /* ... */ }
|
||||
}
|
||||
|
||||
NORETURN WEAK_SYMBOL void OnResultAssertion(Result result) {
|
||||
OnResultAssertion("", 0, "", "", result);
|
||||
}
|
||||
|
||||
}
|
|
@ -22,13 +22,13 @@ namespace ams::settings::fwdbg {
|
|||
|
||||
size_t WEAK_SYMBOL GetSettingsItemValueSize(const char *name, const char *key) {
|
||||
u64 size = 0;
|
||||
R_ASSERT(setsysGetSettingsItemValueSize(name, key, &size));
|
||||
R_ABORT_UNLESS(setsysGetSettingsItemValueSize(name, key, &size));
|
||||
return size;
|
||||
}
|
||||
|
||||
size_t WEAK_SYMBOL GetSettingsItemValue(void *dst, size_t dst_size, const char *name, const char *key) {
|
||||
u64 size = 0;
|
||||
R_ASSERT(setsysGetSettingsItemValue(name, key, dst, dst_size, &size));
|
||||
R_ABORT_UNLESS(setsysGetSettingsItemValue(name, key, dst, dst_size, &size));
|
||||
return size;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace ams::sf::cmif {
|
|||
Entry *entry = &this->entries.front();
|
||||
{
|
||||
std::scoped_lock lk(this->manager->entry_owner_lock);
|
||||
AMS_ASSERT(entry->owner == this);
|
||||
AMS_ABORT_UNLESS(entry->owner == this);
|
||||
entry->owner = nullptr;
|
||||
}
|
||||
entry->object.Reset();
|
||||
|
@ -41,7 +41,7 @@ namespace ams::sf::cmif {
|
|||
for (size_t i = 0; i < count; i++) {
|
||||
Entry *entry = this->manager->entry_manager.AllocateEntry();
|
||||
R_UNLESS(entry != nullptr, sf::cmif::ResultOutOfDomainEntries());
|
||||
AMS_ASSERT(entry->owner == nullptr);
|
||||
AMS_ABORT_UNLESS(entry->owner == nullptr);
|
||||
out_ids[i] = this->manager->entry_manager.GetId(entry);
|
||||
}
|
||||
return ResultSuccess();
|
||||
|
@ -54,18 +54,18 @@ namespace ams::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]);
|
||||
AMS_ASSERT(entry != nullptr);
|
||||
AMS_ASSERT(entry->owner == nullptr);
|
||||
AMS_ABORT_UNLESS(entry != nullptr);
|
||||
AMS_ABORT_UNLESS(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);
|
||||
AMS_ASSERT(entry != nullptr);
|
||||
AMS_ABORT_UNLESS(entry != nullptr);
|
||||
{
|
||||
std::scoped_lock lk(this->manager->entry_owner_lock);
|
||||
AMS_ASSERT(entry->owner == nullptr);
|
||||
AMS_ABORT_UNLESS(entry->owner == nullptr);
|
||||
entry->owner = this;
|
||||
this->entries.push_back(*entry);
|
||||
}
|
||||
|
@ -135,8 +135,8 @@ namespace ams::sf::cmif {
|
|||
|
||||
void ServerDomainManager::EntryManager::FreeEntry(Entry *entry) {
|
||||
std::scoped_lock lk(this->lock);
|
||||
AMS_ASSERT(entry->owner == nullptr);
|
||||
AMS_ASSERT(!entry->object);
|
||||
AMS_ABORT_UNLESS(entry->owner == nullptr);
|
||||
AMS_ABORT_UNLESS(!entry->object);
|
||||
this->free_list.push_front(*entry);
|
||||
}
|
||||
|
||||
|
@ -148,8 +148,8 @@ namespace ams::sf::cmif {
|
|||
const auto id = ids[i];
|
||||
Entry *entry = this->GetEntry(id);
|
||||
if (id != InvalidDomainObjectId) {
|
||||
AMS_ASSERT(entry != nullptr);
|
||||
AMS_ASSERT(entry->owner == nullptr);
|
||||
AMS_ABORT_UNLESS(entry != nullptr);
|
||||
AMS_ABORT_UNLESS(entry->owner == nullptr);
|
||||
this->free_list.erase(this->free_list.iterator_to(*entry));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ namespace ams::sf::cmif {
|
|||
/* Write out header. */
|
||||
constexpr size_t out_header_size = sizeof(CmifDomainOutHeader);
|
||||
const size_t impl_out_data_total_size = this->GetImplOutDataTotalSize();
|
||||
AMS_ASSERT(out_header_size + impl_out_data_total_size + sizeof(DomainObjectId) * this->GetOutObjectCount() <= raw_data.GetSize());
|
||||
AMS_ABORT_UNLESS(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. */
|
||||
|
@ -150,7 +150,7 @@ namespace ams::sf::cmif {
|
|||
/* Write out header. */
|
||||
constexpr size_t out_header_size = sizeof(CmifDomainOutHeader);
|
||||
const size_t impl_out_headers_size = this->GetImplOutHeadersSize();
|
||||
AMS_ASSERT(out_header_size + impl_out_headers_size <= raw_data.GetSize());
|
||||
AMS_ABORT_UNLESS(out_header_size + impl_out_headers_size <= raw_data.GetSize());
|
||||
*reinterpret_cast<CmifDomainOutHeader *>(raw_data.GetPointer()) = CmifDomainOutHeader{ .num_out_objects = 0, };
|
||||
|
||||
/* Set output raw data. */
|
||||
|
@ -186,7 +186,7 @@ namespace ams::sf::cmif {
|
|||
}
|
||||
}
|
||||
/* TODO: Can we make this error non-fatal? It isn't for N, since they can reserve IDs earlier due to not having to worry about mitm. */
|
||||
R_ASSERT(this->domain->ReserveIds(reservations, num_unreserved_ids));
|
||||
R_ABORT_UNLESS(this->domain->ReserveIds(reservations, num_unreserved_ids));
|
||||
this->domain->ReserveSpecificIds(specific_ids, num_specific_ids);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace ams::sf::cmif {
|
|||
/* Forward forwardable results, otherwise ensure we can send result to user. */
|
||||
R_TRY_CATCH(command_result) {
|
||||
R_CATCH_RETHROW(sf::impl::ResultRequestContextChanged)
|
||||
R_CATCH_ALL() { AMS_ASSERT(out_header != nullptr); }
|
||||
R_CATCH_ALL() { AMS_ABORT_UNLESS(out_header != nullptr); }
|
||||
} R_END_TRY_CATCH;
|
||||
|
||||
/* Write output header to raw data. */
|
||||
|
@ -93,7 +93,7 @@ namespace ams::sf::cmif {
|
|||
return ctx.session->ForwardRequest(ctx);
|
||||
}
|
||||
R_CATCH_RETHROW(sf::impl::ResultRequestContextChanged)
|
||||
R_CATCH_ALL() { AMS_ASSERT(out_header != nullptr); }
|
||||
R_CATCH_ALL() { AMS_ABORT_UNLESS(out_header != nullptr); }
|
||||
} R_END_TRY_CATCH;
|
||||
|
||||
/* Write output header to raw data. */
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace ams::sf::hipc {
|
|||
NX_INLINE Result ReceiveImpl(Handle session_handle, void *message_buf, size_t message_buf_size) {
|
||||
s32 unused_index;
|
||||
if (message_buf == armGetTls()) {
|
||||
/* Consider: AMS_ASSERT(message_buf_size == TlsMessageBufferSize); */
|
||||
/* Consider: AMS_ABORT_UNLESS(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 ams::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: AMS_ASSERT(message_buf_size == TlsMessageBufferSize); */
|
||||
/* Consider: AMS_ABORT_UNLESS(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 ams::sf::hipc {
|
|||
R_CONVERT(svc::ResultSessionClosed, ResultSuccess())
|
||||
} R_END_TRY_CATCH;
|
||||
/* ReplyImpl should *always* return an error. */
|
||||
AMS_ASSERT(false);
|
||||
AMS_ABORT_UNLESS(false);
|
||||
}
|
||||
|
||||
Result CreateSession(Handle *out_server_handle, Handle *out_client_handle) {
|
||||
|
|
|
@ -66,11 +66,11 @@ namespace ams::sf::hipc::impl {
|
|||
g_constructed_server = true;
|
||||
}
|
||||
|
||||
R_ASSERT(GetPointer(g_query_server_storage)->RegisterSession(query_handle, cmif::ServiceObjectHolder(std::make_shared<MitmQueryService>(query_func))));
|
||||
R_ABORT_UNLESS(GetPointer(g_query_server_storage)->RegisterSession(query_handle, cmif::ServiceObjectHolder(std::make_shared<MitmQueryService>(query_func))));
|
||||
|
||||
if (!g_registered_any) {
|
||||
R_ASSERT(g_query_server_process_thread.Initialize(&QueryServerProcessThreadMain, GetPointer(g_query_server_storage), QueryServerProcessThreadPriority));
|
||||
R_ASSERT(g_query_server_process_thread.Start());
|
||||
R_ABORT_UNLESS(g_query_server_process_thread.Initialize(&QueryServerProcessThreadMain, GetPointer(g_query_server_storage), QueryServerProcessThreadPriority));
|
||||
R_ABORT_UNLESS(g_query_server_process_thread.Start());
|
||||
g_registered_any = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,16 +40,16 @@ namespace ams::sf::hipc {
|
|||
|
||||
/* Create new session handles. */
|
||||
Handle server_handle;
|
||||
R_ASSERT(hipc::CreateSession(&server_handle, out_client_handle));
|
||||
R_ABORT_UNLESS(hipc::CreateSession(&server_handle, out_client_handle));
|
||||
|
||||
/* Register with manager. */
|
||||
if (!is_mitm_session) {
|
||||
R_ASSERT(tagged_manager->RegisterSession(server_handle, std::move(clone)));
|
||||
R_ABORT_UNLESS(tagged_manager->RegisterSession(server_handle, std::move(clone)));
|
||||
} else {
|
||||
/* Clone the forward service. */
|
||||
std::shared_ptr<::Service> new_forward_service = std::move(ServerSession::CreateForwardService());
|
||||
R_ASSERT(serviceClone(this->session->forward_service.get(), new_forward_service.get()));
|
||||
R_ASSERT(tagged_manager->RegisterMitmSession(server_handle, std::move(clone), std::move(new_forward_service)));
|
||||
R_ABORT_UNLESS(serviceClone(this->session->forward_service.get(), new_forward_service.get()));
|
||||
R_ABORT_UNLESS(tagged_manager->RegisterMitmSession(server_handle, std::move(clone), std::move(new_forward_service)));
|
||||
}
|
||||
|
||||
return ResultSuccess();
|
||||
|
@ -71,7 +71,7 @@ namespace ams::sf::hipc {
|
|||
|
||||
if (this->is_mitm_session) {
|
||||
/* If we're a mitm session, we need to convert the remote session to domain. */
|
||||
AMS_ASSERT(session->forward_service->own_handle);
|
||||
AMS_ABORT_UNLESS(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. */
|
||||
|
@ -90,8 +90,8 @@ namespace ams::sf::hipc {
|
|||
new_holder = cmif::ServiceObjectHolder(std::move(std::shared_ptr<cmif::DomainServiceObject>(domain_ptr, cmif::ServerDomainManager::DestroyDomainServiceObject)));
|
||||
}
|
||||
|
||||
AMS_ASSERT(object_id != cmif::InvalidDomainObjectId);
|
||||
AMS_ASSERT(static_cast<bool>(new_holder));
|
||||
AMS_ABORT_UNLESS(object_id != cmif::InvalidDomainObjectId);
|
||||
AMS_ABORT_UNLESS(static_cast<bool>(new_holder));
|
||||
|
||||
/* We succeeded! */
|
||||
domain_guard.Cancel();
|
||||
|
@ -117,10 +117,10 @@ namespace ams::sf::hipc {
|
|||
if (!this->is_mitm_session || object_id.value != serviceGetObjectId(this->session->forward_service.get())) {
|
||||
/* Create new session handles. */
|
||||
Handle server_handle;
|
||||
R_ASSERT(hipc::CreateSession(&server_handle, out.GetHandlePointer()));
|
||||
R_ABORT_UNLESS(hipc::CreateSession(&server_handle, out.GetHandlePointer()));
|
||||
|
||||
/* Register. */
|
||||
R_ASSERT(this->manager->RegisterSession(server_handle, std::move(object)));
|
||||
R_ABORT_UNLESS(this->manager->RegisterSession(server_handle, std::move(object)));
|
||||
} else {
|
||||
/* Copy from the target domain. */
|
||||
Handle new_forward_target;
|
||||
|
@ -128,12 +128,12 @@ namespace ams::sf::hipc {
|
|||
|
||||
/* Create new session handles. */
|
||||
Handle server_handle;
|
||||
R_ASSERT(hipc::CreateSession(&server_handle, out.GetHandlePointer()));
|
||||
R_ABORT_UNLESS(hipc::CreateSession(&server_handle, out.GetHandlePointer()));
|
||||
|
||||
/* Register. */
|
||||
std::shared_ptr<::Service> new_forward_service = std::move(ServerSession::CreateForwardService());
|
||||
serviceCreate(new_forward_service.get(), new_forward_target);
|
||||
R_ASSERT(this->manager->RegisterMitmSession(server_handle, std::move(object), std::move(new_forward_service)));
|
||||
R_ABORT_UNLESS(this->manager->RegisterMitmSession(server_handle, std::move(object), std::move(new_forward_service)));
|
||||
}
|
||||
|
||||
return ResultSuccess();
|
||||
|
|
|
@ -76,14 +76,14 @@ namespace ams::sf::hipc {
|
|||
|
||||
void ServerManagerBase::AddUserWaitableHolder(os::WaitableHolder *waitable) {
|
||||
const auto user_data_tag = static_cast<UserDataTag>(waitable->GetUserData());
|
||||
AMS_ASSERT(user_data_tag != UserDataTag::Server);
|
||||
AMS_ASSERT(user_data_tag != UserDataTag::MitmServer);
|
||||
AMS_ASSERT(user_data_tag != UserDataTag::Session);
|
||||
AMS_ABORT_UNLESS(user_data_tag != UserDataTag::Server);
|
||||
AMS_ABORT_UNLESS(user_data_tag != UserDataTag::MitmServer);
|
||||
AMS_ABORT_UNLESS(user_data_tag != UserDataTag::Session);
|
||||
this->RegisterToWaitList(waitable);
|
||||
}
|
||||
|
||||
Result ServerManagerBase::ProcessForServer(os::WaitableHolder *holder) {
|
||||
AMS_ASSERT(static_cast<UserDataTag>(holder->GetUserData()) == UserDataTag::Server);
|
||||
AMS_ABORT_UNLESS(static_cast<UserDataTag>(holder->GetUserData()) == UserDataTag::Server);
|
||||
|
||||
ServerBase *server = static_cast<ServerBase *>(holder);
|
||||
ON_SCOPE_EXIT { this->RegisterToWaitList(server); };
|
||||
|
@ -94,14 +94,14 @@ namespace ams::sf::hipc {
|
|||
server->CreateSessionObjectHolder(&obj, &fsrv);
|
||||
|
||||
/* Not a mitm server, so we must have no forward service. */
|
||||
AMS_ASSERT(fsrv == nullptr);
|
||||
AMS_ABORT_UNLESS(fsrv == nullptr);
|
||||
|
||||
/* Try to accept. */
|
||||
return this->AcceptSession(server->port_handle, std::move(obj));
|
||||
}
|
||||
|
||||
Result ServerManagerBase::ProcessForMitmServer(os::WaitableHolder *holder) {
|
||||
AMS_ASSERT(static_cast<UserDataTag>(holder->GetUserData()) == UserDataTag::MitmServer);
|
||||
AMS_ABORT_UNLESS(static_cast<UserDataTag>(holder->GetUserData()) == UserDataTag::MitmServer);
|
||||
|
||||
ServerBase *server = static_cast<ServerBase *>(holder);
|
||||
ON_SCOPE_EXIT { this->RegisterToWaitList(server); };
|
||||
|
@ -112,20 +112,20 @@ namespace ams::sf::hipc {
|
|||
server->CreateSessionObjectHolder(&obj, &fsrv);
|
||||
|
||||
/* Mitm server, so we must have forward service. */
|
||||
AMS_ASSERT(fsrv != nullptr);
|
||||
AMS_ABORT_UNLESS(fsrv != nullptr);
|
||||
|
||||
/* Try to accept. */
|
||||
return this->AcceptMitmSession(server->port_handle, std::move(obj), std::move(fsrv));
|
||||
}
|
||||
|
||||
Result ServerManagerBase::ProcessForSession(os::WaitableHolder *holder) {
|
||||
AMS_ASSERT(static_cast<UserDataTag>(holder->GetUserData()) == UserDataTag::Session);
|
||||
AMS_ABORT_UNLESS(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;
|
||||
AMS_ASSERT(tls_message.GetSize() == saved_message.GetSize());
|
||||
AMS_ABORT_UNLESS(tls_message.GetSize() == saved_message.GetSize());
|
||||
if (!session->has_received) {
|
||||
R_TRY(this->ReceiveRequest(session, tls_message));
|
||||
session->has_received = true;
|
||||
|
@ -208,7 +208,7 @@ namespace ams::sf::hipc {
|
|||
if (!waitable) {
|
||||
return false;
|
||||
}
|
||||
R_ASSERT(this->Process(waitable));
|
||||
R_ABORT_UNLESS(this->Process(waitable));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,10 +40,10 @@ namespace ams::sf::hipc {
|
|||
}
|
||||
|
||||
Result ServerSession::ForwardRequest(const cmif::ServiceDispatchContext &ctx) const {
|
||||
AMS_ASSERT(this->IsMitmSession());
|
||||
AMS_ABORT_UNLESS(this->IsMitmSession());
|
||||
/* TODO: Support non-TLS messages? */
|
||||
AMS_ASSERT(this->saved_message.GetPointer() != nullptr);
|
||||
AMS_ASSERT(this->saved_message.GetSize() == TlsMessageBufferSize);
|
||||
AMS_ABORT_UNLESS(this->saved_message.GetPointer() != nullptr);
|
||||
AMS_ABORT_UNLESS(this->saved_message.GetSize() == TlsMessageBufferSize);
|
||||
|
||||
/* Copy saved TLS in. */
|
||||
std::memcpy(armGetTls(), this->saved_message.GetPointer(), this->saved_message.GetSize());
|
||||
|
@ -78,7 +78,7 @@ namespace ams::sf::hipc {
|
|||
void ServerSessionManager::CloseSessionImpl(ServerSession *session) {
|
||||
const Handle session_handle = session->session_handle;
|
||||
this->DestroySession(session);
|
||||
R_ASSERT(svcCloseHandle(session_handle));
|
||||
R_ABORT_UNLESS(svcCloseHandle(session_handle));
|
||||
}
|
||||
|
||||
Result ServerSessionManager::RegisterSessionImpl(ServerSession *session_memory, Handle session_handle, cmif::ServiceObjectHolder &&obj) {
|
||||
|
@ -99,7 +99,7 @@ namespace ams::sf::hipc {
|
|||
bool succeeded = false;
|
||||
ON_SCOPE_EXIT {
|
||||
if (!succeeded) {
|
||||
R_ASSERT(svcCloseHandle(session_handle));
|
||||
R_ABORT_UNLESS(svcCloseHandle(session_handle));
|
||||
}
|
||||
};
|
||||
/* Register session. */
|
||||
|
@ -115,7 +115,7 @@ namespace ams::sf::hipc {
|
|||
session_memory->pointer_buffer = this->GetSessionPointerBuffer(session_memory);
|
||||
session_memory->saved_message = this->GetSessionSavedMessageBuffer(session_memory);
|
||||
/* Validate session pointer buffer. */
|
||||
AMS_ASSERT(session_memory->pointer_buffer.GetSize() >= session_memory->forward_service->pointer_buffer_size);
|
||||
AMS_ABORT_UNLESS(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);
|
||||
|
@ -129,7 +129,7 @@ namespace ams::sf::hipc {
|
|||
bool succeeded = false;
|
||||
ON_SCOPE_EXIT {
|
||||
if (!succeeded) {
|
||||
R_ASSERT(svcCloseHandle(mitm_session_handle));
|
||||
R_ABORT_UNLESS(svcCloseHandle(mitm_session_handle));
|
||||
}
|
||||
};
|
||||
/* Register session. */
|
||||
|
@ -291,7 +291,7 @@ namespace ams::sf::hipc {
|
|||
{
|
||||
ON_SCOPE_EXIT {
|
||||
for (size_t i = 0; i < handles_to_close.num_handles; i++) {
|
||||
R_ASSERT(svcCloseHandle(handles_to_close.handles[i]));
|
||||
R_ABORT_UNLESS(svcCloseHandle(handles_to_close.handles[i]));
|
||||
}
|
||||
};
|
||||
R_TRY(hipc::Reply(session->session_handle, out_message));
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace ams::sm::impl {
|
|||
Result DoWithUserSession(F f) {
|
||||
std::scoped_lock<os::RecursiveMutex &> lk(GetUserSessionMutex());
|
||||
{
|
||||
R_ASSERT(smInitialize());
|
||||
R_ABORT_UNLESS(smInitialize());
|
||||
ON_SCOPE_EXIT { smExit(); };
|
||||
|
||||
return f();
|
||||
|
@ -40,7 +40,7 @@ namespace ams::sm::impl {
|
|||
Result DoWithMitmAcknowledgementSession(F f) {
|
||||
std::scoped_lock<os::RecursiveMutex &> lk(GetMitmAcknowledgementSessionMutex());
|
||||
{
|
||||
R_ASSERT(smAtmosphereMitmInitialize());
|
||||
R_ABORT_UNLESS(smAtmosphereMitmInitialize());
|
||||
ON_SCOPE_EXIT { smAtmosphereMitmExit(); };
|
||||
|
||||
return f();
|
||||
|
@ -52,7 +52,7 @@ namespace ams::sm::impl {
|
|||
Service srv;
|
||||
{
|
||||
std::scoped_lock<os::RecursiveMutex &> lk(GetPerThreadSessionMutex());
|
||||
R_ASSERT(smAtmosphereOpenSession(&srv));
|
||||
R_ABORT_UNLESS(smAtmosphereOpenSession(&srv));
|
||||
}
|
||||
{
|
||||
ON_SCOPE_EXIT { smAtmosphereCloseSession(&srv); };
|
||||
|
|
|
@ -349,7 +349,7 @@ namespace ams::spl::smc {
|
|||
}
|
||||
|
||||
Result AtmosphereWriteAddress(void *dst, const void *src, size_t size) {
|
||||
AMS_ASSERT(size <= sizeof(u64));
|
||||
AMS_ABORT_UNLESS(size <= sizeof(u64));
|
||||
|
||||
SecmonArgs args;
|
||||
args.X[0] = static_cast<u64>(FunctionId::AtmosphereWriteAddress);
|
||||
|
@ -363,7 +363,7 @@ namespace ams::spl::smc {
|
|||
|
||||
Result AtmosphereGetEmummcConfig(void *out_config, void *out_paths, u32 storage_id) {
|
||||
const u64 paths = reinterpret_cast<u64>(out_paths);
|
||||
AMS_ASSERT(util::IsAligned(paths, os::MemoryPageSize));
|
||||
AMS_ABORT_UNLESS(util::IsAligned(paths, os::MemoryPageSize));
|
||||
|
||||
SecmonArgs args = {};
|
||||
args.X[0] = static_cast<u64>(FunctionId::AtmosphereGetEmummcConfig);
|
||||
|
|
|
@ -19,13 +19,13 @@ namespace ams::spl {
|
|||
|
||||
HardwareType GetHardwareType() {
|
||||
u64 out_val = 0;
|
||||
R_ASSERT(splGetConfig(SplConfigItem_HardwareType, &out_val));
|
||||
R_ABORT_UNLESS(splGetConfig(SplConfigItem_HardwareType, &out_val));
|
||||
return static_cast<HardwareType>(out_val);
|
||||
}
|
||||
|
||||
MemoryArrangement GetMemoryArrangement() {
|
||||
u64 arrange = 0;
|
||||
R_ASSERT(splGetConfig(SplConfigItem_MemoryArrange, &arrange));
|
||||
R_ABORT_UNLESS(splGetConfig(SplConfigItem_MemoryArrange, &arrange));
|
||||
arrange &= 0x3F;
|
||||
switch (arrange) {
|
||||
case 2:
|
||||
|
@ -43,19 +43,19 @@ namespace ams::spl {
|
|||
|
||||
bool IsDevelopmentHardware() {
|
||||
bool is_dev_hardware;
|
||||
R_ASSERT(splIsDevelopment(&is_dev_hardware));
|
||||
R_ABORT_UNLESS(splIsDevelopment(&is_dev_hardware));
|
||||
return is_dev_hardware;
|
||||
}
|
||||
|
||||
bool IsDevelopmentFunctionEnabled() {
|
||||
u64 val = 0;
|
||||
R_ASSERT(splGetConfig(SplConfigItem_IsDebugMode, &val));
|
||||
R_ABORT_UNLESS(splGetConfig(SplConfigItem_IsDebugMode, &val));
|
||||
return val != 0;
|
||||
}
|
||||
|
||||
bool IsRecoveryBoot() {
|
||||
u64 val = 0;
|
||||
R_ASSERT(splGetConfig(SplConfigItem_IsRecoveryBoot, &val));
|
||||
R_ABORT_UNLESS(splGetConfig(SplConfigItem_IsRecoveryBoot, &val));
|
||||
return val != 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace ams::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;
|
||||
AMS_ASSERT(work_buffer_size >= sizeof(NcmContentMetaKey) * MaxContentMetas);
|
||||
AMS_ABORT_UNLESS(work_buffer_size >= sizeof(NcmContentMetaKey) * MaxContentMetas);
|
||||
|
||||
/* Open NAND System meta database, list contents. */
|
||||
NcmContentMetaDatabase meta_db;
|
||||
|
@ -150,7 +150,7 @@ namespace ams::updater {
|
|||
return ResultBootImagePackageNotFound();
|
||||
}
|
||||
|
||||
AMS_ASSERT(total_entries == written_entries);
|
||||
AMS_ABORT_UNLESS(total_entries == written_entries);
|
||||
|
||||
/* Output is sorted, return the lowest valid exfat entry. */
|
||||
if (total_entries > 1) {
|
||||
|
@ -187,7 +187,7 @@ namespace ams::updater {
|
|||
R_TRY_CATCH(romfsMountFromDataArchive(data_id, NcmStorageId_BuiltInSystem, GetBootImagePackageMountPath())) {
|
||||
R_CONVERT(fs::ResultTargetNotFound, ResultBootImagePackageNotFound())
|
||||
} R_END_TRY_CATCH;
|
||||
ON_SCOPE_EXIT { R_ASSERT(romfsUnmount(GetBootImagePackageMountPath())); };
|
||||
ON_SCOPE_EXIT { R_ABORT_UNLESS(romfsUnmount(GetBootImagePackageMountPath())); };
|
||||
|
||||
/* Read and validate hashes of boot images. */
|
||||
{
|
||||
|
@ -240,7 +240,7 @@ namespace ams::updater {
|
|||
R_TRY_CATCH(romfsMountFromDataArchive(data_id, NcmStorageId_BuiltInSystem, GetBootImagePackageMountPath())) {
|
||||
R_CONVERT(fs::ResultTargetNotFound, ResultBootImagePackageNotFound())
|
||||
} R_END_TRY_CATCH;
|
||||
ON_SCOPE_EXIT { R_ASSERT(romfsUnmount(GetBootImagePackageMountPath())); };
|
||||
ON_SCOPE_EXIT { R_ABORT_UNLESS(romfsUnmount(GetBootImagePackageMountPath())); };
|
||||
|
||||
/* Read and validate hashes of boot images. */
|
||||
{
|
||||
|
@ -308,7 +308,7 @@ namespace ams::updater {
|
|||
R_TRY_CATCH(romfsMountFromDataArchive(data_id, NcmStorageId_BuiltInSystem, GetBootImagePackageMountPath())) {
|
||||
R_CONVERT(fs::ResultTargetNotFound, ResultBootImagePackageNotFound())
|
||||
} R_END_TRY_CATCH;
|
||||
ON_SCOPE_EXIT { R_ASSERT(romfsUnmount(GetBootImagePackageMountPath())); };
|
||||
ON_SCOPE_EXIT { R_ABORT_UNLESS(romfsUnmount(GetBootImagePackageMountPath())); };
|
||||
|
||||
{
|
||||
Boot0Accessor boot0_accessor;
|
||||
|
@ -363,7 +363,7 @@ namespace ams::updater {
|
|||
R_TRY_CATCH(romfsMountFromDataArchive(data_id, NcmStorageId_BuiltInSystem, GetBootImagePackageMountPath())) {
|
||||
R_CONVERT(fs::ResultTargetNotFound, ResultBootImagePackageNotFound())
|
||||
} R_END_TRY_CATCH;
|
||||
ON_SCOPE_EXIT { R_ASSERT(romfsUnmount(GetBootImagePackageMountPath())); };
|
||||
ON_SCOPE_EXIT { R_ABORT_UNLESS(romfsUnmount(GetBootImagePackageMountPath())); };
|
||||
|
||||
{
|
||||
Boot0Accessor boot0_accessor;
|
||||
|
@ -509,7 +509,7 @@ namespace ams::updater {
|
|||
|
||||
/* Get a session to ncm. */
|
||||
sm::ScopedServiceHolder<ncmInitialize, ncmExit> ncm_holder;
|
||||
R_ASSERT(ncm_holder.GetResult());
|
||||
R_ABORT_UNLESS(ncm_holder.GetResult());
|
||||
|
||||
/* Verify normal, verify safe as needed. */
|
||||
if (verification_state.needs_verify_normal) {
|
||||
|
|
|
@ -31,18 +31,18 @@ namespace ams::updater {
|
|||
}
|
||||
|
||||
Result BisAccessor::Read(void *dst, size_t size, u64 offset) {
|
||||
AMS_ASSERT((offset % SectorAlignment) == 0);
|
||||
AMS_ABORT_UNLESS((offset % SectorAlignment) == 0);
|
||||
return fsStorageRead(&this->storage, offset, dst, size);
|
||||
}
|
||||
|
||||
Result BisAccessor::Write(u64 offset, const void *src, size_t size) {
|
||||
AMS_ASSERT((offset % SectorAlignment) == 0);
|
||||
AMS_ABORT_UNLESS((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) {
|
||||
AMS_ASSERT((offset % SectorAlignment) == 0);
|
||||
AMS_ASSERT((work_buffer_size % SectorAlignment) == 0);
|
||||
AMS_ABORT_UNLESS((offset % SectorAlignment) == 0);
|
||||
AMS_ABORT_UNLESS((work_buffer_size % SectorAlignment) == 0);
|
||||
|
||||
FILE *bip_fp = fopen(bip_path, "rb");
|
||||
if (bip_fp == NULL) {
|
||||
|
@ -59,7 +59,7 @@ namespace ams::updater {
|
|||
return fsdevGetLastResult();
|
||||
}
|
||||
}
|
||||
AMS_ASSERT(written + read_size <= size);
|
||||
AMS_ABORT_UNLESS(written + read_size <= size);
|
||||
|
||||
size_t aligned_size = ((read_size + SectorAlignment - 1) / SectorAlignment) * SectorAlignment;
|
||||
R_TRY(this->Write(offset + written, work_buffer, aligned_size));
|
||||
|
@ -73,8 +73,8 @@ namespace ams::updater {
|
|||
}
|
||||
|
||||
Result BisAccessor::Clear(u64 offset, u64 size, void *work_buffer, size_t work_buffer_size) {
|
||||
AMS_ASSERT((offset % SectorAlignment) == 0);
|
||||
AMS_ASSERT((work_buffer_size % SectorAlignment) == 0);
|
||||
AMS_ABORT_UNLESS((offset % SectorAlignment) == 0);
|
||||
AMS_ABORT_UNLESS((work_buffer_size % SectorAlignment) == 0);
|
||||
|
||||
std::memset(work_buffer, 0, work_buffer_size);
|
||||
|
||||
|
@ -88,8 +88,8 @@ namespace ams::updater {
|
|||
}
|
||||
|
||||
Result BisAccessor::GetHash(void *dst, u64 offset, u64 size, u64 hash_size, void *work_buffer, size_t work_buffer_size) {
|
||||
AMS_ASSERT((offset % SectorAlignment) == 0);
|
||||
AMS_ASSERT((work_buffer_size % SectorAlignment) == 0);
|
||||
AMS_ABORT_UNLESS((offset % SectorAlignment) == 0);
|
||||
AMS_ABORT_UNLESS((work_buffer_size % SectorAlignment) == 0);
|
||||
|
||||
Sha256Context sha_ctx;
|
||||
sha256ContextCreate(&sha_ctx);
|
||||
|
@ -109,12 +109,12 @@ namespace ams::updater {
|
|||
|
||||
size_t Boot0Accessor::GetBootloaderVersion(void *bct) {
|
||||
u32 version = *reinterpret_cast<u32 *>(reinterpret_cast<uintptr_t>(bct) + BctVersionOffset);
|
||||
AMS_ASSERT(version <= BctVersionMax);
|
||||
AMS_ABORT_UNLESS(version <= BctVersionMax);
|
||||
return static_cast<size_t>(version);
|
||||
}
|
||||
|
||||
size_t Boot0Accessor::GetEksIndex(size_t bootloader_version) {
|
||||
AMS_ASSERT(bootloader_version <= BctVersionMax);
|
||||
AMS_ABORT_UNLESS(bootloader_version <= BctVersionMax);
|
||||
return (bootloader_version > 0) ? bootloader_version - 1 : 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -136,13 +136,13 @@ namespace ams::updater {
|
|||
}
|
||||
}
|
||||
|
||||
AMS_ASSERT(entry != nullptr);
|
||||
AMS_ABORT_UNLESS(entry != nullptr);
|
||||
return entry;
|
||||
}
|
||||
public:
|
||||
Result Read(size_t *out_size, void *dst, size_t size, EnumType which) {
|
||||
const auto entry = FindEntry(which);
|
||||
AMS_ASSERT(size >= entry->size);
|
||||
AMS_ABORT_UNLESS(size >= entry->size);
|
||||
|
||||
R_TRY(BisAccessor::Read(dst, entry->size, entry->offset));
|
||||
|
||||
|
@ -152,8 +152,8 @@ namespace ams::updater {
|
|||
|
||||
Result Write(const void *src, size_t size, EnumType which) {
|
||||
const auto entry = FindEntry(which);
|
||||
AMS_ASSERT(size <= entry->size);
|
||||
AMS_ASSERT((size % BisAccessor::SectorAlignment) == 0);
|
||||
AMS_ABORT_UNLESS(size <= entry->size);
|
||||
AMS_ABORT_UNLESS((size % BisAccessor::SectorAlignment) == 0);
|
||||
return BisAccessor::Write(entry->offset, src, size);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@ namespace ams::updater {
|
|||
}
|
||||
|
||||
Result BisSave::Initialize(void *work_buffer, size_t work_buffer_size) {
|
||||
AMS_ASSERT(work_buffer_size >= SaveSize);
|
||||
AMS_ASSERT(util::IsAligned(reinterpret_cast<uintptr_t>(work_buffer), os::MemoryPageSize));
|
||||
AMS_ASSERT(util::IsAligned(work_buffer_size, 0x200));
|
||||
AMS_ABORT_UNLESS(work_buffer_size >= SaveSize);
|
||||
AMS_ABORT_UNLESS(util::IsAligned(reinterpret_cast<uintptr_t>(work_buffer), os::MemoryPageSize));
|
||||
AMS_ABORT_UNLESS(util::IsAligned(work_buffer_size, 0x200));
|
||||
|
||||
R_TRY(this->accessor.Initialize());
|
||||
this->save_buffer = work_buffer;
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace ams::updater {
|
|||
constexpr const char *Package2PathA = "bip:/a/package2";
|
||||
|
||||
const char *ChooseCandidatePath(const char * const *candidates, size_t num_candidates) {
|
||||
AMS_ASSERT(num_candidates > 0);
|
||||
AMS_ABORT_UNLESS(num_candidates > 0);
|
||||
|
||||
for (size_t i = 0; i < num_candidates; i++) {
|
||||
struct stat buf;
|
||||
|
|
|
@ -21,8 +21,8 @@ namespace ams::util {
|
|||
/* Compression utilities. */
|
||||
int CompressLZ4(void *dst, size_t dst_size, const void *src, size_t src_size) {
|
||||
/* Size checks. */
|
||||
AMS_ASSERT(dst_size <= std::numeric_limits<int>::max());
|
||||
AMS_ASSERT(src_size <= std::numeric_limits<int>::max());
|
||||
AMS_ABORT_UNLESS(dst_size <= std::numeric_limits<int>::max());
|
||||
AMS_ABORT_UNLESS(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));
|
||||
|
@ -31,8 +31,8 @@ namespace ams::util {
|
|||
/* Decompression utilities. */
|
||||
int DecompressLZ4(void *dst, size_t dst_size, const void *src, size_t src_size) {
|
||||
/* Size checks. */
|
||||
AMS_ASSERT(dst_size <= std::numeric_limits<int>::max());
|
||||
AMS_ASSERT(src_size <= std::numeric_limits<int>::max());
|
||||
AMS_ABORT_UNLESS(dst_size <= std::numeric_limits<int>::max());
|
||||
AMS_ABORT_UNLESS(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));
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace ams::util::ini {
|
|||
|
||||
explicit FsFileContext(FsFile *f) : f(f), offset(0) {
|
||||
s64 size;
|
||||
R_ASSERT(fsFileGetSize(this->f, &size));
|
||||
R_ABORT_UNLESS(fsFileGetSize(this->f, &size));
|
||||
this->num_left = size_t(size);
|
||||
}
|
||||
};
|
||||
|
@ -46,8 +46,8 @@ namespace ams::util::ini {
|
|||
/* Read as many bytes as we can. */
|
||||
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));
|
||||
AMS_ASSERT(actually_read == try_read);
|
||||
R_ABORT_UNLESS(fsFileRead(ctx->f, ctx->offset, str, try_read, FsReadOption_None, &actually_read));
|
||||
AMS_ABORT_UNLESS(actually_read == try_read);
|
||||
|
||||
/* Only "read" up to the first \n. */
|
||||
size_t offset = actually_read;
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vapours/includes.hpp>
|
||||
#include <vapours/defines.hpp>
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
#include <vapours/literals.hpp>
|
||||
|
||||
#include <vapours/timespan.hpp>
|
||||
|
|
76
libraries/libvapours/include/vapours/assert.hpp
Normal file
76
libraries/libvapours/include/vapours/assert.hpp
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours/common.hpp>
|
||||
|
||||
namespace ams::impl {
|
||||
|
||||
template<typename... ArgTypes>
|
||||
ALWAYS_INLINE void UnusedImpl(ArgTypes... args) {
|
||||
(static_cast<void>(args), ...);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace ams::diag {
|
||||
|
||||
NORETURN NOINLINE void AssertionFailureImpl(const char *file, int line, const char *func, const char *expr, u64 value, const char *format, ...) __attribute__((format(printf, 6, 7)));
|
||||
NORETURN NOINLINE void AssertionFailureImpl(const char *file, int line, const char *func, const char *expr, u64 value);
|
||||
|
||||
NORETURN NOINLINE void AbortImpl(const char *file, int line, const char *func, const char *expr, u64 value, const char *format, ...) __attribute__((format(printf, 6, 7)));
|
||||
NORETURN NOINLINE void AbortImpl(const char *file, int line, const char *func, const char *expr, u64 value);
|
||||
|
||||
}
|
||||
|
||||
#define AMS_UNUSED(...) ::ams::impl::UnusedImpl(__VA_ARGS__)
|
||||
|
||||
#ifdef AMS_ENABLE_DEBUG_PRINT
|
||||
#define AMS_CALL_ASSERT_FAIL_IMPL(cond, ...) ::ams::diag::AssertionFailureImpl(__FILE__, __LINE__, __PRETTY_FUNCTION__, cond, 0, ## __VA_ARGS__)
|
||||
#define AMS_CALL_ABORT_IMPL(cond, ...) ::ams::diag::AbortImpl(__FILE__, __LINE__, __PRETTY_FUNCTION__, cond, 0, ## __VA_ARGS__)
|
||||
#else
|
||||
#define AMS_CALL_ASSERT_FAIL_IMPL(cond, ...) ::ams::diag::AssertionFailureImpl("", 0, "", "", 0)
|
||||
#define AMS_CALL_ABORT_IMPL(cond, ...) ::ams::diag::AbortImpl("", 0, "", "", 0)
|
||||
#endif
|
||||
|
||||
#ifdef AMS_ENABLE_ASSERTIONS
|
||||
#define AMS_ASSERT_IMPL(expr, ...) \
|
||||
({ \
|
||||
if (const bool __tmp_ams_assert_val = (expr); AMS_UNLIKELY(!__tmp_ams_assert_val)) { \
|
||||
AMS_CALL_ASSERT_FAIL_IMPL(#expr, ## __VA_ARGS__); \
|
||||
} \
|
||||
})
|
||||
#else
|
||||
#define AMS_ASSERT_IMPL(expr, ...) AMS_UNUSED(expr, ## __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#define AMS_ASSERT(expr, ...) AMS_ASSERT_IMPL(expr, ## __VA_ARGS__)
|
||||
|
||||
#define AMS_UNREACHABLE_DEFAULT_CASE() default: AMS_CALL_ABORT_IMPL("Unreachable default case entered")
|
||||
|
||||
#ifdef AMS_BUILD_FOR_AUDITING
|
||||
#define AMS_AUDIT(expr, ...) AMS_ASSERT(expr, ## __VA_ARGS__)
|
||||
#else
|
||||
#define AMS_AUDIT(expr, ...) AMS_UNUSED(expr, ## __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#define AMS_ABORT(...) AMS_CALL_ABORT_IMPL("", ## __VA_ARGS__)
|
||||
|
||||
#define AMS_ABORT_UNLESS(expr, ...) \
|
||||
({ \
|
||||
if (const bool __tmp_ams_assert_val = (expr); AMS_UNLIKELY(!__tmp_ams_assert_val)) { \
|
||||
AMS_CALL_ABORT_IMPL(#expr, ##__VA_ARGS__); \
|
||||
} \
|
||||
})
|
31
libraries/libvapours/include/vapours/common.hpp
Normal file
31
libraries/libvapours/include/vapours/common.hpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours/includes.hpp>
|
||||
#include <vapours/defines.hpp>
|
||||
|
||||
#if 0
|
||||
#define AMS_BUILD_FOR_AUDITING
|
||||
#endif
|
||||
|
||||
#ifdef AMS_BUILD_FOR_AUDITING
|
||||
#define AMS_BUILD_FOR_DEBUGGING
|
||||
#endif
|
||||
|
||||
#ifdef AMS_BUILD_FOR_DEBUGGING
|
||||
#define AMS_ENABLE_ASSERTIONS
|
||||
#define AMS_ENABLE_DEBUG_PRINT
|
||||
#endif
|
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vapours/defines.hpp>
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
#include <vapours/util.hpp>
|
||||
|
||||
#ifdef ATMOSPHERE_ARCH_ARM64
|
||||
|
@ -30,7 +31,7 @@
|
|||
|
||||
namespace ams::crypto {
|
||||
|
||||
bool IsSameBytes(const void *lhs, const void *rhs, size_t size) {
|
||||
inline bool IsSameBytes(const void *lhs, const void *rhs, size_t size) {
|
||||
return impl::IsSameBytes(lhs, rhs, size);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
namespace ams::crypto::impl {
|
||||
|
||||
bool IsSameBytes(const void *lhs, const void *rhs, size_t size) {
|
||||
inline bool IsSameBytes(const void *lhs, const void *rhs, size_t size) {
|
||||
bool result;
|
||||
u8 xor_acc, ltmp, rtmp;
|
||||
size_t index;
|
||||
|
|
|
@ -18,10 +18,6 @@
|
|||
|
||||
/* Any broadly useful language defines should go here. */
|
||||
|
||||
#define AMS_ASSERT(expr) do { if (!(expr)) { std::abort(); } } while (0)
|
||||
|
||||
#define AMS_UNREACHABLE_DEFAULT_CASE() default: std::abort()
|
||||
|
||||
#define NON_COPYABLE(cls) \
|
||||
cls(const cls&) = delete; \
|
||||
cls& operator=(const cls&) = delete
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours/defines.hpp>
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
|
||||
namespace ams { inline namespace literals {
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vapours/defines.hpp>
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
#include <vapours/util.hpp>
|
||||
|
||||
/* Utilities. */
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vapours/defines.hpp>
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
|
||||
namespace ams {
|
||||
|
||||
|
@ -31,7 +32,7 @@ namespace ams {
|
|||
static constexpr BaseType ReservedBits = 10;
|
||||
static_assert(ModuleBits + DescriptionBits + ReservedBits == sizeof(BaseType) * CHAR_BIT, "ModuleBits + DescriptionBits + ReservedBits == sizeof(BaseType) * CHAR_BIT");
|
||||
public:
|
||||
NX_CONSTEXPR BaseType MakeValue(BaseType module, BaseType description) {
|
||||
static constexpr ALWAYS_INLINE BaseType MakeValue(BaseType module, BaseType description) {
|
||||
return (module) | (description << ModuleBits);
|
||||
}
|
||||
|
||||
|
@ -41,11 +42,11 @@ namespace ams {
|
|||
static_assert(description < (1 << DescriptionBits), "Invalid Description");
|
||||
};
|
||||
|
||||
NX_CONSTEXPR BaseType GetModuleFromValue(BaseType value) {
|
||||
static constexpr ALWAYS_INLINE BaseType GetModuleFromValue(BaseType value) {
|
||||
return value & ~(~BaseType() << ModuleBits);
|
||||
}
|
||||
|
||||
NX_CONSTEXPR BaseType GetDescriptionFromValue(BaseType value) {
|
||||
static constexpr ALWAYS_INLINE BaseType GetDescriptionFromValue(BaseType value) {
|
||||
return ((value >> ModuleBits) & ~(~BaseType() << DescriptionBits));
|
||||
}
|
||||
};
|
||||
|
@ -126,13 +127,16 @@ namespace ams {
|
|||
|
||||
namespace result::impl {
|
||||
|
||||
NORETURN void OnResultAssertion(Result result);
|
||||
NORETURN NOINLINE void OnResultAssertion(const char *file, int line, const char *func, const char *expr, Result result);
|
||||
NORETURN NOINLINE void OnResultAssertion(Result result);
|
||||
NORETURN NOINLINE void OnResultAbort(const char *file, int line, const char *func, const char *expr, Result result);
|
||||
NORETURN NOINLINE void OnResultAbort(Result result);
|
||||
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE Result::operator ResultSuccess() const {
|
||||
if (!ResultSuccess::CanAccept(*this)) {
|
||||
result::impl::OnResultAssertion(*this);
|
||||
result::impl::OnResultAbort(*this);
|
||||
}
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
@ -149,7 +153,7 @@ namespace ams {
|
|||
static_assert(Value != Base::SuccessValue, "Value != Base::SuccessValue");
|
||||
public:
|
||||
constexpr operator Result() const { return MakeResult(Value); }
|
||||
constexpr operator ResultSuccess() const { OnResultAssertion(Value); }
|
||||
constexpr operator ResultSuccess() const { OnResultAbort(Value); }
|
||||
|
||||
constexpr ALWAYS_INLINE bool IsSuccess() const { return false; }
|
||||
constexpr ALWAYS_INLINE bool IsFailure() const { return !this->IsSuccess(); }
|
||||
|
@ -216,18 +220,39 @@ namespace ams {
|
|||
/// Evaluates an expression that returns a result, and returns the result if it would fail.
|
||||
#define R_TRY(res_expr) \
|
||||
({ \
|
||||
const auto _tmp_r_try_rc = res_expr; \
|
||||
const auto _tmp_r_try_rc = (res_expr); \
|
||||
if (R_FAILED(_tmp_r_try_rc)) { \
|
||||
return _tmp_r_try_rc; \
|
||||
} \
|
||||
})
|
||||
|
||||
/// Evaluates an expression that returns a result, and fatals the result if it would fail.
|
||||
#ifdef AMS_ENABLE_DEBUG_PRINT
|
||||
#define AMS_CALL_ON_RESULT_ASSERTION_IMPL(cond, val) ::ams::result::impl::OnResultAssertion(__FILE__, __LINE__, __PRETTY_FUNCTION__, cond, val)
|
||||
#define AMS_CALL_ON_RESULT_ABORT_IMPL(cond, val) ::ams::result::impl::OnResultAbort(__FILE__, __LINE__, __PRETTY_FUNCTION__, cond, val)
|
||||
#else
|
||||
#define AMS_CALL_ON_RESULT_ASSERTION_IMPL(cond, val) ::ams::result::impl::OnResultAssertion("", 0, "", "", val)
|
||||
#define AMS_CALL_ON_RESULT_ABORT_IMPL(cond, val) ::ams::result::impl::OnResultAbort("", 0, "", "", val)
|
||||
#endif
|
||||
|
||||
/// Evaluates an expression that returns a result, and asserts the result if it would fail.
|
||||
#ifdef AMS_ENABLE_ASSERTIONS
|
||||
#define R_ASSERT(res_expr) \
|
||||
({ \
|
||||
const auto _tmp_r_assert_rc = res_expr; \
|
||||
if (R_FAILED(_tmp_r_assert_rc)) { \
|
||||
::ams::result::impl::OnResultAssertion(_tmp_r_assert_rc); \
|
||||
const auto _tmp_r_assert_rc = (res_expr); \
|
||||
if (AMS_UNLIKELY(R_FAILED(_tmp_r_assert_rc))) { \
|
||||
AMS_CALL_ON_RESULT_ASSERTION_IMPL(#res_expr, _tmp_r_assert_rc); \
|
||||
} \
|
||||
})
|
||||
#else
|
||||
#define R_ASSERT(res_expr) AMS_UNUSED((res_expr));
|
||||
#endif
|
||||
|
||||
/// Evaluates an expression that returns a result, and aborts if the result would fail.
|
||||
#define R_ABORT_UNLESS(res_expr) \
|
||||
({ \
|
||||
const auto _tmp_r_abort_rc = (res_expr); \
|
||||
if (AMS_UNLIKELY(R_FAILED(_tmp_r_abort_rc))) { \
|
||||
AMS_CALL_ON_RESULT_ABORT_IMPL(#res_expr, _tmp_r_abort_rc); \
|
||||
} \
|
||||
})
|
||||
|
||||
|
@ -244,14 +269,14 @@ namespace ams {
|
|||
|
||||
#define R_TRY_CATCH(res_expr) \
|
||||
({ \
|
||||
const auto R_CURRENT_RESULT = res_expr; \
|
||||
const auto R_CURRENT_RESULT = (res_expr); \
|
||||
if (R_FAILED(R_CURRENT_RESULT)) { \
|
||||
if (false)
|
||||
|
||||
namespace ams::result::impl {
|
||||
|
||||
template<typename... Rs>
|
||||
NX_CONSTEXPR bool AnyIncludes(Result result) {
|
||||
constexpr ALWAYS_INLINE bool AnyIncludes(Result result) {
|
||||
return (Rs::Includes(result) || ...);
|
||||
}
|
||||
|
||||
|
@ -287,3 +312,11 @@ namespace ams::result::impl {
|
|||
} \
|
||||
} \
|
||||
})
|
||||
|
||||
|
||||
#define R_END_TRY_CATCH_WITH_ABORT_UNLESS \
|
||||
else { \
|
||||
R_ABORT_UNLESS(R_CURRENT_RESULT); \
|
||||
} \
|
||||
} \
|
||||
})
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vapours/defines.hpp>
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
#include <vapours/results.hpp>
|
||||
|
||||
#include <vapours/svc/svc_types.hpp>
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
#include <vapours/svc/svc_types.hpp>
|
||||
|
||||
namespace ams::svc::codegen::impl {
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
#include <vapours/results.hpp>
|
||||
|
||||
namespace ams::svc {
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "svc_common.hpp"
|
||||
#include "svc_select_hardware_constants.hpp"
|
||||
#include <vapours/svc/svc_common.hpp>
|
||||
#include <vapours/svc/svc_select_hardware_constants.hpp>
|
||||
|
||||
namespace ams::svc {
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vapours/defines.hpp>
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
#include <chrono>
|
||||
|
||||
namespace ams {
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vapours/defines.hpp>
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
|
||||
#include <vapours/util/util_alignment.hpp>
|
||||
#include <vapours/util/util_size.hpp>
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../defines.hpp"
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
|
||||
namespace ams::util {
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../defines.hpp"
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
|
||||
namespace ams::util {
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../defines.hpp"
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
|
||||
namespace ams::util {
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../defines.hpp"
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
|
||||
namespace ams::util {
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../defines.hpp"
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
|
||||
namespace ams::util {
|
||||
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "util_parent_of_member.hpp"
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
#include <vapours/util/util_parent_of_member.hpp>
|
||||
|
||||
namespace ams::util {
|
||||
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
|
||||
#pragma once
|
||||
#include <freebsd/sys/tree.h>
|
||||
#include "util_parent_of_member.hpp"
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
#include <vapours/util/util_parent_of_member.hpp>
|
||||
|
||||
namespace ams::util {
|
||||
|
||||
|
|
|
@ -15,8 +15,9 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../defines.hpp"
|
||||
#include "util_typed_storage.hpp"
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
#include <vapours/util/util_typed_storage.hpp>
|
||||
|
||||
namespace ams::util {
|
||||
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
|
||||
/* Scope guard logic lovingly taken from Andrei Alexandrescu's "Systemic Error Handling in C++" */
|
||||
#pragma once
|
||||
#include "../defines.hpp"
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
|
||||
namespace ams::util {
|
||||
|
||||
|
@ -54,5 +55,5 @@ namespace ams::util {
|
|||
|
||||
}
|
||||
|
||||
#define SCOPE_GUARD ::ams::util::impl::ScopeGuardOnExit() + [&]() ALWAYS_INLINE_LAMBDA
|
||||
#define SCOPE_GUARD ::ams::util::impl::ScopeGuardOnExit() + [&]() ALWAYS_INLINE_LAMBDA
|
||||
#define ON_SCOPE_EXIT auto ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE_) = SCOPE_GUARD
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../defines.hpp"
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
|
||||
namespace ams::util {
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue