Linux Audio

Check our new training course

Loading...
v3.1
 1/*
 2 * Copyright (C) 2007  MIPS Technologies, Inc.
 3 *	All rights reserved.
 4
 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.
 8 *
 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
12 *  for more details.
13 *
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.
17 *
18 * Arbitrary Monitor interface
19 */
20
21#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/smp.h>
24
25#include <asm/addrspace.h>
26#include <asm/mips-boards/launch.h>
27#include <asm/mipsmtregs.h>
 
 
28
29int amon_cpu_avail(int cpu)
30{
31	struct cpulaunch *launch = (struct cpulaunch *)CKSEG0ADDR(CPULAUNCH);
32
33	if (cpu < 0 || cpu >= NCPULAUNCH) {
34		pr_debug("avail: cpu%d is out of range\n", cpu);
35		return 0;
36	}
37
38	launch += cpu;
39	if (!(launch->flags & LAUNCH_FREADY)) {
40		pr_debug("avail: cpu%d is not ready\n", cpu);
41		return 0;
42	}
43	if (launch->flags & (LAUNCH_FGO|LAUNCH_FGONE)) {
44		pr_debug("avail: too late.. cpu%d is already gone\n", cpu);
45		return 0;
46	}
47
48	return 1;
49}
50
51void amon_cpu_start(int cpu,
52		    unsigned long pc, unsigned long sp,
53		    unsigned long gp, unsigned long a0)
54{
55	volatile struct cpulaunch *launch =
56		(struct cpulaunch  *)CKSEG0ADDR(CPULAUNCH);
57
58	if (!amon_cpu_avail(cpu))
59		return;
60	if (cpu == smp_processor_id()) {
61		pr_debug("launch: I am cpu%d!\n", cpu);
62		return;
63	}
64	launch += cpu;
65
66	pr_debug("launch: starting cpu%d\n", cpu);
67
68	launch->pc = pc;
69	launch->gp = gp;
70	launch->sp = sp;
71	launch->a0 = a0;
72
73	smp_wmb();              /* Target must see parameters before go */
74	launch->flags |= LAUNCH_FGO;
75	smp_wmb();              /* Target must see go before we poll  */
76
77	while ((launch->flags & LAUNCH_FGONE) == 0)
78		;
79	smp_rmb();      /* Target will be updating flags soon */
80	pr_debug("launch: cpu%d gone!\n", cpu);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81}
v4.6
 1/*
 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
 4 * for more details.
 
 
 
 
 
 
 
 
 5 *
 6 * Copyright (C) 2007 MIPS Technologies, Inc.  All rights reserved.
 7 * Copyright (C) 2013 Imagination Technologies Ltd.
 
 8 *
 9 * Arbitrary Monitor Interface
10 */
 
11#include <linux/kernel.h>
 
12#include <linux/smp.h>
13
14#include <asm/addrspace.h>
 
15#include <asm/mipsmtregs.h>
16#include <asm/mips-boards/launch.h>
17#include <asm/vpe.h>
18
19int amon_cpu_avail(int cpu)
20{
21	struct cpulaunch *launch = (struct cpulaunch *)CKSEG0ADDR(CPULAUNCH);
22
23	if (cpu < 0 || cpu >= NCPULAUNCH) {
24		pr_debug("avail: cpu%d is out of range\n", cpu);
25		return 0;
26	}
27
28	launch += cpu;
29	if (!(launch->flags & LAUNCH_FREADY)) {
30		pr_debug("avail: cpu%d is not ready\n", cpu);
31		return 0;
32	}
33	if (launch->flags & (LAUNCH_FGO|LAUNCH_FGONE)) {
34		pr_debug("avail: too late.. cpu%d is already gone\n", cpu);
35		return 0;
36	}
37
38	return 1;
39}
40
41int amon_cpu_start(int cpu,
42		    unsigned long pc, unsigned long sp,
43		    unsigned long gp, unsigned long a0)
44{
45	volatile struct cpulaunch *launch =
46		(struct cpulaunch  *)CKSEG0ADDR(CPULAUNCH);
47
48	if (!amon_cpu_avail(cpu))
49		return -1;
50	if (cpu == smp_processor_id()) {
51		pr_debug("launch: I am cpu%d!\n", cpu);
52		return -1;
53	}
54	launch += cpu;
55
56	pr_debug("launch: starting cpu%d\n", cpu);
57
58	launch->pc = pc;
59	launch->gp = gp;
60	launch->sp = sp;
61	launch->a0 = a0;
62
63	smp_wmb();		/* Target must see parameters before go */
64	launch->flags |= LAUNCH_FGO;
65	smp_wmb();		/* Target must see go before we poll  */
66
67	while ((launch->flags & LAUNCH_FGONE) == 0)
68		;
69	smp_rmb();	/* Target will be updating flags soon */
70	pr_debug("launch: cpu%d gone!\n", cpu);
71
72	return 0;
73}
74
75#ifdef CONFIG_MIPS_VPE_LOADER_CMP
76int vpe_run(struct vpe *v)
77{
78	struct vpe_notifications *n;
79
80	if (amon_cpu_start(aprp_cpu_index(), v->__start, 0, 0, 0) < 0)
81		return -1;
82
83	list_for_each_entry(n, &v->notify, list)
84		n->start(VPE_MODULE_MINOR);
85
86	return 0;
87}
88#endif