feat(pit): add pit initialization and handler

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
juju committed 2021-07-26 14:15:21 +02:00
1 parent 5064efa101
commit f6cdc3005d
4 files changed
+25 -4

No files matched your search

+1
View File
@@ -44,6 +44,7 @@ void init_pic(void)
send_icw4();
mask_irqs();
init_keyboard();
init_pit();
asm volatile("sti");
}
+14
View File
@@ -1,9 +1,23 @@
#include "pit.h"
#include "io.h"
#include "stdio.h"
static unsigned long ticks = 0;
void pit_handler(void)
{
++ticks;
}
unsigned long gettick(void)
{
return ticks;
}
void init_pit(void)
{
outb(PIT_CONTROL_REG, PIT_MODE_2 | PIT_RW_LSB | PIT_RW_MSB);
outb(PIT_COUNTER_0, PIT_DIVIDER & 0xff);
outb(PIT_COUNTER_0, PIT_DIVIDER >> 8);
}
+9 -1
View File
@@ -4,9 +4,17 @@
#define PIT_COUNTER_0 0x40
#define PIT_COUNTER_1 0x41
#define PIT_COUNTER_2 0x42
#define PIT_CONTROL_REGISTER 0x43
#define PIT_CONTROL_REG 0x43
#define PIT_MODE_2 (0x2 << 1)
#define PIT_RW_LSB (0x1 << 4)
#define PIT_RW_MSB (0x1 << 5)
#define PIT_DIVIDER 11931
void pit_handler(void);
unsigned long gettick(void);
void init_pit(void);
#endif /* !PIT_H */
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.