Allocating Physical Memory Block for PCI Base Address Regisrer Mapping

Posted: 11-25-2008, 01:08 AM
Hi Everyone,

In my current project, I have a requirement to map a piece of physical
memory into one of the PCI base address register. This BAR maps the
inbound PCI cycles to the local memory of this board. This PCI device
do not support DMA. I have added the following code in the AddDevice
function for this PCI WDM Driver.

LowestAcceptableAddress.QuadPart = 0x0000000000000000;
HighestAcceptableAddress.QuadPart = 0x00000000FFFFFFFF;
BoundaryAddressMultiple.QuadPart = 0x0000000000000000;

fdoData->pNPVirtualMemory =
(PULONG)MmAllocateContiguousMemorySpecifyCache(
0x10000,
LowestAcceptableAddress,
HighestAcceptableAddress,
BoundaryAddressMultiple,
MmNonCached
);

fdoData->pNPPhysicalMemory = MmGetPhysicalAddress(
fdoData->pNPVirtualMemory);
PI7C9X110DebugPrint(INFO,
"NP MEMORY VA:0x%x PA:0x%x\n",
fdoData->pNPVirtualMemory,fdoData->pNPPhysicalMemory);

Note:
fdoData->pNPVirtualMemory is declared as PULONG
fdoData->pNPPhysicalMemory is declared as PHYSICAL_ADDRESS


I plug in the value in fdoData->pNPPhysicalMemory variable to the PCI
Device BAR. But somehow inbound mapping still don't seem to work.

One of the question is, is MmGetPhysicalAddress really returning a
physical address of the memory that can be used with PCI devices. I see
that in places in MSDN, not to use the physical address returned by
MmGetPhysicalAddress for DMA. Even though I am not using DMA, does this
statement still apply to my design?

Below is what I get from windbg for the pool, which says 0x10000 is my
physical address for the non-paged pool.

Windbg Output:
PI7C9X110: NP MEMORY VA:0xf6a21000 PA:0x10000

Thanks in Advance,

Boby
Reply With Quote

Responses to "Allocating Physical Memory Block for PCI Base Address Regisrer Mapping"

 
LinkBack Thread Tools Display Modes
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating Physical Address of users Virtual Memory John Windows XP Device Drivers 0 11-30-2007 07:47 PM
physical to logical memry mapping ma Windows XP Device Drivers 0 01-27-2005 12:11 AM
Allocating memory Milagros_Ramos@adobeforums.com Mac Applications 4 05-21-2004 04:08 PM
RSM cannot manage Physical Drive 1: corrupt data base Bob Windows XP Hardware 1 10-02-2003 11:58 AM