blob: e9bc4d38bf93b15371be567a6ca843dcc9209123 (
plain) (
blame)
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
|
/* SPDX-License-Identifier: copyleft-next-0.3.1 */
/* Copyright 2023 Kim Kuparinen < kimi.h.kuparinen@gmail.com > */
#include <kmi/notify.h>
#include <kmi/queue.h>
#include <kmi/ipi.h>
#include <arch/proc.h>
#include <arch/cpu.h>
/** List for keeping track of which threads have an ipi queued. */
static struct queue_head fifo = INIT_QUEUE(fifo);
/**
* @file ipi.c
*
* IPI function implementations.
*/
void send_ipi(struct tcb *t)
{
/** @todo this should probably have a spinlock guard */
/** @todo killing a thread should make sure it gets removed from ipi
* queue */
queue_push(&fifo, &t->ipi_queue);
cpu_send_ipi(t->cpu_id);
}
void handle_ipi()
{
struct tcb *t = cur_tcb();
adjust_ipi(t);
struct queue_head *q = queue_pop(&fifo);
if (!q)
return;
struct tcb *r = container_of(q, struct tcb, ipi_queue);
notify(r, 0);
/* notify didn't take for whatever reason so return whence we came from */
}
|