WDDM display driver help

i am developing WDDM driver. I have few questions:

  1. in miniport driver all dispatch routines are compulsory to implement or not ?
  2. my driver gets call of addDevice entry point after driverentry called. i am allocating context for my device and returing context address as per documentation of addDevice but after that call it immediately calls removeDevice and unloadDriver routines.

code for adddevice is as follow:

NTSTATUS ntStatus=STATUS_SUCCESS;
PHW_EXTENSION PDevExt=NULL;

PAGED_CODE();

dbgdrv(“SWDxAddDevice”);

*MiniportDeviceContext=NULL;

if (! ARGUMENT_PRESENT(PDevObj) ||
! ARGUMENT_PRESENT(MiniportDeviceContext)) {
dbgdrv(“add_device args !present”);
return STATUS_INVALID_PARAMETER;
}

PDevExt=ExAllocatePoolWithTag(NonPagedPool,sizeof(HW_EXTENSION),DRIVER_TAG);

dbgdrv(“New allocated dev_context 0x%x”,PDevExt);

if(PDevExt==NULL) {
dbgdrv(“mem alloc failed”);
ntStatus=STATUS_INSUFFICIENT_RESOURCES;
return ntStatus;
}

// attach this device object to the physical device object’s stack…

*MiniportDeviceContext=PDevExt;

return ntStatus;

There are no errors while this execution though it fails…

Whether any inf file entry is needed for further call of queryinterface , queryadapterinfo ?

Why this happens i have no idea about it ? any help would be greatful help for me.

hi techies,

now i am trying to load my driver for the existing display adapter and suddenly it gets call for queryinterface, queryadapterinfo, startdevice

why this happens that when display adapter of my pc is present i can’t load my virtual display adapter ?

i read that win7 supports heterogeneous graphics adapters simultaneously.

am i right ? or some configuration or some thing missing , please give your reviews.

i thought at least some is there who faced these problems or can answer my questions :slight_smile:

What makes you think this is an error or preventing you from loading your driver?

Greg

xxxxx@slscorp.com wrote:

From: xxxxx@slscorp.com
To: “Windows System Software Devs Interest List”
Subject: RE:[ntdev] WDDM display driver help
Date: Fri, 2 Jul 2010 10:34:15 -0400 (EDT)

hi techies,

now i am trying to load my driver for the existing display adapter and suddenly it gets call for queryinterface, queryadapterinfo, startdevice

why this happens that when display adapter of my pc is present i can’t load my virtual display adapter ?

i read that win7 supports heterogeneous graphics adapters simultaneously.

am i right ? or some configuration or some thing missing , please give your reviews.

i thought at least some is there who faced these problems or can answer my questions :slight_smile:


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

i thought it is preventing from loading my virtual adapter driver.

hi buddies,

i am getting call in the following order and messages are as follows:

SWDDM:DriverEntry

KDTARGET: Refreshing KD connection

SWDDM:driver entry ret_status 0

SWDDM:SWDxAddDevice
SWDDM:New allocated dev_context 0x84e0db00

SWDDM:AtiQueryInterface

SWDDM:Interface GUID -> 2564aa4f-dddb-4495
-b4-97-6a-d4-a8-41-63-d7

SWDDM:AtiQueryInterface

SWDDM:Interface GUID -> bf4672de-6b4e-4be4
-a3-25-68-a9-1e-a4-9c-9SWDDM:!I2C interface

SWDDM:SWDxStartDevice

SWDDM:SWDxQueryChildRelations

SWDDM:D3DDDIQueryAdapterInfo
SWDDM:DXGKQAITYPE_DRIVERCAPS

SWDDM:D3DDDIQueryAdapterInfo Over

SWDDM:SWDxStopDevice

SWDDM:SWDxRemoveDevice 0x84e0db00

SWDDM:SWDxUnloadDriver

