aboutsummaryrefslogtreecommitdiffstats
path: root/gpxe/src/drivers/block/ata.c
diff options
context:
space:
mode:
Diffstat (limited to 'gpxe/src/drivers/block/ata.c')
-rw-r--r--gpxe/src/drivers/block/ata.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/gpxe/src/drivers/block/ata.c b/gpxe/src/drivers/block/ata.c
index c21d2f65..dc851d72 100644
--- a/gpxe/src/drivers/block/ata.c
+++ b/gpxe/src/drivers/block/ata.c
@@ -16,11 +16,15 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#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
@@ -43,13 +47,34 @@ block_to_ata ( struct block_device *blockdev ) {
*/
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;
}
/**