I am trying to Map physical address of my aureal sound card to a virtual address using MmMapIoSpace. I am using the code below which is not working as expected. The MmMapIoSpace always returns a 00000000 pointer. Logs from DebugView are also given..
CODE
NTSTATUS CAdapterCommon::Init ( IN PRESOURCELIST ResourceList, IN PDEVICE_OBJECT DeviceObject ) { PAGED_CODE();
ASSERT(ResourceList);
ASSERT(DeviceObject);
NTSTATUS ntStatus = STATUS_SUCCESS;
DPF_ENTER(("[CAdapterCommon::Aureal Init]"));
PDWORD m_pCodecBase; // The Aureal I/O port address.
PUCHAR m_pBusMasterBase; // The Aureal 2nd I/O port address.
PDWORD m_pmmio; // The Aureal Memory range mapped to virtual memory.
m_pDeviceObject = DeviceObject;
ASSERT (ResourceList->FindTranslatedPort (0));
m_pCodecBase = (PDWORD)ResourceList->FindTranslatedPort (0)->
u.Port.Start.QuadPart;
ASSERT (ResourceList->FindTranslatedPort (1));
m_pBusMasterBase = (PUCHAR)ResourceList->FindTranslatedPort (1)->
u.Port.Start.QuadPart;
PCM_PARTIAL_RESOURCE_DESCRIPTOR resource;
PHYSICAL_ADDRESS PhysAddr;
resource=ResourceList->FindTranslatedMemory(0);
//resource=ResourceList->FindUntranslatedMemory(0);
PhysAddr=resource->u.Memory.Start;
**m_pmmio=(PDWORD) MmMapIoSpace(resource->u.Memory.Start, resource->u.Memory.Length, MmNonCached);**
//MmCached MmNonCached
DPF_ENTER (("Aureal Configuration:\n"
" Bus Master = 0x%p\n"
" Codec = 0x%p\n"
" Physical Add= 0x%p\n"
" Virtual Add= 0x%p\n",
m_pBusMasterBase, m_pCodecBase, PhysAddr, m_pmmio));
-----------------------------------CODE------------------------------------
-----------------------------------LOGS------------------------------------ 00000000 0.00000000 MSVAD: 00000001 0.00000482 [DriverEntry] 00000002 0.00000693 00000003 0.00025595 MSVAD: 00000004 0.00025957 [AddDevice] 00000005 0.00026108 00000006 0.02436720 MSVAD: 00000007 0.02437443 [StartDevice] 00000008 0.02437655 00000009 0.02437926 MSVAD: 00000010 0.02438197 [ValidateResources] 00000011 0.02438378 00000012 0.02438680 MSVAD: 00000013 0.02439493 Aureal configuration: IO count: 2 00000014 0.02439554 IRQ count: 1 00000015 0.02439614 DMA count: 0 00000016 0.02439674 Memories count: 1 00000017 0.02439735 BusNumbers count: 0 00000018 0.02439795 DevicePrivates count: 0 00000019 0.02439855 00000020 0.02440036 00000021 0.02441483 MSVAD: 00000022 0.02442056 [CAdapterCommon::Aureal Init] 00000023 0.02442267 00000024 0.02443322 MSVAD: 00000025 0.02444196 Aureal Configuration: 00000026 0.02444257 Bus Master = 0x00001040 00000027 0.02444317 Codec = 0x00001048 00000028 0.02444408 Physical Add= 0x90000000 00000029 0.02444468 Virtual Add= 0x00000000 00000030 0.02444649 00000031 0.02444890 MSVAD: 00000032 0.02445191 [CAdapterCommon::InitAurealHW] -----------------------------------LOGS------------------------------------
The properties of the pci card AU8810 are (As seen from Device Manager) Memory Range 90000000 - 9003FFFF I/O Range 1048 - 104F I/O Range 1040 - 1047
resource->u.Memory.Start is Ok 90000000 resource->u.Memory.Length is OK 262144 (256K)
Virtual Add= 0x00000000 is always not Ok.
Anybody please help....