From 19ad221e37602c5411dc95454d03d2c38e5ac9c2 Mon Sep 17 00:00:00 2001 From: PulkoMandy Date: Tue, 9 Sep 2014 21:45:57 +0200 Subject: [PATCH] Raspberry_pi: fix VT100 console driver * Cursor coordinates are 1-based, not 0-based * Color change was disabled and broken This implementation of our console over VT100 is generic and should be moved out of the raspberry-pi specific folder. However, leaving it there for now as we will have some bigger reorganization a swe add FDT support here. --- .../boot/platform/raspberrypi_arm/console.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/system/boot/platform/raspberrypi_arm/console.cpp b/src/system/boot/platform/raspberrypi_arm/console.cpp index 31cc7f286c..9477ed7b00 100644 --- a/src/system/boot/platform/raspberrypi_arm/console.cpp +++ b/src/system/boot/platform/raspberrypi_arm/console.cpp @@ -105,9 +105,9 @@ VTConsole::ClearScreen() void VTConsole::SetCursor(int32 x, int32 y) { - char buffer[8]; - x = MIN(79, MAX(0, x)); - y = MIN(24, MAX(0, y)); + char buffer[9]; + x = MIN(80, MAX(1, x)); + y = MIN(25, MAX(1, y)); int len = snprintf(buffer, sizeof(buffer), "\033[%" B_PRId32 ";%" B_PRId32 "H", y, x); WriteAt(NULL, 0LL, buffer, len); @@ -117,20 +117,19 @@ VTConsole::SetCursor(int32 x, int32 y) void VTConsole::SetColor(int32 foreground, int32 background) { - return; static const char cmap[] = { 0, 4, 2, 6, 1, 5, 3, 7 }; char buffer[12]; - if (foreground < 0 && foreground >= 8) + if (foreground < 0 || foreground >= 8) return; - if (background < 0 && background >= 8) + if (background < 0 || background >= 8) return; // We assume normal display attributes here int len = snprintf(buffer, sizeof(buffer), - "\033[#0;3%" B_PRId32 ";4%" B_PRId32 "m", - cmap[foreground], cmap[background]); + "\033[%" B_PRId32 ";%" B_PRId32 "m", + cmap[foreground] + 30, cmap[background] + 40); WriteAt(NULL, 0LL, buffer, len); }