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