File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55
66void pit_init (uint32_t frequency );
77uint64_t timer_get_ticks (void );
8+ void timer_handler (void );
9+ void timer_init (void );
810
911#endif
1012
Original file line number Diff line number Diff line change 1+ #include <stdint.h>
2+ #include "timer.h"
3+
4+ // This counter increments every time the PIT timer fires
5+ static uint64_t global_ticks = 0 ;
6+
7+ uint64_t timer_get_ticks () {
8+ return global_ticks ;
9+ }
10+
11+ // This is called by your interrupt handler in isr.c
12+ void timer_handler (void ) {
13+ global_ticks ++ ;
14+ }
15+
16+ // Basic PIT initialization (100Hz)
17+ void timer_init (void ) {
18+ // You can add outb() commands here later to set the frequency
19+ }
Original file line number Diff line number Diff line change 88#include "serial.h"
99#include "types.h"
1010
11+ #include "timer.h"
12+
1113static isr_t interrupt_handlers [256 ];
12- static volatile uint64_t timer_ticks = 0 ;
1314static volatile uint32_t interrupt_depth = 0 ;
1415
1516static uint16_t * const vga_buffer = (uint16_t * )0xB8000 ;
@@ -194,7 +195,7 @@ static registers_t* exception_handler(registers_t* regs) {
194195}
195196
196197static registers_t * irq0_handler (registers_t * regs ) {
197- timer_ticks ++ ;
198+ timer_handler () ;
198199 kswapd_tick ();
199200 process_t * previous = 0 ;
200201 process_t * next = switch_task (regs , & previous );
@@ -239,7 +240,3 @@ registers_t* irq_handler(registers_t* regs) {
239240 outb (0x20 , 0x20 );
240241 return regs ;
241242}
242-
243- uint64_t timer_get_ticks (void ) {
244- return timer_ticks ;
245- }
Original file line number Diff line number Diff line change 1+ #include "idt.h"
2+
3+ // Redirect to the implementation in isr.c
4+ void register_interrupt_handler (uint8_t n , isr_t handler );
5+
6+ // This file exists to satisfy dependencies on isr_handler.c
7+ // and can be expanded for specific handler logic if needed.
You can’t perform that action at this time.
0 commit comments