head.s分析(2):SYSCFG配置

系统 1540 0

快乐虾

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 而言,只有 CCEN SSSTEP 两位有效,在这里将 CCEN 位设置为 1 ,表示要启用 64 位的 cycle counter 。而对 SNEN 的置位将被忽略。

System Configuration  Register

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

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

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配置


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论