ipi_bebox.c revision 1.1 1 1.1 kiyohara /* $NetBSD: ipi_bebox.c,v 1.1 2012/10/20 14:53:37 kiyohara Exp $ */
2 1.1 kiyohara
3 1.1 kiyohara /*-
4 1.1 kiyohara * Copyright (c) 2007 The NetBSD Foundation, Inc.
5 1.1 kiyohara * All rights reserved.
6 1.1 kiyohara *
7 1.1 kiyohara * This code is derived from software contributed to The NetBSD Foundation
8 1.1 kiyohara * by Tim Rightnour
9 1.1 kiyohara *
10 1.1 kiyohara * Redistribution and use in source and binary forms, with or without
11 1.1 kiyohara * modification, are permitted provided that the following conditions
12 1.1 kiyohara * are met:
13 1.1 kiyohara * 1. Redistributions of source code must retain the above copyright
14 1.1 kiyohara * notice, this list of conditions and the following disclaimer.
15 1.1 kiyohara * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 kiyohara * notice, this list of conditions and the following disclaimer in the
17 1.1 kiyohara * documentation and/or other materials provided with the distribution.
18 1.1 kiyohara *
19 1.1 kiyohara * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 kiyohara * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 kiyohara * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 kiyohara * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 kiyohara * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 kiyohara * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 kiyohara * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 kiyohara * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 kiyohara * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 kiyohara * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 kiyohara * POSSIBILITY OF SUCH DAMAGE.
30 1.1 kiyohara */
31 1.1 kiyohara
32 1.1 kiyohara #include <sys/cdefs.h>
33 1.1 kiyohara __KERNEL_RCSID(0, "$NetBSD: ipi_bebox.c,v 1.1 2012/10/20 14:53:37 kiyohara Exp $");
34 1.1 kiyohara
35 1.1 kiyohara #include <sys/atomic.h>
36 1.1 kiyohara #include <sys/cpu.h>
37 1.1 kiyohara
38 1.1 kiyohara #include <powerpc/pic/picvar.h>
39 1.1 kiyohara #include <powerpc/pic/ipivar.h>
40 1.1 kiyohara
41 1.1 kiyohara
42 1.1 kiyohara static void bebox_send_ipi(cpuid_t, uint32_t);
43 1.1 kiyohara static void bebox_establish_ipi(int, int, void *);
44 1.1 kiyohara
45 1.1 kiyohara void
46 1.1 kiyohara setup_bebox_ipi(void)
47 1.1 kiyohara {
48 1.1 kiyohara
49 1.1 kiyohara ipiops.ppc_send_ipi = bebox_send_ipi;
50 1.1 kiyohara ipiops.ppc_establish_ipi = bebox_establish_ipi;
51 1.1 kiyohara ipiops.ppc_ipi_vector = IPI_VECTOR;
52 1.1 kiyohara }
53 1.1 kiyohara
54 1.1 kiyohara static void
55 1.1 kiyohara bebox_send_ipi(cpuid_t target, uint32_t mesg)
56 1.1 kiyohara {
57 1.1 kiyohara struct cpu_info * const ci = curcpu();
58 1.1 kiyohara int i;
59 1.1 kiyohara
60 1.1 kiyohara switch (target) {
61 1.1 kiyohara case IPI_DST_ALL:
62 1.1 kiyohara case IPI_DST_NOTME:
63 1.1 kiyohara for (i = 0; i < ncpu; i++) {
64 1.1 kiyohara struct cpu_info * const dst_ci = cpu_lookup(i);
65 1.1 kiyohara
66 1.1 kiyohara if (target == IPI_DST_ALL || dst_ci != ci) {
67 1.1 kiyohara atomic_or_32(&dst_ci->ci_pending_ipis, mesg);
68 1.1 kiyohara }
69 1.1 kiyohara }
70 1.1 kiyohara break;
71 1.1 kiyohara
72 1.1 kiyohara default:
73 1.1 kiyohara {
74 1.1 kiyohara struct cpu_info * const dst_ci = cpu_lookup(target);
75 1.1 kiyohara
76 1.1 kiyohara atomic_or_32(&dst_ci->ci_pending_ipis, mesg);
77 1.1 kiyohara break;
78 1.1 kiyohara }
79 1.1 kiyohara }
80 1.1 kiyohara }
81 1.1 kiyohara
82 1.1 kiyohara static void
83 1.1 kiyohara bebox_establish_ipi(int type, int level, void *ih_args)
84 1.1 kiyohara {
85 1.1 kiyohara /* XXXXX: nothing? */
86 1.1 kiyohara }
87