183d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */ 22a43201aSDennis Gilmore /* 32a43201aSDennis Gilmore * (C) Copyright 2014 42a43201aSDennis Gilmore * NVIDIA Corporation <www.nvidia.com> 52a43201aSDennis Gilmore * 62a43201aSDennis Gilmore * Copyright 2014 Red Hat, Inc. 72a43201aSDennis Gilmore */ 82a43201aSDennis Gilmore 92a43201aSDennis Gilmore #ifndef _CONFIG_CMD_DISTRO_BOOTCMD_H 102a43201aSDennis Gilmore #define _CONFIG_CMD_DISTRO_BOOTCMD_H 112a43201aSDennis Gilmore 1290b7caafSStephen Warren /* 1390b7caafSStephen Warren * A note on error handling: It is possible for BOOT_TARGET_DEVICES to 1490b7caafSStephen Warren * reference a device that is not enabled in the U-Boot configuration, e.g. 1590b7caafSStephen Warren * it may include MMC in the list without CONFIG_CMD_MMC being enabled. Given 1690b7caafSStephen Warren * that BOOT_TARGET_DEVICES is a macro that's expanded by the C pre-processor 1790b7caafSStephen Warren * at compile time, it's not possible to detect and report such problems via 1890b7caafSStephen Warren * a simple #ifdef/#error combination. Still, the code needs to report errors. 1990b7caafSStephen Warren * The best way I've found to do this is to make BOOT_TARGET_DEVICES expand to 2090b7caafSStephen Warren * reference a non-existent symbol, and have the name of that symbol encode 2190b7caafSStephen Warren * the error message. Consequently, this file contains references to e.g. 2290b7caafSStephen Warren * BOOT_TARGET_DEVICES_references_MMC_without_CONFIG_CMD_MMC. Given the 2390b7caafSStephen Warren * prevalence of capitals here, this looks like a pre-processor macro and 2490b7caafSStephen Warren * hence seems like it should be all capitals, but it's really an error 2590b7caafSStephen Warren * message that includes some other pre-processor symbols in the text. 2690b7caafSStephen Warren */ 2790b7caafSStephen Warren 282a43201aSDennis Gilmore #define BOOTENV_SHARED_BLKDEV_BODY(devtypel) \ 292a43201aSDennis Gilmore "if " #devtypel " dev ${devnum}; then " \ 30*13dd6665SAKASHI Takahiro "devtype=" #devtypel "; " \ 31735b1cfeSSjoerd Simons "run scan_dev_for_boot_part; " \ 322a43201aSDennis Gilmore "fi\0" 332a43201aSDennis Gilmore 342a43201aSDennis Gilmore #define BOOTENV_SHARED_BLKDEV(devtypel) \ 352a43201aSDennis Gilmore #devtypel "_boot=" \ 362a43201aSDennis Gilmore BOOTENV_SHARED_BLKDEV_BODY(devtypel) 372a43201aSDennis Gilmore 382a43201aSDennis Gilmore #define BOOTENV_DEV_BLKDEV(devtypeu, devtypel, instance) \ 392a43201aSDennis Gilmore "bootcmd_" #devtypel #instance "=" \ 40*13dd6665SAKASHI Takahiro "devnum=" #instance "; " \ 412a43201aSDennis Gilmore "run " #devtypel "_boot\0" 422a43201aSDennis Gilmore 432a43201aSDennis Gilmore #define BOOTENV_DEV_NAME_BLKDEV(devtypeu, devtypel, instance) \ 442a43201aSDennis Gilmore #devtypel #instance " " 452a43201aSDennis Gilmore 46d0bce0d1SSjoerd Simons #ifdef CONFIG_SANDBOX 47d0bce0d1SSjoerd Simons #define BOOTENV_SHARED_HOST BOOTENV_SHARED_BLKDEV(host) 48d0bce0d1SSjoerd Simons #define BOOTENV_DEV_HOST BOOTENV_DEV_BLKDEV 49d0bce0d1SSjoerd Simons #define BOOTENV_DEV_NAME_HOST BOOTENV_DEV_NAME_BLKDEV 50d0bce0d1SSjoerd Simons #else 51d0bce0d1SSjoerd Simons #define BOOTENV_SHARED_HOST 52d0bce0d1SSjoerd Simons #define BOOTENV_DEV_HOST \ 53d0bce0d1SSjoerd Simons BOOT_TARGET_DEVICES_references_HOST_without_CONFIG_SANDBOX 54d0bce0d1SSjoerd Simons #define BOOTENV_DEV_NAME_HOST \ 55d0bce0d1SSjoerd Simons BOOT_TARGET_DEVICES_references_HOST_without_CONFIG_SANDBOX 56d0bce0d1SSjoerd Simons #endif 57d0bce0d1SSjoerd Simons 582a43201aSDennis Gilmore #ifdef CONFIG_CMD_MMC 592a43201aSDennis Gilmore #define BOOTENV_SHARED_MMC BOOTENV_SHARED_BLKDEV(mmc) 602a43201aSDennis Gilmore #define BOOTENV_DEV_MMC BOOTENV_DEV_BLKDEV 612a43201aSDennis Gilmore #define BOOTENV_DEV_NAME_MMC BOOTENV_DEV_NAME_BLKDEV 622a43201aSDennis Gilmore #else 632a43201aSDennis Gilmore #define BOOTENV_SHARED_MMC 642a43201aSDennis Gilmore #define BOOTENV_DEV_MMC \ 652a43201aSDennis Gilmore BOOT_TARGET_DEVICES_references_MMC_without_CONFIG_CMD_MMC 662a43201aSDennis Gilmore #define BOOTENV_DEV_NAME_MMC \ 672a43201aSDennis Gilmore BOOT_TARGET_DEVICES_references_MMC_without_CONFIG_CMD_MMC 682a43201aSDennis Gilmore #endif 692a43201aSDennis Gilmore 7040d21547SRoy Spliet #ifdef CONFIG_CMD_UBIFS 7140d21547SRoy Spliet #define BOOTENV_SHARED_UBIFS \ 7240d21547SRoy Spliet "ubifs_boot=" \ 736e1364feSDerald D. Woods "env exists bootubipart || " \ 746e1364feSDerald D. Woods "env set bootubipart UBI; " \ 756e1364feSDerald D. Woods "env exists bootubivol || " \ 766e1364feSDerald D. Woods "env set bootubivol boot; " \ 776e1364feSDerald D. Woods "if ubi part ${bootubipart} && " \ 786e1364feSDerald D. Woods "ubifsmount ubi${devnum}:${bootubivol}; " \ 796e1364feSDerald D. Woods "then " \ 80*13dd6665SAKASHI Takahiro "devtype=ubi; " \ 8140d21547SRoy Spliet "run scan_dev_for_boot; " \ 8240d21547SRoy Spliet "fi\0" 8340d21547SRoy Spliet #define BOOTENV_DEV_UBIFS BOOTENV_DEV_BLKDEV 8440d21547SRoy Spliet #define BOOTENV_DEV_NAME_UBIFS BOOTENV_DEV_NAME_BLKDEV 8540d21547SRoy Spliet #else 8640d21547SRoy Spliet #define BOOTENV_SHARED_UBIFS 8740d21547SRoy Spliet #define BOOTENV_DEV_UBIFS \ 8840d21547SRoy Spliet BOOT_TARGET_DEVICES_references_UBIFS_without_CONFIG_CMD_UBIFS 8940d21547SRoy Spliet #define BOOTENV_DEV_NAME_UBIFS \ 9040d21547SRoy Spliet BOOT_TARGET_DEVICES_references_UBIFS_without_CONFIG_CMD_UBIFS 9140d21547SRoy Spliet #endif 9240d21547SRoy Spliet 9374522c89SAlexander Graf #ifdef CONFIG_EFI_LOADER 9474522c89SAlexander Graf #if defined(CONFIG_ARM64) 9574522c89SAlexander Graf #define BOOTEFI_NAME "bootaa64.efi" 9674522c89SAlexander Graf #elif defined(CONFIG_ARM) 9774522c89SAlexander Graf #define BOOTEFI_NAME "bootarm.efi" 98a53fbf40SHeinrich Schuchardt #elif defined(CONFIG_X86_RUN_32BIT) 99a53fbf40SHeinrich Schuchardt #define BOOTEFI_NAME "bootia32.efi" 100a53fbf40SHeinrich Schuchardt #elif defined(CONFIG_X86_RUN_64BIT) 101a53fbf40SHeinrich Schuchardt #define BOOTEFI_NAME "bootx64.efi" 102862e2e75SLukas Auer #elif defined(CONFIG_ARCH_RV32I) 1032c6903faSAlexander Graf #define BOOTEFI_NAME "bootriscv32.efi" 104862e2e75SLukas Auer #elif defined(CONFIG_ARCH_RV64I) 1052c6903faSAlexander Graf #define BOOTEFI_NAME "bootriscv64.efi" 10674522c89SAlexander Graf #endif 10774522c89SAlexander Graf #endif 10874522c89SAlexander Graf 10974522c89SAlexander Graf #ifdef BOOTEFI_NAME 110ff2545abSAlexander Graf #if defined(CONFIG_ARM) && !defined(CONFIG_ARM64) 111ff2545abSAlexander Graf /* 112ff2545abSAlexander Graf * On 32bit ARM systems there is a reasonable number of systems that follow 113ff2545abSAlexander Graf * the $soc-$board$boardver.dtb name scheme for their device trees. Use that 114ff2545abSAlexander Graf * scheme if we don't have an explicit fdtfile variable. 115ff2545abSAlexander Graf */ 116ff2545abSAlexander Graf #define BOOTENV_EFI_SET_FDTFILE_FALLBACK \ 117ff2545abSAlexander Graf "if test -z \"${fdtfile}\" -a -n \"${soc}\"; then " \ 118ff2545abSAlexander Graf "setenv efi_fdtfile ${soc}-${board}${boardver}.dtb; " \ 119ff2545abSAlexander Graf "fi; " 120ff2545abSAlexander Graf #else 121ff2545abSAlexander Graf #define BOOTENV_EFI_SET_FDTFILE_FALLBACK 122ff2545abSAlexander Graf #endif 123ff2545abSAlexander Graf 124ff2545abSAlexander Graf 12574522c89SAlexander Graf #define BOOTENV_SHARED_EFI \ 12674522c89SAlexander Graf "boot_efi_binary=" \ 1279975fe96SRob Clark "if fdt addr ${fdt_addr_r}; then " \ 1289975fe96SRob Clark "bootefi bootmgr ${fdt_addr_r};" \ 1299975fe96SRob Clark "else " \ 1309975fe96SRob Clark "bootefi bootmgr ${fdtcontroladdr};" \ 1319975fe96SRob Clark "fi;" \ 13274522c89SAlexander Graf "load ${devtype} ${devnum}:${distro_bootpart} " \ 13374522c89SAlexander Graf "${kernel_addr_r} efi/boot/"BOOTEFI_NAME"; " \ 1341c39809bSAlexander Graf "if fdt addr ${fdt_addr_r}; then " \ 1351c39809bSAlexander Graf "bootefi ${kernel_addr_r} ${fdt_addr_r};" \ 1361c39809bSAlexander Graf "else " \ 1371c39809bSAlexander Graf "bootefi ${kernel_addr_r} ${fdtcontroladdr};" \ 1381c39809bSAlexander Graf "fi\0" \ 13974522c89SAlexander Graf \ 14074522c89SAlexander Graf "load_efi_dtb=" \ 14174522c89SAlexander Graf "load ${devtype} ${devnum}:${distro_bootpart} " \ 142ff2545abSAlexander Graf "${fdt_addr_r} ${prefix}${efi_fdtfile}\0" \ 14374522c89SAlexander Graf \ 14474522c89SAlexander Graf "efi_dtb_prefixes=/ /dtb/ /dtb/current/\0" \ 14574522c89SAlexander Graf "scan_dev_for_efi=" \ 146ff2545abSAlexander Graf "setenv efi_fdtfile ${fdtfile}; " \ 147ff2545abSAlexander Graf BOOTENV_EFI_SET_FDTFILE_FALLBACK \ 14874522c89SAlexander Graf "for prefix in ${efi_dtb_prefixes}; do " \ 14974522c89SAlexander Graf "if test -e ${devtype} " \ 15074522c89SAlexander Graf "${devnum}:${distro_bootpart} " \ 151ff2545abSAlexander Graf "${prefix}${efi_fdtfile}; then " \ 15274522c89SAlexander Graf "run load_efi_dtb; " \ 15374522c89SAlexander Graf "fi;" \ 15474522c89SAlexander Graf "done;" \ 15574522c89SAlexander Graf "if test -e ${devtype} ${devnum}:${distro_bootpart} " \ 15674522c89SAlexander Graf "efi/boot/"BOOTEFI_NAME"; then " \ 15774522c89SAlexander Graf "echo Found EFI removable media binary " \ 15874522c89SAlexander Graf "efi/boot/"BOOTEFI_NAME"; " \ 15974522c89SAlexander Graf "run boot_efi_binary; " \ 16074522c89SAlexander Graf "echo EFI LOAD FAILED: continuing...; " \ 161ff2545abSAlexander Graf "fi; " \ 162ff2545abSAlexander Graf "setenv efi_fdtfile\0" 16374522c89SAlexander Graf #define SCAN_DEV_FOR_EFI "run scan_dev_for_efi;" 16474522c89SAlexander Graf #else 16574522c89SAlexander Graf #define BOOTENV_SHARED_EFI 16674522c89SAlexander Graf #define SCAN_DEV_FOR_EFI 16774522c89SAlexander Graf #endif 16874522c89SAlexander Graf 16910e40d54SSimon Glass #ifdef CONFIG_SATA 1702a43201aSDennis Gilmore #define BOOTENV_SHARED_SATA BOOTENV_SHARED_BLKDEV(sata) 1712a43201aSDennis Gilmore #define BOOTENV_DEV_SATA BOOTENV_DEV_BLKDEV 1722a43201aSDennis Gilmore #define BOOTENV_DEV_NAME_SATA BOOTENV_DEV_NAME_BLKDEV 1732a43201aSDennis Gilmore #else 1742a43201aSDennis Gilmore #define BOOTENV_SHARED_SATA 1752a43201aSDennis Gilmore #define BOOTENV_DEV_SATA \ 17610e40d54SSimon Glass BOOT_TARGET_DEVICES_references_SATA_without_CONFIG_SATA 1772a43201aSDennis Gilmore #define BOOTENV_DEV_NAME_SATA \ 17810e40d54SSimon Glass BOOT_TARGET_DEVICES_references_SATA_without_CONFIG_SATA 1792a43201aSDennis Gilmore #endif 1802a43201aSDennis Gilmore 1819493e39cSHeinrich Schuchardt #ifdef CONFIG_NVME 1829493e39cSHeinrich Schuchardt #define BOOTENV_RUN_NVME_INIT "run nvme_init; " 1839493e39cSHeinrich Schuchardt #define BOOTENV_SET_NVME_NEED_INIT "setenv nvme_need_init; " 1849493e39cSHeinrich Schuchardt #define BOOTENV_SHARED_NVME \ 1859493e39cSHeinrich Schuchardt "nvme_init=" \ 1869493e39cSHeinrich Schuchardt "if ${nvme_need_init}; then " \ 1879493e39cSHeinrich Schuchardt "setenv nvme_need_init false; " \ 1889493e39cSHeinrich Schuchardt "nvme scan; " \ 1899493e39cSHeinrich Schuchardt "fi\0" \ 1909493e39cSHeinrich Schuchardt \ 1919493e39cSHeinrich Schuchardt "nvme_boot=" \ 1929493e39cSHeinrich Schuchardt BOOTENV_RUN_NVME_INIT \ 1939493e39cSHeinrich Schuchardt BOOTENV_SHARED_BLKDEV_BODY(nvme) 1949493e39cSHeinrich Schuchardt #define BOOTENV_DEV_NVME BOOTENV_DEV_BLKDEV 1959493e39cSHeinrich Schuchardt #define BOOTENV_DEV_NAME_NVME BOOTENV_DEV_NAME_BLKDEV 1969493e39cSHeinrich Schuchardt #else 1979493e39cSHeinrich Schuchardt #define BOOTENV_RUN_NVME_INIT 1989493e39cSHeinrich Schuchardt #define BOOTENV_SET_NVME_NEED_INIT 1999493e39cSHeinrich Schuchardt #define BOOTENV_SHARED_NVME 2009493e39cSHeinrich Schuchardt #define BOOTENV_DEV_NVME \ 2019493e39cSHeinrich Schuchardt BOOT_TARGET_DEVICES_references_NVME_without_CONFIG_NVME 2029493e39cSHeinrich Schuchardt #define BOOTENV_DEV_NAME_NVME \ 2039493e39cSHeinrich Schuchardt BOOT_TARGET_DEVICES_references_NVME_without_CONFIG_NVME 2049493e39cSHeinrich Schuchardt #endif 2059493e39cSHeinrich Schuchardt 206c649e3c9SSimon Glass #ifdef CONFIG_SCSI 207a03bdaa1SHans de Goede #define BOOTENV_RUN_SCSI_INIT "run scsi_init; " 208*13dd6665SAKASHI Takahiro #define BOOTENV_SET_SCSI_NEED_INIT "scsi_need_init=; " 209a03bdaa1SHans de Goede #define BOOTENV_SHARED_SCSI \ 210a03bdaa1SHans de Goede "scsi_init=" \ 211a03bdaa1SHans de Goede "if ${scsi_need_init}; then " \ 212*13dd6665SAKASHI Takahiro "scsi_need_init=false; " \ 213a03bdaa1SHans de Goede "scsi scan; " \ 214a03bdaa1SHans de Goede "fi\0" \ 215a03bdaa1SHans de Goede \ 216a03bdaa1SHans de Goede "scsi_boot=" \ 217a03bdaa1SHans de Goede BOOTENV_RUN_SCSI_INIT \ 218a03bdaa1SHans de Goede BOOTENV_SHARED_BLKDEV_BODY(scsi) 2192a43201aSDennis Gilmore #define BOOTENV_DEV_SCSI BOOTENV_DEV_BLKDEV 2202a43201aSDennis Gilmore #define BOOTENV_DEV_NAME_SCSI BOOTENV_DEV_NAME_BLKDEV 2212a43201aSDennis Gilmore #else 222a03bdaa1SHans de Goede #define BOOTENV_RUN_SCSI_INIT 223a03bdaa1SHans de Goede #define BOOTENV_SET_SCSI_NEED_INIT 2242a43201aSDennis Gilmore #define BOOTENV_SHARED_SCSI 2252a43201aSDennis Gilmore #define BOOTENV_DEV_SCSI \ 226c649e3c9SSimon Glass BOOT_TARGET_DEVICES_references_SCSI_without_CONFIG_SCSI 2272a43201aSDennis Gilmore #define BOOTENV_DEV_NAME_SCSI \ 228c649e3c9SSimon Glass BOOT_TARGET_DEVICES_references_SCSI_without_CONFIG_SCSI 2292a43201aSDennis Gilmore #endif 2302a43201aSDennis Gilmore 231fc843a02SSimon Glass #ifdef CONFIG_IDE 2322a43201aSDennis Gilmore #define BOOTENV_SHARED_IDE BOOTENV_SHARED_BLKDEV(ide) 2332a43201aSDennis Gilmore #define BOOTENV_DEV_IDE BOOTENV_DEV_BLKDEV 2342a43201aSDennis Gilmore #define BOOTENV_DEV_NAME_IDE BOOTENV_DEV_NAME_BLKDEV 2352a43201aSDennis Gilmore #else 2362a43201aSDennis Gilmore #define BOOTENV_SHARED_IDE 2372a43201aSDennis Gilmore #define BOOTENV_DEV_IDE \ 238fc843a02SSimon Glass BOOT_TARGET_DEVICES_references_IDE_without_CONFIG_IDE 2392a43201aSDennis Gilmore #define BOOTENV_DEV_NAME_IDE \ 240fc843a02SSimon Glass BOOT_TARGET_DEVICES_references_IDE_without_CONFIG_IDE 2412a43201aSDennis Gilmore #endif 2422a43201aSDennis Gilmore 24318642424SSimon Glass #if defined(CONFIG_DM_PCI) 244986691fbSStephen Warren #define BOOTENV_RUN_NET_PCI_ENUM "run boot_net_pci_enum; " 245986691fbSStephen Warren #define BOOTENV_SHARED_PCI \ 246986691fbSStephen Warren "boot_net_pci_enum=pci enum\0" 247986691fbSStephen Warren #else 248986691fbSStephen Warren #define BOOTENV_RUN_NET_PCI_ENUM 249986691fbSStephen Warren #define BOOTENV_SHARED_PCI 250986691fbSStephen Warren #endif 251986691fbSStephen Warren 2522a43201aSDennis Gilmore #ifdef CONFIG_CMD_USB 2533483b75dSStephen Warren #define BOOTENV_RUN_NET_USB_START "run boot_net_usb_start; " 2542a43201aSDennis Gilmore #define BOOTENV_SHARED_USB \ 2553483b75dSStephen Warren "boot_net_usb_start=usb start\0" \ 2562a43201aSDennis Gilmore "usb_boot=" \ 2573483b75dSStephen Warren "usb start; " \ 2582a43201aSDennis Gilmore BOOTENV_SHARED_BLKDEV_BODY(usb) 2592a43201aSDennis Gilmore #define BOOTENV_DEV_USB BOOTENV_DEV_BLKDEV 2602a43201aSDennis Gilmore #define BOOTENV_DEV_NAME_USB BOOTENV_DEV_NAME_BLKDEV 2612a43201aSDennis Gilmore #else 2623483b75dSStephen Warren #define BOOTENV_RUN_NET_USB_START 2632a43201aSDennis Gilmore #define BOOTENV_SHARED_USB 2642a43201aSDennis Gilmore #define BOOTENV_DEV_USB \ 2652a43201aSDennis Gilmore BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB 2662a43201aSDennis Gilmore #define BOOTENV_DEV_NAME_USB \ 2672a43201aSDennis Gilmore BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB 2682a43201aSDennis Gilmore #endif 2692a43201aSDennis Gilmore 270a8da9ff4SLukas Auer #ifdef CONFIG_CMD_VIRTIO 271a8da9ff4SLukas Auer #define BOOTENV_SHARED_VIRTIO BOOTENV_SHARED_BLKDEV(virtio) 272a8da9ff4SLukas Auer #define BOOTENV_DEV_VIRTIO BOOTENV_DEV_BLKDEV 273a8da9ff4SLukas Auer #define BOOTENV_DEV_NAME_VIRTIO BOOTENV_DEV_NAME_BLKDEV 274a8da9ff4SLukas Auer #else 275a8da9ff4SLukas Auer #define BOOTENV_SHARED_VIRTIO 276a8da9ff4SLukas Auer #define BOOTENV_DEV_VIRTIO \ 277a8da9ff4SLukas Auer BOOT_TARGET_DEVICES_references_VIRTIO_without_CONFIG_CMD_VIRTIO 278a8da9ff4SLukas Auer #define BOOTENV_DEV_NAME_VIRTIO \ 279a8da9ff4SLukas Auer BOOT_TARGET_DEVICES_references_VIRTIO_without_CONFIG_CMD_VIRTIO 280a8da9ff4SLukas Auer #endif 281a8da9ff4SLukas Auer 2822a43201aSDennis Gilmore #if defined(CONFIG_CMD_DHCP) 28320898ea9SAlexander Graf #if defined(CONFIG_EFI_LOADER) 2842c6903faSAlexander Graf /* http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml */ 285a4958a71SSimon Glass #if defined(CONFIG_ARM64) || defined(__aarch64__) 28620898ea9SAlexander Graf #define BOOTENV_EFI_PXE_ARCH "0xb" 28720898ea9SAlexander Graf #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00011:UNDI:003000" 288a4958a71SSimon Glass #elif defined(CONFIG_ARM) || defined(__arm__) 28920898ea9SAlexander Graf #define BOOTENV_EFI_PXE_ARCH "0xa" 29020898ea9SAlexander Graf #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00010:UNDI:003000" 291a4958a71SSimon Glass #elif defined(CONFIG_X86) || defined(__x86_64__) 29220898ea9SAlexander Graf #define BOOTENV_EFI_PXE_ARCH "0x7" 29320898ea9SAlexander Graf #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00007:UNDI:003000" 294a4958a71SSimon Glass #elif defined(__i386__) 295a4958a71SSimon Glass #define BOOTENV_EFI_PXE_ARCH "0x6" 296a4958a71SSimon Glass #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00006:UNDI:003000" 297862e2e75SLukas Auer #elif defined(CONFIG_ARCH_RV32I) || ((defined(__riscv) && __riscv_xlen == 32)) 2982c6903faSAlexander Graf #define BOOTENV_EFI_PXE_ARCH "0x19" 2992c6903faSAlexander Graf #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00025:UNDI:003000" 300862e2e75SLukas Auer #elif defined(CONFIG_ARCH_RV64I) || ((defined(__riscv) && __riscv_xlen == 64)) 3012c6903faSAlexander Graf #define BOOTENV_EFI_PXE_ARCH "0x1b" 3022c6903faSAlexander Graf #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00027:UNDI:003000" 303a4958a71SSimon Glass #elif defined(CONFIG_SANDBOX) 304a4958a71SSimon Glass # error "sandbox EFI support is only supported on ARM and x86" 30520898ea9SAlexander Graf #else 30620898ea9SAlexander Graf #error Please specify an EFI client identifier 30720898ea9SAlexander Graf #endif 30820898ea9SAlexander Graf 30920898ea9SAlexander Graf /* 31020898ea9SAlexander Graf * Ask the dhcp server for an EFI binary. If we get one, check for a 31120898ea9SAlexander Graf * device tree in the same folder. Then boot everything. If the file was 31220898ea9SAlexander Graf * not an EFI binary, we just return from the bootefi command and continue. 31320898ea9SAlexander Graf */ 31420898ea9SAlexander Graf #define BOOTENV_EFI_RUN_DHCP \ 31520898ea9SAlexander Graf "setenv efi_fdtfile ${fdtfile}; " \ 31620898ea9SAlexander Graf BOOTENV_EFI_SET_FDTFILE_FALLBACK \ 31720898ea9SAlexander Graf "setenv efi_old_vci ${bootp_vci};" \ 31820898ea9SAlexander Graf "setenv efi_old_arch ${bootp_arch};" \ 31920898ea9SAlexander Graf "setenv bootp_vci " BOOTENV_EFI_PXE_VCI ";" \ 32020898ea9SAlexander Graf "setenv bootp_arch " BOOTENV_EFI_PXE_ARCH ";" \ 32120898ea9SAlexander Graf "if dhcp ${kernel_addr_r}; then " \ 32220898ea9SAlexander Graf "tftpboot ${fdt_addr_r} dtb/${efi_fdtfile};" \ 32320898ea9SAlexander Graf "if fdt addr ${fdt_addr_r}; then " \ 32420898ea9SAlexander Graf "bootefi ${kernel_addr_r} ${fdt_addr_r}; " \ 32520898ea9SAlexander Graf "else " \ 32620898ea9SAlexander Graf "bootefi ${kernel_addr_r} ${fdtcontroladdr};" \ 32720898ea9SAlexander Graf "fi;" \ 32820898ea9SAlexander Graf "fi;" \ 32920898ea9SAlexander Graf "setenv bootp_vci ${efi_old_vci};" \ 33020898ea9SAlexander Graf "setenv bootp_arch ${efi_old_arch};" \ 33120898ea9SAlexander Graf "setenv efi_fdtfile;" \ 33220898ea9SAlexander Graf "setenv efi_old_arch;" \ 33320898ea9SAlexander Graf "setenv efi_old_vci;" 33420898ea9SAlexander Graf #else 33520898ea9SAlexander Graf #define BOOTENV_EFI_RUN_DHCP 33620898ea9SAlexander Graf #endif 3372a43201aSDennis Gilmore #define BOOTENV_DEV_DHCP(devtypeu, devtypel, instance) \ 3382a43201aSDennis Gilmore "bootcmd_dhcp=" \ 3393483b75dSStephen Warren BOOTENV_RUN_NET_USB_START \ 340986691fbSStephen Warren BOOTENV_RUN_NET_PCI_ENUM \ 341cc11b392SStephen Warren "if dhcp ${scriptaddr} ${boot_script_dhcp}; then " \ 3422a43201aSDennis Gilmore "source ${scriptaddr}; " \ 34320898ea9SAlexander Graf "fi;" \ 34420898ea9SAlexander Graf BOOTENV_EFI_RUN_DHCP \ 34520898ea9SAlexander Graf "\0" 3462a43201aSDennis Gilmore #define BOOTENV_DEV_NAME_DHCP(devtypeu, devtypel, instance) \ 3472a43201aSDennis Gilmore "dhcp " 3482a43201aSDennis Gilmore #else 3492a43201aSDennis Gilmore #define BOOTENV_DEV_DHCP \ 3502a43201aSDennis Gilmore BOOT_TARGET_DEVICES_references_DHCP_without_CONFIG_CMD_DHCP 3512a43201aSDennis Gilmore #define BOOTENV_DEV_NAME_DHCP \ 3522a43201aSDennis Gilmore BOOT_TARGET_DEVICES_references_DHCP_without_CONFIG_CMD_DHCP 3532a43201aSDennis Gilmore #endif 3542a43201aSDennis Gilmore 3552a43201aSDennis Gilmore #if defined(CONFIG_CMD_DHCP) && defined(CONFIG_CMD_PXE) 3562a43201aSDennis Gilmore #define BOOTENV_DEV_PXE(devtypeu, devtypel, instance) \ 3572a43201aSDennis Gilmore "bootcmd_pxe=" \ 3583483b75dSStephen Warren BOOTENV_RUN_NET_USB_START \ 359986691fbSStephen Warren BOOTENV_RUN_NET_PCI_ENUM \ 3602a43201aSDennis Gilmore "dhcp; " \ 3612a43201aSDennis Gilmore "if pxe get; then " \ 3622a43201aSDennis Gilmore "pxe boot; " \ 3632a43201aSDennis Gilmore "fi\0" 3642a43201aSDennis Gilmore #define BOOTENV_DEV_NAME_PXE(devtypeu, devtypel, instance) \ 3652a43201aSDennis Gilmore "pxe " 3662a43201aSDennis Gilmore #else 3672a43201aSDennis Gilmore #define BOOTENV_DEV_PXE \ 3682a43201aSDennis Gilmore BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE 3692a43201aSDennis Gilmore #define BOOTENV_DEV_NAME_PXE \ 3702a43201aSDennis Gilmore BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE 3712a43201aSDennis Gilmore #endif 3722a43201aSDennis Gilmore 3732a43201aSDennis Gilmore #define BOOTENV_DEV_NAME(devtypeu, devtypel, instance) \ 3742a43201aSDennis Gilmore BOOTENV_DEV_NAME_##devtypeu(devtypeu, devtypel, instance) 3752a43201aSDennis Gilmore #define BOOTENV_BOOT_TARGETS \ 3762a43201aSDennis Gilmore "boot_targets=" BOOT_TARGET_DEVICES(BOOTENV_DEV_NAME) "\0" 3772a43201aSDennis Gilmore 3782a43201aSDennis Gilmore #define BOOTENV_DEV(devtypeu, devtypel, instance) \ 3792a43201aSDennis Gilmore BOOTENV_DEV_##devtypeu(devtypeu, devtypel, instance) 3802a43201aSDennis Gilmore #define BOOTENV \ 381d0bce0d1SSjoerd Simons BOOTENV_SHARED_HOST \ 3822a43201aSDennis Gilmore BOOTENV_SHARED_MMC \ 383986691fbSStephen Warren BOOTENV_SHARED_PCI \ 3842a43201aSDennis Gilmore BOOTENV_SHARED_USB \ 3852a43201aSDennis Gilmore BOOTENV_SHARED_SATA \ 3862a43201aSDennis Gilmore BOOTENV_SHARED_SCSI \ 3879493e39cSHeinrich Schuchardt BOOTENV_SHARED_NVME \ 3882a43201aSDennis Gilmore BOOTENV_SHARED_IDE \ 38940d21547SRoy Spliet BOOTENV_SHARED_UBIFS \ 39074522c89SAlexander Graf BOOTENV_SHARED_EFI \ 391a8da9ff4SLukas Auer BOOTENV_SHARED_VIRTIO \ 3922a43201aSDennis Gilmore "boot_prefixes=/ /boot/\0" \ 3932a43201aSDennis Gilmore "boot_scripts=boot.scr.uimg boot.scr\0" \ 394cc11b392SStephen Warren "boot_script_dhcp=boot.scr.uimg\0" \ 3952a43201aSDennis Gilmore BOOTENV_BOOT_TARGETS \ 3962a43201aSDennis Gilmore \ 397ad5fbc6eSMartyn Welch "boot_syslinux_conf=extlinux/extlinux.conf\0" \ 3982a43201aSDennis Gilmore "boot_extlinux=" \ 39959d03cb3SSjoerd Simons "sysboot ${devtype} ${devnum}:${distro_bootpart} any " \ 400ad5fbc6eSMartyn Welch "${scriptaddr} ${prefix}${boot_syslinux_conf}\0" \ 4012a43201aSDennis Gilmore \ 4022a43201aSDennis Gilmore "scan_dev_for_extlinux=" \ 40359d03cb3SSjoerd Simons "if test -e ${devtype} " \ 40459d03cb3SSjoerd Simons "${devnum}:${distro_bootpart} " \ 405ad5fbc6eSMartyn Welch "${prefix}${boot_syslinux_conf}; then " \ 406ad5fbc6eSMartyn Welch "echo Found ${prefix}${boot_syslinux_conf}; " \ 4072a43201aSDennis Gilmore "run boot_extlinux; " \ 4082a43201aSDennis Gilmore "echo SCRIPT FAILED: continuing...; " \ 4092a43201aSDennis Gilmore "fi\0" \ 4102a43201aSDennis Gilmore \ 4112a43201aSDennis Gilmore "boot_a_script=" \ 41259d03cb3SSjoerd Simons "load ${devtype} ${devnum}:${distro_bootpart} " \ 4132a43201aSDennis Gilmore "${scriptaddr} ${prefix}${script}; " \ 4142a43201aSDennis Gilmore "source ${scriptaddr}\0" \ 4152a43201aSDennis Gilmore \ 4162a43201aSDennis Gilmore "scan_dev_for_scripts=" \ 4172a43201aSDennis Gilmore "for script in ${boot_scripts}; do " \ 41859d03cb3SSjoerd Simons "if test -e ${devtype} " \ 41959d03cb3SSjoerd Simons "${devnum}:${distro_bootpart} " \ 4202a43201aSDennis Gilmore "${prefix}${script}; then " \ 4212a43201aSDennis Gilmore "echo Found U-Boot script " \ 4222a43201aSDennis Gilmore "${prefix}${script}; " \ 4232a43201aSDennis Gilmore "run boot_a_script; " \ 4242a43201aSDennis Gilmore "echo SCRIPT FAILED: continuing...; " \ 4252a43201aSDennis Gilmore "fi; " \ 4262a43201aSDennis Gilmore "done\0" \ 4272a43201aSDennis Gilmore \ 4282a43201aSDennis Gilmore "scan_dev_for_boot=" \ 42959d03cb3SSjoerd Simons "echo Scanning ${devtype} " \ 43059d03cb3SSjoerd Simons "${devnum}:${distro_bootpart}...; " \ 4312a43201aSDennis Gilmore "for prefix in ${boot_prefixes}; do " \ 4322a43201aSDennis Gilmore "run scan_dev_for_extlinux; " \ 4332a43201aSDennis Gilmore "run scan_dev_for_scripts; " \ 43474522c89SAlexander Graf "done;" \ 43574522c89SAlexander Graf SCAN_DEV_FOR_EFI \ 43674522c89SAlexander Graf "\0" \ 4372a43201aSDennis Gilmore \ 438735b1cfeSSjoerd Simons "scan_dev_for_boot_part=" \ 439f643d929SSjoerd Simons "part list ${devtype} ${devnum} -bootable devplist; " \ 440f643d929SSjoerd Simons "env exists devplist || setenv devplist 1; " \ 44159d03cb3SSjoerd Simons "for distro_bootpart in ${devplist}; do " \ 44259d03cb3SSjoerd Simons "if fstype ${devtype} " \ 44359d03cb3SSjoerd Simons "${devnum}:${distro_bootpart} " \ 444735b1cfeSSjoerd Simons "bootfstype; then " \ 445735b1cfeSSjoerd Simons "run scan_dev_for_boot; " \ 446735b1cfeSSjoerd Simons "fi; " \ 447*13dd6665SAKASHI Takahiro "done; " \ 448*13dd6665SAKASHI Takahiro "setenv devplist\0" \ 449735b1cfeSSjoerd Simons \ 4502a43201aSDennis Gilmore BOOT_TARGET_DEVICES(BOOTENV_DEV) \ 4512a43201aSDennis Gilmore \ 452453c6cc1SSjoerd Simons "distro_bootcmd=" BOOTENV_SET_SCSI_NEED_INIT \ 4539493e39cSHeinrich Schuchardt BOOTENV_SET_NVME_NEED_INIT \ 4542a43201aSDennis Gilmore "for target in ${boot_targets}; do " \ 4552a43201aSDennis Gilmore "run bootcmd_${target}; " \ 4562a43201aSDennis Gilmore "done\0" 4572a43201aSDennis Gilmore 458453c6cc1SSjoerd Simons #ifndef CONFIG_BOOTCOMMAND 459453c6cc1SSjoerd Simons #define CONFIG_BOOTCOMMAND "run distro_bootcmd" 460453c6cc1SSjoerd Simons #endif 461453c6cc1SSjoerd Simons 4622a43201aSDennis Gilmore #endif /* _CONFIG_CMD_DISTRO_BOOTCMD_H */ 463