config_distro_bootcmd.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2014
  4. * NVIDIA Corporation <www.nvidia.com>
  5. *
  6. * Copyright 2014 Red Hat, Inc.
  7. */
  8. #ifndef _CONFIG_CMD_DISTRO_BOOTCMD_H
  9. #define _CONFIG_CMD_DISTRO_BOOTCMD_H
  10. /*
  11. * A note on error handling: It is possible for BOOT_TARGET_DEVICES to
  12. * reference a device that is not enabled in the U-Boot configuration, e.g.
  13. * it may include MMC in the list without CONFIG_CMD_MMC being enabled. Given
  14. * that BOOT_TARGET_DEVICES is a macro that's expanded by the C pre-processor
  15. * at compile time, it's not possible to detect and report such problems via
  16. * a simple #ifdef/#error combination. Still, the code needs to report errors.
  17. * The best way I've found to do this is to make BOOT_TARGET_DEVICES expand to
  18. * reference a non-existent symbol, and have the name of that symbol encode
  19. * the error message. Consequently, this file contains references to e.g.
  20. * BOOT_TARGET_DEVICES_references_MMC_without_CONFIG_CMD_MMC. Given the
  21. * prevalence of capitals here, this looks like a pre-processor macro and
  22. * hence seems like it should be all capitals, but it's really an error
  23. * message that includes some other pre-processor symbols in the text.
  24. */
  25. #define BOOTENV_SHARED_BLKDEV_BODY(devtypel) \
  26. "if " #devtypel " dev ${devnum}; then " \
  27. "devtype=" #devtypel "; " \
  28. "run scan_dev_for_boot_part; " \
  29. "fi\0"
  30. #define BOOTENV_SHARED_BLKDEV(devtypel) \
  31. #devtypel "_boot=" \
  32. BOOTENV_SHARED_BLKDEV_BODY(devtypel)
  33. #define BOOTENV_DEV_BLKDEV_NONE(devtypeu, devtypel, instance)
  34. #define BOOTENV_DEV_BLKDEV(devtypeu, devtypel, instance) \
  35. "bootcmd_" #devtypel #instance "=" \
  36. "devnum=" #instance "; " \
  37. "run " #devtypel "_boot\0"
  38. #define BOOTENV_DEV_NAME_BLKDEV_NONE(devtypeu, devtypel, instance)
  39. #define BOOTENV_DEV_NAME_BLKDEV(devtypeu, devtypel, instance) \
  40. #devtypel #instance " "
  41. #ifdef CONFIG_SANDBOX
  42. #define BOOTENV_SHARED_HOST BOOTENV_SHARED_BLKDEV(host)
  43. #define BOOTENV_DEV_HOST BOOTENV_DEV_BLKDEV
  44. #define BOOTENV_DEV_NAME_HOST BOOTENV_DEV_NAME_BLKDEV
  45. #else
  46. #define BOOTENV_SHARED_HOST
  47. #define BOOTENV_DEV_HOST \
  48. BOOT_TARGET_DEVICES_references_HOST_without_CONFIG_SANDBOX
  49. #define BOOTENV_DEV_NAME_HOST \
  50. BOOT_TARGET_DEVICES_references_HOST_without_CONFIG_SANDBOX
  51. #endif
  52. #ifdef CONFIG_CMD_MMC
  53. #define BOOTENV_SHARED_MMC BOOTENV_SHARED_BLKDEV(mmc)
  54. #define BOOTENV_DEV_MMC BOOTENV_DEV_BLKDEV
  55. #define BOOTENV_DEV_NAME_MMC BOOTENV_DEV_NAME_BLKDEV
  56. #elif defined(CONFIG_SPL_BUILD)
  57. #define BOOTENV_SHARED_MMC
  58. #define BOOTENV_DEV_MMC BOOTENV_DEV_BLKDEV_NONE
  59. #define BOOTENV_DEV_NAME_MMC BOOTENV_DEV_NAME_BLKDEV_NONE
  60. #else
  61. #define BOOTENV_SHARED_MMC
  62. #define BOOTENV_DEV_MMC \
  63. BOOT_TARGET_DEVICES_references_MMC_without_CONFIG_CMD_MMC
  64. #define BOOTENV_DEV_NAME_MMC \
  65. BOOT_TARGET_DEVICES_references_MMC_without_CONFIG_CMD_MMC
  66. #endif
  67. #ifdef CONFIG_CMD_UBIFS
  68. #define BOOTENV_SHARED_UBIFS \
  69. "ubifs_boot=" \
  70. "if ubi part ${bootubipart} ${bootubioff} && " \
  71. "ubifsmount ubi0:${bootubivol}; " \
  72. "then " \
  73. "devtype=ubi; " \
  74. "devnum=ubi0; " \
  75. "bootfstype=ubifs; " \
  76. "distro_bootpart=${bootubivol}; " \
  77. "run scan_dev_for_boot; " \
  78. "ubifsumount; " \
  79. "fi\0"
  80. #define BOOTENV_DEV_UBIFS_BOOTUBIOFF(off) #off /* type check, throw error when called with more args */
  81. #define BOOTENV_DEV_UBIFS(devtypeu, devtypel, instance, bootubipart, bootubivol, ...) \
  82. "bootcmd_ubifs" #instance "=" \
  83. "bootubipart=" #bootubipart "; " \
  84. "bootubivol=" #bootubivol "; " \
  85. "bootubioff=" BOOTENV_DEV_UBIFS_BOOTUBIOFF(__VA_ARGS__) "; " \
  86. "run ubifs_boot\0"
  87. #define BOOTENV_DEV_NAME_UBIFS(devtypeu, devtypel, instance, ...) \
  88. #devtypel #instance " "
  89. #else
  90. #define BOOTENV_SHARED_UBIFS
  91. #define BOOTENV_DEV_UBIFS \
  92. BOOT_TARGET_DEVICES_references_UBIFS_without_CONFIG_CMD_UBIFS
  93. #define BOOTENV_DEV_NAME_UBIFS \
  94. BOOT_TARGET_DEVICES_references_UBIFS_without_CONFIG_CMD_UBIFS
  95. #endif
  96. #ifdef CONFIG_EFI_LOADER
  97. #if defined(CONFIG_ARM64)
  98. #define BOOTEFI_NAME "bootaa64.efi"
  99. #elif defined(CONFIG_ARM)
  100. #define BOOTEFI_NAME "bootarm.efi"
  101. #elif defined(CONFIG_X86_RUN_32BIT)
  102. #define BOOTEFI_NAME "bootia32.efi"
  103. #elif defined(CONFIG_X86_RUN_64BIT)
  104. #define BOOTEFI_NAME "bootx64.efi"
  105. #elif defined(CONFIG_ARCH_RV32I)
  106. #define BOOTEFI_NAME "bootriscv32.efi"
  107. #elif defined(CONFIG_ARCH_RV64I)
  108. #define BOOTEFI_NAME "bootriscv64.efi"
  109. #endif
  110. #endif
  111. #ifdef BOOTEFI_NAME
  112. #if defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
  113. /*
  114. * On 32bit ARM systems there is a reasonable number of systems that follow
  115. * the $soc-$board$boardver.dtb name scheme for their device trees. Use that
  116. * scheme if we don't have an explicit fdtfile variable.
  117. */
  118. #define BOOTENV_EFI_SET_FDTFILE_FALLBACK \
  119. "if test -z \"${fdtfile}\" -a -n \"${soc}\"; then " \
  120. "setenv efi_fdtfile ${soc}-${board}${boardver}.dtb; " \
  121. "fi; "
  122. #else
  123. #ifndef BOOTENV_EFI_SET_FDTFILE_FALLBACK
  124. #define BOOTENV_EFI_SET_FDTFILE_FALLBACK
  125. #endif
  126. #endif
  127. #ifdef CONFIG_CMD_BOOTEFI_BOOTMGR
  128. #define BOOTENV_EFI_BOOTMGR \
  129. "boot_efi_bootmgr=" \
  130. "if fdt addr -q ${fdt_addr_r}; then " \
  131. "bootefi bootmgr ${fdt_addr_r};" \
  132. "else " \
  133. "bootefi bootmgr;" \
  134. "fi\0"
  135. #else
  136. #define BOOTENV_EFI_BOOTMGR
  137. #endif
  138. #define BOOTENV_SHARED_EFI \
  139. BOOTENV_EFI_BOOTMGR \
  140. \
  141. "boot_efi_binary=" \
  142. "load ${devtype} ${devnum}:${distro_bootpart} " \
  143. "${kernel_addr_r} efi/boot/"BOOTEFI_NAME"; " \
  144. "if fdt addr -q ${fdt_addr_r}; then " \
  145. "bootefi ${kernel_addr_r} ${fdt_addr_r};" \
  146. "else " \
  147. "bootefi ${kernel_addr_r} ${fdtcontroladdr};" \
  148. "fi\0" \
  149. \
  150. "load_efi_dtb=" \
  151. "load ${devtype} ${devnum}:${distro_bootpart} " \
  152. "${fdt_addr_r} ${prefix}${efi_fdtfile}\0" \
  153. \
  154. "efi_dtb_prefixes=/ /dtb/ /dtb/current/\0" \
  155. "scan_dev_for_efi=" \
  156. "setenv efi_fdtfile ${fdtfile}; " \
  157. BOOTENV_EFI_SET_FDTFILE_FALLBACK \
  158. BOOTENV_RUN_EXTENSION_INIT \
  159. "for prefix in ${efi_dtb_prefixes}; do " \
  160. "if test -e ${devtype} " \
  161. "${devnum}:${distro_bootpart} " \
  162. "${prefix}${efi_fdtfile}; then " \
  163. "run load_efi_dtb; " \
  164. BOOTENV_RUN_EXTENSION_APPLY \
  165. "fi;" \
  166. "done;" \
  167. "run boot_efi_bootmgr;" \
  168. "if test -e ${devtype} ${devnum}:${distro_bootpart} " \
  169. "efi/boot/"BOOTEFI_NAME"; then " \
  170. "echo Found EFI removable media binary " \
  171. "efi/boot/"BOOTEFI_NAME"; " \
  172. "run boot_efi_binary; " \
  173. "echo EFI LOAD FAILED: continuing...; " \
  174. "fi; " \
  175. "setenv efi_fdtfile\0"
  176. #define SCAN_DEV_FOR_EFI "run scan_dev_for_efi;"
  177. #else
  178. #define BOOTENV_SHARED_EFI
  179. #define SCAN_DEV_FOR_EFI
  180. #endif
  181. #ifdef CONFIG_SATA
  182. #define BOOTENV_SHARED_SATA BOOTENV_SHARED_BLKDEV(sata)
  183. #define BOOTENV_DEV_SATA BOOTENV_DEV_BLKDEV
  184. #define BOOTENV_DEV_NAME_SATA BOOTENV_DEV_NAME_BLKDEV
  185. #elif defined(CONFIG_SPL_BUILD)
  186. #define BOOTENV_SHARED_SATA
  187. #define BOOTENV_DEV_SATA BOOTENV_DEV_BLKDEV_NONE
  188. #define BOOTENV_DEV_NAME_SATA BOOTENV_DEV_NAME_BLKDEV_NONE
  189. #else
  190. #define BOOTENV_SHARED_SATA
  191. #define BOOTENV_DEV_SATA \
  192. BOOT_TARGET_DEVICES_references_SATA_without_CONFIG_SATA
  193. #define BOOTENV_DEV_NAME_SATA \
  194. BOOT_TARGET_DEVICES_references_SATA_without_CONFIG_SATA
  195. #endif
  196. #ifdef CONFIG_NVME
  197. #define BOOTENV_RUN_NVME_INIT "run nvme_init; "
  198. #define BOOTENV_SET_NVME_NEED_INIT "setenv nvme_need_init; "
  199. #define BOOTENV_SHARED_NVME \
  200. "nvme_init=" \
  201. "if ${nvme_need_init}; then " \
  202. "setenv nvme_need_init false; " \
  203. "nvme scan; " \
  204. "fi\0" \
  205. \
  206. "nvme_boot=" \
  207. BOOTENV_RUN_PCI_ENUM \
  208. BOOTENV_RUN_NVME_INIT \
  209. BOOTENV_SHARED_BLKDEV_BODY(nvme)
  210. #define BOOTENV_DEV_NVME BOOTENV_DEV_BLKDEV
  211. #define BOOTENV_DEV_NAME_NVME BOOTENV_DEV_NAME_BLKDEV
  212. #else
  213. #define BOOTENV_RUN_NVME_INIT
  214. #define BOOTENV_SET_NVME_NEED_INIT
  215. #define BOOTENV_SHARED_NVME
  216. #define BOOTENV_DEV_NVME \
  217. BOOT_TARGET_DEVICES_references_NVME_without_CONFIG_NVME
  218. #define BOOTENV_DEV_NAME_NVME \
  219. BOOT_TARGET_DEVICES_references_NVME_without_CONFIG_NVME
  220. #endif
  221. #ifdef CONFIG_SCSI
  222. #define BOOTENV_RUN_SCSI_INIT "run scsi_init; "
  223. #define BOOTENV_SET_SCSI_NEED_INIT "scsi_need_init=; "
  224. #define BOOTENV_SHARED_SCSI \
  225. "scsi_init=" \
  226. "if ${scsi_need_init}; then " \
  227. "scsi_need_init=false; " \
  228. "scsi scan; " \
  229. "fi\0" \
  230. \
  231. "scsi_boot=" \
  232. BOOTENV_RUN_PCI_ENUM \
  233. BOOTENV_RUN_SCSI_INIT \
  234. BOOTENV_SHARED_BLKDEV_BODY(scsi)
  235. #define BOOTENV_DEV_SCSI BOOTENV_DEV_BLKDEV
  236. #define BOOTENV_DEV_NAME_SCSI BOOTENV_DEV_NAME_BLKDEV
  237. #else
  238. #define BOOTENV_RUN_SCSI_INIT
  239. #define BOOTENV_SET_SCSI_NEED_INIT
  240. #define BOOTENV_SHARED_SCSI
  241. #define BOOTENV_DEV_SCSI \
  242. BOOT_TARGET_DEVICES_references_SCSI_without_CONFIG_SCSI
  243. #define BOOTENV_DEV_NAME_SCSI \
  244. BOOT_TARGET_DEVICES_references_SCSI_without_CONFIG_SCSI
  245. #endif
  246. #ifdef CONFIG_IDE
  247. #define BOOTENV_RUN_IDE_INIT "run ide_init; "
  248. #define BOOTENV_SET_IDE_NEED_INIT "setenv ide_need_init; "
  249. #define BOOTENV_SHARED_IDE \
  250. "ide_init=" \
  251. "if ${ide_need_init}; then " \
  252. "setenv ide_need_init false; " \
  253. "ide reset; " \
  254. "fi\0" \
  255. \
  256. "ide_boot=" \
  257. BOOTENV_RUN_IDE_INIT \
  258. BOOTENV_SHARED_BLKDEV_BODY(ide)
  259. #define BOOTENV_DEV_IDE BOOTENV_DEV_BLKDEV
  260. #define BOOTENV_DEV_NAME_IDE BOOTENV_DEV_NAME_BLKDEV
  261. #else
  262. #define BOOTENV_RUN_IDE_INIT
  263. #define BOOTENV_SET_IDE_NEED_INIT
  264. #define BOOTENV_SHARED_IDE
  265. #define BOOTENV_DEV_IDE \
  266. BOOT_TARGET_DEVICES_references_IDE_without_CONFIG_IDE
  267. #define BOOTENV_DEV_NAME_IDE \
  268. BOOT_TARGET_DEVICES_references_IDE_without_CONFIG_IDE
  269. #endif
  270. #if defined(CONFIG_PCI)
  271. #define BOOTENV_RUN_PCI_ENUM "run boot_pci_enum; "
  272. #define BOOTENV_SHARED_PCI \
  273. "boot_pci_enum=pci enum\0"
  274. #else
  275. #define BOOTENV_RUN_PCI_ENUM
  276. #define BOOTENV_SHARED_PCI
  277. #endif
  278. #ifdef CONFIG_CMD_USB
  279. #define BOOTENV_RUN_NET_USB_START "run boot_net_usb_start; "
  280. #define BOOTENV_SHARED_USB \
  281. "boot_net_usb_start=usb start\0" \
  282. "usb_boot=" \
  283. "usb start; " \
  284. BOOTENV_SHARED_BLKDEV_BODY(usb)
  285. #define BOOTENV_DEV_USB BOOTENV_DEV_BLKDEV
  286. #define BOOTENV_DEV_NAME_USB BOOTENV_DEV_NAME_BLKDEV
  287. #elif defined(CONFIG_SPL_BUILD)
  288. #define BOOTENV_RUN_NET_USB_START
  289. #define BOOTENV_SHARED_USB
  290. #define BOOTENV_DEV_USB BOOTENV_DEV_BLKDEV_NONE
  291. #define BOOTENV_DEV_NAME_USB BOOTENV_DEV_NAME_BLKDEV_NONE
  292. #else
  293. #define BOOTENV_RUN_NET_USB_START
  294. #define BOOTENV_SHARED_USB
  295. #define BOOTENV_DEV_USB \
  296. BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB
  297. #define BOOTENV_DEV_NAME_USB \
  298. BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB
  299. #endif
  300. #ifdef CONFIG_CMD_VIRTIO
  301. #define BOOTENV_RUN_VIRTIO_INIT "run virtio_init; "
  302. #define BOOTENV_SET_VIRTIO_NEED_INIT "virtio_need_init=; "
  303. #define BOOTENV_SHARED_VIRTIO \
  304. "virtio_init=" \
  305. "if ${virtio_need_init}; then " \
  306. "virtio_need_init=false; " \
  307. "virtio scan; " \
  308. "fi\0" \
  309. \
  310. "virtio_boot=" \
  311. BOOTENV_RUN_PCI_ENUM \
  312. BOOTENV_RUN_VIRTIO_INIT \
  313. BOOTENV_SHARED_BLKDEV_BODY(virtio)
  314. #define BOOTENV_DEV_VIRTIO BOOTENV_DEV_BLKDEV
  315. #define BOOTENV_DEV_NAME_VIRTIO BOOTENV_DEV_NAME_BLKDEV
  316. #else
  317. #define BOOTENV_RUN_VIRTIO_INIT
  318. #define BOOTENV_SET_VIRTIO_NEED_INIT
  319. #define BOOTENV_SHARED_VIRTIO
  320. #define BOOTENV_DEV_VIRTIO \
  321. BOOT_TARGET_DEVICES_references_VIRTIO_without_CONFIG_CMD_VIRTIO
  322. #define BOOTENV_DEV_NAME_VIRTIO \
  323. BOOT_TARGET_DEVICES_references_VIRTIO_without_CONFIG_CMD_VIRTIO
  324. #endif
  325. #if defined(CONFIG_CMD_DHCP)
  326. #if defined(CONFIG_EFI_LOADER)
  327. /* http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml */
  328. #if defined(CONFIG_ARM64) || defined(__aarch64__)
  329. #define BOOTENV_EFI_PXE_ARCH "0xb"
  330. #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00011:UNDI:003000"
  331. #elif defined(CONFIG_ARM) || defined(__arm__)
  332. #define BOOTENV_EFI_PXE_ARCH "0xa"
  333. #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00010:UNDI:003000"
  334. #elif defined(CONFIG_X86) || defined(__x86_64__)
  335. #define BOOTENV_EFI_PXE_ARCH "0x7"
  336. #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00007:UNDI:003000"
  337. #elif defined(__i386__)
  338. #define BOOTENV_EFI_PXE_ARCH "0x6"
  339. #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00006:UNDI:003000"
  340. #elif defined(CONFIG_ARCH_RV32I) || ((defined(__riscv) && __riscv_xlen == 32))
  341. #define BOOTENV_EFI_PXE_ARCH "0x19"
  342. #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00025:UNDI:003000"
  343. #elif defined(CONFIG_ARCH_RV64I) || ((defined(__riscv) && __riscv_xlen == 64))
  344. #define BOOTENV_EFI_PXE_ARCH "0x1b"
  345. #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00027:UNDI:003000"
  346. #elif defined(CONFIG_SANDBOX)
  347. # error "sandbox EFI support is only supported on ARM and x86"
  348. #else
  349. #error Please specify an EFI client identifier
  350. #endif
  351. /*
  352. * Ask the dhcp server for an EFI binary. If we get one, check for a
  353. * device tree in the same folder. Then boot everything. If the file was
  354. * not an EFI binary, we just return from the bootefi command and continue.
  355. */
  356. #define BOOTENV_EFI_RUN_DHCP \
  357. "setenv efi_fdtfile ${fdtfile}; " \
  358. BOOTENV_EFI_SET_FDTFILE_FALLBACK \
  359. "setenv efi_old_vci ${bootp_vci};" \
  360. "setenv efi_old_arch ${bootp_arch};" \
  361. "setenv bootp_vci " BOOTENV_EFI_PXE_VCI ";" \
  362. "setenv bootp_arch " BOOTENV_EFI_PXE_ARCH ";" \
  363. "if dhcp ${kernel_addr_r}; then " \
  364. "tftpboot ${fdt_addr_r} dtb/${efi_fdtfile};" \
  365. "if fdt addr -q ${fdt_addr_r}; then " \
  366. "bootefi ${kernel_addr_r} ${fdt_addr_r}; " \
  367. "else " \
  368. "bootefi ${kernel_addr_r} ${fdtcontroladdr};" \
  369. "fi;" \
  370. "fi;" \
  371. "setenv bootp_vci ${efi_old_vci};" \
  372. "setenv bootp_arch ${efi_old_arch};" \
  373. "setenv efi_fdtfile;" \
  374. "setenv efi_old_arch;" \
  375. "setenv efi_old_vci;"
  376. #else
  377. #define BOOTENV_EFI_RUN_DHCP
  378. #endif
  379. #define BOOTENV_DEV_DHCP(devtypeu, devtypel, instance) \
  380. "bootcmd_dhcp=" \
  381. "devtype=" #devtypel "; " \
  382. BOOTENV_RUN_NET_USB_START \
  383. BOOTENV_RUN_PCI_ENUM \
  384. "if dhcp ${scriptaddr} ${boot_script_dhcp}; then " \
  385. "source ${scriptaddr}; " \
  386. "fi;" \
  387. BOOTENV_EFI_RUN_DHCP \
  388. "\0"
  389. #define BOOTENV_DEV_NAME_DHCP(devtypeu, devtypel, instance) \
  390. "dhcp "
  391. #elif defined(CONFIG_SPL_BUILD)
  392. #define BOOTENV_DEV_DHCP BOOTENV_DEV_BLKDEV_NONE
  393. #define BOOTENV_DEV_NAME_DHCP BOOTENV_DEV_NAME_BLKDEV_NONE
  394. #else
  395. #define BOOTENV_DEV_DHCP \
  396. BOOT_TARGET_DEVICES_references_DHCP_without_CONFIG_CMD_DHCP
  397. #define BOOTENV_DEV_NAME_DHCP \
  398. BOOT_TARGET_DEVICES_references_DHCP_without_CONFIG_CMD_DHCP
  399. #endif
  400. #if defined(CONFIG_CMD_DHCP) && defined(CONFIG_CMD_PXE)
  401. #define BOOTENV_DEV_PXE(devtypeu, devtypel, instance) \
  402. "bootcmd_pxe=" \
  403. BOOTENV_RUN_NET_USB_START \
  404. BOOTENV_RUN_PCI_ENUM \
  405. "dhcp; " \
  406. "if pxe get; then " \
  407. "pxe boot; " \
  408. "fi\0"
  409. #define BOOTENV_DEV_NAME_PXE(devtypeu, devtypel, instance) \
  410. "pxe "
  411. #elif defined(CONFIG_SPL_BUILD)
  412. #define BOOTENV_DEV_PXE BOOTENV_DEV_BLKDEV_NONE
  413. #define BOOTENV_DEV_NAME_PXE BOOTENV_DEV_NAME_BLKDEV_NONE
  414. #else
  415. #define BOOTENV_DEV_PXE \
  416. BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE
  417. #define BOOTENV_DEV_NAME_PXE \
  418. BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE
  419. #endif
  420. #if defined(CONFIG_CMD_EXTENSION)
  421. #define BOOTENV_RUN_EXTENSION_INIT "run extension_init; "
  422. #define BOOTENV_RUN_EXTENSION_APPLY "run extension_apply; "
  423. #define BOOTENV_SET_EXTENSION_NEED_INIT \
  424. "extension_need_init=; " \
  425. "setenv extension_overlay_addr ${fdtoverlay_addr_r}; "
  426. #define BOOTENV_SHARED_EXTENSION \
  427. "extension_init=" \
  428. "echo Extension init...; " \
  429. "if ${extension_need_init}; then " \
  430. "extension_need_init=false; " \
  431. "extension scan; " \
  432. "fi\0" \
  433. \
  434. "extension_overlay_cmd=" \
  435. "load ${devtype} ${devnum}:${distro_bootpart} " \
  436. "${extension_overlay_addr} ${prefix}${extension_overlay_name}\0" \
  437. "extension_apply=" \
  438. "if fdt addr -q ${fdt_addr_r}; then " \
  439. "extension apply all; " \
  440. "fi\0"
  441. #else
  442. #define BOOTENV_RUN_EXTENSION_INIT
  443. #define BOOTENV_RUN_EXTENSION_APPLY
  444. #define BOOTENV_SET_EXTENSION_NEED_INIT
  445. #define BOOTENV_SHARED_EXTENSION
  446. #endif
  447. #define BOOTENV_DEV_NAME(devtypeu, devtypel, instance, ...) \
  448. BOOTENV_DEV_NAME_##devtypeu(devtypeu, devtypel, instance, ## __VA_ARGS__)
  449. #define BOOTENV_BOOT_TARGETS \
  450. "boot_targets=" BOOT_TARGET_DEVICES(BOOTENV_DEV_NAME) "\0"
  451. #define BOOTENV_DEV(devtypeu, devtypel, instance, ...) \
  452. BOOTENV_DEV_##devtypeu(devtypeu, devtypel, instance, ## __VA_ARGS__)
  453. #define BOOTENV \
  454. BOOTENV_SHARED_HOST \
  455. BOOTENV_SHARED_MMC \
  456. BOOTENV_SHARED_PCI \
  457. BOOTENV_SHARED_USB \
  458. BOOTENV_SHARED_SATA \
  459. BOOTENV_SHARED_SCSI \
  460. BOOTENV_SHARED_NVME \
  461. BOOTENV_SHARED_IDE \
  462. BOOTENV_SHARED_UBIFS \
  463. BOOTENV_SHARED_EFI \
  464. BOOTENV_SHARED_VIRTIO \
  465. BOOTENV_SHARED_EXTENSION \
  466. "boot_prefixes=/ /boot/\0" \
  467. "boot_scripts=boot.scr.uimg boot.scr\0" \
  468. "boot_script_dhcp=boot.scr.uimg\0" \
  469. BOOTENV_BOOT_TARGETS \
  470. \
  471. "boot_syslinux_conf=extlinux/extlinux.conf\0" \
  472. "boot_extlinux=" \
  473. "sysboot ${devtype} ${devnum}:${distro_bootpart} any " \
  474. "${scriptaddr} ${prefix}${boot_syslinux_conf}\0" \
  475. \
  476. "scan_dev_for_extlinux=" \
  477. "if test -e ${devtype} " \
  478. "${devnum}:${distro_bootpart} " \
  479. "${prefix}${boot_syslinux_conf}; then " \
  480. "echo Found ${prefix}${boot_syslinux_conf}; " \
  481. "run boot_extlinux; " \
  482. "echo EXTLINUX FAILED: continuing...; " \
  483. "fi\0" \
  484. \
  485. "boot_a_script=" \
  486. "load ${devtype} ${devnum}:${distro_bootpart} " \
  487. "${scriptaddr} ${prefix}${script}; " \
  488. "source ${scriptaddr}\0" \
  489. \
  490. "scan_dev_for_scripts=" \
  491. "for script in ${boot_scripts}; do " \
  492. "if test -e ${devtype} " \
  493. "${devnum}:${distro_bootpart} " \
  494. "${prefix}${script}; then " \
  495. "echo Found U-Boot script " \
  496. "${prefix}${script}; " \
  497. "run boot_a_script; " \
  498. "echo SCRIPT FAILED: continuing...; " \
  499. "fi; " \
  500. "done\0" \
  501. \
  502. "scan_dev_for_boot=" \
  503. "echo Scanning ${devtype} " \
  504. "${devnum}:${distro_bootpart}...; " \
  505. "for prefix in ${boot_prefixes}; do " \
  506. "run scan_dev_for_extlinux; " \
  507. "run scan_dev_for_scripts; " \
  508. "done;" \
  509. SCAN_DEV_FOR_EFI \
  510. "\0" \
  511. \
  512. "scan_dev_for_boot_part=" \
  513. "part list ${devtype} ${devnum} -bootable devplist; " \
  514. "env exists devplist || setenv devplist 1; " \
  515. "for distro_bootpart in ${devplist}; do " \
  516. "if fstype ${devtype} " \
  517. "${devnum}:${distro_bootpart} " \
  518. "bootfstype; then " \
  519. "part uuid ${devtype} " \
  520. "${devnum}:${distro_bootpart} " \
  521. "distro_bootpart_uuid ; " \
  522. "run scan_dev_for_boot; " \
  523. "fi; " \
  524. "done; " \
  525. "setenv devplist\0" \
  526. \
  527. BOOT_TARGET_DEVICES(BOOTENV_DEV) \
  528. \
  529. "distro_bootcmd=" BOOTENV_SET_SCSI_NEED_INIT \
  530. BOOTENV_SET_NVME_NEED_INIT \
  531. BOOTENV_SET_IDE_NEED_INIT \
  532. BOOTENV_SET_VIRTIO_NEED_INIT \
  533. BOOTENV_SET_EXTENSION_NEED_INIT \
  534. "for target in ${boot_targets}; do " \
  535. "run bootcmd_${target}; " \
  536. "done\0"
  537. #endif /* _CONFIG_CMD_DISTRO_BOOTCMD_H */