Dispatch IRQL value

Hello ntdevs,

On NT4 I called MmAllocateContiguousMemory() in response to an
IRP_MJ_DEVICE_CONTROL call. It’s a problem to me that on Win2K this doesn’t
work (MmAllocateContiguousMemory returns null).

I see that Win2K MmAllocateContiguousMemory must be called at IRQL
PASSIVE_LEVEL, so I guess that’s the difference.

My driver is monolithic, so is that a highest-level or lowest-level driver?
From Win2k docs:

---------------------------- begin doc
Most drivers’ Dispatch routines are called in an arbitrary thread context
at IRQL PASSIVE_LEVEL, with the following exceptions:

Any highest-level driver’s Dispatch routines are called in the context of
the thread that originated the I/O request, which is commonly a user-mode
application thread.
In other words, the Dispatch routines of file system drivers and other
highest-level drivers are called in a nonarbitrary thread context at IRQL
PASSIVE_LEVEL.

The DispatchRead, DispatchWrite, and DispatchDeviceControl routines of
lowest-level device drivers and of intermediate drivers layered above them
in the system paging path, can be called at IRQL APC_LEVEL and in an
arbitrary thread context.
---------------------------- end doc

So I guess my DispatchDeviceControl routine is being called at IRQL
APC_LEVEL, but why? (The only application to use it is my own).
Is there a way around this?

[I’d like to save someone the time it takes to criticize allocating non-paged memory outside of DriverEntry(). Its only use is for extremely specialized hardware and controlled environments.]

Thank you all (generally, for list contents),
Justin


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

-----Original Message-----
From: Justin Schoenwald [mailto:xxxxx@cornell.edu]
Sent: Friday, August 17, 2001 3:29 PM
To: NT Developers Interest List
Subject: [ntdev] Dispatch IRQL value

[I’d like to save someone the time it takes to criticize allocating non-paged memory outside of DriverEntry(). Its only use is for extremely specialized hardware and controlled environments.]

Not criticizing, just questioning. Regardless of the environment, why is it
desirable to do this?


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

If your dispatch routine is called at > PASSIVE_LEVEL but you need to
perform some foul and depraved act that requires you to be at
PASSIVE_LEVEL then you need a worker thread that always runs at
PASSIVE_LEVEL to be your minion and do your bidding.

As in:

NTSTATUS
FrobnitzDispatchDeviceDoodle(DeviceObject, Birp)
{
… The usual crapola here

if (KeGetCurrentIrql() != PASSIVE_LEVEL) {

PIO_WORKITEM minion = IoAllocateWorkItem(DeviceObject);
if (minion == NULL) {
//
// notify the caller that the system is going to
// crash in a moment
//
Birp->IoStatus.Status = STATUS_WE_ARE_DOOMED;
IoCompleteRequest(Birp, IO_NO_INCREMENT);
return STATUS_WE_ARE_DOOMED;
}

Birp->IoStatus.Information = minion; // I said this was
depraved
IoMarkIrpPending(Birp);
IoQueueWorkItem(minion, FrobnitzWorkerDepravedAct,
CriticalWorkQueue, Birp);
return STATUS_PENDING;
}

//
// otherwise just do your depraved act here
//

… Whatever

return STATUS_SOMETHING_OR_OTHER;
}

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Justin
Schoenwald
Sent: Friday, August 17, 2001 6:29 PM
To: NT Developers Interest List
Subject: [ntdev] Dispatch IRQL value

Hello ntdevs,

On NT4 I called MmAllocateContiguousMemory() in response to
an IRP_MJ_DEVICE_CONTROL call. It’s a problem to me that on
Win2K this doesn’t work (MmAllocateContiguousMemory returns null).

I see that Win2K MmAllocateContiguousMemory must be called at
IRQL PASSIVE_LEVEL, so I guess that’s the difference.

My driver is monolithic, so is that a highest-level or
lowest-level driver?
From Win2k docs:

---------------------------- begin doc
Most drivers’ Dispatch routines are called in an arbitrary
thread context at IRQL PASSIVE_LEVEL, with the following exceptions:

