chore: Update makefiles & macros

This commit is contained in:
EnderIce2
2024-11-29 04:24:27 +02:00
parent ce3cf8162a
commit 7948d0c6e5
116 changed files with 682 additions and 740 deletions

View File

@ -75,7 +75,7 @@ namespace Memory
}
}
#if defined(a86)
#if defined(__amd64__) || defined(__i386__)
if (bInfo.RSDP)
{
RSDPStart = (uintptr_t)bInfo.RSDP;
@ -101,7 +101,7 @@ namespace Memory
}
#endif
}
#elif defined(aa64)
#elif defined(__aarch64__)
#endif
for (uint64_t i = 0; i < bInfo.Memory.Entries; i++)

View File

@ -121,7 +121,7 @@ namespace Xalloc
{
if (this->SMAPUsed)
{
#if defined(a86)
#if defined(__amd64__) || defined(__i386__)
asm volatile("stac" ::
: "cc");
#endif
@ -132,7 +132,7 @@ namespace Xalloc
{
if (this->SMAPUsed)
{
#if defined(a86)
#if defined(__amd64__) || defined(__i386__)
asm volatile("clac" ::
: "cc");
#endif

View File

@ -56,7 +56,7 @@ NIF void tracepagetable(PageTable *pt)
{
for (int i = 0; i < 512; i++)
{
#if defined(a64)
#if defined(__amd64__)
if (pt->Entries[i].Present)
debug("Entry %03d: %x %x %x %x %x %x %x %p-%#llx", i,
pt->Entries[i].Present, pt->Entries[i].ReadWrite,
@ -64,8 +64,8 @@ NIF void tracepagetable(PageTable *pt)
pt->Entries[i].CacheDisable, pt->Entries[i].Accessed,
pt->Entries[i].ExecuteDisable, pt->Entries[i].Address << 12,
pt->Entries[i]);
#elif defined(a32)
#elif defined(aa64)
#elif defined(__i386__)
#elif defined(__aarch64__)
#endif
}
}
@ -257,15 +257,15 @@ NIF void CreatePageTable(PageTable *pt)
if (PSESupport)
{
#if defined(a64)
#if defined(__amd64__)
CPU::x64::CR4 cr4 = CPU::x64::readcr4();
cr4.PSE = 1;
CPU::x64::writecr4(cr4);
#elif defined(a32)
#elif defined(__i386__)
CPU::x32::CR4 cr4 = CPU::x32::readcr4();
cr4.PSE = 1;
CPU::x32::writecr4(cr4);
#elif defined(aa64)
#elif defined(__aarch64__)
#endif
trace("PSE Support Enabled");
}
@ -289,7 +289,7 @@ NIF void CreatePageTable(PageTable *pt)
NIF void InitializeMemoryManagement()
{
#ifdef DEBUG
#ifndef a32
#ifndef __i386__
for (uint64_t i = 0; i < bInfo.Memory.Entries; i++)
{
uintptr_t Base = r_cst(uintptr_t, bInfo.Memory.Entry[i].BaseAddress);
@ -333,7 +333,7 @@ NIF void InitializeMemoryManagement()
End,
Type);
}
#endif // a32
#endif // __i386__
#endif // DEBUG
trace("Initializing Physical Memory Manager");
// KernelAllocator = Physical(); <- Already called in the constructor

View File

@ -9,9 +9,9 @@ namespace Memory
{
void PageTable::Update()
{
#if defined(a86)
#if defined(__amd64__) || defined(__i386__)
asmv("mov %0, %%cr3" ::"r"(this));
#elif defined(aa64)
#elif defined(__aarch64__)
asmv("msr ttbr0_el1, %0" ::"r"(this));
#endif
}
@ -24,7 +24,7 @@ namespace Memory
memcpy(NewTable, this, sizeof(PageTable));
debug("Forking page table %#lx to %#lx", this, NewTable);
#if defined(a64)
#if defined(__amd64__)
for (size_t i = 0; i < sizeof(Entries) / sizeof(Entries[0]); i++)
{
PageMapLevel4 *PML4 = &Entries[i];

View File

@ -22,7 +22,7 @@ namespace Memory
Virtual::PageMapIndexer::PageMapIndexer(uintptr_t VirtualAddress)
{
uintptr_t Address = VirtualAddress;
#if defined(a64)
#if defined(__amd64__)
Address >>= 12;
this->PTEIndex = Address & 0x1FF;
Address >>= 9;
@ -31,12 +31,12 @@ namespace Memory
this->PDPTEIndex = Address & 0x1FF;
Address >>= 9;
this->PMLIndex = Address & 0x1FF;
#elif defined(a32)
#elif defined(__i386__)
Address >>= 12;
this->PTEIndex = Address & 0x3FF;
Address >>= 10;
this->PDEIndex = Address & 0x3FF;
#elif defined(aa64)
#elif defined(__aarch64__)
#endif
if (VirtualAddress > PAGE_SIZE)
@ -44,7 +44,7 @@ namespace Memory
assert(
this->PTEIndex != 0 ||
this->PDEIndex != 0
#if defined(a64)
#if defined(__amd64__)
|| this->PDPTEIndex != 0 ||
this->PMLIndex != 0
#endif

View File

@ -90,10 +90,10 @@ namespace Memory
Elf_Sym *Symbols = nullptr;
uint8_t *StringAddress = nullptr;
#if defined(a64) || defined(aa64)
#if defined(__amd64__) || defined(__aarch64__)
Elf64_Xword SymbolSize = 0;
Elf64_Xword StringSize = 0;
#elif defined(a32)
#elif defined(__i386__)
Elf32_Word SymbolSize = 0;
Elf32_Word StringSize = 0;
#endif
@ -149,7 +149,7 @@ namespace Memory
TO_PAGES(bInfo.Modules[i].Size));
}
#if defined(a86)
#if defined(__amd64__) || defined(__i386__)
if (bInfo.RSDP)
{
debug("Reserving RSDT region %#lx-%#lx...", bInfo.RSDP,
@ -201,7 +201,7 @@ namespace Memory
this->ReservePages(SDTHdr, TO_PAGES(SDTHdr->Length));
}
}
#elif defined(aa64)
#elif defined(__aarch64__)
#endif
}
}

View File

@ -241,9 +241,9 @@ namespace Memory
pte->CopyOnWrite = false;
debug("PFA %#lx is CoW (pt %#lx, flags %#lx)",
PFA, this->Table, pte->raw);
#if defined(a64)
#if defined(__amd64__)
CPU::x64::invlpg((void *)PFA);
#elif defined(a32)
#elif defined(__i386__)
CPU::x32::invlpg((void *)PFA);
#endif
return true;
@ -303,7 +303,7 @@ namespace Memory
void *AddressToMap = (void *)((uintptr_t)ap.Address + (i * PAGE_SIZE));
void *RealAddress = (void *)((uintptr_t)Address + (i * PAGE_SIZE));
#if defined(a86)
#if defined(__amd64__) || defined(__i386__)
PageTableEntry *pte = vmm.GetPTE(AddressToMap);
uintptr_t Flags = 0;
Flags |= pte->Present ? (uintptr_t)PTFlag::P : 0;