iPXE
efi_driver.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  */
19 
20 FILE_LICENCE ( GPL2_OR_LATER );
21 
22 #include <stddef.h>
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <string.h>
26 #include <errno.h>
27 #include <ipxe/version.h>
28 #include <ipxe/efi/efi.h>
32 #include <ipxe/efi/efi_strings.h>
33 #include <ipxe/efi/efi_path.h>
34 #include <ipxe/efi/efi_driver.h>
35 
36 /** @file
37  *
38  * EFI driver interface
39  *
40  */
41 
42 /* Disambiguate the various error causes */
43 #define EINFO_EEFI_CONNECT \
44  __einfo_uniqify ( EINFO_EPLATFORM, 0x01, \
45  "Could not connect controllers" )
46 #define EINFO_EEFI_CONNECT_PROHIBITED \
47  __einfo_platformify ( EINFO_EEFI_CONNECT, \
48  EFI_SECURITY_VIOLATION, \
49  "Connecting controllers prohibited by " \
50  "security policy" )
51 #define EEFI_CONNECT_PROHIBITED \
52  __einfo_error ( EINFO_EEFI_CONNECT_PROHIBITED )
53 #define EEFI_CONNECT( efirc ) EPLATFORM ( EINFO_EEFI_CONNECT, efirc, \
54  EEFI_CONNECT_PROHIBITED )
55 
57 
58 /** List of controlled EFI devices */
59 static LIST_HEAD ( efi_devices );
60 
61 /** We are currently disconnecting drivers */
63 
64 /**
65  * Allocate new EFI device
66  *
67  * @v device EFI device handle
68  * @ret efidev EFI device, or NULL on error
69  */
72  struct efi_device *efidev = NULL;
73  union {
75  void *interface;
76  } path;
77  EFI_DEVICE_PATH_PROTOCOL *path_end;
78  size_t path_len;
79  EFI_STATUS efirc;
80  int rc;
81 
82  /* Open device path */
83  if ( ( efirc = bs->OpenProtocol ( device,
85  &path.interface, efi_image_handle,
86  device,
88  rc = -EEFI ( efirc );
89  DBGC ( device, "EFIDRV %s could not open device path: %s\n",
90  efi_handle_name ( device ), strerror ( rc ) );
91  goto err_open_path;
92  }
93  path_len = ( efi_path_len ( path.path ) + sizeof ( *path_end ) );
94 
95  /* Allocate and initialise structure */
96  efidev = zalloc ( sizeof ( *efidev ) + path_len );
97  if ( ! efidev )
98  goto err_alloc;
99  efidev->device = device;
100  efidev->dev.desc.bus_type = BUS_TYPE_EFI;
101  efidev->path = ( ( ( void * ) efidev ) + sizeof ( *efidev ) );
102  memcpy ( efidev->path, path.path, path_len );
103  INIT_LIST_HEAD ( &efidev->dev.children );
104  list_add ( &efidev->dev.siblings, &efi_devices );
105 
106  err_alloc:
109  err_open_path:
110  return efidev;
111 }
112 
113 /**
114  * Free EFI device
115  *
116  * @v efidev EFI device
117  */
118 void efidev_free ( struct efi_device *efidev ) {
119 
120  assert ( list_empty ( &efidev->dev.children ) );
121  list_del ( &efidev->dev.siblings );
122  free ( efidev );
123 }
124 
125 /**
126  * Find EFI device
127  *
128  * @v device EFI device handle (or child handle)
129  * @ret efidev EFI device, or NULL if not found
130  */
132  struct efi_device *efidev;
133 
134  /* Avoid false positive matches against NULL children */
135  if ( ! device )
136  return NULL;
137 
138  /* Look for an existing EFI device */
139  list_for_each_entry ( efidev, &efi_devices, dev.siblings ) {
140  if ( ( device == efidev->device ) ||
141  ( device == efidev->child ) ) {
142  return efidev;
143  }
144  }
145 
146  return NULL;
147 }
148 
149 /**
150  * Get parent EFI device
151  *
152  * @v dev Generic device
153  * @ret efidev Parent EFI device, or NULL
154  */
155 struct efi_device * efidev_parent ( struct device *dev ) {
156  struct device *parent;
157  struct efi_device *efidev;
158 
159  /* Walk upwards until we find a registered EFI device */
160  while ( ( parent = dev->parent ) ) {
161  list_for_each_entry ( efidev, &efi_devices, dev.siblings ) {
162  if ( parent == &efidev->dev )
163  return efidev;
164  }
165  dev = parent;
166  }
167 
168  return NULL;
169 }
170 
171 /**
172  * Check to see if driver supports a device
173  *
174  * @v driver EFI driver
175  * @v device EFI device
176  * @v child Path to child device, if any
177  * @ret efirc EFI status code
178  */
179 static EFI_STATUS EFIAPI
182  struct efi_driver *efidrv;
183  int rc;
184 
185  DBGCP ( device, "EFIDRV %s DRIVER_SUPPORTED",
186  efi_handle_name ( device ) );
187  if ( child )
188  DBGCP ( device, " (child %s)", efi_devpath_text ( child ) );
189  DBGCP ( device, "\n" );
190 
191  /* Do nothing if we are already driving this device */
192  if ( efidev_find ( device ) != NULL ) {
193  DBGCP ( device, "EFIDRV %s is already started\n",
194  efi_handle_name ( device ) );
195  return EFI_ALREADY_STARTED;
196  }
197 
198  /* Look for a driver claiming to support this device */
199  for_each_table_entry ( efidrv, EFI_DRIVERS ) {
200  if ( ( rc = efidrv->supported ( device ) ) == 0 ) {
201  DBGC ( device, "EFIDRV %s has driver \"%s\"\n",
202  efi_handle_name ( device ), efidrv->name );
203  return 0;
204  }
205  }
206  DBGCP ( device, "EFIDRV %s has no driver\n",
207  efi_handle_name ( device ) );
208 
209  return EFI_UNSUPPORTED;
210 }
211 
212 /**
213  * Attach driver to device
214  *
215  * @v driver EFI driver
216  * @v device EFI device
217  * @v child Path to child device, if any
218  * @ret efirc EFI status code
219  */
220 static EFI_STATUS EFIAPI
223  struct efi_driver *efidrv;
224  struct efi_device *efidev;
225  struct efi_saved_tpl tpl;
226  EFI_STATUS efirc;
227  int rc;
228 
229  DBGC ( device, "EFIDRV %s DRIVER_START", efi_handle_name ( device ) );
230  if ( child )
231  DBGC ( device, " (child %s)", efi_devpath_text ( child ) );
232  DBGC ( device, "\n" );
233 
234  /* Do nothing if we are already driving this device */
235  efidev = efidev_find ( device );
236  if ( efidev ) {
237  DBGCP ( device, "EFIDRV %s is already started\n",
238  efi_handle_name ( device ) );
239  efirc = EFI_ALREADY_STARTED;
240  goto err_already_started;
241  }
242 
243  /* Raise TPL */
244  efi_raise_tpl ( &tpl );
245 
246  /* Do nothing if we are currently disconnecting drivers */
247  if ( efi_driver_disconnecting ) {
248  DBGC ( device, "EFIDRV %s refusing to start during "
249  "disconnection\n", efi_handle_name ( device ) );
250  efirc = EFI_NOT_READY;
251  goto err_disconnecting;
252  }
253 
254  /* Add new device */
255  efidev = efidev_alloc ( device );
256  if ( ! efidev ) {
257  efirc = EFI_OUT_OF_RESOURCES;
258  goto err_alloc;
259  }
260 
261  /* Try to start this device */
262  for_each_table_entry ( efidrv, EFI_DRIVERS ) {
263  if ( ( rc = efidrv->supported ( device ) ) != 0 ) {
264  DBGC ( device, "EFIDRV %s is not supported by driver "
265  "\"%s\": %s\n", efi_handle_name ( device ),
266  efidrv->name,
267  strerror ( rc ) );
268  continue;
269  }
270  if ( ( rc = efidrv->start ( efidev ) ) == 0 ) {
271  efidev->driver = efidrv;
272  DBGC ( device, "EFIDRV %s using driver \"%s\"\n",
274  efidev->driver->name );
275  efi_restore_tpl ( &tpl );
276  return 0;
277  }
278  DBGC ( device, "EFIDRV %s could not start driver \"%s\": %s\n",
279  efi_handle_name ( device ), efidrv->name,
280  strerror ( rc ) );
281  }
282  efirc = EFI_UNSUPPORTED;
283 
284  efidev_free ( efidev );
285  err_alloc:
286  err_disconnecting:
287  efi_restore_tpl ( &tpl );
288  err_already_started:
289  return efirc;
290 }
291 
292 /**
293  * Detach driver from device
294  *
295  * @v driver EFI driver
296  * @v device EFI device
297  * @v pci PCI device
298  * @v num_children Number of child devices
299  * @v children List of child devices
300  * @ret efirc EFI status code
301  */
302 static EFI_STATUS EFIAPI
304  EFI_HANDLE device, UINTN num_children,
305  EFI_HANDLE *children ) {
306  struct efi_driver *efidrv;
307  struct efi_device *efidev;
308  struct efi_saved_tpl tpl;
309  UINTN i;
310 
311  DBGC ( device, "EFIDRV %s DRIVER_STOP", efi_handle_name ( device ) );
312  for ( i = 0 ; i < num_children ; i++ ) {
313  DBGC ( device, "%s%s", ( i ? ", " : " child " ),
314  efi_handle_name ( children[i] ) );
315  }
316  DBGC ( device, "\n" );
317 
318  /* Do nothing unless we are driving this device */
319  efidev = efidev_find ( device );
320  if ( ! efidev ) {
321  DBGCP ( device, "EFIDRV %s is not started\n",
322  efi_handle_name ( device ) );
323  return EFI_DEVICE_ERROR;
324  }
325 
326  /* Raise TPL */
327  efi_raise_tpl ( &tpl );
328 
329  /* Stop this device */
330  efidrv = efidev->driver;
331  assert ( efidrv != NULL );
332  efidrv->stop ( efidev );
333  efidev_free ( efidev );
334 
335  efi_restore_tpl ( &tpl );
336  return 0;
337 }
338 
339 /** EFI driver binding protocol */
342  .Start = efi_driver_start,
343  .Stop = efi_driver_stop,
344 };
345 
346 /**
347  * Look up driver name
348  *
349  * @v wtf Component name protocol
350  * @v language Language to use
351  * @v driver_name Driver name to fill in
352  * @ret efirc EFI status code
353  */
354 static EFI_STATUS EFIAPI
356  CHAR8 *language __unused, CHAR16 **driver_name ) {
357  const wchar_t *name;
358 
360  *driver_name = ( ( wchar_t * ) name );
361  return 0;
362 }
363 
364 /**
365  * Look up controller name
366  *
367  * @v wtf Component name protocol
368  * @v device Device
369  * @v child Child device, or NULL
370  * @v language Language to use
371  * @v driver_name Device name to fill in
372  * @ret efirc EFI status code
373  */
374 static EFI_STATUS EFIAPI
377  CHAR8 *language, CHAR16 **controller_name ) {
379  union {
381  void *interface;
382  } name2;
383  EFI_STATUS efirc;
384 
385  /* Delegate to the EFI_COMPONENT_NAME2_PROTOCOL instance
386  * installed on child handle, if present.
387  */
388  if ( ( child != NULL ) &&
389  ( ( efirc = bs->OpenProtocol (
391  &name2.interface, NULL, NULL,
392  EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) == 0 ) ) {
393  return name2.name2->GetControllerName ( name2.name2, device,
394  child, language,
395  controller_name );
396  }
397 
398  /* Otherwise, let EFI use the default Device Path Name */
399  return EFI_UNSUPPORTED;
400 }
401 
402 /** EFI component name protocol */
405  .GetControllerName = efi_driver_controller_name,
406  .SupportedLanguages = "en",
407 };
408 
409 /**
410  * Install EFI driver
411  *
412  * @ret rc Return status code
413  */
414 int efi_driver_install ( void ) {
416  EFI_STATUS efirc;
417  int rc;
418 
419  /* Calculate driver version number. We use the build
420  * timestamp (in seconds since the Epoch) shifted right by six
421  * bits: this gives us an approximately one-minute resolution
422  * and a scheme which will last until the year 10680.
423  */
425 
426  /* Install protocols on image handle */
429  if ( ( efirc = bs->InstallMultipleProtocolInterfaces (
433  NULL ) ) != 0 ) {
434  rc = -EEFI ( efirc );
435  DBGC ( &efi_driver_binding, "EFIDRV could not install "
436  "protocols: %s\n", strerror ( rc ) );
437  return rc;
438  }
439 
440  return 0;
441 }
442 
443 /**
444  * Uninstall EFI driver
445  *
446  */
447 void efi_driver_uninstall ( void ) {
449 
450  /* Uninstall protocols */
455 }
456 
457 /**
458  * Try to connect EFI driver
459  *
460  * @v device EFI device
461  * @ret rc Return status code
462  */
465  EFI_HANDLE drivers[2] =
467  EFI_STATUS efirc;
468  int rc;
469 
470  /* Check if we want to drive this device */
472  NULL ) ) != 0 ) {
473  /* Not supported; not an error */
474  return 0;
475  }
476 
477  /* Disconnect any existing drivers */
478  DBGC2 ( device, "EFIDRV %s before disconnecting:\n",
479  efi_handle_name ( device ) );
481  DBGC ( device, "EFIDRV %s disconnecting existing drivers\n",
482  efi_handle_name ( device ) );
484  if ( ( efirc = bs->DisconnectController ( device, NULL,
485  NULL ) ) != 0 ) {
486  rc = -EEFI ( efirc );
487  DBGC ( device, "EFIDRV %s could not disconnect existing "
488  "drivers: %s\n", efi_handle_name ( device ),
489  strerror ( rc ) );
490  /* Ignore the error and attempt to connect our drivers */
491  }
493  DBGC2 ( device, "EFIDRV %s after disconnecting:\n",
494  efi_handle_name ( device ) );
496 
497  /* Connect our driver */
498  DBGC ( device, "EFIDRV %s connecting new drivers\n",
499  efi_handle_name ( device ) );
500  if ( ( efirc = bs->ConnectController ( device, drivers, NULL,
501  TRUE ) ) != 0 ) {
502  rc = -EEFI_CONNECT ( efirc );
503  DBGC ( device, "EFIDRV %s could not connect new drivers: "
504  "%s\n", efi_handle_name ( device ), strerror ( rc ) );
505  DBGC ( device, "EFIDRV %s connecting driver directly\n",
506  efi_handle_name ( device ) );
507  if ( ( efirc = efi_driver_start ( &efi_driver_binding, device,
508  NULL ) ) != 0 ) {
509  rc = -EEFI_CONNECT ( efirc );
510  DBGC ( device, "EFIDRV %s could not connect driver "
511  "directly: %s\n", efi_handle_name ( device ),
512  strerror ( rc ) );
513  return rc;
514  }
515  }
516  DBGC2 ( device, "EFIDRV %s after connecting:\n",
517  efi_handle_name ( device ) );
519 
520  return 0;
521 }
522 
523 /**
524  * Try to disconnect EFI driver
525  *
526  * @v device EFI device
527  * @ret rc Return status code
528  */
531 
532  /* Disconnect our driver */
536  NULL );
538  return 0;
539 }
540 
541 /**
542  * Reconnect original EFI driver
543  *
544  * @v device EFI device
545  * @ret rc Return status code
546  */
549 
550  /* Reconnect any available driver */
552 
553  return 0;
554 }
555 
556 /**
557  * Connect/disconnect EFI driver from all handles
558  *
559  * @v method Connect/disconnect method
560  * @ret rc Return status code
561  */
562 static int efi_driver_handles ( int ( * method ) ( EFI_HANDLE handle ) ) {
564  EFI_HANDLE *handles;
565  UINTN num_handles;
566  EFI_STATUS efirc;
567  UINTN i;
568  int rc;
569 
570  /* Enumerate all handles */
571  if ( ( efirc = bs->LocateHandleBuffer ( AllHandles, NULL, NULL,
572  &num_handles,
573  &handles ) ) != 0 ) {
574  rc = -EEFI ( efirc );
575  DBGC ( &efi_driver_binding, "EFIDRV could not list handles: "
576  "%s\n", strerror ( rc ) );
577  goto err_locate;
578  }
579 
580  /* Connect/disconnect driver from all handles */
581  for ( i = 0 ; i < num_handles ; i++ ) {
582  if ( ( rc = method ( handles[i] ) ) != 0 ) {
583  /* Ignore errors and continue to process
584  * remaining handles.
585  */
586  }
587  }
588 
589  /* Success */
590  rc = 0;
591 
592  bs->FreePool ( handles );
593  err_locate:
594  return rc;
595 }
596 
597 /**
598  * Connect EFI driver to all possible devices
599  *
600  * @ret rc Return status code
601  */
603 
604  DBGC ( &efi_driver_binding, "EFIDRV connecting our drivers\n" );
606 }
607 
608 /**
609  * Disconnect EFI driver from all possible devices
610  *
611  * @ret rc Return status code
612  */
614 
615  DBGC ( &efi_driver_binding, "EFIDRV disconnecting our drivers\n" );
617 }
618 
619 /**
620  * Reconnect original EFI drivers to all possible devices
621  *
622  * @ret rc Return status code
623  */
625 
626  DBGC ( &efi_driver_binding, "EFIDRV reconnecting old drivers\n" );
628 }
int efi_driver_connect_all(void)
Connect EFI driver to all possible devices.
Definition: efi_driver.c:602
void efi_driver_uninstall(void)
Uninstall EFI driver.
Definition: efi_driver.c:447
UEFI DriverBinding Protocol is defined in UEFI specification.
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
#define EFI_UNSUPPORTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:117
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
static int efi_driver_connect(EFI_HANDLE device)
Try to connect EFI driver.
Definition: efi_driver.c:463
static EFI_STATUS EFIAPI efi_driver_name(EFI_COMPONENT_NAME2_PROTOCOL *wtf __unused, CHAR8 *language __unused, CHAR16 **driver_name)
Look up driver name.
Definition: efi_driver.c:355
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:171
struct efi_driver * driver
Driver for this device.
Definition: efi_driver.h:27
#define EFI_ALREADY_STARTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:134
The device path protocol as defined in UEFI 2.0.
This protocol is used to retrieve user readable names of drivers and controllers managed by UEFI Driv...
EFI driver interface.
FILE_LICENCE(GPL2_OR_LATER)
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
Error codes.
Retrieve all the handles in the handle database.
Definition: UefiSpec.h:1511
void efi_raise_tpl(struct efi_saved_tpl *tpl)
Raise task priority level to internal level.
Definition: efi_init.c:399
EFI_DRIVER_BINDING_SUPPORTED Supported
EFI strings.
static EFI_STATUS EFIAPI efi_driver_controller_name(EFI_COMPONENT_NAME2_PROTOCOL *wtf __unused, EFI_HANDLE device, EFI_HANDLE child, CHAR8 *language, CHAR16 **controller_name)
Look up controller name.
Definition: efi_driver.c:375
void(* stop)(struct efi_device *efidev)
Detach driver from device.
Definition: efi_driver.h:55
void efidev_free(struct efi_device *efidev)
Free EFI device.
Definition: efi_driver.c:118
static int efi_driver_disconnecting
We are currently disconnecting drivers.
Definition: efi_driver.c:62
static struct efi_device * efidev_find(EFI_HANDLE device)
Find EFI device.
Definition: efi_driver.c:131
#define DBGC(...)
Definition: compiler.h:505
static LIST_HEAD(efi_devices)
List of controlled EFI devices.
EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1996
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_path.c:144
unsigned short CHAR16
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
uint8_t method
Definition: ib_mad.h:14
uint16_t device
Device ID.
Definition: ena.h:24
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1987
struct device * parent
Bus device.
Definition: device.h:85
#define EFI_OUT_OF_RESOURCES
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:123
int(* supported)(EFI_HANDLE device)
Check if driver supports device.
Definition: efi_driver.h:42
#define EFI_DEVICE_ERROR
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:121
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
static EFI_STATUS EFIAPI efi_driver_supported(EFI_DRIVER_BINDING_PROTOCOL *driver __unused, EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *child)
Check to see if driver supports a device.
Definition: efi_driver.c:180
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
EFI_HANDLE child
EFI child device handle (if present)
Definition: efi_driver.h:23
const wchar_t product_wname[]
Wide-character product name string.
Definition: version.c:85
A hardware device.
Definition: device.h:73
char unsigned long const char unsigned long char ** children
Definition: xenstore.h:25
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void efi_driver_reconnect_all(void)
Reconnect original EFI drivers to all possible devices.
Definition: efi_driver.c:624
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
char wtf[42]
Authenticator response string.
Definition: mschapv2.h:18
An object interface.
Definition: interface.h:124
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
UEFI Component Name 2 Protocol as defined in the UEFI 2.1 specification.
EFI_COMPONENT_NAME2_GET_DRIVER_NAME GetDriverName
struct efi_device * efidev_alloc(EFI_HANDLE device)
Allocate new EFI device.
Definition: efi_driver.c:70
static EFI_STATUS EFIAPI efi_driver_start(EFI_DRIVER_BINDING_PROTOCOL *driver __unused, EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *child)
Attach driver to device.
Definition: efi_driver.c:221
const char * efi_devpath_text(EFI_DEVICE_PATH_PROTOCOL *path)
Get textual representation of device path.
Definition: efi_debug.c:461
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL
Definition: UefiSpec.h:1344
unsigned long build_timestamp
Build timestamp.
Definition: version.c:58
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:808
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
#define EFIAPI
static int efi_driver_reconnect(EFI_HANDLE device)
Reconnect original EFI driver.
Definition: efi_driver.c:547
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
EFI Boot Services Table.
Definition: UefiSpec.h:1917
static int efi_driver_handles(int(*method)(EFI_HANDLE handle))
Connect/disconnect EFI driver from all handles.
Definition: efi_driver.c:562
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:34
EFI_HANDLE DriverBindingHandle
The handle on which this instance of the EFI_DRIVER_BINDING_PROTOCOL is installed.
struct list_head siblings
Devices on the same bus.
Definition: device.h:81
void efi_driver_disconnect_all(void)
Disconnect EFI driver from all possible devices.
Definition: efi_driver.c:613
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:385
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1997
EFI_CONNECT_CONTROLLER ConnectController
Definition: UefiSpec.h:1980
#define EEFI_CONNECT(efirc)
Definition: efi_driver.c:53
EFI device paths.
UINT64 UINTN
Unsigned value of native width.
#define EFI_NOT_READY
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:120
An EFI device.
Definition: efi_driver.h:17
This protocol provides the services required to determine if a driver supports a given controller.
EFI_GUID efi_device_path_protocol_guid
Device path protocol GUID.
Definition: efi_guid.c:143
Version number.
EFI_GUID efi_component_name2_protocol_guid
Component name 2 protocol GUID.
Definition: efi_guid.c:135
#define BUS_TYPE_EFI
EFI bus type.
Definition: device.h:61
EFI_HANDLE ImageHandle
The image handle of the UEFI driver that produced this instance of the EFI_DRIVER_BINDING_PROTOCOL.
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1936
#define TRUE
Definition: tlan.h:46
EFI API.
const wchar_t build_wname[]
Wide-character build name string.
Definition: version.c:91
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
An EFI driver.
Definition: efi_driver.h:33
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
unsigned int bus_type
Bus type.
Definition: device.h:24
An EFI saved task priority level.
Definition: efi.h:76
#define DBGC2(...)
Definition: compiler.h:522
static EFI_DRIVER_BINDING_PROTOCOL efi_driver_binding
EFI driver binding protocol.
Definition: efi_driver.c:56
char CHAR8
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
struct list_head children
Devices attached to this device.
Definition: device.h:83
#define DBGC2_EFI_PROTOCOLS(...)
Definition: efi.h:334
static EFI_STATUS EFIAPI efi_driver_stop(EFI_DRIVER_BINDING_PROTOCOL *driver __unused, EFI_HANDLE device, UINTN num_children, EFI_HANDLE *children)
Detach driver from device.
Definition: efi_driver.c:303
const char * name
Name.
Definition: efi_driver.h:35
struct device_description desc
Device description.
Definition: device.h:79
#define DBGCP(...)
Definition: compiler.h:539
static int efi_driver_disconnect(EFI_HANDLE device)
Try to disconnect EFI driver.
Definition: efi_driver.c:529
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1986
EFI_DEVICE_PATH_PROTOCOL * path
EFI device path copy.
Definition: efi_driver.h:25
struct efi_device * efidev_parent(struct device *dev)
Get parent EFI device.
Definition: efi_driver.c:155
static EFI_COMPONENT_NAME2_PROTOCOL efi_wtf
EFI component name protocol.
Definition: efi_driver.c:403
#define EFI_DRIVERS
EFI driver table.
Definition: efi_driver.h:59
struct device dev
Generic device.
Definition: efi_driver.h:19
uint16_t handle
Handle.
Definition: smbios.h:16
EFI_GUID efi_driver_binding_protocol_guid
Driver binding protocol GUID.
Definition: efi_guid.c:183
void efi_restore_tpl(struct efi_saved_tpl *tpl)
Restore task priority level.
Definition: efi_init.c:415
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
String functions.
int efi_driver_install(void)
Install EFI driver.
Definition: efi_driver.c:414
Definition: efi.h:59
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
Definition: UefiSpec.h:1994
int(* start)(struct efi_device *efidev)
Attach driver to device.
Definition: efi_driver.h:49
UINT32 Version
The version number of the UEFI driver that produced the EFI_DRIVER_BINDING_PROTOCOL.
EFI_DISCONNECT_CONTROLLER DisconnectController
Definition: UefiSpec.h:1981