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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [bootloaders/] [orpmon/] [common/] [common.c] - Diff between revs 375 and 406

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

Rev 375 Rev 406
Line 66... Line 66...
{
{
  debug ("testc %i\n", bd.bi_console_type);
  debug ("testc %i\n", bd.bi_console_type);
  switch (bd.bi_console_type) {
  switch (bd.bi_console_type) {
#if KBD_ENABLED
#if KBD_ENABLED
  case CT_CRT:
  case CT_CRT:
    if (kbd_head == kbd_tail) return 0;
                if (kbd_head == kbd_tail)
    else return getc ();
                        return 0;
 
                else
 
                        return getc();
#endif
#endif
  case CT_UART:
  case CT_UART:
    return uart_testc ();
    return uart_testc ();
    break;
    break;
  case CT_NONE: /* just to satisfy the compiler */
  case CT_NONE: /* just to satisfy the compiler */
Line 92... Line 94...
    }
    }
  }
  }
  return 0;
  return 0;
}
}
 
 
void
void print_or1k_cache_info()
print_or1k_cache_info()
 
{
{
  // Read out UPR, check what modules we have
  // Read out UPR, check what modules we have
  unsigned long upr = mfspr(SPR_UPR);
  unsigned long upr = mfspr(SPR_UPR);
  printf("Instruction cache:\t");
  printf("Instruction cache:\t");
  if (upr & SPR_UPR_ICP)
        if (upr & SPR_UPR_ICP) {
    {
 
      // We have instruction cache, read out ICCFGR
      // We have instruction cache, read out ICCFGR
 
 
      unsigned long iccfgr = mfspr(SPR_ICCFGR);
      unsigned long iccfgr = mfspr(SPR_ICCFGR);
      unsigned int cbs; // cache block size
      unsigned int cbs; // cache block size
      unsigned long ncs = 1 << ((iccfgr & SPR_ICCFGR_NCS) >> 3);
      unsigned long ncs = 1 << ((iccfgr & SPR_ICCFGR_NCS) >> 3);
Line 113... Line 113...
        cbs = 16;
        cbs = 16;
 
 
      printf("%dkB (BS: %d Sets: %d)\n",
      printf("%dkB (BS: %d Sets: %d)\n",
             (cbs * ncs)/1024, cbs, ncs);
             (cbs * ncs)/1024, cbs, ncs);
 
 
    }
        } else
  else
 
    printf(" not present\n");
    printf(" not present\n");
 
 
  printf("Data cache:\t\t");
  printf("Data cache:\t\t");
  if (upr & SPR_UPR_DCP)
        if (upr & SPR_UPR_DCP) {
    {
 
      // We have instruction cache, read out DCCFGR
      // We have instruction cache, read out DCCFGR
 
 
      unsigned long iccfgr = mfspr(SPR_DCCFGR);
      unsigned long iccfgr = mfspr(SPR_DCCFGR);
      unsigned int cbs; // cache block size
      unsigned int cbs; // cache block size
      unsigned long ncs = 1 << ((iccfgr & SPR_DCCFGR_NCS) >> 3);
      unsigned long ncs = 1 << ((iccfgr & SPR_DCCFGR_NCS) >> 3);
Line 133... Line 131...
        cbs = 16;
        cbs = 16;
 
 
      printf("%dkB (BS: %d Sets: %d)\n",
      printf("%dkB (BS: %d Sets: %d)\n",
             (cbs * ncs)/1024, cbs, ncs);
             (cbs * ncs)/1024, cbs, ncs);
 
 
    }
        } else
  else
 
    printf(" not present\n");
    printf(" not present\n");
 
 
}
}
 
 
unsigned long parse_ip (char *ip)
unsigned long parse_ip (char *ip)
{
{
  unsigned long num;
  unsigned long num;
  num = strtoul (ip, &ip, 10) & 0xff;
  num = strtoul (ip, &ip, 10) & 0xff;
  if (*ip++ != '.') return 0;
        if (*ip++ != '.')
 
                return 0;
  num = (num << 8) | (strtoul (ip, &ip, 10) & 0xff);
  num = (num << 8) | (strtoul (ip, &ip, 10) & 0xff);
  if (*ip++ != '.') return 0;
        if (*ip++ != '.')
 
                return 0;
  num = (num << 8) | (strtoul (ip, &ip, 10) & 0xff);
  num = (num << 8) | (strtoul (ip, &ip, 10) & 0xff);
  if (*ip++ != '.') return 0;
        if (*ip++ != '.')
 
                return 0;
  num = (num << 8) | (strtoul (ip, &ip, 10) & 0xff);
  num = (num << 8) | (strtoul (ip, &ip, 10) & 0xff);
  return num;
  return num;
}
}
 
 
void change_console_type (enum bi_console_type_t con_type)
void change_console_type (enum bi_console_type_t con_type)
Line 184... Line 184...
  case CT_SIM:
  case CT_SIM:
    break;
    break;
  }
  }
}
}
 
 
void register_command_func (const char *name, const char *params, const char *help, int (*func)(int argc, char *argv[]))
void register_command_func(const char *name, const char *params,
 
                           const char *help, int (*func) (int argc,
 
                                                          char *argv[]))
{
{
  debug ("register_command '%s'\n", name);
  debug ("register_command '%s'\n", name);
  if (num_commands < MAX_COMMANDS) {
  if (num_commands < MAX_COMMANDS) {
    command[num_commands].name = name;
    command[num_commands].name = name;
    command[num_commands].params = params;
    command[num_commands].params = params;
    command[num_commands].help = help;
    command[num_commands].help = help;
    command[num_commands].func = func;
    command[num_commands].func = func;
    num_commands++;
    num_commands++;
  } else printf ("Command '%s' ignored; MAX_COMMANDS limit reached\n", name);
        } else
 
                printf("Command '%s' ignored; MAX_COMMANDS limit reached\n",
 
                       name);
}
}
 
 
/* Process command and arguments by executing
/* Process command and arguments by executing
   specific function. */
   specific function. */
