From 77081b4e1e024bdfeb0ac3244111a7e115c2ddb9 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 10 Nov 2022 07:09:32 +0200 Subject: [PATCH] Stability fixes (i hope); attempt to implement argc, argv, envp, auxv; Syscalls --- Architecture/aarch64/SystemCalls.cpp | 2 +- Architecture/amd64/SystemCalls.cpp | 2 +- ...dvancedProgrammableInterruptController.cpp | 4 +- .../amd64/cpu/SymmetricMultiprocessing.cpp | 28 +- Architecture/i686/SystemCalls.cpp | 2 +- .../i686/cpu/SymmetricMultiprocessing.cpp | 11 +- Core/{ => Crash}/CrashHandler.cpp | 235 +- Core/Crash/SFrame.cpp | 65 + Core/Crash/UserHandler.cpp | 17 + Core/Crash/chfcts.hpp | 44 + Core/Interrupts/IntManager.cpp | 2 +- Core/Lock.cpp | 4 +- Core/Memory/PhysicalMemoryManager.cpp | 2 + Core/Video/Display.cpp | 2 +- Execute/Spawn.cpp | 26 +- Fennix Kernel.code-workspace | 3 +- KConfig.cpp | 13 + KThread.cpp | 45 +- Kernel.cpp | 2 +- SystemCalls/Linux.cpp | 2409 +++++++++++++++++ SystemCalls/Native.cpp | 46 + SystemCalls/Syscalls.cpp | 25 +- Tasking/InterProcessCommunication.cpp | 5 +- Tasking/Task.cpp | 141 +- include/abi.h | 72 + include/assert.h | 28 +- include/cpu.hpp | 6 + include/exec.hpp | 2 +- include/kconfig.hpp | 1 + include/smp.hpp | 2 +- include/syscalls.hpp | 7 +- include/task.hpp | 20 +- include/types.h | 41 + kernel.h | 1 + syscalls.h | 12 + 35 files changed, 3116 insertions(+), 211 deletions(-) rename Core/{ => Crash}/CrashHandler.cpp (78%) create mode 100644 Core/Crash/SFrame.cpp create mode 100644 Core/Crash/UserHandler.cpp create mode 100644 Core/Crash/chfcts.hpp create mode 100644 SystemCalls/Linux.cpp create mode 100644 SystemCalls/Native.cpp create mode 100644 include/abi.h create mode 100644 syscalls.h diff --git a/Architecture/aarch64/SystemCalls.cpp b/Architecture/aarch64/SystemCalls.cpp index e8b0b0d6..a5f56ba7 100644 --- a/Architecture/aarch64/SystemCalls.cpp +++ b/Architecture/aarch64/SystemCalls.cpp @@ -7,7 +7,7 @@ extern "C" __attribute__((naked, used, no_stack_protector)) void SystemCallHandl } -extern "C" uint64_t SystemCallsHandler(SyscallsRegs *regs); +extern "C" uint64_t SystemCallsHandler(SyscallsFrame *regs); void InitializeSystemCalls() { diff --git a/Architecture/amd64/SystemCalls.cpp b/Architecture/amd64/SystemCalls.cpp index f9607b46..59c22d40 100644 --- a/Architecture/amd64/SystemCalls.cpp +++ b/Architecture/amd64/SystemCalls.cpp @@ -8,7 +8,7 @@ using namespace CPU::x64; // "Core/SystemCalls.cpp" -extern "C" uint64_t SystemCallsHandler(SyscallsRegs *regs); +extern "C" uint64_t SystemCallsHandler(SyscallsFrame *regs); extern "C" void SystemCallHandlerStub(); diff --git a/Architecture/amd64/cpu/AdvancedProgrammableInterruptController.cpp b/Architecture/amd64/cpu/AdvancedProgrammableInterruptController.cpp index 644c39cd..5a3f9fea 100644 --- a/Architecture/amd64/cpu/AdvancedProgrammableInterruptController.cpp +++ b/Architecture/amd64/cpu/AdvancedProgrammableInterruptController.cpp @@ -30,7 +30,9 @@ namespace APIC uint32_t APIC::Read(uint32_t Register) { - if (Register != APIC_ICRLO && Register != APIC_ICRHI) + if (Register != APIC_ICRLO && + Register != APIC_ICRHI && + Register != APIC_ID) debug("APIC::Read(%#lx) [x2=%d]", Register, x2APICSupported ? 1 : 0); if (x2APICSupported) { diff --git a/Architecture/amd64/cpu/SymmetricMultiprocessing.cpp b/Architecture/amd64/cpu/SymmetricMultiprocessing.cpp index ecedace3..7d6b3969 100644 --- a/Architecture/amd64/cpu/SymmetricMultiprocessing.cpp +++ b/Architecture/amd64/cpu/SymmetricMultiprocessing.cpp @@ -2,15 +2,12 @@ #include #include +#include #include #include "../../../kernel.h" -#if defined(__amd64__) -#include "../Architecture/amd64/acpi.hpp" -#include "../Architecture/amd64/cpu/apic.hpp" -#elif defined(__i386__) -#elif defined(__aarch64__) -#endif +#include "../acpi.hpp" +#include "apic.hpp" extern "C" uint64_t _trampoline_start, _trampoline_end; @@ -31,7 +28,24 @@ volatile bool CPUEnabled = false; static __attribute__((aligned(PAGE_SIZE))) CPUData CPUs[MAX_CPU] = {0}; CPUData *GetCPU(long id) { return &CPUs[id]; } -CPUData *GetCurrentCPU() { return (CPUData *)CPU::x64::rdmsr(CPU::x64::MSR_GS_BASE); } +CPUData *GetCurrentCPU() +{ + CPUData *data = (CPUData *)CPU::x64::rdmsr(CPU::x64::MSR_GS_BASE); + + if (data == nullptr && Interrupts::apic[0]) + data = &CPUs[((APIC::APIC *)Interrupts::apic[0])->Read(APIC::APIC_ID) >> 24]; + + if (data == nullptr) + return nullptr; // The caller should handle this. + + if (!data->IsActive) + { + error("CPU %d is not active!", data->ID); + return &CPUs[0]; + } + assert(data->Checksum == CPU_DATA_CHECKSUM); // This should never happen. + return data; +} extern "C" void StartCPU() { diff --git a/Architecture/i686/SystemCalls.cpp b/Architecture/i686/SystemCalls.cpp index 7f344a25..55ce0489 100644 --- a/Architecture/i686/SystemCalls.cpp +++ b/Architecture/i686/SystemCalls.cpp @@ -6,7 +6,7 @@ using namespace CPU::x32; -extern "C" uint32_t SystemCallsHandler(SyscallsRegs *regs); +extern "C" uint32_t SystemCallsHandler(SyscallsFrame *regs); void InitializeSystemCalls() { diff --git a/Architecture/i686/cpu/SymmetricMultiprocessing.cpp b/Architecture/i686/cpu/SymmetricMultiprocessing.cpp index b64644ed..ed41f7b6 100644 --- a/Architecture/i686/cpu/SymmetricMultiprocessing.cpp +++ b/Architecture/i686/cpu/SymmetricMultiprocessing.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include "../../../kernel.h" @@ -16,18 +17,12 @@ CPUData *GetCPU(uint64_t id) { return &CPUs[id]; } CPUData *GetCurrentCPU() { uint64_t ret = 0; - - if (!CPUs[ret].IsActive) + if (!(&CPUs[ret])->IsActive) { error("CPU %d is not active!", ret); return &CPUs[0]; } - - if (CPUs[ret].Checksum != CPU_DATA_CHECKSUM) - { - error("CPU %d data is corrupted!", ret); - return &CPUs[0]; - } + assert((&CPUs[ret])->Checksum == CPU_DATA_CHECKSUM); return &CPUs[ret]; } diff --git a/Core/CrashHandler.cpp b/Core/Crash/CrashHandler.cpp similarity index 78% rename from Core/CrashHandler.cpp rename to Core/Crash/CrashHandler.cpp index 675226b8..d7067fd5 100644 --- a/Core/CrashHandler.cpp +++ b/Core/Crash/CrashHandler.cpp @@ -1,4 +1,5 @@ -#include "crashhandler.hpp" +#include "../crashhandler.hpp" +#include "chfcts.hpp" #include #include @@ -7,87 +8,15 @@ #include #if defined(__amd64__) -#include "../Architecture/amd64/cpu/gdt.hpp" +#include "../../Architecture/amd64/cpu/gdt.hpp" #elif defined(__i386__) #elif defined(__aarch64__) #endif -#include "../kernel.h" - -#if defined(__amd64__) -void DivideByZeroExceptionHandler(CPU::x64::TrapFrame *Frame); -void DebugExceptionHandler(CPU::x64::TrapFrame *Frame); -void NonMaskableInterruptExceptionHandler(CPU::x64::TrapFrame *Frame); -void BreakpointExceptionHandler(CPU::x64::TrapFrame *Frame); -void OverflowExceptionHandler(CPU::x64::TrapFrame *Frame); -void BoundRangeExceptionHandler(CPU::x64::TrapFrame *Frame); -void InvalidOpcodeExceptionHandler(CPU::x64::TrapFrame *Frame); -void DeviceNotAvailableExceptionHandler(CPU::x64::TrapFrame *Frame); -void DoubleFaultExceptionHandler(CPU::x64::TrapFrame *Frame); -void CoprocessorSegmentOverrunExceptionHandler(CPU::x64::TrapFrame *Frame); -void InvalidTSSExceptionHandler(CPU::x64::TrapFrame *Frame); -void SegmentNotPresentExceptionHandler(CPU::x64::TrapFrame *Frame); -void StackFaultExceptionHandler(CPU::x64::TrapFrame *Frame); -void GeneralProtectionExceptionHandler(CPU::x64::TrapFrame *Frame); -void PageFaultExceptionHandler(CPU::x64::TrapFrame *Frame); -void x87FloatingPointExceptionHandler(CPU::x64::TrapFrame *Frame); -void AlignmentCheckExceptionHandler(CPU::x64::TrapFrame *Frame); -void MachineCheckExceptionHandler(CPU::x64::TrapFrame *Frame); -void SIMDFloatingPointExceptionHandler(CPU::x64::TrapFrame *Frame); -void VirtualizationExceptionHandler(CPU::x64::TrapFrame *Frame); -void SecurityExceptionHandler(CPU::x64::TrapFrame *Frame); -void UnknownExceptionHandler(CPU::x64::TrapFrame *Frame); -void UserModeExceptionHandler(CPU::x64::TrapFrame *Frame); -#endif +#include "../../kernel.h" namespace CrashHandler { - struct StackFrame - { - struct StackFrame *rbp; - uint64_t rip; - }; - - __attribute__((no_stack_protector)) void TraceFrames(CPU::x64::TrapFrame *Frame, int Count) - { - struct StackFrame *frames = (struct StackFrame *)Frame->rbp; // (struct StackFrame *)__builtin_frame_address(0); - debug("Stack tracing..."); - EHPrint("\e7981FC\nStack Trace:\n"); - if (!frames || !frames->rip || !frames->rbp) - { - EHPrint("\e2565CC%p", (void *)Frame->rip); - EHPrint("\e7925CC-"); - EHPrint("\eAA25CC%s", KernelSymbolTable->GetSymbolFromAddress(Frame->rip)); - EHPrint("\e7981FC <- Exception"); - EHPrint("\eFF0000\n< No stack trace available. >\n"); - } - else - { - EHPrint("\e2565CC%p", (void *)Frame->rip); - EHPrint("\e7925CC-"); - if (Frame->rip >= 0xFFFFFFFF80000000 && Frame->rip <= (uint64_t)&_kernel_end) - EHPrint("\eAA25CC%s", KernelSymbolTable->GetSymbolFromAddress(Frame->rip)); - else - EHPrint("Outside Kernel"); - EHPrint("\e7981FC <- Exception"); - for (int frame = 0; frame < Count; ++frame) - { - if (!frames->rip) - break; - EHPrint("\n\e2565CC%p", (void *)frames->rip); - EHPrint("\e7925CC-"); - if (frames->rip >= 0xFFFFFFFF80000000 && frames->rip <= (uint64_t)&_kernel_end) - EHPrint("\e25CCC9%s", KernelSymbolTable->GetSymbolFromAddress(frames->rip)); - else - EHPrint("\eFF4CA9Outside Kernel"); - - if (!Memory::Virtual().Check(frames->rbp)) - return; - frames = frames->rbp; - } - } - } - __attribute__((no_stack_protector)) void printfWrapper(char c, void *unused) { Display->Print(c, 255, true); @@ -104,26 +33,44 @@ namespace CrashHandler __attribute__((no_stack_protector)) void Handle(void *Data) { + CPU::Interrupts(CPU::Disable); #if defined(__amd64__) - CPU::x64::TrapFrame *Frame = (CPU::x64::TrapFrame *)Data; + CHArchTrapFrame *Frame = (CHArchTrapFrame *)Data; error("Exception: %#llx", Frame->InterruptNumber); if (Frame->cs != GDT_USER_CODE && Frame->cs != GDT_USER_DATA) { debug("Exception in kernel mode"); - CPU::Interrupts(CPU::Disable); Display->CreateBuffer(0, 0, 255); } else { debug("Exception in user mode"); - if (!GetCurrentCPU()->CurrentThread->Security.IsCritical) + CPUData *data = GetCurrentCPU(); + if (!data) { - UserModeExceptionHandler(Frame); - return; + EHPrint("\eFF0000Cannot get CPU data! This results in a kernel crash!"); + error("Cannot get CPU data! This results in a kernel crash!"); + error("This should never happen!"); } else - EHPrint("\eFF0000Init process crashed!"); + { + debug("CPU %ld data is valid", data->ID); + if (data->CurrentThread) + { + debug("Current thread is valid %#lx", data->CurrentThread); + if (!data->CurrentThread->Security.IsCritical) + { + debug("Current thread is not critical"); + UserModeExceptionHandler(Frame); + return; + } + else + { + EHPrint("\eFF0000Init process crashed!"); + } + } + } } debug("Reading control registers..."); @@ -267,8 +214,39 @@ namespace CrashHandler } } - EHPrint("\e7981FCTechnical Informations on CPU %lld:\n", GetCurrentCPU()->ID); - EHPrint("FS=%#llx GS=%#llx SS=%#llx CS=%#llx DS=%#llx\n", + CPUData *cpudata = GetCurrentCPU(); + + if (cpudata == nullptr) + { + EHPrint("\eFFA500Invalid CPU data!\n"); + for (long i = 0; i < MAX_CPU; i++) + { + cpudata = GetCPU(i); + if (cpudata != nullptr) + break; + if (i == MAX_CPU - 1) + { + EHPrint("\eFF0000No CPU data found!\n"); + cpudata = nullptr; + } + } + debug("CPU ptr %#lx", cpudata); + } + + if (cpudata != nullptr) + EHPrint("\e7981FCTechnical Informations on CPU %lld:\n", cpudata->ID); + + if (TaskManager && cpudata != nullptr) + { + EHPrint("\e7981FCCurrent Process: %s(%ld)\n", + cpudata->CurrentProcess->Name, + cpudata->CurrentProcess->ID); + EHPrint("\e7981FCCurrent Thread: %s(%ld)\n", + cpudata->CurrentThread->Name, + cpudata->CurrentThread->ID); + } + + EHPrint("\e7981FCFS=%#llx GS=%#llx SS=%#llx CS=%#llx DS=%#llx\n", CPU::x64::rdmsr(CPU::x64::MSR_FS_BASE), CPU::x64::rdmsr(CPU::x64::MSR_GS_BASE), Frame->ss, Frame->cs, Frame->ds); EHPrint("R8=%#llx R9=%#llx R10=%#llx R11=%#llx\n", Frame->r8, Frame->r9, Frame->r10, Frame->r11); @@ -358,7 +336,7 @@ namespace CrashHandler } #if defined(__amd64__) || defined(__i386__) -static const char *PagefaultDescriptions[] = { +static const char *PagefaultDescriptions[8] = { "Supervisory process tried to read a non-present page entry\n", "Supervisory process tried to read a page and caused a protection fault\n", "Supervisory process tried to write to a non-present page entry\n", @@ -370,70 +348,41 @@ static const char *PagefaultDescriptions[] = { #endif #if defined(__amd64__) -#define staticbuffer(name) char name[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - -__attribute__((no_stack_protector)) void DivideByZeroExceptionHandler(CPU::x64::TrapFrame *Frame) +__attribute__((no_stack_protector)) void DivideByZeroExceptionHandler(CHArchTrapFrame *Frame) { fixme("Divide by zero exception\n"); } -__attribute__((no_stack_protector)) void DebugExceptionHandler(CPU::x64::TrapFrame *Frame) +__attribute__((no_stack_protector)) void DebugExceptionHandler(CHArchTrapFrame *Frame) { CrashHandler::EHPrint("\eDD2920System crashed!\n"); CrashHandler::EHPrint("Kernel triggered debug exception.\n"); } -__attribute__((no_stack_protector)) void NonMaskableInterruptExceptionHandler(CPU::x64::TrapFrame *Frame) { fixme("NMI exception"); } -__attribute__((no_stack_protector)) void BreakpointExceptionHandler(CPU::x64::TrapFrame *Frame) { fixme("Breakpoint exception"); } -__attribute__((no_stack_protector)) void OverflowExceptionHandler(CPU::x64::TrapFrame *Frame) { fixme("Overflow exception"); } -__attribute__((no_stack_protector)) void BoundRangeExceptionHandler(CPU::x64::TrapFrame *Frame) { fixme("Bound range exception"); } -__attribute__((no_stack_protector)) void InvalidOpcodeExceptionHandler(CPU::x64::TrapFrame *Frame) +__attribute__((no_stack_protector)) void NonMaskableInterruptExceptionHandler(CHArchTrapFrame *Frame) { fixme("NMI exception"); } +__attribute__((no_stack_protector)) void BreakpointExceptionHandler(CHArchTrapFrame *Frame) { fixme("Breakpoint exception"); } +__attribute__((no_stack_protector)) void OverflowExceptionHandler(CHArchTrapFrame *Frame) { fixme("Overflow exception"); } +__attribute__((no_stack_protector)) void BoundRangeExceptionHandler(CHArchTrapFrame *Frame) { fixme("Bound range exception"); } +__attribute__((no_stack_protector)) void InvalidOpcodeExceptionHandler(CHArchTrapFrame *Frame) { CrashHandler::EHPrint("\eDD2920System crashed!\n"); CrashHandler::EHPrint("Kernel tried to execute an invalid opcode.\n"); } -__attribute__((no_stack_protector)) void DeviceNotAvailableExceptionHandler(CPU::x64::TrapFrame *Frame) { fixme("Device not available exception"); } -__attribute__((no_stack_protector)) void DoubleFaultExceptionHandler(CPU::x64::TrapFrame *Frame) { fixme("Double fault exception"); } -__attribute__((no_stack_protector)) void CoprocessorSegmentOverrunExceptionHandler(CPU::x64::TrapFrame *Frame) { fixme("Coprocessor segment overrun exception"); } -__attribute__((no_stack_protector)) void InvalidTSSExceptionHandler(CPU::x64::TrapFrame *Frame) { fixme("Invalid TSS exception"); } -__attribute__((no_stack_protector)) void SegmentNotPresentExceptionHandler(CPU::x64::TrapFrame *Frame) { fixme("Segment not present exception"); } -__attribute__((no_stack_protector)) void StackFaultExceptionHandler(CPU::x64::TrapFrame *Frame) +__attribute__((no_stack_protector)) void DeviceNotAvailableExceptionHandler(CHArchTrapFrame *Frame) { fixme("Device not available exception"); } +__attribute__((no_stack_protector)) void DoubleFaultExceptionHandler(CHArchTrapFrame *Frame) { fixme("Double fault exception"); } +__attribute__((no_stack_protector)) void CoprocessorSegmentOverrunExceptionHandler(CHArchTrapFrame *Frame) { fixme("Coprocessor segment overrun exception"); } +__attribute__((no_stack_protector)) void InvalidTSSExceptionHandler(CHArchTrapFrame *Frame) { fixme("Invalid TSS exception"); } +__attribute__((no_stack_protector)) void SegmentNotPresentExceptionHandler(CHArchTrapFrame *Frame) { fixme("Segment not present exception"); } +__attribute__((no_stack_protector)) void StackFaultExceptionHandler(CHArchTrapFrame *Frame) { - staticbuffer(descbuf); - staticbuffer(desc_ext); - staticbuffer(desc_table); - staticbuffer(desc_idx); - staticbuffer(desc_tmp); CPU::x64::SelectorErrorCode SelCode = {.raw = Frame->ErrorCode}; - switch (SelCode.Table) - { - case 0b00: - memcpy(desc_tmp, "GDT", 3); - break; - case 0b01: - memcpy(desc_tmp, "IDT", 3); - break; - case 0b10: - memcpy(desc_tmp, "LDT", 3); - break; - case 0b11: - memcpy(desc_tmp, "IDT", 3); - break; - default: - memcpy(desc_tmp, "Unknown", 7); - break; - } - debug("external:%d table:%d idx:%#x", SelCode.External, SelCode.Table, SelCode.Idx); - sprintf_(descbuf, "Stack segment fault at address %#lx", Frame->rip); - CrashHandler::EHPrint(descbuf); - sprintf_(desc_ext, "External: %d", SelCode.External); - CrashHandler::EHPrint(desc_ext); - sprintf_(desc_table, "Table: %d (%s)", SelCode.Table, desc_tmp); - CrashHandler::EHPrint(desc_table); - sprintf_(desc_idx, "%s Index: %#x", desc_tmp, SelCode.Idx); - CrashHandler::EHPrint(desc_idx); CrashHandler::EHPrint("\eDD2920System crashed!\n"); CrashHandler::EHPrint("More info about the exception:\n"); + CrashHandler::EHPrint("Stack segment fault at address %#lx\n", Frame->rip); + CrashHandler::EHPrint("External: %d\n", SelCode.External); + CrashHandler::EHPrint("Table: %d\n", SelCode.Table); + CrashHandler::EHPrint("Index: %#x\n", SelCode.Idx); + CrashHandler::EHPrint("Error code: %#lx\n", Frame->ErrorCode); } -__attribute__((no_stack_protector)) void GeneralProtectionExceptionHandler(CPU::x64::TrapFrame *Frame) +__attribute__((no_stack_protector)) void GeneralProtectionExceptionHandler(CHArchTrapFrame *Frame) { // staticbuffer(descbuf); // staticbuffer(desc_ext); @@ -466,7 +415,7 @@ __attribute__((no_stack_protector)) void GeneralProtectionExceptionHandler(CPU:: CrashHandler::EHPrint("Table: %d\n", SelCode.Table); CrashHandler::EHPrint("Index: %#x\n", SelCode.Idx); } -__attribute__((no_stack_protector)) void PageFaultExceptionHandler(CPU::x64::TrapFrame *Frame) +__attribute__((no_stack_protector)) void PageFaultExceptionHandler(CHArchTrapFrame *Frame) { CPU::x64::PageFaultErrorCode params = {.raw = (uint32_t)Frame->ErrorCode}; CrashHandler::EHPrint("\eDD2920System crashed!\n\eFFFFFF"); @@ -484,15 +433,15 @@ __attribute__((no_stack_protector)) void PageFaultExceptionHandler(CPU::x64::Tra else CrashHandler::EHPrint(PagefaultDescriptions[Frame->ErrorCode & 0b111]); } -__attribute__((no_stack_protector)) void x87FloatingPointExceptionHandler(CPU::x64::TrapFrame *Frame) { fixme("x87 floating point exception"); } -__attribute__((no_stack_protector)) void AlignmentCheckExceptionHandler(CPU::x64::TrapFrame *Frame) { fixme("Alignment check exception"); } -__attribute__((no_stack_protector)) void MachineCheckExceptionHandler(CPU::x64::TrapFrame *Frame) { fixme("Machine check exception"); } -__attribute__((no_stack_protector)) void SIMDFloatingPointExceptionHandler(CPU::x64::TrapFrame *Frame) { fixme("SIMD floating point exception"); } -__attribute__((no_stack_protector)) void VirtualizationExceptionHandler(CPU::x64::TrapFrame *Frame) { fixme("Virtualization exception"); } -__attribute__((no_stack_protector)) void SecurityExceptionHandler(CPU::x64::TrapFrame *Frame) { fixme("Security exception"); } -__attribute__((no_stack_protector)) void UnknownExceptionHandler(CPU::x64::TrapFrame *Frame) { fixme("Unknown exception"); } +__attribute__((no_stack_protector)) void x87FloatingPointExceptionHandler(CHArchTrapFrame *Frame) { fixme("x87 floating point exception"); } +__attribute__((no_stack_protector)) void AlignmentCheckExceptionHandler(CHArchTrapFrame *Frame) { fixme("Alignment check exception"); } +__attribute__((no_stack_protector)) void MachineCheckExceptionHandler(CHArchTrapFrame *Frame) { fixme("Machine check exception"); } +__attribute__((no_stack_protector)) void SIMDFloatingPointExceptionHandler(CHArchTrapFrame *Frame) { fixme("SIMD floating point exception"); } +__attribute__((no_stack_protector)) void VirtualizationExceptionHandler(CHArchTrapFrame *Frame) { fixme("Virtualization exception"); } +__attribute__((no_stack_protector)) void SecurityExceptionHandler(CHArchTrapFrame *Frame) { fixme("Security exception"); } +__attribute__((no_stack_protector)) void UnknownExceptionHandler(CHArchTrapFrame *Frame) { fixme("Unknown exception"); } -__attribute__((no_stack_protector)) void UserModeExceptionHandler(CPU::x64::TrapFrame *Frame) +__attribute__((no_stack_protector)) void UserModeExceptionHandler(CHArchTrapFrame *Frame) { CriticalSection cs; debug("Interrupts? %s.", cs.IsInterruptsEnabled() ? "Yes" : "No"); @@ -660,5 +609,9 @@ __attribute__((no_stack_protector)) void UserModeExceptionHandler(CPU::x64::Trap break; } } + error("End of report."); + CPU::Interrupts(CPU::Enable); + debug("Interrupts enabled back."); + return; } #endif diff --git a/Core/Crash/SFrame.cpp b/Core/Crash/SFrame.cpp new file mode 100644 index 00000000..29125933 --- /dev/null +++ b/Core/Crash/SFrame.cpp @@ -0,0 +1,65 @@ +#include "../crashhandler.hpp" +#include "chfcts.hpp" + +#include +#include +#include +#include +#include + +#if defined(__amd64__) +#include "../../Architecture/amd64/cpu/gdt.hpp" +#elif defined(__i386__) +#elif defined(__aarch64__) +#endif + +#include "../../kernel.h" + +namespace CrashHandler +{ + struct StackFrame + { + struct StackFrame *rbp; + uint64_t rip; + }; + + __attribute__((no_stack_protector)) void TraceFrames(CHArchTrapFrame *Frame, int Count) + { + struct StackFrame *frames = (struct StackFrame *)Frame->rbp; // (struct StackFrame *)__builtin_frame_address(0); + debug("Stack tracing..."); + EHPrint("\e7981FC\nStack Trace:\n"); + if (!frames || !frames->rip || !frames->rbp) + { + EHPrint("\e2565CC%p", (void *)Frame->rip); + EHPrint("\e7925CC-"); + EHPrint("\eAA25CC%s", KernelSymbolTable->GetSymbolFromAddress(Frame->rip)); + EHPrint("\e7981FC <- Exception"); + EHPrint("\eFF0000\n< No stack trace available. >\n"); + } + else + { + EHPrint("\e2565CC%p", (void *)Frame->rip); + EHPrint("\e7925CC-"); + if (Frame->rip >= 0xFFFFFFFF80000000 && Frame->rip <= (uint64_t)&_kernel_end) + EHPrint("\eAA25CC%s", KernelSymbolTable->GetSymbolFromAddress(Frame->rip)); + else + EHPrint("Outside Kernel"); + EHPrint("\e7981FC <- Exception"); + for (int frame = 0; frame < Count; ++frame) + { + if (!frames->rip) + break; + EHPrint("\n\e2565CC%p", (void *)frames->rip); + EHPrint("\e7925CC-"); + if (frames->rip >= 0xFFFFFFFF80000000 && frames->rip <= (uint64_t)&_kernel_end) + EHPrint("\e25CCC9%s", KernelSymbolTable->GetSymbolFromAddress(frames->rip)); + else + EHPrint("\eFF4CA9Outside Kernel"); + + if (!Memory::Virtual().Check(frames->rbp)) + return; + frames = frames->rbp; + } + } + } +} \ No newline at end of file diff --git a/Core/Crash/UserHandler.cpp b/Core/Crash/UserHandler.cpp new file mode 100644 index 00000000..89542240 --- /dev/null +++ b/Core/Crash/UserHandler.cpp @@ -0,0 +1,17 @@ +#include "../crashhandler.hpp" +#include "chfcts.hpp" + +#include +#include +#include +#include +#include + +#if defined(__amd64__) +#include "../../Architecture/amd64/cpu/gdt.hpp" +#elif defined(__i386__) +#elif defined(__aarch64__) +#endif + +#include "../../kernel.h" + diff --git a/Core/Crash/chfcts.hpp b/Core/Crash/chfcts.hpp new file mode 100644 index 00000000..26389acb --- /dev/null +++ b/Core/Crash/chfcts.hpp @@ -0,0 +1,44 @@ +#ifndef __FENNIX_KERNEL_CRASH_HANDLERS_FUNCTIONS_H__ +#define __FENNIX_KERNEL_CRASH_HANDLERS_FUNCTIONS_H__ + +#include +#include + +#if defined(__amd64__) +typedef struct CPU::x64::TrapFrame CHArchTrapFrame; +#elif defined(__i386__) +typedef struct CPU::x86::TrapFrame CHArchTrapFrame; +#elif defined(__aarch64__) +typedef struct CPU::aarch64::TrapFrame CHArchTrapFrame; +#endif + +namespace CrashHandler +{ + void TraceFrames(CHArchTrapFrame *Frame, int Count); +} + +void DivideByZeroExceptionHandler(CHArchTrapFrame *Frame); +void DebugExceptionHandler(CHArchTrapFrame *Frame); +void NonMaskableInterruptExceptionHandler(CHArchTrapFrame *Frame); +void BreakpointExceptionHandler(CHArchTrapFrame *Frame); +void OverflowExceptionHandler(CHArchTrapFrame *Frame); +void BoundRangeExceptionHandler(CHArchTrapFrame *Frame); +void InvalidOpcodeExceptionHandler(CHArchTrapFrame *Frame); +void DeviceNotAvailableExceptionHandler(CHArchTrapFrame *Frame); +void DoubleFaultExceptionHandler(CHArchTrapFrame *Frame); +void CoprocessorSegmentOverrunExceptionHandler(CHArchTrapFrame *Frame); +void InvalidTSSExceptionHandler(CHArchTrapFrame *Frame); +void SegmentNotPresentExceptionHandler(CHArchTrapFrame *Frame); +void StackFaultExceptionHandler(CHArchTrapFrame *Frame); +void GeneralProtectionExceptionHandler(CHArchTrapFrame *Frame); +void PageFaultExceptionHandler(CHArchTrapFrame *Frame); +void x87FloatingPointExceptionHandler(CHArchTrapFrame *Frame); +void AlignmentCheckExceptionHandler(CHArchTrapFrame *Frame); +void MachineCheckExceptionHandler(CHArchTrapFrame *Frame); +void SIMDFloatingPointExceptionHandler(CHArchTrapFrame *Frame); +void VirtualizationExceptionHandler(CHArchTrapFrame *Frame); +void SecurityExceptionHandler(CHArchTrapFrame *Frame); +void UnknownExceptionHandler(CHArchTrapFrame *Frame); +void UserModeExceptionHandler(CHArchTrapFrame *Frame); + +#endif // !__FENNIX_KERNEL_CRASH_HANDLERS_FUNCTIONS_H__ diff --git a/Core/Interrupts/IntManager.cpp b/Core/Interrupts/IntManager.cpp index b347e087..877e06d6 100644 --- a/Core/Interrupts/IntManager.cpp +++ b/Core/Interrupts/IntManager.cpp @@ -52,7 +52,7 @@ namespace Interrupts CoreData->Stack = (uint64_t)KernelAllocator.RequestPages(TO_PAGES(STACK_SIZE)) + STACK_SIZE; if (CoreData->Checksum != CPU_DATA_CHECKSUM) { - KPrint("CPU %d data it's corrupted!", Core); + KPrint("CPU %d checksum mismatch! %x != %x", Core, CoreData->Checksum, CPU_DATA_CHECKSUM); CPU::Stop(); } debug("Stack for core %d is %#lx (Address: %#lx)", Core, CoreData->Stack, CoreData->Stack - STACK_SIZE); diff --git a/Core/Lock.cpp b/Core/Lock.cpp index f0ed4b47..9028b1f1 100644 --- a/Core/Lock.cpp +++ b/Core/Lock.cpp @@ -11,7 +11,7 @@ extern "C" void DeadLockHandler(LockClass *Lock) { CPUData *CoreData = GetCurrentCPU(); long CCore = 0xdead; - if (CoreData) + if (CoreData != nullptr) CCore = CoreData->ID; warn("Potential deadlock in lock '%s' held by '%s' (%ld) [%#lx-%ld] [%ld->%ld]", Lock->GetLockData()->AttemptingToGet, @@ -35,7 +35,7 @@ int LockClass::Lock(const char *FunctionName) LockData.CurrentHolder = FunctionName; LockData.Count++; CPUData *CoreData = GetCurrentCPU(); - if (CoreData) + if (CoreData != nullptr) LockData.Core = CoreData->ID; CPU::MemBar::Barrier(); diff --git a/Core/Memory/PhysicalMemoryManager.cpp b/Core/Memory/PhysicalMemoryManager.cpp index f3a9b7c0..fd009bf8 100644 --- a/Core/Memory/PhysicalMemoryManager.cpp +++ b/Core/Memory/PhysicalMemoryManager.cpp @@ -265,9 +265,11 @@ namespace Memory trace("Reserving pages..."); this->ReservePages(0, MemorySize / PAGE_SIZE + 1); + trace("Unreserving usable pages..."); for (uint64_t i = 0; i < Info->Memory.Entries; i++) if (Info->Memory.Entry[i].Type == Usable) this->UnreservePages((void *)Info->Memory.Entry[i].BaseAddress, Info->Memory.Entry[i].Length / PAGE_SIZE + 1); + trace("Locking bitmap pages..."); this->ReservePages(0, 0x100); // Reserve between 0 and 0x100000. this->LockPages(PageBitmap.Buffer, PageBitmap.Size / PAGE_SIZE + 1); } diff --git a/Core/Video/Display.cpp b/Core/Video/Display.cpp index 81d3d4d6..0d756aab 100644 --- a/Core/Video/Display.cpp +++ b/Core/Video/Display.cpp @@ -13,7 +13,7 @@ namespace Video { char Display::Print(char Char, int Index, bool WriteToUART) { - SmartLock(PrintLock); + // SmartLock(PrintLock); if (this->ColorIteration) { diff --git a/Execute/Spawn.cpp b/Execute/Spawn.cpp index 3d30e82a..2be6c5cb 100644 --- a/Execute/Spawn.cpp +++ b/Execute/Spawn.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "../kernel.h" #include "../Fex.hpp" @@ -13,7 +14,7 @@ using namespace Tasking; namespace Execute { - SpawnData Spawn(char *Path, uint64_t Arg0, uint64_t Arg1) + SpawnData Spawn(char *Path, Vector &argv, Vector &envp) { SpawnData ret = {.Status = ExStatus::Unknown, .Process = nullptr, @@ -42,9 +43,11 @@ namespace Execute for (uint64_t i = 0; i < TO_PAGES(ExFile->Node->Length); i++) pva.Map((void *)((uint64_t)BaseImage + (i * PAGE_SIZE)), (void *)((uint64_t)BaseImage + (i * PAGE_SIZE)), Memory::PTFlag::RW | Memory::PTFlag::US); + Vector auxv; // TODO! + TCB *Thread = TaskManager->CreateThread(Process, (IP)FexHdr->Pointer, - Arg0, Arg1, + argv, envp, auxv, (IPOffset)BaseImage, TaskArchitecture::x64, TaskCompatibility::Native); @@ -130,9 +133,20 @@ namespace Execute memcpy(dst, ((char *)BaseImage) + pheader->p_offset, pheader->p_filesz); } + Vector auxv; + + auxv.push_back({.archaux = {.a_type = AT_PHDR, .a_un = {.a_val = (uint64_t)ELFHeader->e_phoff}}}); + auxv.push_back({.archaux = {.a_type = AT_PHENT, .a_un = {.a_val = (uint64_t)ELFHeader->e_phentsize}}}); + auxv.push_back({.archaux = {.a_type = AT_PHNUM, .a_un = {.a_val = (uint64_t)ELFHeader->e_phnum}}}); + auxv.push_back({.archaux = {.a_type = AT_PAGESZ, .a_un = {.a_val = (uint64_t)PAGE_SIZE}}}); + auxv.push_back({.archaux = {.a_type = AT_BASE, .a_un = {.a_val = (uint64_t)Offset}}}); + auxv.push_back({.archaux = {.a_type = AT_ENTRY, .a_un = {.a_val = (uint64_t)ELFHeader->e_entry + (uint64_t)Offset}}}); + auxv.push_back({.archaux = {.a_type = AT_PLATFORM, .a_un = {.a_val = (uint64_t) "x86_64"}}}); + auxv.push_back({.archaux = {.a_type = AT_EXECFN, .a_un = {.a_val = (uint64_t)Path}}}); + TCB *Thread = TaskManager->CreateThread(Process, (IP)ELFHeader->e_entry, - Arg0, Arg1, + argv, envp, auxv, (IPOffset)Offset, Arch, Comp); @@ -154,9 +168,13 @@ namespace Execute ret.Status = ExStatus::InvalidFileEntryPoint; goto Exit; } + + Vector auxv; + fixme("auxv"); + TCB *Thread = TaskManager->CreateThread(Process, (IP)EP, - Arg0, Arg1, + argv, envp, auxv, (IPOffset)BaseImage, Arch, Comp); diff --git a/Fennix Kernel.code-workspace b/Fennix Kernel.code-workspace index 260576f1..8b8506b3 100644 --- a/Fennix Kernel.code-workspace +++ b/Fennix Kernel.code-workspace @@ -19,7 +19,8 @@ "assert.h": "c", "cwalk.h": "c", "md5.h": "c", - "stdint.h": "c" + "stdint.h": "c", + "debug.h": "c" } } } \ No newline at end of file diff --git a/KConfig.cpp b/KConfig.cpp index 88cab3e4..a845af58 100644 --- a/KConfig.cpp +++ b/KConfig.cpp @@ -49,6 +49,12 @@ static struct cag_option ConfigOptions[] = { .value_name = "PATH", .description = "Path to init program"}, + {.identifier = 'o', + .access_letters = NULL, + .access_name = "ioc", + .value_name = "BOOL", + .description = "Enable Interrupts On Crash. If enabled, the navigation keys will be enabled on crash."}, + {.identifier = 'h', .access_letters = "h", .access_name = "help", @@ -335,6 +341,13 @@ ParseSuccess: KPrint("\eAAFFAAUsing %s as init program", value); break; } + case 'o': + { + value = cag_option_get_value(&context); + strcmp(value, "true") ? config.InterruptsOnCrash = false : config.InterruptsOnCrash = true; + KPrint("\eAAFFAAInterrupts on crash: %s", value); + break; + } case 'h': { KPrint("\n---------------------------------------------------------------------------\nUsage: kernel.fsys [OPTION]...\nKernel configuration."); diff --git a/KThread.cpp b/KThread.cpp index 4ee9b665..8a8fc2ac 100644 --- a/KThread.cpp +++ b/KThread.cpp @@ -47,49 +47,66 @@ void FetchDisks() void KernelMainThread() { + Vector argv; + Vector envp; + Vector auxv; + Tasking::TCB *CurrentWorker = nullptr; KPrint("Kernel Compiled at: %s %s with C++ Standard: %d", __DATE__, __TIME__, CPP_LANGUAGE_STANDARD); KPrint("C++ Language Version (__cplusplus): %ld", __cplusplus); TaskManager->GetCurrentThread()->SetPriority(1); - CurrentWorker = TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)StartFilesystem); + CurrentWorker = TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)StartFilesystem, argv, envp, auxv); CurrentWorker->Rename("Disk"); CurrentWorker->SetPriority(100); TaskManager->WaitForThread(CurrentWorker); - CurrentWorker = TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)LoadDrivers); + CurrentWorker = TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)LoadDrivers, argv, envp, auxv); CurrentWorker->Rename("Drivers"); CurrentWorker->SetPriority(100); TaskManager->WaitForThread(CurrentWorker); - CurrentWorker = TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)FetchDisks); + CurrentWorker = TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)FetchDisks, argv, envp, auxv); CurrentWorker->Rename("Fetch Disks"); CurrentWorker->SetPriority(100); TaskManager->WaitForThread(CurrentWorker); - KPrint("Waiting for userspace process to start..."); + KPrint("Setting up userspace..."); - Vector argv; - int argc = 0; + envp.clear(); + envp.push_back("PATH=/system:/system/bin"); + envp.push_back("TERM=tty"); + envp.push_back("HOME=/"); + envp.push_back("USER=root"); + envp.push_back("SHELL=/system/bin/sh"); + envp.push_back("PWD=/"); + envp.push_back("LANG=en_US.UTF-8"); + envp.push_back("TZ=UTC"); - /* ... */ - argv.push_back((char *)"--start"); - /* ... */ - - argv.push_back(nullptr); - argc = argv.size() - 1; + argv.clear(); + argv.push_back("--init"); + argv.push_back("--critical"); // TODO: Untested! - Execute::SpawnData ret = Execute::Spawn(Config.InitPath, argc, (uint64_t)argv.data()); + bool ien = CPU::Interrupts(CPU::Check); + CPU::Interrupts(CPU::Disable); + Execute::SpawnData ret = Execute::Spawn(Config.InitPath, argv, envp); if (ret.Status != Execute::ExStatus::OK) { KPrint("\eE85230Failed to start %s! Code: %d", Config.InitPath, ret.Status); - CPU::Halt(true); + if (ien) + CPU::Interrupts(CPU::Enable); + goto Exit; } ret.Thread->SetCritical(true); + if (ien) + CPU::Interrupts(CPU::Enable); + KPrint("Waiting for \e22AAFF%s\eCCCCCC to start...", Config.InitPath); TaskManager->WaitForThread(ret.Thread); KPrint("\eE85230Userspace process exited with code %d", ret.Thread->GetExitCode()); error("Userspace process exited with code %d (%#x)", ret.Thread->GetExitCode(), ret.Thread->GetExitCode()); +Exit: + KPrint("Well, that's it. I'm going to sleep now."); CPU::Halt(true); } diff --git a/Kernel.cpp b/Kernel.cpp index 1ea91bca..11e4045d 100644 --- a/Kernel.cpp +++ b/Kernel.cpp @@ -26,7 +26,7 @@ KernelConfig Config; Time::Clock BootClock; // For the Display class. Printing on first buffer as default. -extern "C" void putchar(char c) { Display->Print(c, 0); } +EXTERNC void putchar(char c) { Display->Print(c, 0); } EXTERNC void KPrint(const char *Format, ...) { diff --git a/SystemCalls/Linux.cpp b/SystemCalls/Linux.cpp new file mode 100644 index 00000000..094ed20a --- /dev/null +++ b/SystemCalls/Linux.cpp @@ -0,0 +1,2409 @@ +#include + +#include +#include + +#include "../kernel.h" + +#define internal_unimpl(a, b, c, d, e, f, g) \ + { \ + fixme("Unimplemented Syscall: %lld %lld %lld %lld %lld %lld %lld", a, b, c, d, e, f, g); \ + } + +#define stub(a, b, c, d, e, f, g) \ + { \ + fixme("( %lld %lld %lld %lld %lld %lld %lld ) stub", a, b, c, d, e, f, g); \ + } + +static uint64_t sys_read(unsigned int fd, char *buf, size_t count) +{ + fixme("read( %p %p %ld )", fd, buf, count); + return -1; +} + +static uint64_t sys_write(unsigned int fd, const char *buf, size_t count) +{ + fixme("write( %p %p %ld )", fd, buf, count); + return -1; +} + +static uint64_t sys_open(const char *filename, int flags, unsigned short mode) +{ + fixme("open( %s %d %d )", filename, flags, mode); + return -1; +} + +static uint64_t sys_close(unsigned int fd) +{ + fixme("close( %d )", fd); + return -1; +} + +static uint64_t sys_stat(const char *filename, void *statbuf) +{ + fixme("stat( %s %p )", filename, statbuf); + return -1; +} + +static uint64_t sys_fstat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_lstat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_poll(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_lseek(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mmap(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mprotect(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_munmap(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_brk(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_rt_sigaction(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_rt_sigprocmask(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_rt_sigreturn(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_ioctl(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_pread64(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_pwrite64(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_readv(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_writev(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_access(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_pipe(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_select(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sched_yield(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mremap(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_msync(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mincore(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_madvise(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_shmget(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_shmat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_shmctl(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_dup(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_dup2(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_pause(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_nanosleep(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getitimer(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_alarm(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_setitimer(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getpid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sendfile(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_socket(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_connect(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_accept(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sendto(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_recvfrom(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sendmsg(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_recvmsg(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_shutdown(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_bind(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_listen(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getsockname(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getpeername(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_socketpair(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_setsockopt(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getsockopt(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_clone(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_fork(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_vfork(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static int sys_execve(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_exit(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_wait4(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_kill(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_uname(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_semget(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_semop(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_semctl(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_shmdt(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_msgget(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_msgsnd(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_msgrcv(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_msgctl(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_fcntl(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_flock(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_fsync(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_fdatasync(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_truncate(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_ftruncate(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getdents(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getcwd(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_chdir(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_fchdir(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_rename(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mkdir(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_rmdir(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_creat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_link(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_unlink(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_symlink(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_readlink(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_chmod(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_fchmod(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_chown(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_fchown(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_lchown(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_umask(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_gettimeofday(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getrlimit(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getrusage(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sysinfo(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_times(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_ptrace(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static unsigned int sys_getuid(void) +{ + stub(0, 0, 0, 0, 0, 0, 0); + return 0; +} + +static uint64_t sys_syslog(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static unsigned int sys_getgid(void) +{ + stub(0, 0, 0, 0, 0, 0, 0); + return 0; +} + +static uint64_t sys_setuid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_setgid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static unsigned int sys_geteuid(void) +{ + stub(0, 0, 0, 0, 0, 0, 0); + return 0; +} + +static unsigned int sys_getegid(void) +{ + stub(0, 0, 0, 0, 0, 0, 0); + return 0; +} + +static uint64_t sys_setpgid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getppid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getpgrp(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_setsid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_setreuid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_setregid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getgroups(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_setgroups(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_setresuid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getresuid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_setresgid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getresgid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getpgid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_setfsuid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_setfsgid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getsid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_capget(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_capset(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_rt_sigpending(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_rt_sigtimedwait(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_rt_sigqueueinfo(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_rt_sigsuspend(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sigaltstack(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_utime(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mknod(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_uselib(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_personality(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_ustat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_statfs(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_fstatfs(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sysfs(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getpriority(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_setpriority(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sched_setparam(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sched_getparam(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sched_setscheduler(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sched_getscheduler(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sched_get_priority_max(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sched_get_priority_min(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sched_rr_get_interval(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mlock(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_munlock(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mlockall(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_munlockall(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_vhangup(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_modify_ldt(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_pivot_root(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys__sysctl(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_prctl(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_arch_prctl(int code, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5) +{ + trace("( code=%#lx, arg2=%lx, arg3=%lx, arg4=%lx, arg5=%lx )", code, arg2, arg3, arg4, arg5); + + switch (code) + { + case 0x1001: // ARCH_SET_GS + CPU::x64::wrmsr(CPU::x64::MSRID::MSR_GS_BASE, arg2); + return arg2; + case 0x1002: // ARCH_SET_FS + CPU::x64::wrmsr(CPU::x64::MSRID::MSR_FS_BASE, arg2); + return arg2; + case 0x1003: // ARCH_GET_FS + return CPU::x64::rdmsr(CPU::x64::MSRID::MSR_FS_BASE); + case 0x1004: // ARCH_GET_GS + return CPU::x64::rdmsr(CPU::x64::MSRID::MSR_GS_BASE); + default: + warn("Unimplemented prctl code %#lx (arg2=%lx, arg3=%lx, arg4=%lx, arg5=%lx)", code, arg2, arg3, arg4, arg5); + return -1; /* EINVAL */ + } + return -1; +} + +static uint64_t sys_adjtimex(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_setrlimit(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_chroot(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sync(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_acct(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_settimeofday(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mount(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_umount2(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_swapon(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_swapoff(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_reboot(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sethostname(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_setdomainname(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_iopl(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_ioperm(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_create_module(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_init_module(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_delete_module(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_get_kernel_syms(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_query_module(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_quotactl(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_nfsservctl(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getpmsg(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_putpmsg(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_afs_syscall(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_tuxcall(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_security(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_gettid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_readahead(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_setxattr(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_lsetxattr(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_fsetxattr(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getxattr(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_lgetxattr(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_fgetxattr(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_listxattr(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_llistxattr(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_flistxattr(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_removexattr(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_lremovexattr(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_fremovexattr(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_tkill(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_time(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_futex(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sched_setaffinity(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sched_getaffinity(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_set_thread_area(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_io_setup(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_io_destroy(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_io_getevents(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_io_submit(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_io_cancel(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_get_thread_area(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_lookup_dcookie(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_epoll_create(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_epoll_ctl_old(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_epoll_wait_old(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_remap_file_pages(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getdents64(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_set_tid_address(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_restart_syscall(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_semtimedop(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_fadvise64(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_timer_create(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_timer_settime(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_timer_gettime(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_timer_getoverrun(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_timer_delete(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_clock_settime(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_clock_gettime(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_clock_getres(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_clock_nanosleep(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_exit_group(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_epoll_wait(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_epoll_ctl(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_tgkill(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_utimes(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_vserver(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mbind(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_set_mempolicy(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_get_mempolicy(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mq_open(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mq_unlink(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mq_timedsend(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mq_timedreceive(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mq_notify(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mq_getsetattr(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_kexec_load(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_waitid(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_add_key(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_request_key(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_keyctl(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_ioprio_set(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_ioprio_get(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_inotify_init(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_inotify_add_watch(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_inotify_rm_watch(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_migrate_pages(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_openat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mkdirat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_mknodat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_fchownat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_futimesat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_newfstatat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_unlinkat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_renameat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_linkat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_symlinkat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_readlinkat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_fchmodat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_faccessat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_pselect6(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_ppoll(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_unshare(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_set_robust_list(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_get_robust_list(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_splice(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_tee(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sync_file_range(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_vmsplice(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_move_pages(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_utimensat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_epoll_pwait(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_signalfd(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_timerfd_create(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_eventfd(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_fallocate(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_timerfd_settime(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_timerfd_gettime(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_accept4(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_signalfd4(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_eventfd2(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_epoll_create1(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_dup3(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_pipe2(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_inotify_init1(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_preadv(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_pwritev(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_rt_tgsigqueueinfo(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_perf_event_open(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_recvmmsg(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_fanotify_init(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_fanotify_mark(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_prlimit64(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_name_to_handle_at(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_open_by_handle_at(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_clock_adjtime(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_syncfs(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sendmmsg(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_setns(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getcpu(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_process_vm_readv(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_process_vm_writev(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_kcmp(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_finit_module(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sched_setattr(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_sched_getattr(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_renameat2(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_seccomp(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_getrandom(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_memfd_create(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_kexec_file_load(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t sys_bpf(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t stub_execveat(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t userfaultfd(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t membarrier(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t mlock2(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t copy_file_range(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t preadv2(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t pwritev2(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t pkey_mprotect(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t pkey_alloc(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t pkey_free(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t statx(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t io_pgetevents(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t rseq(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +static uint64_t pkey_mprotect_(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) +{ + internal_unimpl(a, b, c, d, e, f, g); + return -1; +} + +// Syscalls list: https://filippo.io/linux-syscall-table/ https://blog.rchapman.org/posts/Linux_System_Call_Table_for_x86_64/ + +static void *LinuxSyscallsTable[] = { + [0] = (void *)sys_read, + [1] = (void *)sys_write, + [2] = (void *)sys_open, + [3] = (void *)sys_close, + [4] = (void *)sys_stat, + [5] = (void *)sys_fstat, + [6] = (void *)sys_lstat, + [7] = (void *)sys_poll, + [8] = (void *)sys_lseek, + [9] = (void *)sys_mmap, + [10] = (void *)sys_mprotect, + [11] = (void *)sys_munmap, + [12] = (void *)sys_brk, + [13] = (void *)sys_rt_sigaction, + [14] = (void *)sys_rt_sigprocmask, + [15] = (void *)sys_rt_sigreturn, + [16] = (void *)sys_ioctl, + [17] = (void *)sys_pread64, + [18] = (void *)sys_pwrite64, + [19] = (void *)sys_readv, + [20] = (void *)sys_writev, + [21] = (void *)sys_access, + [22] = (void *)sys_pipe, + [23] = (void *)sys_select, + [24] = (void *)sys_sched_yield, + [25] = (void *)sys_mremap, + [26] = (void *)sys_msync, + [27] = (void *)sys_mincore, + [28] = (void *)sys_madvise, + [29] = (void *)sys_shmget, + [30] = (void *)sys_shmat, + [31] = (void *)sys_shmctl, + [32] = (void *)sys_dup, + [33] = (void *)sys_dup2, + [34] = (void *)sys_pause, + [35] = (void *)sys_nanosleep, + [36] = (void *)sys_getitimer, + [37] = (void *)sys_alarm, + [38] = (void *)sys_setitimer, + [39] = (void *)sys_getpid, + [40] = (void *)sys_sendfile, + [41] = (void *)sys_socket, + [42] = (void *)sys_connect, + [43] = (void *)sys_accept, + [44] = (void *)sys_sendto, + [45] = (void *)sys_recvfrom, + [46] = (void *)sys_sendmsg, + [47] = (void *)sys_recvmsg, + [48] = (void *)sys_shutdown, + [49] = (void *)sys_bind, + [50] = (void *)sys_listen, + [51] = (void *)sys_getsockname, + [52] = (void *)sys_getpeername, + [53] = (void *)sys_socketpair, + [54] = (void *)sys_setsockopt, + [55] = (void *)sys_getsockopt, + [56] = (void *)sys_clone, + [57] = (void *)sys_fork, + [58] = (void *)sys_vfork, + [59] = (void *)sys_execve, + [60] = (void *)sys_exit, + [61] = (void *)sys_wait4, + [62] = (void *)sys_kill, + [63] = (void *)sys_uname, + [64] = (void *)sys_semget, + [65] = (void *)sys_semop, + [66] = (void *)sys_semctl, + [67] = (void *)sys_shmdt, + [68] = (void *)sys_msgget, + [69] = (void *)sys_msgsnd, + [70] = (void *)sys_msgrcv, + [71] = (void *)sys_msgctl, + [72] = (void *)sys_fcntl, + [73] = (void *)sys_flock, + [74] = (void *)sys_fsync, + [75] = (void *)sys_fdatasync, + [76] = (void *)sys_truncate, + [77] = (void *)sys_ftruncate, + [78] = (void *)sys_getdents, + [79] = (void *)sys_getcwd, + [80] = (void *)sys_chdir, + [81] = (void *)sys_fchdir, + [82] = (void *)sys_rename, + [83] = (void *)sys_mkdir, + [84] = (void *)sys_rmdir, + [85] = (void *)sys_creat, + [86] = (void *)sys_link, + [87] = (void *)sys_unlink, + [88] = (void *)sys_symlink, + [89] = (void *)sys_readlink, + [90] = (void *)sys_chmod, + [91] = (void *)sys_fchmod, + [92] = (void *)sys_chown, + [93] = (void *)sys_fchown, + [94] = (void *)sys_lchown, + [95] = (void *)sys_umask, + [96] = (void *)sys_gettimeofday, + [97] = (void *)sys_getrlimit, + [98] = (void *)sys_getrusage, + [99] = (void *)sys_sysinfo, + [100] = (void *)sys_times, + [101] = (void *)sys_ptrace, + [102] = (void *)sys_getuid, + [103] = (void *)sys_syslog, + [104] = (void *)sys_getgid, + [105] = (void *)sys_setuid, + [106] = (void *)sys_setgid, + [107] = (void *)sys_geteuid, + [108] = (void *)sys_getegid, + [109] = (void *)sys_setpgid, + [110] = (void *)sys_getppid, + [111] = (void *)sys_getpgrp, + [112] = (void *)sys_setsid, + [113] = (void *)sys_setreuid, + [114] = (void *)sys_setregid, + [115] = (void *)sys_getgroups, + [116] = (void *)sys_setgroups, + [117] = (void *)sys_setresuid, + [118] = (void *)sys_getresuid, + [119] = (void *)sys_setresgid, + [120] = (void *)sys_getresgid, + [121] = (void *)sys_getpgid, + [122] = (void *)sys_setfsuid, + [123] = (void *)sys_setfsgid, + [124] = (void *)sys_getsid, + [125] = (void *)sys_capget, + [126] = (void *)sys_capset, + [127] = (void *)sys_rt_sigpending, + [128] = (void *)sys_rt_sigtimedwait, + [129] = (void *)sys_rt_sigqueueinfo, + [130] = (void *)sys_rt_sigsuspend, + [131] = (void *)sys_sigaltstack, + [132] = (void *)sys_utime, + [133] = (void *)sys_mknod, + [134] = (void *)sys_uselib, + [135] = (void *)sys_personality, + [136] = (void *)sys_ustat, + [137] = (void *)sys_statfs, + [138] = (void *)sys_fstatfs, + [139] = (void *)sys_sysfs, + [140] = (void *)sys_getpriority, + [141] = (void *)sys_setpriority, + [142] = (void *)sys_sched_setparam, + [143] = (void *)sys_sched_getparam, + [144] = (void *)sys_sched_setscheduler, + [145] = (void *)sys_sched_getscheduler, + [146] = (void *)sys_sched_get_priority_max, + [147] = (void *)sys_sched_get_priority_min, + [148] = (void *)sys_sched_rr_get_interval, + [149] = (void *)sys_mlock, + [150] = (void *)sys_munlock, + [151] = (void *)sys_mlockall, + [152] = (void *)sys_munlockall, + [153] = (void *)sys_vhangup, + [154] = (void *)sys_modify_ldt, + [155] = (void *)sys_pivot_root, + [156] = (void *)sys__sysctl, + [157] = (void *)sys_prctl, + [158] = (void *)sys_arch_prctl, + [159] = (void *)sys_adjtimex, + [160] = (void *)sys_setrlimit, + [161] = (void *)sys_chroot, + [162] = (void *)sys_sync, + [163] = (void *)sys_acct, + [164] = (void *)sys_settimeofday, + [165] = (void *)sys_mount, + [166] = (void *)sys_umount2, + [167] = (void *)sys_swapon, + [168] = (void *)sys_swapoff, + [169] = (void *)sys_reboot, + [170] = (void *)sys_sethostname, + [171] = (void *)sys_setdomainname, + [172] = (void *)sys_iopl, + [173] = (void *)sys_ioperm, + [174] = (void *)sys_create_module, + [175] = (void *)sys_init_module, + [176] = (void *)sys_delete_module, + [177] = (void *)sys_get_kernel_syms, + [178] = (void *)sys_query_module, + [179] = (void *)sys_quotactl, + [180] = (void *)sys_nfsservctl, + [181] = (void *)sys_getpmsg, + [182] = (void *)sys_putpmsg, + [183] = (void *)sys_afs_syscall, + [184] = (void *)sys_tuxcall, + [185] = (void *)sys_security, + [186] = (void *)sys_gettid, + [187] = (void *)sys_readahead, + [188] = (void *)sys_setxattr, + [189] = (void *)sys_lsetxattr, + [190] = (void *)sys_fsetxattr, + [191] = (void *)sys_getxattr, + [192] = (void *)sys_lgetxattr, + [193] = (void *)sys_fgetxattr, + [194] = (void *)sys_listxattr, + [195] = (void *)sys_llistxattr, + [196] = (void *)sys_flistxattr, + [197] = (void *)sys_removexattr, + [198] = (void *)sys_lremovexattr, + [199] = (void *)sys_fremovexattr, + [200] = (void *)sys_tkill, + [201] = (void *)sys_time, + [202] = (void *)sys_futex, + [203] = (void *)sys_sched_setaffinity, + [204] = (void *)sys_sched_getaffinity, + [205] = (void *)sys_set_thread_area, + [206] = (void *)sys_io_setup, + [207] = (void *)sys_io_destroy, + [208] = (void *)sys_io_getevents, + [209] = (void *)sys_io_submit, + [210] = (void *)sys_io_cancel, + [211] = (void *)sys_get_thread_area, + [212] = (void *)sys_lookup_dcookie, + [213] = (void *)sys_epoll_create, + [214] = (void *)sys_epoll_ctl_old, + [215] = (void *)sys_epoll_wait_old, + [216] = (void *)sys_remap_file_pages, + [217] = (void *)sys_getdents64, + [218] = (void *)sys_set_tid_address, + [219] = (void *)sys_restart_syscall, + [220] = (void *)sys_semtimedop, + [221] = (void *)sys_fadvise64, + [222] = (void *)sys_timer_create, + [223] = (void *)sys_timer_settime, + [224] = (void *)sys_timer_gettime, + [225] = (void *)sys_timer_getoverrun, + [226] = (void *)sys_timer_delete, + [227] = (void *)sys_clock_settime, + [228] = (void *)sys_clock_gettime, + [229] = (void *)sys_clock_getres, + [230] = (void *)sys_clock_nanosleep, + [231] = (void *)sys_exit_group, + [232] = (void *)sys_epoll_wait, + [233] = (void *)sys_epoll_ctl, + [234] = (void *)sys_tgkill, + [235] = (void *)sys_utimes, + [236] = (void *)sys_vserver, + [237] = (void *)sys_mbind, + [238] = (void *)sys_set_mempolicy, + [239] = (void *)sys_get_mempolicy, + [240] = (void *)sys_mq_open, + [241] = (void *)sys_mq_unlink, + [242] = (void *)sys_mq_timedsend, + [243] = (void *)sys_mq_timedreceive, + [244] = (void *)sys_mq_notify, + [245] = (void *)sys_mq_getsetattr, + [246] = (void *)sys_kexec_load, + [247] = (void *)sys_waitid, + [248] = (void *)sys_add_key, + [249] = (void *)sys_request_key, + [250] = (void *)sys_keyctl, + [251] = (void *)sys_ioprio_set, + [252] = (void *)sys_ioprio_get, + [253] = (void *)sys_inotify_init, + [254] = (void *)sys_inotify_add_watch, + [255] = (void *)sys_inotify_rm_watch, + [256] = (void *)sys_migrate_pages, + [257] = (void *)sys_openat, + [258] = (void *)sys_mkdirat, + [259] = (void *)sys_mknodat, + [260] = (void *)sys_fchownat, + [261] = (void *)sys_futimesat, + [262] = (void *)sys_newfstatat, + [263] = (void *)sys_unlinkat, + [264] = (void *)sys_renameat, + [265] = (void *)sys_linkat, + [266] = (void *)sys_symlinkat, + [267] = (void *)sys_readlinkat, + [268] = (void *)sys_fchmodat, + [269] = (void *)sys_faccessat, + [270] = (void *)sys_pselect6, + [271] = (void *)sys_ppoll, + [272] = (void *)sys_unshare, + [273] = (void *)sys_set_robust_list, + [274] = (void *)sys_get_robust_list, + [275] = (void *)sys_splice, + [276] = (void *)sys_tee, + [277] = (void *)sys_sync_file_range, + [278] = (void *)sys_vmsplice, + [279] = (void *)sys_move_pages, + [280] = (void *)sys_utimensat, + [281] = (void *)sys_epoll_pwait, + [282] = (void *)sys_signalfd, + [283] = (void *)sys_timerfd_create, + [284] = (void *)sys_eventfd, + [285] = (void *)sys_fallocate, + [286] = (void *)sys_timerfd_settime, + [287] = (void *)sys_timerfd_gettime, + [288] = (void *)sys_accept4, + [289] = (void *)sys_signalfd4, + [290] = (void *)sys_eventfd2, + [291] = (void *)sys_epoll_create1, + [292] = (void *)sys_dup3, + [293] = (void *)sys_pipe2, + [294] = (void *)sys_inotify_init1, + [295] = (void *)sys_preadv, + [296] = (void *)sys_pwritev, + [297] = (void *)sys_rt_tgsigqueueinfo, + [298] = (void *)sys_perf_event_open, + [299] = (void *)sys_recvmmsg, + [300] = (void *)sys_fanotify_init, + [301] = (void *)sys_fanotify_mark, + [302] = (void *)sys_prlimit64, + [303] = (void *)sys_name_to_handle_at, + [304] = (void *)sys_open_by_handle_at, + [305] = (void *)sys_clock_adjtime, + [306] = (void *)sys_syncfs, + [307] = (void *)sys_sendmmsg, + [308] = (void *)sys_setns, + [309] = (void *)sys_getcpu, + [310] = (void *)sys_process_vm_readv, + [311] = (void *)sys_process_vm_writev, + [312] = (void *)sys_kcmp, + [313] = (void *)sys_finit_module, + [314] = (void *)sys_sched_setattr, + [315] = (void *)sys_sched_getattr, + [316] = (void *)sys_renameat2, + [317] = (void *)sys_seccomp, + [318] = (void *)sys_getrandom, + [319] = (void *)sys_memfd_create, + [320] = (void *)sys_kexec_file_load, + [321] = (void *)sys_bpf, + [322] = (void *)stub_execveat, + [323] = (void *)userfaultfd, + [324] = (void *)membarrier, + [325] = (void *)mlock2, + [326] = (void *)copy_file_range, + [327] = (void *)preadv2, + [328] = (void *)pwritev2, + [329] = (void *)pkey_mprotect, + [330] = (void *)pkey_alloc, + [331] = (void *)pkey_free, + [332] = (void *)statx, + [333] = (void *)io_pgetevents, + [334] = (void *)rseq, + [335] = (void *)pkey_mprotect_, +}; + +uint64_t HandleLinuxSyscalls(SyscallsFrame *Frame) +{ + if (Frame->rax > sizeof(LinuxSyscallsTable)) + { + fixme("Syscall %lld not implemented", Frame->rax); + return -1; + } + + uint64_t (*call)(uint64_t, ...) = reinterpret_cast(LinuxSyscallsTable[Frame->rax]); + if (!call) + { + error("Syscall %#llx failed.", Frame->rax); + return -1; + } + uint64_t ret = call(Frame->rdi, Frame->rsi, Frame->rdx, Frame->r10, Frame->r8, Frame->r9); + Frame->rax = ret; + return ret; +} diff --git a/SystemCalls/Native.cpp b/SystemCalls/Native.cpp new file mode 100644 index 00000000..22f10228 --- /dev/null +++ b/SystemCalls/Native.cpp @@ -0,0 +1,46 @@ +#include + +#include + +#include "../syscalls.h" +#include "../kernel.h" + +static uint64_t sys_exit(SyscallsFrame *Frame, uint64_t code) +{ + trace("Userspace thread %s(%lld) exited with code %#llx", TaskManager->GetCurrentThread()->Name, TaskManager->GetCurrentThread()->ID, code); + TaskManager->GetCurrentThread()->ExitCode = code; + TaskManager->GetCurrentThread()->Status = Tasking::TaskStatus::Terminated; + return 0; +} + +static int sys_print(SyscallsFrame *Frame, char Char, int Index) +{ + debug("%c", Char); + return Display->Print(Char, Index, true); +} + +static void *NativeSyscallsTable[] = { + [_exit] = (void *)sys_exit, + [_print] = (void *)sys_print, +}; + +uint64_t HandleNativeSyscalls(SyscallsFrame *Frame) +{ + debug("rax: %#llx, rbx: %#llx, rcx: %#llx, rdx: %#llx, rsi: %#llx, rdi: %#llx, rbp: %#llx, r8: %#llx, r9: %#llx, r10: %#llx, r11: %#llx, r12: %#llx, r13: %#llx, r14: %#llx, r15: %#llx", Frame->rax, Frame->rbx, Frame->rcx, Frame->rdx, Frame->rsi, Frame->rdi, Frame->rbp, Frame->r8, Frame->r9, Frame->r10, Frame->r11, Frame->r12, Frame->r13, Frame->r14, Frame->r15); + if (Frame->rax > sizeof(NativeSyscallsTable)) + { + fixme("Syscall %lld not implemented", Frame->rax); + return -1; + } + + uint64_t (*call)(uint64_t, ...) = reinterpret_cast(NativeSyscallsTable[Frame->rax]); + if (!call) + { + error("Syscall %#llx failed.", Frame->rax); + return -1; + } + debug("%#lx %#lx %#lx %#lx %#lx %#lx", Frame->rdi, Frame->rsi, Frame->rdx, Frame->rcx, Frame->r8, Frame->r9); + uint64_t ret = call((uint64_t)Frame, Frame->rdi, Frame->rsi, Frame->rdx, Frame->r10, Frame->r8, Frame->r9); + Frame->rax = ret; + return ret; +} diff --git a/SystemCalls/Syscalls.cpp b/SystemCalls/Syscalls.cpp index 8e9686a7..43a7f55a 100644 --- a/SystemCalls/Syscalls.cpp +++ b/SystemCalls/Syscalls.cpp @@ -2,14 +2,33 @@ #include -extern "C" uint64_t SystemCallsHandler(SyscallsRegs *regs) +#include "../kernel.h" + +extern "C" uint64_t SystemCallsHandler(SyscallsFrame *Frame) { #if defined(__amd64__) - fixme("System call %ld", regs->rax); + switch (TaskManager->GetCurrentThread()->Info.Compatibility) + { + case Tasking::TaskCompatibility::Native: + return HandleNativeSyscalls(Frame); + case Tasking::TaskCompatibility::Linux: + return HandleLinuxSyscalls(Frame); + case Tasking::TaskCompatibility::Windows: + { + error("Windows compatibility not implemented yet."); + break; + } + default: + { + error("Unknown compatibility mode! Killing thread..."); + TaskManager->KillThread(TaskManager->GetCurrentThread(), -0xCA11); + break; + } + } #elif defined(__i386__) fixme("System call %lld", regs->eax); #elif defined(__aarch64__) fixme("System call"); #endif - return 0; + return -1; } diff --git a/Tasking/InterProcessCommunication.cpp b/Tasking/InterProcessCommunication.cpp index 5fc2e176..c985cf36 100644 --- a/Tasking/InterProcessCommunication.cpp +++ b/Tasking/InterProcessCommunication.cpp @@ -54,7 +54,10 @@ namespace InterProcessCommunication IPC::IPC() { trace("Starting IPC Service..."); - TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)IPCServiceStub); + Vector argv; + Vector envp; + Vector auxv; + TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)IPCServiceStub, argv, envp, auxv); TaskManager->GetCurrentThread()->Rename("IPC Service"); } diff --git a/Tasking/Task.cpp b/Tasking/Task.cpp index b5861ba0..597995e3 100644 --- a/Tasking/Task.cpp +++ b/Tasking/Task.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include "../kernel.h" @@ -379,6 +380,50 @@ namespace Tasking Success: { +#ifdef DEBUG_SCHEDULER + static int sanity; + const char *Statuses[] = { + "FF0000", // Unknown + "AAFF00", // Ready + "00AA00", // Running + "FFAA00", // Sleeping + "FFAA00", // Waiting + "FF0088", // Stopped + "FF0000", // Terminated + }; + const char *StatusesSign[] = { + "U", // Unknown + "R", // Ready + "r", // Running + "S", // Sleeping + "W", // Waiting + "s", // Stopped + "T", // Terminated + }; + for (int i = 0; i < 200; i++) + for (int j = 0; j < 200; j++) + Display->SetPixel(i, j, 0x222222, 0); + uint32_t tmpX, tmpY; + Display->GetBufferCursor(0, &tmpX, &tmpY); + Display->SetBufferCursor(0, 0, 0); + foreach (auto var in ListProcess) + { + int statuu = var->Status; + printf_("\e%s-> \eAABBCC%s\eCCCCCC[%d] \e00AAAA%s\n", + Statuses[statuu], var->Name, statuu, StatusesSign[statuu]); + foreach (auto var2 in var->Threads) + { + int statui = var2->Status; + printf_(" \e%s-> \eAABBCC%s\eCCCCCC[%d] \e00AAAA%s\n\eAABBCC", + Statuses[statui], var2->Name, statui, StatusesSign[statui]); + } + } + printf_("%d", sanity++); + if (sanity > 1000) + sanity = 0; + Display->SetBufferCursor(0, tmpX, tmpY); + Display->SetBuffer(0); +#endif schedbg("Process \"%s\"(%d) Thread \"%s\"(%d) is now running on CPU %d", CurrentCPU->CurrentProcess->Name, CurrentCPU->CurrentProcess->ID, CurrentCPU->CurrentThread->Name, CurrentCPU->CurrentThread->ID, CurrentCPU->ID); @@ -546,8 +591,9 @@ namespace Tasking TCB *Task::CreateThread(PCB *Parent, IP EntryPoint, - Arg Argument0, - Arg Argument1, + Vector &argv, + Vector &envp, + Vector &auxv, IPOffset Offset, TaskArchitecture Architecture, TaskCompatibility Compatibility) @@ -570,8 +616,6 @@ namespace Tasking strcpy(Thread->Name, Parent->Name); Thread->EntryPoint = EntryPoint; Thread->Offset = Offset; - Thread->Argument0 = Argument0; - Thread->Argument1 = Argument1; Thread->ExitCode = 0xdead; Thread->Stack = (void *)((uint64_t)KernelAllocator.RequestPages(TO_PAGES(STACK_SIZE))); Thread->Status = TaskStatus::Ready; @@ -579,8 +623,6 @@ namespace Tasking #if defined(__amd64__) memset(&Thread->Registers, 0, sizeof(CPU::x64::TrapFrame)); // Just in case Thread->Registers.rip = (EntryPoint + Offset); - Thread->Registers.rdi = Argument0; - Thread->Registers.rsi = Argument1; #elif defined(__i386__) #elif defined(__aarch64__) #endif @@ -622,6 +664,80 @@ namespace Tasking Thread->Registers.rflags.IF = 1; Thread->Registers.rflags.ID = 1; Thread->Registers.rsp = ((uint64_t)Thread->Stack + STACK_SIZE); + + // https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf#figure.3.9 + // What is a "eightbyte"? unsigned long? 1 eightbyte = 8 bytes? 2 eightbyte each = 16 bytes? + uint64_t TmpStack = Thread->Registers.rsp; + uint64_t TmpStack2 = TmpStack; + uint64_t *TmpStackPtr = (uint64_t *)TmpStack; + + // TODO: argc, argv, envp, auxv not tested and probably not working + foreach (auto var in envp) + { + TmpStack -= strlen(var) + 1; + strcpy((char *)TmpStack, var); + } + + foreach (auto var in argv) + { + TmpStack -= strlen(var) + 1; + strcpy((char *)TmpStack, var); + } + + /* align by 16 */ + TmpStack = (uint64_t)((uint64_t)TmpStack - ((uint64_t)TmpStack & 0x0F)); + + /* TODO: more aligment here? */ + + /* auxv null */ + TmpStack -= sizeof(uint64_t); + POKE(uint64_t, TmpStack) = (uint64_t)0; + /* This should be included too? */ + TmpStack -= sizeof(uint64_t); + POKE(uint64_t, TmpStack) = (uint64_t)0; + + /* auxv */ + foreach (auto var in auxv) + { + if (var.archaux.a_type == AT_ENTRY) + Thread->Registers.rdi = var.archaux.a_un.a_val; + + TmpStack -= sizeof(uint64_t) * 2; + POKE(uint64_t, TmpStack) = (uint64_t)var.archaux.a_type; + TmpStack -= sizeof(uint64_t) * 2; + POKE(uint64_t, TmpStack) = (uint64_t)var.archaux.a_un.a_val; + } + + /* empty */ + TmpStack -= sizeof(uint64_t); + POKE(uint64_t, TmpStack) = 0; + + /* envp pointers */ + for (uint64_t i = 0; i < envp.size(); i++) + { + /* Not sure if this works */ + TmpStack2 -= strlen(envp[i]) + 1; + TmpStackPtr[i] = TmpStack2; + } + + /* empty */ + TmpStack -= sizeof(uint64_t); + POKE(uint64_t, TmpStack) = 0; + + /* argv pointers */ + for (uint64_t i = 0; i < argv.size(); i++) + { + /* Not sure if this works */ + TmpStack2 -= strlen(argv[i]) + 1; + TmpStackPtr[i] = TmpStack2; + } + + /* argc */ + TmpStack -= sizeof(uint64_t); + POKE(uint64_t, TmpStack) = argv.size() - 1; + + Thread->Registers.rsp -= (uint64_t)Thread->Stack + STACK_SIZE - TmpStack; + /* We need to leave the libc's crt to make a syscall when the Thread is exited or we are going to get GPF or PF exception. */ Memory::Virtual uva = Memory::Virtual(Parent->PageTable); @@ -635,6 +751,9 @@ namespace Tasking } #elif defined(__i386__) #elif defined(__aarch64__) +#endif +#ifdef DEBUG_SCHEDULER + DumpData(Thread->Name, Thread->Stack, STACK_SIZE); #endif break; } @@ -786,7 +905,10 @@ namespace Tasking TaskArchitecture Arch = TaskArchitecture::ARM64; #endif PCB *kproc = CreateProcess(nullptr, "Kernel", TaskTrustLevel::Kernel); - TCB *kthrd = CreateThread(kproc, EntryPoint, 0, 0, 0, Arch); + Vector argv; + Vector envp; + Vector auxv; + TCB *kthrd = CreateThread(kproc, EntryPoint, argv, envp, auxv, 0, Arch); kthrd->Rename("Main Thread"); debug("Created Kernel Process: %s and Thread: %s", kproc->Name, kthrd->Name); TaskingLock.Lock(__FUNCTION__); @@ -810,7 +932,10 @@ namespace Tasking IdleProcess = CreateProcess(nullptr, (char *)"Idle", TaskTrustLevel::Idle); for (int i = 0; i < SMP::CPUCores; i++) { - IdleThread = CreateThread(IdleProcess, reinterpret_cast(IdleProcessLoop)); + Vector argv; + Vector envp; + Vector auxv; + IdleThread = CreateThread(IdleProcess, reinterpret_cast(IdleProcessLoop), argv, envp, auxv); char IdleName[16]; sprintf_(IdleName, "Idle Thread %d", i); IdleThread->Rename(IdleName); diff --git a/include/abi.h b/include/abi.h new file mode 100644 index 00000000..88216010 --- /dev/null +++ b/include/abi.h @@ -0,0 +1,72 @@ +#ifndef __FENNIX_KERNEL_ABI_H__ +#define __FENNIX_KERNEL_ABI_H__ + +#include + +#define AT_NULL 0 +#define AT_IGNORE 1 +#define AT_EXECFD 2 +#define AT_PHDR 3 +#define AT_PHENT 4 +#define AT_PHNUM 5 +#define AT_PAGESZ 6 +#define AT_BASE 7 +#define AT_FLAGS 8 +#define AT_ENTRY 9 +#define AT_NOTELF 10 +#define AT_UID 11 +#define AT_EUID 12 +#define AT_GID 13 +#define AT_EGID 14 +#define AT_PLATFORM 15 +#define AT_HWCAP 16 +#define AT_CLKTCK 17 +#define AT_SECURE 23 +#define AT_BASE_PLATFORM 24 +#define AT_RANDOM 25 +#define AT_HWCAP2 26 +#define AT_EXECFN 31 +#define AT_SYSINFO 32 +#define AT_SYSINFO_EHDR 33 +#define AT_L1I_CACHESHAPE 34 +#define AT_L1D_CACHESHAPE 35 +#define AT_L2_CACHESHAPE 36 +#define AT_L3_CACHESHAPE 37 +#define AT_L1I_CACHESIZE 40 +#define AT_L1I_CACHEGEOMETRY 41 +#define AT_L1D_CACHESIZE 42 +#define AT_L1D_CACHEGEOMETRY 43 +#define AT_L2_CACHESIZE 44 +#define AT_L2_CACHEGEOMETRY 45 +#define AT_L3_CACHESIZE 46 +#define AT_L3_CACHEGEOMETRY 47 +#define AT_MINSIGSTKSZ 51 + +typedef struct +{ + uint32_t a_type; + union + { + uint32_t a_val; + } a_un; +} Elf32_auxv_t; + +typedef struct +{ + uint64_t a_type; + union + { + uint64_t a_val; + } a_un; +} Elf64_auxv_t; + +typedef struct +{ +#if defined(__amd64__) + Elf64_auxv_t archaux; +#elif defined(__i386__) +#elif defined(__aarch64__) +#endif +} AuxiliaryVector; + +#endif // !__FENNIX_KERNEL_ABI_H__ diff --git a/include/assert.h b/include/assert.h index acefdc53..03c84822 100644 --- a/include/assert.h +++ b/include/assert.h @@ -3,12 +3,28 @@ #include -#define assert(x) \ - do \ - { \ - if (!(x)) \ - while (1) \ - ; \ +#include + +#define assert(x) \ + do \ + { \ + if (!(x)) \ + { \ + void *CallerAddress = __builtin_extract_return_addr(__builtin_return_address(0)); \ + error("Assertion failed! [%s] [%#lx => %s:%s:%d]", #x, CallerAddress, __FILE__, __FUNCTION__, __LINE__); \ + while (1) \ + ; \ + } \ + } while (0) + +#define assert_allow_continue(x) \ + do \ + { \ + if (!(x)) \ + { \ + void *CallerAddress = __builtin_extract_return_addr(__builtin_return_address(0)); \ + error("Assertion failed! [%s] [%#lx => %s:%s:%d]", #x, CallerAddress, __FILE__, __FUNCTION__, __LINE__); \ + } \ } while (0) #define static_assert(x) \ diff --git a/include/cpu.hpp b/include/cpu.hpp index 95b055d6..1dd40d9c 100644 --- a/include/cpu.hpp +++ b/include/cpu.hpp @@ -1585,6 +1585,9 @@ namespace CPU __attribute__((no_stack_protector)) static inline void fxsave(char *FXSaveArea) { #if defined(__amd64__) + if (!FXSaveArea || FXSaveArea >= (char *)0xfffffffffffff000) + return; + _amd64_fxsave(FXSaveArea); // asmv("fxsaveq (%0)" // : @@ -1596,6 +1599,9 @@ namespace CPU __attribute__((no_stack_protector)) static inline void fxrstor(char *FXRstorArea) { #if defined(__amd64__) + if (!FXRstorArea || FXRstorArea >= (char *)0xfffffffffffff000) + return; + _amd64_fxrstor(FXRstorArea); // asmv("fxrstorq (%0)" // : diff --git a/include/exec.hpp b/include/exec.hpp index 5d07153d..f6ffba3f 100644 --- a/include/exec.hpp +++ b/include/exec.hpp @@ -40,7 +40,7 @@ namespace Execute }; BinaryType GetBinaryType(char *Path); - SpawnData Spawn(char *Path, uint64_t Arg0, uint64_t Arg1); + SpawnData Spawn(char *Path, Vector &argv, Vector &envp); void *ELFLoadRel(Elf64_Ehdr *Header); } diff --git a/include/kconfig.hpp b/include/kconfig.hpp index 560d2f51..613b4d4f 100644 --- a/include/kconfig.hpp +++ b/include/kconfig.hpp @@ -10,6 +10,7 @@ struct KernelConfig bool SchedulerType; char DriverDirectory[256]; char InitPath[256]; + bool InterruptsOnCrash; int Cores; }; diff --git a/include/smp.hpp b/include/smp.hpp index 7e0ab38d..d83fb3e4 100644 --- a/include/smp.hpp +++ b/include/smp.hpp @@ -38,7 +38,7 @@ struct CPUData /** @brief Current running thread */ Tasking::TCB *CurrentThread; - /** @brief Architecture-specific CPU data. */ + /** @brief Architecture-specific data. */ CPUArchData *Data; /** @brief Checksum. Used to verify the integrity of the data. Must be equal to CPU_DATA_CHECKSUM (0xC0FFEE). */ int Checksum; diff --git a/include/syscalls.hpp b/include/syscalls.hpp index ce9aeb05..8155a959 100644 --- a/include/syscalls.hpp +++ b/include/syscalls.hpp @@ -3,7 +3,7 @@ #include -typedef struct SyscallsRegs +typedef struct SyscallsFrame { #if defined(__amd64__) uint64_t r15, r14, r13, r12, r11, r10, r9, r8; @@ -15,7 +15,10 @@ typedef struct SyscallsRegs uint64_t InterruptNumber, ErrorCode, eip, cs, eflags, esp, ss; #elif defined(__aarch64__) #endif -} SyscallsRegs; +} SyscallsFrame; + +uint64_t HandleNativeSyscalls(SyscallsFrame *Frame); +uint64_t HandleLinuxSyscalls(SyscallsFrame *Frame); /** * @brief Initialize syscalls for the current CPU. (Function is available on x32, x64 & aarch64) diff --git a/include/task.hpp b/include/task.hpp index a275a8ee..5abc26fb 100644 --- a/include/task.hpp +++ b/include/task.hpp @@ -9,11 +9,11 @@ #include #include #include +#include namespace Tasking { typedef unsigned long IP; - typedef unsigned long Arg; typedef unsigned long IPOffset; typedef unsigned long UPID; typedef unsigned long UTID; @@ -84,8 +84,6 @@ namespace Tasking struct PCB *Parent; IP EntryPoint; IPOffset Offset; - Arg Argument0; - Arg Argument1; int ExitCode; void *Stack; TaskStatus Status; @@ -217,6 +215,17 @@ namespace Tasking public: void Schedule(); long GetUsage(int Core) { return 100 - IdleProcess->Info.Usage[Core]; } + void KillThread(TCB *tcb, int Code) + { + tcb->Status = TaskStatus::Terminated; + tcb->ExitCode = Code; + } + + void KillProcess(PCB *pcb, int Code) + { + pcb->Status = TaskStatus::Terminated; + pcb->ExitCode = Code; + } /** * @brief Get the Current Process object @@ -242,8 +251,9 @@ namespace Tasking TCB *CreateThread(PCB *Parent, IP EntryPoint, - Arg Argument0 = 0, - Arg Argument1 = 0, + Vector &argv, + Vector &envp, + Vector &auxv, IPOffset Offset = 0, TaskArchitecture Architecture = TaskArchitecture::x64, TaskCompatibility Compatibility = TaskCompatibility::Native); diff --git a/include/types.h b/include/types.h index a08724ef..d757b48a 100644 --- a/include/types.h +++ b/include/types.h @@ -200,4 +200,45 @@ typedef __SIZE_TYPE__ size_t; #define WINT_MAX __WINT_MAX__ #define WINT_MIN __WINT_MIN__ +#define b4(x) ((x & 0x0F) << 4 | (x & 0xF0) >> 4) +#define b8(x) ((x)&0xFF) +#define b16(x) __builtin_bswap16(x) +#define b32(x) __builtin_bswap32(x) +#define b48(x) (((((x)&0x0000000000ff) << 40) | (((x)&0x00000000ff00) << 24) | (((x)&0x000000ff0000) << 8) | (((x)&0x0000ff000000) >> 8) | (((x)&0x00ff00000000) >> 24) | (((x)&0xff0000000000) >> 40))) +#define b64(x) __builtin_bswap64(x) + + +#define O0 __attribute__((optimize("O0"))) +#define O1 __attribute__((optimize("O1"))) +#define O2 __attribute__((optimize("O2"))) +#define O3 __attribute__((optimize("O3"))) +#define Os __attribute__((optimize("Os"))) +#define Ofast __attribute__((optimize("Ofast"))) + +/** @brief dbg */ +#define OPTMZ O0 + +#define __unused __attribute__((unused)) +#define __packed __attribute__((packed)) +#define __aligned(x) __attribute__((aligned(x))) +#define __section(x) __attribute__((section(x))) +#define __noreturn __attribute__((noreturn)) +#define __weak __attribute__((weak)) +#define __alias(x) __attribute__((alias(x))) +#define __always_inline __attribute__((always_inline)) +#define __noinline __attribute__((noinline)) +#define __pure __attribute__((pure)) +#define __const __attribute__((const)) +#define __malloc __attribute__((malloc)) +#define __returns_twice __attribute__((returns_twice)) +#define __used __attribute__((used)) +#define __deprecated __attribute__((deprecated)) +#define __deprecated_msg(x) __attribute__((deprecated(x))) +#define __weakref(x) __attribute__((weakref(x))) +#define __weakrefalias(x) __attribute__((weakref(#x))) +#define __visibility(x) __attribute__((visibility(x))) +#define __constructor __attribute__((constructor)) +#define __destructor __attribute__((destructor)) +#define __cleanup(x) __attribute__((cleanup(x))) + #endif // !__FENNIX_KERNEL_TYPES_H__ diff --git a/kernel.h b/kernel.h index 20693695..874eb619 100644 --- a/kernel.h +++ b/kernel.h @@ -35,6 +35,7 @@ extern Disk::Manager *DiskManager; #endif +EXTERNC void putchar(char c); EXTERNC void KPrint(const char *format, ...); EXTERNC void Entry(struct BootInfo *Info); diff --git a/syscalls.h b/syscalls.h new file mode 100644 index 00000000..085527c9 --- /dev/null +++ b/syscalls.h @@ -0,0 +1,12 @@ +#ifndef __FENNIX_KERNEL_SYSCALLS_LIST_H__ +#define __FENNIX_KERNEL_SYSCALLS_LIST_H__ + +#include + +enum NativeSyscalls +{ + _exit = 0, + _print, +}; + +#endif // !__FENNIX_KERNEL_SYSCALLS_LIST_H__