这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » [转帖]loadModuleAt

共1条 1/1 1 跳转至

[转帖]loadModuleAt

菜鸟
2003-01-17 01:26:37     打赏
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 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]