Example #1
0
status check_direct(int test[], char* hit_miss[] , int s ,int l, int test_num ){
  int i, j ;
  int numlines ;
  unsigned int new_tag, index ;
  queue Q ;

  numlines= s / l ;
  line cache[MAXLINES] ;
  // initialize the cache and the queue
  // the queue will store the index of the cache line
  // which has its valid field changed from 0 to 1
  init_cache ( cache, numlines ) ;
  init_queue ( &Q ) ;

  for ( i = 0 ; i < test_num; i++ ){
    if( cache_full( cache, numlines ) == TRUE )
      evict_cache( cache , &Q ) ;
    get_tag_index ( &new_tag, &index, test[i], l, numlines ) ;

    if( cache[index].valid == 1 &&  cache[index].tag == new_tag )
      hit_miss[i] = "HIT" ;
    else{
      hit_miss[i] = "MISS" ;
      cache[index].tag = new_tag ;
      if ( cache[index].valid == 0 ){
        push_int( &Q, index ) ;
      }
      cache[index].valid = 1 ;
    }
  }
  return OK ;
}
Example #2
0
/*
 *  ======== fixup_rsc_table ========
 */
static void fixup_rsc_table(void *data)
{
    struct resource_table *tbl = (struct resource_table *)data;
    struct fw_rsc_trace *trace;
    bool processed = true;
    u32 *rsc_type;
    int i, tag;
#if DEBUG_GENCMBELF
    /* current resource type names as per rsc_types.h */
    char *rsc_names[6] =
            { "carveOut", "devmem", "trace", "vdev", "crashdump", "custom" };
#endif

    DEBUG_PRINT("  fixup resource table entries\n");
    for (i = 0; i < tbl->num; i++) {
        rsc_type = (u32 *)((u32)tbl + tbl->offset[i]);
        if (*rsc_type < 0 || *rsc_type > 6) {
            DEBUG_PRINT("    resource #%d is invalid\n", i);
            continue;
        }

        DEBUG_PRINT("    resource #%d of type_%s ", i, rsc_names[*rsc_type]);
        processed = true;
        if (*rsc_type == TYPE_TRACE) {
            trace = (struct fw_rsc_trace *)rsc_type;
            if (!strcmp(trace->name, CORE1_TRACENAME)) {
                processed = false;
                tag = get_tag_index("trace1");
                if (tag >= 0) {
                    DEBUG_PRINT("fixed up (updated from 0x%x:0x%x to ",
                                    trace->da, trace->len);
                    trace->da = tag_addr[tag];
                    trace->len = tag_size[tag];
                    DEBUG_PRINT("0x%x:0x%x)\n", trace->da, trace->len);
                }
                else {
                    DEBUG_PRINT("fixup failed\n");
                }
            }
        }
        if (processed) {
            DEBUG_PRINT("processed\n");
        }
    }
    DEBUG_PRINT("  resource table entries for Core1 fixed up\n");
}
Example #3
0
void set_tags(char *filename,const char *tags[],int numtags)
{
    long fileindex=get_file_index(filename,1);
    long tagindex;

    if(fileindex==(-1))
        return;
    
    int i;
    for(i=0;i<numtags;i++)
    {
        tagindex=get_tag_index(tags[i]);
        if(tagindex!=-1)
        {
            char *temp=sqlite3_mprintf("INSERT INTO booktags (fileid,tagid) VALUES(%d,%d)",fileindex,tagindex);
            sqlite3_exec(madshelf_database,temp,NULL,NULL,NULL);
            sqlite3_free(temp);
        }
    }
}