mirror of
https://github.com/tailix/kernel.git
synced 2024-10-30 12:03:52 -04:00
Initialize timer
This commit is contained in:
parent
572d79af73
commit
4f336e6cca
4 changed files with 23 additions and 3 deletions
|
@ -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:
|
||||
|
|
|
@ -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
13
arch/timer.c
Normal 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
6
arch/timer.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef KERNELMQ_INCLUDED_TIMER
|
||||
#define KERNELMQ_INCLUDED_TIMER 1
|
||||
|
||||
void timer_initialize(unsigned int frequency);
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue