This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
At 03:04 PM 3/3/99 PST, you wrote: >What is the best way to define fixed memory locations in C, such as >hardware device registers? In particular, I'd like to set it up so >that I can easily define multiple groups of identical hardware >registers at different locations, and have the compiler optimize the >accesses as much as possible. > My solution is a little different, I define all of the access in header files as extern volatile unsigned char my_byte_reguister; Then in the linker files I add... my_byte_regiser = 0x12340000; This also works for hardware that is a structure.... Just define the structure as external and then give tha address in the linker file. Typically I make a link and header file for each "hardware" object. for example foo.h and foo.ld. foo.h can be included multiple times, as it is an extern and won't get multiply defined. foo.ld only goes in at the link step. My linker flags from one of my makefiles... LDFLAGS = -m5200 -Wl -Wl,-n -Tnb5206.ld -Wl,-R$(NBLIBDIR)eth.ld,-R$(NBLIBDIR)sys.ld Where eth.ld is the memory map for my Ethernet chip and sys.ld is the map for the on board registers for the coldfire 5206. If you need more I can post more examples. Paul _______________________________________________ New CrossGCC FAQ: http://www.objsw.com/CrossGCC _______________________________________________ To remove yourself from the crossgcc list, send mail to crossgcc-request@cygnus.com with the text 'unsubscribe' (without the quotes) in the body of the message.