device.c File Reference

Device model. More...

#include <string.h>
#include <gpxe/list.h>
#include <gpxe/tables.h>
#include <gpxe/device.h>
#include <gpxe/init.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
static LIST_HEAD (devices)
 Registered root devices.
static int rootdev_probe (struct root_device *rootdev)
 Probe a root device.
static void rootdev_remove (struct root_device *rootdev)
 Remove a root device.
static void probe_devices (void)
 Probe all devices.
static void remove_devices (int flags)
 Remove all devices.
struct startup_fn startup_devices __startup_fn (STARTUP_NORMAL)


Detailed Description

Device model.

Definition in file device.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

static LIST_HEAD ( devices   )  [static]

Registered root devices.

static int rootdev_probe ( struct root_device rootdev  )  [static]

Probe a root device.

Parameters:
rootdev Root device
Return values:
rc Return status code

Definition at line 43 of file device.c.

References DBG, root_device::dev, root_device::driver, device::name, root_driver::probe, and strerror().

Referenced by probe_devices().

00043                                                          {
00044         int rc;
00045 
00046         DBG ( "Adding %s root bus\n", rootdev->dev.name );
00047         if ( ( rc = rootdev->driver->probe ( rootdev ) ) != 0 ) {
00048                 DBG ( "Failed to add %s root bus: %s\n",
00049                       rootdev->dev.name, strerror ( rc ) );
00050                 return rc;
00051         }
00052 
00053         return 0;
00054 }

static void rootdev_remove ( struct root_device rootdev  )  [static]

Remove a root device.

Parameters:
rootdev Root device

Definition at line 61 of file device.c.

References DBG, root_device::dev, root_device::driver, device::name, and root_driver::remove.

Referenced by remove_devices().

00061                                                            {
00062         rootdev->driver->remove ( rootdev );
00063         DBG ( "Removed %s root bus\n", rootdev->dev.name );
00064 }

static void probe_devices ( void   )  [static]

Probe all devices.

This initiates probing for all devices in the system. After this call, the device hierarchy will be populated, and all hardware should be ready to use.

Definition at line 73 of file device.c.

References device::children, root_device::dev, for_each_table_entry, INIT_LIST_HEAD, list_add, list_del, ROOT_DEVICES, rootdev_probe(), and device::siblings.

00073                                    {
00074         struct root_device *rootdev;
00075         int rc;
00076 
00077         for_each_table_entry ( rootdev, ROOT_DEVICES ) {
00078                 list_add ( &rootdev->dev.siblings, &devices );
00079                 INIT_LIST_HEAD ( &rootdev->dev.children );
00080                 if ( ( rc = rootdev_probe ( rootdev ) ) != 0 )
00081                         list_del ( &rootdev->dev.siblings );
00082         }
00083 }

static void remove_devices ( int  flags  )  [static]

Remove all devices.

Definition at line 89 of file device.c.

References DBG, root_device::dev, list_del, list_for_each_entry_safe, rootdev_remove(), SHUTDOWN_KEEP_DEVICES, and device::siblings.

00089                                          {
00090         struct root_device *rootdev;
00091         struct root_device *tmp;
00092 
00093         if ( flags & SHUTDOWN_KEEP_DEVICES ) {
00094                 DBG ( "Refusing to remove devices on shutdown\n" );
00095                 return;
00096         }
00097 
00098         list_for_each_entry_safe ( rootdev, tmp, &devices, dev.siblings ) {
00099                 rootdev_remove ( rootdev );
00100                 list_del ( &rootdev->dev.siblings );
00101         }
00102 }

struct startup_fn startup_devices __startup_fn ( STARTUP_NORMAL   )  [read]


Generated on Tue Apr 6 20:01:14 2010 for gPXE by  doxygen 1.5.7.1