base for pit initialization(not

This commit is contained in:
shockrah 2019-11-09 19:02:47 -08:00
parent d56780dc0b
commit c36651c5c7
3 changed files with 34 additions and 0 deletions

View File

@ -2,12 +2,14 @@
#include "types.h"
#include "tests.h"
#include "interrupts.h"
#include "pit.h"
#include "stlio.h"
#include "gdt.h"
void kinit() {
//gdt_configure();
init_idt();
pit_install_timer();
test_dispatcher();
}

19
pit.c Normal file
View File

@ -0,0 +1,19 @@
#include "pit.h"
#include "types.h"
#include "interrupts.h"
#include "stlio.h"
timer_ticks = 0;
void inc_ticks(struct cpu_reg_state* cpu) {
timer_ticks++;
if(timer_ticks % 18 == 0) {
printf("One second passed\n");
}
}
void tick_width(u32 width) {
}
void pit_install_timer(void) {
init_irq_handler(0, inc_ticks); // timer interrupt request falls into int 0
}

13
pit.h Normal file
View File

@ -0,0 +1,13 @@
#include "types.h"
u32 timer_ticks;
// 60hz timer for now
#define PIT_TIMER_INTERVAL 100
#define PIT_TIME_DATA0 0x40
#define PIT_TIME_DATA1 0x41
#define PIT_TIME_DATA2 0x42
// Sets the tick rate 100hz
void tick_width(u32);
void inc_ticks(struct cpu_reg_state* cpu);