一直都没有搞懂LDF文件是怎么回事,后续翻到这个文档<cces-LinkerUtilities-manual.pdf>才认真的看了一下
先搞懂ADSP21489的片上RAM空间大小是5Mbit
5Mbit = 160k字的32位数据
= 320k 字的16位数据
= 106.7k字的48位指令(或40位数据)或不同大 小字的组合
只要不超过5 Mb。所有存储器都可以通过16 位、32位、48位或64位字访问。支持16位浮点存储格式, 片内可存储的数据量得以加倍。32位浮点与16位浮点之间 的转换通过单指令执行。虽然每个存储器模块都可以存储 代码和数据的组合,但如果让一个模块存储数据,利用 DM总线进行传输,让另一个模块存储指令和数据,利用 PM总线进行传输,则存取效率最高。
上面紫色字段的个人理解:
16bit,32bit,48bit word 可以再片上RAM上混用,但是最好是相同的word存储在一起.片上存储器可以存储数据和代码,然后模块和模块分开,存储数据的模块就存储数据,存储指令的就存储指令,数据就使用DM进行标识使用DM总线速度最快,而指令则用PM进行标识
疑惑点:为什么会有16bit float?
ADSP21489片上RAM存储物理地址分成4个模块
BLOCK0:
48bit
0x0008 C000–0x0009 3FFF
32bit
0x0009 2000–0x0009 DFFF
16bit
0x0012 4000–0x0013 BFFF
BLOCK1:
48bit
0x000A C000–0x000B 3FFF
32bit
0x000B 2000–0x000B DFFF
16bit
0x0016 4000–0x0017 BFFF
BLOCK2:
48bit
0x000C 0000–0x000C 5554
32bit
0x000C 0000–0x000C 7FFF
16bit
0x0018 0000–0x0018 FFFF
BLOCK3:
48bit
0x000E 0000–0x000E 5554
32bit
0x000E 0000–0x000E 7FFF
16bit
0x001C 0000–0x001C FFFF
看到存储地址这里,又不得不讲一下ADSP21489的boot kernel
** Notes:
** 1) The interrupt Vector Table (IVT) code is placed in internal memory
** by default and has to use ISA (NW, 48 bit) instructions.
** 2) The loader kernel uses 256 ISA instructions from the start of the
** IVT. The final action it does is to load the application code to these
** address overwriting it's own code. The application code in these
** addresses therefore must also be ISA instructions. Do not put
** VISA (SW) instructions in these 256 locations.
** 3) IVT一直存放片上RAM
** 4) ASDP2148处理器上电或复位后启动从boot kernel启动,通过DMA通道自动传输到处理器的RAM,384-word 32bit or 256word(48bit)
下面是原文介绍(不翻译了,我觉得英文自己理解更带劲)
At power-up, after the chip reset, the booting process includes the following steps.
1. Based on the boot type, an appropriate DMA channel is automatically configured for a 384-word (32-bit)
transfer or a 256-word (48-bit) transfer. This transfer boot-loads the boot kernel program into the processor
memory.
2. The boot kernel runs and loads the application executable code and data.
3. The boot kernel overwrites itself with the first 256 (48-bit) words of the application at the end of the booting
process. After that, the application executable code starts running.
就是解释一下: 384word(32bit) = 384*32bit刚好等于256word(48bit) = 256*48bit
第三点:引导程序完成后会重写前面的256word(48bit)空间内容,为啥要重写?没理解
在开始ldf文件之前再介绍了解一下


