VirtualBox

source: vbox/trunk/src/VBox/Devices/Storage/VBoxSCSI.h@ 44533

Last change on this file since 44533 was 44533, checked in by vboxsync, 12 years ago

VBoxSVSI.cpp: doxygen and hungarian adjustments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/* $Id: VBoxSCSI.h 44533 2013-02-04 20:55:12Z vboxsync $ */
2/** @file
3 * VBox storage devices - Simple SCSI interface for BIOS access.
4 */
5
6/*
7 * Copyright (C) 2006-2012 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/** @page pg_drv_scsi Simple SCSI interface for BIOS access.
19 *
20 * This is a simple interface to access SCSI devices from the BIOS which is
21 * shared between the BusLogic and the LsiLogic SCSI host adapters to simplify
22 * the BIOS part.
23 *
24 * The BusLogic interface if available will be starting at port 0x330 and the
25 * LsiLogic starts at 0x340 and each will have a size of 4 ports. The ports are
26 * used as described below:
27 *
28 * +--------+--------+----------+
29 * | Offset | Access | Purpose |
30 * +--------+--------+----------+
31 * | 0 | Write | Command |
32 * +--------+--------+----------+
33 * | 0 | Read | Status |
34 * +--------+--------+----------+
35 * | 1 | Write | Data in |
36 * +--------+--------+----------+
37 * | 1 | Read | Data out |
38 * +--------+--------+----------+
39 * | 2 | R/W | Detect |
40 * +--------+--------+----------+
41 * | 3 | Read | SCSI rc |
42 * +--------+--------+----------+
43 * | 3 | Write | Reset |
44 * +--------+--------+----------+
45 *
46 * The register at port 0 receives the SCSI CDB issued from the driver when
47 * writing to it but before writing the actual CDB the first write gives the
48 * size of the CDB in bytes.
49 *
50 * Reading the port at offset 0 gives status information about the adapter. If
51 * the busy bit is set the adapter is processing a previous issued request if it is
52 * cleared the command finished and the adapter can process another request.
53 * The driver has to poll this bit because the adapter will not assert an IRQ
54 * for simplicity reasons.
55 *
56 * The register at offset 2 is to detect if a host adapter is available. If the
57 * driver writes a value to this port and gets the same value after reading it
58 * again the adapter is available.
59 *
60 * Any write to the register at offset 3 causes the interface to be reset. A
61 * read returns the SCSI status code of the last operation.
62 *
63 * This part has no R0 or RC components.
64 */
65
66#ifndef ___Storage_VBoxSCSI_h
67#define ___Storage_VBoxSCSI_h
68
69/*******************************************************************************
70* Header Files *
71*******************************************************************************/
72//#define DEBUG
73#include <VBox/vmm/pdmdev.h>
74#include <VBox/scsi.h>
75
76typedef enum VBOXSCSISTATE
77{
78 VBOXSCSISTATE_NO_COMMAND = 0x00,
79 VBOXSCSISTATE_READ_TXDIR = 0x01,
80 VBOXSCSISTATE_READ_CDB_SIZE_BUFHI = 0x02,
81 VBOXSCSISTATE_READ_BUFFER_SIZE_LSB = 0x03,
82 VBOXSCSISTATE_READ_BUFFER_SIZE_MID = 0x04,
83 VBOXSCSISTATE_READ_COMMAND = 0x05,
84 VBOXSCSISTATE_COMMAND_READY = 0x06
85} VBOXSCSISTATE;
86
87#define VBOXSCSI_TXDIR_FROM_DEVICE 0
88#define VBOXSCSI_TXDIR_TO_DEVICE 1
89
90/** Maximum CDB size the BIOS driver sends. */
91#define VBOXSCSI_CDB_SIZE_MAX 10
92
93typedef struct VBOXSCSI
94{
95 /** The identify register. */
96 uint8_t regIdentify;
97 /** The target device. */
98 uint8_t uTargetDevice;
99 /** Transfer direction. */
100 uint8_t uTxDir;
101 /** The size of the CDB we are issuing. */
102 uint8_t cbCDB;
103 /** The command to issue. */
104 uint8_t abCDB[12];
105 /** Current position in the array. */
106 uint8_t iCDB;
107
108#if HC_ARCH_BITS == 64
109 uint32_t Alignment0;
110#endif
111
112 /** Pointer to the buffer holding the data. */
113 R3PTRTYPE(uint8_t *) pbBuf;
114 /** Size of the buffer in bytes. */
115 uint32_t cbBuf;
116 /** Current position in the buffer (offBuf if you like). */
117 uint32_t iBuf;
118 /** The result code of last operation. */
119 int32_t rcCompletion;
120#if HC_ARCH_BITS == 64
121 uint32_t Alignment1;
122#endif
123 /** Flag whether a request is pending. */
124 volatile bool fBusy;
125 /** The state we are in when fetching a command from the BIOS. */
126 VBOXSCSISTATE enmState;
127} VBOXSCSI, *PVBOXSCSI;
128
129#define VBOX_SCSI_BUSY RT_BIT(0)
130#define VBOX_SCSI_ERROR RT_BIT(1)
131
132#ifdef IN_RING3
133RT_C_DECLS_BEGIN
134int vboxscsiInitialize(PVBOXSCSI pVBoxSCSI);
135int vboxscsiReadRegister(PVBOXSCSI pVBoxSCSI, uint8_t iRegister, uint32_t *pu32Value);
136int vboxscsiWriteRegister(PVBOXSCSI pVBoxSCSI, uint8_t iRegister, uint8_t uVal);
137int vboxscsiSetupRequest(PVBOXSCSI pVBoxSCSI, PPDMSCSIREQUEST pScsiRequest, uint32_t *puTargetDevice);
138int vboxscsiRequestFinished(PVBOXSCSI pVBoxSCSI, PPDMSCSIREQUEST pScsiRequest, int rcCompletion);
139void vboxscsiSetRequestRedo(PVBOXSCSI pVBoxSCSI, PPDMSCSIREQUEST pScsiRequest);
140int vboxscsiWriteString(PPDMDEVINS pDevIns, PVBOXSCSI pVBoxSCSI, uint8_t iRegister,
141 RTGCPTR *pGCPtrSrc, PRTGCUINTREG pcTransfer, unsigned cb);
142int vboxscsiReadString(PPDMDEVINS pDevIns, PVBOXSCSI pVBoxSCSI, uint8_t iRegister,
143 RTGCPTR *pGCPtrDst, PRTGCUINTREG pcTransfer, unsigned cb);
144RT_C_DECLS_END
145#endif /* IN_RING3 */
146
147#endif /* !___Storage_VBoxSCSI_h */
148
Note: See TracBrowser for help on using the repository browser.

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