From patchwork Thu Sep 4 13:04:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 20 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=1756991117; bh=FrSVxBvz01rCvHY0H/Mk09idRyhq8d+IqfhJ0K1NoHI=; h=From:To:Date:CC:Subject:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=DhdniUQ4GHVnfbq8WX5gfqe+xamzYQbt/1T3mXT3oSASANPso5LDaptgyL71C3z1/ g4ZEg+s+eTewomfM8kH9+XVNJg14AmCD/Hc+19iOh7d4b/CfzQ81qiwMSqcwgGhe6F Iw3sOWtZ+miEtDmn7ByEpGG2SRPqcEMFW3vCzsJBbYW8k9y5Wg58CSb2rC+es8UQGc QLMBnnlPdHj+VIIlX9lH/JSn5XCYFBdDsIOsxlUgSJ2dDQU+mynberlLX0dgJBz5u1 C5d7VhT45+6mLBF+QW8CeSpmo9Fkw7zTxBggw6xN1qUUx1PlT8yUqXxIEaYres865X ESJjOpksAi/sQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 11B8B6795D for ; Thu, 4 Sep 2025 07:05:17 -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 n-f-_--wUAep for ; Thu, 4 Sep 2025 07:05:17 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991116; bh=FrSVxBvz01rCvHY0H/Mk09idRyhq8d+IqfhJ0K1NoHI=; h=From:To:Date:CC:Subject:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=O8pgdFJuLhlHNS6HX7zuKMN/upPbAlrUP3qR86sgsJyZmCbqrkojtcd2S+GJ4dgd6 jcEr/AwduQ7FrtPXUud9U+hVzTcZJo+1jSvYGlPeP5782qaLXvrcyIjTa0lWqby2Xx YtrJB1Axg8EyHyJnF9eSXkwvHBYurc2KdJjLQpxut0ywgCNOB4LGS+hxE9IjwcbxJj Z4YhNXN56WYyOXc1iltjR1LIh9/LOZmEihSYQgxTkLMgwfXM2uhWTZtGVebPADeN22 zxNF2PzJzvECsq9Xt01D87HvXJiFs3iXmtMm5ztMlO3JbT++x7gLRIuZnYt20YXJzn swT9hbxAqUbLQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F153467886 for ; Thu, 4 Sep 2025 07:05:16 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991114; bh=M7L5waxiGvrE+Q+AxwNycsxiu6YvO2yMPQHJuN1UwkI=; h=From:To:Cc:Subject:Date:From; b=cpZgVP2gVhtGcVRvJ/QCXKlBhpKN4bxH7iWNwORjR0LscfcBf56ijPDEb4lgMYXIp twM19MBO2lx9RdEgqNb6+PZc58RpwrdHHTvCoWD85hrtZgMFLfDU20RQ8gzr1FkvBQ +K5ywRC+k38K9Fns49g3+075CrtdjdVpxqn4mLaXoRtxDDJPEUY4wDlaNTsHbnvY8e V4Ka20V7/NfAJd2sMMOa52TSPBqM0XwNI071PXXmVrNdY3OK6U3DxfWsCR4EubbNSi EDKEN0sGs1hcpMBlUPqkPquTv/g9UJAtJdcfL29CNFmqdieG6pA4qFS7URNYDykKRD aFgcZGHlLXxcw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2A27367886; Thu, 4 Sep 2025 07:05:14 -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 YltcN1zn-qOu; Thu, 4 Sep 2025 07:05:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991109; bh=mNLpdKiIQJFqfx7ea9KCUyCyj6/gWMmbdAZXMhNlwV0=; h=From:To:Cc:Subject:Date:From; b=mRjnIDzZWoPpUvxv+nZkijubM8yU/0N/bAYodUvxVc7woV+ErbPHwnF1TPLuopLLC UGzXhFMbYOesl7K08ukAJmWobUcXWbncGOPFvLJftVwyiX6/Gjuwo5FE9xWxwaIlMh g2K/pLUIaDnMD9MyYQvkRWmLbzt50oC+b0d5EC6utLoWgSA9JC72gTaznG0Mf4gSpq 7Hlso03lWJKkOqB1R81DyrRTT+YOA9R+5W7X5LkD3vgKQPyOHXFvG6yAL8G+b3I57V 7PWc9UgeC3aFkP4cqBOd4/QqeKtqLXFYDRMrjQh7UOiFY4NAPtayElZJhHM/1ouNnT KdOLnxRXyPyTg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 449F6678AB; Thu, 4 Sep 2025 07:05:09 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:33 -0600 Message-ID: <20250904130459.848794-1-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Message-ID-Hash: 4ALTCLFM22FS4DYOMNKTKKLSW7TNGU65 X-Message-ID-Hash: 4ALTCLFM22FS4DYOMNKTKKLSW7TNGU65 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 00/18] ulib: Introduce building U-Boot as a shared library 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 U-Boot is currently built as a monolithic binary. While there is an API of sorts, allowing U-Boot to be called from another program, it is not widely used. In some cases it is useful to write a separate program which is in control of the boot process, but uses U-Boot to implement some of the functionality. Some examples are: - Creating a main program written in a different language, such as Rust or Python - For Python specifically, an interface on top of U-Boot would permit direct execution of sandbox tests - For Rust specifically, it could make it feasible to progressively rewrite U-Boot in Rust, if that were desirable - For testing, it would permit tests to be in control of execution, rather than being embedded within U-Boot itself This series begins the progress of supporting U-Boot as a shared library. At this point the functionality is very limited: - it targets sandbox only - the test program simply starts U-Boot and boots to a prompt Future work will build on this meagre foundation. Simon Glass (18): doc: Add fuzzing build documentation board_r: Drop MMC init from the startup sequence sandbox: Avoid mon_len being larger than available RAM sandbox: Move PCI functions to separate header file sandbox: Move main.h contents into u-boot-sandbox header sandbox: Split main() into separate file sandbox: Extract init code into sandbox_init() ulib: Add an option to build U-Boot as a library ulib: Support building U-Boot as a shared library ulib: Create a test program for the shared library ulib: Add linker script for shared library build ulib: efi: Disable relocation or runtime-services ulib: Enable building the ulib test program ulib: Implement GD_FLG_ULIB for library-usage mode ulib: Drop the initial banner for the library ulib: Drop DRAM announcements for the library ulib: Allow dropping NAND init from the startup sequence ulib: Drop dm stats for the library Kconfig | 9 + Makefile | 31 ++- arch/sandbox/cpu/Makefile | 7 +- arch/sandbox/cpu/fuzz.c | 81 ++++++++ arch/sandbox/cpu/main.c | 11 ++ arch/sandbox/cpu/mem.c | 1 + arch/sandbox/cpu/os.c | 76 +------- arch/sandbox/cpu/start.c | 26 ++- arch/sandbox/cpu/u-boot-lib.lds | 88 +++++++++ arch/sandbox/include/asm/main.h | 18 -- arch/sandbox/include/asm/sandbox_pci.h | 61 ++++++ arch/sandbox/include/asm/u-boot-sandbox.h | 76 ++++---- common/board_f.c | 24 ++- common/board_r.c | 17 +- configs/tools-only_defconfig | 1 + doc/build/fuzz.rst | 219 ++++++++++++++++++++++ doc/build/index.rst | 1 + drivers/pci/pci-emul-uclass.c | 3 +- include/asm-generic/global_data.h | 12 ++ lib/display_options.c | 15 +- lib/efi_loader/efi_runtime.c | 4 + test/dm/pci.c | 1 + test/ulib/Makefile | 12 ++ test/ulib/ulib_test.c | 37 ++++ 24 files changed, 658 insertions(+), 173 deletions(-) create mode 100644 arch/sandbox/cpu/fuzz.c create mode 100644 arch/sandbox/cpu/main.c create mode 100644 arch/sandbox/cpu/u-boot-lib.lds delete mode 100644 arch/sandbox/include/asm/main.h create mode 100644 arch/sandbox/include/asm/sandbox_pci.h create mode 100644 doc/build/fuzz.rst create mode 100644 test/ulib/Makefile create mode 100644 test/ulib/ulib_test.c