Virtio.h revision fd8bc8bc503d0dd080a7658484e62f757ccb7a1c
734b6a94890be549309b21156f8ed6d4561cac51darrenm * Virtio.h - Virtio Declarations
734b6a94890be549309b21156f8ed6d4561cac51darrenm * Copyright (C) 2009-2013 Oracle Corporation
734b6a94890be549309b21156f8ed6d4561cac51darrenm * This file is part of VirtualBox Open Source Edition (OSE), as
734b6a94890be549309b21156f8ed6d4561cac51darrenm * available from http://www.virtualbox.org. This file is free software;
734b6a94890be549309b21156f8ed6d4561cac51darrenm * you can redistribute it and/or modify it under the terms of the GNU
734b6a94890be549309b21156f8ed6d4561cac51darrenm * General Public License (GPL) as published by the Free Software
734b6a94890be549309b21156f8ed6d4561cac51darrenm * Foundation, in version 2 as it comes in the "COPYING" file of the
734b6a94890be549309b21156f8ed6d4561cac51darrenm * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
734b6a94890be549309b21156f8ed6d4561cac51darrenm * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
734b6a94890be549309b21156f8ed6d4561cac51darrenm/** @name Saved state versions.
734b6a94890be549309b21156f8ed6d4561cac51darrenm * The saved state version is changed if either common or any of specific
734b6a94890be549309b21156f8ed6d4561cac51darrenm * parts are changed. That is, it is perfectly possible that the version
734b6a94890be549309b21156f8ed6d4561cac51darrenm * of saved vnet state will increase as a result of change in vblk structure
734b6a94890be549309b21156f8ed6d4561cac51darrenm * for example.
734b6a94890be549309b21156f8ed6d4561cac51darrenmtypedef struct VRingDesc
734b6a94890be549309b21156f8ed6d4561cac51darrenmtypedef struct VRingAvail
734b6a94890be549309b21156f8ed6d4561cac51darrenmtypedef struct VRingUsedElem
734b6a94890be549309b21156f8ed6d4561cac51darrenmtypedef struct VRingUsed
734b6a94890be549309b21156f8ed6d4561cac51darrenmtypedef struct VRing
734b6a94890be549309b21156f8ed6d4561cac51darrenmtypedef struct VQueue
734b6a94890be549309b21156f8ed6d4561cac51darrenm void (*pfnCallback)(void *pvState, struct VQueue *pQueue);
734b6a94890be549309b21156f8ed6d4561cac51darrenmtypedef struct VQueueElemSeg
734b6a94890be549309b21156f8ed6d4561cac51darrenmtypedef struct VQueueElem
734b6a94890be549309b21156f8ed6d4561cac51darrenm * The core (/common) state of the VirtIO PCI device
734b6a94890be549309b21156f8ed6d4561cac51darrenm * @implements PDMILEDPORTS
734b6a94890be549309b21156f8ed6d4561cac51darrenmtypedef struct VPCIState_st
734b6a94890be549309b21156f8ed6d4561cac51darrenm PDMCRITSECT cs; /**< Critical section - what is it protecting? */
734b6a94890be549309b21156f8ed6d4561cac51darrenm /* Read-only part, never changes after initialization. */
734b6a94890be549309b21156f8ed6d4561cac51darrenm char szInstance[8]; /**< Instance name, e.g. VNet#1. */
734b6a94890be549309b21156f8ed6d4561cac51darrenm /** Status LUN: Base interface. */
734b6a94890be549309b21156f8ed6d4561cac51darrenm /** Status LUN: LED port interface. */
734b6a94890be549309b21156f8ed6d4561cac51darrenm /** Status LUN: LED connector (peer). */
734b6a94890be549309b21156f8ed6d4561cac51darrenm PPDMDEVINSR3 pDevInsR3; /**< Device instance - R3. */
734b6a94890be549309b21156f8ed6d4561cac51darrenm PPDMDEVINSR0 pDevInsR0; /**< Device instance - R0. */
734b6a94890be549309b21156f8ed6d4561cac51darrenm PPDMDEVINSRC pDevInsRC; /**< Device instance - RC. */
734b6a94890be549309b21156f8ed6d4561cac51darrenm /** TODO */
734b6a94890be549309b21156f8ed6d4561cac51darrenm /** Base port of I/O space region. */
734b6a94890be549309b21156f8ed6d4561cac51darrenm /* Read/write part, protected with critical section. */
734b6a94890be549309b21156f8ed6d4561cac51darrenm /** Status LED. */
734b6a94890be549309b21156f8ed6d4561cac51darrenm uint16_t uQueueSelector; /**< An index in aQueues array. */
734b6a94890be549309b21156f8ed6d4561cac51darrenm uint8_t uStatus; /**< Device Status (bits are device-specific). */
734b6a94890be549309b21156f8ed6d4561cac51darrenm uint32_t nQueues; /**< Actual number of queues used. */
734b6a94890be549309b21156f8ed6d4561cac51darrenm#endif /* VBOX_WITH_STATISTICS */
734b6a94890be549309b21156f8ed6d4561cac51darrenm/** Pointer to the core (/common) state of a VirtIO PCI device. */
734b6a94890be549309b21156f8ed6d4561cac51darrenm/** @name Callbacks
734b6a94890be549309b21156f8ed6d4561cac51darrenmtypedef uint32_t (*PFNGETHOSTFEATURES)(void *pState);
734b6a94890be549309b21156f8ed6d4561cac51darrenmtypedef uint32_t (*PFNGETHOSTMINIMALFEATURES)(void *pState);
734b6a94890be549309b21156f8ed6d4561cac51darrenmtypedef void (*PFNSETHOSTFEATURES)(void *pState, uint32_t uFeatures);
734b6a94890be549309b21156f8ed6d4561cac51darrenmtypedef int (*PFNGETCONFIG)(void *pState, uint32_t port, uint32_t cb, void *data);
734b6a94890be549309b21156f8ed6d4561cac51darrenmtypedef int (*PFNSETCONFIG)(void *pState, uint32_t port, uint32_t cb, void *data);
734b6a94890be549309b21156f8ed6d4561cac51darrenmint vpciRaiseInterrupt(VPCISTATE *pState, int rcBusy, uint8_t u8IntCause);
734b6a94890be549309b21156f8ed6d4561cac51darrenm PFNGETHOSTMINIMALFEATURES pfnGetHostMinimalFeatures,
d3b2efc749bec3b757d5f018cf78c9a09fa29cb3Anthony Scarpinovoid vpciSetWriteLed(PVPCISTATE pState, bool fOn);
d3b2efc749bec3b757d5f018cf78c9a09fa29cb3Anthony Scarpinoint vpciSaveExec(PVPCISTATE pState, PSSMHANDLE pSSM);
734b6a94890be549309b21156f8ed6d4561cac51darrenmint vpciConstruct(PPDMDEVINS pDevIns, VPCISTATE *pState,
734b6a94890be549309b21156f8ed6d4561cac51darrenmvoid vpciRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta);
734b6a94890be549309b21156f8ed6d4561cac51darrenmvoid *vpciQueryInterface(struct PDMIBASE *pInterface, const char *pszIID);
734b6a94890be549309b21156f8ed6d4561cac51darrenmPVQUEUE vpciAddQueue(VPCISTATE* pState, unsigned uSize,
734b6a94890be549309b21156f8ed6d4561cac51darrenm const char *pcszName);
d3b2efc749bec3b757d5f018cf78c9a09fa29cb3Anthony ScarpinoDECLINLINE(int) vpciCsEnter(VPCISTATE *pState, int iBusyRc)
734b6a94890be549309b21156f8ed6d4561cac51darrenmvoid vringSetNotification(PVPCISTATE pState, PVRING pVRing, bool fEnabled);
734b6a94890be549309b21156f8ed6d4561cac51darrenmDECLINLINE(uint16_t) vringReadAvailIndex(PVPCISTATE pState, PVRING pVRing)
734b6a94890be549309b21156f8ed6d4561cac51darrenm pVRing->addrAvail + RT_OFFSETOF(VRINGAVAIL, uNextFreeIndex),
734b6a94890be549309b21156f8ed6d4561cac51darrenmbool vqueueGet(PVPCISTATE pState, PVQUEUE pQueue, PVQUEUEELEM pElem, bool fRemove = true);
734b6a94890be549309b21156f8ed6d4561cac51darrenmvoid vqueuePut(PVPCISTATE pState, PVQUEUE pQueue, PVQUEUEELEM pElem, uint32_t uLen, uint32_t uReserved = 0);
734b6a94890be549309b21156f8ed6d4561cac51darrenmvoid vqueueNotify(PVPCISTATE pState, PVQUEUE pQueue);
734b6a94890be549309b21156f8ed6d4561cac51darrenmDECLINLINE(bool) vqueuePeek(PVPCISTATE pState, PVQUEUE pQueue, PVQUEUEELEM pElem)
734b6a94890be549309b21156f8ed6d4561cac51darrenm return vqueueGet(pState, pQueue, pElem, /* fRemove */ false);
734b6a94890be549309b21156f8ed6d4561cac51darrenmDECLINLINE(bool) vqueueIsReady(PVPCISTATE pState, PVQUEUE pQueue)
734b6a94890be549309b21156f8ed6d4561cac51darrenmDECLINLINE(bool) vqueueIsEmpty(PVPCISTATE pState, PVQUEUE pQueue)
734b6a94890be549309b21156f8ed6d4561cac51darrenm return (vringReadAvailIndex(pState, &pQueue->VRing) == pQueue->uNextAvailIndex);
734b6a94890be549309b21156f8ed6d4561cac51darrenm#endif /* !___VBox_Virtio_h */