diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/device.c | 27 | ||||
| -rw-r--r-- | src/core/edd.c | 56 |
2 files changed, 82 insertions, 1 deletions
diff --git a/src/core/device.c b/src/core/device.c index 1a227fd9c..cb2c23b0a 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -21,8 +21,9 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include <string.h> #include <ipxe/list.h> #include <ipxe/tables.h> -#include <ipxe/device.h> #include <ipxe/init.h> +#include <ipxe/interface.h> +#include <ipxe/device.h> /** * @file @@ -105,3 +106,27 @@ struct startup_fn startup_devices __startup_fn ( STARTUP_NORMAL ) = { .startup = probe_devices, .shutdown = remove_devices, }; + +/** + * Identify a device behind an interface + * + * @v intf Interface + * @ret device Device, or NULL + */ +struct device * identify_device ( struct interface *intf ) { + 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; +} diff --git a/src/core/edd.c b/src/core/edd.c new file mode 100644 index 000000000..8ba24b17f --- /dev/null +++ b/src/core/edd.c @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2010 Michael Brown <mbrown@fensystems.co.uk>. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +FILE_LICENCE ( GPL2_OR_LATER ); + +#include <errno.h> +#include <ipxe/interface.h> +#include <ipxe/edd.h> + +/** @file + * + * Enhanced Disk Drive specification + * + */ + +/** + * Describe a disk device using EDD + * + * @v intf Interface + * @v type EDD interface type + * @v path EDD device path + * @ret rc Return status code + */ +int edd_describe ( struct interface *intf, struct edd_interface_type *type, + union edd_device_path *path ) { + struct interface *dest; + edd_describe_TYPE ( void * ) *op = + intf_get_dest_op ( intf, edd_describe, &dest ); + void *object = intf_object ( dest ); + int rc; + + if ( op ) { + rc = op ( object, type, path ); + } else { + /* Default is to not support this operation */ + rc = -ENOTSUP; + } + + intf_put ( dest ); + return rc; +} |
