From: Don Burn on
StartDevice is just a common name for the code to handle IRP_MN_START_DEVICE
which is a sub-code of IRP_MJ_PNP. It can have anyname you want or be part
of a more general routine handling IRP_MJ_PNP. Look for IRP_MN_START_DEVICE
in samples and you will get the gist of it.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply



"krby_xtrm" <kerby.martino(a)gmail.com> wrote in message
news:1135791066.365035.193170(a)g47g2000cwa.googlegroups.com...
>i see.
> but how does a StartDevice() is called?coz i cant find in many driver
> samples that the routine is assigned or called?
>
> -krby_xtrm-
>


From: Ali on
Isn't StartDevice wdm version of CreateDispatch or DisatchIO? in good
nt days without IRP_MJ_PNP.

From: Don Burn on
You are thinking of StartIo something totally different, and only used by
slow devices.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply



"Ali" <abdulrazaq(a)gmail.com> wrote in message
news:1135794771.114669.113930(a)g43g2000cwa.googlegroups.com...
> Isn't StartDevice wdm version of CreateDispatch or DisatchIO? in good
> nt days without IRP_MJ_PNP.
>


From: krby_xtrm on
Yes. I think I know that, I have minor function IRP_MN_START_DEVICE in
my Pnp Dispatch routine.

NTSTATUS PciWDMPnp (IN PDEVICE_OBJECT fdo, IN PIRP Irp)
{
....
ULONG MinorFunction = IrpStack->MinorFunction;
....
switch(MinorFunction)
{
case IRP_MN_START_DEVICE:
// we should check the allocated resource...
KdPrint((DRIVERNAME " - IRP_MN_START_DEVICE"));
//
break;
case IRP_MN_REMOVE_DEVICE:
KdPrint((DRIVERNAME " - IRP_MN_REMOVE_DEVICE"));
if(pdx->LowerDeviceObject)
IoDetachDevice(pdx->LowerDeviceObject);
IoDeleteDevice(fdo); // delete fdo
break;
}
....
}

and my start device:

NTSTATUS StartDevice(PDEVICE_OBJECT fdo, PCM_PARTIAL_RESOURCE_LIST raw,
PCM_PARTIAL_RESOURCE_LIST translated)
{
....
PHYSICAL_ADDRESS portbase;// base address of range
BOOLEAN gotport = FALSE;

PCM_PARTIAL_RESOURCE_DESCRIPTOR resource =
translated->PartialDescriptors;
ULONG nres = translated->Count;

for (ULONG i = 0; i < nres; ++i, ++resource)
{ // for each resource
switch (resource->Type)
{ // switch on resource type
case CmResourceTypePort:
portbase = resource->u.Port.Start;
pdx->nports = resource->u.Port.Length;
pdx->mappedport = (resource->Flags & CM_RESOURCE_PORT_IO) == 0;
gotport = TRUE;
break;
default:
KdPrint((DRIVERNAME " - Unexpected I/O resource type %d\n",
resource->Type));
break;
}
}
.....
}

From: Pavel A. on
Well it's your driver, you decide how to call your internal function from
PciWDMPnp.
Or just copy what the DDK samples do. To look up function
names in the sources - From Visual Studio:
Edit -> Find and replace -> Find in files

--PA

"krby_xtrm" wrote:
> Yes. I think I know that, I have minor function IRP_MN_START_DEVICE in
> my Pnp Dispatch routine.
>
> NTSTATUS PciWDMPnp (IN PDEVICE_OBJECT fdo, IN PIRP Irp)
> {
> ....
> ULONG MinorFunction = IrpStack->MinorFunction;
> ....
> switch(MinorFunction)
> {
> case IRP_MN_START_DEVICE:
> // we should check the allocated resource...
> KdPrint((DRIVERNAME " - IRP_MN_START_DEVICE"));
> //
> break;
> case IRP_MN_REMOVE_DEVICE:
> KdPrint((DRIVERNAME " - IRP_MN_REMOVE_DEVICE"));
> if(pdx->LowerDeviceObject)
> IoDetachDevice(pdx->LowerDeviceObject);
> IoDeleteDevice(fdo); // delete fdo
> break;
> }
> ....
> }
>
> and my start device:
>
> NTSTATUS StartDevice(PDEVICE_OBJECT fdo, PCM_PARTIAL_RESOURCE_LIST raw,
> PCM_PARTIAL_RESOURCE_LIST translated)
> {
> ....
> PHYSICAL_ADDRESS portbase;// base address of range
> BOOLEAN gotport = FALSE;
>
> PCM_PARTIAL_RESOURCE_DESCRIPTOR resource =
> translated->PartialDescriptors;
> ULONG nres = translated->Count;
>
> for (ULONG i = 0; i < nres; ++i, ++resource)
> { // for each resource
> switch (resource->Type)
> { // switch on resource type
> case CmResourceTypePort:
> portbase = resource->u.Port.Start;
> pdx->nports = resource->u.Port.Length;
> pdx->mappedport = (resource->Flags & CM_RESOURCE_PORT_IO) == 0;
> gotport = TRUE;
> break;
> default:
> KdPrint((DRIVERNAME " - Unexpected I/O resource type %d\n",
> resource->Type));
> break;
> }
> }
> .....
> }
>
>