void main(void) { void *payloadAddress = (void *)0x23F00000; memcpy(payloadAddress, (void*)0x24F00000, *(u32 *)0x24FFFF04); flushCaches(); ((void (*)())payloadAddress)(); }
/****************************************************************************************************** * Makes call to state machine ******************************************************************************************************/ void stateMachine( struct reference* ref ) { // Find which L1 cache to access struct cache L1_cache = cacheType( ref ); // Define initial state struct state state; state.type = ref->type; state.iteration = 0; // Check instruction count if( setFlush == TRUE ) { state.next = FLUSH; } else { state.next = QUERY_L1; } // Define initial L1 reference decomposeAddress( ref, L1 ); state.L1_Index = ref->index[0]; state.L1_Tag = ref->tag[0]; #ifdef PRINT printf( "Tag: %13llx \n", ref->tag[0] ); printf( "Index: %6llx \n", ref->index[0] ); #endif // Start state machine while( TRUE ) { switch( state.next ) { case IDLE: // Increment L1 reference #ifdef PRINT printf( "Increment Reference \n" ); #endif incrementL1( &state, ref ); break; case QUERY_L1: // Query L1 cache for tag #ifdef PRINT printf( "Query L1 \n" ); #endif queryL1( &state, &L1_cache ); break; case QUERY_L2: // Query L2 cache for tag #ifdef PRINT printf( "Query L2 \n" ); #endif queryL2( &state ); break; case ADD_L1: // Add tag to L1 cache #ifdef PRINT printf( "Add L1 \n" ); #endif addL1( &state, &L1_cache ); break; case ADD_L2: // Add tag to L2 cache #ifdef PRINT printf( "Add L2 \n" ); #endif addL2( &state ); break; case HANDLE_WRITE: // Set dirty bit in L1 cache #ifdef PRINT printf( "Handle write case \n" ); #endif handleWrite( &state, &L1_cache ); break; case FLUSH: // Flush and invalidate all caches #ifdef PRINT printf( "Flush \n" ); #endif flushCaches( &state ); break; case TERMINATE: // Break out of state machine #ifdef PRINT printf( "**********************************************************************************************\n" ); #endif terminate( ref ); return; } } }
void CacheManager::enableCaches() { disabled=false; flushCaches(); }
void CacheManager::disableCaches() { disabled=true; flushCaches(); }