aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2021-03-14 23:08:46 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2021-03-14 23:08:46 +0200
commiteb909686f19073b324dee15366b957802dc095a7 (patch)
tree4adf50f94a19f8d2ed76fe9d181bafd8e1fb16fd /drivers
parentAdd GPL3 license (diff)
downloadkernel.cpp-eb909686f19073b324dee15366b957802dc095a7.tar.xz
CGA: map and set buffer address in kernel main
Diffstat (limited to 'drivers')
-rw-r--r--drivers/cga.cc20
-rw-r--r--drivers/cga.h5
2 files changed, 14 insertions, 11 deletions
diff --git a/drivers/cga.cc b/drivers/cga.cc
index 6589cee..51b7221 100644
--- a/drivers/cga.cc
+++ b/drivers/cga.cc
@@ -21,31 +21,31 @@ constexpr uint8_t cursor_addr_l = 15; // 0xf
* 1 1 | blink fast
*/
constexpr uint8_t cursor_hide = 0b00100000;
-constexpr uint32_t address = 0xc03ff000;
-CGA::CGA() {
+void CGA::set_buffer(uint32_t address) {
buffer = reinterpret_cast<Entry*>(address);
+ clear();
+ enable_cursor(14, 15);
+ update_cursor();
+}
- // clear buffer
+void CGA::set_colour(Colour fg, Colour bg) {
+ colour_fg = fg;
+ colour_bg = bg;
for (size_t y = 0; y < max_rows; y++) {
for (size_t x = 0; x < max_columns; x++) {
const size_t index = y * max_columns + x;
- buffer[index].c = ' ';
buffer[index].fg = colour_fg;
buffer[index].bg = colour_bg;
}
}
-
- enable_cursor(14, 15);
- update_cursor();
}
-void CGA::set_colour(Colour fg, Colour bg) {
- colour_fg = fg;
- colour_bg = bg;
+void CGA::clear() {
for (size_t y = 0; y < max_rows; y++) {
for (size_t x = 0; x < max_columns; x++) {
const size_t index = y * max_columns + x;
+ buffer[index].c = ' ';
buffer[index].fg = colour_fg;
buffer[index].bg = colour_bg;
}
diff --git a/drivers/cga.h b/drivers/cga.h
index f4dfb3c..ec207c4 100644
--- a/drivers/cga.h
+++ b/drivers/cga.h
@@ -35,10 +35,13 @@ public:
CGA_COLOR_WHITE = 15,
};
- CGA();
+ CGA() = default;
~CGA() = default;
+ void set_buffer(uint32_t);
+
void set_colour(Colour fg, Colour bg);
+ void clear();
void enable_cursor(uint8_t start, uint8_t end);
void disable_cursor();