Implement memory barriers

This commit is contained in:
Rafal Kupiec 2024-02-04 22:10:37 +01:00
parent ec81294eba
commit 9ce841e957
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
4 changed files with 85 additions and 0 deletions

View File

@ -271,6 +271,23 @@ ArLoadTaskRegister(USHORT Source)
: "rm" (Source));
}
/**
* Orders memory accesses as seen by other processors.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArMemoryBarrier()
{
LONG Barrier;
asm volatile("lock; orl $0, %0;"
:
: "m"(Barrier));
}
/**
* Reads the specified CPU control register and returns its value.
*
@ -485,6 +502,23 @@ ArReadTimeStampCounter()
return ((ULONGLONG)High << 32) | Low;
}
/**
* Orders memory accesses as seen by other processors, without fence.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArReadWriteBarrier()
{
asm volatile(""
:
:
: "memory");
}
/**
* Instructs the processor to set the interrupt flag.
*

View File

@ -252,6 +252,24 @@ ArLoadTaskRegister(USHORT Source)
: "rm" (Source));
}
/**
* Orders memory accesses as seen by other processors.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArMemoryBarrier()
{
LONG Barrier;
asm volatile("xchg %%eax, %0"
:
: "m" (Barrier)
: "%eax");
}
/**
* Reads the specified CPU control register and returns its value.
*
@ -454,6 +472,23 @@ ArReadTimeStampCounter()
return Value;
}
/**
* Orders memory accesses as seen by other processors, without fence.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArReadWriteBarrier()
{
asm volatile(""
:
:
: "memory");
}
/**
* Instructs the processor to set the interrupt flag.
*

View File

@ -63,6 +63,10 @@ XTCDECL
VOID
ArLoadTaskRegister(USHORT Source);
XTCDECL
VOID
ArMemoryBarrier();
XTCDECL
ULONG_PTR
ArReadControlRegister(IN USHORT ControlRegister);
@ -87,6 +91,10 @@ XTCDECL
ULONGLONG
ArReadTimeStampCounter();
XTCDECL
VOID
ArReadWriteBarrier();
XTAPI
VOID
ArSetGdtEntryBase(IN PKGDTENTRY Gdt,

View File

@ -59,6 +59,10 @@ XTCDECL
VOID
ArLoadTaskRegister(USHORT Source);
XTCDECL
VOID
ArMemoryBarrier();
XTCDECL
ULONG_PTR
ArReadControlRegister(IN USHORT ControlRegister);
@ -83,6 +87,10 @@ XTCDECL
ULONGLONG
ArReadTimeStampCounter();
XTCDECL
VOID
ArReadWriteBarrier();
XTAPI
VOID
ArSetGdtEntryBase(IN PKGDTENTRY Gdt,