Пример #1
0
static int bcm1161_wait_interrupt(struct bcm1161_i2c *i2c)
{
	int res = 0;
#if defined (CONFIG_ARCH_BCM116X)
	timer_tick_count_t clk;

	clk = timer_get_tick_count();
#endif
	res =
	    wait_for_completion_timeout(&i2c->cmd_complete,
					msecs_to_jiffies(5000));
#if defined (CONFIG_ARCH_BCM116X)
	clk = timer_get_tick_count() - clk;
	if (clk > i2c_max_irq_wait) {
		i2c_max_irq_wait = clk;
	}
#endif
	if (res == 0) {
		dev_err(&i2c->adapter.dev, "Timeout on wait\n");
		return -ETIMEDOUT;
	} else {
		res = i2c->interrupt;
	}

	i2c->interrupt = 0;

	return res;
}
Пример #2
0
static int bcm1161_check_cmdbusy(void *base)
{
	int i = 0;
#if defined (CONFIG_ARCH_BCM116X)
	timer_tick_count_t clk = timer_get_tick_count();
	timer_tick_count_t clk2;
#endif

	if (REG_I2C_ISR(base) & REG_I2C_ISR_CMD_BUSY) {
		while (REG_I2C_ISR(base) & REG_I2C_ISR_CMD_BUSY) {
			/* wait for I2C CMD not busy */
			if (i > 100000) {
				i2c_errors++;
				REG_I2C_ISR(base) = 0x80;
				return -ETIMEDOUT;
			}
			i++;
		}
	}
#if defined (CONFIG_ARCH_BCM116X)
	clk2 = timer_get_tick_count();
	clk = clk2 - clk;
	if (i > i2c_max_cmdbusy_cnt) {
		i2c_max_cmdbusy_cnt = i;
	}
	if (clk > i2c_max_cmdbusy_clk) {
		i2c_max_cmdbusy_clk = clk;
	}
#endif
	return 0;
}
Пример #3
0
static int bcm1161_wait_interrupt(void *base, struct bcm1161 *i2c)
{
	/* wait for I2C Controller Interrupt */
	unsigned int i = 0;
#if defined (CONFIG_ARCH_BCM116X)
	timer_tick_count_t clk;
	timer_tick_count_t clk2;
#endif
	int isr;

#if defined (CONFIG_ARCH_BCM116X)
	clk = timer_get_tick_count();
#endif
	while ((REG_I2C_ISR(base) & I2C_ISR_MASK_ALL) == 0) {
		i++;
		if (i == (unsigned int)(-1)) {
			I2C_DEBUG(DBG_ERROR, "wait timed out, %d\n", clk);
			return -ETIMEDOUT;
		}
	}

#if defined (CONFIG_ARCH_BCM116X)
	clk2 = timer_get_tick_count();
	clk = clk2 - clk;
	if (clk > i2c_max_irq_wait) {
		i2c_max_irq_wait = clk;
	}
#endif
	isr = REG_I2C_ISR(base);
	REG_I2C_ISR(base) = isr;

	return isr;
}
static ssize_t
timer_test_show(struct device *dev, struct device_attribute *attr,
		const char *buf, size_t n)
{
	uint32_t test_time, num, index, tick_time, mode, clk;
	struct gpt_cfg timer_tst;
	
	/* test_time: The ticks for which the timer needs to run
	 *       num: Number of times the timer has to run (On each 
	 *            instance it would interrupt after test_time.
	 *     index: Index of the GPT to test
	 *      mode: Non-zero value for oneshot, 0 for periodic
	 */
	if (sscanf(buf, "%d %d %d %d %d", &test_time, &num,
				&index, &mode, &clk) == 5) {
		if (gpt_request(index) == GPT_ERR_INVALID_INDEX) {
			pr_err("Error configuring CE timer exit\n");
			return -EINVAL;
		}

		/* Disable Pedestral mode */
		timer_tst.gctrl = SW_PEDEMODE;
		/* Set the clock to 32Khz */
		timer_tst.gclk = clk;
		/* Configure the timer mode oneshot/periodic */
		if (mode)
			timer_tst.gmode = GPT_MODE_ONESHOT;
		else
			timer_tst.gmode = GPT_MODE_PERIODIC;

		/* Global variable to keep track */
		g_gptdev[index].gpt_count = 0;
		g_gptdev[index].gpt_mode = timer_tst.gmode;
		g_gptdev[index].gpt_num_times = num;
		g_gptdev[index].gpt_index = index;

		/* Configure the timer for the above configration */
		gpt_config(index, &timer_tst, gpt_isr, &g_gptdev[index]);

		/* Get tick count before start for ref */
		tick_time = timer_get_tick_count();
		/* The timer starts here */
		gpt_start(index, test_time);

		/* Wait here until the timer completes the test */
		while (g_gptdev[index].gpt_count < g_gptdev[index].gpt_num_times)
			msleep(10);

		/* Print start and end time */
		pr_info("Tick time taken for gpt index %d start:%u end:%u\n",
				index, tick_time, timer_get_tick_count());

		/* Free timer here */
		gpt_free(index);
		return n;
	}

	return -EINVAL;
}
Пример #5
0
bool game_init(scene_t initial_scene)
{
	TICKS_PER_SECOND = g_sysconfig.desired_fps;
	SKIP_TICKS = (1000.0 / (double)TICKS_PER_SECOND);
	MAX_FRAMESKIP = 5;
	FIXED_DELTA = (1.0/TICKS_PER_SECOND);
	max_timer_delta = FIXED_DELTA*2.0;
//	game_paused = 0;
		
	timer_update(&timer);
	timer_update(&timer);
	
	fs_font_load("impact20.fnt", &fps_font);
	fps_font.ri.pos = vec2d_make(0.0, g_sysconfig.screen_h);
	fps_font.ri.anchor_point = vec2d_make(0.0, 1.0);
	
	scene_stack_pointer = 0;
	scene_stack[scene_stack_pointer] = initial_scene;
	current_scene = &scene_stack[scene_stack_pointer];
	scene_stack[scene_stack_pointer].init_func(&scene_stack[scene_stack_pointer]);
	scene_queue_state = S_NONE;


	next_game_tick = timer_get_tick_count();
	timer.delta = 0.0;
	return true;
}
Пример #6
0
/*
 * init_idle_profile - initialize profiling handle
 *
 * parameters:
 *   handle [in/out] - pointer to the profiling handle
 */
