blob: becbe3fa7cc29c80d2236db1da62e2278a36ff98 [file] [log] [blame]
Dennis Gilmore2a432012014-07-30 16:37:14 -06001/*
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 "; " \
16 "run scan_dev_for_boot; " \
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 Goedea03bdaa2014-09-16 09:26:23 +020056#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 Gilmore2a432012014-07-30 16:37:14 -060068#define BOOTENV_DEV_SCSI BOOTENV_DEV_BLKDEV
69#define BOOTENV_DEV_NAME_SCSI BOOTENV_DEV_NAME_BLKDEV
70#else
Hans de Goedea03bdaa2014-09-16 09:26:23 +020071#define BOOTENV_RUN_SCSI_INIT
72#define BOOTENV_SET_SCSI_NEED_INIT
Dennis Gilmore2a432012014-07-30 16:37:14 -060073#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 Goedea1d31072015-01-06 14:27:42 +010093#define BOOTENV_RUN_USB_INIT "usb start; "
Dennis Gilmore2a432012014-07-30 16:37:14 -060094#define BOOTENV_SHARED_USB \
Dennis Gilmore2a432012014-07-30 16:37:14 -060095 "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 Gilmore2a432012014-07-30 16:37:14 -0600102#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 \
113 "if dhcp ${scriptaddr} boot.scr.uimg; then " \
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" \
157 BOOTENV_BOOT_TARGETS \
158 "bootpart=1\0" \
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=" \
189 "echo Scanning ${devtype} ${devnum}...; " \
190 "for prefix in ${boot_prefixes}; do " \
191 "run scan_dev_for_extlinux; " \
192 "run scan_dev_for_scripts; " \
193 "done\0" \
194 \
195 BOOT_TARGET_DEVICES(BOOTENV_DEV) \
196 \
Hans de Goedea1d31072015-01-06 14:27:42 +0100197 "bootcmd=" BOOTENV_SET_SCSI_NEED_INIT \
Dennis Gilmore2a432012014-07-30 16:37:14 -0600198 "for target in ${boot_targets}; do " \
199 "run bootcmd_${target}; " \
200 "done\0"
201
202#endif /* _CONFIG_CMD_DISTRO_BOOTCMD_H */