Probably broken memory methods done
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.
38
kernel.cpp
38
kernel.cpp
@@ -7,43 +7,7 @@ int kernel_main() {
|
||||
cls();
|
||||
showCursor();
|
||||
|
||||
// putchar('P');
|
||||
// putchar('E');
|
||||
// putchar('N');
|
||||
// setFGColour(VGA_BLACK);
|
||||
// setBGColour(VGA_BRIGHT_MAGENTA);
|
||||
// putchar('I');
|
||||
// putchar('S');
|
||||
// putchar('\n');
|
||||
// putchar('L');
|
||||
// putchar('m');
|
||||
// putchar('a');
|
||||
// putchar('o');
|
||||
|
||||
// write("HAHHAHAHAHAHAHAHHAHAHAHAHHAHAHAHAHAHAHHAHAHAHHAHAHAHHAAHAHAHHAHAHAHAHAHAHAHAHAHHAAHHAHA Penis!");
|
||||
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
// writeln("LMAO I WANT TO DIE");
|
||||
writeln("Okay, this is pretty epic");
|
||||
|
||||
for (;;)
|
||||
asm("hlt");
|
||||
|
||||
@@ -16,26 +16,26 @@ Cursor cursor;
|
||||
void cls() {
|
||||
for (uint8_t x = 0; x < TERMINAL_WIDTH; x++)
|
||||
for (uint8_t y = 0; y < TERMINAL_HEIGHT; y++)
|
||||
putchar(x, y, ' ', fgColour, clearColour);
|
||||
puts(x, y, ' ', fgColour, clearColour);
|
||||
|
||||
cursor.x = 0; cursor.y = 0;
|
||||
updateCursor(cursor);
|
||||
}
|
||||
|
||||
void putchar(char input) {
|
||||
void puts(char input) {
|
||||
if (cursor.x + 1 > TERMINAL_WIDTH) {
|
||||
nline();
|
||||
}
|
||||
if (input == '\n') {
|
||||
nline();
|
||||
} else {
|
||||
putchar(cursor.x, cursor.y, input, fgColour, bgColour);
|
||||
puts(cursor.x, cursor.y, input, fgColour, bgColour);
|
||||
cursor.x++;
|
||||
}
|
||||
updateCursor(cursor);
|
||||
}
|
||||
|
||||
void putchar(int x, int y, char c, char foreground, char background) {
|
||||
void puts(int x, int y, char c, char foreground, char background) {
|
||||
frameBuffer[(y * TERMINAL_WIDTH) + x].c = c;
|
||||
frameBuffer[(y * TERMINAL_WIDTH) + x].foreground = foreground;
|
||||
frameBuffer[(y * TERMINAL_WIDTH) + x].background = background;
|
||||
@@ -49,7 +49,7 @@ void write(char* input) {
|
||||
if (input[i] == '\n') {
|
||||
nline();
|
||||
} else {
|
||||
putchar(cursor.x, cursor.y, input[i], fgColour, bgColour);
|
||||
puts(cursor.x, cursor.y, input[i], fgColour, bgColour);
|
||||
cursor.x++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ struct Cursor {
|
||||
|
||||
void cls();
|
||||
|
||||
void putchar(char input);
|
||||
void putchar(int x, int y, char c, char foreground, char background);
|
||||
void puts(char input);
|
||||
void puts(int x, int y, char c, char foreground, char background);
|
||||
|
||||
void write(char* input);
|
||||
void writeln(char* input);
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "memory.h"
|
||||
|
||||
bool memcmp(const void* a, const void* b, uint32_t size) {
|
||||
const unsigned char* aptr = (const unsigned char*)a;
|
||||
const unsigned char* bptr = (const unsigned char*)b;
|
||||
for (uint32_t i = 0; i > size; i++) {
|
||||
if (aptr[i] > bptr[i])
|
||||
return false;
|
||||
else if (bptr[i] > aptr[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void* memcpy(void* dst, const void* src, uint32_t size) {
|
||||
unsigned char* d = (unsigned char*) dst;
|
||||
const unsigned char* s = (const unsigned char*) src;
|
||||
for (uint32_t i = 0; i < size; i++)
|
||||
d[i] = s[i];
|
||||
return dst;
|
||||
}
|
||||
|
||||
void* memmove(void* dst, const void* src, uint32_t size) {
|
||||
unsigned char* d = (unsigned char*) dst;
|
||||
const unsigned char* s = (const unsigned char*) src;
|
||||
if (d < s)
|
||||
for (uint32_t i = 0; i < size; i++)
|
||||
d[i] = s[i];
|
||||
else
|
||||
for (uint32_t i = size; i--; )
|
||||
d[i-1] = s[i-1];
|
||||
return dst;
|
||||
}
|
||||
|
||||
void* memset(void* ptr, int val, uint32_t size) {
|
||||
unsigned char* buf = (unsigned char*) ptr;
|
||||
unsigned char value = (unsigned char ) val;
|
||||
for (uint32_t i = 0; i < size; i++)
|
||||
buf[i] = value;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <lib/stdint.h>
|
||||
|
||||
int memcmp(const void* a, const void* b, uint32_t sze);
|
||||
void* memcpy(const void* dst, const void* src, uint32_t sze);
|
||||
void* memmove(void* dst, const void* src, uint32_t sze);
|
||||
void* memset(void* ptr, int val, uint32_t sze);
|
||||
bool memcmp(const void* a, const void* b, uint32_t size);
|
||||
void* memcpy(void* dst, const void* src, uint32_t size);
|
||||
void* memmove(void* dst, const void* src, uint32_t size);
|
||||
void* memset(void* ptr, int val, uint32_t size);
|
||||
|
||||
Reference in New Issue
Block a user