# vscause.rs - source
Source of the Rust file `/home/runner/.cargo/git/checkouts/riscv-ab2abd16c438337b/11d43cf/src/register/hypervisorx64/vscause.rs`.
Keywords: rust, rustlang, rust-lang

    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
    49
    50

    //! Virtual Supervisor Cause Register.

    use bit_field::BitField;

    #[derive(Copy, Clone, Debug)]
    pub struct Vscause {
        bits: usize,
    }
    impl Vscause {
        #[inline]
        pub fn bits(&self) -> usize {
            return self.bits;
        }
        #[inline]
        pub fn from_bits(x: usize) -> Self {
            return Vscause { bits: x };
        }
        #[inline]
        pub unsafe fn write(&self) {
            _write(self.bits);
        }
        /// Is cause interrupt.
        #[inline]
        pub fn interrupt(&self) -> bool {
            self.bits.get_bit(63)
        }
        #[inline]
        pub fn set_interrupt(&mut self, val: bool) {
            self.bits.set_bit(63, val);
        }
        /// Exception code
        #[inline]
        pub fn code(&self) -> usize {
            self.bits.get_bits(0..63)
        }
        #[inline]
        pub fn set_code(&mut self, val: usize) {
            self.bits.set_bits(0..63, val);
        }
    }
    read_csr_as!(Vscause, 578, __read_vscause);
    write_csr!(578, __write_vscause);
    set!(578, __set_vscause);
    clear!(578, __clear_vscause);
    // bit ops
    set_clear_csr!(
        ///Is cause interrupt.
        , set_interrupt, clear_interrupt, 1 << 63);

    // enums