TlsDriver.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /** @file
  2. Header file of the Driver Binding and Service Binding Protocol for TlsDxe driver.
  3. Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef __EFI_TLS_DRIVER_H__
  7. #define __EFI_TLS_DRIVER_H__
  8. #include <Uefi.h>
  9. //
  10. // Driver Protocols
  11. //
  12. #include <Protocol/ServiceBinding.h>
  13. //
  14. // Driver Version
  15. //
  16. #define TLS_VERSION 0x00000000
  17. #define TLS_SERVICE_SIGNATURE SIGNATURE_32 ('T', 'L', 'S', 'S')
  18. #define TLS_INSTANCE_SIGNATURE SIGNATURE_32 ('T', 'L', 'S', 'I')
  19. ///
  20. /// TLS Service Data
  21. ///
  22. typedef struct _TLS_SERVICE TLS_SERVICE;
  23. ///
  24. /// TLS Instance Data
  25. ///
  26. typedef struct _TLS_INSTANCE TLS_INSTANCE;
  27. struct _TLS_SERVICE {
  28. UINT32 Signature;
  29. EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
  30. UINT16 TlsChildrenNum;
  31. LIST_ENTRY TlsChildrenList;
  32. //
  33. // Handle to install TlsServiceBinding protocol.
  34. //
  35. EFI_HANDLE Handle;
  36. EFI_HANDLE ImageHandle;
  37. //
  38. // Main SSL Context object which is created by a server or client once per program
  39. // life-time and which holds mainly default values for the SSL object which are later
  40. // created for the connections.
  41. //
  42. VOID *TlsCtx;
  43. };
  44. struct _TLS_INSTANCE {
  45. UINT32 Signature;
  46. LIST_ENTRY Link;
  47. BOOLEAN InDestroy;
  48. TLS_SERVICE *Service;
  49. EFI_HANDLE ChildHandle;
  50. EFI_TLS_PROTOCOL Tls;
  51. EFI_TLS_CONFIGURATION_PROTOCOL TlsConfig;
  52. EFI_TLS_SESSION_STATE TlsSessionState;
  53. //
  54. // Main SSL Connection which is created by a server or a client
  55. // per established connection.
  56. //
  57. VOID *TlsConn;
  58. };
  59. #define TLS_SERVICE_FROM_THIS(a) \
  60. CR (a, TLS_SERVICE, ServiceBinding, TLS_SERVICE_SIGNATURE)
  61. #define TLS_INSTANCE_FROM_PROTOCOL(a) \
  62. CR (a, TLS_INSTANCE, Tls, TLS_INSTANCE_SIGNATURE)
  63. #define TLS_INSTANCE_FROM_CONFIGURATION(a) \
  64. CR (a, TLS_INSTANCE, TlsConfig, TLS_INSTANCE_SIGNATURE)
  65. /**
  66. Release all the resources used by the TLS instance.
  67. @param[in] Instance The TLS instance data.
  68. **/
  69. VOID
  70. TlsCleanInstance (
  71. IN TLS_INSTANCE *Instance
  72. );
  73. /**
  74. Create the TLS instance and initialize it.
  75. @param[in] Service The pointer to the TLS service.
  76. @param[out] Instance The pointer to the TLS instance.
  77. @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
  78. @retval EFI_SUCCESS The TLS instance is created.
  79. **/
  80. EFI_STATUS
  81. TlsCreateInstance (
  82. IN TLS_SERVICE *Service,
  83. OUT TLS_INSTANCE **Instance
  84. );
  85. /**
  86. Release all the resources used by the TLS service binding instance.
  87. @param[in] Service The TLS service data.
  88. **/
  89. VOID
  90. TlsCleanService (
  91. IN TLS_SERVICE *Service
  92. );
  93. /**
  94. Create then initialize a TLS service.
  95. @param[in] Image ImageHandle of the TLS driver
  96. @param[out] Service The service for TLS driver
  97. @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to create the service.
  98. @retval EFI_SUCCESS The service is created for the driver.
  99. **/
  100. EFI_STATUS
  101. TlsCreateService (
  102. IN EFI_HANDLE Image,
  103. OUT TLS_SERVICE **Service
  104. );
  105. /**
  106. Unloads an image.
  107. @param[in] ImageHandle Handle that identifies the image to be unloaded.
  108. @retval EFI_SUCCESS The image has been unloaded.
  109. @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
  110. **/
  111. EFI_STATUS
  112. EFIAPI
  113. TlsUnload (
  114. IN EFI_HANDLE ImageHandle
  115. );
  116. /**
  117. This is the declaration of an EFI image entry point. This entry point is
  118. the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
  119. both device drivers and bus drivers.
  120. @param ImageHandle The firmware allocated handle for the UEFI image.
  121. @param SystemTable A pointer to the EFI System Table.
  122. @retval EFI_SUCCESS The operation completed successfully.
  123. @retval Others An unexpected error occurred.
  124. **/
  125. EFI_STATUS
  126. EFIAPI
  127. TlsDriverEntryPoint (
  128. IN EFI_HANDLE ImageHandle,
  129. IN EFI_SYSTEM_TABLE *SystemTable
  130. );
  131. /**
  132. Creates a child handle and installs a protocol.
  133. The CreateChild() function installs a protocol on ChildHandle.
  134. If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
  135. If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
  136. @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
  137. @param[in] ChildHandle Pointer to the handle of the child to create. If it is NULL,
  138. then a new handle is created. If it is a pointer to an existing UEFI handle,
  139. then the protocol is added to the existing UEFI handle.
  140. @retval EFI_SUCCESS The protocol was added to ChildHandle.
  141. @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
  142. @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
  143. the child.
  144. @retval other The child handle was not created.
  145. **/
  146. EFI_STATUS
  147. EFIAPI
  148. TlsServiceBindingCreateChild (
  149. IN EFI_SERVICE_BINDING_PROTOCOL *This,
  150. IN EFI_HANDLE *ChildHandle
  151. );
  152. /**
  153. Destroys a child handle with a protocol installed on it.
  154. The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
  155. that was installed by CreateChild() from ChildHandle. If the removed protocol is the
  156. last protocol on ChildHandle, then ChildHandle is destroyed.
  157. @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
  158. @param ChildHandle Handle of the child to destroy.
  159. @retval EFI_SUCCESS The protocol was removed from ChildHandle.
  160. @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
  161. @retval EFI_INVALID_PARAMETER Child handle is NULL.
  162. @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
  163. because its services are being used.
  164. @retval other The child handle was not destroyed.
  165. **/
  166. EFI_STATUS
  167. EFIAPI
  168. TlsServiceBindingDestroyChild (
  169. IN EFI_SERVICE_BINDING_PROTOCOL *This,
  170. IN EFI_HANDLE ChildHandle
  171. );
  172. #endif