mirror of
https://github.com/Fennix-Project/Lynx.git
synced 2025-05-28 15:34:39 +00:00
Update loader
This commit is contained in:
parent
cdfbbf6eab
commit
4e8599969b
@ -76,8 +76,10 @@ bool LoadElfInMemory(void *Address, size_t Length, bool Allow64)
|
|||||||
debug(" Mapping %d pages at %p (%p-%p)", TO_PAGES(SegmentSize), VirtualAddress, PhysicalAddress, (void *)((uintptr_t)PhysicalAddress + TO_PAGES(SegmentSize) * PAGE_SIZE));
|
debug(" Mapping %d pages at %p (%p-%p)", TO_PAGES(SegmentSize), VirtualAddress, PhysicalAddress, (void *)((uintptr_t)PhysicalAddress + TO_PAGES(SegmentSize) * PAGE_SIZE));
|
||||||
Memory32::Virtual().Map(VirtualAddress, PhysicalAddress, SegmentSize, P | RW);
|
Memory32::Virtual().Map(VirtualAddress, PhysicalAddress, SegmentSize, P | RW);
|
||||||
|
|
||||||
debug(" Copying %#x bytes to %p", ProgramHeader[i].p_filesz, PhysicalAddress);
|
void *memcpy_Dest = (void *)((uintptr_t)PhysicalAddress + (ProgramHeader[i].p_vaddr - 0xC0000000));
|
||||||
memcpy(PhysicalAddress, (void *)((uintptr_t)Address + ProgramHeader[i].p_offset), ProgramHeader[i].p_filesz);
|
void *memcpy_Src = (void *)((uintptr_t)Address + ProgramHeader[i].p_offset);
|
||||||
|
debug(" memcpy(%p, %p, %#x)", memcpy_Dest, memcpy_Src, ProgramHeader[i].p_filesz);
|
||||||
|
memcpy(memcpy_Dest, memcpy_Src, ProgramHeader[i].p_filesz);
|
||||||
|
|
||||||
if (ProgramHeader[i].p_filesz < ProgramHeader[i].p_memsz)
|
if (ProgramHeader[i].p_filesz < ProgramHeader[i].p_memsz)
|
||||||
{
|
{
|
||||||
@ -87,10 +89,10 @@ bool LoadElfInMemory(void *Address, size_t Length, bool Allow64)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *Stack = KernelAllocator32.RequestPage();
|
void *Stack = KernelAllocator32.RequestPage();
|
||||||
memset(Stack, 0, PAGE_SIZE);
|
memset(Stack, 0, PAGE_SIZE - 1);
|
||||||
debug("Stack allocated at: %p", Stack);
|
debug("Stack allocated at: %p", Stack);
|
||||||
|
|
||||||
void *StackTop = (void *)((uintptr_t)Stack + PAGE_SIZE - 1);
|
void *StackTop = (void *)((uintptr_t)Stack + PAGE_SIZE - 0x10);
|
||||||
debug("Stack top at: %p", StackTop);
|
debug("Stack top at: %p", StackTop);
|
||||||
|
|
||||||
debug("Memory Info: %lldMB / %lldMB (%lldMB reserved)",
|
debug("Memory Info: %lldMB / %lldMB (%lldMB reserved)",
|
||||||
@ -119,14 +121,14 @@ bool LoadElfInMemory(void *Address, size_t Length, bool Allow64)
|
|||||||
"mov $0, %esi\n"
|
"mov $0, %esi\n"
|
||||||
"mov $0, %edi\n"
|
"mov $0, %edi\n"
|
||||||
"mov $0, %ebp\n");
|
"mov $0, %ebp\n");
|
||||||
asmv("jmp %0"
|
asmv("call %0"
|
||||||
:
|
:
|
||||||
: "r"(KernelJumpAddress));
|
: "r"(KernelJumpAddress));
|
||||||
|
// asmv("jmp %0"
|
||||||
// asmv("call %0"
|
|
||||||
// :
|
// :
|
||||||
// : "r"(KernelJumpAddress));
|
// : "r"(KernelJumpAddress));
|
||||||
|
|
||||||
|
|
||||||
// asmv("call *%0"
|
// asmv("call *%0"
|
||||||
// :
|
// :
|
||||||
// : "r"(KernelJumpAddress));
|
// : "r"(KernelJumpAddress));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user