From 72b2d8d5253a0828a18cd4b4800ec9c07834dcc2 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sun, 5 Feb 2023 10:27:29 +0000 Subject: [PATCH] x86_64: re-implement ml_halt_cpu() in pure assembly --- arch/x86_64/cpu_ctrl.S | 8 ++++++++ arch/x86_64/include/socks/machine/cpu.h | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 arch/x86_64/cpu_ctrl.S diff --git a/arch/x86_64/cpu_ctrl.S b/arch/x86_64/cpu_ctrl.S new file mode 100644 index 0000000..383afca --- /dev/null +++ b/arch/x86_64/cpu_ctrl.S @@ -0,0 +1,8 @@ + + .global ml_halt_cpu + .type ml_halt_cpu, @function + +ml_halt_cpu: +1: cli + hlt + jmp 1b diff --git a/arch/x86_64/include/socks/machine/cpu.h b/arch/x86_64/include/socks/machine/cpu.h index dfe5bba..ab088b7 100644 --- a/arch/x86_64/include/socks/machine/cpu.h +++ b/arch/x86_64/include/socks/machine/cpu.h @@ -3,7 +3,6 @@ #include -#define ml_halt_cpu() asm volatile("cli;hlt") typedef struct ml_cpu_block { struct gdt c_gdt; @@ -15,4 +14,7 @@ extern int ml_init_bootcpu(void); extern int ml_cpu_block_init(ml_cpu_block *p); extern int ml_cpu_block_use(ml_cpu_block *p); +/* defined in cpu_ctrl.S */ +extern void ml_halt_cpu(void); + #endif