iPXE
efi_driver.h
Go to the documentation of this file.
1 #ifndef _IPXE_EFI_DRIVER_H
2 #define _IPXE_EFI_DRIVER_H
3 
4 /** @file
5  *
6  * EFI driver interface
7  */
8 
9 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
10 FILE_SECBOOT ( PERMITTED );
11 
12 #include <ipxe/device.h>
13 #include <ipxe/tables.h>
14 #include <ipxe/efi/efi.h>
16 
17 /** An EFI device */
18 struct efi_device {
19  /** Generic device */
20  struct device dev;
21  /** EFI device handle */
23  /** EFI child device handle (if present) */
25  /** EFI device path copy */
27  /** Driver for this device */
28  struct efi_driver *driver;
29  /** Driver-private data */
30  void *priv;
31 };
32 
33 /** An EFI driver */
34 struct efi_driver {
35  /** Name */
36  const char *name;
37  /**
38  * Exclude existing drivers
39  *
40  * @v device EFI device handle
41  * @ret rc Return status code
42  */
43  int ( * exclude ) ( EFI_HANDLE device );
44  /**
45  * Check if driver supports device
46  *
47  * @v device EFI device handle
48  * @ret rc Return status code
49  */
50  int ( * supported ) ( EFI_HANDLE device );
51  /**
52  * Attach driver to device
53  *
54  * @v efidev EFI device
55  * @ret rc Return status code
56  */
57  int ( * start ) ( struct efi_device *efidev );
58  /**
59  * Detach driver from device
60  *
61  * @v efidev EFI device
62  */
63  void ( * stop ) ( struct efi_device *efidev );
64 };
65 
66 /** EFI driver table */
67 #define EFI_DRIVERS __table ( struct efi_driver, "efi_drivers" )
68 
69 /** Declare an EFI driver */
70 #define __efi_driver( order ) __table_entry ( EFI_DRIVERS, order )
71 
72 #define EFI_DRIVER_EARLY 01 /**< Early drivers */
73 #define EFI_DRIVER_HARDWARE 02 /**< Hardware drivers */
74 #define EFI_DRIVER_NII 03 /**< NII protocol drivers */
75 #define EFI_DRIVER_SNP 04 /**< SNP protocol drivers */
76 #define EFI_DRIVER_MNP 05 /**< MNP protocol drivers */
77 
78 /**
79  * Set EFI driver-private data
80  *
81  * @v efidev EFI device
82  * @v priv Private data
83  */
84 static inline void efidev_set_drvdata ( struct efi_device *efidev,
85  void *priv ) {
86  efidev->priv = priv;
87 }
88 
89 /**
90  * Get EFI driver-private data
91  *
92  * @v efidev EFI device
93  * @ret priv Private data
94  */
95 static inline void * efidev_get_drvdata ( struct efi_device *efidev ) {
96  return efidev->priv;
97 }
98 
99 extern struct efi_device * efidev_alloc ( EFI_HANDLE device );
100 extern void efidev_free ( struct efi_device *efidev );
101 extern struct efi_device * efidev_parent ( struct device *dev );
102 extern int efi_driver_install ( void );
103 extern void efi_driver_uninstall ( void );
105 extern int efi_driver_connect_all ( void );
106 extern void efi_driver_disconnect_all ( void );
107 extern void efi_driver_reconnect_all ( void );
108 
109 #endif /* _IPXE_EFI_DRIVER_H */
int efi_driver_connect_all(void)
Connect EFI driver to all possible devices.
Definition: efi_driver.c:637
struct efi_driver * driver
Driver for this device.
Definition: efi_driver.h:28
The device path protocol as defined in UEFI 2.0.
int efi_driver_install(void)
Install EFI driver.
Definition: efi_driver.c:388
128 bit buffer containing a unique identifier value.
Definition: Base.h:216
void efidev_free(struct efi_device *efidev)
Free EFI device.
Definition: efi_driver.c:92
void efi_driver_uninstall(void)
Uninstall EFI driver.
Definition: efi_driver.c:421
void(* stop)(struct efi_device *efidev)
Detach driver from device.
Definition: efi_driver.h:63
FILE_SECBOOT(PERMITTED)
struct efi_device * efidev_alloc(EFI_HANDLE device)
Allocate new EFI device.
Definition: efi_driver.c:57
EFI_HANDLE device
EFI device handle.
Definition: efi_driver.h:22
int(* exclude)(EFI_HANDLE device)
Exclude existing drivers.
Definition: efi_driver.h:43
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:46
uint16_t device
Device ID.
Definition: ena.h:24
void efi_driver_reconnect_all(void)
Reconnect original EFI drivers to all possible devices.
Definition: efi_driver.c:659
int(* supported)(EFI_HANDLE device)
Check if driver supports device.
Definition: efi_driver.h:50
EFI_HANDLE child
EFI child device handle (if present)
Definition: efi_driver.h:24
A hardware device.
Definition: device.h:77
int efi_driver_exclude(EFI_HANDLE device, EFI_GUID *protocol)
Try to disconnect an existing EFI driver.
Definition: efi_driver.c:438
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
void * priv
Driver-private data.
Definition: efi_driver.h:30
static void * efidev_get_drvdata(struct efi_device *efidev)
Get EFI driver-private data.
Definition: efi_driver.h:95
An EFI device.
Definition: efi_driver.h:18
struct efi_device * efidev_parent(struct device *dev)
Get parent EFI device.
Definition: efi_driver.c:129
EFI API.
An EFI driver.
Definition: efi_driver.h:34
static struct tlan_private * priv
Definition: tlan.c:225
const char * name
Name.
Definition: efi_driver.h:36
Linker tables.
Device model.
uint16_t protocol
Protocol ID.
Definition: stp.h:19
EFI_DEVICE_PATH_PROTOCOL * path
EFI device path copy.
Definition: efi_driver.h:26
static void efidev_set_drvdata(struct efi_device *efidev, void *priv)
Set EFI driver-private data.
Definition: efi_driver.h:84
struct device dev
Generic device.
Definition: efi_driver.h:20
Definition: efi.h:62
int(* start)(struct efi_device *efidev)
Attach driver to device.
Definition: efi_driver.h:57
void efi_driver_disconnect_all(void)
Disconnect EFI driver from all possible devices.
Definition: efi_driver.c:648