memory nthat

This commit is contained in:
Ben
2019-04-26 18:39:44 +01:00
parent da858dfe76
commit ca72196bf4
7 changed files with 69 additions and 56 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -30,6 +30,16 @@ _start:
push %ebx push %ebx
push %eax push %eax
call kernel_main
cli
1: hlt
jmp 1b
.global ASM_INIT_FPU
ASM_INIT_FPU:
# FPU Config # FPU Config
VAL_037F: VAL_037F:
.hword 0x037F .hword 0x037F
@@ -39,23 +49,13 @@ _start:
.hword 0x037A .hword 0x037A
# Configure FPU # Configure FPU
cli cli
mov %cr0, %eax mov %cr0, %ecx
or $0b00110010, %eax or $0b00110010, %ecx
and $0xFFFFFFFB, %eax and $0xFFFFFFFB, %ecx
mov %eax, %cr0 mov %ecx, %cr0
fldcw VAL_037F fldcw VAL_037F
fldcw VAL_037E fldcw VAL_037E
fldcw VAL_037A fldcw VAL_037A
fninit fninit
call kernel_main
cli
1: hlt
jmp 1b
_hang:
hlt
jmp _hang
.size _start, . - _start .size _start, . - _start

View File

@@ -1,38 +1,28 @@
#include <lib/std/stdlib.h> #include <lib/std/stdlib.h>
#include <kernel/multiboot.h> #include <kernel/multiboot.h>
#include <kernel/kernio.h>
#include <kernel/drivers/terminal/terminal.h> #include <kernel/drivers/terminal/terminal.h>
extern "C" extern "C"
int kernel_main(uint32_t magic, multibootInfo_t* multiboot) { int kernel_main(uint32_t magic, multibootInfo_t* multiboot) {
cls(); cls();
showCursor(); showCursor();
write("OwOS ");
setFGColour(VGA_GREEN); setFGColour(VGA_GREEN);
write("Starting Up..."); write("OwOS V0.2 ");
writeln("Starting Up...");
setFGColour(VGA_WHITE); setFGColour(VGA_WHITE);
nline(); nline();
write("OwO, What's This? "); write("OwO, What's This? ");
write("*notices "); write("*notices ");
write(itoa(multiboot->mem_upper / 1024));
char* ram = ""; write("mb of ram*");
itoa((int)multiboot->mem_upper, ram);
write(ram);
write("mb of ram*");
setFGColour(VGA_BRIGHT_MAGENTA); setFGColour(VGA_BRIGHT_MAGENTA);
write(" OwO That's a lot of memory"); nline(); nline(); nline();
setFGColour(VGA_WHITE);
nline();
nline();
nline();
writeln("Okay, this is pretty epic"); write("~#");
for (;;) for (;;)
asm("hlt"); asm("hlt");

View File

@@ -8,30 +8,53 @@ void swap(int* x, int* y) {
y = t; y = t;
} }
void reverse(char s[]) { void reverse(char *s) {
int i; int length, c;
int j = strlen(s) - 1; char *begin, *end, temp;
char c;
length = strlen(s);
for (i = 0; i < j; i++) { begin = s;
j--; end = s;
c = s[i];
s[i] = s[j]; for (c = 0; c < length - 1; c++)
s[j] = 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 */ char* itoa(int n, char s[]) {
n = -n; /* make n positive */ int i = 0;
i = 0; bool isNegative = false;
do { /* generate digits in reverse order */
s[i++] = n % 10 + '0'; /* get next digit */ if (n == 0) {
} while ((n /= 10) > 0); /* delete it */ s[i++] = '0';
if (sign < 0) s[i] = '\0';
s[i++] = '-'; return s;
s[i] = '\0'; }
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); reverse(s);
return s;
} }

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
void swap(int* a, int* b); void swap(int* a, int* b);
void reverse(char s[]) void reverse(char* s);
void itoa(int i, char[] s); char* itoa(int i, char s[] = "");