TcpDriver.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /** @file
  2. The prototype of driver binding and service binding protocol for TCP driver.
  3. Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _TCP_DRIVER_H_
  7. #define _TCP_DRIVER_H_
  8. #define TCP_DRIVER_SIGNATURE SIGNATURE_32 ('T', 'C', 'P', 'D')
  9. #define TCP_PORT_KNOWN 1024
  10. #define TCP_PORT_USER_RESERVED 65535
  11. typedef struct _TCP_HEARTBEAT_TIMER {
  12. EFI_EVENT TimerEvent;
  13. INTN RefCnt;
  14. } TCP_HEARTBEAT_TIMER;
  15. typedef struct _TCP_SERVICE_DATA {
  16. UINT32 Signature;
  17. EFI_HANDLE ControllerHandle;
  18. EFI_HANDLE DriverBindingHandle;
  19. UINT8 IpVersion;
  20. IP_IO *IpIo;
  21. EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
  22. LIST_ENTRY SocketList;
  23. } TCP_SERVICE_DATA;
  24. typedef struct _TCP_PROTO_DATA {
  25. TCP_SERVICE_DATA *TcpService;
  26. TCP_CB *TcpPcb;
  27. } TCP_PROTO_DATA;
  28. #define TCP_SERVICE_FROM_THIS(a) \
  29. CR ( \
  30. (a), \
  31. TCP_SERVICE_DATA, \
  32. ServiceBinding, \
  33. TCP_DRIVER_SIGNATURE \
  34. )
  35. //
  36. // Function prototype for the driver's entry point
  37. //
  38. /**
  39. The entry point for Tcp driver, used to install Tcp driver on the ImageHandle.
  40. @param[in] ImageHandle The firmware allocated handle for this driver image.
  41. @param[in] SystemTable Pointer to the EFI system table.
  42. @retval EFI_SUCCESS The driver loaded.
  43. @retval other The driver did not load.
  44. **/
  45. EFI_STATUS
  46. EFIAPI
  47. TcpDriverEntryPoint (
  48. IN EFI_HANDLE ImageHandle,
  49. IN EFI_SYSTEM_TABLE *SystemTable
  50. );
  51. //
  52. // Function prototypes for the Driver Binding Protocol
  53. //
  54. /**
  55. Test to see if this driver supports ControllerHandle.
  56. @param[in] This Protocol instance pointer.
  57. @param[in] ControllerHandle Handle of the device to test.
  58. @param[in] RemainingDevicePath Optional parameter use to pick a specific
  59. child device to start.
  60. @retval EFI_SUCCESS This driver supports this device.
  61. @retval EFI_ALREADY_STARTED This driver is already running on this device.
  62. @retval other This driver does not support this device.
  63. **/
  64. EFI_STATUS
  65. EFIAPI
  66. Tcp4DriverBindingSupported (
  67. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  68. IN EFI_HANDLE ControllerHandle,
  69. IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
  70. );
  71. /**
  72. Start this driver on ControllerHandle.
  73. @param[in] This Protocol instance pointer.
  74. @param[in] ControllerHandle Handle of device to bind driver to.
  75. @param[in] RemainingDevicePath Optional parameter use to pick a specific child
  76. device to start.
  77. @retval EFI_SUCCESS The driver was added to ControllerHandle.
  78. @retval EFI_OUT_OF_RESOURCES There are not enough resources to start the
  79. driver.
  80. @retval other The driver cannot be added to ControllerHandle.
  81. **/
  82. EFI_STATUS
  83. EFIAPI
  84. Tcp4DriverBindingStart (
  85. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  86. IN EFI_HANDLE ControllerHandle,
  87. IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
  88. );
  89. /**
  90. Stop this driver on ControllerHandle.
  91. @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
  92. @param[in] ControllerHandle A handle to the device being stopped. The handle must
  93. support a bus specific I/O protocol for the driver
  94. to use to stop the device.
  95. @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
  96. @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
  97. if NumberOfChildren is 0.
  98. @retval EFI_SUCCESS The device was stopped.
  99. @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
  100. **/
  101. EFI_STATUS
  102. EFIAPI
  103. Tcp4DriverBindingStop (
  104. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  105. IN EFI_HANDLE ControllerHandle,
  106. IN UINTN NumberOfChildren,
  107. IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
  108. );
  109. /**
  110. Test to see if this driver supports ControllerHandle.
  111. @param[in] This Protocol instance pointer.
  112. @param[in] ControllerHandle Handle of the device to test.
  113. @param[in] RemainingDevicePath Optional parameter use to pick a specific
  114. child device to start.
  115. @retval EFI_SUCCESS This driver supports this device.
  116. @retval EFI_ALREADY_STARTED This driver is already running on this device.
  117. @retval other This driver does not support this device.
  118. **/
  119. EFI_STATUS
  120. EFIAPI
  121. Tcp6DriverBindingSupported (
  122. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  123. IN EFI_HANDLE ControllerHandle,
  124. IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
  125. );
  126. /**
  127. Start this driver on ControllerHandle.
  128. @param[in] This Protocol instance pointer.
  129. @param[in] ControllerHandle Handle of device to bind driver to.
  130. @param[in] RemainingDevicePath Optional parameter use to pick a specific child
  131. device to start.
  132. @retval EFI_SUCCESS The driver was added to ControllerHandle.
  133. @retval EFI_OUT_OF_RESOURCES There are not enough resources to start the
  134. driver.
  135. @retval other The driver cannot be added to ControllerHandle.
  136. **/
  137. EFI_STATUS
  138. EFIAPI
  139. Tcp6DriverBindingStart (
  140. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  141. IN EFI_HANDLE ControllerHandle,
  142. IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
  143. );
  144. /**
  145. Stop this driver on ControllerHandle.
  146. @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
  147. @param[in] ControllerHandle A handle to the device being stopped. The handle must
  148. support a bus specific I/O protocol for the driver
  149. to use to stop the device.
  150. @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
  151. @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
  152. if NumberOfChildren is 0.
  153. @retval EFI_SUCCESS The device was stopped.
  154. @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
  155. **/
  156. EFI_STATUS
  157. EFIAPI
  158. Tcp6DriverBindingStop (
  159. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  160. IN EFI_HANDLE ControllerHandle,
  161. IN UINTN NumberOfChildren,
  162. IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
  163. );
  164. /**
  165. The Callback function called after the TCP socket is created.
  166. @param[in] This Pointer to the socket just created.
  167. @param[in] Context The context of the socket.
  168. @retval EFI_SUCCESS This protocol is installed successfully.
  169. @retval other An error occurred.
  170. **/
  171. EFI_STATUS
  172. TcpCreateSocketCallback (
  173. IN SOCKET *This,
  174. IN VOID *Context
  175. );
  176. /**
  177. The callback function called before the TCP socket is to be destroyed.
  178. @param[in] This The TCP socket to be destroyed.
  179. @param[in] Context The context of the socket.
  180. **/
  181. VOID
  182. TcpDestroySocketCallback (
  183. IN SOCKET *This,
  184. IN VOID *Context
  185. );
  186. //
  187. // Function prototypes for the ServiceBinding Protocol
  188. //
  189. /**
  190. Creates a child handle with a set of TCP services.
  191. The CreateChild() function installs a protocol on ChildHandle.
  192. If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
  193. If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
  194. @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
  195. @param[in, out] ChildHandle Pointer to the handle of the child to create.
  196. If it is NULL, then a new handle is created.
  197. If it is a pointer to an existing UEFI handle,
  198. then the protocol is added to the existing UEFI handle.
  199. @retval EFI_SUCCESS The protocol was added to ChildHandle.
  200. @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
  201. @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
  202. the child.
  203. @retval other The child handle was not created.
  204. **/
  205. EFI_STATUS
  206. EFIAPI
  207. TcpServiceBindingCreateChild (
  208. IN EFI_SERVICE_BINDING_PROTOCOL *This,
  209. IN OUT EFI_HANDLE *ChildHandle
  210. );
  211. /**
  212. Destroys a child handle with a set of TCP services.
  213. The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
  214. that was installed by CreateChild() from ChildHandle. If the removed protocol is the
  215. last protocol on ChildHandle, then ChildHandle is destroyed.
  216. @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
  217. @param ChildHandle Handle of the child to destroy.
  218. @retval EFI_SUCCESS The protocol was removed from ChildHandle.
  219. @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
  220. @retval EFI_INVALID_PARAMETER The child handle is NULL.
  221. @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
  222. because its services are being used.
  223. @retval other The child handle was not destroyed.
  224. **/
  225. EFI_STATUS
  226. EFIAPI
  227. TcpServiceBindingDestroyChild (
  228. IN EFI_SERVICE_BINDING_PROTOCOL *This,
  229. IN EFI_HANDLE ChildHandle
  230. );
  231. #endif