From de74711dc8bd7eceb9d9c13fb24a2cee40d47009 Mon Sep 17 00:00:00 2001 From: Hsuan Ting Chen Date: Fri, 17 Feb 2023 19:36:38 +0800 Subject: 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/73090 Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons Reviewed-by: Tarun Tuli --- src/drivers/pc80/vga/vga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/drivers/pc80/vga/vga.c') 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; } -- cgit v1.2.3