diff --git a/build/OwOS.bin b/build/OwOS.bin index 5046529..1ee74e1 100755 Binary files a/build/OwOS.bin and b/build/OwOS.bin differ diff --git a/build/OwOS.iso b/build/OwOS.iso index 3a30cea..604d1a6 100644 Binary files a/build/OwOS.iso and b/build/OwOS.iso differ diff --git a/iso/boot/OwOS.bin b/iso/boot/OwOS.bin index 5046529..1ee74e1 100644 Binary files a/iso/boot/OwOS.bin and b/iso/boot/OwOS.bin differ diff --git a/kernel.asm b/kernel.asm index 18270d6..d7db94a 100644 --- a/kernel.asm +++ b/kernel.asm @@ -30,6 +30,16 @@ _start: push %ebx push %eax + call kernel_main + + cli +1: hlt + jmp 1b + + +.global ASM_INIT_FPU + +ASM_INIT_FPU: # FPU Config VAL_037F: .hword 0x037F @@ -39,23 +49,13 @@ _start: .hword 0x037A # Configure FPU cli - mov %cr0, %eax - or $0b00110010, %eax - and $0xFFFFFFFB, %eax - mov %eax, %cr0 + mov %cr0, %ecx + or $0b00110010, %ecx + and $0xFFFFFFFB, %ecx + mov %ecx, %cr0 fldcw VAL_037F fldcw VAL_037E fldcw VAL_037A fninit - call kernel_main - - cli -1: hlt - jmp 1b - -_hang: - hlt - jmp _hang - .size _start, . - _start diff --git a/kernel.cpp b/kernel.cpp index 0464331..4dad3a6 100644 --- a/kernel.cpp +++ b/kernel.cpp @@ -1,38 +1,28 @@ #include #include +#include #include extern "C" - int kernel_main(uint32_t magic, multibootInfo_t* multiboot) { - cls(); showCursor(); - - write("OwOS "); setFGColour(VGA_GREEN); - write("Starting Up..."); + write("OwOS V0.2 "); + writeln("Starting Up..."); setFGColour(VGA_WHITE); - nline(); + write("OwO, What's This? "); write("*notices "); - - char* ram = ""; - itoa((int)multiboot->mem_upper, ram); - - write(ram); - write("mb of ram*"); + write(itoa(multiboot->mem_upper / 1024)); + write("mb of ram*"); setFGColour(VGA_BRIGHT_MAGENTA); - write(" OwO That's a lot of memory"); - setFGColour(VGA_WHITE); - nline(); - nline(); - nline(); + nline(); nline(); nline(); - writeln("Okay, this is pretty epic"); + write("~#"); for (;;) asm("hlt"); diff --git a/lib/std/stdlib.cpp b/lib/std/stdlib.cpp index d26ed6e..ecc11fb 100644 --- a/lib/std/stdlib.cpp +++ b/lib/std/stdlib.cpp @@ -8,30 +8,53 @@ void swap(int* x, int* y) { y = t; } -void reverse(char s[]) { - int i; - int j = strlen(s) - 1; - char c; - - for (i = 0; i < j; i++) { - j--; - c = s[i]; - s[i] = s[j]; - s[j] = c; - } +void reverse(char *s) { + int length, c; + char *begin, *end, temp; + + length = strlen(s); + begin = s; + end = s; + + for (c = 0; c < length - 1; c++) + end++; + + for (c = 0; c < length/2; c++) { + temp = *end; + *end = *begin; + *begin = temp; + + begin++; + end--; + } } -void itoa(int i, char[] s) { - int i, sign; - if ((sign = n) < 0) /* record sign */ - n = -n; /* make n positive */ - i = 0; - do { /* generate digits in reverse order */ - s[i++] = n % 10 + '0'; /* get next digit */ - } while ((n /= 10) > 0); /* delete it */ - if (sign < 0) - s[i++] = '-'; - s[i] = '\0'; +char* itoa(int n, char s[]) { + int i = 0; + bool isNegative = false; + + if (n == 0) { + s[i++] = '0'; + s[i] = '\0'; + return s; + } + + if (n < 0) { + isNegative = true; + n = -n; + } + + while (n != 0) { + s[i++] = n % 10 + '0'; + n /= 10; + } + + if (isNegative) + s[i++] = '-'; + + s[i] = '\0'; + reverse(s); + return s; } diff --git a/lib/std/stdlib.h b/lib/std/stdlib.h index 7354121..1a820d1 100644 --- a/lib/std/stdlib.h +++ b/lib/std/stdlib.h @@ -1,5 +1,5 @@ #pragma once void swap(int* a, int* b); -void reverse(char s[]) -void itoa(int i, char[] s); +void reverse(char* s); +char* itoa(int i, char s[] = "");