2011-04-24 13:57:25     What's the easiest way to do an 'atomic' read from AMS from userspace?

Document created by Aaronwu Employee on Aug 26, 2013
Version 1Show Document
  • View in full screen mode

2011-04-24 13:57:25     What's the easiest way to do an 'atomic' read from AMS from userspace?

Jay Ku (UNITED STATES)

Message: 100134   

 

I have a UART in an FPGA attached to one of the asyncronous memory banks on my BF537.  I've been doing simple read and writes to access the UART registers from my userspace program (this only needs to run on this platform under uclinux), but I just got bitten by blackfin's 'interruptable read' idiosyncracy when reading from my receive fifo (see for example   blackfin.uclinux.org/gf/project/uclinux-dist/forum/?action=ForumBrowse&forum_id=39&thread_id=41218&_forum_action=ForumMessageBrowse).

 

Is there a simple way to do an 'atomic' read from a userspace app?  I'd rather not have to write/modify a device driver to do this.  I tried in-lining assembly with a 'cli', but of course that didn't work from userspace.  Should I be able to use insw() from userspace?  I tried this but couldn't get my program to compile.  Maybe there's a way to use mmap or procfs?

 

Any advice appreciated.

 

- jay

QuoteReplyEditDelete

 

 

2011-04-24 14:09:25     Re: What's the easiest way to do an 'atomic' read from AMS from userspace?

Mike Frysinger (UNITED STATES)

Message: 100135   

 

it is not possible to do this from userspace

QuoteReplyEditDelete

 

 

2011-04-25 01:27:23     Re: What's the easiest way to do an 'atomic' read from AMS from userspace?

Mike Frysinger (UNITED STATES)

Message: 100138   

 

well, that's not entirely true.  officially, there is no way you can mess with interrupts from userspace (which is what is required to make the accesses "atomic").

 

unofficially, there are undocumented/untested/unverified instructions in the current hardware which accidentally works from userspace:

0x0125    STI [SP++]  /* previous state of IMASK moved to memory */

0x0165    CLI [--SP]  /* previous state of IMASK restored from memory */

 

so you could add ".dw 0x0165;" to the start of your code that accesses the async bank and then follow it up with ".dw 0x0125;".  you'll probably also need sufficient NOPs/SSYNCs (see the code in the Blackfin asm io header).

 

but again, this is all on your own and completely unsupported.  if you want support from us, write a proper kernel driver.

 

g'luck

QuoteReplyEditDelete

Attachments

    Outcomes