kernel: add basic spinlocks

This commit is contained in:
2023-02-04 17:46:05 +00:00
parent 6e290ee18a
commit d0a431c860
5 changed files with 125 additions and 18 deletions

View File

@@ -4,5 +4,6 @@
#define __used __attribute__((used))
#define __packed __attribute__((packed))
#define __section(name) __attribute__((section(name)))
#define __aligned(x) __attribute__((aligned(x)))
#endif

View File

@@ -1,11 +1,14 @@
#ifndef SOCKS_LOCKS_H_
#define SOCKS_LOCKS_H_
typedef int __attribute__((aligned(8))) spin_lock_t;
#include <socks/compiler.h>
#include <socks/machine/hwlock.h>
#define SPIN_LOCK_INIT ((spin_lock_t)0)
typedef __aligned(8) ml_hwlock_t spin_lock_t;
extern void spin_lock_irqsave(spin_lock_t *lck, unsigned long *flags);
extern void spin_unlock_irqrestore(spin_lock_t *lck, unsigned long flags);
#define SPIN_LOCK_INIT ML_HWLOCK_INIT
#define spin_lock_irqsave(lck, flags) ml_hwlock_lock_irqsave(lck, flags);
#define spin_unlock_irqrestore(lck, flags) ml_hwlock_unlock_irqrestore(lck, flags);
#endif