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
9FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
10FILE_SECBOOT ( PERMITTED );
11
12#include <ipxe/device.h>
13#include <ipxe/tables.h>
14#include <ipxe/efi/efi.h>
16
17/** An EFI device */
18struct 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 */
29 /** Driver-private data */
30 void *priv;
31};
32
33/** An EFI driver */
34struct 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 */
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/** Define build rules for an EFI driver */
79#define EFI_ROM( _name, _desc )
80
81/**
82 * Set EFI driver-private data
83 *
84 * @v efidev EFI device
85 * @v priv Private data
86 */
87static inline void efidev_set_drvdata ( struct efi_device *efidev,
88 void *priv ) {
89 efidev->priv = priv;
90}
91
92/**
93 * Get EFI driver-private data
94 *
95 * @v efidev EFI device
96 * @ret priv Private data
97 */
98static inline void * efidev_get_drvdata ( struct efi_device *efidev ) {
99 return efidev->priv;
100}
101
102extern struct efi_device * efidev_alloc ( EFI_HANDLE device );
103extern void efidev_free ( struct efi_device *efidev );
104extern struct efi_device * efidev_parent ( struct device *dev );
105extern int efi_driver_install ( void );
106extern void efi_driver_uninstall ( void );
108extern int efi_driver_connect_all ( void );
109extern void efi_driver_disconnect_all ( void );
110extern void efi_driver_reconnect_all ( void );
111
112#endif /* _IPXE_EFI_DRIVER_H */
The device path protocol as defined in UEFI 2.0.
GUID EFI_GUID
128-bit buffer containing a unique identifier value.
Device model.
void efi_driver_disconnect_all(void)
Disconnect EFI driver from all possible devices.
Definition efi_driver.c:648
static void * efidev_get_drvdata(struct efi_device *efidev)
Get EFI driver-private data.
Definition efi_driver.h:98
void efi_driver_reconnect_all(void)
Reconnect original EFI drivers to all possible devices.
Definition efi_driver.c:659
static void efidev_set_drvdata(struct efi_device *efidev, void *priv)
Set EFI driver-private data.
Definition efi_driver.h:87
void efidev_free(struct efi_device *efidev)
Free EFI device.
Definition efi_driver.c:92
int efi_driver_exclude(EFI_HANDLE device, EFI_GUID *protocol)
Try to disconnect an existing EFI driver.
Definition efi_driver.c:438
struct efi_device * efidev_parent(struct device *dev)
Get parent EFI device.
Definition efi_driver.c:129
int efi_driver_connect_all(void)
Connect EFI driver to all possible devices.
Definition efi_driver.c:637
int efi_driver_install(void)
Install EFI driver.
Definition efi_driver.c:388
void efi_driver_uninstall(void)
Uninstall EFI driver.
Definition efi_driver.c:421
struct efi_device * efidev_alloc(EFI_HANDLE device)
Allocate new EFI device.
Definition efi_driver.c:57
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
EFI API.
#define EFI_HANDLE
Definition efi.h:53
uint16_t protocol
Protocol ID.
Definition stp.h:7
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition DevicePath.h:46
A hardware device.
Definition device.h:77
An EFI device.
Definition efi_driver.h:18
EFI_HANDLE device
EFI device handle.
Definition efi_driver.h:22
struct device dev
Generic device.
Definition efi_driver.h:20
void * priv
Driver-private data.
Definition efi_driver.h:30
EFI_HANDLE child
EFI child device handle (if present)
Definition efi_driver.h:24
struct efi_driver * driver
Driver for this device.
Definition efi_driver.h:28
EFI_DEVICE_PATH_PROTOCOL * path
EFI device path copy.
Definition efi_driver.h:26
An EFI driver.
Definition efi_driver.h:34
void(* stop)(struct efi_device *efidev)
Detach driver from device.
Definition efi_driver.h:63
int(* exclude)(EFI_HANDLE device)
Exclude existing drivers.
Definition efi_driver.h:43
const char * name
Name.
Definition efi_driver.h:36
int(* supported)(EFI_HANDLE device)
Check if driver supports device.
Definition efi_driver.h:50
int(* start)(struct efi_device *efidev)
Attach driver to device.
Definition efi_driver.h:57
Linker tables.
static struct tlan_private * priv
Definition tlan.c:225