Exemplo n.º 1
0
void init_timer(uint16_t frequency)
{
	// 0x8e I think is the most important one, when setting IDT
	// in this code, it contains information of privilege level, 
	// which is 0 and e = 1110 which means interrupt gate
	set_IDT(32, (uint32_t)interrupt_handler, 0x08, 0x8e);
	uint16_t divisor = 1193180 / frequency;
	// Send the command port, 0x36 meanx Chanel 0, l/d access, mode 2
	outb(0x43, 0x34);
	// the port just have 8 bits
	uint8_t low = (uint8_t)(divisor & 0xff);
	uint8_t high = (uint8_t)((divisor >> 8) & 0xff);
	// send frequency divisor to data port of chanel 0
	outb(0x40, low);
	outb(0x40, high);
}
Exemplo n.º 2
0
	static void setupIDT() {
		set_IDT(sizeof(idt)-1, idt);
	}