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.

329 lines
7.3 KiB

  1. /*++
  2. Copyright (c) 1991 - 2001 Microsoft Corporation
  3. Module Name:
  4. ### ### ##### ##### ##### ###### ## ##
  5. ## # ### ## ## ## ## ## ## ## ## ##
  6. ### ## ## ## ## ## ## ## ## ## ## ##
  7. ### ## ## ## ## ## ## ##### ## #######
  8. ### ####### ##### ## ## #### ## ## ##
  9. # ## ## ## ## ## ## ## ## ## ## ## ##
  10. ### ## ## ## ##### ## ## ## ## ## ##
  11. Abstract:
  12. This header contains all definitions necessary for
  13. server availability miniport drivers.
  14. Author:
  15. Wesley Witt (wesw) 1-Oct-2001
  16. Environment:
  17. Kernel mode only.
  18. Notes:
  19. --*/
  20. #include "saio.h"
  21. #ifndef _SAPORT_
  22. #define _SAPORT_
  23. #ifdef _SADDK_
  24. #define SAPORT_API DECLSPEC_IMPORT
  25. #else
  26. #define SAPORT_API
  27. #endif
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. //
  32. // Callback function prototypes
  33. //
  34. typedef NTSTATUS (*PSA_HW_INITIALIZE)(
  35. IN PDEVICE_OBJECT DeviceObject,
  36. IN PIRP Irp,
  37. IN PVOID DeviceExtension,
  38. IN PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialResources,
  39. IN ULONG PartialResourceCount
  40. );
  41. typedef NTSTATUS (*PSA_DEVICE_IOCTL)(
  42. IN PVOID DeviceExtension,
  43. IN PIRP Irp,
  44. IN PVOID FsContext,
  45. IN ULONG FunctionCode,
  46. IN PVOID InputBuffer,
  47. IN ULONG InputBufferLength,
  48. IN PVOID OutputBuffer,
  49. IN ULONG OutputBufferLength
  50. );
  51. typedef NTSTATUS (*PSA_IO_ROUTINE)(
  52. IN PVOID DeviceExtension,
  53. IN PIRP Irp,
  54. IN PVOID FsContext,
  55. IN LONGLONG StartingOffset,
  56. IN PVOID DataBuffer,
  57. IN ULONG DataBufferLength
  58. );
  59. typedef NTSTATUS (*PSA_CREATECLOSE)(
  60. IN PVOID DeviceExtension,
  61. IN PIRP Irp,
  62. IN PVOID FsContext
  63. );
  64. typedef VOID (*PSA_CANCEL)(
  65. IN PVOID DeviceExtension,
  66. IN PIRP Irp,
  67. IN BOOLEAN CurrentIo
  68. );
  69. //
  70. // Server availability port driver initialization data structure
  71. //
  72. typedef struct _SAPORT_INITIALIZATION_DATA {
  73. ULONG StructSize; // must be sizeof(STATUS_INVALID_PARAMETER)
  74. ULONG DeviceType; // must be one of the SA_DEVICE defines
  75. ULONG DeviceExtensionSize; //
  76. ULONG FileContextSize; //
  77. PSA_HW_INITIALIZE HwInitialize; // points you the device specific hardware init func
  78. PSA_CREATECLOSE CreateRoutine; //
  79. PSA_CREATECLOSE CloseRoutine; //
  80. PSA_DEVICE_IOCTL DeviceIoctl; //
  81. PSA_IO_ROUTINE Write; //
  82. PSA_IO_ROUTINE Read; //
  83. PSA_CANCEL CancelRoutine; //
  84. PKSERVICE_ROUTINE InterruptServiceRoutine; //
  85. PIO_DPC_ROUTINE IsrForDpcRoutine; //
  86. } SAPORT_INITIALIZATION_DATA, *PSAPORT_INITIALIZATION_DATA;
  87. //
  88. // Debug Helpers
  89. //
  90. #define SAPORT_DEBUG_ERROR_LEVEL 0x00000001
  91. #define SAPORT_DEBUG_WARNING_LEVEL 0x00000002
  92. #define SAPORT_DEBUG_TRACE_LEVEL 0x00000004
  93. #define SAPORT_DEBUG_INFO_LEVEL 0x00000008
  94. #if DBG
  95. #define DebugPrint(_X_) SaPortDebugPrint _X_
  96. #else
  97. #define DebugPrint(_X_)
  98. #endif
  99. #define REPORT_ERROR(_dt_,_msg_,_status_) \
  100. DebugPrint(( _dt_, SAPORT_DEBUG_ERROR_LEVEL, "%s [0x%08x]: %s @ %d\n", _msg_, _status_, __FILE__, __LINE__ ))
  101. #define KeAcquireMutex(_mutex_) KeWaitForMutexObject(_mutex_,Executive,KernelMode,TRUE,NULL)
  102. //
  103. // Server availability functions exported by SAPORT.SYS
  104. //
  105. SAPORT_API
  106. NTSTATUS
  107. SaPortInitialize(
  108. IN PDRIVER_OBJECT DriverObject,
  109. IN PUNICODE_STRING RegistryPath,
  110. IN PSAPORT_INITIALIZATION_DATA SaPortInitData
  111. );
  112. SAPORT_API
  113. PVOID
  114. SaPortAllocatePool(
  115. IN PVOID MiniPortDeviceExtension,
  116. IN SIZE_T NumberOfBytes
  117. );
  118. SAPORT_API
  119. VOID
  120. SaPortFreePool(
  121. IN PVOID DeviceExtension,
  122. IN PVOID P
  123. );
  124. SAPORT_API
  125. PVOID
  126. SaPortGetVirtualAddress(
  127. IN PVOID MiniPortDeviceExtension,
  128. IN PHYSICAL_ADDRESS PhysicalAddress,
  129. IN ULONG Length
  130. );
  131. SAPORT_API
  132. VOID
  133. SaPortRequestDpc(
  134. IN PVOID MiniPortDeviceExtension,
  135. IN PVOID Context
  136. );
  137. SAPORT_API
  138. VOID
  139. SaPortCompleteRequest(
  140. IN PVOID MiniPortDeviceExtension,
  141. IN PIRP Irp,
  142. IN ULONG Information,
  143. IN NTSTATUS Status,
  144. IN BOOLEAN CompleteAll
  145. );
  146. VOID
  147. SaPortDebugPrint(
  148. ULONG DeviceType,
  149. ULONG DebugLevel,
  150. PSTR DebugMessage,
  151. ...
  152. );
  153. NTSTATUS
  154. SaPortGetRegistryValueInformation(
  155. IN PVOID MiniPortDeviceExtension,
  156. IN PWSTR ValueName,
  157. IN OUT PULONG RegistryType,
  158. IN OUT PULONG RegistryDataLength
  159. );
  160. NTSTATUS
  161. SaPortDeleteRegistryValue(
  162. IN PVOID MiniPortDeviceExtension,
  163. IN PWSTR ValueName
  164. );
  165. NTSTATUS
  166. SaPortReadNumericRegistryValue(
  167. IN PVOID MiniPortDeviceExtension,
  168. IN PWSTR ValueName,
  169. OUT PULONG RegistryValue
  170. );
  171. NTSTATUS
  172. SaPortReadUnicodeStringRegistryValue(
  173. IN PVOID MiniPortDeviceExtension,
  174. IN PWSTR ValueName,
  175. OUT PUNICODE_STRING RegistryValue
  176. );
  177. NTSTATUS
  178. SaPortReadBinaryRegistryValue(
  179. IN PVOID MiniPortDeviceExtension,
  180. IN PWSTR ValueName,
  181. OUT PVOID RegistryValue,
  182. IN OUT PULONG RegistryValueLength
  183. );
  184. NTSTATUS
  185. SaPortWriteUnicodeStringRegistryValue(
  186. IN PVOID MiniPortDeviceExtension,
  187. IN PWSTR ValueName,
  188. IN PUNICODE_STRING RegistryValue
  189. );
  190. NTSTATUS
  191. SaPortWriteBinaryRegistryValue(
  192. IN PVOID MiniPortDeviceExtension,
  193. IN PWSTR ValueName,
  194. IN PVOID RegistryValue,
  195. IN ULONG RegistryValueLength
  196. );
  197. NTSTATUS
  198. SaPortWriteNumericRegistryValue(
  199. IN PVOID MiniPortDeviceExtension,
  200. IN PWSTR ValueName,
  201. IN ULONG RegistryValue
  202. );
  203. ULONG
  204. SaPortGetOsVersion(
  205. VOID
  206. );
  207. BOOLEAN
  208. SaPortSynchronizeExecution (
  209. IN PVOID MiniPortDeviceExtension,
  210. IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine,
  211. IN PVOID SynchronizeContext
  212. );
  213. PVOID
  214. SaPortLockPagesForSystem(
  215. IN PVOID MiniPortDeviceExtension,
  216. IN PVOID UserBuffer,
  217. IN ULONG UserBufferLength,
  218. IN OUT PMDL *Mdl
  219. );
  220. VOID
  221. SaPortReleaseLockedPagesForSystem(
  222. IN PVOID MiniPortDeviceExtension,
  223. IN PMDL Mdl
  224. );
  225. NTSTATUS
  226. SaPortCopyUnicodeString(
  227. IN PVOID MiniPortDeviceExtension,
  228. PUNICODE_STRING DestinationString,
  229. PUNICODE_STRING SourceString
  230. );
  231. NTSTATUS
  232. SaPortCreateUnicodeString(
  233. IN PVOID MiniPortDeviceExtension,
  234. PUNICODE_STRING DestinationString,
  235. PWSTR SourceString
  236. );
  237. NTSTATUS
  238. SaPortCreateUnicodeStringCat(
  239. IN PVOID MiniPortDeviceExtension,
  240. PUNICODE_STRING DestinationString,
  241. PWSTR SourceString1,
  242. PWSTR SourceString2
  243. );
  244. VOID
  245. SaPortFreeUnicodeString(
  246. IN PVOID MiniPortDeviceExtension,
  247. PUNICODE_STRING SourceString
  248. );
  249. NTSTATUS
  250. SaPortCreateBasenamedEvent(
  251. IN PVOID MiniPortDeviceExtension,
  252. IN PWSTR EventNameString,
  253. IN OUT PKEVENT *Event,
  254. IN OUT PHANDLE EventHandle
  255. );
  256. NTSTATUS
  257. SaPortCreateThread(
  258. IN PVOID MiniPortDeviceExtension,
  259. IN PKSTART_ROUTINE StartRoutine,
  260. IN PVOID StartContext,
  261. IN OUT PVOID *ThreadObject
  262. );
  263. NTSTATUS
  264. SaPortShutdownSystem(
  265. IN BOOLEAN PowerOff
  266. );
  267. #ifdef __cplusplus
  268. }
  269. #endif
  270. #endif /* _SAPORT_ */