static void init_idle_profile(idle_handle_t * handle)
{
	unsigned long flags;
	spinlock_t *lockp = &get_cpu_var(idle_lock);
	spin_lock_irqsave(lockp, flags);

	handle->last_smtclk = timer_get_tick_count();
	handle->last_idle_count = idle_count;

	spin_unlock_irqrestore(lockp, flags);
	put_cpu_var(idle_lock);
}
Пример #7
0
static irqreturn_t dma_interrupt_handler(int irq, void *dev_id)
{
	DMA_Channel_t *channel;
	DMA_DeviceAttribute_t *devAttr;
	int irqStatus;

	channel = (DMA_Channel_t *) dev_id;

	/*                                                             */

	irqStatus = dmacHw_getInterruptStatus(channel->dmacHwHandle);
	dmacHw_clearInterrupt(channel->dmacHwHandle);

	if ((channel->devType < 0)
	    || (channel->devType > DMA_NUM_DEVICE_ENTRIES)) {
		printk(KERN_ERR "dma_interrupt_handler: Invalid devType: %d\n",
		       channel->devType);
		return IRQ_NONE;
	}
	devAttr = &DMA_gDeviceAttribute[channel->devType];

	/*              */

	if ((irqStatus & dmacHw_INTERRUPT_STATUS_TRANS) != 0) {
		devAttr->transferTicks +=
		    (timer_get_tick_count() - devAttr->transferStartTime);
	}

	if ((irqStatus & dmacHw_INTERRUPT_STATUS_ERROR) != 0) {
		printk(KERN_ERR
		       "dma_interrupt_handler: devType :%d DMA error (%s)\n",
		       channel->devType, devAttr->name);
	} else {
		devAttr->numTransfers++;
		devAttr->transferBytes += devAttr->numBytes;
	}

	/*                            */

	if (devAttr->devHandler != NULL) {
		devAttr->devHandler(channel->devType, irqStatus,
				    devAttr->userData);
	}

	return IRQ_HANDLED;
}
Пример #8
0
int dma_transfer(DMA_Handle_t handle,	/*            */
		 dmacHw_TRANSFER_TYPE_e transferType,	/*                                  */
		 dma_addr_t srcData,	/*                                      */
		 dma_addr_t dstData,	/*                                */
		 size_t numBytes	/*                                           */
    ) {
	DMA_Channel_t *channel;
	DMA_DeviceAttribute_t *devAttr;
	int rc = 0;

	channel = HandleToChannel(handle);
	if (channel == NULL) {
		return -ENODEV;
	}

	devAttr = &DMA_gDeviceAttribute[channel->devType];

	if (devAttr->config.transferType != transferType) {
		return -EINVAL;
	}

	/*                                                                      */
	/*                                                                               */
	/*                                                         */

	{
		rc =
		     dma_alloc_descriptors(handle, transferType, srcData,
					   dstData, numBytes);
		if (rc != 0) {
			return rc;
		}
	}

	/*                           */

	devAttr->numBytes = numBytes;
	devAttr->transferStartTime = timer_get_tick_count();

	dmacHw_initiateTransfer(channel->dmacHwHandle, &devAttr->config,
				devAttr->ring.virtAddr);

	/*                                                     */

	return 0;
}
Пример #9
0
int dma_transfer(DMA_Handle_t handle,	/* DMA Handle */
		 dmacHw_TRANSFER_TYPE_e transferType,	/* Type of transfer being performed */
		 dma_addr_t srcData,	/* Place to get data to write to device */
		 dma_addr_t dstData,	/* Pointer to device data address */
		 size_t numBytes	/* Number of bytes to transfer to the device */
    ) {
	DMA_Channel_t *channel;
	DMA_DeviceAttribute_t *devAttr;
	int rc = 0;

	channel = HandleToChannel(handle);
	if (channel == NULL) {
		return -ENODEV;
	}

	devAttr = &DMA_gDeviceAttribute[channel->devType];

	if (devAttr->config.transferType != transferType) {
		return -EINVAL;
	}

	/* We keep track of the information about the previous request for this */
	/* device, and if the attributes match, then we can use the descriptors we setup */
	/* the last time, and not have to reinitialize everything. */

	{
		rc =
		     dma_alloc_descriptors(handle, transferType, srcData,
					   dstData, numBytes);
		if (rc != 0) {
			return rc;
		}
	}

	/* And kick off the transfer */

	devAttr->numBytes = numBytes;
	devAttr->transferStartTime = timer_get_tick_count();

	dmacHw_initiateTransfer(channel->dmacHwHandle, &devAttr->config,
				devAttr->ring.virtAddr);

	/* Since we got this far, everything went successfully */

	return 0;
}
Пример #10
0
irqreturn_t vc_gpioirq(int irq, void *devId)
{
    mphi_driver_t* mphidrv;

    m_irq_slot.ctrl = 0;  //data
    m_irq_slot.len = timer_get_tick_count();

    mphidrv = (mphi_driver_t*) devId;
    assert(mphidrv);
    if(vchost_gpioirq_handle(irq, devId))
    {
        os_event_signal(&mphidrv->rxtxavail, 0);
    }
    else
    {
        //	  VC_DEBUG(Trace, "vc_gpioirq: ignoring gpio irq\n");
    }

    return IRQ_HANDLED;
}
Пример #11
0
void FP_startProfiling(FRAME_PROFILER_HANDLE profilerHandle)
{
	PROFILER *instance = (PROFILER *) profilerHandle;

	if (instance->profilerState.enable) {
		*instance->profilerData.pstart = timer_get_tick_count();
		instance->profilerData.pstart++;

		if (instance->profilerData.pstart ==
		    (instance->profilerData.start_temp + HISTORY_SIZE)) {
			instance->profilerData.pstart =
			    instance->profilerData.start_temp;
			gosSemTake(instance->semData);
			memcpy(&instance->profilerData.start[0],
			       &instance->profilerData.start_temp[0],
			       HISTORY_SIZE *
			       sizeof(&instance->profilerData.start_temp[0]));
			gosSemGive(instance->semData);
		}
	}
}
Пример #12
0
void FP_stopProfiling(FRAME_PROFILER_HANDLE profilerHandle)
{
	PROFILER *instance = (PROFILER *) profilerHandle;

	if (instance->profilerState.enable) {
		*instance->profilerData.pend = timer_get_tick_count();
		instance->profilerData.pend++;

		if (instance->profilerData.pend ==
		    (instance->profilerData.end_temp + HISTORY_SIZE)) {
			instance->profilerData.pend =
			    instance->profilerData.end_temp;
			gosSemTake(instance->semData);
			memcpy(&instance->profilerData.end[0],
			       &instance->profilerData.end_temp[0],
			       HISTORY_SIZE *
			       sizeof(&instance->profilerData.end_temp[0]));
			gosSemGive(instance->semData);
			wake_up_process(instance->profilerTask);
		}
	}
}
/**
 *	Return the MTT frame header required for MTT signal payload of specified size
 *
 *	@param	inPayloadSize (in)	    size of MTT payload to be sent
 *	@param	outFrameHdrBuf (out)    buffer where frame header should be stored
 *                                  (allocated by caller)
 *	@return	int				    size of header written to outFrameHdrBuf or -1 on error
 **/
