OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_47/] [or1ksim/] [cpu/] [common/] [parse.c] - Diff between revs 1350 and 1353

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 1350 Rev 1353
Line 57... Line 57...
static oraddr_t transl_table;
static oraddr_t transl_table;
 
 
/* Used to signal whether during loading of programs a translation fault occured. */
/* Used to signal whether during loading of programs a translation fault occured. */
static unsigned long transl_error;
static unsigned long transl_error;
 
 
 
 
char *strtoken(char *in, char *out, int which)
 
{
 
  char  *super;
 
  char  *sub;
 
  char  *newline;
 
 
 
  super = strdup(in);
 
  sub = strtok(super, " \t");
 
  while (sub && --which)
 
    sub = strtok(NULL, " \t");
 
  if (sub && !which) {
 
    if ((newline = strchr(sub, '\n')))
 
      newline[0] = '\0';
 
    strcpy(out, sub);
 
  } else
 
    out[0] = '\0';
 
  free(super);
 
  if ((newline = strchr(out, '\r')))  /* get rid of CR */
 
    newline[0] = '\0';
 
  return(out);
 
}
 
 
 
char *
char *
stripwhite (string)
stripwhite (string)
     char *string;
     char *string;
{
{
  register char *s, *t;
  register char *s, *t;
Line 108... Line 85...
  strncpy (dst, src, n);
  strncpy (dst, src, n);
  *(dst + n) = '\0';
  *(dst + n) = '\0';
  return dst;
  return dst;
}
}
 
 
/* Parses string line and puts up to maxparam parameters into argv[]; number of parameters is returned */
 
int tokenize_line (char *str, char *argv[], int maxparam)
 
{
 
  int i, param = 0;
 
  str = stripwhite (str);
 
  while (*str) {
 
    char *p;
 
    argv[param] = str;
 
    while (*str && !isblank (*str)) str++;
 
    param++;
 
    p = str;
 
    if (param >= maxparam) break;
 
    while (*str && isblank (*str)) str++;
 
    *p = 0;
 
  }
 
  for (i = 0; i < param; i++) argv[i] = stripwhite (argv[i]);
 
  return param;
 
}
 
 
 
/* Used only by the simulator loader to translate logical addresses into physical.
/* Used only by the simulator loader to translate logical addresses into physical.
   If loadcode() is called with valid virtphy_transl pointer to a table of
   If loadcode() is called with valid virtphy_transl pointer to a table of
   translations then translate() performs translation otherwise phy address is
   translations then translate() performs translation otherwise phy address is
   equal to logical. */
   equal to logical. */
static oraddr_t translate(oraddr_t laddr,int* breakpoint)
static oraddr_t translate(oraddr_t laddr,int* breakpoint)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.