diff options
| author | Ian Moffett <ian@osmora.org> | 2025-12-22 16:15:58 -0500 |
|---|---|---|
| committer | Ian Moffett <ian@osmora.org> | 2025-12-22 16:15:58 -0500 |
| commit | 09a31b95b6c0e0bd708fc58a99b2ac1abc0bc0c9 (patch) | |
| tree | 5dc434621b12a03ac6e5b3a108797d728affd4c7 | |
| parent | c854bc705bb794582fc562d1e29cb3a194fba454 (diff) | |
mos/x86_64: Add processor primitives + MU interface
Signed-off-by: Ian Moffett <ian@osmora.org>
| -rw-r--r-- | mos/sys/arch/x86_64/cpu/prim.S | 28 | ||||
| -rw-r--r-- | mos/sys/inc/mu/cpu.h | 36 |
2 files changed, 64 insertions, 0 deletions
diff --git a/mos/sys/arch/x86_64/cpu/prim.S b/mos/sys/arch/x86_64/cpu/prim.S new file mode 100644 index 0000000..7ab6269 --- /dev/null +++ b/mos/sys/arch/x86_64/cpu/prim.S @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025, Ian Moffett. + * Provided under the BSD-3 clause. + */ + + .globl mu_cpu_halt + .globl mu_irq_state + .globl mu_irq_setmask +mu_cpu_halt: + hlt + retq +mu_cpu_pause: + pause + retq +mu_irq_state: + pushfq + pop %rax + shr $9, %rax /* IF */ + and $1, %rax /* Isolate */ + retq +mu_irq_setmask: + test $1, %rdi + jnz irq_mask + sti + retq +irq_mask: + cli + retq diff --git a/mos/sys/inc/mu/cpu.h b/mos/sys/inc/mu/cpu.h new file mode 100644 index 0000000..e91a084 --- /dev/null +++ b/mos/sys/inc/mu/cpu.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025, Ian Moffett. + * Provided under the BSD-3 clause. + */ + +#ifndef _MU_CPU_H_ +#define _MU_CPU_H_ 1 + +#include <sdk/types.h> + +/* + * Get the current IRQ state + * + * (TRUE: IRQs unmasked, FALSE: IRQs masked) + */ +BOOL mu_irq_state(void); + +/* + * Mask or unmask IRQs + * + * @mask: If true, mask IRQs + */ +void mu_irq_setmask(BOOL mask); + +/* + * Halt the current processor core + */ +void mu_cpu_halt(void); + +/* + * Signal a spinwait hint to the currnet + * processor core + */ +void mu_cpu_pause(void); + +#endif /* !_MU_CPU_H_ */ |
