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 device path copy */
24  /** Driver for this device */
25  struct efi_driver *driver;
26  /** Driver-private data */
27  void *priv;
28 };
29 
30 /** An EFI driver */
31 struct efi_driver {
32  /** Name */
33  const char *name;
34  /**
35  * Check if driver supports device
36  *
37  * @v device EFI device handle
38  * @ret rc Return status code
39  */
40  int ( * supported ) ( EFI_HANDLE device );
41  /**
42  * Attach driver to device
43  *
44  * @v efidev EFI device
45  * @ret rc Return status code
46  */
47  int ( * start ) ( struct efi_device *efidev );
48  /**
49  * Detach driver from device
50  *
51  * @v efidev EFI device
52  */
53  void ( * stop ) ( struct efi_device *efidev );
54 };
55 
56 /** EFI driver table */
57 #define EFI_DRIVERS __table ( struct efi_driver, "efi_drivers" )
58 
59 /** Declare an EFI driver */
60 #define __efi_driver( order ) __table_entry ( EFI_DRIVERS, order )
61 
62 #define EFI_DRIVER_EARLY 01 /**< Early drivers */
63 #define EFI_DRIVER_NORMAL 02 /**< Normal drivers */
64 #define EFI_DRIVER_LATE 03 /**< Late drivers */
65 
66 /**
67  * Set EFI driver-private data
68  *
69  * @v efidev EFI device
70  * @v priv Private data
71  */
72 static inline void efidev_set_drvdata ( struct efi_device *efidev,
73  void *priv ) {
74  efidev->priv = priv;
75 }
76 
77 /**
78  * Get EFI driver-private data
79  *
80  * @v efidev EFI device
81  * @ret priv Private data
82  */
83 static inline void * efidev_get_drvdata ( struct efi_device *efidev ) {
84  return efidev->priv;
85 }
86 
87 extern struct efi_device * efidev_parent ( struct device *dev );
88 extern int efi_driver_install ( void );
89 extern void efi_driver_uninstall ( void );
90 extern int efi_driver_connect_all ( void );
91 extern void efi_driver_disconnect_all ( void );
92 extern void efi_driver_reconnect_all ( void );
93 
94 #endif /* _IPXE_EFI_DRIVER_H */
int efi_driver_connect_all(void)
Connect EFI driver to all possible devices.
Definition: efi_driver.c:551
struct efi_driver * driver
Driver for this device.
Definition: efi_driver.h:25
The device path protocol as defined in UEFI 2.0.
int efi_driver_install(void)
Install EFI driver.
Definition: efi_driver.c:372
void efi_driver_uninstall(void)
Uninstall EFI driver.
Definition: efi_driver.c:405
void(* stop)(struct efi_device *efidev)
Detach driver from device.
Definition: efi_driver.h:53
EFI_HANDLE device
EFI device handle.
Definition: efi_driver.h:21
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:51
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:573
int(* supported)(EFI_HANDLE device)
Check if driver supports device.
Definition: efi_driver.h:40
A hardware device.
Definition: device.h:73
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
void * priv
Driver-private data.
Definition: efi_driver.h:27
static void * efidev_get_drvdata(struct efi_device *efidev)
Get EFI driver-private data.
Definition: efi_driver.h:83
An EFI device.
Definition: efi_driver.h:17
struct efi_device * efidev_parent(struct device *dev)
Get parent EFI device.
Definition: efi_driver.c:74
EFI API.
An EFI driver.
Definition: efi_driver.h:31
static struct tlan_private * priv
Definition: tlan.c:224
const char * name
Name.
Definition: efi_driver.h:33
Linker tables.
Device model.
EFI_DEVICE_PATH_PROTOCOL * path
EFI device path copy.
Definition: efi_driver.h:23
static void efidev_set_drvdata(struct efi_device *efidev, void *priv)
Set EFI driver-private data.
Definition: efi_driver.h:72
struct device dev
Generic device.
Definition: efi_driver.h:19
Definition: efi.h:55
int(* start)(struct efi_device *efidev)
Attach driver to device.
Definition: efi_driver.h:47
void efi_driver_disconnect_all(void)
Disconnect EFI driver from all possible devices.
Definition: efi_driver.c:562