/*
 * Copyright (c) 2026, Chloe M.
 * Provided under the BSD-3 clause.
 *
 * Description: Processor primitives
 * Author:      Chloe M.
 */

#ifndef _HAL_PRIM_H_
#define _HAL_PRIM_H_ 1

#include <machine/prim.h>
#include <ptdef.h>

/*
 * Suspend the current processor until the next
 * interrupt.
 */
ALWAYS_INLINE static inline VOID
HalCpuSuspend(VOID)
{
    MdCpuSuspend();
}

/*
 * Hint to the processor core that it is in a spin
 * loop.
 */
ALWAYS_INLINE static inline VOID
HalCpuSpinWait(VOID)
{
    MdCpuSpinWait();
}

/*
 * Perform an atomic swap operation
 *
 * @Ptr:   Location to swap with @Value
 * @Value: Value to swap with data at @Ptr
 */
ALWAYS_INLINE static inline UQUAD
HalCpuAswap(UQUAD *Ptr, UQUAD Value)
{
    return MdCpuAswap(Ptr, Value);
}

#endif  /* !_HAL_PRIM_H_ */