i am going to implemnt I2C interface for adapter. so, when it queries for queryInterface other than I2C my driver returns STATUS_NOT_SUPPORTED

it asks for queryAdapterInfo for adapter_capability but after that it stops the device and unloading driver

returning child descriptor for video output device for 1 child and number of video sources are 1 returned in start_device.

i stuck here can any body help please?? :slight_smile:

i am refering R200 the and only WDDM sample provided by microsoft.

hi guys,

its the query_adapter_info during query_capability we should return version number of wddm while i was not passing it because i was refering to structure defined in wdk help while i see that structure definition in .h file it was different.

so , ultimately now i am getting call for createDevice , createDeviceContext and after that queryfor segment descriptor but it crashes after that.

i have one question:

i am implementing virtual adapter. is it necessary to pass physical memory address to video memory manager?
and if not whether i have to implement memory segment or aperture segment ?

thanks for your suggestions.

xxxxx@slscorp.com wrote:

its the query_adapter_info during query_capability we should return version number of wddm while i was not passing it because i was refering to structure defined in wdk help while i see that structure definition in .h file it was different.

so , ultimately now i am getting call for createDevice , createDeviceContext and after that queryfor segment descriptor but it crashes after that.

You’re going to have to be more specific. There are very few people in
the world who have real-life experience with WDDM drivers. Most of
those who do are sequestered inside one of the 3 remaining companies
that are doing display drivers, and those companies don’t like them to
share what they know with their competition. Those of us who have done
the reading might be able to help you, but only if you are more specific
about exactly which callback you’re in and exactly which structure is
giving you trouble.

i have one question:

i am implementing virtual adapter. is it necessary to pass physical memory address to video memory manager?
and if not whether i have to implement memory segment or aperture segment ?

I believe that a WDDM driver is required to have a frame buffer.
Remember that a WDDM device is fundamentally expected to have a hardware
implementation of Direct3D. The model does not (as I understand it)
lend itself to virtual devices. That’s why we haven’t seen a lot of
WDDM mirror drivers.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi, Tim Roberts

That is to say, Virtual WDDM driver does’t support, Must be a XPDM driver if we want to develop a virtual display driver?

Best Regards.
Allen

hi tim roberts,

thanks for ur step for helping. and as you told that known persons hiding their knowledge but i am sure if we will do it then definately we will share it with the community to intersted peoples…

i am using WDK 7600.16385.0 kit and vista x86 build environment for driver compilation.

structure problem:

for query_adpater( DXGKQAITYPE_DRIVERCAPS) callback :
the structure _DXGK_DRIVERCAPS defined in wdk help is different from the _DXGK_DRIVERCAPS structure defined in d3dkmddi.h file of WDK 7600.16385.0 kit for extra support of win7.

that thing resolved by sending version number in WDDMVersion attribute.

//////////////////////

current problem:

currently i am getting call for QueryAdapterInfo( ) for query about segment descriptors.

during first call i am sending number of segments supported is 1.
during second call i am passing first descriptor for the first segment, which as follow:

[
my segment is virtual frame buffer, so i am using memory segment type,
size of segment is 8 MB,
i am implementing virtual adapter so i am allocating 8 MB from nonpaged area in RAM, and passing its physical address in the base address of segment descriptor, (getting physical address of my buffer by using API MmIoGetPhysicalAddress( ) which is stored in PDevExt->PSegmntInfo[i].SegPhyAddress )

]

pDxgkSegDesc[i].BaseAddress=PDevExt->PSegmntInfo[i].SegPhyAddress;
pDxgkSegDesc[i].CpuTranslatedAddress=PDevExt->PSegmntInfo[i].SegPhyAddress;
pDxgkSegDesc[i].Size=8*1024*1024; // for AGP it will be ignored
pDxgkSegDesc[i].NbOfBanks=0;
pDxgkSegDesc[i].pBankRangeTable=0;

