Attention is currently required from: Jérémy Compostella.
Alper Nebi Yasak has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/82063?usp=email )
Change subject: drivers/pc80/vga/vga: Move big buffer for vga_write_text out of stack ......................................................................
drivers/pc80/vga/vga: Move big buffer for vga_write_text out of stack
The vga_write_text() uses a buffer for text large enough to fill the entire of VGA text mode screen, in order to split its input into lines and print each line. When trying to build it for ARM64 we get the following error:
src/drivers/pc80/vga/vga.c: In function 'vga_write_text': src/drivers/pc80/vga/vga.c:286:1: error: stack usage is 2064 bytes [-Werror=stack-usage=] 286 | vga_write_text(enum VGA_TEXT_ALIGNMENT alignment, unsigned int line, | ^~~~~~~~~~~~~~ cc1: all warnings being treated as errors make: *** [Makefile:419: build/qemu_arm64/ramstage/drivers/pc80/vga/vga.o] Error 1
This is an error because toolchain.mk adds `-Wstack-usage=1536` to CFLAGS for non-x86 architectures, which is accompanied with a note that some boards only have 2K stacks, so ignoring the warning with #pragma is likely unsafe.
The toolchain.mk comment advises us to "Store larger buffers in BSS, use static to share data in cache-as-ram on x86". Mark the big text buffer as static and clear it each time it's called.
Change-Id: Icbc6da144988060532d686d199afd7f26cbc6679 Signed-off-by: Alper Nebi Yasak alpernebiyasak@gmail.com --- M src/drivers/pc80/vga/vga.c 1 file changed, 2 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/63/82063/1
diff --git a/src/drivers/pc80/vga/vga.c b/src/drivers/pc80/vga/vga.c index 7f8ce69..9fbf5bc 100644 --- a/src/drivers/pc80/vga/vga.c +++ b/src/drivers/pc80/vga/vga.c @@ -287,7 +287,8 @@ const unsigned char *ustring) { const char *string = (const char *)ustring; - char str[VGA_COLUMNS * VGA_LINES] = {0}; + static char str[VGA_COLUMNS * VGA_LINES] = {0}; + memset(str, 0, sizeof(str) - 1); memcpy(str, string, strnlen(string, sizeof(str) - 1));
char *token = strtok(str, "\n");