aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/pc80/vga/vga.c
diff options
context:
space:
mode:
authorHsuan Ting Chen <roccochen@chromium.org>2023-02-17 19:36:38 +0800
committerFelix Held <felix-coreboot@felixheld.de>2023-02-21 21:31:25 +0000
commitde74711dc8bd7eceb9d9c13fb24a2cee40d47009 (patch)
tree5616948a98fc31ed135a0d762b5d83a0a0a518ce /src/drivers/pc80/vga/vga.c
parent73e9ac66ad8ff8f4b15389b5685f808ac20e204c (diff)
vga: Fix the support of extended ASCII
VGA defineds the extended ASCII set based on CP437, but there is a bug on printing them: in vga_write_at_offset(), we perform a bitwise or between 'unsigned short' and 'signed char': ``` p[i] = 0x0F00 | string[i]; ``` If we want to show an extended ASCII character, string[i] will be negative and this bitwise operation will fail due to their implicit casting rule: convert signed char to unsigned short by adding 65536. To fix this, we need to cast the string to unsigned char manually somewhere. Since we still want to leverage the built-in string utilities which only accepts const char*, we still preserve the original prototypes before, and cast it until we write into the frame buffer. BRANCH=brya BUG=b:264666392 TEST=emerge-brya coreboot chromeos-bootimage and verify drawing characters with code > 127. Change-Id: I9cd65fe9794e5b0d338147924f28efd27fc8a1e8 Signed-off-by: Hsuan Ting Chen <roccochen@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/73090 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Tarun Tuli <taruntuli@google.com>
Diffstat (limited to 'src/drivers/pc80/vga/vga.c')
-rw-r--r--src/drivers/pc80/vga/vga.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/drivers/pc80/vga/vga.c b/src/drivers/pc80/vga/vga.c
index a52ba6dc1f..a9befcaccc 100644
--- a/src/drivers/pc80/vga/vga.c
+++ b/src/drivers/pc80/vga/vga.c
@@ -267,7 +267,7 @@ vga_write_at_offset(unsigned int line, unsigned int offset, const char *string)
for (i = 0; i < (VGA_COLUMNS - offset); i++) {
if (i < len)
- p[i] = 0x0F00 | string[i];
+ p[i] = 0x0F00 | (unsigned char)string[i];
else
p[i] = 0x0F00;
}