From patchwork Wed Oct 1 23:05:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 469 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=1759359966; bh=Sx+RRCCii3LZ+p+oBg+Cvvxnti3iZF45GQFLDJQ7Z5g=; 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=mO5bEKkFLeAU4f+UVJxtnKCXzukcY6c1d4SCNzH8uH1/QqW1vprj6B11Yg36i5et+ cnDDO6ko6eaW3GgnQdELXoMlmZYViz/4d6QChlBrmFO2RD9aLKxSjMaKFkmadorm5u FFwfJjIKETvJpvBztsTcYVQeuKCZLazdATCMENHt7MX408vcuCjqWrdCOScxtaqYUD d30pWP2CA7QXfSsnlZJPOoKZ3QIA24FnRgcX8d+MjmQFNhKC3p8QaFhTevK9cRsTXy as9+DNagc87YnhrbUyhAiJAIyiLnQtO7TRDqNGe6c+rQT2DGobKEBYqF5ogVTlfAMe 6aMKvh0jY4qcg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3C5AA67EE8 for ; Wed, 1 Oct 2025 17:06:06 -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 eaF5X7LFpfjM for ; Wed, 1 Oct 2025 17:06:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759359966; bh=Sx+RRCCii3LZ+p+oBg+Cvvxnti3iZF45GQFLDJQ7Z5g=; 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=mO5bEKkFLeAU4f+UVJxtnKCXzukcY6c1d4SCNzH8uH1/QqW1vprj6B11Yg36i5et+ cnDDO6ko6eaW3GgnQdELXoMlmZYViz/4d6QChlBrmFO2RD9aLKxSjMaKFkmadorm5u FFwfJjIKETvJpvBztsTcYVQeuKCZLazdATCMENHt7MX408vcuCjqWrdCOScxtaqYUD d30pWP2CA7QXfSsnlZJPOoKZ3QIA24FnRgcX8d+MjmQFNhKC3p8QaFhTevK9cRsTXy as9+DNagc87YnhrbUyhAiJAIyiLnQtO7TRDqNGe6c+rQT2DGobKEBYqF5ogVTlfAMe 6aMKvh0jY4qcg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2B6BF67E4B for ; Wed, 1 Oct 2025 17:06:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759359964; bh=3mBb29K6roMm26EFRL0RDwnf1QO1KuQATr26Wi/Y2Ew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ngSmssqtFy2/6Cd/zcMUZBWwJbD1ndIlYTok/+rEeVBNfB5UGkKHu6//+M86sHliX JsZfcBanYqqCY/V2jDIOnbA0tVhj+v88dM0oYu1XAf8ENlkK4aIKipz3XjInlmYae9 7Xav6n8r+TRp+Sa5NhhIyGRRmz6D8bQ1iAACWr1KE844Y8Ww1WqIgCpWR6FZeElO18 rk6sAN91VPBq+3sKZw1i/5c4jU/8kr4qndM4OFxjj5kq3m/9XtYghKtwJ5n6QGyhkf 4mOQAovEcn4aRdVKMslqDq9ey8BiuG0H+8j9fLshY44rmomZ4ilcyW5uSIcdg8jFXJ yo2UKKYrXLIwg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2B0EA67E4B; Wed, 1 Oct 2025 17:06:04 -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 1j9ZurE4p2Ud; Wed, 1 Oct 2025 17:06:04 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759359958; bh=tOrceccj5EDkXFmr8IHjAtA9imVxKtAoxGq8046OPvo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ILqDHvm69uR1mFWro9UEPhe/9TRMmwkW6Fi5owskhhTiMNK2nZ68JJ/2j+1uFDp4q 7d16s653ce1YHMACGtexCCe8x+cRJZZCkFOswgrHTY+QAT+bABZAQErNwwjfw+bH9G DcipjBKV7DUJ8hzBbtR4vDHSMXPURaxfyiZ6ATpbqPQmfHazCaP8cDMKNN5IkO0+pC 2fSxg9SyDInPA8NbUPbrOgT8AIX7cnbhxPGEFb3jiIDcy9mp1PreOVe0sTNItve3FY O1awrT/0/FdArjHwd021GLkIsqQZwpt0c6ex2R9eXeZuthQT4LXc8A0Le5FkoflHvB ukpxGtFhHA8fw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E0B7567E44; Wed, 1 Oct 2025 17:05:57 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 1 Oct 2025 17:05:29 -0600 Message-ID: <20251001230537.3324058-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251001230537.3324058-1-sjg@u-boot.org> References: <20251001230537.3324058-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VMRPWYWCETMQDGCTLXAIFPNVFSOSTWHF X-Message-ID-Hash: VMRPWYWCETMQDGCTLXAIFPNVFSOSTWHF 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 3/6] 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 --- 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..35d6d7f1fd4 --- /dev/null +++ b/include/video_image.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2025 Google LLC + * 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