28f7f8
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
39700a
From: Fedora Ninjas <grub2-owner@fedoraproject.org>
39700a
Date: Sat, 15 Feb 2014 15:10:22 -0500
28f7f8
Subject: [PATCH] reopen SNP protocol for exclusive use by grub
39700a
39700a
---
39700a
 grub-core/net/drivers/efi/efinet.c | 16 ++++++++++++++++
39700a
 1 file changed, 16 insertions(+)
39700a
39700a
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
28f7f8
index 2b344d6ef78..a6e4c7992f7 100644
39700a
--- a/grub-core/net/drivers/efi/efinet.c
39700a
+++ b/grub-core/net/drivers/efi/efinet.c
39700a
@@ -223,6 +223,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
39700a
 {
39700a
   struct grub_net_card *card;
39700a
   grub_efi_device_path_t *dp;
39700a
+  grub_efi_simple_network_t *net;
39700a
 
39700a
   dp = grub_efi_get_device_path (hnd);
39700a
   if (! dp)
39700a
@@ -250,6 +251,21 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
39700a
 				    &pxe_mode->dhcp_ack,
39700a
 				    sizeof (pxe_mode->dhcp_ack),
39700a
 				    1, device, path);
39700a
+    net = grub_efi_open_protocol (card->efi_handle, &net_io_guid,
39700a
+				  GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE);
39700a
+    if (net) {
39700a
+      if (net->mode->state == GRUB_EFI_NETWORK_STOPPED
39700a
+	  && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS)
39700a
+	continue;
39700a
+
39700a
+      if (net->mode->state == GRUB_EFI_NETWORK_STOPPED)
39700a
+	continue;
39700a
+
39700a
+      if (net->mode->state == GRUB_EFI_NETWORK_STARTED
39700a
+	  && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS)
39700a
+	continue;
39700a
+      card->efi_net = net;
39700a
+    }
39700a
     return;
39700a
   }
39700a
 }