From: Borja F. <bor...@gm...> - 2012-03-05 20:57:38
|
I'm currently implementing support for interrupt handling. But before going any further into implementing it in the backend (the frontend part is nearly done) I want to get things clear. Eric this one is probably for you because it's about avr-libc but anyways, here we go: There are 2 function attributes to add: 1) signal (ISR macro): normal interrupt handler. Every register used inside the handler gets saved in the stack, including special code to save SREG. So we have to mark all registers to be callee saved. 2) interrupt (ISR_NOBLOCK): same as above but adding a sei instruction at the very top of function entry. Now, the naked attribute is already implemented and i don't need to handle anything with it. It avoids any prologue/epilogue code to be inserted. BUT by default the ret/reti instruction gets emitted, and avr-libc says that it should be done by the programmer so I have to handle that, right? This doesn't matter if it's an ISR or a normal func. The ISR_ALIASOF macro works correctly, so no more work is needed there (using NOBLOCK or NAKED with ALIASOF doesn't make sense at all, right?) Now i want to talk about combining attributes: Truth table format: |signal | interrupt | naked| 1) 0 0 0 -> nothing 2) 0 0 1 -> no prologue/epilogue and no ret/reti (used in any arbitrary function)(so as i said before, don't emit ret/reti?) 3) 0 1 0 -> emit sei, and save all used regs inside the function plus SREG. 4) 0 1 1 -> naked wins, do case 1. 5) 1 0 0 -> normal ISR macro, do what i said when explaining the signal attrib. 6) 1 0 1 -> naked wins again. 7) 1 1 0 -> interrupt wins, do case 3. 8) 1 1 1 -> naked wins. So this is what I understand I have to do, please let me know if I'm wrong on anything I've mentioned. |