aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorFranklin Wei <frankhwei536@gmail.com>2015-02-09 21:00:38 -0500
committerFranklin Wei <frankhwei536@gmail.com>2015-02-09 21:00:38 -0500
commit893694168d8b943505ff30bd4db57ac8aaef6fef (patch)
treec5e74fade8a3183e5b6db53e45eb58cb707dff05 /kernel
parentd894f23d893ee2fa05c34f02231e5c46563dc312 (diff)
downloadkappa-893694168d8b943505ff30bd4db57ac8aaef6fef.zip
kappa-893694168d8b943505ff30bd4db57ac8aaef6fef.tar.gz
kappa-893694168d8b943505ff30bd4db57ac8aaef6fef.tar.bz2
kappa-893694168d8b943505ff30bd4db57ac8aaef6fef.tar.xz
optimization
Diffstat (limited to 'kernel')
-rw-r--r--kernel/include/fpu.h4
-rw-r--r--kernel/include/log.h2
-rw-r--r--kernel/log.c2
-rw-r--r--kernel/main.c58
4 files changed, 47 insertions, 19 deletions
diff --git a/kernel/include/fpu.h b/kernel/include/fpu.h
index da2b48a..0eb448a 100644
--- a/kernel/include/fpu.h
+++ b/kernel/include/fpu.h
@@ -1,2 +1,2 @@
-void enable_fpu(void);
-void disable_fpu(void);
+void fpu_enable(void);
+void fpu_disable(void);
diff --git a/kernel/include/log.h b/kernel/include/log.h
index 6953bee..1a28c0d 100644
--- a/kernel/include/log.h
+++ b/kernel/include/log.h
@@ -1,3 +1,3 @@
-void log_putchar(char);
+void log_putchar(int);
void log_puts(const char*);
void log(const char*, ...);
diff --git a/kernel/log.c b/kernel/log.c
index efc945d..311af54 100644
--- a/kernel/log.c
+++ b/kernel/log.c
@@ -7,7 +7,7 @@
void log_putchar(int ch)
{
- BOCHS_PUTCHAR(ch);
+ BOCHS_PUTCHAR((char)ch);
}
void log_puts(const char* str)
diff --git a/kernel/main.c b/kernel/main.c
index 787a471..fd263db 100644
--- a/kernel/main.c
+++ b/kernel/main.c
@@ -1,8 +1,10 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include "fpu.h"
#include "gdt.h"
#include "gfx.h"
+#include "gfx_font.h"
#include "idt.h"
#include "isr.h"
#include "irq.h"
@@ -17,10 +19,11 @@
void gpf(struct regs_t regs)
{
+ gfx_reset();
printf("General protection fault!\n");
printf("EIP before fault: 0x%x\n", regs.eip);
printf("Error code: 0x%x\n", regs.err_code);
- panic("GPF");
+ panic("GPF!");
}
void main(struct multiboot_info_t *hdr, uint32_t magic)
@@ -63,22 +66,30 @@ void main(struct multiboot_info_t *hdr, uint32_t magic)
printf("Boot finished.\n");
- printf("Testing RNG...\n");
- srand(*current_tick);
+ printf("Running graphics benchmark...\n");
+ srand(42);
+
if(gfx_status)
{
+ const int width = *gfx_width;
+ const int height = *gfx_height;
+
+ gfx_clear();
+
int startpix = *current_tick;
for(int i=0;i<1000000;++i)
{
- int rx = rand() % *gfx_width;
- int ry = rand() % *gfx_height;
+ int rx = rand() % width;
+ int ry = rand() % height;
gfx_set_foreground(rand() % 0x1000000);
gfx_drawpixel(rx, ry);
}
int endpix = *current_tick;
+ gfx_clear();
+
int startfill = *current_tick;
for(int i=0;i<1000;++i)
{
@@ -87,14 +98,13 @@ void main(struct multiboot_info_t *hdr, uint32_t magic)
}
int endfill = *current_tick;
- gfx_set_background(0);
- gfx_set_foreground(0xFFFFFF);
gfx_clear();
int starttext = *current_tick;
for(int i=0;i<1000000;++i)
{
- int rx = rand() % *gfx_width;
- int ry = rand() % *gfx_height;
+ int rx = rand() % width;
+ int ry = rand() % height;
+ gfx_set_foreground(rand() % 0x1000000);
gfx_drawchar(rx, ry, rand()%127+1);
}
int endtext = *current_tick;
@@ -103,7 +113,8 @@ void main(struct multiboot_info_t *hdr, uint32_t magic)
int starthline = *current_tick;
for(int i=0;i<1000000;++i)
{
- gfx_hline(rand() % *gfx_width, rand() % *gfx_width, rand() % *gfx_height);
+ gfx_set_foreground(rand() % 0x1000000);
+ gfx_hline(rand() % width, rand() % width, rand() % height);
}
int endhline = *current_tick;
@@ -112,7 +123,8 @@ void main(struct multiboot_info_t *hdr, uint32_t magic)
int startvline = *current_tick;
for(int i=0;i<1000000;++i)
{
- gfx_vline(rand() % *gfx_height, rand() % *gfx_height, rand() % *gfx_width);
+ gfx_set_foreground(rand() % 0x1000000);
+ gfx_vline(rand() % height, rand() % height, rand() % width);
}
int endvline = *current_tick;
@@ -121,14 +133,29 @@ void main(struct multiboot_info_t *hdr, uint32_t magic)
int startrect = *current_tick;
for(int i=0;i<10000;++i)
{
- int x = rand() % *gfx_width;
- int y = rand() % *gfx_height;
- int w = rand() % (*gfx_width - x);
- int h = rand() % (*gfx_height - y);
+ int x = rand() % width;
+ int y = rand() % height;
+ int w = rand() % (width - x);
+ int h = rand() % (height - y);
+ gfx_set_foreground(rand() % 0x1000000);
gfx_fillrect(x, y, w, h);
}
int endrect = *current_tick;
+ gfx_clear();
+
+ int startline = *current_tick;
+ for(int i=0;i<1000000;++i)
+ {
+ int x1= rand() % width;
+ int x2= rand() % width;
+ int y1= rand() % height;
+ int y2= rand() % height;
+ gfx_set_foreground(rand() % 0x1000000);
+ gfx_drawline(x1, y1, x2, y2);
+ }
+ int endline = *current_tick;
+
gfx_reset();
printf("--- Graphics benchmark results ---\n");
printf("Ticks for 1,000,000 random pixels: %d\n", endpix-startpix);
@@ -137,6 +164,7 @@ void main(struct multiboot_info_t *hdr, uint32_t magic)
printf("Ticks for 1,000,000 random hlines: %d\n", endhline-starthline);
printf("Ticks for 1,000,000 random vlines: %d\n", endvline-startvline);
printf("Ticks for 10,000 random rects: %d\n", endrect-startrect);
+ printf("Ticks for 1,000,000 random lines: %d\n", endline-startline);
printf("Ticks per second: %d\n", HZ);
printf("Resolution: %dx%dx%d\n", *gfx_width, *gfx_height, *gfx_bpp * 8);
}