28 if (Instance !=
NULL) {
29 if (Instance->TlsConn !=
NULL) {
58 if (TlsInstance ==
NULL) {
59 return EFI_OUT_OF_RESOURCES;
62 TlsInstance->Signature = TLS_INSTANCE_SIGNATURE;
64 TlsInstance->InDestroy =
FALSE;
65 TlsInstance->Service = Service;
67 CopyMem (&TlsInstance->Tls, &mTlsProtocol, sizeof (TlsInstance->Tls));
68 CopyMem (&TlsInstance->TlsConfig, &mTlsConfigurationProtocol, sizeof (TlsInstance->TlsConfig));
72 *Instance = TlsInstance;
88 if (Service !=
NULL) {
89 if (Service->TlsCtx !=
NULL) {
115 ASSERT (Service !=
NULL);
123 if (TlsService ==
NULL) {
124 return EFI_OUT_OF_RESOURCES;
130 TlsService->Signature = TLS_SERVICE_SIGNATURE;
131 CopyMem (&TlsService->ServiceBinding, &mTlsServiceBinding, sizeof (TlsService->ServiceBinding));
132 TlsService->TlsChildrenNum = 0;
134 TlsService->ImageHandle = Image;
136 *Service = TlsService;
164 ServiceBinding =
NULL;
170 Status =
gBS->LocateHandleBuffer (
172 &gEfiTlsServiceBindingProtocolGuid,
177 if (EFI_ERROR (Status)) {
181 for (Index = 0; Index < HandleNum; Index++) {
185 Status =
gBS->OpenProtocol (
187 &gEfiTlsServiceBindingProtocolGuid,
188 (VOID **)&ServiceBinding,
191 EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL
193 if (EFI_ERROR (Status)) {
197 TlsService = TLS_SERVICE_FROM_THIS (ServiceBinding);
202 Status =
gBS->UninstallMultipleProtocolInterfaces (
204 &gEfiTlsServiceBindingProtocolGuid,
208 if (EFI_ERROR (Status)) {
215 if (HandleBuffer !=
NULL) {
248 if (EFI_ERROR (Status)) {
252 ASSERT (TlsService !=
NULL);
264 if (TlsService->TlsCtx ==
NULL) {
272 Status =
gBS->InstallMultipleProtocolInterfaces (
274 &gEfiTlsServiceBindingProtocolGuid,
275 &TlsService->ServiceBinding,
278 if (EFI_ERROR (Status)) {
279 goto ON_CLEAN_SERVICE;
321 if ((This ==
NULL) || (ChildHandle ==
NULL)) {
322 return EFI_INVALID_PARAMETER;
325 TlsService = TLS_SERVICE_FROM_THIS (This);
328 if (EFI_ERROR (Status)) {
332 ASSERT (TlsInstance !=
NULL);
337 TlsInstance->TlsConn =
TlsNew (TlsService->TlsCtx);
338 if (TlsInstance->TlsConn ==
NULL) {
339 Status = EFI_ABORTED;
347 if (EFI_ERROR (Status)) {
354 Status =
gBS->InstallMultipleProtocolInterfaces (
356 &gEfiTlsProtocolGuid,
358 &gEfiTlsConfigurationProtocolGuid,
359 &TlsInstance->TlsConfig,
362 if (EFI_ERROR (Status)) {
366 TlsInstance->ChildHandle = *ChildHandle;
371 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
373 InsertTailList (&TlsService->TlsChildrenList, &TlsInstance->Link);
374 TlsService->TlsChildrenNum++;
376 gBS->RestoreTPL (OldTpl);
418 if ((This ==
NULL) || (ChildHandle ==
NULL)) {
419 return EFI_INVALID_PARAMETER;
422 TlsService = TLS_SERVICE_FROM_THIS (This);
427 Status =
gBS->OpenProtocol (
429 &gEfiTlsProtocolGuid,
431 TlsService->ImageHandle,
433 EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL
435 if (EFI_ERROR (Status)) {
442 Status =
gBS->OpenProtocol (
444 &gEfiTlsConfigurationProtocolGuid,
446 TlsService->ImageHandle,
448 EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL
450 if (EFI_ERROR (Status)) {
454 TlsInstance = TLS_INSTANCE_FROM_PROTOCOL (Tls);
456 if (TlsInstance->Service != TlsService) {
457 return EFI_INVALID_PARAMETER;
460 if (TlsInstance->InDestroy) {
464 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
466 TlsInstance->InDestroy =
TRUE;
471 Status =
gBS->UninstallMultipleProtocolInterfaces (
473 &gEfiTlsProtocolGuid,
475 &gEfiTlsConfigurationProtocolGuid,
479 if (EFI_ERROR (Status)) {
484 TlsService->TlsChildrenNum--;
486 gBS->RestoreTPL (OldTpl);
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define TLS10_PROTOCOL_VERSION_MAJOR
@ EfiTlsSessionNotStarted
VOID TlsCleanService(IN TLS_SERVICE *Service)
EFI_STATUS EFIAPI TlsServiceBindingCreateChild(IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_HANDLE *ChildHandle)
EFI_STATUS EFIAPI TlsServiceBindingDestroyChild(IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_HANDLE ChildHandle)
VOID TlsCleanInstance(IN TLS_INSTANCE *Instance)
EFI_STATUS TlsCreateService(IN EFI_HANDLE Image, OUT TLS_SERVICE **Service)
EFI_STATUS TlsCreateInstance(IN TLS_SERVICE *Service, OUT TLS_INSTANCE **Instance)
EFI_STATUS EFIAPI TlsUnload(IN EFI_HANDLE ImageHandle)
EFI_STATUS EFIAPI TlsDriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID *EFIAPI TlsCtxNew(IN UINT8 MajorVer, IN UINT8 MinorVer)
VOID EFIAPI TlsFree(IN VOID *Tls)
VOID *EFIAPI TlsNew(IN VOID *TlsCtx)
EFI_STATUS EFIAPI TlsSetConnectionEnd(IN VOID *Tls, IN BOOLEAN IsServer)
VOID EFIAPI TlsCtxFree(IN VOID *TlsCtx)
BOOLEAN EFIAPI TlsInitialize(VOID)