void mon_command(void)
void mon_command(void)
Line 211... Line 215...
  int chcnt = 0;
  int chcnt = 0;
 
 
  /* Show prompt */
  /* Show prompt */
  printf ("\n" BOARD_DEF_NAME"> ");
  printf ("\n" BOARD_DEF_NAME"> ");
 
 
  while(1)
        while (1) {
    {
 
      c=getc();
      c=getc();
 
 
      if (c == 0x7f) // Backspace on picocom is showing up as 0x7f
      if (c == 0x7f) // Backspace on picocom is showing up as 0x7f
        c = '\b';
        c = '\b';
 
 
      if (c == '\r' || c == '\f' || c == '\n')
                if (c == '\r' || c == '\f' || c == '\n') {
        {
 
          // Mark end of string
          // Mark end of string
          *pstr = '\0';
          *pstr = '\0';
          putc('\n');
          putc('\n');
          break;
          break;
        }
                } else if (c == '\b')   // Backspace
      else if (c == '\b') // Backspace
 
        {
 
          if (chcnt > 0)
 
            {
            {
 
                        if (chcnt > 0) {
              putc(c);
              putc(c);
              putc(' '); // cover char with space
              putc(' '); // cover char with space
              putc(c);
              putc(c);
              pstr--;
              pstr--;
              chcnt--;
              chcnt--;
            }
            }
        }
                } else {
      else
 
        {
 
          putc(c);
          putc(c);
          *pstr++ = c;
          *pstr++ = c;
          chcnt++;
          chcnt++;
        }
        }
    }
    }
 
 
  /* Skip leading blanks */
  /* Skip leading blanks */
  pstr = str;
  pstr = str;
  while (*pstr == ' ' && *pstr != '\0') pstr++;
        while (*pstr == ' ' && *pstr != '\0')
 
                pstr++;
 
 
  /* Get command from the string */
  /* Get command from the string */
  command_str = pstr;
  command_str = pstr;
 
 
  while (1) {
  while (1) {
    /* Go to next argument */
    /* Go to next argument */
    while (*pstr != ' ' && *pstr != '\0') pstr++;
                while (*pstr != ' ' && *pstr != '\0')
 
                        pstr++;
    if (*pstr) {
    if (*pstr) {
      *pstr++ = '\0';
      *pstr++ = '\0';
      while (*pstr == ' ') pstr++;
                        while (*pstr == ' ')
 
                                pstr++;
      argv[argc++] = pstr;
      argv[argc++] = pstr;
    }
                } else
    else
 
      break;
      break;
  }
  }
 
 
  {
  {
    int i, found = 0;
    int i, found = 0;
 
 
    for (i = 0; i < num_commands; i++)
    for (i = 0; i < num_commands; i++)
      if (strcmp (command_str, command[i].name) == 0)
                        if (strcmp(command_str, command[i].name) == 0) {
      {
                                switch (command[i].func(argc, &argv[0])) {
        switch ( command[i].func(argc, &argv[0]) )
 
        {
 
          case -1:
          case -1:
            printf ("Missing/wrong parameters, usage: %s %s\n",
                                        printf
                    command[i].name, command[i].params);
                                            ("Missing/wrong parameters, usage: %s %s\n",
 
                                             command[i].name,
 
                                             command[i].params);
            break;
            break;
        }
        }
 
 
        found++;
        found++;
        break;
        break;
Line 298... Line 298...
/* Displays help screen */
/* Displays help screen */
int help_cmd (int argc, char *argv[])
int help_cmd (int argc, char *argv[])
{
{
  int i;
  int i;
  for (i = 0; i < num_commands; i++)
  for (i = 0; i < num_commands; i++)
    printf ("%-10s %-20s - %s\n", command[i].name, command[i].params, command[i].help);
                printf("%-10s %-20s - %s\n", command[i].name, command[i].params,
 
                       command[i].help);
 
 
  // Build info....
  // Build info....
  printf("\n");
  printf("\n");
  printf("CPU info\n");
  printf("CPU info\n");
  printf("Frequency\t\t%dMHz\n", IN_CLK/1000000);
  printf("Frequency\t\t%dMHz\n", IN_CLK/1000000);
Line 325... Line 326...
void tick_init(void);
void tick_init(void);
void module_touch_init (void);
void module_touch_init (void);
void module_ata_init (void);
void module_ata_init (void);
void module_hdbug_init (void);
void module_hdbug_init (void);
 
 
 
 
/* List of all initializations */
/* List of all initializations */
void mon_init (void)
void mon_init (void)
{
{
  /* Set defaults */
  /* Set defaults */
  global.erase_method = 2; /* as needed */
  global.erase_method = 2; /* as needed */
Line 392... Line 392...
 
 
#ifdef TICK_CMDS
#ifdef TICK_CMDS
#endif
#endif
 
 
}
}
 
 
int tboot_cmd (int argc, char *argv[]);
int tboot_cmd (int argc, char *argv[]);
/* Main shell loop */
/* Main shell loop */
int main(int argc, char **argv)
int main(int argc, char **argv)
{
{
  extern unsigned long calc_mycrc32 (void);
  extern unsigned long calc_mycrc32 (void);
Line 425... Line 426...
 
 
  disable_spincursor();
  disable_spincursor();
 
 
  tick_init();
  tick_init();
 
 
 
        if (HELP_ENABLED)
  if (HELP_ENABLED) register_command ("help", "", "shows this help", help_cmd);
                register_command("help", "", "shows this help", help_cmd);
 
 
  printf ("\n" BOARD_DEF_NAME " monitor (type 'help' for help)\n");
  printf ("\n" BOARD_DEF_NAME " monitor (type 'help' for help)\n");
  printf("\tbuild: %s", BUILD_VERSION);
  printf("\tbuild: %s", BUILD_VERSION);
 
 
  // Loop forever, accepting commands
  // Loop forever, accepting commands
  while(1)
        while (1) {
    {
 
      mon_command();
      mon_command();
    }
    }
 
 
}
}
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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