Re: Why I love open source.....
Peter Onion <[email protected]>
| Newsgroups | gmane.comp.hardware.microcontrollers.gnupic |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 2005-07-13 at 00:53 +1000, Iain Dooley wrote: > > BTW the technique means I can include drivers for various devices (like > > UART,TMRx,LCDdisplays) by simply including the appropriate ".o" file in > > the liker command and adding EXTERN declarations for the device API. > > The overhead is a small ISR and a bit of generic startup code. No need > > to worry about the device initialisation or interrupt handlers as they > > all get included and called automagically. > > why does this required the objects to be linked in any particular order? It only really requires that you can ensure a particular piece of code is going to be the start and another at the end of a segment. Each device driver file contains code in typically three code segments. Device initialisation code goes in a segment called "initcode", the interrupt handler goes in "handlers" and the API code goes in a third segment (name unimportant). A small ISR at address 0x4 saves the context and jumps to the start of the handlers segment. Each handler checks it's device flags and skips over itself if nothing needs doing. The last piece of code in the segment restores the context and executes the retfie. The startup code similarly calls a label at the start of the initcode segment and all the linked devices are set up before the last section of code in the segment executes a return. Because I know how gplink deals with these things I'm happy to use the technique. As I said MPLINK users are in the dark about how that linker operates so they choose to make nothing but discouraging comments :-( Closed Source - Closed Minds. Peter