int BCMMTT_MakeMTTSignalHeader( unsigned short inPayloadSize, unsigned char* outFrameHdrBuf )
{
	unsigned char* pHbuf;
	unsigned short i;
	unsigned long trace_time_stamp;

    
	trace_time_stamp = timer_get_tick_count() / 32;	

	pHbuf = outFrameHdrBuf;

	*pHbuf++ = MTTLOG_FrameSync0;
	*pHbuf++ = MTTLOG_FrameSync1;

	if (CpCrashDumpInProgress())
		*pHbuf++ = cp_crash_frame_counter++;
	else
	pHbuf++;
	*pHbuf++ = MTTLOG_MttVersion;
	*pHbuf++ = trace_time_stamp>>24;
	*pHbuf++ = (trace_time_stamp>>16)&0xFF;
	*pHbuf++ = (trace_time_stamp>>8)&0xFF;
	*pHbuf++ = trace_time_stamp & 0xFF;
	i = MTTLOG_MsgTypeSDL;
	*pHbuf++ = i>>8;
	*pHbuf++ = i & 0xFF;
	*pHbuf++ = inPayloadSize>>8;
	*pHbuf++ = inPayloadSize & 0xFF;
	// done at logging driver to assure sequential increase of 
	if (CpCrashDumpInProgress())
	{
		*pHbuf++ = MTTLOG_Checksum16( outFrameHdrBuf, 12 );
	}
	else
	pHbuf++;

	return (int)(pHbuf - outFrameHdrBuf);
}
Пример #14
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();
}
Пример #15
0
/* ----------------------------------------------------------------------
 * queue a message for transmission.  the two output channels share a
 * single fifo.
 *
 * if the output fifo is full, this routine returns immediately with
 * MPHI_ERROR_FIFO_FULL.
 *
 * when the message has been fully read from memory,
 * MPHI_EVENT_OUT_DMA_COMPLETED is generated.  note that this does
 * not mean that the host has read the message; the message is placed
 * in a message fifo and held until the host responds to its interrupt
 * and issues the appropriate number of read cycles.
 * -------------------------------------------------------------------- */
