|
@@ -21,8 +21,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
21
|
21
|
#include <stddef.h>
|
22
|
22
|
#include <string.h>
|
23
|
23
|
#include <assert.h>
|
|
24
|
+#include <errno.h>
|
24
|
25
|
#include <byteswap.h>
|
25
|
26
|
#include <gpxe/blockdev.h>
|
|
27
|
+#include <gpxe/process.h>
|
26
|
28
|
#include <gpxe/ata.h>
|
27
|
29
|
|
28
|
30
|
/** @file
|
|
@@ -45,13 +47,34 @@ block_to_ata ( struct block_device *blockdev ) {
|
45
|
47
|
*/
|
46
|
48
|
static inline __attribute__ (( always_inline )) int
|
47
|
49
|
ata_command ( struct ata_device *ata, struct ata_command *command ) {
|
|
50
|
+ int rc;
|
|
51
|
+
|
48
|
52
|
DBG ( "ATA cmd %02x dev %02x LBA%s %llx count %04x\n",
|
49
|
53
|
command->cb.cmd_stat, command->cb.device,
|
50
|
54
|
( command->cb.lba48 ? "48" : "" ),
|
51
|
55
|
( unsigned long long ) command->cb.lba.native,
|
52
|
56
|
command->cb.count.native );
|
53
|
57
|
|
54
|
|
- return ata->command ( ata, command );
|
|
58
|
+ /* Flag command as in-progress */
|
|
59
|
+ command->rc = -EINPROGRESS;
|
|
60
|
+
|
|
61
|
+ /* Issue ATA command */
|
|
62
|
+ if ( ( rc = ata->command ( ata, command ) ) != 0 ) {
|
|
63
|
+ /* Something went wrong with the issuing mechanism */
|
|
64
|
+ DBG ( "ATA could not issue command: %s\n", strerror ( rc ) );
|
|
65
|
+ return rc;
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ /* Wait for command to complete */
|
|
69
|
+ while ( command->rc == -EINPROGRESS )
|
|
70
|
+ step();
|
|
71
|
+ if ( ( rc = command->rc ) != 0 ) {
|
|
72
|
+ /* Something went wrong with the command execution */
|
|
73
|
+ DBG ( "ATA command failed: %s\n", strerror ( rc ) );
|
|
74
|
+ return rc;
|
|
75
|
+ }
|
|
76
|
+
|
|
77
|
+ return 0;
|
55
|
78
|
}
|
56
|
79
|
|
57
|
80
|
/**
|