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
//! Code for managing VBAR (*Vector Base Address Register*)
use crate::register::{SysReg, SysRegRead, SysRegWrite};
/// VBAR (*Vector Base Address Register*)
///
/// There is no `modify` method because this register holds a single 32-bit address.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(transparent)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Vbar(pub u32);
impl SysReg for Vbar {
const CP: u32 = 15;
const CRN: u32 = 12;
const OP1: u32 = 0;
const CRM: u32 = 0;
const OP2: u32 = 0;
}
impl SysRegRead for Vbar {}
impl SysRegWrite for Vbar {}
impl Vbar {
/// Read VBAR (*Vector Base Address Register*)
#[inline]
pub fn read() -> Vbar {
Self(<Self as SysRegRead>::read_raw())
}
/// Write VBAR (*Vector Base Address Register*)
///
/// # Safety
///
/// You must supply a correctly-aligned address of a valid Arm AArch32
/// Vector Table.
#[inline]
pub unsafe fn write(value: Self) {
// Safety: Writing this register is atomic
unsafe {
<Self as SysRegWrite>::write_raw(value.0);
}
}
}