Path: news.mitre.org!blanket.mitre.org!news.tufts.edu!cam-news-feed5.bbnplanet.com!cam-news-hub1.bbnplanet.com!news.bbnplanet.com!news.maxwell.syr.edu!news-feed.inet.tele.dk!bofh.vszbr.cz!news.inet.tele.dk!not-for-mail From: "Søren Gullach" Newsgroups: comp.os.ms-windows.programmer.nt.kernel-mode Subject: Re: how do you do fast i/o Date: Mon, 8 Dec 1997 12:52:57 +0100 Lines: 106 Message-ID: <66gn69$eaq$1@mail-in1.inet.tele.dk> References: <01bcfe5b$671d8c40$3c66ec84@cu-dialup.cornell.edu> <661j3s$mcq$1@mail-in1.inet.tele.dk> NNTP-Posting-Host: cph243.ppp.dknet.dk X-Newsreader: Microsoft Outlook Express 4.71.1008.3 X-MimeOLE: Produced By Microsoft MimeOLE Engine V4.71.1008.3 Sorry its not Art Baker Its Windows NT Programming in Practice ISBN: 0-87930-472-3 SHG wrote in article <661j3s$mcq$1@mail-in1.inet.tele.dk>... > Hi >I have used this code from Art Baker > >#ifdef DIRECT_IO > /* These are the two undocumented calls that we will use to give the >calling > * process I/O access. Ke386IoSetAccessMap() copies the passed map to the >TSS. > * Ke386IoSetAccessProcess() adjusts the IOPM offset pointer so that the >newly > * copied map is actually used. Otherwise, the IOPM offset points beyond >the > * end of the TSS segment limit, causing any I/O access by the user-mode > * process to generate an exception. */ > extern "C" void Ke386SetIoAccessMap(int, IOPM *); // 1 copy buffer, 0 fill >with 0xFF > extern "C" void Ke386QueryIoAccessMap(int, IOPM *); // 1 copy buffer, 0 >fill with 0xFF > extern "C" void Ke386IoSetAccessProcess(PEPROCESS, int); // 1 enable IO, 0 >disable IO >#endif > >This code is in the DispatchOpen >#ifdef DIRECT_IO > // Alter NT IO map so app on ring 3 can do IO > if( pDeviceExtension->fDirectIO != 0 ) > { > IOPM *pIOPM; // pointer to IO protection map > > pIOPM = (IOPM*)MmAllocateNonCachedMemory(sizeof(IOPM)); > if(pIOPM == NULL) > { > hwioRegDebug( L"DispatchCreate", (USHORT)0xFF, L"Direct IO NOT set" ); > Status = STATUS_INSUFFICIENT_RESOURCES; > } > else > { > hwioRegDebug( L"DispatchCreate", >(USHORT)pDeviceExtension->NtDeviceNumber, L"Direct IO set" ); > Ke386QueryIoAccessMap(1, pIOPM); // 1 copy buffer, 0 fill with 0xFF > > // Alter IO bits > USHORT PortFirst = (USHORT)(pDeviceExtension->IntelPortBase); > USHORT PortLast = >(USHORT)(pDeviceExtension->IntelPortBase+pDeviceExtension->PortCount); >//hwioRegDebug( L"DispatchCreate port first", >(USHORT)pDeviceExtension->NtDeviceNumber, (ULONG)PortFirst ); >//hwioRegDebug( L"DispatchCreate port last", >(USHORT)pDeviceExtension->NtDeviceNumber, (ULONG)PortLast ); > for( USHORT p=PortFirst; p { > (*(pIOPM))[p/8] &= (UCHAR)(0xFF7F>>(p%8)); > } > > Ke386IoSetAccessProcess(PsGetCurrentProcess(), 1); // 1 enable IO, 0 >disable IO > Ke386SetIoAccessMap(1, pIOPM ); // 1 copy buffer, 0 fill with 0xFF > > MmFreeNonCachedMemory( pIOPM, sizeof(IOPM) ); > } > } > else > hwioRegDebug( L"DispatchCreate", (USHORT)pDeviceExtension->NtDeviceNumber, >L"Direct IO disabled" ); >#endif > >This code is in DispatchClose >#ifdef DIRECT_IO > PDEVICE_EXTENSION pDeviceExtension = >(PDEVICE_EXTENSION)pDeviceObject->DeviceExtension; > > if( pDeviceExtension->fDirectIO != 0 ) > { > hwioRegDebug( L"DispatchClose", (USHORT)pDeviceExtension->NtDeviceNumber, >L"Direct IO removed" ); > Ke386IoSetAccessProcess(PsGetCurrentProcess(), 0); // 1 enable IO, 0 >disable IO > } >#endif > >Søren Gullach >SGullach@ramtex.dk > > >John Landau wrote in article ><01bcfe5b$671d8c40$3c66ec84@cu-dialup.cornell.edu>... > >>Hi, >> I think it was Art Baker in his The Windows NT Device Driver Book >>who said that for highest performance I/O you'd make the I/O page >>accessible to user-mode code. >> How is this done? Are there any books on NT Device Drivers that >>address this and/or other optimization issues? >> Regards, >> John >> > >