# vsstatus.rs - source
Source of the Rust file `/home/runner/.cargo/git/checkouts/riscv-ab2abd16c438337b/11d43cf/src/register/hypervisorx64/vsstatus.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
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154

    //! Hypervisor Guest External Interrupt Pending Register.

    use bit_field::BitField;

    #[derive(Copy, Clone, Debug)]
    pub struct Vsstatus {
        bits: usize,
    }
    impl Vsstatus {
        #[inline]
        pub fn bits(&self) -> usize {
            return self.bits;
        }
        #[inline]
        pub fn from_bits(x: usize) -> Self {
            return Vsstatus { bits: x };
        }
        #[inline]
        pub unsafe fn write(&self) {
            _write(self.bits);
        }
        ///
        #[inline]
        pub fn sd(&self) -> usize {
            self.bits.get_bits(60..64)
        }
        #[inline]
        pub fn set_sd(&mut self, val: usize) {
            self.bits.set_bits(60..64, val);
        }
        /// Effective User XLEN.
        #[inline]
        pub fn uxl(&self) -> UxlValues {
            UxlValues::from(self.bits.get_bits(32..34))
        }
        #[inline]
        pub fn set_uxl(&mut self, val: UxlValues) {
            self.bits.set_bits(32..34, val as usize);
        }
        ///
        #[inline]
        pub fn mxr(&self) -> bool {
            self.bits.get_bit(19)
        }
        #[inline]
        pub fn set_mxr(&mut self, val: bool) {
            self.bits.set_bit(19, val);
        }
        ///
        #[inline]
        pub fn sum(&self) -> bool {
            self.bits.get_bit(18)
        }
        #[inline]
        pub fn set_sum(&mut self, val: bool) {
            self.bits.set_bit(18, val);
        }
        ///
        #[inline]
        pub fn xs(&self) -> usize {
            self.bits.get_bits(15..17)
        }
        #[inline]
        pub fn set_xs(&mut self, val: usize) {
            self.bits.set_bits(15..17, val);
        }
        ///
        #[inline]
        pub fn fs(&self) -> usize {
            self.bits.get_bits(13..15)
        }
        #[inline]
        pub fn set_fs(&mut self, val: usize) {
            self.bits.set_bits(13..15, val);
        }
        ///
        #[inline]
        pub fn spp(&self) -> bool {
            self.bits.get_bit(8)
        }
        #[inline]
        pub fn set_spp(&mut self, val: bool) {
            self.bits.set_bit(8, val);
        }
        ///
        #[inline]
        pub fn ube(&self) -> bool {
            self.bits.get_bit(6)
        }
        #[inline]
        pub fn set_ube(&mut self, val: bool) {
            self.bits.set_bit(6, val);
        }
        ///
        #[inline]
        pub fn spie(&self) -> bool {
            self.bits.get_bit(5)
        }
        #[inline]
        pub fn set_spie(&mut self, val: bool) {
            self.bits.set_bit(5, val);
        }
        ///
        #[inline]
        pub fn sie(&self) -> bool {
            self.bits.get_bit(1)
        }
        #[inline]
        pub fn set_sie(&mut self, val: bool) {
            self.bits.set_bit(1, val);
        }
    }
    read_csr_as!(Vsstatus, 512, __read_vsstatus);
    write_csr!(512, __write_vsstatus);
    set!(512, __set_vsstatus);
    clear!(512, __clear_vsstatus);
    // bit ops
    set_clear_csr!(
        ///
        , set_mxr, clear_mxr, 1 << 19);
    set_clear_csr!(
        ///
        , set_sum, clear_sum, 1 << 18);
    set_clear_csr!(
        ///
        , set_spp, clear_spp, 1 << 8);
    set_clear_csr!(
        ///
        , set_ube, clear_ube, 1 << 6);
    set_clear_csr!(
        ///
        , set_spie, clear_spie, 1 << 5);
    set_clear_csr!(
        ///
        , set_sie, clear_sie, 1 << 1);

    // enums
    #[derive(Copy, Clone, Debug)]
    #[repr(usize)]
    pub enum UxlValues {
        Uxl32 = 1,
        Uxl64 = 2,
        Uxl128 = 3,
    }
    impl UxlValues {
        fn from(x: usize) -> Self {
            match x {
                1 => Self::Uxl32,
                2 => Self::Uxl64,
                3 => Self::Uxl128,
                _ => unreachable!(),
            }
        }
    }