1 /** @file
2   UEFI Service Binding Protocol is defined in UEFI specification.
3 
4   The file defines the generic Service Binding Protocol functions.
5   It provides services that are required to create and destroy child
6   handles that support a given set of protocols.
7 
8   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
9   This program and the accompanying materials
10   are licensed and made available under the terms and conditions of the BSD License
11   which accompanies this distribution.  The full text of the license may be found at
12   http://opensource.org/licenses/bsd-license.php
13 
14   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 
17 **/
18 
19 #ifndef __EFI_SERVICE_BINDING_H__
20 #define __EFI_SERVICE_BINDING_H__
21 
22 ///
23 /// Forward reference for pure ANSI compatibility
24 ///
25 typedef struct _EFI_SERVICE_BINDING_PROTOCOL EFI_SERVICE_BINDING_PROTOCOL;
26 
27 /**
28   Creates a child handle and installs a protocol.
29 
30   The CreateChild() function installs a protocol on ChildHandle.
31   If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
32   If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
33 
34   @param  This        Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
35   @param  ChildHandle Pointer to the handle of the child to create. If it is NULL,
36                       then a new handle is created. If it is a pointer to an existing UEFI handle,
37                       then the protocol is added to the existing UEFI handle.
38 
39   @retval EFI_SUCCES            The protocol was added to ChildHandle.
40   @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
41   @retval EFI_OUT_OF_RESOURCES  There are not enough resources available to create
42                                 the child
43   @retval other                 The child handle was not created
44 
45 **/
46 typedef
47 EFI_STATUS
48 (EFIAPI *EFI_SERVICE_BINDING_CREATE_CHILD)(
49   IN     EFI_SERVICE_BINDING_PROTOCOL  *This,
50   IN OUT EFI_HANDLE                    *ChildHandle
51   );
52 
53 /**
54   Destroys a child handle with a protocol installed on it.
55 
56   The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
57   that was installed by CreateChild() from ChildHandle. If the removed protocol is the
58   last protocol on ChildHandle, then ChildHandle is destroyed.
59 
60   @param  This        Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
61   @param  ChildHandle Handle of the child to destroy
62 
63   @retval EFI_SUCCES            The protocol was removed from ChildHandle.
64   @retval EFI_UNSUPPORTED       ChildHandle does not support the protocol that is being removed.
65   @retval EFI_INVALID_PARAMETER Child handle is NULL.
66   @retval EFI_ACCESS_DENIED     The protocol could not be removed from the ChildHandle
67                                 because its services are being used.
68   @retval other                 The child handle was not destroyed
69 
70 **/
71 typedef
72 EFI_STATUS
73 (EFIAPI *EFI_SERVICE_BINDING_DESTROY_CHILD)(
74   IN EFI_SERVICE_BINDING_PROTOCOL          *This,
75   IN EFI_HANDLE                            ChildHandle
76   );
77 
78 ///
79 /// The EFI_SERVICE_BINDING_PROTOCOL provides member functions to create and destroy
80 /// child handles. A driver is responsible for adding protocols to the child handle
81 /// in CreateChild() and removing protocols in DestroyChild(). It is also required
82 /// that the CreateChild() function opens the parent protocol BY_CHILD_CONTROLLER
83 /// to establish the parent-child relationship, and closes the protocol in DestroyChild().
84 /// The pseudo code for CreateChild() and DestroyChild() is provided to specify the
85 /// required behavior, not to specify the required implementation. Each consumer of
86 /// a software protocol is responsible for calling CreateChild() when it requires the
87 /// protocol and calling DestroyChild() when it is finished with that protocol.
88 ///
89 struct _EFI_SERVICE_BINDING_PROTOCOL {
90   EFI_SERVICE_BINDING_CREATE_CHILD         CreateChild;
91   EFI_SERVICE_BINDING_DESTROY_CHILD        DestroyChild;
92 };
93 
94 #endif
95