#include <stddef.h>
#include <string.h>
#include <assert.h>
+#include <errno.h>
#include <byteswap.h>
#include <gpxe/blockdev.h>
+#include <gpxe/process.h>
#include <gpxe/ata.h>
/** @file
*/
static inline __attribute__ (( always_inline )) int
ata_command ( struct ata_device *ata, struct ata_command *command ) {
+ int rc;
+
DBG ( "ATA cmd %02x dev %02x LBA%s %llx count %04x\n",
command->cb.cmd_stat, command->cb.device,
( command->cb.lba48 ? "48" : "" ),
( unsigned long long ) command->cb.lba.native,
command->cb.count.native );
- return ata->command ( ata, command );
+ /* Flag command as in-progress */
+ command->rc = -EINPROGRESS;
+
+ /* Issue ATA command */
+ if ( ( rc = ata->command ( ata, command ) ) != 0 ) {
+ /* Something went wrong with the issuing mechanism */
+ DBG ( "ATA could not issue command: %s\n", strerror ( rc ) );
+ return rc;
+ }
+
+ /* Wait for command to complete */
+ while ( command->rc == -EINPROGRESS )
+ step();
+ if ( ( rc = command->rc ) != 0 ) {
+ /* Something went wrong with the command execution */
+ DBG ( "ATA command failed: %s\n", strerror ( rc ) );
+ return rc;
+ }
+
+ return 0;
}
/**
#define ERRFILE_arbel ( ERRFILE_DRIVER | 0x00710000 )
#define ERRFILE_hermon ( ERRFILE_DRIVER | 0x00720000 )
#define ERRFILE_linda ( ERRFILE_DRIVER | 0x00730000 )
+#define ERRFILE_ata ( ERRFILE_DRIVER | 0x00740000 )
#define ERRFILE_aoe ( ERRFILE_NET | 0x00000000 )
#define ERRFILE_arp ( ERRFILE_NET | 0x00010000 )
/* Record overall command status */
if ( aoe->command ) {
aoe->command->cb.cmd_stat = aoe->status;
+ aoe->command->rc = rc;
aoe->command = NULL;
}
struct ata_command *command ) {
struct aoe_session *aoe =
container_of ( ata->backend, struct aoe_session, refcnt );
- int rc;
aoe->command = command;
aoe->status = 0;
aoe_send_command ( aoe );
- aoe->rc = -EINPROGRESS;
- while ( aoe->rc == -EINPROGRESS )
- step();
- rc = aoe->rc;
-
- return rc;
+ return 0;
}
-
/**
* Issue AoE config query for AoE target discovery
*