Commit b1fa716443d9854ce6745139cce5c12895882cd1

Authored by blueswir1
1 parent a1620fac

Revert v4260, breaks Sparc32

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4280 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 13 additions and 24 deletions
hw/scsi-disk.c
@@ -34,18 +34,6 @@ do { fprintf(stderr, "scsi-disk: " fmt , ##args); } while (0) @@ -34,18 +34,6 @@ do { fprintf(stderr, "scsi-disk: " fmt , ##args); } while (0)
34 #define SENSE_HARDWARE_ERROR 4 34 #define SENSE_HARDWARE_ERROR 4
35 #define SENSE_ILLEGAL_REQUEST 5 35 #define SENSE_ILLEGAL_REQUEST 5
36 36
37 -#define SCSI_OK 0  
38 -#define SCSI_CHECK_COND 0x2  
39 -#define SCSI_COND_MET 0x4  
40 -#define SCSI_BUSY 0x8  
41 -#define SCSI_INTERMEDIATE 0x10  
42 -#define SCSI_INTER_MET 0x14  
43 -#define SCSI_RES_CONFLICT 0x18  
44 -#define SCSI_CMD_TERMINATED 0x22  
45 -#define SCSI_QUEUE_FULL 0x28  
46 -#define SCSI_ACA_ACTIVE 0x30  
47 -#define SCSI_TASK_ABORTED 0x40  
48 -  
49 #define SCSI_DMA_BUF_SIZE 65536 37 #define SCSI_DMA_BUF_SIZE 65536
50 38
51 typedef struct SCSIRequest { 39 typedef struct SCSIRequest {
@@ -136,7 +124,7 @@ static SCSIRequest *scsi_find_request(SCSIDeviceState *s, uint32_t tag) @@ -136,7 +124,7 @@ static SCSIRequest *scsi_find_request(SCSIDeviceState *s, uint32_t tag)
136 } 124 }
137 125
138 /* Helper function for command completion. */ 126 /* Helper function for command completion. */
139 -static void scsi_command_complete(SCSIRequest *r, int status, int sense) 127 +static void scsi_command_complete(SCSIRequest *r, int sense)
140 { 128 {
141 SCSIDeviceState *s = r->dev; 129 SCSIDeviceState *s = r->dev;
142 uint32_t tag; 130 uint32_t tag;
@@ -144,7 +132,7 @@ static void scsi_command_complete(SCSIRequest *r, int status, int sense) @@ -144,7 +132,7 @@ static void scsi_command_complete(SCSIRequest *r, int status, int sense)
144 s->sense = sense; 132 s->sense = sense;
145 tag = r->tag; 133 tag = r->tag;
146 scsi_remove_request(r); 134 scsi_remove_request(r);
147 - s->completion(s->opaque, SCSI_REASON_DONE, tag, status); 135 + s->completion(s->opaque, SCSI_REASON_DONE, tag, sense);
148 } 136 }
149 137
150 /* Cancel a pending data transfer. */ 138 /* Cancel a pending data transfer. */
@@ -169,7 +157,7 @@ static void scsi_read_complete(void * opaque, int ret) @@ -169,7 +157,7 @@ static void scsi_read_complete(void * opaque, int ret)
169 157
170 if (ret) { 158 if (ret) {
171 DPRINTF("IO error\n"); 159 DPRINTF("IO error\n");
172 - scsi_command_complete(r, SCSI_CHECK_COND, SENSE_HARDWARE_ERROR); 160 + scsi_command_complete(r, SENSE_HARDWARE_ERROR);
173 return; 161 return;
174 } 162 }
175 DPRINTF("Data ready tag=0x%x len=%d\n", r->tag, r->buf_len); 163 DPRINTF("Data ready tag=0x%x len=%d\n", r->tag, r->buf_len);
@@ -187,7 +175,8 @@ static void scsi_read_data(SCSIDevice *d, uint32_t tag) @@ -187,7 +175,8 @@ static void scsi_read_data(SCSIDevice *d, uint32_t tag)
187 r = scsi_find_request(s, tag); 175 r = scsi_find_request(s, tag);
188 if (!r) { 176 if (!r) {
189 BADF("Bad read tag 0x%x\n", tag); 177 BADF("Bad read tag 0x%x\n", tag);
190 - scsi_command_complete(r, SCSI_CHECK_COND, SENSE_HARDWARE_ERROR); 178 + /* ??? This is the wrong error. */
  179 + scsi_command_complete(r, SENSE_HARDWARE_ERROR);
191 return; 180 return;
192 } 181 }
193 if (r->sector_count == (uint32_t)-1) { 182 if (r->sector_count == (uint32_t)-1) {
@@ -198,7 +187,7 @@ static void scsi_read_data(SCSIDevice *d, uint32_t tag) @@ -198,7 +187,7 @@ static void scsi_read_data(SCSIDevice *d, uint32_t tag)
198 } 187 }
199 DPRINTF("Read sector_count=%d\n", r->sector_count); 188 DPRINTF("Read sector_count=%d\n", r->sector_count);
200 if (r->sector_count == 0) { 189 if (r->sector_count == 0) {
201 - scsi_command_complete(r, SCSI_OK, SENSE_NO_SENSE); 190 + scsi_command_complete(r, SENSE_NO_SENSE);
202 return; 191 return;
203 } 192 }
204 193
@@ -210,7 +199,7 @@ static void scsi_read_data(SCSIDevice *d, uint32_t tag) @@ -210,7 +199,7 @@ static void scsi_read_data(SCSIDevice *d, uint32_t tag)
210 r->aiocb = bdrv_aio_read(s->bdrv, r->sector, r->dma_buf, n, 199 r->aiocb = bdrv_aio_read(s->bdrv, r->sector, r->dma_buf, n,
211 scsi_read_complete, r); 200 scsi_read_complete, r);
212 if (r->aiocb == NULL) 201 if (r->aiocb == NULL)
213 - scsi_command_complete(r, SCSI_CHECK_COND, SENSE_HARDWARE_ERROR); 202 + scsi_command_complete(r, SENSE_HARDWARE_ERROR);
214 r->sector += n; 203 r->sector += n;
215 r->sector_count -= n; 204 r->sector_count -= n;
216 } 205 }
@@ -228,7 +217,7 @@ static void scsi_write_complete(void * opaque, int ret) @@ -228,7 +217,7 @@ static void scsi_write_complete(void * opaque, int ret)
228 217
229 r->aiocb = NULL; 218 r->aiocb = NULL;
230 if (r->sector_count == 0) { 219 if (r->sector_count == 0) {
231 - scsi_command_complete(r, SCSI_OK, SENSE_NO_SENSE); 220 + scsi_command_complete(r, SENSE_NO_SENSE);
232 } else { 221 } else {
233 len = r->sector_count * 512; 222 len = r->sector_count * 512;
234 if (len > SCSI_DMA_BUF_SIZE) { 223 if (len > SCSI_DMA_BUF_SIZE) {
@@ -252,7 +241,7 @@ static int scsi_write_data(SCSIDevice *d, uint32_t tag) @@ -252,7 +241,7 @@ static int scsi_write_data(SCSIDevice *d, uint32_t tag)
252 r = scsi_find_request(s, tag); 241 r = scsi_find_request(s, tag);
253 if (!r) { 242 if (!r) {
254 BADF("Bad write tag 0x%x\n", tag); 243 BADF("Bad write tag 0x%x\n", tag);
255 - scsi_command_complete(r, SCSI_CHECK_COND, SENSE_HARDWARE_ERROR); 244 + scsi_command_complete(r, SENSE_HARDWARE_ERROR);
256 return 1; 245 return 1;
257 } 246 }
258 if (r->aiocb) 247 if (r->aiocb)
@@ -262,7 +251,7 @@ static int scsi_write_data(SCSIDevice *d, uint32_t tag) @@ -262,7 +251,7 @@ static int scsi_write_data(SCSIDevice *d, uint32_t tag)
262 r->aiocb = bdrv_aio_write(s->bdrv, r->sector, r->dma_buf, n, 251 r->aiocb = bdrv_aio_write(s->bdrv, r->sector, r->dma_buf, n,
263 scsi_write_complete, r); 252 scsi_write_complete, r);
264 if (r->aiocb == NULL) 253 if (r->aiocb == NULL)
265 - scsi_command_complete(r, SCSI_CHECK_COND, SENSE_HARDWARE_ERROR); 254 + scsi_command_complete(r, SENSE_HARDWARE_ERROR);
266 r->sector += n; 255 r->sector += n;
267 r->sector_count -= n; 256 r->sector_count -= n;
268 } else { 257 } else {
@@ -612,7 +601,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, @@ -612,7 +601,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag,
612 outbuf[7] = 0; 601 outbuf[7] = 0;
613 r->buf_len = 8; 602 r->buf_len = 8;
614 } else { 603 } else {
615 - scsi_command_complete(r, SCSI_CHECK_COND, SENSE_NOT_READY); 604 + scsi_command_complete(r, SENSE_NOT_READY);
616 return 0; 605 return 0;
617 } 606 }
618 break; 607 break;
@@ -699,11 +688,11 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, @@ -699,11 +688,11 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag,
699 default: 688 default:
700 DPRINTF("Unknown SCSI command (%2.2x)\n", buf[0]); 689 DPRINTF("Unknown SCSI command (%2.2x)\n", buf[0]);
701 fail: 690 fail:
702 - scsi_command_complete(r, SCSI_CHECK_COND, SENSE_ILLEGAL_REQUEST); 691 + scsi_command_complete(r, SENSE_ILLEGAL_REQUEST);
703 return 0; 692 return 0;
704 } 693 }
705 if (r->sector_count == 0 && r->buf_len == 0) { 694 if (r->sector_count == 0 && r->buf_len == 0) {
706 - scsi_command_complete(r, SCSI_OK, SENSE_NO_SENSE); 695 + scsi_command_complete(r, SENSE_NO_SENSE);
707 } 696 }
708 len = r->sector_count * 512 + r->buf_len; 697 len = r->sector_count * 512 + r->buf_len;
709 if (is_write) { 698 if (is_write) {