--- BasiliskII/src/AmigaOS/scsi_amiga.cpp 2002/01/15 14:58:34 1.6 +++ BasiliskII/src/AmigaOS/scsi_amiga.cpp 2002/09/01 12:01:46 1.8 @@ -1,7 +1,7 @@ /* * scsi_amiga.cpp - SCSI Manager, Amiga specific stuff * - * Basilisk II (C) 1997-2002 Christian Bauer + * Basilisk II (C) 1997-2001 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +22,9 @@ #include #include #include +#define __USE_SYSBASE #include +#include #include "sysdeps.h" #include "main.h" @@ -51,6 +53,8 @@ static UBYTE cmd_buffer[12]; // Buffer const int SENSE_LENGTH = 256; static UBYTE *sense_buffer = NULL; // Buffer for autosense data +static bool direct_transfers_supported = false; // Direct data transfers (bypassing the buffer) are supported + /* * Initialization @@ -67,6 +71,7 @@ void SCSIInit(void) break; case 2: buffer_memf = MEMF_ANY | MEMF_PUBLIC; + direct_transfers_supported = true; break; default: buffer_memf = MEMF_CHIP | MEMF_PUBLIC; @@ -97,7 +102,7 @@ void SCSIInit(void) struct IOStdReq *io = (struct IOStdReq *)CreateIORequest(the_port, sizeof(struct IOStdReq)); if (io == NULL) continue; - if (OpenDevice((UBYTE *)dev_name, dev_unit + lun * 10, (struct IORequest *)io, 0)) { + if (OpenDevice((UBYTE *) dev_name, dev_unit + lun * 10, (struct IORequest *)io, 0)) { DeleteIORequest(io); continue; } @@ -210,23 +215,29 @@ bool scsi_set_target(int id, int lun) bool scsi_send_cmd(size_t data_length, bool reading, int sg_size, uint8 **sg_ptr, uint32 *sg_len, uint16 *stat, uint32 timeout) { - // Check if buffer is large enough, allocate new buffer if needed - if (!try_buffer(data_length)) { - char str[256]; - sprintf(str, GetString(STR_SCSI_BUFFER_ERR), data_length); - ErrorAlert(str); - return false; - } + // Bypass the buffer if there's only one S/G table entry + bool do_direct_transfer = (sg_size == 1 && ((uint32)sg_ptr[0] & 1) == 0 && direct_transfers_supported); + + if (!do_direct_transfer) { + + // Check if buffer is large enough, allocate new buffer if needed + if (!try_buffer(data_length)) { + char str[256]; + sprintf(str, GetString(STR_SCSI_BUFFER_ERR), data_length); + ErrorAlert(str); + return false; + } - // Process S/G table when writing - if (!reading) { - D(bug(" writing to buffer\n")); - uint8 *buffer_ptr = buffer; - for (int i=0; i