From 945699694eafce5454c8e2016e74879b666896bc Mon Sep 17 00:00:00 2001 From: tkchia Date: Wed, 14 Sep 2022 06:26:33 +0800 Subject: [PATCH] Bare metal VGA: clarify code comments (#616) --- libc/vga/readv-vga.c | 10 +++++++++- libc/vga/vga.internal.h | 16 +++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/libc/vga/readv-vga.c b/libc/vga/readv-vga.c index a9668723f..2a761c6fd 100644 --- a/libc/vga/readv-vga.c +++ b/libc/vga/readv-vga.c @@ -30,7 +30,15 @@ #include "libc/vga/vga.internal.h" ssize_t sys_readv_vga(struct Fd *fd, const struct iovec *iov, int iovlen) { - /* NOTE: this routine is always non-blocking. */ + /* + * NOTE: this routine is always non-blocking. + * + * sys_readv_metal() calls here to ask if the VGA teletypewriter has any + * "status reports" escape sequences to send out. + * + * If there are no such status reports, then immediately return ≤ 0. + * sysv_readv_metal() will then try to read from an actual input device. + */ size_t i, redd = 0; ssize_t res = 0; for (i = 0; i < iovlen; ++i) { diff --git a/libc/vga/vga.internal.h b/libc/vga/vga.internal.h index bfc6488e1..2d4e06e9f 100644 --- a/libc/vga/vga.internal.h +++ b/libc/vga/vga.internal.h @@ -2,9 +2,9 @@ #define COSMOPOLITAN_LIBC_VGA_VGA_INTERNAL_H_ /* - * VGA_TTY_HEIGHT, VGA_TTY_WIDTH, & VGA_USE_WCS are configuration knobs - * which can potentially be used to tweak the features to be compiled into - * our VGA teletypewriter support. + * VGA_TTY_HEIGHT, VGA_TTY_WIDTH, VGA_USE_WCS, & VGA_PERSNICKETY_STATUS are + * configuration knobs which can potentially be used to tweak the features + * to be compiled into our VGA teletypewriter support. */ /** @@ -20,8 +20,14 @@ /** * If VGA_USE_WCS is defined, the tty code can maintain an array of the * Unicode characters "underlying" the 8-bit (or 9-bit) characters that are - * actually displayed on the text screen. This can be used to implement - * something similar to Linux's /dev/vcsu* facility. + * actually displayed on the text screen. This Unicode character + * information is not used in Cosmopolitan as of now (Sep 2022). A Linux + * mailing list post suggests that such information could be of use to + * applications such as screen readers. + * + * If VGA_USE_WCS is undefined, then the Unicode character information is + * not maintained, & we arrange for the relevant logic to be optimized away + * by the compiler. * * @see lkml.kernel.org/lkml/204888.1529277815@turing-police.cc.vt.edu/T/ */