Patrick Rudolph has uploaded this change for review.

View Change

payloads: Add gfxtest

Draws 4 colored bars to the screen.
To be used when debugging framebuffer code.

Change-Id: I0e1fd6344925edc0ceb42286bf7492bc16a2668c
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
---
M payloads/Kconfig
M payloads/Makefile.inc
A payloads/gfxtest/Makefile
A payloads/gfxtest/gfxtest.c
4 files changed, 95 insertions(+), 1 deletion(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/89/41189/1
diff --git a/payloads/Kconfig b/payloads/Kconfig
index cfb28d6..3e34101 100644
--- a/payloads/Kconfig
+++ b/payloads/Kconfig
@@ -138,6 +138,14 @@
nvramcui can be loaded as a secondary payload under SeaBIOS, GRUB,
or any other payload that can load additional payloads.

+config GFXTEST_SECONDARY_PAYLOAD
+ bool "Load gfxtest as a secondary payload"
+ default n
+ depends on ARCH_X86
+ help
+ gfxtest can be loaded as a secondary payload under SeaBIOS, GRUB,
+ or any other payload that can load additional payloads.
+
config TINT_SECONDARY_PAYLOAD
bool "Load tint as a secondary payload"
default n
diff --git a/payloads/Makefile.inc b/payloads/Makefile.inc
index 83d3910..df68b18 100644
--- a/payloads/Makefile.inc
+++ b/payloads/Makefile.inc
@@ -18,6 +18,11 @@
img/coreinfo-type := payload
img/coreinfo-compression := $(CBFS_SECONDARY_PAYLOAD_COMPRESS_FLAG)

+cbfs-files-$(CONFIG_GFXTEST_SECONDARY_PAYLOAD) += img/gfxtest
+img/gfxtest-file := payloads/gfxtest/gfxtest.elf
+img/gfxtest-type := payload
+img/gfxtest-compression := $(CBFS_SECONDARY_PAYLOAD_COMPRESS_FLAG)
+
cbfs-files-$(CONFIG_NVRAMCUI_SECONDARY_PAYLOAD) += img/nvramcui
img/nvramcui-file := payloads/nvramcui/nvramcui.elf
img/nvramcui-type := payload
@@ -25,6 +30,7 @@

PAYLOADS_LIST=\
payloads/coreinfo \
+payloads/gfxtest \
payloads/nvramcui \
payloads/libpayload \
payloads/external/depthcharge \
@@ -41,6 +47,9 @@
payloads/coreinfo/build/coreinfo.elf coreinfo:
$(MAKE) -C payloads/coreinfo defaultbuild

+payloads/gfxtest/gfxtest.elf gfxtest:
+ $(MAKE) -C payloads/gfxtest
+
payloads/nvramcui/nvramcui.elf nvramcui:
$(MAKE) -C payloads/nvramcui

@@ -53,4 +62,4 @@
print-repo-info-payloads:
-$(foreach payload, $(PAYLOADS_LIST), $(MAKE) -C $(payload) print-repo-info 2>/dev/null; )

-.PHONY: clean-payloads distclean-payloads print-repo-info-payloads nvramcui coreinfo
+.PHONY: clean-payloads distclean-payloads print-repo-info-payloads nvramcui coreinfo gfxtest
diff --git a/payloads/gfxtest/Makefile b/payloads/gfxtest/Makefile
new file mode 100644
index 0000000..c4cfff9
--- /dev/null
+++ b/payloads/gfxtest/Makefile
@@ -0,0 +1,34 @@
+LIBPAYLOAD_DIR=$(CURDIR)/libpayload
+XCOMPILE=$(LIBPAYLOAD_DIR)/libpayload.xcompile
+# build libpayload and put .config file in $(CURDIR) instead of ../libpayload
+# to avoid pollute the libpayload source directory and possible conflicts
+LPOPTS=obj="$(CURDIR)/build" DESTDIR="$(CURDIR)" DOTCONFIG="$(CURDIR)/.config"
+CFLAGS += -Wall -Wvla -Werror -Os -ffreestanding -nostdinc -nostdlib
+
+all: gfxtest.elf
+
+$(LIBPAYLOAD_DIR):
+ $(MAKE) -C ../libpayload $(LPOPTS) defconfig
+ $(MAKE) -C ../libpayload $(LPOPTS)
+ $(MAKE) -C ../libpayload $(LPOPTS) install
+
+ifneq ($(strip $(wildcard libpayload)),)
+include $(XCOMPILE)
+LPGCC = CC="$(GCC_CC_x86_32)" "$(LIBPAYLOAD_DIR)/bin/lpgcc"
+%.elf: %.c Makefile
+ $(LPGCC) $(CFLAGS) -o $*.elf $*.c
+else
+# If libpayload is not found, first build libpayload,
+# then do the make, this time it'll find libpayload
+# and generate the gfxtest.elf target
+%.elf: $(LIBPAYLOAD_DIR)
+ $(MAKE) all
+endif
+
+clean:
+ rm -f gfxtest.elf
+
+distclean: clean
+ rm -rf build libpayload .config .config.old
+
+.PHONY: all clean distclean
diff --git a/payloads/gfxtest/gfxtest.c b/payloads/gfxtest/gfxtest.c
new file mode 100644
index 0000000..91bf4ff
--- /dev/null
+++ b/payloads/gfxtest/gfxtest.c
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* This file is part of the coreboot project. */
+
+#include <libpayload.h>
+
+int main(void)
+{
+ struct rgb_color black = {0};
+ int i;
+
+ struct rgb_color colors[] = {
+ {0xff, 0x00, 0x00},
+ {0x00, 0xff, 0x00},
+ {0x00, 0x00, 0xff},
+ {0xff, 0xff, 0xff},
+ };
+
+ if (CONFIG(LP_USB))
+ usb_initialize();
+
+ /* coreboot data structures */
+ lib_get_sysinfo();
+
+ if (!lib_sysinfo.framebuffer) {
+ printf("No framebuffer found\n");
+ halt();
+ }
+
+ clear_screen(&black);
+ printf("GFXTEST - R G B W\n");
+
+ for (i = 0; i < ARRAY_SIZE(colors); i++) {
+ struct rect box;
+ box.size.width = CANVAS_SCALE / ARRAY_SIZE(colors);
+ box.offset.x = box.size.width * i;
+ box.offset.y = CANVAS_SCALE * 1 / 10;
+ box.size.height = CANVAS_SCALE * 9 / 10;
+
+ draw_box(&box, &colors[i]);
+ }
+
+ halt();
+}

To view, visit change 41189. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I0e1fd6344925edc0ceb42286bf7492bc16a2668c
Gerrit-Change-Number: 41189
Gerrit-PatchSet: 1
Gerrit-Owner: Patrick Rudolph <siro@das-labor.org>
Gerrit-MessageType: newchange