VirtualBox

source: vbox/trunk/include/VBox/vscsi.h@ 28228

最後變更 在這個檔案從28228是 28065,由 vboxsync 提交於 15 年 前

Storage: Convert from PDMDATASEG to RTSGSEG to avoid casting between those two in VBoxHDD and more async I/O updates

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 10.4 KB
 
1/* $Id: vscsi.h 28065 2010-04-07 20:54:34Z vboxsync $ */
2/** @file
3 * VBox storage drivers: Virtual SCSI driver
4 */
5
6/*
7 * Copyright (C) 2006-2010 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.alldomusa.eu.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 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 *
26 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31#ifndef ___VBox_vscsi_h
32#define ___VBox_vscsi_h
33
34#include <VBox/cdefs.h>
35#include <VBox/types.h>
36#include <iprt/sg.h>
37
38RT_C_DECLS_BEGIN
39
40#ifdef IN_RING0
41# error "There are no VBox VSCSI APIs available in Ring-0 Host Context!"
42#endif
43
44/** A virtual SCSI device handle */
45typedef struct VSCSIDEVICEINT *VSCSIDEVICE;
46/** A pointer to a virtual SCSI device handle. */
47typedef VSCSIDEVICE *PVSCSIDEVICE;
48/** A virtual SCSI LUN handle. */
49typedef struct VSCSILUNINT *VSCSILUN;
50/** A pointer to a virtual SCSI LUN handle. */
51typedef VSCSILUN *PVSCSILUN;
52/** A virtual SCSI request handle. */
53typedef struct VSCSIREQINT *VSCSIREQ;
54/** A pointer to a virtual SCSI request handle. */
55typedef VSCSIREQ *PVSCSIREQ;
56/** A SCSI I/O request handle. */
57typedef struct VSCSIIOREQINT *VSCSIIOREQ;
58/** A pointer to a SCSI I/O request handle. */
59typedef VSCSIIOREQ *PVSCSIIOREQ;
60
61/**
62 * Virtual SCSI I/O request transfer direction.
63 */
64typedef enum VSCSIIOREQTXDIR
65{
66 /** Invalid direction */
67 VSCSIIOREQTXDIR_INVALID = 0,
68 /** Read */
69 VSCSIIOREQTXDIR_READ,
70 /** Write */
71 VSCSIIOREQTXDIR_WRITE,
72 /** Flush */
73 VSCSIIOREQTXDIR_FLUSH,
74 /** 32bit hack */
75 VSCSIIOREQTXDIR_32BIT_HACK = 0x7fffffff
76} VSCSIIOREQTXDIR;
77/** Pointer to a SCSI LUN type */
78typedef VSCSIIOREQTXDIR *PVSCSIIOREQTXDIR;
79
80/**
81 * LUN types we support
82 */
83typedef enum VSCSILUNTYPE
84{
85 /** Invalid type */
86 VSCSILUNTYPE_INVALID = 0,
87 /** Hard disk (SBC) */
88 VSCSILUNTYPE_SBC,
89 /** CD/DVD drive (MMC) */
90 VSCSILUNTYPE_MMC,
91 /** Last value to indicate an invalid device */
92 VSCSILUNTYPE_LAST,
93 /** 32bit hack */
94 VSCSILUNTYPE_32BIT_HACK = 0x7fffffff
95} VSCSILUNTYPE;
96/** Pointer to a SCSI LUN type */
97typedef VSCSILUNTYPE *PVSCSILUNTYPE;
98
99/**
100 * Virtual SCSI LUN I/O Callback table.
101 */
102typedef struct VSCSILUNIOCALLBACKS
103{
104 /**
105 * Retrieve the size of the underlying medium.
106 *
107 * @returns VBox status status code.
108 * @param hVScsiLun Virtual SCSI LUN handle.
109 * @param pvScsiLunUser Opaque user data which may
110 * be used to identify the medium.
111 * @param pcbSize Where to store the size of the
112 * medium.
113 */
114 DECLR3CALLBACKMEMBER(int, pfnVScsiLunMediumGetSize, (VSCSILUN hVScsiLun,
115 void *pvScsiLunUser,
116 uint64_t *pcbSize));
117
118 /**
119 * Enqueue a read or write request from the medium.
120 *
121 * @returns VBox status status code.
122 * @param hVScsiLun Virtual SCSI LUN handle.
123 * @param pvScsiLunUser Opaque user data which may
124 * be used to identify the medium.
125 * @param hVScsiIoReq Virtual SCSI I/O request handle.
126 */
127 DECLR3CALLBACKMEMBER(int, pfnVScsiLunReqTransferEnqueue, (VSCSILUN hVScsiLun,
128 void *pvScsiLunUser,
129 VSCSIIOREQ hVScsiIoReq));
130
131} VSCSILUNIOCALLBACKS;
132/** Pointer to a virtual SCSI LUN I/O callback table. */
133typedef VSCSILUNIOCALLBACKS *PVSCSILUNIOCALLBACKS;
134
135/**
136 * The virtual SCSI request completed callback.
137 */
138typedef DECLCALLBACK(void) FNVSCSIREQCOMPLETED(VSCSIDEVICE hVScsiDevice,
139 void *pvVScsiDeviceUser,
140 void *pvVScsiReqUser,
141 int rcReq);
142/** Pointer to a virtual SCSI request completed callback. */
143typedef FNVSCSIREQCOMPLETED *PFNVSCSIREQCOMPLETED;
144
145/**
146 * Create a new empty SCSI device instance.
147 *
148 * @returns VBox status code.
149 * @param phVScsiDevice Where to store the SCSI device handle.
150 * @param pfnVScsiReqCompleted The method call after a request completed.
151 * @param pvVScsiDeviceUser Opaque user data given in the completion callback.
152 */
153VBOXDDU_DECL(int) VSCSIDeviceCreate(PVSCSIDEVICE phVScsiDevice,
154 PFNVSCSIREQCOMPLETED pfnVScsiReqCompleted,
155 void *pvVScsiDeviceUser);
156
157/**
158 * Destroy a SCSI device instance.
159 *
160 * @returns VBox status code.
161 * @param hScsiDevice The SCSI device handle to destroy.
162 */
163VBOXDDU_DECL(int) VSCSIDeviceDestroy(VSCSIDEVICE hVScsiDevice);
164
165/**
166 * Attach a LUN to the SCSI device.
167 *
168 * @returns VBox status code.
169 * @param hScsiDevice The SCSI device handle to add the LUN to.
170 * @param hScsiLun The LUN handle to add.
171 * @param iLun The LUN number.
172 */
173VBOXDDU_DECL(int) VSCSIDeviceLunAttach(VSCSIDEVICE hVScsiDevice, VSCSILUN hVScsiLun, uint32_t iLun);
174
175/**
176 * Detach a LUN from the SCSI device.
177 *
178 * @returns VBox status code.
179 * @param hVScsiDevice The SCSI device handle to add the LUN to.
180 * @param iLun The LUN number to remove.
181 * @param phVScsiLun Where to store the detached LUN handle.
182 */
183VBOXDDU_DECL(int) VSCSIDeviceLunDetach(VSCSIDEVICE hVScsiDevice, uint32_t iLun,
184 PVSCSILUN phVScsiLun);
185
186/**
187 * Return the SCSI LUN handle.
188 *
189 * @returns VBox status code.
190 * @param hVScsiDevice The SCSI device handle.
191 * @param iLun The LUN number to get.
192 * @param phVScsiLun Where to store the LUN handle.
193 */
194VBOXDDU_DECL(int) VSCSIDeviceLunGet(VSCSIDEVICE hVScsiDevice, uint32_t iLun,
195 PVSCSILUN phVScsiLun);
196
197/**
198 * Enqueue a request to the SCSI device.
199 *
200 * @returns VBox status code.
201 * @param hVScsiDevice The SCSI device handle.
202 * @param hVScsiReq The SCSI request handle to enqueue.
203 */
204VBOXDDU_DECL(int) VSCSIDeviceReqEnqueue(VSCSIDEVICE hVScsiDevice, VSCSIREQ hVScsiReq);
205
206/**
207 * Allocate a new request handle.
208 *
209 * @returns VBox status code.
210 * @param phVScsiDevice The SCSI device handle.
211 * @param phVScsiReq Where to SCSI request handle.
212 * @param iLun The LUN the request is for.
213 * @param pbCDB The CDB for the request.
214 * @param cbCDB The size of the CDB in bytes.
215 * @param cbSGList Number of bytes the S/G list describes.
216 * @param cSGListEntries Number of S/G list entries.
217 * @param paSGList Pointer to the S/G list.
218 * @param pbSense Pointer to the sense buffer.
219 * @param cbSense Size of the sense buffer.
220 * @param pvVScsiReqUser Opqaue user data returned when the request completes.
221 */
222VBOXDDU_DECL(int) VSCSIDeviceReqCreate(VSCSIDEVICE hVScsiDevice, PVSCSIREQ phVScsiReq,
223 uint32_t iLun, uint8_t *pbCDB, size_t cbCDB,
224 size_t cbSGList, unsigned cSGListEntries,
225 PCRTSGSEG paSGList, uint8_t *pbSense,
226 size_t cbSense, void *pvVScsiReqUser);
227
228/**
229 * Create a new LUN.
230 *
231 * @returns VBox status code.
232 * @param phVScsiLun Where to store the SCSI LUN handle.
233 * @param enmLunType The Lun type.
234 * @param pVScsiLunIoCallbacks Pointer to the I/O callbacks to use for his LUN.
235 * @param pvVScsiLunUser Opaque user argument which
236 * is returned in the pvScsiLunUser parameter
237 * when the request completion callback is called.
238 */
239VBOXDDU_DECL(int) VSCSILunCreate(PVSCSILUN phVScsiLun, VSCSILUNTYPE enmLunType,
240 PVSCSILUNIOCALLBACKS pVScsiLunIoCallbacks,
241 void *pvVScsiLunUser);
242
243/**
244 * Destroy virtual SCSI LUN.
245 *
246 * @returns VBox status code.
247 * @param hVScsiLun The virtal SCSI LUN handle to destroy.
248 */
249VBOXDDU_DECL(int) VSCSILunDestroy(VSCSILUN hVScsiLun);
250
251/**
252 * Notify a that a I/O request completed.
253 *
254 * @returns VBox status code.
255 * @param hVScsiIoReq The I/O request handle that completed.
256 * This is given when a I/O callback for
257 * the LUN is called by the virtual SCSI layer.
258 * @param rcIoReq The status code the I/O request completed with.
259 */
260VBOXDDU_DECL(int) VSCSIIoReqCompleted(VSCSIIOREQ hVScsiIoReq, int rcIoReq);
261
262/**
263 * Query the transfer direction of the I/O request.
264 *
265 * @returns Transfer direction.of the given I/O request
266 * @param hVScsiIoReq The SCSI I/O request handle.
267 */
268VBOXDDU_DECL(VSCSIIOREQTXDIR) VSCSIIoReqTxDirGet(VSCSIIOREQ hVScsiIoReq);
269
270/**
271 * Query I/O parameters.
272 *
273 * @returns VBox status code.
274 * @param hVScsiIoReq The SCSI I/O request handle.
275 * @param puOffset Where to store the start offset.
276 * @param pcbTransfer Where to store the amount of bytes to transfer.
277 * @param pcSeg Where to store the number of segments in the S/G list.
278 * @param pcbSeg Where to store the number of bytes the S/G list describes.
279 * @param ppaSeg Where to store the pointer to the S/G list.
280 */
281VBOXDDU_DECL(int) VSCSIIoReqParamsGet(VSCSIIOREQ hVScsiIoReq, uint64_t *puOffset,
282 size_t *pcbTransfer, unsigned *pcSeg,
283 size_t *pcbSeg, PCRTSGSEG *ppaSeg);
284
285RT_C_DECLS_END
286
287#endif /* ___VBox_vscsi_h */
288
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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