source: mainline/kernel/arch/sparc64/src/smp/sun4v/ipi.c

Last change on this file was c5429fe, checked in by Jakub Jermar <jakub@…>, 7 years ago

Disambiguate architecture specific doxygroups

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 * Copyright (c) 2006 Jakub Jermar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
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.
16 *
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.
27 */
28
29/** @addtogroup kernel_sparc64
30 * @{
31 */
32/** @file
33 */
34
35#include <smp/ipi.h>
36#include <cpu.h>
37#include <config.h>
38#include <interrupt.h>
39#include <arch/asm.h>
40#include <arch/cpu.h>
41#include <arch/sun4v/hypercall.h>
42#include <arch/sun4v/ipi.h>
43
44#define IPI_MESSAGE_SIZE 8
45
46static uint64_t data[MAX_NUM_STRANDS][IPI_MESSAGE_SIZE]
47 __attribute__((aligned(64)));
48
49static uint16_t ipi_cpu_list[MAX_NUM_STRANDS][MAX_NUM_STRANDS];
50
51/**
52 * Sends an inter-processor interrupt to all virtual processors whose IDs are
53 * listed in the list.
54 *
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)
58 *
59 * @return error code returned by the CPU_MONDO_SEND hypercall
60 */
61uint64_t ipi_brodcast_to(void (*func)(void), uint16_t cpu_list[MAX_NUM_STRANDS],
62 uint64_t list_size)
63{
64
65 data[CPU->arch.id][0] = (uint64_t) func;
66
67 unsigned int i;
68 for (i = 0; i < list_size; i++) {
69 ipi_cpu_list[CPU->arch.id][i] = cpu_list[i];
70 }
71
72 return __hypercall_fast3(CPU_MONDO_SEND, list_size,
73 KA2PA(ipi_cpu_list[CPU->arch.id]), KA2PA(data[CPU->arch.id]));
74}
75
76/**
77 * Send an inter-processor interrupt to a particular CPU.
78 *
79 * @param func address of the function to be invoked on the recipient
80 * @param cpu_is CPU ID (16-bit identifier) of the recipient
81 *
82 * @return error code returned by the CPU_MONDO_SEND hypercall
83 */
84uint64_t ipi_unicast_to(void (*func)(void), uint16_t cpu_id)
85{
86 ipi_cpu_list[CPU->arch.id][0] = cpu_id;
87 return ipi_brodcast_to(func, ipi_cpu_list[CPU->arch.id], 1);
88}
89
90/*
91 * Deliver IPI to all processors except the current one.
92 *
93 * We assume that interrupts are disabled.
94 *
95 * @param ipi IPI number.
96 */
97void ipi_broadcast_arch(int ipi)
98{
99 void (*func)(void);
100
101 switch (ipi) {
102 case IPI_TLB_SHOOTDOWN:
103 func = tlb_shootdown_ipi_recv;
104 break;
105 default:
106 panic("Unknown IPI (%d).\n", ipi);
107 break;
108 }
109
110 unsigned int i;
111 unsigned idx = 0;
112 for (i = 0; i < config.cpu_active; i++) {
113 if (&cpus[i] == CPU) {
114 continue;
115 }
116
117 ipi_cpu_list[CPU->id][idx] = (uint16_t) cpus[i].id;
118 idx++;
119 }
120
121 ipi_brodcast_to(func, ipi_cpu_list[CPU->arch.id], idx);
122}
123
124/** @}
125 */
Note: See TracBrowser for help on using the repository browser.