ipi_openpic.c revision 1.2 1 1.2 garbled /* $NetBSD: ipi_openpic.c,v 1.2 2007/10/17 19:56:45 garbled Exp $ */
2 1.2 garbled /*-
3 1.2 garbled * Copyright (c) 2007 The NetBSD Foundation, Inc.
4 1.2 garbled * All rights reserved.
5 1.2 garbled *
6 1.2 garbled * This code is derived from software contributed to The NetBSD Foundation
7 1.2 garbled * by Tim Rightnour
8 1.2 garbled *
9 1.2 garbled * Redistribution and use in source and binary forms, with or without
10 1.2 garbled * modification, are permitted provided that the following conditions
11 1.2 garbled * are met:
12 1.2 garbled * 1. Redistributions of source code must retain the above copyright
13 1.2 garbled * notice, this list of conditions and the following disclaimer.
14 1.2 garbled * 2. Redistributions in binary form must reproduce the above copyright
15 1.2 garbled * notice, this list of conditions and the following disclaimer in the
16 1.2 garbled * documentation and/or other materials provided with the distribution.
17 1.2 garbled * 3. All advertising materials mentioning features or use of this software
18 1.2 garbled * must display the following acknowledgement:
19 1.2 garbled * This product includes software developed by the NetBSD
20 1.2 garbled * Foundation, Inc. and its contributors.
21 1.2 garbled * 4. Neither the name of The NetBSD Foundation nor the names of its
22 1.2 garbled * contributors may be used to endorse or promote products derived
23 1.2 garbled * from this software without specific prior written permission.
24 1.2 garbled *
25 1.2 garbled * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26 1.2 garbled * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.2 garbled * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.2 garbled * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29 1.2 garbled * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.2 garbled * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.2 garbled * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.2 garbled * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.2 garbled * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.2 garbled * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.2 garbled * POSSIBILITY OF SUCH DAMAGE.
36 1.2 garbled */
37 1.2 garbled
38 1.2 garbled #include <sys/cdefs.h>
39 1.2 garbled __KERNEL_RCSID(0, "$NetBSD: ipi_openpic.c,v 1.2 2007/10/17 19:56:45 garbled Exp $");
40 1.2 garbled
41 1.2 garbled #include "opt_multiprocessor.h"
42 1.2 garbled #include <sys/param.h>
43 1.2 garbled #include <sys/malloc.h>
44 1.2 garbled #include <sys/kernel.h>
45 1.2 garbled
46 1.2 garbled #include <uvm/uvm_extern.h>
47 1.2 garbled
48 1.2 garbled #include <machine/pio.h>
49 1.2 garbled #include <powerpc/openpic.h>
50 1.2 garbled #include <powerpc/atomic.h>
51 1.2 garbled
52 1.2 garbled #include <arch/powerpc/pic/picvar.h>
53 1.2 garbled #include <arch/powerpc/pic/ipivar.h>
54 1.2 garbled
55 1.2 garbled #ifdef MULTIPROCESSOR
56 1.2 garbled
57 1.2 garbled extern struct ipi_ops ipiops;
58 1.2 garbled extern volatile u_long IPI[CPU_MAXNUM];
59 1.2 garbled static void openpic_send_ipi(int, u_long);
60 1.2 garbled static void openpic_establish_ipi(int, int, void *);
61 1.2 garbled
62 1.2 garbled void
63 1.2 garbled setup_openpic_ipi(void)
64 1.2 garbled {
65 1.2 garbled uint32_t x;
66 1.2 garbled
67 1.2 garbled ipiops.ppc_send_ipi = openpic_send_ipi;
68 1.2 garbled ipiops.ppc_establish_ipi = openpic_establish_ipi;
69 1.2 garbled ipiops.ppc_ipi_vector = IPI_VECTOR;
70 1.2 garbled
71 1.2 garbled x = openpic_read(OPENPIC_IPI_VECTOR(1));
72 1.2 garbled x &= ~(OPENPIC_IMASK | OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK);
73 1.2 garbled x |= (15 << OPENPIC_PRIORITY_SHIFT) | ipiops.ppc_ipi_vector;
74 1.2 garbled openpic_write(OPENPIC_IPI_VECTOR(1), x);
75 1.2 garbled }
76 1.2 garbled
77 1.2 garbled static void
78 1.2 garbled openpic_send_ipi(int target, u_long mesg)
79 1.2 garbled {
80 1.2 garbled int cpumask = 0, i;
81 1.2 garbled
82 1.2 garbled switch(target) {
83 1.2 garbled case IPI_T_ALL:
84 1.2 garbled for (i = 0; i < ncpu; i++) {
85 1.2 garbled cpumask |= 1 << i;
86 1.2 garbled atomic_setbits_ulong(&IPI[i], mesg);
87 1.2 garbled }
88 1.2 garbled break;
89 1.2 garbled case IPI_T_NOTME:
90 1.2 garbled for (i = 0; i < ncpu; i++) {
91 1.2 garbled if (i != cpu_number())
92 1.2 garbled cpumask |= 1 << i;
93 1.2 garbled atomic_setbits_ulong(&IPI[i], mesg);
94 1.2 garbled }
95 1.2 garbled break;
96 1.2 garbled default:
97 1.2 garbled cpumask = 1 << target;
98 1.2 garbled atomic_setbits_ulong(&IPI[target], mesg);
99 1.2 garbled }
100 1.2 garbled openpic_write(OPENPIC_IPI(cpu_number(), 1), cpumask);
101 1.2 garbled }
102 1.2 garbled
103 1.2 garbled static void
104 1.2 garbled openpic_establish_ipi(int type, int level, void *ih_args)
105 1.2 garbled {
106 1.2 garbled /*
107 1.2 garbled * XXX
108 1.2 garbled * for now we catch IPIs early in pic_handle_intr() so no need to do anything
109 1.2 garbled * here
110 1.2 garbled */
111 1.2 garbled #if 0
112 1.2 garbled intr_establish(ipiops.ppc_ipi_vector, type, level, ppcipi_intr,
113 1.2 garbled ih_args);
114 1.2 garbled #endif
115 1.2 garbled }
116 1.2 garbled
117 1.2 garbled #endif /*MULTIPROCESSOR*/
118