从用户空间创建物理内存以用于 DMA 传输
我想创建一些内存用于 DMA 传输。 (使用 Linux 2.6.18-128.el5 #1 SMP)
我的硬件有一个 API 堆栈+内核驱动程序,可以为我做到这一点,但它非常非常慢!
如果我使用 API 创建 DMA 传输,它会在系统 RAM 中分配一些非常高的内存(例如,一次运行时为 0x7373a6f8)。 (我有设备的 ICD,所以有一个内存映射 mmap,这就是我如何找到这个地址,以及最终我如何设置为我自己的地址,因此 /dev/mem在下面的地图中)
我似乎无法在这个高地址周围映射内存,大概是因为它超出了我的虚拟内存空间并且我被内核阻止了?
我想要做的就是使用(映射)给定的这个地址,这样我就可以读/写它,或者创建我自己的可以读/写的物理内存。
# cat /proc/iomem
00000000-0009fbff : System RAM
00000000-00000000 : Crash kernel
000a0000-000bffff : Video RAM area
000c0000-000c7fff : Video ROM
000f0000-000fffff : System ROM
00100000-7fd64fff : System RAM # Is this all of /dev/mem?
00400000-00612916 : Kernel code
00612917-006ef9db : Kernel data
# cat /proc/3450/maps
08207000-08228000 rw-p 08207000 00:00 0 [heap]
b7e7b000-b7f85000 rw-p b7e7b000 00:00 0
b7f89000-b7f8a000 rw-p b7f89000 00:00 0
b7f8a000-b7f8b000 rw-s 80114000 00:11 1541 /dev/mem
b7f8b000-b7f8d000 rw-p b7f8b000 00:00 0
bff70000-bff85000 rw-p bffea000 00:00 0 [stack]
I want to create some memory to use for DMA transfers. (Using Linux 2.6.18-128.el5 #1 SMP)
I have a API stack+kernel driver for my H/W that can do this for me, but its very very slow!
If I use the API to create a DMA transfer, it allocates some memory very high up in System RAM (eg 0x7373a6f8 on one run). (I have the ICD of the device, so have a memory map mmap'd over, this is how I can find this address out, and how in the end I want to SET to my own address, and hence the /dev/mem in the maps below)
I cannot seem to be able to mmap memory around this high address, presumably as its out of my virtual memory space and im being blocked by the kernel?
What I want to be able to do is either use (map) this address given, so I can read/write to it, OR create my own physical memory that I can read/write to.
# cat /proc/iomem
00000000-0009fbff : System RAM
00000000-00000000 : Crash kernel
000a0000-000bffff : Video RAM area
000c0000-000c7fff : Video ROM
000f0000-000fffff : System ROM
00100000-7fd64fff : System RAM # Is this all of /dev/mem?
00400000-00612916 : Kernel code
00612917-006ef9db : Kernel data
# cat /proc/3450/maps
08207000-08228000 rw-p 08207000 00:00 0 [heap]
b7e7b000-b7f85000 rw-p b7e7b000 00:00 0
b7f89000-b7f8a000 rw-p b7f89000 00:00 0
b7f8a000-b7f8b000 rw-s 80114000 00:11 1541 /dev/mem
b7f8b000-b7f8d000 rw-p b7f8b000 00:00 0
bff70000-bff85000 rw-p bffea000 00:00 0 [stack]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确的话,您有一个表现不佳的设备驱动程序,并且您正在尝试通过从用户空间手动分配物理 RAM 来解决这个问题?您是否有理由对修复驱动程序不感兴趣?
这听起来像是一个非常奇怪的请求,大多数人都不会认为这是一个正确的解决方案。我怀疑如果您正在解决潜在的驱动程序问题,您会得到更多帮助。
(从上面的评论复制。)
If I'm understanding you correctly, you have a device driver that's behaving poorly, and you're trying to work around that by manually allocating physical RAM from userspace? Is there a reason you're not interested in fixing the driver instead?
This sounds like a very odd request, not something that would be considered a proper fix by most people. I suspect you'd get more help if you were working on the underlying driver problem.
(copied from comment above.)