Forum Discussion
Altera_Forum
Honored Contributor
12 years agoPersonally I wouldn't ever have written anything like IOWR_32DIRECT() or any of its friends.
It is much, much, much safer to define C structures to map device registers and then either use a pointer initialiased to the correct value or get the linker to assign a constant to a normal C structure variable. That doesn't, or course, solve the problem of bypassing the cache - using the stwio instruction is one way of doing that. __builtin_stwio() if probably defined as: void __builtin_stwio(void *, unsigned int); So your 'data' value will need to be an integeral one (not a pointer). It is actually much easier to bypass the data cache by setting the high bit of the address and using 'normal' memory access instructions (not the xxxio ones). In which case you can just dereference a normal C pointer (to a structure of the correct type). If your code might run in a system with an mmu it is all more complex, and the OS will likely have support functions.