From patchwork Thu Nov 16 04:10:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1864597 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=IAG9FXJ/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SW6Zq3jJSz1yRV for ; Thu, 16 Nov 2023 15:32:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3C05987045; Thu, 16 Nov 2023 05:32:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="IAG9FXJ/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 558CD8744D; Thu, 16 Nov 2023 05:11:22 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EA2B187438 for ; Thu, 16 Nov 2023 05:11:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-7afff3ea94dso12444639f.3 for ; Wed, 15 Nov 2023 20:11:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1700107877; x=1700712677; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=asXP4V5YoZAPdMymETvSzKr3a+LSYs95xd4SQKfHIKs=; b=IAG9FXJ/OmKqBQxsFQdkKVNOZYtjY1waRhC2P1XdQgnIkSgyI4VQlXjhsSWFaNFMo3 7hE1d53fHOiuKg/u9clhnN8oH1SMd7cF5OYHpDKi3jGdNOBCNeG2Jqnwd9JJtcWIlv74 cXFVcMhB1P/z4/yF91wbGqxAECNt55wK172Ek= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700107877; x=1700712677; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=asXP4V5YoZAPdMymETvSzKr3a+LSYs95xd4SQKfHIKs=; b=wuTtxHigC0E5NuFGsfmSzqPLXJgMkPvPE5zpvKmfyH2+ktGNhMZ8xzjVsqM9qn3PMD i380o60fpwwF4vRTCEEuMMVmNQM8j3z1lH9ElREwRraKSZibORAS5Jd39axguKUW6JUD UfCdAX+oRyKOzBrnXc2KXoDNsCNNurnLZc8Ocqi5eZovtZm5rQJdIDe+GpFN32uMKN+F 7C3PV3pFvUGh65EhppCsswGBEOzDgUQOSmZAclXqwwL64SHwwO5njGPavwrAls6aCaO2 9psQ19bBxLWqB2YP0fOU7D3B9TRnDSncgGd9z8lzTBoWZj8OQfwsOo9CF/PloY24kxTS Bivg== X-Gm-Message-State: AOJu0YzQQtdnolPYhdDcnUCIw31kWfZm/QatsYCzCJzjDlLS8MUKKr6Y plhW8aVXu1luXO8BxboI8g3Zdnb5UckFq/1chTfkUw== X-Google-Smtp-Source: AGHT+IGJTuE4H/HvKTph7N+MKnM1YPUdSmrUCx6suqiyN0o4IkQqZE1p5BYOFIuCHlSFgwfxwV71Lg== X-Received: by 2002:a05:6602:164a:b0:7a6:a3b1:b45c with SMTP id y10-20020a056602164a00b007a6a3b1b45cmr21658253iow.14.1700107877472; Wed, 15 Nov 2023 20:11:17 -0800 (PST) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id f3-20020a02a803000000b0045a1063713asm1307527jaj.130.2023.11.15.20.11.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 20:11:17 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Heinrich Schuchardt , Tom Rini , Simon Glass , Albert Aribaud , Alexander Gendin , Baruch Siach , Bin Meng , Eddie James , Evgeny Bachinin , Fabio Estevam , Ivan Mikhaylov , Jaehoon Chung , Jerry Van Baren , Joe Hershberger , Linus Walleij , =?utf-8?q?Marek_Beh=C3=BAn?= , Marek Vasut , Marek Vasut , Mattijs Korpershoek , Michal Simek , "NXP i.MX U-Boot Team" , Peng Fan , Qu Wenruo , Safae Ouajih , Sean Anderson , Sean Anderson , Stefano Babic , Stephen Carlson , This contributor prefers not to receive mails , Tim Harvey , Tobias Waldekranz , linux-btrfs@vger.kernel.org Subject: [PATCH v2 00/32] bootm: Refactoring to reduce reliance on CMDLINE (part A) Date: Wed, 15 Nov 2023 21:10:00 -0700 Message-ID: <20231116041043.362055-1-sjg@chromium.org> X-Mailer: git-send-email 2.43.0.rc0.421.g78406f8d94-goog MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 16 Nov 2023 05:32:30 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean It would be useful to be able to boot an OS when CONFIG_CMDLINE is disabled. This could allow reduced code size. Standard boot provides a way to handle programmatic boot, without scripts, so such a feature is possible. The main impediment is the inability to use the booting features of U-Boot without a command line. So the solution is to avoid passing command arguments and the like to code in boot/ A similar process has taken place with filesystems, for example, where we have (somewhat) separate Kconfig options for the filesystem commands and the filesystems themselves. This series starts the process of refactoring the bootm logic so that it can be called from standard boot without using the command line. Mostly it removes the use of argc, argv and cmdtbl from the internal logic. Some limited tidy-up is included, but this is kept to smaller patches, rather than trying to remove all #ifdefs etc. Some function comments are added, however. A simple programmatic boot is provided as a starting point. This work will likely take many series, so this is just the start. Size growth with this series for firefly-rk3288 (Thumb2) is: arm: (for 1/1 boards) all +23.0 rodata -49.0 text +72.0 This should be removed by: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/11 but it is not included in this series as it is already large enough. No functional change is intended in this series. Changes in v2: - Add new patch to adjust position of unmap_sysmem() in boot_get_kernel() - Add new patch to obtain command arguments - Fix 'boot_find_os' typo - Pass in the command name - Use the command table to provide the command name, instead of "bootm" Simon Glass (32): arm: x86: Drop discarding of command linker-lists README: Correct docs for CONFIG_SPL_BUILD mmc: env: Unify the U_BOOT_ENV_LOCATION conditions treewide: Tidy up semicolon after command macros bootstd: Add missing header file from bootdev.h bootstd: Introduce programmable boot bootm: Drop arguments from bootm_start() bootm: Simplify arguments for bootm_pre_load() bootm: Move boot_get_kernel() higher in the file image: Tidy up genimg_get_kernel_addr_fit() bootm: Reduce arguments to boot_get_kernel() image: Document error codes from fit_image_load() bootm: Adjust boot_get_kernel() to return an error bootm: Adjust position of unmap_sysmem() in boot_get_kernel() bootm: Use the error return from boot_get_kernel() bootstage: Drop BOOTSTAGE_ID_FIT_KERNEL_INFO bootm: Move error printing out of boot_get_kernel() bootm: Reduce arguments to bootm_find_os() bootm: Reduce arguments to boot_get_ramdisk() fdt: Allow use of fdt_support inside if() statements bootm: Drop #ifdef in bootm_find_images() bootm: Pass image buffer to boot_get_fdt() bootm: Reduce arguments to boot_get_fdt() bootm: Reduce arguments to boot_get_fpga() bootm: Reduce arguments to boot_get_loadables() bootm: Simplify Android ramdisk addr in bootm_find_images() bootm: efi: Drop special call to bootm_find_other() bootm: optee: Drop special call to bootm_find_other() bootm: Adjust the parameters of bootm_find_images() bootm: Add a function to check overlap bootm: Reduce arguments to bootm_find_other() RFC: command: Introduce functions to obtain command arguments README | 26 +- arch/arm/cpu/u-boot.lds | 3 - arch/x86/cpu/u-boot-64.lds | 4 - arch/x86/cpu/u-boot-spl.lds | 4 - arch/x86/cpu/u-boot.lds | 4 - board/freescale/common/vid.c | 2 +- board/xilinx/common/fru.c | 2 +- board/xilinx/versal/cmds.c | 2 +- board/xilinx/zynqmp/cmds.c | 2 +- boot/Kconfig | 11 + boot/Makefile | 2 + boot/bootm.c | 577 +++++++++++++++++++---------------- boot/bootm_os.c | 16 - boot/image-board.c | 67 +--- boot/image-fdt.c | 39 +-- boot/prog_boot.c | 51 ++++ cmd/booti.c | 4 +- cmd/bootz.c | 4 +- cmd/btrfs.c | 2 +- cmd/disk.c | 4 +- cmd/eeprom.c | 2 +- cmd/ext2.c | 4 +- cmd/fs.c | 8 +- cmd/fuse.c | 2 +- cmd/mmc.c | 2 +- cmd/pinmux.c | 2 +- cmd/qfw.c | 2 +- common/main.c | 9 + drivers/misc/gsc.c | 6 +- env/mmc.c | 2 +- fs/fs.c | 4 +- include/bootdev.h | 1 + include/bootm.h | 26 +- include/bootstage.h | 1 - include/bootstd.h | 9 + include/command.h | 35 ++- include/fdt_support.h | 5 +- include/image.h | 127 ++++++-- test/cmd_ut.c | 2 +- 39 files changed, 612 insertions(+), 463 deletions(-) create mode 100644 boot/prog_boot.c