fn update_csr_trap_registers(
        &mut self,
        exception_pc: u64,
        trap_code: u8,
        trap_value: u64,
        previous_privilege: Privilege,
        is_interrupt: bool,
    ) {
        self.csr.write_direct(
            match self.privilege {
                Privilege::User => CSR_UEPC,
                Privilege::Supervisor => CSR_SEPC,
                Privilege::Hypervisor => CSR_HEPC,
                Privilege::Machine => CSR_MEPC,
            },
            exception_pc,
        );

        let cause = self.get_cause(trap_code, is_interrupt);
        self.csr.write_direct(
            match self.privilege {
                Privilege::User => CSR_UCAUSE,
                Privilege::Supervisor => CSR_SCAUSE,
                Privilege::Hypervisor => CSR_HCAUSE,
                Privilege::Machine => CSR_MCAUSE,
            },
            cause,
        );

        self.csr.write_direct(
            match self.privilege {
                Privilege::User => CSR_UTVAL,
                Privilege::Supervisor => CSR_STVAL,
                Privilege::Hypervisor => CSR_HTVAL,
                Privilege::Machine => CSR_MTVAL,
            },
            trap_value,
        );

        let status_reg = match self.privilege {
            Privilege::User => CSR_USTATUS,
            Privilege::Supervisor => CSR_SSTATUS,
            Privilege::Hypervisor => CSR_HSTATUS,
            Privilege::Machine => CSR_MSTATUS,
        };
        let p = self.privilege.clone() as u8;
        let ie = ((self.csr.read_direct(status_reg) >> p) & 0x1) as u64;
        self.csr.read_modify_write_direct(
            status_reg,
            match self.privilege {
                Privilege::User => panic!("TODO"),
                Privilege::Supervisor => (ie << 5) | ((previous_privilege as u64) << 8),
                Privilege::Hypervisor => panic!("TODO"),
                Privilege::Machine => (ie << 7) | ((previous_privilege as u64) << 11),
            },
            match self.privilege {
                Privilege::User => panic!("TODO"),
                Privilege::Supervisor => 0x122,
                Privilege::Hypervisor => panic!("TODO"),
                Privilege::Machine => 0x1888,
            },
        );
    }
/// update CSR/xEPC, xCAUSE, xTVAL, xSTATUS registers by interrupts.
update CSR/xEPC, xCAUSE, xTVAL, xSTATUS registers by interrupts.
update CSR / xEPC xCAUSE xTVAL xSTATUS registers by interrupts .
fn update_csr_trap_registers(
        &mut self,
        exception_pc: u64,
        trap_code: u8,
        trap_value: u64,
        previous_privilege: Privilege,
        is_interrupt: bool,
    ) {
        self.csr.write_direct(
            match self.privilege {
                Privilege::User => CSR_UEPC,
                Privilege::Supervisor => CSR_SEPC,
                Privilege::Hypervisor => CSR_HEPC,
                Privilege::Machine => CSR_MEPC,
            },
            exception_pc,
        );
        let cause = self.get_cause(trap_code, is_interrupt);
        self.csr.write_direct(
            match self.privilege {
                Privilege::User => CSR_UCAUSE,
                Privilege::Supervisor => CSR_SCAUSE,
                Privilege::Hypervisor => CSR_HCAUSE,
                Privilege::Machine => CSR_MCAUSE,
            },
            cause,
        );
        self.csr.write_direct(
            match self.privilege {
                Privilege::User => CSR_UTVAL,
                Privilege::Supervisor => CSR_STVAL,
                Privilege::Hypervisor => CSR_HTVAL,
                Privilege::Machine => CSR_MTVAL,
            },
            trap_value,
        );
        let status_reg = match self.privilege {
            Privilege::User => CSR_USTATUS,
            Privilege::Supervisor => CSR_SSTATUS,
            Privilege::Hypervisor => CSR_HSTATUS,
            Privilege::Machine => CSR_MSTATUS,
        };
        let p = self.privilege.clone() as u8;
        let ie = ((self.csr.read_direct(status_reg) >> p) & 0x1) as u64;
        self.csr.read_modify_write_direct(
            status_reg,
            match self.privilege {
                Privilege::User => panic!("TODO"),
                Privilege::Supervisor => (ie << 5) | ((previous_privilege as u64) << 8),
                Privilege::Hypervisor => panic!("TODO"),
                Privilege::Machine => (ie << 7) | ((previous_privilege as u64) << 11),
            },
            match self.privilege {
                Privilege::User => panic!("TODO"),
                Privilege::Supervisor => 0x122,
                Privilege::Hypervisor => panic!("TODO"),
                Privilege::Machine => 0x1888,
            },
        );
    }
fn update_csr_trap_registers ( & mut self , exception_pc : u64 , trap_code : u8 , trap_value : u64 , previous_privilege : Privilege , is_interrupt : bool , ) { self . csr . write_direct ( match self . privilege { Privilege :: User => CSR_UEPC , Privilege :: Supervisor => CSR_SEPC , Privilege :: Hypervisor => CSR_HEPC , Privilege :: Machine => CSR_MEPC , } , exception_pc , ) ; let cause = self . get_cause ( trap_code , is_interrupt ) ; self . csr . write_direct ( match self . privilege { Privilege :: User => CSR_UCAUSE , Privilege :: Supervisor => CSR_SCAUSE , Privilege :: Hypervisor => CSR_HCAUSE , Privilege :: Machine => CSR_MCAUSE , } , cause , ) ; self . csr . write_direct ( match self . privilege { Privilege :: User => CSR_UTVAL , Privilege :: Supervisor => CSR_STVAL , Privilege :: Hypervisor => CSR_HTVAL , Privilege :: Machine => CSR_MTVAL , } , trap_value , ) ; let status_reg = match self . privilege { Privilege :: User => CSR_USTATUS , Privilege :: Supervisor => CSR_SSTATUS , Privilege :: Hypervisor => CSR_HSTATUS , Privilege :: Machine => CSR_MSTATUS , } ; let p = self . privilege . clone ( ) as u8 ; let ie = ( ( self . csr . read_direct ( status_reg ) >> p ) & 0x1 ) as u64 ; self . csr . read_modify_write_direct ( status_reg , match self . privilege { Privilege :: User => panic ! ( " " ) , Privilege :: Supervisor => ( ie << 5 ) | ( ( previous_privilege as u64 ) << 8 ) , Privilege :: Hypervisor => panic ! ( " " ) , Privilege :: Machine => ( ie << 7 ) | ( ( previous_privilege as u64 ) << 11 ) , } , match self . privilege { Privilege :: User => panic ! ( " " ) , Privilege :: Supervisor => 0x122 , Privilege :: Hypervisor => panic ! ( " " ) , Privilege :: Machine => 0x1888 , } , ) ; }
update CSR/xEPC, xCAUSE, xTVAL, xSTATUS registers by interrupts.
update CSR / xEPC xCAUSE xTVAL xSTATUS registers by interrupts .
&mut self
exception_pc
u64
trap_code
u8
trap_value
u64
previous_privilege
Privilege
is_interrupt
bool