- Timestamp:
- Sep 7, 2017 2:54:24 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VMMDevCoreTypes.h
r68691 r68696 40 40 * @{ 41 41 */ 42 43 /* Helpful forward declarations: */ 44 struct VMMDevRequestHeader; 45 struct VMMDevReqMousePointer; 46 struct VMMDevMemory; 47 42 48 43 49 /** @name VMMDev events. … … 117 123 118 124 119 120 121 /**122 * HGCM service location types.123 * @ingroup grp_vmmdev_req124 */125 typedef enum126 {127 VMMDevHGCMLoc_Invalid = 0,128 VMMDevHGCMLoc_LocalHost = 1,129 VMMDevHGCMLoc_LocalHost_Existing = 2,130 VMMDevHGCMLoc_SizeHack = 0x7fffffff131 } HGCMServiceLocationType;132 AssertCompileSize(HGCMServiceLocationType, 4);133 134 /**135 * HGCM host service location.136 * @ingroup grp_vmmdev_req137 */138 typedef struct139 {140 char achName[128]; /**< This is really szName. */141 } HGCMServiceLocationHost;142 AssertCompileSize(HGCMServiceLocationHost, 128);143 144 /**145 * HGCM service location.146 * @ingroup grp_vmmdev_req147 */148 typedef struct HGCMSERVICELOCATION149 {150 /** Type of the location. */151 HGCMServiceLocationType type;152 153 union154 {155 HGCMServiceLocationHost host;156 } u;157 } HGCMServiceLocation;158 AssertCompileSize(HGCMServiceLocation, 128+4);159 160 161 /**162 * HGCM parameter type.163 */164 typedef enum165 {166 VMMDevHGCMParmType_Invalid = 0,167 VMMDevHGCMParmType_32bit = 1,168 VMMDevHGCMParmType_64bit = 2,169 VMMDevHGCMParmType_PhysAddr = 3, /**< @deprecated Doesn't work, use PageList. */170 VMMDevHGCMParmType_LinAddr = 4, /**< In and Out */171 VMMDevHGCMParmType_LinAddr_In = 5, /**< In (read; host<-guest) */172 VMMDevHGCMParmType_LinAddr_Out = 6, /**< Out (write; host->guest) */173 VMMDevHGCMParmType_LinAddr_Locked = 7, /**< Locked In and Out */174 VMMDevHGCMParmType_LinAddr_Locked_In = 8, /**< Locked In (read; host<-guest) */175 VMMDevHGCMParmType_LinAddr_Locked_Out = 9, /**< Locked Out (write; host->guest) */176 VMMDevHGCMParmType_PageList = 10, /**< Physical addresses of locked pages for a buffer. */177 VMMDevHGCMParmType_SizeHack = 0x7fffffff178 } HGCMFunctionParameterType;179 AssertCompileSize(HGCMFunctionParameterType, 4);180 181 182 # ifdef VBOX_WITH_64_BITS_GUESTS183 /**184 * HGCM function parameter, 32-bit client.185 */186 # pragma pack(4) /* We force structure dword packing here for hysterical raisins. Saves us 4 bytes, at the cost of187 misaligning the value64 member of every other parameter structure. */188 typedef struct189 {190 HGCMFunctionParameterType type;191 union192 {193 uint32_t value32;194 uint64_t value64;195 struct196 {197 uint32_t size;198 199 union200 {201 RTGCPHYS32 physAddr;202 RTGCPTR32 linearAddr;203 } u;204 } Pointer;205 struct206 {207 uint32_t size; /**< Size of the buffer described by the page list. */208 uint32_t offset; /**< Relative to the request header, valid if size != 0. */209 } PageList;210 } u;211 # ifdef __cplusplus212 void SetUInt32(uint32_t u32)213 {214 type = VMMDevHGCMParmType_32bit;215 u.value64 = 0; /* init unused bits to 0 */216 u.value32 = u32;217 }218 219 int GetUInt32(uint32_t RT_FAR *pu32)220 {221 if (type == VMMDevHGCMParmType_32bit)222 {223 *pu32 = u.value32;224 return VINF_SUCCESS;225 }226 return VERR_INVALID_PARAMETER;227 }228 229 void SetUInt64(uint64_t u64)230 {231 type = VMMDevHGCMParmType_64bit;232 u.value64 = u64;233 }234 235 int GetUInt64(uint64_t RT_FAR *pu64)236 {237 if (type == VMMDevHGCMParmType_64bit)238 {239 *pu64 = u.value64;240 return VINF_SUCCESS;241 }242 return VERR_INVALID_PARAMETER;243 }244 245 void SetPtr(void RT_FAR *pv, uint32_t cb)246 {247 type = VMMDevHGCMParmType_LinAddr;248 u.Pointer.size = cb;249 u.Pointer.u.linearAddr = (RTGCPTR32)(uintptr_t)pv;250 }251 # endif /* __cplusplus */252 } HGCMFunctionParameter32;253 # pragma pack()254 AssertCompileSize(HGCMFunctionParameter32, 4+8);255 256 /**257 * HGCM function parameter, 64-bit client.258 */259 # pragma pack(4)/* We force structure dword packing here for hysterical raisins. Saves us 4 bytes, at the cost of260 misaligning the value64, physAddr and linearAddr members of every other parameter structure. */261 typedef struct262 {263 HGCMFunctionParameterType type;264 union265 {266 uint32_t value32;267 uint64_t value64;268 struct269 {270 uint32_t size;271 272 union273 {274 RTGCPHYS64 physAddr;275 RTGCPTR64 linearAddr;276 } u;277 } Pointer;278 struct279 {280 uint32_t size; /**< Size of the buffer described by the page list. */281 uint32_t offset; /**< Relative to the request header, valid if size != 0. */282 } PageList;283 } u;284 # ifdef __cplusplus285 void SetUInt32(uint32_t u32)286 {287 type = VMMDevHGCMParmType_32bit;288 u.value64 = 0; /* init unused bits to 0 */289 u.value32 = u32;290 }291 292 int GetUInt32(uint32_t RT_FAR *pu32)293 {294 if (type == VMMDevHGCMParmType_32bit)295 {296 *pu32 = u.value32;297 return VINF_SUCCESS;298 }299 return VERR_INVALID_PARAMETER;300 }301 302 void SetUInt64(uint64_t u64)303 {304 type = VMMDevHGCMParmType_64bit;305 u.value64 = u64;306 }307 308 int GetUInt64(uint64_t RT_FAR *pu64)309 {310 if (type == VMMDevHGCMParmType_64bit)311 {312 *pu64 = u.value64;313 return VINF_SUCCESS;314 }315 return VERR_INVALID_PARAMETER;316 }317 318 void SetPtr(void RT_FAR *pv, uint32_t cb)319 {320 type = VMMDevHGCMParmType_LinAddr;321 u.Pointer.size = cb;322 u.Pointer.u.linearAddr = (uintptr_t)pv;323 }324 # endif /** __cplusplus */325 } HGCMFunctionParameter64;326 # pragma pack()327 AssertCompileSize(HGCMFunctionParameter64, 4+12);328 329 /* Redefine the structure type for the guest code. */330 # ifndef VBOX_HGCM_HOST_CODE331 # if ARCH_BITS == 64332 # define HGCMFunctionParameter HGCMFunctionParameter64333 # elif ARCH_BITS == 32 || ARCH_BITS == 16334 # define HGCMFunctionParameter HGCMFunctionParameter32335 # else336 # error "Unsupported sizeof (void *)"337 # endif338 # endif /* !VBOX_HGCM_HOST_CODE */339 340 # else /* !VBOX_WITH_64_BITS_GUESTS */341 342 /**343 * HGCM function parameter, 32-bit client.344 *345 * @todo If this is the same as HGCMFunctionParameter32, why the duplication?346 */347 # pragma pack(4) /* We force structure dword packing here for hysterical raisins. Saves us 4 bytes, at the cost of348 misaligning the value64 member of every other parameter structure. */349 typedef struct350 {351 HGCMFunctionParameterType type;352 union353 {354 uint32_t value32;355 uint64_t value64;356 struct357 {358 uint32_t size;359 360 union361 {362 RTGCPHYS32 physAddr;363 RTGCPTR32 linearAddr;364 } u;365 } Pointer;366 struct367 {368 uint32_t size; /**< Size of the buffer described by the page list. */369 uint32_t offset; /**< Relative to the request header, valid if size != 0. */370 } PageList;371 } u;372 # ifdef __cplusplus373 void SetUInt32(uint32_t u32)374 {375 type = VMMDevHGCMParmType_32bit;376 u.value64 = 0; /* init unused bits to 0 */377 u.value32 = u32;378 }379 380 int GetUInt32(uint32_t *pu32)381 {382 if (type == VMMDevHGCMParmType_32bit)383 {384 *pu32 = u.value32;385 return VINF_SUCCESS;386 }387 return VERR_INVALID_PARAMETER;388 }389 390 void SetUInt64(uint64_t u64)391 {392 type = VMMDevHGCMParmType_64bit;393 u.value64 = u64;394 }395 396 int GetUInt64(uint64_t *pu64)397 {398 if (type == VMMDevHGCMParmType_64bit)399 {400 *pu64 = u.value64;401 return VINF_SUCCESS;402 }403 return VERR_INVALID_PARAMETER;404 }405 406 void SetPtr(void *pv, uint32_t cb)407 {408 type = VMMDevHGCMParmType_LinAddr;409 u.Pointer.size = cb;410 u.Pointer.u.linearAddr = (uintptr_t)pv;411 }412 # endif /* __cplusplus */413 } HGCMFunctionParameter;414 # pragma pack()415 AssertCompileSize(HGCMFunctionParameter, 4+8);416 # endif /* !VBOX_WITH_64_BITS_GUESTS */417 418 419 420 125 /** @name Guest capability bits. 421 126 * Used by VMMDevReq_ReportGuestCapabilities and VMMDevReq_SetGuestCapabilities. … … 507 212 AssertCompileSize(VBoxGuestUserState, 4); 508 213 509 /* forward declarations: */ 510 struct VMMDevRequestHeader; 511 struct VMMDevReqMousePointer; 512 struct VMMDevMemory; 214 215 216 /** 217 * HGCM service location types. 218 * @ingroup grp_vmmdev_req 219 */ 220 typedef enum 221 { 222 VMMDevHGCMLoc_Invalid = 0, 223 VMMDevHGCMLoc_LocalHost = 1, 224 VMMDevHGCMLoc_LocalHost_Existing = 2, 225 VMMDevHGCMLoc_SizeHack = 0x7fffffff 226 } HGCMServiceLocationType; 227 AssertCompileSize(HGCMServiceLocationType, 4); 228 229 /** 230 * HGCM host service location. 231 * @ingroup grp_vmmdev_req 232 */ 233 typedef struct 234 { 235 char achName[128]; /**< This is really szName. */ 236 } HGCMServiceLocationHost; 237 AssertCompileSize(HGCMServiceLocationHost, 128); 238 239 /** 240 * HGCM service location. 241 * @ingroup grp_vmmdev_req 242 */ 243 typedef struct HGCMSERVICELOCATION 244 { 245 /** Type of the location. */ 246 HGCMServiceLocationType type; 247 248 union 249 { 250 HGCMServiceLocationHost host; 251 } u; 252 } HGCMServiceLocation; 253 AssertCompileSize(HGCMServiceLocation, 128+4); 254 255 256 /** 257 * HGCM parameter type. 258 */ 259 typedef enum 260 { 261 VMMDevHGCMParmType_Invalid = 0, 262 VMMDevHGCMParmType_32bit = 1, 263 VMMDevHGCMParmType_64bit = 2, 264 VMMDevHGCMParmType_PhysAddr = 3, /**< @deprecated Doesn't work, use PageList. */ 265 VMMDevHGCMParmType_LinAddr = 4, /**< In and Out */ 266 VMMDevHGCMParmType_LinAddr_In = 5, /**< In (read; host<-guest) */ 267 VMMDevHGCMParmType_LinAddr_Out = 6, /**< Out (write; host->guest) */ 268 VMMDevHGCMParmType_LinAddr_Locked = 7, /**< Locked In and Out */ 269 VMMDevHGCMParmType_LinAddr_Locked_In = 8, /**< Locked In (read; host<-guest) */ 270 VMMDevHGCMParmType_LinAddr_Locked_Out = 9, /**< Locked Out (write; host->guest) */ 271 VMMDevHGCMParmType_PageList = 10, /**< Physical addresses of locked pages for a buffer. */ 272 VMMDevHGCMParmType_SizeHack = 0x7fffffff 273 } HGCMFunctionParameterType; 274 AssertCompileSize(HGCMFunctionParameterType, 4); 275 276 277 # ifdef VBOX_WITH_64_BITS_GUESTS 278 /** 279 * HGCM function parameter, 32-bit client. 280 */ 281 # pragma pack(4) /* We force structure dword packing here for hysterical raisins. Saves us 4 bytes, at the cost of 282 misaligning the value64 member of every other parameter structure. */ 283 typedef struct 284 { 285 HGCMFunctionParameterType type; 286 union 287 { 288 uint32_t value32; 289 uint64_t value64; 290 struct 291 { 292 uint32_t size; 293 294 union 295 { 296 RTGCPHYS32 physAddr; 297 RTGCPTR32 linearAddr; 298 } u; 299 } Pointer; 300 struct 301 { 302 uint32_t size; /**< Size of the buffer described by the page list. */ 303 uint32_t offset; /**< Relative to the request header, valid if size != 0. */ 304 } PageList; 305 } u; 306 # ifdef __cplusplus 307 void SetUInt32(uint32_t u32) 308 { 309 type = VMMDevHGCMParmType_32bit; 310 u.value64 = 0; /* init unused bits to 0 */ 311 u.value32 = u32; 312 } 313 314 int GetUInt32(uint32_t RT_FAR *pu32) 315 { 316 if (type == VMMDevHGCMParmType_32bit) 317 { 318 *pu32 = u.value32; 319 return VINF_SUCCESS; 320 } 321 return VERR_INVALID_PARAMETER; 322 } 323 324 void SetUInt64(uint64_t u64) 325 { 326 type = VMMDevHGCMParmType_64bit; 327 u.value64 = u64; 328 } 329 330 int GetUInt64(uint64_t RT_FAR *pu64) 331 { 332 if (type == VMMDevHGCMParmType_64bit) 333 { 334 *pu64 = u.value64; 335 return VINF_SUCCESS; 336 } 337 return VERR_INVALID_PARAMETER; 338 } 339 340 void SetPtr(void RT_FAR *pv, uint32_t cb) 341 { 342 type = VMMDevHGCMParmType_LinAddr; 343 u.Pointer.size = cb; 344 u.Pointer.u.linearAddr = (RTGCPTR32)(uintptr_t)pv; 345 } 346 # endif /* __cplusplus */ 347 } HGCMFunctionParameter32; 348 # pragma pack() 349 AssertCompileSize(HGCMFunctionParameter32, 4+8); 350 351 /** 352 * HGCM function parameter, 64-bit client. 353 */ 354 # pragma pack(4)/* We force structure dword packing here for hysterical raisins. Saves us 4 bytes, at the cost of 355 misaligning the value64, physAddr and linearAddr members of every other parameter structure. */ 356 typedef struct 357 { 358 HGCMFunctionParameterType type; 359 union 360 { 361 uint32_t value32; 362 uint64_t value64; 363 struct 364 { 365 uint32_t size; 366 367 union 368 { 369 RTGCPHYS64 physAddr; 370 RTGCPTR64 linearAddr; 371 } u; 372 } Pointer; 373 struct 374 { 375 uint32_t size; /**< Size of the buffer described by the page list. */ 376 uint32_t offset; /**< Relative to the request header, valid if size != 0. */ 377 } PageList; 378 } u; 379 # ifdef __cplusplus 380 void SetUInt32(uint32_t u32) 381 { 382 type = VMMDevHGCMParmType_32bit; 383 u.value64 = 0; /* init unused bits to 0 */ 384 u.value32 = u32; 385 } 386 387 int GetUInt32(uint32_t RT_FAR *pu32) 388 { 389 if (type == VMMDevHGCMParmType_32bit) 390 { 391 *pu32 = u.value32; 392 return VINF_SUCCESS; 393 } 394 return VERR_INVALID_PARAMETER; 395 } 396 397 void SetUInt64(uint64_t u64) 398 { 399 type = VMMDevHGCMParmType_64bit; 400 u.value64 = u64; 401 } 402 403 int GetUInt64(uint64_t RT_FAR *pu64) 404 { 405 if (type == VMMDevHGCMParmType_64bit) 406 { 407 *pu64 = u.value64; 408 return VINF_SUCCESS; 409 } 410 return VERR_INVALID_PARAMETER; 411 } 412 413 void SetPtr(void RT_FAR *pv, uint32_t cb) 414 { 415 type = VMMDevHGCMParmType_LinAddr; 416 u.Pointer.size = cb; 417 u.Pointer.u.linearAddr = (uintptr_t)pv; 418 } 419 # endif /** __cplusplus */ 420 } HGCMFunctionParameter64; 421 # pragma pack() 422 AssertCompileSize(HGCMFunctionParameter64, 4+12); 423 424 /* Redefine the structure type for the guest code. */ 425 # ifndef VBOX_HGCM_HOST_CODE 426 # if ARCH_BITS == 64 427 # define HGCMFunctionParameter HGCMFunctionParameter64 428 # elif ARCH_BITS == 32 || ARCH_BITS == 16 429 # define HGCMFunctionParameter HGCMFunctionParameter32 430 # else 431 # error "Unsupported sizeof (void *)" 432 # endif 433 # endif /* !VBOX_HGCM_HOST_CODE */ 434 435 # else /* !VBOX_WITH_64_BITS_GUESTS */ 436 437 /** 438 * HGCM function parameter, 32-bit client. 439 * 440 * @todo If this is the same as HGCMFunctionParameter32, why the duplication? 441 */ 442 # pragma pack(4) /* We force structure dword packing here for hysterical raisins. Saves us 4 bytes, at the cost of 443 misaligning the value64 member of every other parameter structure. */ 444 typedef struct 445 { 446 HGCMFunctionParameterType type; 447 union 448 { 449 uint32_t value32; 450 uint64_t value64; 451 struct 452 { 453 uint32_t size; 454 455 union 456 { 457 RTGCPHYS32 physAddr; 458 RTGCPTR32 linearAddr; 459 } u; 460 } Pointer; 461 struct 462 { 463 uint32_t size; /**< Size of the buffer described by the page list. */ 464 uint32_t offset; /**< Relative to the request header, valid if size != 0. */ 465 } PageList; 466 } u; 467 # ifdef __cplusplus 468 void SetUInt32(uint32_t u32) 469 { 470 type = VMMDevHGCMParmType_32bit; 471 u.value64 = 0; /* init unused bits to 0 */ 472 u.value32 = u32; 473 } 474 475 int GetUInt32(uint32_t *pu32) 476 { 477 if (type == VMMDevHGCMParmType_32bit) 478 { 479 *pu32 = u.value32; 480 return VINF_SUCCESS; 481 } 482 return VERR_INVALID_PARAMETER; 483 } 484 485 void SetUInt64(uint64_t u64) 486 { 487 type = VMMDevHGCMParmType_64bit; 488 u.value64 = u64; 489 } 490 491 int GetUInt64(uint64_t *pu64) 492 { 493 if (type == VMMDevHGCMParmType_64bit) 494 { 495 *pu64 = u.value64; 496 return VINF_SUCCESS; 497 } 498 return VERR_INVALID_PARAMETER; 499 } 500 501 void SetPtr(void *pv, uint32_t cb) 502 { 503 type = VMMDevHGCMParmType_LinAddr; 504 u.Pointer.size = cb; 505 u.Pointer.u.linearAddr = (uintptr_t)pv; 506 } 507 # endif /* __cplusplus */ 508 } HGCMFunctionParameter; 509 # pragma pack() 510 AssertCompileSize(HGCMFunctionParameter, 4+8); 511 # endif /* !VBOX_WITH_64_BITS_GUESTS */ 513 512 514 513 /** @} */
Note:
See TracChangeset
for help on using the changeset viewer.