aboutsummaryrefslogtreecommitdiff
path: root/src/include/ipxe/scsi.h
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2010-09-03 16:11:51 +0100
committerMichael Brown <mcb30@ipxe.org>2010-09-14 20:37:15 +0100
commit220495f8bf2222e1dc1aa7db554d23997b545546 (patch)
treef04aa0d123a0b643fc41e178db81cfe63ba913bf /src/include/ipxe/scsi.h
parent46c7f99c66e18bf1735a68ada35aa963c979d59b (diff)
downloadipxe-220495f8bf2222e1dc1aa7db554d23997b545546.zip
ipxe-220495f8bf2222e1dc1aa7db554d23997b545546.tar.gz
ipxe-220495f8bf2222e1dc1aa7db554d23997b545546.tar.bz2
[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>
Diffstat (limited to 'src/include/ipxe/scsi.h')
-rw-r--r--src/include/ipxe/scsi.h100
1 files changed, 57 insertions, 43 deletions
diff --git a/src/include/ipxe/scsi.h b/src/include/ipxe/scsi.h
index b56ab75..b90aa3a 100644
--- a/src/include/ipxe/scsi.h
+++ b/src/include/ipxe/scsi.h
@@ -2,9 +2,8 @@
#define _IPXE_SCSI_H
#include <stdint.h>
-#include <ipxe/blockdev.h>
#include <ipxe/uaccess.h>
-#include <ipxe/refcnt.h>
+#include <ipxe/interface.h>
/** @file
*
@@ -14,6 +13,9 @@
FILE_LICENCE ( GPL2_OR_LATER );
+/** Maximum block for READ/WRITE (10) commands */
+#define SCSI_MAX_BLOCK_10 0xffffffffULL
+
/**
* @defgroup scsiops SCSI operation codes
* @{
@@ -214,8 +216,27 @@ union scsi_cdb {
/** @} */
-/** A SCSI command */
-struct scsi_command {
+/** A SCSI LUN
+ *
+ * This is a four-level LUN as specified by SAM-2, in big-endian
+ * order.
+ */
+struct scsi_lun {
+ uint16_t u16[4];
+} __attribute__ (( packed ));
+
+/** printf() format for dumping a scsi_lun */
+#define SCSI_LUN_FORMAT "%04x-%04x-%04x-%04x"
+
+/** printf() parameters for dumping a scsi_lun */
+#define SCSI_LUN_DATA(lun) \
+ ntohs ( (lun).u16[0] ), ntohs ( (lun).u16[1] ), \
+ ntohs ( (lun).u16[2] ), ntohs ( (lun).u16[3] )
+
+/** A SCSI command information unit */
+struct scsi_cmd {
+ /** LUN */
+ struct scsi_lun lun;
/** CDB for this command */
union scsi_cdb cdb;
/** Data-out buffer (may be NULL) */
@@ -232,50 +253,43 @@ struct scsi_command {
* Must be zero if @c data_in is NULL
*/
size_t data_in_len;
- /** SCSI status code */
- uint8_t status;
- /** SCSI sense response code */
- uint8_t sense_response;
- /** Command status code */
- int rc;
};
-/** A SCSI LUN
- *
- * This is a four-level LUN as specified by SAM-2, in big-endian
- * order.
- */
-struct scsi_lun {
- uint16_t u16[4];
-} __attribute__ (( packed ));
+/** SCSI sense data */
+struct scsi_sns {
+ /** Response code */
+ uint8_t code;
+ /** Reserved */
+ uint8_t reserved;
+ /** Sense key */
+ uint8_t key;
+ /** Information */
+ uint32_t info;
+};
-/** A SCSI device */
-struct scsi_device {
- /** Block device interface */
- struct block_device blockdev;
- /**
- * Issue SCSI command
- *
- * @v scsi SCSI device
- * @v command SCSI command
- * @ret rc Return status code
- *
- * Note that a successful return status code indicates only
- * that the SCSI command was issued. The caller must check
- * the status field in the command structure to see when the
- * command completes and whether, for example, the device
- * returned CHECK CONDITION or some other non-success status
- * code.
- */
- int ( * command ) ( struct scsi_device *scsi,
- struct scsi_command *command );
- /** Backing device */
- struct refcnt *backend;
+/** A SCSI response information unit */
+struct scsi_rsp {
+ /** SCSI status code */
+ uint8_t status;
+ /** Data overrun (or negative underrun) */
+ ssize_t overrun;
+ /** Autosense data (if any) */
+ struct scsi_sns sense;
};
-extern int scsi_detached_command ( struct scsi_device *scsi,
- struct scsi_command *command );
-extern int init_scsidev ( struct scsi_device *scsi );
extern int scsi_parse_lun ( const char *lun_string, struct scsi_lun *lun );
+extern int scsi_command ( struct interface *control, struct interface *data,
+ struct scsi_cmd *command );
+#define scsi_command_TYPE( object_type ) \
+ typeof ( int ( object_type, struct interface *data, \
+ struct scsi_cmd *command ) )
+
+extern void scsi_response ( struct interface *intf, struct scsi_rsp *response );
+#define scsi_response_TYPE( object_type ) \
+ typeof ( void ( object_type, struct scsi_rsp *response ) )
+
+extern int scsi_open ( struct interface *block, struct interface *scsi,
+ struct scsi_lun *lun );
+
#endif /* _IPXE_SCSI_H */