base for pit initialization(not
This commit is contained in:
parent
d56780dc0b
commit
c36651c5c7
2
kernel.c
2
kernel.c
@ -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
19
pit.c
Normal 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
13
pit.h
Normal 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);
|
Loading…
Reference in New Issue
Block a user