Memory Manager Started.

git-svn-id: https://spexeah.com:8443/svn/Asuro@103 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
kieron committed 2017-05-18 14:44:13 +00:00
1 parent 1414f10ba1
commit c595bfb819
7 files changed
+44 -3

No files matched your search

BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
+9
View File
@@ -26,6 +26,7 @@ var
mbm : uint32; mbm : uint32;
z : uint32; z : uint32;
dds : uint32; dds : uint32;
pint : puint32;
begin begin
mbi:= mbinfo; mbi:= mbinfo;
@@ -46,6 +47,14 @@ begin
isr.init(); isr.init();
irq.init(); irq.init();
memorymanager.init();
pint:= kalloc(sizeof(uint32));
if pint = nil then console.writestringln('!');
pint^:= 1234;
console.writeintln(pint^);
pint:= kalloc(18);
util.halt_and_catch_fire;
STI; STI;
isr32.hook(uint32(@bios_data_area.tick_update)); isr32.hook(uint32(@bios_data_area.tick_update));
+35 -3
View File
@@ -3,7 +3,8 @@ unit memorymanager;
interface interface
uses uses
util; util,
console;
const const
ALLOC_SPACE = 8; //64-Bit Allocations ALLOC_SPACE = 8; //64-Bit Allocations
@@ -17,16 +18,47 @@ implementation
var var
Memory_Start : uint32; Memory_Start : uint32;
Memory_Manager : bitpacked array[1..MAX_ENTRIES] of Boolean; Memory_Manager : packed array[1..MAX_ENTRIES] of Boolean;
procedure init; procedure init;
var
i : uint32;
begin begin
For i:=0 to MAX_ENTRIES-1 do begin
Memory_Manager[i]:= false;
end;
Memory_Start:= uint32(@util.endptr); Memory_Start:= uint32(@util.endptr);
end; end;
function kalloc(size : uint32) : void; function kalloc(size : uint32) : void;
var
blocks : uint32;
rem : uint32;
i,j : uint32;
miss : boolean;
begin begin
kalloc:= void(0); blocks:= size div 8;
rem:= size - (blocks * 8);
if rem > 0 then blocks:= blocks + 1;
kalloc:= nil;
for i:=0 to MAX_ENTRIES-1 do begin
miss:= false;
for j:=0 to blocks-1 do begin
if Memory_Manager[i+j] then miss:= true;
end;
if not miss then begin
kalloc:= void(Memory_Start+(i * 8));
for j:=0 to blocks-1 do begin
Memory_Manager[i+j]:= true;
end;
console.writestring('Allocated ');
console.writeint(blocks);
console.writestringln(' Block(s).');
break;
end;
end;
end; end;
procedure kfree(area : void); procedure kfree(area : void);