summaryrefslogtreecommitdiff
path: root/sys/arch/hppa/hppa/ipi.c
blob: f3f0aec7500ad2cda8c110b641cbf20e81c4b3d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
 * Copyright (c) 2010 Joel Sing <jsing@openbsd.org>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <sys/types.h>
#include <sys/systm.h>
#include <sys/mutex.h>

#include <machine/cpu.h>
#include <machine/cpufunc.h>
#include <machine/iomod.h>
#include <machine/intr.h>
#include <machine/mutex.h>
#include <machine/reg.h>

void hppa_ipi_nop(void);

void (*ipifunc[HPPA_NIPI])(void) =
{
	hppa_ipi_nop
};

void
hppa_ipi_init(struct cpu_info *ci)
{
	/* Initialise IPIs for given CPU. */
	mtx_init(&ci->ci_ipi_mtx, IPL_IPI);
	ci->ci_mask |= (1 << 30);
}

int
hppa_ipi_intr(void *arg)
{
	struct cpu_info *ci = curcpu();
	u_long ipi_pending;
	int bit = 0;

	/* Handle an IPI. */
	mtx_enter(&ci->ci_ipi_mtx);
	ipi_pending = ci->ci_ipi;
	ci->ci_ipi = 0;
	mtx_leave(&ci->ci_ipi_mtx);

	while (ipi_pending) {
		if (ipi_pending & (1L << bit))
			(*ipifunc[bit])();
		ipi_pending &= ~(1L << bit);
		bit++;
	}

	return 1;
}

int
hppa_ipi_send(struct cpu_info *ci, u_long ipi)
{
	struct iomod *cpu;

	if (!(ci->ci_flags & CPUF_RUNNING))
		return -1;

	mtx_enter(&ci->ci_ipi_mtx);
	ci->ci_ipi |= (1L << ipi);
	asm volatile ("sync" ::: "memory");
	mtx_leave(&ci->ci_ipi_mtx);

	/* Send an IPI to the specified CPU by triggering EIR{1} (irq 30). */
	cpu = (struct iomod *)(ci->ci_hpa);
	cpu->io_eir = 1;
	asm volatile ("sync" ::: "memory");

	return 0;
}

void
hppa_ipi_nop(void)
{
}