46 bool commitThreadExit =
false;
47 bool exitCurrentProcess =
false;
48 bool rebootSystem =
false;
49 Machine::ShutdownType shutdownType = Machine::ShutdownType::Halt;
50 bool userReturnTerminal =
false;
51 int processExitCode = 0;
55 const bool fromUserspace =
62 const size_t serviceNumber = syscallState.getSyscallService();
63#if PEDIGREE_BENCHMARK_SYSCALL_TIMING
64 if (fromUserspace && serviceNumber == linuxCompat) {
70 if (
LIKELY(serviceNumber < serviceEnd)) {
72 if (
m_Instance.acquireHandler(
static_cast<Service_t
>(serviceNumber), handler, action)) {
75 syscallState.setSyscallReturnValue(
m_Instance.dispatchHandler(handler, syscallState));
76 syscallState.setSyscallErrno(thread->
getErrno());
81#if HOSTED && PEDIGREE_HOSTED_SMOKE_TESTS
82 if (handled && action.kind != NoPostSyscallAction &&
93 const bool directUserTransition =
94 action.kind == ReturnFromEvent || action.kind == PopEventState ||
95 action.kind == RestoreProcessorState || action.kind == JumpToUserspace;
96 if (directUserTransition) {
98 PerProcessorScheduler::ProcessStopGateMode::DirectUserTransition);
101 userReturnTerminal =
true;
105 switch (action.kind) {
106 case TerminateCurrentThread:
107 commitThreadExit =
true;
109 case ExitCurrentProcess:
110 exitCurrentProcess =
true;
111 processExitCode =
static_cast<int>(action.value);
113 case ReturnFromEvent:
114 if (userReturnTerminal) {
121 if (!userReturnTerminal) {
125 case RestoreProcessorState:
126 if (!userReturnTerminal) {
127 FATAL(
"Processor-state restoration requested on hosted.");
130 case JumpToUserspace:
131 if (userReturnTerminal) {
138 action.state.getStackPointer());
141 shutdownType =
static_cast<Machine::ShutdownType
>(action.value);
143 case NoPostSyscallAction:
146 if (current && current->canSkipUserReturnWork()) {
157 if (!exitCurrentProcess && !rebootSystem) {
162 commitThreadExit =
true;
165 NOTICE(
"Unwind state exit at syscall return");
166 exitCurrentProcess =
true;
168 processExitCode = request.code;
169 processExitCause = request.cause;
179 system_reboot(shutdownType);
182 if (exitCurrentProcess) {
184 processExitCode, processExitCause);
186 if (commitThreadExit) {
uintptr_t syscall(Service_t service, uintptr_t function, uintptr_t p1, uintptr_t p2, uintptr_t p3, uintptr_t p4, uintptr_t p5)
static void jumpUser(volatile uintptr_t *pLock, uintptr_t address, uintptr_t stack, uintptr_t p1=0, uintptr_t p2=0, uintptr_t p3=0, uintptr_t p4=0) NORETURN