1/* 2 * Copyright (C) 2006-2017 Oracle Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 23 24#ifndef ___VBox_Graphics_HGSMIDefs_h 25#define ___VBox_Graphics_HGSMIDefs_h 26 27#include "VBoxVideoIPRT.h" 28 29/* HGSMI uses 32 bit offsets and sizes. */ 30typedef uint32_t HGSMISIZE; 31typedef uint32_t HGSMIOFFSET; 32 33#define HGSMIOFFSET_VOID ((HGSMIOFFSET)~0) 34 35/* Describes a shared memory area buffer. 36 * Used for calculations with offsets and for buffers verification. 37 */ 38typedef struct HGSMIAREA 39{ 40 uint8_t *pu8Base; /* The starting address of the area. Corresponds to offset 'offBase'. */ 41 HGSMIOFFSET offBase; /* The starting offset of the area. */ 42 HGSMIOFFSET offLast; /* The last valid offset: 43 * offBase + cbArea - 1 - (sizeof(header) + sizeof(tail)). 44 */ 45 HGSMISIZE cbArea; /* Size of the area. */ 46} HGSMIAREA; 47 48 49/* The buffer description flags. */ 50#define HGSMI_BUFFER_HEADER_F_SEQ_MASK 0x03 /* Buffer sequence type mask. */ 51#define HGSMI_BUFFER_HEADER_F_SEQ_SINGLE 0x00 /* Single buffer, not a part of a sequence. */ 52#define HGSMI_BUFFER_HEADER_F_SEQ_START 0x01 /* The first buffer in a sequence. */ 53#define HGSMI_BUFFER_HEADER_F_SEQ_CONTINUE 0x02 /* A middle buffer in a sequence. */ 54#define HGSMI_BUFFER_HEADER_F_SEQ_END 0x03 /* The last buffer in a sequence. */ 55 56 57#pragma pack(1) /** @todo not necessary. use AssertCompileSize instead. */ 58/* 16 bytes buffer header. */ 59typedef struct HGSMIBUFFERHEADER 60{ 61 uint32_t u32DataSize; /* Size of data that follows the header. */ 62 63 uint8_t u8Flags; /* The buffer description: HGSMI_BUFFER_HEADER_F_* */ 64 65 uint8_t u8Channel; /* The channel the data must be routed to. */ 66 uint16_t u16ChannelInfo; /* Opaque to the HGSMI, used by the channel. */ 67 68 union { 69 uint8_t au8Union[8]; /* Opaque placeholder to make the union 8 bytes. */ 70 71 struct 72 { /* HGSMI_BUFFER_HEADER_F_SEQ_SINGLE */ 73 uint32_t u32Reserved1; /* A reserved field, initialize to 0. */ 74 uint32_t u32Reserved2; /* A reserved field, initialize to 0. */ 75 } Buffer; 76 77 struct 78 { /* HGSMI_BUFFER_HEADER_F_SEQ_START */ 79 uint32_t u32SequenceNumber; /* The sequence number, the same for all buffers in the sequence. */ 80 uint32_t u32SequenceSize; /* The total size of the sequence. */ 81 } SequenceStart; 82 83 struct 84 { /* HGSMI_BUFFER_HEADER_F_SEQ_CONTINUE and HGSMI_BUFFER_HEADER_F_SEQ_END */ 85 uint32_t u32SequenceNumber; /* The sequence number, the same for all buffers in the sequence. */ 86 uint32_t u32SequenceOffset; /* Data offset in the entire sequence. */ 87 } SequenceContinue; 88 } u; 89} HGSMIBUFFERHEADER; 90 91/* 8 bytes buffer tail. */ 92typedef struct HGSMIBUFFERTAIL 93{ 94 uint32_t u32Reserved; /* Reserved, must be initialized to 0. */ 95 uint32_t u32Checksum; /* Verifyer for the buffer header and offset and for first 4 bytes of the tail. */ 96} HGSMIBUFFERTAIL; 97#pragma pack() 98 99AssertCompileSize(HGSMIBUFFERHEADER, 16); 100AssertCompileSize(HGSMIBUFFERTAIL, 8); 101 102/* The size of the array of channels. Array indexes are uint8_t. Note: the value must not be changed. */ 103#define HGSMI_NUMBER_OF_CHANNELS 0x100 104 105typedef struct HGSMIENV 106{ 107 /* Environment context pointer. */ 108 void *pvEnv; 109 110 /* Allocate system memory. */ 111 DECLCALLBACKMEMBER(void *, pfnAlloc)(void *pvEnv, HGSMISIZE cb); 112 113 /* Free system memory. */ 114 DECLCALLBACKMEMBER(void, pfnFree)(void *pvEnv, void *pv); 115} HGSMIENV; 116 117#endif /* !___VBox_Graphics_HGSMIDefs_h */ 118 119