OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [bootloaders/] [orpmon/] [common/] [common.c] - Diff between revs 175 and 246

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

Rev 175 Rev 246
Line 1... Line 1...
#include "common.h"
#include "common.h"
#include "uart.h"
#include "uart.h"
#include "screen.h"
#include "screen.h"
#include "support.h"
#include "support.h"
#include "keyboard.h"
#include "keyboard.h"
#include "spr_defs.h"
#include "spr-defs.h"
 
#include "spincursor.h"
#include "int.h"
#include "int.h"
 
 
#include "build.h"
#include "build.h"
 
 
#define MAX_COMMANDS  100
#define MAX_COMMANDS  100
 
 
 
// Value from linker script
extern unsigned long src_addr;
extern unsigned long src_addr;
 
 
bd_t bd;
bd_t bd;
 
 
int num_commands = 0;
int num_commands = 0;
Line 90... Line 92...
    }
    }
  }
  }
  return 0;
  return 0;
}
}
 
 
 
void
 
print_or1k_cache_info()
 
{
 
  // Read out UPR, check what modules we have
 
  unsigned long upr = mfspr(SPR_UPR);
 
  printf("Instruction cache:\t");
 
  if (upr & SPR_UPR_ICP)
 
    {
 
      // We have instruction cache, read out ICCFGR
 
 
 
      unsigned long iccfgr = mfspr(SPR_ICCFGR);
 
      unsigned int cbs; // cache block size
 
      unsigned long ncs = 1 << ((iccfgr & SPR_ICCFGR_NCS) >> 3);
 
      if (iccfgr & SPR_ICCFGR_CBS)
 
        cbs = 32;
 
      else
 
        cbs = 16;
 
 
 
      printf("%dkB (BS: %d Sets: %d)\n",
 
             (cbs * ncs)/1024, cbs, ncs);
 
 
 
    }
 
  else
 
    printf(" not present\n");
 
 
 
  printf("Data cache:\t\t");
 
  if (upr & SPR_UPR_DCP)
 
    {
 
      // We have instruction cache, read out DCCFGR
 
 
 
      unsigned long iccfgr = mfspr(SPR_DCCFGR);
 
      unsigned int cbs; // cache block size
 
      unsigned long ncs = 1 << ((iccfgr & SPR_DCCFGR_NCS) >> 3);
 
      if (iccfgr & SPR_DCCFGR_CBS)
 
        cbs = 32;
 
      else
 
        cbs = 16;
 
 
 
      printf("%dkB (BS: %d Sets: %d)\n",
 
             (cbs * ncs)/1024, cbs, ncs);
 
 
 
    }
 
  else
 
    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;
Line 157... Line 206...
  char str[1000];
  char str[1000];
  char *pstr = str;
  char *pstr = str;
  char *command_str;
  char *command_str;
  char *argv[20];
  char *argv[20];
  int argc = 0;
  int argc = 0;
 
  int chcnt = 0;
 
 
  /* Show prompt */
  /* Show prompt */
#ifdef XESS
 
  printf ("\norp-xsv> ");
 
#else
 
  printf ("\n" BOARD_DEF_NAME"> ");
  printf ("\n" BOARD_DEF_NAME"> ");
#endif
 
 
 
  /* Get characters from UART */
  while(1)
 
    {
  c = getc();
  c = getc();
  while (c != '\r' && c != '\f' && c != '\n')
      if (c == '\r' || c == '\f' || c == '\n')
  {
  {
    if (c == '\b')
          // Mark end of string
 
          *pstr = '\0';
 
          putc('\n');
 
          break;
 
        }
 
      else if (c == '\b') // Backspace
 
        {
 
          if (chcnt > 0)
 
            {
 
              putc(c);
 
              putc(' '); // cover char with space
 
              putc(c);
      pstr--;
      pstr--;
 
              chcnt--;
 
            }
 
        }
    else
    else
      *pstr++ = c;
        {
    putc(c);
    putc(c);
    c = getc();
          *pstr++ = c;
 
          chcnt++;
 
        }
  }
  }
  *pstr = '\0';
 
  printf ("\n");
 
 
 
  /* Skip leading blanks */
  /* Skip leading blanks */
  pstr = str;
  pstr = str;
  while (*pstr == ' ' && *pstr != '\0') pstr++;
  while (*pstr == ' ' && *pstr != '\0') pstr++;
 
 
Line 207... Line 268...
      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", command[i].name, command[i].params);
            printf ("Missing/wrong parameters, usage: %s %s\n",
 
                    command[i].name, command[i].params);
            break;
            break;
        }
        }
 
 
        found++;
        found++;
        break;
        break;
