miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Loading...
Searching...
No Matches
ipi.h
Go to the documentation of this file.
1// MIT License
2//
3// Copyright (c) 2026 Christian Spoo
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in all
13// copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21// SOFTWARE.
22
35
36#ifndef _MINIOS_IPI_IPI_H_
37#define _MINIOS_IPI_IPI_H_
38
39#include <miniOS/types.h>
41
50typedef struct {
51 volatile uint32_t ack_count; /* decremented by each handler */
52 uint64_t virt; /* virtual address for TLB shootdown */
54
55/* Global TLB shootdown barrier — shared between initiator and all ISR handlers */
57
62static inline void ipi_barrier_ack(ipi_barrier_t *b) {
63 __asm__ volatile("lock subl $1, %0" : "+m"(b->ack_count) : : "memory");
64}
65
70static inline void ipi_barrier_wait(ipi_barrier_t *b) {
71 while (b->ack_count > 0)
72 __asm__ volatile("pause" : : : "memory");
73}
74
87
96void tlb_shootdown_isr(void *frame);
97
106void ipi_panic_halt(void);
107
115void panic_halt_isr(void *frame);
116
118
119#endif /* _MINIOS_IPI_IPI_H_ */
ipi_barrier_t g_tlb_barrier
Definition ipi.c:29
void tlb_shootdown_isr(void *frame)
ISR for TLB_SHOOTDOWN_VECTOR (51) on remote CPUs.
Definition ipi.c:57
void panic_halt_isr(void *frame)
ISR for PANIC_HALT_VECTOR (52) on APs.
Definition ipi.c:110
void ipi_panic_halt(void)
Broadcast halt IPI to all APs on kernel panic.
Definition ipi.c:71
static void ipi_barrier_ack(ipi_barrier_t *b)
Atomically decrement the barrier's ack_count.
Definition ipi.h:62
void ipi_tlb_shootdown(uint64_t virt)
Broadcast TLB-shootdown IPI and wait for all CPUs to flush.
Definition ipi.c:31
static void ipi_barrier_wait(ipi_barrier_t *b)
Spin until barrier->ack_count reaches 0.
Definition ipi.h:70
Definition ipi.h:50
uint64_t virt
Definition ipi.h:52
volatile uint32_t ack_count
Definition ipi.h:51
unsigned int uint32_t
Definition types.h:34
unsigned long int uint64_t
Definition types.h:37