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