@@ -208,17 +208,23 @@ function read_mip(read_type : XipReadType) -> Minterrupts =
208208function update_mip () -> unit = {
209209 let old_mip = mip . bits ;
210210
211- // This updates `mip` for any timer interrupts that may now have fired,
212- // and for any machine-level software interrupts arising from the
213- // CLINT.
211+ // This updates `mip` for any timer interrupts that may now have
212+ // fired, and for any machine-level software interrupts arising from
213+ // the CLINT. Currently, the only timer support is from the CLINT;
214+ // so without a CLINT, no timer interrupts can fire. This may need
215+ // to change when we support other or multiple interrupt
216+ // controllers.
217+
218+ let platform_has_timer = plat_have_clint ;
219+
214220 let cur_mtime = get_mtime ();
215221 let hart_mtimecmp = get_hart_mtimecmp ();
216222
217223 mip [MSI ] = get_machine_software_interrupt_pending ();
218- mip [MTI ] = bool_to_bit (hart_mtimecmp <= _u cur_mtime );
224+ mip [MTI ] = bool_to_bit (platform_has_timer & ( hart_mtimecmp <= _u cur_mtime ) );
219225
220226 if currentlyEnabled (Ext_Sstc ) & menvcfg [STCE ] == 0b1 then {
221- mip [STI ] = bool_to_bit (stimecmp <= _u cur_mtime );
227+ mip [STI ] = bool_to_bit (platform_has_timer & ( stimecmp <= _u cur_mtime ) );
222228 };
223229
224230 if currentlyEnabled (Ext_H ) then {
@@ -240,7 +246,7 @@ function update_mip() -> unit = {
240246 var VSTI : bits (1 ) = hvip [VSTI ];
241247
242248 if currentlyEnabled (Ext_Sstc ) & read_henvcfg ()[STCE ] == 0b1 then {
243- VSTI = VSTI | bool_to_bit (vstimecmp <= _u (cur_mtime + htimedelta ));
249+ VSTI = VSTI | bool_to_bit (platform_has_timer & ( vstimecmp <= _u (cur_mtime + htimedelta ) ));
244250 };
245251 mip [VSTI ] = VSTI ;
246252 };
0 commit comments