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