From: Roddy, Mark [Mark_Roddy@stratus.com] Sent: Tuesday, May 02, 2000 8:53 AM To: NT Developers Interest List Subject: [ntdev] RE: METHOD_DIRECT_IO or METHOD_BUFFERED? > > Mark, > but if I call driver from win32 application is MDL > initialized from system > or not. It depends. Generally yes. If the target DeviceObject uses METHOD_DIRECT then the IoManager, for Reads writes and several other data transfer oriented operations, will construct the MDL pointed at by Irp->MdlAddress. For IOCTLs the story is more complicated. Each IOCTL determines, by the bit encoding of the IOCTL control code, the buffering method for each of the two data buffers described by the IOCTL IRP. Ignoring METHOD_NEITHER, the input buffer is always a SystemBuffer. There is no MDL for this buffer. If you need one you will have to manage its creation/destruction on your own. For METHOD_BUFFERED, the output buffer is also described by SystemBuffer, so once again you will have to build your own MDL. For METHOD_IN/OUT_DIRECT the output buffer is described by Irp->MdlAddress. Without knowing what the IOCTL code is I cannot tell what the problem is, but I'm guessing that Irp->MdlAddress is bogus. You should look at the definition of the IOCTL, as this will indicate exactly which buffer method is in use. If the IOCTL is defined as METHOD_IN/OUT_DIRECT and the output buffer is zero length then Irp->MdlAddress will be bogus. Read operations presumably would have a non-zero length for the output buffer and consequently would have a valid Irp->MdlAddress. One thing to consider is that the 'output buffer" can transfer data in EITHER direction. So your "write ioctl" might work if the application switched input buffer for output buffer on the DeviceControl call. The purists will object that the IOCTL needs to be redefined correctly (either IN_DIRECT or OUT_DIRECT, I give up which one it is) and they are probably right. >Well one thing fell on my mind that I haven't created > MDL during > initialization as I think that this job system do by itself. Is it so? > The problem I have is when I call read operation everything > goes well (by > ICTL code form win32 app), I mean system doesn't crush (I > heven't checked > the validity of this operation). Then when I call write > operation system > crush > on call MmGetMdlVirtualAddress(Irp->MdlAddress). This exact > function I use > also in read operation and it work OK. Any ideas? I'm sending > you part of > code that "should" do DMA writing on serial port. > > Regard, > Neno > > --- You are currently subscribed to ntdev as: GlennEverhart@FirstUSA.com To unsubscribe send a blank email to leave-ntdev-247T@lists.osr.com