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
13 #define BOOTENV_SHARED_BLKDEV_BODY(devtypel) \
14 "if " #devtypel " dev ${devnum}; then " \
15 "setenv devtype " #devtypel "; " \
16 "run scan_dev_for_boot; " \
19 #define BOOTENV_SHARED_BLKDEV(devtypel) \
21 BOOTENV_SHARED_BLKDEV_BODY(devtypel)
23 #define BOOTENV_DEV_BLKDEV(devtypeu, devtypel, instance) \
24 "bootcmd_" #devtypel #instance "=" \
25 "setenv devnum " #instance "; " \
26 "run " #devtypel "_boot\0"
28 #define BOOTENV_DEV_NAME_BLKDEV(devtypeu, devtypel, instance) \
29 #devtypel #instance " "
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
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
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
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
55 #ifdef CONFIG_CMD_SCSI
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 \
60 "if ${scsi_need_init}; then " \
61 "setenv scsi_need_init false; " \
66 BOOTENV_RUN_SCSI_INIT \
67 BOOTENV_SHARED_BLKDEV_BODY(scsi)
68 #define BOOTENV_DEV_SCSI BOOTENV_DEV_BLKDEV
69 #define BOOTENV_DEV_NAME_SCSI BOOTENV_DEV_NAME_BLKDEV
71 #define BOOTENV_RUN_SCSI_INIT
72 #define BOOTENV_SET_SCSI_NEED_INIT
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
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
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
93 #define BOOTENV_RUN_USB_INIT "run usb_init; "
94 #define BOOTENV_SET_USB_NEED_INIT "setenv usb_need_init; "
95 #define BOOTENV_SHARED_USB \
97 "if ${usb_need_init}; then " \
98 "setenv usb_need_init false; " \
103 BOOTENV_RUN_USB_INIT \
104 BOOTENV_SHARED_BLKDEV_BODY(usb)
105 #define BOOTENV_DEV_USB BOOTENV_DEV_BLKDEV
106 #define BOOTENV_DEV_NAME_USB BOOTENV_DEV_NAME_BLKDEV
108 #define BOOTENV_RUN_USB_INIT
109 #define BOOTENV_SET_USB_NEED_INIT
110 #define BOOTENV_SHARED_USB
111 #define BOOTENV_DEV_USB \
112 BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB
113 #define BOOTENV_DEV_NAME_USB \
114 BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB
117 #if defined(CONFIG_CMD_DHCP)
118 #define BOOTENV_DEV_DHCP(devtypeu, devtypel, instance) \
120 BOOTENV_RUN_USB_INIT \
121 "if dhcp ${scriptaddr} boot.scr.uimg; then " \
122 "source ${scriptaddr}; " \
124 #define BOOTENV_DEV_NAME_DHCP(devtypeu, devtypel, instance) \
127 #define BOOTENV_DEV_DHCP \
128 BOOT_TARGET_DEVICES_references_DHCP_without_CONFIG_CMD_DHCP
129 #define BOOTENV_DEV_NAME_DHCP \
130 BOOT_TARGET_DEVICES_references_DHCP_without_CONFIG_CMD_DHCP
133 #if defined(CONFIG_CMD_DHCP) && defined(CONFIG_CMD_PXE)
134 #define BOOTENV_DEV_PXE(devtypeu, devtypel, instance) \
136 BOOTENV_RUN_USB_INIT \
138 "if pxe get; then " \
141 #define BOOTENV_DEV_NAME_PXE(devtypeu, devtypel, instance) \
144 #define BOOTENV_DEV_PXE \
145 BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE
146 #define BOOTENV_DEV_NAME_PXE \
147 BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE
150 #define BOOTENV_DEV_NAME(devtypeu, devtypel, instance) \
151 BOOTENV_DEV_NAME_##devtypeu(devtypeu, devtypel, instance)
152 #define BOOTENV_BOOT_TARGETS \
153 "boot_targets=" BOOT_TARGET_DEVICES(BOOTENV_DEV_NAME) "\0"
155 #define BOOTENV_DEV(devtypeu, devtypel, instance) \
156 BOOTENV_DEV_##devtypeu(devtypeu, devtypel, instance)
160 BOOTENV_SHARED_SATA \
161 BOOTENV_SHARED_SCSI \
163 "boot_prefixes=/ /boot/\0" \
164 "boot_scripts=boot.scr.uimg boot.scr\0" \
165 BOOTENV_BOOT_TARGETS \
169 "sysboot ${devtype} ${devnum}:${bootpart} any " \
170 "${scriptaddr} ${prefix}extlinux/extlinux.conf\0" \
172 "scan_dev_for_extlinux=" \
173 "if test -e ${devtype} ${devnum}:${bootpart} " \
174 "${prefix}extlinux/extlinux.conf; then " \
175 "echo Found ${prefix}extlinux/extlinux.conf; " \
176 "run boot_extlinux; " \
177 "echo SCRIPT FAILED: continuing...; " \
181 "load ${devtype} ${devnum}:${bootpart} " \
182 "${scriptaddr} ${prefix}${script}; " \
183 "source ${scriptaddr}\0" \
185 "scan_dev_for_scripts=" \
186 "for script in ${boot_scripts}; do " \
187 "if test -e ${devtype} ${devnum}:${bootpart} " \
188 "${prefix}${script}; then " \
189 "echo Found U-Boot script " \
190 "${prefix}${script}; " \
191 "run boot_a_script; " \
192 "echo SCRIPT FAILED: continuing...; " \
196 "scan_dev_for_boot=" \
197 "echo Scanning ${devtype} ${devnum}...; " \
198 "for prefix in ${boot_prefixes}; do " \
199 "run scan_dev_for_extlinux; " \
200 "run scan_dev_for_scripts; " \
203 BOOT_TARGET_DEVICES(BOOTENV_DEV) \
205 "bootcmd=" BOOTENV_SET_USB_NEED_INIT BOOTENV_SET_SCSI_NEED_INIT \
206 "for target in ${boot_targets}; do " \
207 "run bootcmd_${target}; " \
210 #endif /* _CONFIG_CMD_DISTRO_BOOTCMD_H */