//// for memory segment CommitLimit should be same as size of segment
pDxgkSegDesc[i].CommitLimit=8*1024*1024;
pDxgkSegDesc[i].Flags.Aperture=0x0;
pDxgkSegDesc[i].Flags.CpuVisible=1; // cpu visible virtual address, For AGP it has no meaning
pDxgkSegDesc[i].Flags.PopulatedFromSystemMemory=1;

after returning success in this call , it crashes with following dump information:

*******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************

PAGE_FAULT_IN_NONPAGED_AREA (50)
Invalid system memory was referenced. This cannot be protected by try-except,
it must be protected by a Probe. Typically the address is just plain bad or it
is pointing at freed memory.
Arguments:
Arg1: ffff0002, memory referenced.
Arg2: 00000001, value 0 = read operation, 1 = write operation.
Arg3: 82a49ca0, If non-zero, the instruction address which referenced the bad memory
address.
Arg4: 00000000, (reserved)

Debugging Details:

***** Kernel symbols are WRONG. Please fix symbols to do analysis.

*************************************************************************
*** ***
*** ***
*** Your debugger is not using the correct symbols ***
*** ***
*** In order for this command to work properly, your symbol path ***
*** must point to .pdb files that have full type information. ***
*** ***
*** Certain .pdb files (such as the public OS symbols) do not ***
*** contain the required information. Contact the group that ***
*** provided you with these symbols if you need this command to ***
*** work. ***
*** ***
*** Type referenced: nt!_KPRCB ***
*** ***
*************************************************************************
*************************************************************************
*** ***
*** ***
*** Your debugger is not using the correct symbols ***
*** ***
*** In order for this command to work properly, your symbol path ***
*** must point to .pdb files that have full type information. ***
*** ***
*** Certain .pdb files (such as the public OS symbols) do not ***
*** contain the required information. Contact the group that ***
*** provided you with these symbols if you need this command to ***
*** work. ***
*** ***
*** Type referenced: nt!_KPRCB ***
*** ***
*************************************************************************
*************************************************************************
*** ***
*** ***
*** Your debugger is not using the correct symbols ***
*** ***
*** In order for this command to work properly, your symbol path ***
*** must point to .pdb files that have full type information. ***
*** ***
*** Certain .pdb files (such as the public OS symbols) do not ***
*** contain the required information. Contact the group that ***
*** provided you with these symbols if you need this command to ***
*** work. ***
*** ***
*** Type referenced: nt!_KPRCB ***
*** ***
*************************************************************************
*************************************************************************
*** ***
*** ***
*** Your debugger is not using the correct symbols ***
*** ***
*** In order for this command to work properly, your symbol path ***
*** must point to .pdb files that have full type information. ***
*** ***
*** Certain .pdb files (such as the public OS symbols) do not ***
*** contain the required information. Contact the group that ***
*** provided you with these symbols if you need this command to ***
*** work. ***
*** ***
*** Type referenced: kernel32!pNlsUserInfo ***
*** ***
*************************************************************************
*************************************************************************
*** ***
*** ***
*** Your debugger is not using the correct symbols ***
*** ***
*** In order for this command to work properly, your symbol path ***
*** must point to .pdb files that have full type information. ***
*** ***
*** Certain .pdb files (such as the public OS symbols) do not ***
*** contain the required information. Contact the group that ***
*** provided you with these symbols if you need this command to ***
*** work. ***
*** ***
*** Type referenced: kernel32!pNlsUserInfo ***
*** ***
*************************************************************************

ADDITIONAL_DEBUG_TEXT:
Use ‘!findthebuild’ command to search for the target build information.
If the build information is available, run ‘!findthebuild -s ; .reload’ to set symbol path and load symbols.

MODULE_NAME: dxgkrnl

FAULTING_MODULE: 82a03000 nt

DEBUG_FLR_IMAGE_TIMESTAMP: 497025ce

