exynos: Enable pre-relocation malloc()
[platform/kernel/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 #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_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)
68 #define BOOTENV_DEV_SCSI        BOOTENV_DEV_BLKDEV
69 #define BOOTENV_DEV_NAME_SCSI   BOOTENV_DEV_NAME_BLKDEV
70 #else
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
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
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 \
96         "usb_init=" \
97                 "if ${usb_need_init}; then " \
98                         "setenv usb_need_init false; " \
99                         "usb start 0; " \
100                 "fi\0" \
101         \
102         "usb_boot=" \
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
107 #else
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
115 #endif
116
117 #if defined(CONFIG_CMD_DHCP)
118 #define BOOTENV_DEV_DHCP(devtypeu, devtypel, instance) \
119         "bootcmd_dhcp=" \
120                 BOOTENV_RUN_USB_INIT \
121                 "if dhcp ${scriptaddr} boot.scr.uimg; then " \
122                         "source ${scriptaddr}; " \
123                 "fi\0"
124 #define BOOTENV_DEV_NAME_DHCP(devtypeu, devtypel, instance) \
125         "dhcp "
126 #else
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
131 #endif
132
133 #if defined(CONFIG_CMD_DHCP) && defined(CONFIG_CMD_PXE)
134 #define BOOTENV_DEV_PXE(devtypeu, devtypel, instance) \
135         "bootcmd_pxe=" \
136                 BOOTENV_RUN_USB_INIT \
137                 "dhcp; " \
138                 "if pxe get; then " \
139                         "pxe boot; " \
140                 "fi\0"
141 #define BOOTENV_DEV_NAME_PXE(devtypeu, devtypel, instance) \
142         "pxe "
143 #else
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
148 #endif
149
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"
154
155 #define BOOTENV_DEV(devtypeu, devtypel, instance) \
156         BOOTENV_DEV_##devtypeu(devtypeu, devtypel, instance)
157 #define BOOTENV \
158         BOOTENV_SHARED_MMC \
159         BOOTENV_SHARED_USB \
160         BOOTENV_SHARED_SATA \
161         BOOTENV_SHARED_SCSI \
162         BOOTENV_SHARED_IDE \
163         "boot_prefixes=/ /boot/\0" \
164         "boot_scripts=boot.scr.uimg boot.scr\0" \
165         BOOTENV_BOOT_TARGETS \
166         "bootpart=1\0" \
167         \
168         "boot_extlinux="                                                  \
169                 "sysboot ${devtype} ${devnum}:${bootpart} any "           \
170                         "${scriptaddr} ${prefix}extlinux/extlinux.conf\0" \
171         \
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...; "             \
178                 "fi\0"                                                    \
179         \
180         "boot_a_script="                                                  \
181                 "load ${devtype} ${devnum}:${bootpart} "                  \
182                         "${scriptaddr} ${prefix}${script}; "              \
183                 "source ${scriptaddr}\0"                                  \
184         \
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...; "     \
193                         "fi; "                                            \
194                 "done\0"                                                  \
195         \
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; "                      \
201                 "done\0"                                                  \
202         \
203         BOOT_TARGET_DEVICES(BOOTENV_DEV)                                  \
204         \
205         "bootcmd=" BOOTENV_SET_USB_NEED_INIT BOOTENV_SET_SCSI_NEED_INIT   \
206                 "for target in ${boot_targets}; do "                      \
207                         "run bootcmd_${target}; "                         \
208                 "done\0"
209
210 #endif  /* _CONFIG_CMD_DISTRO_BOOTCMD_H */