Any highest-level driver’s Dispatch routines are called in
the context of the thread that originated the I/O request,
which is commonly a user-mode application thread.
In other words, the Dispatch routines of file system drivers
and other highest-level drivers are called in a nonarbitrary
thread context at IRQL PASSIVE_LEVEL.

The DispatchRead, DispatchWrite, and DispatchDeviceControl
routines of lowest-level device drivers and of intermediate
drivers layered above them in the system paging path, can be
called at IRQL APC_LEVEL and in an arbitrary thread context.
---------------------------- end doc

So I guess my DispatchDeviceControl routine is being called
at IRQL APC_LEVEL, but why? (The only application to use it
is my own). Is there a way around this?

[I’d like to save someone the time it takes to criticize allocating non-paged memory outside of DriverEntry(). Its only use is for extremely specialized hardware and controlled environments.]

Thank you all (generally, for list contents),
Justin


You are currently subscribed to ntdev as:
xxxxx@hollistech.com To unsubscribe send a blank email to
leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Mark,

_Much in the same fashion that NT != VMS, ULONG != PVOID.

Slightly less depraved/more portable to 64 bits than the suggestion below,
is to use Birp->Tail.Overlay.DriverContext[0] to store the work item instead
of the IoStatus.Information. Beware of using that field, however, if you’re
queueing IRPs - it’s part of a union that’s used for both purposes
(driver-specific data and IRP queues).

For example, if in the example below you were tempted to put the IRP into a
queue so the work item could handle many of them when it finally got a
chance to run (perhaps a reasonable thing to do), you’d be overwriting your
queue pointer when you assigned the work item into the IRP.

Somebody apparently forgot to explain all that to the 98 WDM team for the
PnP IRPs, however…

-Tim

Timothy A. Johns — xxxxx@driverdev.com
Driver Development Corporation — 800.841.0092
Bring Up Your Hardware — Fast. www.driverdev.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Mark Roddy
Sent: Friday, August 17, 2001 4:44 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Dispatch IRQL value

If your dispatch routine is called at > PASSIVE_LEVEL but you need to
perform some foul and depraved act that requires you to be at
PASSIVE_LEVEL then you need a worker thread that always runs at
PASSIVE_LEVEL to be your minion and do your bidding.

As in:

NTSTATUS
FrobnitzDispatchDeviceDoodle(DeviceObject, Birp)
{
… The usual crapola here

if (KeGetCurrentIrql() != PASSIVE_LEVEL) {

PIO_WORKITEM minion = IoAllocateWorkItem(DeviceObject);
if (minion == NULL) {
//
// notify the caller that the system is going to
// crash in a moment
//
Birp->IoStatus.Status = STATUS_WE_ARE_DOOMED;
IoCompleteRequest(Birp, IO_NO_INCREMENT);
return STATUS_WE_ARE_DOOMED;
}

Birp->IoStatus.Information = minion; // I said this was
depraved
IoMarkIrpPending(Birp);
IoQueueWorkItem(minion, FrobnitzWorkerDepravedAct,
CriticalWorkQueue, Birp);
return STATUS_PENDING;
}

//
// otherwise just do your depraved act here
//

… Whatever

return STATUS_SOMETHING_OR_OTHER;
}

> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Justin
> Schoenwald
> Sent: Friday, August 17, 2001 6:29 PM
> To: NT Developers Interest List
> Subject: [ntdev] Dispatch IRQL value
>
>
> Hello ntdevs,
>
> On NT4 I called MmAllocateContiguousMemory() in response to
> an IRP_MJ_DEVICE_CONTROL call. It’s a problem to me that on
> Win2K this doesn’t work (MmAllocateContiguousMemory returns null).
>
> I see that Win2K MmAllocateContiguousMemory must be called at
> IRQL PASSIVE_LEVEL, so I guess that’s the difference.
>
> My driver is monolithic, so is that a highest-level or
> lowest-level driver?
> From Win2k docs:
>
> ---------------------------- begin doc
> Most drivers’ Dispatch routines are called in an arbitrary
> thread context at IRQL PASSIVE_LEVEL, with the following exceptions:
>
> Any highest-level driver’s Dispatch routines are called in
> the context of the thread that originated the I/O request,
> which is commonly a user-mode application thread.
> In other words, the Dispatch routines of file system drivers
> and other highest-level drivers are called in a nonarbitrary
> thread context at IRQL PASSIVE_LEVEL.
>
> The DispatchRead, DispatchWrite, and DispatchDeviceControl
> routines of lowest-level device drivers and of intermediate
> drivers layered above them in the system paging path, can be
> called at IRQL APC_LEVEL and in an arbitrary thread context.
> ---------------------------- end doc
>
> So I guess my DispatchDeviceControl routine is being called
> at IRQL APC_LEVEL, but why? (The only application to use it
> is my own). Is there a way around this?
>
> [I’d like to save someone the time it takes to criticize \> allocating non-paged memory outside of DriverEntry(). Its \> only use is for extremely specialized hardware and controlled \> environments.]
>
> Thank you all (generally, for list contents),
> Justin
>
> —
> You are currently subscribed to ntdev as:
> xxxxx@hollistech.com To unsubscribe send a blank email to
> leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
>


You are currently subscribed to ntdev as: xxxxx@driverdev.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com_

Hmmm…

First of all I said it was depraved. However:

