VirtualBox

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

Last change on this file since 27933 was 27901, checked in by vboxsync, 15 years ago

OSE header fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.4 KB
Line 
1/* $Id: vscsi.h 27901 2010-03-31 14:07:26Z 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.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 * 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
37RT_C_DECLS_BEGIN
38
39#ifdef IN_RING0
40# error "There are no VBox VSCSI APIs available in Ring-0 Host Context!"
41#endif
42
43/** A virtual SCSI device handle */
44typedef struct VSCSIDEVICEINT *VSCSIDEVICE;
45/** A pointer to a virtual SCSI device handle. */
46typedef VSCSIDEVICE *PVSCSIDEVICE;
47/** A virtual SCSI LUN handle. */
48typedef struct VSCSILUNINT *VSCSILUN;
49/** A pointer to a virtual SCSI LUN handle. */
50typedef VSCSILUN *PVSCSILUN;
51/** A virtual SCSI request handle. */
52typedef struct VSCSIREQINT *VSCSIREQ;
53/** A pointer to a virtual SCSI request handle. */
54typedef VSCSIREQ *PVSCSIREQ;
55/** A SCSI I/O request handle. */
56typedef struct VSCSIIOREQINT *VSCSIIOREQ;
57/** A pointer to a SCSI I/O request handle. */
58typedef VSCSIIOREQ *PVSCSIIOREQ;
59
60/**
61 * Virtual SCSI I/O request transfer direction.
62 */
63typedef enum VSCSIIOREQTXDIR
64{
65 /** Invalid direction */
66 VSCSIIOREQTXDIR_INVALID = 0,
67 /** Read */
68 VSCSIIOREQTXDIR_READ,
69 /** Write */
70 VSCSIIOREQTXDIR_WRITE,
71 /** Flush */
72 VSCSIIOREQTXDIR_FLUSH,
73 /** 32bit hack */
74 VSCSIIOREQTXDIR_32BIT_HACK = 0x7fffffff
75} VSCSIIOREQTXDIR;
76/** Pointer to a SCSI LUN type */
77typedef VSCSIIOREQTXDIR *PVSCSIIOREQTXDIR;
78
79/**
80 * LUN types we support
81 */
82typedef enum VSCSILUNTYPE
83{
84 /** Invalid type */
85 VSCSILUNTYPE_INVALID = 0,
86 /** Hard disk (SBC) */
87 VSCSILUNTYPE_SBC,
88 /** CD/DVD drive (MMC) */
89 VSCSILUNTYPE_MMC,
90 /** Last value to indicate an invalid device */
91 VSCSILUNTYPE_LAST,
92 /** 32bit hack */
93 VSCSILUNTYPE_32BIT_HACK = 0x7fffffff
94} VSCSILUNTYPE;
95/** Pointer to a SCSI LUN type */
96typedef VSCSILUNTYPE *PVSCSILUNTYPE;
97
98/**
99 * Virtual SCSI LUN I/O Callback table.
100 */
101typedef struct VSCSILUNIOCALLBACKS
102{
103 /**
104 * Retrieve the size of the underlying medium.
105 *
106 * @returns VBox status status code.
107 * @param hVScsiLun Virtual SCSI LUN handle.
108 * @param pvScsiLunUser Opaque user data which may
109 * be used to identify the medium.
110 * @param pcbSize Where to store the size of the
111 * medium.
112 */
113 DECLR3CALLBACKMEMBER(int, pfnVScsiLunMediumGetSize, (VSCSILUN hVScsiLun,
114 void *pvScsiLunUser,
115 uint64_t *pcbSize));
116
117 /**
118 * Enqueue a read or write request from the medium.
119 *
120 * @returns VBox status status code.
121 * @param hVScsiLun Virtual SCSI LUN handle.
122 * @param pvScsiLunUser Opaque user data which may
123 * be used to identify the medium.
124 * @param hVScsiIoReq Virtual SCSI I/O request handle.
125 */
126 DECLR3CALLBACKMEMBER(int, pfnVScsiLunReqTransferEnqueue, (VSCSILUN hVScsiLun,
127 void *pvScsiLunUser,
128 VSCSIIOREQ hVScsiIoReq));
129
130} VSCSILUNIOCALLBACKS;
131/** Pointer to a virtual SCSI LUN I/O callback table. */
132typedef VSCSILUNIOCALLBACKS *PVSCSILUNIOCALLBACKS;
133
134/**
135 * The virtual SCSI request completed callback.
136 */
137typedef DECLCALLBACK(void) FNVSCSIREQCOMPLETED(VSCSIDEVICE hVScsiDevice,
138 void *pvVScsiDeviceUser,
139 void *pvVScsiReqUser,
140 int rcReq);
141/** Pointer to a virtual SCSI request completed callback. */
142typedef FNVSCSIREQCOMPLETED *PFNVSCSIREQCOMPLETED;
143
144/**
145 * Create a new empty SCSI device instance.
146 *
147 * @returns VBox status code.
148 * @param phVScsiDevice Where to store the SCSI device handle.
149 * @param pfnVScsiReqCompleted The method call after a request completed.
150 * @param pvVScsiDeviceUser Opaque user data given in the completion callback.
151 */
152VBOXDDU_DECL(int) VSCSIDeviceCreate(PVSCSIDEVICE phVScsiDevice,
153 PFNVSCSIREQCOMPLETED pfnVScsiReqCompleted,
154 void *pvVScsiDeviceUser);
155
156/**
157 * Destroy a SCSI device instance.
158 *
159 * @returns VBox status code.
160 * @param hScsiDevice The SCSI device handle to destroy.
161 */
162VBOXDDU_DECL(int) VSCSIDeviceDestroy(VSCSIDEVICE hVScsiDevice);
163
164/**
165 * Attach a LUN to the SCSI device.
166 *
167 * @returns VBox status code.
168 * @param hScsiDevice The SCSI device handle to add the LUN to.
169 * @param hScsiLun The LUN handle to add.
170 * @param iLun The LUN number.
171 */
172VBOXDDU_DECL(int) VSCSIDeviceLunAttach(VSCSIDEVICE hVScsiDevice, VSCSILUN hVScsiLun, uint32_t iLun);
173
174/**
175 * Detach a LUN from the SCSI device.
176 *
177 * @returns VBox status code.
178 * @param hVScsiDevice The SCSI device handle to add the LUN to.
179 * @param iLun The LUN number to remove.
180 * @param phVScsiLun Where to store the detached LUN handle.
181 */
182VBOXDDU_DECL(int) VSCSIDeviceLunDetach(VSCSIDEVICE hVScsiDevice, uint32_t iLun,
183 PVSCSILUN phVScsiLun);
184
185/**
186 * Return the SCSI LUN handle.
187 *
188 * @returns VBox status code.
189 * @param hVScsiDevice The SCSI device handle.
190 * @param iLun The LUN number to get.
191 * @param phVScsiLun Where to store the LUN handle.
192 */
193VBOXDDU_DECL(int) VSCSIDeviceLunGet(VSCSIDEVICE hVScsiDevice, uint32_t iLun,
194 PVSCSILUN phVScsiLun);
195
196/**
197 * Enqueue a request to the SCSI device.
198 *
199 * @returns VBox status code.
200 * @param hVScsiDevice The SCSI device handle.
201 * @param hVScsiReq The SCSI request handle to enqueue.
202 */
203VBOXDDU_DECL(int) VSCSIDeviceReqEnqueue(VSCSIDEVICE hVScsiDevice, VSCSIREQ hVScsiReq);
204
205/**
206 * Allocate a new request handle.
207 *
208 * @returns VBox status code.
209 * @param phVScsiDevice The SCSI device handle.
210 * @param phVScsiReq Where to SCSI request handle.
211 * @param iLun The LUN the request is for.
212 * @param pbCDB The CDB for the request.
213 * @param cbCDB The size of the CDB in bytes.
214 * @param cbSGList Number of bytes the S/G list describes.
215 * @param cSGListEntries Number of S/G list entries.
216 * @param paSGList Pointer to the S/G list.
217 * @param pbSense Pointer to the sense buffer.
218 * @param cbSense Size of the sense buffer.
219 * @param pvVScsiReqUser Opqaue user data returned when the request completes.
220 */
221VBOXDDU_DECL(int) VSCSIDeviceReqCreate(VSCSIDEVICE hVScsiDevice, PVSCSIREQ phVScsiReq,
222 uint32_t iLun, uint8_t *pbCDB, size_t cbCDB,
223 size_t cbSGList, unsigned cSGListEntries,
224 PPDMDATASEG paSGList, uint8_t *pbSense,
225 size_t cbSense, void *pvVScsiReqUser);
226
227/**
228 * Create a new LUN.
229 *
230 * @returns VBox status code.
231 * @param phVScsiLun Where to store the SCSI LUN handle.
232 * @param enmLunType The Lun type.
233 * @param pVScsiLunIoCallbacks Pointer to the I/O callbacks to use for his LUN.
234 * @param pvVScsiLunUser Opaque user argument which
235 * is returned in the pvScsiLunUser parameter
236 * when the request completion callback is called.
237 */
238VBOXDDU_DECL(int) VSCSILunCreate(PVSCSILUN phVScsiLun, VSCSILUNTYPE enmLunType,
239 PVSCSILUNIOCALLBACKS pVScsiLunIoCallbacks,
240 void *pvVScsiLunUser);
241
242/**
243 * Destroy virtual SCSI LUN.
244 *
245 * @returns VBox status code.
246 * @param hVScsiLun The virtal SCSI LUN handle to destroy.
247 */
248VBOXDDU_DECL(int) VSCSILunDestroy(VSCSILUN hVScsiLun);
249
250/**
251 * Notify a that a I/O request completed.
252 *
253 * @returns VBox status code.
254 * @param hVScsiIoReq The I/O request handle that completed.
255 * This is given when a I/O callback for
256 * the LUN is called by the virtual SCSI layer.
257 * @param rcIoReq The status code the I/O request completed with.
258 */
259VBOXDDU_DECL(int) VSCSIIoReqCompleted(VSCSIIOREQ hVScsiIoReq, int rcIoReq);
260
261/**
262 * Query the transfer direction of the I/O request.
263 *
264 * @returns Transfer direction.of the given I/O request
265 * @param hVScsiIoReq The SCSI I/O request handle.
266 */
267VBOXDDU_DECL(VSCSIIOREQTXDIR) VSCSIIoReqTxDirGet(VSCSIIOREQ hVScsiIoReq);
268
269/**
270 * Query I/O parameters.
271 *
272 * @returns VBox status code.
273 * @param hVScsiIoReq The SCSI I/O request handle.
274 * @param puOffset Where to store the start offset.
275 * @param pcbTransfer Where to store the amount of bytes to transfer.
276 * @param pcSeg Where to store the number of segments in the S/G list.
277 * @param pcbSeg Where to store the number of bytes the S/G list describes.
278 * @param ppaSeg Where to store the pointer to the S/G list.
279 */
280VBOXDDU_DECL(int) VSCSIIoReqParamsGet(VSCSIIOREQ hVScsiIoReq, uint64_t *puOffset,
281 size_t *pcbTransfer, unsigned *pcSeg,
282 size_t *pcbSeg, PCPDMDATASEG *ppaSeg);
283
284RT_C_DECLS_END
285
286#endif /* ___VBox_vscsi_h */
287
Note: See TracBrowser for help on using the repository browser.

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