快乐虾
http://blog.csdn.net/lights_joy/
lights@hb165.com
本文适用于
ADI bf561 DSP
uclinux-2008r1.5-rc3(smp patch)
Visual DSP++ 5.0(update 5)
欢迎转载,但请保留作者信息
在内核初始化的时候,会调用l1_data_sram_init函数,这个函数将登记L1 data bank中的可用空间。
void __init l1_data_sram_init(void)
{
unsigned int cpu;
#if L1_DATA_A_LENGTH != 0
printk(KERN_INFO "Blackfin DATA_A SRAM: %d KB/n",
L1_DATA_A_LENGTH >> 10);
for (cpu = 0; cpu < NR_CPUS; ++cpu) {
memset(&per_cpu(l1sram, cpu).l1_data_A_sram, 0x00,
sizeof(per_cpu(l1sram, cpu).l1_data_A_sram));
per_cpu(l1sram, cpu).l1_data_A_sram[0].paddr = (void *)get_l1_data_a_start_cpu(cpu) +
0x2000/*(_ebss_l1 - _sdata_l1)*/;
per_cpu(l1sram, cpu).l1_data_A_sram[0].size = L1_DATA_A_LENGTH - 0x2000/*(_ebss_l1 - _sdata_l1)*/;
per_cpu(l1sram, cpu).l1_data_A_sram[0].flag = SRAM_SLT_FREE;
}
#endif
#if L1_DATA_B_LENGTH != 0
printk(KERN_INFO "Blackfin DATA_B SRAM: %d KB/n",
L1_DATA_B_LENGTH >> 10);
for (cpu = 0; cpu < NR_CPUS; ++cpu) {
memset(&per_cpu(l1sram, cpu).l1_data_B_sram, 0x00, sizeof(per_cpu(l1sram, cpu).l1_data_B_sram));
per_cpu(l1sram, cpu).l1_data_B_sram[0].paddr = (void *)get_l1_data_b_start_cpu(cpu)+0x2000/*(_ebss_b_l1 - _sdata_b_l1)*/;
per_cpu(l1sram, cpu).l1_data_B_sram[0].size = L1_DATA_B_LENGTH-0x2000/*(_ebss_b_l1 - _sdata_b_l1)*/;
per_cpu(l1sram, cpu).l1_data_B_sram[0].flag = SRAM_SLT_FREE;
}
#endif
/* mutex initialize */
spin_lock_init(&per_cpu(l1sram, cpu).l1_data_sram_lock);
}
但是到了最后一行
spin_lock_init(&per_cpu(l1sram, cpu).l1_data_sram_lock);
这个时候,很明显cpu这个变量的值为2。
看看per_cpu的定义:
#define per_cpu(var, cpu) (*({ /
extern int simple_identifier_##var(void); /
RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]); }))
它要引用一个全局变量:__per_cpu_offset[cpu]
那么这个变量是怎么定义的呢?
unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;
这里NR_CPUS的值为2!也就是说对__per_cpu_offset[2]的引用是非法的。
1 参考资料
uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(65):B核启动(2009-2-13)
uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(66):_ebss_l1(2009-02-13)
uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(67):li1240(2009-2-14)
uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(68):PLL配置(2009-02-16)