WRITE_ADDRESS: unable to get nt!MmSpecialPoolStart
unable to get nt!MmSpecialPoolEnd
unable to get nt!MmPoolCodeStart
unable to get nt!MmPoolCodeEnd
ffff0002

FAULTING_IP:
nt!memcpy+a0
82a49ca0 8807 mov byte ptr [edi],al

MM_INTERNAL_CODE: 0

DEFAULT_BUCKET_ID: VISTA_DRIVER_FAULT

BUGCHECK_STR: 0x50

CURRENT_IRQL: 0

LAST_CONTROL_TRANSFER: from 82af0aaf to 82a902fc

STACK_TEXT:
WARNING: Stack unwind information not available. Following frames may be wrong.
8a34525c 82af0aaf 00000003 84e5b1a8 00000000 nt!DbgBreakPointWithStatus+0x4
8a345628 82a9b97d 00000050 ffff0002 00000001 nt!KeBugCheckEx+0xc7b
8a3456b4 82a51800 00000001 ffff0002 00000000 nt!IoGetIoPriorityHint+0x3cb
8a3456ec 82c4cca2 82a4e66a 00000000 00000000 nt!Kei386EoiHelper+0x2788
8a345748 82c01e9b ffff0002 8dd517a8 00000004 nt!RtlUpcaseUnicodeChar+0xfff
8a345768 82c01488 8dd517a8 8a345928 c0000023 nt!RtlQueryRegistryValues+0x9c6
8a345790 82c017f2 00000001 00000000 8ae3807e nt!NtNotifyChangeDirectoryFile+0x756
8a3457f8 8b37b9aa 00000000 8b8b7600 8a345820 nt!RtlQueryRegistryValues+0x31d
8a345858 8b3a584b 84eb2920 8b3536c8 8a345928 dxgkrnl!DpiGetDriverVersion+0x1b071
8a345940 8b3a7c18 8ae3807e 00000000 8ae381a4 dxgkrnl!DpiGetDriverVersion+0x44f12
8a345a30 8b3a7961 83e16000 8ae3807e 83e16000 dxgkrnl!DpiGetDriverVersion+0x472df
8a345a50 8b3a7683 83e16000 83e165c0 84eb0000 dxgkrnl!DpiGetDriverVersion+0x47028
8a345b1c 8b3a8ffb ffffeaae 00000000 8b39cac7 dxgkrnl!DpiGetDriverVersion+0x46d4a
8a345b38 8b3a8f79 84eb2920 8a345b4c 8dd461b0 dxgkrnl!DpiGetDriverVersion+0x486c2
8a345b50 8b39cf4e 84eb2920 84eb2f64 84fbbd68 dxgkrnl!DpiGetDriverVersion+0x48640
8a345c68 8b39ca0a 84eb2920 00000001 00000000 dxgkrnl!DpiGetDriverVersion+0x3c615
8a345c90 8b397b69 00000000 8ae3d9c8 00000044 dxgkrnl!DpiGetDriverVersion+0x3c0d1
8a345cb0 8ae3de09 8a345cc8 8eeb300c 00000001 dxgkrnl!DpiGetDriverVersion+0x37230
8a345cb8 8eeb300c 00000001 ffffc0bd 8a345d18 watchdog!SMgrNotifySessionChange+0x19
8a345cc8 8eea67fa 00000001 00000000 850b8b80 win32k!EngFntCacheLookUp+0x5eee
8a345d18 8eea67bc 0023fa48 8a345d34 82a4e66a win32k!EngWideCharToMultiByte+0x3be6
8a345d24 82a4e66a 00000044 00000048 0023fa64 win32k!EngWideCharToMultiByte+0x3ba8
8a345d70 77afaf8d 001718d4 00000001 ffffffff nt!ZwYieldExecution+0xb4e
8a345d80 00000000 001f0003 77ae7c70 00000000 ntdll!RtlpStartWaitThread+0xd

STACK_COMMAND: kb

