diff --git a/.gitattributes b/.gitattributes
index 12b0908..b2a7b41 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,3 +1,4 @@
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.svg filter=lfs diff=lfs merge=lfs -text
+demodisk.img filter=lfs diff=lfs merge=lfs -text
diff --git a/.gitignore b/.gitignore
index c795b05..a897a63 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
-build
\ No newline at end of file
+build
+CON
+.vscode
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
deleted file mode 100644
index 862aed8..0000000
--- a/.vscode/c_cpp_properties.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "configurations": [
- {
- "name": "Linux",
- "includePath": [
- "${workspaceFolder}/**"
- ],
- "defines": [],
- "compilerPath": "/usr/bin/gcc",
- "cStandard": "gnu17",
- "cppStandard": "gnu++14",
- "intelliSenseMode": "linux-gcc-x64"
- }
- ],
- "version": 4
-}
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 90aa8cf..56af78b 100644
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,7 @@ all: clean build
build: build_kernel run
run:
- $(EMULATOR) -kernel $(BUILD_DIR)/myos.bin -serial stdio -vga std
+ $(EMULATOR) -kernel $(BUILD_DIR)/myos.bin -serial file:CON -vga std -monitor stdio -display gtk -m 2G -cpu core2duo -drive file=demodisk.img
build_kernel: $(OBJ_LINK_LIST)
diff --git a/README.md b/README.md
index 6aa56a7..bba2564 100644
--- a/README.md
+++ b/README.md
@@ -10,18 +10,17 @@ ________________________
The first scrolling boot screen. 😲
-
+![Interrupt handeling](screenshots/WIP_interruptHandling.png) \
W.I.P - Working on interrupt handling
+
+![Multiboot integration](screenshots/multiboot.png) \
+Multiboot information can be read by the kernel.
________________________
### The goal
Writing a hobby operating system to better understand the basic building blocks of any operating system.
-
-
-
-
________________________
### Operating System Technical specs/details
The operating system can print strings to the
diff --git a/screenshots/.blank b/screenshots/.blank
deleted file mode 100644
index e69de29..0000000
diff --git a/screenshots/multiboot.png b/screenshots/multiboot.png
new file mode 100644
index 0000000..25cf7ff
--- /dev/null
+++ b/screenshots/multiboot.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:13bb64394a1c4df50f254a7adfeda213a085b5338c44d6f61bbe2221c32e1929
+size 21530
diff --git a/src/kernel/arch/i386/idt/idt.cpp b/src/kernel/arch/i386/idt/idt.cpp
index 4722109..4ab65b2 100644
--- a/src/kernel/arch/i386/idt/idt.cpp
+++ b/src/kernel/arch/i386/idt/idt.cpp
@@ -23,6 +23,9 @@ void irs_handler (registers regs) {
printf(" Error code: %d \n", regs.err_code);
}
+
+
+
}
diff --git a/src/kernel/arch/i386/tty/kterm.c b/src/kernel/arch/i386/tty/kterm.c
index 2f2ce6f..c7914ee 100644
--- a/src/kernel/arch/i386/tty/kterm.c
+++ b/src/kernel/arch/i386/tty/kterm.c
@@ -46,6 +46,48 @@ void kterm_putat (char c, uint8_t color, size_t x, size_t y ) {
}
+void enable_cursor (uint8_t start_cursor , uint8_t end_cursor ){
+ outb(0x3D4, 0x0A);
+ outb(0x3D5, (inb(0x3D5) & 0xC0) | start_cursor);
+
+ outb(0x3D4, 0x0B);
+ outb(0x3D5, (inb(0x3D5) & 0xE0) | end_cursor);
+}
+
+void disable_cursor()
+{
+ outb(0x3D4, 0x0A);
+ outb(0x3D5, 0x20);
+}
+
+
+void update_cursor(int x, int y){
+ uint16_t pos = y * VGA_WIDTH + x;
+
+ outb(0x3D4, 0x0F);
+ outb(0x3D5, (uint8_t) (pos & 0xFF));
+ outb(0x3D4, 0x0E);
+ outb(0x3D5, (uint8_t) ((pos >> 8) & 0xFF));
+}
+
+uint16_t get_cursor_position(){
+ uint16_t pos = 0;
+ outb(0x3D4, 0x0F);
+ pos |= inb(0x3D5);
+ outb(0x3D4, 0x0E);
+ pos |= ((uint16_t) inb(0x3D5)) << 8;
+ return pos;
+}
+
+int get_cursor_x (uint16_t cursor_pos) {
+ return cursor_pos % VGA_WIDTH;
+}
+
+int get_cursor_y (uint16_t cursor_pos ) {
+ return cursor_pos / VGA_WIDTH;
+}
+
+
/**
* With the help from:
@@ -63,6 +105,7 @@ void kterm_scrollup(){
void kterm_put (char c) {
if(++kterm_column == VGA_WIDTH || c == '\n' ) {
+ update_cursor(kterm_column , kterm_row);
kterm_column = 0;
if(kterm_row == VGA_HEIGHT-1 ) {
kterm_scrollup();
diff --git a/src/kernel/arch/i386/tty/kterm.h b/src/kernel/arch/i386/tty/kterm.h
index d9f704f..9986b51 100644
--- a/src/kernel/arch/i386/tty/kterm.h
+++ b/src/kernel/arch/i386/tty/kterm.h
@@ -5,12 +5,14 @@
#include
#include "../vga/colors.h"
-
+#include "../../../io.h"
void kterm_init();
+/* Kernel terminal - Colour functions*/
void kterm_resetcolor();
void kterm_setcolor(uint8_t);
+/* Kernel terminal - Printing function */
void kterm_putat(char, uint8_t, size_t, size_t);
void kterm_put(char);
void kterm_write(const char*, size_t);
@@ -18,6 +20,15 @@ void kterm_writestring(const char*);
void kterm_scrollup();
+/* Kernel terminal - Cursor functions */
+void enable_cursor (uint8_t start_cursor , uint8_t end_cursor );
+void disable_cursor();
+void update_cursor(int x, int y);
+uint16_t get_cursor_position();
+int get_cursor_x (uint16_t cursor_pos);
+int get_cursor_y (uint16_t cursor_pos);
+
+
void printf ( const char *format, ...);
static void itoa (char *buf, int base, int d);
diff --git a/src/kernel/arch/i386/vga/VBE.h b/src/kernel/arch/i386/vga/VBE.h
new file mode 100644
index 0000000..8b63cd4
--- /dev/null
+++ b/src/kernel/arch/i386/vga/VBE.h
@@ -0,0 +1,41 @@
+
+#define VBE_DISPI_IOPORT_INDEX 0x01CE
+#define VBE_DISPI_IOPORT_DATA 0x01CF
+
+/* VBE index values*/
+#define VBE_DISPI_INDEX_ID 0x0
+#define VBE_DISPI_INDEX_XRES 0x1
+#define VBE_DISPI_INDEX_YRES 0x2
+#define VBE_DISPI_INDEX_BPP 0x3
+#define VBE_DISPI_INDEX_ENABLE 0x4
+#define VBE_DISPI_INDEX_BANK 0x5
+#define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
+#define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
+#define VBE_DISPI_INDEX_X_OFFSET 0x8
+#define VBE_DISPI_INDEX_Y_OFFSET 0x9
+
+/* BGA Version */
+#define VBE_DISPI_ID5 0xB0C5
+#define VBE_DISPI_ID4 0xB0C3
+#define VBE_DISPI_ID3 0xB0C2
+#define VBE_DISPI_ID2 0xB0C1
+#define VBE_DISPI_ID1 0xB0C0
+
+
+/* BGA BIT DEPTH */
+#define VBE_DISPI_BPP_4 0x04
+#define VBE_DISPI_BPP_8 0x08
+#define VBE_DISPI_BPP_15 0x0F
+#define VBE_DISPI_BPP_16 0x10
+#define VBE_DISPI_BPP_24 0x18
+#define VBE_DISPI_BPP_32 0x20
+
+
+ /*unsigned short BGAReadRegister(unsigned short IndexValue){
+ // outpw(VBE_DISPI_IOPORT_INDEX, IndexValue);
+ // return inpw (VBE_DISPI_IOPORT_DATA);
+ }
+
+ int BGAIsAvailable (){
+ return (BGAReadRegister(VBE_DISPI_INDEX_ID) == VBE_DISPI_ID5);
+ }*/
diff --git a/src/kernel/cpu.h b/src/kernel/cpu.h
new file mode 100644
index 0000000..4b90a9e
--- /dev/null
+++ b/src/kernel/cpu.h
@@ -0,0 +1,16 @@
+#include // NOTE: Only available in GCC
+
+ static int get_model(){
+ int ebx, unused;
+ __cpuid(0, unused, ebx, unused, unused);
+ return ebx;
+ }
+
+ enum {
+ CPUID_FEAT_EDX_APIC = 1 << 9
+ };
+ static int check_apic (){
+ unsigned int eax, unused, edx;
+ __get_cpuid(1, &eax, &unused, &unused, &edx);
+ return edx & CPUID_FEAT_EDX_APIC;
+ }
diff --git a/src/kernel/kernel.cpp b/src/kernel/kernel.cpp
index 5087b0e..df18683 100644
--- a/src/kernel/kernel.cpp
+++ b/src/kernel/kernel.cpp
@@ -1,108 +1,14 @@
#include "kernel.h"
-/**
- * simple delay function
- **/
-void delay(int t){
- volatile int i,j;
- for(i=0;iflags, 12)){
printf("Can draw!");
}
+
+ int cpu_model = get_model();
+ int local_apic = check_apic();
+ printf( "CPU Model: %x, Local APIC: %D\n", cpu_model, local_apic);
+
}
void kernel_main (void) {
-
init_serial();
- /** Setup the MMU **/
- //kterm_writestring("Starting MMU...\n");
- //auto mmu = MMU();
- //mmu.enable();
- //kterm_writestring("MMU enabled!\n");
-
-
-
-
-
-
- /** test interrupt handlers **/
- //asm volatile ("int $0x03");
-
- //asm volatile ("int $0x04");
while (true){
//Read time indefinetely
@@ -232,14 +127,8 @@ extern "C" {
delay(1000);
}
-
- /** Lets start using the serial port for debugging .. **/
- // Hopefully once we go into realmode or do something that
- // cause the screen to go black.. this serial comms part will give
- // some situational awareness
- //Serial serialbus = Serial::init();
-
-
+
+
}
}
diff --git a/src/kernel/kernel.h b/src/kernel/kernel.h
index a863a97..b9b22bf 100644
--- a/src/kernel/kernel.h
+++ b/src/kernel/kernel.h
@@ -9,6 +9,105 @@ extern "C" {
#include "MMU.h"
#include "io.h"
#include "time.h"
+#include "cpu.h"
+#include "arch/i386/vga/VBE.h"
+#define CHECK_FLAG(flags, bit) ((flags) & (1 <<(bit)))
-#define CHECK_FLAG(flags, bit) ((flags) & (1 <<(bit)))
\ No newline at end of file
+
+/* This needs to be moved! */
+/**
+ * simple delay function
+ **/
+void delay(int t){
+ volatile int i,j;
+ for(i=0;i