Commit a136e5a8b176bfd3ba687769ed999c55782f2584

Authored by bellard
1 parent 4796f5e9

ATAPI transfer size fix (NetBSD CDROM access fix) - added WIN_CHECKPOWERMODE1 - …

…set error to zero in some cases


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@574 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 11 additions and 3 deletions
hw/ide.c
@@ -550,6 +550,7 @@ static void ide_sector_read(IDEState *s) @@ -550,6 +550,7 @@ static void ide_sector_read(IDEState *s)
550 int ret, n; 550 int ret, n;
551 551
552 s->status = READY_STAT | SEEK_STAT; 552 s->status = READY_STAT | SEEK_STAT;
  553 + s->error = 0; /* not needed by IDE spec, but needed by Windows */
553 sector_num = ide_get_sector(s); 554 sector_num = ide_get_sector(s);
554 n = s->nsector; 555 n = s->nsector;
555 if (n == 0) { 556 if (n == 0) {
@@ -694,10 +695,9 @@ static void ide_atapi_cmd_reply_end(IDEState *s) @@ -694,10 +695,9 @@ static void ide_atapi_cmd_reply_end(IDEState *s)
694 if (byte_count_limit & 1) 695 if (byte_count_limit & 1)
695 byte_count_limit--; 696 byte_count_limit--;
696 size = byte_count_limit; 697 size = byte_count_limit;
697 - } else {  
698 - s->lcyl = size;  
699 - s->hcyl = size >> 8;  
700 } 698 }
  699 + s->lcyl = size;
  700 + s->hcyl = size >> 8;
701 s->elementary_transfer_size = size; 701 s->elementary_transfer_size = size;
702 /* we cannot transmit more than one sector at a time */ 702 /* we cannot transmit more than one sector at a time */
703 if (s->lba != -1) { 703 if (s->lba != -1) {
@@ -1106,6 +1106,7 @@ static void ide_ioport_write(CPUState *env, uint32_t addr, uint32_t val) @@ -1106,6 +1106,7 @@ static void ide_ioport_write(CPUState *env, uint32_t addr, uint32_t val)
1106 break; 1106 break;
1107 case WIN_SPECIFY: 1107 case WIN_SPECIFY:
1108 case WIN_RECAL: 1108 case WIN_RECAL:
  1109 + s->error = 0;
1109 s->status = READY_STAT; 1110 s->status = READY_STAT;
1110 ide_set_irq(s); 1111 ide_set_irq(s);
1111 break; 1112 break;
@@ -1135,6 +1136,7 @@ static void ide_ioport_write(CPUState *env, uint32_t addr, uint32_t val) @@ -1135,6 +1136,7 @@ static void ide_ioport_write(CPUState *env, uint32_t addr, uint32_t val)
1135 break; 1136 break;
1136 case WIN_WRITE: 1137 case WIN_WRITE:
1137 case WIN_WRITE_ONCE: 1138 case WIN_WRITE_ONCE:
  1139 + s->error = 0;
1138 s->status = SEEK_STAT; 1140 s->status = SEEK_STAT;
1139 s->req_nb_sectors = 1; 1141 s->req_nb_sectors = 1;
1140 ide_transfer_start(s, s->io_buffer, 512, ide_sector_write); 1142 ide_transfer_start(s, s->io_buffer, 512, ide_sector_write);
@@ -1148,6 +1150,7 @@ static void ide_ioport_write(CPUState *env, uint32_t addr, uint32_t val) @@ -1148,6 +1150,7 @@ static void ide_ioport_write(CPUState *env, uint32_t addr, uint32_t val)
1148 case WIN_MULTWRITE: 1150 case WIN_MULTWRITE:
1149 if (!s->mult_sectors) 1151 if (!s->mult_sectors)
1150 goto abort_cmd; 1152 goto abort_cmd;
  1153 + s->error = 0;
1151 s->status = SEEK_STAT; 1154 s->status = SEEK_STAT;
1152 s->req_nb_sectors = s->mult_sectors; 1155 s->req_nb_sectors = s->mult_sectors;
1153 n = s->nsector; 1156 n = s->nsector;
@@ -1160,6 +1163,11 @@ static void ide_ioport_write(CPUState *env, uint32_t addr, uint32_t val) @@ -1160,6 +1163,11 @@ static void ide_ioport_write(CPUState *env, uint32_t addr, uint32_t val)
1160 s->status = READY_STAT; 1163 s->status = READY_STAT;
1161 ide_set_irq(s); 1164 ide_set_irq(s);
1162 break; 1165 break;
  1166 + case WIN_CHECKPOWERMODE1:
  1167 + s->nsector = 0xff; /* device active or idle */
  1168 + s->status = READY_STAT;
  1169 + ide_set_irq(s);
  1170 + break;
1163 1171
1164 /* ATAPI commands */ 1172 /* ATAPI commands */
1165 case WIN_PIDENTIFY: 1173 case WIN_PIDENTIFY: