Hi, I will like to know if I can use the method above to
modify the access speed of an i/o window?

If I can't is there a way in which I can do it?

Is there any sample codes available for using
PCMCIA_MODIFY_MEMORY_WINDOW?

Re: PCMCIA_MODIFY_MEMORY_WINDOW by Pavel

Pavel
Tue Nov 25 16:05:09 CST 2003

"Wei Wei" <anonymous@discussions.microsoft.com> wrote in message
news:081d01c3ae89$4d64a560$a101280a@phx.gbl...
> Hi, I will like to know if I can use the method above to
> modify the access speed of an i/o window?
>
> If I can't is there a way in which I can do it?
>
> Is there any sample codes available for using
> PCMCIA_MODIFY_MEMORY_WINDOW?

Well since nobody replied... I've found this ancient code snippet from the dark days of NT5 beta.
It served to create an attribute window as workaround until MS implements it in INF format.
*Warning* I haven't touched it since then so it may not work with current DDK
but hopefully you'll get the idea.

--------------- begin------------
// Change window type to attrib using PCMCIA_INTERFACE_STANDARD
// for win2k beta, 11-may-1999
#include "mydebug.h"

#define INITGUID

#include <wdm.h>
#include "ntddpcm.h"


// Compl. handler for irp
static
NTSTATUS
myComplRoutine(
IN PDEVICE_OBJECT pdo,
IN PIRP pirp,
IN PKEVENT pevt
)
{
KeSetEvent( pevt, 0, FALSE );
return STATUS_MORE_PROCESSING_REQUIRED;
}


static
PCMCIA_INTERFACE_STANDARD iface;

// PhysAddr: host address of the window to make attribute.
BOOLEAN
MySetupAttribWindow( ULONG PhysAddr )
{
NTSTATUS st;
PIRP pirp;
PDEVICE_OBJECT PcmciaObj = 0;
PFILE_OBJECT pfo;
KEVENT evt;
BOOLEAN r;
UNICODE_STRING us;
PIO_STACK_LOCATION sl;

RtlInitUnicodeString( &us, L"\\Device\\Pcmcia0" );

st = IoGetDeviceObjectPointer(
&us,
FILE_ALL_ACCESS,
&pfo,
&PcmciaObj
);

if( (st != STATUS_SUCCESS) || (!PcmciaObj) ) {
DbgP1( "failed get pcmcia obj=%x\n", st );
return FALSE;
}

if( pfo ) {
ObDereferenceObject( pfo ); // immediately deref the file object
}

pirp = IoAllocateIrp( PcmciaObj->StackSize, FALSE );

if( !pirp ) {
DbgP0("alloc irp failed\n");
return 0;
}

sl = IoGetNextIrpStackLocation( pirp );
sl->MajorFunction = IRP_MJ_DEVICE_CONTROL;
sl->MinorFunction = IRP_MN_QUERY_INTERFACE;
sl->Parameters.QueryInterface.InterfaceType = &GUID_PCMCIA_INTERFACE_STANDARD; //pguid;
sl->Parameters.QueryInterface.Interface = (PVOID)&iface;

RtlZeroMemory( &iface, sizeof(iface) );
iface.Size = sizeof( PCMCIA_INTERFACE_STANDARD );

KeInitializeEvent( &evt, NotificationEvent, FALSE );

IoSetCompletionRoutine(
pirp,
(PIO_COMPLETION_ROUTINE)myComplRoutine,
(PVOID)&evt,
TRUE,
TRUE,
TRUE
);

st = IoCallDriver( PcmciaObj, pirp );

if( st != STATUS_SUCCESS && st != STATUS_PENDING ) {
DbgP1("err calldriver=%x\n", st);
return FALSE;
}

st = KeWaitForSingleObject(
&evt, // object
Executive, // reason: for drivers must be Executive
KernelMode, // wait mode
FALSE, // not alertable
NULL // & timeout
);

if( st != STATUS_SUCCESS ) {
DbgP1("wait err=%x\n", st);
DbgBrk();
}

st = pirp->IoStatus.Status;
IoFreeIrp( pirp );

if( st != STATUS_SUCCESS ) {
DbgP1("ioctl err=%x\n", st );
return FALSE;
}

if( iface.Size >= sizeof( PCMCIA_INTERFACE_STANDARD ) ) {

r = iface.ModifyMemoryWindow(
iface.Context, // IN PVOID Context
(ULONGLONG)PhysAddr, // IN ULONGLONG HostBase,
0, // IN ULONGLONG CardBase,
TRUE, // IN BOOLEAN Enable,
0, // no chg/4k/8k IN ULONG WindowSize OPTIONAL,
0, //??? IN UCHAR AccessSpeed OPTIONAL,
0, //??? 8? IN UCHAR BusWidth OPTIONAL,
TRUE // IN BOOLEAN IsAttributeMemory
);

} else {
r = FALSE;
}

iface.InterfaceDereference( iface.Context );
return r;
}
------------------- end --------------------------


Good luck
- Pavel