From 130ef7a34df14a57097a273867bc2bb5816d5f49 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Tue, 30 Apr 2024 20:41:44 -0400 Subject: kernel/amd64: machdep: Add cpu_halt_others() Halts all other processors except self Signed-off-by: Ian Moffett --- sys/arch/amd64/amd64/machdep.c | 15 +++++++++++++++ sys/include/arch/amd64/sysvec.h | 1 + sys/include/sys/machdep.h | 1 + 3 files changed, 17 insertions(+) diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 809eb27..f73d773 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -62,6 +63,13 @@ __KERNEL_META("$Hyra$: machdep.c, Ian Marco Moffett, " void syscall_isr(void); +__attr(interrupt) +static void +halt_isr(void *sf) +{ + processor_halt(); +} + static inline void init_tss(struct cpu_info *cur_cpu) { @@ -88,6 +96,7 @@ interrupts_init(void) idt_set_desc(0xD, IDT_TRAP_GATE_FLAGS, ISR(general_prot), 0); idt_set_desc(0xE, IDT_TRAP_GATE_FLAGS, ISR(page_fault), 0); idt_set_desc(0x80, IDT_INT_GATE_USER, ISR(syscall_isr), 0); + idt_set_desc(SYSVEC_HLT, IDT_INT_GATE_FLAGS, ISR(halt_isr), 0); idt_load(); } @@ -209,6 +218,12 @@ backtrace(void) } } +void +cpu_halt_others(void) +{ + lapic_send_ipi(0, IPI_SHORTHAND_OTHERS, SYSVEC_HLT); +} + int processor_init_pcb(struct proc *proc) { diff --git a/sys/include/arch/amd64/sysvec.h b/sys/include/arch/amd64/sysvec.h index 81383ea..8feecb7 100644 --- a/sys/include/arch/amd64/sysvec.h +++ b/sys/include/arch/amd64/sysvec.h @@ -41,6 +41,7 @@ typedef enum { SYSVEC_LAPIC_TIMER = 0x21, /* Local APIC timer */ SYSVEC_IPI, /* IPI vector */ + SYSVEC_HLT, /* Halt vector */ /* -- XXX: New vectors go above -- */ NSYSVEC_BASE, /* Non-system vector base */ diff --git a/sys/include/sys/machdep.h b/sys/include/sys/machdep.h index 811f6be..99ebbac 100644 --- a/sys/include/sys/machdep.h +++ b/sys/include/sys/machdep.h @@ -49,6 +49,7 @@ __weak void chips_init(void); __weak void pre_init(void); __weak void serial_dbgch(char c); __weak void backtrace(void); +__weak void cpu_halt_others(void); #endif /* defined(_KERNEL) */ #endif /* !_SYS_MACHDEP_H_ */ -- cgit v1.2.3