VBoxSCSI.h revision 3f8dc16a69546ae938abc5b07b62693316cfb0ce
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * VBox storage devices - Simple SCSI interface for BIOS access.
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * Copyright (C) 2006-2012 Oracle Corporation
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * available from http://www.virtualbox.org. This file is free software;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * you can redistribute it and/or modify it under the terms of the GNU
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * General Public License (GPL) as published by the Free Software
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync/** @page pg_drv_scsi Simple SCSI interface for BIOS access.
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * This is a simple interface to access SCSI devices from the BIOS which is
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * shared between the BusLogic and the LsiLogic SCSI host adapters to simplify
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * the BIOS part.
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * The BusLogic interface if available will be starting at port 0x330 and the
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * LsiLogic starts at 0x340 and each will have a size of 4 ports. The ports are
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * used as described below:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * +--------+--------+----------+
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * | Offset | Access | Purpose |
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * +--------+--------+----------+
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * | 0 | Write | Command |
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * +--------+--------+----------+
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * | 0 | Read | Status |
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * +--------+--------+----------+
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * | 1 | Write | Data in |
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * +--------+--------+----------+
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * | 1 | Read | Data out |
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * +--------+--------+----------+
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * | 2 | R/W | Detect |
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * +--------+--------+----------+
b7a04f3d42ada4fd6106ef61c28f7ef0a64af878vboxsync * | 3 | Read | SCSI rc |
b7a04f3d42ada4fd6106ef61c28f7ef0a64af878vboxsync * +--------+--------+----------+
060711075893fd64c1eaaefe41f318d83011e4e3vboxsync * | 3 | Write | Reset |
060711075893fd64c1eaaefe41f318d83011e4e3vboxsync * +--------+--------+----------+
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * The register at port 0 receives the SCSI CDB issued from the driver when
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * writing to it but before writing the actual CDB the first write gives the
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * size of the CDB in bytes.
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * Reading the port at offset 0 gives status information about the adapter. If
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * the busy bit is set the adapter is processing a previous issued request if it is
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * cleared the command finished and the adapter can process another request.
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * The driver has to poll this bit because the adapter will not assert an IRQ
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * for simplicity reasons.
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * The register at offset 2 is to detect if a host adapter is available. If the
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * driver writes a value to this port and gets the same value after reading it
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * again the adapter is available.
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * Any write to the register at offset 3 causes the interface to be reset. A
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * read returns the SCSI status code of the last operation.
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync * This part has no R0 or RC components.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/*******************************************************************************
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync* Header Files *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync*******************************************************************************/
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync//#define DEBUG
060711075893fd64c1eaaefe41f318d83011e4e3vboxsync/** Maximum CDB size the BIOS driver sends. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsynctypedef struct VBOXSCSI
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The identify register. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The target device. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Transfer direction. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The size of the CDB we are issuing. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The command to issue. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Current position in the array. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Pointer to the buffer holding the data. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Size of the buffer in bytes. */
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync /** Current position in the buffer (offBuf if you like). */
b7a04f3d42ada4fd6106ef61c28f7ef0a64af878vboxsync /** The result code of last operation. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Flag whether a request is pending. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync volatile bool fBusy;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The state we are in when fetching a command from the BIOS. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncint vboxscsiReadRegister(PVBOXSCSI pVBoxSCSI, uint8_t iRegister, uint32_t *pu32Value);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncint vboxscsiWriteRegister(PVBOXSCSI pVBoxSCSI, uint8_t iRegister, uint8_t uVal);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncint vboxscsiSetupRequest(PVBOXSCSI pVBoxSCSI, PPDMSCSIREQUEST pScsiRequest, uint32_t *puTargetDevice);
b7a04f3d42ada4fd6106ef61c28f7ef0a64af878vboxsyncint vboxscsiRequestFinished(PVBOXSCSI pVBoxSCSI, PPDMSCSIREQUEST pScsiRequest, int rcCompletion);
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsyncvoid vboxscsiSetRequestRedo(PVBOXSCSI pVBoxSCSI, PPDMSCSIREQUEST pScsiRequest);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncint vboxscsiWriteString(PPDMDEVINS pDevIns, PVBOXSCSI pVBoxSCSI, uint8_t iRegister,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTGCPTR *pGCPtrSrc, PRTGCUINTREG pcTransfer, unsigned cb);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncint vboxscsiReadString(PPDMDEVINS pDevIns, PVBOXSCSI pVBoxSCSI, uint8_t iRegister,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTGCPTR *pGCPtrDst, PRTGCUINTREG pcTransfer, unsigned cb);
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync#endif /* IN_RING3 */
3f8dc16a69546ae938abc5b07b62693316cfb0cevboxsync#endif /* !___Storage_VBoxSCSI_h */