git-svn-id: https://spexeah.com:8443/svn/Asuro@507 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c

This commit is contained in:
kieron
2018-04-12 14:38:50 +00:00
parent 866362b5b0
commit 3124582151
110 changed files with 2499 additions and 1450 deletions

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR0
* Description: Divide-By-Zero Exception
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr0;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(0));
end;
BSOD('DBZ', 'Divide By Zero Exception.');
console.writestringln('Divide by Zero Exception.');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(0, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR1
* Description: Debug Exception
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr1;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(1));
end;
BSOD('DE', 'Debug Exception');
console.writestringln('Debug Exception.');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(1, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR10
* Description: Bad TSS Exception
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr10;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(10));
end;
BSOD('TSS', 'Bad TSS Exception.');
console.writestringln('Bad TSS Exception.');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(10, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR11
* Description: Segment Not Present Exception
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr11;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(11));
end;
BSOD('SNS', 'Segment Not Present Exception.');
console.writestringln('Segment Not Present Exception.');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(11, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR12
* Description: Stack Fault Exception
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr12;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(12));
end;
BSOD('SF', 'Stack Fault Exception.');
console.writestringln('Stack Fault Exception.');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(12, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,88 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR13
* Description: General Protection Fault
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr13;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : uint32;
Regs : PRegisters;
begin
CLI;
asm
MOV EAX, EBP
MOV Regs, EAX
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(13));
end;
BSOD('GPF', 'General Protection Fault.');
console.writestringln('General Protection Fault.');
console.writestring('Flags: ');
console.writehexln(Regs^.EFlags);
console.writestring('EIP: ');
console.writehexln(Regs^.EIP);
console.writestring('CS: ');
console.writehexln(Regs^.CS);
console.writestring('Error Code: ');
console.writehexln(Regs^.ErrorCode);
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(13, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR14
* Description: Page Fault
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr14;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(14));
end;
BSOD('PF', 'Page Fault.');
console.writestringln('Page Fault.');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(14, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR15
* Description: Unknown Interrupt Exception
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr15;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(15));
end;
BSOD('UI', 'Unknown Interrupt Exception.');
console.writestringln('Unknown Interrupt Exception.');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(15, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR11
* Description: Coprocessor Fault Exception
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr16;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(16));
end;
BSOD('CF', 'Coprocessor Fault Exception.');
console.writestringln('Coprocessor Fault Exception.');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(16, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR17
* Description: Alignment Check Exception
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr17;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(17));
end;
BSOD('AC', 'Alignment Check Exception.');
console.writestringln('Alignment Check Exception.');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(17, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR18
* Description: Machine Check Exception
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr18;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(18));
end;
BSOD('MC', 'Machine Check Exception.');
console.writestringln('Machine Check Exception.');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(18, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR2
* Description: Non-Maskable Interrupt Exception
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr2;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(2));
end;
BSOD('NMI', 'Non-Maskable Interrupt Exception.');
console.writestringln('NMI Exception.');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(2, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR3
* Description: Breakpoint Exception
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr3;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(3));
end;
BSOD('BE', 'Breakpoint Exception.');
console.writestringln('Breakpoint Exception');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(3, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,88 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/isr32
* Description: 1024hz Timer interrupt
************************************************
* Author: Aaron Hance
* Contributors: K Morris
************************************************ }
unit isr32;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main; interrupt; //IRQ0, 1024.19hz aprox
var
i : integer;
regs : PRegisters;
begin
CLI;
asm
MOV EAX, EBP
MOV Regs, EAX
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then begin
Hooks[i](nil);
end;
end;
outb($20, $20);
end;
procedure register();
begin
asm
mov al, $36
out $46, al
mov ax, 1165
out $40, al
mov al, ah
out $40, al
end;
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(32, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,81 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/isr33
* Description: Keyboard interrupt
************************************************
* Author: Aaron Hance
* Contributors: K Morris
************************************************ }
unit isr33;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
b : dword;
begin
//writechar('!'); // Bug traces all the way back to here - when the keyboard randomly doesn't work, this inturrupt isn't even called...
// This needs further investigation... Is there something that can go wrong when setting up the PIC?
CLI;
b:= inb($60);
//console.writehexln(b);
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then begin
Hooks[i](void(b));
end;
end;
outb($20, $20);
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(33, uint32(@Main), $08, ISR_RING_0);
inb($60);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR4
* Description: Into Detected Overflow Exception
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr4;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(4));
end;
BSOD('IDO', 'Into Detected Overflow Exception.');
console.writestringln('IDO Exception.');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(4, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,74 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/isr40
* Description: 1024/s Timer interrupt
************************************************
* Author: Aaron Hance
* Contributors: K Morris
************************************************ }
unit isr40;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main; interrupt; //IRQ0, called 1024 times a second.
var
i : integer;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(18));
end;
outb($A0, $20);
outb($20, $20);
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(40, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,183 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR45
* Description: Mouse ISR (IRQ12)
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr44;
interface
uses
tracer,
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
Cycle : uint32 = 0;
Mouse_Byte : Array[0..2] of uint8;
Packet : uint32;
procedure mouse_wait(w_type : uint8);
var
timeout : uint32;
begin
push_trace('isr44.mouse_wait');
timeout:= 100000;
if (w_type = 0) then begin
while (timeout > 0) do begin
if ((inb($64) AND $01) = $01) then break;
timeout:= timeout-1;
end;
end else begin
while (timeout > 0) do begin
if ((inb($64) AND 2) = 0) then break;
timeout := timeout - 1;
end;
end;
pop_trace;
end;
procedure mouse_write(value : uint8);
begin
push_trace('isr44.mouse_write');
mouse_wait(1);
outb($64, $D4);
mouse_wait(1);
outb($60, value);
pop_trace;
end;
function mouse_read : uint8;
begin
push_trace('isr44.mouse_read');
mouse_wait(0);
mouse_read:= inb($60);
pop_trace;
end;
procedure Main(); interrupt;
var
i : integer;
b : byte;
begin
{push_trace('isr44.main');
b:= mouse_read;
push_trace('isr44.main1');
if Cycle = 0 then begin
push_trace('isr44.main2');
if (b AND $08) = $08 then begin
push_trace('isr44.main3');
Mouse_Byte[Cycle]:= b;
push_trace('isr44.main4');
inc(Cycle);
end;
end else begin
push_trace('isr44.main5');
Mouse_Byte[Cycle]:= b;
push_trace('isr44.main6');
inc(Cycle);
end;
push_trace('isr44.main7');
if Cycle > 2 then begin
Cycle:= 0;
push_trace('isr44.main8');
// console.writestring('Packet[0]: ');
// console.writeintln(Mouse_Byte[0]);
// console.writestring('Packet[1]: ');
// console.writeintln(Mouse_Byte[1]);
// console.writestring('Packet[2]: ');
// console.writeintln(Mouse_Byte[2]);
push_trace('isr44.main9');
Packet:= (Mouse_Byte[0] SHL 24) OR (Mouse_Byte[1] SHL 16) OR (Mouse_Byte[2] SHL 8) OR ($FF);
push_trace('isr44.main10');
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(Packet));
end;
push_trace('isr44.main11');
end;
push_trace('isr44.main12');
outb($20, $20);
outb($A0, $20);
pop_trace;}
end;
procedure register();
var
status : uint8;
bm : PBitMask;
ak : uint8;
begin
push_trace('isr44.register');
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
mouse_wait(1);
outb($64, $A8);
mouse_wait(1);
outb($64, $20);
mouse_wait(0);
status:= inb($60) OR $02;
mouse_wait(1);
outb($64, $60);
mouse_wait(1);
outb($60, status);
mouse_write($F6);
mouse_read();
mouse_write($F4);
mouse_read();
IDT.set_gate(44, uint32(@Main), $08, ISR_RING_0);
pop_trace;
end;
procedure hook(hook_method : uint32);
var
i : uint32;
cont : boolean;
begin
push_trace('isr44.hook');
cont:= true;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then begin
cont:= false;
break;
end;
end;
if cont then begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
break;
end;
end;
end;
pop_trace;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
push_trace('isr44.unhook');
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
break;
end;
pop_trace;
end;
end.

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR5
* Description: Out of Bounds Exception
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr5;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(5));
end;
BSOD('OOB', 'Out of Bouunds Exception.');
console.writestringln('OOB Exception.');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(5, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR6
* Description: Invalid OPCode Exception
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr6;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(6));
end;
BSOD('IO', 'Invalid OPCode Exception.');
console.writestringln('Invalid OPCode Exception.');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(6, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR7
* Description: No Coprocessor Exception
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr7;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(7));
end;
BSOD('NC', 'No Coprocessor Exception.');
console.writestringln('No Coprocessor Exception.');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(7, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,73 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR46
* Description: Primary ATA IRQ
************************************************
* Author: Aaron Hance
* Contributors:
************************************************ }
unit isr76;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void($00000000));
end;
console.writestringln('Disk Operation Complete');
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(76, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR8
* Description: Double Fault Exception
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr8;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(8));
end;
BSOD('DF', 'Double Fault.');
console.writestringln('Double Fault.');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(8, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

View File

@ -1,75 +0,0 @@
{ ************************************************
* Asuro
* Unit: Drivers/ISR9
* Description: Coprocessor Seg Overrun Exception
************************************************
* Author: K Morris
* Contributors:
************************************************ }
unit isr9;
interface
uses
util,
console,
isr_types,
IDT;
procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin
CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(9));
end;
BSOD('CSO', 'Coprocessor Seg Overrun Exception.');
console.writestringln('Coprocessor Seg Overrun Exception.');
util.halt_and_catch_fire;
end;
procedure register();
begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(9, uint32(@Main), $08, ISR_RING_0);
end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end.

1595
src/isr/isrmanager.pas Normal file

File diff suppressed because it is too large Load Diff