Add: PIT (sysclock)
This commit is contained in:
Binary file not shown.
BIN
kernel.elf
BIN
kernel.elf
Binary file not shown.
25
kmain.c
25
kmain.c
@@ -23,34 +23,13 @@ int kmain(int retvalue)
|
||||
|
||||
clear();
|
||||
|
||||
// printf testing
|
||||
colorputs("Blank OS version 1 iteration 3 minor 20\n", 10);
|
||||
|
||||
// TODO: Framebuffer upgrade: color output
|
||||
// TODO: Serial printf to dump registers on kernel panic
|
||||
// TODO: Fix scrolling bug (framebuffer driver)
|
||||
|
||||
int age = 34;
|
||||
int problems = 124;
|
||||
char* name = "xamidev";
|
||||
|
||||
printf("Hello %s, you are %d years old and have %d problems. wow %%\n", name, age, problems);
|
||||
|
||||
long suchwow = 2934342;
|
||||
char character = 65;
|
||||
printf("such number %u\nsuch character %c", suchwow, character);
|
||||
|
||||
printf("wow negative %d\n", -3742);
|
||||
printf("such hex %x %X\n", 0xcafe, 0xdeadbeef);
|
||||
|
||||
printf("such pointer %p\n", (void*)0xcafe1234);
|
||||
|
||||
for (int i=0; i<10; i++)
|
||||
{
|
||||
colorputs("hello colorful world!!\n", i);
|
||||
}
|
||||
// Div by zero exception
|
||||
|
||||
//printf("Lalala, what a beautiful day! %d", 4/0);
|
||||
timer_install();
|
||||
|
||||
return retvalue;
|
||||
}
|
||||
|
||||
2
makefile
2
makefile
@@ -1,4 +1,4 @@
|
||||
OBJECTS = loader.o kmain.o stdio.o io.o string.o serial.o gdt.o idt.o system.o isr.o irq.o
|
||||
OBJECTS = loader.o kmain.o stdio.o io.o string.o serial.o gdt.o idt.o system.o isr.o irq.o timer.o
|
||||
CC = gcc
|
||||
CFLAGS = -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -Wall -Wextra -c
|
||||
LDFLAGS = -T link.ld -melf_i386
|
||||
|
||||
3
system.h
3
system.h
@@ -17,4 +17,7 @@ void isr_install();
|
||||
void irq_install();
|
||||
void irq_install_handler(int irq, void (*handler)(struct regs *r));
|
||||
void irq_uninstall_handler(int irq);
|
||||
void timer_install();
|
||||
void delay(int ticks);
|
||||
#endif
|
||||
|
||||
|
||||
26
timer.c
Normal file
26
timer.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "system.h"
|
||||
#include "stdio.h"
|
||||
|
||||
int timer_ticks = 0;
|
||||
|
||||
void timer_handler()
|
||||
{
|
||||
timer_ticks++;
|
||||
|
||||
if(timer_ticks % 18 == 0)
|
||||
{
|
||||
puts("One second has passed\n");
|
||||
}
|
||||
}
|
||||
|
||||
void timer_install()
|
||||
{
|
||||
irq_install_handler(0, timer_handler);
|
||||
}
|
||||
|
||||
void delay(int ticks)
|
||||
{
|
||||
unsigned long eticks;
|
||||
eticks = timer_ticks + ticks;
|
||||
while ((unsigned long)timer_ticks < eticks);
|
||||
}
|
||||
Reference in New Issue
Block a user