Started Hooking for ISRs.
git-svn-id: https://spexeah.com:8443/svn/Asuro@74 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
parent
6b2f0220fd
commit
c528e72f4a
BIN
bin/kernel.bin
BIN
bin/kernel.bin
Binary file not shown.
Binary file not shown.
BIN
lib/isr.ppu
BIN
lib/isr.ppu
Binary file not shown.
BIN
lib/isr0.ppu
BIN
lib/isr0.ppu
Binary file not shown.
BIN
lib/libpkernel.a
BIN
lib/libpkernel.a
Binary file not shown.
@ -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.
|
@ -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,21 +29,21 @@ 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;
|
||||||
|
|
||||||
procedure register();
|
procedure register();
|
||||||
begin
|
begin
|
||||||
asm
|
asm
|
||||||
mov al, $36
|
mov al, $36
|
||||||
out $46, al
|
out $46, al
|
||||||
mov ax, 1165
|
mov ax, 1165
|
||||||
out $40, al
|
out $40, al
|
||||||
mov al, ah
|
mov al, ah
|
||||||
out $40, al
|
out $40, al
|
||||||
end;
|
end;
|
||||||
IDT.set_gate(32, uint32(@Main), $08, ISR_RING_0);
|
IDT.set_gate(32, uint32(@Main), $08, ISR_RING_0);
|
||||||
end;
|
end;
|
||||||
|
@ -14,6 +14,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
util,
|
util,
|
||||||
console,
|
console,
|
||||||
|
isr_types,
|
||||||
IDT;
|
IDT;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
@ -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;
|
||||||
|
@ -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.
|
Loading…
x
Reference in New Issue
Block a user