[????] BUILD 0.1.1.??? DATE 9/0?/2011 AT ?:?? ??

====================================================
Mainly changed: Tasking
+ Implemented multitasking
This commit is contained in:
2021-09-14 18:54:59 +03:00
parent 04449cb787
commit e3b3584734
36 changed files with 427 additions and 400 deletions

View File

@ -28,8 +28,7 @@ uint32 _malloc_init2 (uint32 size, uint8 page_aligned, uint32* phys)
if (phys)
{
Page *pg = PagingGetPage(ret, 0, KernelDirectory);
*phys = (*pg & PageFrame) + (ret & 0xFFF);
*phys = PagingGetPhysical(ret, KernelDirectory) + (ret & 0xFFF);
Log("Mem","%#Allocated %u bytes (%spage aligned) at address 0x%x (phys=%x).\n", ColorLightMagenta, size, ((page_aligned) ? "" : "not "), ret, *phys);
}

View File

@ -6,7 +6,6 @@
*/
#include <memory-add.h>
// MemoryGetFree(), MemoryGetTotal(), MemoryGet blah blah...
// Returns total physical memory in bytes
uint32 MemoryGetTotal()
@ -17,13 +16,13 @@ uint32 MemoryGetTotal()
// Returns total free physical memory in bytes
uint32 MemoryGetFree()
{
return (TotalFrames - UsedFrames) * 0x4;
return (TotalBlocks - UsedBlocks) * 0x4;
}
// Total used physical memory in bytes
uint32 MemoryGetUsed()
{
return UsedFrames * 0x4;
return UsedBlocks * 0x4;
}
// Same as above functions, but in frames
@ -34,15 +33,15 @@ uint32 MemoryGetFrameSize()
uint32 MemoryGetFramesTotal()
{
return TotalFrames;
return TotalBlocks;
}
uint32 MemoryGetFramesUsed()
{
return UsedFrames;
return UsedBlocks;
}
uint32 MemoryGetFramesFree()
{
return (TotalFrames - UsedFrames);
}
return (TotalBlocks - UsedBlocks);
}

View File

@ -10,7 +10,6 @@
#include "../../drivers/cmos/cmos.h"
#include <stdio.h>
uint32 mem_kernel_end = 0;
uint8 mem_initialized = 0;
@ -42,7 +41,7 @@ void _memory_reserve_system(MultibootInfo* info)
while ((uint32)location < (info->MemoryMapAddress + info->MemoryMapLength))
{
if (location->Type > 1)
MemPhReserveFrames((uint32)location->Address, (uint32)location->Length);
MemPhReserveBlocks((uint32)location->Address, (uint32)location->Length);
location = (MultibootMemoryMapEntry*) ((uint32)location + location->Size + sizeof(uint32));
}
@ -53,29 +52,35 @@ void _memory_reserve_system(MultibootInfo* info)
Error("Mem", "%#Missing %#memory map%# info from bootloader.\n", ColorLightRed, ColorWhite, ColorLightRed);
// Standard memory hole at 15mb
MemPhReserveFrames(0x00F00000, 0x00100000);
MemPhReserveBlocks(0x00F00000, 0x00100000);
}
// Standard reserved memory areas
MemPhReserveFrames(0x0, 0x400 + 256); // Real mode IVT, BDA
MemPhReserveFrames(0x1000, 0x2400); // DMA buffer
MemPhReserveFrames(0x9FC00, 385*1024); // EBDA, Video memory, ROM area
}
void MemoryInitialize (MultibootInfo* info)
{
// Get total system memory
uint32 totalSystemMemory = _memory_get_total_mem(info);
// Initialize physical & virtual memory managers
uint32 end = mem_kernel_end + 0x80000;
MemPhInitialize(totalSystemMemory);
PagingInitialize(0x200000);
PagingInitialize(&end);
// Reserve physical blocks
_memory_reserve_system(info);
uint32 i;
// Allocate some space for the kernel heap
for (i = KERNEL_HEAP_START; i <= KERNEL_HEAP_END; i += 0x1000)
PagingMapPage(MemPhAllocateBlock(), i, PageWriteable, KernelDirectory);
// Create the kernel heap
KernelHeap = MemHeapCreate(KERNEL_HEAP_START, KERNEL_HEAP_START
+ KERNEL_HEAP_INITIAL_SIZE, 0xCFFFF000, 3); // is kernel, writeable
Log("Mem", "Done initializing memory!");
Log("Mem", "Done initializing memory!\n");
mem_initialized = 2;
}
@ -84,5 +89,5 @@ void MemoryTempInitialize (uint32 kernel_end)
{
mem_initialized = 1;
mem_kernel_end = kernel_end;
Log("Mem", "Initialized temporary memory manager, allocating from %#0x%x.\n", kernel_end);
Log("Mem", "Initialized temporary memory manager, allocating from %#0x%x.\n", ColorWhite, mem_kernel_end);
}