Files
2026-06-23 22:20:11 +00:00

49 lines
878 B
C

/*
* 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_ */