Example #1
0
static void
sanity_check_tsb(tsb_t *tsb) {
  if(tsb->size_bits > TSB_SIZE_MAX) {
    gf_error(M_BADTSB,
	     FLINE_f
	     "Tsb '%s', size bits 0x%llx out of range (0-0x%x).\n",
	     SRC_FLINE(tsb), tsb->name, tsb->size_bits, TSB_SIZE_MAX);
  }

  if(tsb->split > 1) {
    gf_error(M_BADTSB, 
	     FLINE_f "Tsb '%s', split 0x%llx out of range (0-1).\n",
	     SRC_FLINE(tsb), tsb->name, tsb->split);
  }

  if(tsb->num_entries == 0) {
    gf_error(M_BADTSB, 
	     FLINE_f "Tsb '%s', num_entries cannot be zero.\n",
	     SRC_FLINE(tsb), tsb->name);
  }
  if(tsb->start_addr == NO_ADDR) {
    gf_error(M_BADTSB, 
	     "Tsb '%s', no start_addr set.\n",
	     SRC_FLINE(tsb), tsb->name);
  }
  
}
Example #2
0
void
tsb_link_add_entry(tsb_link_t *tsb_link, uint64_t tag, uint64_t data,
		   tsb_entry_t *tsb_entry, block_t *block,
		   block_tsb_t *block_tsb) 
{
  tsb_link_entry_t *link_entry;

  if(tsb_entry->tag == TSB_LINK_TAG) {
    uint64_t index;
    /* add to chain */

    index = (tsb_entry->data - tsb_link->start_addr) / LINK_SIZE;
    link_entry = VECTOR_ELEM(tsb_link->entries, index,
			     tsb_link_entry_vector_el_t);

    /* chase to the end of the chain */
    while(link_entry->next) {
      if((link_entry->tag == tag) && !Suppress_dup_tags_error) {

	gf_error(M_DUPLICATETAG,
		 "Conflict in TSB_Link '%s'.\n"
		 "Tag 0x%llx being added twice.\n"
		 FLINE_f
		 "First from block '%s'\n"
		 FLINE_f
		 "Again from block '%s'\n",
		 tsb_link->name, tag, 
		 SRC_FLINE(link_entry->block), link_entry->block->name,
		 SRC_FLINE(block), block->name);
      }
      link_entry = link_entry->next;
    }

    add_to_chain(tsb_link, link_entry, tag, data, block, block_tsb);
  } else {
    /* create new chain */
    link_entry = start_new_chain(tsb_link, tsb_entry->tag, tsb_entry->data,
				 block, block_tsb);
    add_to_chain(tsb_link, link_entry, tag, data, block, block_tsb);

    if((link_entry->tag == tag) && !Suppress_dup_tags_error) {
      gf_error(M_DUPLICATETAG,
	       "Conflict in TSB_Link '%s'.\n"
	       "Tag 0x%llx being added twice.\n"
	       FLINE_f
	       "First from block '%s'\n"
	       FLINE_f
	       "Again from block '%s'\n",
	       tsb_link->name, tag, 
	       SRC_FLINE(tsb_entry->block), tsb_entry->block->name,	       
	       SRC_FLINE(block), block->name);
    }


    tsb_entry->tag  = TSB_LINK_TAG;
    tsb_entry->data = link_entry->my_link;

  }
}
Example #3
0
void
add_entry(tsb_t *tsb, uint64_t index, uint64_t tag, uint64_t data,
	  block_t *block, block_tsb_t *block_tsb) 
{
  if(index >= tsb->num_entries) {
    gf_error(M_BADTSB,
	     FLINE_f "Cannot insert entry into TSB '%s' at "
	     "index %lld since it has only %lld entries!\n",
	     SRC_FLINE(tsb), tsb->name, index, tsb->num_entries);
  }

  if((tsb->entries[index].tag == 0) && (tsb->entries[index].data == 0)) {
    /* no collision */
    tsb->entries[index].tag  = tag;
    tsb->entries[index].data = data;
    tsb->entries[index].block = block;
    tsb->entries[index].block_tsb = block_tsb;
  } else {
    /* need to create a linked vector */
    if(!Allow_tsb_conflicts) {
      gf_error(M_VACOLLIDE,
	       "VA collision in TSB %s at index %lld.\n"
	       FLINE_f
	       "This_va=0x%llx (tag %llx) from block %s.\n"
	       FLINE_f
	       "Conficting_va=0x%llx from block %s.\n"
	       "Not allowed unless -allow_tsb_conflicts is used.\n",
	       tsb->name, index, SRC_FLINE(block),
	       tag2va(block_tsb, tag, index), tag, block->name,
	       SRC_FLINE(tsb->entries[index].block_tsb->block),
	       tag2va(tsb->entries[index].block_tsb, tsb->entries[index].tag,
		      index),
	       tsb->entries[index].block->name
	       );
    } else if(!tsb->link_ptr) {
      gf_error(M_BADTSB,
	       "TSB %s has entry collsion and no link area.\n"
	       FLINE_f
	       "First addr:  0x%llx from block %s.\n"
	       FLINE_f
	       "Second addr: 0x%llx from block %s.\n",
	       tsb->name,
	       SRC_FLINE(block), tag2va(block_tsb, tag, index), block->name,
	       SRC_FLINE(tsb->entries[index].block_tsb->block),
	       tag2va(tsb->entries[index].block_tsb, tsb->entries[index].tag,
		      index),
	       tsb->entries[index].block->name
	       );
    }

    tsb_link_add_entry(tsb->link_ptr, tag, data,
		       &(tsb->entries[index]), block, block_tsb);
  }

}
Example #4
0
void
open_new_tsb(char *name, int lineno) {
  int new_index;
  tsb_t *tsb;
  int i;
  int exists_error = 0;

  if(get_tsb_ptr_by_name(name)) {
    exists_error = 1;
    /* Defer error until after object is created to use standard error
       handlers */
  }

  new_index = add_vector_elements(&Tsb_vector, 1);

  Open_tsb_index = new_index;
  tsb = VECTOR_ELEM(Tsb_vector, new_index, tsb_vector_el_t);

  tsb->name = strdup(name);
  tsb->lineno = lineno;

  if(exists_error) {
    gf_error(M_BADTSB, FLINE_f "TSB named '%s' already exists!\n",
	     SRC_FLINE(tsb), name);
  }

}
Example #5
0
void usage(char *s)
{
  fprintf(stderr, "usage: gf_time w tests seed size(bytes) iterations [method [params]] - does timing\n");
  fprintf(stderr, "\n");
  fprintf(stderr, "does unit testing in GF(2^w)\n");
  fprintf(stderr, "\n");
  fprintf(stderr, "Legal w are: 1 - 32, 64 and 128\n");
  fprintf(stderr, "\n");
  fprintf(stderr, "Tests may be any combination of:\n");
  fprintf(stderr, "       A: All\n");
  fprintf(stderr, "       S: All Single Operations\n");
  fprintf(stderr, "       R: All Region Operations\n");
  fprintf(stderr, "       M: Single: Multiplications\n");
  fprintf(stderr, "       D: Single: Divisions\n");
  fprintf(stderr, "       I: Single: Inverses\n");
  fprintf(stderr, "       G: Region: Buffer-Constant Multiplication\n");
  fprintf(stderr, "       0: Region: Doing nothing, and bzero()\n");
  fprintf(stderr, "       1: Region: Memcpy() and XOR\n");
  fprintf(stderr, "       2: Region: Multiplying by two\n");
  fprintf(stderr, "\n");
  fprintf(stderr, "Use -1 for time(0) as a seed.\n");
  fprintf(stderr, "\n");
  if (s == BM) {
    fprintf(stderr, "%s", BM);
    gf_error();
  } else if (s != NULL) {
    fprintf(stderr, "%s\n", s);
  }
  exit(1);
}
Example #6
0
static void
sanity_check_tsb_link(tsb_link_t *tsb_link) {
  if(tsb_link->start_addr == UNSPECIFIED_START) {
    gf_error(M_BADTSB, 
	     FLINE_f
	     "TSB_link '%s' does not specify a starting address!\n",
	     SRC_FLINE(tsb_link), tsb_link->name);
  }
}
Example #7
0
void
close_tsb(int lineno) {
  if(Open_tsb_index == NO_OPEN_TSB) {
    gf_error(M_GOLDFINGERPARSE, FLINE_f
	     "Cannot close TSB since none is open!\n", GF_FLINE_NUM(lineno));
  }

  sanity_check_tsb(VECTOR_ELEM(Tsb_vector, Open_tsb_index, tsb_vector_el_t));

  Open_tsb_index = NO_OPEN_TSB;
}
Example #8
0
void usage(char *s)
{
  fprintf(stderr, "usage: gf_unit w tests seed [method] - does unit testing in GF(2^w)\n");
  fprintf(stderr, "\n");    
  fprintf(stderr, "Legal w are: 1 - 32, 64 and 128\n");
  fprintf(stderr, "           128 is hex only (i.e. '128' will be an error - do '128h')\n");
  fprintf(stderr, "\n");
  fprintf(stderr, "Tests may be any combination of:\n");
  fprintf(stderr, "       A: All\n");
  fprintf(stderr, "       S: Single operations (multiplication/division)\n");
  fprintf(stderr, "       R: Region operations\n");
  fprintf(stderr, "       V: Verbose Output\n");
  fprintf(stderr, "\n");
  fprintf(stderr, "Use -1 for time(0) as a seed.\n");
  fprintf(stderr, "\n");
  if (s == BM) {
    fprintf(stderr, "%s", BM);
    gf_error();
  } else if (s != NULL) {
    fprintf(stderr, "%s\n", s);
  }
  exit(1);
}
Example #9
0
static void
finish_single_tsb_init(tsb_vector_el_t *tsbp, void* data) {
  tsb_t *tsb = *tsbp;

  tsb_link_t *link_ptr = NULL;
  uint64_t entries_bytes = 0;

  if(tsb->link_area) {
    link_ptr = get_tsb_link_ptr_by_name(tsb->link_area);
    if(!link_ptr) {
      gf_error(M_BADTSB, FLINE_f
	       "TSB '%s' defines a non-existent link area '%s'!\n",
	       SRC_FLINE(tsb), tsb->name, tsb->link_area);
    } else {
      tsb->link_ptr = link_ptr;
    }
  }

  entries_bytes = tsb->num_entries * sizeof(* (tsb->entries));

  tsb->entries = gf_malloc( entries_bytes );
  bzero(tsb->entries, entries_bytes);

}