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