Memory Manager D'x

git-svn-id: https://spexeah.com:8443/svn/Asuro@148 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
kieron 2017-05-20 19:08:00 +00:00
parent c7968006c9
commit e330bc426b
8 changed files with 32 additions and 20 deletions

BIN
Asuro.iso

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -50,6 +50,9 @@ begin
isr.init(); isr.init();
irq.init(); irq.init();
pmemorymanager.init(); pmemorymanager.init();
//while true do begin end;
vmemorymanager.init(); vmemorymanager.init();
vmemorymanager.new_page(0); vmemorymanager.new_page(0);

View File

@ -29,24 +29,28 @@ var
procedure set_memory_area_present(base : uint64; length : uint64; present : boolean); procedure set_memory_area_present(base : uint64; length : uint64; present : boolean);
var var
BlockHigh, BlockLow : uint16; FirstBlock : uint32;
LastBlock : uint32;
i : uint32;
begin begin
BlockLow:= base SHR 22; FirstBlock:= base SHR 22;
BlockHigh:= base+length SHR 22; LastBlock:= (base+length) SHR 22;
if not present then begin console.writewordln(FirstBlock);
PhysicalMemory[BlockLow].Scanned:= True; console.writewordln(LastBlock);
PhysicalMemory[BlockHigh].Scanned:= True; if (FirstBlock > 1023) then exit;
PhysicalMemory[BlockLow].Present:= False; while LastBlock > 1023 do begin
PhysicalMemory[BlockHigh].Present:= False; LastBlock:= LastBlock-1;
end else begin end;
If not PhysicalMemory[BlockLow].Scanned then begin for i:=FirstBlock to LastBlock do begin
PhysicalMemory[BlockLow].Scanned:= True; if not present then begin
PhysicalMemory[BlockLow].Present:= True; PhysicalMemory[i].Scanned:= True;
end; PhysicalMemory[i].Present:= present;
If not PhysicalMemory[BlockHigh].Scanned then begin end else begin
PhysicalMemory[BlockHigh].Scanned:= True; If not PhysicalMemory[i].Scanned then begin
PhysicalMemory[BlockHigh].Present:= True; PhysicalMemory[i].Scanned:= True;
PhysicalMemory[i].Present:= present;
end;
end; end;
end; end;
end; end;
@ -63,15 +67,20 @@ begin
length:= multibootinfo^.mmap_length; length:= multibootinfo^.mmap_length;
mmap:= Pmemory_map_t(address); mmap:= Pmemory_map_t(address);
for i:=0 to 1023 do begin for i:=0 to 1023 do begin
PhysicalMemory[i].Present:= True; PhysicalMemory[i].Present:= False;
PhysicalMemory[i].Allocated:= False; PhysicalMemory[i].Allocated:= False;
PhysicalMemory[i].Scanned:= False; PhysicalMemory[i].Scanned:= False;
PhysicalMemory[i].MappedTo:= 0; PhysicalMemory[i].MappedTo:= 0;
end; end;
while uint32(mmap) < (address + length) do begin while uint32(mmap) < (address + length) do begin
console.writewordln(mmap^.mtype); console.writehexln(mmap^.base_addr);
console.writehexln(mmap^.length);
console.writehexln(mmap^.mtype);
console.writestringln('');
if mmap^.mtype <> $01 then begin if mmap^.mtype <> $01 then begin
set_memory_area_present(mmap^.base_addr, mmap^.length, False); set_memory_area_present(mmap^.base_addr, mmap^.length, False);
end else begin
set_memory_area_present(mmap^.base_addr, mmap^.length, True);
end; end;
mmap:= Pmemory_map_t(uint32(mmap)+mmap^.size+sizeof(mmap^.size)); mmap:= Pmemory_map_t(uint32(mmap)+mmap^.size+sizeof(mmap^.size));
end; end;
@ -100,7 +109,7 @@ begin
walk_memory_map; walk_memory_map;
force_alloc_block(0, 0); force_alloc_block(0, 0);
force_alloc_block(1, 0); force_alloc_block(1, 0);
force_alloc_block(2, 0); //First 12MiB reserved for Kernel/BIOS. alloc_block(2, 0); //First 12MiB reserved for Kernel/BIOS.
console.writestring('PMM: '); console.writestring('PMM: ');
console.writeword(nPresent); console.writeword(nPresent);
console.writestringln('/1024 Block Available for Allocation.'); console.writestringln('/1024 Block Available for Allocation.');
@ -116,7 +125,7 @@ begin
end else begin end else begin
PhysicalMemory[block].Allocated:= True; PhysicalMemory[block].Allocated:= True;
PhysicalMemory[block].MappedTo:= caller; PhysicalMemory[block].MappedTo:= caller;
console.writestring('4MiB Block Allocated @ '); console.writestring('PMM: 4MiB Block Allocated @ ');
console.writeword(block); console.writeword(block);
console.writestring(' ['); console.writestring(' [');
console.writehex(block SHL 22); console.writehex(block SHL 22);