Path: blob/master/arch/mips/mti-malta/malta-amon.c
10817 views
/*1* Copyright (C) 2007 MIPS Technologies, Inc.2* All rights reserved.34* This program is free software; you can distribute it and/or modify it5* under the terms of the GNU General Public License (Version 2) as6* published by the Free Software Foundation.7*8* This program is distributed in the hope it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* for more details.12*13* You should have received a copy of the GNU General Public License along14* with this program; if not, write to the Free Software Foundation, Inc.,15* 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.16*17* Arbitrary Monitor interface18*/1920#include <linux/kernel.h>21#include <linux/init.h>22#include <linux/smp.h>2324#include <asm/addrspace.h>25#include <asm/mips-boards/launch.h>26#include <asm/mipsmtregs.h>2728int amon_cpu_avail(int cpu)29{30struct cpulaunch *launch = (struct cpulaunch *)CKSEG0ADDR(CPULAUNCH);3132if (cpu < 0 || cpu >= NCPULAUNCH) {33pr_debug("avail: cpu%d is out of range\n", cpu);34return 0;35}3637launch += cpu;38if (!(launch->flags & LAUNCH_FREADY)) {39pr_debug("avail: cpu%d is not ready\n", cpu);40return 0;41}42if (launch->flags & (LAUNCH_FGO|LAUNCH_FGONE)) {43pr_debug("avail: too late.. cpu%d is already gone\n", cpu);44return 0;45}4647return 1;48}4950void amon_cpu_start(int cpu,51unsigned long pc, unsigned long sp,52unsigned long gp, unsigned long a0)53{54volatile struct cpulaunch *launch =55(struct cpulaunch *)CKSEG0ADDR(CPULAUNCH);5657if (!amon_cpu_avail(cpu))58return;59if (cpu == smp_processor_id()) {60pr_debug("launch: I am cpu%d!\n", cpu);61return;62}63launch += cpu;6465pr_debug("launch: starting cpu%d\n", cpu);6667launch->pc = pc;68launch->gp = gp;69launch->sp = sp;70launch->a0 = a0;7172smp_wmb(); /* Target must see parameters before go */73launch->flags |= LAUNCH_FGO;74smp_wmb(); /* Target must see go before we poll */7576while ((launch->flags & LAUNCH_FGONE) == 0)77;78smp_rmb(); /* Target will be updating flags soon */79pr_debug("launch: cpu%d gone!\n", cpu);80}818283