diff options
author | Ian Moffett <ian@osmora.org> | 2024-04-30 20:41:44 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-04-30 20:41:44 -0400 |
commit | 130ef7a34df14a57097a273867bc2bb5816d5f49 (patch) | |
tree | e4e33b29b2e713e794ed1caefcc0af13d3a6000a | |
parent | 1586c50040f6d40630a0c9215575190103c4270f (diff) |
kernel/amd64: machdep: Add cpu_halt_others()
Halts all other processors except self
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | sys/arch/amd64/amd64/machdep.c | 15 | ||||
-rw-r--r-- | sys/include/arch/amd64/sysvec.h | 1 | ||||
-rw-r--r-- | sys/include/sys/machdep.h | 1 |
3 files changed, 17 insertions, 0 deletions
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 <machine/cpu.h> #include <machine/uart.h> #include <machine/cpuid.h> +#include <machine/sysvec.h> #include <dev/pci/pci.h> #include <vm/vm.h> #include <vm/dynalloc.h> @@ -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_ */ |