diff --git a/Asuro.iso b/Asuro.iso index 8b3c9d43..6b95f5fa 100644 Binary files a/Asuro.iso and b/Asuro.iso differ diff --git a/bin/kernel.bin b/bin/kernel.bin index f3cf6967..91610c2b 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 f3cf6967..91610c2b 100755 Binary files a/iso/boot/asuro.bin and b/iso/boot/asuro.bin differ diff --git a/lib/BIOS_DATA_AREA.ppu b/lib/bios_data_area.ppu similarity index 87% rename from lib/BIOS_DATA_AREA.ppu rename to lib/bios_data_area.ppu index b2095c80..5931e98e 100644 Binary files a/lib/BIOS_DATA_AREA.ppu and b/lib/bios_data_area.ppu differ diff --git a/lib/console.o b/lib/console.o index b1cb47ee..48a627fb 100644 Binary files a/lib/console.o and b/lib/console.o differ diff --git a/lib/console.ppu b/lib/console.ppu index 0de019db..bc5c92a2 100644 Binary files a/lib/console.ppu and b/lib/console.ppu differ diff --git a/lib/kernel.o b/lib/kernel.o index b3c9bf50..2facf145 100644 Binary files a/lib/kernel.o and b/lib/kernel.o differ diff --git a/lib/kernel.ppu b/lib/kernel.ppu index b9d2c6cc..29ea8025 100644 Binary files a/lib/kernel.ppu and b/lib/kernel.ppu differ diff --git a/lib/keyboard.ppu b/lib/keyboard.ppu new file mode 100644 index 00000000..e9d9534b Binary files /dev/null and b/lib/keyboard.ppu differ diff --git a/lib/util.ppu b/lib/util.ppu index 00fb1bce..afbebfda 100644 Binary files a/lib/util.ppu and b/lib/util.ppu differ diff --git a/src/bios_data_area.pas b/src/bios_data_area.pas index b0c269d9..5f32060a 100644 --- a/src/bios_data_area.pas +++ b/src/bios_data_area.pas @@ -1,4 +1,4 @@ -unit BIOS_DATA_AREA; +unit bios_data_area; interface diff --git a/src/console.pas b/src/console.pas index 2215bfe6..1fc388dc 100644 --- a/src/console.pas +++ b/src/console.pas @@ -4,7 +4,7 @@ interface uses util, - BIOS_DATA_AREA; + bios_data_area; type TColor = ( Black = $0, @@ -32,21 +32,25 @@ procedure writechar(character : char); procedure writestring(str: PChar); procedure writeint(i: Integer); procedure writeword(i: DWORD); +procedure writehex(i: DWORD); procedure writecharln(character : char); procedure writestringln(str: PChar); procedure writeintln(i: Integer); procedure writewordln(i: DWORD); +procedure writehexln(i: DWORD); procedure writecharex(character : char; attributes : char); procedure writestringex(str: PChar; attributes : char); procedure writeintex(i: Integer; attributes : char); procedure writewordex(i: DWORD; attributes : char); +procedure writehexex(i : DWORD; attributes : char); procedure writecharlnex(character : char; attributes : char); procedure writestringlnex(str: PChar; attributes : char); procedure writeintlnex(i: Integer; attributes : char); procedure writewordlnex(i: DWORD; attributes : char); +procedure writehexlnex(i: DWORD; attributes : char); function combinecolors(Foreground, Background : TColor) : char; @@ -159,6 +163,68 @@ begin console._safeincrement_x(); end; +procedure writehexex(i : dword; attributes: char); [public, alias: 'console_writehexex']; +var + Hex : Array[0..7] of Byte; + Res : DWORD; + Rem : DWORD; + c : Integer; + +begin + for c:=0 to 7 do begin + Hex[c]:= 255; + end; + c:=0; + Res:= i; + Rem:= Res mod 16; + while Res > 0 do begin + Hex[c]:= Rem; + Res:= Res div 16; + Rem:= Res mod 16; + c:=c+1; + end; + writestringex('0x', attributes); + for c:=7 downto 0 do begin + if Hex[c] <> 255 then begin + case Hex[c] of + 0:writecharex('0', attributes); + 1:writecharex('1', attributes); + 2:writecharex('2', attributes); + 3:writecharex('3', attributes); + 4:writecharex('4', attributes); + 5:writecharex('5', attributes); + 6:writecharex('6', attributes); + 7:writecharex('7', attributes); + 8:writecharex('8', attributes); + 9:writecharex('9', attributes); + 10:writecharex('A', attributes); + 11:writecharex('B', attributes); + 12:writecharex('C', attributes); + 13:writecharex('D', attributes); + 14:writecharex('E', attributes); + 15:writecharex('F', attributes); + else writecharex('?', attributes); + end; + end; + end; +end; + +procedure writehex(i : dword); [public, alias: 'console_writehex']; +begin + console.writehexex(i, Console_Properties.Default_Attribute); +end; + +procedure writehexlnex(i : dword; attributes : char); +begin + console.writehexex(i, attributes); + console._safeincrement_y(); +end; + +procedure writehexln(i : dword); +begin + writehexlnex(i, Console_Properties.Default_Attribute); +end; + procedure writestringex(str: PChar; attributes: char); [public, alias: 'console_writestringex']; var i : integer; diff --git a/src/kernel.pas b/src/kernel.pas index 61e2373a..83af5d69 100644 --- a/src/kernel.pas +++ b/src/kernel.pas @@ -6,13 +6,17 @@ uses multiboot, util, console, - BIOS_DATA_AREA; + bios_data_area, + keyboard; procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: DWORD); stdcall; implementation procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: DWORD); stdcall; [public, alias: 'kmain']; +var + c : byte; + begin console.init(); console.writestringln('Booting Asuro...'); @@ -37,6 +41,10 @@ begin console.writeint(((mbinfo^.mem_upper + 1000) div 1024) +1); console.writestringln('MB'); console.setdefaultattribute(console.combinecolors(lYellow, Black)); + while true do begin + c:= keyboard.get_scancode; + console.writehexln(c); + end; util.halt_and_catch_fire; end; diff --git a/src/keyboard.pas b/src/keyboard.pas new file mode 100644 index 00000000..f51e7a7b --- /dev/null +++ b/src/keyboard.pas @@ -0,0 +1,31 @@ +unit keyboard; + +{$ASMMODE intel} + +interface + +uses + util; + +function get_scancode() : byte; + +implementation + +function get_scancode() : byte; [public, alias: 'get_scancode']; +var + c : byte; + +begin + c:= 0; + while true do begin + if inb($60) <> c then begin + c:= inb($60); + if c > 0 then begin + get_scancode:= c; + exit; + end; + end; + end; +end; + +end. diff --git a/src/util.pas b/src/util.pas index 27aea650..5839ac0b 100644 --- a/src/util.pas +++ b/src/util.pas @@ -11,6 +11,9 @@ procedure outb(port : word; val : byte); procedure outw(port : word; val : word); procedure outl(port : word; val : longword); procedure halt_and_catch_fire(); +function inb(port : word) : byte; +function inw(port : word) : word; +function inl(port : word) : dword; implementation @@ -76,4 +79,43 @@ begin end; end; +function inl(port : word) : dword; [public, alias: 'inl']; +begin + asm + PUSH EAX + PUSH EDX + MOV DX, port + IN EAX, DX + MOV inl, EAX + POP EDX + POP EAX + end; +end; + +function inw(port : word) : word; [public, alias: 'inw']; +begin + asm + PUSH EAX + PUSH EDX + MOV DX, port + IN AX, DX + MOV inw, AX + POP EDX + POP EAX + end; +end; + +function inb(port : word) : byte; [public, alias: 'inb']; +begin + asm + PUSH EAX + PUSH EDX + MOV DX, port + IN AL, DX + MOV inb, AL + POP EDX + POP EAX + end; +end; + end.