mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-11 07:19:20 +00:00
Stability fixes (i hope); attempt to implement argc, argv, envp, auxv; Syscalls
This commit is contained in:
@ -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()
|
||||
{
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -2,15 +2,12 @@
|
||||
|
||||
#include <interrupts.hpp>
|
||||
#include <memory.hpp>
|
||||
#include <assert.h>
|
||||
#include <cpu.hpp>
|
||||
|
||||
#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()
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
using namespace CPU::x32;
|
||||
|
||||
extern "C" uint32_t SystemCallsHandler(SyscallsRegs *regs);
|
||||
extern "C" uint32_t SystemCallsHandler(SyscallsFrame *regs);
|
||||
|
||||
void InitializeSystemCalls()
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <interrupts.hpp>
|
||||
#include <memory.hpp>
|
||||
#include <assert.h>
|
||||
#include <cpu.hpp>
|
||||
|
||||
#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];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user