iPXE
Functions | Variables
device.c File Reference

Device model. More...

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

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
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 booting __unused)
 Remove all devices.
struct startup_fn startup_devices __startup_fn (STARTUP_NORMAL)
struct deviceidentify_device (struct interface *intf)
 Identify a device behind an interface.

Variables

int device_keep_count = 0
 Device removal inhibition counter.

Detailed Description

Device model.

Definition in file device.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static LIST_HEAD ( devices  ) [static]

Registered root devices.

static int rootdev_probe ( struct root_device rootdev) [static]

Probe a root device.

Parameters:
rootdevRoot device
Return values:
rcReturn status code

Definition at line 52 of file device.c.

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

Referenced by probe_devices().

                                                         {
        int rc;

        DBG ( "Adding %s root bus\n", rootdev->dev.name );
        if ( ( rc = rootdev->driver->probe ( rootdev ) ) != 0 ) {
                DBG ( "Failed to add %s root bus: %s\n",
                      rootdev->dev.name, strerror ( rc ) );
                return rc;
        }

        return 0;
}
static void rootdev_remove ( struct root_device rootdev) [static]

Remove a root device.

Parameters:
rootdevRoot device

Definition at line 70 of file device.c.

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

Referenced by remove_devices().

                                                           {
        rootdev->driver->remove ( rootdev );
        DBG ( "Removed %s root bus\n", rootdev->dev.name );
}
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 82 of file device.c.

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

                                   {
        struct root_device *rootdev;
        int rc;

        for_each_table_entry ( rootdev, ROOT_DEVICES ) {
                list_add ( &rootdev->dev.siblings, &devices );
                INIT_LIST_HEAD ( &rootdev->dev.children );
                if ( ( rc = rootdev_probe ( rootdev ) ) != 0 )
                        list_del ( &rootdev->dev.siblings );
        }
}
static void remove_devices ( int booting  __unused) [static]

Remove all devices.

Definition at line 98 of file device.c.

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

                                                    {
        struct root_device *rootdev;
        struct root_device *tmp;

        if ( device_keep_count != 0 ) {
                DBG ( "Refusing to remove devices on shutdown\n" );
                return;
        }

        list_for_each_entry_safe ( rootdev, tmp, &devices, dev.siblings ) {
                rootdev_remove ( rootdev );
                list_del ( &rootdev->dev.siblings );
        }
}
struct startup_fn startup_devices __startup_fn ( STARTUP_NORMAL  ) [read]
struct device* identify_device ( struct interface intf) [read]

Identify a device behind an interface.

Parameters:
intfInterface
Return values:
deviceDevice, or NULL

Definition at line 124 of file device.c.

References dest, device, identify_device(), identify_device_TYPE, intf_get_dest_op, intf_object(), intf_put(), NULL, and op.

Referenced by fcpdev_identify_device(), identify_device(), and int13_device_path_info().

                                                           {
        struct interface *dest;
        identify_device_TYPE ( void * ) *op =
                intf_get_dest_op ( intf, identify_device, &dest );
        void *object = intf_object ( dest );
        void *device;

        if ( op ) {
                device = op ( object );
        } else {
                /* Default is to return NULL */
                device = NULL;
        }

        intf_put ( dest );
        return device;
}

Variable Documentation

Device removal inhibition counter.

Definition at line 44 of file device.c.

Referenced by devices_get(), devices_put(), and remove_devices().