SCSIDevice.cpp

Go to the documentation of this file.
00001 /* ES40 emulator.
00002  * Copyright (C) 2007-2008 by the ES40 Emulator Project
00003  *
00004  * WWW    : http://sourceforge.net/projects/es40
00005  * E-mail : camiel@camicom.com
00006  * 
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00020  * 
00021  * Although this is not required, the author would appreciate being notified of, 
00022  * and receiving any modifications you may make to the source code that might serve
00023  * the general public.
00024  */
00025 
00039 #include "StdAfx.h"
00040 #include "SCSIDevice.h"
00041 #include "SCSIBus.h"
00042 
00048 CSCSIDevice::CSCSIDevice(void)
00049 {
00050   int i;
00051   for(i = 0; i < 10; i++)
00052   {
00053     scsi_bus[i] = 0;
00054     scsi_initiator_id[i] = -1;
00055   }
00056 }
00057 
00061 CSCSIDevice::~CSCSIDevice(void)
00062 { }
00063 
00067 void CSCSIDevice::scsi_register(int busno, class CSCSIBus* with, int target)
00068 {
00069   scsi_bus[busno] = with;
00070   scsi_initiator_id[busno] = target;
00071   scsi_bus[busno]->scsi_register(this, busno, target);
00072 }
00073 
00079 bool CSCSIDevice::scsi_arbitrate(int bus)
00080 {
00081   return scsi_bus[bus]->arbitrate(scsi_initiator_id[bus]);
00082 }
00083 
00089 bool CSCSIDevice::scsi_select(int bus, int target)
00090 {
00091   return scsi_bus[bus]->select(scsi_initiator_id[bus], target);
00092 }
00093 
00101 void CSCSIDevice::scsi_select_me(int bus)
00102 {
00103   FAILURE(NotImplemented, "selected device doesn't implement scsi_select_me");
00104 }
00105 
00111 void CSCSIDevice::scsi_set_phase(int bus, int phase)
00112 {
00113   scsi_bus[bus]->set_phase(scsi_initiator_id[bus], phase);
00114 }
00115 
00121 int CSCSIDevice::scsi_get_phase(int bus)
00122 {
00123   return scsi_bus[bus]->get_phase();
00124 }
00125 
00131 void CSCSIDevice::scsi_free(int bus)
00132 {
00133   return scsi_bus[bus]->free_bus(scsi_initiator_id[bus]);
00134 }
00135 
00146 size_t CSCSIDevice::scsi_expected_xfer_me(int bus)
00147 {
00148   FAILURE(NotImplemented,
00149           "selected device doesn't implement scsi_expected_xfer_me");
00150 }
00151 
00162 size_t CSCSIDevice::scsi_expected_xfer(int bus)
00163 {
00164   return scsi_bus[bus]->targets[scsi_bus[bus]->state.target]->scsi_expected_xfer_me(scsi_bus[bus]->target_bus_no[scsi_bus[bus]->state.target]);
00165 }
00166 
00176 void* CSCSIDevice::scsi_xfer_ptr_me(int bus, size_t bytes)
00177 {
00178   FAILURE(NotImplemented, "selected device doesn't implement scsi_xfer_ptr_me");
00179 }
00180 
00199 void* CSCSIDevice::scsi_xfer_ptr(int bus, size_t bytes)
00200 {
00201   return scsi_bus[bus]->targets[scsi_bus[bus]->state.target]->scsi_xfer_ptr_me(scsi_bus[bus]->target_bus_no[scsi_bus[bus]->state.target],
00202                                                                                bytes);
00203 }
00204 
00214 void CSCSIDevice::scsi_xfer_done_me(int bus)
00215 {
00216   FAILURE(NotImplemented, "selected device doesn't implement scsi_xfer_done_me");
00217 }
00218 
00228 void CSCSIDevice::scsi_xfer_done(int bus)
00229 {
00230   scsi_bus[bus]->targets[scsi_bus[bus]->state.target]->scsi_xfer_done_me(scsi_bus[bus]->target_bus_no[scsi_bus[bus]->state.target]);
00231 }

SourceForge.net Logo
Project space on SourceForge.net