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

This commit is contained in:
aaron 2017-05-17 17:38:37 +00:00
parent f8399ecace
commit 0e67eaf2b6
2 changed files with 85 additions and 23 deletions

View File

@ -1,7 +1,7 @@
{ ************************************************ { ************************************************
* Asuro * Asuro
* Unit: Drivers/isr32 * Unit: Drivers/isr32
* Description: 55ms Timer interrupt * Description: 1024hz Timer interrupt
************************************************ ************************************************
* Author: Aaron Hance * Author: Aaron Hance
* Contributors: * Contributors:
@ -17,21 +17,27 @@ uses
isr_types, isr_types,
IDT; IDT;
//type
// pp_void = procedure();
//var
// procedure_ptr : pp_void = nil;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
procedure Main; interrupt; //IRQ0, called every 55ms var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main; interrupt; //IRQ0, 1024.19hz aprox
var
i : integer;
begin begin
//if(procedure_ptr <> nil) then begin for i:=0 to MAX_HOOKS-1 do begin
//procedure_ptr(); if uint32(Hooks[i]) <> 0 then begin
//end; Hooks[i](nil);
end else begin
Hooks[i](nil);
end;
end;
outb($20, $20); outb($20, $20);
end; end;
@ -45,7 +51,34 @@ begin
mov al, ah mov al, ah
out $40, al out $40, al
end; end;
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(32, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(32, 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 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. end.

View File

@ -17,24 +17,27 @@ uses
isr_types, isr_types,
IDT; IDT;
type
pp_byte = procedure(key_code : byte);
var
procedure_ptr : pp_byte = nil;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
procedure Main; interrupt; //IRQ1, Keyboard Interrupt var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt;
var
i : integer;
begin begin
console.writestring('Keyboard: ');
console.writehexln(inb($60)); for i:=0 to MAX_HOOKS-1 do begin
if(procedure_ptr <> nil) then begin if uint32(Hooks[i]) <> 0 then begin
procedure_ptr(inb($60)); Hooks[i](nil);
end else begin
Hooks[i](void(inb($60)));
end;
end; end;
outb($A0, $20);
outb($20, $20); outb($20, $20);
end; end;
@ -42,5 +45,31 @@ procedure register();
begin begin
IDT.set_gate(33, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(33, 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 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. end.