summaryrefslogtreecommitdiffstats
path: root/src/arch/x86/prefix/efiprefix.c
diff options
context:
space:
mode:
authorMichael Brown2014-06-25 15:47:35 +0200
committerMichael Brown2014-06-25 15:47:35 +0200
commit0e3ab6064e9f9eec28712c3b2c1e082672e73461 (patch)
tree244639d414c47633e9f761c568ff5b4559a4b7a4 /src/arch/x86/prefix/efiprefix.c
parent[efi] Provide a meaningful EFI SNP device name (diff)
downloadipxe-0e3ab6064e9f9eec28712c3b2c1e082672e73461.tar.gz
ipxe-0e3ab6064e9f9eec28712c3b2c1e082672e73461.tar.xz
ipxe-0e3ab6064e9f9eec28712c3b2c1e082672e73461.zip
[efi] Restructure EFI driver model
Provide a single instance of EFI_DRIVER_BINDING_PROTOCOL (attached to our image handle); this matches the expectations scattered throughout the EFI specification. Open the underlying hardware device using EFI_OPEN_PROTOCOL_BY_DRIVER and EFI_OPEN_PROTOCOL_EXCLUSIVE, to prevent other drivers from attaching to the same device. Do not automatically connect to devices when being loaded as a driver; leave this task to the platform firmware (or to the user, if loading directly from the EFI shell). When running as an application, forcibly disconnect any existing drivers from devices that we want to control, and reconnect them on exit. Provide a meaningful driver version number (based on the build timestamp), to allow platform firmware to automatically load newer versions of iPXE drivers if multiple drivers are present. Include device paths within debug messages where possible, to aid in debugging. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/x86/prefix/efiprefix.c')
-rw-r--r--src/arch/x86/prefix/efiprefix.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/arch/x86/prefix/efiprefix.c b/src/arch/x86/prefix/efiprefix.c
index eb8aa738..216b9988 100644
--- a/src/arch/x86/prefix/efiprefix.c
+++ b/src/arch/x86/prefix/efiprefix.c
@@ -21,7 +21,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <stdlib.h>
#include <errno.h>
+#include <ipxe/device.h>
#include <ipxe/efi/efi.h>
+#include <ipxe/efi/efi_driver.h>
/**
* EFI entry point
@@ -47,6 +49,39 @@ EFI_STATUS EFIAPI _efi_start ( EFI_HANDLE image_handle,
err_main:
efi_loaded_image->Unload ( image_handle );
+ efi_driver_reconnect_all();
err_init:
return efirc;
}
+
+/**
+ * Probe EFI root bus
+ *
+ * @v rootdev EFI root device
+ */
+static int efi_probe ( struct root_device *rootdev __unused ) {
+
+ return efi_driver_connect_all();
+}
+
+/**
+ * Remove EFI root bus
+ *
+ * @v rootdev EFI root device
+ */
+static void efi_remove ( struct root_device *rootdev __unused ) {
+
+ efi_driver_disconnect_all();
+}
+
+/** EFI root device driver */
+static struct root_driver efi_root_driver = {
+ .probe = efi_probe,
+ .remove = efi_remove,
+};
+
+/** EFI root device */
+struct root_device efi_root_device __root_device = {
+ .dev = { .name = "EFI" },
+ .driver = &efi_root_driver,
+};