#[inline(always)]
pub(super) fn arch_cpu_relax() {
    unsafe {
        core::arch::aarch64::__yield();
    }
}

#[inline(always)]
pub(super) fn arch_smp_rmb() {
    unsafe {
        core::arch::aarch64::__dmb(core::arch::aarch64::ISHLD);
    }
}

#[inline(always)]
pub(super) fn arch_smp_wmb() {
    unsafe {
        core::arch::aarch64::__dmb(core::arch::aarch64::ISHST);
    }
}

#[inline(always)]
pub(super) fn arch_smp_mb() {
    unsafe {
        core::arch::aarch64::__dmb(core::arch::aarch64::ISH);
    }
}

// MMIO 屏障：用 outer-shareable 域的 dmb 约束 MMIO 与普通内存间顺序(等价 Linux arm64
// 的 `__iowmb`/`__iormb`)。设备/DMA 可能落在 outer 域，故用 OSH 而非 inner 的 ISH。

#[inline(always)]
pub(super) fn arch_io_wmb() {
    unsafe {
        core::arch::aarch64::__dmb(core::arch::aarch64::OSHST);
    }
}

#[inline(always)]
pub(super) fn arch_io_rmb() {
    unsafe {
        core::arch::aarch64::__dmb(core::arch::aarch64::OSHLD);
    }
}

#[inline(always)]
pub(super) fn arch_isb() {
    unsafe {
        core::arch::aarch64::__isb(core::arch::aarch64::SY);
    }
}
