2 * Copyright (C) 2007 MIPS Technologies, Inc.
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
18 * Arbitrary Monitor interface
21 #include <linux/kernel.h>
22 #include <linux/init.h>
23 #include <linux/smp.h>
25 #include <asm/addrspace.h>
26 #include <asm/mips-boards/launch.h>
27 #include <asm/mipsmtregs.h>
30 int amon_cpu_avail(int cpu)
32 struct cpulaunch *launch = (struct cpulaunch *)CKSEG0ADDR(CPULAUNCH);
34 if (cpu < 0 || cpu >= NCPULAUNCH) {
35 pr_debug("avail: cpu%d is out of range\n", cpu);
40 if (!(launch->flags & LAUNCH_FREADY)) {
41 pr_debug("avail: cpu%d is not ready\n", cpu);
44 if (launch->flags & (LAUNCH_FGO|LAUNCH_FGONE)) {
45 pr_debug("avail: too late.. cpu%d is already gone\n", cpu);
52 int amon_cpu_start(int cpu,
53 unsigned long pc, unsigned long sp,
54 unsigned long gp, unsigned long a0)
56 volatile struct cpulaunch *launch =
57 (struct cpulaunch *)CKSEG0ADDR(CPULAUNCH);
59 if (!amon_cpu_avail(cpu))
61 if (cpu == smp_processor_id()) {
62 pr_debug("launch: I am cpu%d!\n", cpu);
67 pr_debug("launch: starting cpu%d\n", cpu);
74 smp_wmb(); /* Target must see parameters before go */
75 launch->flags |= LAUNCH_FGO;
76 smp_wmb(); /* Target must see go before we poll */
78 while ((launch->flags & LAUNCH_FGONE) == 0)
80 smp_rmb(); /* Target will be updating flags soon */
81 pr_debug("launch: cpu%d gone!\n", cpu);
86 #ifdef CONFIG_MIPS_VPE_LOADER
87 int vpe_run(struct vpe *v)
89 struct vpe_notifications *n;
91 if (amon_cpu_start(aprp_cpu_index(), v->__start, 0, 0, 0) < 0)
94 list_for_each_entry(n, &v->notify, list)
95 n->start(VPE_MODULE_MINOR);