Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
4.3 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1996-1998 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: comport.h
  6. * Content: Routines for COM port I/O
  7. * History:
  8. * Date By Reason
  9. * ==== == ======
  10. * 4/10/96 kipo created it
  11. * 4/15/96 kipo added msinternal
  12. * 5/22/96 kipo added support for RTSDTR flow control
  13. * 6/10/96 kipo added modem support
  14. * 6/22/96 kipo added support for EnumConnectionData().
  15. * 7/13/96 kipo added GetComPortAddress()
  16. * 8/15/96 kipo added CRC
  17. * 1/06/97 kipo updated for objects
  18. * 2/11/97 kipo pass player flags to GetAddress()
  19. * 2/18/97 kipo allow multiple instances of service provider
  20. * 4/08/97 kipo added support for separate modem and serial baud rates
  21. * 5/07/97 kipo added support for modem choice list
  22. * 5/23/97 kipo added support return status codes
  23. * 1/30/98 kipo added hTerminateThreadEvent to fix bugs #15220 & #15228
  24. ***************************************************************************/
  25. #ifndef __COMPORT_INCLUDED__
  26. #define __COMPORT_INCLUDED__
  27. #include <windows.h>
  28. #include <windowsx.h>
  29. #include <objbase.h>
  30. #include "dplay.h"
  31. #include "dplaysp.h"
  32. #include "bilink.h"
  33. typedef struct _DPCOMPORT DPCOMPORT;
  34. typedef DPCOMPORT *LPDPCOMPORT;
  35. typedef HRESULT (*LPDISPOSECOMPORT)(LPDPCOMPORT globals);
  36. typedef HRESULT (*LPCONNECTCOMPORT)(LPDPCOMPORT globals, BOOL bWaitForConnection, BOOL bReturnStatus);
  37. typedef HRESULT (*LPDISCONNECTCOMPORT)(LPDPCOMPORT globals);
  38. typedef HRESULT (*LPSETUPCOMPORT)(LPDPCOMPORT globals, HANDLE hCom);
  39. typedef HRESULT (*LPSHUTDOWNCOMPORT)(LPDPCOMPORT globals);
  40. typedef DWORD (*LPREADCOMPORT)(LPDPCOMPORT globals, LPVOID lpvBuffer, DWORD nMaxLength);
  41. typedef DWORD (*LPWRITECOMPORT)(LPDPCOMPORT globals, LPVOID lpvBuffer, DWORD dwLength, BOOLEAN bQueueOnReenter);
  42. typedef HRESULT (*LPGETCOMPORTBAUDRATE)(LPDPCOMPORT globals, LPDWORD lpdwBaudRate);
  43. typedef HANDLE (*LPGETCOMPORTHANDLE)(LPDPCOMPORT globals);
  44. typedef HRESULT (*LPGETCOMPORTADDRESS)(LPDPCOMPORT globals, DWORD dwPlayerFlags, LPVOID lpAddress, LPDWORD lpdwAddressSize);
  45. typedef HRESULT (*LPGETCOMPORTADDRESSCHOICES)(LPDPCOMPORT globals, LPVOID lpAddress, LPDWORD lpdwAddressSize);
  46. typedef void (*LPREADROUTINE)(LPDIRECTPLAYSP);
  47. // struct used for pending sends.
  48. typedef struct _PENDING_SEND {
  49. BILINK Bilink;
  50. DWORD dwBytesToWrite;
  51. UCHAR Data[0];
  52. } PENDING_SEND, *LPPENDING_SEND;
  53. struct _DPCOMPORT {
  54. // com port globals
  55. HANDLE hCom; // handle to comm object
  56. HANDLE hIOThread; // handle to read thread
  57. DWORD IOThreadID; // ID of read thread
  58. HANDLE hTerminateThreadEvent; // signalled to terminate the thread
  59. OVERLAPPED readOverlapped; // overlapped sections for asynch I/O
  60. OVERLAPPED writeOverlapped;
  61. LPREADROUTINE lpReadRoutine; // routine to call when read is ready
  62. LPDIRECTPLAYSP lpDPlay; // pointer to IDirectPlaySP needed to call back into DPlay
  63. // need to queue sends if we are in the middle of writing and drain queue when done writing.
  64. CRITICAL_SECTION csWriting; // locks pending list and bWriting
  65. BILINK PendingSends; // bilink list of pending sends
  66. BOOL bWriting; // guards re-entry to WriteComPort()
  67. // com port methods
  68. LPDISPOSECOMPORT Dispose; // dispose
  69. LPCONNECTCOMPORT Connect; // connect
  70. LPDISCONNECTCOMPORT Disconnect; // disconnect
  71. LPSETUPCOMPORT Setup; // setup com port
  72. LPSHUTDOWNCOMPORT Shutdown; // shutdown com port
  73. LPREADCOMPORT Read; // read
  74. LPWRITECOMPORT Write; // write
  75. LPGETCOMPORTBAUDRATE GetBaudRate; // get baud rate
  76. LPGETCOMPORTHANDLE GetHandle; // get com port handle
  77. LPGETCOMPORTADDRESS GetAddress; // get address
  78. LPGETCOMPORTADDRESSCHOICES GetAddressChoices; // get address choices
  79. };
  80. extern HRESULT NewComPort(DWORD dwObjectSize,
  81. LPDIRECTPLAYSP lpDPlay, LPREADROUTINE lpReadRoutine,
  82. LPDPCOMPORT *lplpObject);
  83. extern HRESULT NewModem(LPVOID lpConnectionData, DWORD dwConnectionDataSize,
  84. LPDIRECTPLAYSP lpDPlay, LPREADROUTINE lpReadRoutine,
  85. LPDPCOMPORT *storage);
  86. extern HRESULT NewSerial(LPVOID lpConnectionData, DWORD dwConnectionDataSize,
  87. LPDIRECTPLAYSP lpDPlay, LPREADROUTINE lpReadRoutine,
  88. LPDPCOMPORT *storage);
  89. extern DWORD GenerateCRC(LPVOID pBuffer, DWORD dwBufferSize);
  90. #endif