Dennis Gilmore | 8cc9684 | 2014-07-30 16:37:14 -0600 | [diff] [blame] | 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 | #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 |
| 56 | #define BOOTENV_SHARED_SCSI BOOTENV_SHARED_BLKDEV(scsi) |
| 57 | #define BOOTENV_DEV_SCSI BOOTENV_DEV_BLKDEV |
| 58 | #define BOOTENV_DEV_NAME_SCSI BOOTENV_DEV_NAME_BLKDEV |
| 59 | #else |
| 60 | #define BOOTENV_SHARED_SCSI |
| 61 | #define BOOTENV_DEV_SCSI \ |
| 62 | BOOT_TARGET_DEVICES_references_SCSI_without_CONFIG_CMD_SCSI |
| 63 | #define BOOTENV_DEV_NAME_SCSI \ |
| 64 | BOOT_TARGET_DEVICES_references_SCSI_without_CONFIG_CMD_SCSI |
| 65 | #endif |
| 66 | |
| 67 | #ifdef CONFIG_CMD_IDE |
| 68 | #define BOOTENV_SHARED_IDE BOOTENV_SHARED_BLKDEV(ide) |
| 69 | #define BOOTENV_DEV_IDE BOOTENV_DEV_BLKDEV |
| 70 | #define BOOTENV_DEV_NAME_IDE BOOTENV_DEV_NAME_BLKDEV |
| 71 | #else |
| 72 | #define BOOTENV_SHARED_IDE |
| 73 | #define BOOTENV_DEV_IDE \ |
| 74 | BOOT_TARGET_DEVICES_references_IDE_without_CONFIG_CMD_IDE |
| 75 | #define BOOTENV_DEV_NAME_IDE \ |
| 76 | BOOT_TARGET_DEVICES_references_IDE_without_CONFIG_CMD_IDE |
| 77 | #endif |
| 78 | |
| 79 | #ifdef CONFIG_CMD_USB |
| 80 | #define BOOTENV_RUN_USB_INIT "run usb_init; " |
| 81 | #define BOOTENV_SET_USB_NEED_INIT "setenv usb_need_init; " |
| 82 | #define BOOTENV_SHARED_USB \ |
| 83 | "usb_init=" \ |
| 84 | "if ${usb_need_init}; then " \ |
| 85 | "setenv usb_need_init false; " \ |
| 86 | "usb start 0; " \ |
| 87 | "fi\0" \ |
| 88 | \ |
| 89 | "usb_boot=" \ |
| 90 | BOOTENV_RUN_USB_INIT \ |
| 91 | BOOTENV_SHARED_BLKDEV_BODY(usb) |
| 92 | #define BOOTENV_DEV_USB BOOTENV_DEV_BLKDEV |
| 93 | #define BOOTENV_DEV_NAME_USB BOOTENV_DEV_NAME_BLKDEV |
| 94 | #else |
| 95 | #define BOOTENV_RUN_USB_INIT |
| 96 | #define BOOTENV_SET_USB_NEED_INIT |
| 97 | #define BOOTENV_SHARED_USB |
| 98 | #define BOOTENV_DEV_USB \ |
| 99 | BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB |
| 100 | #define BOOTENV_DEV_NAME_USB \ |
| 101 | BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB |
| 102 | #endif |
| 103 | |
| 104 | #if defined(CONFIG_CMD_DHCP) |
| 105 | #define BOOTENV_DEV_DHCP(devtypeu, devtypel, instance) \ |
| 106 | "bootcmd_dhcp=" \ |
| 107 | BOOTENV_RUN_USB_INIT \ |
| 108 | "if dhcp ${scriptaddr} boot.scr.uimg; then " \ |
| 109 | "source ${scriptaddr}; " \ |
| 110 | "fi\0" |
| 111 | #define BOOTENV_DEV_NAME_DHCP(devtypeu, devtypel, instance) \ |
| 112 | "dhcp " |
| 113 | #else |
| 114 | #define BOOTENV_DEV_DHCP \ |
| 115 | BOOT_TARGET_DEVICES_references_DHCP_without_CONFIG_CMD_DHCP |
| 116 | #define BOOTENV_DEV_NAME_DHCP \ |
| 117 | BOOT_TARGET_DEVICES_references_DHCP_without_CONFIG_CMD_DHCP |
| 118 | #endif |
| 119 | |
| 120 | #if defined(CONFIG_CMD_DHCP) && defined(CONFIG_CMD_PXE) |
| 121 | #define BOOTENV_DEV_PXE(devtypeu, devtypel, instance) \ |
| 122 | "bootcmd_pxe=" \ |
| 123 | BOOTENV_RUN_USB_INIT \ |
| 124 | "dhcp; " \ |
| 125 | "if pxe get; then " \ |
| 126 | "pxe boot; " \ |
| 127 | "fi\0" |
| 128 | #define BOOTENV_DEV_NAME_PXE(devtypeu, devtypel, instance) \ |
| 129 | "pxe " |
| 130 | #else |
| 131 | #define BOOTENV_DEV_PXE \ |
| 132 | BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE |
| 133 | #define BOOTENV_DEV_NAME_PXE \ |
| 134 | BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE |
| 135 | #endif |
| 136 | |
| 137 | #define BOOTENV_DEV_NAME(devtypeu, devtypel, instance) \ |
| 138 | BOOTENV_DEV_NAME_##devtypeu(devtypeu, devtypel, instance) |
| 139 | #define BOOTENV_BOOT_TARGETS \ |
| 140 | "boot_targets=" BOOT_TARGET_DEVICES(BOOTENV_DEV_NAME) "\0" |
| 141 | |
| 142 | #define BOOTENV_DEV(devtypeu, devtypel, instance) \ |
| 143 | BOOTENV_DEV_##devtypeu(devtypeu, devtypel, instance) |
| 144 | #define BOOTENV \ |
| 145 | BOOTENV_SHARED_MMC \ |
| 146 | BOOTENV_SHARED_USB \ |
| 147 | BOOTENV_SHARED_SATA \ |
| 148 | BOOTENV_SHARED_SCSI \ |
| 149 | BOOTENV_SHARED_IDE \ |
| 150 | "boot_prefixes=/ /boot/\0" \ |
| 151 | "boot_scripts=boot.scr.uimg boot.scr\0" \ |
| 152 | BOOTENV_BOOT_TARGETS \ |
| 153 | "bootpart=1\0" \ |
| 154 | \ |
| 155 | "boot_extlinux=" \ |
| 156 | "sysboot ${devtype} ${devnum}:${bootpart} any " \ |
| 157 | "${scriptaddr} ${prefix}extlinux/extlinux.conf\0" \ |
| 158 | \ |
| 159 | "scan_dev_for_extlinux=" \ |
| 160 | "if test -e ${devtype} ${devnum}:${bootpart} " \ |
| 161 | "${prefix}extlinux/extlinux.conf; then " \ |
| 162 | "echo Found ${prefix}extlinux/extlinux.conf; " \ |
| 163 | "run boot_extlinux; " \ |
| 164 | "echo SCRIPT FAILED: continuing...; " \ |
| 165 | "fi\0" \ |
| 166 | \ |
| 167 | "boot_a_script=" \ |
| 168 | "load ${devtype} ${devnum}:${bootpart} " \ |
| 169 | "${scriptaddr} ${prefix}${script}; " \ |
| 170 | "source ${scriptaddr}\0" \ |
| 171 | \ |
| 172 | "scan_dev_for_scripts=" \ |
| 173 | "for script in ${boot_scripts}; do " \ |
| 174 | "if test -e ${devtype} ${devnum}:${bootpart} " \ |
| 175 | "${prefix}${script}; then " \ |
| 176 | "echo Found U-Boot script " \ |
| 177 | "${prefix}${script}; " \ |
| 178 | "run boot_a_script; " \ |
| 179 | "echo SCRIPT FAILED: continuing...; " \ |
| 180 | "fi; " \ |
| 181 | "done\0" \ |
| 182 | \ |
| 183 | "scan_dev_for_boot=" \ |
| 184 | "echo Scanning ${devtype} ${devnum}...; " \ |
| 185 | "for prefix in ${boot_prefixes}; do " \ |
| 186 | "run scan_dev_for_extlinux; " \ |
| 187 | "run scan_dev_for_scripts; " \ |
| 188 | "done\0" \ |
| 189 | \ |
| 190 | BOOT_TARGET_DEVICES(BOOTENV_DEV) \ |
| 191 | \ |
| 192 | "bootcmd=" BOOTENV_SET_USB_NEED_INIT \ |
| 193 | "for target in ${boot_targets}; do " \ |
| 194 | "run bootcmd_${target}; " \ |
| 195 | "done\0" |
| 196 | |
| 197 | #endif /* _CONFIG_CMD_DISTRO_BOOTCMD_H */ |