VirtualBox

Ignore:
Timestamp:
Nov 17, 2011 5:25:25 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
74940
Message:

Reshuffled things some more.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/BIOS-new/scsi.c

    r39347 r39355  
    2424
    2525
     26//#define VBOX_SCSI_DEBUG 1 /* temporary */
     27
     28#ifdef VBOX_SCSI_DEBUG
     29# define VBSCSI_DEBUG(...)    BX_INFO(__VA_ARGS__)
     30#else
     31# define VBSCSI_DEBUG(...)
     32#endif
     33
     34#define VBSCSI_BUSY (1 << 0)
     35
    2636/* The I/O port of the BusLogic SCSI adapter. */
    2737#define BUSLOGIC_ISA_IO_PORT 0x330
     
    4959#define SCSI_TXDIR_TO_DEVICE   1
    5060
    51 #define VBSCSI_BUSY (1 << 0)
    52 
    53 //#define VBOX_SCSI_DEBUG 1 /* temporary */
    54 
    55 #ifdef VBOX_SCSI_DEBUG
    56 # define VBSCSI_DEBUG(...)    BX_INFO(__VA_ARGS__)
    57 #else
    58 # define VBSCSI_DEBUG(...)
    59 #endif
     61#pragma pack(1)
     62
     63/* READ_10/WRITE_10 CDB layout. */
     64typedef struct {
     65    uint16_t    command;    /* Command. */
     66    uint32_t    lba;        /* LBA, MSB first! */
     67    uint8_t     pad1;       /* Unused. */
     68    uint16_t    nsect;      /* Sector count, MSB first! */
     69    uint8_t     pad2;       /* Unused. */
     70} cdb_rw10;
     71
     72#pragma pack()
     73
     74ct_assert(sizeof(cdb_rw10) == 10);
    6075
    6176int scsi_cmd_data_in(uint16_t io_base, uint8_t device_id, uint8_t __far *aCDB,
     
    146161{
    147162    uint8_t             rc;
    148     uint8_t             aCDB[10];
     163    cdb_rw10            cdb;
    149164    uint16_t            io_base;
    150165    uint8_t             target_id;
     
    154169        BX_PANIC("scsi_read_sectors: device_id out of range %d\n", device_id);
    155170
     171    /* Prepare a CDB. */
     172    cdb.command = SCSI_READ_10;
     173    cdb.lba     = swap_32(lba);
     174    cdb.pad1    = 0;
     175    cdb.nsect   = swap_16(count);
     176    cdb.pad2    = 0;
     177
    156178    bios_dsk = read_word(0x0040, 0x000E) :> &EbdaData->bdisk;
    157 
    158     /* Reset the count of transferred sectors/bytes. */
    159     bios_dsk->trsfsectors = 0;
    160     bios_dsk->trsfbytes   = 0;
    161 
    162     /* Prepare CDB */
    163     //@todo: make CDB a struct, this is stupid
    164     aCDB[0] = SCSI_READ_10;
    165     aCDB[1] = 0;
    166     aCDB[2] = (uint8_t)(lba >> 24);
    167     aCDB[3] = (uint8_t)(lba >> 16);
    168     aCDB[4] = (uint8_t)(lba >>  8);
    169     aCDB[5] = (uint8_t)(lba);
    170     aCDB[6] = 0;
    171     aCDB[7] = (uint8_t)(count >> 8);
    172     aCDB[8] = (uint8_t)(count);
    173     aCDB[9] = 0;
    174179
    175180    io_base   = bios_dsk->scsidev[device_id].io_base;
    176181    target_id = bios_dsk->scsidev[device_id].target_id;
    177182
    178     rc = scsi_cmd_data_in(io_base, target_id, aCDB, 10, buffer, (count * 512));
     183    rc = scsi_cmd_data_in(io_base, target_id, (void __far *)&cdb, 10, buffer, (count * 512));
    179184
    180185    if (!rc)
    181186    {
    182         bios_dsk->trsfsectors = count;
    183         bios_dsk->trsfbytes   = count * 512;
     187        bios_dsk->drqp.trsfsectors = count;
     188        bios_dsk->drqp.trsfbytes   = count * 512;
    184189    }
    185190
     
    199204{
    200205    uint8_t             rc;
    201     uint8_t             aCDB[10];
     206    cdb_rw10            cdb;
    202207    uint16_t            io_base;
    203208    uint8_t             target_id;
     
    207212        BX_PANIC("scsi_write_sectors: device_id out of range %d\n", device_id);
    208213
     214    /* Prepare a CDB. */
     215    cdb.command = SCSI_WRITE_10;
     216    cdb.lba     = swap_32(lba);
     217    cdb.pad1    = 0;
     218    cdb.nsect   = swap_16(count);
     219    cdb.pad2    = 0;
     220
    209221    bios_dsk = read_word(0x0040, 0x000E) :> &EbdaData->bdisk;
    210 
    211     // Reset count of transferred data
    212     bios_dsk->trsfsectors = 0;
    213     bios_dsk->trsfbytes   = 0;
    214 
    215     /* Prepare CDB */
    216     //@todo: make CDB a struct, this is stupid
    217     aCDB[0] = SCSI_WRITE_10;
    218     aCDB[1] = 0;
    219     aCDB[2] = (uint8_t)(lba >> 24);
    220     aCDB[3] = (uint8_t)(lba >> 16);
    221     aCDB[4] = (uint8_t)(lba >>  8);
    222     aCDB[5] = (uint8_t)(lba);
    223     aCDB[6] = 0;
    224     aCDB[7] = (uint8_t)(count >> 8);
    225     aCDB[8] = (uint8_t)(count);
    226     aCDB[9] = 0;
    227222
    228223    io_base   = bios_dsk->scsidev[device_id].io_base;
    229224    target_id = bios_dsk->scsidev[device_id].target_id;
    230225
    231     rc = scsi_cmd_data_out(io_base, target_id, aCDB, 10, buffer, (count * 512));
     226    rc = scsi_cmd_data_out(io_base, target_id, (void __far *)&cdb, 10, buffer, (count * 512));
    232227
    233228    if (!rc)
    234229    {
    235         bios_dsk->trsfsectors = count;
    236         bios_dsk->trsfbytes   = (count * 512);
     230        bios_dsk->drqp.trsfsectors = count;
     231        bios_dsk->drqp.trsfbytes   = (count * 512);
    237232    }
    238233
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette