stos: ke: Add initial support for spinlocks
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
@@ -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 <stdef.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_ */
|
||||
Reference in New Issue
Block a user