Reply by Not Really Me June 23, 20082008-06-23
"Roman Mashak" <mrv@tusur.ru> wrote in message 
news:g3kj9a$uvt$1@relay.tomsk.ru...
> Hello, > > I'm trying to understand the mechanism of remapping on AT91SAM7 chips and > it's concerned the ARM assembly language. Basically what I wish to > perceive is the way C-startup is implemented. As far as I understand, it > strongly depends on a board involved and purpose of the firmware. > > But there are some common parts of startup code as well, for example the > vector table: some examples I explored use "B .." instructions, while > others do various variations of "LDR pc ...". To my understanding, the > first one is doing _PC-relative_ jump, and "LDR pc, ..." populate PC with > an _absolute_ address. > > So when is is preferable to use the first method (via 'B' instructions) > and whe the second one with absolute addresses? Are there any rules or > common practises for that? > > Thanks. > > Best regards, Roman Mashak >
You can use the relative addressing if all of your interrupt handlers fit in the first 32K of code (14 bit address range). Some folks have a first level handler in that space that dispatches to other relocatable code outside of that range. The second method allows you to put full 32 bit addresses in the table (which usually immediately follows the vectors). Normally you boot from flash and then set up RAM and do a remap to put the RAM version of the vector table at 0. Once that is done you can modify the jump table to install handlers. For SAM7/9 chips they also have an advanced interrupt controller which can provide handler addresses. You hard code the IRQ and FIQ vectors to do get the jump address directly from the AIC. ldr pc, [pc, #-0xF20] ; Branch to irq_handler via AIC IVR Make sure to init the AIC and the handlers before enabling interrupts though. Scott
Reply by Roman Mashak June 22, 20082008-06-22
Hello,

I'm trying to understand the mechanism of remapping on AT91SAM7 chips and 
it's concerned the ARM assembly language. Basically what I wish to perceive 
is the way C-startup is implemented. As far as I understand, it strongly 
depends on a board involved and purpose of the firmware.

But there are some common parts of startup code as well, for example the 
vector table: some examples I explored use "B .." instructions, while others 
do various variations of "LDR pc ...".  To my understanding, the first one 
is doing _PC-relative_ jump, and "LDR pc, ..." populate PC with an 
_absolute_ address.

So when is is preferable to use the first method (via 'B' instructions) and 
whe the second one with absolute addresses? Are there any rules or common 
practises for that?

Thanks.

Best regards, Roman Mashak