1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/***********************************************************************************************************************
 * Copyright (c) 2019 by the authors
 *
 * Author: André Borrmann
 * License: Apache License 2.0
 **********************************************************************************************************************/
#![doc(html_root_url = "https://docs.rs/ruspiro-cache/0.3.0")]
#![no_std]
#![feature(asm)]

//! # Raspberry Pi cache maintenance
//!
//! If the caches are active on the Raspberry Pi than there might be specific cache
//! operations needed to clean and invalidate the cache to ensure in cross core and/or
//! ARM core to GPU communications the most recent data is seen.
//!
//! # Usage
//!
//! ```no_run
//! use ruspiro_cache as cache;
//!
//! fn doc() {
//!     cache::clean(); // clean the data cache
//!     cache::invalidate(); // invalidate the data cache
//!     cache::cleaninvalidate(); // clean and invalidate the data cache
//! }
//! ```

/// Perform a cache clean operation on the entire data cache
pub fn clean() {
    unsafe { __clean_dcache() }
}

/// Perform a cache invalidate operation on the entire data cache
pub fn invalidate() {
    unsafe { __invalidate_dcache() }
}

/// Perform a cache clean and invalidate operation on the entire data cache
pub fn cleaninvalidate() {
    unsafe { __cleaninvalidate_dcache() }
}

extern "C" {
    fn __clean_dcache();
    fn __invalidate_dcache();
    fn __cleaninvalidate_dcache();
}