@@ -141,6 +141,36 @@ int armv8_cache_d_inner_flush_virt(struct armv8_common *armv8, target_addr_t va,
141141 return retval ;
142142}
143143
144+ static int armv8_cache_i_inner_clean_inval_all (struct armv8_common * armv8 )
145+ {
146+ struct arm_dpm * dpm = armv8 -> arm .dpm ;
147+ int retval ;
148+
149+ retval = armv8_i_cache_sanity_check (armv8 );
150+ if (retval != ERROR_OK )
151+ return retval ;
152+
153+ LOG_DEBUG ("flushing cache" );
154+
155+ retval = dpm -> prepare (dpm );
156+ if (retval != ERROR_OK )
157+ goto done ;
158+
159+ retval = dpm -> instr_execute (dpm , armv8_opcode (armv8 , ARMV8_OPC_ICIALLU ));
160+ if (retval != ERROR_OK )
161+ goto done ;
162+
163+ dpm -> finish (dpm );
164+ LOG_DEBUG ("flushing cache done" );
165+ return retval ;
166+
167+ done :
168+ LOG_ERROR ("i-cache invalidate failed" );
169+ dpm -> finish (dpm );
170+
171+ return retval ;
172+ }
173+
144174int armv8_cache_i_inner_inval_virt (struct armv8_common * armv8 , target_addr_t va , size_t size )
145175{
146176 struct arm_dpm * dpm = armv8 -> arm .dpm ;
@@ -253,6 +283,32 @@ static int armv8_flush_all_data(struct target *target)
253283 return retval ;
254284}
255285
286+ static int armv8_flush_all_instruction (struct target * target )
287+ {
288+ int retval = ERROR_FAIL ;
289+ /* check that armv8_cache is correctly identify */
290+ struct armv8_common * armv8 = target_to_armv8 (target );
291+ if (armv8 -> armv8_mmu .armv8_cache .info == -1 ) {
292+ LOG_ERROR ("trying to flush un-identified cache" );
293+ return retval ;
294+ }
295+
296+ if (target -> smp ) {
297+ /* look if all the other target have been flushed in order to flush icache */
298+ struct target_list * head ;
299+ foreach_smp_target (head , target -> smp_targets ) {
300+ struct target * curr = head -> target ;
301+ if (curr -> state == TARGET_HALTED ) {
302+ LOG_TARGET_INFO (curr , "Wait flushing instruction l1." );
303+ retval = armv8_cache_i_inner_clean_inval_all (target_to_armv8 (curr ));
304+ }
305+ }
306+ } else {
307+ retval = armv8_cache_i_inner_clean_inval_all (armv8 );
308+ }
309+ return retval ;
310+ }
311+
256312static int get_cache_info (struct arm_dpm * dpm , int cl , int ct , uint32_t * cache_reg )
257313{
258314 struct armv8_common * armv8 = dpm -> arm -> arch_info ;
@@ -412,6 +468,12 @@ int armv8_identify_cache(struct armv8_common *armv8)
412468 armv8 -> armv8_mmu .armv8_cache .flush_all_data_cache =
413469 armv8_flush_all_data ;
414470 }
471+ if (!armv8 -> armv8_mmu .armv8_cache .invalidate_all_instruction_cache ) {
472+ armv8 -> armv8_mmu .armv8_cache .display_cache_info =
473+ armv8_handle_inner_cache_info_command ;
474+ armv8 -> armv8_mmu .armv8_cache .invalidate_all_instruction_cache =
475+ armv8_flush_all_instruction ;
476+ }
415477
416478done :
417479 armv8_dpm_modeswitch (dpm , ARM_MODE_ANY );
0 commit comments