Poke paging. Still a little strange. Removed excess debugging.
This commit is contained in:
parent
15165b1562
commit
0ff9705fc8
|
@ -118,6 +118,8 @@ void InitPaging() {
|
|||
Allocator = PhysAllocateZeroMem(Size);
|
||||
Allocator = CreateAllocatorWithPool(Allocator, Size);
|
||||
|
||||
SerialPrintf("Everything preallocated. Setting up paging.\n");
|
||||
|
||||
KernelAddressSpace = (address_space_t) {
|
||||
.Lock = {0},
|
||||
.PML4 = PhysAllocateZeroMem(PAGE_SIZE)
|
||||
|
@ -125,6 +127,7 @@ void InitPaging() {
|
|||
|
||||
size_t* Pagetable = KernelAddressSpace.PML4;
|
||||
|
||||
SerialPrintf("About to identity map the higher half.\n");
|
||||
// Identity map the higher half
|
||||
for(int i = 256; i < 512; i++) {
|
||||
Pagetable[i] = (size_t)PhysAllocateZeroMem(PAGE_SIZE);
|
||||
|
@ -132,12 +135,16 @@ void InitPaging() {
|
|||
Pagetable[i] |= (PAGE_PRESENT | PAGE_RW);
|
||||
}
|
||||
|
||||
SerialPrintf("Identity mapping complete.\n");
|
||||
|
||||
MMapEnt* TopEntry = (MMapEnt*)(((&bootldr) + bootldr.size) - sizeof(MMapEnt));
|
||||
size_t LargestAddress = TopEntry->ptr + TopEntry->size;
|
||||
|
||||
SerialPrintf("About to map lower memory into the Direct Region.\n");
|
||||
for(size_t Address = 0; Address < AlignUpwards(LargestAddress, PAGE_SIZE); Address += PAGE_SIZE) {
|
||||
MapVirtualMemory(&KernelAddressSpace, (size_t*)(((char*)Address) + DIRECT_REGION), Address, MAP_WRITE);
|
||||
}
|
||||
SerialPrintf("Lower half mapping complete.\n");
|
||||
|
||||
SerialPrintf("Mapping kernel into new memory map.\r\n");
|
||||
|
||||
|
|
|
@ -138,20 +138,20 @@ static directptr_t BuddyAllocate(buddy_t* Buddy, size_t Size) {
|
|||
SerialPrintf("Searching for a valid order to allocate into. Condition: {\r\n\tOrder: %d,\r\n\tSize: 0x%x\r\n}\r\n\n", InitialOrder, WantedSize);
|
||||
|
||||
for(int Order = InitialOrder; Order < Buddy->MaxOrder; Order++) {
|
||||
SerialPrintf("\tCurrent Order: %d, Buddy entry: %x\r\n", Order, Buddy->List[Order - MIN_ORDER]);
|
||||
//SerialPrintf("\tCurrent Order: %d, Buddy entry: %x\r\n", Order, Buddy->List[Order - MIN_ORDER]);
|
||||
if(Buddy->List[Order - MIN_ORDER] != 0) {
|
||||
SerialPrintf("\t\tFound a valid Order!\r\n");
|
||||
SerialPrintf("\tFound a valid Order!\r\n");
|
||||
directptr_t Address = Buddy->List[Order - MIN_ORDER];
|
||||
Buddy->List[Order - MIN_ORDER] = PEEK(directptr_t, Address);
|
||||
TicketUnlock(&Buddy->Lock);
|
||||
|
||||
size_t FoundSize = 1ull << Order;
|
||||
|
||||
SerialPrintf("\t\tAdding area - Address 0x%p, Size 0x%x\r\n\n", Address, FoundSize);
|
||||
SerialPrintf("\tAdding area - Address 0x%p, Size 0x%x\r\n\n", Address, FoundSize);
|
||||
|
||||
AddRangeToBuddy(Buddy, (void*)((size_t)Address + WantedSize), FoundSize - WantedSize);
|
||||
|
||||
SerialPrintf("\t\tArea added!\r\n\n");
|
||||
SerialPrintf("\tArea added!\r\n\n");
|
||||
return Address;
|
||||
}
|
||||
}
|
||||
|
@ -272,11 +272,15 @@ directptr_t PhysAllocateLowMem(size_t Size) {
|
|||
directptr_t PhysAllocateMem(size_t Size) {
|
||||
directptr_t Pointer = NULL;
|
||||
|
||||
if(HighBuddy.Base == 0)
|
||||
if(HighBuddy.Base == 0) {
|
||||
SerialPrintf("Attempting allocation into high memory.\n");
|
||||
Pointer = BuddyAllocate(&HighBuddy, Size);
|
||||
}
|
||||
|
||||
if(Pointer == NULL)
|
||||
if(Pointer == NULL) {
|
||||
SerialPrintf("Attempting allocation into low memory.\n");
|
||||
Pointer = BuddyAllocate(&LowBuddy, Size);
|
||||
}
|
||||
|
||||
ASSERT(Pointer != NULL, "PhysAllocateMem: Unable to allocate memory!");
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user