diff --git a/Asuro.iso b/Asuro.iso index 99ab082f..d32d4b1f 100644 Binary files a/Asuro.iso and b/Asuro.iso differ diff --git a/iso/boot/asuro.bin b/iso/boot/asuro.bin index eba019b4..0193c546 100755 Binary files a/iso/boot/asuro.bin and b/iso/boot/asuro.bin differ diff --git a/lib/libpconsole.a b/lib/libpconsole.a index 2603a457..d1a26206 100644 Binary files a/lib/libpconsole.a and b/lib/libpconsole.a differ diff --git a/lib/libpmultiboot.a b/lib/libpmultiboot.a index 235d523b..3a6b7319 100644 Binary files a/lib/libpmultiboot.a and b/lib/libpmultiboot.a differ diff --git a/lib/libpsystem.a b/lib/libpsystem.a index 9d95bbe6..98af4db3 100644 Binary files a/lib/libpsystem.a and b/lib/libpsystem.a differ diff --git a/src/kernel.pas b/src/kernel.pas index e8b46669..46e9f3e9 100644 --- a/src/kernel.pas +++ b/src/kernel.pas @@ -26,6 +26,7 @@ var mbm : uint32; z : uint32; dds : uint32; + pint : puint32; begin mbi:= mbinfo; @@ -46,6 +47,14 @@ begin isr.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; isr32.hook(uint32(@bios_data_area.tick_update)); diff --git a/src/memorymanager.pas b/src/memorymanager.pas index 16431e2a..e397d37f 100644 --- a/src/memorymanager.pas +++ b/src/memorymanager.pas @@ -3,7 +3,8 @@ unit memorymanager; interface uses - util; + util, + console; const ALLOC_SPACE = 8; //64-Bit Allocations @@ -17,16 +18,47 @@ implementation var Memory_Start : uint32; - Memory_Manager : bitpacked array[1..MAX_ENTRIES] of Boolean; + Memory_Manager : packed array[1..MAX_ENTRIES] of Boolean; procedure init; +var + i : uint32; + begin + For i:=0 to MAX_ENTRIES-1 do begin + Memory_Manager[i]:= false; + end; Memory_Start:= uint32(@util.endptr); end; function kalloc(size : uint32) : void; +var + blocks : uint32; + rem : uint32; + i,j : uint32; + miss : boolean; + 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; procedure kfree(area : void);