Files
SystemPaw3/paw/stos/arch/amd64/ke/knot.S
T
Chloe M. 81d5f13a30 stos: Add kernel knotting impl
Signed-off-by: Chloe M. <chloe@mensia.org>
2026-06-23 05:36:10 +00:00

52 lines
1.5 KiB
ArmAsm

/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause.
*
* Description: Fucks and knots the kernel
* Author: Chloe M.
*/
.text
.globl KeKnot
KeKnot:
/*
* When we are called here, the kernel is to be fucked with
* the most love and care we can put out before we knot it
* and fill it with warm cum...
*/
cli /* Don't get interrupted */
cld /* Just in case */
/*
* We don't want another processor to attempt to fuck the kernel
* while we are already knotting it to avoid it becoming too
* cumdrunk and misbehaving further. If another processor attempts
* to do so, knot and lock them hard, because that's what needy
* cores get :3
*/
mov $1, %rax /* Prepare the lock */
xchg %rax, MpLock /* Ah!~ Fuck~ @.@ */
or %rax, %rax /* Are we another core? */
jnz 1f
/*
* The kernel is being extra needy and may or may not have
* kicked its paws into its stack. It's okay little kernel,
* we'll give you a new stack that's safe and cozy to lay in
* before the knotting begins!
*/
lea KnotStackTop(%rip), %rsp
call KiKnot /* Enter the main knot handler */
1: mfence /* Drain those caches~ */
.Lock:
cli /* Don't get interrupted */
hlt /* Get knotted >:3 */
jmp .Lock
.section .data
MpLock: .quad 0
KnotStack: .fill 4096, 1, 0
KnotStackTop: