ams: revamp assertion system

This commit is contained in:
Michael Scire
2020-02-22 23:05:14 -08:00
parent 9572fb2ce3
commit 40400aee1f
168 changed files with 1014 additions and 696 deletions

View File

@@ -25,7 +25,7 @@ namespace ams::fatal::srv {
/* Event creator. */
Handle GetFatalDirtyEventReadableHandle() {
Event evt;
R_ASSERT(setsysBindFatalDirtyFlagEvent(&evt));
R_ABORT_UNLESS(setsysBindFatalDirtyFlagEvent(&evt));
return evt.revent;
}

View File

@@ -20,7 +20,7 @@ namespace ams::fatal::srv {
FatalEventManager::FatalEventManager() {
/* Just create all the events. */
for (size_t i = 0; i < FatalEventManager::NumFatalEvents; i++) {
R_ASSERT(eventCreate(&this->events[i], true));
R_ABORT_UNLESS(eventCreate(&this->events[i], true));
}
}

View File

@@ -76,27 +76,27 @@ void __appInit(void) {
hos::SetVersionForLibnx();
sm::DoWithSession([&]() {
R_ASSERT(setInitialize());
R_ASSERT(setsysInitialize());
R_ASSERT(pminfoInitialize());
R_ASSERT(i2cInitialize());
R_ASSERT(bpcInitialize());
R_ABORT_UNLESS(setInitialize());
R_ABORT_UNLESS(setsysInitialize());
R_ABORT_UNLESS(pminfoInitialize());
R_ABORT_UNLESS(i2cInitialize());
R_ABORT_UNLESS(bpcInitialize());
if (hos::GetVersion() >= hos::Version_800) {
R_ASSERT(clkrstInitialize());
R_ABORT_UNLESS(clkrstInitialize());
} else {
R_ASSERT(pcvInitialize());
R_ABORT_UNLESS(pcvInitialize());
}
R_ASSERT(lblInitialize());
R_ASSERT(psmInitialize());
R_ASSERT(spsmInitialize());
R_ASSERT(plInitialize());
R_ASSERT(gpioInitialize());
R_ASSERT(fsInitialize());
R_ABORT_UNLESS(lblInitialize());
R_ABORT_UNLESS(psmInitialize());
R_ABORT_UNLESS(spsmInitialize());
R_ABORT_UNLESS(plInitialize());
R_ABORT_UNLESS(gpioInitialize());
R_ABORT_UNLESS(fsInitialize());
});
R_ASSERT(fsdevMountSdmc());
R_ABORT_UNLESS(fsdevMountSdmc());
/* fatal cannot throw fatal, so don't do: ams::CheckApiVersion(); */
}
@@ -144,14 +144,14 @@ namespace {
int main(int argc, char **argv)
{
/* Load shared font. */
R_ASSERT(fatal::srv::font::InitializeSharedFont());
R_ABORT_UNLESS(fatal::srv::font::InitializeSharedFont());
/* Check whether we should throw fatal due to repair process. */
fatal::srv::CheckRepairStatus();
/* Create services. */
R_ASSERT((g_server_manager.RegisterServer<fatal::srv::PrivateService>(PrivateServiceName, PrivateMaxSessions)));
R_ASSERT((g_server_manager.RegisterServer<fatal::srv::UserService>(UserServiceName, UserMaxSessions)));
R_ABORT_UNLESS((g_server_manager.RegisterServer<fatal::srv::PrivateService>(PrivateServiceName, PrivateMaxSessions)));
R_ABORT_UNLESS((g_server_manager.RegisterServer<fatal::srv::UserService>(UserServiceName, UserMaxSessions)));
/* Add dirty event holder. */
/* TODO: s_server_manager.AddWaitable(ams::fatal::srv::GetFatalDirtyEvent()); */
@@ -167,7 +167,7 @@ int main(int argc, char **argv)
g_server_manager.AddUserWaitableHolder(signaled_holder);
} else {
/* A server/session was signaled. Have the manager handle it. */
R_ASSERT(g_server_manager.Process(signaled_holder));
R_ABORT_UNLESS(g_server_manager.Process(signaled_holder));
}
}

View File

@@ -39,8 +39,8 @@ namespace ams::fatal::srv {
public:
ServiceContext() {
this->context.ClearState();
R_ASSERT(eventCreate(&this->context.erpt_event, false));
R_ASSERT(eventCreate(&this->context.battery_event, false));
R_ABORT_UNLESS(eventCreate(&this->context.erpt_event, false));
R_ABORT_UNLESS(eventCreate(&this->context.battery_event, false));
this->has_thrown = false;
}

View File

@@ -42,8 +42,8 @@ namespace ams::fatal::srv {
public:
TaskThread() { /* ... */ }
void StartTask(ITask *task) {
R_ASSERT(this->thread.Initialize(&RunTaskImpl, task, task->GetStack(), task->GetStackSize(), TaskThreadPriority));
R_ASSERT(this->thread.Start());
R_ABORT_UNLESS(this->thread.Initialize(&RunTaskImpl, task, task->GetStack(), task->GetStackSize(), TaskThreadPriority));
R_ABORT_UNLESS(this->thread.Start());
}
};
@@ -57,7 +57,7 @@ namespace ams::fatal::srv {
public:
TaskManager() { /* ... */ }
void StartTask(ITask *task) {
AMS_ASSERT(this->task_count < MaxTasks);
AMS_ABORT_UNLESS(this->task_count < MaxTasks);
this->task_threads[this->task_count++].StartTask(task);
}
};

View File

@@ -182,7 +182,7 @@ namespace ams::fatal::srv {
/* Prepare screen for drawing. */
sm::DoWithSession([&]() {
R_ASSERT(PrepareScreenForDrawing());
R_ABORT_UNLESS(PrepareScreenForDrawing());
});
/* Dequeue a buffer. */