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