- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello i need to acess my registers from userspace, i am developing a
critical timing application and i can't consider the time needed to call the device driver and read my timestamp register. I need to read my timestamp register from userspace, how can i do that? I know that 0x8 is for uncached, therefore peripherals adresses will have the 8 in the adress. I am trying to use inl(0x000024e0 (my adress), 0); however i get a segmentation fault... i tried to include io.h but with no sucess # define inl(addr) ({ unsigned int __res; __asm__ __volatile__( "ldwio %0, 0(%1)" : "=r"(__res) : "r" (addr)); __res; }) //----------------------------------------------------------------------- # define inb(addr) ({ unsigned int __res; __asm__ __volatile__( "ldbio %0, 0(%1)" : "=r"(__res) : "r" (addr)); __res; }) //----------------------------------------------------------------------- # define outl(b,addr) ({ __asm__ __volatile__( "stwio %0, 0(%1)" : : "r"(, "r" (addr)); }) //----------------------------------------------------------------------- # define outw(b,addr) ({ __asm__ __volatile__( "sthio %0, 0(%1)" : : "r"(, "r" (addr)); }) //----------------------------------------------------------------------- # define outb(b,addr) ({ __asm__ __volatile__( "stbio %0, 0(%1)" : : "r"(, "r" (addr)); })Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please don't cross-post between the mailing list and the nios2-dev list. Or if you do so, please at least link put a link to the other, so people searching for answers to the same or similar questions can find it in the other place too.
As already stated on nios2-dev, this won't work (for obvious reasons). Please see http://article.gmane.org/gmane.linux.uclinux.nios2.devel/189 for the full answer.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Okay, is there any easy way to acess the list archive?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, there is. Either the mailman archive at http://sopc.et.ntust.edu.tw/pipermail/nios2-dev/ or at gmane (only massages since around beginning of june 2011): http://news.gmane.org/gmane.linux.uclinux.nios2.devel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is my final code
memfd = open("/dev/mem", O_RDWR | O_SYNC ); if (memfd < 0) { log_msg("Cannot open /dev/mem\n"); exit(1); } pgoff = (unsigned int) (MENOS_BASE & (sysconf(_SC_PAGE_SIZE)-1)); map_len = 16 + pgoff; mapped = mmap(NULL, map_len, (PROT_READ | PROT_WRITE), MAP_SHARED, memfd, MENOS_BASE - pgoff); if (mapped == MAP_FAILED ) { log_msg("Cannot map registers\n"); } ts_my = mapped + pgoff; inl(ts_my);
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page