static int32_t mphi_out_queue_message(const DRIVER_HANDLE_T handle, uint8_t control,
                                      const void *addr, size_t len, uint8_t slot_id, const MPHI_FLAGS_T flags )
{
    int ret;
    MPHI_HANDLE_T *mphi;
    mphi_slot_t slot;

    mphi = (MPHI_HANDLE_T *) handle;
    slot.addr = (uint32_t)addr;
    slot.len = len;
    slot.id = slot_id;
    slot.ctrl = control;
    slot.pos = 0;
    slot.flags = flags;

    if(1)
    {
        //mphi_dumpmsg(mphi->drv, "TQ", &slot);
        m_out_slot.ctrl = 0;  //data
        m_out_slot.len = timer_get_tick_count();
    }

    ret = add_slotin((MPHI_HANDLE_T*)handle, &slot);
    //zrl
    if (ret==0)
    {
        //VC_DEBUG(Trace, "mphi_out_queue_message slot\n");
        os_event_signal(&(mphi->drv->rxtxavail), 1); //0
    }

    if(0 != ret)
    {
        return MPHI_ERROR_FIFO_FULL;
    }

    return 0;
}
Пример #16
0
timer_msec_t timer_get_msec(void)
{
	return timer_ticks_to_msec(timer_get_tick_count());
}
Пример #17
0
/****************************************************************************
*
*  iodump_gettime
*
*  Get timestamp for info being logged.
*
***************************************************************************/
static int iodump_gettime(void)
{
    return ( timer_get_tick_count() );
}
Пример #18
0
/****************************************************************************
*
*  pcf506xx_process_interrupt
*
***************************************************************************/
static int pcf506xx_process_interrupt(BCM_PMU_Chip_t chip)
{
   int rc;
   u8 intBits[PCF506XX_MAX_NUM_INT_REGS];
   u8 maskBits[PCF506XX_MAX_NUM_INT_REGS];
   u32 intStatus;
   u32 intMask;
   int i;
   u32 clk = timer_get_tick_count();

   memset(intBits, 0, sizeof(intBits));
   memset(maskBits, 0, sizeof(maskBits));

   /* read the interrupt status registers */
   rc = pmu_i2c_read_bytes(PCF506XX_REG_INT1(chip), intBits, PCF506XX_NUM_INT_REGS(chip));
   if ( rc < 0)
   {
      printk("pcf506xx_isr - error %d reading interrupt registers.\n", rc);
      return -EINVAL;
   }

   /* read the interrupt mask bit registers */
   rc = pmu_i2c_read_bytes(PCF506XX_REG_INT1M(chip), maskBits, PCF506XX_NUM_INT_REGS(chip));
   if ( rc < 0)
   {
      printk("pcf506xx_isr - error %d reading interrupt registers.\n", rc);
      return -EINVAL;
   }

   /* make one big interrupt status register */
   intStatus = intBits[0] | (intBits[1] << 8) | (intBits[2] << 16) | (intBits[3] << 24);

   /* make one big interrupt mask register */
   intMask = maskBits[0] | (maskBits[1] << 8) | (maskBits[2] << 16) | (maskBits[3] << 24);

   /* apply mask, note that 0 means enabled in the mask */
   intStatus &= ~intMask;

   /* run ISR's for each interrupt that is not masked out */
   for ( i = 0; i < PCF506XX_NUM_IRQS(chip); i++ )
   {
      if ( intStatus & pmu_intPriorityBit[i] )
      {
         if ( pmuIRQVectorTable[pmu_intPriority[i]] != NULL )
         {
            (*pmuIRQVectorTable[pmu_intPriority[i]])(pmu_intPriority[i]);
         }
      }
   }

#if 0
   ONE_LOG(ONE_LOG_TRACE,("PMU - intStatus 1 = 0x%x\n",intBits[0]));
   ONE_LOG(ONE_LOG_TRACE,("PMU - intStatus 2 = 0x%x\n",intBits[1]));
   ONE_LOG(ONE_LOG_TRACE,("PMU - intStatus 3 = 0x%x\n",intBits[2]));
   ONE_LOG(ONE_LOG_TRACE,("PMU - intStatus 4 = 0x%x\n",intBits[3]));
#endif

   clk = timer_get_tick_count() - clk;
   if (clk > pmu_max_isr_clk)
   {
      pmu_max_isr_clk = clk;
   }

   return 0;

} /*pcf506xx_process_interrupt */
Пример #19
0
void game_did_become_active(void)
{
	next_game_tick = timer_get_tick_count();
	timer_update(&timer);
	timer_update(&timer);
}
Пример #20
0
void game_tick(void)
{
	if (scene_queue_state != S_NONE)
	{
		switch (scene_queue_state)
		{
			case S_SET:
				current_scene->free_func(current_scene);
				scene_stack[scene_stack_pointer] = next_scene;
				current_scene = &scene_stack[scene_stack_pointer];
				current_scene->init_func(current_scene);
				break;
			case S_PUSHED:
				current_scene = &scene_stack[scene_stack_pointer];
				break;
			case S_POPPED:
				for (int i = 0; i < pop_counter; i++)
				{
					scene_stack_pointer--;
					if (scene_stack_pointer < 0)
					{
						printf("You f****d up the stack!\n");
						abort();
						return;
					}
					current_scene->free_func(current_scene);
					current_scene = &scene_stack[scene_stack_pointer];
				}
				pop_counter = 0;
				break;
			default:
				abort();
				break;
		}
		scene_queue_state = S_NONE;
	
		printf("current scene is: %p ...\n", current_scene);
		next_game_tick = timer_get_tick_count();
		timer_update(&timer);
		timer_update(&timer);
	}
	
	timer_update(&timer);
	timer_get_fps(&timer);
	sprintf(fps_str, "fps: %.2f", timer.fps);

	//delta based loop (don't use)
	

	/* do while instead of just while will remove the jerkiness if we get 0 loops.
	 on the other hand it won't allow for eg. 30fps gameplay on a 60fps device :( 
	 
	 while(t > ...) instead of (while timer_get_tick_count() > ...) seems to work ... time will tell
	 */
	
	if (timer.delta > max_timer_delta)
	{
		unsigned int t = timer_get_tick_count();
		loops = 0;
		while (t > next_game_tick)// && loops < MAX_FRAMESKIP)
		{
			fs_input_update();
			current_scene->pre_frame_func(current_scene);
			current_scene->update_func(current_scene, FIXED_DELTA);
			next_game_tick += SKIP_TICKS;
			loops++;
		}
		if (loops > 0)
		{	
			//printf("%i\n", loops);
			
		}
	}
	else
	{
		next_game_tick = timer_get_tick_count();
		fs_input_update();
		current_scene->pre_frame_func(current_scene);
		current_scene->update_func(current_scene, timer.delta);
	}
	
}
/**
 *	Frame a string for output to MTT.  Characters not in [0x20, 0x7e]
 *	are converted to blanks (0x20).
 *
 *	@param	p_dest	(out)	pointer to destination buffer
 *	@param	p_src	(in)	pointer to source buffer
 *	@param	buflen	(in)	size of the destination buffer
 *	@return	int				frame length, or -1 on error
 **/
