我是靠谱客的博主 精明大山,最近开发中收集的这篇文章主要介绍head.s分析(2):SYSCFG配置1       参考资料,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

 

快乐虾

http://blog.csdn.net/lights_joy/

lights@hb165.com

  

本文适用于

ADI bf561 DSP

uclinux-2008r1.5-rc3 (移植到vdsp5)

Visual DSP++ 5.0(update 5)

 

欢迎转载,但请保留作者信息

 

     /* Enable Cycle Counter and Nesting Of Interrupts */

#ifdef CONFIG_BFIN_SCRATCH_REG_CYCLES

     R0 = SYSCFG_SNEN;

#else

     R0 = SYSCFG_SNEN | SYSCFG_CCEN;

#endif

     SYSCFG = R0;

这几行代码用于设置SYSCFG的值,关于SYSCFG这个寄存器,vdsp文件这样说:

The System Configuration Register (SYSCFG) shown in Figure 4-3 controls the configuration of the processor

对于BF561而言,只有CCENSSSTEP两位有效,在这里将CCEN位设置为1,表示要启用64位的cycle counter。而对SNEN的置位将被忽略。

System Configuration  Register

在启用了CCEN之后,CYCLESCYCLES2两个寄存器将开始统计CCLK的个数。

下面是vdsp文档中对CYCLESCYCLES2这两个寄存器的一个说明:

The cycle counter counts CCLK cycles while the program is executing. All cycles, including execution, wait state, interrupts, and events, are counted while the processor is in User or Supervisor mode, but the cycle counter stops counting in Emulator mode.

The cycle counter is 64 bits wide and increments every cycle. The count value is stored in two 32-bit registers, CYCLES and CYCLES2. The least significant 32 bits (LSBs) are stored in CYCLES. The most significant 32 bits (MSBs) are stored in CYCLES2.

Note: To ensure read coherency, first read CYCLES, then CYCLES2, and then CYCLES again, to detect if an overflow has occurred in the LSBs during the read operations.

In User mode, these two registers may be read, but not written. In Supervisor and Emulator modes, they are read/write registers.

To enable the cycle counters, set the CCEN bit in the SYSCFG register. The following example shows how to use the cycle counter:

R2 = 0;

CYCLES = R2;

CYCLES2 = R2;

R2 = SYSCFG;

BITSET(R2,1);

SYSCFG = R2;

/* Insert code to be benchmarked here. */

R2 = SYSCFG;

BITCLR(R2,1);

SYSCFG = R2;

通常这两个寄存器可以用于性能统计。但是由于这两个寄存器在几种模式下均是可写的,因此也可以将它们当成通用寄存器使用。在uclinux内核中,提供了一个叫CONFIG_BFIN_SCRATCH_REG_CYCLES的选项来控制CYCLES的用途:

config BFIN_SCRATCH_REG_CYCLES

     bool "CYCLES"

     help

       Use the CYCLES register in the Blackfin exception handler

       as a stack scratch register.  This means you cannot

       safely use the CYCLES performance registers on a Blackfin

       board at anytime, but you can debug the system with a JTAG

       ICE and use the NMI.

当设置了CONFIG_BFIN_SCRATCH_REG_CYCLES后,在linux-2.6.x/arch/blackfin/mach-common/entry.S文件中将CYCLES做为普通寄存器使用:

#if defined(CONFIG_BFIN_SCRATCH_REG_RETN)

# define EX_SCRATCH_REG RETN

#elif defined(CONFIG_BFIN_SCRATCH_REG_RETE)

# define EX_SCRATCH_REG RETE

#else

# define EX_SCRATCH_REG CYCLES

#endif

自然,在此时CYCLES是不应该自动计数的,因此SYSCFG_CCEN应该保持为0

uclinux内核代码中搜索CYCLES,可以发现有以下几个文件使用了它:

linux-2.6.x/drivers/char/bfin_timer_latency.c

linux-2.6.x/drivers/media/video/blackfin/blackfin_cam.c

linux-2.6.x/drivers/zaptel/bfsi-spi-framework.c

linux-2.6.x/drivers/zaptel/bfsi.c

当要使用这几个驱动时,就一定需要使SYSCFG_CCEN=1

 

1       参考资料

head.s分析(1):保存u-boot传递过来的指针(2009-1-19)

最后

以上就是精明大山为你收集整理的head.s分析(2):SYSCFG配置1       参考资料的全部内容,希望文章能够帮你解决head.s分析(2):SYSCFG配置1       参考资料所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部