From patchwork Thu Oct 2 15:45:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 478 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759419999; bh=bvJlCwUmamlWx9kBMRaj/8JDZACuN7+PFJtLEXCh+MU=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=nZ/5qr3BD3SnzSmSB25K+cCdb8GK6RTNf2nNL7HV4rnq3caZRFRIZN9GEhel5bT4h 6TLgdKpk19Ck6D/I0XPMcDONB7wMtB6/UYikLXpjXChEpes04NEcLJJg3bcPIDEJ6A W0ZqiY0BtervLfikdUsWuMSYYjGoUr9g0LBsGCuYqUR2ED4cKM1Rmyuf6LUeH7oaff z+wf2Br3HolEyG10PjRgJSn4/2NFoGnJ70w/wp942T43v1XvbO4/6R0oOzcWWXpTrG EWERwTr0DeKAAb2kjiev1Wa2SZFqQTnbjcVcv5UMKJxIvmolcMohj6hjNSYgF/owhO /gwen2CmnA1eA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9A92567F2A for ; Thu, 2 Oct 2025 09:46:39 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id w52Xo6sp3n68 for ; Thu, 2 Oct 2025 09:46:39 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759419998; bh=bvJlCwUmamlWx9kBMRaj/8JDZACuN7+PFJtLEXCh+MU=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=LgGHR2Qk3W9/CLR0YzCVHqeLtb7w2/6PLrXoV0E7XynT86rK8C23nfBO/nOR5FWLE jqzg68LNJ7MVSddoTZxRDlZZkGk0QMNX93uQp06ajBJ7sRCQp4gYhdckpgELuvZw3y LFtzowsE8f6ixAjucJXbma0fDfR8ANRExnKyGytmB2ymXCyjtj/7uCmv0HAGTYWLyw oqiQzPN+DBWfG7qfPC4UDRDo48YwaVqtOsr9Hquzd+jn7zrhMd/2NVALmxmZwARpEX GuEmvwh9RWL3k4kPinkL1iIS6thT66+Z2CCOHXToBFhVabgb5rTa9bKDN410JF08Ws xIgqRsMhoYNkg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CDC7967F14 for ; Thu, 2 Oct 2025 09:46:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759419997; bh=uMlih6kobzn1qxIOL79G0Digay+Lq6OqioLNIGTNN5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KMC3lfp2QI3HlLBcZ1cMwKwsgP/N3PBewnEET1njUYtZbXRYX2Jonokztz+NJh5DG zkracfP2izxLn5spiy3O8HlI8O5LuAiAmeIYWasarY611ejeRV+LdC514gv6KUzlyN 1e2ateOzSK8dPrt9OBsPYHG9xa5FOrmAcIRUkWmVmds2GnGMk2ScdfMBv82hGV2k1k D6OoL1IjnMlYykcInvgeUn2GnXB2Yi68puXFSB8lWBnlL+5jTp7fUnI0Dj4PYolF/i 5MD0qzO3OtoYM07a7CIg0TcjMG07cKMn77fp7PbCQbpNOSnPkQLm7emX3ku6t3aVRY 4af32p+NIHrMg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0D98967F16; Thu, 2 Oct 2025 09:46:37 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id EWd5i7mYYyoV; Thu, 2 Oct 2025 09:46:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759419994; bh=1AYip8ef3TOSCTdvf0jQquVFBVkjE+JibyhJVIEf8lo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mJCzml/nBcRlBiEnXSPR6CEX/jZ14Veb7WcMllvBhli0yqZqpErNCozz/N4GknPJT 0pn7dLE7JqeGdClRP2QJnIqBhfcZUEOXKPOIUnh2UcWnDmaNINjMuc/O9PLGteUDS/ Goer66v7axcqHOAvWwdSyOFOOEOTkjsGIQyOdvFc3/34J/xPBF/f+2zQ/3OwqhlakO gH2c5P+HoY98xRMtXpxvzZItSoub84coPHs+yKnJsRFRXn3ltFxeGFjTpP8npDFa6E PpotXrmCCATfKR/OiuKDRQtReSB7vHBLV+CKuLWmyCeY0QM8UO6P19BfhgoJvDQRgw xbRT9fI2z7suw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7D71467F1A; Thu, 2 Oct 2025 09:46:34 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 2 Oct 2025 09:45:46 -0600 Message-ID: <20251002154554.4129220-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251002154554.4129220-1-sjg@u-boot.org> References: <20251002154554.4129220-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: IHXXCS3OIPQ2AQ3RURU3QDPJYJFSNOGI X-Message-ID-Hash: IHXXCS3OIPQ2AQ3RURU3QDPJYJFSNOGI X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 6/9] video: Support a linker list of images List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass It is inconvenient to have to access graphical images as independent symbols. Create a new rule which handles any file mentioned in drivers/video/images/Makefile For each graphical image, embed in the image and create a linker-list entry for it. Co-developed-by: Claude Signed-off-by: Simon Glass --- Changes in v2: - Use Canonical copyright include/video.h | 46 +++++++++++++++++++++++++++++++++++++++++++ include/video_image.h | 13 ++++++++++++ scripts/Makefile.lib | 38 +++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 include/video_image.h diff --git a/include/video.h b/include/video.h index 9f891cf9d30..9985f5adcf8 100644 --- a/include/video.h +++ b/include/video.h @@ -7,7 +7,9 @@ #ifndef _VIDEO_H_ #define _VIDEO_H_ +#include #include +#include #ifdef CONFIG_SANDBOX #include #endif @@ -201,6 +203,50 @@ enum colour_idx { VID_COLOUR_COUNT }; +/** + * struct video_image - Information about an embedded image + * + * This structure holds the pointers to the start and end of an image + * that is embedded in the U-Boot binary, along with its name. + * On 64-bit: 2*8 + VIDEO_IMAGE_NAMELEN = 32 bytes + * On 32-bit: 2*4 + VIDEO_IMAGE_NAMELEN = 24 bytes + * + * @begin: Pointer to the start of the image data + * @end: Pointer to the end of the image data + * @name: Name of the image (e.g., "u_boot", "canonical"), null-terminated + */ +struct video_image { + const void *begin; + const void *end; + char name[VIDEO_IMAGE_NAMELEN]; +}; + +/** + * video_image_get() - Get the start address and size of an image + * + * @_name: Name of the image taken from filename (e.g. u_boot) + * @_sizep: Returns the size of the image in bytes + * Return: Pointer to the start of the image data + */ +#define video_image_get(_name, _sizep) ({ \ + struct video_image *__img = ll_entry_get(struct video_image, _name, \ + video_image); \ + *(_sizep) = (ulong)__img->end - (ulong)__img->begin; \ + (void *)__img->begin; \ + }) + +/** + * video_image_getptr() - Get the start address of an image + * + * @_name: Name of the image taken from filename (e.g. u_boot) + * Return: Pointer to the start of the image data + */ +#define video_image_getptr(_name) ({ \ + struct video_image *__img = ll_entry_get(struct video_image, _name, \ + video_image); \ + (void *)__img->begin; \ + }) + /** * video_index_to_colour() - convert a color code to a pixel's internal * representation diff --git a/include/video_image.h b/include/video_image.h new file mode 100644 index 00000000000..6c4370937aa --- /dev/null +++ b/include/video_image.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2025 Canonical Ltd + * Written by Simon Glass + */ + +#ifndef __VIDEO_IMAGE_H +#define __VIDEO_IMAGE_H + +/* Maximum length of an embedded image name */ +#define VIDEO_IMAGE_NAMELEN 16 + +#endif /* __VIDEO_IMAGE_H */ diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 5abe428e752..e812327b585 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -523,6 +523,44 @@ cmd_S_splash= \ $(obj)/%_logo.S: $(src)/%_logo.bmp $(call cmd,S_splash) +# Handle image files in drivers/video/images without _logo suffix +# Generate an assembly file to wrap the image data and create a linker-list entry +quiet_cmd_S_image= IMAGE $@ +cmd_S_image= \ +( \ + echo '\#include '; \ + echo '.section .rodata.image.init,"a"'; \ + echo '.balign 16'; \ + echo '.global __image_$(*F)_begin'; \ + echo '__image_$(*F)_begin:'; \ + echo '.incbin "$<" '; \ + echo '__image_$(*F)_end:'; \ + echo '.global __image_$(*F)_end'; \ + echo '.balign 16'; \ + echo ''; \ + echo '/* Linker list entry for this image */'; \ + echo '.section __u_boot_list_2_video_image_2_$(*F), "aw"'; \ + echo '.balign 8'; \ + echo '.global _u_boot_list_2_video_image_2_$(*F)'; \ + echo '_u_boot_list_2_video_image_2_$(*F):'; \ + echo '\#ifdef __LP64__'; \ + echo '.quad __image_$(*F)_begin'; \ + echo '.quad __image_$(*F)_end'; \ + echo '.asciz "'$(*F)'"'; \ + echo '.org _u_boot_list_2_video_image_2_$(*F) + 16 + VIDEO_IMAGE_NAMELEN'; \ + echo '\#else'; \ + echo '.long __image_$(*F)_begin'; \ + echo '.long __image_$(*F)_end'; \ + echo '.asciz "'$(*F)'"'; \ + echo '.org _u_boot_list_2_video_image_2_$(*F) + 8 + VIDEO_IMAGE_NAMELEN'; \ + echo '\#endif'; \ +) > $@ + +ifneq ($(filter drivers/video/images,$(obj)),) +$(obj)/%.S: $(src)/%.bmp + $(call cmd,S_image) +endif + # Generate an assembly file to wrap the EFI 'Boot Graphics Resource Table' image quiet_cmd_S_bgrt= BGRT $@ # Modified for U-Boot