FOLLOWUP_IP:
dxgkrnl!DpiGetDriverVersion+1b071
8b37b9aa 8bf8 mov edi,eax

SYMBOL_STACK_INDEX: 8
SYMBOL_NAME: dxgkrnl!DpiGetDriverVersion+1b071
FOLLOWUP_NAME: MachineOwner
IMAGE_NAME: dxgkrnl.sys
BUCKET_ID: WRONG_SYMBOLS
Followup: MachineOwner

Q.1
is this a proper way for virtual adapter to give segment physical address of allocated buffer by allocating segment in system ram ? or any other way we can do it ?

Q.2
is there another way to load my virtual driver because when i am trying to load virtual driver using hdwwiz it calls addDevice () callback and after that it calls for REmoveDevice() and unloadDriver () callbacks. thats why i am using Q.3 method for driver loading.

Q.3
i am updating driver of exising standard VGA Adapter in my PC , which is a PCI based physical device and i am trying to load virtual adapter driver for it by using physical memroy for segment that’s why it is failing ?

thanks again to people sharing their knowledge and experience in WDDM.

xxxxx@sina.com wrote:

That is to say, Virtual WDDM driver does’t support, Must be a XPDM driver if we want to develop a virtual display driver?

Well, that depends on what you’re trying to achieve. No one creates a
virtual display driver just for the exercise. You’re developing it to
solve some problem.

As I said, the operating system expects a WDDM driver to implement
Direct3D. If you want to simulate D3D in your driver, you should be
able to do it. It’s a lot easier to create a virtual driver in XPDM.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

xxxxx@slscorp.com wrote:

current problem:

currently i am getting call for QueryAdapterInfo( ) for query about segment descriptors.

during first call i am sending number of segments supported is 1.
during second call i am passing first descriptor for the first segment, which as follow:

[
my segment is virtual frame buffer, so i am using memory segment type,
size of segment is 8 MB,
i am implementing virtual adapter so i am allocating 8 MB from nonpaged area in RAM, and passing its physical address in the base address of segment descriptor, (getting physical address of my buffer by using API MmIoGetPhysicalAddress( ) which is stored in PDevExt->PSegmntInfo[i].SegPhyAddress )
]

How are you allocating the memory? You are assuming that the pages in
your 8MB region were assigned contiguous physical addresses. Unless you
used AllocateCommonBuffer, there’s no guarantee of that. The first time
someone write beyond the first page, they’re likely writing to random
pages in memory.

Q.1
is this a proper way for virtual adapter to give segment physical address of allocated buffer by allocating segment in system ram ? or any other way we can do it ?

You are blazing new ground here. I don’t think there are any “best
practices” in this area yet.

Q.2
is there another way to load my virtual driver because when i am trying to load virtual driver using hdwwiz it calls addDevice () callback and after that it calls for REmoveDevice() and unloadDriver () callbacks. thats why i am using Q.3 method for driver loading.

Are you running Vista or Windows 7? Vista will not run two different
WDDM drivers. Only one at a time is allowed. If you’re on Windows 7,
then you probably have some problem in the way you set up the registry
to configure your device. Are you looking at the R200 sample in the old
WDK?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Tim Roberts,

Thank you very much,
Yes, It’s easier to create a virtual driver in XPDM.
and R200 sample is in the old WDK(DDK for Vista), I can’t find the new sample in Windows 7 DDK, R200 be removed on Win7 DDK, Where can I find a new sample? Thanks a lot

Best Regards,
Allen

xxxxx@sina.com wrote:

Yes, It’s easier to create a virtual driver in XPDM.
and R200 sample is in the old WDK(DDK for Vista), I can’t find the new sample in Windows 7 DDK, R200 be removed on Win7 DDK, Where can I find a new sample? Thanks a lot

