@@ -144,14 +144,14 @@ template <typename WORD_TYPE> struct clic : public memory_elem {
144144private:
145145 iss::status read_mem (addr_t const & addr, unsigned length, uint8_t * data) {
146146 auto end_addr = addr.val - 1 + length;
147- if (addr.space == 0 && addr.val <= end_addr && addr.val >= cfg.clic_base && end_addr <= (cfg.clic_base + 0x7fff ))
147+ if (addr.space == 0 && addr.val <= end_addr && addr.val >= cfg.clic_base && end_addr <= (cfg.clic_base + 0x7fff ))
148148 return read_clic (addr.val , length, data);
149149 return down_stream_mem.rd_mem (addr, length, data);
150150 }
151151
152152 iss::status write_mem (addr_t const & addr, unsigned length, uint8_t const * data) {
153153 auto end_addr = addr.val - 1 + length;
154- if (addr.space == 0 && addr.val <= end_addr && addr.val >= cfg.clic_base && end_addr <= (cfg.clic_base + 0x7fff ))
154+ if (addr.space == 0 && addr.val <= end_addr && addr.val >= cfg.clic_base && end_addr <= (cfg.clic_base + 0x7fff ))
155155 return write_clic (addr.val , length, data);
156156 return down_stream_mem.wr_mem (addr, length, data);
157157 }
@@ -198,37 +198,37 @@ template <typename WORD_TYPE> struct clic : public memory_elem {
198198 iss::status write_xtvec (unsigned addr, reg_t val) {
199199 hart_if.set_csr (addr, val);
200200 if ((val & 0x3 ) != 0x3 ) {
201- clic_mprev_lvl = 0xff >> cfg.clic_int_ctl_bits ;
202- clic_uprev_lvl = 0xff >> cfg.clic_int_ctl_bits ;
201+ clic_mprev_lvl = 0xff >> cfg.clic_int_ctl_bits ;
202+ clic_uprev_lvl = 0xff >> cfg.clic_int_ctl_bits ;
203203 }
204204 return iss::Ok;
205205 }
206206
207207 iss::status read_cause (unsigned addr, reg_t & val) {
208208 val = hart_if.get_csr (addr) & ((1UL << (WORD_LEN - 1 )) | (hart_if.max_irq - 1 ));
209209 auto xtvec = hart_if.get_csr (arch::mtvec);
210- if ((xtvec& 0x3 ) == 0x3 ) {
211- if (addr == arch::mcause) { // mcause access
212- val |= hart_if.state .mstatus .MPP << 28 | hart_if.state .mstatus .MPIE << 27 |clic_mprev_lvl<< 16 ;
213- } else if (addr ==arch::ucause) {
214- val |= hart_if.state .mstatus .UPIE << 27 | clic_uprev_lvl<< 16 ;
210+ if ((xtvec & 0x3 ) == 0x3 ) {
211+ if (addr == arch::mcause) { // mcause access
212+ val |= hart_if.state .mstatus .MPP << 28 | hart_if.state .mstatus .MPIE << 27 | clic_mprev_lvl << 16 ;
213+ } else if (addr == arch::ucause) {
214+ val |= hart_if.state .mstatus .UPIE << 27 | clic_uprev_lvl << 16 ;
215215 }
216216 }
217217 return iss::Ok;
218218 }
219219
220220 iss::status write_cause (unsigned addr, reg_t val) {
221221 auto mask = ((1UL << (WORD_LEN - 1 )) | (hart_if.max_irq - 1 ));
222- hart_if.set_csr (addr,(val & mask) | (hart_if.get_csr (addr) & ~mask));
222+ hart_if.set_csr (addr, (val & mask) | (hart_if.get_csr (addr) & ~mask));
223223 auto xtvec = hart_if.get_csr (arch::mtvec);
224224 if ((xtvec & 0x3 ) == 0x3 ) {
225- if (addr == arch::mcause){ // mcause access
226- hart_if.state .mstatus .MPIE = (val>> 27 )& 1 ;
227- clic_mprev_lvl = ((val >> 16 ) & 0xff ) | 0xff >> cfg.clic_int_ctl_bits ;
228- hart_if.state .mstatus .MPP = (val <<28 )& 0x3 ;
229- } else if (addr ==arch::ucause) {
230- hart_if.state .mstatus .UPIE = (val>> 27 )& 1 ;
231- clic_uprev_lvl = ((val >> 16 ) & 0xff ) | 0xff >> cfg.clic_int_ctl_bits ;
225+ if (addr == arch::mcause) { // mcause access
226+ hart_if.state .mstatus .MPIE = (val >> 27 ) & 1 ;
227+ clic_mprev_lvl = ((val >> 16 ) & 0xff ) | 0xff >> cfg.clic_int_ctl_bits ;
228+ hart_if.state .mstatus .MPP = (val << 28 ) & 0x3 ;
229+ } else if (addr == arch::ucause) {
230+ hart_if.state .mstatus .UPIE = (val >> 27 ) & 1 ;
231+ clic_uprev_lvl = ((val >> 16 ) & 0xff ) | 0xff >> cfg.clic_int_ctl_bits ;
232232 }
233233 }
234234 return iss::Ok;
0 commit comments