2
* Copyright (c) 2006 Jakub Jermar
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
9
* - Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* - Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
14
* - The name of the author may not be used to endorse or promote products
15
* derived from this software without specific prior written permission.
17
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
/** @addtogroup sparc64
38
#include <interrupt.h>
41
#include <arch/sun4v/hypercall.h>
42
#include <arch/sun4v/ipi.h>
44
#define IPI_MESSAGE_SIZE 8
46
static uint64_t data[MAX_NUM_STRANDS][IPI_MESSAGE_SIZE]
47
__attribute__ ((aligned (64)));
49
static uint16_t ipi_cpu_list[MAX_NUM_STRANDS][MAX_NUM_STRANDS];
52
* Sends an inter-processor interrupt to all virtual processors whose IDs are
55
* @param func address of the function to be invoked on the recipient
56
* @param cpu_list list of CPU IDs (16-bit identifiers) of the recipients
57
* @param list_size number of recipients (number of valid cpu_list entries)
59
* @return error code returned by the CPU_MONDO_SEND hypercall
61
uint64_t ipi_brodcast_to(void (*func)(void), uint16_t cpu_list[MAX_NUM_STRANDS],
64
data[CPU->arch.id][0] = (uint64_t) func;
67
for (i = 0; i < list_size; i++) {
68
ipi_cpu_list[CPU->arch.id][i] = cpu_list[i];
71
return __hypercall_fast3(CPU_MONDO_SEND, list_size,
72
KA2PA(ipi_cpu_list[CPU->arch.id]), KA2PA(data[CPU->arch.id]));
76
* Send an inter-processor interrupt to a particular CPU.
78
* @param func address of the function to be invoked on the recipient
79
* @param cpu_is CPU ID (16-bit identifier) of the recipient
81
* @return error code returned by the CPU_MONDO_SEND hypercall
83
uint64_t ipi_unicast_to(void (*func)(void), uint16_t cpu_id) {
84
ipi_cpu_list[CPU->arch.id][0] = cpu_id;
85
return ipi_brodcast_to(func, ipi_cpu_list[CPU->arch.id], 1);
89
* Deliver IPI to all processors except the current one.
91
* We assume that interrupts are disabled.
93
* @param ipi IPI number.
95
void ipi_broadcast_arch(int ipi)
100
case IPI_TLB_SHOOTDOWN:
101
func = tlb_shootdown_ipi_recv;
104
panic("Unknown IPI (%d).\n", ipi);
110
for (i = 0; i < config.cpu_active; i++) {
111
if (&cpus[i] == CPU) {
115
ipi_cpu_list[CPU->id][idx] = (uint16_t) cpus[i].id;
119
ipi_brodcast_to(func, ipi_cpu_list[CPU->arch.id], idx);