2010-04-19 21:16:01 +02:00
|
|
|
#ifndef _IPXE_SANBOOT_H
|
|
|
|
#define _IPXE_SANBOOT_H
|
2008-10-13 11:05:23 +02:00
|
|
|
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
/** @file
|
|
|
|
*
|
|
|
|
* iPXE sanboot API
|
|
|
|
*
|
|
|
|
* The sanboot API provides methods for hooking, unhooking,
|
|
|
|
* describing, and booting from SAN devices.
|
|
|
|
*/
|
|
|
|
|
2015-03-02 12:54:40 +01:00
|
|
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
2009-05-01 16:41:06 +02:00
|
|
|
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
#include <ipxe/api.h>
|
2017-03-04 19:43:07 +01:00
|
|
|
#include <ipxe/refcnt.h>
|
|
|
|
#include <ipxe/list.h>
|
|
|
|
#include <ipxe/uri.h>
|
|
|
|
#include <ipxe/retry.h>
|
2017-03-26 14:12:11 +02:00
|
|
|
#include <ipxe/process.h>
|
2017-03-04 19:43:07 +01:00
|
|
|
#include <ipxe/blockdev.h>
|
2017-03-27 17:20:34 +02:00
|
|
|
#include <ipxe/acpi.h>
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
#include <config/sanboot.h>
|
|
|
|
|
2017-03-26 14:12:11 +02:00
|
|
|
/** A SAN path */
|
|
|
|
struct san_path {
|
|
|
|
/** Containing SAN device */
|
|
|
|
struct san_device *sandev;
|
|
|
|
/** Path index */
|
|
|
|
unsigned int index;
|
|
|
|
/** SAN device URI */
|
|
|
|
struct uri *uri;
|
|
|
|
/** List of open/closed paths */
|
|
|
|
struct list_head list;
|
|
|
|
|
|
|
|
/** Underlying block device interface */
|
|
|
|
struct interface block;
|
|
|
|
/** Process */
|
|
|
|
struct process process;
|
|
|
|
/** Path status */
|
|
|
|
int path_rc;
|
2017-03-27 17:20:34 +02:00
|
|
|
|
|
|
|
/** ACPI descriptor (if applicable) */
|
|
|
|
struct acpi_descriptor *desc;
|
2017-03-26 14:12:11 +02:00
|
|
|
};
|
|
|
|
|
2017-03-04 19:43:07 +01:00
|
|
|
/** A SAN device */
|
|
|
|
struct san_device {
|
|
|
|
/** Reference count */
|
|
|
|
struct refcnt refcnt;
|
|
|
|
/** List of SAN devices */
|
|
|
|
struct list_head list;
|
|
|
|
|
|
|
|
/** Drive number */
|
|
|
|
unsigned int drive;
|
2017-03-27 17:20:34 +02:00
|
|
|
/** Flags */
|
|
|
|
unsigned int flags;
|
2017-03-04 19:43:07 +01:00
|
|
|
|
|
|
|
/** Command interface */
|
|
|
|
struct interface command;
|
|
|
|
/** Command timeout timer */
|
|
|
|
struct retry_timer timer;
|
|
|
|
/** Command status */
|
|
|
|
int command_rc;
|
|
|
|
|
|
|
|
/** Raw block device capacity */
|
|
|
|
struct block_device_capacity capacity;
|
|
|
|
/** Block size shift
|
|
|
|
*
|
|
|
|
* To allow for emulation of CD-ROM access, this represents
|
|
|
|
* the left-shift required to translate from exposed logical
|
|
|
|
* I/O blocks to underlying blocks.
|
|
|
|
*/
|
|
|
|
unsigned int blksize_shift;
|
|
|
|
/** Drive is a CD-ROM */
|
|
|
|
int is_cdrom;
|
|
|
|
|
|
|
|
/** Driver private data */
|
|
|
|
void *priv;
|
2017-03-26 14:12:11 +02:00
|
|
|
|
2017-03-27 12:06:16 +02:00
|
|
|
/** Number of paths */
|
|
|
|
unsigned int paths;
|
2017-03-26 14:12:11 +02:00
|
|
|
/** Current active path */
|
|
|
|
struct san_path *active;
|
|
|
|
/** List of opened SAN paths */
|
|
|
|
struct list_head opened;
|
|
|
|
/** List of closed SAN paths */
|
|
|
|
struct list_head closed;
|
|
|
|
/** SAN paths */
|
|
|
|
struct san_path path[0];
|
2017-03-04 19:43:07 +01:00
|
|
|
};
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
|
2017-03-27 17:20:34 +02:00
|
|
|
/** SAN device flags */
|
|
|
|
enum san_device_flags {
|
|
|
|
/** Device should not be included in description tables */
|
|
|
|
SAN_NO_DESCRIBE = 0x0001,
|
|
|
|
};
|
|
|
|
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
/**
|
|
|
|
* Calculate static inline sanboot API function name
|
|
|
|
*
|
|
|
|
* @v _prefix Subsystem prefix
|
|
|
|
* @v _api_func API function
|
|
|
|
* @ret _subsys_func Subsystem API function
|
|
|
|
*/
|
|
|
|
#define SANBOOT_INLINE( _subsys, _api_func ) \
|
|
|
|
SINGLE_API_INLINE ( SANBOOT_PREFIX_ ## _subsys, _api_func )
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Provide a sanboot API implementation
|
|
|
|
*
|
|
|
|
* @v _prefix Subsystem prefix
|
|
|
|
* @v _api_func API function
|
|
|
|
* @v _func Implementing function
|
|
|
|
*/
|
|
|
|
#define PROVIDE_SANBOOT( _subsys, _api_func, _func ) \
|
|
|
|
PROVIDE_SINGLE_API ( SANBOOT_PREFIX_ ## _subsys, _api_func, _func )
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Provide a static inline sanboot API implementation
|
|
|
|
*
|
|
|
|
* @v _prefix Subsystem prefix
|
|
|
|
* @v _api_func API function
|
|
|
|
*/
|
|
|
|
#define PROVIDE_SANBOOT_INLINE( _subsys, _api_func ) \
|
|
|
|
PROVIDE_SINGLE_API_INLINE ( SANBOOT_PREFIX_ ## _subsys, _api_func )
|
|
|
|
|
|
|
|
/* Include all architecture-independent sanboot API headers */
|
|
|
|
#include <ipxe/null_sanboot.h>
|
2017-03-26 14:42:52 +02:00
|
|
|
#include <ipxe/dummy_sanboot.h>
|
2016-11-16 23:22:22 +01:00
|
|
|
#include <ipxe/efi/efi_block.h>
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
|
|
|
|
/* Include all architecture-dependent sanboot API headers */
|
|
|
|
#include <bits/sanboot.h>
|
2008-10-13 11:05:23 +02:00
|
|
|
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
/**
|
|
|
|
* Hook SAN device
|
|
|
|
*
|
2011-04-23 10:50:38 +02:00
|
|
|
* @v drive Drive number
|
2017-03-26 14:12:11 +02:00
|
|
|
* @v uris List of URIs
|
|
|
|
* @v count Number of URIs
|
2017-03-27 17:20:34 +02:00
|
|
|
* @v flags Flags
|
2016-03-20 10:16:13 +01:00
|
|
|
* @ret drive Drive number, or negative error
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
*/
|
2017-03-27 17:20:34 +02:00
|
|
|
int san_hook ( unsigned int drive, struct uri **uris, unsigned int count,
|
|
|
|
unsigned int flags );
|
2008-10-13 11:05:23 +02:00
|
|
|
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
/**
|
|
|
|
* Unhook SAN device
|
|
|
|
*
|
|
|
|
* @v drive Drive number
|
|
|
|
*/
|
|
|
|
void san_unhook ( unsigned int drive );
|
2009-03-12 20:41:40 +01:00
|
|
|
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
/**
|
|
|
|
* Attempt to boot from a SAN device
|
|
|
|
*
|
|
|
|
* @v drive Drive number
|
2017-04-12 16:03:25 +02:00
|
|
|
* @v filename Filename (or NULL to use default)
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
* @ret rc Return status code
|
|
|
|
*/
|
2017-04-12 16:03:25 +02:00
|
|
|
int san_boot ( unsigned int drive, const char *filename );
|
2008-10-13 11:05:23 +02:00
|
|
|
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
/**
|
2017-03-27 17:20:34 +02:00
|
|
|
* Describe SAN devices for SAN-booted operating system
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
*
|
|
|
|
* @ret rc Return status code
|
|
|
|
*/
|
2017-03-27 17:20:34 +02:00
|
|
|
int san_describe ( void );
|
2009-11-04 02:18:08 +01:00
|
|
|
|
2017-03-04 19:43:07 +01:00
|
|
|
extern struct list_head san_devices;
|
|
|
|
|
|
|
|
/** Iterate over all SAN devices */
|
|
|
|
#define for_each_sandev( sandev ) \
|
|
|
|
list_for_each_entry ( (sandev), &san_devices, list )
|
|
|
|
|
|
|
|
/** There exist some SAN devices
|
|
|
|
*
|
|
|
|
* @ret existence Existence of SAN devices
|
|
|
|
*/
|
|
|
|
static inline int have_sandevs ( void ) {
|
|
|
|
return ( ! list_empty ( &san_devices ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get reference to SAN device
|
|
|
|
*
|
|
|
|
* @v sandev SAN device
|
|
|
|
* @ret sandev SAN device
|
|
|
|
*/
|
|
|
|
static inline __attribute__ (( always_inline )) struct san_device *
|
|
|
|
sandev_get ( struct san_device *sandev ) {
|
|
|
|
ref_get ( &sandev->refcnt );
|
|
|
|
return sandev;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Drop reference to SAN device
|
|
|
|
*
|
|
|
|
* @v sandev SAN device
|
|
|
|
*/
|
|
|
|
static inline __attribute__ (( always_inline )) void
|
|
|
|
sandev_put ( struct san_device *sandev ) {
|
|
|
|
ref_put ( &sandev->refcnt );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate SAN device block size
|
|
|
|
*
|
|
|
|
* @v sandev SAN device
|
|
|
|
* @ret blksize Sector size
|
|
|
|
*/
|
|
|
|
static inline size_t sandev_blksize ( struct san_device *sandev ) {
|
|
|
|
return ( sandev->capacity.blksize << sandev->blksize_shift );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate SAN device capacity
|
|
|
|
*
|
|
|
|
* @v sandev SAN device
|
|
|
|
* @ret blocks Number of blocks
|
|
|
|
*/
|
|
|
|
static inline uint64_t sandev_capacity ( struct san_device *sandev ) {
|
|
|
|
return ( sandev->capacity.blocks >> sandev->blksize_shift );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if SAN device needs to be reopened
|
|
|
|
*
|
|
|
|
* @v sandev SAN device
|
|
|
|
* @ret needs_reopen SAN device needs to be reopened
|
|
|
|
*/
|
|
|
|
static inline int sandev_needs_reopen ( struct san_device *sandev ) {
|
2017-03-26 14:12:11 +02:00
|
|
|
return ( sandev->active == NULL );
|
2017-03-04 19:43:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
extern struct san_device * sandev_find ( unsigned int drive );
|
|
|
|
extern int sandev_reopen ( struct san_device *sandev );
|
|
|
|
extern int sandev_reset ( struct san_device *sandev );
|
|
|
|
extern int sandev_rw ( struct san_device *sandev, uint64_t lba,
|
|
|
|
unsigned int count, userptr_t buffer,
|
|
|
|
int ( * block_rw ) ( struct interface *control,
|
|
|
|
struct interface *data,
|
|
|
|
uint64_t lba, unsigned int count,
|
|
|
|
userptr_t buffer, size_t len ) );
|
2017-03-26 14:12:11 +02:00
|
|
|
extern struct san_device * alloc_sandev ( struct uri **uris, unsigned int count,
|
|
|
|
size_t priv_size );
|
2017-03-27 17:20:34 +02:00
|
|
|
extern int register_sandev ( struct san_device *sandev, unsigned int drive,
|
|
|
|
unsigned int flags );
|
2017-03-04 19:43:07 +01:00
|
|
|
extern void unregister_sandev ( struct san_device *sandev );
|
2017-03-06 13:25:20 +01:00
|
|
|
extern unsigned int san_default_drive ( void );
|
2017-03-04 19:43:07 +01:00
|
|
|
|
2010-04-19 21:16:01 +02:00
|
|
|
#endif /* _IPXE_SANBOOT_H */
|