//! TLB 维护操作
#![no_std]
#![allow(unsafe_code)]
#![cfg_attr(aarch64_moana, feature(stdarch_arm_barrier))]

cfg_if::cfg_if! {
    if #[cfg(aarch64_moana)] {
        #[path = "aarch64.rs"]
        mod arch;
    } else if #[cfg(riscv64_moana)] {
        #[path = "riscv64.rs"]
        mod arch;
    } else {
        #[path = "stub.rs"]
        mod arch;
    }
}

/// 无效化本核全部 TLB
#[inline(always)]
pub fn local_flush_tlb_all() {
    arch::arch_local_flush_tlb_all();
}

/// 无效化指定地址空间（ASID）的全部 TLB
#[inline(always)]
pub fn flush_tlb_space(asid: usize) {
    arch::arch_flush_tlb_space(asid);
}

/// 无效化指定地址空间中一段虚拟地址范围的 TLB
#[inline(always)]
pub fn flush_tlb_range(asid: usize, start: usize, end: usize, stride: usize) {
    arch::arch_flush_tlb_range(asid, start, end, stride);
}
