共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网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【笔记】生成报错synthdesignERROR被打赏50分 | |
【STM32H7S78-DK评测】LTDC+DMA2D驱动RGBLCD屏幕被打赏50分 | |
【STM32H7S78-DK评测】Coremark基准测试被打赏50分 | |
【STM32H7S78-DK评测】浮点数计算性能测试被打赏50分 | |
【STM32H7S78-DK评测】Execute in place(XIP)模式学习笔记被打赏50分 | |
每周了解几个硬件知识+buckboost电路(五)被打赏10分 | |
【换取逻辑分析仪】RA8 PMU 模块功能寄存器功能说明被打赏20分 | |
野火启明6M5适配SPI被打赏20分 | |
NUCLEO-U083RC学习历程2-串口输出测试被打赏20分 | |
【笔记】STM32CUBEIDE的Noruletomaketarget编译问题被打赏50分 |