aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/drivers/vga_text_buffer/vga_text_buffer.c30
-rw-r--r--kernel/include/drivers/vga_text_buffer.h13
2 files changed, 18 insertions, 25 deletions
diff --git a/kernel/drivers/vga_text_buffer/vga_text_buffer.c b/kernel/drivers/vga_text_buffer/vga_text_buffer.c
index 286b1ed..6f79f46 100644
--- a/kernel/drivers/vga_text_buffer/vga_text_buffer.c
+++ b/kernel/drivers/vga_text_buffer/vga_text_buffer.c
@@ -20,6 +20,8 @@
#include <stddef.h>
#include <stdint.h>
+#include <common.h>
+
#include <libk/stdio.h>
#include <libk/string.h>
@@ -30,29 +32,10 @@
static uint16_t *vga_text_buffer_buffer = (uint16_t *) 0xB8000;
static uint8_t vga_text_buffer_row = 0;
static uint8_t vga_text_buffer_column = 0;
-static uint8_t vga_text_buffer_color;
-
-static uint8_t
-vga_entry_color(const vga_color fg, const vga_color bg)
-{
- /*
- * bg fg
- * 1110 0101
- */
- return bg << 4 | fg;
-}
+static uint8_t vga_text_buffer_color
+ = vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK);
-static uint16_t
-vga_entry(const unsigned char character, const uint8_t color)
-{
- /*
- * color character
- * 1110 0101 1001 1010
- */
- return (uint16_t) color << 8 | (uint16_t) character;
-}
-
-static void
+ALWAYS_INLINE static void
vga_text_buffer_write_entry_at(const char c,
const uint8_t color,
const uint8_t x,
@@ -72,9 +55,6 @@ vga_text_buffer_initialize(void)
outb(0x3D4, 0x0A);
outb(0x3D5, 0x20);
- vga_text_buffer_color
- = vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK);
-
for (uint8_t y = 0; y < VGA_HEIGHT; y++)
for (uint8_t x = 0; x < VGA_WIDTH; x++)
vga_text_buffer_write_entry_at(' ', vga_text_buffer_color, x, y);
diff --git a/kernel/include/drivers/vga_text_buffer.h b/kernel/include/drivers/vga_text_buffer.h
index 7bb88d6..e09bf2e 100644
--- a/kernel/include/drivers/vga_text_buffer.h
+++ b/kernel/include/drivers/vga_text_buffer.h
@@ -50,6 +50,19 @@ typedef enum {
VGA_COLOR_WHITE = 15,
} vga_color;
+/*
+ * bg fg
+ * 1110 0101
+ */
+#define vga_entry_color(fg, bg) (bg << 4 | fg)
+
+/*
+ * color character
+ * 1110 0101 1001 1010
+ */
+#define vga_entry(character, color) \
+ ((uint16_t) color << 8 | (uint16_t) character)
+
bool vga_text_buffer_is_initialized(void);
void vga_text_buffer_initialize(void);