summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/efi/efi_driver.h
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/include/ipxe/efi/efi_driver.h
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/include/ipxe/efi/efi_driver.h')
-rw-r--r--src/include/ipxe/efi/efi_driver.h61
1 files changed, 35 insertions, 26 deletions
diff --git a/src/include/ipxe/efi/efi_driver.h b/src/include/ipxe/efi/efi_driver.h
index afa574d0..600d304f 100644
--- a/src/include/ipxe/efi/efi_driver.h
+++ b/src/include/ipxe/efi/efi_driver.h
@@ -8,43 +8,52 @@
FILE_LICENCE ( GPL2_OR_LATER );
+#include <ipxe/tables.h>
#include <ipxe/efi/efi.h>
-#include <ipxe/efi/Protocol/DriverBinding.h>
-#include <ipxe/efi/Protocol/ComponentName2.h>
#include <ipxe/efi/Protocol/DevicePath.h>
/** An EFI driver */
struct efi_driver {
/** Name */
const char *name;
- /** EFI name */
- CHAR16 wname[32];
- /** EFI driver binding protocol */
- EFI_DRIVER_BINDING_PROTOCOL driver;
- /** EFI component name protocol */
- EFI_COMPONENT_NAME2_PROTOCOL wtf;
+ /**
+ * Check if driver supports device
+ *
+ * @v device Device
+ * @ret rc Return status code
+ */
+ int ( * supported ) ( EFI_HANDLE device );
+ /**
+ * Attach driver to device
+ *
+ * @v device Device
+ * @ret rc Return status code
+ */
+ int ( * start ) ( EFI_HANDLE device );
+ /**
+ * Detach driver from device
+ *
+ * @v device Device
+ */
+ void ( * stop ) ( EFI_HANDLE device );
};
-/** Initialise an EFI driver
- *
- * @v name Driver name
- * @v supported Device supported method
- * @v start Device start method
- * @v stop Device stop method
- */
-#define EFI_DRIVER_INIT( _name, _supported, _start, _stop ) { \
- .name = _name, \
- .driver = { \
- .Supported = _supported, \
- .Start = _start, \
- .Stop = _stop, \
- .Version = 0x10, \
- } }
+/** EFI driver table */
+#define EFI_DRIVERS __table ( struct efi_driver, "efi_drivers" )
+
+/** Declare an EFI driver */
+#define __efi_driver( order ) __table_entry ( EFI_DRIVERS, order )
+
+#define EFI_DRIVER_EARLY 01 /**< Early drivers */
+#define EFI_DRIVER_NORMAL 02 /**< Normal drivers */
+#define EFI_DRIVER_LATE 03 /**< Late drivers */
extern EFI_DEVICE_PATH_PROTOCOL *
efi_devpath_end ( EFI_DEVICE_PATH_PROTOCOL *path );
-
-extern int efi_driver_install ( struct efi_driver *efidrv );
-extern void efi_driver_uninstall ( struct efi_driver *efidrv );
+extern int efi_driver_install ( void );
+extern void efi_driver_uninstall ( void );
+extern int efi_driver_connect_all ( void );
+extern void efi_driver_disconnect_all ( void );
+extern void efi_driver_reconnect_all ( void );
#endif /* _IPXE_EFI_DRIVER_H */