Tom Rini | 8abb4cb | 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 | |
| 7 | #include <common.h> |
| 8 | #include <command.h> |
Simon Glass | 370382c | 2019-11-14 12:57:35 -0700 | [diff] [blame] | 9 | #include <cpu_func.h> |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 10 | #include <elf.h> |
Simon Glass | 83c2e49 | 2019-08-01 09:46:50 -0600 | [diff] [blame] | 11 | #include <env.h> |
Simon Glass | 85f1378 | 2019-12-28 10:45:03 -0700 | [diff] [blame] | 12 | #include <image.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 13 | #include <log.h> |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 14 | #include <net.h> |
Niklaus Giger | f662b23 | 2008-11-03 22:15:34 +0100 | [diff] [blame] | 15 | #include <vxworks.h> |
Bin Meng | 321e860 | 2015-10-07 20:19:18 -0700 | [diff] [blame] | 16 | #ifdef CONFIG_X86 |
Bin Meng | 71606c4 | 2018-04-11 22:02:19 -0700 | [diff] [blame] | 17 | #include <vbe.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 18 | #include <asm/cache.h> |
Bin Meng | 321e860 | 2015-10-07 20:19:18 -0700 | [diff] [blame] | 19 | #include <asm/e820.h> |
Bin Meng | f6900e2 | 2015-10-07 20:19:19 -0700 | [diff] [blame] | 20 | #include <linux/linkage.h> |
Bin Meng | 321e860 | 2015-10-07 20:19:18 -0700 | [diff] [blame] | 21 | #endif |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 22 | |
Mike Frysinger | e60644a | 2008-04-13 19:42:18 -0400 | [diff] [blame] | 23 | /* Allow ports to override the default behavior */ |
Jeroen Hofstee | 3cc2a74 | 2014-10-08 22:57:31 +0200 | [diff] [blame] | 24 | static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]), |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 25 | int argc, char *const argv[]) |
Mike Frysinger | f79507e | 2008-01-29 18:21:05 -0500 | [diff] [blame] | 26 | { |
Mike Frysinger | e60644a | 2008-04-13 19:42:18 -0400 | [diff] [blame] | 27 | unsigned long ret; |
| 28 | |
Mike Frysinger | f79507e | 2008-01-29 18:21:05 -0500 | [diff] [blame] | 29 | /* |
Mike Frysinger | e60644a | 2008-04-13 19:42:18 -0400 | [diff] [blame] | 30 | * pass address parameter as argv[0] (aka command name), |
| 31 | * and all remaining args |
| 32 | */ |
Daniel Schwierzeck | fa87af3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 33 | ret = entry(argc, argv); |
Mike Frysinger | f79507e | 2008-01-29 18:21:05 -0500 | [diff] [blame] | 34 | |
Mike Frysinger | e60644a | 2008-04-13 19:42:18 -0400 | [diff] [blame] | 35 | return ret; |
| 36 | } |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 37 | |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 38 | /* Interpreter command to boot an arbitrary ELF image from memory */ |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 39 | 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] | 40 | { |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 41 | unsigned long addr; /* Address of the ELF image */ |
| 42 | unsigned long rc; /* Return value from user code */ |
Tom Rini | 3c95c79 | 2017-05-18 17:03:07 -0400 | [diff] [blame] | 43 | char *sload = NULL; |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 44 | const char *ep = env_get("autostart"); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 45 | int rcode = 0; |
| 46 | |
Tom Rini | 3c95c79 | 2017-05-18 17:03:07 -0400 | [diff] [blame] | 47 | /* Consume 'bootelf' */ |
| 48 | argc--; argv++; |
Mike Frysinger | e6dc29f | 2010-10-02 15:44:53 -0400 | [diff] [blame] | 49 | |
Tom Rini | 3c95c79 | 2017-05-18 17:03:07 -0400 | [diff] [blame] | 50 | /* Check for flag. */ |
| 51 | if (argc >= 1 && (argv[0][0] == '-' && \ |
| 52 | (argv[0][1] == 'p' || argv[0][1] == 's'))) { |
| 53 | sload = argv[0]; |
| 54 | /* Consume flag. */ |
| 55 | argc--; argv++; |
| 56 | } |
| 57 | /* Check for address. */ |
| 58 | if (argc >= 1 && strict_strtoul(argv[0], 16, &addr) != -EINVAL) { |
| 59 | /* Consume address */ |
| 60 | argc--; argv++; |
| 61 | } else |
Simon Glass | 892265d | 2019-12-28 10:45:02 -0700 | [diff] [blame] | 62 | addr = image_load_addr; |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 63 | |
Daniel Schwierzeck | fa87af3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 64 | if (!valid_elf_image(addr)) |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 65 | return 1; |
| 66 | |
Mike Frysinger | e6dc29f | 2010-10-02 15:44:53 -0400 | [diff] [blame] | 67 | if (sload && sload[1] == 'p') |
| 68 | addr = load_elf_image_phdr(addr); |
| 69 | else |
| 70 | addr = load_elf_image_shdr(addr); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 71 | |
Siva Durga Prasad Paladugu | 3825bfa | 2015-03-09 12:46:47 +0100 | [diff] [blame] | 72 | if (ep && !strcmp(ep, "no")) |
| 73 | return rcode; |
| 74 | |
Daniel Schwierzeck | fa87af3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 75 | printf("## Starting application at 0x%08lx ...\n", addr); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 76 | |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 77 | /* |
| 78 | * pass address parameter as argv[0] (aka command name), |
| 79 | * and all remaining args |
| 80 | */ |
Tom Rini | 3c95c79 | 2017-05-18 17:03:07 -0400 | [diff] [blame] | 81 | rc = do_bootelf_exec((void *)addr, argc, argv); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 82 | if (rc != 0) |
| 83 | rcode = 1; |
| 84 | |
Daniel Schwierzeck | fa87af3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 85 | printf("## Application terminated, rc = 0x%lx\n", rc); |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 86 | |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 87 | return rcode; |
| 88 | } |
| 89 | |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 90 | /* |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 91 | * Interpreter command to boot VxWorks from a memory image. The image can |
| 92 | * be either an ELF image or a raw binary. Will attempt to setup the |
| 93 | * bootline and other parameters correctly. |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 94 | */ |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 95 | 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] | 96 | { |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 97 | unsigned long addr; /* Address of image */ |
Bin Meng | 75f4b72 | 2018-04-11 22:02:22 -0700 | [diff] [blame] | 98 | unsigned long bootaddr = 0; /* Address to put the bootline */ |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 99 | char *bootline; /* Text of the bootline */ |
| 100 | char *tmp; /* Temporary char pointer */ |
| 101 | char build_buf[128]; /* Buffer for building the bootline */ |
Bin Meng | 0401c86 | 2015-10-07 20:19:15 -0700 | [diff] [blame] | 102 | int ptr = 0; |
Bin Meng | 321e860 | 2015-10-07 20:19:18 -0700 | [diff] [blame] | 103 | #ifdef CONFIG_X86 |
Bin Meng | e3be890 | 2018-04-11 22:02:07 -0700 | [diff] [blame] | 104 | ulong base; |
Bin Meng | dde4ebb | 2018-04-11 22:02:09 -0700 | [diff] [blame] | 105 | struct e820_info *info; |
Bin Meng | 4b8fc74 | 2018-04-11 22:02:11 -0700 | [diff] [blame] | 106 | struct e820_entry *data; |
Bin Meng | 71606c4 | 2018-04-11 22:02:19 -0700 | [diff] [blame] | 107 | struct efi_gop_info *gop; |
| 108 | struct vesa_mode_info *vesa = &mode_info.vesa; |
Bin Meng | 321e860 | 2015-10-07 20:19:18 -0700 | [diff] [blame] | 109 | #endif |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 110 | |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 111 | /* |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 112 | * Check the loadaddr variable. |
| 113 | * If we don't know where the image is then we're done. |
| 114 | */ |
Stany MARCEL | e5deaf58 | 2013-11-27 14:48:43 +0100 | [diff] [blame] | 115 | if (argc < 2) |
Simon Glass | 892265d | 2019-12-28 10:45:02 -0700 | [diff] [blame] | 116 | addr = image_load_addr; |
Stefan Roese | 0048778 | 2006-11-29 12:53:15 +0100 | [diff] [blame] | 117 | else |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 118 | addr = hextoul(argv[1], NULL); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 119 | |
Jon Loeliger | 54324d0 | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 120 | #if defined(CONFIG_CMD_NET) |
Daniel Schwierzeck | fa87af3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 121 | /* |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 122 | * Check to see if we need to tftp the image ourselves |
| 123 | * before starting |
Daniel Schwierzeck | fa87af3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 124 | */ |
Stany MARCEL | e5deaf58 | 2013-11-27 14:48:43 +0100 | [diff] [blame] | 125 | if ((argc == 2) && (strcmp(argv[1], "tftp") == 0)) { |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 126 | if (net_loop(TFTPGET) <= 0) |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 127 | return 1; |
Daniel Schwierzeck | fa87af3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 128 | printf("Automatic boot of VxWorks image at address 0x%08lx ...\n", |
| 129 | addr); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 130 | } |
| 131 | #endif |
| 132 | |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 133 | /* |
| 134 | * This should equate to |
| 135 | * NV_RAM_ADRS + NV_BOOT_OFFSET + NV_ENET_OFFSET |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 136 | * from the VxWorks BSP header files. |
| 137 | * This will vary from board to board |
| 138 | */ |
Tuomas Tynkkynen | f66276d | 2018-01-21 18:16:42 +0200 | [diff] [blame] | 139 | #if defined(CONFIG_SYS_VXWORKS_MAC_PTR) |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 140 | tmp = (char *)CONFIG_SYS_VXWORKS_MAC_PTR; |
Simon Glass | 399a9ce | 2017-08-03 12:22:14 -0600 | [diff] [blame] | 141 | eth_env_get_enetaddr("ethaddr", (uchar *)build_buf); |
Mike Frysinger | 8bcee04 | 2009-02-11 18:51:43 -0500 | [diff] [blame] | 142 | memcpy(tmp, build_buf, 6); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 143 | #else |
Daniel Schwierzeck | fa87af3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 144 | puts("## Ethernet MAC address not copied to NV RAM\n"); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 145 | #endif |
| 146 | |
Bin Meng | 75f4b72 | 2018-04-11 22:02:22 -0700 | [diff] [blame] | 147 | #ifdef CONFIG_X86 |
| 148 | /* |
| 149 | * Get VxWorks's physical memory base address from environment, |
| 150 | * if we don't specify it in the environment, use a default one. |
| 151 | */ |
| 152 | base = env_get_hex("vx_phys_mem_base", VXWORKS_PHYS_MEM_BASE); |
| 153 | data = (struct e820_entry *)(base + E820_DATA_OFFSET); |
| 154 | info = (struct e820_info *)(base + E820_INFO_OFFSET); |
| 155 | |
| 156 | memset(info, 0, sizeof(struct e820_info)); |
| 157 | info->sign = E820_SIGNATURE; |
| 158 | info->entries = install_e820_map(E820MAX, data); |
| 159 | info->addr = (info->entries - 1) * sizeof(struct e820_entry) + |
| 160 | E820_DATA_OFFSET; |
| 161 | |
| 162 | /* |
| 163 | * Explicitly clear the bootloader image size otherwise if memory |
| 164 | * at this offset happens to contain some garbage data, the final |
| 165 | * available memory size for the kernel is insane. |
| 166 | */ |
| 167 | *(u32 *)(base + BOOT_IMAGE_SIZE_OFFSET) = 0; |
| 168 | |
| 169 | /* |
| 170 | * Prepare compatible framebuffer information block. |
| 171 | * The VESA mode has to be 32-bit RGBA. |
| 172 | */ |
| 173 | if (vesa->x_resolution && vesa->y_resolution) { |
| 174 | gop = (struct efi_gop_info *)(base + EFI_GOP_INFO_OFFSET); |
| 175 | gop->magic = EFI_GOP_INFO_MAGIC; |
| 176 | gop->info.version = 0; |
| 177 | gop->info.width = vesa->x_resolution; |
| 178 | gop->info.height = vesa->y_resolution; |
| 179 | gop->info.pixel_format = EFI_GOT_RGBA8; |
| 180 | gop->info.pixels_per_scanline = vesa->bytes_per_scanline / 4; |
| 181 | gop->fb_base = vesa->phys_base_ptr; |
| 182 | gop->fb_size = vesa->bytes_per_scanline * vesa->y_resolution; |
| 183 | } |
| 184 | #endif |
| 185 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 186 | /* |
| 187 | * Use bootaddr to find the location in memory that VxWorks |
Bin Meng | fb694b9 | 2015-10-07 20:19:17 -0700 | [diff] [blame] | 188 | * will look for the bootline string. The default value is |
| 189 | * (LOCAL_MEM_LOCAL_ADRS + BOOT_LINE_OFFSET) as defined by |
| 190 | * VxWorks BSP. For example, on PowerPC it defaults to 0x4200. |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 191 | */ |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 192 | tmp = env_get("bootaddr"); |
Bin Meng | fb694b9 | 2015-10-07 20:19:17 -0700 | [diff] [blame] | 193 | if (!tmp) { |
Bin Meng | 75f4b72 | 2018-04-11 22:02:22 -0700 | [diff] [blame] | 194 | #ifdef CONFIG_X86 |
| 195 | bootaddr = base + X86_BOOT_LINE_OFFSET; |
| 196 | #else |
Bin Meng | fb694b9 | 2015-10-07 20:19:17 -0700 | [diff] [blame] | 197 | printf("## VxWorks bootline address not specified\n"); |
Bin Meng | 051f95e | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 198 | return 1; |
Bin Meng | 75f4b72 | 2018-04-11 22:02:22 -0700 | [diff] [blame] | 199 | #endif |
Bin Meng | 051f95e | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Bin Meng | 75f4b72 | 2018-04-11 22:02:22 -0700 | [diff] [blame] | 202 | if (!bootaddr) |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 203 | bootaddr = hextoul(tmp, NULL); |
Bin Meng | 051f95e | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 204 | |
| 205 | /* |
| 206 | * Check to see if the bootline is defined in the 'bootargs' parameter. |
| 207 | * If it is not defined, we may be able to construct the info. |
| 208 | */ |
| 209 | bootline = env_get("bootargs"); |
| 210 | if (!bootline) { |
| 211 | tmp = env_get("bootdev"); |
| 212 | if (tmp) { |
| 213 | strcpy(build_buf, tmp); |
| 214 | ptr = strlen(tmp); |
| 215 | } else { |
| 216 | printf("## VxWorks boot device not specified\n"); |
| 217 | } |
| 218 | |
| 219 | tmp = env_get("bootfile"); |
| 220 | if (tmp) |
| 221 | ptr += sprintf(build_buf + ptr, "host:%s ", tmp); |
| 222 | else |
| 223 | ptr += sprintf(build_buf + ptr, "host:vxWorks "); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 224 | |
Bin Meng | fb694b9 | 2015-10-07 20:19:17 -0700 | [diff] [blame] | 225 | /* |
Bin Meng | 051f95e | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 226 | * The following parameters are only needed if 'bootdev' |
| 227 | * is an ethernet device, otherwise they are optional. |
Bin Meng | fb694b9 | 2015-10-07 20:19:17 -0700 | [diff] [blame] | 228 | */ |
Bin Meng | 051f95e | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 229 | tmp = env_get("ipaddr"); |
| 230 | if (tmp) { |
| 231 | ptr += sprintf(build_buf + ptr, "e=%s", tmp); |
| 232 | tmp = env_get("netmask"); |
Ben Whitten | 34fd6c9 | 2015-12-30 13:05:58 +0000 | [diff] [blame] | 233 | if (tmp) { |
Bin Meng | 051f95e | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 234 | u32 mask = env_get_ip("netmask").s_addr; |
Bin Meng | fb694b9 | 2015-10-07 20:19:17 -0700 | [diff] [blame] | 235 | ptr += sprintf(build_buf + ptr, |
Bin Meng | 051f95e | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 236 | ":%08x ", ntohl(mask)); |
| 237 | } else { |
| 238 | ptr += sprintf(build_buf + ptr, " "); |
Bin Meng | bf0ba25 | 2015-10-07 20:19:16 -0700 | [diff] [blame] | 239 | } |
Bin Meng | 051f95e | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 240 | } |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 241 | |
Bin Meng | 051f95e | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 242 | tmp = env_get("serverip"); |
| 243 | if (tmp) |
| 244 | ptr += sprintf(build_buf + ptr, "h=%s ", tmp); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 245 | |
Bin Meng | 051f95e | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 246 | tmp = env_get("gatewayip"); |
| 247 | if (tmp) |
| 248 | ptr += sprintf(build_buf + ptr, "g=%s ", tmp); |
Bin Meng | bf0ba25 | 2015-10-07 20:19:16 -0700 | [diff] [blame] | 249 | |
Bin Meng | 051f95e | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 250 | tmp = env_get("hostname"); |
| 251 | if (tmp) |
| 252 | ptr += sprintf(build_buf + ptr, "tn=%s ", tmp); |
Daniel Schwierzeck | fa87af3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 253 | |
Bin Meng | 051f95e | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 254 | tmp = env_get("othbootargs"); |
| 255 | if (tmp) { |
| 256 | strcpy(build_buf + ptr, tmp); |
| 257 | ptr += strlen(tmp); |
Bin Meng | fb694b9 | 2015-10-07 20:19:17 -0700 | [diff] [blame] | 258 | } |
| 259 | |
Bin Meng | 051f95e | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 260 | bootline = build_buf; |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 261 | } |
| 262 | |
Bin Meng | 051f95e | 2018-04-11 22:02:21 -0700 | [diff] [blame] | 263 | memcpy((void *)bootaddr, bootline, max(strlen(bootline), (size_t)255)); |
| 264 | flush_cache(bootaddr, max(strlen(bootline), (size_t)255)); |
| 265 | printf("## Using bootline (@ 0x%lx): %s\n", bootaddr, (char *)bootaddr); |
| 266 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 267 | /* |
| 268 | * If the data at the load address is an elf image, then |
| 269 | * treat it like an elf image. Otherwise, assume that it is a |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 270 | * binary image. |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 271 | */ |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 272 | if (valid_elf_image(addr)) |
Christian Gmeiner | ae7d4be | 2018-03-20 14:18:25 +0100 | [diff] [blame] | 273 | addr = load_elf_image_phdr(addr); |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 274 | else |
Daniel Schwierzeck | fa87af3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 275 | puts("## Not an ELF image, assuming binary\n"); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 276 | |
Daniel Schwierzeck | fa87af3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 277 | printf("## Starting vxWorks at 0x%08lx ...\n", addr); |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 278 | |
Reinhard Arlt | 4fa117c | 2011-11-18 09:06:52 +0000 | [diff] [blame] | 279 | dcache_disable(); |
Vasyl Vavrychuk | 70b551c | 2018-04-10 12:36:36 +0300 | [diff] [blame] | 280 | #if defined(CONFIG_ARM64) && defined(CONFIG_ARMV8_PSCI) |
| 281 | armv8_setup_psci(); |
| 282 | smp_kick_all_cpus(); |
| 283 | #endif |
| 284 | |
Bin Meng | f6900e2 | 2015-10-07 20:19:19 -0700 | [diff] [blame] | 285 | #ifdef CONFIG_X86 |
| 286 | /* VxWorks on x86 uses stack to pass parameters */ |
| 287 | ((asmlinkage void (*)(int))addr)(0); |
| 288 | #else |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 289 | ((void (*)(int))addr)(0); |
Bin Meng | f6900e2 | 2015-10-07 20:19:19 -0700 | [diff] [blame] | 290 | #endif |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 291 | |
Daniel Schwierzeck | fa87af3 | 2012-09-16 06:55:05 +0000 | [diff] [blame] | 292 | puts("## vxWorks terminated\n"); |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 293 | |
wdenk | 458ded3 | 2002-09-20 10:59:08 +0000 | [diff] [blame] | 294 | return 1; |
| 295 | } |
| 296 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 297 | U_BOOT_CMD( |
Tom Rini | 3c95c79 | 2017-05-18 17:03:07 -0400 | [diff] [blame] | 298 | bootelf, CONFIG_SYS_MAXARGS, 0, do_bootelf, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 299 | "Boot from an ELF image in memory", |
Mike Frysinger | e6dc29f | 2010-10-02 15:44:53 -0400 | [diff] [blame] | 300 | "[-p|-s] [address]\n" |
| 301 | "\t- load ELF image at [address] via program headers (-p)\n" |
| 302 | "\t or via section headers (-s)" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 303 | ); |
| 304 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 305 | U_BOOT_CMD( |
Bin Meng | 53f3afb | 2015-10-07 20:19:13 -0700 | [diff] [blame] | 306 | bootvx, 2, 0, do_bootvx, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 307 | "Boot vxWorks from an ELF image", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 308 | " [address] - load address of vxWorks ELF image." |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 309 | ); |