47355efb636d69b667c1cef0f2fe826569b991b0vboxsync/** @file
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync *
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * VBox Host Guest Shared Memory Interface (HGSMI).
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * Host/Guest shared part: types and defines.
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync/*
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * Copyright (C) 2006-2014 Oracle Corporation
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync *
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * available from http://www.virtualbox.org. This file is free software;
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * you can redistribute it and/or modify it under the terms of the GNU
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * General Public License (GPL) as published by the Free Software
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync *
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * The contents of this file may alternatively be used under the terms
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * of the Common Development and Distribution License Version 1.0
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * VirtualBox OSE distribution, in which case the provisions of the
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * CDDL are applicable instead of those of the GPL.
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync *
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * You may elect to license modified versions of this file under the
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * terms and conditions of either the GPL or the CDDL or both.
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync#ifndef ___VBox_HGSMI_HGSMIDefs_h
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync#define ___VBox_HGSMI_HGSMIDefs_h
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync#include <iprt/assert.h>
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync#include <iprt/types.h>
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync/* HGSMI uses 32 bit offsets and sizes. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsynctypedef uint32_t HGSMISIZE;
47355efb636d69b667c1cef0f2fe826569b991b0vboxsynctypedef uint32_t HGSMIOFFSET;
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync#define HGSMIOFFSET_VOID ((HGSMIOFFSET)~0)
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync/* Describes a shared memory area buffer.
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * Used for calculations with offsets and for buffers verification.
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsynctypedef struct HGSMIAREA
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync{
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync uint8_t *pu8Base; /* The starting address of the area. Corresponds to offset 'offBase'. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync HGSMIOFFSET offBase; /* The starting offset of the area. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync HGSMIOFFSET offLast; /* The last valid offset:
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync * offBase + cbArea - 1 - (sizeof(header) + sizeof(tail)).
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync HGSMISIZE cbArea; /* Size of the area. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync} HGSMIAREA;
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync/* The buffer description flags. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync#define HGSMI_BUFFER_HEADER_F_SEQ_MASK 0x03 /* Buffer sequence type mask. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync#define HGSMI_BUFFER_HEADER_F_SEQ_SINGLE 0x00 /* Single buffer, not a part of a sequence. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync#define HGSMI_BUFFER_HEADER_F_SEQ_START 0x01 /* The first buffer in a sequence. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync#define HGSMI_BUFFER_HEADER_F_SEQ_CONTINUE 0x02 /* A middle buffer in a sequence. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync#define HGSMI_BUFFER_HEADER_F_SEQ_END 0x03 /* The last buffer in a sequence. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync#pragma pack(1)
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync/* 16 bytes buffer header. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsynctypedef struct HGSMIBUFFERHEADER
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync{
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync uint32_t u32DataSize; /* Size of data that follows the header. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync uint8_t u8Flags; /* The buffer description: HGSMI_BUFFER_HEADER_F_* */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync uint8_t u8Channel; /* The channel the data must be routed to. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync uint16_t u16ChannelInfo; /* Opaque to the HGSMI, used by the channel. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync union {
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync uint8_t au8Union[8]; /* Opaque placeholder to make the union 8 bytes. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync struct
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync { /* HGSMI_BUFFER_HEADER_F_SEQ_SINGLE */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync uint32_t u32Reserved1; /* A reserved field, initialize to 0. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync uint32_t u32Reserved2; /* A reserved field, initialize to 0. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync } Buffer;
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync struct
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync { /* HGSMI_BUFFER_HEADER_F_SEQ_START */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync uint32_t u32SequenceNumber; /* The sequence number, the same for all buffers in the sequence. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync uint32_t u32SequenceSize; /* The total size of the sequence. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync } SequenceStart;
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync struct
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync { /* HGSMI_BUFFER_HEADER_F_SEQ_CONTINUE and HGSMI_BUFFER_HEADER_F_SEQ_END */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync uint32_t u32SequenceNumber; /* The sequence number, the same for all buffers in the sequence. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync uint32_t u32SequenceOffset; /* Data offset in the entire sequence. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync } SequenceContinue;
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync } u;
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync} HGSMIBUFFERHEADER;
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync/* 8 bytes buffer tail. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsynctypedef struct HGSMIBUFFERTAIL
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync{
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync uint32_t u32Reserved; /* Reserved, must be initialized to 0. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync uint32_t u32Checksum; /* Verifyer for the buffer header and offset and for first 4 bytes of the tail. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync} HGSMIBUFFERTAIL;
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync#pragma pack()
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsyncAssertCompileSize(HGSMIBUFFERHEADER, 16);
47355efb636d69b667c1cef0f2fe826569b991b0vboxsyncAssertCompileSize(HGSMIBUFFERTAIL, 8);
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync/* The size of the array of channels. Array indexes are uint8_t. Note: the value must not be changed. */
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync#define HGSMI_NUMBER_OF_CHANNELS 0x100
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync
32b1164f35483be483177be7b5235002a4a5afbevboxsynctypedef struct HGSMIENV
32b1164f35483be483177be7b5235002a4a5afbevboxsync{
32b1164f35483be483177be7b5235002a4a5afbevboxsync /* Environment context pointer. */
32b1164f35483be483177be7b5235002a4a5afbevboxsync void *pvEnv;
32b1164f35483be483177be7b5235002a4a5afbevboxsync
32b1164f35483be483177be7b5235002a4a5afbevboxsync /* Allocate system memory. */
32b1164f35483be483177be7b5235002a4a5afbevboxsync DECLCALLBACKMEMBER(void *, pfnAlloc)(void *pvEnv, HGSMISIZE cb);
32b1164f35483be483177be7b5235002a4a5afbevboxsync
32b1164f35483be483177be7b5235002a4a5afbevboxsync /* Free system memory. */
32b1164f35483be483177be7b5235002a4a5afbevboxsync DECLCALLBACKMEMBER(void, pfnFree)(void *pvEnv, void *pv);
32b1164f35483be483177be7b5235002a4a5afbevboxsync} HGSMIENV;
32b1164f35483be483177be7b5235002a4a5afbevboxsync
47355efb636d69b667c1cef0f2fe826569b991b0vboxsync#endif /* !___VBox_HGSMI_HGSMIDefs_h */