OcCpuLib: Initial import of OcAtomicPreIncUint8

This commit is contained in:
Marvin Häuser 2021-03-19 16:35:31 +01:00
parent 6e13160e22
commit 31129295c3
4 changed files with 51 additions and 0 deletions

View File

@ -234,4 +234,17 @@ OcGetTSCFrequency (
VOID
);
/**
Atomically pre-increment 8-bit integer.
@param[in] Value Pointer to 8-bit integer to increment.
@retval value before incrementing.
**/
UINT8
EFIAPI
OcAtomicPreIncUint8 (
IN OUT volatile UINT8 *Value
);
#endif // OC_CPU_LIB_H_

View File

@ -18,6 +18,20 @@ DEFAULT REL
SECTION .text
;------------------------------------------------------------------------------
; UINT8
; EFIAPI
; OcAtomicPreIncUint8 (
; IN OUT volatile UINT8 *Value
; );
;------------------------------------------------------------------------------
global ASM_PFX(OcAtomicPreIncUint8)
ASM_PFX(OcAtomicPreIncUint8):
mov ecx, [esp + 4]
mov eax, 1
lock xadd byte [ecx], al
ret
;------------------------------------------------------------------------------
; UINT32
; EFIAPI

View File

@ -18,6 +18,19 @@ DEFAULT REL
SECTION .text
;------------------------------------------------------------------------------
; UINT8
; EFIAPI
; OcAtomicPreIncUint8 (
; IN OUT volatile UINT8 *Value
; );
;------------------------------------------------------------------------------
global ASM_PFX(OcAtomicPreIncUint8)
ASM_PFX(OcAtomicPreIncUint8):
mov eax, 1
lock xadd byte [rcx], al
ret
;------------------------------------------------------------------------------
; UINT32
; EFIAPI

View File

@ -161,6 +161,17 @@ AsmCpuidEx (
#endif
}
UINT8
EFIAPI
OcAtomicPreIncUint8 (
IN OUT volatile UINT8 *Value
)
{
ASSERT (FALSE);
return 0;
}
UINT32
EFIAPI
AsmIncrementUint32 (