xref: /freebsd/sys/contrib/edk2/Include/Protocol/PciHotPlugRequest.h (revision f439973d6726c3be929c8fb3b1545b8b1744abc3)
1*f439973dSWarner Losh /** @file
2*f439973dSWarner Losh   Provides services to notify the PCI bus driver that some events have happened
3*f439973dSWarner Losh   in a hot-plug controller (such as a PC Card socket, or PHPC), and to ask the
4*f439973dSWarner Losh   PCI bus driver to create or destroy handles for PCI-like devices.
5*f439973dSWarner Losh 
6*f439973dSWarner Losh   A hot-plug capable PCI bus driver should produce the EFI PCI Hot Plug Request
7*f439973dSWarner Losh   protocol. When a PCI device or a PCI-like device (for example, 32-bit PC Card)
8*f439973dSWarner Losh   is installed after PCI bus does the enumeration, the PCI bus driver can be
9*f439973dSWarner Losh   notified through this protocol. For example, when a 32-bit PC Card is inserted
10*f439973dSWarner Losh   into the PC Card socket, the PC Card bus driver can call interface of this
11*f439973dSWarner Losh   protocol to notify PCI bus driver to allocate resource and create handles for
12*f439973dSWarner Losh   this PC Card.
13*f439973dSWarner Losh 
14*f439973dSWarner Losh   The EFI_PCI_HOTPLUG_REQUEST_PROTOCOL is installed by the PCI bus driver on a
15*f439973dSWarner Losh   separate handle when PCI bus driver starts up. There is only one instance in
16*f439973dSWarner Losh   the system.  Any driver that wants to use this protocol must locate it globally.
17*f439973dSWarner Losh   The EFI_PCI_HOTPLUG_REQUEST_PROTOCOL allows the driver of hot-plug controller,
18*f439973dSWarner Losh   for example, PC Card Bus driver, to notify PCI bus driver that an event has
19*f439973dSWarner Losh   happened in the hot-plug controller, and the PCI bus driver is requested to
20*f439973dSWarner Losh   create (add) or destroy (remove) handles for the specified PCI-like devices.
21*f439973dSWarner Losh   For example, when a 32-bit PC Card is inserted, this protocol interface will
22*f439973dSWarner Losh   be called with an add operation, and the PCI bus driver will enumerate and
23*f439973dSWarner Losh   start the devices inserted; when a 32-bit PC Card is removed, this protocol
24*f439973dSWarner Losh   interface will be called with a remove operation, and the PCI bus driver will
25*f439973dSWarner Losh   stop the devices and destroy their handles.  The existence of this protocol
26*f439973dSWarner Losh   represents the capability of the PCI bus driver. If this protocol exists in
27*f439973dSWarner Losh   system, it means PCI bus driver is hot-plug capable, thus together with the
28*f439973dSWarner Losh   effort of PC Card bus driver, hot-plug of PC Card can be supported. Otherwise,
29*f439973dSWarner Losh   the hot-plug capability is not provided.
30*f439973dSWarner Losh 
31*f439973dSWarner Losh   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
32*f439973dSWarner Losh   SPDX-License-Identifier: BSD-2-Clause-Patent
33*f439973dSWarner Losh 
34*f439973dSWarner Losh   @par Revision Reference:
35*f439973dSWarner Losh   This Protocol is defined in UEFI Platform Initialization Specification 1.2
36*f439973dSWarner Losh   Volume 5: Standards
37*f439973dSWarner Losh 
38*f439973dSWarner Losh **/
39*f439973dSWarner Losh 
40*f439973dSWarner Losh #ifndef __PCI_HOTPLUG_REQUEST_H_
41*f439973dSWarner Losh #define __PCI_HOTPLUG_REQUEST_H_
42*f439973dSWarner Losh 
43*f439973dSWarner Losh ///
44*f439973dSWarner Losh /// Global ID for EFI_PCI_HOTPLUG_REQUEST_PROTOCOL
45*f439973dSWarner Losh ///
46*f439973dSWarner Losh #define EFI_PCI_HOTPLUG_REQUEST_PROTOCOL_GUID \
47*f439973dSWarner Losh   { \
48*f439973dSWarner Losh     0x19cb87ab, 0x2cb9, 0x4665, {0x83, 0x60, 0xdd, 0xcf, 0x60, 0x54, 0xf7, 0x9d} \
49*f439973dSWarner Losh   }
50*f439973dSWarner Losh 
51*f439973dSWarner Losh ///
52*f439973dSWarner Losh /// Forward declaration for EFI_PCI_HOTPLUG_REQUEST_PROTOCOL
53*f439973dSWarner Losh ///
54*f439973dSWarner Losh typedef struct _EFI_PCI_HOTPLUG_REQUEST_PROTOCOL EFI_PCI_HOTPLUG_REQUEST_PROTOCOL;
55*f439973dSWarner Losh 
56*f439973dSWarner Losh ///
57*f439973dSWarner Losh /// Enumeration of PCI hot plug operations
58*f439973dSWarner Losh ///
59*f439973dSWarner Losh typedef enum {
60*f439973dSWarner Losh   ///
61*f439973dSWarner Losh   /// The PCI bus driver is requested to create handles for the specified devices.
62*f439973dSWarner Losh   /// An array of EFI_HANDLE is returned, with a NULL element marking the end of
63*f439973dSWarner Losh   /// the array.
64*f439973dSWarner Losh   ///
65*f439973dSWarner Losh   EfiPciHotPlugRequestAdd,
66*f439973dSWarner Losh 
67*f439973dSWarner Losh   ///
68*f439973dSWarner Losh   /// The PCI bus driver is requested to destroy handles for the specified devices.
69*f439973dSWarner Losh   ///
70*f439973dSWarner Losh   EfiPciHotplugRequestRemove
71*f439973dSWarner Losh } EFI_PCI_HOTPLUG_OPERATION;
72*f439973dSWarner Losh 
73*f439973dSWarner Losh /**
74*f439973dSWarner Losh   This function is used to notify PCI bus driver that some events happened in a
75*f439973dSWarner Losh   hot-plug controller, and the PCI bus driver is requested to start or stop
76*f439973dSWarner Losh   specified PCI-like devices.
77*f439973dSWarner Losh 
78*f439973dSWarner Losh   This function allows the PCI bus driver to be notified to act as requested when
79*f439973dSWarner Losh   a hot-plug event has happened on the hot-plug controller. Currently, the
80*f439973dSWarner Losh   operations include add operation and remove operation.  If it is a add operation,
81*f439973dSWarner Losh   the PCI bus driver will enumerate, allocate resources for devices behind the
82*f439973dSWarner Losh   hot-plug controller, and create handle for the device specified by RemainingDevicePath.
83*f439973dSWarner Losh   The RemainingDevicePath is an optional parameter. If it is not NULL, only the
84*f439973dSWarner Losh   specified device is started; if it is NULL, all devices behind the hot-plug
85*f439973dSWarner Losh   controller are started.  The newly created handles of PC Card functions are
86*f439973dSWarner Losh   returned in the ChildHandleBuffer, together with the number of child handle in
87*f439973dSWarner Losh   NumberOfChildren.  If it is a remove operation, when NumberOfChildren contains
88*f439973dSWarner Losh   a non-zero value, child handles specified in ChildHandleBuffer are stopped and
89*f439973dSWarner Losh   destroyed; otherwise, PCI bus driver is notified to stop managing the controller
90*f439973dSWarner Losh   handle.
91*f439973dSWarner Losh 
92*f439973dSWarner Losh     @param[in] This                    A pointer to the EFI_PCI_HOTPLUG_REQUEST_PROTOCOL
93*f439973dSWarner Losh                                        instance.
94*f439973dSWarner Losh     @param[in] Operation               The operation the PCI bus driver is requested
95*f439973dSWarner Losh                                        to make.
96*f439973dSWarner Losh     @param[in] Controller              The handle of the hot-plug controller.
97*f439973dSWarner Losh     @param[in] RemainingDevicePath     The remaining device path for the PCI-like
98*f439973dSWarner Losh                                        hot-plug device.  It only contains device
99*f439973dSWarner Losh                                        path nodes behind the hot-plug controller.
100*f439973dSWarner Losh                                        It is an optional parameter and only valid
101*f439973dSWarner Losh                                        when the Operation is a add operation. If
102*f439973dSWarner Losh                                        it is NULL, all devices behind the PC Card
103*f439973dSWarner Losh                                        socket are started.
104*f439973dSWarner Losh     @param[in,out] NumberOfChildren    The number of child handles. For an add
105*f439973dSWarner Losh                                        operation, it is an output parameter.  For
106*f439973dSWarner Losh                                        a remove operation, it's an input parameter.
107*f439973dSWarner Losh                                        When it contains a non-zero value, children
108*f439973dSWarner Losh                                        handles specified in ChildHandleBuffer are
109*f439973dSWarner Losh                                        destroyed.  Otherwise, PCI bus driver is
110*f439973dSWarner Losh                                        notified to stop managing the controller
111*f439973dSWarner Losh                                        handle.
112*f439973dSWarner Losh     @param[in,out] ChildHandleBuffer   The buffer which contains the child handles.
113*f439973dSWarner Losh                                        For an add operation, it is an output
114*f439973dSWarner Losh                                        parameter and contains all newly created
115*f439973dSWarner Losh                                        child handles.  For a remove operation, it
116*f439973dSWarner Losh                                        contains child handles to be destroyed when
117*f439973dSWarner Losh                                        NumberOfChildren contains a non-zero value.
118*f439973dSWarner Losh                                        It can be NULL when NumberOfChildren is 0.
119*f439973dSWarner Losh                                        It's the caller's responsibility to allocate
120*f439973dSWarner Losh                                        and free memory for this buffer.
121*f439973dSWarner Losh 
122*f439973dSWarner Losh   @retval EFI_SUCCESS             The handles for the specified device have been
123*f439973dSWarner Losh                                   created or destroyed as requested, and for an
124*f439973dSWarner Losh                                   add operation, the new handles are returned in
125*f439973dSWarner Losh                                   ChildHandleBuffer.
126*f439973dSWarner Losh   @retval EFI_INVALID_PARAMETER   Operation is not a legal value.
127*f439973dSWarner Losh   @retval EFI_INVALID_PARAMETER   Controller is NULL or not a valid handle.
128*f439973dSWarner Losh   @retval EFI_INVALID_PARAMETER   NumberOfChildren is NULL.
129*f439973dSWarner Losh   @retval EFI_INVALID_PARAMETER   ChildHandleBuffer is NULL while Operation is
130*f439973dSWarner Losh                                   remove and NumberOfChildren contains a non-zero
131*f439973dSWarner Losh                                   value.
132*f439973dSWarner Losh   @retval EFI_INVALID_PARAMETER   ChildHandleBuffer is NULL while Operation is add.
133*f439973dSWarner Losh   @retval EFI_OUT_OF_RESOURCES    There are no enough resources to start the
134*f439973dSWarner Losh                                   devices.
135*f439973dSWarner Losh **/
136*f439973dSWarner Losh typedef
137*f439973dSWarner Losh EFI_STATUS
138*f439973dSWarner Losh (EFIAPI *EFI_PCI_HOTPLUG_REQUEST_NOTIFY)(
139*f439973dSWarner Losh   IN     EFI_PCI_HOTPLUG_REQUEST_PROTOCOL  *This,
140*f439973dSWarner Losh   IN     EFI_PCI_HOTPLUG_OPERATION         Operation,
141*f439973dSWarner Losh   IN     EFI_HANDLE                        Controller,
142*f439973dSWarner Losh   IN     EFI_DEVICE_PATH_PROTOCOL          *RemainingDevicePath  OPTIONAL,
143*f439973dSWarner Losh   IN OUT UINT8                             *NumberOfChildren,
144*f439973dSWarner Losh   IN OUT EFI_HANDLE                        *ChildHandleBuffer
145*f439973dSWarner Losh   );
146*f439973dSWarner Losh 
147*f439973dSWarner Losh ///
148*f439973dSWarner Losh /// Provides services to notify PCI bus driver that some events have happened in
149*f439973dSWarner Losh /// a hot-plug controller (for example, PC Card socket, or PHPC), and ask PCI bus
150*f439973dSWarner Losh /// driver to create or destroy handles for the PCI-like devices.
151*f439973dSWarner Losh ///
152*f439973dSWarner Losh struct _EFI_PCI_HOTPLUG_REQUEST_PROTOCOL {
153*f439973dSWarner Losh   ///
154*f439973dSWarner Losh   /// Notify the PCI bus driver that some events have happened in a hot-plug
155*f439973dSWarner Losh   /// controller (for example, PC Card socket, or PHPC), and ask PCI bus driver
156*f439973dSWarner Losh   /// to create or destroy handles for the PCI-like devices. See Section 0 for
157*f439973dSWarner Losh   /// a detailed description.
158*f439973dSWarner Losh   ///
159*f439973dSWarner Losh   EFI_PCI_HOTPLUG_REQUEST_NOTIFY    Notify;
160*f439973dSWarner Losh };
161*f439973dSWarner Losh 
162*f439973dSWarner Losh extern EFI_GUID  gEfiPciHotPlugRequestProtocolGuid;
163*f439973dSWarner Losh 
164*f439973dSWarner Losh #endif
165