@@ -83,6 +83,7 @@ set(KERNEL_MAIN_SOURCES src/kernel_main.c
include/types/allocator.hpp
include/types/cplusplus.hpp
include/types/list.hpp
+ include/types/lock.h
include/types/string.hpp
include/types/vector.hpp
include/kernel_main.h
@@ -0,0 +1,35 @@
+#pragma once
+
+#include <types/stdint.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+static inline void spin_lock(uint32_t* lock_addr)
+{
+ asm volatile(
+ "_spin:\n\t\
+ movl $1, %%eax\n\t\
+ xchgl %%eax, (%0)\n\t\
+ test $0, %%eax\n\t\
+ jne _spin\n\t\
+ "
+ : "=r" (lock_addr)
+ : "0" (lock_addr)
+ : "eax", "memory"
+ );
+}
+static inline void spin_unlock(uint32_t* lock_addr)
+ asm volatile("movl $0, %%eax\nxchgl %%eax, (%0)"
+ :
+ : "r" (lock_addr)