Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/73090 )
Change subject: vga: Fix the support of extended ASCII ......................................................................
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 --- M src/drivers/pc80/vga/vga.c 1 file changed, 37 insertions(+), 1 deletion(-)
Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved Tarun Tuli: Looks good to me, approved
diff --git a/src/drivers/pc80/vga/vga.c b/src/drivers/pc80/vga/vga.c index a52ba6d..a9befca 100644 --- a/src/drivers/pc80/vga/vga.c +++ b/src/drivers/pc80/vga/vga.c @@ -267,7 +267,7 @@
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; }