void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) { debug("image entry point: 0x%X\n", spl_image->entry_point); start_cpu((u32)spl_image->entry_point); halt_avp(); }
static void smm_other_cpus(struct bus *cpu_bus, device_t bsp_cpu) { device_t cpu; int pre_count = atomic_read(&active_cpus); /* Loop through the cpus once to let them run through SMM relocator */ for (cpu = cpu_bus->children; cpu; cpu = cpu->sibling) { if (cpu->path.type != DEVICE_PATH_APIC) continue; printk(BIOS_ERR, "considering CPU 0x%02x for SMM init\n", cpu->path.apic.apic_id); if (cpu == bsp_cpu) continue; if (!cpu->enabled) continue; if (!start_cpu(cpu)) /* Record the error in cpu? */ printk(BIOS_ERR, "CPU 0x%02x would not start!\n", cpu->path.apic.apic_id); /* FIXME: endless loop */ while (atomic_read(&active_cpus) != pre_count) ; } }
static int cntrl_start_cpu(unsigned int id, void (*entry)(void)) { if (id >= CONFIG_MAX_CPUS) return -1; start_cpu(id, entry); return 0; }
void ccplex_cpu_start(void *entry_addr) { /* Enable common clocks for the shared resources between the cores. */ start_common_clocks(); start_cpu(0, entry_addr); }
static void start_other_cpus(struct bus *cpu_bus, struct device *bsp_cpu) { struct device *cpu; /* Loop through the cpus once getting them started */ for (cpu = cpu_bus->children; cpu; cpu = cpu->sibling) { if (cpu->path.type != DEVICE_PATH_APIC) continue; if (IS_ENABLED(CONFIG_PARALLEL_CPU_INIT) && (cpu == bsp_cpu)) continue; if (!cpu->enabled) continue; if (cpu->initialized) continue; if (!start_cpu(cpu)) /* Record the error in cpu? */ printk(BIOS_ERR, "CPU 0x%02x would not start!\n", cpu->path.apic.apic_id); if (!IS_ENABLED(CONFIG_PARALLEL_CPU_INIT)) udelay(10); } }
static int cntrl_start_cpu(unsigned int id, void (*entry)(void)) { if (id != 1) return -1; start_cpu(1, entry); return 0; }
static void start_each_secondary(int fdtnode, u64 regval __unused, void *info) { struct secondary_entry_data *datap = info; struct start_threads ret = start_cpu(fdtnode, datap->entry, datap->r3); nr_threads += ret.nr_threads; datap->nr_started += ret.nr_started; }
int main(int argc,char *argv[]){ if(argc==4){ sscanf(argv[3],"%d",&stop_ins); } init_sim(); int program_start= load_program(argv[1]); printf("\n"); start_cpu(); return 0; }
/* * Add a new virtual cpu to the domain. */ static int vcpu_config_new(processorid_t id) { extern int start_cpu(processorid_t); int error; if (ncpus == 1) { printf("cannot (yet) add cpus to a single-cpu domain\n"); return (ENOTSUP); } affinity_set(CPU_CURRENT); error = start_cpu(id); affinity_clear(); return (error); }
/* * This routine is used to start a previously powered off processor. * Note that restarted cpus are initialized into the offline state. */ void restart_other_cpu(int cpuid) { struct cpu *cp; kthread_id_t tp; caddr_t sp; extern void idle(); ASSERT(MUTEX_HELD(&cpu_lock)); ASSERT(cpuid < NCPU && cpu[cpuid] != NULL); /* * Obtain pointer to the appropriate cpu structure. */ cp = cpu[cpuid]; common_startup_init(cp, cpuid); /* * idle thread t_lock is held when the idle thread is suspended. * Manually unlock the t_lock of idle loop so that we can resume * the suspended idle thread. * Also adjust the PC of idle thread for re-retry. */ cp->cpu_intr_actv = 0; /* clear the value from previous life */ cp->cpu_m.mutex_ready = 0; /* we are not ready yet */ lock_clear(&cp->cpu_idle_thread->t_lock); tp = cp->cpu_idle_thread; sp = tp->t_stk; tp->t_sp = (uintptr_t)((struct rwindow *)sp - 1) - STACK_BIAS; tp->t_pc = (uintptr_t)idle - 8; /* * restart the cpu now */ promsafe_pause_cpus(); start_cpu(cpuid, warm_flag_set); start_cpus(); /* call cmn_err outside pause_cpus/start_cpus to avoid deadlock */ cmn_err(CE_CONT, "!cpu%d initialization complete - restarted\n", cpuid); }
void board_init_r(gd_t *id, ulong dummy) { struct pmux_tri_ctlr *pmt = (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE; /* enable JTAG */ writel(0xC0, &pmt->pmt_cfg_ctl); debug(">>spl:board_init_r()\n"); mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START, CONFIG_SYS_SPL_MALLOC_SIZE); #ifdef CONFIG_SPL_BOARD_INIT spl_board_init(); #endif clock_early_init(); serial_init(); preloader_console_init(); start_cpu((u32)CONFIG_SYS_TEXT_BASE); halt_avp(); /* not reached */ }
int mainloop(char **arg) { static uint64_t ovfl_count = 0; /* static to avoid setjmp issue */ struct pollfd pollfds[1]; int ret; int fd = -1; int i; if (pfm_initialize() != PFM_SUCCESS) errx(1, "libpfm initialization failed\n"); pgsz = sysconf(_SC_PAGESIZE); map_size = (options.mmap_pages+1)*pgsz; if (options.cgroup) { fd = open_cgroup(options.cgroup); if (fd == -1) err(1, "cannot open cgroup file %s\n", options.cgroup); } setup_cpu(options.cpu, fd); signal(SIGALRM, handler); signal(SIGINT, handler); pollfds[0].fd = fds[0].fd; pollfds[0].events = POLLIN; printf("monitoring on CPU%d, session ending in %ds\n", options.cpu, options.delay); if (setjmp(jbuf) == 1) goto terminate_session; start_cpu(); alarm(options.delay); /* * core loop */ for(;;) { ret = poll(pollfds, 1, -1); if (ret < 0 && errno == EINTR) break; ovfl_count++; process_smpl_buf(&fds[0]); } terminate_session: for(i=0; i < num_fds; i++) close(fds[i].fd); /* check for partial event buffer */ process_smpl_buf(&fds[0]); munmap(fds[0].buf, map_size); free(fds); printf("%"PRIu64" samples collected in %"PRIu64" poll events, %"PRIu64" lost samples\n", collected_samples, ovfl_count, lost_samples); return 0; }
/*ARGSUSED*/ void start_other_cpus(int flag) { int cpuid; extern void idlestop_init(void); int bootcpu; /* * Check if cpu_bringup_set has been explicitly set before * initializing it. */ if (CPUSET_ISNULL(cpu_bringup_set)) { CPUSET_ALL(cpu_bringup_set); } if (&cpu_feature_init) cpu_feature_init(); /* * Initialize CPC. */ kcpc_hw_init(); mutex_enter(&cpu_lock); /* * Initialize our own cpu_info. */ init_cpu_info(CPU); /* * Initialize CPU 0 cpu module private data area, including scrubber. */ cpu_init_private(CPU); populate_idstr(CPU); /* * perform such initialization as is needed * to be able to take CPUs on- and off-line. */ cpu_pause_init(); xc_init(); /* initialize processor crosscalls */ idlestop_init(); if (!use_mp) { mutex_exit(&cpu_lock); cmn_err(CE_CONT, "?***** Not in MP mode\n"); return; } /* * should we be initializing this cpu? */ bootcpu = getprocessorid(); /* * launch all the slave cpus now */ for (cpuid = 0; cpuid < NCPU; cpuid++) { pnode_t nodeid = cpunodes[cpuid].nodeid; if (nodeid == (pnode_t)0) continue; if (cpuid == bootcpu) { if (!CPU_IN_SET(cpu_bringup_set, cpuid)) { cmn_err(CE_WARN, "boot cpu not a member " "of cpu_bringup_set, adding it"); CPUSET_ADD(cpu_bringup_set, cpuid); } continue; } if (!CPU_IN_SET(cpu_bringup_set, cpuid)) continue; ASSERT(cpu[cpuid] == NULL); if (setup_cpu_common(cpuid)) { cmn_err(CE_PANIC, "cpu%d: setup failed", cpuid); } common_startup_init(cpu[cpuid], cpuid); start_cpu(cpuid, cold_flag_set); /* * Because slave_startup() gets fired off after init() * starts, we can't use the '?' trick to do 'boot -v' * printing - so we always direct the 'cpu .. online' * messages to the log. */ cmn_err(CE_CONT, "!cpu%d initialization complete - online\n", cpuid); cpu_state_change_notify(cpuid, CPU_SETUP); if (dtrace_cpu_init != NULL) (*dtrace_cpu_init)(cpuid); } /* * since all the cpus are online now, redistribute interrupts to them. */ intr_redist_all_cpus(); mutex_exit(&cpu_lock); /* * Start the Ecache scrubber. Must be done after all calls to * cpu_init_private for every cpu (including CPU 0). */ cpu_init_cache_scrub(); if (&cpu_mp_init) cpu_mp_init(); }
void measure(void) { int c, cmin, cmax, ncpus; int cfd = -1; cmin = 0; cmax = (int)sysconf(_SC_NPROCESSORS_ONLN); ncpus = cmax; if (options.cpu != -1) { cmin = options.cpu; cmax = cmin + 1; } all_fds = malloc(ncpus * sizeof(perf_event_desc_t *)); if (!all_fds) err(1, "cannot allocate memory for all_fds"); if (options.cgroup_name) { cfd = open_cgroup(options.cgroup_name); if (cfd == -1) exit(1); } for(c=cmin ; c < cmax; c++) setup_cpu(c, cfd); printf("<press CTRL-C to quit before %ds time limit>\n", options.delay); /* * FIX this for hotplug CPU */ if (options.interval) { struct timespec tv; int delay; for (delay = 1 ; delay <= options.delay; delay++) { for(c=cmin ; c < cmax; c++) start_cpu(c); if (0) { tv.tv_sec = 0; tv.tv_nsec = 100000000; nanosleep(&tv, NULL); } else sleep(1); for(c=cmin ; c < cmax; c++) stop_cpu(c); for(c = cmin; c < cmax; c++) { printf("# %'ds -----\n", delay); read_cpu(c); } } } else { for(c=cmin ; c < cmax; c++) start_cpu(c); sleep(options.delay); if (0) for(c=cmin ; c < cmax; c++) stop_cpu(c); for(c = cmin; c < cmax; c++) { printf("# -----\n"); read_cpu(c); } } for(c = cmin; c < cmax; c++) close_cpu(c); free(all_fds); }
int main(int argc, char** argv) { int fd, n; unsigned long loadaddr; char* p; char m4IsStopped = 0; char m4IsRunning = 0; int m4TraceFlags = 0; int m4Retry; char* filepath = argv[1]; int currentSoC = -1; if (argc < 2) { LogError(HEADER); LogError("-- %s -- \nUsage:\n" "%s [filename.bin] [0xLOADADDR] [--verbose] # loads new firmware\n" "or: %s stop # holds the auxiliary core in reset\n" "or: %s start # releases the auxiliary core from reset\n" "or: %s kick [n] # triggers interrupt on RPMsg virtqueue n\n", NAME_OF_UTILITY, argv[0], argv[0], argv[0], argv[0], argv[0]); return RETURN_CODE_ARGUMENTS_ERROR; } currentSoC = get_board_id(); if (currentSoC == -1) { LogError(HEADER); LogError("Board is not supported.\n"); return RETURN_CODE_ARGUMENTS_ERROR; } fd = open("/dev/mem", O_RDWR | O_SYNC); if (fd < 0) { LogError(HEADER); LogError("Could not open /dev/mem, are you root?\n"); return RETURN_CODE_ARGUMENTS_ERROR; } /* PARTIAL COMMANDS */ if (!strcmp(argv[1], "stop")) { stop_cpu(fd, currentSoC); return RETURN_CODE_OK; } else if (!strcmp(argv[1], "start")) { start_cpu(fd, currentSoC); return RETURN_CODE_OK; } else if (!strcmp(argv[1], "kick")) { if (argc < 3) { LogError(HEADER); LogError("%s - Usage: %s kick {vq_id to kick}\n", NAME_OF_UTILITY, argv[0]); return RETURN_CODE_ARGUMENTS_ERROR; } rpmsg_mu_kick(fd, currentSoC, strtoul(argv[2], &p, 16)); return RETURN_CODE_OK; } /* FW LOADING */ if (argc < 3) { LogError(HEADER); LogError("%s - Usage: %s [yourfwname.bin] [0xLOADADDR] [--verbose]\n", NAME_OF_UTILITY, argv[0]); return RETURN_CODE_ARGUMENTS_ERROR; } if (access(filepath, F_OK) == -1) { LogError("File %s not found.\n", argv[1]); return RETURN_CODE_ARGUMENTS_ERROR; } loadaddr = strtoul(argv[2], &p, 16); if (argc == 4) { if (!strcmp(argv[3], "--verbose")) { verbose = 1; } else { LogError(HEADER); LogError("%s - Usage: %s [yourfwname.bin] [0xLOADADDR] [--verbose]\n", NAME_OF_UTILITY, argv[0]); return RETURN_CODE_ARGUMENTS_ERROR; } } LogVerbose("LoadAddr is: %X\n", loadaddr); LogVerbose("Will stop CPU now...\n"); stop_cpu(fd, currentSoC); LogVerbose("Will ungate M4 clock source...\n"); ungate_m4_clk(fd, currentSoC); LogVerbose("Will load M4 firmware...\n"); load_m4_fw(fd, currentSoC, filepath, loadaddr); LogVerbose("Will start CPU now...\n"); start_cpu(fd, currentSoC); LogVerbose("Done!\n"); close(fd); return RETURN_CODE_OK; }