ptos: ke: Add spinlock impl

Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
2026-07-13 04:05:00 +00:00
parent 7fb0e4e88c
commit a40f3dc2ea
2 changed files with 100 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause.
*
* Description: Spinlock primitive
* Author: Chloe M.
*/
#ifndef _KE_SPINLOCK_H_
#define _KE_SPINLOCK_H_ 1
#include <ptdef.h>
#include <hal/intr.h>
/*
* Represents a spinlock that may be acquired for mutual
* exclusion of threads.
*
* @Data: Spinlock data (must be zero on init)
*/
typedef struct {
UQUAD Data;
} SPINLOCK;
/*
* Initialize a spinlock
*
* @Lock: Spinlock to initialize
* @Name: Name of spinlock
*/
VOID KeSpinLockInit(SPINLOCK *Lock, const CHAR *Name);
/*
* Acquire a spinlock
*
* @Lock: Lock to acquire
* @IrqMut: If true, mututate IRQ state upon acquisition
*/
VOID KeSpinLockAcquire(SPINLOCK *Lock, BOOLEAN IrqMut);
/*
* Release a spinlock
*
* @Lock: Spinlock to release
*/
VOID KeSpinLockRelease(SPINLOCK *Lock);
#endif /* !_KE_SPINLOCK_H_ */