I am a novice in writing drivers. I am trying to develop waveRT audio driver for windows 7.
I am looking at the code sample for ac97 audio device (provided with win ddk) which includes sample for writing waveRT drivers.
I am quite confused with the mdl (memory descriptor list) and bdl(buffer descriptor list) code in stream.h and stream.cpp files.
I understand that the IMiniportWaveRT stream interface requires us to implement AllocateAudioBuffer method. This method allocates a memory descriptor list using the AllocateContiguousPagesForMdl(since the device in the sample code does not support scatter-gather) method of PORTWAVERTSTREAM interface, an instance of which is passed to the driver while creating a new stream. After this memory allocation succeeds, BDL(buffer descriptor list) is programmed, and this is where I get confused. Following is the code snippet which does that:
PMDL audioBufferMdl = m_pPortStream->AllocateContiguousPagesForMdl (low, high, requestedSize);
// Program the BDL
for (UINT loop = 0; loop < MAX_BDL_ENTRIES; loop++)
BDList[loop].dwPtrToPhyAddress = m_pPortStream->GetPhysicalPageAddress (audioBufferMdl, 0).LowPart;
BDList[loop].wLength = (WORD)requestedSize/2;
if ((loop == MAX_BDL_ENTRIES / 2) || (loop == MAX_BDL_ENTRIES - 1))
BDList[loop].wPolicyBits = IOC_ENABLE;
BDList[loop].wPolicyBits = 0;
I don't understand why while getting the physical address of the Mdl, we always use the index as 0? Why all the entries of BDList point to same physical address?
Also, it would be great if anyone can give me any pointers to understand the concepts behind MDL and BDL wrt waveRT audio drivers.
Thanks in advance!