Tom Rini | 89789eb | 2020-01-29 11:03:34 -0500 | [diff] [blame] | 1 | // SPDX-License-Identifier: BSD-2-Clause |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2001 William L. Pitts |
| 4 | * All rights reserved. |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 7 | #include <command.h> |
Simon Glass | 62270f4 | 2019-11-14 12:57:35 -0700 | [diff] [blame] | 8 | #include <cpu_func.h> |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 9 | #include <elf.h> |
Simon Glass | cdbff9f | 2019-08-01 09:46:50 -0600 | [diff] [blame] | 10 | #include <env.h> |
Simon Glass | 8e8ccfe | 2019-12-28 10:45:03 -0700 | [diff] [blame] | 11 | #include <image.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 12 | #include <log.h> |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 13 | #include <net.h> |
Niklaus Giger | 29a4c24 | 2008-11-03 22:15:34 +0100 | [diff] [blame] | 14 | #include <vxworks.h> |
Bin Meng | b90ff0f | 2015-10-07 20:19:18 -0700 | [diff] [blame] | 15 | #ifdef CONFIG_X86 |
Simon Glass | cafe871 | 2022-07-30 15:52:04 -0600 | [diff] [blame] | 16 | #include <vesa.h> |
Simon Glass | 90526e9 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 17 | #include <asm/cache.h> |
Bin Meng | b90ff0f | 2015-10-07 20:19:18 -0700 | [diff] [blame] | 18 | #include <asm/e820.h> |
Bin Meng | 9aa1280 | 2015-10-07 20:19:19 -0700 | [diff] [blame] | 19 | #include <linux/linkage.h> |
Bin Meng | b90ff0f | 2015-10-07 20:19:18 -0700 | [diff] [blame] | 20 | #endif |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 21 | |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 22 | /* Interpreter command to boot an arbitrary ELF image from memory */ |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 23 | int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 24 | { |
Maxim Moskalets | 6d1734f | 2024-03-08 00:29:14 +0300 | [diff] [blame] | 25 | #if CONFIG_IS_ENABLED(CMD_ELF_FDT_SETUP) |
| 26 | struct bootm_headers img = {0}; |
| 27 | unsigned long fdt_addr = 0; /* Address of the FDT */ |
| 28 | #endif |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 29 | unsigned long addr; /* Address of the ELF image */ |
| 30 | unsigned long rc; /* Return value from user code */ |
Maxim Moskalets | 46b6a3e | 2024-06-05 21:43:34 +0300 | [diff] [blame] | 31 | int rcode = CMD_RET_SUCCESS; |
| 32 | Bootelf_flags flags = {0}; |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 33 | |
Tom Rini | be1b867 | 2017-05-18 17:03:07 -0400 | [diff] [blame] | 34 | /* Consume 'bootelf' */ |
| 35 | argc--; argv++; |
Mike Frysinger | f44a928 | 2010-10-02 15:44:53 -0400 | [diff] [blame] | 36 | |
Maxim Moskalets | 6d1734f | 2024-03-08 00:29:14 +0300 | [diff] [blame] | 37 | /* Check for [-p|-s] flag. */ |
Tom Rini | be1b867 | 2017-05-18 17:03:07 -0400 | [diff] [blame] | 38 | if (argc >= 1 && (argv[0][0] == '-' && \ |
| 39 | (argv[0][1] == 'p' || argv[0][1] == 's'))) { |
Maxim Moskalets | 46b6a3e | 2024-06-05 21:43:34 +0300 | [diff] [blame] | 40 | if (argv[0][1] == 'p') |
| 41 | flags.phdr = 1; |
| 42 | log_debug("Using ELF header format %s\n", |
| 43 | flags.phdr ? "phdr" : "shdr"); |
Tom Rini | be1b867 | 2017-05-18 17:03:07 -0400 | [diff] [blame] | 44 | /* Consume flag. */ |
| 45 | argc--; argv++; |
| 46 | } |
Maxim Moskalets | 6d1734f | 2024-03-08 00:29:14 +0300 | [diff] [blame] | 47 | |
| 48 | #if CONFIG_IS_ENABLED(CMD_ELF_FDT_SETUP) |
| 49 | /* Check for [-d fdt_addr_r] option. */ |
| 50 | if ((argc >= 2) && (argv[0][0] == '-') && (argv[0][1] == 'd')) { |
| 51 | if (strict_strtoul(argv[1], 16, &fdt_addr) != 0) |
| 52 | return CMD_RET_USAGE; |
| 53 | /* Consume option. */ |
| 54 | argc -= 2; |
| 55 | argv += 2; |
| 56 | } |
| 57 | #endif |
| 58 | |
Tom Rini | be1b867 | 2017-05-18 17:03:07 -0400 | [diff] [blame] | 59 | /* Check for address. */ |
| 60 | if (argc >= 1 && strict_strtoul(argv[0], 16, &addr) != -EINVAL) { |
| 61 | /* Consume address */ |
| 62 | argc--; argv++; |
| 63 | } else |
Simon Glass | bb872dd | 2019-12-28 10:45:02 -0700 | [diff] [blame] | 64 | addr = image_load_addr; |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 65 | |
Maxim Moskalets | 6d1734f | 2024-03-08 00:29:14 +0300 | [diff] [blame] | 66 | #if CONFIG_IS_ENABLED(CMD_ELF_FDT_SETUP) |
| 67 | if (fdt_addr) { |
Maxim Moskalets | 46b6a3e | 2024-06-05 21:43:34 +0300 | [diff] [blame] | 68 | log_debug("Setting up FDT at 0x%08lx ...\n", fdt_addr); |
Maxim Moskalets | 6d1734f | 2024-03-08 00:29:14 +0300 | [diff] [blame] | 69 | flush(); |
| 70 | |
Maxim Moskalets | 8d57f46 | 2024-06-28 11:34:11 +0300 | [diff] [blame] | 71 | fdt_set_totalsize((void *)fdt_addr, |
| 72 | fdt_totalsize(fdt_addr) + CONFIG_SYS_FDT_PAD); |
Maxim Moskalets | 6d1734f | 2024-03-08 00:29:14 +0300 | [diff] [blame] | 73 | if (image_setup_libfdt(&img, (void *)fdt_addr, NULL)) |
| 74 | return 1; |
| 75 | } |
| 76 | #endif |
| 77 | |
Maxim Moskalets | 46b6a3e | 2024-06-05 21:43:34 +0300 | [diff] [blame] | 78 | if (env_get_autostart()) { |
| 79 | flags.autostart = 1; |
| 80 | log_debug("Starting application at 0x%08lx ...\n", addr); |
| 81 | flush(); |
| 82 | } |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 83 | |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 84 | /* |
| 85 | * pass address parameter as argv[0] (aka command name), |
Maxim Moskalets | 46b6a3e | 2024-06-05 21:43:34 +0300 | [diff] [blame] | 86 | * and all remaining arguments |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 87 | */ |
Maxim Moskalets | 46b6a3e | 2024-06-05 21:43:34 +0300 | [diff] [blame] | 88 | rc = bootelf(addr, flags, argc, argv); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 89 | if (rc != 0) |
Maxim Moskalets | 46b6a3e | 2024-06-05 21:43:34 +0300 | [diff] [blame] | 90 | rcode = CMD_RET_FAILURE; |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 91 | |
Maxim Moskalets | 46b6a3e | 2024-06-05 21:43:34 +0300 | [diff] [blame] | 92 | if (flags.autostart) |
| 93 | { |
| 94 | if (ENOEXEC == errno) |
| 95 | log_err("Invalid ELF image\n"); |
| 96 | else |
| 97 | log_debug("## Application terminated, rc = 0x%lx\n", rc); |
| 98 | } |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 99 | |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 100 | return rcode; |
| 101 | } |
| 102 | |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 103 | /* |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 104 | * Interpreter command to boot VxWorks from a memory image. The image can |
| 105 | * be either an ELF image or a raw binary. Will attempt to setup the |
| 106 | * bootline and other parameters correctly. |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 107 | */ |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 108 | int do_bootvx(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 109 | { |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 110 | unsigned long addr; /* Address of image */ |
Bin Meng | 79c584e | 2018-04-11 22:02:22 -0700 | [diff] [blame] | 111 | unsigned long bootaddr = 0; /* Address to put the bootline */ |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 112 | char *bootline; /* Text of the bootline */ |
| 113 | char *tmp; /* Temporary char pointer */ |
| 114 | char build_buf[128]; /* Buffer for building the bootline */ |
Bin Meng | 7f0c3c5 | 2015-10-07 20:19:15 -0700 | [diff] [blame] | 115 | int ptr = 0; |
Bin Meng | b90ff0f | 2015-10-07 20:19:18 -0700 | [diff] [blame] | 116 | #ifdef CONFIG_X86 |
Bin Meng | 2902be8 | 2018-04-11 22:02:07 -0700 | [diff] [blame] | 117 | ulong base; |
Bin Meng | fa5e91f | 2018-04-11 22:02:09 -0700 | [diff] [blame] | 118 | struct e820_info *info; |
Bin Meng | 4551992 | 2018-04-11 22:02:11 -0700 | [diff] [blame] | 119 | struct e820_entry *data; |
Bin Meng | 447ae4f | 2018-04-11 22:02:19 -0700 | [diff] [blame] | 120 | struct efi_gop_info *gop; |
| 121 | struct vesa_mode_info *vesa = &mode_info.vesa; |
Bin Meng | b90ff0f | 2015-10-07 20:19:18 -0700 | [diff] [blame] | 122 | #endif |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 123 | |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 124 | /* |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 125 | * Check the loadaddr variable. |
| 126 | * If we don't know where the image is then we're done. |
| 127 | */ |
Stany MARCEL | 07a1a0c | 2013-11-27 14:48:43 +0100 | [diff] [blame] | 128 | if (argc < 2) |
Simon Glass | bb872dd | 2019-12-28 10:45:02 -0700 | [diff] [blame] | 129 | addr = image_load_addr; |
Stefan Roese | 1bdd468 | 2006-11-29 12:53:15 +0100 | [diff] [blame] | 130 | else |
Simon Glass | 7e5f460 | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 131 | addr = hextoul(argv[1], NULL); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 132 | |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 133 | #if defined(CONFIG_CMD_NET) |
Daniel Schwierzeck | 62e03d3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 134 | /* |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 135 | * Check to see if we need to tftp the image ourselves |
| 136 | * before starting |
Daniel Schwierzeck | 62e03d3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 137 | */ |
Stany MARCEL | 07a1a0c | 2013-11-27 14:48:43 +0100 | [diff] [blame] | 138 | if ((argc == 2) && (strcmp(argv[1], "tftp") == 0)) { |
Joe Hershberger | bc0571f | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 139 | if (net_loop(TFTPGET) <= 0) |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 140 | return 1; |
Daniel Schwierzeck | 62e03d3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 141 | printf("Automatic boot of VxWorks image at address 0x%08lx ...\n", |
| 142 | addr); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 143 | } |
| 144 | #endif |
| 145 | |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 146 | /* |
| 147 | * This should equate to |
| 148 | * NV_RAM_ADRS + NV_BOOT_OFFSET + NV_ENET_OFFSET |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 149 | * from the VxWorks BSP header files. |
| 150 | * This will vary from board to board |
| 151 | */ |
Tuomas Tynkkynen | 8996975 | 2018-01-21 18:16:42 +0200 | [diff] [blame] | 152 | #if defined(CONFIG_SYS_VXWORKS_MAC_PTR) |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 153 | tmp = (char *)CONFIG_SYS_VXWORKS_MAC_PTR; |
Simon Glass | 35affd7 | 2017-08-03 12:22:14 -0600 | [diff] [blame] | 154 | eth_env_get_enetaddr("ethaddr", (uchar *)build_buf); |
Mike Frysinger | 62c93d9 | 2009-02-11 18:51:43 -0500 | [diff] [blame] | 155 | memcpy(tmp, build_buf, 6); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 156 | #else |
Daniel Schwierzeck | 62e03d3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 157 | puts("## Ethernet MAC address not copied to NV RAM\n"); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 158 | #endif |
| 159 | |
Bin Meng | 79c584e | 2018-04-11 22:02:22 -0700 | [diff] [blame] | 160 | #ifdef CONFIG_X86 |
| 161 | /* |
| 162 | * Get VxWorks's physical memory base address from environment, |
| 163 | * if we don't specify it in the environment, use a default one. |
| 164 | */ |
| 165 | base = env_get_hex("vx_phys_mem_base", VXWORKS_PHYS_MEM_BASE); |
| 166 | data = (struct e820_entry *)(base + E820_DATA_OFFSET); |
| 167 | info = (struct e820_info *)(base + E820_INFO_OFFSET); |
| 168 | |
| 169 | memset(info, 0, sizeof(struct e820_info)); |
| 170 | info->sign = E820_SIGNATURE; |
| 171 | info->entries = install_e820_map(E820MAX, data); |
| 172 | info->addr = (info->entries - 1) * sizeof(struct e820_entry) + |
| 173 | E820_DATA_OFFSET; |
| 174 | |
| 175 | /* |
| 176 | * Explicitly clear the bootloader image size otherwise if memory |
| 177 | * at this offset happens to contain some garbage data, the final |
| 178 | * available memory size for the kernel is insane. |
| 179 | */ |
| 180 | *(u32 *)(base + BOOT_IMAGE_SIZE_OFFSET) = 0; |
| 181 | |
| 182 | /* |
| 183 | * Prepare compatible framebuffer information block. |
| 184 | * The VESA mode has to be 32-bit RGBA. |
| 185 | */ |
| 186 | if (vesa->x_resolution && vesa->y_resolution) { |
| 187 | gop = (struct efi_gop_info *)(base + EFI_GOP_INFO_OFFSET); |
| 188 | gop->magic = EFI_GOP_INFO_MAGIC; |
| 189 | gop->info.version = 0; |
| 190 | gop->info.width = vesa->x_resolution; |
| 191 | gop->info.height = vesa->y_resolution; |
| 192 | gop->info.pixel_format = EFI_GOT_RGBA8; |
| 193 | gop->info.pixels_per_scanline = vesa->bytes_per_scanline / 4; |
| 194 | gop->fb_base = vesa->phys_base_ptr; |
| 195 | gop->fb_size = vesa->bytes_per_scanline * vesa->y_resolution; |
| 196 | } |
| 197 | #endif |
| 198 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 199 | /* |
| 200 | * Use bootaddr to find the location in memory that VxWorks |
Bin Meng | 9e98b7e | 2015-10-07 20:19:17 -0700 | [diff] [blame] | 201 | * will look for the bootline string. The default value is |
| 202 | * (LOCAL_MEM_LOCAL_ADRS + BOOT_LINE_OFFSET) as defined by |
| 203 | * VxWorks BSP. For example, on PowerPC it defaults to 0x4200. |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 204 | */ |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 205 | tmp = env_get("bootaddr"); |
Bin Meng | 9e98b7e | 2015-10-07 20:19:17 -0700 | [diff] [blame] | 206 | if (!tmp) { |
Bin Meng | 79c584e | 2018-04-11 22:02:22 -0700 | [diff] [blame] | 207 | #ifdef CONFIG_X86 |
| 208 | bootaddr = base + X86_BOOT_LINE_OFFSET; |
| 209 | #else |
Bin Meng | 9e98b7e | 2015-10-07 20:19:17 -0700 | [diff] [blame] | 210 | printf("## VxWorks bootline address not specified\n"); |
Bin Meng | ced71a2 | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 211 | return 1; |
Bin Meng | 79c584e | 2018-04-11 22:02:22 -0700 | [diff] [blame] | 212 | #endif |
Bin Meng | ced71a2 | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 213 | } |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 214 | |
Bin Meng | 79c584e | 2018-04-11 22:02:22 -0700 | [diff] [blame] | 215 | if (!bootaddr) |
Simon Glass | 7e5f460 | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 216 | bootaddr = hextoul(tmp, NULL); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 217 | |
Bin Meng | ced71a2 | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 218 | /* |
| 219 | * Check to see if the bootline is defined in the 'bootargs' parameter. |
| 220 | * If it is not defined, we may be able to construct the info. |
| 221 | */ |
| 222 | bootline = env_get("bootargs"); |
| 223 | if (!bootline) { |
| 224 | tmp = env_get("bootdev"); |
| 225 | if (tmp) { |
| 226 | strcpy(build_buf, tmp); |
| 227 | ptr = strlen(tmp); |
| 228 | } else { |
| 229 | printf("## VxWorks boot device not specified\n"); |
Bin Meng | a4092db | 2015-10-07 20:19:16 -0700 | [diff] [blame] | 230 | } |
Niklaus Giger | 29a4c24 | 2008-11-03 22:15:34 +0100 | [diff] [blame] | 231 | |
Bin Meng | ced71a2 | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 232 | tmp = env_get("bootfile"); |
| 233 | if (tmp) |
| 234 | ptr += sprintf(build_buf + ptr, "host:%s ", tmp); |
| 235 | else |
| 236 | ptr += sprintf(build_buf + ptr, "host:vxWorks "); |
| 237 | |
| 238 | /* |
| 239 | * The following parameters are only needed if 'bootdev' |
| 240 | * is an ethernet device, otherwise they are optional. |
| 241 | */ |
| 242 | tmp = env_get("ipaddr"); |
| 243 | if (tmp) { |
| 244 | ptr += sprintf(build_buf + ptr, "e=%s", tmp); |
| 245 | tmp = env_get("netmask"); |
| 246 | if (tmp) { |
| 247 | u32 mask = env_get_ip("netmask").s_addr; |
| 248 | ptr += sprintf(build_buf + ptr, |
| 249 | ":%08x ", ntohl(mask)); |
| 250 | } else { |
| 251 | ptr += sprintf(build_buf + ptr, " "); |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | tmp = env_get("serverip"); |
| 256 | if (tmp) |
| 257 | ptr += sprintf(build_buf + ptr, "h=%s ", tmp); |
| 258 | |
| 259 | tmp = env_get("gatewayip"); |
| 260 | if (tmp) |
| 261 | ptr += sprintf(build_buf + ptr, "g=%s ", tmp); |
| 262 | |
| 263 | tmp = env_get("hostname"); |
| 264 | if (tmp) |
| 265 | ptr += sprintf(build_buf + ptr, "tn=%s ", tmp); |
| 266 | |
| 267 | tmp = env_get("othbootargs"); |
| 268 | if (tmp) { |
| 269 | strcpy(build_buf + ptr, tmp); |
| 270 | ptr += strlen(tmp); |
| 271 | } |
| 272 | |
| 273 | bootline = build_buf; |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 274 | } |
| 275 | |
Bin Meng | ced71a2 | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 276 | memcpy((void *)bootaddr, bootline, max(strlen(bootline), (size_t)255)); |
| 277 | flush_cache(bootaddr, max(strlen(bootline), (size_t)255)); |
| 278 | printf("## Using bootline (@ 0x%lx): %s\n", bootaddr, (char *)bootaddr); |
| 279 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 280 | /* |
| 281 | * If the data at the load address is an elf image, then |
| 282 | * treat it like an elf image. Otherwise, assume that it is a |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 283 | * binary image. |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 284 | */ |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 285 | if (valid_elf_image(addr)) |
Christian Gmeiner | 476c2fc | 2018-03-20 14:18:25 +0100 | [diff] [blame] | 286 | addr = load_elf_image_phdr(addr); |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 287 | else |
Daniel Schwierzeck | 62e03d3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 288 | puts("## Not an ELF image, assuming binary\n"); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 289 | |
Daniel Schwierzeck | 62e03d3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 290 | printf("## Starting vxWorks at 0x%08lx ...\n", addr); |
Pali Rohár | efc3f95 | 2022-09-05 11:31:21 +0200 | [diff] [blame] | 291 | flush(); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 292 | |
Reinhard Arlt | 6eee21d | 2011-11-18 09:06:52 +0000 | [diff] [blame] | 293 | dcache_disable(); |
Vasyl Vavrychuk | 3194daa | 2018-04-10 12:36:36 +0300 | [diff] [blame] | 294 | #if defined(CONFIG_ARM64) && defined(CONFIG_ARMV8_PSCI) |
| 295 | armv8_setup_psci(); |
| 296 | smp_kick_all_cpus(); |
| 297 | #endif |
| 298 | |
Bin Meng | 9aa1280 | 2015-10-07 20:19:19 -0700 | [diff] [blame] | 299 | #ifdef CONFIG_X86 |
| 300 | /* VxWorks on x86 uses stack to pass parameters */ |
| 301 | ((asmlinkage void (*)(int))addr)(0); |
| 302 | #else |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 303 | ((void (*)(int))addr)(0); |
Bin Meng | 9aa1280 | 2015-10-07 20:19:19 -0700 | [diff] [blame] | 304 | #endif |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 305 | |
Daniel Schwierzeck | 62e03d3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 306 | puts("## vxWorks terminated\n"); |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 307 | |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 308 | return 1; |
| 309 | } |
| 310 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 311 | U_BOOT_CMD( |
Tom Rini | be1b867 | 2017-05-18 17:03:07 -0400 | [diff] [blame] | 312 | bootelf, CONFIG_SYS_MAXARGS, 0, do_bootelf, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 313 | "Boot from an ELF image in memory", |
Maxim Moskalets | 6d1734f | 2024-03-08 00:29:14 +0300 | [diff] [blame] | 314 | "[-p|-s] " |
| 315 | #if CONFIG_IS_ENABLED(CMD_ELF_FDT_SETUP) |
| 316 | "[-d fdt_addr_r] " |
| 317 | #endif |
| 318 | "[address]\n" |
Mike Frysinger | f44a928 | 2010-10-02 15:44:53 -0400 | [diff] [blame] | 319 | "\t- load ELF image at [address] via program headers (-p)\n" |
Maxim Moskalets | 6d1734f | 2024-03-08 00:29:14 +0300 | [diff] [blame] | 320 | "\t or via section headers (-s)\n" |
| 321 | #if CONFIG_IS_ENABLED(CMD_ELF_FDT_SETUP) |
| 322 | "\t- setup FDT image at [fdt_addr_r] (-d)" |
| 323 | #endif |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 324 | ); |
| 325 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 326 | U_BOOT_CMD( |
Bin Meng | ebca3df | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 327 | bootvx, 2, 0, do_bootvx, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 328 | "Boot vxWorks from an ELF image", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 329 | " [address] - load address of vxWorks ELF image." |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 330 | ); |