memory nthat
This commit is contained in:
BIN
build/OwOS.bin
BIN
build/OwOS.bin
Binary file not shown.
BIN
build/OwOS.iso
BIN
build/OwOS.iso
Binary file not shown.
Binary file not shown.
28
kernel.asm
28
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
|
||||
|
||||
24
kernel.cpp
24
kernel.cpp
@@ -1,38 +1,28 @@
|
||||
#include <lib/std/stdlib.h>
|
||||
#include <kernel/multiboot.h>
|
||||
#include <kernel/kernio.h>
|
||||
#include <kernel/drivers/terminal/terminal.h>
|
||||
|
||||
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(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");
|
||||
|
||||
@@ -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;
|
||||
void reverse(char *s) {
|
||||
int length, c;
|
||||
char *begin, *end, temp;
|
||||
|
||||
for (i = 0; i < j; i++) {
|
||||
j--;
|
||||
c = s[i];
|
||||
s[i] = s[j];
|
||||
s[j] = c;
|
||||
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++] = '-';
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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[] = "");
|
||||
|
||||
Reference in New Issue
Block a user