summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-08-21 23:59:19 +0200
committerAlexis211 <alexis211@gmail.com>2009-08-21 23:59:19 +0200
commit74e721676ddd5d996ccf2e1d35da57320f658609 (patch)
treeb39d766c8e27a654c89c2435131e5eaf193125d8 /Source
parentae803baa4e0ec584c7afd3f6d55f2e6b32010b46 (diff)
downloadMelon-74e721676ddd5d996ccf2e1d35da57320f658609.tar.gz
Melon-74e721676ddd5d996ccf2e1d35da57320f658609.zip
Kernel now loads in higher half, and uses a VT for output.
Diffstat (limited to 'Source')
-rw-r--r--Source/Kernel/Core/.kmain.wtf.cpp.swpbin12288 -> 12288 bytes
-rw-r--r--Source/Kernel/Core/CMem.ns.obin991 -> 0 bytes
-rw-r--r--Source/Kernel/Core/Sys.ns.cpp15
-rw-r--r--Source/Kernel/Core/Sys.ns.obin1676 -> 0 bytes
-rw-r--r--Source/Kernel/Core/common.wtf.h13
-rw-r--r--Source/Kernel/Core/cppsupport.wtf.obin741 -> 0 bytes
-rw-r--r--Source/Kernel/Core/kmain.wtf.cpp14
-rw-r--r--Source/Kernel/Core/kmain.wtf.obin2948 -> 0 bytes
-rw-r--r--Source/Kernel/Core/loader.wtf.asm28
-rw-r--r--Source/Kernel/Core/loader.wtf.obin1312 -> 0 bytes
-rw-r--r--Source/Kernel/Devices/Display/Display.proto.h2
-rw-r--r--Source/Kernel/Devices/Display/VGATextOutput.class.cpp8
-rw-r--r--Source/Kernel/Devices/Display/VGATextOutput.class.h2
-rw-r--r--Source/Kernel/Devices/Display/VGATextOutput.class.obin1592 -> 0 bytes
-rw-r--r--Source/Kernel/DisplayManager/Disp.ns.cpp2
-rw-r--r--Source/Kernel/DisplayManager/Disp.ns.h2
-rw-r--r--Source/Kernel/DisplayManager/Disp.ns.obin1412 -> 0 bytes
-rw-r--r--Source/Kernel/Link.ld14
-rw-r--r--Source/Kernel/Makefile2
-rw-r--r--Source/Kernel/Map.txt257
-rwxr-xr-xSource/Kernel/Melon.kebin15445 -> 21251 bytes
-rw-r--r--Source/Kernel/MemoryManager/Mem.ns.cpp23
-rw-r--r--Source/Kernel/MemoryManager/Mem.ns.h16
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal.class.cpp158
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal.class.h51
25 files changed, 501 insertions, 106 deletions
diff --git a/Source/Kernel/Core/.kmain.wtf.cpp.swp b/Source/Kernel/Core/.kmain.wtf.cpp.swp
index bc7a8c6..bf1668b 100644
--- a/Source/Kernel/Core/.kmain.wtf.cpp.swp
+++ b/Source/Kernel/Core/.kmain.wtf.cpp.swp
Binary files differ
diff --git a/Source/Kernel/Core/CMem.ns.o b/Source/Kernel/Core/CMem.ns.o
deleted file mode 100644
index b8b6dbb..0000000
--- a/Source/Kernel/Core/CMem.ns.o
+++ /dev/null
Binary files differ
diff --git a/Source/Kernel/Core/Sys.ns.cpp b/Source/Kernel/Core/Sys.ns.cpp
index eca826f..361dda6 100644
--- a/Source/Kernel/Core/Sys.ns.cpp
+++ b/Source/Kernel/Core/Sys.ns.cpp
@@ -1,5 +1,8 @@
//This automatically includes Sys.ns.h
#include <Core/common.wtf.h>
+#include <VTManager/VirtualTerminal.class.h>
+
+#define DEBUGVT(x) VirtualTerminal *x = new VirtualTerminal(5, 46, 0, 15); x->map(); x->put('\n');
using namespace CMem;
@@ -43,20 +46,24 @@ void bochs_output(char *message, char *file, u32int line) {
void panic(char *message, char *file, u32int line) {
asm volatile("cli");
- bochs_output("PANIC : ", file, 0);
+ DEBUGVT(vt);
+ bochs_output("PANIC : ", file, line);
bochs_output(message, file, 0);
+ *vt << " PANIC : " << message << "\n In " << file << ":" << (s32int)line << "\n";
- while (1); //Enter infinite loop for halt
+ while (1) asm volatile("hlt"); //Enter infinite loop for halt
}
//Used by ASSERT() macro (see common.wtf.h)
void panic_assert(char *file, u32int line, char *desc) {
asm volatile("cli");
- bochs_output("ASSERTION FAILED : ", file, 0);
+ DEBUGVT(vt);
+ bochs_output("ASSERTION FAILED : ", file, line);
bochs_output(desc, file, 0);
+ *vt << " ASSERTION FAILED : " << desc << "\n In " << file << ":" << (s32int)line << "\n";
- while (1); //Enter infinite loop for halt
+ while (1) asm volatile("hlt"); //Enter infinite loop for halt
}
void reboot() {
diff --git a/Source/Kernel/Core/Sys.ns.o b/Source/Kernel/Core/Sys.ns.o
deleted file mode 100644
index 58f3dc8..0000000
--- a/Source/Kernel/Core/Sys.ns.o
+++ /dev/null
Binary files differ
diff --git a/Source/Kernel/Core/common.wtf.h b/Source/Kernel/Core/common.wtf.h
index 9b1bc7e..617a73c 100644
--- a/Source/Kernel/Core/common.wtf.h
+++ b/Source/Kernel/Core/common.wtf.h
@@ -24,4 +24,17 @@ typedef char s8int;
#define DEBUG(m)
#endif
+#include <MemoryManager/Mem.ns.h>
+
+//Standard implemenations of operator new/delete
+inline void* operator new(u32int, void *p) { return p; }
+inline void* operator new[](u32int, void *p) { return p; }
+inline void operator delete(void*, void*) { }
+inline void operator delete[](void*, void*) { }
+
+inline void* operator new(u32int sz) { return Mem::kalloc(sz); }
+inline void* operator new[](u32int sz) { return Mem::kalloc(sz); }
+inline void operator delete(void *ptr) { Mem::kfree(ptr); }
+inline void operator delete[](void *ptr) { Mem::kfree(ptr); }
+
#endif
diff --git a/Source/Kernel/Core/cppsupport.wtf.o b/Source/Kernel/Core/cppsupport.wtf.o
deleted file mode 100644
index 4088bfb..0000000
--- a/Source/Kernel/Core/cppsupport.wtf.o
+++ /dev/null
Binary files differ
diff --git a/Source/Kernel/Core/kmain.wtf.cpp b/Source/Kernel/Core/kmain.wtf.cpp
index 59fa45a..e201a07 100644
--- a/Source/Kernel/Core/kmain.wtf.cpp
+++ b/Source/Kernel/Core/kmain.wtf.cpp
@@ -3,6 +3,7 @@
#include <Devices/Display/VGATextOutput.class.h>
#include <DisplayManager/Disp.ns.h>
+#include <VTManager/VirtualTerminal.class.h>
#include <Ressources/logo.cd>
@@ -13,9 +14,11 @@ extern "C" void kmain(multiboot_info_t* mbd, u32int magic);
void kmain(multiboot_info_t* mbd, u32int magic) {
DEBUG("Entering kmain.");
- VGATextOutput vgaout;
+ Mem::placementAddress = (u32int)&end;
- Disp::setDisplay(&vgaout);
+ VGATextOutput *vgaout = new VGATextOutput();
+
+ Disp::setDisplay(vgaout);
for (int i = 0; i < melonLogoLines; i++) {
int startCol = (Disp::textCols() / 2) - (melonLogoCols / 2);
@@ -24,6 +27,13 @@ void kmain(multiboot_info_t* mbd, u32int magic) {
}
}
+ VirtualTerminal *kvt = new VirtualTerminal(12, 40, 0, 2);
+ kvt->map(melonLogoLines + 4);
+
+ *kvt << "Kernel initializing in HIGHER HALF!\n";
+
+ *kvt << "Lower ram : " << (s32int)mbd->mem_lower << "k, upper : " << (s32int)mbd->mem_upper << "k.\n";
+
if (magic != MULTIBOOT_BOOTLOADER_MAGIC) {
PANIC("Error with multiboot header.");
}
diff --git a/Source/Kernel/Core/kmain.wtf.o b/Source/Kernel/Core/kmain.wtf.o
deleted file mode 100644
index 19a82cf..0000000
--- a/Source/Kernel/Core/kmain.wtf.o
+++ /dev/null
Binary files differ
diff --git a/Source/Kernel/Core/loader.wtf.asm b/Source/Kernel/Core/loader.wtf.asm
index e5f5839..c5248e9 100644
--- a/Source/Kernel/Core/loader.wtf.asm
+++ b/Source/Kernel/Core/loader.wtf.asm
@@ -21,8 +21,21 @@ STACKSIZE equ 0x4000 ; that's 16k.
extern start_ctors, end_ctors, start_dtors, end_dtors
loader:
+ lgdt [trickgdt]
+ mov cx, 0x10;
+ mov ds, cx;
+ mov es, cx;
+ mov fs, cx;
+ mov gs, cx;
+ mov ss, cx;
+
+ jmp 0x08:higherhalf
+
+
+higherhalf:
mov esp, stack+STACKSIZE ; set up the stack
push eax ; pass Multiboot magic number
+ add ebx, 0xC0000000 ; update the MB info structure so that it is in the new seg.
push ebx ; pass Multiboot info structure
static_ctors_loop:
@@ -52,8 +65,21 @@ static_dtors_loop: ; useless, kernel should never return
hang:
hlt ; halt machine should kernel return
jmp hang
+
+[section .setup]
+
+trickgdt:
+ dw gdt_end - gdt - 1
+ dd gdt
+
+gdt:
+ dd 0, 0
+ db 0xFF, 0xFF, 0, 0, 0, 10011010b, 11001111b, 0x40
+ db 0xFF, 0xFF, 0, 0, 0, 10010010b, 11001111b, 0x40
+
+gdt_end:
-section .bss
+[section .bss]
align 32
stack:
resb STACKSIZE ; reserve 16k stack on a quadword boundary
diff --git a/Source/Kernel/Core/loader.wtf.o b/Source/Kernel/Core/loader.wtf.o
deleted file mode 100644
index caed8f0..0000000
--- a/Source/Kernel/Core/loader.wtf.o
+++ /dev/null
Binary files differ
diff --git a/Source/Kernel/Devices/Display/Display.proto.h b/Source/Kernel/Devices/Display/Display.proto.h
index 8e8e29d..d91023a 100644
--- a/Source/Kernel/Devices/Display/Display.proto.h
+++ b/Source/Kernel/Devices/Display/Display.proto.h
@@ -7,7 +7,7 @@ class Display {
public:
virtual u16int textCols() = 0;
virtual u16int textRows() = 0;
- virtual void putChar(u16int line, u16int col, char c, char color) = 0; //Color : <bg 4byte><fg 4byte>
+ virtual void putChar(u16int line, u16int col, char c, u8int color) = 0; //Color : <bg 4byte><fg 4byte>
virtual void moveCursor(u16int line, u16int col) = 0;
virtual void clear() = 0;
};
diff --git a/Source/Kernel/Devices/Display/VGATextOutput.class.cpp b/Source/Kernel/Devices/Display/VGATextOutput.class.cpp
index 66bffd5..28c943a 100644
--- a/Source/Kernel/Devices/Display/VGATextOutput.class.cpp
+++ b/Source/Kernel/Devices/Display/VGATextOutput.class.cpp
@@ -1,5 +1,7 @@
#include "VGATextOutput.class.h"
+#define RAM_ADDR 0xC00B8000
+
using namespace Sys; //For outb
u16int VGATextOutput::textCols() {
@@ -10,8 +12,8 @@ u16int VGATextOutput::textRows() {
return 25;
}
-void VGATextOutput::putChar(u16int line, u16int col, char c, char color) {
- u16int* where = (u16int*)0xB8000;
+void VGATextOutput::putChar(u16int line, u16int col, char c, u8int color) {
+ u16int* where = (u16int*)RAM_ADDR;
where[(80 * line) + col] = (color << 8) | c;
}
@@ -24,6 +26,6 @@ void VGATextOutput::moveCursor(u16int line, u16int col) {
}
void VGATextOutput::clear() {
- u16int* where = (u16int*)0xB8000;
+ u16int* where = (u16int*)RAM_ADDR;
for (int i = 0; i < 25 * 80; i++) where[i] = 0;
}
diff --git a/Source/Kernel/Devices/Display/VGATextOutput.class.h b/Source/Kernel/Devices/Display/VGATextOutput.class.h
index 72ad604..a7968c7 100644
--- a/Source/Kernel/Devices/Display/VGATextOutput.class.h
+++ b/Source/Kernel/Devices/Display/VGATextOutput.class.h
@@ -7,7 +7,7 @@ class VGATextOutput : public Display {
public:
u16int textCols();
u16int textRows();
- void putChar(u16int line, u16int col, char c, char color);
+ void putChar(u16int line, u16int col, char c, u8int color);
void moveCursor(u16int line, u16int col);
void clear();
};
diff --git a/Source/Kernel/Devices/Display/VGATextOutput.class.o b/Source/Kernel/Devices/Display/VGATextOutput.class.o
deleted file mode 100644
index ccd63a1..0000000
--- a/Source/Kernel/Devices/Display/VGATextOutput.class.o
+++ /dev/null
Binary files differ
diff --git a/Source/Kernel/DisplayManager/Disp.ns.cpp b/Source/Kernel/DisplayManager/Disp.ns.cpp
index 75344f8..8db9503 100644
--- a/Source/Kernel/DisplayManager/Disp.ns.cpp
+++ b/Source/Kernel/DisplayManager/Disp.ns.cpp
@@ -12,7 +12,7 @@ u16int textRows() {
return mode.textRows;
}
-void putChar(u16int line, u16int col, char c, char color) {
+void putChar(u16int line, u16int col, char c, u8int color) {
if (line >= mode.textRows or col >= mode.textCols) return;
mode.device->putChar(line, col, c, color);
}
diff --git a/Source/Kernel/DisplayManager/Disp.ns.h b/Source/Kernel/DisplayManager/Disp.ns.h
index 76c9f60..a815836 100644
--- a/Source/Kernel/DisplayManager/Disp.ns.h
+++ b/Source/Kernel/DisplayManager/Disp.ns.h
@@ -11,7 +11,7 @@ namespace Disp {
u16int textCols();
u16int textRows();
- void putChar(u16int line, u16int col, char c, char color);
+ void putChar(u16int line, u16int col, char c, u8int color);
void moveCursor(u16int line, u16int col);
void clear();
diff --git a/Source/Kernel/DisplayManager/Disp.ns.o b/Source/Kernel/DisplayManager/Disp.ns.o
deleted file mode 100644
index 1ac31fd..0000000
--- a/Source/Kernel/DisplayManager/Disp.ns.o
+++ /dev/null
Binary files differ
diff --git a/Source/Kernel/Link.ld b/Source/Kernel/Link.ld
index bcd0b90..dd6add0 100644
--- a/Source/Kernel/Link.ld
+++ b/Source/Kernel/Link.ld
@@ -3,15 +3,21 @@ ENTRY (loader)
SECTIONS{
. = 0x00100000;
- .text :{
+ .setup : {
+ *(.setup)
+ }
+
+ . += 0xC0000000;
+
+ .text : AT(ADDR(.text) - 0xC0000000) {
*(.text)
}
- .rodata ALIGN (0x1000) : {
+ .rodata ALIGN (0x1000) : AT(ADDR(.rodata) - 0xC0000000) {
*(.rodata)
}
- .data ALIGN (0x1000) : {
+ .data ALIGN (0x1000) : AT(ADDR(.data) - 0xC0000000) {
start_ctors = .;
*(.ctor*)
end_ctors = .;
@@ -21,7 +27,7 @@ SECTIONS{
*(.data)
}
- .bss : {
+ .bss : AT(ADDR(.bss) - 0xC0000000) {
sbss = .;
*(COMMON)
*(.bss)
diff --git a/Source/Kernel/Makefile b/Source/Kernel/Makefile
index 3cc45cc..e42e881 100644
--- a/Source/Kernel/Makefile
+++ b/Source/Kernel/Makefile
@@ -15,7 +15,9 @@ Objects = Core/kmain.wtf.o \
Core/cppsupport.wtf.o \
Core/Sys.ns.o \
Core/CMem.ns.o \
+ MemoryManager/Mem.ns.o \
DisplayManager/Disp.ns.o \
+ VTManager/VirtualTerminal.class.o \
Devices/Display/VGATextOutput.class.o
all: $(OutFile)
diff --git a/Source/Kernel/Map.txt b/Source/Kernel/Map.txt
index 9049ad0..fec07b3 100644
--- a/Source/Kernel/Map.txt
+++ b/Source/Kernel/Map.txt
@@ -4,6 +4,18 @@ Discarded input sections
.group 0x00000000 0x0 Core/kmain.wtf.o
.group 0x00000000 0x0 Core/kmain.wtf.o
.group 0x00000000 0x0 Core/kmain.wtf.o
+ .group 0x00000000 0x0 Core/kmain.wtf.o
+ .group 0x00000000 0x0 Core/kmain.wtf.o
+ .group 0x00000000 0x0 Core/kmain.wtf.o
+ .group 0x00000000 0x0 Core/Sys.ns.o
+ .group 0x00000000 0x0 Core/Sys.ns.o
+ .group 0x00000000 0x0 Core/Sys.ns.o
+ .text._Znwj 0x00000000 0x0 Core/Sys.ns.o
+ .text._ZN15VirtualTerminallsEPc
+ 0x00000000 0x0 Core/Sys.ns.o
+ .text._ZN15VirtualTerminallsEi
+ 0x00000000 0x0 Core/Sys.ns.o
+ .group 0x00000000 0x0 VTManager/VirtualTerminal.class.o
.group 0x00000000 0x0 Devices/Display/VGATextOutput.class.o
Memory Configuration
@@ -15,78 +27,132 @@ Linker script and memory map
0x00100000 . = 0x100000
-.text 0x00100000 0x6cf
+.setup 0x00100000 0x1e
+ *(.setup)
+ .setup 0x00100000 0x1e Core/loader.wtf.o
+ 0xc010001e . = (. + 0xc0000000)
+
+.text 0xc0100020 0x1277 load address 0x00100020
*(.text)
- .text 0x00100000 0x106 Core/kmain.wtf.o
- 0x00100000 kmain
- *fill* 0x00100106 0xa 00
- .text 0x00100110 0x53 Core/loader.wtf.o
- 0x0010011c loader
- *fill* 0x00100163 0x1 00
- .text 0x00100164 0xf Core/cppsupport.wtf.o
- 0x00100164 __cxa_pure_virtual
- 0x00100169 __cxa_atexit
- *fill* 0x00100173 0x1 00
- .text 0x00100174 0x1ec Core/Sys.ns.o
- 0x001001ce Sys::bochs_output(char*, char*, unsigned int)
- 0x00100192 Sys::inb(unsigned short)
- 0x001001af Sys::inw(unsigned short)
- 0x001002c8 Sys::panic(char*, char*, unsigned int)
- 0x00100344 Sys::reboot()
- 0x00100174 Sys::outb(unsigned short, unsigned char)
- 0x00100306 Sys::panic_assert(char*, unsigned int, char*)
- .text 0x00100360 0xd5 Core/CMem.ns.o
- 0x00100396 CMem::memset(unsigned char*, unsigned char, int)
- 0x001003cd CMem::memsetw(unsigned short*, unsigned short, int)
- 0x00100408 CMem::strlen(char const*)
- 0x00100360 CMem::memcpy(unsigned char*, unsigned char const*, int)
- *fill* 0x00100435 0x3 00
- .text 0x00100438 0x167 DisplayManager/Disp.ns.o
- 0x0010044c Disp::putChar(unsigned short, unsigned short, char, char)
- 0x00100442 Disp::textRows()
- 0x0010052e Disp::clear()
- 0x00100438 Disp::textCols()
- 0x0010054c Disp::setDisplay(Display*)
- 0x001004cd Disp::moveCursor(unsigned short, unsigned short)
- *fill* 0x0010059f 0x1 00
- .text 0x001005a0 0x12f Devices/Display/VGATextOutput.class.o
- 0x001005a0 VGATextOutput::textCols()
- 0x00100698 VGATextOutput::clear()
- 0x00100612 VGATextOutput::moveCursor(unsigned short, unsigned short)
- 0x001005aa VGATextOutput::textRows()
- 0x001005b4 VGATextOutput::putChar(unsigned short, unsigned short, char, char)
+ .text 0xc0100020 0x1f0 Core/kmain.wtf.o
+ 0xc0100020 kmain
+ .text 0xc0100210 0x75 Core/loader.wtf.o
+ 0xc010021c loader
+ *fill* 0xc0100285 0x3 00
+ .text 0xc0100288 0xf Core/cppsupport.wtf.o
+ 0xc0100288 __cxa_pure_virtual
+ 0xc010028d __cxa_atexit
+ *fill* 0xc0100297 0x1 00
+ .text 0xc0100298 0x3b0 Core/Sys.ns.o
+ 0xc01002f2 Sys::bochs_output(char*, char*, unsigned int)
+ 0xc01002b6 Sys::inb(unsigned short)
+ 0xc01002d3 Sys::inw(unsigned short)
+ 0xc01003ec Sys::panic(char*, char*, unsigned int)
+ 0xc010062c Sys::reboot()
+ 0xc0100298 Sys::outb(unsigned short, unsigned char)
+ 0xc010050c Sys::panic_assert(char*, unsigned int, char*)
+ .text 0xc0100648 0xd5 Core/CMem.ns.o
+ 0xc010067e CMem::memset(unsigned char*, unsigned char, int)
+ 0xc01006b5 CMem::memsetw(unsigned short*, unsigned short, int)
+ 0xc01006f0 CMem::strlen(char const*)
+ 0xc0100648 CMem::memcpy(unsigned char*, unsigned char const*, int)
+ *fill* 0xc010071d 0x3 00
+ .text 0xc0100720 0x8e MemoryManager/Mem.ns.o
+ 0xc0100778 Mem::kalloc(unsigned int, bool)
+ 0xc0100720 Mem::kallocInternal(unsigned int, bool)
+ *fill* 0xc01007ae 0x2 00
+ .text 0xc01007b0 0x167 DisplayManager/Disp.ns.o
+ 0xc01007ba Disp::textRows()
+ 0xc01008a6 Disp::clear()
+ 0xc01007b0 Disp::textCols()
+ 0xc01008c4 Disp::setDisplay(Display*)
+ 0xc0100845 Disp::moveCursor(unsigned short, unsigned short)
+ 0xc01007c4 Disp::putChar(unsigned short, unsigned short, char, unsigned char)
+ *fill* 0xc0100917 0x1 00
+ .text 0xc0100918 0x84d VTManager/VirtualTerminal.class.o
+ 0xc0100b7e VirtualTerminal::map(int, int)
+ 0xc0100bec VirtualTerminal::unmap()
+ 0xc0100e26 VirtualTerminal::put(char, bool)
+ 0xc0100dee VirtualTerminal::setCursorLine(unsigned int)
+ 0xc0100a18 VirtualTerminal::setColor(unsigned char, unsigned char)
+ 0xc0100e0a VirtualTerminal::setCursorCol(unsigned int)
+ 0xc0100998 VirtualTerminal::VirtualTerminal(unsigned int, unsigned int, unsigned char, unsigned char)
+ 0xc0100d8c VirtualTerminal::updateCursor()
+ 0xc0100f74 VirtualTerminal::write(char*, bool)
+ 0xc0100fc8 VirtualTerminal::writeDec(int, bool)
+ 0xc0100bf8 VirtualTerminal::redraw()
+ 0xc0100a66 VirtualTerminal::putChar(unsigned int, unsigned int, char)
+ 0xc01010ca VirtualTerminal::writeHex(unsigned int, bool)
+ 0xc0100cd2 VirtualTerminal::scroll()
+ 0xc0100918 VirtualTerminal::VirtualTerminal(unsigned int, unsigned int, unsigned char, unsigned char)
+ 0xc0100b14 VirtualTerminal::clear()
+ 0xc0100dc8 VirtualTerminal::moveCursor(unsigned int, unsigned int)
+ *fill* 0xc0101165 0x3 00
+ .text 0xc0101168 0x12f Devices/Display/VGATextOutput.class.o
+ 0xc0101168 VGATextOutput::textCols()
+ 0xc0101260 VGATextOutput::clear()
+ 0xc01011da VGATextOutput::moveCursor(unsigned short, unsigned short)
+ 0xc010117c VGATextOutput::putChar(unsigned short, unsigned short, char, unsigned char)
+ 0xc0101172 VGATextOutput::textRows()
+
+.text._Znwj 0xc0101297 0x1b load address 0x00101297
+ .text._Znwj 0xc0101297 0x1b Core/kmain.wtf.o
+ 0xc0101297 operator new(unsigned int)
+
+.text._ZN15VirtualTerminallsEPc
+ 0xc01012b2 0x25 load address 0x001012b2
+ .text._ZN15VirtualTerminallsEPc
+ 0xc01012b2 0x25 Core/kmain.wtf.o
+ 0xc01012b2 VirtualTerminal::operator<<(char*)
+
+.text._ZN15VirtualTerminallsEi
+ 0xc01012d8 0x25 load address 0x001012d8
+ .text._ZN15VirtualTerminallsEi
+ 0xc01012d8 0x25 Core/kmain.wtf.o
+ 0xc01012d8 VirtualTerminal::operator<<(int)
.text._ZN7DisplayC2Ev
- 0x001006d0 0xe
+ 0xc01012fe 0xe load address 0x001012fe
.text._ZN7DisplayC2Ev
- 0x001006d0 0xe Core/kmain.wtf.o
- 0x001006d0 Display::Display()
+ 0xc01012fe 0xe Core/kmain.wtf.o
+ 0xc01012fe Display::Display()
.text._ZN13VGATextOutputC1Ev
- 0x001006de 0x1c
+ 0xc010130c 0x1c load address 0x0010130c
.text._ZN13VGATextOutputC1Ev
- 0x001006de 0x1c Core/kmain.wtf.o
- 0x001006de VGATextOutput::VGATextOutput()
+ 0xc010130c 0x1c Core/kmain.wtf.o
+ 0xc010130c VGATextOutput::VGATextOutput()
-.rodata 0x00101000 0x220
+.text._Znaj 0xc0101328 0x1b load address 0x00101328
+ .text._Znaj 0xc0101328 0x1b VTManager/VirtualTerminal.class.o
+ 0xc0101328 operator new[](unsigned int)
+
+.rodata 0xc0102000 0x293 load address 0x00102000
*(.rodata)
- .rodata 0x00101000 0x1fd Core/kmain.wtf.o
- .rodata 0x001011fd 0x23 Core/Sys.ns.o
+ .rodata 0xc0102000 0x23f Core/kmain.wtf.o
+ .rodata 0xc010223f 0x51 Core/Sys.ns.o
+ .rodata 0xc0102290 0x3 VTManager/VirtualTerminal.class.o
.rodata._ZTV7Display
- 0x00101220 0x1c
+ 0xc0102298 0x1c load address 0x00102298
.rodata._ZTV7Display
- 0x00101220 0x1c Core/kmain.wtf.o
- 0x00101220 vtable for Display
+ 0xc0102298 0x1c Core/kmain.wtf.o
+ 0xc0102298 vtable for Display
.rodata._ZTV13VGATextOutput
- 0x00101240 0x1c
+ 0xc01022b8 0x1c load address 0x001022b8
.rodata._ZTV13VGATextOutput
- 0x00101240 0x1c Devices/Display/VGATextOutput.class.o
- 0x00101240 vtable for VGATextOutput
+ 0xc01022b8 0x1c Devices/Display/VGATextOutput.class.o
+ 0xc01022b8 vtable for VGATextOutput
-.rel.dyn 0x0010125c 0x0
+.rel.dyn 0xc01022d4 0x0 load address 0x001022d4
.rel.text 0x00000000 0x0 Core/kmain.wtf.o
+ .rel.text._Znwj
+ 0x00000000 0x0 Core/kmain.wtf.o
+ .rel.text._ZN15VirtualTerminallsEPc
+ 0x00000000 0x0 Core/kmain.wtf.o
+ .rel.text._ZN15VirtualTerminallsEi
+ 0x00000000 0x0 Core/kmain.wtf.o
.rel.text._ZN7DisplayC2Ev
0x00000000 0x0 Core/kmain.wtf.o
.rel.text._ZN13VGATextOutputC1Ev
@@ -94,58 +160,69 @@ Linker script and memory map
.rel.rodata._ZTV7Display
0x00000000 0x0 Core/kmain.wtf.o
-.data 0x00102000 0x24
- 0x00102000 start_ctors = .
+.data 0xc0103000 0x24 load address 0x00103000
+ 0xc0103000 start_ctors = .
*(.ctor*)
- 0x00102000 end_ctors = .
- 0x00102000 start_dtors = .
+ 0xc0103000 end_ctors = .
+ 0xc0103000 start_dtors = .
*(.dtor*)
- 0x00102000 end_dtors = .
+ 0xc0103000 end_dtors = .
*(.data)
- .data 0x00102000 0x24 Core/kmain.wtf.o
- 0x00102020 melonLogoCols
- 0x00102000 melonLogo
- 0x0010201c melonLogoLines
- .data 0x00102024 0x0 Core/cppsupport.wtf.o
- .data 0x00102024 0x0 Core/Sys.ns.o
- .data 0x00102024 0x0 Core/CMem.ns.o
- .data 0x00102024 0x0 DisplayManager/Disp.ns.o
- .data 0x00102024 0x0 Devices/Display/VGATextOutput.class.o
-
-.bss 0x00102024 0x4010
- 0x00102024 sbss = .
+ .data 0xc0103000 0x24 Core/kmain.wtf.o
+ 0xc0103020 melonLogoCols
+ 0xc0103000 melonLogo
+ 0xc010301c melonLogoLines
+ .data 0xc0103024 0x0 Core/cppsupport.wtf.o
+ .data 0xc0103024 0x0 Core/Sys.ns.o
+ .data 0xc0103024 0x0 Core/CMem.ns.o
+ .data 0xc0103024 0x0 MemoryManager/Mem.ns.o
+ .data 0xc0103024 0x0 DisplayManager/Disp.ns.o
+ .data 0xc0103024 0x0 VTManager/VirtualTerminal.class.o
+ .data 0xc0103024 0x0 Devices/Display/VGATextOutput.class.o
+
+.bss 0xc0103024 0x401c load address 0x00103024
+ 0xc0103024 sbss = .
*(COMMON)
*(.bss)
- .bss 0x00102024 0x0 Core/kmain.wtf.o
- .bss 0x00102024 0x4000 Core/loader.wtf.o
- .bss 0x00106024 0x4 Core/cppsupport.wtf.o
- 0x00106024 __dso_handle
- .bss 0x00106028 0x0 Core/Sys.ns.o
- .bss 0x00106028 0x0 Core/CMem.ns.o
- .bss 0x00106028 0xc DisplayManager/Disp.ns.o
- 0x00106028 Disp::mode
- .bss 0x00106034 0x0 Devices/Display/VGATextOutput.class.o
- 0x00106034 ebss = .
- 0x00106034 end = .
- 0x00106034 _end = .
- 0x00106034 __end = .
+ .bss 0xc0103024 0x0 Core/kmain.wtf.o
+ .bss 0xc0103024 0x4000 Core/loader.wtf.o
+ .bss 0xc0107024 0x4 Core/cppsupport.wtf.o
+ 0xc0107024 __dso_handle
+ .bss 0xc0107028 0x0 Core/Sys.ns.o
+ .bss 0xc0107028 0x0 Core/CMem.ns.o
+ .bss 0xc0107028 0xc MemoryManager/Mem.ns.o
+ 0xc0107030 Mem::kheapFree
+ 0xc0107028 Mem::kheapUsable
+ 0xc010702c Mem::placementAddress
+ .bss 0xc0107034 0xc DisplayManager/Disp.ns.o
+ 0xc0107034 Disp::mode
+ .bss 0xc0107040 0x0 VTManager/VirtualTerminal.class.o
+ .bss 0xc0107040 0x0 Devices/Display/VGATextOutput.class.o
+ 0xc0107040 ebss = .
+ 0xc0107040 end = .
+ 0xc0107040 _end = .
+ 0xc0107040 __end = .
LOAD Core/kmain.wtf.o
LOAD Core/loader.wtf.o
LOAD Core/cppsupport.wtf.o
LOAD Core/Sys.ns.o
LOAD Core/CMem.ns.o
+LOAD MemoryManager/Mem.ns.o
LOAD DisplayManager/Disp.ns.o
+LOAD VTManager/VirtualTerminal.class.o
LOAD Devices/Display/VGATextOutput.class.o
OUTPUT(Melon.ke elf32-i386)
-.comment 0x00000000 0x8b
+.comment 0x00000000 0xaf
.comment 0x00000000 0x12 Core/kmain.wtf.o
.comment 0x00000012 0x1f Core/loader.wtf.o
.comment 0x00000031 0x12 Core/cppsupport.wtf.o
.comment 0x00000043 0x12 Core/Sys.ns.o
.comment 0x00000055 0x12 Core/CMem.ns.o
- .comment 0x00000067 0x12 DisplayManager/Disp.ns.o
- .comment 0x00000079 0x12 Devices/Display/VGATextOutput.class.o
+ .comment 0x00000067 0x12 MemoryManager/Mem.ns.o
+ .comment 0x00000079 0x12 DisplayManager/Disp.ns.o
+ .comment 0x0000008b 0x12 VTManager/VirtualTerminal.class.o
+ .comment 0x0000009d 0x12 Devices/Display/VGATextOutput.class.o
.note.GNU-stack
0x00000000 0x0
@@ -158,6 +235,10 @@ OUTPUT(Melon.ke elf32-i386)
.note.GNU-stack
0x00000000 0x0 Core/CMem.ns.o
.note.GNU-stack
+ 0x00000000 0x0 MemoryManager/Mem.ns.o
+ .note.GNU-stack
0x00000000 0x0 DisplayManager/Disp.ns.o
.note.GNU-stack
+ 0x00000000 0x0 VTManager/VirtualTerminal.class.o
+ .note.GNU-stack
0x00000000 0x0 Devices/Display/VGATextOutput.class.o
diff --git a/Source/Kernel/Melon.ke b/Source/Kernel/Melon.ke
index b4a7f39..5b40f90 100755
--- a/Source/Kernel/Melon.ke
+++ b/Source/Kernel/Melon.ke
Binary files differ
diff --git a/Source/Kernel/MemoryManager/Mem.ns.cpp b/Source/Kernel/MemoryManager/Mem.ns.cpp
new file mode 100644
index 0000000..d8bfc4f
--- /dev/null
+++ b/Source/Kernel/MemoryManager/Mem.ns.cpp
@@ -0,0 +1,23 @@
+#include <Core/common.wtf.h>
+
+namespace Mem {
+
+bool kheapUsable = false;
+u32int placementAddress, kheapFree;
+
+void *kallocInternal(u32int sz, bool align) {
+ if (align && (placementAddress & 0xFFFFF000)) {
+ placementAddress &= 0xFFFFF000;
+ placementAddress += 0x1000;
+ }
+ u32int temp = placementAddress;
+ placementAddress += sz;
+ return (void*)temp;
+}
+
+void *kalloc(u32int sz, bool align) {
+ if (!kheapUsable) return kallocInternal(sz, align);
+ return 0;
+}
+
+}
diff --git a/Source/Kernel/MemoryManager/Mem.ns.h b/Source/Kernel/MemoryManager/Mem.ns.h
new file mode 100644
index 0000000..b3177a4
--- /dev/null
+++ b/Source/Kernel/MemoryManager/Mem.ns.h
@@ -0,0 +1,16 @@
+#ifdef DEF_COMMON
+
+#ifndef DEF_MEM_NS_H
+#define DEF_MEM_NS_H
+
+namespace Mem {
+ extern u32int placementAddress, kheapFree;
+
+ void *kalloc(u32int sz, bool align = false);
+ void kfree(void *ptr);
+
+}
+
+#endif
+
+#endif
diff --git a/Source/Kernel/VTManager/VirtualTerminal.class.cpp b/Source/Kernel/VTManager/VirtualTerminal.class.cpp
new file mode 100644
index 0000000..6478be4
--- /dev/null
+++ b/Source/Kernel/VTManager/VirtualTerminal.class.cpp
@@ -0,0 +1,158 @@
+#include "VirtualTerminal.class.h"
+#include <DisplayManager/Disp.ns.h>
+
+#define BUFCHR(l, c) m_buff[(l * m_rows) + c]
+
+VirtualTerminal::VirtualTerminal(u32int rows, u32int cols, u8int fgcolor, u8int bgcolor) {
+ m_buff = new chr[rows * cols];
+ m_rows = rows;
+ m_cols = cols;
+ m_mapped = false;
+ setColor(fgcolor, bgcolor);
+ clear();
+
+ m_csrcol = 0;
+ m_csrlin = 0;
+}
+
+void VirtualTerminal::setColor(u8int fgcolor, u8int bgcolor) {
+ if (bgcolor == 0xFF) {
+ m_color = (m_color & 0xF0) | fgcolor;
+ } else {
+ m_color = (bgcolor << 4) | fgcolor;
+ }
+}
+
+void VirtualTerminal::putChar(u32int row, u32int col, char c) {
+ chr* ch = &BUFCHR(row, col);
+ ch->c = c;
+ ch->color = m_color;
+ if (m_mapped)
+ Disp::putChar(row + m_maprow, col + m_mapcol, BUFCHR(row, col).c, m_color);
+}
+
+void VirtualTerminal::clear() {
+ for (u32int i = 0; i < m_rows * m_cols; i++) {
+ m_buff[i].c = ' ';
+ m_buff[i].color = m_color;
+ }
+ if (m_mapped) redraw();
+}
+
+void VirtualTerminal::map(s32int row, s32int col) {
+ m_maprow = (row == -1 ? (Disp::textRows() / 2) - (m_rows / 2) : row);
+ m_mapcol = (col == -1 ? (Disp::textCols() / 2) - (m_cols / 2) : col);
+ m_mapped = true;
+ redraw();
+}
+
+void VirtualTerminal::unmap() {
+ m_mapped = false;
+}
+
+void VirtualTerminal::redraw() {
+ if (!m_mapped) return;
+ for (u32int r = 0; r < m_rows; r++) {
+ for (u32int c = 0; c < m_cols; c++) {
+ Disp::putChar(r + m_maprow, c + m_mapcol, BUFCHR(r, c).c, BUFCHR(r, c).color);
+ }
+ }
+}
+
+void VirtualTerminal::scroll() {
+ for (u32int l = 0; l < m_rows - 1; l++) {
+ for (u32int c = 0; c < m_cols; c++) {
+ BUFCHR(l, c) = BUFCHR(l + 1, c);
+ }
+ }
+ for (u32int c = 0; c < m_cols; c++) {
+ BUFCHR(m_rows - 1, c).c = ' ';
+ BUFCHR(m_rows - 1, c).color = m_color;
+ }
+}
+
+void VirtualTerminal::updateCursor() {
+ Disp::moveCursor(m_csrlin + m_maprow, m_csrcol + m_mapcol);
+}
+
+void VirtualTerminal::moveCursor(u32int row, u32int col) {
+ m_csrlin = row;
+ m_csrcol = col;
+ updateCursor();
+}
+
+void VirtualTerminal::setCursorLine(u32int line) {
+ m_csrlin = line;
+ updateCursor();
+}
+
+void VirtualTerminal::setCursorCol(u32int col) {
+ m_csrcol = col;
+ updateCursor();
+}
+
+
+// Display functionn
+void VirtualTerminal::put(char c, bool updatecsr) {
+ if (c == 0x08) { //Ascii backspace
+ if (m_csrcol > 0) m_csrcol--;
+ putChar(m_csrlin, m_csrcol, ' ');
+ } else if (c == 0x09) { //Ascii tab
+ m_csrcol = (m_csrcol + 8) &~(8 - 1);
+ } else if (c == '\r') {
+ m_csrcol = 0;
+ } else if (c == '\n') {
+ m_csrcol = 0;
+ m_csrlin++;
+ } else if (c >= ' ') { //Printable character
+ putChar(m_csrlin, m_csrcol, c);
+ m_csrcol++;
+ }
+ if (m_csrcol >= m_cols) {
+ m_csrcol = 0;
+ m_csrlin++;
+ }
+ if (m_csrlin >= m_rows) {
+ scroll();
+ m_csrlin--;
+ }
+ if (updatecsr) updateCursor();
+}
+
+void VirtualTerminal::write(char* c, bool updatecsr) {
+ while (*c) {
+ put(*(c++), false);
+ }
+ if (updatecsr) updateCursor();
+}
+
+void VirtualTerminal::writeDec(s32int i, bool updatecsr) {
+ if (i == 0) {
+ put('0', false);
+ } else if (i < 0) {
+ put('-', false);
+ i = 0 - i;
+ }
+ char c[32];
+ int n = 0;
+ while (i > 0) {
+ c[n] = '0' + (i % 10);
+ i /= 10;
+ n++;
+ }
+ while (n > 0) {
+ n--;
+ put(c[n], false);
+ }
+ if (updatecsr) updateCursor();
+}
+
+void VirtualTerminal::writeHex(u32int i, bool updatecsr) {
+ write("0x", false);
+ char hexdigits[] = "0123456789ABCDEF";
+ for (u32int j = 0; j < 8; j++) {
+ put(hexdigits[(i & 0xF0000000) >> 28], false);
+ i = i << 4;
+ }
+ if (updatecsr) updateCursor();
+}
diff --git a/Source/Kernel/VTManager/VirtualTerminal.class.h b/Source/Kernel/VTManager/VirtualTerminal.class.h
new file mode 100644
index 0000000..801d009
--- /dev/null
+++ b/Source/Kernel/VTManager/VirtualTerminal.class.h
@@ -0,0 +1,51 @@
+#ifndef DEF_VIRTUALTERMINAL_CLASS_H
+#define DEF_VIRTUALTERMINAL_CLASS_H
+
+#include <Core/common.wtf.h>
+
+struct chr {
+ u8int color;
+ char c;
+ };
+
+class VirtualTerminal {
+ private:
+ chr* m_buff;
+ u32int m_rows, m_cols;
+ u8int m_color;
+
+ u32int m_maprow, m_mapcol;
+ bool m_mapped;
+
+ u32int m_csrlin, m_csrcol;
+
+ public:
+ VirtualTerminal(u32int rows, u32int cols, u8int fgcolor = 7, u8int bgcolor = 0);
+
+ void setColor(u8int fgcolor, u8int bgcolor = 0xFF);
+ void putChar(u32int row, u32int col, char c);
+ void clear();
+
+ void map(s32int row = -1, s32int col = -1);
+ void unmap();
+ void redraw();
+ void scroll(); //Scrolls 1 line
+
+ void updateCursor();
+ void moveCursor(u32int row, u32int col);
+ void setCursorLine(u32int line);
+ void setCursorCol(u32int col);
+
+ //Display functions
+ void put(char c, bool updatecsr = true);
+ void write(char *c, bool updatecsr = true);
+ void writeDec(s32int i, bool updatecsr = true);
+ void writeHex(u32int i, bool updatecsr = true);
+
+ inline VirtualTerminal& operator<<(char *c) { write(c); return *this; }
+ inline VirtualTerminal& operator<<(char c) { put(c); return *this; }
+ inline VirtualTerminal& operator<<(s32int i) { writeDec(i); return *this; }
+ inline VirtualTerminal& operator<<(u32int i) { writeHex(i); return *this; }
+};
+
+#endif