共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网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
vscode+cmake搭建雅特力AT32L021开发环境被打赏30分 | |
【换取逻辑分析仪】自制底板并驱动ArduinoNanoRP2040ConnectLCD扩展板被打赏47分 | |
【分享评测,赢取加热台】RISC-V GCC 内嵌汇编使用被打赏38分 | |
【换取逻辑分析仪】-基于ADI单片机MAX78000的简易MP3音乐播放器被打赏48分 | |
我想要一部加热台+树莓派PICO驱动AHT10被打赏38分 | |
【换取逻辑分析仪】-硬件SPI驱动OLED屏幕被打赏36分 | |
换逻辑分析仪+上下拉与多路选择器被打赏29分 | |
Let'sdo第3期任务合集被打赏50分 | |
换逻辑分析仪+Verilog三态门被打赏27分 | |
换逻辑分析仪+Verilog多输出门被打赏24分 |