@@ -1736,9 +1736,17 @@ impl Drop for TplGuard {
17361736#[ repr( u32 ) ]
17371737#[ derive( Debug ) ]
17381738pub enum OpenProtocolAttributes {
1739- /// Used by drivers to get a protocol interface for a handle. The
1740- /// driver will not be informed if the interface is uninstalled or
1741- /// reinstalled.
1739+ /// Used by applications and drivers to open a protocol interface for a
1740+ /// handle.
1741+ ///
1742+ /// # Safety
1743+ ///
1744+ /// The interface is opened non-exclusively. The caller must ensure that
1745+ /// either the interface is immutable, or that no conflicting concurrent
1746+ /// access occurs.
1747+ ///
1748+ /// The caller must ensure that the interface is not uninstalled or
1749+ /// reinstalled while still in use.
17421750 GetProtocol = 0x02 ,
17431751
17441752 /// Used by bus drivers to show that a protocol is being used by one
@@ -1753,17 +1761,42 @@ pub enum OpenProtocolAttributes {
17531761 /// the `ByDriver` attribute.
17541762 ByDriver = 0x10 ,
17551763
1756- /// Used by a driver to gain exclusive access to a protocol
1757- /// interface. If any other drivers have the protocol interface
1758- /// opened with an attribute of `ByDriver`, then an attempt will be
1759- /// made to remove them with `DisconnectController`.
1760- ByDriverExclusive = 0x30 ,
1761-
17621764 /// Used by applications to gain exclusive access to a protocol
17631765 /// interface. If any drivers have the protocol opened with an
17641766 /// attribute of `ByDriver`, then an attempt will be made to remove
17651767 /// them by calling the driver's `Stop` function.
1768+ ///
1769+ /// # Warning
1770+ ///
1771+ /// Opening an interface in exclusive mode can have surprising side
1772+ /// effects. For example:
1773+ ///
1774+ /// * Opening a serial protocol in exclusive mode may disconnect it from
1775+ /// other output protocols, and that connection will not be automatically
1776+ /// restored when the exclusive access is ended. ([`connect_controller`]
1777+ /// can sometimes be used to manually restore such connections.)
1778+ ///
1779+ /// * Stopping drivers that have the protocol open may be very slow. On some
1780+ /// firmware, opening any of the disk protocols in exclusive mode can take
1781+ /// nearly one second to complete.
1782+ ///
1783+ /// In many cases it is better to use [`GetProtocol`], even though it
1784+ /// requires the use of `unsafe`.
1785+ ///
1786+ /// [`GetProtocol`]: Self::GetProtocol
17661787 Exclusive = 0x20 ,
1788+
1789+ /// Used by a driver to gain exclusive access to a protocol
1790+ /// interface. If any other drivers have the protocol interface
1791+ /// opened with an attribute of `ByDriver`, then an attempt will be
1792+ /// made to remove them with `DisconnectController`.
1793+ ///
1794+ /// # Warning
1795+ ///
1796+ /// See warning section of [`Exclusive`].
1797+ ///
1798+ /// [`Exclusive`]: Self::Exclusive
1799+ ByDriverExclusive = 0x30 ,
17671800}
17681801
17691802/// Parameters passed to [`open_protocol`].
0 commit comments