Updated types

This commit is contained in:
Alex
2022-12-21 00:43:51 +02:00
parent 684b76a1ca
commit a677f3c159
62 changed files with 471 additions and 448 deletions

View File

@ -102,23 +102,21 @@ namespace CPU
{
case Check:
{
uintptr_t Flags;
#if defined(__amd64__)
uint64_t rflags;
asmv("pushfq");
asmv("popq %0"
: "=r"(rflags));
return rflags & (1 << 9);
: "=r"(Flags));
return Flags & (1 << 9);
#elif defined(__i386__)
uint32_t rflags;
asmv("pushfl");
asmv("popl %0"
: "=r"(rflags));
return rflags & (1 << 9);
: "=r"(Flags));
return Flags & (1 << 9);
#elif defined(__aarch64__)
uint64_t daif;
asmv("mrs %0, daif"
: "=r"(daif));
return !(daif & (1 << 2));
: "=r"(Flags));
return !(Flags & (1 << 2));
#endif
}
case Enable:
@ -254,21 +252,20 @@ namespace CPU
#endif
}
uint64_t Counter()
uintptr_t Counter()
{
// TODO: Get the counter from the x2APIC or any other timer that is available. (TSC is not available on all CPUs)
uintptr_t Counter;
#if defined(__amd64__)
uint64_t counter;
asmv("rdtsc"
: "=A"(counter));
return counter;
: "=A"(Counter));
#elif defined(__i386__)
return 0;
asmv("rdtsc"
: "=A"(Counter));
#elif defined(__aarch64__)
uint64_t counter;
asmv("mrs %0, cntvct_el0"
: "=r"(counter));
return counter;
: "=r"(Counter));
#endif
return Counter;
}
}

View File

