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/smp.h>
14 #include <asm/addrspace.h>
15 #include <asm/mipsmtregs.h>
16 #include <asm/mips-boards/launch.h>
19 int amon_cpu_avail(int cpu
)
21 struct cpulaunch
*launch
= (struct cpulaunch
*)CKSEG0ADDR(CPULAUNCH
);
23 if (cpu
< 0 || cpu
>= NCPULAUNCH
) {
24 pr_debug("avail: cpu%d is out of range\n", cpu
);
29 if (!(launch
->flags
& LAUNCH_FREADY
)) {
30 pr_debug("avail: cpu%d is not ready\n", cpu
);
33 if (launch
->flags
& (LAUNCH_FGO
|LAUNCH_FGONE
)) {
34 pr_debug("avail: too late.. cpu%d is already gone\n", cpu
);
41 int amon_cpu_start(int cpu
,
42 unsigned long pc
, unsigned long sp
,
43 unsigned long gp
, unsigned long a0
)
45 volatile struct cpulaunch
*launch
=
46 (struct cpulaunch
*)CKSEG0ADDR(CPULAUNCH
);
48 if (!amon_cpu_avail(cpu
))
50 if (cpu
== smp_processor_id()) {
51 pr_debug("launch: I am cpu%d!\n", cpu
);
56 pr_debug("launch: starting cpu%d\n", cpu
);
63 smp_wmb(); /* Target must see parameters before go */
64 launch
->flags
|= LAUNCH_FGO
;
65 smp_wmb(); /* Target must see go before we poll */
67 while ((launch
->flags
& LAUNCH_FGONE
) == 0)
69 smp_rmb(); /* Target will be updating flags soon */
70 pr_debug("launch: cpu%d gone!\n", cpu
);
75 #ifdef CONFIG_MIPS_VPE_LOADER_CMP
76 int vpe_run(struct vpe
*v
)
78 struct vpe_notifications
*n
;
80 if (amon_cpu_start(aprp_cpu_index(), v
->__start
, 0, 0, 0) < 0)
83 list_for_each_entry(n
, &v
->notify
, list
)
84 n
->start(VPE_MODULE_MINOR
);