summaryrefslogtreecommitdiff
path: root/src/VBox/Devices/PC/BIOS/scsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/Devices/PC/BIOS/scsi.c')
-rw-r--r--src/VBox/Devices/PC/BIOS/scsi.c399
1 files changed, 297 insertions, 102 deletions
diff --git a/src/VBox/Devices/PC/BIOS/scsi.c b/src/VBox/Devices/PC/BIOS/scsi.c
index 10a143bd..b40255ea 100644
--- a/src/VBox/Devices/PC/BIOS/scsi.c
+++ b/src/VBox/Devices/PC/BIOS/scsi.c
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2004-2011 Oracle Corporation
+ * Copyright (C) 2004-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -22,28 +22,28 @@
#include "ebda.h"
-//#define VBOX_SCSI_DEBUG 1 /* temporary */
-
-#ifdef VBOX_SCSI_DEBUG
-# define VBSCSI_DEBUG(...) BX_INFO(__VA_ARGS__)
+#if DEBUG_SCSI
+# define DBG_SCSI(...) BX_INFO(__VA_ARGS__)
#else
-# define VBSCSI_DEBUG(...)
+# define DBG_SCSI(...)
#endif
-#define VBSCSI_BUSY (1 << 0)
+#define VBSCSI_BUSY (1 << 0)
+#define VBSCSI_ERROR (1 << 1)
/* The I/O port of the BusLogic SCSI adapter. */
-#define BUSLOGIC_BIOS_IO_PORT 0x330
+#define BUSLOGIC_BIOS_IO_PORT 0x430
/* The I/O port of the LsiLogic SCSI adapter. */
-#define LSILOGIC_BIOS_IO_PORT 0x340
+#define LSILOGIC_BIOS_IO_PORT 0x434
/* The I/O port of the LsiLogic SAS adapter. */
-#define LSILOGIC_SAS_BIOS_IO_PORT 0x350
+#define LSILOGIC_SAS_BIOS_IO_PORT 0x438
#define VBSCSI_REGISTER_STATUS 0
#define VBSCSI_REGISTER_COMMAND 0
#define VBSCSI_REGISTER_DATA_IN 1
#define VBSCSI_REGISTER_IDENTIFY 2
#define VBSCSI_REGISTER_RESET 3
+#define VBSCSI_REGISTER_DEVSTAT 3
#define VBSCSI_MAX_DEVICES 16 /* Maximum number of devices a SCSI device can have. */
@@ -72,76 +72,96 @@ typedef struct {
ct_assert(sizeof(cdb_rw10) == 10);
-int scsi_cmd_data_in(uint16_t io_base, uint8_t device_id, uint8_t __far *aCDB,
- uint8_t cbCDB, uint8_t __far *buffer, uint16_t cbBuffer)
+
+void insb_discard(unsigned nbytes, unsigned port);
+#pragma aux insb_discard = \
+ ".286" \
+ "again:" \
+ "in al,dx" \
+ "loop again" \
+ parm [cx] [dx] modify exact [cx ax] nomemory;
+
+
+int scsi_cmd_data_in(uint16_t io_base, uint8_t target_id, uint8_t __far *aCDB,
+ uint8_t cbCDB, uint8_t __far *buffer, uint32_t length)
{
/* Check that the adapter is ready. */
- uint8_t status;
+ uint8_t status, sizes;
uint16_t i;
do
- {
- status = inb(io_base+VBSCSI_REGISTER_STATUS);
- } while (status & VBSCSI_BUSY);
-
- /* Write target ID. */
- outb(io_base+VBSCSI_REGISTER_COMMAND, device_id);
- /* Write transfer direction. */
- outb(io_base+VBSCSI_REGISTER_COMMAND, SCSI_TXDIR_FROM_DEVICE);
- /* Write the CDB size. */
- outb(io_base+VBSCSI_REGISTER_COMMAND, cbCDB);
- /* Write buffer size. */
- outb(io_base+VBSCSI_REGISTER_COMMAND, cbBuffer);
- outb(io_base+VBSCSI_REGISTER_COMMAND, (cbBuffer >> 8));
- /* Write the CDB. */
- for (i = 0; i < cbCDB; i++)
- outb(io_base+VBSCSI_REGISTER_COMMAND, aCDB[i]);
+ status = inb(io_base + VBSCSI_REGISTER_STATUS);
+ while (status & VBSCSI_BUSY);
+
+
+ sizes = ((length >> 12) & 0xF0) | cbCDB;
+ outb(io_base + VBSCSI_REGISTER_COMMAND, target_id); /* Write the target ID. */
+ outb(io_base + VBSCSI_REGISTER_COMMAND, SCSI_TXDIR_FROM_DEVICE); /* Write the transfer direction. */
+ outb(io_base + VBSCSI_REGISTER_COMMAND, sizes); /* Write CDB size and top bufsize bits. */
+ outb(io_base + VBSCSI_REGISTER_COMMAND, length); /* Write the buffer size. */
+ outb(io_base + VBSCSI_REGISTER_COMMAND, (length >> 8));
+ for (i = 0; i < cbCDB; i++) /* Write the CDB. */
+ outb(io_base + VBSCSI_REGISTER_COMMAND, aCDB[i]);
/* Now wait for the command to complete. */
do
- {
- status = inb(io_base+VBSCSI_REGISTER_STATUS);
- } while (status & VBSCSI_BUSY);
+ status = inb(io_base + VBSCSI_REGISTER_STATUS);
+ while (status & VBSCSI_BUSY);
+
+ /* Read in the data. The transfer length may be exactly 64K or more,
+ * which needs a bit of care when we're using 16-bit 'rep ins'.
+ */
+ while (length > 32768) {
+ DBG_SCSI("%s: reading 32K to %X:%X\n", __func__, FP_SEG(buffer), FP_OFF(buffer));
+ rep_insb(buffer, 32768, io_base + VBSCSI_REGISTER_DATA_IN);
+ length -= 32768;
+ buffer = (FP_SEG(buffer) + (32768 >> 4)) :> FP_OFF(buffer);
+ }
- /* Get the read data. */
- rep_insb(buffer, cbBuffer, io_base + VBSCSI_REGISTER_DATA_IN);
+ DBG_SCSI("%s: reading %ld bytes to %X:%X\n", __func__, length, FP_SEG(buffer), FP_OFF(buffer));
+ rep_insb(buffer, length, io_base + VBSCSI_REGISTER_DATA_IN);
return 0;
}
-int scsi_cmd_data_out(uint16_t io_base, uint8_t device_id, uint8_t __far *aCDB,
- uint8_t cbCDB, uint8_t __far *buffer, uint16_t cbBuffer)
+int scsi_cmd_data_out(uint16_t io_base, uint8_t target_id, uint8_t __far *aCDB,
+ uint8_t cbCDB, uint8_t __far *buffer, uint32_t length)
{
/* Check that the adapter is ready. */
- uint8_t status;
+ uint8_t status, sizes;
uint16_t i;
do
- {
- status = inb(io_base+VBSCSI_REGISTER_STATUS);
- } while (status & VBSCSI_BUSY);
-
- /* Write target ID. */
- outb(io_base+VBSCSI_REGISTER_COMMAND, device_id);
- /* Write transfer direction. */
- outb(io_base+VBSCSI_REGISTER_COMMAND, SCSI_TXDIR_TO_DEVICE);
- /* Write the CDB size. */
- outb(io_base+VBSCSI_REGISTER_COMMAND, cbCDB);
- /* Write buffer size. */
- outb(io_base+VBSCSI_REGISTER_COMMAND, cbBuffer);
- outb(io_base+VBSCSI_REGISTER_COMMAND, (cbBuffer >> 8));
- /* Write the CDB. */
- for (i = 0; i < cbCDB; i++)
- outb(io_base+VBSCSI_REGISTER_COMMAND, aCDB[i]);
-
- /* Write data to I/O port. */
- rep_outsb(buffer, cbBuffer, io_base+VBSCSI_REGISTER_DATA_IN);
+ status = inb(io_base + VBSCSI_REGISTER_STATUS);
+ while (status & VBSCSI_BUSY);
+
+
+ sizes = ((length >> 12) & 0xF0) | cbCDB;
+ outb(io_base + VBSCSI_REGISTER_COMMAND, target_id); /* Write the target ID. */
+ outb(io_base + VBSCSI_REGISTER_COMMAND, SCSI_TXDIR_TO_DEVICE); /* Write the transfer direction. */
+ outb(io_base + VBSCSI_REGISTER_COMMAND, sizes); /* Write CDB size and top bufsize bits. */
+ outb(io_base + VBSCSI_REGISTER_COMMAND, length); /* Write the buffer size. */
+ outb(io_base + VBSCSI_REGISTER_COMMAND, (length >> 8));
+ for (i = 0; i < cbCDB; i++) /* Write the CDB. */
+ outb(io_base + VBSCSI_REGISTER_COMMAND, aCDB[i]);
+
+ /* Write out the data. The transfer length may be exactly 64K or more,
+ * which needs a bit of care when we're using 16-bit 'rep outs'.
+ */
+ while (length > 32768) {
+ DBG_SCSI("%s: writing 32K from %X:%X\n", __func__, FP_SEG(buffer), FP_OFF(buffer));
+ rep_outsb(buffer, 32768, io_base + VBSCSI_REGISTER_DATA_IN);
+ length -= 32768;
+ buffer = (FP_SEG(buffer) + (32768 >> 4)) :> FP_OFF(buffer);
+ }
+
+ DBG_SCSI("%s: writing %ld bytes from %X:%X\n", __func__, length, FP_SEG(buffer), FP_OFF(buffer));
+ rep_outsb(buffer, length, io_base + VBSCSI_REGISTER_DATA_IN);
/* Now wait for the command to complete. */
do
- {
- status = inb(io_base+VBSCSI_REGISTER_STATUS);
- } while (status & VBSCSI_BUSY);
+ status = inb(io_base + VBSCSI_REGISTER_STATUS);
+ while (status & VBSCSI_BUSY);
return 0;
}
@@ -150,7 +170,7 @@ int scsi_cmd_data_out(uint16_t io_base, uint8_t device_id, uint8_t __far *aCDB,
* Read sectors from an attached SCSI device.
*
* @returns status code.
- * @param bios_dsk Pointer to disk request packet (in the
+ * @param bios_dsk Pointer to disk request packet (in the
* EBDA).
*/
int scsi_read_sectors(bio_dsk_t __far *bios_dsk)
@@ -179,14 +199,18 @@ int scsi_read_sectors(bio_dsk_t __far *bios_dsk)
io_base = bios_dsk->scsidev[device_id].io_base;
target_id = bios_dsk->scsidev[device_id].target_id;
- rc = scsi_cmd_data_in(io_base, target_id, (void __far *)&cdb, 10,
- bios_dsk->drqp.buffer, (count * 512));
+ DBG_SCSI("%s: reading %u sectors, device %d, target %d\n", __func__,
+ count, device_id, bios_dsk->scsidev[device_id].target_id);
+
+ rc = scsi_cmd_data_in(io_base, target_id, (void __far *)&cdb, 10,
+ bios_dsk->drqp.buffer, (count * 512L));
if (!rc)
{
bios_dsk->drqp.trsfsectors = count;
- bios_dsk->drqp.trsfbytes = count * 512;
+ bios_dsk->drqp.trsfbytes = count * 512L;
}
+ DBG_SCSI("%s: transferred %u sectors\n", __func__, bios_dsk->drqp.nsect);
return rc;
}
@@ -195,7 +219,7 @@ int scsi_read_sectors(bio_dsk_t __far *bios_dsk)
* Write sectors to an attached SCSI device.
*
* @returns status code.
- * @param bios_dsk Pointer to disk request packet (in the
+ * @param bios_dsk Pointer to disk request packet (in the
* EBDA).
*/
int scsi_write_sectors(bio_dsk_t __far *bios_dsk)
@@ -223,18 +247,125 @@ int scsi_write_sectors(bio_dsk_t __far *bios_dsk)
io_base = bios_dsk->scsidev[device_id].io_base;
target_id = bios_dsk->scsidev[device_id].target_id;
+ DBG_SCSI("%s: writing %u sectors, device %d, target %d\n", __func__,
+ count, device_id, bios_dsk->scsidev[device_id].target_id);
+
rc = scsi_cmd_data_out(io_base, target_id, (void __far *)&cdb, 10,
- bios_dsk->drqp.buffer, (count * 512));
+ bios_dsk->drqp.buffer, (count * 512L));
if (!rc)
{
bios_dsk->drqp.trsfsectors = count;
- bios_dsk->drqp.trsfbytes = (count * 512);
+ bios_dsk->drqp.trsfbytes = (count * 512L);
}
+ DBG_SCSI("%s: transferred %u sectors\n", __func__, bios_dsk->drqp.nsect);
return rc;
}
+
+//@todo: move
+#define ATA_DATA_NO 0x00
+#define ATA_DATA_IN 0x01
+#define ATA_DATA_OUT 0x02
+
+/**
+ * Perform a "packet style" read with supplied CDB.
+ *
+ * @returns status code.
+ * @param bios_dsk Pointer to disk request packet (in the
+ * EBDA).
+ */
+uint16_t scsi_cmd_packet(uint16_t device_id, uint8_t cmdlen, char __far *cmdbuf,
+ uint16_t before, uint32_t length, uint8_t inout, char __far *buffer)
+{
+ bio_dsk_t __far *bios_dsk = read_word(0x0040, 0x000E) :> &EbdaData->bdisk;
+ uint32_t read_len;
+ uint8_t status, sizes;
+ uint16_t i;
+ uint16_t io_base;
+ uint8_t target_id;
+
+ /* Data out is currently not supported. */
+ if (inout == ATA_DATA_OUT) {
+ BX_INFO("%s: DATA_OUT not supported yet\n", __func__);
+ return 1;
+ }
+
+ /* Convert to SCSI specific device number. */
+ device_id = VBOX_GET_SCSI_DEVICE(device_id);
+
+ DBG_SCSI("%s: reading %lu bytes, skip %u/%u, device %d, target %d\n", __func__,
+ length, bios_dsk->drqp.skip_b, bios_dsk->drqp.skip_a,
+ device_id, bios_dsk->scsidev[device_id].target_id);
+ DBG_SCSI("%s: reading %u %u-byte sectors\n", __func__,
+ bios_dsk->drqp.nsect, bios_dsk->drqp.sect_sz);
+
+ cmdlen -= 2; /* ATAPI uses 12-byte command packets for a READ 10. */
+
+ io_base = bios_dsk->scsidev[device_id].io_base;
+ target_id = bios_dsk->scsidev[device_id].target_id;
+
+ /* Wait until the adapter is ready. */
+ do
+ status = inb(io_base + VBSCSI_REGISTER_STATUS);
+ while (status & VBSCSI_BUSY);
+
+ /* On the SCSI level, we have to transfer whole sectors. */
+ /* NB: With proper residual length support, this should not be necessary; we should
+ * be able to avoid transferring the 'after' part of the sector.
+ */
+ read_len = length + before + bios_dsk->drqp.skip_a;
+
+ sizes = (((read_len) >> 12) & 0xF0) | cmdlen;
+ outb(io_base + VBSCSI_REGISTER_COMMAND, target_id); /* Write the target ID. */
+ outb(io_base + VBSCSI_REGISTER_COMMAND, SCSI_TXDIR_FROM_DEVICE); /* Write the transfer direction. */
+ outb(io_base + VBSCSI_REGISTER_COMMAND, sizes); /* Write the CDB size. */
+ outb(io_base + VBSCSI_REGISTER_COMMAND, read_len); /* Write the buffer size. */
+ outb(io_base + VBSCSI_REGISTER_COMMAND, (read_len) >> 8);
+ for (i = 0; i < cmdlen; i++) /* Write the CDB. */
+ outb(io_base + VBSCSI_REGISTER_COMMAND, cmdbuf[i]);
+
+ /* Now wait for the command to complete. */
+ do
+ status = inb(io_base + VBSCSI_REGISTER_STATUS);
+ while (status & VBSCSI_BUSY);
+
+ /* If any error occurred, inform the caller and don't bother reading the data. */
+ if (status & VBSCSI_ERROR) {
+ outb(io_base + VBSCSI_REGISTER_RESET, 0);
+
+ status = inb(io_base + VBSCSI_REGISTER_DEVSTAT);
+ DBG_SCSI("%s: read failed, device status %02X\n", __func__, status);
+ return 3;
+ }
+
+ /* Transfer the data read from the device. */
+
+ if (before) /* If necessary, throw away data which needs to be skipped. */
+ insb_discard(before, io_base + VBSCSI_REGISTER_DATA_IN);
+
+ bios_dsk->drqp.trsfbytes = length;
+
+ /* The requested length may be exactly 64K or more, which needs
+ * a bit of care when we're using 16-bit 'rep ins'.
+ */
+ while (length > 32768) {
+ DBG_SCSI("%s: reading 32K to %X:%X\n", __func__, FP_SEG(buffer), FP_OFF(buffer));
+ rep_insb(buffer, 32768, io_base + VBSCSI_REGISTER_DATA_IN);
+ length -= 32768;
+ buffer = (FP_SEG(buffer) + (32768 >> 4)) :> FP_OFF(buffer);
+ }
+
+ DBG_SCSI("%s: reading %ld bytes to %X:%X\n", __func__, length, FP_SEG(buffer), FP_OFF(buffer));
+ rep_insb(buffer, length, io_base + VBSCSI_REGISTER_DATA_IN);
+
+ if (bios_dsk->drqp.skip_a) /* If necessary, throw away more data. */
+ insb_discard(bios_dsk->drqp.skip_a, io_base + VBSCSI_REGISTER_DATA_IN);
+
+ return 0;
+}
+
/**
* Enumerate attached devices.
*
@@ -254,6 +385,7 @@ void scsi_enumerate_attached_devices(uint16_t io_base)
{
uint8_t rc;
uint8_t aCDB[10];
+ uint8_t hd_index, devcount_scsi;
aCDB[0] = SCSI_INQUIRY;
aCDB[1] = 0;
@@ -264,20 +396,21 @@ void scsi_enumerate_attached_devices(uint16_t io_base)
rc = scsi_cmd_data_in(io_base, i, aCDB, 6, buffer, 5);
if (rc != 0)
- BX_PANIC("scsi_enumerate_attached_devices: SCSI_INQUIRY failed\n");
+ BX_PANIC("%s: SCSI_INQUIRY failed\n", __func__);
- /* Check if there is a disk attached. */
+ /* Check the attached device. */
if ( ((buffer[0] & 0xe0) == 0)
&& ((buffer[0] & 0x1f) == 0x00))
{
- VBSCSI_DEBUG("scsi_enumerate_attached_devices: Disk detected at %d\n", i);
+ DBG_SCSI("%s: Disk detected at %d\n", __func__, i);
/* We add the disk only if the maximum is not reached yet. */
- if (bios_dsk->scsi_hdcount < BX_MAX_SCSI_DEVICES)
+ if (bios_dsk->scsi_devcount < BX_MAX_SCSI_DEVICES)
{
uint32_t sectors, sector_size, cylinders;
uint16_t heads, sectors_per_track;
- uint8_t hdcount, hdcount_scsi, hd_index;
+ uint8_t hdcount;
+ uint8_t cmos_base;
/* Issue a read capacity command now. */
_fmemset(aCDB, 0, sizeof(aCDB));
@@ -285,7 +418,7 @@ void scsi_enumerate_attached_devices(uint16_t io_base)
rc = scsi_cmd_data_in(io_base, i, aCDB, 10, buffer, 8);
if (rc != 0)
- BX_PANIC("scsi_enumerate_attached_devices: SCSI_READ_CAPACITY failed\n");
+ BX_PANIC("%s: SCSI_READ_CAPACITY failed\n", __func__);
/* Build sector number and size from the buffer. */
//@todo: byte swapping for dword sized items should be farmed out...
@@ -307,32 +440,62 @@ void scsi_enumerate_attached_devices(uint16_t io_base)
continue;
}
- /* We need to calculate the geometry for the disk. From
- * the BusLogic driver in the Linux kernel.
- */
- if (sectors >= (uint32_t)4 * 1024 * 1024)
+ devcount_scsi = bios_dsk->scsi_devcount;
+
+ /* Get logical CHS geometry. */
+ switch (devcount_scsi)
{
- heads = 255;
- sectors_per_track = 63;
+ case 0:
+ cmos_base = 0x90;
+ break;
+ case 1:
+ cmos_base = 0x98;
+ break;
+ case 2:
+ cmos_base = 0xA0;
+ break;
+ case 3:
+ cmos_base = 0xA8;
+ break;
+ default:
+ cmos_base = 0;
}
- else if (sectors >= (uint32_t)2 * 1024 * 1024)
+
+ if (cmos_base && inb_cmos(cmos_base + 7))
{
- heads = 128;
- sectors_per_track = 32;
+ /* If provided, grab the logical geometry from CMOS. */
+ cylinders = inb_cmos(cmos_base + 0) + (inb_cmos(cmos_base + 1) << 8);
+ heads = inb_cmos(cmos_base + 2);
+ sectors_per_track = inb_cmos(cmos_base + 7);
}
else
{
- heads = 64;
- sectors_per_track = 32;
+ /* Calculate default logical geometry. NB: Very different
+ * from default ATA/SATA logical geometry!
+ */
+ if (sectors >= (uint32_t)4 * 1024 * 1024)
+ {
+ heads = 255;
+ sectors_per_track = 63;
+ }
+ else if (sectors >= (uint32_t)2 * 1024 * 1024)
+ {
+ heads = 128;
+ sectors_per_track = 32;
+ }
+ else
+ {
+ heads = 64;
+ sectors_per_track = 32;
+ }
+ cylinders = (uint32_t)(sectors / (heads * sectors_per_track));
}
- cylinders = (uint32_t)(sectors / (heads * sectors_per_track));
- hdcount_scsi = bios_dsk->scsi_hdcount;
/* Calculate index into the generic disk table. */
- hd_index = hdcount_scsi + BX_MAX_ATA_DEVICES;
+ hd_index = devcount_scsi + BX_MAX_ATA_DEVICES;
- bios_dsk->scsidev[hdcount_scsi].io_base = io_base;
- bios_dsk->scsidev[hdcount_scsi].target_id = i;
+ bios_dsk->scsidev[devcount_scsi].io_base = io_base;
+ bios_dsk->scsidev[devcount_scsi].target_id = i;
bios_dsk->devices[hd_index].type = DSK_TYPE_SCSI;
bios_dsk->devices[hd_index].device = DSK_DEVICE_HD;
bios_dsk->devices[hd_index].removable = 0;
@@ -348,6 +511,9 @@ void scsi_enumerate_attached_devices(uint16_t io_base)
else
bios_dsk->devices[hd_index].lchs.cylinders = (uint16_t)cylinders;
+ BX_INFO("SCSI %d-ID#%d: LCHS=%u/%u/%u %ld sectors\n", devcount_scsi,
+ i, (uint16_t)cylinders, heads, sectors_per_track, sectors);
+
/* Write PCHS values. */
bios_dsk->devices[hd_index].pchs.heads = heads;
bios_dsk->devices[hd_index].pchs.spt = sectors_per_track;
@@ -360,7 +526,7 @@ void scsi_enumerate_attached_devices(uint16_t io_base)
/* Store the id of the disk in the ata hdidmap. */
hdcount = bios_dsk->hdcount;
- bios_dsk->hdidmap[hdcount] = hdcount_scsi + BX_MAX_ATA_DEVICES;
+ bios_dsk->hdidmap[hdcount] = devcount_scsi + BX_MAX_ATA_DEVICES;
hdcount++;
bios_dsk->hdcount = hdcount;
@@ -369,8 +535,8 @@ void scsi_enumerate_attached_devices(uint16_t io_base)
hdcount++;
write_byte(0x40, 0x75, hdcount);
- hdcount_scsi++;
- bios_dsk->scsi_hdcount = hdcount_scsi;
+ devcount_scsi++;
+ bios_dsk->scsi_devcount = devcount_scsi;
}
else
{
@@ -378,8 +544,37 @@ void scsi_enumerate_attached_devices(uint16_t io_base)
break;
}
}
+ else if ( ((buffer[0] & 0xe0) == 0)
+ && ((buffer[0] & 0x1f) == 0x05))
+ {
+ uint8_t cdcount;
+ uint8_t removable;
+
+ BX_INFO("SCSI %d-ID#%d: CD/DVD-ROM\n", devcount_scsi, i);
+
+ /* Calculate index into the generic device table. */
+ hd_index = devcount_scsi + BX_MAX_ATA_DEVICES;
+
+ removable = buffer[1] & 0x80 ? 1 : 0;
+
+ bios_dsk->scsidev[devcount_scsi].io_base = io_base;
+ bios_dsk->scsidev[devcount_scsi].target_id = i;
+ bios_dsk->devices[hd_index].type = DSK_TYPE_SCSI;
+ bios_dsk->devices[hd_index].device = DSK_DEVICE_CDROM;
+ bios_dsk->devices[hd_index].removable = removable;
+ bios_dsk->devices[hd_index].blksize = 2048;
+
+ /* Store the ID of the device in the BIOS cdidmap. */
+ cdcount = bios_dsk->cdcount;
+ bios_dsk->cdidmap[cdcount] = devcount_scsi + BX_MAX_ATA_DEVICES;
+ cdcount++;
+ bios_dsk->cdcount = cdcount;
+
+ devcount_scsi++;
+ bios_dsk->scsi_devcount = devcount_scsi;
+ }
else
- VBSCSI_DEBUG("scsi_enumerate_attached_devices: No disk detected at %d\n", i);
+ DBG_SCSI("%s: No supported device detected at %d\n", __func__, i);
}
}
@@ -393,55 +588,55 @@ void BIOSCALL scsi_init(void)
bios_dsk = read_word(0x0040, 0x000E) :> &EbdaData->bdisk;
- bios_dsk->scsi_hdcount = 0;
+ bios_dsk->scsi_devcount = 0;
identifier = 0;
- /* Detect BusLogic adapter. */
+ /* Detect the BusLogic adapter. */
outb(BUSLOGIC_BIOS_IO_PORT+VBSCSI_REGISTER_IDENTIFY, 0x55);
identifier = inb(BUSLOGIC_BIOS_IO_PORT+VBSCSI_REGISTER_IDENTIFY);
if (identifier == 0x55)
{
/* Detected - Enumerate attached devices. */
- VBSCSI_DEBUG("scsi_init: BusLogic SCSI adapter detected\n");
+ DBG_SCSI("scsi_init: BusLogic SCSI adapter detected\n");
outb(BUSLOGIC_BIOS_IO_PORT+VBSCSI_REGISTER_RESET, 0);
scsi_enumerate_attached_devices(BUSLOGIC_BIOS_IO_PORT);
}
else
{
- VBSCSI_DEBUG("scsi_init: BusLogic SCSI adapter not detected\n");
+ DBG_SCSI("scsi_init: BusLogic SCSI adapter not detected\n");
}
- /* Detect LsiLogic adapter. */
+ /* Detect the LSI Logic parallel SCSI adapter. */
outb(LSILOGIC_BIOS_IO_PORT+VBSCSI_REGISTER_IDENTIFY, 0x55);
identifier = inb(LSILOGIC_BIOS_IO_PORT+VBSCSI_REGISTER_IDENTIFY);
if (identifier == 0x55)
{
/* Detected - Enumerate attached devices. */
- VBSCSI_DEBUG("scsi_init: LSI Logic SCSI adapter detected\n");
+ DBG_SCSI("scsi_init: LSI Logic SCSI adapter detected\n");
outb(LSILOGIC_BIOS_IO_PORT+VBSCSI_REGISTER_RESET, 0);
scsi_enumerate_attached_devices(LSILOGIC_BIOS_IO_PORT);
}
else
{
- VBSCSI_DEBUG("scsi_init: LSI Logic SCSI adapter not detected\n");
+ DBG_SCSI("scsi_init: LSI Logic SCSI adapter not detected\n");
}
- /* Detect LsiLogic SAS adapter. */
+ /* Detect the LSI Logic SAS adapter. */
outb(LSILOGIC_SAS_BIOS_IO_PORT+VBSCSI_REGISTER_IDENTIFY, 0x55);
identifier = inb(LSILOGIC_SAS_BIOS_IO_PORT+VBSCSI_REGISTER_IDENTIFY);
if (identifier == 0x55)
{
/* Detected - Enumerate attached devices. */
- VBSCSI_DEBUG("scsi_init: LSI Logic SAS adapter detected\n");
+ DBG_SCSI("scsi_init: LSI Logic SAS adapter detected\n");
outb(LSILOGIC_SAS_BIOS_IO_PORT+VBSCSI_REGISTER_RESET, 0);
scsi_enumerate_attached_devices(LSILOGIC_SAS_BIOS_IO_PORT);
}
else
{
- VBSCSI_DEBUG("scsi_init: LSI Logic SAS adapter not detected\n");
+ DBG_SCSI("scsi_init: LSI Logic SAS adapter not detected\n");
}
}