pit: fix pit_init and add freq argument
This commit is contained in:
+1
-1
@@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
#include "../include/utils.h"
|
#include "../include/utils.h"
|
||||||
|
|
||||||
void pit_init();
|
void pit_init(int freq);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ void default_handler()
|
|||||||
|
|
||||||
__attribute__((interrupt)) void isr_timer(struct interrupt_frame *frame)
|
__attribute__((interrupt)) void isr_timer(struct interrupt_frame *frame)
|
||||||
{
|
{
|
||||||
pit_init();
|
pit_init(100);
|
||||||
pic_end_int(0x0);
|
pic_end_int(0x0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ void kmain()
|
|||||||
printf("KatauOS booting up\n");
|
printf("KatauOS booting up\n");
|
||||||
isr_install();
|
isr_install();
|
||||||
pic_remap(0x20, 0x28);
|
pic_remap(0x20, 0x28);
|
||||||
pit_init();
|
pit_init(100);
|
||||||
|
|
||||||
apply_pic_masks();
|
apply_pic_masks();
|
||||||
|
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ Bit/s Usage
|
|||||||
#define PIT_COMMAND_PORT 0x43
|
#define PIT_COMMAND_PORT 0x43
|
||||||
#define PIT_DATA_PORT 0x40
|
#define PIT_DATA_PORT 0x40
|
||||||
|
|
||||||
void pit_init() {
|
void pit_init(int freq) {
|
||||||
uint16_t frequency = 100;
|
int divisor = 1193180 / freq;
|
||||||
uint8_t command = 0x36;//00110110 see above to get the idea wtf is this number
|
uint8_t command = 0x36;//00110110 see above to get the idea wtf is this number
|
||||||
|
|
||||||
outb(PIT_COMMAND_PORT, command);
|
outb(PIT_COMMAND_PORT, command);
|
||||||
|
|
||||||
outb(PIT_DATA_PORT, (uint8_t)(frequency & 0xFF));
|
outb(PIT_DATA_PORT, divisor & 0xFF);
|
||||||
outb(PIT_DATA_PORT, (uint8_t)((frequency >> 8) & 0xFF));
|
outb(PIT_DATA_PORT, divisor >> 8);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user