@ -121,7 +121,7 @@ SafeFunction void PageFaultExceptionHandler(CHArchTrapFrame *Frame)
CrashHandler::EHPrint(PageFaultDescriptions[Frame->ErrorCode & 0b111]);
#ifdef DEBUG
uint64_t CheckPageFaultAddress = 0;
uintptr_t CheckPageFaultAddress = 0;
CheckPageFaultAddress = CPU::x64::readcr2().PFLA;
if (CheckPageFaultAddress == 0)
CheckPageFaultAddress = Frame->rip;
@ -155,11 +155,11 @@ SafeFunction void PageFaultExceptionHandler(CHArchTrapFrame *Frame)
if (Present)
{
uint64_t CheckPageFaultLinearAddress = (uint64_t)CheckPageFaultAddress;
uintptr_t CheckPageFaultLinearAddress = (uintptr_t)CheckPageFaultAddress;
CheckPageFaultLinearAddress &= 0xFFFFFFFFFFFFF000;
debug("%#lx -> %#lx", CheckPageFaultAddress, CheckPageFaultLinearAddress);
Memory::Virtual::PageMapIndexer Index = Memory::Virtual::PageMapIndexer((uint64_t)CheckPageFaultLinearAddress);
Memory::Virtual::PageMapIndexer Index = Memory::Virtual::PageMapIndexer((uintptr_t)CheckPageFaultLinearAddress);
debug("Index for %#lx is PML:%d PDPTE:%d PDE:%d PTE:%d",
CheckPageFaultLinearAddress,
Index.PMLIndex,
@ -168,9 +168,9 @@ SafeFunction void PageFaultExceptionHandler(CHArchTrapFrame *Frame)
Index.PTEIndex);
Memory::PageMapLevel4 PML4 = ((Memory::PageTable4 *)CPU::x64::readcr3().raw)->Entries[Index.PMLIndex];
Memory::PageDirectoryPointerTableEntryPtr *PDPTE = (Memory::PageDirectoryPointerTableEntryPtr *)((uint64_t)PML4.GetAddress() << 12);
Memory::PageDirectoryEntryPtr *PDE = (Memory::PageDirectoryEntryPtr *)((uint64_t)PDPTE->Entries[Index.PDPTEIndex].GetAddress() << 12);
Memory::PageTableEntryPtr *PTE = (Memory::PageTableEntryPtr *)((uint64_t)PDE->Entries[Index.PDEIndex].GetAddress() << 12);
Memory::PageDirectoryPointerTableEntryPtr *PDPTE = (Memory::PageDirectoryPointerTableEntryPtr *)((uintptr_t)PML4.GetAddress() << 12);
Memory::PageDirectoryEntryPtr *PDE = (Memory::PageDirectoryEntryPtr *)((uintptr_t)PDPTE->Entries[Index.PDPTEIndex].GetAddress() << 12);
Memory::PageTableEntryPtr *PTE = (Memory::PageTableEntryPtr *)((uintptr_t)PDE->Entries[Index.PDEIndex].GetAddress() << 12);
debug("# %03d-%03d-%03d-%03d: P:%s RW:%s US:%s PWT:%s PCB:%s A:%s NX:%s Address:%#lx",
Index.PMLIndex, 0, 0, 0,

View File

@ -294,8 +294,8 @@ namespace CrashHandler
else if (strncmp(Input, "ifr", 3) == 0)
{
char *arg = TrimWhiteSpace(Input + 3);
uint64_t CountI = atoi(arg);
uint64_t TotalCount = sizeof(EHIntFrames) / sizeof(EHIntFrames[0]);
int CountI = atoi(arg);
int TotalCount = sizeof(EHIntFrames) / sizeof(EHIntFrames[0]);
debug("Printing %ld interrupt frames.", CountI);
@ -306,7 +306,7 @@ namespace CrashHandler
}
else
{
for (uint64_t i = 0; i < CountI; i++)
for (int i = 0; i < CountI; i++)
{
if (EHIntFrames[i])
{
@ -315,12 +315,12 @@ namespace CrashHandler
EHPrint("\n\e2565CC%p", EHIntFrames[i]);
EHPrint("\e7925CC-");
#if defined(__amd64__)
if ((uint64_t)EHIntFrames[i] >= 0xFFFFFFFF80000000 && (uint64_t)EHIntFrames[i] <= (uint64_t)&_kernel_end)
if ((uintptr_t)EHIntFrames[i] >= 0xFFFFFFFF80000000 && (uintptr_t)EHIntFrames[i] <= (uintptr_t)&_kernel_end)
#elif defined(__i386__)
if ((uint64_t)EHIntFrames[i] >= 0xC0000000 && (uint64_t)EHIntFrames[i] <= (uint64_t)&_kernel_end)
if ((uintptr_t)EHIntFrames[i] >= 0xC0000000 && (uintptr_t)EHIntFrames[i] <= (uintptr_t)&_kernel_end)
#elif defined(__aarch64__)
#endif
EHPrint("\e25CCC9%s", KernelSymbolTable->GetSymbolFromAddress((uint64_t)EHIntFrames[i]));
EHPrint("\e25CCC9%s", KernelSymbolTable->GetSymbolFromAddress((uintptr_t)EHIntFrames[i]));
else
EHPrint("\eFF4CA9Outside Kernel");
for (int i = 0; i < 20000; i++)
@ -333,7 +333,7 @@ namespace CrashHandler
else if (strncmp(Input, "tlb", 3) == 0)
{
char *arg = TrimWhiteSpace(Input + 3);
uint64_t Address = NULL;
uintptr_t Address = NULL;
Address = strtol(arg, NULL, 16);
debug("Converted %s to %#lx", arg, Address);
Memory::PageTable4 *BasePageTable = (Memory::PageTable4 *)Address;
@ -355,7 +355,7 @@ namespace CrashHandler
Display->SetBuffer(SBIdx);
if (PML4.Present)
{
Memory::PageDirectoryPointerTableEntryPtr *PDPTE = (Memory::PageDirectoryPointerTableEntryPtr *)((uint64_t)PML4.GetAddress() << 12);
Memory::PageDirectoryPointerTableEntryPtr *PDPTE = (Memory::PageDirectoryPointerTableEntryPtr *)((uintptr_t)PML4.GetAddress() << 12);
if (PDPTE)
{
for (int PDPTEIndex = 0; PDPTEIndex < 512; PDPTEIndex++)
@ -373,7 +373,7 @@ namespace CrashHandler
Display->SetBuffer(SBIdx);
if ((PDPTE->Entries[PDPTEIndex].Present))
{
Memory::PageDirectoryEntryPtr *PDE = (Memory::PageDirectoryEntryPtr *)((uint64_t)PDPTE->Entries[PDPTEIndex].GetAddress() << 12);
Memory::PageDirectoryEntryPtr *PDE = (Memory::PageDirectoryEntryPtr *)((uintptr_t)PDPTE->Entries[PDPTEIndex].GetAddress() << 12);
if (PDE)
{
for (int PDEIndex = 0; PDEIndex < 512; PDEIndex++)
@ -391,7 +391,7 @@ namespace CrashHandler
Display->SetBuffer(SBIdx);
if ((PDE->Entries[PDEIndex].Present))
{
Memory::PageTableEntryPtr *PTE = (Memory::PageTableEntryPtr *)((uint64_t)PDE->Entries[PDEIndex].GetAddress() << 12);
Memory::PageTableEntryPtr *PTE = (Memory::PageTableEntryPtr *)((uintptr_t)PDE->Entries[PDEIndex].GetAddress() << 12);
if (PTE)
{
for (int PTEIndex = 0; PTEIndex < 512; PTEIndex++)
@ -428,7 +428,7 @@ namespace CrashHandler
Bitmap bm = KernelAllocator.GetPageBitmap();
EHPrint("\n\eFAFAFA[0%%] %08ld: ", 0);
for (uint64_t i = 0; i < bm.Size; i++)
for (size_t i = 0; i < bm.Size; i++)
{
if (bm.Get(i))
EHPrint("\eFF00001");
@ -436,7 +436,7 @@ namespace CrashHandler
EHPrint("\e00FF000");
if (i % 128 == 127)
{
uint64_t Percentage = (i * 100) / bm.Size;
short Percentage = (i * 100) / bm.Size;
EHPrint("\n\eFAFAFA[%03ld%%] %08ld: ", Percentage, i);
Display->SetBuffer(SBIdx);
}
@ -642,7 +642,7 @@ namespace CrashHandler
CPU::x64::CR8 cr8 = CPU::x64::readcr8();
CPU::x64::EFER efer;
efer.raw = CPU::x64::rdmsr(CPU::x64::MSR_EFER);
uint64_t ds;
uintptr_t ds;
asmv("mov %%ds, %0"
: "=r"(ds));
@ -703,7 +703,7 @@ namespace CrashHandler
crashdata.cr4 = CPU::x64::readcr4();
crashdata.cr8 = CPU::x64::readcr8();
crashdata.efer.raw = CPU::x64::rdmsr(CPU::x64::MSR_EFER);
uint64_t ds;
uintptr_t ds;
asmv("mov %%ds, %0"
: "=r"(ds));

View File

@ -20,7 +20,7 @@ namespace CrashHandler
struct StackFrame
{
struct StackFrame *rbp;
uint64_t rip;
uintptr_t rip;
};
SafeFunction void TraceFrames(CHArchTrapFrame *Frame, int Count, SymbolResolver::Symbols *SymHandle, bool Kernel)
@ -75,14 +75,14 @@ namespace CrashHandler
#if defined(__amd64__)
EHPrint("\e2565CC%p", (void *)Frame->rip);
EHPrint("\e7925CC-");
if ((Frame->rip >= 0xFFFFFFFF80000000 && Frame->rip <= (uint64_t)&_kernel_end) || !Kernel)
if ((Frame->rip >= 0xFFFFFFFF80000000 && Frame->rip <= (uintptr_t)&_kernel_end) || !Kernel)
EHPrint("\eAA25CC%s", SymHandle->GetSymbolFromAddress(Frame->rip));
else
EHPrint("Outside Kernel");
#elif defined(__i386__)
EHPrint("\e2565CC%p", (void *)Frame->eip);
EHPrint("\e7925CC-");
if ((Frame->eip >= 0xC0000000 && Frame->eip <= (uint64_t)&_kernel_end) || !Kernel)
if ((Frame->eip >= 0xC0000000 && Frame->eip <= (uintptr_t)&_kernel_end) || !Kernel)
EHPrint("\eAA25CC%s", SymHandle->GetSymbolFromAddress(Frame->eip));
else
EHPrint("Outside Kernel");
@ -96,9 +96,9 @@ namespace CrashHandler
EHPrint("\n\e2565CC%p", (void *)frames->rip);
EHPrint("\e7925CC-");
#if defined(__amd64__)
if ((frames->rip >= 0xFFFFFFFF80000000 && frames->rip <= (uint64_t)&_kernel_end) || !Kernel)
if ((frames->rip >= 0xFFFFFFFF80000000 && frames->rip <= (uintptr_t)&_kernel_end) || !Kernel)
#elif defined(__i386__)
if ((frames->rip >= 0xC0000000 && frames->rip <= (uint64_t)&_kernel_end) || !Kernel)
if ((frames->rip >= 0xC0000000 && frames->rip <= (uintptr_t)&_kernel_end) || !Kernel)
#elif defined(__aarch64__)
#endif
EHPrint("\e25CCC9%s", SymHandle->GetSymbolFromAddress(frames->rip));

View File

@ -28,6 +28,7 @@ namespace CrashHandler
data.Thread->Name,
data.Thread->ID);
EHPrint("\e7981FCTechnical Informations on CPU %lld:\n", data.ID);
uintptr_t ds;
#if defined(__amd64__)
CPUData *cpu = (CPUData *)data.CPUData;
@ -46,11 +47,9 @@ namespace CrashHandler
EHPrint("Checksum: 0x%X\n", cpu->Checksum);
}
uint64_t ds;
asmv("mov %%ds, %0"
: "=r"(ds));
#elif defined(__i386__)
uint32_t ds;
asmv("mov %%ds, %0"
: "=r"(ds));
#elif defined(__aarch64__)

View File

@ -32,7 +32,7 @@ namespace CrashHandler
TraceFrames(data.Frame, 40, sh, false);
}
EHPrint("\n\eFAFAFATracing interrupt frames...");
for (uint64_t i = 0; i < 8; i++)
for (short i = 0; i < 8; i++)
{
if (EHIntFrames[i])
{
@ -41,12 +41,12 @@ namespace CrashHandler
EHPrint("\n\e2565CC%p", EHIntFrames[i]);
EHPrint("\e7925CC-");
#if defined(__amd64__)
if ((uint64_t)EHIntFrames[i] >= 0xFFFFFFFF80000000 && (uint64_t)EHIntFrames[i] <= (uint64_t)&_kernel_end)
if ((uintptr_t)EHIntFrames[i] >= 0xFFFFFFFF80000000 && (uintptr_t)EHIntFrames[i] <= (uintptr_t)&_kernel_end)
#elif defined(__i386__)
if ((uint64_t)EHIntFrames[i] >= 0xC0000000 && (uint64_t)EHIntFrames[i] <= (uint64_t)&_kernel_end)
if ((uintptr_t)EHIntFrames[i] >= 0xC0000000 && (uintptr_t)EHIntFrames[i] <= (uintptr_t)&_kernel_end)
#elif defined(__aarch64__)
#endif
EHPrint("\e25CCC9%s", KernelSymbolTable->GetSymbolFromAddress((uint64_t)EHIntFrames[i]));
EHPrint("\e25CCC9%s", KernelSymbolTable->GetSymbolFromAddress((uintptr_t)EHIntFrames[i]));
else
EHPrint("\eFF4CA9Outside Kernel");
}
@ -58,7 +58,7 @@ namespace CrashHandler
if (!sh)
EHPrint("\n\eFFA500Warning: No symbol table available.");
int SameItr = 0;
uint64_t LastRIP = 0;
uintptr_t LastRIP = 0;
for (int i = 0; i < 128; i++)
{
if (data.Thread->RIPHistory[i] == 0)
@ -75,7 +75,7 @@ namespace CrashHandler
if (!sh)
EHPrint("\n\e2565CC%p", data.Thread->RIPHistory[i]);
else
EHPrint("\n\e2565CC%p\e7925CC-\e25CCC9%s", data.Thread->RIPHistory[i], sh->GetSymbolFromAddress((uint64_t)data.Thread->RIPHistory[i]));
EHPrint("\n\e2565CC%p\e7925CC-\e25CCC9%s", data.Thread->RIPHistory[i], sh->GetSymbolFromAddress(data.Thread->RIPHistory[i]));
}
EHPrint("\n\e7925CCNote: \e2565CCSame RIPs are not shown more than 3 times.\n");
}

View File

@ -43,12 +43,11 @@ SafeFunction void UserModeExceptionHandler(CHArchTrapFrame *Frame)
efer.raw = CPU::x64::rdmsr(CPU::x64::MSR_EFER);
error("Technical Informations on CPU %lld:", CurCPU->ID);
uintptr_t ds;
#if defined(__amd64__)
uint64_t ds;
asmv("mov %%ds, %0"
: "=r"(ds));
#elif defined(__i386__)
uint32_t ds;
asmv("mov %%ds, %0"
: "=r"(ds));
#elif defined(__aarch64__)
@ -177,7 +176,7 @@ SafeFunction void UserModeExceptionHandler(CHArchTrapFrame *Frame)
}
case CPU::x64::PageFault:
{
uint64_t CheckPageFaultAddress = 0;
uintptr_t CheckPageFaultAddress = 0;
CPU::x64::PageFaultErrorCode params = {.raw = (uint32_t)Frame->ErrorCode};
#if defined(__amd64__)
CheckPageFaultAddress = CPU::x64::readcr2().PFLA;
@ -234,11 +233,11 @@ SafeFunction void UserModeExceptionHandler(CHArchTrapFrame *Frame)
if (Present)
{
uint64_t CheckPageFaultLinearAddress = (uint64_t)CheckPageFaultAddress;
uintptr_t CheckPageFaultLinearAddress = (uintptr_t)CheckPageFaultAddress;
CheckPageFaultLinearAddress &= 0xFFFFFFFFFFFFF000;
debug("%#lx -> %#lx", CheckPageFaultAddress, CheckPageFaultLinearAddress);
Memory::Virtual::PageMapIndexer Index = Memory::Virtual::PageMapIndexer((uint64_t)CheckPageFaultLinearAddress);
Memory::Virtual::PageMapIndexer Index = Memory::Virtual::PageMapIndexer((uintptr_t)CheckPageFaultLinearAddress);
debug("Index for %#lx is PML:%d PDPTE:%d PDE:%d PTE:%d",
CheckPageFaultLinearAddress,
Index.PMLIndex,
@ -247,9 +246,9 @@ SafeFunction void UserModeExceptionHandler(CHArchTrapFrame *Frame)
Index.PTEIndex);
Memory::PageMapLevel4 PML4 = CurCPU->CurrentProcess->PageTable->Entries[Index.PMLIndex];
Memory::PageDirectoryPointerTableEntryPtr *PDPTE = (Memory::PageDirectoryPointerTableEntryPtr *)((uint64_t)PML4.GetAddress() << 12);
Memory::PageDirectoryEntryPtr *PDE = (Memory::PageDirectoryEntryPtr *)((uint64_t)PDPTE->Entries[Index.PDPTEIndex].GetAddress() << 12);
Memory::PageTableEntryPtr *PTE = (Memory::PageTableEntryPtr *)((uint64_t)PDE->Entries[Index.PDEIndex].GetAddress() << 12);
Memory::PageDirectoryPointerTableEntryPtr *PDPTE = (Memory::PageDirectoryPointerTableEntryPtr *)((uintptr_t)PML4.GetAddress() << 12);
Memory::PageDirectoryEntryPtr *PDE = (Memory::PageDirectoryEntryPtr *)((uintptr_t)PDPTE->Entries[Index.PDPTEIndex].GetAddress() << 12);
Memory::PageTableEntryPtr *PTE = (Memory::PageTableEntryPtr *)((uintptr_t)PDE->Entries[Index.PDEIndex].GetAddress() << 12);
debug("# %03d-%03d-%03d-%03d: P:%s RW:%s US:%s PWT:%s PCB:%s A:%s NX:%s Address:%#lx",
Index.PMLIndex, 0, 0, 0,

View File

@ -20,7 +20,7 @@ struct CRData
CPU::x64::CR4 cr4;
CPU::x64::CR8 cr8;
CPU::x64::EFER efer;
uint64_t dr0, dr1, dr2, dr3, dr6;
uintptr_t dr0, dr1, dr2, dr3, dr6;
CPU::x64::DR7 dr7;
long ID;
@ -42,7 +42,7 @@ struct CRData
CPU::x32::CR4 cr4;
CPU::x32::CR8 cr8;
CPU::x32::EFER efer;
uint64_t dr0, dr1, dr2, dr3, dr6;
uintptr_t dr0, dr1, dr2, dr3, dr6;
CPU::x32::DR7 dr7;
long ID;

View File

@ -77,8 +77,8 @@ namespace Driver
foreach (auto var in Drivers)
if (var->DriverUID == DUID)
{
FexExtended *DrvExtHdr = (FexExtended *)((uint64_t)var->Address + EXTENDED_SECTION_ADDRESS);
return ((int (*)(void *))((uint64_t)DrvExtHdr->Driver.Callback + (uint64_t)var->Address))(KCB);
FexExtended *DrvExtHdr = (FexExtended *)((uintptr_t)var->Address + EXTENDED_SECTION_ADDRESS);
return ((int (*)(void *))((uintptr_t)DrvExtHdr->Driver.Callback + (uintptr_t)var->Address))(KCB);
}
return -1;
}
@ -91,14 +91,14 @@ namespace Driver
((KernelAPI *)KAPIAddress)->Info.DriverUID = DriverUIDs++;
debug("Calling driver entry point ( %#lx %ld )", (unsigned long)fex, ((KernelAPI *)KAPIAddress)->Info.DriverUID);
int ret = ((int (*)(KernelAPI *))((uint64_t)((Fex *)fex)->EntryPoint + (uint64_t)fex))(((KernelAPI *)KAPIAddress));
int ret = ((int (*)(KernelAPI *))((uintptr_t)((Fex *)fex)->EntryPoint + (uintptr_t)fex))(((KernelAPI *)KAPIAddress));
if (DriverReturnCode::OK != ret)
return DriverCode::DRIVER_RETURNED_ERROR;
return DriverCode::OK;
}
DriverCode Driver::LoadDriver(uint64_t DriverAddress, uint64_t Size)
DriverCode Driver::LoadDriver(uintptr_t DriverAddress, uintptr_t Size)
{
Fex *DrvHdr = (Fex *)DriverAddress;
if (DrvHdr->Magic[0] != 'F' || DrvHdr->Magic[1] != 'E' || DrvHdr->Magic[2] != 'X' || DrvHdr->Magic[3] != '\0')
@ -114,7 +114,7 @@ namespace Driver
if (ElfDrvHdr->Type == FexFormatType::FexFormatType_Driver)
{
FexExtended *ElfDrvExtHdr = (FexExtended *)((uint64_t)ElfDrvHdr + EXTENDED_SECTION_ADDRESS);
FexExtended *ElfDrvExtHdr = (FexExtended *)((uintptr_t)ElfDrvHdr + EXTENDED_SECTION_ADDRESS);
debug("Name: \"%s\"; Type: %d; Callback: %#lx", ElfDrvExtHdr->Driver.Name, ElfDrvExtHdr->Driver.Type, ElfDrvExtHdr->Driver.Callback);
if (ElfDrvExtHdr->Driver.Bind.Type == DriverBindType::BIND_PCI)
@ -139,7 +139,7 @@ namespace Driver
if (DrvHdr->Type == FexFormatType::FexFormatType_Driver)
{
FexExtended *DrvExtHdr = (FexExtended *)((uint64_t)DrvHdr + EXTENDED_SECTION_ADDRESS);
FexExtended *DrvExtHdr = (FexExtended *)((uintptr_t)DrvHdr + EXTENDED_SECTION_ADDRESS);
debug("Name: \"%s\"; Type: %d; Callback: %#lx", DrvExtHdr->Driver.Name, DrvExtHdr->Driver.Type, DrvExtHdr->Driver.Callback);
if (DrvExtHdr->Driver.Bind.Type == DriverBindType::BIND_PCI)
@ -171,7 +171,7 @@ namespace Driver
cwk_path_get_extension(driver->Name, &extension, nullptr);
if (!strcmp(extension, ".fex") || !strcmp(extension, ".elf"))
{
uint64_t ret = this->LoadDriver(driver->Address, driver->Length);
uintptr_t ret = this->LoadDriver(driver->Address, driver->Length);
char RetString[128];
if (ret == DriverCode::OK)
strncpy(RetString, "\e058C19OK", 64);

View File

@ -14,13 +14,13 @@
namespace Driver
{
DriverCode Driver::DriverLoadBindInput(void *DrvExtHdr, uint64_t DriverAddress, uint64_t Size, bool IsElf)
DriverCode Driver::DriverLoadBindInput(void *DrvExtHdr, uintptr_t DriverAddress, size_t Size, bool IsElf)
{
Memory::Tracker *Tracker = new Memory::Tracker;
Fex *fex = (Fex *)Tracker->RequestPages(TO_PAGES(Size));
memcpy(fex, (void *)DriverAddress, Size);
FexExtended *fexExtended = (FexExtended *)((uint64_t)fex + EXTENDED_SECTION_ADDRESS);
debug("Driver allocated at %#lx-%#lx", fex, (uint64_t)fex + Size);
FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
debug("Driver allocated at %#lx-%#lx", fex, (uintptr_t)fex + Size);
#ifdef DEBUG
uint8_t *result = md5File((uint8_t *)fex, Size);
debug("MD5: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
@ -47,7 +47,7 @@ namespace Driver
KCallback->RawPtr = nullptr;
break;
KCallback->Reason = CallbackReason::ConfigurationReason;
int CallbackRet = ((int (*)(KernelCallback *))((uint64_t)fexExtended->Driver.Callback + (uint64_t)fex))(KCallback);
int CallbackRet = ((int (*)(KernelCallback *))((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex))(KCallback);
if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED)
{
delete Tracker;

View File

@ -14,13 +14,13 @@
namespace Driver
{
DriverCode Driver::DriverLoadBindInterrupt(void *DrvExtHdr, uint64_t DriverAddress, uint64_t Size, bool IsElf)
DriverCode Driver::DriverLoadBindInterrupt(void *DrvExtHdr, uintptr_t DriverAddress, size_t Size, bool IsElf)
{
Memory::Tracker *Tracker = new Memory::Tracker;
Fex *fex = (Fex *)Tracker->RequestPages(TO_PAGES(Size));
memcpy(fex, (void *)DriverAddress, Size);
FexExtended *fexExtended = (FexExtended *)((uint64_t)fex + EXTENDED_SECTION_ADDRESS);
debug("Driver allocated at %#lx-%#lx", fex, (uint64_t)fex + Size);
FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
debug("Driver allocated at %#lx-%#lx", fex, (uintptr_t)fex + Size);
#ifdef DEBUG
uint8_t *result = md5File((uint8_t *)fex, Size);
debug("MD5: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
@ -79,7 +79,7 @@ namespace Driver
KCallback->RawPtr = nullptr;
KCallback->Reason = CallbackReason::ConfigurationReason;
int CallbackRet = ((int (*)(KernelCallback *))((uint64_t)fexExtended->Driver.Callback + (uint64_t)fex))(KCallback);
int CallbackRet = ((int (*)(KernelCallback *))((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex))(KCallback);
if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED)
{
error("Driver %s does not implement the configuration callback", fexExtended->Driver.Name);
@ -111,7 +111,7 @@ namespace Driver
DriverInterruptHook *InterruptHook = nullptr;
if (((FexExtended *)DrvExtHdr)->Driver.Bind.Interrupt.Vector[0] != 0)
InterruptHook = new DriverInterruptHook(((FexExtended *)DrvExtHdr)->Driver.Bind.Interrupt.Vector[0] + 32, // x86
(void *)((uint64_t)fexExtended->Driver.Callback + (uint64_t)fex),
(void *)((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex),
KCallback);
for (unsigned long i = 0; i < sizeof(((FexExtended *)DrvExtHdr)->Driver.Bind.Interrupt.Vector) / sizeof(((FexExtended *)DrvExtHdr)->Driver.Bind.Interrupt.Vector[0]); i++)
@ -119,14 +119,14 @@ namespace Driver
if (((FexExtended *)DrvExtHdr)->Driver.Bind.Interrupt.Vector[i] == 0)
break;
// InterruptHook = new DriverInterruptHook(((FexExtended *)DrvExtHdr)->Driver.Bind.Interrupt.Vector[i] + 32, // x86
// (void *)((uint64_t)fexExtended->Driver.Callback + (uint64_t)fex),
// (void *)((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex),
// KCallback);
fixme("TODO: MULTIPLE BIND INTERRUPT VECTORS %d", ((FexExtended *)DrvExtHdr)->Driver.Bind.Interrupt.Vector[i]);
}
KCallback->RawPtr = nullptr;
KCallback->Reason = CallbackReason::ConfigurationReason;
int CallbackRet = ((int (*)(KernelCallback *))((uint64_t)fexExtended->Driver.Callback + (uint64_t)fex))(KCallback);
int CallbackRet = ((int (*)(KernelCallback *))((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex))(KCallback);
if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED)
{
error("Driver %s does not implement the configuration callback", fexExtended->Driver.Name);

View File

@ -14,7 +14,7 @@
namespace Driver
{
DriverCode Driver::DriverLoadBindPCI(void *DrvExtHdr, uint64_t DriverAddress, uint64_t Size, bool IsElf)
DriverCode Driver::DriverLoadBindPCI(void *DrvExtHdr, uintptr_t DriverAddress, size_t Size, bool IsElf)
{
for (unsigned long Vidx = 0; Vidx < sizeof(((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.VendorID) / sizeof(((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.VendorID[0]); Vidx++)
for (unsigned long Didx = 0; Didx < sizeof(((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.DeviceID) / sizeof(((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.DeviceID[0]); Didx++)
@ -34,8 +34,8 @@ namespace Driver
Memory::Tracker *Tracker = new Memory::Tracker();
Fex *fex = (Fex *)Tracker->RequestPages(TO_PAGES(Size));
memcpy(fex, (void *)DriverAddress, Size);
FexExtended *fexExtended = (FexExtended *)((uint64_t)fex + EXTENDED_SECTION_ADDRESS);
debug("Driver allocated at %#lx-%#lx", fex, (uint64_t)fex + Size);
FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
debug("Driver allocated at %#lx-%#lx", fex, (uintptr_t)fex + Size);
#ifdef DEBUG
uint8_t *result = md5File((uint8_t *)fex, Size);
debug("MD5: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
@ -60,21 +60,21 @@ namespace Driver
((PCI::PCIHeader0 *)PCIDevice)->BAR0 & (~15));
if ((((PCI::PCIHeader0 *)PCIDevice)->BAR0 & 1) != 0)
if (!Memory::Virtual().Check((void *)(uint64_t)(((PCI::PCIHeader0 *)PCIDevice)->BAR1 & (~3))))
if (!Memory::Virtual().Check((void *)(uintptr_t)(((PCI::PCIHeader0 *)PCIDevice)->BAR1 & (~3))))
{
debug("IO base (BAR1 & ~3) is not mapped");
Memory::Virtual().Map((void *)(uint64_t)(((PCI::PCIHeader0 *)PCIDevice)->BAR1 & (~3)), (void *)(uint64_t)(((PCI::PCIHeader0 *)PCIDevice)->BAR1 & (~3)), Memory::PTFlag::RW);
Memory::Virtual().Map((void *)(uintptr_t)(((PCI::PCIHeader0 *)PCIDevice)->BAR1 & (~3)), (void *)(uintptr_t)(((PCI::PCIHeader0 *)PCIDevice)->BAR1 & (~3)), Memory::PTFlag::RW);
}
if ((((PCI::PCIHeader0 *)PCIDevice)->BAR0 & 1) == 0)
if (!Memory::Virtual().Check((void *)(uint64_t)(((PCI::PCIHeader0 *)PCIDevice)->BAR0 & (~15))))
if (!Memory::Virtual().Check((void *)(uintptr_t)(((PCI::PCIHeader0 *)PCIDevice)->BAR0 & (~15))))
{
debug("Memory base (BAR0 & ~15) is not mapped");
Memory::Virtual().Map((void *)(uint64_t)(((PCI::PCIHeader0 *)PCIDevice)->BAR0 & (~15)), (void *)(uint64_t)(((PCI::PCIHeader0 *)PCIDevice)->BAR0 & (~15)), Memory::PTFlag::RW);
Memory::Virtual().Map((void *)(uintptr_t)(((PCI::PCIHeader0 *)PCIDevice)->BAR0 & (~15)), (void *)(uintptr_t)(((PCI::PCIHeader0 *)PCIDevice)->BAR0 & (~15)), Memory::PTFlag::RW);
uint64_t original = ((PCI::PCIHeader0 *)PCIDevice)->BAR0;
uintptr_t original = ((PCI::PCIHeader0 *)PCIDevice)->BAR0;
((PCI::PCIHeader0 *)PCIDevice)->BAR0 = 0xFFFFFFFF;
uint64_t size = ((PCI::PCIHeader0 *)PCIDevice)->BAR0 & 0xFFFFFFF0;
uintptr_t size = ((PCI::PCIHeader0 *)PCIDevice)->BAR0 & 0xFFFFFFF0;
((PCI::PCIHeader0 *)PCIDevice)->BAR0 = original;
debug("Size: %#lx (%ld pages)", size, TO_PAGES(size));
fixme("TODO: [BUG] Mapping is broken!!!!!!");
@ -97,12 +97,12 @@ namespace Driver
case FexDriverType::FexDriverType_Network:
{
DriverInterruptHook *InterruptHook = new DriverInterruptHook(((int)((PCI::PCIHeader0 *)devices[0])->InterruptLine) + 32, // x86
(void *)((uint64_t)fexExtended->Driver.Callback + (uint64_t)fex),
(void *)((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex),
KCallback);
KCallback->RawPtr = PCIDevice;
KCallback->Reason = CallbackReason::ConfigurationReason;
int CallbackRet = ((int (*)(KernelCallback *))((uint64_t)fexExtended->Driver.Callback + (uint64_t)fex))(KCallback);
int CallbackRet = ((int (*)(KernelCallback *))((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex))(KCallback);
if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED)
{
error("Driver %s does not implement the configuration callback", fexExtended->Driver.Name);
@ -134,7 +134,7 @@ namespace Driver
{
KCallback->RawPtr = PCIDevice;
KCallback->Reason = CallbackReason::ConfigurationReason;
int CallbackRet = ((int (*)(KernelCallback *))((uint64_t)fexExtended->Driver.Callback + (uint64_t)fex))(KCallback);
int CallbackRet = ((int (*)(KernelCallback *))((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex))(KCallback);
if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED)
{
error("Driver %s does not implement the configuration callback", fexExtended->Driver.Name);

View File

@ -14,7 +14,7 @@
namespace Driver
{
DriverCode Driver::DriverLoadBindProcess(void *DrvExtHdr, uint64_t DriverAddress, uint64_t Size, bool IsElf)
DriverCode Driver::DriverLoadBindProcess(void *DrvExtHdr, uintptr_t DriverAddress, size_t Size, bool IsElf)
{
fixme("Process driver: %s", ((FexExtended *)DrvExtHdr)->Driver.Name);
return DriverCode::NOT_IMPLEMENTED;

View File

@ -49,8 +49,8 @@ namespace Interrupts
CPU::x64::wrmsr(CPU::x64::MSR_SHADOW_GS_BASE, (uint64_t)CoreData);
CoreData->ID = Core;
CoreData->IsActive = true;
CoreData->SystemCallStack = (uint8_t *)((uint64_t)KernelAllocator.RequestPages(TO_PAGES(STACK_SIZE)) + STACK_SIZE);
CoreData->Stack = (uint64_t)KernelAllocator.RequestPages(TO_PAGES(STACK_SIZE)) + STACK_SIZE;
CoreData->SystemCallStack = (uint8_t *)((uintptr_t)KernelAllocator.RequestPages(TO_PAGES(STACK_SIZE)) + STACK_SIZE);
CoreData->Stack = (uintptr_t)KernelAllocator.RequestPages(TO_PAGES(STACK_SIZE)) + STACK_SIZE;
if (CoreData->Checksum != CPU_DATA_CHECKSUM)
{
KPrint("CPU %d checksum mismatch! %x != %x", Core, CoreData->Checksum, CPU_DATA_CHECKSUM);

View File

@ -6,10 +6,10 @@ namespace Xalloc
{
struct SpinLockData
{
uint64_t LockData = 0x0;
uintptr_t LockData = 0x0;
const char *CurrentHolder = "(null)";
const char *AttemptingToGet = "(null)";
uint64_t Count = 0;
size_t Count = 0;
};
void DeadLock(SpinLockData Lock)

View File

@ -45,9 +45,9 @@ __no_instrument_function void MapFromZero(PageTable4 *PT, BootInfo *Info)
void *NullAddress = KernelAllocator.RequestPage();
memset(NullAddress, 0, PAGE_SIZE); // TODO: If the CPU instruction pointer hits this page, there should be function to handle it. (memcpy assembly code?)
va.Map((void *)0, (void *)NullAddress, PTFlag::RW | PTFlag::US);
uint64_t VirtualOffsetNormalVMA = NORMAL_VMA_OFFSET;
uint64_t MemSize = Info->Memory.Size;
for (uint64_t t = 0; t < MemSize; t += PAGE_SIZE)
uintptr_t VirtualOffsetNormalVMA = NORMAL_VMA_OFFSET;
size_t MemSize = Info->Memory.Size;
for (size_t t = 0; t < MemSize; t += PAGE_SIZE)
{
va.Map((void *)t, (void *)t, PTFlag::RW /* | PTFlag::US */);
va.Map((void *)VirtualOffsetNormalVMA, (void *)t, PTFlag::RW /* | PTFlag::US */);
@ -70,8 +70,8 @@ __no_instrument_function void MapFramebuffer(PageTable4 *PT, BootInfo *Info)
if (!Info->Framebuffer[itrfb].BaseAddress)
break;
for (uint64_t fb_base = (uint64_t)Info->Framebuffer[itrfb].BaseAddress;
fb_base < ((uint64_t)Info->Framebuffer[itrfb].BaseAddress + ((Info->Framebuffer[itrfb].Pitch * Info->Framebuffer[itrfb].Height) + PAGE_SIZE));
for (uintptr_t fb_base = (uintptr_t)Info->Framebuffer[itrfb].BaseAddress;
fb_base < ((uintptr_t)Info->Framebuffer[itrfb].BaseAddress + ((Info->Framebuffer[itrfb].Pitch * Info->Framebuffer[itrfb].Height) + PAGE_SIZE));
fb_base += PAGE_SIZE)
va.Map((void *)fb_base, (void *)fb_base, PTFlag::RW | PTFlag::US | PTFlag::G);
itrfb++;
@ -84,14 +84,14 @@ __no_instrument_function void MapKernel(PageTable4 *PT, BootInfo *Info)
Kernel Start & Text Start ------ Text End ------ Kernel Rodata End ------ Kernel Data End & Kernel End
*/
Virtual va = Virtual(PT);
uint64_t KernelStart = (uint64_t)&_kernel_start;
uint64_t KernelTextEnd = (uint64_t)&_kernel_text_end;
uint64_t KernelDataEnd = (uint64_t)&_kernel_data_end;
uint64_t KernelRoDataEnd = (uint64_t)&_kernel_rodata_end;
uint64_t KernelEnd = (uint64_t)&_kernel_end;
uintptr_t KernelStart = (uintptr_t)&_kernel_start;
uintptr_t KernelTextEnd = (uintptr_t)&_kernel_text_end;
uintptr_t KernelDataEnd = (uintptr_t)&_kernel_data_end;
uintptr_t KernelRoDataEnd = (uintptr_t)&_kernel_rodata_end;
uintptr_t KernelEnd = (uintptr_t)&_kernel_end;
uint64_t BaseKernelMapAddress = (uint64_t)Info->Kernel.PhysicalBase;
uint64_t k;
uintptr_t BaseKernelMapAddress = (uintptr_t)Info->Kernel.PhysicalBase;
uintptr_t k;
for (k = KernelStart; k < KernelTextEnd; k += PAGE_SIZE)
{
@ -130,9 +130,9 @@ __no_instrument_function void InitializeMemoryManagement(BootInfo *Info)
#ifdef DEBUG
for (uint64_t i = 0; i < Info->Memory.Entries; i++)
{
uint64_t Base = reinterpret_cast<uint64_t>(Info->Memory.Entry[i].BaseAddress);
uint64_t Length = Info->Memory.Entry[i].Length;
uint64_t End = Base + Length;
uintptr_t Base = reinterpret_cast<uintptr_t>(Info->Memory.Entry[i].BaseAddress);
uintptr_t Length = Info->Memory.Entry[i].Length;
uintptr_t End = Base + Length;
const char *Type = "Unknown";
switch (Info->Memory.Entry[i].Type)
@ -233,7 +233,7 @@ __no_instrument_function void InitializeMemoryManagement(BootInfo *Info)
}
}
void *HeapMalloc(uint64_t Size)
void *HeapMalloc(size_t Size)
{
switch (AllocatorType)
{
@ -256,7 +256,7 @@ void *HeapMalloc(uint64_t Size)
}
}
void *HeapCalloc(uint64_t n, uint64_t Size)
void *HeapCalloc(size_t n, size_t Size)
{
switch (AllocatorType)
{
@ -279,7 +279,7 @@ void *HeapCalloc(uint64_t n, uint64_t Size)
}
}
void *HeapRealloc(void *Address, uint64_t Size)
void *HeapRealloc(void *Address, size_t Size)
{
switch (AllocatorType)
{

View File

@ -2,10 +2,10 @@
namespace Memory
{
Virtual::PageMapIndexer::PageMapIndexer(uint64_t VirtualAddress)
Virtual::PageMapIndexer::PageMapIndexer(uintptr_t VirtualAddress)
{
#if defined(__amd64__)
uint64_t Address = VirtualAddress;
uintptr_t Address = VirtualAddress;
Address >>= 12;
this->PTEIndex = Address & 0x1FF;
Address >>= 9;
@ -15,7 +15,7 @@ namespace Memory
Address >>= 9;
this->PMLIndex = Address & 0x1FF;
#elif defined(__i386__)
uint64_t Address = VirtualAddress;
uintptr_t Address = VirtualAddress;
Address >>= 12;
this->PTEIndex = Address & 0x3FF;
Address >>= 10;

View File

@ -34,10 +34,10 @@ namespace Memory
return false;
}
bool Physical::SwapPages(void *Address, uint64_t PageCount)
bool Physical::SwapPages(void *Address, size_t PageCount)
{
for (uint64_t i = 0; i < PageCount; i++)
if (!this->SwapPage((void *)((uint64_t)Address + (i * PAGE_SIZE))))
for (size_t i = 0; i < PageCount; i++)
if (!this->SwapPage((void *)((uintptr_t)Address + (i * PAGE_SIZE))))
return false;
return false;
}
@ -48,10 +48,10 @@ namespace Memory
return false;
}
bool Physical::UnswapPages(void *Address, uint64_t PageCount)
bool Physical::UnswapPages(void *Address, size_t PageCount)
{
for (uint64_t i = 0; i < PageCount; i++)
if (!this->UnswapPage((void *)((uint64_t)Address + (i * PAGE_SIZE))))
for (size_t i = 0; i < PageCount; i++)
if (!this->UnswapPage((void *)((uintptr_t)Address + (i * PAGE_SIZE))))
return false;
return false;
}
@ -78,7 +78,7 @@ namespace Memory
return nullptr;
}
void *Physical::RequestPages(uint64_t Count)
void *Physical::RequestPages(size_t Count)
{
SmartLock(this->MemoryLock);
for (; PageBitmapIndex < PageBitmap.Size * 8; PageBitmapIndex++)
@ -91,7 +91,7 @@ namespace Memory
if (PageBitmap[Index] == true)
continue;
for (uint64_t i = 0; i < Count; i++)
for (size_t i = 0; i < Count; i++)
if (PageBitmap[Index + i] == true)
goto NextPage;
@ -123,7 +123,7 @@ namespace Memory
warn("Null pointer passed to FreePage.");
return;
}
uint64_t Index = (uint64_t)Address / PAGE_SIZE;
size_t Index = (size_t)Address / PAGE_SIZE;
if (unlikely(PageBitmap[Index] == false))
return;
@ -136,7 +136,7 @@ namespace Memory
}
}
void Physical::FreePages(void *Address, uint64_t Count)
void Physical::FreePages(void *Address, size_t Count)
{
if (unlikely(Address == nullptr || Count == 0))
{
@ -144,8 +144,8 @@ namespace Memory
return;
}
for (uint64_t t = 0; t < Count; t++)
this->FreePage((void *)((uint64_t)Address + (t * PAGE_SIZE)));
for (size_t t = 0; t < Count; t++)
this->FreePage((void *)((uintptr_t)Address + (t * PAGE_SIZE)));
}
void Physical::LockPage(void *Address)
@ -153,7 +153,7 @@ namespace Memory
if (unlikely(Address == nullptr))
warn("Trying to lock null address.");
uint64_t Index = (uint64_t)Address / PAGE_SIZE;
uintptr_t Index = (uintptr_t)Address / PAGE_SIZE;
if (unlikely(PageBitmap[Index] == true))
return;
if (PageBitmap.Set(Index, true))
@ -163,13 +163,13 @@ namespace Memory
}
}
void Physical::LockPages(void *Address, uint64_t PageCount)
void Physical::LockPages(void *Address, size_t PageCount)
{
if (unlikely(Address == nullptr || PageCount == 0))
warn("Trying to lock %s%s.", Address ? "null address" : "", PageCount ? "0 pages" : "");
for (uint64_t i = 0; i < PageCount; i++)
this->LockPage((void *)((uint64_t)Address + (i * PAGE_SIZE)));
for (size_t i = 0; i < PageCount; i++)
this->LockPage((void *)((uintptr_t)Address + (i * PAGE_SIZE)));
}
void Physical::ReservePage(void *Address)
@ -177,7 +177,7 @@ namespace Memory
if (unlikely(Address == nullptr))
warn("Trying to reserve null address.");
uint64_t Index = (uint64_t)Address / PAGE_SIZE;
uintptr_t Index = (uintptr_t)Address / PAGE_SIZE;
if (unlikely(PageBitmap[Index] == true))
return;
@ -188,13 +188,13 @@ namespace Memory
}
}
void Physical::ReservePages(void *Address, uint64_t PageCount)
void Physical::ReservePages(void *Address, size_t PageCount)
{
if (unlikely(Address == nullptr || PageCount == 0))
warn("Trying to reserve %s%s.", Address ? "null address" : "", PageCount ? "0 pages" : "");
for (uint64_t t = 0; t < PageCount; t++)
this->ReservePage((void *)((uint64_t)Address + (t * PAGE_SIZE)));
for (size_t t = 0; t < PageCount; t++)
this->ReservePage((void *)((uintptr_t)Address + (t * PAGE_SIZE)));
}
void Physical::UnreservePage(void *Address)
@ -202,7 +202,7 @@ namespace Memory
if (unlikely(Address == nullptr))
warn("Trying to unreserve null address.");
uint64_t Index = (uint64_t)Address / PAGE_SIZE;
uintptr_t Index = (uintptr_t)Address / PAGE_SIZE;
if (unlikely(PageBitmap[Index] == false))
return;
@ -215,13 +215,13 @@ namespace Memory
}
}
void Physical::UnreservePages(void *Address, uint64_t PageCount)
void Physical::UnreservePages(void *Address, size_t PageCount)
{
if (unlikely(Address == nullptr || PageCount == 0))
warn("Trying to unreserve %s%s.", Address ? "null address" : "", PageCount ? "0 pages" : "");
for (uint64_t t = 0; t < PageCount; t++)
this->UnreservePage((void *)((uint64_t)Address + (t * PAGE_SIZE)));
for (size_t t = 0; t < PageCount; t++)
this->UnreservePage((void *)((uintptr_t)Address + (t * PAGE_SIZE)));
}
void Physical::Init(BootInfo *Info)
@ -253,14 +253,14 @@ namespace Memory
CPU::Stop();
}
uint64_t BitmapSize = (MemorySize / PAGE_SIZE) / 8 + 1;
size_t BitmapSize = (MemorySize / PAGE_SIZE) / 8 + 1;
trace("Initializing Bitmap at %llp-%llp (%lld Bytes)",
LargestFreeMemorySegment,
(void *)((uint64_t)LargestFreeMemorySegment + BitmapSize),
(void *)((uintptr_t)LargestFreeMemorySegment + BitmapSize),
BitmapSize);
PageBitmap.Size = BitmapSize;
PageBitmap.Buffer = (uint8_t *)LargestFreeMemorySegment;
for (uint64_t i = 0; i < BitmapSize; i++)
for (size_t i = 0; i < BitmapSize; i++)
*(uint8_t *)(PageBitmap.Buffer + i) = 0;
trace("Reserving pages...");

View File

@ -13,18 +13,18 @@ namespace Memory
void *AllocatedStack = KernelAllocator.RequestPages(TO_PAGES(USER_STACK_SIZE));
debug("AllocatedStack: %p", AllocatedStack);
memset(AllocatedStack, 0, USER_STACK_SIZE);
for (uint64_t i = 0; i < TO_PAGES(USER_STACK_SIZE); i++)
for (size_t i = 0; i < TO_PAGES(USER_STACK_SIZE); i++)
{
Virtual(Table).Map((void *)(USER_STACK_BASE + (i * PAGE_SIZE)),
(void *)((uint64_t)AllocatedStack + (i * PAGE_SIZE)),
(void *)((uintptr_t)AllocatedStack + (i * PAGE_SIZE)),
PTFlag::RW | PTFlag::US);
debug("Mapped %p to %p", (void *)(USER_STACK_BASE + (i * PAGE_SIZE)),
(void *)((uint64_t)AllocatedStack + (i * PAGE_SIZE)));
(void *)((uintptr_t)AllocatedStack + (i * PAGE_SIZE)));
}
this->StackBottom = (void *)USER_STACK_BASE;
this->StackTop = (void *)(USER_STACK_BASE + USER_STACK_SIZE);
this->StackPhyiscalBottom = AllocatedStack;
this->StackPhyiscalTop = (void *)((uint64_t)AllocatedStack + USER_STACK_SIZE);
this->StackPhyiscalTop = (void *)((uintptr_t)AllocatedStack + USER_STACK_SIZE);
this->Size = USER_STACK_SIZE;
}
else
@ -33,7 +33,7 @@ namespace Memory
this->StackPhyiscalBottom = this->StackBottom;
debug("StackBottom: %p", this->StackBottom);
memset(this->StackBottom, 0, STACK_SIZE);
this->StackTop = (void *)((uint64_t)this->StackBottom + STACK_SIZE);
this->StackTop = (void *)((uintptr_t)this->StackBottom + STACK_SIZE);
this->StackPhyiscalTop = this->StackTop;
this->Size = STACK_SIZE;
}
@ -47,12 +47,12 @@ namespace Memory
// debug("Freed stack at %p", this->StackBottom);
}
bool StackGuard::Expand(uint64_t FaultAddress)
bool StackGuard::Expand(uintptr_t FaultAddress)
{
if (this->UserMode)
{
if (FaultAddress < (uint64_t)this->StackBottom - USER_STACK_SIZE ||
FaultAddress > (uint64_t)this->StackTop)
if (FaultAddress < (uintptr_t)this->StackBottom - USER_STACK_SIZE ||
FaultAddress > (uintptr_t)this->StackTop)
{
return false; // It's not about the stack.
}
@ -61,12 +61,12 @@ namespace Memory
void *AllocatedStack = KernelAllocator.RequestPages(TO_PAGES(USER_STACK_SIZE));
debug("AllocatedStack: %p", AllocatedStack);
memset(AllocatedStack, 0, USER_STACK_SIZE);
for (uint64_t i = 0; i < TO_PAGES(USER_STACK_SIZE); i++)
for (uintptr_t i = 0; i < TO_PAGES(USER_STACK_SIZE); i++)
{
Virtual(this->Table).Map((void *)((uint64_t)this->StackBottom - (i * PAGE_SIZE)), (void *)((uint64_t)AllocatedStack + (i * PAGE_SIZE)), PTFlag::RW | PTFlag::US);
debug("Mapped %p to %p", (void *)((uint64_t)this->StackBottom - (i * PAGE_SIZE)), (void *)((uint64_t)AllocatedStack + (i * PAGE_SIZE)));
Virtual(this->Table).Map((void *)((uintptr_t)this->StackBottom - (i * PAGE_SIZE)), (void *)((uintptr_t)AllocatedStack + (i * PAGE_SIZE)), PTFlag::RW | PTFlag::US);
debug("Mapped %p to %p", (void *)((uintptr_t)this->StackBottom - (i * PAGE_SIZE)), (void *)((uintptr_t)AllocatedStack + (i * PAGE_SIZE)));
}
this->StackBottom = (void *)((uint64_t)this->StackBottom - USER_STACK_SIZE);
this->StackBottom = (void *)((uintptr_t)this->StackBottom - USER_STACK_SIZE);
this->Size += USER_STACK_SIZE;
info("Stack expanded to %p", this->StackBottom);
return true;

View File

@ -11,22 +11,22 @@ namespace Memory
return FROM_PAGES(Size);
}
void *Tracker::RequestPages(uint64_t Count)
void *Tracker::RequestPages(size_t Count)
{
void *Address = KernelAllocator.RequestPages(Count);
for (uint64_t i = 0; i < Count; i++)
Memory::Virtual(this->PageTable).Remap((void *)((uint64_t)Address + (i * PAGE_SIZE)), (void *)((uint64_t)Address + (i * PAGE_SIZE)), Memory::PTFlag::RW | Memory::PTFlag::US);
for (size_t i = 0; i < Count; i++)
Memory::Virtual(this->PageTable).Remap((void *)((uintptr_t)Address + (i * PAGE_SIZE)), (void *)((uint64_t)Address + (i * PAGE_SIZE)), Memory::PTFlag::RW | Memory::PTFlag::US);
AllocatedPagesList.push_back({Address, Count});
return Address;
}
void Tracker::FreePages(void *Address, uint64_t Count)
void Tracker::FreePages(void *Address, size_t Count)
{
KernelAllocator.FreePages(Address, Count);
for (uint64_t i = 0; i < Count; i++)
Memory::Virtual(this->PageTable).Remap((void *)((uint64_t)Address + (i * PAGE_SIZE)), (void *)((uint64_t)Address + (i * PAGE_SIZE)), Memory::PTFlag::RW);
for (size_t i = 0; i < Count; i++)
Memory::Virtual(this->PageTable).Remap((void *)((uintptr_t)Address + (i * PAGE_SIZE)), (void *)((uint64_t)Address + (i * PAGE_SIZE)), Memory::PTFlag::RW);
for (uint64_t i = 0; i < AllocatedPagesList.size(); i++)
for (uintptr_t i = 0; i < AllocatedPagesList.size(); i++)
if (AllocatedPagesList[i].Address == Address)
{
AllocatedPagesList.remove(i);
@ -48,8 +48,8 @@ namespace Memory
foreach (auto var in AllocatedPagesList)
{
KernelAllocator.FreePages(var.Address, var.PageCount);
for (uint64_t i = 0; i < var.PageCount; i++)
Memory::Virtual(this->PageTable).Remap((void *)((uint64_t)var.Address + (i * PAGE_SIZE)), (void *)((uint64_t)var.Address + (i * PAGE_SIZE)), Memory::PTFlag::RW);
for (size_t i = 0; i < var.PageCount; i++)
Memory::Virtual(this->PageTable).Remap((void *)((uintptr_t)var.Address + (i * PAGE_SIZE)), (void *)((uintptr_t)var.Address + (i * PAGE_SIZE)), Memory::PTFlag::RW);
}
debug("Tracker destroyed.");
}

View File

@ -8,10 +8,10 @@ namespace Memory
bool Virtual::Check(void *VirtualAddress, PTFlag Flag)
{
// 0x1000 aligned
uint64_t Address = (uint64_t)VirtualAddress;
uintptr_t Address = (uintptr_t)VirtualAddress;
Address &= 0xFFFFFFFFFFFFF000;
PageMapIndexer Index = PageMapIndexer((uint64_t)Address);
PageMapIndexer Index = PageMapIndexer(Address);
PageMapLevel4 PML4 = this->Table->Entries[Index.PMLIndex];
PageDirectoryPointerTableEntryPtr *PDPTE = nullptr;
@ -20,15 +20,15 @@ namespace Memory
if ((PML4.raw & Flag) > 0)
{
PDPTE = (PageDirectoryPointerTableEntryPtr *)((uint64_t)PML4.GetAddress() << 12);
PDPTE = (PageDirectoryPointerTableEntryPtr *)((uintptr_t)PML4.GetAddress() << 12);
if (PDPTE)
if ((PDPTE->Entries[Index.PDPTEIndex].Present))
{
PDE = (PageDirectoryEntryPtr *)((uint64_t)PDPTE->Entries[Index.PDPTEIndex].GetAddress() << 12);
PDE = (PageDirectoryEntryPtr *)((uintptr_t)PDPTE->Entries[Index.PDPTEIndex].GetAddress() << 12);
if (PDE)
if ((PDE->Entries[Index.PDEIndex].Present))
{
PTE = (PageTableEntryPtr *)((uint64_t)PDE->Entries[Index.PDEIndex].GetAddress() << 12);
PTE = (PageTableEntryPtr *)((uintptr_t)PDE->Entries[Index.PDEIndex].GetAddress() << 12);
if (PTE)
if ((PTE->Entries[Index.PTEIndex].Present))
{
@ -49,7 +49,7 @@ namespace Memory
return;
}
PageMapIndexer Index = PageMapIndexer((uint64_t)VirtualAddress);
PageMapIndexer Index = PageMapIndexer((uintptr_t)VirtualAddress);
// Clear any flags that are not 1 << 0 (Present) - 1 << 5 (Accessed) because rest are for page table entries only
uint64_t DirectoryFlags = Flags & 0x3F;
@ -60,10 +60,10 @@ namespace Memory
PDPTEPtr = (PageDirectoryPointerTableEntryPtr *)KernelAllocator.RequestPage();
memset(PDPTEPtr, 0, PAGE_SIZE);
PML4.Present = true;
PML4.SetAddress((uint64_t)PDPTEPtr >> 12);
PML4.SetAddress((uintptr_t)PDPTEPtr >> 12);
}
else
PDPTEPtr = (PageDirectoryPointerTableEntryPtr *)((uint64_t)PML4.GetAddress() << 12);
PDPTEPtr = (PageDirectoryPointerTableEntryPtr *)((uintptr_t)PML4.GetAddress() << 12);
PML4.raw |= DirectoryFlags;
this->Table->Entries[Index.PMLIndex] = PML4;
@ -74,10 +74,10 @@ namespace Memory
PDEPtr = (PageDirectoryEntryPtr *)KernelAllocator.RequestPage();
memset(PDEPtr, 0, PAGE_SIZE);
PDPTE.Present = true;
PDPTE.SetAddress((uint64_t)PDEPtr >> 12);
PDPTE.SetAddress((uintptr_t)PDEPtr >> 12);
}
else
PDEPtr = (PageDirectoryEntryPtr *)((uint64_t)PDPTE.GetAddress() << 12);
PDEPtr = (PageDirectoryEntryPtr *)((uintptr_t)PDPTE.GetAddress() << 12);
PDPTE.raw |= DirectoryFlags;
PDPTEPtr->Entries[Index.PDPTEIndex] = PDPTE;
@ -88,17 +88,17 @@ namespace Memory
PTEPtr = (PageTableEntryPtr *)KernelAllocator.RequestPage();
memset(PTEPtr, 0, PAGE_SIZE);
PDE.Present = true;
PDE.SetAddress((uint64_t)PTEPtr >> 12);
PDE.SetAddress((uintptr_t)PTEPtr >> 12);
}
else
PTEPtr = (PageTableEntryPtr *)((uint64_t)PDE.GetAddress() << 12);
PTEPtr = (PageTableEntryPtr *)((uintptr_t)PDE.GetAddress() << 12);
PDE.raw |= DirectoryFlags;
PDEPtr->Entries[Index.PDEIndex] = PDE;
PageTableEntry PTE = PTEPtr->Entries[Index.PTEIndex];
PTE.Present = true;
PTE.raw |= Flags;
PTE.SetAddress((uint64_t)PhysicalAddress >> 12);
PTE.SetAddress((uintptr_t)PhysicalAddress >> 12);
PTEPtr->Entries[Index.PTEIndex] = PTE;
#if defined(__amd64__)
@ -133,10 +133,10 @@ namespace Memory
#endif
}
void Virtual::Map(void *VirtualAddress, void *PhysicalAddress, uint64_t PageCount, uint64_t Flags)
void Virtual::Map(void *VirtualAddress, void *PhysicalAddress, size_t PageCount, uint64_t Flags)
{
for (uint64_t i = 0; i < PageCount; i++)
this->Map((void *)((uint64_t)VirtualAddress + (i * PAGE_SIZE)), (void *)((uint64_t)PhysicalAddress + (i * PAGE_SIZE)), Flags);
for (size_t i = 0; i < PageCount; i++)
this->Map((void *)((uintptr_t)VirtualAddress + (i * PAGE_SIZE)), (void *)((uintptr_t)PhysicalAddress + (i * PAGE_SIZE)), Flags);
}
void Virtual::Unmap(void *VirtualAddress)
@ -148,28 +148,28 @@ namespace Memory
return;
}
PageMapIndexer Index = PageMapIndexer((uint64_t)VirtualAddress);
PageMapIndexer Index = PageMapIndexer((uintptr_t)VirtualAddress);
PageMapLevel4 PML4 = this->Table->Entries[Index.PMLIndex];
if (!PML4.Present)
{
error("Page not present");
return;
}
PageDirectoryPointerTableEntryPtr *PDPTEPtr = (PageDirectoryPointerTableEntryPtr *)((uint64_t)PML4.Address << 12);
PageDirectoryPointerTableEntryPtr *PDPTEPtr = (PageDirectoryPointerTableEntryPtr *)((uintptr_t)PML4.Address << 12);
PageDirectoryPointerTableEntry PDPTE = PDPTEPtr->Entries[Index.PDPTEIndex];
if (!PDPTE.Present)
{
error("Page not present");
return;
}
PageDirectoryEntryPtr *PDEPtr = (PageDirectoryEntryPtr *)((uint64_t)PDPTE.Address << 12);
PageDirectoryEntryPtr *PDEPtr = (PageDirectoryEntryPtr *)((uintptr_t)PDPTE.Address << 12);
PageDirectoryEntry PDE = PDEPtr->Entries[Index.PDEIndex];
if (!PDE.Present)
{
error("Page not present");
return;
}
PageTableEntryPtr *PTEPtr = (PageTableEntryPtr *)((uint64_t)PDE.Address << 12);
PageTableEntryPtr *PTEPtr = (PageTableEntryPtr *)((uintptr_t)PDE.Address << 12);
PageTableEntry PTE = PTEPtr->Entries[Index.PTEIndex];
if (!PTE.Present)
{
@ -195,10 +195,10 @@ namespace Memory
#endif
}
void Virtual::Unmap(void *VirtualAddress, uint64_t PageCount)
void Virtual::Unmap(void *VirtualAddress, size_t PageCount)
{
for (uint64_t i = 0; i < PageCount; i++)
this->Unmap((void *)((uint64_t)VirtualAddress + (i * PAGE_SIZE)));
for (size_t i = 0; i < PageCount; i++)
this->Unmap((void *)((uintptr_t)VirtualAddress + (i * PAGE_SIZE)));
}
void Virtual::Remap(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags)

View File

@ -772,10 +772,10 @@ namespace PCI
}
#endif
void PCI::EnumerateFunction(uint64_t DeviceAddress, uint64_t Function)
void PCI::EnumerateFunction(uintptr_t DeviceAddress, uintptr_t Function)
{
uint64_t Offset = Function << 12;
uint64_t FunctionAddress = DeviceAddress + Offset;
uintptr_t Offset = Function << 12;
uintptr_t FunctionAddress = DeviceAddress + Offset;
Memory::Virtual().Map((void *)FunctionAddress, (void *)FunctionAddress, Memory::PTFlag::RW);
PCIDeviceHeader *PCIDeviceHdr = (PCIDeviceHeader *)FunctionAddress;
if (PCIDeviceHdr->DeviceID == 0)
@ -788,24 +788,24 @@ namespace PCI
#endif
}
void PCI::EnumerateDevice(uint64_t BusAddress, uint64_t Device)
void PCI::EnumerateDevice(uintptr_t BusAddress, uintptr_t Device)
{
uint64_t Offset = Device << 15;
uint64_t DeviceAddress = BusAddress + Offset;
uintptr_t Offset = Device << 15;
uintptr_t DeviceAddress = BusAddress + Offset;
Memory::Virtual().Map((void *)DeviceAddress, (void *)DeviceAddress, Memory::PTFlag::RW);
PCIDeviceHeader *PCIDeviceHdr = (PCIDeviceHeader *)DeviceAddress;
if (PCIDeviceHdr->DeviceID == 0)
return;
if (PCIDeviceHdr->DeviceID == 0xFFFF)
return;
for (uint64_t Function = 0; Function < 8; Function++)
for (uintptr_t Function = 0; Function < 8; Function++)
EnumerateFunction(DeviceAddress, Function);
}
void PCI::EnumerateBus(uint64_t BaseAddress, uint64_t Bus)
void PCI::EnumerateBus(uintptr_t BaseAddress, uintptr_t Bus)
{
uint64_t Offset = Bus << 20;
uint64_t BusAddress = BaseAddress + Offset;
uintptr_t Offset = Bus << 20;
uintptr_t BusAddress = BaseAddress + Offset;
Memory::Virtual().Map((void *)BusAddress, (void *)BusAddress, Memory::PTFlag::RW);
PCIDeviceHeader *PCIDeviceHdr = (PCIDeviceHeader *)BusAddress;
if (Bus != 0) // TODO: VirtualBox workaround (UNTESTED ON REAL HARDWARE!)
@ -820,7 +820,7 @@ namespace PCI
PCIDeviceHdr->CacheLineSize, PCIDeviceHdr->Class, PCIDeviceHdr->Command,
PCIDeviceHdr->HeaderType, PCIDeviceHdr->LatencyTimer, PCIDeviceHdr->ProgIF,
PCIDeviceHdr->RevisionID, PCIDeviceHdr->Status, PCIDeviceHdr->Subclass);
for (uint64_t Device = 0; Device < 32; Device++)
for (uintptr_t Device = 0; Device < 32; Device++)
EnumerateDevice(BusAddress, Device);
}
@ -848,11 +848,11 @@ namespace PCI
int Entries = ((((ACPI::ACPI *)PowerManager->GetACPI())->MCFG->Header.Length) - sizeof(ACPI::ACPI::MCFGHeader)) / sizeof(DeviceConfig);
for (int t = 0; t < Entries; t++)
{
DeviceConfig *NewDeviceConfig = (DeviceConfig *)((uint64_t)((ACPI::ACPI *)PowerManager->GetACPI())->MCFG + sizeof(ACPI::ACPI::MCFGHeader) + (sizeof(DeviceConfig) * t));
DeviceConfig *NewDeviceConfig = (DeviceConfig *)((uintptr_t)((ACPI::ACPI *)PowerManager->GetACPI())->MCFG + sizeof(ACPI::ACPI::MCFGHeader) + (sizeof(DeviceConfig) * t));
Memory::Virtual().Map((void *)NewDeviceConfig->BaseAddress, (void *)NewDeviceConfig->BaseAddress, Memory::PTFlag::RW);
trace("PCI Entry %d Address:%#llx BUS:%#llx-%#llx", t, NewDeviceConfig->BaseAddress,
NewDeviceConfig->StartBus, NewDeviceConfig->EndBus);
for (uint64_t Bus = NewDeviceConfig->StartBus; Bus < NewDeviceConfig->EndBus; Bus++)
for (uintptr_t Bus = NewDeviceConfig->StartBus; Bus < NewDeviceConfig->EndBus; Bus++)
EnumerateBus(NewDeviceConfig->BaseAddress, Bus);
}
#elif defined(__i386__)

View File

@ -52,7 +52,7 @@ typedef struct
namespace SymbolResolver
{
Symbols::Symbols(uint64_t ImageAddress)
Symbols::Symbols(uintptr_t ImageAddress)
{
debug("Solving symbols for address: %#llx", ImageAddress);
Elf64_Ehdr *Header = (Elf64_Ehdr *)ImageAddress;
@ -68,7 +68,7 @@ namespace SymbolResolver
Elf64_Sym *ElfSymbols = nullptr;
char *strtab = nullptr;
for (uint64_t i = 0; i < Header->e_shnum; i++)
for (uint16_t i = 0; i < Header->e_shnum; i++)
switch (ElfSections[i].sh_type)
{
case SHT_SYMTAB:
@ -83,7 +83,7 @@ namespace SymbolResolver
}
else
{
strtab = (char *)(uint64_t)ImageAddress + ElfSections[i].sh_offset;
strtab = (char *)(ImageAddress + ElfSections[i].sh_offset);
debug("String table found, %d entries", ElfSections[i].sh_size);
}
break;
@ -91,8 +91,8 @@ namespace SymbolResolver
if (ElfSymbols != nullptr && strtab != nullptr)
{
size_t Index, MinimumIndex;
for (size_t i = 0; i < this->TotalEntries - 1; i++)
uintptr_t Index, MinimumIndex;
for (uintptr_t i = 0; i < this->TotalEntries - 1; i++)
{
MinimumIndex = i;
for (Index = i + 1; Index < this->TotalEntries; Index++)
@ -114,7 +114,7 @@ namespace SymbolResolver
#endif
trace("Symbol table loaded, %d entries (%ldKB)", this->TotalEntries, TO_KB(this->TotalEntries * sizeof(SymbolTable)));
for (size_t i = 0, g = this->TotalEntries; i < g; i++)
for (uintptr_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];
@ -133,10 +133,10 @@ namespace SymbolResolver
Symbols::~Symbols() {}
const __no_instrument_function char *Symbols::GetSymbolFromAddress(uint64_t Address)
const __no_instrument_function char *Symbols::GetSymbolFromAddress(uintptr_t Address)
{
Symbols::SymbolTable Result{0, (char *)"<unknown>"};
for (size_t i = 0; i < this->TotalEntries; i++)
for (uintptr_t i = 0; i < this->TotalEntries; i++)
if (this->SymTable[i].Address <= Address && this->SymTable[i].Address > Result.Address)
Result = this->SymTable[i];
return Result.FunctionName;

View File

@ -38,16 +38,16 @@ namespace SMBIOS
SMBIOSEntryPoint *Header = (SMBIOSEntryPoint *)bInfo->SMBIOSPtr;
debug("Getting SMBIOS header for type %d", Type);
struct SMBIOSHeader *hdr = (SMBIOSHeader *)(uint64_t)Header->TableAddress;
struct SMBIOSHeader *hdr = (SMBIOSHeader *)(uintptr_t)Header->TableAddress;
for (int i = 0; i <= 11; i++)
{
if (hdr < (void *)(uint64_t)(Header->TableAddress + Header->TableLength))
if (hdr < (void *)(uintptr_t)(Header->TableAddress + Header->TableLength))
if (hdr->Type == Type)
{
debug("Found SMBIOS header for type %d at %#lx", Type, hdr);
return hdr;
}
hdr = (struct SMBIOSHeader *)((uint64_t)hdr + SMBIOSTableLength(hdr));
hdr = (struct SMBIOSHeader *)((uintptr_t)hdr + SMBIOSTableLength(hdr));
}
return nullptr;
}

View File

@ -12,10 +12,10 @@
namespace Time
{
void time::Sleep(uint64_t Milliseconds)
void time::Sleep(uintptr_t Milliseconds)
{
#if defined(__amd64__) || defined(__i386__)
uint64_t Target = mminq(&((HPET *)hpet)->MainCounterValue) + (Milliseconds * 1000000000) / clk;
uintptr_t Target = mminq(&((HPET *)hpet)->MainCounterValue) + (Milliseconds * 1000000000) / clk;
while (mminq(&((HPET *)hpet)->MainCounterValue) < Target)
CPU::Pause();
#elif defined(__aarch64__)

View File

@ -138,7 +138,7 @@ namespace UniversalAsynchronousReceiverTransmitter
SafeFunction __no_instrument_function Events::~Events()
{
for (uint64_t i = 0; i < RegisteredEvents.size(); i++)
for (uintptr_t i = 0; i < RegisteredEvents.size(); i++)
if (RegisteredEvents[i] == this)
{
RegisteredEvents.remove(i);

View File

@ -3,9 +3,9 @@
#include <uart.hpp>
#include <debug.h>
extern uint64_t _binary_Files_ter_powerline_v12n_psf_start;
extern uint64_t _binary_Files_ter_powerline_v12n_psf_end;
extern uint64_t _binary_Files_ter_powerline_v12n_psf_size;
extern uintptr_t _binary_Files_ter_powerline_v12n_psf_start;
extern uintptr_t _binary_Files_ter_powerline_v12n_psf_end;
extern uintptr_t _binary_Files_ter_powerline_v12n_psf_size;
NewLock(PrintLock);
@ -67,7 +67,7 @@ namespace Video
for (unsigned long Y = this->Buffers[Index]->CursorY; Y < this->Buffers[Index]->CursorY + fonthdrHeight; Y++)
for (unsigned long X = this->Buffers[Index]->CursorX - fonthdrWidth; X < this->Buffers[Index]->CursorX; X++)
*(uint32_t *)((uint64_t)this->Buffers[Index]->Buffer +
*(uint32_t *)((uintptr_t)this->Buffers[Index]->Buffer +
(Y * this->Buffers[Index]->Width + X) * (this->framebuffer.BitsPerPixel / 8)) = 0;
break;
}
@ -145,7 +145,7 @@ namespace Video
{
for (uint64_t X = this->Buffers[Index]->CursorX; X < this->Buffers[Index]->CursorX + fonthdrWidth; X++)
if ((*FontPtr & (0b10000000 >> (X - this->Buffers[Index]->CursorX))) > 0)
*(uint32_t *)((uint64_t)this->Buffers[Index]->Buffer +
*(uint32_t *)((uintptr_t)this->Buffers[Index]->Buffer +
(Y * this->Buffers[Index]->Width + X) * (this->framebuffer.BitsPerPixel / 8)) = this->Buffers[Index]->Color;
FontPtr += BytesPerLine;

View File

@ -4,7 +4,7 @@
namespace Video
{
Font::Font(uint64_t *Start, uint64_t *End, FontType Type)
Font::Font(uintptr_t *Start, uintptr_t *End, FontType Type)
{
trace("Initializing font with start %#llx and end %#llx Type: %d", Start, End, Type);
this->Info.StartAddress = Start;
@ -14,9 +14,9 @@ namespace Video
{
this->Info.PSF2Font = new PSF2_FONT;
uint64_t FontDataLength = End - Start;
uintptr_t FontDataLength = End - Start;
PSF2_HEADER *font2 = (PSF2_HEADER *)KernelAllocator.RequestPages(FontDataLength / PAGE_SIZE + 1);
for (uint64_t i = 0; i < FontDataLength / PAGE_SIZE + 1; i++)
for (uintptr_t i = 0; i < FontDataLength / PAGE_SIZE + 1; i++)
Memory::Virtual().Map((void *)(font2 + (i * PAGE_SIZE)), (void *)(font2 + (i * PAGE_SIZE)), Memory::PTFlag::RW);
memcpy((void *)font2, Start, FontDataLength);
@ -26,7 +26,7 @@ namespace Video
error("Font2 magic mismatch.");
this->Info.PSF2Font->Header = font2;
this->Info.PSF2Font->GlyphBuffer = reinterpret_cast<void *>(reinterpret_cast<uint64_t>(Start) + sizeof(PSF2_HEADER));
this->Info.PSF2Font->GlyphBuffer = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(Start) + sizeof(PSF2_HEADER));
}
else if (Type == FontType::PCScreenFont1)
{
@ -37,7 +37,7 @@ namespace Video
uint32_t glyphBufferSize = font1->charsize * 256;
if (font1->mode == 1) // 512 glyph mode
glyphBufferSize = font1->charsize * 512;
void *glyphBuffer = reinterpret_cast<void *>(reinterpret_cast<uint64_t>(Start) + sizeof(PSF1_HEADER));
void *glyphBuffer = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(Start) + sizeof(PSF1_HEADER));
this->Info.PSF1Font->Header = font1;
this->Info.PSF1Font->GlyphBuffer = glyphBuffer;
UNUSED(glyphBufferSize); // TODO: Use this in the future?