3 * NVIDIA Corporation <www.nvidia.com>
5 * Copyright 2014 Red Hat, Inc.
7 * SPDX-License-Identifier: GPL-2.0+
10 #ifndef _CONFIG_CMD_DISTRO_BOOTCMD_H
11 #define _CONFIG_CMD_DISTRO_BOOTCMD_H
14 * A note on error handling: It is possible for BOOT_TARGET_DEVICES to
15 * reference a device that is not enabled in the U-Boot configuration, e.g.
16 * it may include MMC in the list without CONFIG_CMD_MMC being enabled. Given
17 * that BOOT_TARGET_DEVICES is a macro that's expanded by the C pre-processor
18 * at compile time, it's not possible to detect and report such problems via
19 * a simple #ifdef/#error combination. Still, the code needs to report errors.
20 * The best way I've found to do this is to make BOOT_TARGET_DEVICES expand to
21 * reference a non-existent symbol, and have the name of that symbol encode
22 * the error message. Consequently, this file contains references to e.g.
23 * BOOT_TARGET_DEVICES_references_MMC_without_CONFIG_CMD_MMC. Given the
24 * prevalence of capitals here, this looks like a pre-processor macro and
25 * hence seems like it should be all capitals, but it's really an error
26 * message that includes some other pre-processor symbols in the text.
29 /* We need the part command */
30 #define CONFIG_PARTITION_UUIDS
31 #define CONFIG_CMD_PART
33 #define BOOTENV_SHARED_BLKDEV_BODY(devtypel) \
34 "if " #devtypel " dev ${devnum}; then " \
35 "setenv devtype " #devtypel "; " \
36 "run scan_dev_for_boot_part; " \
39 #define BOOTENV_SHARED_BLKDEV(devtypel) \
41 BOOTENV_SHARED_BLKDEV_BODY(devtypel)
43 #define BOOTENV_DEV_BLKDEV(devtypeu, devtypel, instance) \
44 "bootcmd_" #devtypel #instance "=" \
45 "setenv devnum " #instance "; " \
46 "run " #devtypel "_boot\0"
48 #define BOOTENV_DEV_NAME_BLKDEV(devtypeu, devtypel, instance) \
49 #devtypel #instance " "
52 #define BOOTENV_SHARED_MMC BOOTENV_SHARED_BLKDEV(mmc)
53 #define BOOTENV_DEV_MMC BOOTENV_DEV_BLKDEV
54 #define BOOTENV_DEV_NAME_MMC BOOTENV_DEV_NAME_BLKDEV
56 #define BOOTENV_SHARED_MMC
57 #define BOOTENV_DEV_MMC \
58 BOOT_TARGET_DEVICES_references_MMC_without_CONFIG_CMD_MMC
59 #define BOOTENV_DEV_NAME_MMC \
60 BOOT_TARGET_DEVICES_references_MMC_without_CONFIG_CMD_MMC
63 #ifdef CONFIG_CMD_SATA
64 #define BOOTENV_SHARED_SATA BOOTENV_SHARED_BLKDEV(sata)
65 #define BOOTENV_DEV_SATA BOOTENV_DEV_BLKDEV
66 #define BOOTENV_DEV_NAME_SATA BOOTENV_DEV_NAME_BLKDEV
68 #define BOOTENV_SHARED_SATA
69 #define BOOTENV_DEV_SATA \
70 BOOT_TARGET_DEVICES_references_SATA_without_CONFIG_CMD_SATA
71 #define BOOTENV_DEV_NAME_SATA \
72 BOOT_TARGET_DEVICES_references_SATA_without_CONFIG_CMD_SATA
75 #ifdef CONFIG_CMD_SCSI
76 #define BOOTENV_RUN_SCSI_INIT "run scsi_init; "
77 #define BOOTENV_SET_SCSI_NEED_INIT "setenv scsi_need_init; "
78 #define BOOTENV_SHARED_SCSI \
80 "if ${scsi_need_init}; then " \
81 "setenv scsi_need_init false; " \
86 BOOTENV_RUN_SCSI_INIT \
87 BOOTENV_SHARED_BLKDEV_BODY(scsi)
88 #define BOOTENV_DEV_SCSI BOOTENV_DEV_BLKDEV
89 #define BOOTENV_DEV_NAME_SCSI BOOTENV_DEV_NAME_BLKDEV
91 #define BOOTENV_RUN_SCSI_INIT
92 #define BOOTENV_SET_SCSI_NEED_INIT
93 #define BOOTENV_SHARED_SCSI
94 #define BOOTENV_DEV_SCSI \
95 BOOT_TARGET_DEVICES_references_SCSI_without_CONFIG_CMD_SCSI
96 #define BOOTENV_DEV_NAME_SCSI \
97 BOOT_TARGET_DEVICES_references_SCSI_without_CONFIG_CMD_SCSI
100 #ifdef CONFIG_CMD_IDE
101 #define BOOTENV_SHARED_IDE BOOTENV_SHARED_BLKDEV(ide)
102 #define BOOTENV_DEV_IDE BOOTENV_DEV_BLKDEV
103 #define BOOTENV_DEV_NAME_IDE BOOTENV_DEV_NAME_BLKDEV
105 #define BOOTENV_SHARED_IDE
106 #define BOOTENV_DEV_IDE \
107 BOOT_TARGET_DEVICES_references_IDE_without_CONFIG_CMD_IDE
108 #define BOOTENV_DEV_NAME_IDE \
109 BOOT_TARGET_DEVICES_references_IDE_without_CONFIG_CMD_IDE
112 #ifdef CONFIG_CMD_USB
113 #define BOOTENV_RUN_USB_INIT "usb start; "
114 #define BOOTENV_SHARED_USB \
116 BOOTENV_RUN_USB_INIT \
117 BOOTENV_SHARED_BLKDEV_BODY(usb)
118 #define BOOTENV_DEV_USB BOOTENV_DEV_BLKDEV
119 #define BOOTENV_DEV_NAME_USB BOOTENV_DEV_NAME_BLKDEV
121 #define BOOTENV_RUN_USB_INIT
122 #define BOOTENV_SHARED_USB
123 #define BOOTENV_DEV_USB \
124 BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB
125 #define BOOTENV_DEV_NAME_USB \
126 BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB
129 #if defined(CONFIG_CMD_DHCP)
130 #define BOOTENV_DEV_DHCP(devtypeu, devtypel, instance) \
132 BOOTENV_RUN_USB_INIT \
133 "if dhcp ${scriptaddr} ${boot_script_dhcp}; then " \
134 "source ${scriptaddr}; " \
136 #define BOOTENV_DEV_NAME_DHCP(devtypeu, devtypel, instance) \
139 #define BOOTENV_DEV_DHCP \
140 BOOT_TARGET_DEVICES_references_DHCP_without_CONFIG_CMD_DHCP
141 #define BOOTENV_DEV_NAME_DHCP \
142 BOOT_TARGET_DEVICES_references_DHCP_without_CONFIG_CMD_DHCP
145 #if defined(CONFIG_CMD_DHCP) && defined(CONFIG_CMD_PXE)
146 #define BOOTENV_DEV_PXE(devtypeu, devtypel, instance) \
148 BOOTENV_RUN_USB_INIT \
150 "if pxe get; then " \
153 #define BOOTENV_DEV_NAME_PXE(devtypeu, devtypel, instance) \
156 #define BOOTENV_DEV_PXE \
157 BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE
158 #define BOOTENV_DEV_NAME_PXE \
159 BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE
162 #define BOOTENV_DEV_NAME(devtypeu, devtypel, instance) \
163 BOOTENV_DEV_NAME_##devtypeu(devtypeu, devtypel, instance)
164 #define BOOTENV_BOOT_TARGETS \
165 "boot_targets=" BOOT_TARGET_DEVICES(BOOTENV_DEV_NAME) "\0"
167 #define BOOTENV_DEV(devtypeu, devtypel, instance) \
168 BOOTENV_DEV_##devtypeu(devtypeu, devtypel, instance)
172 BOOTENV_SHARED_SATA \
173 BOOTENV_SHARED_SCSI \
175 "boot_prefixes=/ /boot/\0" \
176 "boot_scripts=boot.scr.uimg boot.scr\0" \
177 "boot_script_dhcp=boot.scr.uimg\0" \
178 BOOTENV_BOOT_TARGETS \
181 "sysboot ${devtype} ${devnum}:${bootpart} any " \
182 "${scriptaddr} ${prefix}extlinux/extlinux.conf\0" \
184 "scan_dev_for_extlinux=" \
185 "if test -e ${devtype} ${devnum}:${bootpart} " \
186 "${prefix}extlinux/extlinux.conf; then " \
187 "echo Found ${prefix}extlinux/extlinux.conf; " \
188 "run boot_extlinux; " \
189 "echo SCRIPT FAILED: continuing...; " \
193 "load ${devtype} ${devnum}:${bootpart} " \
194 "${scriptaddr} ${prefix}${script}; " \
195 "source ${scriptaddr}\0" \
197 "scan_dev_for_scripts=" \
198 "for script in ${boot_scripts}; do " \
199 "if test -e ${devtype} ${devnum}:${bootpart} " \
200 "${prefix}${script}; then " \
201 "echo Found U-Boot script " \
202 "${prefix}${script}; " \
203 "run boot_a_script; " \
204 "echo SCRIPT FAILED: continuing...; " \
208 "scan_dev_for_boot=" \
209 "echo Scanning ${devtype} ${devnum}:${bootpart}...; " \
210 "for prefix in ${boot_prefixes}; do " \
211 "run scan_dev_for_extlinux; " \
212 "run scan_dev_for_scripts; " \
215 "scan_dev_for_boot_part=" \
216 "part list ${devtype} ${devnum} -bootable devplist; " \
217 "env exists devplist || setenv devplist 1; " \
218 "for bootpart in ${devplist}; do " \
219 "if fstype ${devtype} ${devnum}:${bootpart} " \
220 "bootfstype; then " \
221 "run scan_dev_for_boot; " \
225 BOOT_TARGET_DEVICES(BOOTENV_DEV) \
227 "distro_bootcmd=" BOOTENV_SET_SCSI_NEED_INIT \
228 "for target in ${boot_targets}; do " \
229 "run bootcmd_${target}; " \
232 #ifndef CONFIG_BOOTCOMMAND
233 #define CONFIG_BOOTCOMMAND "run distro_bootcmd"
236 #endif /* _CONFIG_CMD_DISTRO_BOOTCMD_H */