How to check if a file descriptor/ memory is mmap able?
I am trying to access a memory location "/dev/xdma_h2c_0". I have achieved the read/write using system read/write functions.
Now I am trying to use mmap to do the same. But I am getting No such device error.
Is there a quick way to tell whether a location/file descriptor is mmap (-able) or not?
(This memory location is available on the Xilinx Virtex FPGA board using the Xilinx drivers)
python
add a comment |
I am trying to access a memory location "/dev/xdma_h2c_0". I have achieved the read/write using system read/write functions.
Now I am trying to use mmap to do the same. But I am getting No such device error.
Is there a quick way to tell whether a location/file descriptor is mmap (-able) or not?
(This memory location is available on the Xilinx Virtex FPGA board using the Xilinx drivers)
python
This is a region of memory exposed by the FPGA? Is/dev/xdma_h2c_0a character device or block device? What is the errno?ENODEV/ENOENT? From what you've provided, I'd suggest it isn't, but that doesn't mean you can't potentially improve the driver to make it possible!
– Attie
Feb 13 at 9:48
Yes. It's a character device. Errno as given by python script is "OSError: [Errno 19] No such device". Can you tell from this whether is possible to mmap it?
– user10589957
Feb 13 at 11:29
You cannotmmap()character devices - they aren't seekable, etc...
– Attie
Feb 13 at 18:47
add a comment |
I am trying to access a memory location "/dev/xdma_h2c_0". I have achieved the read/write using system read/write functions.
Now I am trying to use mmap to do the same. But I am getting No such device error.
Is there a quick way to tell whether a location/file descriptor is mmap (-able) or not?
(This memory location is available on the Xilinx Virtex FPGA board using the Xilinx drivers)
python
I am trying to access a memory location "/dev/xdma_h2c_0". I have achieved the read/write using system read/write functions.
Now I am trying to use mmap to do the same. But I am getting No such device error.
Is there a quick way to tell whether a location/file descriptor is mmap (-able) or not?
(This memory location is available on the Xilinx Virtex FPGA board using the Xilinx drivers)
python
python
asked Feb 13 at 9:42
user10589957user10589957
31
31
This is a region of memory exposed by the FPGA? Is/dev/xdma_h2c_0a character device or block device? What is the errno?ENODEV/ENOENT? From what you've provided, I'd suggest it isn't, but that doesn't mean you can't potentially improve the driver to make it possible!
– Attie
Feb 13 at 9:48
Yes. It's a character device. Errno as given by python script is "OSError: [Errno 19] No such device". Can you tell from this whether is possible to mmap it?
– user10589957
Feb 13 at 11:29
You cannotmmap()character devices - they aren't seekable, etc...
– Attie
Feb 13 at 18:47
add a comment |
This is a region of memory exposed by the FPGA? Is/dev/xdma_h2c_0a character device or block device? What is the errno?ENODEV/ENOENT? From what you've provided, I'd suggest it isn't, but that doesn't mean you can't potentially improve the driver to make it possible!
– Attie
Feb 13 at 9:48
Yes. It's a character device. Errno as given by python script is "OSError: [Errno 19] No such device". Can you tell from this whether is possible to mmap it?
– user10589957
Feb 13 at 11:29
You cannotmmap()character devices - they aren't seekable, etc...
– Attie
Feb 13 at 18:47
This is a region of memory exposed by the FPGA? Is
/dev/xdma_h2c_0 a character device or block device? What is the errno? ENODEV / ENOENT? From what you've provided, I'd suggest it isn't, but that doesn't mean you can't potentially improve the driver to make it possible!– Attie
Feb 13 at 9:48
This is a region of memory exposed by the FPGA? Is
/dev/xdma_h2c_0 a character device or block device? What is the errno? ENODEV / ENOENT? From what you've provided, I'd suggest it isn't, but that doesn't mean you can't potentially improve the driver to make it possible!– Attie
Feb 13 at 9:48
Yes. It's a character device. Errno as given by python script is "OSError: [Errno 19] No such device". Can you tell from this whether is possible to mmap it?
– user10589957
Feb 13 at 11:29
Yes. It's a character device. Errno as given by python script is "OSError: [Errno 19] No such device". Can you tell from this whether is possible to mmap it?
– user10589957
Feb 13 at 11:29
You cannot
mmap() character devices - they aren't seekable, etc...– Attie
Feb 13 at 18:47
You cannot
mmap() character devices - they aren't seekable, etc...– Attie
Feb 13 at 18:47
add a comment |
1 Answer
1
active
oldest
votes
According to your comments, /dev/xdma_h2c_0 is a character device, and thus it is not possible to use mmap() on it - that just makes no sense, primarily because it's not an addressable device (you can't use lseek() / fseek() either).
If the FPGA's address space is presented via PCI / PCIe, then you might have luck with using lspci to locate its memory regions, opening /dev/mem, and using mmap() with that... though this comes with all relevant security concerns and warnings... i.e: don't do this in a real product or outside the lab / home.
More ideally though, you'd write a proper drive to expose whatever functionality you're providing in the FPGA.
According to your follow-up comments, you are able to call lseek() on the device, which is not typical for character devices.
The file_operations structure outlines what "features" are available from the device or node.
Is that because the address space is presented via the Xilinx PCIe drivers?
Looking in the mainline kernel I can't immediately see the driver, but if the interface to the FPGA is indeed PCIe, and there isn't some weird windowing mechanism used, then I would imagine there is some flag region of memory available and therefore a method for seeking within it.
Thanks for the explanation. Just a small doubt. I can actually lseek() it since that's how I implemented read/write using system functions (os.lseek() then os.read()/os.write() in python). Is that because the address space is presented via the Xilinx PCIe drivers?
– user10589957
Feb 14 at 3:49
Interesting - it's not typically possible to uselseek()on a character device... See my update :-)
– Attie
Feb 14 at 11:14
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1405189%2fhow-to-check-if-a-file-descriptor-memory-is-mmap-able%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
According to your comments, /dev/xdma_h2c_0 is a character device, and thus it is not possible to use mmap() on it - that just makes no sense, primarily because it's not an addressable device (you can't use lseek() / fseek() either).
If the FPGA's address space is presented via PCI / PCIe, then you might have luck with using lspci to locate its memory regions, opening /dev/mem, and using mmap() with that... though this comes with all relevant security concerns and warnings... i.e: don't do this in a real product or outside the lab / home.
More ideally though, you'd write a proper drive to expose whatever functionality you're providing in the FPGA.
According to your follow-up comments, you are able to call lseek() on the device, which is not typical for character devices.
The file_operations structure outlines what "features" are available from the device or node.
Is that because the address space is presented via the Xilinx PCIe drivers?
Looking in the mainline kernel I can't immediately see the driver, but if the interface to the FPGA is indeed PCIe, and there isn't some weird windowing mechanism used, then I would imagine there is some flag region of memory available and therefore a method for seeking within it.
Thanks for the explanation. Just a small doubt. I can actually lseek() it since that's how I implemented read/write using system functions (os.lseek() then os.read()/os.write() in python). Is that because the address space is presented via the Xilinx PCIe drivers?
– user10589957
Feb 14 at 3:49
Interesting - it's not typically possible to uselseek()on a character device... See my update :-)
– Attie
Feb 14 at 11:14
add a comment |
According to your comments, /dev/xdma_h2c_0 is a character device, and thus it is not possible to use mmap() on it - that just makes no sense, primarily because it's not an addressable device (you can't use lseek() / fseek() either).
If the FPGA's address space is presented via PCI / PCIe, then you might have luck with using lspci to locate its memory regions, opening /dev/mem, and using mmap() with that... though this comes with all relevant security concerns and warnings... i.e: don't do this in a real product or outside the lab / home.
More ideally though, you'd write a proper drive to expose whatever functionality you're providing in the FPGA.
According to your follow-up comments, you are able to call lseek() on the device, which is not typical for character devices.
The file_operations structure outlines what "features" are available from the device or node.
Is that because the address space is presented via the Xilinx PCIe drivers?
Looking in the mainline kernel I can't immediately see the driver, but if the interface to the FPGA is indeed PCIe, and there isn't some weird windowing mechanism used, then I would imagine there is some flag region of memory available and therefore a method for seeking within it.
Thanks for the explanation. Just a small doubt. I can actually lseek() it since that's how I implemented read/write using system functions (os.lseek() then os.read()/os.write() in python). Is that because the address space is presented via the Xilinx PCIe drivers?
– user10589957
Feb 14 at 3:49
Interesting - it's not typically possible to uselseek()on a character device... See my update :-)
– Attie
Feb 14 at 11:14
add a comment |
According to your comments, /dev/xdma_h2c_0 is a character device, and thus it is not possible to use mmap() on it - that just makes no sense, primarily because it's not an addressable device (you can't use lseek() / fseek() either).
If the FPGA's address space is presented via PCI / PCIe, then you might have luck with using lspci to locate its memory regions, opening /dev/mem, and using mmap() with that... though this comes with all relevant security concerns and warnings... i.e: don't do this in a real product or outside the lab / home.
More ideally though, you'd write a proper drive to expose whatever functionality you're providing in the FPGA.
According to your follow-up comments, you are able to call lseek() on the device, which is not typical for character devices.
The file_operations structure outlines what "features" are available from the device or node.
Is that because the address space is presented via the Xilinx PCIe drivers?
Looking in the mainline kernel I can't immediately see the driver, but if the interface to the FPGA is indeed PCIe, and there isn't some weird windowing mechanism used, then I would imagine there is some flag region of memory available and therefore a method for seeking within it.
According to your comments, /dev/xdma_h2c_0 is a character device, and thus it is not possible to use mmap() on it - that just makes no sense, primarily because it's not an addressable device (you can't use lseek() / fseek() either).
If the FPGA's address space is presented via PCI / PCIe, then you might have luck with using lspci to locate its memory regions, opening /dev/mem, and using mmap() with that... though this comes with all relevant security concerns and warnings... i.e: don't do this in a real product or outside the lab / home.
More ideally though, you'd write a proper drive to expose whatever functionality you're providing in the FPGA.
According to your follow-up comments, you are able to call lseek() on the device, which is not typical for character devices.
The file_operations structure outlines what "features" are available from the device or node.
Is that because the address space is presented via the Xilinx PCIe drivers?
Looking in the mainline kernel I can't immediately see the driver, but if the interface to the FPGA is indeed PCIe, and there isn't some weird windowing mechanism used, then I would imagine there is some flag region of memory available and therefore a method for seeking within it.
edited Feb 14 at 11:14
answered Feb 13 at 18:52
AttieAttie
11.7k32845
11.7k32845
Thanks for the explanation. Just a small doubt. I can actually lseek() it since that's how I implemented read/write using system functions (os.lseek() then os.read()/os.write() in python). Is that because the address space is presented via the Xilinx PCIe drivers?
– user10589957
Feb 14 at 3:49
Interesting - it's not typically possible to uselseek()on a character device... See my update :-)
– Attie
Feb 14 at 11:14
add a comment |
Thanks for the explanation. Just a small doubt. I can actually lseek() it since that's how I implemented read/write using system functions (os.lseek() then os.read()/os.write() in python). Is that because the address space is presented via the Xilinx PCIe drivers?
– user10589957
Feb 14 at 3:49
Interesting - it's not typically possible to uselseek()on a character device... See my update :-)
– Attie
Feb 14 at 11:14
Thanks for the explanation. Just a small doubt. I can actually lseek() it since that's how I implemented read/write using system functions (os.lseek() then os.read()/os.write() in python). Is that because the address space is presented via the Xilinx PCIe drivers?
– user10589957
Feb 14 at 3:49
Thanks for the explanation. Just a small doubt. I can actually lseek() it since that's how I implemented read/write using system functions (os.lseek() then os.read()/os.write() in python). Is that because the address space is presented via the Xilinx PCIe drivers?
– user10589957
Feb 14 at 3:49
Interesting - it's not typically possible to use
lseek() on a character device... See my update :-)– Attie
Feb 14 at 11:14
Interesting - it's not typically possible to use
lseek() on a character device... See my update :-)– Attie
Feb 14 at 11:14
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1405189%2fhow-to-check-if-a-file-descriptor-memory-is-mmap-able%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
This is a region of memory exposed by the FPGA? Is
/dev/xdma_h2c_0a character device or block device? What is the errno?ENODEV/ENOENT? From what you've provided, I'd suggest it isn't, but that doesn't mean you can't potentially improve the driver to make it possible!– Attie
Feb 13 at 9:48
Yes. It's a character device. Errno as given by python script is "OSError: [Errno 19] No such device". Can you tell from this whether is possible to mmap it?
– user10589957
Feb 13 at 11:29
You cannot
mmap()character devices - they aren't seekable, etc...– Attie
Feb 13 at 18:47