aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/graphics/vga.c28
-rw-r--r--src/graphics/vga.h2
-rw-r--r--src/input/ps2/mouse.c4
-rw-r--r--src/io/io.c4
-rw-r--r--src/io/io.h2
-rw-r--r--src/kernel.c5
6 files changed, 35 insertions, 10 deletions
diff --git a/src/graphics/vga.c b/src/graphics/vga.c
index 54527e1..7efa014 100644
--- a/src/graphics/vga.c
+++ b/src/graphics/vga.c
@@ -1,5 +1,6 @@
#include <stddef.h>
#include <stdint.h>
+#include <stdbool.h>
// Hardware text mode color constants
enum vga_color {
@@ -66,16 +67,33 @@ void terminal_put_entry_at(char c, uint8_t color, size_t x, size_t y) {
terminal_buffer[index] = vga_entry(c, color);
}
+void terminal_clear() {
+ for (size_t x = 0; x < VGA_WIDTH; x++)
+ for (size_t y = 0; y < VGA_HEIGHT; y++)
+ terminal_put_entry_at(' ', terminal_color, x, y);
+}
+
void terminal_put_char(char c) {
- if (c == '\n' || c == '\r') {
+ bool new_line = c == '\n' || c == '\r';
+
+ if (new_line) {
terminal_row += 1;
terminal_column = 0;
} else {
terminal_put_entry_at(c, terminal_color, terminal_column, terminal_row);
- if (++terminal_column == VGA_WIDTH) {
- terminal_column = 0;
- if (++terminal_row == VGA_HEIGHT)
- terminal_row = 0;
+ }
+
+ // Scroll content up
+ if (++terminal_column >= VGA_WIDTH || new_line) {
+ terminal_column = 0;
+ if (++terminal_row >= VGA_HEIGHT) {
+ terminal_row = VGA_HEIGHT - 1;
+ for (size_t x = 0; x < VGA_WIDTH; x++)
+ for (size_t y = 0; y < VGA_HEIGHT; y++) {
+ uint16_t c = terminal_buffer[y * VGA_WIDTH + x];
+ terminal_buffer[(y - 1) * VGA_WIDTH + x] = c;
+ terminal_buffer[y * VGA_WIDTH + x] = vga_entry(' ', terminal_color);
+ }
}
}
}
diff --git a/src/graphics/vga.h b/src/graphics/vga.h
index efe2117..7c449f1 100644
--- a/src/graphics/vga.h
+++ b/src/graphics/vga.h
@@ -10,6 +10,8 @@ void terminal_initialize(void);
void terminal_set_color(uint8_t color);
+void terminal_clear();
+
void terminal_write_string(const char *data);
void terminal_put_char(char c);
diff --git a/src/input/ps2/mouse.c b/src/input/ps2/mouse.c
index 191c270..8e5a3e3 100644
--- a/src/input/ps2/mouse.c
+++ b/src/input/ps2/mouse.c
@@ -1,7 +1,6 @@
#include "../../io/io.h"
#include "../../interrupts/interrupts.h"
#include "../../graphics/vga.h"
-#include "../input.h"
char mouse_cycle = 0;
signed char mouse_byte[3], mouse_ex[3];
@@ -38,6 +37,9 @@ void mouse_handler(struct regs *a_r) {
default:
break;
}
+ if (mm_n[0] == 1) {
+ terminal_write_string("CLICK!\n");
+ }
}
inline void mouse_wait(char a_type) {
diff --git a/src/io/io.c b/src/io/io.c
index d617cf2..2f42d04 100644
--- a/src/io/io.c
+++ b/src/io/io.c
@@ -4,6 +4,6 @@ unsigned char receive(unsigned short port) {
return value;
}
-void send(unsigned short _port, unsigned char _data) {
- __asm__ __volatile__ ("outb %1, %0" : : "dN" (_port), "a" (_data));
+void send(unsigned short port, unsigned char data) {
+ __asm__ __volatile__ ("outb %1, %0" : : "dN" (port), "a" (data));
}
diff --git a/src/io/io.h b/src/io/io.h
index 8d3beda..41042c3 100644
--- a/src/io/io.h
+++ b/src/io/io.h
@@ -5,6 +5,6 @@
unsigned char receive(unsigned short port);
-void send(unsigned short _port, unsigned char _data);
+void send(unsigned short port, unsigned char data);
#endif
diff --git a/src/kernel.c b/src/kernel.c
index e4b8a37..0e1b020 100644
--- a/src/kernel.c
+++ b/src/kernel.c
@@ -5,11 +5,14 @@
#include "timer/timer.h"
void kernel_main(void) {
- terminal_initialize();
gdt_install();
idt_install();
isrs_install();
irq_install();
+
+ __asm__ __volatile__ ("sti");
+
+ terminal_initialize();
timer_install();
keyboard_install();
mouse_install();