Line 226... Line 288...
  }
  }
 
 
}
}
 
 
#if HELP_ENABLED
#if HELP_ENABLED
extern unsigned long src_addr; // Stack section ends here
extern unsigned long src_addr; // Stack section ends here, will print it out
/* 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("Info: CPU@ %dMHz", IN_CLK/1000000);
  printf("\n");
#if IC_ENABLE==1
  printf("CPU info\n");
  printf(" IC=%dB",IC_SIZE);
  printf("Frequency\t\t%dMHz\n", IN_CLK/1000000);
#endif
  print_or1k_cache_info();
#if DC_ENABLE==1
 
  printf(" DC=%dB",DC_SIZE);
 
#endif
 
  printf("\n");
  printf("\n");
  printf("Info: Stack section addr 0x%x\n",(unsigned long) &src_addr);
  printf("Info: Stack section addr 0x%x\n",(unsigned long) &src_addr);
  printf("Build tag: %s", BUILD_VERSION);
  printf("Build tag: %s", BUILD_VERSION);
 
 
  return 0;
  return 0;
Line 320... Line 379...
#endif
#endif
#ifdef HDBUG_CMDS
#ifdef HDBUG_CMDS
  module_hdbug_init ();
  module_hdbug_init ();
#endif
#endif
 
 
  tick_init();
#ifdef TICK_CMDS
 
#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);
 
 
#if 0
#if 0
  extern unsigned long mycrc32, mysize;
  extern unsigned long mycrc32, mysize;
#endif
#endif
 
 
  timestamp = 0; // clear timer counter
  timestamp = 0; // clear timer counter
 
 
  int_init ();
  int_init ();
 
 
  change_console_type (CONSOLE_TYPE);
  change_console_type (CONSOLE_TYPE);
 
 
  mtspr(SPR_SR, mfspr(SPR_SR) | SPR_SR_IEE);
  mtspr(SPR_SR, mfspr(SPR_SR) | SPR_SR_IEE);
 
 
#if SELF_CHECK
#if SELF_CHECK
  printf ("Self check... ");
  printf ("Self check... ");
  if ((t = calc_mycrc32 ()))
  if ((t = calc_mycrc32 ()))
      printf ("FAILED!!!\n");
      printf ("FAILED!!!\n");
  else
  else
      printf ("OK\n");
      printf ("OK\n");
#endif /* SELF_CHECK */
#endif /* SELF_CHECK */
 
 
  num_commands=0;
  num_commands=0;
  mon_init ();
  mon_init ();
 
 
 
  disable_spincursor();
 
 
 
  tick_init();
 
 
 
 
  if (HELP_ENABLED) register_command ("help", "", "shows this help", help_cmd);
  if (HELP_ENABLED) register_command ("help", "", "shows this help", help_cmd);
 
 
#ifdef XESS
 
  printf ("\nORP-XSV Monitor (type 'help' for help)\n");
 
#else
 
  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);
#endif
 
 
 
  while(1) mon_command();
  // Loop forever, accepting commands
  // Run tboot in sim for now:  tboot_cmd (0,0);
  while(1)
 
    {
 
      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.