Dennis Gilmore | 2a43201 | 2014-07-30 16:37:14 -0600 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2014 |
| 3 | * NVIDIA Corporation <www.nvidia.com> |
| 4 | * |
| 5 | * Copyright 2014 Red Hat, Inc. |
| 6 | * |
| 7 | * SPDX-License-Identifier: GPL-2.0+ |
| 8 | */ |
| 9 | |
| 10 | #ifndef _CONFIG_CMD_DISTRO_BOOTCMD_H |
| 11 | #define _CONFIG_CMD_DISTRO_BOOTCMD_H |
| 12 | |
| 13 | #define BOOTENV_SHARED_BLKDEV_BODY(devtypel) \ |
| 14 | "if " #devtypel " dev ${devnum}; then " \ |
| 15 | "setenv devtype " #devtypel "; " \ |
Sjoerd Simons | 735b1cf | 2015-01-05 18:13:38 +0100 | [diff] [blame] | 16 | "run scan_dev_for_boot_part; " \ |
Dennis Gilmore | 2a43201 | 2014-07-30 16:37:14 -0600 | [diff] [blame] | 17 | "fi\0" |
| 18 | |
| 19 | #define BOOTENV_SHARED_BLKDEV(devtypel) \ |
| 20 | #devtypel "_boot=" \ |
| 21 | BOOTENV_SHARED_BLKDEV_BODY(devtypel) |
| 22 | |
| 23 | #define BOOTENV_DEV_BLKDEV(devtypeu, devtypel, instance) \ |
| 24 | "bootcmd_" #devtypel #instance "=" \ |
| 25 | "setenv devnum " #instance "; " \ |
| 26 | "run " #devtypel "_boot\0" |
| 27 | |
| 28 | #define BOOTENV_DEV_NAME_BLKDEV(devtypeu, devtypel, instance) \ |
| 29 | #devtypel #instance " " |
| 30 | |
| 31 | #ifdef CONFIG_CMD_MMC |
| 32 | #define BOOTENV_SHARED_MMC BOOTENV_SHARED_BLKDEV(mmc) |
| 33 | #define BOOTENV_DEV_MMC BOOTENV_DEV_BLKDEV |
| 34 | #define BOOTENV_DEV_NAME_MMC BOOTENV_DEV_NAME_BLKDEV |
| 35 | #else |
| 36 | #define BOOTENV_SHARED_MMC |
| 37 | #define BOOTENV_DEV_MMC \ |
| 38 | BOOT_TARGET_DEVICES_references_MMC_without_CONFIG_CMD_MMC |
| 39 | #define BOOTENV_DEV_NAME_MMC \ |
| 40 | BOOT_TARGET_DEVICES_references_MMC_without_CONFIG_CMD_MMC |
| 41 | #endif |
| 42 | |
| 43 | #ifdef CONFIG_CMD_SATA |
| 44 | #define BOOTENV_SHARED_SATA BOOTENV_SHARED_BLKDEV(sata) |
| 45 | #define BOOTENV_DEV_SATA BOOTENV_DEV_BLKDEV |
| 46 | #define BOOTENV_DEV_NAME_SATA BOOTENV_DEV_NAME_BLKDEV |
| 47 | #else |
| 48 | #define BOOTENV_SHARED_SATA |
| 49 | #define BOOTENV_DEV_SATA \ |
| 50 | BOOT_TARGET_DEVICES_references_SATA_without_CONFIG_CMD_SATA |
| 51 | #define BOOTENV_DEV_NAME_SATA \ |
| 52 | BOOT_TARGET_DEVICES_references_SATA_without_CONFIG_CMD_SATA |
| 53 | #endif |
| 54 | |
| 55 | #ifdef CONFIG_CMD_SCSI |
Hans de Goede | a03bdaa | 2014-09-16 09:26:23 +0200 | [diff] [blame] | 56 | #define BOOTENV_RUN_SCSI_INIT "run scsi_init; " |
| 57 | #define BOOTENV_SET_SCSI_NEED_INIT "setenv scsi_need_init; " |
| 58 | #define BOOTENV_SHARED_SCSI \ |
| 59 | "scsi_init=" \ |
| 60 | "if ${scsi_need_init}; then " \ |
| 61 | "setenv scsi_need_init false; " \ |
| 62 | "scsi scan; " \ |
| 63 | "fi\0" \ |
| 64 | \ |
| 65 | "scsi_boot=" \ |
| 66 | BOOTENV_RUN_SCSI_INIT \ |
| 67 | BOOTENV_SHARED_BLKDEV_BODY(scsi) |
Dennis Gilmore | 2a43201 | 2014-07-30 16:37:14 -0600 | [diff] [blame] | 68 | #define BOOTENV_DEV_SCSI BOOTENV_DEV_BLKDEV |
| 69 | #define BOOTENV_DEV_NAME_SCSI BOOTENV_DEV_NAME_BLKDEV |
| 70 | #else |
Hans de Goede | a03bdaa | 2014-09-16 09:26:23 +0200 | [diff] [blame] | 71 | #define BOOTENV_RUN_SCSI_INIT |
| 72 | #define BOOTENV_SET_SCSI_NEED_INIT |
Dennis Gilmore | 2a43201 | 2014-07-30 16:37:14 -0600 | [diff] [blame] | 73 | #define BOOTENV_SHARED_SCSI |
| 74 | #define BOOTENV_DEV_SCSI \ |
| 75 | BOOT_TARGET_DEVICES_references_SCSI_without_CONFIG_CMD_SCSI |
| 76 | #define BOOTENV_DEV_NAME_SCSI \ |
| 77 | BOOT_TARGET_DEVICES_references_SCSI_without_CONFIG_CMD_SCSI |
| 78 | #endif |
| 79 | |
| 80 | #ifdef CONFIG_CMD_IDE |
| 81 | #define BOOTENV_SHARED_IDE BOOTENV_SHARED_BLKDEV(ide) |
| 82 | #define BOOTENV_DEV_IDE BOOTENV_DEV_BLKDEV |
| 83 | #define BOOTENV_DEV_NAME_IDE BOOTENV_DEV_NAME_BLKDEV |
| 84 | #else |
| 85 | #define BOOTENV_SHARED_IDE |
| 86 | #define BOOTENV_DEV_IDE \ |
| 87 | BOOT_TARGET_DEVICES_references_IDE_without_CONFIG_CMD_IDE |
| 88 | #define BOOTENV_DEV_NAME_IDE \ |
| 89 | BOOT_TARGET_DEVICES_references_IDE_without_CONFIG_CMD_IDE |
| 90 | #endif |
| 91 | |
| 92 | #ifdef CONFIG_CMD_USB |
Hans de Goede | a1d3107 | 2015-01-06 14:27:42 +0100 | [diff] [blame] | 93 | #define BOOTENV_RUN_USB_INIT "usb start; " |
Dennis Gilmore | 2a43201 | 2014-07-30 16:37:14 -0600 | [diff] [blame] | 94 | #define BOOTENV_SHARED_USB \ |
Dennis Gilmore | 2a43201 | 2014-07-30 16:37:14 -0600 | [diff] [blame] | 95 | "usb_boot=" \ |
| 96 | BOOTENV_RUN_USB_INIT \ |
| 97 | BOOTENV_SHARED_BLKDEV_BODY(usb) |
| 98 | #define BOOTENV_DEV_USB BOOTENV_DEV_BLKDEV |
| 99 | #define BOOTENV_DEV_NAME_USB BOOTENV_DEV_NAME_BLKDEV |
| 100 | #else |
| 101 | #define BOOTENV_RUN_USB_INIT |
Dennis Gilmore | 2a43201 | 2014-07-30 16:37:14 -0600 | [diff] [blame] | 102 | #define BOOTENV_SHARED_USB |
| 103 | #define BOOTENV_DEV_USB \ |
| 104 | BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB |
| 105 | #define BOOTENV_DEV_NAME_USB \ |
| 106 | BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB |
| 107 | #endif |
| 108 | |
| 109 | #if defined(CONFIG_CMD_DHCP) |
| 110 | #define BOOTENV_DEV_DHCP(devtypeu, devtypel, instance) \ |
| 111 | "bootcmd_dhcp=" \ |
| 112 | BOOTENV_RUN_USB_INIT \ |
Stephen Warren | cc11b39 | 2015-01-19 16:39:11 -0700 | [diff] [blame] | 113 | "if dhcp ${scriptaddr} ${boot_script_dhcp}; then " \ |
Dennis Gilmore | 2a43201 | 2014-07-30 16:37:14 -0600 | [diff] [blame] | 114 | "source ${scriptaddr}; " \ |
| 115 | "fi\0" |
| 116 | #define BOOTENV_DEV_NAME_DHCP(devtypeu, devtypel, instance) \ |
| 117 | "dhcp " |
| 118 | #else |
| 119 | #define BOOTENV_DEV_DHCP \ |
| 120 | BOOT_TARGET_DEVICES_references_DHCP_without_CONFIG_CMD_DHCP |
| 121 | #define BOOTENV_DEV_NAME_DHCP \ |
| 122 | BOOT_TARGET_DEVICES_references_DHCP_without_CONFIG_CMD_DHCP |
| 123 | #endif |
| 124 | |
| 125 | #if defined(CONFIG_CMD_DHCP) && defined(CONFIG_CMD_PXE) |
| 126 | #define BOOTENV_DEV_PXE(devtypeu, devtypel, instance) \ |
| 127 | "bootcmd_pxe=" \ |
| 128 | BOOTENV_RUN_USB_INIT \ |
| 129 | "dhcp; " \ |
| 130 | "if pxe get; then " \ |
| 131 | "pxe boot; " \ |
| 132 | "fi\0" |
| 133 | #define BOOTENV_DEV_NAME_PXE(devtypeu, devtypel, instance) \ |
| 134 | "pxe " |
| 135 | #else |
| 136 | #define BOOTENV_DEV_PXE \ |
| 137 | BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE |
| 138 | #define BOOTENV_DEV_NAME_PXE \ |
| 139 | BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE |
| 140 | #endif |
| 141 | |
| 142 | #define BOOTENV_DEV_NAME(devtypeu, devtypel, instance) \ |
| 143 | BOOTENV_DEV_NAME_##devtypeu(devtypeu, devtypel, instance) |
| 144 | #define BOOTENV_BOOT_TARGETS \ |
| 145 | "boot_targets=" BOOT_TARGET_DEVICES(BOOTENV_DEV_NAME) "\0" |
| 146 | |
| 147 | #define BOOTENV_DEV(devtypeu, devtypel, instance) \ |
| 148 | BOOTENV_DEV_##devtypeu(devtypeu, devtypel, instance) |
| 149 | #define BOOTENV \ |
| 150 | BOOTENV_SHARED_MMC \ |
| 151 | BOOTENV_SHARED_USB \ |
| 152 | BOOTENV_SHARED_SATA \ |
| 153 | BOOTENV_SHARED_SCSI \ |
| 154 | BOOTENV_SHARED_IDE \ |
| 155 | "boot_prefixes=/ /boot/\0" \ |
| 156 | "boot_scripts=boot.scr.uimg boot.scr\0" \ |
Stephen Warren | cc11b39 | 2015-01-19 16:39:11 -0700 | [diff] [blame] | 157 | "boot_script_dhcp=boot.scr.uimg\0" \ |
Dennis Gilmore | 2a43201 | 2014-07-30 16:37:14 -0600 | [diff] [blame] | 158 | BOOTENV_BOOT_TARGETS \ |
Dennis Gilmore | 2a43201 | 2014-07-30 16:37:14 -0600 | [diff] [blame] | 159 | \ |
| 160 | "boot_extlinux=" \ |
| 161 | "sysboot ${devtype} ${devnum}:${bootpart} any " \ |
| 162 | "${scriptaddr} ${prefix}extlinux/extlinux.conf\0" \ |
| 163 | \ |
| 164 | "scan_dev_for_extlinux=" \ |
| 165 | "if test -e ${devtype} ${devnum}:${bootpart} " \ |
| 166 | "${prefix}extlinux/extlinux.conf; then " \ |
| 167 | "echo Found ${prefix}extlinux/extlinux.conf; " \ |
| 168 | "run boot_extlinux; " \ |
| 169 | "echo SCRIPT FAILED: continuing...; " \ |
| 170 | "fi\0" \ |
| 171 | \ |
| 172 | "boot_a_script=" \ |
| 173 | "load ${devtype} ${devnum}:${bootpart} " \ |
| 174 | "${scriptaddr} ${prefix}${script}; " \ |
| 175 | "source ${scriptaddr}\0" \ |
| 176 | \ |
| 177 | "scan_dev_for_scripts=" \ |
| 178 | "for script in ${boot_scripts}; do " \ |
| 179 | "if test -e ${devtype} ${devnum}:${bootpart} " \ |
| 180 | "${prefix}${script}; then " \ |
| 181 | "echo Found U-Boot script " \ |
| 182 | "${prefix}${script}; " \ |
| 183 | "run boot_a_script; " \ |
| 184 | "echo SCRIPT FAILED: continuing...; " \ |
| 185 | "fi; " \ |
| 186 | "done\0" \ |
| 187 | \ |
| 188 | "scan_dev_for_boot=" \ |
Sjoerd Simons | 735b1cf | 2015-01-05 18:13:38 +0100 | [diff] [blame] | 189 | "echo Scanning ${devtype} ${devnum}:${bootpart}...; " \ |
Dennis Gilmore | 2a43201 | 2014-07-30 16:37:14 -0600 | [diff] [blame] | 190 | "for prefix in ${boot_prefixes}; do " \ |
| 191 | "run scan_dev_for_extlinux; " \ |
| 192 | "run scan_dev_for_scripts; " \ |
| 193 | "done\0" \ |
| 194 | \ |
Sjoerd Simons | 735b1cf | 2015-01-05 18:13:38 +0100 | [diff] [blame] | 195 | "scan_dev_for_boot_part=" \ |
| 196 | "part list ${devtype} ${devnum} devplist; " \ |
| 197 | "for bootpart in ${devplist}; do " \ |
| 198 | "if fstype ${devtype} ${devnum}:${bootpart} " \ |
| 199 | "bootfstype; then " \ |
| 200 | "run scan_dev_for_boot; " \ |
| 201 | "fi; " \ |
| 202 | "done\0" \ |
| 203 | \ |
Dennis Gilmore | 2a43201 | 2014-07-30 16:37:14 -0600 | [diff] [blame] | 204 | BOOT_TARGET_DEVICES(BOOTENV_DEV) \ |
| 205 | \ |
Sjoerd Simons | 453c6cc | 2015-01-05 18:13:39 +0100 | [diff] [blame] | 206 | "distro_bootcmd=" BOOTENV_SET_SCSI_NEED_INIT \ |
Dennis Gilmore | 2a43201 | 2014-07-30 16:37:14 -0600 | [diff] [blame] | 207 | "for target in ${boot_targets}; do " \ |
| 208 | "run bootcmd_${target}; " \ |
| 209 | "done\0" |
| 210 | |
Sjoerd Simons | 453c6cc | 2015-01-05 18:13:39 +0100 | [diff] [blame] | 211 | #ifndef CONFIG_BOOTCOMMAND |
| 212 | #define CONFIG_BOOTCOMMAND "run distro_bootcmd" |
| 213 | #endif |
| 214 | |
Dennis Gilmore | 2a43201 | 2014-07-30 16:37:14 -0600 | [diff] [blame] | 215 | #endif /* _CONFIG_CMD_DISTRO_BOOTCMD_H */ |