Started Hooking for ISRs.
git-svn-id: https://spexeah.com:8443/svn/Asuro@74 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
		
							
								
								
									
										
											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; | ||||
|  | ||||
| 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. | ||||
| @@ -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; | ||||
|   | ||||
| @@ -14,6 +14,7 @@ interface | ||||
| uses | ||||
|     util, | ||||
|     console, | ||||
|     isr_types, | ||||
|     IDT; | ||||
|  | ||||
| type | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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. | ||||
		Reference in New Issue
	
	Block a user
	 kieron
					kieron