Are you saying in an application:

OpenProtocol(Handle, &gEfiDiskIoProtocolGuid, (void**) &DiskIO,
ImageHandle, NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL)

is not safe - it will still invalidate the pointers in DiskIO when
removed and won't wait until CloseProtocol is used?

On Tue, Feb 12, 2013 at 12:19 PM, Andrew Fish <af...@apple.com> wrote:
>
> On Feb 12, 2013, at 10:48 AM, David F. <df7...@gmail.com> wrote:
>
>> I mean the device itself may be removed, USB hard drive, 1394, etc..
>> I presume it would still be safe and attempts to access it would
>> simply fail?
>>
>
> The bus driver (USB Bus Driver for example) does a 
> gBS->DisconnectController() and causes the Block IO driver to stop. Stop 
> means uninstall your protocols. This works fine for the EFI driver model as 
> the leaf gets stopped first. So the file system driver first, then the 
> partition driver, and then the Block IO driver get stopped. The problem we 
> run into is the EFI application may do a HandleProtocol() and in this case it 
> will not be notified when the stack gets torn down.
>
> In my other mail where I attached a patch, there was a library that wraps 
> Block IO and makes it safe to use by following the driver model. Basically 
> you just call library functions and if you application is in the middle of a 
> block IO call you fail the stop. This library implements the BY_DRIVER 
> attribute of OpenProtocol() and produces a driver binding protocol instance 
> so a surprise removal request can be detected or deferred.
>
> This model is a side effect of some of the other rules we have. For example 
> device paths must be unique, only one instance of a protocol per handle, and 
> how the DXE core tracks all the drivers and their parent child relationships.
>
> Thanks,
>
> Andrew Fish
>
>> On Tue, Feb 12, 2013 at 8:44 AM, Andrew Fish <af...@apple.com> wrote:
>>> What do you mean by device being removed? Media being removed from a device 
>>> is a different case than unplugging an USB disk.
>>>
>>> Andrew Fish
>>>
>>>
>>> On Feb 11, 2013, at 7:38 PM, "David F." <df7...@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I'd like to open the DISK_IO protocol and leave it open for quite a
>>>> while (hours).  In the mean time the device may be removed.  I would
>>>> assume that I can continue to try using the protocol to read/write and
>>>> there would simply be a failure (as long as its detached - if
>>>> something else in its place may fail due to media-id difference, but
>>>> that is understood).  Once I close the protocol, then the item is
>>>> cleaned up.
>>>>
>>>> Is the assumption good?
>>>>
>>>> TIA!!
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Free Next-Gen Firewall Hardware Offer
>>>> Buy your Sophos next-gen firewall before the end March 2013
>>>> and get the hardware for free! Learn more.
>>>> http://p.sf.net/sfu/sophos-d2d-feb
>>>> _______________________________________________
>>>> edk2-devel mailing list
>>>> edk2-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Free Next-Gen Firewall Hardware Offer
>>> Buy your Sophos next-gen firewall before the end March 2013
>>> and get the hardware for free! Learn more.
>>> http://p.sf.net/sfu/sophos-d2d-feb
>>> _______________________________________________
>>> edk2-devel mailing list
>>> edk2-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>>
>> ------------------------------------------------------------------------------
>> Free Next-Gen Firewall Hardware Offer
>> Buy your Sophos next-gen firewall before the end March 2013
>> and get the hardware for free! Learn more.
>> http://p.sf.net/sfu/sophos-d2d-feb
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>
>
> ------------------------------------------------------------------------------
> Free Next-Gen Firewall Hardware Offer
> Buy your Sophos next-gen firewall before the end March 2013
> and get the hardware for free! Learn more.
> http://p.sf.net/sfu/sophos-d2d-feb
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to