summaryrefslogtreecommitdiff
path: root/src/interrupt.h
blob: 5e0112b4939a2ddd905f068818a6f0690d9f7925 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

#ifndef __INTERRUPT_H
#define __INTERRUPT_H

#include <stdint.h>
#include <stddef.h>
#include "vga.h"
#include "port.h"

struct gate_desc
{
	uint16_t handler_low;  // the low bits of the address of the handler
	uint16_t gdt_code_seg; // the address of the code segment descriptor
	uint8_t reserved;      // we don't use this apparently
	uint8_t access;        // access rights
	uint16_t handler_high; // the high bits of the address of the handler
} __attribute__((packed));

struct gate_desc idt[256];

struct idt_pointer
{
	uint16_t size;
	uint32_t base;
} __attribute__((packed));

void set_int_desc_entry(uint8_t int_number, uint16_t gdt_code_seg,
						void (*handler)(), uint8_t privlege_level,
						uint8_t desc_type);

void interrupt_init();

void start_interrupts();

void handle_irq0x00();
void handle_irq0x01();
void handle_irq0x0D();

void int_ignore();

struct port pic_master_command;
struct port pic_master_data;
struct port pic_slave_command;
struct port pic_slave_data; 

#endif