Interrupts for Arm-elf-gcc
Shaun Jackman
sjackman@pathwayconnect.com
Wed Jul 23 15:17:00 GMT 2003
Here's another way of doing it. Stuff a bunch of pc relative branches in
the IRQ vectors, and have your standard IRQ vector table immediately
following. Then, somewhere in your C initialization write
IRQVector = IRQHandler;
In your code below, be careful not to confuse preprocessor symbols, and
linker symbols. The two don't know anything about each-other. Unless it
was defined used #define, or by passing -D to cpp, you cannot test it
with #ifdef. In particular, you can't check for the existence of
functions using the preprocessor. That has to be done with the linker.
You can do what you want using __attribute__((weak)) though. When I was
checking attributes, I also noticed that __attribute__((interrupt)) is
supported for the arm now. Check that out too!
Cheers,
Shaun
ldr pc, [pc, #24]
ldr pc, [pc, #24]
ldr pc, [pc, #24]
ldr pc, [pc, #24]
ldr pc, [pc, #24]
ldr pc, [pc, #24]
ldr pc, [pc, #24]
ldr pc, [pc, #24]
START:
.word start
UDINSTVector:
.word die
SWIVector:
.word die
PABORTVector:
.word die
DABORTVector:
.word die
RESERVEDVector:
.word die
IRQVector:
.word die
FIQVector:
.word die
die:
b $
start:
; your code starts here
On Wed, 2003-07-23 at 02:26, David Mc Kenna wrote:
> Hi Shaun,
>
> Thanks for the reply. Just one or two questions with your code.
>
> For ARM, the first few lines of code are your Interrupt vectors which look something
> like this
>
> b start SVC 0x00
> b UDINSTHandler UND 0x04
> b SWIHandler SVC 0x08
> b PABORTHandler ABORT 0x0C
> b DABORTHandler ABORT 0x10
> b RESERVED\n"
> b IRQHandler IRQ 0x18
> b FIQHandler FIQ 0x1C
>
> When an interrupt occurs, e.g. an IRQ, the core jumps to 0x18, switches to ARM
> if in thumb mode, and enters IRQ mode, which gives us access to the IRQ bank
> of registers. As the location is only one word in size we require a branch to
> another location, our IRQHandler. This code then executes our interrupt.
> The problem I have is that I don't want to always have to go in and manually
> write IRQHandler to jump to the function in C. What I would like to do, as it
> seems interrupts haven't being implemented in C is to something along these
> lines:
>
> IRQHandler:
> #ifdef IRQ_Interrupt
> bl IRQ_Interrupt
> #endif
>
> What I hope this will do is the if a function written in C is present, that
> it will include this code ( bl IRQ_Interrupt ) in my IRQHandler. But when I
> do not write the function IRQ_Interrupt, it will not.
> The above code works for when the function is written in C but when I remove
> it I get the following error:
>
> interrupts.o: In function `IRQHandler':
> interrupts.o(.text+0x38): undefined reference to `IRQ_Interrupt'
> collect2: ld returned 1 exit status
>
> Any help is appreciated,
>
> Thanks,
> Dave
------
Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com
More information about the crossgcc
mailing list