Re: mmap for I/O access



Robert Scott wrote:
My call to mmap is causing a Segmentation fault. Is this the right way to do
it?

It should work more or less as you have guessed, but there are a few things to fix :

- you need to map to an offset which is a multiple of the page size, usually 4K. Get the page size with a call to getpagesize(2).

- The size you're mapping to also needs to be a multiple of the page size.

I usually write a little wrapper function which allows the user to map arbitrary addresses, computing the offset and alignment for you behind the scenes.

- check that you're mapping to the physical address as actually presented on the CPU's bus, and not the mapped or translated address supported by the CPU. I don't know what way this is set up on ARM. Ask your hardware engineer or check the hardware guide for the board.

- I would strongly recommend that you ass the O_SYNC flag to the open(2) call. This will tell the OS to use an uncached mapping. Not using O_SYNC may cause weird effects.
.



Relevant Pages

  • Re: Question on Effective Java Item 27
    ... value to convey multiple meanings. ... Because I haved programmed in different prog langs, ... Returns the value to which the specified key is mapped in this identity hash map, or null if the map contains no mapping for this key. ... A return value of null does not necessarily indicate that the map contains no mapping for the key; it is also possible that the map explicitly maps the key to null. ...
    (comp.object)
  • Re: Decoding strategy
    ... Mapping is actually two-step process, ... address at which to map the file, this isn't necessary, nor does it to my ... needs physical RAM that's not available). ... This doesn't reserve any ...
    (microsoft.public.dotnet.languages.csharp)
  • behavior as mapping
    ... seeing behavior as a mapping from a very high dimension ... that the map has been changed. ... The brain has a finite and relatively fixed number of neurons, ... But in fact, before we learned how to ride a bike, ...
    (comp.ai.philosophy)
  • Re: Binary Tree and Pairs of Nodes
    ... Every node in your infinite binary tree occurs at the ... So you say you have a mapping of every path to a node. ... You do not map My path to 1, because whichEVER path YOU mapped to 1, ...
    (sci.logic)
  • Re: MVC - Model binding to collection
    ... If you use ViewPage, you have a more explicit way of defining your model so you can drill through more explicitly. ... I am creating the view without problem, but my expectation is that I can create a textbox with a name which will enable the defaultmodelbinder to map back the post variables to the model. ... I'm sure that my model could be a little simpler, although I would still have Contact Data as a collection and it is complicated a little because of the linqtosql mapping. ...
    (microsoft.public.dotnet.framework.aspnet)