]> git.ipfire.org Git - people/ms/u-boot.git/blob - include/config_distro_bootcmd.h
dwc3: core: added an API to invoke irq handlers
[people/ms/u-boot.git] / include / config_distro_bootcmd.h
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 /*
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.
27 */
28
29 /* We need the part command */
30 #define CONFIG_PARTITION_UUIDS
31 #define CONFIG_CMD_PART
32
33 #define BOOTENV_SHARED_BLKDEV_BODY(devtypel) \
34 "if " #devtypel " dev ${devnum}; then " \
35 "setenv devtype " #devtypel "; " \
36 "run scan_dev_for_boot_part; " \
37 "fi\0"
38
39 #define BOOTENV_SHARED_BLKDEV(devtypel) \
40 #devtypel "_boot=" \
41 BOOTENV_SHARED_BLKDEV_BODY(devtypel)
42
43 #define BOOTENV_DEV_BLKDEV(devtypeu, devtypel, instance) \
44 "bootcmd_" #devtypel #instance "=" \
45 "setenv devnum " #instance "; " \
46 "run " #devtypel "_boot\0"
47
48 #define BOOTENV_DEV_NAME_BLKDEV(devtypeu, devtypel, instance) \
49 #devtypel #instance " "
50
51 #ifdef CONFIG_CMD_MMC
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
55 #else
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
61 #endif
62
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
67 #else
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
73 #endif
74
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 \
79 "scsi_init=" \
80 "if ${scsi_need_init}; then " \
81 "setenv scsi_need_init false; " \
82 "scsi scan; " \
83 "fi\0" \
84 \
85 "scsi_boot=" \
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
90 #else
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
98 #endif
99
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
104 #else
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
110 #endif
111
112 #ifdef CONFIG_CMD_USB
113 #define BOOTENV_RUN_USB_INIT "usb start; "
114 #define BOOTENV_SHARED_USB \
115 "usb_boot=" \
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
120 #else
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
127 #endif
128
129 #if defined(CONFIG_CMD_DHCP)
130 #define BOOTENV_DEV_DHCP(devtypeu, devtypel, instance) \
131 "bootcmd_dhcp=" \
132 BOOTENV_RUN_USB_INIT \
133 "if dhcp ${scriptaddr} ${boot_script_dhcp}; then " \
134 "source ${scriptaddr}; " \
135 "fi\0"
136 #define BOOTENV_DEV_NAME_DHCP(devtypeu, devtypel, instance) \
137 "dhcp "
138 #else
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
143 #endif
144
145 #if defined(CONFIG_CMD_DHCP) && defined(CONFIG_CMD_PXE)
146 #define BOOTENV_DEV_PXE(devtypeu, devtypel, instance) \
147 "bootcmd_pxe=" \
148 BOOTENV_RUN_USB_INIT \
149 "dhcp; " \
150 "if pxe get; then " \
151 "pxe boot; " \
152 "fi\0"
153 #define BOOTENV_DEV_NAME_PXE(devtypeu, devtypel, instance) \
154 "pxe "
155 #else
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
160 #endif
161
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"
166
167 #define BOOTENV_DEV(devtypeu, devtypel, instance) \
168 BOOTENV_DEV_##devtypeu(devtypeu, devtypel, instance)
169 #define BOOTENV \
170 BOOTENV_SHARED_MMC \
171 BOOTENV_SHARED_USB \
172 BOOTENV_SHARED_SATA \
173 BOOTENV_SHARED_SCSI \
174 BOOTENV_SHARED_IDE \
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 \
179 \
180 "boot_extlinux=" \
181 "sysboot ${devtype} ${devnum}:${bootpart} any " \
182 "${scriptaddr} ${prefix}extlinux/extlinux.conf\0" \
183 \
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...; " \
190 "fi\0" \
191 \
192 "boot_a_script=" \
193 "load ${devtype} ${devnum}:${bootpart} " \
194 "${scriptaddr} ${prefix}${script}; " \
195 "source ${scriptaddr}\0" \
196 \
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...; " \
205 "fi; " \
206 "done\0" \
207 \
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; " \
213 "done\0" \
214 \
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; " \
222 "fi; " \
223 "done\0" \
224 \
225 BOOT_TARGET_DEVICES(BOOTENV_DEV) \
226 \
227 "distro_bootcmd=" BOOTENV_SET_SCSI_NEED_INIT \
228 "for target in ${boot_targets}; do " \
229 "run bootcmd_${target}; " \
230 "done\0"
231
232 #ifndef CONFIG_BOOTCOMMAND
233 #define CONFIG_BOOTCOMMAND "run distro_bootcmd"
234 #endif
235
236 #endif /* _CONFIG_CMD_DISTRO_BOOTCMD_H */