summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-05-01 09:48:30 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-05-01 09:48:30 +0200
commit9d6ac8440a3588bd1a4f763f5aeb741bb6f7bb47 (patch)
treed375840a707e1e462cf370afdea86c43802d378b
parentb66488781fe10292962a6c85881c329dcbafd0ba (diff)
downloadabaos-9d6ac8440a3588bd1a4f763f5aeb741bb6f7bb47.tar.gz
abaos-9d6ac8440a3588bd1a4f763f5aeb741bb6f7bb47.tar.bz2
started vga module, puzzled about eliminated dead loops in clang?
-rw-r--r--src/Makefile2
-rw-r--r--src/kernel.c8
-rw-r--r--src/vga.c1
-rw-r--r--src/vga.h18
4 files changed, 24 insertions, 5 deletions
diff --git a/src/Makefile b/src/Makefile
index 041a029..94fb3f1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,5 +1,5 @@
CC := gcc
-CFLAGS := -std=c99 -m32 -ffreestanding
+CFLAGS := -std=c99 -m32 -ffreestanding -Os -g -Wall -Werror
LD := ld
all: image.bin
diff --git a/src/kernel.c b/src/kernel.c
index 100fc6d..ecd9aca 100644
--- a/src/kernel.c
+++ b/src/kernel.c
@@ -12,9 +12,9 @@ void entry( )
*(VIDEO_MEMORY+10) = '_';
uint8_t bar[4] = "\\|/-";
- char backup = *VIDEO_MEMORY;
int pos = 10;
- for( int i = 0; i < 200000; i++ ) {
+ volatile int i = 0;
+ for( i = 0; i < 20000; i++ ) {
if( i % 1000 == 0 ) {
*(VIDEO_MEMORY+pos) = '.';
*(VIDEO_MEMORY+pos+1) = 0x07;
@@ -22,7 +22,7 @@ void entry( )
}
*(VIDEO_MEMORY+pos) = bar[i%4];
*(VIDEO_MEMORY+pos+1) = 0x07;
- for( int j = 0; j < 10000; j++ );
+ for( int j = 0; j < 10000; j++ ) {
+ }
}
- *VIDEO_MEMORY = backup;
}
diff --git a/src/vga.c b/src/vga.c
new file mode 100644
index 0000000..26208a0
--- /dev/null
+++ b/src/vga.c
@@ -0,0 +1 @@
+#include "vga.h"
diff --git a/src/vga.h b/src/vga.h
new file mode 100644
index 0000000..49fe8f2
--- /dev/null
+++ b/src/vga.h
@@ -0,0 +1,18 @@
+#ifndef VGA_H
+#define VGA_H
+
+#include <inttypes.h>
+
+enum {
+ VGA_DEFAULT_RES_X = 80,
+ VGA_DEFAULT_RES_Y = 25
+};
+
+typedef struct vga_t {
+ int res_x; // resolution, default 80
+ int res_y; // resolution, default 25
+ int cursor_x; // current cursor position X
+ int cursor_y; // current cursor position Y
+} vga_t;
+
+#endif /* VGA_H */