Put CPU namespaces in separate files to make cpu.hpp smaller

This commit is contained in:
Alex
2023-02-22 01:48:38 +02:00
parent a35482694f
commit c817be50ff
24 changed files with 4872 additions and 4736 deletions

56
include/cpu/membar.hpp Normal file
View File

@ -0,0 +1,56 @@
#ifndef __FENNIX_KERNEL_CPU_MEMBAR_H__
#define __FENNIX_KERNEL_CPU_MEMBAR_H__
#include <types.h>
namespace CPU
{
namespace MemBar
{
SafeFunction static inline void Barrier()
{
#if defined(__amd64__) || defined(__i386__)
asmv("" ::
: "memory");
#elif defined(__aarch64__)
asmv("dmb ish" ::
: "memory");
#endif
}
SafeFunction static inline void Fence()
{
#if defined(__amd64__) || defined(__i386__)
asmv("mfence" ::
: "memory");
#elif defined(__aarch64__)
asmv("dmb ish" ::
: "memory");
#endif
}
SafeFunction static inline void StoreFence()
{
#if defined(__amd64__) || defined(__i386__)
asmv("sfence" ::
: "memory");
#elif defined(__aarch64__)
asmv("dmb ishst" ::
: "memory");
#endif
}
SafeFunction static inline void LoadFence()
{
#if defined(__amd64__) || defined(__i386__)
asmv("lfence" ::
: "memory");
#elif defined(__aarch64__)
asmv("dmb ishld" ::
: "memory");
#endif
}
}
}
#endif // !__FENNIX_KERNEL_CPU_MEMBAR_H__