typedef struct _IO_STATUS_BLOCK {
union {
NTSTATUS Status;
PVOID Pointer;
};

ULONG_PTR Information;
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;

Perhaps you meant that the Status field is a union? Information is
actually yours to use as you see fit until you complete the IRP, right?
(Of course there is the other problem that PnP IRPS use this field as
whatever the heck they want to use it for, so my example is not depraved
enough to use for pnp requests.)

Secondly, Microsoft was struck with the Altairian Idiocy Ray when they
dreamed up the Io*WorkItem interface replacement for Ke*WorkItem and
neglected once again to provide a back pointer to the workitem so that
the worker function could deallocate it without the originator having to
either allocate memory for such pointer or commit depraved acts of field
overuse.

Finally I agree completely, NT is not the same as VMS and void * is not
at all the same as unsigned long. I note also that this is 2001 not
1980, that DEC does not even exist anymore, and that the way my compaq
stock is going the remnants of DEC may not survive much longer either.

VMS forever, whatever.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Timothy A. Johns
Sent: Friday, August 17, 2001 9:14 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Dispatch IRQL value

Mark,

_>

Much in the same fashion that NT != VMS, ULONG != PVOID.

Slightly less depraved/more portable to 64 bits than the
suggestion below, is to use
Birp->Tail.Overlay.DriverContext[0] to store the work item
instead of the IoStatus.Information. Beware of using that
field, however, if you’re queueing IRPs - it’s part of a
union that’s used for both purposes (driver-specific data and
IRP queues).

For example, if in the example below you were tempted to put
the IRP into a queue so the work item could handle many of
them when it finally got a chance to run (perhaps a
reasonable thing to do), you’d be overwriting your queue
pointer when you assigned the work item into the IRP.

Somebody apparently forgot to explain all that to the 98 WDM
team for the PnP IRPs, however…

-Tim

Timothy A. Johns — xxxxx@driverdev.com
Driver Development Corporation — 800.841.0092
Bring Up Your Hardware — Fast. www.driverdev.com

> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of Mark Roddy
> Sent: Friday, August 17, 2001 4:44 PM
> To: NT Developers Interest List
> Subject: [ntdev] RE: Dispatch IRQL value
>
>
> If your dispatch routine is called at > PASSIVE_LEVEL but
you need to
> perform some foul and depraved act that requires you to be at
> PASSIVE_LEVEL then you need a worker thread that always runs at
> PASSIVE_LEVEL to be your minion and do your bidding.
>
> As in:
>
> NTSTATUS
> FrobnitzDispatchDeviceDoodle(DeviceObject, Birp)
> {
> … The usual crapola here
>
> if (KeGetCurrentIrql() != PASSIVE_LEVEL) {
>
> PIO_WORKITEM minion = IoAllocateWorkItem(DeviceObject);
> if (minion == NULL) {
> //
> // notify the caller that the system is going to
> // crash in a moment
> //
> Birp->IoStatus.Status = STATUS_WE_ARE_DOOMED;
> IoCompleteRequest(Birp, IO_NO_INCREMENT);
> return STATUS_WE_ARE_DOOMED;
> }
>
> Birp->IoStatus.Information = minion; // I said
this was depraved
> IoMarkIrpPending(Birp);
> IoQueueWorkItem(minion, FrobnitzWorkerDepravedAct,
> CriticalWorkQueue, Birp);
> return STATUS_PENDING;
> }
>
> //
> // otherwise just do your depraved act here
> //
>
> … Whatever
>
> return STATUS_SOMETHING_OR_OTHER;
> }
>
>
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com] On Behalf Of Justin
> > Schoenwald
> > Sent: Friday, August 17, 2001 6:29 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] Dispatch IRQL value
> >
> >
> > Hello ntdevs,
> >
> > On NT4 I called MmAllocateContiguousMemory() in response to an
> > IRP_MJ_DEVICE_CONTROL call. It’s a problem to me that on
Win2K this
> > doesn’t work (MmAllocateContiguousMemory returns null).
> >
> > I see that Win2K MmAllocateContiguousMemory must be
called at IRQL
> > PASSIVE_LEVEL, so I guess that’s the difference.
> >
> > My driver is monolithic, so is that a highest-level or
lowest-level
> > driver? From Win2k docs:
> >
> > ---------------------------- begin doc
> > Most drivers’ Dispatch routines are called in an arbitrary thread
> > context at IRQL PASSIVE_LEVEL, with the following exceptions:
> >
> > Any highest-level driver’s Dispatch routines are called in the
> > context of the thread that originated the I/O request, which is
> > commonly a user-mode application thread. In other words, the
> > Dispatch routines of file system drivers and other highest-level
> > drivers are called in a nonarbitrary thread context at IRQL
> > PASSIVE_LEVEL.
> >
> > The DispatchRead, DispatchWrite, and
DispatchDeviceControl routines
> > of lowest-level device drivers and of intermediate
drivers layered
> > above them in the system paging path, can be called at IRQL
> > APC_LEVEL and in an arbitrary thread context.
> > ---------------------------- end doc
> >
> > So I guess my DispatchDeviceControl routine is being
called at IRQL
> > APC_LEVEL, but why? (The only application to use it is my
own). Is
> > there a way around this?
> >
> > [I’d like to save someone the time it takes to criticize allocating \> \> non-paged memory outside of DriverEntry(). Its only use is for \> \> extremely specialized hardware and controlled environments.]
> >
> > Thank you all (generally, for list contents),
> > Justin
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@hollistech.com To
> > unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> >
> >
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@driverdev.com To
> unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntdev as:
xxxxx@hollistech.com To unsubscribe send a blank email to
leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com_

> is to use Birp->Tail.Overlay.DriverContext[0] to store the work item
instead

of the IoStatus.Information. Beware of using that field, however, if
you’re

Irp->IoStatus.Information is ULONG_PTR, not ULONG.
You can put a pointer there on IA64 too.
In fact, most PnP IRPs do this.

Max


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

You know I just re-parsed Tim’s response, and now it makes more sense.
He was talking about DriverContext being overlayed and used for
queueing, rather than IoStatus.Information. Unfortunately that leaves my
response to his response a little devoid of meaning or information. (I
know, nothing new there, huh?)

Actually I also at first thought that the overuse of IoStatus by PnP
IRPs was a hideous ugly hack, but the fact is that it really is not so
bad at all as a place to plunk your own private per-IRP state
information in addition to or instead of using the overlayed
DriverContext field.

I will however in the future refer to all my IRP pointers using the
variable name ‘Birp’ just because the sound of it pleases me and my
four-year-old sense of humor, and I hate all forms of hungarian
notation. (Do Hungarians object to this terminology?) “Don’t forget to
initialize that Birp.” “Make sure you complete that Birp in your
dispatch routine.” Yes, code review could get down to a 2-year-old level
in no time at all.

Oh and VMS forever, whatever.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim
S. Shatskih
Sent: Saturday, August 18, 2001 1:48 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Dispatch IRQL value

> is to use Birp->Tail.Overlay.DriverContext[0] to store the work item
instead
> of the IoStatus.Information. Beware of using that field, however, if
you’re

Irp->IoStatus.Information is ULONG_PTR, not ULONG.
You can put a pointer there on IA64 too.
In fact, most PnP IRPs do this.

Max


You are currently subscribed to ntdev as:
xxxxx@hollistech.com To unsubscribe send a blank email to
leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Tim,

Not if you manage your own queues and do not use StartIo.

Gary G. Little
Staff Engineer
Broadband Storage, Inc.
xxxxx@broadstor.com

-----Original Message-----
From: Timothy A. Johns [mailto:xxxxx@driverdev.com]
Sent: Friday, August 17, 2001 6:14 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Dispatch IRQL value

Mark,

_Much in the same fashion that NT != VMS, ULONG != PVOID.

Slightly less depraved/more portable to 64 bits than the suggestion below,
is to use Birp->Tail.Overlay.DriverContext[0] to store the work item instead
of the IoStatus.Information. Beware of using that field, however, if you’re
queueing IRPs - it’s part of a union that’s used for both purposes
(driver-specific data and IRP queues).

For example, if in the example below you were tempted to put the IRP into a
queue so the work item could handle many of them when it finally got a
chance to run (perhaps a reasonable thing to do), you’d be overwriting your
queue pointer when you assigned the work item into the IRP.

Somebody apparently forgot to explain all that to the 98 WDM team for the
PnP IRPs, however…

-Tim

Timothy A. Johns — xxxxx@driverdev.com
Driver Development Corporation — 800.841.0092
Bring Up Your Hardware — Fast. www.driverdev.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Mark Roddy
Sent: Friday, August 17, 2001 4:44 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Dispatch IRQL value

If your dispatch routine is called at > PASSIVE_LEVEL but you need to
perform some foul and depraved act that requires you to be at
PASSIVE_LEVEL then you need a worker thread that always runs at
PASSIVE_LEVEL to be your minion and do your bidding.

As in:

NTSTATUS
FrobnitzDispatchDeviceDoodle(DeviceObject, Birp)
{
… The usual crapola here

if (KeGetCurrentIrql() != PASSIVE_LEVEL) {

PIO_WORKITEM minion = IoAllocateWorkItem(DeviceObject);
if (minion == NULL) {
//
// notify the caller that the system is going to
// crash in a moment
//
Birp->IoStatus.Status = STATUS_WE_ARE_DOOMED;
IoCompleteRequest(Birp, IO_NO_INCREMENT);
return STATUS_WE_ARE_DOOMED;
}

Birp->IoStatus.Information = minion; // I said this was
depraved
IoMarkIrpPending(Birp);
IoQueueWorkItem(minion, FrobnitzWorkerDepravedAct,
CriticalWorkQueue, Birp);
return STATUS_PENDING;
}

//
// otherwise just do your depraved act here
//

… Whatever

return STATUS_SOMETHING_OR_OTHER;
}

> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Justin
> Schoenwald
> Sent: Friday, August 17, 2001 6:29 PM
> To: NT Developers Interest List
> Subject: [ntdev] Dispatch IRQL value
>
>
> Hello ntdevs,
>
> On NT4 I called MmAllocateContiguousMemory() in response to
> an IRP_MJ_DEVICE_CONTROL call. It’s a problem to me that on
> Win2K this doesn’t work (MmAllocateContiguousMemory returns null).
>
> I see that Win2K MmAllocateContiguousMemory must be called at
> IRQL PASSIVE_LEVEL, so I guess that’s the difference.
>
> My driver is monolithic, so is that a highest-level or
> lowest-level driver?
> From Win2k docs:
>
> ---------------------------- begin doc
> Most drivers’ Dispatch routines are called in an arbitrary
> thread context at IRQL PASSIVE_LEVEL, with the following exceptions:
>
> Any highest-level driver’s Dispatch routines are called in
> the context of the thread that originated the I/O request,
> which is commonly a user-mode application thread.
> In other words, the Dispatch routines of file system drivers
> and other highest-level drivers are called in a nonarbitrary
> thread context at IRQL PASSIVE_LEVEL.
>
> The DispatchRead, DispatchWrite, and DispatchDeviceControl
> routines of lowest-level device drivers and of intermediate
> drivers layered above them in the system paging path, can be
> called at IRQL APC_LEVEL and in an arbitrary thread context.
> ---------------------------- end doc
>
> So I guess my DispatchDeviceControl routine is being called
> at IRQL APC_LEVEL, but why? (The only application to use it
> is my own). Is there a way around this?
>
> [I’d like to save someone the time it takes to criticize \> allocating non-paged memory outside of DriverEntry(). Its \> only use is for extremely specialized hardware and controlled \> environments.]
>
> Thank you all (generally, for list contents),
> Justin
>
> —
> You are currently subscribed to ntdev as:
> xxxxx@hollistech.com To unsubscribe send a blank email to
> leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
>


You are currently subscribed to ntdev as: xxxxx@driverdev.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@broadstor.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com_

Gary,

True, good point - if you’re using the list-entry API to manage your own
queues rather than the device-queue API.

Technically speaking: Any functions that make use of the IRP’s
DeviceQueueEntry, such as IoStartPacket, IoStartNextPacket, and
IoStartNextPacketByKey will overwrite portions of the DriverContext. If you
use the IRP’s DeviceQueueEntry in calls to KeInsertDeviceQueue,
KeInsertByKeyDeviceQueue, and KeRemoveEntryDeviceQueue, those will overwrite
portions of the DriverContext.

It looks from the comments in ntddk.h that the new cancel-safer queue
support explicitly overwrites DriverContext[3], which strikes me as a bit
odd. I wonder if Microsoft did that to make DriverContext[0] from
DeviceQueueEntry, or if it’s a typo, or what. I’m anxious to see the full
docs for the new cancel-safer queue support.

-Tim

Timothy A. Johns — xxxxx@driverdev.com
Driver Development Corporation — 800.841.0092
Bring Up Your Hardware — Fast. www.driverdev.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Gary Little
Sent: Monday, August 20, 2001 9:26 AM
To: NT Developers Interest List
Subject: [ntdev] RE: Dispatch IRQL value

Tim,

Not if you manage your own queues and do not use StartIo.

Gary G. Little
Staff Engineer
Broadband Storage, Inc.
xxxxx@broadstor.com

-----Original Message-----
From: Timothy A. Johns [mailto:xxxxx@driverdev.com]
Sent: Friday, August 17, 2001 6:14 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Dispatch IRQL value

Mark,

_>

Much in the same fashion that NT != VMS, ULONG != PVOID.

Slightly less depraved/more portable to 64 bits than the suggestion below,
is to use Birp->Tail.Overlay.DriverContext[0] to store the work
item instead
of the IoStatus.Information. Beware of using that field, however,
if you’re
queueing IRPs - it’s part of a union that’s used for both purposes
(driver-specific data and IRP queues).

For example, if in the example below you were tempted to put the
IRP into a
queue so the work item could handle many of them when it finally got a
chance to run (perhaps a reasonable thing to do), you’d be
overwriting your
queue pointer when you assigned the work item into the IRP.

Somebody apparently forgot to explain all that to the 98 WDM team for the
PnP IRPs, however…

-Tim

Timothy A. Johns — xxxxx@driverdev.com
Driver Development Corporation — 800.841.0092
Bring Up Your Hardware — Fast. www.driverdev.com

> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of Mark Roddy
> Sent: Friday, August 17, 2001 4:44 PM
> To: NT Developers Interest List
> Subject: [ntdev] RE: Dispatch IRQL value
>
>
> If your dispatch routine is called at > PASSIVE_LEVEL but you need to
> perform some foul and depraved act that requires you to be at
> PASSIVE_LEVEL then you need a worker thread that always runs at
> PASSIVE_LEVEL to be your minion and do your bidding.
>
> As in:
>
> NTSTATUS
> FrobnitzDispatchDeviceDoodle(DeviceObject, Birp)
> {
> … The usual crapola here
>
> if (KeGetCurrentIrql() != PASSIVE_LEVEL) {
>
> PIO_WORKITEM minion = IoAllocateWorkItem(DeviceObject);
> if (minion == NULL) {
> //
> // notify the caller that the system is going to
> // crash in a moment
> //
> Birp->IoStatus.Status = STATUS_WE_ARE_DOOMED;
> IoCompleteRequest(Birp, IO_NO_INCREMENT);
> return STATUS_WE_ARE_DOOMED;
> }
>
> Birp->IoStatus.Information = minion; // I said this was
> depraved
> IoMarkIrpPending(Birp);
> IoQueueWorkItem(minion, FrobnitzWorkerDepravedAct,
> CriticalWorkQueue, Birp);
> return STATUS_PENDING;
> }
>
> //
> // otherwise just do your depraved act here
> //
>
> … Whatever
>
> return STATUS_SOMETHING_OR_OTHER;
> }
>
>
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com] On Behalf Of Justin
> > Schoenwald
> > Sent: Friday, August 17, 2001 6:29 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] Dispatch IRQL value
> >
> >
> > Hello ntdevs,
> >
> > On NT4 I called MmAllocateContiguousMemory() in response to
> > an IRP_MJ_DEVICE_CONTROL call. It’s a problem to me that on
> > Win2K this doesn’t work (MmAllocateContiguousMemory returns null).
> >
> > I see that Win2K MmAllocateContiguousMemory must be called at
> > IRQL PASSIVE_LEVEL, so I guess that’s the difference.
> >
> > My driver is monolithic, so is that a highest-level or
> > lowest-level driver?
> > From Win2k docs:
> >
> > ---------------------------- begin doc
> > Most drivers’ Dispatch routines are called in an arbitrary
> > thread context at IRQL PASSIVE_LEVEL, with the following exceptions:
> >
> > Any highest-level driver’s Dispatch routines are called in
> > the context of the thread that originated the I/O request,
> > which is commonly a user-mode application thread.
> > In other words, the Dispatch routines of file system drivers
> > and other highest-level drivers are called in a nonarbitrary
> > thread context at IRQL PASSIVE_LEVEL.
> >
> > The DispatchRead, DispatchWrite, and DispatchDeviceControl
> > routines of lowest-level device drivers and of intermediate
> > drivers layered above them in the system paging path, can be
> > called at IRQL APC_LEVEL and in an arbitrary thread context.
> > ---------------------------- end doc
> >
> > So I guess my DispatchDeviceControl routine is being called
> > at IRQL APC_LEVEL, but why? (The only application to use it
> > is my own). Is there a way around this?
> >
> > [I’d like to save someone the time it takes to criticize \> \> allocating non-paged memory outside of DriverEntry(). Its \> \> only use is for extremely specialized hardware and controlled \> \> environments.]
> >
> > Thank you all (generally, for list contents),
> > Justin
> >
> > —
> > You are currently subscribed to ntdev as:
> > xxxxx@hollistech.com To unsubscribe send a blank email to
> > leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> >
> >
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@driverdev.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntdev as: xxxxx@broadstor.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@driverdev.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com_

>> [I’d like to save someone the time it takes to criticize allocating

> non-paged memory outside of DriverEntry(). Its only use is for extremely
> specialized hardware and controlled environments.]

> Not criticizing, just questioning. Regardless of the environment, why
is it
> desirable to do this?

The user application includes a text-based interpreter (a “little
language”) for development support of reconfigurable hardware (FPGA)
applications over the PCI bus. Because of the nature of the hardware,
required system resources are completely application dependent. The
interpreter supports non-paged memory allocation for busmastering including
software scatter-gather.

I’m considering allocation of user-specified contiguous and total
scatter-gather amounts for the life of the driver at startup, for the next
generation of hw/sw.

Thanks for responses esp. Mark,
Justin


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com