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.

232 lines
7.2 KiB

  1. //----- utils.h
  2. VOID SyncUp(IN PKINTERRUPT IntObj,
  3. IN PKSPIN_LOCK SpinLock,
  4. IN PKSYNCHRONIZE_ROUTINE SyncProc,
  5. IN PVOID Context);
  6. VOID
  7. SerialKillAllReadsOrWrites(
  8. IN PDEVICE_OBJECT DeviceObject,
  9. IN PLIST_ENTRY QueueToClean,
  10. IN PIRP *CurrentOpIrp
  11. );
  12. VOID
  13. SerialGetNextIrp(
  14. IN PIRP *CurrentOpIrp,
  15. IN PLIST_ENTRY QueueToProcess,
  16. OUT PIRP *NextIrp,
  17. IN BOOLEAN CompleteCurrent,
  18. IN PSERIAL_DEVICE_EXTENSION extension
  19. );
  20. VOID
  21. SerialTryToCompleteCurrent(
  22. IN PSERIAL_DEVICE_EXTENSION Extension,
  23. IN PKSYNCHRONIZE_ROUTINE SynchRoutine OPTIONAL,
  24. IN KIRQL IrqlForRelease,
  25. IN NTSTATUS StatusToUse,
  26. IN PIRP *CurrentOpIrp,
  27. IN PLIST_ENTRY QueueToProcess OPTIONAL,
  28. IN PKTIMER IntervalTimer OPTIONAL,
  29. IN PKTIMER TotalTimer OPTIONAL,
  30. IN PSERIAL_START_ROUTINE Starter OPTIONAL,
  31. IN PSERIAL_GET_NEXT_ROUTINE GetNextIrp OPTIONAL,
  32. IN LONG RefType
  33. );
  34. VOID
  35. SerialRundownIrpRefs(
  36. IN PIRP *CurrentOpIrp,
  37. IN PKTIMER IntervalTimer OPTIONAL,
  38. IN PKTIMER TotalTimer OPTIONAL
  39. );
  40. NTSTATUS
  41. SerialStartOrQueue(
  42. IN PSERIAL_DEVICE_EXTENSION Extension,
  43. IN PIRP Irp,
  44. IN PLIST_ENTRY QueueToExamine,
  45. IN PIRP *CurrentOpIrp,
  46. IN PSERIAL_START_ROUTINE Starter
  47. );
  48. VOID
  49. SerialCancelQueued(
  50. PDEVICE_OBJECT DeviceObject,
  51. PIRP Irp
  52. );
  53. NTSTATUS
  54. SerialCompleteIfError(
  55. PDEVICE_OBJECT DeviceObject,
  56. PIRP Irp
  57. );
  58. //--- error.h
  59. VOID
  60. SerialCommError(
  61. IN PKDPC Dpc,
  62. IN PVOID DeferredContext,
  63. IN PVOID SystemContext1,
  64. IN PVOID SystemContext2
  65. );
  66. //--- flush.h
  67. NTSTATUS SerialFlush(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
  68. NTSTATUS SerialStartFlush(IN PSERIAL_DEVICE_EXTENSION Extension);
  69. //---- purge.h
  70. NTSTATUS SerialStartPurge(IN PSERIAL_DEVICE_EXTENSION Extension);
  71. //---- qsfile.h
  72. NTSTATUS
  73. SerialQueryInformationFile(
  74. IN PDEVICE_OBJECT DeviceObject,
  75. IN PIRP Irp
  76. );
  77. NTSTATUS
  78. SerialSetInformationFile(
  79. IN PDEVICE_OBJECT DeviceObject,
  80. IN PIRP Irp
  81. );
  82. //---- routines to deal with unicode bloat
  83. //---- typedefs to convienently allocate uniccode struct and buffer
  84. typedef struct {
  85. UNICODE_STRING ustr;
  86. WCHAR wstr[240];
  87. } USTR_240;
  88. typedef struct {
  89. UNICODE_STRING ustr;
  90. WCHAR wstr[160];
  91. } USTR_160;
  92. typedef struct {
  93. UNICODE_STRING ustr;
  94. WCHAR wstr[80];
  95. } USTR_80;
  96. typedef struct {
  97. UNICODE_STRING ustr;
  98. WCHAR wstr[40];
  99. } USTR_40;
  100. OUT PCHAR UToC1(IN PUNICODE_STRING ustr);
  101. OUT PCHAR UToCStr(
  102. IN OUT PCHAR Buffer,
  103. IN PUNICODE_STRING ustr,
  104. IN int BufferSize);
  105. OUT PUNICODE_STRING CToU1(IN const char *c_str);
  106. OUT PUNICODE_STRING CToU2(IN const char *c_str);
  107. OUT PUNICODE_STRING CToUStr(
  108. OUT PUNICODE_STRING Buffer,
  109. IN const char * c_str,
  110. IN int BufferSize);
  111. VOID WStrToCStr(OUT PCHAR c_str, IN PWCHAR w_str, int max_size);
  112. int get_reg_value(
  113. IN HANDLE keyHandle,
  114. OUT PVOID outptr,
  115. IN PCHAR val_name,
  116. int max_size);
  117. void OurTrace(char *leadstr, char *newdata);
  118. void TraceDump(PSERIAL_DEVICE_EXTENSION ext, char *newdata, int sCount, int style);
  119. void TracePut(char *newdata, int sCount);
  120. int __cdecl our_vsnprintf(char *buffer, size_t Limit, const char *format, va_list Next);
  121. void __cdecl TTprintf(char *leadstr, const char *format, ...);
  122. void __cdecl Tprintf(const char *format, ...);
  123. void __cdecl Sprintf(char *dest, const char *format, ...);
  124. void __cdecl Dprintf(const char *format, ...);
  125. void __cdecl Eprintf(const char *format, ...);
  126. void MyAssertMessage(char *filename, int line);
  127. void EvLog(char *mess);
  128. char *our_ultoa(unsigned long u, char* s, int radix);
  129. char *our_ltoa(long value, char* s, int radix);
  130. int listfind(char *str, char **list);
  131. int our_isdigit(char c);
  132. int getnumbers(char *str, long *nums, int max_nums, int hex_flag);
  133. int getstr(char *deststr, char *textptr, int *countptr, int max_size);
  134. int my_lstricmp(char *str1, char *str2);
  135. int getint(char *textptr, int *countptr);
  136. int getnum(char *str, int *index);
  137. int my_sub_lstricmp(const char *name, const char *codeline);
  138. unsigned int gethint(char *bufptr, int *countptr);
  139. int my_toupper(int c);
  140. void hextoa(char *str, unsigned int v, int places);
  141. void our_free(PVOID ptr, char *str);
  142. PVOID our_locked_alloc(ULONG size, char *str);
  143. void our_assert(int id, int line);
  144. int mac_cmp(UCHAR *mac1, UCHAR *mac2);
  145. void time_stall(int tenth_secs);
  146. void ms_time_stall(int millisecs);
  147. WCHAR *str_to_wstr_dup(char *str, int alloc_space);
  148. int BoardExtToNumber(PSERIAL_DEVICE_EXTENSION board_ext);
  149. int NumDevices(void);
  150. int NumPorts(PSERIAL_DEVICE_EXTENSION board_ext);
  151. int PortExtToIndex(PSERIAL_DEVICE_EXTENSION port_ext,
  152. int driver_flag);
  153. int is_board_in_use(PSERIAL_DEVICE_EXTENSION board_ext);
  154. PSERIAL_DEVICE_EXTENSION find_ext_by_name(char *name, int *dev_num);
  155. PSERIAL_DEVICE_EXTENSION find_ext_by_index(int dev_num, int port_num);
  156. int our_open_key(OUT PHANDLE phandle,
  157. IN OPTIONAL HANDLE relative_key_handle,
  158. IN char *regkeyname,
  159. IN ULONG attribs);
  160. int our_enum_key(IN HANDLE handle,
  161. IN int index,
  162. IN CHAR *buffer,
  163. IN ULONG max_buffer_size,
  164. OUT PCHAR *retdataptr);
  165. int our_query_value(IN HANDLE Handle,
  166. IN char *key_name,
  167. IN CHAR *buffer,
  168. IN ULONG max_buffer_size,
  169. OUT PULONG type,
  170. OUT PCHAR *retdataptr);
  171. int our_enum_value(IN HANDLE handle,
  172. IN int index,
  173. IN CHAR *buffer,
  174. IN ULONG max_buffer_size,
  175. OUT PULONG type,
  176. OUT PCHAR *retdataptr,
  177. OUT PCHAR sz_retname);
  178. int our_set_value(IN HANDLE Handle,
  179. IN char *key_name,
  180. IN PVOID pValue,
  181. IN ULONG value_size,
  182. IN ULONG value_type);
  183. int our_open_device_reg(OUT HANDLE *pHandle,
  184. IN PSERIAL_DEVICE_EXTENSION dev_ext,
  185. IN ULONG RegOpenRights);
  186. int our_open_driver_reg(OUT HANDLE *pHandle,
  187. IN ULONG RegOpenRights);
  188. #define our_close_key(handle) \
  189. { if (handle) {ZwClose(handle); handle = NULL;} }
  190. void ModemReset(PSERIAL_DEVICE_EXTENSION ext, int on);
  191. void ModemSpeakerEnable(PSERIAL_DEVICE_EXTENSION ext);
  192. void ModemWriteROW(PSERIAL_DEVICE_EXTENSION ext, USHORT CountryCode);
  193. void ModemWrite(PSERIAL_DEVICE_EXTENSION ext,char *string,int length);
  194. void ModemWriteDelay(PSERIAL_DEVICE_EXTENSION ext,char *string,int length);
  195. void ModemIOReady(PSERIAL_DEVICE_EXTENSION ext,int speed);
  196. void ModemUnReady(PSERIAL_DEVICE_EXTENSION ext);
  197. int ModemRead(PSERIAL_DEVICE_EXTENSION ext,char *s0,int len0,int poll_retries);
  198. int ModemReadChoice(PSERIAL_DEVICE_EXTENSION ext,char *s0,int len0,char *s1,int len1,int poll_retries);
  199. int TxFIFOReady(PSERIAL_DEVICE_EXTENSION ext);
  200. int TxFIFOStatus(PSERIAL_DEVICE_EXTENSION ext);
  201. int RxFIFOReady(PSERIAL_DEVICE_EXTENSION ext);