pit ticks each ms
This commit is contained in:
parent
57a6d51e68
commit
3e127f4686
1
Makefile
1
Makefile
|
@ -20,6 +20,7 @@ ISO := Hazel.iso
|
|||
CFLAGS := -ffreestanding -Wall -Wextra -Werror -I $(INCLUDEDIR) -I lib
|
||||
LDFLAGS := -ffreestanding -nostdlib -lgcc -T kernel/kernel.ld
|
||||
QEMUFLAGS := -cdrom $(BUILDDIR)/$(ISO) \
|
||||
-d int \
|
||||
-serial stdio
|
||||
|
||||
$(BUILDDIR)/$(KIMG): $(KOBJ) $(LOBJ)
|
||||
|
|
|
@ -7,12 +7,13 @@
|
|||
#define PIT_MODE_CMD 0x43
|
||||
|
||||
#define PIT_MODE0 0
|
||||
#define PIT_MODE2 (2<<1)
|
||||
#define PIT_LOBYTE (1<<4)
|
||||
#define PIT_LOHIGH (3<<4)
|
||||
#define PIT_CHAN0 0
|
||||
|
||||
#define PIT_FREQUENCY 1193182
|
||||
#define DESIRED_FREQUENCY 100
|
||||
#define DESIRED_FREQUENCY 1000
|
||||
#define DIVISOR (PIT_FREQUENCY/DESIRED_FREQUENCY)
|
||||
|
||||
void pit_init(void);
|
||||
|
|
|
@ -6,14 +6,16 @@
|
|||
extern kernel_ctx_t ctx;
|
||||
|
||||
void pit_init(void) {
|
||||
outb(PIT_MODE_CMD, PIT_CHAN0 | PIT_LOBYTE | PIT_MODE0);
|
||||
outb(PIT_MODE_CMD, PIT_CHAN0 | PIT_LOHIGH | PIT_MODE2);
|
||||
|
||||
outb(PIT_CHAN0_DATA, (uint8_t)(DIVISOR & 0xff));
|
||||
outb(PIT_CHAN0_DATA, (uint8_t)((DIVISOR & 0xff00) >> 8));
|
||||
}
|
||||
|
||||
void pit_handler(void) {
|
||||
ctx.ticks++;
|
||||
|
||||
outb(PIT_CHAN0_DATA, (uint8_t)(DIVISOR & 0xff));
|
||||
outb(PIT_CHAN0_DATA, (uint8_t)((DIVISOR & 0xff00) >> 8));
|
||||
pic_send_eoi(0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user