Skip to contentSkip to conversation

Fix sparc booting with no CD in drive

PATCH In review Blue Swirl 2 participants 4 messages Aug 13, 2006 – Aug 15, 2006

lore
Share & tools
lore

Blue Swirl

author
#0 lore raw

PATCH 1/1 Fix sparc booting with no CD in drive

If there is no CD in drive, sparc system emulator fails to boot. This happens because error handling is a bit broken in scsi-disk.c. The older OpenBIOS just didn't care.

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

Fix booting without CD in drive.

hw/scsi-disk.c +4 -1
Index: qemu/hw/scsi-disk.c
===================================================================
@@ -109,8 +109,10 @@
     uint32_t n;
 
     DPRINTF("Read %d (%d/%d)\n", len, s->buf_len, s->sector_count);
-    if (s->buf_len == 0 && s->sector_count == 0)
+    if (s->buf_len == 0 && s->sector_count == 0) {
+        scsi_command_complete(s, SENSE_NO_SENSE);
         return 1;
+    }
 
     if (s->buf_len) {
         n = s->buf_len;
@@ -447,6 +449,7 @@
             s->buf_len = 8;
         } else {
             scsi_command_complete(s, SENSE_NOT_READY);
+            return 0;
         }
	break;
     case 0x08:
#1 lore raw
Quoted 9 lines · Blue Swirl

If there is no CD in drive, sparc system emulator fails to boot. This happens because error handling is a bit broken in scsi-disk.c. The older OpenBIOS just didn't care.

Index: qemu/hw/scsi-disk.c
===================================================================

hw/scsi-disk.c line 116

Quoted 9 lines
hw/scsi-disk.c +3 -1
@@ -109,8 +109,10 @@
     uint32_t n;
 
     DPRINTF("Read %d (%d/%d)\n", len, s->buf_len, s->sector_count);
-    if (s->buf_len == 0 && s->sector_count == 0)
+    if (s->buf_len == 0 && s->sector_count == 0) {
+        scsi_command_complete(s, SENSE_NO_SENSE);
         return 1;
+    }
 

Why are we getting reads when no data is available? The command should already have completed.

hw/scsi-disk.c line 455

Quoted 8 lines
hw/scsi-disk.c +1 -0
@@ -447,6 +449,7 @@
             s->buf_len = 8;
         } else {
             scsi_command_complete(s, SENSE_NOT_READY);
+            return 0;
         }
 	break;
     case 0x08:

This bit looks ok.

Paul

author
#2 lore raw
Quoted 2 lines

Why are we getting reads when no data is available? The command should already have completed.

I don't know. Should all SCSI commands return something with the transfer mechanism? Or is it a bug in OpenBIOS, should it get the SCSI error status somehow without transferring data?

The background here is that OpenBIOS probes for SCSI devices, but when probing of capacity for nonexistent CDROM, the command fails.

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/

#3 lore raw
Quoted 7 lines · Blue Swirl
Quoted 3 lines

Why are we getting reads when no data is available? The command should already
have completed.

I don't know. Should all SCSI commands return something with the transfer mechanism? Or is it a bug in OpenBIOS, should it get the SCSI error status somehow without transferring data?

The scsi_read_data and scsi_write_data routines correspond directly to the SCSI DATA IN and DATA OUT phases.

It's up to the HBA (ie. esp) emulation to keep track of the SCSI phase based on the return value of scsi_send_command and whether the command completion routine has been called.
It's also up to the HBA to implement the SCSI STATUS phase based on the sense code passed to the completion routine. Calling completion routine with SCSI_REASON_DONE indicates that the command has finished (success is determined by the sense code) and the disk is ready for the next command.

Commands can fail at any time, including before any data has been transferred. On LSI HBA this causes an invalid phase exception to be raised when data transfer is attempted. I don't remember offhand how the ESP controller handles this. There are also some commands that complete successfully without transfering any data.

Quoted 2 lines

The background here is that OpenBIOS probes for SCSI devices, but when probing of capacity for nonexistent CDROM, the command fails.

The read capacity command deliberately fails when there is no media present.

Paul