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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [testsuite/] [test-code-or1k/] [tick/] [tick.c] - Diff between revs 458 and 538

Show entire file | Details | Blame | View Log

Rev 458 Rev 538
Line 26... Line 26...
   --------------------------------------------------------------------------*/
   --------------------------------------------------------------------------*/
 
 
#include "spr-defs.h"
#include "spr-defs.h"
#include "support.h"
#include "support.h"
 
 
 
/*! Whether to perform spurious interrupt test */
 
#define DO_SPURIOUS_INT_TEST 0
 
 
/*! Number of spurious interrupts we'll allow before properly disabling them */
/*! Number of spurious interrupts we'll allow before properly disabling them */
#define MAX_SPURIOUS  5
#define MAX_SPURIOUS  5
 
 
/*! Convenience macro to check that a test has passed */
/*! Convenience macro to check that a test has passed */
Line 46... Line 48...
#define SET_TTCR(x) (mtspr (SPR_TTCR, x))
#define SET_TTCR(x) (mtspr (SPR_TTCR, x))
 
 
/*! Global count of number of times interrupt handler has been called  */
/*! Global count of number of times interrupt handler has been called  */
static volatile int tick_cnt = 0;
static volatile int tick_cnt = 0;
 
 
 
#if DO_SPURIOUS_INT_TEST==1
/*! Global flag to indicate if the TTMR_IP flag should be cleared */
/*! Global flag to indicate if the TTMR_IP flag should be cleared */
static int clear_ip = 1;
static int clear_ip = 1;
 
#endif
 
 
 
 
/* --------------------------------------------------------------------------*/
/* --------------------------------------------------------------------------*/
/*!Report failure
/*!Report failure
 
 
Line 103... Line 107...
/* --------------------------------------------------------------------------*/
/* --------------------------------------------------------------------------*/
static unsigned long int
static unsigned long int
set_period (unsigned long int  ttmr,
set_period (unsigned long int  ttmr,
            unsigned long int  period)
            unsigned long int  period)
{
{
  ttmr &= ~SPR_TTMR_PERIOD;
  ttmr &= ~SPR_TTMR_TP;
  ttmr |= period & SPR_TTMR_PERIOD;
  ttmr |= period & SPR_TTMR_TP;
 
 
  return  ttmr;
  return  ttmr;
 
 
}       /* set_period () */
}       /* set_period () */
 
 
Line 218... Line 222...
  mtspr (SPR_TTMR, ttmr);
  mtspr (SPR_TTMR, ttmr);
 
 
}       /* tick_count () */
}       /* tick_count () */
 
 
 
 
 
#if DO_SPURIOUS_INT_TEST==1
/* --------------------------------------------------------------------------*/
/* --------------------------------------------------------------------------*/
/*!Tick interrupt handler generting spurious interrupts
/*!Tick interrupt handler generting spurious interrupts
 
 
  If we have a one-shot timer set, then when we clear the interrupt (if a
  If we have a one-shot timer set, then when we clear the interrupt (if a
  global flag allows), but leave the interrupt enabled we should get a
  global flag allows), but leave the interrupt enabled we should get a
Line 255... Line 260...
      mtspr (SPR_TTMR, ttmr);
      mtspr (SPR_TTMR, ttmr);
 
 
 
 
    }
    }
}       /* tick_int_spurious () */
}       /* tick_int_spurious () */
 
#endif
 
 
/* --------------------------------------------------------------------------*/
/* --------------------------------------------------------------------------*/
/*!Waste a little time
/*!Waste a little time
 
 
  We are waiting for TTCR to increment
  We are waiting for TTCR to increment
Line 502... Line 507...
  /* The counter should start counting from 0x20000 and wrap around to 0x100
  /* The counter should start counting from 0x20000 and wrap around to 0x100
   * causeing an interrupt. Check we keep on counting. */
   * causeing an interrupt. Check we keep on counting. */
  waste_time();
  waste_time();
  ASSERT (GET_TTCR () > 0x20000, "Timer started counting from high value");
  ASSERT (GET_TTCR () > 0x20000, "Timer started counting from high value");
 
 
  /* If TTCR is greater than TTMR_PERIOD then the interrupt gets delivered after
  /* If TTCR is greater than TTMR_TP then the interrupt gets delivered after
     TTCR wraps around to 0 and counts to SPR_TTMR_PERIOD.
     TTCR wraps around to 0 and counts to SPR_TTMR_TP.
 
 
     Set up an auto-restart timer to wrap around. Reset the tick count,
     Set up an auto-restart timer to wrap around. Reset the tick count,
     because it may have incremented since the last match. */
     because it may have incremented since the last match. */
  ttmr = clear_ttmr ();
  ttmr = clear_ttmr ();
  ttcr = 0xffffc00;
  ttcr = 0xffffc00;
Line 531... Line 536...
  tick_cnt = 0;
  tick_cnt = 0;
  ttmr = new_timer (0x10000, SPR_TTMR_CR, SPR_TTMR_IE);
  ttmr = new_timer (0x10000, SPR_TTMR_CR, SPR_TTMR_IE);
 
 
  /* Wait for trigger, then check that we have carried on counting. */
  /* Wait for trigger, then check that we have carried on counting. */
  wait_match();
  wait_match();
  ttcr = GET_TTCR () & SPR_TTCR_PERIOD;
  ttcr = GET_TTCR () & SPR_TTCR_CNT;
 
 
  ASSERT ((0x10000 < ttcr) && (ttcr < 0xffffc00),
  ASSERT ((0x00010000 < ttcr) && (ttcr < 0xfffffc00),
          "Continuous mode wrapped round");
          "Continuous mode wrapped round");
 
 
 
#if DO_SPURIOUS_INT_TEST==1
 
 
  /* Disable the timer and set up the special spurious interrupt handler, to
  /* Disable the timer and set up the special spurious interrupt handler, to
     check spurious interrupts occur as expected. */
     check spurious interrupts occur as expected. */
  ttmr = clear_ttmr ();
  ttmr = clear_ttmr ();
  excpt_tick = (unsigned long)tick_int_spurious;
  excpt_tick = (unsigned long)tick_int_spurious;
 
 
Line 582... Line 589...
 
 
  while(tick_cnt != MAX_SPURIOUS)
  while(tick_cnt != MAX_SPURIOUS)
    {
    {
    }
    }
 
 
 
#endif
 
 
  /* If we get here everything worked. */
  /* If we get here everything worked. */
  report(0xdeaddead);
  report(0xdeaddead);
  return 0;
  return 0;
 
 
}       /* main () */
}       /* main () */

powered by: WebSVN 2.1.0

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