1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-10-30 12:03:52 -04:00

Initialize timer

This commit is contained in:
Braiden Vasco 2017-11-03 04:19:48 +00:00
parent 572d79af73
commit 4f336e6cca
4 changed files with 23 additions and 3 deletions

View file

@ -11,6 +11,8 @@ OBJS += protected.c.o protected.asm.cpp.o
OBJS += exception.c.o exception.asm.cpp.o
OBJS += hwint.c.o hwint.asm.cpp.o
OBJS += timer.c.o
all: kernel
clean:

View file

@ -1,6 +1,7 @@
#include "multiboot.h"
#include "logger.h"
#include "protected.h"
#include "timer.h"
void main(struct KernelMQ_Multiboot_Info multiboot_info)
{
@ -11,9 +12,7 @@ void main(struct KernelMQ_Multiboot_Info multiboot_info)
logger_info("Kernel initialization started.");
protected_initialize();
asm volatile ("int $0x3");
asm volatile ("int $0x24");
timer_initialize(50);
logger_warn("Nothing to do.");
logger_fail("Halt.");

13
arch/timer.c Normal file
View file

@ -0,0 +1,13 @@
#include "timer.h"
#include "logger.h"
#include "asm.h"
void timer_initialize(unsigned int frequency)
{
logger_info("Initialize timer.");
outportb(0x43, 0x36);
outportb(0x40, (1193180 / frequency) & 0xFF);
outportb(0x40, (1193180 / frequency) >> 8);
}

6
arch/timer.h Normal file
View file

@ -0,0 +1,6 @@
#ifndef KERNELMQ_INCLUDED_TIMER
#define KERNELMQ_INCLUDED_TIMER 1
void timer_initialize(unsigned int frequency);
#endif