blob: c195dc28ad70497fcd800c7296681dff68672417 [file] [log] [blame]
Aaron Williamse602dd52020-08-20 07:22:03 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2020 Stefan Roese <sr@denx.de>
4 */
5
6#include <command.h>
7#include <config.h>
8#include <cpu_func.h>
9#include <dm.h>
10#include <elf.h>
11#include <env.h>
Simon Glass401d1c42020-10-30 21:38:53 -060012#include <asm/global_data.h>
Aaron Williamse602dd52020-08-20 07:22:03 +020013
14#include <asm/io.h>
15#include <linux/compat.h>
16#include <linux/ctype.h>
17#include <linux/delay.h>
18#include <linux/io.h>
19
20#include <mach/cvmx-coremask.h>
21#include <mach/cvmx-bootinfo.h>
22#include <mach/cvmx-bootmem.h>
23#include <mach/cvmx-regs.h>
24#include <mach/cvmx-fuse.h>
25#include <mach/octeon-model.h>
26#include <mach/octeon-feature.h>
27#include <mach/bootoct_cmd.h>
Stefan Roeseb0f4ba02020-12-11 17:05:56 +010028#include <mach/cvmx-ciu-defs.h>
Aaron Williamse602dd52020-08-20 07:22:03 +020029
30DECLARE_GLOBAL_DATA_PTR;
31
32/* ToDo: Revisit these settings */
33#define OCTEON_RESERVED_LOW_MEM_SIZE (512 * 1024)
34#define OCTEON_RESERVED_LOW_BOOT_MEM_SIZE (1024 * 1024)
35#define BOOTLOADER_BOOTMEM_DESC_SPACE (1024 * 1024)
36
37/* Default stack and heap sizes, in bytes */
38#define DEFAULT_STACK_SIZE (1 * 1024 * 1024)
39#define DEFAULT_HEAP_SIZE (3 * 1024 * 1024)
40
41/**
42 * NOTE: This must duplicate octeon_boot_descriptor_t in the toolchain
43 * octeon-app-init.h file.
44 */
45enum {
46 /* If set, core should do app-wide init, only one core per app will have
47 * this flag set.
48 */
49 BOOT_FLAG_INIT_CORE = 1,
50 OCTEON_BL_FLAG_DEBUG = 1 << 1,
51 OCTEON_BL_FLAG_NO_MAGIC = 1 << 2,
52 /* If set, use uart1 for console */
53 OCTEON_BL_FLAG_CONSOLE_UART1 = 1 << 3,
54 OCTEON_BL_FLAG_CONSOLE_PCI = 1 << 4, /* If set, use PCI console */
55 /* Call exit on break on serial port */
56 OCTEON_BL_FLAG_BREAK = 1 << 5,
57 /*
58 * Be sure to update OCTEON_APP_INIT_H_VERSION when new fields are added
59 * and to conditionalize the new flag's usage based on the version.
60 */
61} octeon_boot_descriptor_flag;
62
63/**
64 * NOTE: This must duplicate octeon_boot_descriptor_t in the toolchain
65 * octeon-app-init.h file.
66 */
67#ifndef OCTEON_CURRENT_DESC_VERSION
68# define OCTEON_CURRENT_DESC_VERSION 7
69#endif
70/**
71 * NOTE: This must duplicate octeon_boot_descriptor_t in the toolchain
72 * octeon-app-init.h file.
73 */
74/* Version 7 changes: Change names of deprecated fields */
75#ifndef OCTEON_ARGV_MAX_ARGS
76# define OCTEON_ARGV_MAX_ARGS 64
77#endif
78
79/**
80 * NOTE: This must duplicate octeon_boot_descriptor_t in the toolchain
81 * octeon-app-init.h file.
82 */
83#ifndef OCTEON_SERIAL_LEN
84# define OCTEON_SERIAL_LEN 20
85#endif
86
87/**
88 * Bootloader structure used to pass info to Octeon executive startup code.
89 * NOTE: all fields are deprecated except for:
90 * * desc_version
91 * * desc_size,
92 * * heap_base
93 * * heap_end
94 * * eclock_hz
95 * * flags
96 * * argc
97 * * argv
98 * * cvmx_desc_vaddr
99 * * debugger_flags_base_addr
100 *
101 * All other fields have been moved to the cvmx_descriptor, and the new
102 * fields should be added there. They are left as placeholders in this
103 * structure for binary compatibility.
104 *
105 * NOTE: This structure must match what is in the toolchain octeon-app-init.h
106 * file.
107 */
108struct octeon_boot_descriptor {
109 /* Start of block referenced by assembly code - do not change! */
110 u32 desc_version;
111 u32 desc_size;
112 u64 stack_top;
113 u64 heap_base;
114 u64 heap_end;
115 u64 deprecated17;
116 u64 deprecated16;
117 /* End of block referenced by assembly code - do not change! */
118 u32 deprecated18;
119 u32 deprecated15;
120 u32 deprecated14;
121 u32 argc; /* argc for main() */
122 u32 argv[OCTEON_ARGV_MAX_ARGS]; /* argv for main() */
123 u32 flags; /* Flags for application */
124 u32 core_mask; /* Coremask running this image */
125 u32 dram_size; /* DEPRECATED, DRAM size in megabyes. Used up to SDK 1.8.1 */
126 u32 phy_mem_desc_addr;
127 u32 debugger_flags_base_addr; /* used to pass flags from app to debugger. */
128 u32 eclock_hz; /* CPU clock speed, in hz. */
129 u32 deprecated10;
130 u32 deprecated9;
131 u16 deprecated8;
132 u8 deprecated7;
133 u8 deprecated6;
134 u16 deprecated5;
135 u8 deprecated4;
136 u8 deprecated3;
137 char deprecated2[OCTEON_SERIAL_LEN];
138 u8 deprecated1[6];
139 u8 deprecated0;
140 u64 cvmx_desc_vaddr; /* Address of cvmx descriptor */
141};
142
143static struct octeon_boot_descriptor boot_desc[CVMX_MIPS_MAX_CORES];
144static struct cvmx_bootinfo cvmx_bootinfo_array[CVMX_MIPS_MAX_CORES];
145
146/**
147 * Programs the boot bus moveable region
148 * @param base base address to place the boot bus moveable region
149 * (bits [31:7])
150 * @param region_num Selects which region, 0 or 1 for node 0,
151 * 2 or 3 for node 1
152 * @param enable Set true to enable, false to disable
153 * @param data Pointer to data to put in the region, up to
154 * 16 dwords.
155 * @param num_words Number of data dwords (up to 32)
156 *
157 * @return 0 for success, -1 on error
158 */
159static int octeon_set_moveable_region(u32 base, int region_num,
160 bool enable, const u64 *data,
161 unsigned int num_words)
162{
163 int node = region_num >> 1;
164 u64 val;
165 int i;
166 u8 node_mask = 0x01; /* ToDo: Currently only one node is supported */
167
168 debug("%s(0x%x, %d, %d, %p, %u)\n", __func__, base, region_num, enable,
169 data, num_words);
170
171 if (num_words > 32) {
172 printf("%s: Too many words (%d) for region %d\n", __func__,
173 num_words, region_num);
174 return -1;
175 }
176
177 if (base & 0x7f) {
178 printf("%s: Error: base address 0x%x must be 128 byte aligned\n",
179 __func__, base);
180 return -1;
181 }
182
183 if (region_num > (node_mask > 1 ? 3 : 1)) {
184 printf("%s: Region number %d out of range\n",
185 __func__, region_num);
186 return -1;
187 }
188
189 if (!data && num_words > 0) {
190 printf("%s: Error: NULL data\n", __func__);
191 return -1;
192 }
193
194 region_num &= 1;
195
196 val = MIO_BOOT_LOC_CFG_EN |
197 FIELD_PREP(MIO_BOOT_LOC_CFG_BASE, base >> 7);
198 debug("%s: Setting MIO_BOOT_LOC_CFG(%d) on node %d to 0x%llx\n",
199 __func__, region_num, node, val);
200 csr_wr(CVMX_MIO_BOOT_LOC_CFGX(region_num & 1), val);
201
202 val = FIELD_PREP(MIO_BOOT_LOC_ADR_ADR, (region_num ? 0x80 : 0x00) >> 3);
203 debug("%s: Setting MIO_BOOT_LOC_ADR start to 0x%llx\n", __func__, val);
204 csr_wr(CVMX_MIO_BOOT_LOC_ADR, val);
205
206 for (i = 0; i < num_words; i++) {
207 debug(" 0x%02llx: 0x%016llx\n",
208 csr_rd(CVMX_MIO_BOOT_LOC_ADR), data[i]);
209 csr_wr(CVMX_MIO_BOOT_LOC_DAT, data[i]);
210 }
211
212 return 0;
213}
214
215/**
216 * Parse comma separated numbers into an array
217 *
218 * @param[out] values values read for each node
219 * @param[in] str string to parse
220 * @param base 0 for auto, otherwise 8, 10 or 16 for the number base
221 *
222 * @return number of values read.
223 */
224static int octeon_parse_nodes(u64 values[CVMX_MAX_NODES],
225 const char *str, int base)
226{
227 int node = 0;
228 char *sep;
229
230 do {
231 debug("Parsing node %d: \"%s\"\n", node, str);
232 values[node] = simple_strtoull(str, &sep, base);
233 debug(" node %d: 0x%llx\n", node, values[node]);
234 str = sep + 1;
235 } while (++node < CVMX_MAX_NODES && *sep == ',');
236
237 debug("%s: returning %d\n", __func__, node);
238 return node;
239}
240
241/**
242 * Parse command line arguments
243 *
244 * @param argc number of arguments
245 * @param[in] argv array of argument strings
246 * @param cmd command type
247 * @param[out] boot_args parsed values
248 *
249 * @return number of arguments parsed
250 */
251int octeon_parse_bootopts(int argc, char *const argv[],
252 enum octeon_boot_cmd_type cmd,
253 struct octeon_boot_args *boot_args)
254{
255 u64 node_values[CVMX_MAX_NODES];
256 int arg, j;
257 int num_values;
258 int node;
259 u8 node_mask = 0x01; /* ToDo: Currently only one node is supported */
260
261 debug("%s(%d, %p, %d, %p)\n", __func__, argc, argv, cmd, boot_args);
262 memset(boot_args, 0, sizeof(*boot_args));
263 boot_args->stack_size = DEFAULT_STACK_SIZE;
264 boot_args->heap_size = DEFAULT_HEAP_SIZE;
265 boot_args->node_mask = 0;
266
267 for (arg = 0; arg < argc; arg++) {
268 debug(" argv[%d]: %s\n", arg, argv[arg]);
269 if (cmd == BOOTOCT && !strncmp(argv[arg], "stack=", 6)) {
270 boot_args->stack_size = simple_strtoul(argv[arg] + 6,
271 NULL, 0);
272 } else if (cmd == BOOTOCT && !strncmp(argv[arg], "heap=", 5)) {
273 boot_args->heap_size = simple_strtoul(argv[arg] + 5,
274 NULL, 0);
275 } else if (!strncmp(argv[arg], "debug", 5)) {
276 puts("setting debug flag!\n");
277 boot_args->boot_flags |= OCTEON_BL_FLAG_DEBUG;
278 } else if (cmd == BOOTOCT && !strncmp(argv[arg], "break", 5)) {
279 puts("setting break flag!\n");
280 boot_args->boot_flags |= OCTEON_BL_FLAG_BREAK;
281 } else if (!strncmp(argv[arg], "forceboot", 9)) {
282 boot_args->forceboot = true;
283 } else if (!strncmp(argv[arg], "nodemask=", 9)) {
284 boot_args->node_mask = simple_strtoul(argv[arg] + 9,
285 NULL, 16);
286 } else if (!strncmp(argv[arg], "numcores=", 9)) {
287 memset(node_values, 0, sizeof(node_values));
288 num_values = octeon_parse_nodes(node_values,
289 argv[arg] + 9, 0);
290 for (j = 0; j < num_values; j++)
291 boot_args->num_cores[j] = node_values[j];
292 boot_args->num_cores_set = true;
293 } else if (!strncmp(argv[arg], "skipcores=", 10)) {
294 memset(node_values, 0, sizeof(node_values));
295 num_values = octeon_parse_nodes(node_values,
296 argv[arg] + 10, 0);
297 for (j = 0; j < num_values; j++)
298 boot_args->num_skipped[j] = node_values[j];
299 boot_args->num_skipped_set = true;
300 } else if (!strncmp(argv[arg], "console_uart=", 13)) {
301 boot_args->console_uart = simple_strtoul(argv[arg] + 13,
302 NULL, 0);
303 if (boot_args->console_uart == 1) {
304 boot_args->boot_flags |=
305 OCTEON_BL_FLAG_CONSOLE_UART1;
306 } else if (!boot_args->console_uart) {
307 boot_args->boot_flags &=
308 ~OCTEON_BL_FLAG_CONSOLE_UART1;
309 }
310 } else if (!strncmp(argv[arg], "coremask=", 9)) {
311 memset(node_values, 0, sizeof(node_values));
312 num_values = octeon_parse_nodes(node_values,
313 argv[arg] + 9, 16);
314 for (j = 0; j < num_values; j++)
315 cvmx_coremask_set64_node(&boot_args->coremask,
316 j, node_values[j]);
317 boot_args->coremask_set = true;
318 } else if (cmd == BOOTOCTLINUX &&
319 !strncmp(argv[arg], "namedblock=", 11)) {
320 boot_args->named_block = argv[arg] + 11;
321 } else if (!strncmp(argv[arg], "endbootargs", 11)) {
322 boot_args->endbootargs = 1;
323 arg++;
324 if (argc >= arg && cmd != BOOTOCTLINUX)
325 boot_args->app_name = argv[arg];
326 break;
327 } else {
328 debug(" Unknown argument \"%s\"\n", argv[arg]);
329 }
330 }
331
332 if (boot_args->coremask_set && boot_args->num_cores_set) {
333 puts("Warning: both coremask and numcores are set, using coremask.\n");
334 } else if (!boot_args->coremask_set && !boot_args->num_cores_set) {
335 cvmx_coremask_set_core(&boot_args->coremask, 0);
336 boot_args->coremask_set = true;
337 } else if ((!boot_args->coremask_set) && boot_args->num_cores_set) {
338 cvmx_coremask_for_each_node(node, node_mask)
339 cvmx_coremask_set64_node(&boot_args->coremask, node,
340 ((1ull << boot_args->num_cores[node]) - 1) <<
341 boot_args->num_skipped[node]);
342 boot_args->coremask_set = true;
343 }
344
345 /* Update the node mask based on the coremask or the number of cores */
346 for (j = 0; j < CVMX_MAX_NODES; j++) {
347 if (cvmx_coremask_get64_node(&boot_args->coremask, j))
348 boot_args->node_mask |= 1 << j;
349 }
350
351 debug("%s: return %d\n", __func__, arg);
352 return arg;
353}
354
355int do_bootoctlinux(struct cmd_tbl *cmdtp, int flag, int argc,
356 char *const argv[])
357{
358 typedef void __noreturn (*kernel_entry_t)(int, ulong, ulong, ulong);
359 kernel_entry_t kernel;
360 struct octeon_boot_args boot_args;
361 int arg_start = 1;
362 int arg_count;
363 u64 addr = 0; /* Address of the ELF image */
364 int arg0;
365 u64 arg1;
366 u64 arg2;
367 u64 arg3;
368 int ret;
369 struct cvmx_coremask core_mask;
370 struct cvmx_coremask coremask_to_run;
371 struct cvmx_coremask avail_coremask;
372 int first_core;
373 int core;
Aaron Williamse602dd52020-08-20 07:22:03 +0200374 const u64 *nmi_code;
375 int num_dwords;
376 u8 node_mask = 0x01;
377 int i;
378
379 cvmx_coremask_clear_all(&core_mask);
380 cvmx_coremask_clear_all(&coremask_to_run);
381
382 if (argc >= 2 && (isxdigit(argv[1][0]) && (isxdigit(argv[1][1]) ||
383 argv[1][1] == 'x' ||
384 argv[1][1] == 'X' ||
385 argv[1][1] == '\0'))) {
386 addr = simple_strtoul(argv[1], NULL, 16);
387 if (!addr)
388 addr = CONFIG_SYS_LOAD_ADDR;
389 arg_start++;
390 }
391 if (addr == 0)
392 addr = CONFIG_SYS_LOAD_ADDR;
393
394 debug("%s: arg start: %d\n", __func__, arg_start);
395 arg_count = octeon_parse_bootopts(argc - arg_start, argv + arg_start,
396 BOOTOCTLINUX, &boot_args);
397
398 debug("%s:\n"
399 " named block: %s\n"
400 " node mask: 0x%x\n"
401 " stack size: 0x%x\n"
402 " heap size: 0x%x\n"
403 " boot flags: 0x%x\n"
404 " force boot: %s\n"
405 " coremask set: %s\n"
406 " num cores set: %s\n"
407 " num skipped set: %s\n"
408 " endbootargs: %s\n",
409 __func__,
410 boot_args.named_block ? boot_args.named_block : "none",
411 boot_args.node_mask,
412 boot_args.stack_size,
413 boot_args.heap_size,
414 boot_args.boot_flags,
415 boot_args.forceboot ? "true" : "false",
416 boot_args.coremask_set ? "true" : "false",
417 boot_args.num_cores_set ? "true" : "false",
418 boot_args.num_skipped_set ? "true" : "false",
419 boot_args.endbootargs ? "true" : "false");
420 debug(" num cores: ");
421 for (i = 0; i < CVMX_MAX_NODES; i++)
422 debug("%s%d", i > 0 ? ", " : "", boot_args.num_cores[i]);
423 debug("\n num skipped: ");
424 for (i = 0; i < CVMX_MAX_NODES; i++) {
425 debug("%s%d", i > 0 ? ", " : "", boot_args.num_skipped[i]);
426 debug("\n coremask:\n");
427 cvmx_coremask_dprint(&boot_args.coremask);
428 }
429
430 if (boot_args.endbootargs) {
431 debug("endbootargs set, adjusting argc from %d to %d, arg_count: %d, arg_start: %d\n",
432 argc, argc - (arg_count + arg_start), arg_count,
433 arg_start);
434 argc -= (arg_count + arg_start);
435 argv += (arg_count + arg_start);
436 }
437
438 /*
439 * numcores specification overrides a coremask on the same command line
440 */
441 cvmx_coremask_copy(&core_mask, &boot_args.coremask);
442
443 /*
444 * Remove cores from coremask based on environment variable stored in
445 * flash
446 */
447 if (validate_coremask(&core_mask) != 0) {
448 puts("Invalid coremask.\n");
449 return 1;
450 } else if (cvmx_coremask_is_empty(&core_mask)) {
451 puts("Coremask is empty after coremask_override mask. Nothing to do.\n");
452 return 0;
453 }
454
455 if (cvmx_coremask_intersects(&core_mask, &coremask_to_run)) {
456 puts("ERROR: Can't load code on core twice! Provided coremask:\n");
457 cvmx_coremask_print(&core_mask);
458 puts("overlaps previously loaded coremask:\n");
459 cvmx_coremask_print(&coremask_to_run);
460 return -1;
461 }
462
463 debug("Setting up boot descriptor block with core mask:\n");
464 cvmx_coremask_dprint(&core_mask);
465
466 /*
467 * Add coremask to global mask of cores that have been set up and are
468 * runable
469 */
470 cvmx_coremask_or(&coremask_to_run, &coremask_to_run, &core_mask);
471
Aaron Williamse602dd52020-08-20 07:22:03 +0200472 /*
473 * Load kernel ELF image, or try binary if ELF is not detected.
474 * This way the much smaller vmlinux.bin can also be started but
475 * has to be loaded at the correct address (ep as parameter).
476 */
477 if (!valid_elf_image(addr))
478 printf("Booting binary image instead (vmlinux.bin)...\n");
479 else
480 addr = load_elf_image_shdr(addr);
481
482 /* Set kernel entry point */
483 kernel = (kernel_entry_t)addr;
484
485 /* Init bootmem list for Linux kernel booting */
486 if (!cvmx_bootmem_phy_mem_list_init(
Stefan Roeseb7eac192020-10-28 15:10:02 +0100487 gd->ram_size, OCTEON_RESERVED_LOW_MEM_SIZE,
Aaron Williamse602dd52020-08-20 07:22:03 +0200488 (void *)CKSEG0ADDR(BOOTLOADER_BOOTMEM_DESC_SPACE))) {
489 printf("FATAL: Error initializing free memory list\n");
490 return 0;
491 }
492
493 first_core = cvmx_coremask_get_first_core(&coremask_to_run);
494
495 cvmx_coremask_for_each_core(core, &coremask_to_run) {
496 debug("%s: Activating core %d\n", __func__, core);
497
498 cvmx_bootinfo_array[core].core_mask =
499 cvmx_coremask_get32(&coremask_to_run);
500 cvmx_coremask_copy(&cvmx_bootinfo_array[core].ext_core_mask,
501 &coremask_to_run);
502
503 if (core == first_core)
504 cvmx_bootinfo_array[core].flags |= BOOT_FLAG_INIT_CORE;
505
Stefan Roeseb7eac192020-10-28 15:10:02 +0100506 cvmx_bootinfo_array[core].dram_size = gd->ram_size /
507 (1024 * 1024);
Aaron Williamse602dd52020-08-20 07:22:03 +0200508
509 cvmx_bootinfo_array[core].dclock_hz = gd->mem_clk * 1000000;
510 cvmx_bootinfo_array[core].eclock_hz = gd->cpu_clk;
511
512 cvmx_bootinfo_array[core].led_display_base_addr = 0;
513 cvmx_bootinfo_array[core].phy_mem_desc_addr =
514 ((u32)(u64)__cvmx_bootmem_internal_get_desc_ptr()) &
515 0x7ffffff;
516
517 cvmx_bootinfo_array[core].major_version = CVMX_BOOTINFO_MAJ_VER;
518 cvmx_bootinfo_array[core].minor_version = CVMX_BOOTINFO_MIN_VER;
519 cvmx_bootinfo_array[core].fdt_addr = virt_to_phys(gd->fdt_blob);
520
521 boot_desc[core].dram_size = gd->ram_size / (1024 * 1024);
522 boot_desc[core].cvmx_desc_vaddr =
523 virt_to_phys(&cvmx_bootinfo_array[core]);
524
525 boot_desc[core].desc_version = OCTEON_CURRENT_DESC_VERSION;
526 boot_desc[core].desc_size = sizeof(boot_desc[0]);
527
528 boot_desc[core].flags = cvmx_bootinfo_array[core].flags;
529 boot_desc[core].eclock_hz = cvmx_bootinfo_array[core].eclock_hz;
530
531 boot_desc[core].argc = argc;
532 for (i = 0; i < argc; i++)
533 boot_desc[core].argv[i] = (u32)virt_to_phys(argv[i]);
534 }
535
536 core = 0;
537 arg0 = argc;
538 arg1 = (u64)argv;
539 arg2 = 0x1; /* Core 0 sets init core for Linux */
540 arg3 = XKPHYS | virt_to_phys(&boot_desc[core]);
541
542 debug("## Transferring control to Linux (at address %p) ...\n", kernel);
543
544 /*
545 * Flush cache before jumping to application. Let's flush the
546 * whole SDRAM area, since we don't know the size of the image
547 * that was loaded.
548 */
549 flush_cache(gd->ram_base, gd->ram_top - gd->ram_base);
550
551 /* Take all cores out of reset */
552 csr_wr(CVMX_CIU_PP_RST, 0);
553 sync();
554
555 /* Wait a short while for the other cores... */
556 mdelay(100);
557
558 /* Install boot code into moveable bus for NMI (other cores) */
559 nmi_code = (const u64 *)nmi_bootvector;
560 num_dwords = (((u64)&nmi_handler_para[0] - (u64)nmi_code) + 7) / 8;
561
562 ret = octeon_set_moveable_region(0x1fc00000, 0, true, nmi_code,
563 num_dwords);
564 if (ret) {
565 printf("Error installing NMI handler for SMP core startup\n");
566 return 0;
567 }
568
569 /* Write NMI handler parameters for Linux kernel booting */
570 nmi_handler_para[0] = (u64)kernel;
571 nmi_handler_para[1] = arg0;
572 nmi_handler_para[2] = arg1;
573 nmi_handler_para[3] = 0; /* Don't set init core for secondary cores */
574 nmi_handler_para[4] = arg3;
575 sync();
576
577 /* Wait a short while for the other cores... */
578 mdelay(100);
579
580 /*
581 * Cores have already been taken out of reset to conserve power.
582 * We need to send a NMI to get the cores out of their wait loop
583 */
584 octeon_get_available_coremask(&avail_coremask);
585 debug("Available coremask:\n");
586 cvmx_coremask_dprint(&avail_coremask);
587 debug("Starting coremask:\n");
588 cvmx_coremask_dprint(&coremask_to_run);
589 debug("Sending NMIs to other cores\n");
590 if (octeon_has_feature(OCTEON_FEATURE_CIU3)) {
591 u64 avail_cm;
592 int node;
593
594 cvmx_coremask_for_each_node(node, node_mask) {
595 avail_cm = cvmx_coremask_get64_node(&avail_coremask,
596 node);
597
598 if (avail_cm != 0) {
599 debug("Sending NMI to node %d, coremask=0x%llx, CIU3_NMI=0x%llx\n",
600 node, avail_cm,
601 (node > 0 ? -1ull : -2ull) & avail_cm);
602 csr_wr(CVMX_CIU3_NMI,
603 (node > 0 ? -1ull : -2ull) & avail_cm);
604 }
605 }
606 } else {
607 csr_wr(CVMX_CIU_NMI,
608 -2ull & cvmx_coremask_get64(&avail_coremask));
609 }
610 debug("Done sending NMIs\n");
611
612 /* Wait a short while for the other cores... */
613 mdelay(100);
614
615 /*
616 * pass address parameter as argv[0] (aka command name),
617 * and all remaining args
618 * a0 = argc
619 * a1 = argv (32 bit physical addresses, not pointers)
620 * a2 = init core
621 * a3 = boot descriptor address
622 * a4/t0 = entry point (only used by assembly stub)
623 */
624 kernel(arg0, arg1, arg2, arg3);
625
626 return 0;
627}
628
629U_BOOT_CMD(bootoctlinux, 32, 0, do_bootoctlinux,
630 "Boot from a linux ELF image in memory",
631 "elf_address [coremask=mask_to_run | numcores=core_cnt_to_run] "
632 "[forceboot] [skipcores=core_cnt_to_skip] [namedblock=name] [endbootargs] [app_args ...]\n"
633 "elf_address - address of ELF image to load. If 0, default load address\n"
634 " is used.\n"
635 "coremask - mask of cores to run on. Anded with coremask_override\n"
636 " environment variable to ensure only working cores are used\n"
637 "numcores - number of cores to run on. Runs on specified number of cores,\n"
638 " taking into account the coremask_override.\n"
639 "skipcores - only meaningful with numcores. Skips this many cores\n"
640 " (starting from 0) when loading the numcores cores.\n"
641 " For example, setting skipcores to 1 will skip core 0\n"
642 " and load the application starting at the next available core.\n"
643 "forceboot - if set, boots application even if core 0 is not in mask\n"
644 "namedblock - specifies a named block to load the kernel\n"
645 "endbootargs - if set, bootloader does not process any further arguments and\n"
646 " only passes the arguments that follow to the kernel.\n"
647 " If not set, the kernel gets the entire commnad line as\n"
648 " arguments.\n" "\n");