diff --git a/Asuro.iso b/Asuro.iso index 7af67587..c989de90 100644 Binary files a/Asuro.iso and b/Asuro.iso differ diff --git a/bin/kernel.bin b/bin/kernel.bin index 3cdc3fa5..49a71228 100755 Binary files a/bin/kernel.bin and b/bin/kernel.bin differ diff --git a/iso/boot/asuro.bin b/iso/boot/asuro.bin index 3cdc3fa5..49a71228 100755 Binary files a/iso/boot/asuro.bin and b/iso/boot/asuro.bin differ diff --git a/lib/IDE.ppu b/lib/IDE.ppu index 137930f2..310dad7c 100644 Binary files a/lib/IDE.ppu and b/lib/IDE.ppu differ diff --git a/lib/kernel.ppu b/lib/kernel.ppu index bd13738c..dbcf60d7 100644 Binary files a/lib/kernel.ppu and b/lib/kernel.ppu differ diff --git a/lib/libpconsole.a b/lib/libpconsole.a index 35e04950..5720ab9c 100644 Binary files a/lib/libpconsole.a and b/lib/libpconsole.a differ diff --git a/lib/libpmultiboot.a b/lib/libpmultiboot.a index b28ee836..e2d62fcf 100644 Binary files a/lib/libpmultiboot.a and b/lib/libpmultiboot.a differ diff --git a/lib/libpsystem.a b/lib/libpsystem.a index 08a46487..709f32ee 100644 Binary files a/lib/libpsystem.a and b/lib/libpsystem.a differ diff --git a/lib/lists.ppu b/lib/lists.ppu new file mode 100644 index 00000000..eb4e3d37 Binary files /dev/null and b/lib/lists.ppu differ diff --git a/lib/pmemorymanager.ppu b/lib/pmemorymanager.ppu index cf921aae..8d704e6a 100644 Binary files a/lib/pmemorymanager.ppu and b/lib/pmemorymanager.ppu differ diff --git a/lib/storagemanagement.ppu b/lib/storagemanagement.ppu index 7cbd1f41..8c0c3801 100644 Binary files a/lib/storagemanagement.ppu and b/lib/storagemanagement.ppu differ diff --git a/lib/vmemorymanager.ppu b/lib/vmemorymanager.ppu index 791eb9f5..9b103258 100644 Binary files a/lib/vmemorymanager.ppu and b/lib/vmemorymanager.ppu differ diff --git a/src/kernel.pas b/src/kernel.pas index 03e744d3..9227b65d 100644 --- a/src/kernel.pas +++ b/src/kernel.pas @@ -36,8 +36,9 @@ uses testdriver, E1000, IDE, - storagemanagement; - //ipv4; + storagemanagement, + ipv4, + lists; procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall; @@ -85,6 +86,11 @@ var temp : uint32; atmp : puint32; test : puint8; + + LList : PLinkedListBase; + Elem : Void; + Str : PChar; + begin multibootinfo:= mbinfo; @@ -141,7 +147,7 @@ begin mouse.init(); testdriver.init(); E1000.init(); - IDE.init(); + //IDE.init(); //Nothing beyond here USB.init(); @@ -157,6 +163,8 @@ begin console.writestringln(''); console.writestringln('Press any key to boot in to Asuro Terminal...'); + LL_TEST(); + keyboard.hook(@temphook); util.halt_and_dont_catch_fire; diff --git a/src/lists.pas b/src/lists.pas new file mode 100644 index 00000000..9c2f7ce1 --- /dev/null +++ b/src/lists.pas @@ -0,0 +1,216 @@ +unit lists; + +interface + +uses + console, + lmemorymanager; + +type + { Managed Linked List } + PLinkedList = ^TLinkedList; + TLinkedList = record + Previous : PLinkedList; + Data : void; + Next : PLinkedList; + end; + + PLinkedListBase = ^TLinkedListBase; + TLinkedListBase = record + Count : uint32; + Head : PLinkedList; + ElementSize : uint32; + end; + +{ Managed Linked List } +function LL_New(ElementSize : uint32) : PLinkedListBase; +function LL_Add(LinkedList : PLinkedListBase) : Void; +function LL_Delete(LinkedList : PLinkedListBase; idx : uint32) : boolean; +function LL_Size(LinkedList : PLinkedListBase) : uint32; +function LL_Insert(LinkedList : PLinkedListBase; idx : uint32) : Void; +function LL_Get(LinkedList : PLinkedListBase; idx : uint32) : Void; +procedure LL_TEST(); + +implementation + +{ Managed Linked List } + +function LL_New(ElementSize : uint32) : PLinkedListBase; +begin + LL_New:= PLinkedListBase(kalloc(sizeof(TLinkedListBase))); + LL_New^.ElementSize:= ElementSize; + LL_New^.Count:= 0; + LL_New^.Head:= nil; +end; + +function LL_Add(LinkedList : PLinkedListBase) : Void; +var + Element : PLinkedList; + Base : PLinkedList; + Count : uint32; + +begin + if LinkedList^.Head = nil then begin + Element:= PLinkedList(kalloc(sizeof(TLinkedList))); + Element^.Previous:= nil; + Element^.Next:= nil; + Element^.Data:= kalloc(LinkedList^.ElementSize); + LinkedList^.Head:= Element; + LinkedList^.Count:= LinkedList^.Count + 1; + LL_Add:= Element^.Data; + end else begin + Base:= LinkedList^.Head; + Count:= 1; + While Base^.Next <> nil do begin + Base:= Base^.Next; + Count:= Count + 1; + end; + Element:= PLinkedList(kalloc(sizeof(TLinkedList))); + Base^.Next:= Element; + Element^.Previous:= Base; + Element^.Next:= nil; + Element^.Data:= kalloc(LinkedList^.ElementSize); + LinkedList^.Count:= LinkedList^.Count + 1; + LL_Add:= Element^.Data; + end; +end; + +function LL_Delete(LinkedList : PLinkedListBase; idx : uint32) : boolean; +var + Prev, Next : PLinkedList; + Base : PLinkedList; + i : uint32; + +begin + Base:= LinkedList^.Head; + i:= 0; + while (i < idx) and (Base <> nil) do begin + i:= i + 1; + Base:= Base^.Next; + end; + if Base = nil then begin + LL_Delete:= false; + exit; + end; + Prev:= Base^.Previous; + Next:= Base^.Next; + if Prev = nil then begin + LinkedList^.Head:= Next; + end else begin + Prev^.Next:= Next; + end; + if Next <> nil then begin + Next^.Previous:= Prev; + end; + LinkedList^.Count:= LinkedList^.Count - 1; + kfree(void(Base^.Data)); + kfree(void(Base)); + LL_Delete:= True; +end; + +function LL_Size(LinkedList : PLinkedListBase) : uint32; +begin + LL_Size:= LinkedList^.Count; +end; + +function LL_Insert(LinkedList : PLinkedListBase; idx : uint32) : void; +var + i : uint32; + Base : PLinkedList; + Prev, Next : PLinkedList; + Element : PLinkedList; + +begin + LL_Insert:= nil; + if idx >= LinkedList^.Count then exit; + Base:= LinkedList^.Head; + i:=0; + while (i < idx) and (Base <> nil) do begin + i:= i + 1; + Base:= Base^.Next; + end; + if Base = nil then exit; + Prev:= Base^.Previous; + Next:= Base; + Element:= PLinkedList(kalloc(sizeof(TLinkedList))); + Element^.Data:= kalloc(LinkedList^.ElementSize); + Element^.Previous:= Prev; + Element^.Next:= Next; + if Prev = nil then begin + LinkedList^.Head:= Element; + end else begin + Prev^.Next:= Element; + end; + if Next <> nil then begin + Next^.Previous:= Element; + end; + LinkedList^.Count:= LinkedList^.Count + 1; + LL_Insert:= Element^.Data; +end; + +function LL_Get(LinkedList : PLinkedListBase; idx : uint32) : void; +var + i : uint32; + Base : PLinkedList; + +begin + LL_Get:= nil; + if idx >= LinkedList^.Count then exit; + Base:= LinkedList^.Head; + i:=0; + while (i < idx) and (Base <> nil) do begin + i:= i + 1; + Base:= Base^.Next; + end; + if Base = nil then exit; + LL_Get:= Base^.Data; +end; + +procedure LL_Test(); +var + i : uint32; + LList : PLinkedListBase; + Elem : Void; + Str : PChar; + +begin + console.writestringln('Add 3 Elements: '); + LList:= LL_New(10); + Elem:= LL_Add(LList); + Str:= PChar(Elem); + Str[0]:= 'H'; + Str[1]:= 'E'; + Str[2]:= 'L'; + Str[3]:= 'L'; + Str[4]:= 'O'; + Str[5]:= Char(0); + Elem:= LL_Add(LList); + Str:= PChar(Elem); + Str[0]:= 'W'; + Str[1]:= 'O'; + Str[2]:= 'R'; + Str[3]:= 'L'; + Str[4]:= 'D'; + Str[5]:= Char(0); + Elem:= LL_Add(LList); + Str:= PChar(Elem); + Str[0]:= 'T'; + Str[1]:= 'E'; + Str[2]:= 'S'; + Str[3]:= 'T'; + Str[4]:= Char(0); + + for i:=0 to LL_Size(LList)-1 do begin + console.writestringln(PChar(LL_Get(LList, i))); + end; + + console.writestringln(' '); + console.writestringln('Remove Element 1:'); + LL_Delete(LList, 1); + + for i:=0 to LL_Size(LList)-1 do begin + console.writestringln(PChar(LL_Get(LList, i))); + end; +end; + +end. \ No newline at end of file