com0com-cvs Mailing List for Null-modem emulator (Page 28)
The virtual serial port driver for Windows.
Brought to you by:
vfrolov
You can subscribe to this list here.
2005 |
Jan
|
Feb
(7) |
Mar
|
Apr
|
May
(13) |
Jun
(18) |
Jul
(9) |
Aug
(10) |
Sep
(15) |
Oct
(6) |
Nov
(9) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(6) |
Feb
(4) |
Mar
(4) |
Apr
(2) |
May
(7) |
Jun
(11) |
Jul
(6) |
Aug
(9) |
Sep
(1) |
Oct
(27) |
Nov
(22) |
Dec
(3) |
2007 |
Jan
(13) |
Feb
(16) |
Mar
(2) |
Apr
(3) |
May
(7) |
Jun
(17) |
Jul
(9) |
Aug
(1) |
Sep
(13) |
Oct
(20) |
Nov
(18) |
Dec
(1) |
2008 |
Jan
|
Feb
(3) |
Mar
(46) |
Apr
(40) |
May
(4) |
Jun
(9) |
Jul
(7) |
Aug
(62) |
Sep
(25) |
Oct
(51) |
Nov
(67) |
Dec
(81) |
2009 |
Jan
(13) |
Feb
(31) |
Mar
(12) |
Apr
|
May
(10) |
Jun
|
Jul
(5) |
Aug
(2) |
Sep
(10) |
Oct
|
Nov
(3) |
Dec
(1) |
2010 |
Jan
|
Feb
(1) |
Mar
(4) |
Apr
|
May
(12) |
Jun
(9) |
Jul
(12) |
Aug
(7) |
Sep
(6) |
Oct
|
Nov
|
Dec
(1) |
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(11) |
Jun
|
Jul
(26) |
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
(23) |
2012 |
Jan
(7) |
Feb
(3) |
Mar
|
Apr
|
May
(2) |
Jun
(9) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Vyacheslav F. <vf...@us...> - 2007-07-03 14:42:16
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv16299 Modified Files: setup.cpp Log Message: Added friendly name setting for bus device Index: setup.cpp =================================================================== RCS file: /cvsroot/com0com/com0com/setup/setup.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** setup.cpp 14 Jun 2007 16:14:19 -0000 1.14 --- setup.cpp 3 Jul 2007 14:42:10 -0000 1.15 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.15 2007/07/03 14:42:10 vfrolov + * Added friendly name setting for bus device + * * Revision 1.14 2007/06/14 16:14:19 vfrolov * Added test for "in use" in the COM port database *************** *** 218,221 **** --- 221,255 ---- } /////////////////////////////////////////////////////////////// + static VOID SetFriendlyName( + HDEVINFO hDevInfo, + PSP_DEVINFO_DATA pDevInfoData, + int num) + { + char portName[2][20]; + + for (int j = 0 ; j < 2 ; j++) { + char phPortName[20]; + + SNPRINTF(phPortName, sizeof(phPortName)/sizeof(phPortName[0]), "%s%d", + j ? C0C_PREF_PORT_NAME_B : C0C_PREF_PORT_NAME_A, num); + + PortParameters portParameters(C0C_SERVICE, phPortName); + + if (portParameters.Load() == ERROR_SUCCESS) + portParameters.FillPortName(portName[j], sizeof(portName[j])/sizeof(portName[j][0])); + else + SNPRINTF(portName[j], sizeof(portName[j])/sizeof(portName[j][0]), "%s", phPortName); + } + + char friendlyName[80]; + + SNPRINTF(friendlyName, sizeof(friendlyName)/sizeof(friendlyName[0]), + "com0com - bus for serial port pair emulator (%s <-> %s)", + portName[0], portName[1]); + + SetupDiSetDeviceRegistryProperty(hDevInfo, pDevInfoData, SPDRP_FRIENDLYNAME, + (LPBYTE)friendlyName, (lstrlen(friendlyName) + 1) * sizeof(*friendlyName)); + } + /////////////////////////////////////////////////////////////// struct ChangeDeviceParams { ChangeDeviceParams(InfFile &_infFile, const char *_pPhPortName, const char *_pParameters) *************** *** 276,279 **** --- 310,315 ---- Trace("change %s %s\n", phPortName, buf); + SetFriendlyName(hDevInfo, pDevInfoData, i); + DevProperties devProperties; devProperties.pDevId = C0C_PORT_DEVICE_ID; *************** *** 421,432 **** { int res; do { res = IDCONTINUE; ! LONG err = SetPortNum(hDevInfo, pDevInfoData, *(int *)pParam); if (err != ERROR_SUCCESS) ! res = ShowError(MB_CANCELTRYCONTINUE, err, "SetPortNum(%d)", *(int *)pParam); } while (res == IDTRYAGAIN); --- 457,469 ---- { int res; + int num = *(int *)pParam; do { res = IDCONTINUE; ! LONG err = SetPortNum(hDevInfo, pDevInfoData, num); if (err != ERROR_SUCCESS) ! res = ShowError(MB_CANCELTRYCONTINUE, err, "SetPortNum(%d)", num); } while (res == IDTRYAGAIN); *************** *** 435,438 **** --- 472,477 ---- return FALSE; + SetFriendlyName(hDevInfo, pDevInfoData, num); + return TRUE; } |
From: Vyacheslav F. <vf...@us...> - 2007-07-03 14:39:55
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv15327 Modified Files: params.cpp params.h Log Message: Implemented pinout customization Index: params.h =================================================================== RCS file: /cvsroot/com0com/com0com/setup/params.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** params.h 1 Jun 2007 16:32:04 -0000 1.3 --- params.h 3 Jul 2007 14:39:49 -0000 1.4 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.4 2007/07/03 14:39:49 vfrolov + * Implemented pinout customization + * * Revision 1.3 2007/06/01 16:32:04 vfrolov * Implemented plug-in and exclusive modes *************** *** 52,60 **** BOOL FillParametersKey(char *pRegKey, int size); BOOL SetPortName(const char *pNewPortName); ! DWORD *GetFlagPtr(DWORD bit); const char *GetBitName(DWORD bit); ! BOOL SetFlag(const char *pNewFlag, DWORD bit); ! void LoadFlag(HKEY hKey, DWORD bit); ! LONG SaveFlag(HKEY hKey, DWORD bit); DWORD maskChanged; --- 55,64 ---- BOOL FillParametersKey(char *pRegKey, int size); BOOL SetPortName(const char *pNewPortName); ! DWORD *GetDwPtr(DWORD bit); const char *GetBitName(DWORD bit); ! BOOL SetFlag(const char *pNewVal, DWORD bit); ! BOOL SetPin(const char *pNewVal, DWORD bit); ! void LoadDw(HKEY hKey, DWORD bit); ! LONG SaveDw(HKEY hKey, DWORD bit); DWORD maskChanged; *************** *** 65,68 **** --- 69,76 ---- DWORD plugInMode; DWORD exclusiveMode; + DWORD pinCTS; + DWORD pinDSR; + DWORD pinDCD; + DWORD pinRI; char service[20]; Index: params.cpp =================================================================== RCS file: /cvsroot/com0com/com0com/setup/params.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** params.cpp 1 Jun 2007 16:32:04 -0000 1.5 --- params.cpp 3 Jul 2007 14:39:49 -0000 1.6 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.6 2007/07/03 14:39:49 vfrolov + * Implemented pinout customization + * * Revision 1.5 2007/06/01 16:32:04 vfrolov * Implemented plug-in and exclusive modes *************** *** 42,45 **** --- 45,51 ---- #include "msg.h" + #define TEXT_PREF + #include "../include/com0com.h" + /////////////////////////////////////////////////////////////// enum { *************** *** 49,52 **** --- 55,62 ---- m_plugInMode = 0x0008, m_exclusiveMode = 0x0010, + m_pinCTS = 0x0100, + m_pinDSR = 0x0200, + m_pinDCD = 0x0400, + m_pinRI = 0x0800, }; /////////////////////////////////////////////////////////////// *************** *** 58,61 **** --- 68,78 ---- }; /////////////////////////////////////////////////////////////// + static DWORD pinBits[] = { + m_pinCTS, + m_pinDSR, + m_pinDCD, + m_pinRI + }; + /////////////////////////////////////////////////////////////// PortParameters::PortParameters(const char *pService, const char *pPhPortName) { *************** *** 74,77 **** --- 91,99 ---- exclusiveMode = 0; + pinCTS = 0; + pinDSR = 0; + pinDCD = 0; + pinRI = 0; + maskChanged = 0; maskExplicit = 0; *************** *** 105,109 **** } /////////////////////////////////////////////////////////////// ! DWORD *PortParameters::GetFlagPtr(DWORD bit) { switch (bit) { --- 127,131 ---- } /////////////////////////////////////////////////////////////// ! DWORD *PortParameters::GetDwPtr(DWORD bit) { switch (bit) { *************** *** 112,115 **** --- 134,141 ---- case m_plugInMode: return &plugInMode; case m_exclusiveMode: return &exclusiveMode; + case m_pinCTS: return &pinCTS; + case m_pinDSR: return &pinDSR; + case m_pinDCD: return &pinDCD; + case m_pinRI: return &pinRI; } *************** *** 125,128 **** --- 151,158 ---- case m_plugInMode: return "PlugInMode"; case m_exclusiveMode: return "ExclusiveMode"; + case m_pinCTS: return "cts"; + case m_pinDSR: return "dsr"; + case m_pinDCD: return "dcd"; + case m_pinRI: return "ri"; } *************** *** 130,161 **** } /////////////////////////////////////////////////////////////// ! BOOL PortParameters::SetFlag(const char *pNewFlag, DWORD bit) { ! if (!lstrcmpi(pNewFlag, "*")) return TRUE; DWORD newFlag; ! if (!lstrcmpi(pNewFlag, "yes")) { newFlag = 0xFFFFFFFF; } else ! if (!lstrcmpi(pNewFlag, "no")) { newFlag = 0; } else ! if (!lstrcmpi(pNewFlag, "-")) { newFlag = 0; } else { return FALSE; } ! DWORD *pFlag = GetFlagPtr(bit); if (pFlag == NULL) return FALSE; ! if (lstrcmpi("-", pNewFlag)) { if ((maskExplicit & bit) == 0) { maskExplicit |= bit; --- 160,192 ---- } /////////////////////////////////////////////////////////////// ! BOOL PortParameters::SetFlag(const char *pNewVal, DWORD bit) { ! if (!lstrcmpi(pNewVal, "*")) return TRUE; DWORD newFlag; ! if (!lstrcmpi(pNewVal, "yes")) { newFlag = 0xFFFFFFFF; } else ! if (!lstrcmpi(pNewVal, "no")) { newFlag = 0; } else ! if (!lstrcmpi(pNewVal, "-")) { newFlag = 0; } else { + Trace("Invalid value '%s'\n", pNewVal); return FALSE; } ! DWORD *pFlag = GetDwPtr(bit); if (pFlag == NULL) return FALSE; ! if (lstrcmpi("-", pNewVal)) { if ((maskExplicit & bit) == 0) { maskExplicit |= bit; *************** *** 177,180 **** --- 208,286 ---- } /////////////////////////////////////////////////////////////// + BOOL PortParameters::SetPin(const char *pNewVal, DWORD bit) + { + if (!lstrcmpi(pNewVal, "*")) + return TRUE; + + DWORD newPin; + + if (*pNewVal == '!') { + newPin = C0C_PIN_NEGATIVE; + pNewVal++; + } else { + newPin = 0; + } + + if (!lstrcmpi(pNewVal, "rrts")) { + newPin |= C0C_PIN_RRTS; + } + else + if (!lstrcmpi(pNewVal, "rdtr")) { + newPin |= C0C_PIN_RDTR; + } + else + if (!lstrcmpi(pNewVal, "rout1")) { + newPin |= C0C_PIN_ROUT1; + } + else + if (!lstrcmpi(pNewVal, "lrts")) { + newPin |= C0C_PIN_LRTS; + } + else + if (!lstrcmpi(pNewVal, "ldtr")) { + newPin |= C0C_PIN_LDTR; + } + else + if (!lstrcmpi(pNewVal, "lout1")) { + newPin |= C0C_PIN_LOUT1; + } + else + if (!lstrcmpi(pNewVal, "on")) { + newPin |= C0C_PIN_ON; + } + else + if (!lstrcmpi(pNewVal, "-")) { + newPin = 0; + } + else { + Trace("Invalid value '%s'\n", pNewVal); + return FALSE; + } + + DWORD *pPin = GetDwPtr(bit); + + if (pPin == NULL) + return FALSE; + + if (lstrcmpi("-", pNewVal)) { + if ((maskExplicit & bit) == 0) { + maskExplicit |= bit; + maskChanged |= bit; + } + } else { + if (maskExplicit & bit) { + maskExplicit &= ~bit; + maskChanged |= bit; + } + } + + if (*pPin != newPin) { + *pPin = newPin; + maskChanged |= bit; + } + + return TRUE; + } + /////////////////////////////////////////////////////////////// BOOL PortParameters::FillParametersKey(char *pRegKey, int size) { *************** *** 188,197 **** } /////////////////////////////////////////////////////////////// ! void PortParameters::LoadFlag(HKEY hKey, DWORD bit) { ! DWORD *pFlag = GetFlagPtr(bit); const char *pName = GetBitName(bit); ! if (pFlag == NULL || pName == NULL) return; --- 294,303 ---- } /////////////////////////////////////////////////////////////// ! void PortParameters::LoadDw(HKEY hKey, DWORD bit) { ! DWORD *pDw = GetDwPtr(bit); const char *pName = GetBitName(bit); ! if (pDw == NULL || pName == NULL) return; *************** *** 207,224 **** if (err == ERROR_SUCCESS) { ! *pFlag = buf; maskExplicit |= bit; ! //Trace(" %s=0x%lX\n", pName, (unsigned long)*pFlag); } } /////////////////////////////////////////////////////////////// ! LONG PortParameters::SaveFlag(HKEY hKey, DWORD bit) { if (maskChanged & bit) { ! DWORD *pFlag = GetFlagPtr(bit); const char *pName = GetBitName(bit); ! if (pFlag == NULL || pName == NULL) return ERROR_BAD_COMMAND; --- 313,330 ---- if (err == ERROR_SUCCESS) { ! *pDw = buf; maskExplicit |= bit; ! //Trace(" %s=0x%lX\n", pName, (unsigned long)*pDw); } } /////////////////////////////////////////////////////////////// ! LONG PortParameters::SaveDw(HKEY hKey, DWORD bit) { if (maskChanged & bit) { ! DWORD *pDw = GetDwPtr(bit); const char *pName = GetBitName(bit); ! if (pDw == NULL || pName == NULL) return ERROR_BAD_COMMAND; *************** *** 230,235 **** NULL, REG_DWORD, ! (PBYTE)pFlag, ! sizeof(*pFlag)); } else { err = RegDeleteValue(hKey, pName); --- 336,341 ---- NULL, REG_DWORD, ! (PBYTE)pDw, ! sizeof(*pDw)); } else { err = RegDeleteValue(hKey, pName); *************** *** 243,247 **** maskChanged &= ~bit; ! //Trace(" New %s=0x%lX\n", pName, (unsigned long)*pFlag); } --- 349,353 ---- maskChanged &= ~bit; ! //Trace(" New %s=0x%lX\n", pName, (unsigned long)*pDw); } *************** *** 291,296 **** } ! for (int i = 0 ; i < sizeof(flagBits)/sizeof(flagBits[0]) ; i++) ! LoadFlag(hKey, flagBits[i]); RegCloseKey(hKey); --- 397,407 ---- } ! int i; ! ! for (i = 0 ; i < sizeof(flagBits)/sizeof(flagBits[0]) ; i++) ! LoadDw(hKey, flagBits[i]); ! ! for (i = 0 ; i < sizeof(pinBits)/sizeof(pinBits[0]) ; i++) ! LoadDw(hKey, pinBits[i]); RegCloseKey(hKey); *************** *** 348,353 **** } ! for (int i = 0 ; i < sizeof(flagBits)/sizeof(flagBits[0]) ; i++) { ! if (SaveFlag(hKey, flagBits[i]) != ERROR_SUCCESS) goto err; } --- 459,471 ---- } ! int i; ! ! for (i = 0 ; i < sizeof(flagBits)/sizeof(flagBits[0]) ; i++) { ! if (SaveDw(hKey, flagBits[i]) != ERROR_SUCCESS) ! goto err; ! } ! ! for (i = 0 ; i < sizeof(pinBits)/sizeof(pinBits[0]) ; i++) { ! if (SaveDw(hKey, pinBits[i]) != ERROR_SUCCESS) goto err; } *************** *** 368,375 **** return FALSE; ! for (int i = 0 ; i < sizeof(flagBits)/sizeof(flagBits[0]) ; i++) { if (!tmp.SetFlag(pParameters, flagBits[i])) return FALSE; } } else { char pars[200]; --- 486,500 ---- return FALSE; ! int i; ! ! for (i = 0 ; i < sizeof(flagBits)/sizeof(flagBits[0]) ; i++) { if (!tmp.SetFlag(pParameters, flagBits[i])) return FALSE; } + + for (i = 0 ; i < sizeof(pinBits)/sizeof(pinBits[0]) ; i++) { + if (!tmp.SetPin(pParameters, pinBits[i])) + return FALSE; + } } else { char pars[200]; *************** *** 387,392 **** //Trace("'%s'='%s'\n", pKey, pVal); ! if (!pVal) return FALSE; if (!lstrcmpi(pKey, "PortName")) { --- 512,519 ---- //Trace("'%s'='%s'\n", pKey, pVal); ! if (!pVal) { ! Trace("Missing value for '%s'\n", pKey); return FALSE; + } if (!lstrcmpi(pKey, "PortName")) { *************** *** 398,402 **** for (i = 0 ; i < sizeof(flagBits)/sizeof(flagBits[0]) ; i++) { DWORD bit = flagBits[i]; ! DWORD *pFlag = GetFlagPtr(bit); const char *pName = GetBitName(bit); --- 525,529 ---- for (i = 0 ; i < sizeof(flagBits)/sizeof(flagBits[0]) ; i++) { DWORD bit = flagBits[i]; ! DWORD *pFlag = GetDwPtr(bit); const char *pName = GetBitName(bit); *************** *** 410,415 **** } } ! if (i >= sizeof(flagBits)/sizeof(flagBits[0])) ! return FALSE; } } --- 537,561 ---- } } ! if (i >= sizeof(flagBits)/sizeof(flagBits[0])) { ! for (i = 0 ; i < sizeof(pinBits)/sizeof(pinBits[0]) ; i++) { ! DWORD bit = pinBits[i]; ! DWORD *pPin = GetDwPtr(bit); ! const char *pName = GetBitName(bit); ! ! if (pPin == NULL || pName == NULL) ! continue; ! ! if (!lstrcmpi(pKey, pName)) { ! if (!tmp.SetPin(pVal, bit)) ! return FALSE; ! break; ! } ! } ! ! if (i >= sizeof(pinBits)/sizeof(pinBits[0])) { ! Trace("Invalid parameter '%s'\n", pKey); ! return FALSE; ! } ! } } } *************** *** 433,441 **** size -= len; ! for (int i = 0 ; i < sizeof(flagBits)/sizeof(flagBits[0]) ; i++) { DWORD bit = flagBits[i]; if ((maskExplicit & bit) != 0) { ! DWORD *pFlag = GetFlagPtr(bit); const char *pName = GetBitName(bit); --- 579,589 ---- size -= len; ! int i; ! ! for (i = 0 ; i < sizeof(flagBits)/sizeof(flagBits[0]) ; i++) { DWORD bit = flagBits[i]; if ((maskExplicit & bit) != 0) { ! DWORD *pFlag = GetDwPtr(bit); const char *pName = GetBitName(bit); *************** *** 453,456 **** --- 601,639 ---- } + for (i = 0 ; i < sizeof(pinBits)/sizeof(pinBits[0]) ; i++) { + DWORD bit = pinBits[i]; + + if ((maskExplicit & bit) != 0) { + DWORD *pPin = GetDwPtr(bit); + const char *pName = GetBitName(bit); + + if (pPin == NULL || pName == NULL) + continue; + + const char *pVal = NULL; + + switch (*pPin & ~C0C_PIN_NEGATIVE) { + case C0C_PIN_RRTS: pVal = "rrts"; break; + case C0C_PIN_RDTR: pVal = "rdtr"; break; + case C0C_PIN_ROUT1: pVal = "rout1"; break; + case C0C_PIN_LRTS: pVal = "lrts"; break; + case C0C_PIN_LDTR: pVal = "ldtr"; break; + case C0C_PIN_LOUT1: pVal = "lout1"; break; + case C0C_PIN_ON: pVal = "on"; break; + } + + if (pVal == NULL) + continue; + + len = SNPRINTF(pParameters, size, ",%s=%s%s", pName, (*pPin & C0C_PIN_NEGATIVE) == 0 ? "" : "!", pVal); + + if (len < 0) + return FALSE; + + pParameters += len; + size -= len; + } + } + return TRUE; } *************** *** 480,488 **** " to the paired port (disabled by default)\n" " EmuOverrun={yes|no} - enable/disable buffer overrun (disabled by default)\n" ! " PlugInMode={yes|no} - enable/disable plug-in mode (disabled by default),\n" ! " the plug-in mode port is hidden and can't be open if\n" ! " the paired port is not open\n" ! " ExclusiveMode={yes|no} - enable/disable exclusive mode (disabled by default),\n" ! " the exclusive mode port is hidden if it is open\n" "\n" "Special values:\n" --- 663,679 ---- " to the paired port (disabled by default)\n" " EmuOverrun={yes|no} - enable/disable buffer overrun (disabled by default)\n" ! " PlugInMode={yes|no} - enable/disable plug-in mode, the plug-in mode port\n" ! " is hidden and can't be open if the paired port is\n" ! " not open (disabled by default)\n" ! " ExclusiveMode={yes|no} - enable/disable exclusive mode, the exclusive mode\n" ! " port is hidden if it is open (disabled by default)\n" ! " cts=[!]<p> - wire CTS pin to <p> (rrts by default)\n" ! " dsr=[!]<p> - wire DSR pin to <p> (rdtr by default)\n" ! " dcd=[!]<p> - wire DCD pin to <p> (rdtr by default)\n" ! " ri=[!]<p> - wire RI pin to <p> (!on by default)\n" ! "\n" ! "The possible values of <p> above can be rrts, lrts, rdtr, ldtr, rout1, lout1\n" ! "(remote/local RTS/DTR/OUT1) or on (logical ON). The exclamation sign (!) can\n" ! "be used to invert the value.\n" "\n" "Special values:\n" |
From: Vyacheslav F. <vf...@us...> - 2007-07-03 14:35:49
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv13803 Modified Files: adddev.c com0com.h handflow.c io.c ioctl.c openclos.c sources Added Files: pinouts.c Log Message: Implemented pinout customization --- NEW FILE: pinouts.c --- /* * $Id: pinouts.c,v 1.1 2007/07/03 14:35:17 vfrolov Exp $ * * Copyright (c) 2007 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: pinouts.c,v $ * Revision 1.1 2007/07/03 14:35:17 vfrolov * Implemented pinout customization * * */ #include "precomp.h" /* * FILE_ID used by HALT_UNLESS to put it on BSOD */ #define FILE_ID 0xE VOID SetModemControl( IN PC0C_IO_PORT pIoPort, IN UCHAR bits, IN UCHAR mask, PLIST_ENTRY pQueueToComplete) { UCHAR modemControlOld; UCHAR modemControlNew; UCHAR modemControlChanged; modemControlOld = modemControlNew = pIoPort->modemControl; modemControlNew |= bits & mask; modemControlNew &= ~(~bits & mask); modemControlChanged = modemControlOld ^ modemControlNew; if (modemControlChanged) { UCHAR bitsStatusRemote, maskStatusRemote; UCHAR bitsStatusLocal, maskStatusLocal; pIoPort->modemControl = modemControlNew; bitsStatusRemote = maskStatusRemote = 0; bitsStatusLocal = maskStatusLocal = 0; #define SET_PIN_OUTS(pin) \ if (modemControlChanged & C0C_MCR_##pin) { \ maskStatusRemote |= pIoPort->pinOuts[C0C_PIN_OUTS_##pin].remote.positive | \ pIoPort->pinOuts[C0C_PIN_OUTS_##pin].remote.negative; \ maskStatusLocal |= pIoPort->pinOuts[C0C_PIN_OUTS_##pin].local.positive | \ pIoPort->pinOuts[C0C_PIN_OUTS_##pin].local.negative; \ if (modemControlNew & C0C_MCR_##pin) { \ bitsStatusRemote |= pIoPort->pinOuts[C0C_PIN_OUTS_##pin].remote.positive; \ bitsStatusLocal |= pIoPort->pinOuts[C0C_PIN_OUTS_##pin].local.positive; \ } else { \ bitsStatusRemote |= pIoPort->pinOuts[C0C_PIN_OUTS_##pin].remote.negative; \ bitsStatusLocal |= pIoPort->pinOuts[C0C_PIN_OUTS_##pin].local.negative; \ } \ } SET_PIN_OUTS(RTS); SET_PIN_OUTS(DTR); SET_PIN_OUTS(OUT1); #undef SET_PIN_OUTS if (maskStatusRemote) SetModemStatus(pIoPort->pIoPortRemote, bitsStatusRemote, maskStatusRemote, pQueueToComplete); if (maskStatusLocal) SetModemStatus(pIoPort, bitsStatusLocal, maskStatusLocal, pQueueToComplete); } } VOID PinWire( PC0C_IO_PORT pIoPortLocal, PC0C_IO_PORT pIoPortRemote, ULONG pinSrc, UCHAR pinDst, PUCHAR pModemStatus) { switch (pinSrc) { case C0C_PIN_ON: *pModemStatus |= pinDst; break; case C0C_PIN_ON|C0C_PIN_NEGATIVE: *pModemStatus &= ~pinDst; break; #define CASE_PIN(pin) \ case C0C_PIN_R##pin: \ pIoPortRemote->pinOuts[C0C_PIN_OUTS_##pin].remote.positive |= pinDst; \ if (pIoPortRemote->modemControl & C0C_MCR_##pin) \ *pModemStatus |= pinDst; \ else \ *pModemStatus &= ~pinDst; \ break; \ case C0C_PIN_L##pin: \ pIoPortLocal->pinOuts[C0C_PIN_OUTS_##pin].local.positive |= pinDst; \ if (pIoPortLocal->modemControl & C0C_MCR_##pin) \ *pModemStatus |= pinDst; \ else \ *pModemStatus &= ~pinDst; \ break; \ case C0C_PIN_R##pin|C0C_PIN_NEGATIVE: \ pIoPortRemote->pinOuts[C0C_PIN_OUTS_##pin].remote.negative |= pinDst; \ if (pIoPortRemote->modemControl & C0C_MCR_##pin) \ *pModemStatus &= ~pinDst; \ else \ *pModemStatus |= pinDst; \ break; \ case C0C_PIN_L##pin|C0C_PIN_NEGATIVE: \ pIoPortLocal->pinOuts[C0C_PIN_OUTS_##pin].local.negative |= pinDst; \ if (pIoPortLocal->modemControl & C0C_MCR_##pin) \ *pModemStatus &= ~pinDst; \ else \ *pModemStatus |= pinDst; \ break; CASE_PIN(RTS) CASE_PIN(DTR) CASE_PIN(OUT1) #undef CASE_PIN } } VOID PinMap( IN PC0C_IO_PORT pIoPort, IN ULONG pinCTS, IN ULONG pinDSR, IN ULONG pinDCD, IN ULONG pinRI) { PC0C_IO_PORT pIoPortRemote; int i; for (i = 0 ; i < sizeof(pIoPort->pinOuts)/sizeof(pIoPort->pinOuts[0]) ; i++) RtlZeroMemory(&pIoPort->pinOuts[i].local, sizeof(pIoPort->pinOuts[i].local)); pIoPortRemote = pIoPort->pIoPortRemote; for (i = 0 ; i < sizeof(pIoPortRemote->pinOuts)/sizeof(pIoPortRemote->pinOuts[0]) ; i++) RtlZeroMemory(&pIoPortRemote->pinOuts[i].remote, sizeof(pIoPortRemote->pinOuts[i].remote)); if (!pinCTS) pinCTS = C0C_PIN_RRTS; PinWire(pIoPort, pIoPortRemote, pinCTS, C0C_MSB_CTS, &pIoPort->modemStatus); if (!pinDSR) pinDSR = C0C_PIN_RDTR; PinWire(pIoPort, pIoPortRemote, pinDSR, C0C_MSB_DSR, &pIoPort->modemStatus); if (!pinDCD) pinDCD = C0C_PIN_RDTR; PinWire(pIoPort, pIoPortRemote, pinDCD, C0C_MSB_RLSD, &pIoPort->modemStatus); if (!pinRI) pinRI = C0C_PIN_ON|C0C_PIN_NEGATIVE; PinWire(pIoPort, pIoPortRemote, pinRI, C0C_MSB_RING, &pIoPort->modemStatus); } Index: openclos.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/openclos.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** openclos.c 4 Jun 2007 15:24:32 -0000 1.18 --- openclos.c 3 Jul 2007 14:35:17 -0000 1.19 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.19 2007/07/03 14:35:17 vfrolov + * Implemented pinout customization + * * Revision 1.18 2007/06/04 15:24:32 vfrolov * Fixed open reject just after close in exclusiveMode *************** *** 219,223 **** pIoPort->writeHoldingRemote = 0; pIoPort->sendXonXoff = 0; ! SetModemStatus(pIoPort->pIoPortRemote, 0, C0C_MSB_CTS | C0C_MSB_DSR, &queueToComplete); FreeBuffer(&pIoPort->readBuf); SetBreakHolding(pIoPort, FALSE); --- 222,226 ---- pIoPort->writeHoldingRemote = 0; pIoPort->sendXonXoff = 0; ! SetModemControl(pIoPort, 0, C0C_MCR_RTS | C0C_MCR_DTR, &queueToComplete); FreeBuffer(&pIoPort->readBuf); SetBreakHolding(pIoPort, FALSE); Index: ioctl.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/ioctl.c,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** ioctl.c 1 Jun 2007 08:36:26 -0000 1.30 --- ioctl.c 3 Jul 2007 14:35:17 -0000 1.31 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.31 2007/07/03 14:35:17 vfrolov + * Implemented pinout customization + * * Revision 1.30 2007/06/01 08:36:26 vfrolov * Changed parameter type for SetWriteDelay() *************** *** 162,169 **** InitializeListHead(&queueToComplete); ! SetModemStatus( ! pIoPortLocal->pIoPortRemote, ! code == IOCTL_SERIAL_SET_RTS ? C0C_MSB_CTS : 0, ! C0C_MSB_CTS, &queueToComplete); --- 165,172 ---- InitializeListHead(&queueToComplete); ! SetModemControl( ! pIoPortLocal, ! code == IOCTL_SERIAL_SET_RTS ? C0C_MCR_RTS : 0, ! C0C_MCR_RTS, &queueToComplete); *************** *** 193,200 **** InitializeListHead(&queueToComplete); ! SetModemStatus( ! pIoPortLocal->pIoPortRemote, ! code == IOCTL_SERIAL_SET_DTR ? C0C_MSB_DSR : 0, ! C0C_MSB_DSR, &queueToComplete); --- 196,203 ---- InitializeListHead(&queueToComplete); ! SetModemControl( ! pIoPortLocal, ! code == IOCTL_SERIAL_SET_DTR ? C0C_MCR_DTR : 0, ! C0C_MCR_DTR, &queueToComplete); *************** *** 213,217 **** case IOCTL_SERIAL_GET_MODEM_CONTROL: case IOCTL_SERIAL_GET_DTRRTS: { ! ULONG modemStatusRemote; if (pIrpStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(ULONG)) { --- 216,220 ---- case IOCTL_SERIAL_GET_MODEM_CONTROL: case IOCTL_SERIAL_GET_DTRRTS: { ! ULONG modemControl; if (pIrpStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(ULONG)) { *************** *** 221,234 **** KeAcquireSpinLock(pIoPortLocal->pIoLock, &oldIrql); ! modemStatusRemote = pIoPortLocal->pIoPortRemote->modemStatus; KeReleaseSpinLock(pIoPortLocal->pIoLock, oldIrql); ! *(PULONG)pIrp->AssociatedIrp.SystemBuffer = ! ((modemStatusRemote & C0C_MSB_DSR) ? SERIAL_DTR_STATE : 0) | ! ((modemStatusRemote & C0C_MSB_CTS) ? SERIAL_RTS_STATE : 0); ! ! if (code == IOCTL_SERIAL_GET_MODEM_CONTROL) ! *(PULONG)pIrp->AssociatedIrp.SystemBuffer |= 0x8; pIrp->IoStatus.Information = sizeof(ULONG); --- 224,234 ---- KeAcquireSpinLock(pIoPortLocal->pIoLock, &oldIrql); ! modemControl = pIoPortLocal->modemControl; KeReleaseSpinLock(pIoPortLocal->pIoLock, oldIrql); ! if (code == IOCTL_SERIAL_GET_DTRRTS) ! modemControl &= SERIAL_DTR_STATE | SERIAL_RTS_STATE; + *(PULONG)pIrp->AssociatedIrp.SystemBuffer = modemControl; pIrp->IoStatus.Information = sizeof(ULONG); Index: io.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/io.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** io.c 9 Jun 2007 08:49:47 -0000 1.33 --- io.c 3 Jul 2007 14:35:17 -0000 1.34 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.34 2007/07/03 14:35:17 vfrolov + * Implemented pinout customization + * * Revision 1.33 2007/06/09 08:49:47 vfrolov * Improved baudrate emulation *************** *** 881,891 **** } - readBufBusyEnd = C0C_BUFFER_BUSY(&pIoPortRead->readBuf); - - if (readBufBusyBeg > readBufBusyEnd) { - UpdateHandFlow(pIoPortRead, TRUE, pQueueToComplete); - readBufBusyBeg = readBufBusyEnd; - } - /* get char */ --- 884,887 ---- *************** *** 1084,1102 **** pQueueToComplete, pWriteLimit, &done); - readBufBusyEnd = C0C_BUFFER_BUSY(&pIoPortRead->readBuf); - - if (readBufBusyBeg < readBufBusyEnd) { - if ((pIoPortRead->waitMask & SERIAL_EV_RX80FULL) && - readBufBusyEnd > pIoPortRead->readBuf.size80 && - readBufBusyBeg <= pIoPortRead->readBuf.size80) - { - pIoPortRead->eventMask |= SERIAL_EV_RX80FULL; - WaitComplete(pIoPortRead, pQueueToComplete); - } - - UpdateHandFlow(pIoPortRead, FALSE, pQueueToComplete); - readBufBusyBeg = readBufBusyEnd; - } - if (pIoPortRead->emuOverrun && dataChar.data.chr.isChr && --- 1080,1083 ---- *************** *** 1161,1179 **** pQueueToComplete, pWriteLimit, &done); - readBufBusyEnd = C0C_BUFFER_BUSY(&pIoPortRead->readBuf); - - if (readBufBusyBeg < readBufBusyEnd) { - if ((pIoPortRead->waitMask & SERIAL_EV_RX80FULL) && - readBufBusyEnd > pIoPortRead->readBuf.size80 && - readBufBusyBeg <= pIoPortRead->readBuf.size80) - { - pIoPortRead->eventMask |= SERIAL_EV_RX80FULL; - WaitComplete(pIoPortRead, pQueueToComplete); - } - - UpdateHandFlow(pIoPortRead, FALSE, pQueueToComplete); - readBufBusyBeg = readBufBusyEnd; - } - if (pIoPortRead->emuOverrun && dataIrpWrite.data.irp.status == STATUS_PENDING && --- 1142,1145 ---- *************** *** 1250,1253 **** --- 1216,1237 ---- } + readBufBusyEnd = C0C_BUFFER_BUSY(&pIoPortRead->readBuf); + + if (readBufBusyBeg > readBufBusyEnd) { + UpdateHandFlow(pIoPortRead, TRUE, pQueueToComplete); + } + else + if (readBufBusyBeg < readBufBusyEnd) { + if ((pIoPortRead->waitMask & SERIAL_EV_RX80FULL) && + readBufBusyEnd > pIoPortRead->readBuf.size80 && + readBufBusyBeg <= pIoPortRead->readBuf.size80) + { + pIoPortRead->eventMask |= SERIAL_EV_RX80FULL; + WaitComplete(pIoPortRead, pQueueToComplete); + } + + UpdateHandFlow(pIoPortRead, FALSE, pQueueToComplete); + } + if (wasWrite && !pQueueWrite->pCurrent && pIoPortWrite->waitMask & SERIAL_EV_TXEMPTY) *************** *** 1271,1274 **** --- 1255,1260 ---- NTSTATUS status; + pIoPortWrite->tryWrite = FALSE; + status = TryReadWrite( pIoPortRead, startRead, *************** *** 1276,1287 **** pQueueToComplete); ! pIoPortWrite->tryWrite = FALSE; ! while (pIoPortRead->tryWrite) { ! PC0C_IO_PORT pIoPortTmp; ! pIoPortTmp = pIoPortRead; ! pIoPortRead = pIoPortWrite; ! pIoPortWrite = pIoPortTmp; TryReadWrite( --- 1262,1275 ---- pQueueToComplete); ! while (pIoPortWrite->tryWrite || pIoPortRead->tryWrite) { ! if (!pIoPortWrite->tryWrite) { ! PC0C_IO_PORT pIoPortTmp; ! pIoPortTmp = pIoPortRead; ! pIoPortRead = pIoPortWrite; ! pIoPortWrite = pIoPortTmp; ! } ! pIoPortWrite->tryWrite = FALSE; TryReadWrite( *************** *** 1289,1297 **** pIoPortWrite, FALSE, pQueueToComplete); - - pIoPortWrite->tryWrite = FALSE; - - if (status == STATUS_PENDING && (startRead || startWrite)) - break; } --- 1277,1280 ---- *************** *** 1301,1325 **** VOID SetModemStatus( IN PC0C_IO_PORT pIoPort, ! IN ULONG bits, ! IN ULONG mask, PLIST_ENTRY pQueueToComplete) { ! ULONG modemStatusOld; ! ULONG modemStatusChanged; ! ! modemStatusOld = pIoPort->modemStatus; ! pIoPort->modemStatus |= bits & mask; ! pIoPort->modemStatus &= ~(~bits & mask); ! /* DCD = DSR */ ! if (pIoPort->modemStatus & C0C_MSB_DSR) ! pIoPort->modemStatus |= C0C_MSB_RLSD; ! else ! pIoPort->modemStatus &= ~C0C_MSB_RLSD; ! modemStatusChanged = modemStatusOld ^ pIoPort->modemStatus; if (modemStatusChanged) { TraceModemStatus(pIoPort); --- 1284,1305 ---- VOID SetModemStatus( IN PC0C_IO_PORT pIoPort, ! IN UCHAR bits, ! IN UCHAR mask, PLIST_ENTRY pQueueToComplete) { ! UCHAR modemStatusOld; ! UCHAR modemStatusNew; ! UCHAR modemStatusChanged; ! modemStatusOld = modemStatusNew = pIoPort->modemStatus; ! modemStatusNew |= bits & mask; ! modemStatusNew &= ~(~bits & mask); ! modemStatusChanged = modemStatusOld ^ modemStatusNew; if (modemStatusChanged) { + pIoPort->modemStatus = modemStatusNew; + TraceModemStatus(pIoPort); Index: com0com.h =================================================================== RCS file: /cvsroot/com0com/com0com/sys/com0com.h,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** com0com.h 4 Jun 2007 15:24:32 -0000 1.35 --- com0com.h 3 Jul 2007 14:35:17 -0000 1.36 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.36 2007/07/03 14:35:17 vfrolov + * Implemented pinout customization + * * Revision 1.35 2007/06/04 15:24:32 vfrolov * Fixed open reject just after close in exclusiveMode *************** *** 206,209 **** --- 209,219 ---- struct _C0C_ADAPTIVE_DELAY; + typedef struct _C0C_PIN_OUTS { + struct { + UCHAR positive; + UCHAR negative; + } remote, local; + } C0C_PIN_OUTS, *PC0C_PIN_OUTS; + typedef struct _C0C_IO_PORT { *************** *** 238,241 **** --- 248,257 ---- struct _C0C_ADAPTIVE_DELAY *pWriteDelay; + #define C0C_PIN_OUTS_RTS 0 + #define C0C_PIN_OUTS_DTR 1 + #define C0C_PIN_OUTS_OUT1 2 + + C0C_PIN_OUTS pinOuts[3]; + SERIAL_HANDFLOW handFlow; SERIAL_CHARS specialChars; *************** *** 254,258 **** #define C0C_MSB_RLSD 0x80 ! ULONG modemStatus; C0C_BUFFER readBuf; --- 270,282 ---- #define C0C_MSB_RLSD 0x80 ! UCHAR modemStatus; ! ! #define C0C_MCR_DTR 0x01 ! #define C0C_MCR_RTS 0x02 ! #define C0C_MCR_OUT1 0x04 ! #define C0C_MCR_OUT2 0x08 ! #define C0C_MCR_LOOP 0x10 ! ! UCHAR modemControl; C0C_BUFFER readBuf; *************** *** 426,433 **** VOID SetModemStatus( IN PC0C_IO_PORT pIoPort, ! IN ULONG bits, ! IN ULONG mask, PLIST_ENTRY pQueueToComplete); #define C0C_TAG 'c0c' #define C0C_ALLOCATE_POOL(PoolType, NumberOfBytes) \ --- 450,470 ---- VOID SetModemStatus( IN PC0C_IO_PORT pIoPort, ! IN UCHAR bits, ! IN UCHAR mask, PLIST_ENTRY pQueueToComplete); + VOID SetModemControl( + IN PC0C_IO_PORT pIoPort, + IN UCHAR bits, + IN UCHAR mask, + PLIST_ENTRY pQueueToComplete); + + VOID PinMap( + IN PC0C_IO_PORT pIoPort, + IN ULONG pinCTS, + IN ULONG pinDSR, + IN ULONG pinDCD, + IN ULONG pinRI); + #define C0C_TAG 'c0c' #define C0C_ALLOCATE_POOL(PoolType, NumberOfBytes) \ Index: adddev.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/adddev.c,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** adddev.c 5 Jun 2007 12:15:08 -0000 1.27 --- adddev.c 3 Jul 2007 14:35:17 -0000 1.28 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.28 2007/07/03 14:35:17 vfrolov + * Implemented pinout customization + * * Revision 1.27 2007/06/05 12:15:08 vfrolov * Fixed memory leak *************** *** 168,171 **** --- 171,175 ---- PC0C_PDOPORT_EXTENSION pPhDevExt; ULONG emuBR, emuOverrun, plugInMode, exclusiveMode; + ULONG pinCTS, pinDSR, pinDCD, pinRI; UNICODE_STRING ntDeviceName; PWCHAR pPortName; *************** *** 241,247 **** emuBR = emuOverrun = plugInMode = exclusiveMode = 0; if (NT_SUCCESS(status)) { ! RTL_QUERY_REGISTRY_TABLE queryTable[5]; ULONG zero = 0; int i; --- 245,252 ---- emuBR = emuOverrun = plugInMode = exclusiveMode = 0; + pinCTS = pinDSR = pinDCD = pinRI = 0; if (NT_SUCCESS(status)) { ! RTL_QUERY_REGISTRY_TABLE queryTable[9]; ULONG zero = 0; int i; *************** *** 249,283 **** RtlZeroMemory(queryTable, sizeof(queryTable)); i = 0; - queryTable[i].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[i].Name = L"EmuBR"; queryTable[i].EntryContext = &emuBR; - queryTable[i].DefaultType = REG_DWORD; - queryTable[i].DefaultData = &zero; - queryTable[i].DefaultLength = sizeof(ULONG); i++; - queryTable[i].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[i].Name = L"EmuOverrun"; queryTable[i].EntryContext = &emuOverrun; - queryTable[i].DefaultType = REG_DWORD; - queryTable[i].DefaultData = &zero; - queryTable[i].DefaultLength = sizeof(ULONG); i++; - queryTable[i].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[i].Name = L"PlugInMode"; queryTable[i].EntryContext = &plugInMode; - queryTable[i].DefaultType = REG_DWORD; - queryTable[i].DefaultData = &zero; - queryTable[i].DefaultLength = sizeof(ULONG); i++; - queryTable[i].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[i].Name = L"ExclusiveMode"; queryTable[i].EntryContext = &exclusiveMode; ! queryTable[i].DefaultType = REG_DWORD; ! queryTable[i].DefaultData = &zero; ! queryTable[i].DefaultLength = sizeof(ULONG); RtlQueryRegistryValues( --- 254,295 ---- RtlZeroMemory(queryTable, sizeof(queryTable)); + for (i = 0 ; i < (sizeof(queryTable)/sizeof(queryTable[0]) - 1) ; i++) { + queryTable[i].Flags = RTL_QUERY_REGISTRY_DIRECT; + queryTable[i].DefaultType = REG_DWORD; + queryTable[i].DefaultData = &zero; + queryTable[i].DefaultLength = sizeof(ULONG); + } + i = 0; queryTable[i].Name = L"EmuBR"; queryTable[i].EntryContext = &emuBR; i++; queryTable[i].Name = L"EmuOverrun"; queryTable[i].EntryContext = &emuOverrun; i++; queryTable[i].Name = L"PlugInMode"; queryTable[i].EntryContext = &plugInMode; i++; queryTable[i].Name = L"ExclusiveMode"; queryTable[i].EntryContext = &exclusiveMode; ! ! i++; ! queryTable[i].Name = L"cts"; ! queryTable[i].EntryContext = &pinCTS; ! ! i++; ! queryTable[i].Name = L"dsr"; ! queryTable[i].EntryContext = &pinDSR; ! ! i++; ! queryTable[i].Name = L"dcd"; ! queryTable[i].EntryContext = &pinDCD; ! ! i++; ! queryTable[i].Name = L"ri"; ! queryTable[i].EntryContext = &pinRI; RtlQueryRegistryValues( *************** *** 375,378 **** --- 387,394 ---- SetWriteDelay(pDevExt); + pDevExt->pIoPortLocal->modemControl |= C0C_MCR_OUT2; + + PinMap(pDevExt->pIoPortLocal, pinCTS, pinDSR, pinDCD, pinRI); + pDevExt->pLowDevObj = IoAttachDeviceToDeviceStack(pNewDevObj, pPhDevObj); Index: sources =================================================================== RCS file: /cvsroot/com0com/com0com/sys/sources,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** sources 1 Jun 2007 16:22:40 -0000 1.8 --- sources 3 Jul 2007 14:35:17 -0000 1.9 *************** *** 21,24 **** --- 21,25 ---- fileinfo.c \ io.c \ + pinouts.c \ handflow.c \ startirp.c \ Index: handflow.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/handflow.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** handflow.c 21 Jun 2006 16:23:57 -0000 1.7 --- handflow.c 3 Jul 2007 14:35:17 -0000 1.8 *************** *** 2,6 **** * $Id$ * ! * Copyright (c) 2005-2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify --- 2,6 ---- * $Id$ * ! * Copyright (c) 2005-2007 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.8 2007/07/03 14:35:17 vfrolov + * Implemented pinout customization + * * Revision 1.7 2006/06/21 16:23:57 vfrolov * Fixed possible BSOD after one port of pair removal *************** *** 59,63 **** PLIST_ENTRY pQueueToComplete) { ! ULONG bits, mask; PC0C_BUFFER pReadBuf; PSERIAL_HANDFLOW pNewHandFlow; --- 62,66 ---- PLIST_ENTRY pQueueToComplete) { ! UCHAR bits, mask; PC0C_BUFFER pReadBuf; PSERIAL_HANDFLOW pNewHandFlow; *************** *** 106,120 **** case 0: pIoPort->writeHoldingRemote &= ~SERIAL_TX_WAITING_FOR_CTS; ! mask |= C0C_MSB_CTS; // Turn off CTS on remote side if RTS is disabled break; case SERIAL_RTS_CONTROL: pIoPort->writeHoldingRemote &= ~SERIAL_TX_WAITING_FOR_CTS; ! bits |= C0C_MSB_CTS; ! mask |= C0C_MSB_CTS; break; case SERIAL_RTS_HANDSHAKE: if (C0C_BUFFER_BUSY(pReadBuf) > (C0C_BUFFER_SIZE(pReadBuf) - pNewHandFlow->XoffLimit)) { pIoPort->writeHoldingRemote |= SERIAL_TX_WAITING_FOR_CTS; ! mask |= C0C_MSB_CTS; } else --- 109,123 ---- case 0: pIoPort->writeHoldingRemote &= ~SERIAL_TX_WAITING_FOR_CTS; ! mask |= C0C_MCR_RTS; break; case SERIAL_RTS_CONTROL: pIoPort->writeHoldingRemote &= ~SERIAL_TX_WAITING_FOR_CTS; ! bits |= C0C_MCR_RTS; ! mask |= C0C_MCR_RTS; break; case SERIAL_RTS_HANDSHAKE: if (C0C_BUFFER_BUSY(pReadBuf) > (C0C_BUFFER_SIZE(pReadBuf) - pNewHandFlow->XoffLimit)) { pIoPort->writeHoldingRemote |= SERIAL_TX_WAITING_FOR_CTS; ! mask |= C0C_MCR_RTS; } else *************** *** 122,132 **** if (C0C_BUFFER_BUSY(pReadBuf) <= (SIZE_T)pNewHandFlow->XonLimit) { pIoPort->writeHoldingRemote &= ~SERIAL_TX_WAITING_FOR_CTS; ! bits |= C0C_MSB_CTS; ! mask |= C0C_MSB_CTS; } } else { ! bits |= C0C_MSB_CTS; ! mask |= C0C_MSB_CTS; } } --- 125,135 ---- if (C0C_BUFFER_BUSY(pReadBuf) <= (SIZE_T)pNewHandFlow->XonLimit) { pIoPort->writeHoldingRemote &= ~SERIAL_TX_WAITING_FOR_CTS; ! bits |= C0C_MCR_RTS; ! mask |= C0C_MCR_RTS; } } else { ! bits |= C0C_MCR_RTS; ! mask |= C0C_MCR_RTS; } } *************** *** 140,154 **** case 0: pIoPort->writeHoldingRemote &= ~SERIAL_TX_WAITING_FOR_DSR; ! mask |= C0C_MSB_DSR; // Turn off DSR on remote side if DTR is disabled break; case SERIAL_DTR_CONTROL: pIoPort->writeHoldingRemote &= ~SERIAL_TX_WAITING_FOR_DSR; ! bits |= C0C_MSB_DSR; ! mask |= C0C_MSB_DSR; break; case SERIAL_DTR_HANDSHAKE: if (C0C_BUFFER_BUSY(pReadBuf) > (C0C_BUFFER_SIZE(pReadBuf) - pNewHandFlow->XoffLimit)) { pIoPort->writeHoldingRemote |= SERIAL_TX_WAITING_FOR_DSR; ! mask |= C0C_MSB_DSR; } else --- 143,157 ---- case 0: pIoPort->writeHoldingRemote &= ~SERIAL_TX_WAITING_FOR_DSR; ! mask |= C0C_MCR_DTR; break; case SERIAL_DTR_CONTROL: pIoPort->writeHoldingRemote &= ~SERIAL_TX_WAITING_FOR_DSR; ! bits |= C0C_MCR_DTR; ! mask |= C0C_MCR_DTR; break; case SERIAL_DTR_HANDSHAKE: if (C0C_BUFFER_BUSY(pReadBuf) > (C0C_BUFFER_SIZE(pReadBuf) - pNewHandFlow->XoffLimit)) { pIoPort->writeHoldingRemote |= SERIAL_TX_WAITING_FOR_DSR; ! mask |= C0C_MCR_DTR; } else *************** *** 156,166 **** if (C0C_BUFFER_BUSY(pReadBuf) <= (SIZE_T)pNewHandFlow->XonLimit) { pIoPort->writeHoldingRemote &= ~SERIAL_TX_WAITING_FOR_DSR; ! bits |= C0C_MSB_DSR; ! mask |= C0C_MSB_DSR; } } else { ! bits |= C0C_MSB_DSR; ! mask |= C0C_MSB_DSR; } } --- 159,169 ---- if (C0C_BUFFER_BUSY(pReadBuf) <= (SIZE_T)pNewHandFlow->XonLimit) { pIoPort->writeHoldingRemote &= ~SERIAL_TX_WAITING_FOR_DSR; ! bits |= C0C_MCR_DTR; ! mask |= C0C_MCR_DTR; } } else { ! bits |= C0C_MCR_DTR; ! mask |= C0C_MCR_DTR; } } *************** *** 202,206 **** if (mask) ! SetModemStatus(pIoPort->pIoPortRemote, bits, mask, pQueueToComplete); UpdateTransmitToggle(pIoPort, pQueueToComplete); --- 205,209 ---- if (mask) ! SetModemControl(pIoPort, bits, mask, pQueueToComplete); UpdateTransmitToggle(pIoPort, pQueueToComplete); *************** *** 231,235 **** PLIST_ENTRY pQueueToComplete) { ! ULONG bits, mask; PC0C_BUFFER pReadBuf; PSERIAL_HANDFLOW pHandFlowLocal, pHandFlowRemote; --- 234,238 ---- PLIST_ENTRY pQueueToComplete) { ! UCHAR bits, mask; PC0C_BUFFER pReadBuf; PSERIAL_HANDFLOW pHandFlowLocal, pHandFlowRemote; *************** *** 245,254 **** if ((pHandFlowLocal->FlowReplace & SERIAL_RTS_MASK) == SERIAL_RTS_HANDSHAKE) { pIoPort->writeHoldingRemote |= SERIAL_TX_WAITING_FOR_CTS; ! mask |= C0C_MSB_CTS; } if ((pHandFlowLocal->ControlHandShake & SERIAL_DTR_MASK) == SERIAL_DTR_HANDSHAKE) { pIoPort->writeHoldingRemote |= SERIAL_TX_WAITING_FOR_DSR; ! mask |= C0C_MSB_DSR; } --- 248,257 ---- if ((pHandFlowLocal->FlowReplace & SERIAL_RTS_MASK) == SERIAL_RTS_HANDSHAKE) { pIoPort->writeHoldingRemote |= SERIAL_TX_WAITING_FOR_CTS; ! mask |= C0C_MCR_RTS; } if ((pHandFlowLocal->ControlHandShake & SERIAL_DTR_MASK) == SERIAL_DTR_HANDSHAKE) { pIoPort->writeHoldingRemote |= SERIAL_TX_WAITING_FOR_DSR; ! mask |= C0C_MCR_DTR; } *************** *** 265,276 **** if ((pHandFlowLocal->FlowReplace & SERIAL_RTS_MASK) == SERIAL_RTS_HANDSHAKE) { pIoPort->writeHoldingRemote &= ~SERIAL_TX_WAITING_FOR_CTS; ! bits |= C0C_MSB_CTS; ! mask |= C0C_MSB_CTS; } if ((pHandFlowLocal->ControlHandShake & SERIAL_DTR_MASK) == SERIAL_DTR_HANDSHAKE) { pIoPort->writeHoldingRemote &= ~SERIAL_TX_WAITING_FOR_DSR; ! bits |= C0C_MSB_DSR; ! mask |= C0C_MSB_DSR; } --- 268,279 ---- if ((pHandFlowLocal->FlowReplace & SERIAL_RTS_MASK) == SERIAL_RTS_HANDSHAKE) { pIoPort->writeHoldingRemote &= ~SERIAL_TX_WAITING_FOR_CTS; ! bits |= C0C_MCR_RTS; ! mask |= C0C_MCR_RTS; } if ((pHandFlowLocal->ControlHandShake & SERIAL_DTR_MASK) == SERIAL_DTR_HANDSHAKE) { pIoPort->writeHoldingRemote &= ~SERIAL_TX_WAITING_FOR_DSR; ! bits |= C0C_MCR_DTR; ! mask |= C0C_MCR_DTR; } *************** *** 285,289 **** if (mask) ! SetModemStatus(pIoPort->pIoPortRemote, bits, mask, pQueueToComplete); } --- 288,292 ---- if (mask) ! SetModemControl(pIoPort, bits, mask, pQueueToComplete); } *************** *** 293,307 **** { if ((pIoPort->handFlow.FlowReplace & SERIAL_RTS_MASK) == SERIAL_TRANSMIT_TOGGLE) { ! ULONG bits; if ((pIoPort->writeHolding & SERIAL_TX_WAITING_ON_BREAK) == 0 && (pIoPort->sendXonXoff || pIoPort->irpQueues[C0C_QUEUE_WRITE].pCurrent)) { ! bits = C0C_MSB_CTS; } else { bits = 0; } ! SetModemStatus(pIoPort->pIoPortRemote, bits, C0C_MSB_CTS, pQueueToComplete); } } --- 296,310 ---- { if ((pIoPort->handFlow.FlowReplace & SERIAL_RTS_MASK) == SERIAL_TRANSMIT_TOGGLE) { ! UCHAR bits; if ((pIoPort->writeHolding & SERIAL_TX_WAITING_ON_BREAK) == 0 && (pIoPort->sendXonXoff || pIoPort->irpQueues[C0C_QUEUE_WRITE].pCurrent)) { ! bits = C0C_MCR_RTS; } else { bits = 0; } ! SetModemControl(pIoPort, bits, C0C_MCR_RTS, pQueueToComplete); } } |
From: Vyacheslav F. <vf...@us...> - 2007-07-03 14:25:17
|
Update of /cvsroot/com0com/com0com/include In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv9967 Modified Files: com0com.h Log Message: Implemented pinout customization Index: com0com.h =================================================================== RCS file: /cvsroot/com0com/com0com/include/com0com.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** com0com.h 3 Nov 2006 13:06:33 -0000 1.3 --- com0com.h 3 Jul 2007 14:25:12 -0000 1.4 *************** *** 2,6 **** * $Id$ * ! * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify --- 2,6 ---- * $Id$ * ! * Copyright (c) 2006-2007 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.4 2007/07/03 14:25:12 vfrolov + * Implemented pinout customization + * * Revision 1.3 2006/11/03 13:06:33 vfrolov * Moved C0C_PORT_NAME_LEN from sys/com0com.h to include/com0com.h *************** *** 48,50 **** --- 51,62 ---- #define C0C_REGSTR_VAL_PORT_NUM TEXT_PREF"PortNum" + #define C0C_PIN_RRTS 0x00000001 + #define C0C_PIN_RDTR 0x00000002 + #define C0C_PIN_ROUT1 0x00000004 + #define C0C_PIN_LRTS 0x00000100 + #define C0C_PIN_LDTR 0x00000200 + #define C0C_PIN_LOUT1 0x00000400 + #define C0C_PIN_ON 0x10000000 + #define C0C_PIN_NEGATIVE 0x80000000 + #endif /* _INCLUDE_C0C_COM0COM_H_ */ |
From: Vyacheslav F. <vf...@us...> - 2007-06-20 10:37:54
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv13713 Modified Files: startirp.c Log Message: Fixed double decrementing of amountInWriteQueue on CANCEL Index: startirp.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/startirp.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** startirp.c 4 Jun 2007 15:24:33 -0000 1.17 --- startirp.c 20 Jun 2007 10:37:47 -0000 1.18 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.18 2007/06/20 10:37:47 vfrolov + * Fixed double decrementing of amountInWriteQueue on CANCEL + * * Revision 1.17 2007/06/04 15:24:33 vfrolov * Fixed open reject just after close in exclusiveMode *************** *** 161,169 **** KeAcquireSpinLock(pIoPort->pIoLock, &oldIrql); - if (pState->iQueue == C0C_QUEUE_WRITE) { - pIoPort->amountInWriteQueue -= - GetWriteLength(pIrp) - (ULONG)pIrp->IoStatus.Information; - } - if (pState->flags & C0C_IRP_FLAG_IN_QUEUE) { RemoveEntryList(&pIrp->Tail.Overlay.ListEntry); --- 164,167 ---- |
From: Vyacheslav F. <vf...@us...> - 2007-06-20 10:32:47
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv11830 Modified Files: trace.c Log Message: Added PID tracing on IRP_MJ_CREATE Index: trace.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/trace.c,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** trace.c 5 Jun 2007 12:26:38 -0000 1.27 --- trace.c 20 Jun 2007 10:32:44 -0000 1.28 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.28 2007/06/20 10:32:44 vfrolov + * Added PID tracing on IRP_MJ_CREATE + * * Revision 1.27 2007/06/05 12:26:38 vfrolov * Allocate trace buffers only if trace enabled *************** *** 1378,1381 **** --- 1381,1388 ---- switch (major) { + case IRP_MJ_CREATE: + if (flags & TRACE_FLAG_PARAMS) + pDestStr = AnsiStrFormat(pDestStr, &size, ", PID:%lu", PtrToUlong(PsGetCurrentProcessId())); + break; case IRP_MJ_WRITE: case IRP_MJ_READ: |
From: Vyacheslav F. <vf...@us...> - 2007-06-20 10:30:55
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv11066 Modified Files: version.h Log Message: Post-tagging version change Index: version.h =================================================================== RCS file: /cvsroot/com0com/com0com/sys/version.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** version.h 15 Jun 2007 09:48:03 -0000 1.10 --- version.h 20 Jun 2007 10:30:48 -0000 1.11 *************** *** 28,32 **** #define C0C_V2 8 #define C0C_V3 0 ! #define C0C_V4 0 #define MK_VERSION_STR1(V1, V2, V3, V4) #V1 "." #V2 "." #V3 "." #V4 --- 28,32 ---- #define C0C_V2 8 #define C0C_V3 0 ! #define C0C_V4 1 #define MK_VERSION_STR1(V1, V2, V3, V4) #V1 "." #V2 "." #V3 "." #V4 |
From: Vyacheslav F. <vf...@us...> - 2007-06-15 09:48:10
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv12689 Modified Files: version.h Log Message: Pre-tagging version change Index: version.h =================================================================== RCS file: /cvsroot/com0com/com0com/sys/version.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** version.h 11 Jan 2007 14:39:08 -0000 1.9 --- version.h 15 Jun 2007 09:48:03 -0000 1.10 *************** *** 26,32 **** #define C0C_V1 1 ! #define C0C_V2 7 #define C0C_V3 0 ! #define C0C_V4 1 #define MK_VERSION_STR1(V1, V2, V3, V4) #V1 "." #V2 "." #V3 "." #V4 --- 26,32 ---- #define C0C_V1 1 ! #define C0C_V2 8 #define C0C_V3 0 ! #define C0C_V4 0 #define MK_VERSION_STR1(V1, V2, V3, V4) #V1 "." #V2 "." #V3 "." #V4 |
From: Vyacheslav F. <vf...@us...> - 2007-06-15 09:45:59
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv11745 Modified Files: inffile.cpp Log Message: Increased list size for SetupGetInfFileList() Index: inffile.cpp =================================================================== RCS file: /cvsroot/com0com/com0com/setup/inffile.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** inffile.cpp 14 Jun 2007 16:11:01 -0000 1.3 --- inffile.cpp 15 Jun 2007 09:45:50 -0000 1.4 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.4 2007/06/15 09:45:50 vfrolov + * Increased list size for SetupGetInfFileList() + * * Revision 1.3 2007/06/14 16:11:01 vfrolov * Added Scan INF files progress indication *************** *** 420,423 **** --- 423,427 ---- Trace("..."); + size += 256; // possible new INF files were added since char *pList = (char *)LocalAlloc(LPTR, size*sizeof(pList[0])); *************** *** 428,432 **** Trace("\n"); ! ShowError(MB_OK|MB_ICONSTOP, err, "SetupGetInfFileList()"); LocalFree(pList); return FALSE; --- 432,436 ---- Trace("\n"); ! ShowError(MB_OK|MB_ICONSTOP, err, "SetupGetInfFileList(%lu)", (unsigned long)size); LocalFree(pList); return FALSE; *************** *** 437,441 **** Trace("\n"); ! ShowError(MB_OK|MB_ICONSTOP, err, "LocalAlloc()"); return FALSE; } --- 441,445 ---- Trace("\n"); ! ShowError(MB_OK|MB_ICONSTOP, err, "LocalAlloc(%lu)", (unsigned long)size); return FALSE; } |
From: Vyacheslav F. <vf...@us...> - 2007-06-14 16:14:22
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv21696 Modified Files: setup.cpp sources Log Message: Added test for "in use" in the COM port database Index: sources =================================================================== RCS file: /cvsroot/com0com/com0com/setup/sources,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sources 15 Jan 2007 16:23:49 -0000 1.4 --- sources 14 Jun 2007 16:14:19 -0000 1.5 *************** *** 23,26 **** --- 23,27 ---- $(DDK_LIB_PATH)\newdev.lib \ $(DDK_LIB_PATH)\user32.lib \ + $(DDK_LIB_PATH)\msports.lib \ PRECOMPILED_INCLUDE=precomp.h Index: setup.cpp =================================================================== RCS file: /cvsroot/com0com/com0com/setup/setup.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** setup.cpp 29 May 2007 15:30:41 -0000 1.13 --- setup.cpp 14 Jun 2007 16:14:19 -0000 1.14 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.14 2007/06/14 16:14:19 vfrolov + * Added test for "in use" in the COM port database + * * Revision 1.13 2007/05/29 15:30:41 vfrolov * Fixed big hepl text interrupt *************** *** 74,77 **** --- 77,81 ---- #include "utils.h" #include "portnum.h" + #include <msports.h> #define TEXT_PREF *************** *** 130,135 **** if (!QueryDosDevice(pPortName, phDevName, sizeof(phDevName)/sizeof(phDevName[0]))) { ! if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) ! break; phDevName[0] = 0; --- 134,202 ---- if (!QueryDosDevice(pPortName, phDevName, sizeof(phDevName)/sizeof(phDevName[0]))) { ! if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { ! if ((pPortName[0] == 'C' || pPortName[0] == 'c') && ! (pPortName[1] == 'O' || pPortName[1] == 'o') && ! (pPortName[2] == 'M' || pPortName[2] == 'm')) ! { ! int num; ! ! if (StrToInt(pPortName + 3, &num) && num > 0) { ! HCOMDB hComDB; ! LONG err; ! ! err = ComDBOpen(&hComDB); ! ! if (err != ERROR_SUCCESS) { ! res = ShowLastError(MB_CANCELTRYCONTINUE, "ComDBOpen()"); ! continue; ! } ! ! DWORD maxPortsReported; ! ! err = ComDBGetCurrentPortUsage(hComDB, NULL, 0, CDB_REPORT_BYTES, &maxPortsReported); ! ! if (err != ERROR_SUCCESS) { ! ComDBClose(hComDB); ! res = ShowError(MB_CANCELTRYCONTINUE, err, "ComDBGetCurrentPortUsage()"); ! continue; ! } ! ! if (maxPortsReported < (DWORD)num) { ! ComDBClose(hComDB); ! continue; ! } ! ! if (maxPortsReported > (DWORD)num) ! maxPortsReported = num; ! ! BYTE *pBuf = (BYTE *)LocalAlloc(LPTR, maxPortsReported); ! ! if (!pBuf) { ! err = GetLastError(); ! ComDBClose(hComDB); ! res = ShowError(MB_CANCELTRYCONTINUE, err, "LocalAlloc(%lu)", (unsigned long)maxPortsReported); ! continue; ! } ! ! err = ComDBGetCurrentPortUsage(hComDB, pBuf, num, CDB_REPORT_BYTES, &maxPortsReported); ! ComDBClose(hComDB); ! ! if (err != ERROR_SUCCESS) { ! LocalFree(pBuf); ! res = ShowError(MB_CANCELTRYCONTINUE, err, "ComDBGetCurrentPortUsage()"); ! continue; ! } ! ! if (pBuf[num - 1]) ! res = ShowMsg(MB_CANCELTRYCONTINUE, ! "The port name %s is already logged as \"in use\"\n" ! "in the COM port database.", ! pPortName); ! ! LocalFree(pBuf); ! } ! } ! continue; ! } phDevName[0] = 0; |
From: Vyacheslav F. <vf...@us...> - 2007-06-14 16:11:07
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20535 Modified Files: inffile.cpp Log Message: Added Scan INF files progress indication Index: inffile.cpp =================================================================== RCS file: /cvsroot/com0com/com0com/setup/inffile.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** inffile.cpp 19 Oct 2006 13:28:48 -0000 1.2 --- inffile.cpp 14 Jun 2007 16:11:01 -0000 1.3 *************** *** 2,6 **** * $Id$ * ! * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify --- 2,6 ---- * $Id$ * ! * Copyright (c) 2006-2007 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.3 2007/06/14 16:11:01 vfrolov + * Added Scan INF files progress indication + * * Revision 1.2 2006/10/19 13:28:48 vfrolov * Added InfFile::UninstallAllInfFiles() *************** *** 402,425 **** const char *_pProvider) { DWORD size; if (!SetupGetInfFileList(NULL, INF_STYLE_WIN4, NULL, 0, &size)) { ! ShowLastError(MB_OK|MB_ICONSTOP, "SetupGetInfFileList()"); return FALSE; } char *pList = (char *)LocalAlloc(LPTR, size*sizeof(pList[0])); if (pList) { if (!SetupGetInfFileList(NULL, INF_STYLE_WIN4, pList, size, NULL)) { ! ShowLastError(MB_OK|MB_ICONSTOP, "SetupGetInfFileList()"); LocalFree(pList); return FALSE; } } else { ! ShowLastError(MB_OK|MB_ICONSTOP, "LocalAlloc()"); return FALSE; } char windir[MAX_PATH]; --- 405,446 ---- const char *_pProvider) { + Trace("Scan INF files ."); + DWORD size; if (!SetupGetInfFileList(NULL, INF_STYLE_WIN4, NULL, 0, &size)) { ! DWORD err = GetLastError(); ! ! Trace("\n"); ! ! ShowError(MB_OK|MB_ICONSTOP, err, "SetupGetInfFileList()"); return FALSE; } + Trace("..."); + char *pList = (char *)LocalAlloc(LPTR, size*sizeof(pList[0])); if (pList) { if (!SetupGetInfFileList(NULL, INF_STYLE_WIN4, pList, size, NULL)) { ! DWORD err = GetLastError(); ! ! Trace("\n"); ! ! ShowError(MB_OK|MB_ICONSTOP, err, "SetupGetInfFileList()"); LocalFree(pList); return FALSE; } } else { ! DWORD err = GetLastError(); ! ! Trace("\n"); ! ! ShowError(MB_OK|MB_ICONSTOP, err, "LocalAlloc()"); return FALSE; } + Trace("."); + char windir[MAX_PATH]; *************** *** 436,441 **** --- 457,483 ---- char *p = pList; + int i; + int m; + + p = pList; + i = 0; + + do { + i++; + p += lstrlen(p) + 1; + } while (*p); + + m = i/3; + + if (m == 0) + m = 1; + + p = pList; + i = 0; do { + if (++i%m == 0) + Trace("."); + char infPath[MAX_PATH]; *************** *** 459,462 **** --- 501,505 ---- infFile.Provider(FALSE)) == IDYES) { + Trace("\n"); UninstallInf(infFile.Path()); } *************** *** 467,470 **** --- 510,515 ---- } while (*p); + Trace(" done.\n"); + LocalFree(pList); |
From: Vyacheslav F. <vf...@us...> - 2007-06-09 08:49:53
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv6462 Modified Files: delay.c delay.h io.c Log Message: Improved baudrate emulation Index: io.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/io.c,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** io.c 7 Jun 2007 14:51:47 -0000 1.32 --- io.c 9 Jun 2007 08:49:47 -0000 1.33 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.33 2007/06/09 08:49:47 vfrolov + * Improved baudrate emulation + * * Revision 1.32 2007/06/07 14:51:47 vfrolov * Added check for NULL of pIrpXoffCounter *************** *** 945,950 **** if (done) { ! if (pWriteDelay) pWriteDelay->sentFrames += done; } } --- 948,955 ---- if (done) { ! if (pWriteDelay) { pWriteDelay->sentFrames += done; + pWriteDelay->idleCount = 0; + } } } *************** *** 983,988 **** wasWrite = TRUE; ! if (pWriteDelay) pWriteDelay->sentFrames += done; } } --- 988,995 ---- wasWrite = TRUE; ! if (pWriteDelay) { pWriteDelay->sentFrames += done; + pWriteDelay->idleCount = 0; + } } } *************** *** 1102,1107 **** if (done) { ! if (pWriteDelay) pWriteDelay->sentFrames += done; } } --- 1109,1116 ---- if (done) { ! if (pWriteDelay) { pWriteDelay->sentFrames += done; + pWriteDelay->idleCount = 0; + } } } *************** *** 1180,1185 **** wasWrite = TRUE; ! if (pWriteDelay) pWriteDelay->sentFrames += done; } } --- 1189,1196 ---- wasWrite = TRUE; ! if (pWriteDelay) { pWriteDelay->sentFrames += done; + pWriteDelay->idleCount = 0; + } } } Index: delay.h =================================================================== RCS file: /cvsroot/com0com/com0com/sys/delay.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** delay.h 1 Jun 2007 08:36:26 -0000 1.4 --- delay.h 9 Jun 2007 08:49:47 -0000 1.5 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.5 2007/06/09 08:49:47 vfrolov + * Improved baudrate emulation + * * Revision 1.4 2007/06/01 08:36:26 vfrolov * Changed parameter type for SetWriteDelay() *************** *** 51,54 **** --- 54,58 ---- ULONGLONG startTime; ULONGLONG sentFrames; + short idleCount; BOOLEAN started; } C0C_ADAPTIVE_DELAY, *PC0C_ADAPTIVE_DELAY; Index: delay.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/delay.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** delay.c 1 Jun 2007 16:15:02 -0000 1.7 --- delay.c 9 Jun 2007 08:49:47 -0000 1.8 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.8 2007/06/09 08:49:47 vfrolov + * Improved baudrate emulation + * * Revision 1.7 2007/06/01 16:15:02 vfrolov * Fixed previous fix *************** *** 90,95 **** &queueToComplete); ! if (status != STATUS_PENDING) ! StopWriteDelayTimer(pWriteDelay); } --- 93,102 ---- &queueToComplete); ! if (status != STATUS_PENDING) { ! if (++pWriteDelay->idleCount > 3) ! StopWriteDelayTimer(pWriteDelay); ! } else { ! pWriteDelay->idleCount = 0; ! } } *************** *** 226,229 **** --- 233,237 ---- pWriteDelay->startTime = KeQueryInterruptTime(); pWriteDelay->sentFrames = 0; + pWriteDelay->idleCount = 0; /* 100-nanosecond intervals per frame */ |
From: Vyacheslav F. <vf...@us...> - 2007-06-07 14:51:50
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv576 Modified Files: io.c Log Message: Added check for NULL of pIrpXoffCounter Index: io.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/io.c,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** io.c 4 Jun 2007 15:24:32 -0000 1.31 --- io.c 7 Jun 2007 14:51:47 -0000 1.32 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.32 2007/06/07 14:51:47 vfrolov + * Added check for NULL of pIrpXoffCounter + * * Revision 1.31 2007/06/04 15:24:32 vfrolov * Fixed open reject just after close in exclusiveMode *************** *** 635,644 **** pQueue = &pIoPortWrite->irpQueues[C0C_QUEUE_WRITE]; - - #if DBG HALT_UNLESS(!pQueue->started); - #endif /* DBG */ pIrpXoffCounter = pQueue->pCurrent; ShiftQueue(pQueue); --- 638,646 ---- pQueue = &pIoPortWrite->irpQueues[C0C_QUEUE_WRITE]; HALT_UNLESS(!pQueue->started); pIrpXoffCounter = pQueue->pCurrent; + HALT_UNLESS(pIrpXoffCounter); + ShiftQueue(pQueue); |
From: Vyacheslav F. <vf...@us...> - 2007-06-05 12:26:42
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20603 Modified Files: trace.c Log Message: Allocate trace buffers only if trace enabled Index: trace.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/trace.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** trace.c 21 Feb 2007 16:52:34 -0000 1.26 --- trace.c 5 Jun 2007 12:26:38 -0000 1.27 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.27 2007/06/05 12:26:38 vfrolov + * Allocate trace buffers only if trace enabled + * * Revision 1.26 2007/02/21 16:52:34 vfrolov * Added tracing of IRP_MJ_POWER with more details *************** *** 126,130 **** #define TRACE_ERROR_LIMIT 10 #define TRACE_BUF_SIZE 256 ! #define TRACE_BUFS_NUM 4 #define TRACE_IRQL_BUF_SIZE 1024 /********************************************************************/ --- 129,133 ---- #define TRACE_ERROR_LIMIT 10 #define TRACE_BUF_SIZE 256 ! #define TRACE_BUFS_NUM 8 #define TRACE_IRQL_BUF_SIZE 1024 /********************************************************************/ *************** *** 133,162 **** CHAR buf[TRACE_BUF_SIZE]; } TRACE_BUFFER, *PTRACE_BUFFER; - /********************************************************************/ - #define TRACE_ENABLE_IRP 0x00000001 - #define TRACE_ENABLE_DUMP 0x00000002 ! #define TRACE_ENABLE_ALL 0xFFFFFFFF ! static struct { ! ULONG read; ! ULONG write; ! ULONG getTimeouts; ! ULONG setTimeouts; ! ULONG getCommStatus; ! ULONG getModemStatus; ! ULONG modemStatus; ! } traceEnable; /********************************************************************/ ! static int errorCount; ! static WCHAR traceFileNameBuf[256]; ! static UNICODE_STRING traceFileName; static PDRIVER_OBJECT pDrvObj; - static KSPIN_LOCK irqlBufLock; - static KSPIN_LOCK bufsLock; - static TRACE_BUFFER traceBufs[TRACE_BUFS_NUM]; - static LONG skippedTraces; /********************************************************************/ ! #define TRACE_FILE_OK (traceFileName.Buffer != NULL) /********************************************************************/ --- 136,179 ---- CHAR buf[TRACE_BUF_SIZE]; } TRACE_BUFFER, *PTRACE_BUFFER; ! typedef struct _TRACE_DATA { ! UNICODE_STRING traceFileName; ! struct { ! KSPIN_LOCK lock; ! TRACE_BUFFER bufs[TRACE_BUFS_NUM]; ! } bufs; ! ! struct { ! KSPIN_LOCK lock; ! CHAR buf[TRACE_IRQL_BUF_SIZE]; ! LONG busyInd; ! LONG freeInd; ! } irqlBuf; ! ! #define TRACE_ENABLE_IRP 0x00000001 ! #define TRACE_ENABLE_DUMP 0x00000002 ! ! #define TRACE_ENABLE_ALL 0xFFFFFFFF ! ! struct { ! ULONG read; ! ULONG write; ! ULONG getTimeouts; ! ULONG setTimeouts; ! ULONG getCommStatus; ! ULONG getModemStatus; ! ULONG modemStatus; ! } traceEnable; ! ! int errorCount; ! LONG skippedTraces; ! ! } TRACE_DATA, *PTRACE_DATA; /********************************************************************/ ! static PTRACE_DATA pTraceData = NULL; static PDRIVER_OBJECT pDrvObj; /********************************************************************/ ! #define TRACE_FILE_OK (pTraceData != NULL) /********************************************************************/ *************** *** 180,190 **** RtlZeroMemory(queryTable, sizeof(queryTable)); ! traceFileName.Length = 0; ! traceFileName.MaximumLength = sizeof(traceFileNameBuf); ! traceFileName.Buffer = traceFileNameBuf; queryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED; queryTable[0].Name = L"TraceFile"; ! queryTable[0].EntryContext = &traceFileName; status = RtlQueryRegistryValues( --- 197,208 ---- RtlZeroMemory(queryTable, sizeof(queryTable)); ! if (pTraceData->traceFileName.Buffer) { ! RtlFreeUnicodeString(&pTraceData->traceFileName); ! RtlInitUnicodeString(&pTraceData->traceFileName, NULL); ! } queryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED; queryTable[0].Name = L"TraceFile"; ! queryTable[0].EntryContext = &pTraceData->traceFileName; status = RtlQueryRegistryValues( *************** *** 198,202 **** if (!NT_SUCCESS(status)) ! RtlInitUnicodeString(&traceFileName, NULL); } --- 216,220 ---- if (!NT_SUCCESS(status)) ! RtlInitUnicodeString(&pTraceData->traceFileName, NULL); } *************** *** 208,212 **** ULONG zero = 0; ! RtlZeroMemory(&traceEnable, sizeof(traceEnable)); status = STATUS_SUCCESS; --- 226,230 ---- ULONG zero = 0; ! RtlZeroMemory(&pTraceData->traceEnable, sizeof(pTraceData->traceEnable)); status = STATUS_SUCCESS; *************** *** 225,229 **** queryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[0].Name = L"Read"; ! queryTable[0].EntryContext = &traceEnable.read; queryTable[0].DefaultType = REG_DWORD; queryTable[0].DefaultData = &zero; --- 243,247 ---- queryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[0].Name = L"Read"; ! queryTable[0].EntryContext = &pTraceData->traceEnable.read; queryTable[0].DefaultType = REG_DWORD; queryTable[0].DefaultData = &zero; *************** *** 232,236 **** queryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[1].Name = L"Write"; ! queryTable[1].EntryContext = &traceEnable.write; queryTable[1].DefaultType = REG_DWORD; queryTable[1].DefaultData = &zero; --- 250,254 ---- queryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[1].Name = L"Write"; ! queryTable[1].EntryContext = &pTraceData->traceEnable.write; queryTable[1].DefaultType = REG_DWORD; queryTable[1].DefaultData = &zero; *************** *** 239,243 **** queryTable[2].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[2].Name = L"GetTimeouts"; ! queryTable[2].EntryContext = &traceEnable.getTimeouts; queryTable[2].DefaultType = REG_DWORD; queryTable[2].DefaultData = &zero; --- 257,261 ---- queryTable[2].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[2].Name = L"GetTimeouts"; ! queryTable[2].EntryContext = &pTraceData->traceEnable.getTimeouts; queryTable[2].DefaultType = REG_DWORD; queryTable[2].DefaultData = &zero; *************** *** 246,250 **** queryTable[3].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[3].Name = L"SetTimeouts"; ! queryTable[3].EntryContext = &traceEnable.setTimeouts; queryTable[3].DefaultType = REG_DWORD; queryTable[3].DefaultData = &zero; --- 264,268 ---- queryTable[3].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[3].Name = L"SetTimeouts"; ! queryTable[3].EntryContext = &pTraceData->traceEnable.setTimeouts; queryTable[3].DefaultType = REG_DWORD; queryTable[3].DefaultData = &zero; *************** *** 253,257 **** queryTable[4].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[4].Name = L"GetCommStatus"; ! queryTable[4].EntryContext = &traceEnable.getCommStatus; queryTable[4].DefaultType = REG_DWORD; queryTable[4].DefaultData = &zero; --- 271,275 ---- queryTable[4].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[4].Name = L"GetCommStatus"; ! queryTable[4].EntryContext = &pTraceData->traceEnable.getCommStatus; queryTable[4].DefaultType = REG_DWORD; queryTable[4].DefaultData = &zero; *************** *** 260,264 **** queryTable[5].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[5].Name = L"GetModemStatus"; ! queryTable[5].EntryContext = &traceEnable.getModemStatus; queryTable[5].DefaultType = REG_DWORD; queryTable[5].DefaultData = &zero; --- 278,282 ---- queryTable[5].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[5].Name = L"GetModemStatus"; ! queryTable[5].EntryContext = &pTraceData->traceEnable.getModemStatus; queryTable[5].DefaultType = REG_DWORD; queryTable[5].DefaultData = &zero; *************** *** 267,271 **** queryTable[6].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[6].Name = L"ModemStatus"; ! queryTable[6].EntryContext = &traceEnable.modemStatus; queryTable[6].DefaultType = REG_DWORD; queryTable[6].DefaultData = &zero; --- 285,289 ---- queryTable[6].Flags = RTL_QUERY_REGISTRY_DIRECT; queryTable[6].Name = L"ModemStatus"; ! queryTable[6].EntryContext = &pTraceData->traceEnable.modemStatus; queryTable[6].DefaultType = REG_DWORD; queryTable[6].DefaultData = &zero; *************** *** 291,306 **** pBuf = NULL; ! KeAcquireSpinLock(&bufsLock, &oldIrql); for (i = 0 ; i < TRACE_BUFS_NUM ; i++) { ! if (!traceBufs[i].busy) { ! traceBufs[i].busy = TRUE; ! pBuf = &traceBufs[i]; break; } } ! KeReleaseSpinLock(&bufsLock, oldIrql); if (!pBuf) ! InterlockedIncrement(&skippedTraces); return pBuf; --- 309,324 ---- pBuf = NULL; ! KeAcquireSpinLock(&pTraceData->bufs.lock, &oldIrql); for (i = 0 ; i < TRACE_BUFS_NUM ; i++) { ! if (!pTraceData->bufs.bufs[i].busy) { ! pTraceData->bufs.bufs[i].busy = TRUE; ! pBuf = &pTraceData->bufs.bufs[i]; break; } } ! KeReleaseSpinLock(&pTraceData->bufs.lock, oldIrql); if (!pBuf) ! InterlockedIncrement(&pTraceData->skippedTraces); return pBuf; *************** *** 932,936 **** if (!NT_SUCCESS(status)) { ! errorCount++; SysLog(pIoObject, status, L"TraceWrite ZwWriteFile FAIL"); } --- 950,954 ---- if (!NT_SUCCESS(status)) { ! pTraceData->errorCount++; SysLog(pIoObject, status, L"TraceWrite ZwWriteFile FAIL"); } *************** *** 949,959 **** IO_STATUS_BLOCK ioStatusBlock; ! static CHAR irqlBuf[TRACE_IRQL_BUF_SIZE]; ! static LONG irqlBufBusyInd = 0; ! static LONG irqlBufFreeInd = 0; ! ! if (errorCount > TRACE_ERROR_LIMIT) { ! if (errorCount < (TRACE_ERROR_LIMIT + 100)) { ! errorCount += 100; SysLog(pDrvObj, STATUS_SUCCESS, L"Trace disabled"); } --- 967,973 ---- IO_STATUS_BLOCK ioStatusBlock; ! if (pTraceData->errorCount > TRACE_ERROR_LIMIT) { ! if (pTraceData->errorCount < (TRACE_ERROR_LIMIT + 100)) { ! pTraceData->errorCount += 100; SysLog(pDrvObj, STATUS_SUCCESS, L"Trace disabled"); } *************** *** 972,983 **** GetTimeFields(&timeFields); ! KeAcquireSpinLock(&irqlBufLock, &oldIrql); ! size = sizeof(irqlBuf) - irqlBufFreeInd; ! pDestStr = irqlBuf + (sizeof(irqlBuf) - size); pDestStr = AnsiStrCopyTimeFields(pDestStr, &size, &timeFields); pDestStr = AnsiStrFormat(pDestStr, &size, " *%u* %s\r\n", (unsigned)KeGetCurrentIrql(), pStr); ! HALT_UNLESS3(size > 0, irqlBufFreeInd, irqlBufBusyInd, sizeof(irqlBuf)); if (size == 1) { --- 986,998 ---- GetTimeFields(&timeFields); ! KeAcquireSpinLock(&pTraceData->irqlBuf.lock, &oldIrql); ! size = sizeof(pTraceData->irqlBuf.buf) - pTraceData->irqlBuf.freeInd; ! pDestStr = pTraceData->irqlBuf.buf + (sizeof(pTraceData->irqlBuf.buf) - size); pDestStr = AnsiStrCopyTimeFields(pDestStr, &size, &timeFields); pDestStr = AnsiStrFormat(pDestStr, &size, " *%u* %s\r\n", (unsigned)KeGetCurrentIrql(), pStr); ! HALT_UNLESS3(size > 0, pTraceData->irqlBuf.freeInd, ! pTraceData->irqlBuf.busyInd, sizeof(pTraceData->irqlBuf.buf)); if (size == 1) { *************** *** 987,993 **** } ! irqlBufFreeInd = (LONG)(sizeof(irqlBuf) - size); ! KeReleaseSpinLock(&irqlBufLock, oldIrql); return; --- 1002,1008 ---- } ! pTraceData->irqlBuf.freeInd = (LONG)(sizeof(pTraceData->irqlBuf.buf) - size); ! KeReleaseSpinLock(&pTraceData->irqlBuf.lock, oldIrql); return; *************** *** 1000,1004 **** HALT_UNLESS(TRACE_FILE_OK); ! InitializeObjectAttributes(&objectAttributes, &traceFileName, 0, NULL, NULL); status = ZwCreateFile( --- 1015,1024 ---- HALT_UNLESS(TRACE_FILE_OK); ! InitializeObjectAttributes( ! &objectAttributes, ! &pTraceData->traceFileName, ! OBJ_KERNEL_HANDLE, ! NULL, ! NULL); status = ZwCreateFile( *************** *** 1028,1048 **** pDestStr = pBuf->buf; ! while (irqlBufFreeInd) { SIZE_T lenBuf; KIRQL oldIrql; ! KeAcquireSpinLock(&irqlBufLock, &oldIrql); ! lenBuf = irqlBufFreeInd - irqlBufBusyInd; if (lenBuf) { if (lenBuf > size - 1) lenBuf = size - 1; ! RtlCopyMemory(pDestStr, &irqlBuf[irqlBufBusyInd], lenBuf); pDestStr[lenBuf] = 0; ! irqlBufBusyInd += (LONG)lenBuf; ! HALT_UNLESS3(irqlBufBusyInd <= irqlBufFreeInd, irqlBufFreeInd, irqlBufBusyInd, lenBuf); ! if (irqlBufBusyInd == irqlBufFreeInd) ! irqlBufFreeInd = irqlBufBusyInd = 0; } ! KeReleaseSpinLock(&irqlBufLock, oldIrql); if (lenBuf) --- 1048,1069 ---- pDestStr = pBuf->buf; ! while (pTraceData->irqlBuf.freeInd) { SIZE_T lenBuf; KIRQL oldIrql; ! KeAcquireSpinLock(&pTraceData->irqlBuf.lock, &oldIrql); ! lenBuf = pTraceData->irqlBuf.freeInd - pTraceData->irqlBuf.busyInd; if (lenBuf) { if (lenBuf > size - 1) lenBuf = size - 1; ! RtlCopyMemory(pDestStr, &pTraceData->irqlBuf.buf[pTraceData->irqlBuf.busyInd], lenBuf); pDestStr[lenBuf] = 0; ! pTraceData->irqlBuf.busyInd += (LONG)lenBuf; ! HALT_UNLESS3(pTraceData->irqlBuf.busyInd <= pTraceData->irqlBuf.freeInd, ! pTraceData->irqlBuf.freeInd, pTraceData->irqlBuf.busyInd, lenBuf); ! if (pTraceData->irqlBuf.busyInd == pTraceData->irqlBuf.freeInd) ! pTraceData->irqlBuf.freeInd = pTraceData->irqlBuf.busyInd = 0; } ! KeReleaseSpinLock(&pTraceData->irqlBuf.lock, oldIrql); if (lenBuf) *************** *** 1050,1054 **** } ! skipped = InterlockedExchange(&skippedTraces, 0); if (skipped) { --- 1071,1075 ---- } ! skipped = InterlockedExchange(&pTraceData->skippedTraces, 0); if (skipped) { *************** *** 1076,1085 **** if (!NT_SUCCESS(status)) { ! errorCount++; SysLog(pIoObject, status, L"TraceOutput ZwClose FAIL"); } } else { ! errorCount++; SysLog(pIoObject, status, L"TraceOutput ZwCreateFile FAIL"); } --- 1097,1106 ---- if (!NT_SUCCESS(status)) { ! pTraceData->errorCount++; SysLog(pIoObject, status, L"TraceOutput ZwClose FAIL"); } } else { ! pTraceData->errorCount++; SysLog(pIoObject, status, L"TraceOutput ZwCreateFile FAIL"); } *************** *** 1114,1117 **** --- 1135,1148 ---- } /********************************************************************/ + VOID TraceDisable() + { + if (pTraceData) { + if (pTraceData->traceFileName.Buffer) + RtlFreeUnicodeString(&pTraceData->traceFileName); + + C0C_FREE_POOL(pTraceData); + pTraceData = NULL; + } + } VOID TraceOpen( *************** *** 1121,1135 **** pDrvObj = _pDrvObj; ! KeInitializeSpinLock(&irqlBufLock); ! KeInitializeSpinLock(&bufsLock); ! skippedTraces = 0; ! RtlZeroMemory(traceBufs, sizeof(traceBufs)); ! RtlInitUnicodeString(&traceFileName, NULL); ! errorCount = 0; QueryRegistryTrace(pRegistryPath); QueryRegistryTraceEnable(pRegistryPath); if (TRACE_FILE_OK) { UNICODE_STRING msg; --- 1152,1173 ---- pDrvObj = _pDrvObj; ! pTraceData = (PTRACE_DATA)C0C_ALLOCATE_POOL(NonPagedPool, sizeof(*pTraceData)); ! if (!pTraceData) { ! SysLog(pDrvObj, STATUS_INSUFFICIENT_RESOURCES, L"TraceEnable C0C_ALLOCATE_POOL FAIL"); ! return; ! } ! ! RtlZeroMemory(pTraceData, sizeof(*pTraceData)); ! ! KeInitializeSpinLock(&pTraceData->bufs.lock); ! KeInitializeSpinLock(&pTraceData->irqlBuf.lock); QueryRegistryTrace(pRegistryPath); QueryRegistryTraceEnable(pRegistryPath); + if (!pTraceData->traceFileName.Buffer) + TraceDisable(); + if (TRACE_FILE_OK) { UNICODE_STRING msg; *************** *** 1140,1144 **** RtlInitUnicodeString(&msg, NULL); StrAppendStr0(&status, &msg, L"Trace enabled. See "); ! StrAppendStr(&status, &msg, traceFileName.Buffer, traceFileName.Length); if (NT_SUCCESS(status)) --- 1178,1182 ---- RtlInitUnicodeString(&msg, NULL); StrAppendStr0(&status, &msg, L"Trace enabled. See "); ! StrAppendStr(&status, &msg, pTraceData->traceFileName.Buffer, pTraceData->traceFileName.Length); if (NT_SUCCESS(status)) *************** *** 1150,1155 **** TraceF(NULL, "VERSION " C0C_VERSION_STR " (" __DATE__ " " __TIME__ ")"); ! if (errorCount) { ! RtlInitUnicodeString(&traceFileName, NULL); SysLog(pDrvObj, STATUS_SUCCESS, L"Trace disabled"); } --- 1188,1193 ---- TraceF(NULL, "VERSION " C0C_VERSION_STR " (" __DATE__ " " __TIME__ ")"); ! if (pTraceData->errorCount) { ! TraceDisable(); SysLog(pDrvObj, STATUS_SUCCESS, L"Trace disabled"); } *************** *** 1164,1168 **** TraceF(NULL, "===== END ====="); ! RtlInitUnicodeString(&traceFileName, NULL); } --- 1202,1206 ---- TraceF(NULL, "===== END ====="); ! TraceDisable(); } *************** *** 1251,1255 **** return; ! if (!traceEnable.modemStatus) return; --- 1289,1293 ---- return; ! if (!pTraceData->traceEnable.modemStatus) return; *************** *** 1286,1307 **** switch (major) { case IRP_MJ_WRITE: ! enableMask = traceEnable.write; break; case IRP_MJ_READ: ! enableMask = traceEnable.read; break; case IRP_MJ_DEVICE_CONTROL: switch (pIrpStack->Parameters.DeviceIoControl.IoControlCode) { case IOCTL_SERIAL_GET_TIMEOUTS: ! enableMask = traceEnable.getTimeouts; break; case IOCTL_SERIAL_SET_TIMEOUTS: ! enableMask = traceEnable.setTimeouts; break; case IOCTL_SERIAL_GET_COMMSTATUS: ! enableMask = traceEnable.getCommStatus; break; case IOCTL_SERIAL_GET_MODEMSTATUS: ! enableMask = traceEnable.getModemStatus; break; } --- 1324,1345 ---- switch (major) { case IRP_MJ_WRITE: ! enableMask = pTraceData->traceEnable.write; break; case IRP_MJ_READ: ! enableMask = pTraceData->traceEnable.read; break; case IRP_MJ_DEVICE_CONTROL: switch (pIrpStack->Parameters.DeviceIoControl.IoControlCode) { case IOCTL_SERIAL_GET_TIMEOUTS: ! enableMask = pTraceData->traceEnable.getTimeouts; break; case IOCTL_SERIAL_SET_TIMEOUTS: ! enableMask = pTraceData->traceEnable.setTimeouts; break; case IOCTL_SERIAL_GET_COMMSTATUS: ! enableMask = pTraceData->traceEnable.getCommStatus; break; case IOCTL_SERIAL_GET_MODEMSTATUS: ! enableMask = pTraceData->traceEnable.getModemStatus; break; } |
From: Vyacheslav F. <vf...@us...> - 2007-06-05 12:15:13
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv16398 Modified Files: adddev.c Log Message: Fixed memory leak Index: adddev.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/adddev.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** adddev.c 1 Jun 2007 16:22:40 -0000 1.26 --- adddev.c 5 Jun 2007 12:15:08 -0000 1.27 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.27 2007/06/05 12:15:08 vfrolov + * Fixed memory leak + * * Revision 1.26 2007/06/01 16:22:40 vfrolov * Implemented plug-in and exclusive modes *************** *** 143,146 **** --- 146,152 ---- SysLog(pDevExt->pDevObj, STATUS_UNSUCCESSFUL, L"RemoveFdoPort HidePort FAIL"); + if (pDevExt->symbolicLinkName.Buffer) + RtlFreeUnicodeString(&pDevExt->symbolicLinkName); + StrFree(&pDevExt->ntDeviceName); StrFree(&pDevExt->win32DeviceName); |
From: Vyacheslav F. <vf...@us...> - 2007-06-04 15:28:16
|
Update of /cvsroot/com0com/com0com In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv10873 Modified Files: ReadMe.txt Log Message: Added question about hiding ports Index: ReadMe.txt =================================================================== RCS file: /cvsroot/com0com/com0com/ReadMe.txt,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ReadMe.txt 11 Jan 2007 15:07:39 -0000 1.12 --- ReadMe.txt 4 Jun 2007 15:28:12 -0000 1.13 *************** *** 87,92 **** ! FAQ ! === Q. Is it possible to change the names CNCA0 and CNCB0 to COM2 and COM3? --- 87,92 ---- ! FAQ & HOWTO ! =========== Q. Is it possible to change the names CNCA0 and CNCB0 to COM2 and COM3? *************** *** 128,129 **** --- 128,142 ---- command> change CNCB0 EmuOverrun=yes command> change CNCA0 EmuBR=yes + + Q. I have to write an application connected to one side of the com0com port pair, + and I don't want users to 'see' all the virtual ports created by com0com, but + only the really available ones. + A. if your application use port CNCB0 and other (used by users) paired port is CNCA0, + then CNCB0 can be 'hidden' and CNCA0 can be 'shown' on opening CNCB0 by your + application. To enable it: + + 1. Launch the Setup Command Prompt shortcut. + 2. Enter the change commands: + + command> change CNCB0 ExclusiveMode=yes + command> change CNCA0 PlugInMode=yes |
From: Vyacheslav F. <vf...@us...> - 2007-06-04 15:24:42
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv9382 Modified Files: com0com.h io.c openclos.c pnp.c startirp.c timeout.c timeout.h Log Message: Fixed open reject just after close in exclusiveMode Index: openclos.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/openclos.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** openclos.c 1 Jun 2007 16:22:40 -0000 1.17 --- openclos.c 4 Jun 2007 15:24:32 -0000 1.18 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.18 2007/06/04 15:24:32 vfrolov + * Fixed open reject just after close in exclusiveMode + * * Revision 1.17 2007/06/01 16:22:40 vfrolov * Implemented plug-in and exclusive modes *************** *** 83,86 **** --- 86,90 ---- #include "bufutils.h" #include "strutils.h" + #include "timeout.h" NTSTATUS FdoPortOpen(IN PC0C_FDOPORT_EXTENSION pDevExt) *************** *** 174,179 **** } ! NTSTATUS FdoPortClose(IN PC0C_FDOPORT_EXTENSION pDevExt) { LIST_ENTRY queueToComplete; KIRQL oldIrql; --- 178,205 ---- } ! NTSTATUS StartIrpClose( ! IN PC0C_IO_PORT pIoPort, ! IN PLIST_ENTRY pQueueToComplete) { + UNREFERENCED_PARAMETER(pQueueToComplete); + + if (!pIoPort->exclusiveMode) { + PIRP pIrp; + + InterlockedDecrement(&pIoPort->pDevExt->openCount); + pIrp = pIoPort->irpQueues[C0C_QUEUE_CLOSE].pCurrent; + pIrp->IoStatus.Information = 0; + return STATUS_SUCCESS; + } + + IoInvalidateDeviceRelations(pIoPort->pPhDevObj, BusRelations); + SetCloseTimeout(pIoPort); + + return STATUS_PENDING; + } + + NTSTATUS FdoPortClose(IN PC0C_FDOPORT_EXTENSION pDevExt, IN PIRP pIrp) + { + NTSTATUS status; LIST_ENTRY queueToComplete; KIRQL oldIrql; *************** *** 199,210 **** KeReleaseSpinLock(pIoPort->pIoLock, oldIrql); - if (pIoPort->exclusiveMode) - IoInvalidateDeviceRelations(pIoPort->pPhDevObj, BusRelations); - FdoPortCompleteQueue(&queueToComplete); ! InterlockedDecrement(&pDevExt->openCount); ! return STATUS_SUCCESS; } --- 225,238 ---- KeReleaseSpinLock(pIoPort->pIoLock, oldIrql); FdoPortCompleteQueue(&queueToComplete); ! status = FdoPortStartIrp(pIoPort, pIrp, C0C_QUEUE_CLOSE, StartIrpClose); ! if (status != STATUS_PENDING) { ! pIrp->IoStatus.Status = status; ! IoCompleteRequest(pIrp, IO_NO_INCREMENT); ! } ! ! return status; } *************** *** 226,231 **** --- 254,261 ---- pIrp->IoStatus.Information = 0; + #if DBG if (!NT_SUCCESS(status)) TraceIrp("c0cOpen", pIrp, &status, TRACE_FLAG_RESULTS); + #endif /* DBG */ pIrp->IoStatus.Status = status; *************** *** 240,260 **** PC0C_COMMON_EXTENSION pDevExt = pDevObj->DeviceExtension; TraceIrp("--- Close ---", pIrp, NULL, TRACE_FLAG_PARAMS); switch (pDevExt->doType) { case C0C_DOTYPE_FP: ! status = FdoPortClose((PC0C_FDOPORT_EXTENSION)pDevExt); break; default: status = STATUS_INVALID_DEVICE_REQUEST; } ! pIrp->IoStatus.Information = 0; ! ! if (!NT_SUCCESS(status)) ! TraceIrp("c0cClose", pIrp, &status, TRACE_FLAG_RESULTS); ! ! pIrp->IoStatus.Status = status; ! IoCompleteRequest(pIrp, IO_NO_INCREMENT); return status; --- 270,294 ---- PC0C_COMMON_EXTENSION pDevExt = pDevObj->DeviceExtension; + #if DBG + ULONG code = IoGetCurrentIrpStackLocation(pIrp)->MajorFunction; + #endif /* DBG */ + TraceIrp("--- Close ---", pIrp, NULL, TRACE_FLAG_PARAMS); switch (pDevExt->doType) { case C0C_DOTYPE_FP: ! status = FdoPortClose((PC0C_FDOPORT_EXTENSION)pDevExt, pIrp); break; default: status = STATUS_INVALID_DEVICE_REQUEST; + pIrp->IoStatus.Information = 0; + pIrp->IoStatus.Status = status; + IoCompleteRequest(pIrp, IO_NO_INCREMENT); } ! #if DBG ! if (status != STATUS_SUCCESS) ! TraceCode(pDevExt, "IRP_MJ_", codeNameTableIrpMj, code, &status); ! #endif /* DBG */ return status; Index: timeout.h =================================================================== RCS file: /cvsroot/com0com/com0com/sys/timeout.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** timeout.h 20 Feb 2007 12:05:11 -0000 1.5 --- timeout.h 4 Jun 2007 15:24:33 -0000 1.6 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.6 2007/06/04 15:24:33 vfrolov + * Fixed open reject just after close in exclusiveMode + * * Revision 1.5 2007/02/20 12:05:11 vfrolov * Implemented IOCTL_SERIAL_XOFF_COUNTER *************** *** 47,50 **** --- 50,55 ---- VOID SetIntervalTimeout(PC0C_IO_PORT pIoPort); + VOID SetCloseTimeout(PC0C_IO_PORT pIoPort); + VOID SetXoffCounterTimeout( PC0C_IO_PORT pIoPort, Index: com0com.h =================================================================== RCS file: /cvsroot/com0com/com0com/sys/com0com.h,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** com0com.h 1 Jun 2007 16:22:40 -0000 1.34 --- com0com.h 4 Jun 2007 15:24:32 -0000 1.35 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.35 2007/06/04 15:24:32 vfrolov + * Fixed open reject just after close in exclusiveMode + * * Revision 1.34 2007/06/01 16:22:40 vfrolov * Implemented plug-in and exclusive modes *************** *** 214,219 **** #define C0C_QUEUE_WRITE 1 #define C0C_QUEUE_WAIT 2 ! #define C0C_QUEUE_SIZE 3 C0C_IRP_QUEUE irpQueues[C0C_QUEUE_SIZE]; --- 217,223 ---- #define C0C_QUEUE_WRITE 1 #define C0C_QUEUE_WAIT 2 + #define C0C_QUEUE_CLOSE 3 ! #define C0C_QUEUE_SIZE 4 C0C_IRP_QUEUE irpQueues[C0C_QUEUE_SIZE]; *************** *** 229,232 **** --- 233,239 ---- KDPC timerWriteTotalDpc; + KTIMER timerClose; + KDPC timerCloseDpc; + struct _C0C_ADAPTIVE_DELAY *pWriteDelay; *************** *** 399,402 **** --- 406,410 ---- ULONG GetWriteLength(IN PIRP pIrp); + #define C0C_IO_TYPE_CLOSE_COMPLETE 2 #define C0C_IO_TYPE_WAIT_COMPLETE 3 #define C0C_IO_TYPE_INSERT 4 Index: startirp.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/startirp.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** startirp.c 20 Feb 2007 12:05:11 -0000 1.16 --- startirp.c 4 Jun 2007 15:24:33 -0000 1.17 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.17 2007/06/04 15:24:33 vfrolov + * Fixed open reject just after close in exclusiveMode + * * Revision 1.16 2007/02/20 12:05:11 vfrolov * Implemented IOCTL_SERIAL_XOFF_COUNTER *************** *** 100,103 **** --- 103,107 ---- break; case IRP_MJ_FLUSH_BUFFERS: + case IRP_MJ_CLOSE: return (PC0C_IRP_STATE)&pIrpStack->Parameters.Others.Argument1; } Index: io.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/io.c,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** io.c 20 Feb 2007 12:05:11 -0000 1.30 --- io.c 4 Jun 2007 15:24:32 -0000 1.31 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.31 2007/06/04 15:24:32 vfrolov + * Fixed open reject just after close in exclusiveMode + * * Revision 1.30 2007/02/20 12:05:11 vfrolov * Implemented IOCTL_SERIAL_XOFF_COUNTER *************** *** 675,682 **** PIRP pIrpCurrent; PDRIVER_CANCEL pCancelRoutineCurrent; - SIZE_T done; first = TRUE; - done = 0; status = STATUS_PENDING; --- 678,683 ---- *************** *** 701,704 **** --- 702,710 ---- InsertDirect((PC0C_RAW_DATA)pParam, pIrpCurrent, &status, &statusCurrent, &doneCurrent); break; + case C0C_IO_TYPE_CLOSE_COMPLETE: + InterlockedDecrement(&pIoPort->pDevExt->openCount); + pIrpCurrent->IoStatus.Information = 0; + statusCurrent = STATUS_SUCCESS; + break; } Index: pnp.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/pnp.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pnp.c 1 Jun 2007 16:22:40 -0000 1.7 --- pnp.c 4 Jun 2007 15:24:33 -0000 1.8 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.8 2007/06/04 15:24:33 vfrolov + * Fixed open reject just after close in exclusiveMode + * * Revision 1.7 2007/06/01 16:22:40 vfrolov * Implemented plug-in and exclusive modes *************** *** 319,322 **** --- 322,327 ---- switch (minorFunction) { case IRP_MN_QUERY_DEVICE_RELATIONS: { + LIST_ENTRY queueToComplete; + KIRQL oldIrql; PC0C_IO_PORT pIoPort = pDevExt->pIoPortLocal; *************** *** 328,331 **** --- 333,350 ---- ShowPort(pDevExt); } + + /* complete pending CLOSE IRPs */ + + InitializeListHead(&queueToComplete); + + KeAcquireSpinLock(pIoPort->pIoLock, &oldIrql); + FdoPortIo(C0C_IO_TYPE_CLOSE_COMPLETE, + NULL, + pIoPort, + &pIoPort->irpQueues[C0C_QUEUE_CLOSE], + &queueToComplete); + KeReleaseSpinLock(pIoPort->pIoLock, oldIrql); + + FdoPortCompleteQueue(&queueToComplete); break; } Index: timeout.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/timeout.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** timeout.c 20 Feb 2007 12:05:11 -0000 1.8 --- timeout.c 4 Jun 2007 15:24:33 -0000 1.9 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.9 2007/06/04 15:24:33 vfrolov + * Fixed open reject just after close in exclusiveMode + * * Revision 1.8 2007/02/20 12:05:11 vfrolov * Implemented IOCTL_SERIAL_XOFF_COUNTER *************** *** 75,82 **** pState->flags |= C0C_IRP_FLAG_EXPIRED; ! if (pState->iQueue == C0C_QUEUE_WRITE) ! ReadWrite(pIoPort->pIoPortRemote, FALSE, pIoPort, FALSE, &queueToComplete); ! else ! ReadWrite(pIoPort, FALSE, pIoPort->pIoPortRemote, FALSE, &queueToComplete); } --- 78,96 ---- pState->flags |= C0C_IRP_FLAG_EXPIRED; ! switch (pState->iQueue) { ! case C0C_QUEUE_WRITE: ! ReadWrite(pIoPort->pIoPortRemote, FALSE, pIoPort, FALSE, &queueToComplete); ! break; ! case C0C_QUEUE_READ: ! ReadWrite(pIoPort, FALSE, pIoPort->pIoPortRemote, FALSE, &queueToComplete); ! break; ! case C0C_QUEUE_CLOSE: ! FdoPortIo(C0C_IO_TYPE_CLOSE_COMPLETE, ! NULL, ! pIoPort, ! &pIoPort->irpQueues[C0C_QUEUE_CLOSE], ! &queueToComplete); ! break; ! } } *************** *** 277,280 **** --- 291,309 ---- } + VOID TimeoutClose( + IN PKDPC pDpc, + IN PVOID deferredContext, + IN PVOID systemArgument1, + IN PVOID systemArgument2) + { + PC0C_IO_PORT pIoPort = (PC0C_IO_PORT)deferredContext; + + UNREFERENCED_PARAMETER(pDpc); + UNREFERENCED_PARAMETER(systemArgument1); + UNREFERENCED_PARAMETER(systemArgument2); + + TimeoutRoutine(pIoPort, &pIoPort->irpQueues[C0C_QUEUE_CLOSE]); + } + VOID AllocTimeouts(PC0C_IO_PORT pIoPort) { *************** *** 282,289 **** --- 311,320 ---- KeInitializeTimer(&pIoPort->timerReadInterval); KeInitializeTimer(&pIoPort->timerWriteTotal); + KeInitializeTimer(&pIoPort->timerClose); KeInitializeDpc(&pIoPort->timerReadTotalDpc, TimeoutReadTotal, pIoPort); KeInitializeDpc(&pIoPort->timerReadIntervalDpc, TimeoutReadInterval, pIoPort); KeInitializeDpc(&pIoPort->timerWriteTotalDpc, TimeoutWriteTotal, pIoPort); + KeInitializeDpc(&pIoPort->timerCloseDpc, TimeoutClose, pIoPort); } *************** *** 293,300 **** --- 324,333 ---- KeCancelTimer(&pIoPort->timerReadInterval); KeCancelTimer(&pIoPort->timerWriteTotal); + KeCancelTimer(&pIoPort->timerClose); KeRemoveQueueDpc(&pIoPort->timerReadTotalDpc); KeRemoveQueueDpc(&pIoPort->timerReadIntervalDpc); KeRemoveQueueDpc(&pIoPort->timerWriteTotalDpc); + KeRemoveQueueDpc(&pIoPort->timerCloseDpc); } *************** *** 304,307 **** --- 337,349 ---- } + VOID SetCloseTimeout(PC0C_IO_PORT pIoPort) + { + LARGE_INTEGER total; + + total.QuadPart = ((LONGLONG)1000) * -10000; + + KeSetTimer(&pIoPort->timerClose, total, &pIoPort->timerCloseDpc); + } + NTSTATUS SetIrpTimeout( PC0C_IO_PORT pIoPort, |
From: Vyacheslav F. <vf...@us...> - 2007-06-01 16:32:28
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3271 Modified Files: params.cpp params.h Log Message: Implemented plug-in and exclusive modes Index: params.h =================================================================== RCS file: /cvsroot/com0com/com0com/setup/params.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** params.h 27 Oct 2006 13:11:58 -0000 1.2 --- params.h 1 Jun 2007 16:32:04 -0000 1.3 *************** *** 2,6 **** * $Id$ * ! * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify --- 2,6 ---- * $Id$ * ! * Copyright (c) 2006-2007 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.3 2007/06/01 16:32:04 vfrolov + * Implemented plug-in and exclusive modes + * * Revision 1.2 2006/10/27 13:11:58 vfrolov * Added PortParameters::FillPortName() *************** *** 49,54 **** BOOL FillParametersKey(char *pRegKey, int size); BOOL SetPortName(const char *pNewPortName); ! BOOL SetEmuBR(const char *pNewEmuBR); ! BOOL SetEmuOverrun(const char *pNewEmuOverrun); DWORD maskChanged; --- 52,60 ---- BOOL FillParametersKey(char *pRegKey, int size); BOOL SetPortName(const char *pNewPortName); ! DWORD *GetFlagPtr(DWORD bit); ! const char *GetBitName(DWORD bit); ! BOOL SetFlag(const char *pNewFlag, DWORD bit); ! void LoadFlag(HKEY hKey, DWORD bit); ! LONG SaveFlag(HKEY hKey, DWORD bit); DWORD maskChanged; *************** *** 57,60 **** --- 63,68 ---- DWORD emuBR; DWORD emuOverrun; + DWORD plugInMode; + DWORD exclusiveMode; char service[20]; Index: params.cpp =================================================================== RCS file: /cvsroot/com0com/com0com/setup/params.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** params.cpp 11 Jan 2007 15:05:03 -0000 1.4 --- params.cpp 1 Jun 2007 16:32:04 -0000 1.5 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.5 2007/06/01 16:32:04 vfrolov + * Implemented plug-in and exclusive modes + * * Revision 1.4 2007/01/11 15:05:03 vfrolov * Replaced strtok() by STRTOK_R() *************** *** 41,47 **** /////////////////////////////////////////////////////////////// enum { ! m_portName = 0x0001, ! m_emuBR = 0x0002, ! m_emuOverrun = 0x0004, }; /////////////////////////////////////////////////////////////// --- 44,59 ---- /////////////////////////////////////////////////////////////// enum { ! m_portName = 0x0001, ! m_emuBR = 0x0002, ! m_emuOverrun = 0x0004, ! m_plugInMode = 0x0008, ! m_exclusiveMode = 0x0010, ! }; ! /////////////////////////////////////////////////////////////// ! static DWORD flagBits[] = { ! m_emuBR, ! m_emuOverrun, ! m_plugInMode, ! m_exclusiveMode }; /////////////////////////////////////////////////////////////// *************** *** 59,62 **** --- 71,76 ---- emuBR = 0; emuOverrun = 0; + plugInMode = 0; + exclusiveMode = 0; maskChanged = 0; *************** *** 91,153 **** } /////////////////////////////////////////////////////////////// ! BOOL PortParameters::SetEmuBR(const char *pNewEmuBR) { ! if (!lstrcmpi(pNewEmuBR, "*")) ! return TRUE; ! ! DWORD newEmuBR; ! ! if (!lstrcmpi(pNewEmuBR, "yes")) { ! newEmuBR = 0xFFFFFFFF; ! } ! else ! if (!lstrcmpi(pNewEmuBR, "no")) { ! newEmuBR = 0; ! } ! else ! if (!lstrcmpi(pNewEmuBR, "-")) { ! newEmuBR = 0; ! } ! else { ! return FALSE; ! } ! ! if (lstrcmpi("-", pNewEmuBR)) { ! if ((maskExplicit & m_emuBR) == 0) { ! maskExplicit |= m_emuBR; ! maskChanged |= m_emuBR; ! } ! } else { ! if (maskExplicit & m_emuBR) { ! maskExplicit &= ~m_emuBR; ! maskChanged |= m_emuBR; ! } } ! if (emuBR != newEmuBR) { ! emuBR = newEmuBR; ! maskChanged |= m_emuBR; } ! return TRUE; } /////////////////////////////////////////////////////////////// ! BOOL PortParameters::SetEmuOverrun(const char *pNewEmuOverrun) { ! if (!lstrcmpi(pNewEmuOverrun, "*")) return TRUE; ! DWORD newEmuOverrun; ! if (!lstrcmpi(pNewEmuOverrun, "yes")) { ! newEmuOverrun = 0xFFFFFFFF; } else ! if (!lstrcmpi(pNewEmuOverrun, "no")) { ! newEmuOverrun = 0; } else ! if (!lstrcmpi(pNewEmuOverrun, "-")) { ! newEmuOverrun = 0; } else { --- 105,150 ---- } /////////////////////////////////////////////////////////////// ! DWORD *PortParameters::GetFlagPtr(DWORD bit) { ! switch (bit) { ! case m_emuBR: return &emuBR; ! case m_emuOverrun: return &emuOverrun; ! case m_plugInMode: return &plugInMode; ! case m_exclusiveMode: return &exclusiveMode; } ! return NULL; ! } ! /////////////////////////////////////////////////////////////// ! const char *PortParameters::GetBitName(DWORD bit) ! { ! switch (bit) { ! case m_portName: return "PortName"; ! case m_emuBR: return "EmuBR"; ! case m_emuOverrun: return "EmuOverrun"; ! case m_plugInMode: return "PlugInMode"; ! case m_exclusiveMode: return "ExclusiveMode"; } ! return NULL; } /////////////////////////////////////////////////////////////// ! BOOL PortParameters::SetFlag(const char *pNewFlag, DWORD bit) { ! if (!lstrcmpi(pNewFlag, "*")) return TRUE; ! DWORD newFlag; ! if (!lstrcmpi(pNewFlag, "yes")) { ! newFlag = 0xFFFFFFFF; } else ! if (!lstrcmpi(pNewFlag, "no")) { ! newFlag = 0; } else ! if (!lstrcmpi(pNewFlag, "-")) { ! newFlag = 0; } else { *************** *** 155,173 **** } ! if (lstrcmpi("-", pNewEmuOverrun)) { ! if ((maskExplicit & m_emuOverrun) == 0) { ! maskExplicit |= m_emuOverrun; ! maskChanged |= m_emuOverrun; } } else { ! if (maskExplicit & m_emuOverrun) { ! maskExplicit &= ~m_emuOverrun; ! maskChanged |= m_emuOverrun; } } ! if (emuOverrun != newEmuOverrun) { ! emuOverrun = newEmuOverrun; ! maskChanged |= m_emuOverrun; } --- 152,175 ---- } ! DWORD *pFlag = GetFlagPtr(bit); ! ! if (pFlag == NULL) ! return FALSE; ! ! if (lstrcmpi("-", pNewFlag)) { ! if ((maskExplicit & bit) == 0) { ! maskExplicit |= bit; ! maskChanged |= bit; } } else { ! if (maskExplicit & bit) { ! maskExplicit &= ~bit; ! maskChanged |= bit; } } ! if (*pFlag != newFlag) { ! *pFlag = newFlag; ! maskChanged |= bit; } *************** *** 186,189 **** --- 188,252 ---- } /////////////////////////////////////////////////////////////// + void PortParameters::LoadFlag(HKEY hKey, DWORD bit) + { + DWORD *pFlag = GetFlagPtr(bit); + const char *pName = GetBitName(bit); + + if (pFlag == NULL || pName == NULL) + return; + + DWORD buf; + DWORD len = sizeof(buf); + + LONG err = RegQueryValueEx(hKey, + pName, + NULL, + NULL, + (PBYTE)&buf, + &len); + + if (err == ERROR_SUCCESS) { + *pFlag = buf; + maskExplicit |= bit; + + //Trace(" %s=0x%lX\n", pName, (unsigned long)*pFlag); + } + } + /////////////////////////////////////////////////////////////// + LONG PortParameters::SaveFlag(HKEY hKey, DWORD bit) + { + if (maskChanged & bit) { + DWORD *pFlag = GetFlagPtr(bit); + const char *pName = GetBitName(bit); + + if (pFlag == NULL || pName == NULL) + return ERROR_BAD_COMMAND; + + LONG err; + + if (maskExplicit & bit) { + err = RegSetValueEx(hKey, + pName, + NULL, + REG_DWORD, + (PBYTE)pFlag, + sizeof(*pFlag)); + } else { + err = RegDeleteValue(hKey, pName); + + if (err == ERROR_FILE_NOT_FOUND) + err = ERROR_SUCCESS; + } + + if (err != ERROR_SUCCESS) + return err; + + maskChanged &= ~bit; + //Trace(" New %s=0x%lX\n", pName, (unsigned long)*pFlag); + } + + return ERROR_SUCCESS; + } + /////////////////////////////////////////////////////////////// LONG PortParameters::Load() { *************** *** 228,262 **** } ! len = sizeof(buf); ! ! err = RegQueryValueEx(hKey, ! "EmuBR", ! NULL, ! NULL, ! (PBYTE)buf, ! &len); ! ! if (err == ERROR_SUCCESS) { ! emuBR = *(PDWORD)buf; ! maskExplicit |= m_emuBR; ! ! //Trace(" EmuBR=0x%lX\n", (unsigned long)emuBR); ! } ! ! len = sizeof(buf); ! ! err = RegQueryValueEx(hKey, ! "EmuOverrun", ! NULL, ! NULL, ! (PBYTE)buf, ! &len); ! ! if (err == ERROR_SUCCESS) { ! emuOverrun = *(PDWORD)buf; ! maskExplicit |= m_emuOverrun; ! ! //Trace(" EmuOverrun=0x%lX\n", (unsigned long)emuOverrun); ! } RegCloseKey(hKey); --- 291,296 ---- } ! for (int i = 0 ; i < sizeof(flagBits)/sizeof(flagBits[0]) ; i++) ! LoadFlag(hKey, flagBits[i]); RegCloseKey(hKey); *************** *** 314,359 **** } ! if (maskChanged & m_emuBR) { ! if (maskExplicit & m_emuBR) { ! err = RegSetValueEx(hKey, ! "EmuBR", ! NULL, ! REG_DWORD, ! (PBYTE)&emuBR, ! sizeof(emuBR)); ! } else { ! err = RegDeleteValue(hKey, "EmuBR"); ! ! if (err == ERROR_FILE_NOT_FOUND) ! err = ERROR_SUCCESS; ! } ! ! if (err != ERROR_SUCCESS) ! goto err; ! ! maskChanged &= ~m_emuBR; ! //Trace(" New EmuBR=0x%lX\n", (unsigned long)emuBR); ! } ! ! if (maskChanged & m_emuOverrun) { ! if (maskExplicit & m_emuOverrun) { ! err = RegSetValueEx(hKey, ! "EmuOverrun", ! NULL, ! REG_DWORD, ! (PBYTE)&emuOverrun, ! sizeof(emuOverrun)); ! } else { ! err = RegDeleteValue(hKey, "EmuOverrun"); ! ! if (err == ERROR_FILE_NOT_FOUND) ! err = ERROR_SUCCESS; ! } ! ! if (err != ERROR_SUCCESS) goto err; - - maskChanged &= ~m_emuOverrun; - //Trace(" New EmuOverrun=0x%lX\n", (unsigned long)emuOverrun); } --- 348,354 ---- } ! for (int i = 0 ; i < sizeof(flagBits)/sizeof(flagBits[0]) ; i++) { ! if (SaveFlag(hKey, flagBits[i]) != ERROR_SUCCESS) goto err; } *************** *** 372,381 **** if (!tmp.SetPortName(pParameters)) return FALSE; ! if (!tmp.SetEmuBR(pParameters)) ! return FALSE; ! if (!tmp.SetEmuOverrun(pParameters)) ! return FALSE; } else { ! char pars[100]; lstrcpyn(pars, pParameters, sizeof(pars)); --- 367,377 ---- if (!tmp.SetPortName(pParameters)) return FALSE; ! ! for (int i = 0 ; i < sizeof(flagBits)/sizeof(flagBits[0]) ; i++) { ! if (!tmp.SetFlag(pParameters, flagBits[i])) ! return FALSE; ! } } else { ! char pars[200]; lstrcpyn(pars, pParameters, sizeof(pars)); *************** *** 397,414 **** if (!tmp.SetPortName(pVal)) return FALSE; ! } ! else ! if (!lstrcmpi(pKey, "EmuBR")) { ! if (!tmp.SetEmuBR(pVal)) ! return FALSE; ! } ! else ! if (!lstrcmpi(pKey, "EmuOverrun")) { ! if (!tmp.SetEmuOverrun(pVal)) return FALSE; } - else { - return FALSE; - } } } --- 393,416 ---- if (!tmp.SetPortName(pVal)) return FALSE; ! } else { ! int i; ! ! for (i = 0 ; i < sizeof(flagBits)/sizeof(flagBits[0]) ; i++) { ! DWORD bit = flagBits[i]; ! DWORD *pFlag = GetFlagPtr(bit); ! const char *pName = GetBitName(bit); ! ! if (pFlag == NULL || pName == NULL) ! continue; ! ! if (!lstrcmpi(pKey, pName)) { ! if (!tmp.SetFlag(pVal, bit)) ! return FALSE; ! break; ! } ! } ! if (i >= sizeof(flagBits)/sizeof(flagBits[0])) return FALSE; } } } *************** *** 423,432 **** int len; ! len = SNPRINTF(pParameters, size, "PortName=%s,EmuBR=%s,EmuOverrun=%s", ! (maskExplicit & m_portName) ? (portName) : "-", ! (maskExplicit & m_emuBR) ? (emuBR ? "yes" : "no") : "-", ! (maskExplicit & m_emuOverrun) ? (emuOverrun ? "yes" : "no") : "-"); ! return len >= 0; } /////////////////////////////////////////////////////////////// --- 425,457 ---- int len; ! len = SNPRINTF(pParameters, size, "PortName=%s", (maskExplicit & m_portName) ? (portName) : "-"); ! if (len < 0) ! return FALSE; ! ! pParameters += len; ! size -= len; ! ! for (int i = 0 ; i < sizeof(flagBits)/sizeof(flagBits[0]) ; i++) { ! DWORD bit = flagBits[i]; ! ! if ((maskExplicit & bit) != 0) { ! DWORD *pFlag = GetFlagPtr(bit); ! const char *pName = GetBitName(bit); ! ! if (pFlag == NULL || pName == NULL) ! continue; ! ! len = SNPRINTF(pParameters, size, ",%s=%s", pName, *pFlag ? "yes" : "no"); ! ! if (len < 0) ! return FALSE; ! ! pParameters += len; ! size -= len; ! } ! } ! ! return TRUE; } /////////////////////////////////////////////////////////////// *************** *** 452,459 **** " PortName=<name> - set port name to <name>\n" " (port identifier by default)\n" ! " EmuBR={yes|no} - enable/disable baud rate emulation\n" ! " (disabled by default)\n" ! " EmuOverrun={yes|no} - enable/disable buffer overrun\n" ! " (disabled by default)\n" "\n" "Special values:\n" --- 477,488 ---- " PortName=<name> - set port name to <name>\n" " (port identifier by default)\n" ! " EmuBR={yes|no} - enable/disable baud rate emulation in the direction\n" ! " to the paired port (disabled by default)\n" ! " EmuOverrun={yes|no} - enable/disable buffer overrun (disabled by default)\n" ! " PlugInMode={yes|no} - enable/disable plug-in mode (disabled by default),\n" ! " the plug-in mode port is hidden and can't be open if\n" ! " the paired port is not open\n" ! " ExclusiveMode={yes|no} - enable/disable exclusive mode (disabled by default),\n" ! " the exclusive mode port is hidden if it is open\n" "\n" "Special values:\n" |
From: Vyacheslav F. <vf...@us...> - 2007-06-01 16:22:46
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv32250 Modified Files: adddev.c com0com.h openclos.c pnp.c sources wmi.c Added Files: showport.c showport.h Log Message: Implemented plug-in and exclusive modes Index: openclos.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/openclos.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** openclos.c 11 Jan 2007 14:50:29 -0000 1.16 --- openclos.c 1 Jun 2007 16:22:40 -0000 1.17 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.17 2007/06/01 16:22:40 vfrolov + * Implemented plug-in and exclusive modes + * * Revision 1.16 2007/01/11 14:50:29 vfrolov * Pool functions replaced by *************** *** 96,99 **** --- 99,110 ---- pIoPort = pDevExt->pIoPortLocal; + if (pIoPort->plugInMode && !pIoPort->pIoPortRemote->isOpen) { + InterlockedDecrement(&pDevExt->openCount); + return STATUS_ACCESS_DENIED; + } + + if (pIoPort->exclusiveMode) + IoInvalidateDeviceRelations(pIoPort->pPhDevObj, BusRelations); + switch (MmQuerySystemSize()) { case MmLargeSystem: *************** *** 153,156 **** --- 164,172 ---- KeReleaseSpinLock(pIoPort->pIoLock, oldIrql); + pIoPort->isOpen = TRUE; + + if (pIoPort->pIoPortRemote->plugInMode) + IoInvalidateDeviceRelations(pIoPort->pIoPortRemote->pPhDevObj, BusRelations); + FdoPortCompleteQueue(&queueToComplete); *************** *** 166,169 **** --- 182,190 ---- pIoPort = pDevExt->pIoPortLocal; + pIoPort->isOpen = FALSE; + + if (pIoPort->pIoPortRemote->plugInMode) + IoInvalidateDeviceRelations(pIoPort->pIoPortRemote->pPhDevObj, BusRelations); + InitializeListHead(&queueToComplete); *************** *** 178,181 **** --- 199,205 ---- KeReleaseSpinLock(pIoPort->pIoLock, oldIrql); + if (pIoPort->exclusiveMode) + IoInvalidateDeviceRelations(pIoPort->pPhDevObj, BusRelations); + FdoPortCompleteQueue(&queueToComplete); --- NEW FILE: showport.c --- /* * $Id: showport.c,v 1.1 2007/06/01 16:22:40 vfrolov Exp $ * * Copyright (c) 2007 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: showport.c,v $ * Revision 1.1 2007/06/01 16:22:40 vfrolov * Implemented plug-in and exclusive modes * * */ #include "precomp.h" #include "showport.h" /* * FILE_ID used by HALT_UNLESS to put it on BSOD */ #define FILE_ID 0xD #define C0C_SHOW_SETNAME 0x01 #define C0C_SHOW_SYMLINK 0x02 #define C0C_SHOW_DEVICEMAP 0x04 #define C0C_SHOW_INTERFACE 0x08 #define C0C_SHOW_WMIREG 0x10 #define C0C_SHOW_SHOWN 0x80 #ifndef NTDDI_VERSION /* ZwDeleteValueKey is missing in old DDKs */ NTSYSAPI NTSTATUS NTAPI ZwDeleteValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName); #endif BOOLEAN HidePortName(IN PC0C_FDOPORT_EXTENSION pDevExt) { BOOLEAN res; HANDLE hKey; NTSTATUS status; res = TRUE; status = IoOpenDeviceRegistryKey(pDevExt->pIoPortLocal->pPhDevObj, PLUGPLAY_REGKEY_DEVICE, STANDARD_RIGHTS_WRITE, &hKey); if (NT_SUCCESS(status)) { UNICODE_STRING keyName; RtlInitUnicodeString(&keyName, L"PortName"); status = ZwDeleteValueKey(hKey, &keyName); if (!NT_SUCCESS(status) && (pDevExt->shown & C0C_SHOW_SETNAME) != 0) { res = FALSE; Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"HidePortName ZwDeleteValueKey(PortName) FAIL"); } ZwClose(hKey); } else if ((pDevExt->shown & C0C_SHOW_SETNAME) != 0) { res = FALSE; Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"HidePortName IoOpenDeviceRegistryKey(PLUGPLAY_REGKEY_DEVICE) FAIL"); } pDevExt->shown &= ~C0C_SHOW_SETNAME; return res; } BOOLEAN HidePort(IN PC0C_FDOPORT_EXTENSION pDevExt) { BOOLEAN res; NTSTATUS status; if (!pDevExt->shown) return TRUE; res = TRUE; if ((pDevExt->shown & C0C_SHOW_WMIREG) != 0) { status = IoWMIRegistrationControl(pDevExt->pDevObj, WMIREG_ACTION_DEREGISTER); pDevExt->shown &= ~C0C_SHOW_WMIREG; if (!NT_SUCCESS(status)) { res = FALSE; Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"HidePort IoWMIRegistrationControl FAIL"); } } if (pDevExt->symbolicLinkName.Buffer && (pDevExt->shown & C0C_SHOW_INTERFACE) != 0) { status = IoSetDeviceInterfaceState(&pDevExt->symbolicLinkName, FALSE); pDevExt->shown &= ~C0C_SHOW_INTERFACE; if (!NT_SUCCESS(status)) { res = FALSE; Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"HidePort IoSetDeviceInterfaceState FAIL"); } } if (pDevExt->ntDeviceName.Buffer && (pDevExt->shown & C0C_SHOW_DEVICEMAP) != 0) { status = RtlDeleteRegistryValue(RTL_REGISTRY_DEVICEMAP, C0C_SERIAL_DEVICEMAP, pDevExt->ntDeviceName.Buffer); pDevExt->shown &= ~C0C_SHOW_DEVICEMAP; if (!NT_SUCCESS(status)) { res = FALSE; Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"HidePort RtlDeleteRegistryValue " C0C_SERIAL_DEVICEMAP L" FAIL"); } } if (pDevExt->win32DeviceName.Buffer && (pDevExt->shown & C0C_SHOW_SYMLINK) != 0) { status = IoDeleteSymbolicLink(&pDevExt->win32DeviceName); pDevExt->shown &= ~C0C_SHOW_SYMLINK; if (!NT_SUCCESS(status)) { res = FALSE; Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"HidePort IoDeleteSymbolicLink FAIL"); } } if ((pDevExt->shown & C0C_SHOW_SETNAME) != 0) res = (HidePortName(pDevExt) && res); pDevExt->shown &= ~C0C_SHOW_SHOWN; Trace00((PC0C_COMMON_EXTENSION)pDevExt, L"HidePort - ", res ? L"OK" : L"FAIL"); return res; } BOOLEAN ShowPort(IN PC0C_FDOPORT_EXTENSION pDevExt) { BOOLEAN res; NTSTATUS status; if ((pDevExt->shown & C0C_SHOW_SHOWN) != 0) return TRUE; res = TRUE; if ((pDevExt->shown & C0C_SHOW_SETNAME) == 0) { HANDLE hKey; status = IoOpenDeviceRegistryKey(pDevExt->pIoPortLocal->pPhDevObj, PLUGPLAY_REGKEY_DEVICE, STANDARD_RIGHTS_WRITE, &hKey); if (status == STATUS_SUCCESS) { UNICODE_STRING keyName; RtlInitUnicodeString(&keyName, L"PortName"); status = ZwSetValueKey(hKey, &keyName, 0, REG_SZ, pDevExt->portName, (ULONG)((wcslen(pDevExt->portName) + 1) * sizeof(WCHAR))); if (NT_SUCCESS(status)) { pDevExt->shown |= C0C_SHOW_SETNAME; } else { res = FALSE; Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"ShowPort ZwSetValueKey(PortName) FAIL"); } ZwClose(hKey); } else { res = FALSE; Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"ShowPort IoOpenDeviceRegistryKey(PLUGPLAY_REGKEY_DEVICE) FAIL"); } } if (pDevExt->ntDeviceName.Buffer) { if (pDevExt->win32DeviceName.Buffer && (pDevExt->shown & C0C_SHOW_SYMLINK) == 0) { status = IoCreateSymbolicLink(&pDevExt->win32DeviceName, &pDevExt->ntDeviceName); if (NT_SUCCESS(status)) { pDevExt->shown |= C0C_SHOW_SYMLINK; } else { res = FALSE; Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"ShowPort IoCreateSymbolicLink FAIL"); } } if ((pDevExt->shown & C0C_SHOW_SYMLINK) != 0 && (pDevExt->shown & C0C_SHOW_DEVICEMAP) == 0) { status = RtlWriteRegistryValue(RTL_REGISTRY_DEVICEMAP, C0C_SERIAL_DEVICEMAP, pDevExt->ntDeviceName.Buffer, REG_SZ, pDevExt->portName, (ULONG)((wcslen(pDevExt->portName) + 1) * sizeof(WCHAR))); if (NT_SUCCESS(status)) { pDevExt->shown |= C0C_SHOW_DEVICEMAP; } else { res = FALSE; Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"ShowPort RtlWriteRegistryValue " C0C_SERIAL_DEVICEMAP L" FAIL"); } } } if (pDevExt->symbolicLinkName.Buffer && (pDevExt->shown & C0C_SHOW_INTERFACE) == 0) { status = IoSetDeviceInterfaceState(&pDevExt->symbolicLinkName, TRUE); if (NT_SUCCESS(status)) { pDevExt->shown |= C0C_SHOW_INTERFACE; } else { res = FALSE; Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"ShowPort IoSetDeviceInterfaceState FAIL"); } } if ((pDevExt->shown & C0C_SHOW_WMIREG) == 0) { status = IoWMIRegistrationControl(pDevExt->pDevObj, WMIREG_ACTION_REGISTER); if (NT_SUCCESS(status)) { pDevExt->shown |= C0C_SHOW_WMIREG; } else { res = FALSE; Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"ShowPort IoWMIRegistrationControl FAIL"); } } pDevExt->shown |= C0C_SHOW_SHOWN; Trace00((PC0C_COMMON_EXTENSION)pDevExt, L"ShowPort - ", res ? L"OK" : L"FAIL"); return res; } Index: sources =================================================================== RCS file: /cvsroot/com0com/com0com/sys/sources,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** sources 23 Oct 2006 11:59:55 -0000 1.7 --- sources 1 Jun 2007 16:22:40 -0000 1.8 *************** *** 9,12 **** --- 9,13 ---- initunlo.c \ adddev.c \ + showport.c \ openclos.c \ pnp.c \ Index: com0com.h =================================================================== RCS file: /cvsroot/com0com/com0com/sys/com0com.h,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** com0com.h 20 Feb 2007 12:05:11 -0000 1.33 --- com0com.h 1 Jun 2007 16:22:40 -0000 1.34 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.34 2007/06/01 16:22:40 vfrolov + * Implemented plug-in and exclusive modes + * * Revision 1.33 2007/02/20 12:05:11 vfrolov * Implemented IOCTL_SERIAL_XOFF_COUNTER *************** *** 153,157 **** #define FDO_EXTENSION \ COMMON_EXTENSION \ - PDEVICE_OBJECT pPhDevObj; \ PDEVICE_OBJECT pLowDevObj; \ --- 156,159 ---- *************** *** 205,208 **** --- 207,211 ---- struct _C0C_FDOPORT_EXTENSION *pDevExt; + PDEVICE_OBJECT pPhDevObj; struct _C0C_IO_PORT *pIoPortRemote; PKSPIN_LOCK pIoLock; *************** *** 254,258 **** --- 257,264 ---- BOOLEAN tryWrite; + BOOLEAN isOpen; BOOLEAN emuOverrun; + BOOLEAN plugInMode; + BOOLEAN exclusiveMode; } C0C_IO_PORT, *PC0C_IO_PORT; *************** *** 276,279 **** --- 282,286 ---- UNICODE_STRING win32DeviceName; UNICODE_STRING symbolicLinkName; + unsigned short shown; LONG openCount; --- NEW FILE: showport.h --- /* * $Id: showport.h,v 1.1 2007/06/01 16:22:40 vfrolov Exp $ * * Copyright (c) 2007 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: showport.h,v $ * Revision 1.1 2007/06/01 16:22:40 vfrolov * Implemented plug-in and exclusive modes * * */ #ifndef _C0C_SHOWPORT_H_ #define _C0C_SHOWPORT_H_ BOOLEAN HidePortName(IN PC0C_FDOPORT_EXTENSION pDevExt); BOOLEAN HidePort(IN PC0C_FDOPORT_EXTENSION pDevExt); BOOLEAN ShowPort(IN PC0C_FDOPORT_EXTENSION pDevExt); #endif /* _C0C_SHOWPORT_H_ */ Index: adddev.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/adddev.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** adddev.c 1 Jun 2007 08:36:26 -0000 1.25 --- adddev.c 1 Jun 2007 16:22:40 -0000 1.26 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.26 2007/06/01 16:22:40 vfrolov + * Implemented plug-in and exclusive modes + * * Revision 1.25 2007/06/01 08:36:26 vfrolov * Changed parameter type for SetWriteDelay() *************** *** 109,112 **** --- 112,116 ---- #include "delay.h" #include "strutils.h" + #include "showport.h" /* *************** *** 131,154 **** FreeTimeouts(pDevExt->pIoPortLocal); FreeWriteDelay(pDevExt->pIoPortLocal); pDevExt->pIoPortLocal->pDevExt = NULL; } ! IoWMIRegistrationControl(pDevExt->pDevObj, WMIREG_ACTION_DEREGISTER); ! ! if (pDevExt->symbolicLinkName.Buffer) { ! IoSetDeviceInterfaceState(&pDevExt->symbolicLinkName, FALSE); ! RtlFreeUnicodeString(&pDevExt->symbolicLinkName); ! } ! ! if (pDevExt->ntDeviceName.Buffer) { ! RtlDeleteRegistryValue(RTL_REGISTRY_DEVICEMAP, C0C_SERIAL_DEVICEMAP, ! pDevExt->ntDeviceName.Buffer); ! StrFree(&pDevExt->ntDeviceName); ! } ! if (pDevExt->win32DeviceName.Buffer) { ! IoDeleteSymbolicLink(&pDevExt->win32DeviceName); ! StrFree(&pDevExt->win32DeviceName); ! } if (pDevExt->pLowDevObj) --- 135,148 ---- FreeTimeouts(pDevExt->pIoPortLocal); FreeWriteDelay(pDevExt->pIoPortLocal); + pDevExt->pIoPortLocal->plugInMode = FALSE; + pDevExt->pIoPortLocal->exclusiveMode = FALSE; pDevExt->pIoPortLocal->pDevExt = NULL; } ! if (!HidePort(pDevExt)) ! SysLog(pDevExt->pDevObj, STATUS_UNSUCCESSFUL, L"RemoveFdoPort HidePort FAIL"); ! StrFree(&pDevExt->ntDeviceName); ! StrFree(&pDevExt->win32DeviceName); if (pDevExt->pLowDevObj) *************** *** 167,171 **** PC0C_FDOPORT_EXTENSION pDevExt; PC0C_PDOPORT_EXTENSION pPhDevExt; ! ULONG emuBR, emuOverrun; UNICODE_STRING ntDeviceName; PWCHAR pPortName; --- 161,165 ---- PC0C_FDOPORT_EXTENSION pDevExt; PC0C_PDOPORT_EXTENSION pPhDevExt; ! ULONG emuBR, emuOverrun, plugInMode, exclusiveMode; UNICODE_STRING ntDeviceName; PWCHAR pPortName; *************** *** 240,264 **** } ! emuBR = emuOverrun = 0; if (NT_SUCCESS(status)) { ! RTL_QUERY_REGISTRY_TABLE queryTable[3]; ULONG zero = 0; RtlZeroMemory(queryTable, sizeof(queryTable)); ! queryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; ! queryTable[0].Name = L"EmuBR"; ! queryTable[0].EntryContext = &emuBR; ! queryTable[0].DefaultType = REG_DWORD; ! queryTable[0].DefaultData = &zero; ! queryTable[0].DefaultLength = sizeof(ULONG); ! queryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT; ! queryTable[1].Name = L"EmuOverrun"; ! queryTable[1].EntryContext = &emuOverrun; ! queryTable[1].DefaultType = REG_DWORD; ! queryTable[1].DefaultData = &zero; ! queryTable[1].DefaultLength = sizeof(ULONG); RtlQueryRegistryValues( --- 234,277 ---- } ! emuBR = emuOverrun = plugInMode = exclusiveMode = 0; if (NT_SUCCESS(status)) { ! RTL_QUERY_REGISTRY_TABLE queryTable[5]; ULONG zero = 0; + int i; RtlZeroMemory(queryTable, sizeof(queryTable)); ! i = 0; ! queryTable[i].Flags = RTL_QUERY_REGISTRY_DIRECT; ! queryTable[i].Name = L"EmuBR"; ! queryTable[i].EntryContext = &emuBR; ! queryTable[i].DefaultType = REG_DWORD; ! queryTable[i].DefaultData = &zero; ! queryTable[i].DefaultLength = sizeof(ULONG); ! i++; ! queryTable[i].Flags = RTL_QUERY_REGISTRY_DIRECT; ! queryTable[i].Name = L"EmuOverrun"; ! queryTable[i].EntryContext = &emuOverrun; ! queryTable[i].DefaultType = REG_DWORD; ! queryTable[i].DefaultData = &zero; ! queryTable[i].DefaultLength = sizeof(ULONG); ! ! i++; ! queryTable[i].Flags = RTL_QUERY_REGISTRY_DIRECT; ! queryTable[i].Name = L"PlugInMode"; ! queryTable[i].EntryContext = &plugInMode; ! queryTable[i].DefaultType = REG_DWORD; ! queryTable[i].DefaultData = &zero; ! queryTable[i].DefaultLength = sizeof(ULONG); ! ! i++; ! queryTable[i].Flags = RTL_QUERY_REGISTRY_DIRECT; ! queryTable[i].Name = L"ExclusiveMode"; ! queryTable[i].EntryContext = &exclusiveMode; ! queryTable[i].DefaultType = REG_DWORD; ! queryTable[i].DefaultData = &zero; ! queryTable[i].DefaultLength = sizeof(ULONG); RtlQueryRegistryValues( *************** *** 278,305 **** } - { - HANDLE hKey; - - status = IoOpenDeviceRegistryKey(pPhDevObj, - PLUGPLAY_REGKEY_DEVICE, - STANDARD_RIGHTS_READ, - &hKey); - - if (status == STATUS_SUCCESS) { - UNICODE_STRING keyName; - - RtlInitUnicodeString(&keyName, L"PortName"); - - status = ZwSetValueKey(hKey, &keyName, 0, REG_SZ, portName.Buffer, portName.Length + sizeof(WCHAR)); - - if (!NT_SUCCESS(status)) - SysLog(pPhDevObj, status, L"ZwSetValueKey(PortName) FAIL"); - - ZwClose(hKey); - } else { - SysLog(pPhDevObj, status, L"IoOpenDeviceRegistryKey(PLUGPLAY_REGKEY_DEVICE) FAIL"); - } - } - status = IoCreateDevice(pDrvObj, sizeof(*pDevExt), --- 291,294 ---- *************** *** 318,321 **** --- 307,311 ---- pDevExt = pNewDevObj->DeviceExtension; RtlZeroMemory(pDevExt, sizeof(*pDevExt)); + pDevExt->pIoPortLocal = pPhDevExt->pIoPortLocal; status = InitCommonExt((PC0C_COMMON_EXTENSION)pDevExt, pNewDevObj, C0C_DOTYPE_FP, portName.Buffer); *************** *** 325,329 **** } - pDevExt->pIoPortLocal = pPhDevExt->pIoPortLocal; pDevExt->pIoPortLocal->pDevExt = pDevExt; --- 315,318 ---- *************** *** 345,348 **** --- 334,353 ---- } + if (plugInMode) { + pDevExt->pIoPortLocal->plugInMode = TRUE; + Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Enabled plug-in mode"); + } else { + pDevExt->pIoPortLocal->plugInMode = FALSE; + Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Disabled plug-in mode"); + } + + if (exclusiveMode) { + pDevExt->pIoPortLocal->exclusiveMode = TRUE; + Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Enabled exclusive mode"); + } else { + pDevExt->pIoPortLocal->exclusiveMode = FALSE; + Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Disabled exclusive mode"); + } + AllocTimeouts(pDevExt->pIoPortLocal); *************** *** 364,368 **** SetWriteDelay(pDevExt); - pDevExt->pPhDevObj = pPhDevObj; pDevExt->pLowDevObj = IoAttachDeviceToDeviceStack(pNewDevObj, pPhDevObj); --- 369,372 ---- *************** *** 385,409 **** StrAppendStr0(&status, &pDevExt->win32DeviceName, portName.Buffer); ! if (NT_SUCCESS(status)) { ! status = IoCreateSymbolicLink(&pDevExt->win32DeviceName, &pDevExt->ntDeviceName); ! ! if (NT_SUCCESS(status)) { ! status = RtlWriteRegistryValue(RTL_REGISTRY_DEVICEMAP, C0C_SERIAL_DEVICEMAP, ! pDevExt->ntDeviceName.Buffer, REG_SZ, ! portName.Buffer, ! portName.Length + sizeof(WCHAR)); ! ! if (!NT_SUCCESS(status)) { ! StrFree(&pDevExt->ntDeviceName); ! ! SysLog(pPhDevObj, status, L"AddFdoPort RtlWriteRegistryValue" C0C_SERIAL_DEVICEMAP L" FAIL"); ! } ! } else { ! StrFree(&pDevExt->win32DeviceName); ! StrFree(&pDevExt->ntDeviceName); ! ! SysLog(pPhDevObj, status, L"AddFdoPort IoCreateSymbolicLink FAIL"); ! } ! } else { StrFree(&pDevExt->win32DeviceName); StrFree(&pDevExt->ntDeviceName); --- 389,393 ---- StrAppendStr0(&status, &pDevExt->win32DeviceName, portName.Buffer); ! if (!NT_SUCCESS(status)) { StrFree(&pDevExt->win32DeviceName); StrFree(&pDevExt->ntDeviceName); *************** *** 417,434 **** &pDevExt->symbolicLinkName); ! if (NT_SUCCESS(status)) { ! status = IoSetDeviceInterfaceState(&pDevExt->symbolicLinkName, TRUE); ! ! if (!NT_SUCCESS(status)) ! SysLog(pPhDevObj, status, L"AddFdoPort IoSetDeviceInterfaceState FAIL"); ! } else { SysLog(pPhDevObj, status, L"AddFdoPort IoRegisterDeviceInterface FAIL"); pDevExt->symbolicLinkName.Buffer = NULL; } ! status = IoWMIRegistrationControl(pNewDevObj, WMIREG_ACTION_REGISTER); ! ! if (!NT_SUCCESS(status)) ! SysLog(pPhDevObj, status, L"AddFdoPort IoWMIRegistrationControl FAIL"); status = STATUS_SUCCESS; --- 401,415 ---- &pDevExt->symbolicLinkName); ! if (!NT_SUCCESS(status)) { SysLog(pPhDevObj, status, L"AddFdoPort IoRegisterDeviceInterface FAIL"); pDevExt->symbolicLinkName.Buffer = NULL; } ! if (!pDevExt->pIoPortLocal->plugInMode || pDevExt->pIoPortLocal->pIoPortRemote->isOpen) { ! if (!ShowPort(pDevExt)) ! SysLog(pDevExt->pDevObj, STATUS_UNSUCCESSFUL, L"AddFdoPort ShowPort FAIL"); ! } else { ! HidePortName(pDevExt); ! } status = STATUS_SUCCESS; *************** *** 497,500 **** --- 478,482 ---- HALT_UNLESS(pNewDevObj); + pIoPortLocal->pPhDevObj = pNewDevObj; pDevExt = (pNewDevObj)->DeviceExtension; RtlZeroMemory(pDevExt, sizeof(*pDevExt)); *************** *** 716,720 **** pDevExt->portNum = num; - pDevExt->pPhDevObj = pPhDevObj; pDevExt->pLowDevObj = IoAttachDeviceToDeviceStack(pNewDevObj, pPhDevObj); --- 698,701 ---- Index: wmi.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/wmi.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** wmi.c 27 Oct 2006 12:44:14 -0000 1.3 --- wmi.c 1 Jun 2007 16:22:40 -0000 1.4 *************** *** 2,6 **** * $Id$ * ! * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify --- 2,6 ---- * $Id$ * ! * Copyright (c) 2006-2007 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.4 2007/06/01 16:22:40 vfrolov + * Implemented plug-in and exclusive modes + * * Revision 1.3 2006/10/27 12:44:14 vfrolov * Fixed typecasting *************** *** 94,98 **** *pRegFlags = WMIREG_FLAG_INSTANCE_PDO; ! *ppPhDevObj = pDevExt->pPhDevObj; return STATUS_SUCCESS; --- 97,101 ---- *pRegFlags = WMIREG_FLAG_INSTANCE_PDO; ! *ppPhDevObj = pDevExt->pIoPortLocal->pPhDevObj; return STATUS_SUCCESS; Index: pnp.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/pnp.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pnp.c 11 Jan 2007 14:50:29 -0000 1.6 --- pnp.c 1 Jun 2007 16:22:40 -0000 1.7 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.7 2007/06/01 16:22:40 vfrolov + * Implemented plug-in and exclusive modes + * * Revision 1.6 2007/01/11 14:50:29 vfrolov * Pool functions replaced by *************** *** 46,51 **** #include "precomp.h" - #include "strutils.h" #include <initguid.h> /* --- 49,55 ---- #include "precomp.h" #include <initguid.h> + #include "strutils.h" + #include "showport.h" /* *************** *** 314,317 **** --- 318,333 ---- switch (minorFunction) { + case IRP_MN_QUERY_DEVICE_RELATIONS: { + PC0C_IO_PORT pIoPort = pDevExt->pIoPortLocal; + + if ((pIoPort->exclusiveMode && pIoPort->isOpen) || + (pIoPort->plugInMode && !pIoPort->pIoPortRemote->isOpen)) + { + HidePort(pDevExt); + } else { + ShowPort(pDevExt); + } + break; + } case IRP_MN_QUERY_REMOVE_DEVICE: if (pDevExt->openCount) |
From: Vyacheslav F. <vf...@us...> - 2007-06-01 16:15:08
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv29253 Modified Files: delay.c Log Message: Fixed previous fix Index: delay.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/delay.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** delay.c 1 Jun 2007 08:36:26 -0000 1.6 --- delay.c 1 Jun 2007 16:15:02 -0000 1.7 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.7 2007/06/01 16:15:02 vfrolov + * Fixed previous fix + * * Revision 1.6 2007/06/01 08:36:26 vfrolov * Changed parameter type for SetWriteDelay() *************** *** 161,170 **** return; ! KeAcquireSpinLock(&pDevExt->controlLock, &oldIrql); lineControl = pDevExt->lineControl; params.baudRate = pDevExt->baudRate.BaudRate; ! KeReleaseSpinLock(&pDevExt->controlLock, oldIrql); ! ! KeAcquireSpinLock(pDevExt->pIoPortLocal->pIoLock, &oldIrql); /* Startbit + WordLength */ --- 164,173 ---- return; ! KeAcquireSpinLock(pDevExt->pIoPortLocal->pIoLock, &oldIrql); ! ! KeAcquireSpinLockAtDpcLevel(&pDevExt->controlLock); lineControl = pDevExt->lineControl; params.baudRate = pDevExt->baudRate.BaudRate; ! KeReleaseSpinLockFromDpcLevel(&pDevExt->controlLock); /* Startbit + WordLength */ |
From: Vyacheslav F. <vf...@us...> - 2007-06-01 08:36:34
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv22342 Modified Files: adddev.c delay.c delay.h ioctl.c Log Message: Changed parameter type for SetWriteDelay() Index: adddev.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/adddev.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** adddev.c 11 Jan 2007 14:50:28 -0000 1.24 --- adddev.c 1 Jun 2007 08:36:26 -0000 1.25 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.25 2007/06/01 08:36:26 vfrolov + * Changed parameter type for SetWriteDelay() + * * Revision 1.24 2007/01/11 14:50:28 vfrolov * Pool functions replaced by *************** *** 359,363 **** pDevExt->baudRate.BaudRate = 1200; ! SetWriteDelay(pDevExt->pIoPortLocal); pDevExt->pPhDevObj = pPhDevObj; --- 362,366 ---- pDevExt->baudRate.BaudRate = 1200; ! SetWriteDelay(pDevExt); pDevExt->pPhDevObj = pPhDevObj; Index: delay.h =================================================================== RCS file: /cvsroot/com0com/com0com/sys/delay.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** delay.h 23 Jun 2006 11:44:52 -0000 1.3 --- delay.h 1 Jun 2007 08:36:26 -0000 1.4 *************** *** 2,6 **** * $Id$ * ! * Copyright (c) 2005-2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify --- 2,6 ---- * $Id$ * ! * Copyright (c) 2005-2007 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.4 2007/06/01 08:36:26 vfrolov + * Changed parameter type for SetWriteDelay() + * * Revision 1.3 2006/06/23 11:44:52 vfrolov * Mass replacement pDevExt by pIoPort *************** *** 54,58 **** VOID FreeWriteDelay(PC0C_IO_PORT pIoPort); SIZE_T GetWriteLimit(PC0C_ADAPTIVE_DELAY pWriteDelay); ! VOID SetWriteDelay(PC0C_IO_PORT pIoPort); VOID StartWriteDelayTimer(PC0C_ADAPTIVE_DELAY pWriteDelay); VOID StopWriteDelayTimer(PC0C_ADAPTIVE_DELAY pWriteDelay); --- 57,61 ---- VOID FreeWriteDelay(PC0C_IO_PORT pIoPort); SIZE_T GetWriteLimit(PC0C_ADAPTIVE_DELAY pWriteDelay); ! VOID SetWriteDelay(PC0C_FDOPORT_EXTENSION pDevExt); VOID StartWriteDelayTimer(PC0C_ADAPTIVE_DELAY pWriteDelay); VOID StopWriteDelayTimer(PC0C_ADAPTIVE_DELAY pWriteDelay); Index: ioctl.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/ioctl.c,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** ioctl.c 20 Feb 2007 12:05:11 -0000 1.29 --- ioctl.c 1 Jun 2007 08:36:26 -0000 1.30 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.30 2007/06/01 08:36:26 vfrolov + * Changed parameter type for SetWriteDelay() + * * Revision 1.29 2007/02/20 12:05:11 vfrolov * Implemented IOCTL_SERIAL_XOFF_COUNTER *************** *** 544,548 **** KeReleaseSpinLock(&pDevExt->controlLock, oldIrql); ! SetWriteDelay(pIoPortLocal); break; case IOCTL_SERIAL_GET_LINE_CONTROL: --- 547,551 ---- KeReleaseSpinLock(&pDevExt->controlLock, oldIrql); ! SetWriteDelay(pDevExt); break; case IOCTL_SERIAL_GET_LINE_CONTROL: *************** *** 569,573 **** KeReleaseSpinLock(&pDevExt->controlLock, oldIrql); ! SetWriteDelay(pIoPortLocal); break; case IOCTL_SERIAL_GET_BAUD_RATE: --- 572,576 ---- KeReleaseSpinLock(&pDevExt->controlLock, oldIrql); ! SetWriteDelay(pDevExt); break; case IOCTL_SERIAL_GET_BAUD_RATE: Index: delay.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/delay.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** delay.c 11 Jan 2007 14:50:29 -0000 1.5 --- delay.c 1 Jun 2007 08:36:26 -0000 1.6 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.6 2007/06/01 08:36:26 vfrolov + * Changed parameter type for SetWriteDelay() + * * Revision 1.5 2007/01/11 14:50:29 vfrolov * Pool functions replaced by *************** *** 146,150 **** } ! VOID SetWriteDelay(PC0C_IO_PORT pIoPort) { PC0C_ADAPTIVE_DELAY pWriteDelay; --- 149,153 ---- } ! VOID SetWriteDelay(PC0C_FDOPORT_EXTENSION pDevExt) { PC0C_ADAPTIVE_DELAY pWriteDelay; *************** *** 152,171 **** C0C_DELAY_PARAMS params; SERIAL_LINE_CONTROL lineControl; - PC0C_FDOPORT_EXTENSION pDevExt; ! pWriteDelay = pIoPort->pWriteDelay; if (!pWriteDelay) return; ! KeAcquireSpinLock(pIoPort->pIoLock, &oldIrql); ! ! pDevExt = pIoPort->pDevExt; ! HALT_UNLESS(pDevExt); ! ! KeAcquireSpinLockAtDpcLevel(&pDevExt->controlLock); lineControl = pDevExt->lineControl; params.baudRate = pDevExt->baudRate.BaudRate; ! KeReleaseSpinLockFromDpcLevel(&pDevExt->controlLock); /* Startbit + WordLength */ --- 155,170 ---- C0C_DELAY_PARAMS params; SERIAL_LINE_CONTROL lineControl; ! pWriteDelay = pDevExt->pIoPortLocal->pWriteDelay; if (!pWriteDelay) return; ! KeAcquireSpinLock(&pDevExt->controlLock, &oldIrql); lineControl = pDevExt->lineControl; params.baudRate = pDevExt->baudRate.BaudRate; ! KeReleaseSpinLock(&pDevExt->controlLock, oldIrql); ! ! KeAcquireSpinLock(pDevExt->pIoPortLocal->pIoLock, &oldIrql); /* Startbit + WordLength */ *************** *** 207,211 **** } ! KeReleaseSpinLock(pIoPort->pIoLock, oldIrql); } --- 206,210 ---- } ! KeReleaseSpinLock(pDevExt->pIoPortLocal->pIoLock, oldIrql); } |
From: Vyacheslav F. <vf...@us...> - 2007-05-29 15:30:45
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3313 Modified Files: setup.cpp Log Message: Fixed big hepl text interrupt Index: setup.cpp =================================================================== RCS file: /cvsroot/com0com/com0com/setup/setup.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** setup.cpp 11 Jan 2007 15:05:03 -0000 1.12 --- setup.cpp 29 May 2007 15:30:41 -0000 1.13 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.13 2007/05/29 15:30:41 vfrolov + * Fixed big hepl text interrupt + * * Revision 1.12 2007/01/11 15:05:03 vfrolov * Replaced strtok() by STRTOK_R() *************** *** 729,735 **** ); ConsoleWrite( ! "\n" ! "%s", ! PortParameters::GetHelp()); ConsoleWrite( "\n" --- 732,748 ---- ); ConsoleWrite( ! "\n"); ! ! const char *pStr = PortParameters::GetHelp(); ! ! while (*pStr) { ! char buf[100]; ! ! lstrcpyn(buf, pStr, sizeof(buf)/sizeof(buf[0])); ! pStr += lstrlen(buf); ! ! ConsoleWrite("%s", buf); ! } ! ConsoleWrite( "\n" |
From: Vyacheslav F. <vf...@us...> - 2007-05-29 15:22:05
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv32347 Modified Files: utils.cpp Log Message: Fixed buffer overflow Index: utils.cpp =================================================================== RCS file: /cvsroot/com0com/com0com/setup/utils.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** utils.cpp 11 Jan 2007 15:03:43 -0000 1.4 --- utils.cpp 29 May 2007 15:22:00 -0000 1.5 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.5 2007/05/29 15:22:00 vfrolov + * Fixed buffer overflow + * * Revision 1.4 2007/01/11 15:03:43 vfrolov * Added STRTOK_R() *************** *** 41,45 **** int VSNPRINTF(char *pBuf, int size, const char *pFmt, va_list va) { ! char buf[1024]; int res1 = wvsprintf(buf, pFmt, va); --- 44,48 ---- int VSNPRINTF(char *pBuf, int size, const char *pFmt, va_list va) { ! char buf[1025]; int res1 = wvsprintf(buf, pFmt, va); |
From: Vyacheslav F. <vf...@us...> - 2007-05-28 13:34:06
|
Update of /cvsroot/com0com/com2tcp In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv10514 Modified Files: ReadMe.txt Log Message: Fixed typo Index: ReadMe.txt =================================================================== RCS file: /cvsroot/com0com/com2tcp/ReadMe.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ReadMe.txt 7 May 2007 11:14:59 -0000 1.4 --- ReadMe.txt 28 May 2007 13:34:02 -0000 1.5 *************** *** 19,23 **** ======== ! Start Microsoft Visual C++ 2005 with hub4com.vcproj file. Set Active Configuration to "com2tcp - Win32 Release". Build com2tcp.exe. --- 19,23 ---- ======== ! Start Microsoft Visual C++ 2005 with com2tcp.vcproj file. Set Active Configuration to "com2tcp - Win32 Release". Build com2tcp.exe. |
From: Vyacheslav F. <vf...@us...> - 2007-05-14 12:06:41
|
Update of /cvsroot/com0com/hub4com In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv5110 Modified Files: comparams.cpp comparams.h comio.cpp hub4com.cpp Log Message: Added read interval timeout option Index: comparams.h =================================================================== RCS file: /cvsroot/com0com/hub4com/comparams.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** comparams.h 6 Feb 2007 11:53:33 -0000 1.3 --- comparams.h 14 May 2007 12:06:37 -0000 1.4 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.4 2007/05/14 12:06:37 vfrolov + * Added read interval timeout option + * * Revision 1.3 2007/02/06 11:53:33 vfrolov * Added options --odsr, --ox, --ix and --idsr *************** *** 51,54 **** --- 54,58 ---- BOOL SetInX(const char *pInX) { return SetFlag(pInX, &inX); } BOOL SetInDsr(const char *pInDsr) { return SetFlag(pInDsr, &inDsr); } + BOOL SetIntervalTimeout(const char *pIntervalTimeout); static string BaudRateStr(long baudRate); *************** *** 61,64 **** --- 65,69 ---- static string InXStr(int inX) { return FlagStr(inX); } static string InDsrStr(int inDsr) { return FlagStr(inDsr); } + static string IntervalTimeoutStr(long intervalTimeout); string BaudRateStr() const { return BaudRateStr(baudRate); } *************** *** 71,74 **** --- 76,80 ---- string InXStr() const { return InXStr(inX); } string InDsrStr() const { return InDsrStr(inDsr); } + string IntervalTimeoutStr() const { return IntervalTimeoutStr(intervalTimeout); } static const char *BaudRateLst(); *************** *** 81,84 **** --- 87,91 ---- static const char *InXLst() { return FlagLst(); } static const char *InDsrLst() { return FlagLst(); } + static const char *IntervalTimeoutLst(); long BaudRate() const { return baudRate; } *************** *** 91,94 **** --- 98,102 ---- int InX() const { return inX; } int InDsr() const { return inDsr; } + long IntervalTimeout() const { return intervalTimeout; } private: *************** *** 106,109 **** --- 114,118 ---- int inX; int inDsr; + long intervalTimeout; }; /////////////////////////////////////////////////////////////// Index: comparams.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/comparams.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** comparams.cpp 6 Feb 2007 11:53:33 -0000 1.3 --- comparams.cpp 14 May 2007 12:06:37 -0000 1.4 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.4 2007/05/14 12:06:37 vfrolov + * Added read interval timeout option + * * Revision 1.3 2007/02/06 11:53:33 vfrolov * Added options --odsr, --ox, --ix and --idsr *************** *** 46,50 **** outX(0), inX(0), ! inDsr(0) { } --- 49,54 ---- outX(0), inX(0), ! inDsr(0), ! intervalTimeout(0) { } *************** *** 110,113 **** --- 114,127 ---- } + BOOL ComParams::SetIntervalTimeout(const char *pIntervalTimeout) + { + if (isdigit(*pIntervalTimeout)) { + intervalTimeout = atol(pIntervalTimeout); + return TRUE; + } + + return FALSE; + } + BOOL ComParams::SetFlag(const char *pFlagStr, int *pFlag) { *************** *** 175,178 **** --- 189,203 ---- } + string ComParams::IntervalTimeoutStr(long intervalTimeout) + { + if (intervalTimeout > 0) { + stringstream buf; + buf << intervalTimeout; + return buf.str(); + } + + return "0"; + } + string ComParams::FlagStr(int flag) { *************** *** 205,208 **** --- 230,238 ---- } + const char *ComParams::IntervalTimeoutLst() + { + return "a positive number or 0 milliseconds"; + } + const char *ComParams::FlagLst() { Index: hub4com.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/hub4com.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** hub4com.cpp 6 Feb 2007 11:53:33 -0000 1.4 --- hub4com.cpp 14 May 2007 12:06:37 -0000 1.5 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.5 2007/05/14 12:06:37 vfrolov + * Added read interval timeout option + * * Revision 1.4 2007/02/06 11:53:33 vfrolov * Added options --odsr, --ox, --ix and --idsr *************** *** 79,82 **** --- 82,87 ---- << " (" << ComParams().InDsrStr() << " by default), where <c> is" << endl << " " << ComParams::InDsrLst() << "." << endl + << " --ito=<t> - set read interval timeout to <t> (" << ComParams().IntervalTimeoutStr() << " by default)," << endl + << " where <t> is " << ComParams::IntervalTimeoutLst() << "." << endl << endl << " The value c[urrent] above means to use current COM port settings." << endl *************** *** 262,265 **** --- 267,276 ---- } } else + if ((pParam = GetParam(pArg, "ito=")) != NULL) { + if (!comParams.SetIntervalTimeout(pParam)) { + cerr << "Unknown read interval timeout value " << pParam << endl; + exit(1); + } + } else if ((pParam = GetParam(pArg, "route=")) != NULL) { defaultRouteData = FALSE; Index: comio.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/comio.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** comio.cpp 6 Feb 2007 11:53:33 -0000 1.4 --- comio.cpp 14 May 2007 12:06:37 -0000 1.5 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.5 2007/05/14 12:06:37 vfrolov + * Added read interval timeout option + * * Revision 1.4 2007/02/06 11:53:33 vfrolov * Added options --odsr, --ox, --ix and --idsr *************** *** 142,148 **** } ! timeouts.ReadTotalTimeoutMultiplier = MAXDWORD; ! timeouts.ReadTotalTimeoutConstant = MAXDWORD - 1; ! timeouts.ReadIntervalTimeout = MAXDWORD; timeouts.WriteTotalTimeoutMultiplier = 0; --- 145,157 ---- } ! if (comParams.IntervalTimeout() > 0) { ! timeouts.ReadTotalTimeoutMultiplier = 0; ! timeouts.ReadTotalTimeoutConstant = 0; ! timeouts.ReadIntervalTimeout = (DWORD)comParams.IntervalTimeout(); ! } else { ! timeouts.ReadTotalTimeoutMultiplier = MAXDWORD; ! timeouts.ReadTotalTimeoutConstant = MAXDWORD - 1; ! timeouts.ReadIntervalTimeout = MAXDWORD; ! } timeouts.WriteTotalTimeoutMultiplier = 0; *************** *** 166,169 **** --- 175,179 ---- << ", ix=" << ComParams::InXStr(dcb.fInX) << ", idsr=" << ComParams::InDsrStr(dcb.fDsrSensitivity) + << ", ito=" << comParams.IntervalTimeoutStr() << ") - OK" << endl; return handle; |