aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile4
-rw-r--r--src/boot/boot.S2
-rw-r--r--src/bringelle.c18
-rw-r--r--src/infos.binbin200 -> 0 bytes
-rw-r--r--src/libc/math.c14
-rw-r--r--src/libc/math.h6
-rw-r--r--src/libc/stdio.c25
-rw-r--r--src/libc/stdio.h10
-rw-r--r--src/libc/string.c29
-rw-r--r--src/libc/string.h6
-rw-r--r--src/utils/8042.c2
-rw-r--r--src/utils/8042.h42
-rw-r--r--src/utils/framebuffer.c (renamed from src/utils/print.c)25
-rw-r--r--src/utils/framebuffer.h (renamed from src/utils/print.h)14
-rw-r--r--src/utils/gdt.c1
-rw-r--r--src/utils/mem.h1
-rw-r--r--src/utils/pic.c2
17 files changed, 132 insertions, 69 deletions
diff --git a/src/Makefile b/src/Makefile
index af32fdd..a7a8586 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -7,10 +7,12 @@ LD_SCRIPT := linker.ld
# first in the kernel binary (thus it must be linked first, cf the $(EXEC) rule)
BOOT_OBJ := $(addsuffix .o,$(basename $(shell find ./boot -name "*.[c|S]" ! -name "boot.S")))
UTILS_OBJ := $(addsuffix .o,$(basename $(shell find ./utils -name "*.[c|S]")))
+LIBC_OBJ := $(addsuffix .o,$(basename $(shell find ./libc -name "*.[c|S]")))
+
all: $(EXEC)
-$(EXEC): boot/boot.o $(BOOT_OBJ) $(UTILS_OBJ) bringelle.o
+$(EXEC): boot/boot.o $(BOOT_OBJ) $(UTILS_OBJ) $(LIBC_OBJ) bringelle.o
ld -n -T $(LD_SCRIPT) -nostdlib -o bringelle $^
%.o: %.S
diff --git a/src/boot/boot.S b/src/boot/boot.S
index 469cc82..77b04c0 100644
--- a/src/boot/boot.S
+++ b/src/boot/boot.S
@@ -44,7 +44,7 @@ MB_INFO:
.int 0xABCDEF # Will contains the Multiboot2 information data structure address
_start:
-mov %ebx, (MB_INFO)
+mov %ebx, (MB_INFO) # Store Bootloader informations address
# Copy GDT into memory then load its register
call gdt_memcpy
diff --git a/src/bringelle.c b/src/bringelle.c
index f6b099c..5431ad4 100644
--- a/src/bringelle.c
+++ b/src/bringelle.c
@@ -1,23 +1,15 @@
-#include "utils/print.h"
-#include "utils/asm.h"
+#include "libc/stdio.h"
#include "utils/pic.h"
-#include "utils/8042.h"
#include "boot/multiboot.h"
-extern char *name_addr;
-
void bringelle(){
clear();
- printc("Booting Bringelle...\n",GREEN);
- pic_enable_interrupt();
+ printc("Booting Bringelle...",GREEN);
- // Search for bootloader informations
- MBI_TAG_BL_NAME bl_infos;
- if(!mb_load_bl_name(&bl_infos)){
- print(bl_infos.name);
- print(" detected!\n");
- }
+ // Kernel boot sequence
+ pic_enable_interrupt();
+ printc(" done!\n",GREEN);
while(1);
}
diff --git a/src/infos.bin b/src/infos.bin
deleted file mode 100644
index 770850f..0000000
--- a/src/infos.bin
+++ /dev/null
Binary files differ
diff --git a/src/libc/math.c b/src/libc/math.c
new file mode 100644
index 0000000..2051dc1
--- /dev/null
+++ b/src/libc/math.c
@@ -0,0 +1,14 @@
+#include "math.h"
+
+int pow(int x,int n){
+ if(n<0)
+ return -1;
+ else if(n==0)
+ return 1;
+ else if(n==1)
+ return x;
+ int ret=x;
+ for(int i=0;i<(n-1);i++)
+ ret*=x;
+ return ret;
+} \ No newline at end of file
diff --git a/src/libc/math.h b/src/libc/math.h
new file mode 100644
index 0000000..56f1788
--- /dev/null
+++ b/src/libc/math.h
@@ -0,0 +1,6 @@
+#ifndef MATH_H
+#define MATH_H
+
+int pow(int x,int n);
+
+#endif \ No newline at end of file
diff --git a/src/libc/stdio.c b/src/libc/stdio.c
new file mode 100644
index 0000000..6e0063b
--- /dev/null
+++ b/src/libc/stdio.c
@@ -0,0 +1,25 @@
+#include "stdio.h"
+#include "string.h"
+
+extern VIDEO_STATE VS;
+
+void print(char *str){
+ int i=0;
+ while(str[i]!='\0'){
+ putchar(str[i]);
+ i++;
+ }
+}
+
+void printc(char* str,VIDEO_COLORS c){
+ VIDEO_COLORS backup=VS.fg;
+ VS.fg=c;
+ print(str);
+ VS.fg=backup;
+}
+
+void printi(int i){
+ char str[12];
+ itoa(i,str);
+ print(str);
+} \ No newline at end of file
diff --git a/src/libc/stdio.h b/src/libc/stdio.h
new file mode 100644
index 0000000..ece8df5
--- /dev/null
+++ b/src/libc/stdio.h
@@ -0,0 +1,10 @@
+#ifndef STDIO_H
+#define STDIO_H
+
+#include "utils/framebuffer.h"
+
+void print(char*);
+void printc(char*,VIDEO_COLORS c);
+void printi(int i);
+
+#endif \ No newline at end of file
diff --git a/src/libc/string.c b/src/libc/string.c
new file mode 100644
index 0000000..93a9e63
--- /dev/null
+++ b/src/libc/string.c
@@ -0,0 +1,29 @@
+#include "string.h"
+#include "math.h"
+
+void itoa(int i, char *a){
+ // Check if lower than 0
+ char neg=0;
+ if(i<0){
+ neg=1;
+ i=-i;
+ a[0]='-';
+ }
+
+ // Count number of digits
+ int len=1;
+ while(i/pow(10,len)>=1)
+ {
+ len++;
+ }
+
+ // Build string
+ int max_pow=len-1;
+ for(int j=0;j<=max_pow;j++){
+ int cur_pow=pow(10,max_pow-j);
+ char digit=i/cur_pow;
+ a[j+neg]='0'+digit;
+ i=i-digit*cur_pow; // Remove first digits (most significant)
+ }
+ a[len+neg]='\0';
+} \ No newline at end of file
diff --git a/src/libc/string.h b/src/libc/string.h
new file mode 100644
index 0000000..82106b2
--- /dev/null
+++ b/src/libc/string.h
@@ -0,0 +1,6 @@
+#ifndef STRING_H
+#define STRING_H
+
+void itoa(int i, char *a);
+
+#endif \ No newline at end of file
diff --git a/src/utils/8042.c b/src/utils/8042.c
index d8a5ba0..1d22152 100644
--- a/src/utils/8042.c
+++ b/src/utils/8042.c
@@ -1,5 +1,5 @@
#include "8042.h"
-#include "print.h"
+#include "framebuffer.h"
#include "asm.h"
DEFINE_AZERTY;
diff --git a/src/utils/8042.h b/src/utils/8042.h
index 068a0ef..8efa8ce 100644
--- a/src/utils/8042.h
+++ b/src/utils/8042.h
@@ -6,22 +6,22 @@
void _8042_keypress();
#define DEFINE_AZERTY char AZERTY[]={\
- '?',\
- '?',\
- '?',\
- '?',\
- '?',\
- '?',\
- '?',\
- '?',\
- '?',\
- '?',/* 10 */\
- '?',\
- '?',\
- '?',\
- '?',\
- '?',\
- '?',\
+ '\0',\
+ '\0',\
+ '&',\
+ '\0',\
+ '"',\
+ '\'',\
+ '(',\
+ '-',\
+ '\0',\
+ '_',/* 10 */\
+ '\0',\
+ '\0',\
+ ')',\
+ '=',\
+ '\0',\
+ '\t',\
'a',\
'z',\
'e',\
@@ -34,8 +34,8 @@ void _8042_keypress();
'p',\
'^',\
'$',\
- '?',\
- '?',\
+ '\0',\
+ '\0',\
'q',/* 0x1E (30) */\
's',\
'd',\
@@ -46,9 +46,9 @@ void _8042_keypress();
'k',\
'l',\
'm',\
- '?',\
- '?',\
- '?',\
+ '\0',\
+ '\0',\
+ '\0',\
'*',\
'w',\
'x',\
diff --git a/src/utils/print.c b/src/utils/framebuffer.c
index c2cdaf1..110dc73 100644
--- a/src/utils/print.c
+++ b/src/utils/framebuffer.c
@@ -1,16 +1,8 @@
-#include "print.h"
+#include "framebuffer.h"
#define MAX_COL 80
#define MAX_LINE 25
-struct VIDEO_STATE {
- u8 *mem;
- u8 col;
- u8 line;
- u8 bg;
- u8 fg;
-};
-
VIDEO_STATE VS={
(u8 *)0xB8000,
0,
@@ -47,21 +39,6 @@ void putchar(char c){
}
}
-void print(char *str){
- int i=0;
- while(str[i]!='\0'){
- putchar(str[i]);
- i++;
- }
-}
-
-void printc(char* str,VIDEO_COLORS c){
- VIDEO_COLORS backup=VS.fg;
- VS.fg=c;
- print(str);
- VS.fg=backup;
-}
-
void clear(){
for(char i=0;i<MAX_LINE;i++){
scrollup();
diff --git a/src/utils/print.h b/src/utils/framebuffer.h
index 163f4ec..f4e52a0 100644
--- a/src/utils/print.h
+++ b/src/utils/framebuffer.h
@@ -1,5 +1,5 @@
-#ifndef PRINT_H
-#define PRINT_H
+#ifndef FRAMEBUFFER_H
+#define FRAMEBUFFER_H
#include "types.h"
@@ -9,14 +9,18 @@ typedef enum VIDEO_COLORS {
} VIDEO_COLORS;
-typedef struct VIDEO_STATE VIDEO_STATE;
+typedef struct VIDEO_STATE {
+ u8 *mem;
+ u8 col;
+ u8 line;
+ u8 bg;
+ u8 fg;
+} VIDEO_STATE;
/**
* Print char
*/
void putchar(char);
-void print(char*);
-void printc(char*,VIDEO_COLORS c);
void scrollup();
void clear();
diff --git a/src/utils/gdt.c b/src/utils/gdt.c
index 85c4a09..e82ebe4 100644
--- a/src/utils/gdt.c
+++ b/src/utils/gdt.c
@@ -1,5 +1,4 @@
#include "gdt.h"
-#include "print.h"
#include "mem.h"
struct GDT_REGISTER GDTR = { 0, 0 };
diff --git a/src/utils/mem.h b/src/utils/mem.h
index b09c3f0..f051219 100644
--- a/src/utils/mem.h
+++ b/src/utils/mem.h
@@ -3,7 +3,6 @@
#include "types.h"
-
void memcpy(void *src, void *dst, int size);
#endif
diff --git a/src/utils/pic.c b/src/utils/pic.c
index 4806cb9..dcbd983 100644
--- a/src/utils/pic.c
+++ b/src/utils/pic.c
@@ -56,7 +56,7 @@ void pic_enable_interrupt(){
outbj(0xA1,0x01); // Default operating mode
// OCW: Masking
- outbj(0x21,0);
+ outbj(0x21,0b11111100);
asm("lidtl (IDTR)");