On Sep 19, 2014, at 11:27 AM, Andrei Borzenkov <[email protected]> wrote:

> While revisiting problem discussed
> http://sourceforge.net/p/edk2/mailman/message/32171128/ I tried to
> understand why using EXCLUSIVE as suggested in this thread did not
> work. I added print of EFI status code from protocol open and to my
> surprise it was 3 (UNSUPPORTED). This happens in this code:
> 
>  handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, &net_io_guid,
>                                    0, &num_handles);
>  if (! handles)
>    return;
>  for (handle = handles; num_handles--; handle++)
>    {
>      grub_efi_simple_network_t *net;
>      struct grub_net_card *card;
> 
>      net = grub_efi_open_protocol (*handle, &net_io_guid,
>                                    GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE);
>      if (! net)
>        /* This should not happen... Why?  */
>        continue;
> 
> The problem is, original grub2 code is using
> GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL here and works. I do not understand
> how it can return UNSUPPORTED, when we just located handles that claim
> support simple network protocol. And if it fails with EXCLUSIVE, why it
> works wit GET_PROTOCOL?
> 

Per the UEFI 2.4 (this goes all the way back to EFI 1.10) EXCLUSIVE and 
BY_PROTOCOL have different behavior. So why do you expect them to work the 
exact same?

GET_PROTOCOL:
Used by a driver to get a protocol interface from a handle. Care must be taken 
when using this open mode because the driver that opens a protocol interface in 
this manner will not be informed if the protocol interface is uninstalled or 
reinstalled. The caller is also not required to close the protocol interface 
with CloseProtocol().

EXCLUSIVE:
Used by applications to gain exclusive access to a protocol interface. If any 
drivers have the protocol interface opened with an attribute of BY_DRIVER, then 
an attempt will be made to remove them by calling the driver’s Stop() function.

If you look in the text of OpenProtocol() you will see the set of conditions 
where EXCLUSIVE would fail and GET_PROTOCOL would not.

Thanks,

Andrew Fish

> What is more puzzling, when called later the same open succeeds.
> 
> I probably miss something obvious here; any hints appreciated.
> 
> I'm using 64 bit OVMF at commit SVN 16106; qemu is called as
> 
> qemu-system-x86_64 -bios /usr/share/qemu/ovmf-x86_64.bin -net 
> nic,model=virtio -net 
> user,tftp=/tmp/tftpboot,bootfile=/boot/grub/x86_64-efi/core.efi
> 
> Thank you!
> 
> -andrei
> 
> ------------------------------------------------------------------------------
> Slashdot TV.  Video for Nerds.  Stuff that Matters.
> http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/edk2-devel


------------------------------------------------------------------------------
Slashdot TV.  Video for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to