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

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.

View File

@ -18,12 +18,23 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; 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.'); console.writestringln('Divide by Zero Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
@ -33,4 +44,27 @@ begin
IDT.set_gate(0, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(0, uint32(@Main), $08, ISR_RING_0);
end; 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. end.

View File

@ -14,13 +14,14 @@ interface
uses uses
util, util,
console, console,
isr_types,
IDT; IDT;
type //type
pp_void = procedure(); // pp_void = procedure();
var //var
procedure_ptr : pp_void = nil; // procedure_ptr : pp_void = nil;
procedure register(); procedure register();
@ -28,9 +29,9 @@ implementation
procedure Main; interrupt; //IRQ0, called every 55ms procedure Main; interrupt; //IRQ0, called every 55ms
begin begin
if(procedure_ptr <> nil) then begin //if(procedure_ptr <> nil) then begin
procedure_ptr(); //procedure_ptr();
end; //end;
outb($20, $20); outb($20, $20);
end; end;

View File

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

View File

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

View File

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