Moved types to system.pas

Added first ISR (ISR0).

git-svn-id: https://spexeah.com:8443/svn/Asuro@37 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
kieron 2017-05-17 11:19:16 +00:00
parent cbd4685407
commit 220d6d8071
31 changed files with 96 additions and 68 deletions

BIN
Asuro.iso

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/idt.ppu Normal file

Binary file not shown.

BIN
lib/isr.ppu Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

12
src/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,12 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "gdb",
"request": "launch",
"target": "./bin/executable",
"cwd": "${workspaceRoot}"
}
]
}

View File

@ -2,9 +2,6 @@ unit bios_data_area;
interface interface
uses
types;
type type
TBDA = bitpacked record TBDA = bitpacked record
COM1 : uint16; COM1 : uint16;

View File

@ -2,9 +2,6 @@ unit gdt;
interface interface
uses
types;
type type
TGDT_Entry = bitpacked record TGDT_Entry = bitpacked record
limit_low : uint16; limit_low : uint16;

View File

@ -3,7 +3,6 @@ unit idt;
interface interface
uses uses
types,
util; util;
type type
@ -27,6 +26,7 @@ var
IDT_Pointer : TIDT_Pointer; IDT_Pointer : TIDT_Pointer;
procedure init(); procedure init();
procedure set_gate(Number : uint8; Base : uint32; Selector : uint16; Flags : uint8);
implementation implementation

31
src/isr.pas Normal file
View File

@ -0,0 +1,31 @@
unit isr;
interface
uses
idt,
console,
util;
procedure init();
implementation
procedure CLI(); assembler; nostackframe;
asm
CLI
end;
procedure isr0(); interrupt;
begin
CLI;
console.writestringln('Divide by Zero Exception.');
util.halt_and_catch_fire;
end;
procedure init();
begin
idt.set_gate(0, uint32(@isr0), $08, $8E);
end;
end.

View File

@ -3,11 +3,11 @@ unit kernel;
interface interface
uses uses
types,
multiboot, multiboot,
util, util,
gdt, gdt,
idt, idt,
isr,
console, console,
bios_data_area, bios_data_area,
keyboard; keyboard;
@ -21,6 +21,7 @@ var
c : uint8; c : uint8;
mbi : Pmultiboot_info_t; mbi : Pmultiboot_info_t;
mbm : uint32; mbm : uint32;
z : uint32;
dds : uint32; dds : uint32;
begin begin
@ -28,6 +29,7 @@ begin
mbm:= mbmagic; mbm:= mbmagic;
gdt.init(); gdt.init();
idt.init(); idt.init();
isr.init();
console.init(); console.init();
console.writestringln('Booting Asuro...'); console.writestringln('Booting Asuro...');
if (mbm <> MULTIBOOT_BOOTLOADER_MAGIC) then begin if (mbm <> MULTIBOOT_BOOTLOADER_MAGIC) then begin
@ -41,6 +43,7 @@ begin
asm asm
MOV dds, CS MOV dds, CS
end; end;
z:=0;
console.setdefaultattribute(console.combinecolors(Red, Black)); console.setdefaultattribute(console.combinecolors(Red, Black));
if dds = $08 then console.setdefaultattribute(console.combinecolors(Green, Black)); if dds = $08 then console.setdefaultattribute(console.combinecolors(Green, Black));
console.writehexln(dds); console.writehexln(dds);
@ -58,6 +61,8 @@ begin
console.writeint(((mbinfo^.mem_upper + 1000) div 1024) +1); console.writeint(((mbinfo^.mem_upper + 1000) div 1024) +1);
console.writestringln('MB'); console.writestringln('MB');
console.setdefaultattribute(console.combinecolors(lYellow, Black)); console.setdefaultattribute(console.combinecolors(lYellow, Black));
mbm := mbm div z;
util.halt_and_catch_fire;
{while true do begin {while true do begin
c:= keyboard.get_scancode; c:= keyboard.get_scancode;
console.writehexln(c); console.writehexln(c);

View File

@ -5,7 +5,6 @@ unit keyboard;
interface interface
uses uses
types,
util; util;
function get_scancode() : uint8; function get_scancode() : uint8;

View File

@ -1,9 +1,6 @@
unit multiboot; unit multiboot;
interface interface
uses
types;
const const
KERNEL_STACKSIZE = $4000; KERNEL_STACKSIZE = $4000;

View File

@ -1,15 +1,46 @@
unit system; unit system;
interface interface
type type
cardinal = 0..$FFFFFFFF; //internal types
hresult = cardinal; cardinal = 0..$FFFFFFFF;
dword = cardinal; hresult = cardinal;
integer = longint; dword = cardinal;
integer = longint;
pchar = ^char;
pchar = ^char;
implementation
//Standard Types
end. uInt8 = BYTE;
uInt16 = WORD;
uInt32 = DWORD;
uInt64 = QWORD;
sInt8 = shortint;
sInt16 = smallint;
sInt32 = integer;
sInt64 = longint;
Float = Single;
//Pointer Types
PuByte = ^Byte;
PuInt8 = PuByte;
PuInt16 = ^uInt16;
PuInt32 = ^uInt32;
PuInt64 = ^uInt64;
PsInt8 = ^sInt8;
PsInt16 = ^sInt16;
PsInt32 = ^sInt32;
PsInt64 = ^sInt64;
PFloat = ^Float;
PDouble = ^Double;
Void = ^uInt32;
implementation
end.

View File

@ -1,38 +0,0 @@
unit types;
interface
type
//Standard Types
uInt8 = BYTE;
uInt16 = WORD;
uInt32 = DWORD;
uInt64 = QWORD;
sInt8 = shortint;
sInt16 = smallint;
sInt32 = integer;
sInt64 = longint;
Float = Single;
//Pointer Types
PuByte = ^Byte;
PuInt8 = PuByte;
PuInt16 = ^uInt16;
PuInt32 = ^uInt32;
PuInt64 = ^uInt64;
PsInt8 = ^sInt8;
PsInt16 = ^sInt16;
PsInt32 = ^sInt32;
PsInt64 = ^sInt64;
PFloat = ^Float;
PDouble = ^Double;
Void = ^uInt32;
implementation
end.

View File

@ -4,9 +4,6 @@ unit util;
interface interface
uses
types;
function hi(b : uint8) : uint8; function hi(b : uint8) : uint8;
function lo(b : uint8) : uint8; function lo(b : uint8) : uint8;
function switchendian(b : uint8) : uint8; function switchendian(b : uint8) : uint8;