mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Fix compiler issues in 32-bit
This commit is contained in:
parent
83bd843e2b
commit
05610c7e7a
@ -298,23 +298,25 @@ typedef struct
|
||||
uint64_t value;
|
||||
} atomic_uint64_t;
|
||||
|
||||
uint64_t __atomic_load_8(const atomic_uint64_t *p)
|
||||
{
|
||||
uint64_t value;
|
||||
__asm__ volatile("lock cmpxchg8b %1"
|
||||
: "=A"(value)
|
||||
: "m"(*p)
|
||||
: "memory");
|
||||
return value;
|
||||
}
|
||||
/* No longer needed? */
|
||||
|
||||
void __atomic_store_8(atomic_uint64_t *p, uint64_t value)
|
||||
{
|
||||
__asm__ volatile("lock cmpxchg8b %0"
|
||||
: "=m"(p->value)
|
||||
: "a"((uint32_t)value), "d"((uint32_t)(value >> 32)), "m"(*p)
|
||||
: "memory");
|
||||
}
|
||||
// uint64_t __atomic_load_8(const atomic_uint64_t *p)
|
||||
// {
|
||||
// uint64_t value;
|
||||
// __asm__ volatile("lock cmpxchg8b %1"
|
||||
// : "=A"(value)
|
||||
// : "m"(*p)
|
||||
// : "memory");
|
||||
// return value;
|
||||
// }
|
||||
|
||||
// void __atomic_store_8(atomic_uint64_t *p, uint64_t value)
|
||||
// {
|
||||
// __asm__ volatile("lock cmpxchg8b %0"
|
||||
// : "=m"(p->value)
|
||||
// : "a"((uint32_t)value), "d"((uint32_t)(value >> 32)), "m"(*p)
|
||||
// : "memory");
|
||||
// }
|
||||
|
||||
int __fixsfsi(float a)
|
||||
{
|
||||
|
@ -41,7 +41,6 @@ EXTERNC void multiboot_main(uintptr_t Magic, uintptr_t Info)
|
||||
BootInfo mb2binfo{};
|
||||
|
||||
{
|
||||
int pos = 0;
|
||||
auto InfoAddress = Info;
|
||||
for (auto Tag = (struct multiboot_tag *)((uint8_t *)InfoAddress + 8);
|
||||
;
|
||||
|
@ -229,13 +229,9 @@ namespace GlobalDescriptorTable
|
||||
gdt[Core].Entries->TaskStateSegment.BaseMiddle = uint8_t((Base >> 16) & 0xFF);
|
||||
gdt[Core].Entries->TaskStateSegment.BaseHigh = uint8_t((Base >> 24) & 0xFF);
|
||||
|
||||
#pragma diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wshift-count-overflow"
|
||||
|
||||
gdt[Core].Entries->TaskStateSegment.BaseUpper = s_cst(uint32_t, (Base >> 32) & 0xFFFFFFFF);
|
||||
|
||||
#pragma diagnostic pop
|
||||
|
||||
gdt[Core].Entries->TaskStateSegment.Access = {.A = 1, .RW = 0, .DC = 0, .E = 1, .S = 0, .DPL = 0, .P = 1};
|
||||
gdt[Core].Entries->TaskStateSegment.Granularity = (0 << 4) | ((Limit >> 16) & 0xF);
|
||||
|
||||
@ -259,7 +255,7 @@ namespace GlobalDescriptorTable
|
||||
|
||||
SafeFunction void SetKernelStack(void *Stack)
|
||||
{
|
||||
long CPUID = GetCurrentCPU()->ID;
|
||||
stub;
|
||||
}
|
||||
|
||||
void *GetKernelStack() { return (void *)nullptr; }
|
||||
|
@ -231,6 +231,10 @@ SafeFunction void UserModeExceptionHandler(CHArchTrapFrame *Frame)
|
||||
|
||||
error("An exception occurred at %#lx by %#lx", CrashHandler::PageFaultAddress, Frame->rip);
|
||||
#elif defined(a32)
|
||||
CheckPageFaultAddress = CrashHandler::PageFaultAddress;
|
||||
if (CheckPageFaultAddress == 0)
|
||||
CheckPageFaultAddress = Frame->eip;
|
||||
|
||||
error("An exception occurred at %#lx by %#lx", CrashHandler::PageFaultAddress, Frame->eip);
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
@ -65,7 +65,7 @@ namespace SymbolResolver
|
||||
Elf32_Word SymbolSize = 0;
|
||||
// Elf32_Word StringSize = 0;
|
||||
#endif
|
||||
int64_t TotalEntries = 0;
|
||||
size_t TotalEntries = 0;
|
||||
|
||||
for (size_t i = 0; i < Num; ++i)
|
||||
{
|
||||
@ -81,7 +81,7 @@ namespace SymbolResolver
|
||||
// StringSize = (int)str->sh_size;
|
||||
// TotalEntries = Section.sh_size / sizeof(Elf64_Sym)
|
||||
TotalEntries = sym->sh_size / sym->sh_entsize;
|
||||
debug("Symbol table found, %d entries",
|
||||
trace("Symbol table found, %d entries",
|
||||
SymbolSize / sym->sh_entsize);
|
||||
UNUSED(SymbolSize);
|
||||
break;
|
||||
@ -90,8 +90,8 @@ namespace SymbolResolver
|
||||
|
||||
if (Symbols != nullptr && StringAddress != nullptr)
|
||||
{
|
||||
int64_t Index, MinimumIndex;
|
||||
for (int64_t i = 0; i < TotalEntries - 1; i++)
|
||||
size_t Index, MinimumIndex;
|
||||
for (size_t i = 0; i < TotalEntries - 1; i++)
|
||||
{
|
||||
MinimumIndex = i;
|
||||
for (Index = i + 1; Index < TotalEntries; Index++)
|
||||
@ -116,11 +116,11 @@ namespace SymbolResolver
|
||||
return;
|
||||
}
|
||||
|
||||
debug("Symbol table loaded, %d entries (%ld KiB)",
|
||||
trace("Symbol table loaded, %d entries (%ld KiB)",
|
||||
TotalEntries, TO_KiB(TotalEntries * sizeof(SymbolTable)));
|
||||
Elf_Sym *sym = nullptr;
|
||||
const char *name = nullptr;
|
||||
for (int64_t i = 0, g = TotalEntries; i < g; i++)
|
||||
for (size_t i = 0, g = TotalEntries; i < g; i++)
|
||||
{
|
||||
sym = &Symbols[i];
|
||||
name = (const char *)&StringAddress[Symbols[i].st_name];
|
||||
@ -168,7 +168,7 @@ namespace SymbolResolver
|
||||
Elf_Shdr *ElfSections = (Elf_Shdr *)(ImageAddress + Header->e_shoff);
|
||||
Elf_Sym *ElfSymbols = nullptr;
|
||||
char *strtab = nullptr;
|
||||
int64_t TotalEntries = 0;
|
||||
size_t TotalEntries = 0;
|
||||
|
||||
for (uint16_t i = 0; i < Header->e_shnum; i++)
|
||||
{
|
||||
@ -197,8 +197,8 @@ namespace SymbolResolver
|
||||
|
||||
if (ElfSymbols != nullptr && strtab != nullptr)
|
||||
{
|
||||
int64_t Index, MinimumIndex;
|
||||
for (int64_t i = 0; i < TotalEntries - 1; i++)
|
||||
size_t Index, MinimumIndex;
|
||||
for (size_t i = 0; i < TotalEntries - 1; i++)
|
||||
{
|
||||
MinimumIndex = i;
|
||||
for (Index = i + 1; Index < TotalEntries; Index++)
|
||||
@ -221,7 +221,7 @@ namespace SymbolResolver
|
||||
/* TODO: maybe a checker for duplicated addresses? */
|
||||
Elf_Sym *sym = nullptr;
|
||||
const char *name = nullptr;
|
||||
for (int64_t i = 0, g = TotalEntries; i < g; i++)
|
||||
for (size_t i = 0, g = TotalEntries; i < g; i++)
|
||||
{
|
||||
sym = &ElfSymbols[i];
|
||||
name = &strtab[ElfSymbols[i].st_name];
|
||||
|
@ -23,7 +23,7 @@ namespace Video
|
||||
{
|
||||
Font::Font(uintptr_t *Start, uintptr_t *End, FontType Type)
|
||||
{
|
||||
trace("Initializing font with start %#llx and end %#llx Type: %d", Start, End, Type);
|
||||
trace("Initializing font with start %#lx and end %#lx Type: %d", Start, End, Type);
|
||||
this->Info.StartAddress = Start;
|
||||
this->Info.EndAddress = End;
|
||||
this->Info.Type = Type;
|
||||
|
@ -1056,7 +1056,32 @@ uintptr_t HandleLinuxSyscalls(SyscallsFrame *Frame)
|
||||
return call(Frame->rdi, Frame->rsi, Frame->rdx,
|
||||
Frame->r10, Frame->r8, Frame->r9);
|
||||
#elif defined(a32)
|
||||
return 0;
|
||||
if (Frame->eax > sizeof(LinuxSyscallsTable) / sizeof(SyscallData))
|
||||
{
|
||||
fixme("Syscall %d not implemented",
|
||||
Frame->eax);
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
SyscallData Syscall = LinuxSyscallsTable[Frame->eax];
|
||||
|
||||
long (*call)(long, ...) = r_cst(long (*)(long, ...),
|
||||
Syscall.Handler);
|
||||
|
||||
if (unlikely(!call))
|
||||
{
|
||||
fixme("Syscall %s(%d) not implemented.",
|
||||
Syscall.Name, Frame->eax);
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
debug("[%d:\"%s\"]->( %#lx %#lx %#lx %#lx %#lx %#lx )",
|
||||
Frame->eax, Syscall.Name,
|
||||
Frame->ebx, Frame->ecx, Frame->edx,
|
||||
Frame->esi, Frame->edi, Frame->ebp);
|
||||
|
||||
return call(Frame->ebx, Frame->ecx, Frame->edx,
|
||||
Frame->esi, Frame->edi, Frame->ebp);
|
||||
#elif defined(aa64)
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -701,7 +701,44 @@ uintptr_t HandleNativeSyscalls(SysFrm *Frame)
|
||||
Frame->rdi, Frame->rsi, Frame->rdx,
|
||||
Frame->r10, Frame->r8, Frame->r9);
|
||||
#elif defined(a32)
|
||||
if (unlikely(Frame->eax > sys_MaxSyscall))
|
||||
{
|
||||
fixme("Syscall %ld not implemented.", Frame->eax);
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
SyscallData Syscall = NativeSyscallsTable[Frame->eax];
|
||||
|
||||
uintptr_t (*call)(SysFrm *, uintptr_t, ...) =
|
||||
r_cst(uintptr_t(*)(SysFrm *, uintptr_t, ...),
|
||||
Syscall.Handler);
|
||||
|
||||
if (unlikely(!call))
|
||||
{
|
||||
error("Syscall %s(%d) not implemented.",
|
||||
Syscall.Name, Frame->eax);
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
int euid = thisProcess->Security.Effective.UserID;
|
||||
int egid = thisProcess->Security.Effective.GroupID;
|
||||
int reqID = Syscall.RequiredID;
|
||||
if (euid > reqID || egid > reqID)
|
||||
{
|
||||
warn("Process %s(%d) tried to access a system call \"%s\" with insufficient privileges.",
|
||||
thisProcess->Name, thisProcess->ID, Syscall.Name);
|
||||
debug("Required: %d; Effective u:%d, g:%d", reqID, euid, egid);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
debug("[%d:\"%s\"]->( %#x %#x %#x %#x %#x %#x )",
|
||||
Frame->eax, Syscall.Name,
|
||||
Frame->ebx, Frame->ecx, Frame->edx,
|
||||
Frame->esi, Frame->edi, Frame->ebp);
|
||||
|
||||
return call(Frame,
|
||||
Frame->ebx, Frame->ecx, Frame->edx,
|
||||
Frame->esi, Frame->edi, Frame->ebp);
|
||||
#elif defined(aa64)
|
||||
return -ENOSYS;
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user