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  * Check if driver supports device
38  *
39  * @v device EFI device handle
40  * @ret rc Return status code
41  */
42  int ( * supported ) ( EFI_HANDLE device );
43  /**
44  * Attach driver to device
45  *
46  * @v efidev EFI device
47  * @ret rc Return status code
48  */
49  int ( * start ) ( struct efi_device *efidev );
50  /**
51  * Detach driver from device
52  *
53  * @v efidev EFI device
54  */
55  void ( * stop ) ( struct efi_device *efidev );
56 };
57 
58 /** EFI driver table */
59 #define EFI_DRIVERS __table ( struct efi_driver, "efi_drivers" )
60 
61 /** Declare an EFI driver */
62 #define __efi_driver( order ) __table_entry ( EFI_DRIVERS, order )
63 
64 #define EFI_DRIVER_EARLY 01 /**< Early drivers */
65 #define EFI_DRIVER_NORMAL 02 /**< Normal drivers */
66 #define EFI_DRIVER_LATE 03 /**< Late drivers */
67 
68 /**
69  * Set EFI driver-private data
70  *
71  * @v efidev EFI device
72  * @v priv Private data
73  */
74 static inline void efidev_set_drvdata ( struct efi_device *efidev,
75  void *priv ) {
76  efidev->priv = priv;
77 }
78 
79 /**
80  * Get EFI driver-private data
81  *
82  * @v efidev EFI device
83  * @ret priv Private data
84  */
85 static inline void * efidev_get_drvdata ( struct efi_device *efidev ) {
86  return efidev->priv;
87 }
88 
89 extern struct efi_device * efidev_alloc ( EFI_HANDLE device );
90 extern void efidev_free ( struct efi_device *efidev );
91 extern struct efi_device * efidev_parent ( struct device *dev );
92 extern int efi_driver_install ( void );
93 extern void efi_driver_uninstall ( void );
94 extern int efi_driver_connect_all ( void );
95 extern void efi_driver_disconnect_all ( void );
96 extern void efi_driver_reconnect_all ( void );
97 
98 #endif /* _IPXE_EFI_DRIVER_H */
int efi_driver_connect_all(void)
Connect EFI driver to all possible devices.
Definition: efi_driver.c:602
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:414
void efidev_free(struct efi_device *efidev)
Free EFI device.
Definition: efi_driver.c:118
void efi_driver_uninstall(void)
Uninstall EFI driver.
Definition: efi_driver.c:447
void(* stop)(struct efi_device *efidev)
Detach driver from device.
Definition: efi_driver.h:55
struct efi_device * efidev_alloc(EFI_HANDLE device)
Allocate new EFI device.
Definition: efi_driver.c:70
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: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:624
int(* supported)(EFI_HANDLE device)
Check if driver supports device.
Definition: efi_driver.h:42
EFI_HANDLE child
EFI child device handle (if present)
Definition: efi_driver.h:23
A hardware device.
Definition: device.h:73
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:85
An EFI device.
Definition: efi_driver.h:17
struct efi_device * efidev_parent(struct device *dev)
Get parent EFI device.
Definition: efi_driver.c:155
EFI API.
An EFI driver.
Definition: efi_driver.h:33
static struct tlan_private * priv
Definition: tlan.c:224
const char * name
Name.
Definition: efi_driver.h:35
Linker tables.
Device model.
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:74
struct device dev
Generic device.
Definition: efi_driver.h:19
Definition: efi.h:59
int(* start)(struct efi_device *efidev)
Attach driver to device.
Definition: efi_driver.h:49
void efi_driver_disconnect_all(void)
Disconnect EFI driver from all possible devices.
Definition: efi_driver.c:613