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