Exemplo n.º 1
0
timer_msec_t timer_ticks_to_msec(timer_tick_count_t ticks)
{
	static int tickRateMsec;

	if (tickRateMsec == 0) {
		tickRateMsec = timer_get_tick_rate() / 1000;
	}

	return ticks / tickRateMsec;
}
Exemplo n.º 2
0
/*
 * get_idle_profile - get the idle profiling results for the provided handle
 *
 * parameters:
 *   handle [in] - pointer to the profiling handle, must be previously initialized
 *   idle [out]  - returns the number of idle cycles since last init or get call
 *   total [out] - returns the number of total cycles since last init or get call
 *
 * return:
 *   The number of cycles per second
 *
 * note:
 *   To prevent overflowing the cycle counters, the get call must be made no
 *   later than (2^32 / ticks_per_second) seconds from the last init or get call.
 *   For 1024 ticks per second, the time is 4,194,304 seconds = 48.54 days;
 *   For 812500 ticks per second, the time is 5286 seconds = 1 hour 28 minutes.
 */
static int get_idle_profile(idle_handle_t * handle, u32 *idle, u32 *total)
{
	unsigned long flags;
	spinlock_t *lockp = &get_cpu_var(idle_lock);
	u32 now;
	u32 cur_idle_count;

	spin_lock_irqsave(lockp, flags);

	now = timer_get_tick_count();
	cur_idle_count = get_cpu_var(idle_count);
	put_cpu_var(idle_count);

	*idle = cur_idle_count - handle->last_idle_count;
	*total = now - handle->last_smtclk;

	handle->last_idle_count = cur_idle_count;
	handle->last_smtclk = now;

	spin_unlock_irqrestore(lockp, flags);
	put_cpu_var(idle_lock);
	return timer_get_tick_rate();
}
Exemplo n.º 3
0
unsigned int microSec(timer_tick_count_t ticks)
{
	return (ticks / (timer_get_tick_rate() / 1000000));
}
Exemplo n.º 4
0
/* Get a banner to print to the various output mechanisms */
static void getBanner(char **linepp, int maxlen, int events)
{
   char tmp[160];
   char *tmpp = tmp;

   snprintf(*linepp, maxlen, "Kernel Log Dump Start (logging disabled while dumping)...\n");
   snprintf(tmpp, sizeof(tmp), "%u ticks/sec, %u (0x%08x) max_timestamp, %d entries\n", timer_get_tick_rate(), ~0, ~0, events);
   strncat(*linepp, tmpp, maxlen);
#if defined ( XCONFIG_BCM_PERFCNT_SUPPORT )
   if (knllog.use_perfcnt)
   {
      snprintf(tmpp, sizeof(tmp),
               "ticks%s/cycles/%s/%s/bus_idle\n",
               knllog.deltatime ? "/deltas" : "",
               perfcnt_get_evtstr0(),
               perfcnt_get_evtstr1() );
      strncat(*linepp, tmpp, maxlen);
   }
   else
#endif
   if (knllog.deltatime)
   {
      snprintf(tmpp, sizeof(tmp), "ticks/deltas\n");
      strncat(*linepp, tmpp, maxlen);
   #if !defined ( CONFIG_ARCH_BCMHANA )
      snprintf(tmpp, sizeof(tmp), "/bus_idle");
      strncat(*linepp, tmpp, maxlen);
   #endif
      snprintf(tmpp, sizeof(tmp), "\n");
      strncat(*linepp, tmpp, maxlen);
   }

   (*linepp)[maxlen-1] = '\0';
}
Exemplo n.º 5
0
/* decode an event into a symbolic string */
static void decodeEvent(KNLLOG_ENTRY *ep, char **linepp, int linelen, int eventnum)
{
   char *line = *linepp;
   char field[160];

   *line = '\0';
   if (eventnum == 0)
   {
      knllog.lasttime = ep->time;
      knllog.starttime = ep->time;
   }
#if defined ( CONFIG_SMP )
   snprintf(field, sizeof(field), "CPU_%u: ", ep->cpuid);
   strlcat(line, field, linelen );
#endif

   if ( knllog.msec )
   {
       int ticks = ep->time - knllog.starttime;
       int usecs = ticks / ( timer_get_tick_rate() / 1000000 );
       snprintf(field, sizeof(field), "%6d.%03d: ", usecs / 1000u, usecs % 1000u);
   }
   else
   {
       snprintf(field, sizeof(field), "%10u: ", ep->time);
   }
   strlcat(line, field, linelen );

   if ( knllog.deltatime)
   {
      if ( knllog.msec )
      {
          int deltaticks = ep->time - knllog.lasttime;
          int deltausecs = deltaticks / ( timer_get_tick_rate() / 1000000 );
          snprintf(field, sizeof(field), "%6d.%03d: ", deltausecs / 1000u, deltausecs % 1000u);
      }
      else
      {
          snprintf(field, sizeof(field), "%10u: ", ep->time - knllog.lasttime);
      }
      strlcat(line, field, linelen );
   }

#if defined ( CONFIG_BCM_PERFCNT_SUPPORT )
   if (knllog.use_perfcnt)
   {
         #if defined ( CONFIG_ARCH_BCMRING )

         snprintf(field, sizeof(field), "%10u: ", ep->cntrs.ccr);
         strlcat(line, field, linelen );
         snprintf(field, sizeof(field), "%10u: ", ep->cntrs.cr0);
         strlcat(line, field, linelen );
         snprintf(field, sizeof(field), "%10u: ", ep->cntrs.cr1);
         strlcat(line, field, linelen );
         snprintf(field, sizeof(field), "%10u: ", ep->cntrs.bus_idle);
         strlcat(line, field, linelen );

         #elif defined ( CONFIG_ARCH_BCMHANA )

         snprintf(field, sizeof(field), "%10u: ", ep->cntrs.ccr);
         strlcat(line, field, linelen );
         snprintf(field, sizeof(field), "%10u: ", ep->cntrs.cr[0]);
         strlcat(line, field, linelen );
         snprintf(field, sizeof(field), "%10u: ", ep->cntrs.cr[1]);
         strlcat(line, field, linelen );

         #endif
   }
#endif
   snprintf(field, sizeof(field), "%s: ", ep->function);
   strlcat(line, field, linelen );

   if ( ep->fmt == knllogDumpMemFmt )
   {
       int      i;
       int      numBytes;
       uint8_t *data;

       snprintf( field, sizeof( field ), "%08x: ", ep->data[0]);
       strlcat(line, field, linelen );

       numBytes = ep->data[1];
       data = (uint8_t *)&ep->data[2];

       for ( i = 0; i < MAX_BYTES_PER_LINE; i++ )
       {
           if ( i < numBytes )
           {
               snprintf( field, sizeof( field ), "%02x ", data[ i ]);
               strlcat(line, field, linelen );
           }
           else
           {
               strlcat(line, "   ", linelen );
           }
       }
       for ( i = 0; i < numBytes; i++ )
       {
           if (( data[i] >= ' ' ) && ( data[i] <= '~' ))
           {
               field[i] = data[i];
           }
           else
           {
               field[i] = '.';
           }
       }
       field[ numBytes ] = '\0';
       strlcat(line, field, linelen );
   }
   else
   {
       /* Make sure the data parameter list length matches 'MAXARGS' defined at the top of this file */
       scnprintf( field, sizeof(field), ep->fmt, ep->data[0], ep->data[1], ep->data[2], ep->data[3], ep->data[4], ep->data[5] );
       strlcat(line, field, linelen );
   }
   /* #3823 - Remove all trailing newlines that exist */
   {
      int i;
      int checkcnt = strlen(line); /* timestamp/func/etc guarantee nonzero linelen here */
      char replaceChar = '\0';
      for (i = 0; i < checkcnt; i++)
      {
         if ((line[checkcnt - 1 - i] != '\n'))
         {
            /* Replace non-eol newlines with spaces */
            replaceChar = ' ';
         }
         else
         {
            line[checkcnt - 1 - i] = replaceChar;
         }
      }
   }
   /* Add a newline if necessary */
   if (line[strlen(line)-1] != '\n')
   {
      strlcat(line, "\n", linelen );
   }
   /* At this point there will be a single trailing newline */
   line[linelen - 1] = '\0';   /* in case of overflow */
}