mirror of
https://github.com/gbowne1/ClassicOS.git
synced 2025-10-13 21:25:07 -07:00
doing some memory work and gdt and timer and vga
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#include "timer.h"
|
||||
#include "io.h"
|
||||
#include "isr.h"
|
||||
#include "terminal.h"
|
||||
|
||||
static uint32_t tick = 0;
|
||||
|
||||
void timer_callback(void) {
|
||||
tick++;
|
||||
// Optional: Print every 100 ticks
|
||||
// if (tick % 100 == 0) {
|
||||
// terminal_write("Tick\n");
|
||||
// }
|
||||
}
|
||||
|
||||
void timer_init(uint32_t frequency) {
|
||||
register_interrupt_handler(32, timer_callback); // IRQ0 = Interrupt 32
|
||||
|
||||
uint32_t divisor = 1193180 / frequency;
|
||||
|
||||
outb(0x43, 0x36); // Command byte
|
||||
outb(0x40, divisor & 0xFF); // Low byte
|
||||
outb(0x40, (divisor >> 8)); // High byte
|
||||
}
|
||||
|
||||
uint32_t timer_get_ticks(void) {
|
||||
return tick;
|
||||
}
|
Reference in New Issue
Block a user