• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2024, The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 //! Low-level CPU-specific operations.
16 
17 #[cfg(target_arch = "aarch64")]
18 pub mod aarch64;
19 
20 #[cfg(target_arch = "aarch64")]
21 pub use aarch64::platform;
22 
23 #[cfg(target_arch = "aarch64")]
24 pub use aarch64::layout;
25 
26 #[cfg(target_arch = "aarch64")]
27 pub use aarch64::linker;
28 
29 #[cfg(target_arch = "aarch64")]
30 pub use aarch64::dbm;
31 
32 #[cfg(target_arch = "aarch64")]
33 pub use aarch64::rand;
34 
35 #[cfg(target_arch = "aarch64")]
36 pub use aarch64::uart;
37 
38 #[cfg(target_arch = "aarch64")]
39 pub use aarch64_paging::paging::VirtualAddress;
40 
41 /// Flush `size` bytes of data cache by virtual address.
42 #[inline]
flush_region(start: usize, size: usize)43 pub(crate) fn flush_region(start: usize, size: usize) {
44     cfg_if::cfg_if! {
45         if #[cfg(target_arch = "aarch64")] {
46             let line_size = aarch64::min_dcache_line_size();
47             let end = start + size;
48             let start = crate::util::unchecked_align_down(start, line_size);
49             for line in (start..end).step_by(line_size) {
50                 crate::dc!("cvau", line);
51             }
52         } else {
53             compile_error!("Unsupported target_arch")
54         }
55     }
56 }
57