mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-13 08:19:18 +00:00
Fix type sizes
This commit is contained in:
107
Core/CPU.cpp
107
Core/CPU.cpp
@ -201,14 +201,14 @@ namespace CPU
|
||||
|
||||
void InitializeFeatures(long Core)
|
||||
{
|
||||
#if defined(a64)
|
||||
static int BSP = 0;
|
||||
bool PGESupport = false;
|
||||
bool SSESupport = false;
|
||||
#if defined(a64)
|
||||
bool UMIPSupport = false;
|
||||
bool SMEPSupport = false;
|
||||
bool SMAPSupport = false;
|
||||
|
||||
static int BSP = 0;
|
||||
x64::CR0 cr0 = x64::readcr0();
|
||||
x64::CR4 cr4 = x64::readcr4();
|
||||
|
||||
@ -335,6 +335,105 @@ namespace CPU
|
||||
if (SSEEnableAfter)
|
||||
SSEEnabled = true;
|
||||
#elif defined(a32)
|
||||
|
||||
x32::CR0 cr0 = x32::readcr0();
|
||||
x32::CR4 cr4 = x32::readcr4();
|
||||
|
||||
if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_AMD) == 0)
|
||||
{
|
||||
CPU::x86::AMD::CPUID0x00000001 cpuid1;
|
||||
cpuid1.Get();
|
||||
|
||||
PGESupport = cpuid1.EDX.PGE;
|
||||
SSESupport = cpuid1.EDX.SSE;
|
||||
}
|
||||
else if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_INTEL) == 0)
|
||||
{
|
||||
CPU::x86::Intel::CPUID0x00000001 cpuid1;
|
||||
cpuid1.Get();
|
||||
PGESupport = cpuid1.EDX.PGE;
|
||||
SSESupport = cpuid1.EDX.SSE;
|
||||
}
|
||||
|
||||
if (Config.SIMD == false)
|
||||
{
|
||||
debug("Disabling SSE support...");
|
||||
SSESupport = false;
|
||||
}
|
||||
|
||||
if (PGESupport)
|
||||
{
|
||||
debug("Enabling global pages support...");
|
||||
if (!BSP)
|
||||
KPrint("Global Pages is supported.");
|
||||
cr4.PGE = 1;
|
||||
}
|
||||
|
||||
bool SSEEnableAfter = false;
|
||||
|
||||
/* Not sure if my code is not working properly or something else is the issue. */
|
||||
if ((strcmp(Hypervisor(), x86_CPUID_VENDOR_TCG) != 0 &&
|
||||
strcmp(Hypervisor(), x86_CPUID_VENDOR_VIRTUALBOX) != 0) &&
|
||||
SSESupport)
|
||||
{
|
||||
debug("Enabling FPU...");
|
||||
bool FPU = false;
|
||||
{
|
||||
x32::CR0 _cr0;
|
||||
__asm__ __volatile__(
|
||||
"mov %%cr0, %0\n\t"
|
||||
"and $0xfffffff8, %0\n\t"
|
||||
"mov %0, %%cr0\n\t"
|
||||
"fninit\n\t"
|
||||
"fwait\n\t"
|
||||
"mov %%cr0, %0\n\t"
|
||||
: "=r"(_cr0.raw)
|
||||
:
|
||||
: "memory");
|
||||
if ((_cr0.EM) == 0)
|
||||
{
|
||||
FPU = true;
|
||||
debug("FPU is supported");
|
||||
}
|
||||
}
|
||||
|
||||
if (FPU)
|
||||
KPrint("FPU is supported.");
|
||||
|
||||
debug("Enabling SSE support...");
|
||||
if (!BSP)
|
||||
KPrint("SSE is supported.");
|
||||
cr0.EM = 0;
|
||||
cr0.MP = 1;
|
||||
cr4.OSFXSR = 1;
|
||||
cr4.OSXMMEXCPT = 1;
|
||||
|
||||
CPUData *CoreData = GetCPU(Core);
|
||||
CoreData->Data.FPU = (CPU::x32::FXState *)KernelAllocator.RequestPages(TO_PAGES(sizeof(CPU::x32::FXState) + 1));
|
||||
memset(CoreData->Data.FPU, 0, FROM_PAGES(TO_PAGES(sizeof(CPU::x32::FXState))));
|
||||
CoreData->Data.FPU->mxcsr = 0b0001111110000000;
|
||||
CoreData->Data.FPU->mxcsrmask = 0b1111111110111111;
|
||||
CoreData->Data.FPU->fcw = 0b0000001100111111;
|
||||
CPU::x32::fxrstor(CoreData->Data.FPU);
|
||||
|
||||
SSEEnableAfter = true;
|
||||
}
|
||||
|
||||
cr0.NW = 0;
|
||||
cr0.CD = 0;
|
||||
cr0.WP = 1;
|
||||
|
||||
x32::writecr0(cr0);
|
||||
debug("Writing CR4...");
|
||||
x32::writecr4(cr4);
|
||||
debug("Wrote CR4.");
|
||||
|
||||
debug("Enabling PAT support...");
|
||||
x32::wrmsr(x32::MSR_CR_PAT, 0x6 | (0x0 << 8) | (0x1 << 16));
|
||||
if (!BSP++)
|
||||
trace("Features for BSP initialized.");
|
||||
if (SSEEnableAfter)
|
||||
SSEEnabled = true;
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
}
|
||||
@ -358,10 +457,6 @@ namespace CPU
|
||||
|
||||
uint64_t CheckSIMD()
|
||||
{
|
||||
#if defined(a32)
|
||||
return SIMD_NONE; /* TODO: Support x86 SIMD on x32 */
|
||||
#endif
|
||||
|
||||
if (unlikely(!SSEEnabled))
|
||||
return SIMD_NONE;
|
||||
|
||||
|
@ -662,9 +662,9 @@ namespace CrashHandler
|
||||
else
|
||||
{
|
||||
uint64_t Address = strtoul(addr, NULL, 16);
|
||||
uint64_t Length = strtoul(len, NULL, 10);
|
||||
size_t Length = strtoul(len, NULL, 10);
|
||||
debug("Dumping %ld bytes from %#lx\n", Length, Address);
|
||||
EHDumpData((void *)Address, Length);
|
||||
EHDumpData((void *)Address, (unsigned long)Length);
|
||||
}
|
||||
}
|
||||
else if (strncmp(Input, "uartmemdmp", 10) == 0)
|
||||
@ -705,13 +705,13 @@ namespace CrashHandler
|
||||
}
|
||||
EHPrint("\eF8F8F8Dumping memory to UART port %c (%#lx) and %s inaccessible pages.\n", cPort[0], port, cBoolSkip[0] == '1' ? "skipping" : "zeroing");
|
||||
Display->SetBuffer(SBIdx);
|
||||
uint64_t Length = KernelAllocator.GetTotalMemory();
|
||||
uint64_t ProgressLength = Length;
|
||||
uint64_t TotalMemLength = KernelAllocator.GetTotalMemory();
|
||||
uint64_t ProgressLength = TotalMemLength;
|
||||
UniversalAsynchronousReceiverTransmitter::UART uart(port);
|
||||
Memory::Virtual vma;
|
||||
uint8_t *Address = reinterpret_cast<uint8_t *>(0x0);
|
||||
int Progress = 0;
|
||||
for (size_t i = 0; i < Length; i++)
|
||||
for (size_t i = 0; i < TotalMemLength; i++)
|
||||
{
|
||||
if (vma.Check(Address))
|
||||
uart.Write(*Address);
|
||||
|
@ -83,7 +83,7 @@ namespace CrashHandler
|
||||
data.Frame->ss, data.Frame->cs, ds);
|
||||
EHPrint("EAX=%#llx EBX=%#llx ECX=%#llx EDX=%#llx\n", data.Frame->eax, data.Frame->ebx, data.Frame->ecx, data.Frame->edx);
|
||||
EHPrint("ESI=%#llx EDI=%#llx EBP=%#llx ESP=%#llx\n", data.Frame->esi, data.Frame->edi, data.Frame->ebp, data.Frame->esp);
|
||||
EHPrint("EIP=%#llx EFL=%#llx INT=%#llx ERR=%#llx EFER=%#llx\n", data.Frame->eip, data.Frame->eflags.raw, data.Frame->InterruptNumber, data.Frame->ErrorCode, data.efer.raw);
|
||||
EHPrint("EIP=%#llx EFL=%#llx INT=%#llx ERR=%#llx\n", data.Frame->eip, data.Frame->eflags.raw, data.Frame->InterruptNumber, data.Frame->ErrorCode);
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
@ -144,10 +144,12 @@ namespace CrashHandler
|
||||
data.dr7.ConditionsDR2 ? "True " : "False", data.dr7.SizeDR2 ? "True " : "False", data.dr7.ConditionsDR3 ? "True " : "False", data.dr7.SizeDR3 ? "True " : "False",
|
||||
data.dr7.Reserved);
|
||||
|
||||
#ifdef a64
|
||||
EHPrint("\e009FF0EFER: SCE:%s LME:%s LMA:%s NXE:%s\n SVME:%s LMSLE:%s FFXSR:%s TCE:%s\n R0:%#x R1:%#x R2:%#x\n",
|
||||
data.efer.SCE ? "True " : "False", data.efer.LME ? "True " : "False", data.efer.LMA ? "True " : "False", data.efer.NXE ? "True " : "False",
|
||||
data.efer.SVME ? "True " : "False", data.efer.LMSLE ? "True " : "False", data.efer.FFXSR ? "True " : "False", data.efer.TCE ? "True " : "False",
|
||||
data.efer.Reserved0, data.efer.Reserved1, data.efer.Reserved2);
|
||||
#endif // a64
|
||||
#endif
|
||||
|
||||
switch (data.Frame->InterruptNumber)
|
||||
|
@ -113,7 +113,7 @@ namespace Disk
|
||||
}
|
||||
partition.StartLBA = GPTPartition.FirstLBA;
|
||||
partition.EndLBA = GPTPartition.LastLBA;
|
||||
partition.Sectors = partition.EndLBA - partition.StartLBA;
|
||||
partition.Sectors = (size_t)(partition.EndLBA - partition.StartLBA);
|
||||
partition.Port = ItrPort;
|
||||
partition.Flags = Present;
|
||||
partition.Style = GPT;
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
if (fexExtended->Driver.OverrideOnConflict)
|
||||
{
|
||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
||||
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||
foreach (auto Drv in Drivers)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
if (fexExtended->Driver.OverrideOnConflict)
|
||||
{
|
||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
||||
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||
foreach (auto Drv in Drivers)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
if (fexExtended->Driver.OverrideOnConflict)
|
||||
{
|
||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
||||
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||
foreach (auto Drv in Drivers)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
if (fexExtended->Driver.OverrideOnConflict)
|
||||
{
|
||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
||||
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||
foreach (auto Drv in Drivers)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -38,7 +38,7 @@ namespace Driver
|
||||
debug("Searching for conflicting drivers...");
|
||||
if (fexExtended->Driver.OverrideOnConflict)
|
||||
{
|
||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
||||
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||
foreach (auto Drv in Drivers)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
if (fexExtended->Driver.OverrideOnConflict)
|
||||
{
|
||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
||||
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||
foreach (auto Drv in Drivers)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
if (fexExtended->Driver.OverrideOnConflict)
|
||||
{
|
||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
||||
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||
foreach (auto Drv in Drivers)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
if (fexExtended->Driver.OverrideOnConflict)
|
||||
{
|
||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
||||
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||
foreach (auto Drv in Drivers)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -38,7 +38,7 @@ namespace Driver
|
||||
|
||||
if (fexExtended->Driver.OverrideOnConflict)
|
||||
{
|
||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
||||
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||
foreach (auto Drv in Drivers)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -38,7 +38,7 @@ namespace Driver
|
||||
|
||||
if (fexExtended->Driver.OverrideOnConflict)
|
||||
{
|
||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
||||
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||
foreach (auto Drv in Drivers)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -38,7 +38,7 @@ namespace Driver
|
||||
|
||||
if (fexExtended->Driver.OverrideOnConflict)
|
||||
{
|
||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
||||
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||
foreach (auto Drv in Drivers)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -38,7 +38,7 @@ namespace Driver
|
||||
|
||||
if (fexExtended->Driver.OverrideOnConflict)
|
||||
{
|
||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
||||
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||
foreach (auto Drv in Drivers)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
if (fexExtended->Driver.OverrideOnConflict)
|
||||
{
|
||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
||||
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||
foreach (auto Drv in Drivers)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
if (fexExtended->Driver.OverrideOnConflict)
|
||||
{
|
||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
||||
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||
foreach (auto Drv in Drivers)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -116,7 +116,7 @@ NIF void MapFramebuffer(PageTable *PT)
|
||||
|
||||
va.OptimizedMap((void *)bInfo.Framebuffer[itrfb].BaseAddress,
|
||||
(void *)bInfo.Framebuffer[itrfb].BaseAddress,
|
||||
bInfo.Framebuffer[itrfb].Pitch * bInfo.Framebuffer[itrfb].Height,
|
||||
(size_t)(bInfo.Framebuffer[itrfb].Pitch * bInfo.Framebuffer[itrfb].Height),
|
||||
PTFlag::RW | PTFlag::US | PTFlag::G);
|
||||
itrfb++;
|
||||
|
||||
|
@ -55,11 +55,11 @@ namespace Memory
|
||||
if (Offset > node->Length)
|
||||
return -1;
|
||||
node->Offset = Offset;
|
||||
NewOffset = node->Offset;
|
||||
NewOffset = (long)node->Offset;
|
||||
}
|
||||
else if (Whence == SEEK_CUR)
|
||||
{
|
||||
NewOffset = node->Offset + Offset;
|
||||
NewOffset = (long)(node->Offset + Offset);
|
||||
if ((size_t)NewOffset > node->Length || NewOffset < 0)
|
||||
return -1;
|
||||
node->Offset = NewOffset;
|
||||
|
@ -377,7 +377,7 @@ namespace Memory
|
||||
TotalMemory = MemorySize;
|
||||
FreeMemory = MemorySize;
|
||||
|
||||
size_t BitmapSize = (MemorySize / PAGE_SIZE) / 8 + 1;
|
||||
size_t BitmapSize = (size_t)(MemorySize / PAGE_SIZE) / 8 + 1;
|
||||
uintptr_t BitmapAddress = 0x0;
|
||||
size_t BitmapAddressSize = 0;
|
||||
|
||||
|
@ -789,7 +789,7 @@ namespace PCI
|
||||
}
|
||||
#endif
|
||||
|
||||
void PCI::EnumerateFunction(uintptr_t DeviceAddress, uint64_t Function)
|
||||
void PCI::EnumerateFunction(uintptr_t DeviceAddress, uintptr_t Function)
|
||||
{
|
||||
uintptr_t Offset = Function << 12;
|
||||
uintptr_t FunctionAddress = DeviceAddress + Offset;
|
||||
@ -805,7 +805,7 @@ namespace PCI
|
||||
#endif
|
||||
}
|
||||
|
||||
void PCI::EnumerateDevice(uintptr_t BusAddress, uint64_t Device)
|
||||
void PCI::EnumerateDevice(uintptr_t BusAddress, uintptr_t Device)
|
||||
{
|
||||
uintptr_t Offset = Device << 15;
|
||||
uintptr_t DeviceAddress = BusAddress + Offset;
|
||||
@ -819,7 +819,7 @@ namespace PCI
|
||||
EnumerateFunction(DeviceAddress, Function);
|
||||
}
|
||||
|
||||
void PCI::EnumerateBus(uintptr_t BaseAddress, uint64_t Bus)
|
||||
void PCI::EnumerateBus(uintptr_t BaseAddress, uintptr_t Bus)
|
||||
{
|
||||
uintptr_t Offset = Bus << 20;
|
||||
uintptr_t BusAddress = BaseAddress + Offset;
|
||||
|
@ -127,7 +127,7 @@ namespace Random
|
||||
|
||||
if (RDRANDFlag)
|
||||
{
|
||||
uint64_t RDRANDValue = 0;
|
||||
uintptr_t RDRANDValue = 0;
|
||||
asmv("1: rdrand %0; jnc 1b"
|
||||
: "=r"(RDRANDValue));
|
||||
return RDRANDValue;
|
||||
|
@ -55,16 +55,26 @@ namespace SymbolResolver
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(a64)
|
||||
Elf64_Shdr *ElfSections = (Elf64_Shdr *)(Sections);
|
||||
Elf64_Sym *ElfSymbols = nullptr;
|
||||
#elif defined(a32)
|
||||
Elf32_Shdr *ElfSections = (Elf32_Shdr *)(Sections);
|
||||
Elf32_Sym *ElfSymbols = nullptr;
|
||||
#endif
|
||||
char *strtab = nullptr;
|
||||
|
||||
for (uint64_t i = 0; i < Num; i++)
|
||||
switch (ElfSections[i].sh_type)
|
||||
{
|
||||
case SHT_SYMTAB:
|
||||
#if defined(a64)
|
||||
ElfSymbols = (Elf64_Sym *)(Sections + ElfSections[i].sh_offset);
|
||||
this->TotalEntries = ElfSections[i].sh_size / sizeof(Elf64_Sym);
|
||||
#elif defined(a32)
|
||||
ElfSymbols = (Elf32_Sym *)(Sections + ElfSections[i].sh_offset);
|
||||
this->TotalEntries = ElfSections[i].sh_size / sizeof(Elf32_Sym);
|
||||
#endif
|
||||
if (this->TotalEntries >= 0x10000)
|
||||
this->TotalEntries = 0x10000 - 1;
|
||||
|
||||
@ -94,7 +104,11 @@ namespace SymbolResolver
|
||||
for (Index = i + 1; Index < this->TotalEntries; Index++)
|
||||
if (ElfSymbols[Index].st_value < ElfSymbols[MinimumIndex].st_value)
|
||||
MinimumIndex = Index;
|
||||
#if defined(a64)
|
||||
Elf64_Sym tmp = ElfSymbols[MinimumIndex];
|
||||
#elif defined(a32)
|
||||
Elf32_Sym tmp = ElfSymbols[MinimumIndex];
|
||||
#endif
|
||||
ElfSymbols[MinimumIndex] = ElfSymbols[i];
|
||||
ElfSymbols[i] = tmp;
|
||||
}
|
||||
@ -114,7 +128,7 @@ namespace SymbolResolver
|
||||
}
|
||||
|
||||
trace("Symbol table loaded, %d entries (%ldKB)", this->TotalEntries, TO_KB(this->TotalEntries * sizeof(SymbolTable)));
|
||||
for (uintptr_t i = 0, g = this->TotalEntries; i < g; i++)
|
||||
for (int64_t i = 0, g = this->TotalEntries; i < g; i++)
|
||||
{
|
||||
this->SymTable[i].Address = ElfSymbols[i].st_value;
|
||||
this->SymTable[i].FunctionName = &strtab[ElfSymbols[i].st_name];
|
||||
@ -134,7 +148,11 @@ namespace SymbolResolver
|
||||
|
||||
this->Image = (void *)ImageAddress;
|
||||
debug("Solving symbols for address: %#llx", ImageAddress);
|
||||
#if defined(a64)
|
||||
Elf64_Ehdr *Header = (Elf64_Ehdr *)ImageAddress;
|
||||
#elif defined(a32)
|
||||
Elf32_Ehdr *Header = (Elf32_Ehdr *)ImageAddress;
|
||||
#endif
|
||||
if (Header->e_ident[0] != 0x7F &&
|
||||
Header->e_ident[1] != 'E' &&
|
||||
Header->e_ident[2] != 'L' &&
|
||||
@ -143,16 +161,26 @@ namespace SymbolResolver
|
||||
error("Invalid ELF header");
|
||||
return;
|
||||
}
|
||||
#if defined(a64)
|
||||
Elf64_Shdr *ElfSections = (Elf64_Shdr *)(ImageAddress + Header->e_shoff);
|
||||
Elf64_Sym *ElfSymbols = nullptr;
|
||||
#elif defined(a32)
|
||||
Elf32_Shdr *ElfSections = (Elf32_Shdr *)(ImageAddress + Header->e_shoff);
|
||||
Elf32_Sym *ElfSymbols = nullptr;
|
||||
#endif
|
||||
char *strtab = nullptr;
|
||||
|
||||
for (uint16_t i = 0; i < Header->e_shnum; i++)
|
||||
switch (ElfSections[i].sh_type)
|
||||
{
|
||||
case SHT_SYMTAB:
|
||||
#if defined(a64)
|
||||
ElfSymbols = (Elf64_Sym *)(ImageAddress + ElfSections[i].sh_offset);
|
||||
this->TotalEntries = ElfSections[i].sh_size / sizeof(Elf64_Sym);
|
||||
#elif defined(a32)
|
||||
ElfSymbols = (Elf32_Sym *)(ImageAddress + ElfSections[i].sh_offset);
|
||||
this->TotalEntries = ElfSections[i].sh_size / sizeof(Elf32_Sym);
|
||||
#endif
|
||||
if (this->TotalEntries >= 0x10000)
|
||||
this->TotalEntries = 0x10000 - 1;
|
||||
|
||||
@ -182,7 +210,11 @@ namespace SymbolResolver
|
||||
for (Index = i + 1; Index < this->TotalEntries; Index++)
|
||||
if (ElfSymbols[Index].st_value < ElfSymbols[MinimumIndex].st_value)
|
||||
MinimumIndex = Index;
|
||||
#if defined(a64)
|
||||
Elf64_Sym tmp = ElfSymbols[MinimumIndex];
|
||||
#elif defined(a32)
|
||||
Elf32_Sym tmp = ElfSymbols[MinimumIndex];
|
||||
#endif
|
||||
ElfSymbols[MinimumIndex] = ElfSymbols[i];
|
||||
ElfSymbols[i] = tmp;
|
||||
}
|
||||
@ -194,7 +226,7 @@ namespace SymbolResolver
|
||||
}
|
||||
|
||||
trace("Symbol table loaded, %d entries (%ldKB)", this->TotalEntries, TO_KB(this->TotalEntries * sizeof(SymbolTable)));
|
||||
for (uintptr_t i = 0, g = this->TotalEntries; i < g; i++)
|
||||
for (int64_t i = 0, g = this->TotalEntries; i < g; i++)
|
||||
{
|
||||
this->SymTable[i].Address = ElfSymbols[i].st_value;
|
||||
this->SymTable[i].FunctionName = &strtab[ElfSymbols[i].st_name];
|
||||
|
@ -34,25 +34,35 @@ namespace Time
|
||||
{
|
||||
bool HighPrecisionEventTimer::Sleep(uint64_t Duration, Units Unit)
|
||||
{
|
||||
#if defined(a86)
|
||||
#if defined(a64)
|
||||
uint64_t Target = mminq(&((HPET *)hpet)->MainCounterValue) + (Duration * ConvertUnit(Unit)) / clk;
|
||||
while (mminq(&((HPET *)hpet)->MainCounterValue) < Target)
|
||||
CPU::Pause();
|
||||
return true;
|
||||
#elif defined(a32)
|
||||
uint64_t Target = mminl(&((HPET *)hpet)->MainCounterValue) + (Duration * ConvertUnit(Unit)) / clk;
|
||||
while (mminl(&((HPET *)hpet)->MainCounterValue) < Target)
|
||||
CPU::Pause();
|
||||
return true;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t HighPrecisionEventTimer::GetCounter()
|
||||
{
|
||||
#if defined(a86)
|
||||
#if defined(a64)
|
||||
return mminq(&((HPET *)hpet)->MainCounterValue);
|
||||
#elif defined(a32)
|
||||
return mminl(&((HPET *)hpet)->MainCounterValue);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint64_t HighPrecisionEventTimer::CalculateTarget(uint64_t Target, Units Unit)
|
||||
{
|
||||
#if defined(a86)
|
||||
#if defined(a64)
|
||||
return mminq(&((HPET *)hpet)->MainCounterValue) + (Target * ConvertUnit(Unit)) / clk;
|
||||
#elif defined(a32)
|
||||
return mminl(&((HPET *)hpet)->MainCounterValue) + (Target * ConvertUnit(Unit)) / clk;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -75,10 +85,16 @@ namespace Time
|
||||
Memory::PTFlag::RW | Memory::PTFlag::PCD);
|
||||
this->hpet = (HPET *)HPET_HDR->Address.Address;
|
||||
trace("%s timer is at address %016p", HPET_HDR->Header.OEMID, (void *)HPET_HDR->Address.Address);
|
||||
clk = s_cst(uint32_t, this->hpet->GeneralCapabilities >> 32);
|
||||
clk = s_cst(uint32_t, (uint64_t)this->hpet->GeneralCapabilities >> 32);
|
||||
#ifdef a64
|
||||
mmoutq(&this->hpet->GeneralConfiguration, 0);
|
||||
mmoutq(&this->hpet->MainCounterValue, 0);
|
||||
mmoutq(&this->hpet->GeneralConfiguration, 1);
|
||||
#else
|
||||
mmoutl(&this->hpet->GeneralConfiguration, 0);
|
||||
mmoutl(&this->hpet->MainCounterValue, 0);
|
||||
mmoutl(&this->hpet->GeneralConfiguration, 1);
|
||||
#endif
|
||||
ClassCreationTime = this->GetCounter();
|
||||
#endif
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace Video
|
||||
Font *Display::GetCurrentFont() { return CurrentFont; }
|
||||
void Display::SetCurrentFont(Font *Font) { CurrentFont = Font; }
|
||||
uint16_t Display::GetBitsPerPixel() { return this->framebuffer.BitsPerPixel; }
|
||||
uint64_t Display::GetPitch() { return this->framebuffer.Pitch; }
|
||||
size_t Display::GetPitch() { return this->framebuffer.Pitch; }
|
||||
|
||||
void Display::CreateBuffer(uint32_t Width, uint32_t Height, int Index)
|
||||
{
|
||||
|
Reference in New Issue
Block a user