summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--RedirectionConstants.h4
-rw-r--r--amtider.c8
-rw-r--r--ider.c16
-rw-r--r--redir.c3
4 files changed, 18 insertions, 13 deletions
diff --git a/RedirectionConstants.h b/RedirectionConstants.h
index 92fd95f..3b41c08 100644
--- a/RedirectionConstants.h
+++ b/RedirectionConstants.h
@@ -102,6 +102,10 @@
#define IDER_START_GRACEFUL 0x10
#define IDER_START_NOW 0x18
+/* IDER device types */
+#define IDER_DEVICE_FLOPPY 0xa0
+#define IDER_DEVICE_CDROM 0xb0
+
#define START_IDER_REDIRECTION_LENGTH 18
#define START_IDER_REDIRECTION_REPLY_LENGTH 30 //TODO: There is a OEM Defined data field that we are assuming to be 0 bytes..
#define END_IDER_REDIRECTION_LENGTH 8
diff --git a/amtider.c b/amtider.c
index abea4a5..d30676b 100644
--- a/amtider.c
+++ b/amtider.c
@@ -197,7 +197,7 @@ int main(int argc, char *argv[])
r.cb_data = &r;
r.cb_state = state_ider;
- r.device = 0xb0;
+ r.device = IDER_DEVICE_CDROM;
r.enable_options = IDER_START_NOW;
if (NULL != (h = getenv("AMT_PASSWORD")))
@@ -214,13 +214,13 @@ int main(int argc, char *argv[])
r.verbose = 0;
break;
case 'f':
- r.device = 0xa0;
+ r.device = IDER_DEVICE_FLOPPY;
break;
case 'u':
snprintf(r.user, sizeof(r.user), "%s", optarg);
break;
case 'c':
- r.device = 0xb0;
+ r.device = IDER_DEVICE_CDROM;
break;
case 'g':
r.enable_options = IDER_START_GRACEFUL;
@@ -293,7 +293,7 @@ int main(int argc, char *argv[])
perror("mmap");
exit(1);
}
- if (r.device == 0xa0) {
+ if (r.device == IDER_DEVICE_FLOPPY) {
r.lba_size = 512;
r.lba_shift = 9;
} else {
diff --git a/ider.c b/ider.c
index 946b96c..372a8d0 100644
--- a/ider.c
+++ b/ider.c
@@ -89,7 +89,7 @@ static int ider_packet_sense(struct redir *r,
msg.asq = asq;
}
return redir_write(r, (const char *)&msg, sizeof(msg));
-}
+}
static int ider_read_data(struct redir *r, unsigned char device, bool use_dma,
unsigned long lba, unsigned int count)
@@ -286,7 +286,7 @@ int ider_handle_command(struct redir *r, unsigned int seqno,
seqno, cdb[2], mode_len);
switch (cdb[2] & 0x3f) {
case 0x01:
- if (device == 0xa0) {
+ if (device == IDER_DEVICE_FLOPPY) {
if (lba < 0xb40)
mode_sense = ider_mode_page_01_floppy;
else
@@ -295,7 +295,7 @@ int ider_handle_command(struct redir *r, unsigned int seqno,
mode_sense = ider_mode_page_01_cdrom;
break;
case 0x05:
- if (device == 0xa0) {
+ if (device == IDER_DEVICE_FLOPPY) {
if (lba < 0xb40)
mode_sense = ider_mode_page_05_floppy;
else
@@ -303,7 +303,7 @@ int ider_handle_command(struct redir *r, unsigned int seqno,
}
break;
case 0x3f:
- if (device == 0xa0) {
+ if (device == IDER_DEVICE_FLOPPY) {
if (lba < 0xb40)
mode_sense = ider_mode_page_3f_floppy;
else
@@ -312,15 +312,15 @@ int ider_handle_command(struct redir *r, unsigned int seqno,
mode_sense = ider_mode_page_3f_cdrom;
break;
case 0x1a:
- if (device == 0xb0)
+ if (device == IDER_DEVICE_CDROM)
mode_sense = ider_mode_page_1a_cdrom;
break;
case 0x1d:
- if (device == 0xb0)
+ if (device == IDER_DEVICE_CDROM)
mode_sense = ider_mode_page_1d_cdrom;
break;
case 0x2a:
- if (device == 0xb0)
+ if (device == IDER_DEVICE_CDROM)
mode_sense = ider_mode_page_2a_cdrom;
break;
}
@@ -343,7 +343,7 @@ int ider_handle_command(struct redir *r, unsigned int seqno,
seqno, lba, r->lba_size);
return ider_data_to_host(r, device, resp, 8, true, use_dma);
case READ_TOC:
- if (device == 0xa0) {
+ if (device == IDER_DEVICE_FLOPPY) {
/* ILLEGAL REQUEST, INVALID COMMAND OPERATION CODE */
return ider_packet_sense(r, device, 0x05, 0x20, 0x00);
} else {
diff --git a/redir.c b/redir.c
index 02a0984..8ff9a98 100644
--- a/redir.c
+++ b/redir.c
@@ -447,7 +447,8 @@ static int redir_ider_command(struct redir *r, unsigned int seqno)
{
struct ider_command_written_message *msg =
(struct ider_command_written_message *)r->buf;
- unsigned char device = msg->drive_select & 0x10 ? 0xb0 : 0xa0;
+ unsigned char device = msg->drive_select & 0x10 ?
+ IDER_DEVICE_CDROM : IDER_DEVICE_FLOPPY;
bool use_dma = msg->feature & 1;
int i;