阅读:1573回复:12
如何分配一片连续的物理内存?
我想在driver里面分配一片连续的物理内存(大约5M左右),用于DMA传输。各位高手给点意见和建议,例子或相关函数均可!多谢!
|
|
最新喜欢:![]() |
沙发#
发布于:2002-12-16 09:39
MmAllocateContiguousMemory(
IN ULONG NumberOfBytes, IN PHYSICAL_ADDRESS HighestAcceptableAddress) 这个函数用过? MmAllocateContiguousMemory can be called to allocate a contiguous block of physical memory for a long-term internal buffer, usually from the DriverEntry routine.A device driver that must use contiguous memory should allocate only what it needs during driver initialization because nonpaged pool is likely to become fragmented as the system runs. Such a driver must deallocate the memory if it is unloaded. Contiguous allocations are aligned on an integral multiple of the processor\'s data-cache-line size to prevent cache and coherency problems OK? 如果认为有价值,就不要吝啬了,给点分吧。 |
|
|
板凳#
发布于:2002-12-16 10:23
实际上现在我们只得到了一个虚拟地址,可是在DMA传输的时候我们用到的是逻辑地址,那么又如何才能得到这个虚拟地址对应的逻辑地址呢?
|
|
地板#
发布于:2002-12-16 10:25
既然我已经贴出了要给的分数,怎么会吝啬呢?只要你回答得好,绝对给分! :D :D :D
|
|
地下室#
发布于:2002-12-16 14:24
你一次都说完好不好?
可以进行地址转换呀,或者利用函数MmGetMdlVirtualAddress。你试试。 |
|
|
5楼#
发布于:2003-01-02 19:10
赫赫,dma用的时物理地址
|
|
|
6楼#
发布于:2003-01-02 21:08
我只在miniport里用ScsiPortGetPhysicalAddress干过,不过可能对你没帮助,在DDK文档里找找看?...
|
|
7楼#
发布于:2003-01-02 21:11
哦,用这个MmGetPhysicalAddress
|
|
8楼#
发布于:2003-01-02 22:19
MmAllocateContiguousMemory()
MmGetPhysicalAddress() IoAllocateMdl() MmBuildMdlForNonPagedPool() 什么地址都可以有了。 |
|
9楼#
发布于:2003-01-03 12:21
DMA不一定要在物理内存里面分连续的呀。art baker的那本书。
|
|
10楼#
发布于:2003-01-03 13:24
用Mm系列函数分配的物理连续的内存,在DMA传输时是没有问题的。在用其对应的逻辑地址进行内存COPY时在NT架构的OS上速度极慢,要注意。
|
|
11楼#
发布于:2003-01-07 19:12
请问高手如何才能快呢?我的应用程序是用基地址加偏移量访问的,还有mdl的大小有限制吗?
|
|
12楼#
发布于:2003-01-08 09:19
各位的方法我试过了,用MmAllocateContiguousMemory()在Win2k下总是得到NULL返回值!分配的大小已经小到几K,还是不行!难道我还有什么工作没有做?
|
|