#144353 - simonjhall - Wed Oct 31, 2007 11:08 pm
Yo,
I recently moved loads of code into itcm in order to improve performance a bit and also to reduce the main memory load a bit.
Well after doing this, I assumed that I'd be able to regain up to 32k of heap space, since the code would be resident in the itcm memory instead, but this wasn't the case. I forgot about this and now have decided to dig it up again since people seem to have problems loading a few levels due to a lack of RAM.
I seem to remember that in the early startup of a DS program, the memory protection unit gets set up, code gets copied into various places etc etc, and this is where code is sent to itcm allowing calls to these functions (from the main program) to work correctly. Well once they've been copied, the memory they originally occupied in main memory is no longer needed, right?
But poking through my elf and the link scripts says otherwise, and as a result I'm not able to win myself back that max 32k of main memory.
The link script basically says that *main* memory looks like this:
- the text section
- something else, which has the exact same size as the itcm section
- the bss section
- the heap.
Here's the sections header from my elf:
Even though I've got 16k currently in the itcm section, there's still a 16k 'gap' between the data section and the text section - and I want it back!
How trivial is it to wiggle the linker script in order to get the DS startup code (in crt0.s?) to work whilst winning me back some memory after code has been copied into itcm?
Ta as ever :-)
_________________
Big thanks to everyone who donated for Quake2
I recently moved loads of code into itcm in order to improve performance a bit and also to reduce the main memory load a bit.
Well after doing this, I assumed that I'd be able to regain up to 32k of heap space, since the code would be resident in the itcm memory instead, but this wasn't the case. I forgot about this and now have decided to dig it up again since people seem to have problems loading a few levels due to a lack of RAM.
I seem to remember that in the early startup of a DS program, the memory protection unit gets set up, code gets copied into various places etc etc, and this is where code is sent to itcm allowing calls to these functions (from the main program) to work correctly. Well once they've been copied, the memory they originally occupied in main memory is no longer needed, right?
But poking through my elf and the link scripts says otherwise, and as a result I'm not able to win myself back that max 32k of main memory.
The link script basically says that *main* memory looks like this:
- the text section
- something else, which has the exact same size as the itcm section
- the bss section
- the heap.
Here's the sections header from my elf:
Code: |
Program Header:
0x70000001 off 0x000779cc vaddr 0x0206f9cc paddr 0x0206f9cc align 2**2 filesz 0x00000110 memsz 0x00000110 flags r-- LOAD off 0x00008000 vaddr 0x02000000 paddr 0x02000000 align 2**15 <--- this is the text section filesz 0x000751d4 memsz 0x000751d4 flags rwx LOAD off 0x00080000 vaddr 0x01000000 paddr 0x020751d4 align 2**15 <--- this is the itcm section filesz 0x00004d74 memsz 0x00004d74 flags rwx LOAD off 0x00081f48 vaddr 0x02079f48 paddr 0x02079f48 align 2**15 <--- this is the bss section filesz 0x00000000 memsz 0x00068d5c flags rw- private flags = 4000002: [Version4 EABI] [has entry point] |
How trivial is it to wiggle the linker script in order to get the DS startup code (in crt0.s?) to work whilst winning me back some memory after code has been copied into itcm?
Ta as ever :-)
_________________
Big thanks to everyone who donated for Quake2