共1条
1/1 1 跳转至页
[转帖]loadModuleAt
I want to use the loadModuleAt command to get around the 24 bit relocation (32meg) restriction. I don't want to compile with -mlongcall because of performance reasons I cannot afford. However, I also need the system to have more of the 128meg available than just 32meg. My problem is how do I know a safe location for text, data, and Bss? What globals and calls (like sysMemTop()) and others can I use to determine where to place the next module? I am loading several modules.
Hello,
Using loadModuleAt is not the way to get around the 24 bit relocation limit. Since you don't want to use the -mlongcall option, you have a few possibilities:
1) Set USER_RESERVED_MEM to be 96MB (i.e. 128MB - 32MB). That will leave just 32MB for the kernel initially. Load all your modules at the start of execution, then, once they are loaded, you can use memAddToPool() to add the reserved 96MB into the system memory partition.
2) Again, reserve the upper section of the memory, but this time don't add it to the system pool. Instead, use it for your application's dynamic allocation requirements. Create a memory partition in there using memPartCreate(), then allocate and free directly from it using memPartAlloc() and memPartFree().
If you really want to try to use loadModuleAt(), one trick you perhaps get away with would be to move the data/bss segments above the 32MB line, and keep the code below. To do this though will require some ingenuity:
a) You will need to reserve the upper memory again.
b) As soon as the system starts up, allocate a block from the heap that will be used for the text segments - make sure it is large enough for all the text segments you plan to load. Use this allocated block to create a new memory partition - the text partition.
c) Use memAddToPool() to add back the reserved memory.
Now, when you want to load a file, simply allocate enough memory for the text from the text partition, and allocate enough memory for the data+bss from the system heap. Then use loadModuleAt() to load the module.
There is one little thing that you will need to do first though: work out the sizes of the segments so that you know how much memory to allocate. I don't believe that there is an API for that, so you'd probably have to open the file and read the OMF headers yourself to work it out.
HTH,
John...
关键词: 转帖 loadModuleAt
共1条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
与电子爱好者谈读图二被打赏50分 | |
【FRDM-MCXN947评测】Core1适配运行FreeRtos被打赏50分 | |
【FRDM-MCXN947评测】双核调试被打赏50分 | |
【CPKCORRA8D1B评测】---移植CoreMark被打赏50分 | |
【CPKCORRA8D1B评测】---打开硬件定时器被打赏50分 | |
【FRDM-MCXA156评测】4、CAN loopback模式测试被打赏50分 | |
【CPKcorRA8D1评测】--搭建初始环境被打赏50分 | |
【FRDM-MCXA156评测】3、使用FlexIO模拟UART被打赏50分 | |
【FRDM-MCXA156评测】2、rt-thread MCXA156 BSP制作被打赏50分 | |
【FRDM-MCXN947评测】核间通信MUTEX被打赏50分 |