Started Hooking for ISRs.

git-svn-id: https://spexeah.com:8443/svn/Asuro@74 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
kieron
2017-05-17 16:58:54 +00:00
parent 6b2f0220fd
commit c528e72f4a
11 changed files with 61 additions and 21 deletions

View File

@ -18,12 +18,23 @@ uses
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](nil);
end;
console.writestringln('Divide by Zero Exception.');
util.halt_and_catch_fire;
end;
@ -33,4 +44,27 @@ begin
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 Hooks[i]:= pp_hook_method(hook_method);
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

@ -14,13 +14,14 @@ interface
uses
util,
console,
isr_types,
IDT;
type
pp_void = procedure();
//type
// pp_void = procedure();
var
procedure_ptr : pp_void = nil;
//var
// procedure_ptr : pp_void = nil;
procedure register();
@ -28,21 +29,21 @@ implementation
procedure Main; interrupt; //IRQ0, called every 55ms
begin
if(procedure_ptr <> nil) then begin
procedure_ptr();
end;
//if(procedure_ptr <> nil) then begin
//procedure_ptr();
//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
mov al, $36
out $46, al
mov ax, 1165
out $40, al
mov al, ah
out $40, al
end;
IDT.set_gate(32, uint32(@Main), $08, ISR_RING_0);
end;

View File

@ -14,6 +14,7 @@ interface
uses
util,
console,
isr_types,
IDT;
type

View File

@ -14,13 +14,11 @@ interface
uses
util,
console,
isr_types,
IDT;
type
pp_void = procedure();
var
procedure_ptr : pp_void = nil;
//var
//procedure_ptr : pp_void = nil;
procedure register();
@ -29,9 +27,9 @@ implementation
procedure Main; interrupt; //IRQ0, called 1024 times a second.
begin
console.writestringln('helo3');
if(procedure_ptr <> nil) then begin
procedure_ptr();
end;
//if(procedure_ptr <> nil) then begin
// procedure_ptr();
//end;
outb($A0, $20);
outb($20, $20);
end;

View File

@ -11,12 +11,18 @@ unit isr_types;
interface
const
MAX_HOOKS = 16;
type
ISR_REGS = record
ip, cs, flags, sp, ss : uint16;
end;
PISR_REGS = ^ISR_REGS;
pp_hook_method = procedure(data : void);
pp_void = pp_hook_method;
implementation
end.