iPXE
efi_driver.h
Go to the documentation of this file.
00001 #ifndef _IPXE_EFI_DRIVER_H
00002 #define _IPXE_EFI_DRIVER_H
00003 
00004 /** @file
00005  *
00006  * EFI driver interface
00007  */
00008 
00009 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00010 
00011 #include <ipxe/device.h>
00012 #include <ipxe/tables.h>
00013 #include <ipxe/efi/efi.h>
00014 #include <ipxe/efi/Protocol/DevicePath.h>
00015 
00016 /** An EFI device */
00017 struct efi_device {
00018         /** Generic device */
00019         struct device dev;
00020         /** EFI device handle */
00021         EFI_HANDLE device;
00022         /** EFI device path copy */
00023         EFI_DEVICE_PATH_PROTOCOL *path;
00024         /** Driver for this device */
00025         struct efi_driver *driver;
00026         /** Driver-private data */
00027         void *priv;
00028 };
00029 
00030 /** An EFI driver */
00031 struct efi_driver {
00032         /** Name */
00033         const char *name;
00034         /**
00035          * Check if driver supports device
00036          *
00037          * @v device            EFI device handle
00038          * @ret rc              Return status code
00039          */
00040         int ( * supported ) ( EFI_HANDLE device );
00041         /**
00042          * Attach driver to device
00043          *
00044          * @v efidev            EFI device
00045          * @ret rc              Return status code
00046          */
00047         int ( * start ) ( struct efi_device *efidev );
00048         /**
00049          * Detach driver from device
00050          *
00051          * @v efidev            EFI device
00052          */
00053         void ( * stop ) ( struct efi_device *efidev );
00054 };
00055 
00056 /** EFI driver table */
00057 #define EFI_DRIVERS __table ( struct efi_driver, "efi_drivers" )
00058 
00059 /** Declare an EFI driver */
00060 #define __efi_driver( order ) __table_entry ( EFI_DRIVERS, order )
00061 
00062 #define EFI_DRIVER_EARLY        01      /**< Early drivers */
00063 #define EFI_DRIVER_NORMAL       02      /**< Normal drivers */
00064 #define EFI_DRIVER_LATE         03      /**< Late drivers */
00065 
00066 /**
00067  * Set EFI driver-private data
00068  *
00069  * @v efidev            EFI device
00070  * @v priv              Private data
00071  */
00072 static inline void efidev_set_drvdata ( struct efi_device *efidev,
00073                                         void *priv ) {
00074         efidev->priv = priv;
00075 }
00076 
00077 /**
00078  * Get EFI driver-private data
00079  *
00080  * @v efidev            EFI device
00081  * @ret priv            Private data
00082  */
00083 static inline void * efidev_get_drvdata ( struct efi_device *efidev ) {
00084         return efidev->priv;
00085 }
00086 
00087 extern struct efi_device * efidev_parent ( struct device *dev );
00088 extern int efi_driver_install ( void );
00089 extern void efi_driver_uninstall ( void );
00090 extern int efi_driver_connect_all ( void );
00091 extern void efi_driver_disconnect_all ( void );
00092 extern void efi_driver_reconnect_all ( void );
00093 
00094 #endif /* _IPXE_EFI_DRIVER_H */