lock: merge spinlock and mtx locks into one

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-08-13 14:19:10 -04:00
commit 2076f1dae1
Signed by: michaelsshaw
GPG key ID: 5A5E0FB20708A9E7
32 changed files with 158 additions and 169 deletions

View file

@ -3,7 +3,7 @@
#define _DRIVER_H_
#include <kernel/common.h>
#include <kernel/spinlock.h>
#include <kernel/lock.h>
#include <lib/list.h>
#include <drivers/pci.h>

19
include/kernel/lock.h Normal file
View file

@ -0,0 +1,19 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _LOCK_H_
#define _LOCK_H_
#include <kernel/types.h>
#include <kernel/common.h>
#define CLEANUP_SLOCK CLEANUP(cleanup_spinlock)
typedef u32 lock_t;
void spin_lock(lock_t *lock);
void spin_unlock(lock_t *lock);
void cleanup_spinlock(lock_t **lock_ptr);
void mtx_lock(lock_t *l);
void mtx_unlock(lock_t *l);
#endif /* _LOCK_H_ */

View file

@ -3,7 +3,7 @@
#define _MEM_H_
#include <kernel/common.h>
#include <kernel/spinlock.h>
#include <kernel/lock.h>
#define ALIGN(_a) __attribute__((aligned(_a)))
#define PHYSICAL_PAGE_MASK (~(hhdm_start))

View file

@ -3,7 +3,7 @@
#define _SLAB_H_
#include <kernel/common.h>
#include <kernel/spinlock.h>
#include <kernel/lock.h>
#define ALLOC_KERN 0x1
#define ALLOC_USER 0x2
@ -19,7 +19,7 @@ typedef struct _mem_cache_t {
size_t num_members;
size_t num_free;
vaddr_t next_free;
spinlock_t lock;
lock_t lock;
struct _mem_cache_t *next;
} mem_cache_t;

View file

@ -3,7 +3,7 @@
#define _THREAD_H_
#include <kernel/types.h>
#include <kernel/spinlock.h>
#include <kernel/lock.h>
#include <kernel/mem.h>
#include <kernel/page.h>
#include <fs/vfs.h>
@ -33,7 +33,7 @@ struct file {
u64 flags;
u64 offset;
u64 refcount;
spinlock_t lock;
lock_t lock;
};
struct thread {
@ -53,15 +53,15 @@ struct thread {
pgd_t *pgd;
spinlock_t mem_lock;
lock_t mem_lock;
rbtree_t memmap;
spinlock_t alloc_lock;
lock_t alloc_lock;
rbtree_t alloc_map;
uaddr_t entry;
spinlock_t fd_lock;
lock_t fd_lock;
size_t fd_array_size;
struct file *fdt;