71 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			71 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| #include <system.h>
 | |
| #include "isrs.h"
 | |
| #include "../idt/idt.h"
 | |
| 
 | |
| extern void _STOP_ERROR_SCREEN(ISR_stack_regs *);
 | |
| /* This is a very repetitive function... it's not hard, it's
 | |
| *  just annoying. As you can see, we set the first 32 entries
 | |
| *  in the IDT to the first 32 ISRs. We can't use a for loop
 | |
| *  for this, because there is no way to get the function names
 | |
| *  that correspond to that given entry. We set the access
 | |
| *  flags to 0x8E. This means that the entry is present, is
 | |
| *  running in ring 0 (kernel level), and has the lower 5 bits
 | |
| *  set to the required '14', which is represented by 'E' in
 | |
| *  hex. */
 | |
| void i86_isrs_install()
 | |
| {
 | |
|       i86_idt_set_gate(0, (unsigned)i86_isr0, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(1, (unsigned)i86_isr1, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(2, (unsigned)i86_isr2, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(3, (unsigned)i86_isr3, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(4, (unsigned)i86_isr4, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(5, (unsigned)i86_isr5, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(6, (unsigned)i86_isr6, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(7, (unsigned)i86_isr7, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(8, (unsigned)i86_isr8, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(9, (unsigned)i86_isr9, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(10, (unsigned)i86_isr10, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(11, (unsigned)i86_isr11, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(12, (unsigned)i86_isr12, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(13, (unsigned)i86_isr13, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(14, (unsigned)i86_isr14, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(15, (unsigned)i86_isr15, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(16, (unsigned)i86_isr16, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(17, (unsigned)i86_isr17, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(18, (unsigned)i86_isr18, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(19, (unsigned)i86_isr19, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(20, (unsigned)i86_isr20, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(21, (unsigned)i86_isr21, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(22, (unsigned)i86_isr22, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(23, (unsigned)i86_isr23, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(24, (unsigned)i86_isr24, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(25, (unsigned)i86_isr25, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(26, (unsigned)i86_isr26, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(27, (unsigned)i86_isr27, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(28, (unsigned)i86_isr28, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(29, (unsigned)i86_isr29, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(30, (unsigned)i86_isr30, 0x08, 0x8E);
 | |
|       i86_idt_set_gate(31, (unsigned)i86_isr31, 0x08, 0x8E);
 | |
| }
 | |
| 
 | |
| 
 | |
| 
 | |
| /* All of our Exception handling Interrupt Service Routines will
 | |
| *  point to this function. This will tell us what exception has
 | |
| *  happened! Right now, we simply halt the system by hitting an
 | |
| *  endless loop. All ISRs disable interrupts while they are being
 | |
| *  serviced as a 'locking' mechanism to prevent an IRQ from
 | |
| *  happening and messing up kernel data structures */
 | |
| void i86_fault_handler(ISR_stack_regs *r)
 | |
| {
 | |
|     /* Is this a fault whose number is from 0 to 31? */
 | |
|     if (r->int_no < 32)
 | |
|     {
 | |
|         _STOP_ERROR_SCREEN(r);
 | |
|         /* Display the description for the Exception that occurred.*/
 | |
|         
 | |
|         /* Put on the BSOD screen*/
 | |
|         for (;;);
 | |
|     }
 | |
| }
 |