默认的.ldf文件映射了许多输入部分,允许对在内存中放置代码和数据的位置进行一些控制;请参阅SHARC处理器表的内存输入部分。
存储空间分布表
MEMORY
{/* ADSP-21489 MEMORY MAP.**** The SHARC 21489 has 5Mbit RAM in total.**** -------------------------- BLOCK 0 ---------------------------------------** 0x0008 C000 to 0x0009 3FFF Normal word (48) Space (1.5 Mbit RAM)** 0x0009 2000 to 0x0009 DFFF Normal word (32) Space (1.5 Mbit RAM)** 0x0012 4000 to 0x0013 BFFF Short word (16) Space (1.5 Mbit RAM)**** Notes:** 1) The interrupt Vector Table (IVT) code is placed in internal memory** by default and has to use ISA (NW, 48 bit) instructions.** 2) The loader kernel uses 256 ISA instructions from the start of the ** IVT. The final action it does is to load the application code to these** address overwriting it's own code. The application code in these** addresses therefore must also be ISA instructions. Do not put ** VISA (SW) instructions in these 256 locations.*/mem_iv_code { TYPE(PM RAM) START(0x0008C000) END(0x0008C0A7) WIDTH(48) }mem_block0_nwco { TYPE(PM RAM) START(0x0008C0A8) END(0x0008C0FF) WIDTH(48) }mem_block0_sw16 { TYPE(SW RAM) START(0x00124300) END(0x0013BFFF) WIDTH(16) }/*** -------------------------- BLOCK 1 ---------------------------------------** 0x000A C000 to 0x000B 3FFF Normal word (48) Space (1.5 Mbit RAM)** 0x000B 2000 to 0x000B DFFF Normal word (32) Space (1.5 Mbit RAM)** 0x0016 4000 to 0x0017 BFFF Short word (16) Space (1.5 Mbit RAM)*/mem_block1_dm32 { TYPE(DM RAM) START(0x000B2000) END(0x000BDFFF) WIDTH(32) }/*** -------------------------- BLOCK 2 ---------------------------------------** 0x000C 0000 to 0x000C 5554 Normal word (48) Space (1 Mbit RAM)** 0x000C 0000 to 0x000C 7FFF Normal word (32) Space (1 Mbit RAM)** 0x0018 0000 to 0x0018 FFFF Short word (16) Space (1 Mbit RAM)*/mem_block2_pm32 { TYPE(PM RAM) START(0x000C0000) END(0x000C7FFF) WIDTH(32) }/*** -------------------------- BLOCK 3 ---------------------------------------** 0x000E 0000 to 0x000E 5554 Normal word (48) Space (1 Mbit RAM)** 0x000E 0000 to 0x000E 7FFF Normal word (32) Space (1 Mbit RAM)** 0x001C 0000 to 0x001C FFFF Short word (16) Space (1 Mbit RAM)*/mem_block3_dm32 { TYPE(DM RAM) START(0x000E0000) END(0x000E7FFF) WIDTH(32) }mem_sram { TYPE(DM RAM ASYNCHRONOUS) START(0x0C000000) END(0x0C01FFFF) WIDTH(8) }mem_flash { TYPE(DM RAM ASYNCHRONOUS) START(0x04000000) END(0x043FFFFF) WIDTH(8) }/*$VDSG<insert-new-memory-segments> *//* Text inserted between these $VDSG comments will be preserved */mem_block0_dm32 { TYPE(DM RAM) START(0x0009DA00) END(0x0009DFFF) WIDTH(32) } mem_block3_dm48 { TYPE(DM RAM) START(0x000E0000) END(0x000E17FF) WIDTH(48) }mem_sdram_dmda1 { TYPE(DM RAM) START(0x00660000) END(0x00666BFF) WIDTH(16) } /*$VDSG<insert-new-memory-segments> */} /* MEMORY */
问题1:
mem_block0_sw16的含义
表示片上空间block0段定义为16bit时的存储空间,ADSP21489片上的5Mbit RAM大小一共被分配成4个block,存储分配如下
BLOCK 0 = 1.5Mbit
BLOCK 1 = 1.5Mbit
BLOCK 2 = 1Mbit
BLOCK 3 = 1Mbit
合计5Mbit
问题2:DM和PM的表面意义就是数据和程序空间的意思,但是数据空间是指的存储数据,那么程序空间是指在RAM上存储程序代码吗?
问题3:解释一下在ldf中的section是啥意思
#pragma section("ss_fw_code_fast")
void DelayMs(int nCount)
{int i = 0;for (i = 0; i < nCount; i++){NOP;}
}
在LDF文件中又经常看见如下
INPUT_SECTIONS( $OBJECTS(iv_code) )INPUT_SECTIONS( $OBJS_LIBS(seg_int_code seg_init seg_pmco) )
这里个人理解借用TI DSP的cmd文件进行理解一下
{ input_sections } —— 输入段,其语法如下:花括号“{}”中是输入段名。这里对输入段和输出段做一个区分,每一个C语言文件经过编译都会生成若干个段,多个汇编语言或C语言文件生成的段大都是同名的,常见的的段有如.cinit、.ebss等,这些都属于输入段。这些归属于不同文件的输入段,在CMD文件的指示下,会被链接器链接在一起生成输出段。
问题4:解释一下在ldf中的INPUT_SECTIONS( $OBJS_LIBS(seg_int_code_sw seg_int_code) )中各种美元符$后的标志的意思
$OBJS_LIBS(seg_int_code seg_init seg_pmco)
$OBJECTS(ss_block0_data) $LIBRARIES(ss_block0_data)
os_mem1 {INPUT_SECTIONS($OBJECTS(program))
} >mem1
os_mem2 {INPUT_SECTIONS($OBJECTS(program))
} >mem2
找了一下原文解释
In the above example, if some of the input sections included in $OBJECTS(program) do not fit in os_mem1,
the linker will try to map them into os_mem2.
在上述示例中,如果$OBJECTS(program)中包含的一些输入部分不适合os_mem1,链接器将尝试将它们映射到os_mem2。
写这里最后还补充一次一个完整的写法说明
#define IV_CODE dxe_iv_codeIV_CODE PM{/* iv_code表示一个输入端(中断向量代码) */ /* INPUT_SECTIONS() 就是表示后面的对象内容放置到执行文件中 *//* mem_iv_code表示指定code存放在该内存段上 *//* IV_CODE也就是dxe_iv_code,看到dxe的前缀就知道是输出段 */INPUT_SECTIONS( $OBJECTS(iv_code) )} > mem_iv_code
问题5:PM和SW是什么意思
