diff --git a/Asuro.iso b/Asuro.iso index f04c9fc4..3cfdcf4e 100644 Binary files a/Asuro.iso and b/Asuro.iso differ diff --git a/bin/kernel.bin b/bin/kernel.bin index 50449ebf..04c5a769 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 50449ebf..04c5a769 100755 Binary files a/iso/boot/asuro.bin and b/iso/boot/asuro.bin differ diff --git a/lib/bda.ppu b/lib/bda.ppu deleted file mode 100644 index 0667234e..00000000 Binary files a/lib/bda.ppu and /dev/null differ diff --git a/lib/console.o b/lib/console.o index e60d5fe9..dac0c0ba 100644 Binary files a/lib/console.o and b/lib/console.o differ diff --git a/lib/console.ppu b/lib/console.ppu index b2e8b6f2..4bf9b489 100644 Binary files a/lib/console.ppu and b/lib/console.ppu differ diff --git a/lib/consoleutil.ppu b/lib/consoleutil.ppu deleted file mode 100644 index a98ee936..00000000 Binary files a/lib/consoleutil.ppu and /dev/null differ diff --git a/lib/gdt.ppu b/lib/gdt.ppu index 8c60088c..922ef2d5 100644 Binary files a/lib/gdt.ppu and b/lib/gdt.ppu differ diff --git a/lib/kernel.o b/lib/kernel.o index 76d00292..05e0a1ab 100644 Binary files a/lib/kernel.o and b/lib/kernel.o differ diff --git a/lib/kernel.ppu b/lib/kernel.ppu index d9a04496..96a7ac44 100644 Binary files a/lib/kernel.ppu and b/lib/kernel.ppu differ diff --git a/lib/keyboard.ppu b/lib/keyboard.ppu index 992e7956..43a3718f 100644 Binary files a/lib/keyboard.ppu and b/lib/keyboard.ppu differ diff --git a/lib/libpconsole.a b/lib/libpconsole.a index 5b18de4d..ce14ba47 100644 Binary files a/lib/libpconsole.a and b/lib/libpconsole.a differ diff --git a/lib/libpkernel.a b/lib/libpkernel.a index 641f8945..159effa5 100644 Binary files a/lib/libpkernel.a and b/lib/libpkernel.a differ diff --git a/lib/libpmultiboot.a b/lib/libpmultiboot.a index b9fcbfcf..be9e973f 100644 Binary files a/lib/libpmultiboot.a and b/lib/libpmultiboot.a differ diff --git a/lib/libpsystem.a b/lib/libpsystem.a index 176bc62b..1c2f3778 100644 Binary files a/lib/libpsystem.a and b/lib/libpsystem.a differ diff --git a/lib/multiboot.o b/lib/multiboot.o index ffdfd06d..22500298 100644 Binary files a/lib/multiboot.o and b/lib/multiboot.o differ diff --git a/lib/multiboot.ppu b/lib/multiboot.ppu index 64c62ab8..36171961 100644 Binary files a/lib/multiboot.ppu and b/lib/multiboot.ppu differ diff --git a/lib/system.o b/lib/system.o index 736030d7..186f4ad4 100644 Binary files a/lib/system.o and b/lib/system.o differ diff --git a/lib/system.ppu b/lib/system.ppu index 94b122af..020971fa 100644 Binary files a/lib/system.ppu and b/lib/system.ppu differ diff --git a/lib/types.ppu b/lib/types.ppu index a279f6b8..118a89ac 100644 Binary files a/lib/types.ppu and b/lib/types.ppu differ diff --git a/lib/util.ppu b/lib/util.ppu index 759f3df9..9b3b0f4d 100644 Binary files a/lib/util.ppu and b/lib/util.ppu differ diff --git a/src/gdt.pas b/src/gdt.pas index 35cfdde2..74fa1a8a 100644 --- a/src/gdt.pas +++ b/src/gdt.pas @@ -1,101 +1,71 @@ unit gdt; - + interface uses - util, - types, - console; - -procedure create(base : dword; limit : dword; flags : byte); -procedure init(); + types; type - TSegmentDescriptor = bitpacked record - limit_low : WORD; - base_low : WORD; - access : Byte; - limit_n_flags : Byte; - base_high : Byte; + TGDT_Entry = bitpacked record + limit_low : int16; + base_low : int16; + base_middle : int8; + access : int8; + granularity : int8; + base_high : int8; end; - PSegmentDescriptor = ^TSegmentDescriptor; + PGDT_Entry = ^TGDT_Entry; + TGDT_Pointer = bitpacked record + limit : int16; + base : int32; + end; + +var + gdt_entries : array[0..4] of TGDT_Entry; + gdt_pointer : TGDT_Pointer; + +procedure init(); + implementation -var - GDTarr : array [0..2] of TSegmentDescriptor; - GDTptr : PSegmentDescriptor; - GDT_length : integer = 0; - -procedure create(base : dword; limit : dword; flags : byte); -var - descriptor : array[0..8] of Byte; - descriptor_ptr : PByte; - - s_descriptor : TSegmentDescriptor; - s_descriptor_ptr : PSegmentDescriptor; +procedure flush_gdt(gdt_pointer : int32); assembler; nostackframe; +asm + MOV EAX, gdt_pointer + LGDT [EAX] + MOV AX, $10 + MOV DS, AX + MOV ES, AX + MOV FS, AX + MOV GS, AX + MOV SS, AX + db $EA // Bypass stupid inline ASM restrictions- + dw @@flush, $08 // by assembling the farjump instruction ourselves. + // It's just data, honest gov'. +@@flush: + RET +end; +procedure set_gate(Gate_Number : int32; Base : int32; Limit : int32; Access : int8; Granularity : int8); begin - descriptor_ptr:= @descriptor[0]; - s_descriptor_ptr:= @s_descriptor; - if limit <= 65536 then begin - descriptor[6] := $40; - end else begin - if (limit and $FFF) <> $FFF then begin - limit := (limit SHR 12) - 1; - end else begin - limit := limit SHR 12; - end; - descriptor[6] := $C0; - end; - - descriptor[0] := limit and $FF; - descriptor[1] := (limit shr 8) and $FF; - descriptor[6] := descriptor[6] or ((limit shr 16) and $F); - - descriptor[2] := base and $FF; - descriptor[3] := (base shr 8) and $FF; - descriptor[4] := (base shr 16) and $FF; - descriptor[7] := (base shr 24) and $FF; - - descriptor[5] := flags; - - asm - MOV EAX, descriptor_ptr - MOV s_descriptor_ptr, EAX - end; - - descriptor_ptr:= @descriptor[4]; - - asm - MOV EAX, descriptor_ptr - MOV EBX, s_descriptor_ptr - ADD EBX, 1 - MOV [EBX], EAX - end; - - GDTarr[GDT_length] := s_descriptor; - GDT_length := GDT_length + 1; + gdt_entries[Gate_Number].base_low := (Base AND $FFFF); + gdt_entries[Gate_Number].base_middle := (Base SHR 16) AND $FF; + gdt_entries[Gate_Number].base_high := (Base SHR 24) AND $FF; + gdt_entries[Gate_Number].limit_low := (Limit AND $FFFF); + gdt_entries[Gate_Number].granularity := ((Limit SHR 16) AND $0F) OR (Granularity AND $F0); + gdt_entries[Gate_Number].access := Access; end; procedure init(); -var - data_addr : dword; begin - GDTptr := @GDTarr[0]; - data_addr := (@GDTarr[2] - @GDTarr[0]) shr 16; - create($0000, $0000, $00); //null segment / GDT pointer - create($0000, $FFFF, $9A); //code descriptor - create($0000, $FFFF, $92); //data descriptor - asm - LGDT GDTptr - MOV EAX, data_addr - MOV DS, AX - MOV SS, AX - MOV ES, AX - MOV FS, AX - MOV GS, AX - end; + gdt_pointer.limit := (sizeof(TGDT_Entry) * 5) - 1; + gdt_pointer.base := int32(@gdt_entries); + set_gate($00, $00, $00, $00, $00); + set_gate($01, $00, $FFFFFFFF, $9A, $CF); + set_gate($02, $00, $FFFFFFFF, $92, $CF); + set_gate($03, $00, $FFFFFFFF, $FA, $CF); + set_gate($04, $00, $FFFFFFFF, $F2, $CF); + flush_gdt(int32(@gdt_pointer)) end; -end. +end. \ No newline at end of file diff --git a/src/system.pas b/src/system.pas index 6f706f00..dd3e3d48 100644 --- a/src/system.pas +++ b/src/system.pas @@ -3,12 +3,12 @@ unit system; interface type - cardinal = 0..$FFFFFFFF; - hresult = cardinal; - dword = cardinal; - integer = longint; + cardinal = 0..$FFFFFFFF; + hresult = cardinal; + dword = cardinal; + integer = longint; - pchar = ^char; + pchar = ^char; implementation