2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2007 MIPS Technologies, Inc. All rights reserved.
7 * Copyright (C) 2013 Imagination Technologies Ltd.
9 * Arbitrary Monitor Interface
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/smp.h>
15 #include <asm/addrspace.h>
16 #include <asm/mipsmtregs.h>
17 #include <asm/mips-boards/launch.h>
20 int amon_cpu_avail(int cpu)
22 struct cpulaunch *launch = (struct cpulaunch *)CKSEG0ADDR(CPULAUNCH);
24 if (cpu < 0 || cpu >= NCPULAUNCH) {
25 pr_debug("avail: cpu%d is out of range\n", cpu);
30 if (!(launch->flags & LAUNCH_FREADY)) {
31 pr_debug("avail: cpu%d is not ready\n", cpu);
34 if (launch->flags & (LAUNCH_FGO|LAUNCH_FGONE)) {
35 pr_debug("avail: too late.. cpu%d is already gone\n", cpu);
42 int amon_cpu_start(int cpu,
43 unsigned long pc, unsigned long sp,
44 unsigned long gp, unsigned long a0)
46 volatile struct cpulaunch *launch =
47 (struct cpulaunch *)CKSEG0ADDR(CPULAUNCH);
49 if (!amon_cpu_avail(cpu))
51 if (cpu == smp_processor_id()) {
52 pr_debug("launch: I am cpu%d!\n", cpu);
57 pr_debug("launch: starting cpu%d\n", cpu);
64 smp_wmb(); /* Target must see parameters before go */
65 launch->flags |= LAUNCH_FGO;
66 smp_wmb(); /* Target must see go before we poll */
68 while ((launch->flags & LAUNCH_FGONE) == 0)
70 smp_rmb(); /* Target will be updating flags soon */
71 pr_debug("launch: cpu%d gone!\n", cpu);
76 #ifdef CONFIG_MIPS_VPE_LOADER
77 int vpe_run(struct vpe *v)
79 struct vpe_notifications *n;
81 if (amon_cpu_start(aprp_cpu_index(), v->__start, 0, 0, 0) < 0)
84 list_for_each_entry(n, &v->notify, list)
85 n->start(VPE_MODULE_MINOR);