64비트 AVStream 드라이버에서 DMA 지원

AVStream은 32비트 및 64비트 주소 지정 가능 디바이스에서 DMA를 지원합니다.

Win64 플랫폼용으로 컴파일된 모든 드라이버는 KsDeviceRegisterAdapterObject 대신 IKsDeviceFunctions::RegisterAdapterObjectEx를 사용해야 합니다.

IKsDeviceFunctions::RegisterAdapterObjectEx 는 Microsoft Windows Server 2003 SP1 이상에서만 사용할 수 있습니다.

다음 코드 예제에서는 x64 기반 클라이언트 릴리스와 32비트 플랫폼 모두에서 DMA를 지원하는 방법을 보여 줍니다.

NTSTATUS MyDeviceStart (...) {
// Get the DMA adapter object and store it in the Context member of the I/O stack location.
Context -> AdapterObject = IoGetDmaAdapter (
Device -> PhysicalDeviceObject,
&DeviceDesc,
&Context -> NumberOfMapRegisters
);

PUNKNOWN DeviceUnk =
KsDeviceGetOuterUnknown (
Device
);

// Register the DMA adapter with AVStream
IKsDeviceFunctions *DeviceFunctions;
NTSTATUS Status = DeviceUnk -> QueryInterface (
__uuidof (IKsDeviceFunctions),
(PVOID *)&DeviceFunctions
);

// Conditionally, call IksDeviceFunctions::RegisterAdapterObjectEx, 
// which will not break downlevel load compatibility.

if (NT_SUCCESS (Status)) {
DeviceFunctions -> RegisterAdapterObjectEx (
Context -> AdapterObject,
&DeviceDesc,
Context -> NumMapRegisters,
MAX_MAPPING,
sizeof (KSMAPPING)
);
DeviceFunctions -> Release ();
}

// If this call fails, call KsDeviceRegisterAdapterObject to
// preserve downlevel load compatibility.
else {
KsDeviceRegisterAdapterObject (
Device,
Context -> AdapterObject,
MAX_MAPPING,
sizeof (KSMAPPING)
);
}
...

이 코드 예제는 64비트 및 32비트 플랫폼에서 작동합니다. 드라이버가 IKsDeviceFunctions::RegisterAdapterObjectEx를 찾지 못하면 여전히 KsDeviceRegisterAdapter를 호출합니다.

또한 64비트 AVStream 드라이버를 작성할 때 보유되는 동시 프레임 잠금 수를 최소화합니다. AVStream은 미니드라이버가 프레임을 처음 잠길 때 분산/수집 매핑을 생성하므로 이 지침을 따르지 않으면 드라이버에 리소스가 부족할 수 있습니다. 특히 32비트 카드 있는 Win64 플랫폼에서 실행할 드라이버를 작성하는 경우 메모리 부족 버퍼가 제한된 리소스이므로 동시 잠금 수를 늘리면 잠금이 실패할 가능성이 높아집니다.