There is no new sample. As near as I can tell, all of the companies who
are seriously developing WDDM drivers (and that list contains fewer than
5 companies worldwide) have teams of people in Redmond who are working
directly with the display driver folks to get their information. The
lack of a good sample is one of the key gaps in the WDK.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Tim Roberts, Thank you.

hi tim sir,

i am using win7. yes i am refering R200 sample .my registery settings are same as R200 sample’s inf file.

How are you allocating the memory? You are assuming that the pages in
your 8MB region were assigned contiguous physical addresses. Unless you
used AllocateCommonBuffer, there’s no guarantee of that. The first time
someone write beyond the first page, they’re likely writing to random
pages in memory.

thanks for upgrading my knowledge @ this buffer concept.
but i thought after querying for segment descriptors dx doen’t immediately writes to it.

ok, one good news, my crash problem solved ,

in the old one during second call to queryAdapterInfo for segment information query the DXGK_QUERYSEGMENTOUT->PagingBufferSegmentId=0
mentioned.

now i am passing paginBufferSegId=1 and it doen’t crash now but after this call success my driver’s StopDevice callback called and it unloads my driver.

also in d3kmddi.h 0 is defined as DXGK_SEGMENT_ID_INVALID. So, i thought u can’t assign zero id to any segment id.

the information i passed in segment_descriptor is same as mentioned in previous mail.

whether i have to implement physical fake device for success of this project ?

xxxxx@slscorp.com wrote:

whether i have to implement physical fake device for success of this project ?

Well, isn’t that exactly what you’re doing here? In the final analysis,
the operating system doesn’t care whether there really is hardware at
the bottom level or not. Your driver simply has to behave in a way that
allows the operating system to believe there is hardware.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

ya u r right but i am asking whether driver has to show related to PCI interface to OS ? like frame buffer address in PCI address space. now i am getting call for segment desc but after calling queryAdapterInfo for segment desc query 2 times it crashes …

where can we find infomration about necessary registery entry settings for WDDM drivers?

xxxxx@slscorp.com wrote:

ya u r right but i am asking whether driver has to show related to PCI interface to OS ? like frame buffer address in PCI address space. now i am getting call for segment desc but after calling queryAdapterInfo for segment desc query 2 times it crashes …

There has to be a frame buffer. It doesn’t have to be in PCI address space.

I have seen one posting that implied that a WDDM device must have an
interrupt, but I’m dubious about that. I don’t see how that would be
enforced.

where can we find infomration about necessary registery entry settings for WDDM drivers?

I don’t think the requirements are very different from an XPDM driver.
If there is not enough information in the samples or in MSDN, then you
need to contact Microsoft directly.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

hi tim,

i have tested two options of memory segment support of virtual adpater:

  1. frame buffer , means aperture flag is disable of segment descriptor’s flag member.
  2. also tried with setting of aperture flag to true and saying that my adapter will support aperture space segment.

results of tests:

case 1. after queryAdapterInfo(DRIVER_CAPABILITIES) it calls’ drivers stopDevice and unloadDriver callback interfaces.
case 2. immediately after querying segment descriptors it calls driver’s BuildPagingBuffer(MAP_APERTURE_SPACE_SEGMENT for primary surface because at that call hDevice is null) interface but fails(PAGE_FAULT_IN_NON_PAGED_AREA) because i am not doing nothing in it and just returing success.

i don’t know why it stops my driver in option 1 ? has any body idea @ this one ?

i have other questions and doubts also :

let me clear what i understand first…

aperture space segment has no physical pages for backing storage (RAM). its just an address space which will be used by video mem manager to map buffers. video mem manger will call buildPagingBuffer() function to map buffers into this aperture space segment by describing mdl of buffrer which has physical pages allocated in RAM.
so, i have to map mdl buffer’s physical pages to driver’s aperture space segment so that h/w rendrer will use that system buffer for rendering or i m wrong here ?

if write then how to map physical pages to my aperture segment virtual address ?

if wrong please correct me…

Are study DisplayLink?
It looks that it is work well.

Allen