Re: how to access Configuration and status register o f PC card

Thanx for the info Shiv, actually I did implemented like this and I was
trying to read The status register but
I was getting value zero.I had assumed that IRP_MN_READ_CONFIG would read
from Configuration and
Status register of PC card and I would not have to parse for configuration
and status register in Attribute memory.

Following is the code I had implemented

pdo=deviceExtension->pdo;
ownIrp = IoAllocateIrp(pdo->StackSize, FALSE);

if (!ownIrp) {

return STATUS_INSUFFICIENT_RESOURCES;

}

ownIrp->IoStatus.Status = STATUS_NOT_SUPPORTED;
KeInitializeEvent(&Event, NotificationEvent, FALSE);

IoSetCompletionRoutine(ownIrp,FilterIrpCompletion,&Event,
TRUE, TRUE, TRUE);

IoStack = IoGetNextIrpStackLocation(ownIrp);

UCHAR buffer=0;

IoStack->MajorFunction= IRP_MJ_PNP;
IoStack->MinorFunction= IRP_MN_READ_CONFIG;
IoStack->Parameters.ReadWriteConfig.WhichSpace =
PCMCIA_CONFIG_SPACE ;
IoStack->Parameters.ReadWriteConfig.Buffer = &buffer;
IoStack->Parameters.ReadWriteConfig.Offset = 2;
IoStack->Parameters.ReadWriteConfig.Length = sizeof(UCHAR);

Status = IoCallDriver(pdo, ownIrp);

if (Status == STATUS_PENDING) {

KeWaitForSingleObject(&Event, Executive, KernelMode,
FALSE, NULL);
Status = ownIrp->IoStatus.Status;

}

DebugPrint((“The value of byte %d\n”,buffer));

IoFreeIrp(ownIrp);

===
Regards
Ashish

-----Original Message-----
From: Shiva Prasad. T. S. [mailto:xxxxx@yahoo.com]
Sent: Friday, August 30, 2002 9:52 PM
To: NT Developers Interest List
Subject: [ntdev] Re: how to access Configuration and status register of PC
card

Hi Ashish,

For accessing the Status and configuration registers of 16-bit PC card, U
will have to do READ/WRITE access to the Attribute Memory…The following
code is what I implemented using a sample in Knowledge base article…U can
use the following code to access the attribute memory…

#pragma PAGEDCODE
NTSTATUS ReadWriteAttribMem(PDEVICE_OBJECT fdo,BOOLEAN flag,UCHAR
*attribMemBuffContent,int offset)
{
KdPrint((“Entering READWRITEATTRIBMEM function”));

int i;
PIRP Irp=IoAllocateIrp(fdo->StackSize,TRUE);
if(!Irp)
{
KdPrint((“Hardware not found,resource not allocated”));
return STATUS_INSUFFICIENT_RESOURCES;
}

Irp->IoStatus.Status=STATUS_NOT_SUPPORTED;

PIO_STACK_LOCATION stack=IoGetNextIrpStackLocation(Irp);

KEVENT Event;
KeInitializeEvent(&Event,NotificationEvent,FALSE);

IoSetCompletionRoutine(Irp,Pcmcia_RW_Completion_Routine,
&Event,TRUE,TRUE,TRUE);

KdPrint((“Setting the Stack parameter for reading attrib Mem”));

stack->MajorFunction=IRP_MJ_PNP;
stack->MinorFunction=flag? IRP_MN_WRITE_CONFIG : IRP_MN_READ_CONFIG;

if(flag)
{
KdPrint((“Performing Attrib Mem Write”));
}
else
{
KdPrint((“Performing Attrib Mem Read”));
}

stack->Parameters.ReadWriteConfig.WhichSpace=PCCARD_ATTRIBUTE_MEMORY;
stack->Parameters.ReadWriteConfig.Buffer=attribMemBuffContent;
stack->Parameters.ReadWriteConfig.Offset=offset;

stack->Parameters.ReadWriteConfig.Length=sizeof(*(attribMemBuffContent));

PDEVICE_EXTENSION pdx= (PDEVICE_EXTENSION)fdo->DeviceExtension;

NTSTATUS status=IoCallDriver(pdx->LowerDeviceObject,Irp);
if(status == STATUS_PENDING)
{

KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
status=Irp->IoStatus.Status;
}

IoFreeIrp(Irp);
KdPrint((“Quitting READWRITEATTRIBMEM Function”));

return status;
}

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

/****************Completion Routine for the ReadWriteAttribMem
Function***************************/

#pragma PAGEDCODE
NTSTATUS Pcmcia_RW_Completion_Routine(IN PDEVICE_OBJECT fdo,
IN
PIRP Irp,

IN PVOID Context)

{
KeSetEvent((PKEVENT) Context, IO_NO_INCREMENT, FALSE);
return STATUS_MORE_PROCESSING_REQUIRED;
}

Hope this helps,

regards,

Shiv


You are currently subscribed to ntdev as: xxxxx@itronix.com
To unsubscribe send a blank email to %%email.unsub%%