1 | /** @file
|
---|
2 | * Virtual Disk Container API - Media type definitions shared with PDM.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2017-2023 Oracle and/or its affiliates.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox base platform packages, as
|
---|
9 | * available from https://www.virtualbox.org.
|
---|
10 | *
|
---|
11 | * This program is free software; you can redistribute it and/or
|
---|
12 | * modify it under the terms of the GNU General Public License
|
---|
13 | * as published by the Free Software Foundation, in version 3 of the
|
---|
14 | * License.
|
---|
15 | *
|
---|
16 | * This program is distributed in the hope that it will be useful, but
|
---|
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
19 | * General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU General Public License
|
---|
22 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
23 | *
|
---|
24 | * The contents of this file may alternatively be used under the terms
|
---|
25 | * of the Common Development and Distribution License Version 1.0
|
---|
26 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
27 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
28 | * CDDL are applicable instead of those of the GPL.
|
---|
29 | *
|
---|
30 | * You may elect to license modified versions of this file under the
|
---|
31 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
32 | *
|
---|
33 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
34 | */
|
---|
35 |
|
---|
36 | #ifndef VBOX_INCLUDED_vdmedia_h
|
---|
37 | #define VBOX_INCLUDED_vdmedia_h
|
---|
38 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
39 | # pragma once
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | #include <iprt/types.h>
|
---|
43 |
|
---|
44 | /** @name VD container type.
|
---|
45 | * @{
|
---|
46 | */
|
---|
47 | typedef enum VDTYPE
|
---|
48 | {
|
---|
49 | /** Invalid. */
|
---|
50 | VDTYPE_INVALID = 0,
|
---|
51 | /** HardDisk */
|
---|
52 | VDTYPE_HDD,
|
---|
53 | /** Any kind of optical disc (CD/DVD etc.). */
|
---|
54 | VDTYPE_OPTICAL_DISC,
|
---|
55 | /** Floppy. */
|
---|
56 | VDTYPE_FLOPPY
|
---|
57 | } VDTYPE;
|
---|
58 | /** @}*/
|
---|
59 |
|
---|
60 | /** @name VD medium type.
|
---|
61 | * @{
|
---|
62 | */
|
---|
63 | typedef enum VDMEDIUMTYPE
|
---|
64 | {
|
---|
65 | /** Invalid. */
|
---|
66 | VDMEDIUMTYPE_INVALID = 0,
|
---|
67 | /** HardDisk (spinning platter or SSD). */
|
---|
68 | VDMEDIUMTYPE_HDD,
|
---|
69 | /** CD-ROM */
|
---|
70 | VDMEDIUMTYPE_CDROM,
|
---|
71 | /** DVD-ROM */
|
---|
72 | VDMEDIUMTYPE_DVDROM,
|
---|
73 | /** BluRay. */
|
---|
74 | VDMEDIUMTYPE_BD,
|
---|
75 | /** 360KB 5 1/4" floppy. */
|
---|
76 | VDMEDIUMTYPE_FLOPPY_360,
|
---|
77 | /** 720KB 3 1/2" floppy. */
|
---|
78 | VDMEDIUMTYPE_FLOPPY_720,
|
---|
79 | /** 1.2MB 5 1/4" floppy. */
|
---|
80 | VDMEDIUMTYPE_FLOPPY_1_20,
|
---|
81 | /** 1.44MB 3 1/2" floppy. */
|
---|
82 | VDMEDIUMTYPE_FLOPPY_1_44,
|
---|
83 | /** 2.88MB 3 1/2" floppy. */
|
---|
84 | VDMEDIUMTYPE_FLOPPY_2_88,
|
---|
85 | /** Fake disk that can take up to 15.6 MB images.
|
---|
86 | * C=255, H=2, S=63. */
|
---|
87 | VDMEDIUMTYPE_FLOPPY_FAKE_15_6,
|
---|
88 | /** Fake disk that can take up to 63.5 MB images.
|
---|
89 | * C=255, H=2, S=255. */
|
---|
90 | VDMEDIUMTYPE_FLOPPY_FAKE_63_5
|
---|
91 | } VDMEDIUMTYPE;
|
---|
92 | /** @} */
|
---|
93 |
|
---|
94 | /** Check if the given medium type is a floppy. */
|
---|
95 | #define VDMEDIUMTYPE_IS_FLOPPY(a_enmType) ( (a_enmType) >= VDMEDIUMTYPE_FLOPPY_360 && (a_enmType) <= VDMEDIUMTYPE_FLOPPY_2_88 )
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * Disk geometry.
|
---|
99 | */
|
---|
100 | typedef struct VDGEOMETRY
|
---|
101 | {
|
---|
102 | /** Number of cylinders. */
|
---|
103 | uint32_t cCylinders;
|
---|
104 | /** Number of heads. */
|
---|
105 | uint32_t cHeads;
|
---|
106 | /** Number of sectors. */
|
---|
107 | uint32_t cSectors;
|
---|
108 | } VDGEOMETRY;
|
---|
109 |
|
---|
110 | /** Pointer to disk geometry. */
|
---|
111 | typedef VDGEOMETRY *PVDGEOMETRY;
|
---|
112 | /** Pointer to constant disk geometry. */
|
---|
113 | typedef const VDGEOMETRY *PCVDGEOMETRY;
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * Disk region data form known to us from various standards.
|
---|
117 | */
|
---|
118 | typedef enum VDREGIONDATAFORM
|
---|
119 | {
|
---|
120 | /** Invalid data form. */
|
---|
121 | VDREGIONDATAFORM_INVALID = 0,
|
---|
122 | /** Raw data, no standardized format. */
|
---|
123 | VDREGIONDATAFORM_RAW,
|
---|
124 | /** CD-DA (audio CD), 2352 bytes of data. */
|
---|
125 | VDREGIONDATAFORM_CDDA,
|
---|
126 | /** CDDA data is pause. */
|
---|
127 | VDREGIONDATAFORM_CDDA_PAUSE,
|
---|
128 | /** Mode 1 with 2048 bytes sector size. */
|
---|
129 | VDREGIONDATAFORM_MODE1_2048,
|
---|
130 | /** Mode 1 with 2352 bytes sector size. */
|
---|
131 | VDREGIONDATAFORM_MODE1_2352,
|
---|
132 | /** Mode 1 with 0 bytes sector size (generated by the drive). */
|
---|
133 | VDREGIONDATAFORM_MODE1_0,
|
---|
134 | /** XA Mode with 2336 bytes sector size. */
|
---|
135 | VDREGIONDATAFORM_XA_2336,
|
---|
136 | /** XA Mode with 2352 bytes sector size. */
|
---|
137 | VDREGIONDATAFORM_XA_2352,
|
---|
138 | /** XA Mode with 0 bytes sector size (generated by the drive). */
|
---|
139 | VDREGIONDATAFORM_XA_0,
|
---|
140 | /** Mode 2 with 2336 bytes sector size. */
|
---|
141 | VDREGIONDATAFORM_MODE2_2336,
|
---|
142 | /** Mode 2 with 2352 bytes sector size. */
|
---|
143 | VDREGIONDATAFORM_MODE2_2352,
|
---|
144 | /** Mode 2 with 0 bytes sector size (generated by the drive). */
|
---|
145 | VDREGIONDATAFORM_MODE2_0
|
---|
146 | } VDREGIONDATAFORM;
|
---|
147 | /** Pointer to a region data form. */
|
---|
148 | typedef VDREGIONDATAFORM *PVDREGIONDATAFORM;
|
---|
149 | /** Pointer to a const region data form. */
|
---|
150 | typedef const VDREGIONDATAFORM PCVDREGIONDATAFORM;
|
---|
151 |
|
---|
152 | /**
|
---|
153 | * Disk region metadata forms known to us.
|
---|
154 | */
|
---|
155 | typedef enum VDREGIONMETADATAFORM
|
---|
156 | {
|
---|
157 | /** Invalid metadata form. */
|
---|
158 | VDREGIONMETADATAFORM_INVALID = 0,
|
---|
159 | /** No metadata assined to the region. */
|
---|
160 | VDREGIONMETADATAFORM_NONE,
|
---|
161 | /** Raw metadata, no standardized format. */
|
---|
162 | VDREGIONMETADATAFORM_RAW
|
---|
163 | } VDREGIONMETADATAFORM;
|
---|
164 | /** Pointer to a region metadata form. */
|
---|
165 | typedef VDREGIONMETADATAFORM *PVDREGIONMETADATAFORM;
|
---|
166 | /** Pointer to a const region metadata form. */
|
---|
167 | typedef const VDREGIONMETADATAFORM PCVDREGIONMETADATAFORM;
|
---|
168 |
|
---|
169 | /**
|
---|
170 | * Disk region descriptor.
|
---|
171 | */
|
---|
172 | typedef struct VDREGIONDESC
|
---|
173 | {
|
---|
174 | /** Start of the region in bytes or LBA number (depending on the flag in the
|
---|
175 | * list header). */
|
---|
176 | uint64_t offRegion;
|
---|
177 | /** Overall size of the region in bytes or number of blocks (depending on the
|
---|
178 | * flag in the list header). */
|
---|
179 | uint64_t cRegionBlocksOrBytes;
|
---|
180 | /** Size of one block in bytes, containing user and metadata. */
|
---|
181 | uint64_t cbBlock;
|
---|
182 | /** User data form of the block. */
|
---|
183 | VDREGIONDATAFORM enmDataForm;
|
---|
184 | /** Metadata form of the block. */
|
---|
185 | VDREGIONMETADATAFORM enmMetadataForm;
|
---|
186 | /** Size of the data block in bytes. */
|
---|
187 | uint64_t cbData;
|
---|
188 | /** Size of the metadata in a block in bytes. */
|
---|
189 | uint64_t cbMetadata;
|
---|
190 | } VDREGIONDESC;
|
---|
191 | /** Pointer to a region descriptor. */
|
---|
192 | typedef VDREGIONDESC *PVDREGIONDESC;
|
---|
193 | /** Pointer to a constant region descriptor. */
|
---|
194 | typedef const VDREGIONDESC *PCVDREGIONDESC;
|
---|
195 |
|
---|
196 | /**
|
---|
197 | * Disk region list.
|
---|
198 | */
|
---|
199 | typedef struct VDREGIONLIST
|
---|
200 | {
|
---|
201 | /** Flags valid for the region list. */
|
---|
202 | uint32_t fFlags;
|
---|
203 | /** Number of regions in the descriptor array. */
|
---|
204 | uint32_t cRegions;
|
---|
205 | /** Region descriptors - variable in size. */
|
---|
206 | VDREGIONDESC aRegions[RT_FLEXIBLE_ARRAY_NESTED];
|
---|
207 | } VDREGIONLIST;
|
---|
208 | /** Pointer to a region list. */
|
---|
209 | typedef VDREGIONLIST *PVDREGIONLIST;
|
---|
210 | /** Pointer to a constant region list. */
|
---|
211 | typedef const VDREGIONLIST *PCVDREGIONLIST;
|
---|
212 | /** Pointer to a region list pointer. */
|
---|
213 | typedef PVDREGIONLIST *PPVDREGIONLIST;
|
---|
214 |
|
---|
215 | /** @name Valid region list flags.
|
---|
216 | * @{
|
---|
217 | */
|
---|
218 | /** When set the region start offset and size are given in numbers of blocks
|
---|
219 | * instead of byte offsets and sizes. */
|
---|
220 | #define VD_REGION_LIST_F_LOC_SIZE_BLOCKS RT_BIT_32(0)
|
---|
221 | /** Mask of all valid flags. */
|
---|
222 | #define VD_REGION_LIST_F_VALID (VD_REGION_LIST_F_LOC_SIZE_BLOCKS)
|
---|
223 | /** @} */
|
---|
224 |
|
---|
225 | #endif /* !VBOX_INCLUDED_vdmedia_h */
|
---|
226 |
|
---|