Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

15
  • 1
    While your answer does answer my question directly, Warren's answer seems to be the better way to go about it. :-) Commented May 2, 2012 at 6:32
  • 1
    @WarrenYoung I have no idea what you are supposed to do with it. I would guess "uint8_t *ptr = 0x8000000" with my example? Or that may segfault... Huh, I really don't know. Again, I knew the answer because I was an end user of a poorly designed PCI card where I had to manually allocate a buffer below the 4G mark and then tell a driver where that space was; it may not be possible from userland. Commented May 2, 2012 at 10:14
  • 2
    Just for grins, I looked a little deeper into this, and it appears you need MMAP_FIXED | MMAP_ANON. Without a custom DMA device here to play with, I can't say if it actually does what the OP wanted, but my CentOS box happily gave me an 8 MB block at 512 MB when I said memmap=8M$512M in GRUB. It doesn't even require root access, as I had feared it might. But even if this does do the right thing, I still think you'll probably need a driver to handle interrupts and such. Commented May 2, 2012 at 13:05
  • 3
    @AaronD.Marasco: No, mmap()'d pages are zeroed before userland code gets to see them. It's done for security, so that data doesn't leak from one process to the next. Another reason to use a driver, since you might need to preserve the contents of the DMA buffer at driver load time. Oh and by the way, the arbitrarily-located mmap() call succeeds even without the memmap kernel boot option, at least as long as no one is already using memory located where you asked. The boot option doubtless increases the chances of success, but it's not strictly necessary. Commented May 3, 2012 at 17:42
  • 1
    @AaronD.Marasco hmm, okay. interesting. thank you for that link, it's a good read. Commented Mar 21, 2017 at 14:10