int BCMMTT_FrameString( char* p_dest, char* p_src, int buflen )
{
	int slen = MTTLOG_StringLen(p_src);
	int n;
	char* pSbuf;
	unsigned long systime ;

	
	if (slen == 0) 
	{
		return 0 ;
	}

	if (slen > buflen - MTTLOG_NumFrameBytes) 
	{
		return 0 ;
	}

	systime = timer_get_tick_count() / 32 ;	
	
	pSbuf = p_dest;

	*pSbuf++ = MTTLOG_FrameSync0;
	*pSbuf++ = MTTLOG_FrameSync1;
	if (CpCrashDumpInProgress())
		*pSbuf++ = cp_crash_frame_counter++;
	else
	pSbuf++;
	*pSbuf++ = MTTLOG_MttVersion;

	*pSbuf++ = ( systime >> 24 )        ;
	*pSbuf++ = ( systime >> 16 ) & 0xff ;
	*pSbuf++ = ( systime >>  8 ) & 0xff ;
	*pSbuf++ = ( systime       ) & 0xff ;
	
	*pSbuf++ = MTTLOG_MsgTypeASCII >> 8 ;
	*pSbuf++ = MTTLOG_MsgTypeASCII & 0xFF ;
	
	*pSbuf++ = slen >> 8 ;
	*pSbuf++ = slen & 0xFF ;
	
	if (CpCrashDumpInProgress())
	{
		n = pSbuf - p_dest ;
		*pSbuf++ = MTTLOG_Checksum16((unsigned char*)p_dest, n );
	}
	else
		pSbuf++;

	while (*p_src)
	{
		if (*p_src < 0x20 || *p_src > 0x7E)	//	[0x20 .. 0x7E] is range of 'printable' characters
		{
			*pSbuf++ = ' ';
			p_src++;
		}
		else
		{
			*pSbuf++ = *p_src++;
		}
	}

	n = MTTLOG_Checksum16((unsigned char*)(pSbuf-slen), slen);
	
	*pSbuf++ = n >> 8 ;
	*pSbuf++ = n & 0xFF ;

	return MTTLOG_NumFrameBytes + slen ;
}
Пример #22
0
/* helper routine to obtain hardware time stamp */
static int getTime( void )
{
   return ( timer_get_tick_count() );
}
Пример #23
0
int mphi_dumpmsg(mphi_driver_t* drv, const char* prefix, mphi_slot_t* slotptr)
{
    const uint32_t ctrlid = MAKE_FOURCC("LRTC");
    uint8_t* addr =  (uint8_t*)slotptr->addr;
    uint32_t cmd, paylen, i;
    static int cnt = 0;
    char str[0x100];
    int len;

    if(slotptr->ctrl && gVcDebug_SID != 0)
        // if(gVcDebug_SID != 0)
    {
        if(*(uint32_t*) (addr + 4) != gVcDebug_SID)
        {
            return 0;
        }
    }

    ++cnt;
    len = 0;
    len += sprintf(str + len, "[%04d %08u] %s %c tlen=%u ",
                   cnt,  timer_get_tick_count(),
                   prefix, slotptr->ctrl ? 'c' : 'd', slotptr->len);
    if(slotptr->ctrl)
    {
        paylen = *(uint16_t*)(addr + 0xE);
        len += sprintf(str + len, "sid=%c%c%c%c slotcnt=0x%04X paylen=0x%04X ",
                       addr[4], addr[5], addr[6], addr[7],
                       *(uint16_t*)(addr + 0xC),
                       paylen);
        if(*(uint32_t*)(addr + 4) == ctrlid && paylen > 0)
        {
            addr += 0x10;
            cmd = *(uint32_t*)(addr);
            switch(cmd)
            {
            case BULK_TRANSFER_RX:
            {
                len += sprintf(str + len, "cmd=%s(%d) sid=%c%c%c%c(%02X%02X%02X%02X) sz=0x%08X",
                               mphi_ctrlcmd2str(cmd), cmd,
                               addr[4], addr[5], addr[6], addr[7],
                               addr[4], addr[5], addr[6], addr[7],
                               *(uint32_t*)(addr + 0x8));
                break;
            }
            case XON:
            case XOFF:
            {
                len += sprintf(str + len, "cmd=%s(%d) sid=%c%c%c%c",
                               mphi_ctrlcmd2str(cmd), cmd,
                               addr[4], addr[5], addr[6], addr[7]
                              );
                break;
            }
            default:
            {
                len += sprintf(str + len, "cmd=%s(%d) 0x%08X 0x%08X 0x%08X",
                               mphi_ctrlcmd2str(cmd), cmd,
                               *(uint32_t*)(addr + 0x4),
                               *(uint32_t*)(addr + 0x8),
                               *(uint32_t*)(addr + 0xC));
                break;
            }
            }
        }
        else
        {
            addr += 0x10;
            for(i = 0; i < paylen && i < 0x18; i +=2)
            {
                len += sprintf(str + len, "%04X ", *(uint16_t*) addr);
                addr += 2;
            }
        }
    }

    len += sprintf(str + len, "\n");

    if ( gVcDebugMphiDumpMsg )
    {
        printk( KERN_INFO "%s", str );
    }

    MPHI_LOGSTR(drv, str, len);

    return 0;
}