Commit made by Daniel, including the implementation of the daemon.
[vdi_driver.git] / src / types.h
blob555539bb6f4f2dcbc8aa91afb2bba1a43ea20564
1 #ifndef TYPES_H
2 #define TYPES_H
4 #include "cdefs.h"
5 #include "config.h"
6 #include "time.h"
7 #include <stdint.h>
9 # define uintptr_t linux_uintptr_t
10 # include <linux/types.h>
11 # include <linux/stddef.h>
12 # undef uintptr_t
14 /** Unsigned integer which can contain a HC ring-3 pointer. */
15 #if R3_ARCH_BITS == 32
16 typedef uint32_t RTR3UINTPTR;
17 #elif R3_ARCH_BITS == 64
18 typedef uint64_t RTR3UINTPTR;
19 #else
20 # error Unsupported R3_ARCH_BITS value.
21 #endif
23 /** Unsigned integer register in the current context. */
24 #if ARCH_BITS == 32
25 typedef uint32_t RTCCUINTREG;
26 #elif ARCH_BITS == 64
27 typedef uint64_t RTCCUINTREG;
28 #else
29 # error "Unsupported ARCH_BITS!"
30 #endif
31 /** Pointer to an unsigned integer register in the current context. */
32 typedef RTCCUINTREG *PRTCCUINTREG;
33 /** Pointer to a const unsigned integer register in the current context. */
34 typedef const RTCCUINTREG *PCRTCCUINTREG;
36 /** HC ring-3 pointer. */
37 #ifdef IN_RING3
38 typedef void * RTR3PTR;
39 #else
40 typedef RTR3UINTPTR RTR3PTR;
41 #endif
43 /** File mode (see iprt/fs.h). */
44 typedef uint32_t RTFMODE;
45 /** Pointer to file mode. */
46 typedef RTFMODE *PRTFMODE;
48 /** User id. */
49 typedef uint32_t RTUID;
50 /** Pointer to a user id. */
51 typedef RTUID *PRTUID;
53 /** Group id. */
54 typedef uint32_t RTGID;
55 /** Pointer to a group id. */
56 typedef RTGID *PRTGID;
58 /** Device unix number. */
59 typedef uint32_t RTDEV;
60 /** Pointer to a device unix number. */
61 typedef RTDEV *PRTDEV;
63 /** i-node number. */
64 typedef uint64_t RTINODE;
65 /** Pointer to a i-node number. */
66 typedef RTINODE *PRTINODE;
68 /**
69 * UUID data type.
71 typedef union RTUUID
73 /** 8-bit view. */
74 uint8_t au8[16];
75 /** 16-bit view. */
76 uint16_t au16[8];
77 /** 32-bit view. */
78 uint32_t au32[4];
79 /** 64-bit view. */
80 uint64_t au64[2];
81 /** The way the UUID is declared by the ext2 guys. */
82 struct
84 uint32_t u32TimeLow;
85 uint16_t u16TimeMid;
86 uint16_t u16TimeHiAndVersion;
87 uint16_t u16ClockSeq;
88 uint8_t au8Node[6];
89 } Gen;
90 /** @deprecated */
91 unsigned char aUuid[16];
92 } RTUUID;
93 /** Pointer to UUID data. */
94 typedef RTUUID *PRTUUID;
95 /** Pointer to readonly UUID data. */
96 typedef const RTUUID *PCRTUUID;
98 /** Unsigned integer. */
99 typedef uint32_t RTUINT;
100 /** File handle. */
101 typedef RTUINT RTFILE;
102 /** Pointer to file handle. */
103 typedef RTFILE *PRTFILE;
104 /** Nil file handle. */
105 #define NIL_RTFILE (~(RTFILE)0)
108 * BIOS translation mode.
110 typedef enum PDMBIOSTRANSLATION
112 /** No translation. */
113 PDMBIOSTRANSLATION_NONE = 1,
114 /** LBA translation. */
115 PDMBIOSTRANSLATION_LBA,
116 /** Automatic select mode. */
117 PDMBIOSTRANSLATION_AUTO
118 } PDMBIOSTRANSLATION;
120 /** Pointer to BIOS translation mode. */
121 typedef PDMBIOSTRANSLATION *PPDMBIOSTRANSLATION;
123 /** Pointer to a media interface. */
124 typedef struct PDMIMEDIA *PPDMIMEDIA;
126 * Media interface.
127 * Makes up the fundation for PDMIBLOCK and PDMIBLOCKBIOS.
129 typedef struct PDMIMEDIA
132 * Read bits.
134 * @returns VBox status code.
135 * @param pInterface Pointer to the interface structure containing the called function pointer.
136 * @param off Offset to start reading from.
137 * @param pvBuf Where to store the read bits.
138 * @param cbRead Number of bytes to read.
139 * @thread Any thread.
141 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMIMEDIA pInterface, uint64_t off, void *pvBuf, size_t cbRead));
144 * Write bits.
146 * @returns VBox status code.
147 * @param pInterface Pointer to the interface structure containing the called function pointer.
148 * @param off Offset to start writing at.
149 * @param pvBuf Where to store the write bits.
150 * @param cbWrite Number of bytes to write.
151 * @thread Any thread.
153 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMIMEDIA pInterface, uint64_t off, const void *pvBuf, size_t cbWrite));
156 * Make sure that the bits written are actually on the storage medium.
158 * @returns VBox status code.
159 * @param pInterface Pointer to the interface structure containing the called function pointer.
160 * @thread Any thread.
162 DECLR3CALLBACKMEMBER(int, pfnFlush,(PPDMIMEDIA pInterface));
165 * Get the media size in bytes.
167 * @returns Media size in bytes.
168 * @param pInterface Pointer to the interface structure containing the called function pointer.
169 * @thread Any thread.
171 DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize,(PPDMIMEDIA pInterface));
174 * Check if the media is readonly or not.
176 * @returns true if readonly.
177 * @returns false if read/write.
178 * @param pInterface Pointer to the interface structure containing the called function pointer.
179 * @thread Any thread.
181 DECLR3CALLBACKMEMBER(bool, pfnIsReadOnly,(PPDMIMEDIA pInterface));
184 * Get stored media geometry - BIOS property.
185 * This is an optional feature of a media.
187 * @returns VBox status code.
188 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
189 * @returns VERR_PDM_GEOMETRY_NOT_SET if the geometry hasn't been set using pfnBiosSetGeometry() yet.
190 * @param pInterface Pointer to the interface structure containing the called function pointer.
191 * @param pcCylinders Number of cylinders.
192 * @param pcHeads Number of heads.
193 * @param pcSectors Number of sectors. This number is 1-based.
194 * @remark This have no influence on the read/write operations.
195 * @thread Any thread.
197 DECLR3CALLBACKMEMBER(int, pfnBiosGetGeometry,(PPDMIMEDIA pInterface, uint32_t *pcCylinders, uint32_t *pcHeads, uint32_t *pcSectors));
200 * Store the media geometry - BIOS property.
201 * This is an optional feature of a media.
203 * @returns VBox status code.
204 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
205 * @param pInterface Pointer to the interface structure containing the called function pointer.
206 * @param cCylinders Number of cylinders.
207 * @param cHeads Number of heads.
208 * @param cSectors Number of sectors. This number is 1-based.
209 * @remark This have no influence on the read/write operations.
210 * @thread The emulation thread.
212 DECLR3CALLBACKMEMBER(int, pfnBiosSetGeometry,(PPDMIMEDIA pInterface, uint32_t cCylinders, uint32_t cHeads, uint32_t cSectors));
215 * Get stored geometry translation mode - BIOS property.
216 * This is an optional feature of a media.
218 * @returns VBox status code.
219 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry translation mode.
220 * @returns VERR_PDM_TRANSLATION_NOT_SET if the translation hasn't been set using pfnBiosSetTranslation() yet.
221 * @param pInterface Pointer to the interface structure containing the called function pointer.
222 * @param penmTranslation Where to store the translation type.
223 * @remark This have no influence on the read/write operations.
224 * @thread Any thread.
226 DECLR3CALLBACKMEMBER(int, pfnBiosGetTranslation,(PPDMIMEDIA pInterface, PPDMBIOSTRANSLATION penmTranslation));
229 * Store media geometry - BIOS property.
230 * This is an optional feature of a media.
232 * @returns VBox status code.
233 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
234 * @param pInterface Pointer to the interface structure containing the called function pointer.
235 * @param enmTranslation The translation type.
236 * @remark This have no influence on the read/write operations.
237 * @thread The emulation thread.
239 DECLR3CALLBACKMEMBER(int, pfnBiosSetTranslation,(PPDMIMEDIA pInterface, PDMBIOSTRANSLATION enmTranslation));
242 * Gets the UUID of the media drive.
244 * @returns VBox status code.
245 * @param pInterface Pointer to the interface structure containing the called function pointer.
246 * @param pUuid Where to store the UUID on success.
247 * @thread Any thread.
249 DECLR3CALLBACKMEMBER(int, pfnGetUuid,(PPDMIMEDIA pInterface, PRTUUID pUuid));
251 } PDMIMEDIA;
253 /** Pointer to a PDM Driver Instance. */
254 typedef struct PDMDRVINS *PPDMDRVINS;
255 /** Pointer to a pointer to a PDM Driver Instance. */
256 typedef PPDMDRVINS *PPPDMDRVINS;
258 /** A file offset / size (off_t). */
259 typedef int64_t RTFOFF;
260 /** Pointer to a file offset / size. */
261 typedef RTFOFF *PRTFOFF;
263 /** File mode (see iprt/fs.h). */
264 typedef uint32_t RTFMODE;
265 /** Pointer to file mode. */
266 typedef RTFMODE *PRTFMODE;
269 * Progress callback.
270 * This will report the completion percentage of an operation.
272 * @returns VINF_SUCCESS.
273 * @returns Error code to cancel the operation with.
274 * @param pVM The VM handle.
275 * @param uPercent Completetion precentage (0-100).
276 * @param pvUser User specified argument.
278 typedef int FNVMPROGRESS(void* pVM, unsigned uPercent, void *pvUser);
279 /** Pointer to a FNVMPROGRESS function. */
280 typedef FNVMPROGRESS *PFNVMPROGRESS;
283 * Generic process callback.
285 * @returns VBox status code. Failure will cancel the operation.
286 * @param uPercentage The percentage of the operation which has been completed.
287 * @param pvUser The user specified argument.
289 typedef int FNRTPROGRESS(unsigned uPrecentage, void *pvUser);
290 /** Pointer to a generic progress callback function, FNRTPROCESS(). */
291 typedef FNRTPROGRESS *PFNRTPROGRESS;
294 * 64-bit unsigned interger union.
296 typedef union RTUINT64U
298 /** Natural view. */
299 uint64_t u;
300 /** Hi/Low view. */
301 struct
303 uint32_t Lo;
304 uint32_t Hi;
305 } s;
306 /** Double-Word view. */
307 struct
309 uint32_t dw0;
310 uint32_t dw1;
311 } DWords;
312 /** Word view. */
313 struct
315 uint16_t w0;
316 uint16_t w1;
317 uint16_t w2;
318 uint16_t w3;
319 } Words;
321 /** 64-bit view. */
322 uint64_t au64[1];
323 /** 32-bit view. */
324 uint32_t au32[2];
325 /** 16-bit view. */
326 uint16_t au16[4];
327 /** 8-bit view. */
328 uint8_t au8[8];
329 } RTUINT64U;
330 /** Pointer to a 64-bit unsigned interger union. */
331 typedef RTUINT64U *PRTUINT64U;
332 /** Pointer to a const 64-bit unsigned interger union. */
333 typedef const RTUINT64U *PCRTUINT64U;
336 * UTF-16 character.
337 * @remark wchar_t is not usable since it's compiler defined.
338 * @remark When we use the term character we're not talking about unicode code point, but
339 * the basic unit of the string encoding. Thus cuc - count of unicode chars - means
340 * count of RTUTF16. And cch means count of the typedef 'char', which is assumed
341 * to be an octet.
343 typedef uint16_t RTUTF16;
344 /** Pointer to a UTF-16 character. */
345 typedef RTUTF16 *PRTUTF16;
346 /** Pointer to a const UTF-16 character. */
347 typedef const RTUTF16 *PCRTUTF16;
350 * UCS-2 character.
351 * @remark wchar_t is not usable since it's compiler defined.
352 * @deprecated Use RTUTF16!
354 typedef RTUTF16 RTUCS2;
355 /** Pointer to UCS-2 character.
356 * @deprecated Use PRTUTF16!
358 typedef PRTUTF16 PRTUCS2;
359 /** Pointer to const UCS-2 character.
360 * @deprecated Use PCRTUTF16!
362 typedef PCRTUTF16 PCRTUCS2;
364 #endif