pdmthread.h revision 0b74a2f80aba476dc8be8bc1c63891fc53945986
/** @file
* PDM - Pluggable Device Manager, Threads.
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___VBox_vmm_pdmthread_h
#define ___VBox_vmm_pdmthread_h
#ifdef IN_RING3
#endif
/** @defgroup grp_pdm_thread The PDM Threads API
* @ingroup grp_pdm
* @{
*/
/**
* The thread state
*/
typedef enum PDMTHREADSTATE
{
/** The usual invalid 0 entry. */
/** The thread is initializing.
* Prev state: none
* Next state: suspended, terminating (error) */
/** The thread has been asked to suspend.
* Prev state: running
* Next state: suspended */
/** The thread is supended.
* Prev state: suspending, initializing
* Next state: resuming, terminated. */
/** The thread is active.
* Prev state: suspended
* Next state: running, terminating. */
/** The thread is active.
* Prev state: resuming
* Next state: suspending, terminating. */
/** The thread has been asked to terminate.
* Prev state: initializing, suspended, resuming, running
* Next state: terminated. */
/** The thread is terminating / has terminated.
* Prev state: terminating
* Next state: none */
/** The usual 32-bit hack. */
PDMTHREADSTATE_32BIT_HACK = 0x7fffffff
/** A pointer to a PDM thread. */
/** A pointer to a pointer to a PDM thread. */
typedef PPDMTHREAD *PPPDMTHREAD;
/**
* PDM thread, device variation.
*
* @returns VBox status code.
* @param pDevIns The device instance.
* @param pThread The PDM thread data.
*/
/** Pointer to a FNPDMTHREADDEV(). */
typedef FNPDMTHREADDEV *PFNPDMTHREADDEV;
/**
* PDM thread, USB device variation.
*
* @returns VBox status code.
* @param pUsbIns The USB device instance.
* @param pThread The PDM thread data.
*/
/** Pointer to a FNPDMTHREADUSB(). */
typedef FNPDMTHREADUSB *PFNPDMTHREADUSB;
/**
* PDM thread, driver variation.
*
* @returns VBox status code.
* @param pDrvIns The driver instance.
* @param pThread The PDM thread data.
*/
/** Pointer to a FNPDMTHREADDRV(). */
typedef FNPDMTHREADDRV *PFNPDMTHREADDRV;
/**
* PDM thread, driver variation.
*
* @returns VBox status code.
* @param pVM The VM handle.
* @param pThread The PDM thread data.
*/
/** Pointer to a FNPDMTHREADINT(). */
typedef FNPDMTHREADINT *PFNPDMTHREADINT;
/**
* PDM thread, driver variation.
*
* @returns VBox status code.
* @param pThread The PDM thread data.
*/
/** Pointer to a FNPDMTHREADEXT(). */
typedef FNPDMTHREADEXT *PFNPDMTHREADEXT;
/**
* PDM thread wakeup call, device variation.
*
* @returns VBox status code.
* @param pDevIns The device instance.
* @param pThread The PDM thread data.
*/
/** Pointer to a FNPDMTHREADDEV(). */
typedef FNPDMTHREADWAKEUPDEV *PFNPDMTHREADWAKEUPDEV;
/**
* PDM thread wakeup call, device variation.
*
* @returns VBox status code.
* @param pUsbIns The USB device instance.
* @param pThread The PDM thread data.
*/
/** Pointer to a FNPDMTHREADUSB(). */
typedef FNPDMTHREADWAKEUPUSB *PFNPDMTHREADWAKEUPUSB;
/**
* PDM thread wakeup call, driver variation.
*
* @returns VBox status code.
* @param pDrvIns The driver instance.
* @param pThread The PDM thread data.
*/
/** Pointer to a FNPDMTHREADDRV(). */
typedef FNPDMTHREADWAKEUPDRV *PFNPDMTHREADWAKEUPDRV;
/**
* PDM thread wakeup call, internal variation.
*
* @returns VBox status code.
* @param pVM The VM handle.
* @param pThread The PDM thread data.
*/
/** Pointer to a FNPDMTHREADWAKEUPINT(). */
typedef FNPDMTHREADWAKEUPINT *PFNPDMTHREADWAKEUPINT;
/**
* PDM thread wakeup call, external variation.
*
* @returns VBox status code.
* @param pThread The PDM thread data.
*/
/** Pointer to a FNPDMTHREADEXT(). */
typedef FNPDMTHREADWAKEUPEXT *PFNPDMTHREADWAKEUPEXT;
/**
* PDM Thread instance data.
*/
typedef struct PDMTHREAD
{
/** PDMTHREAD_VERSION. */
/** The thread state. */
PDMTHREADSTATE volatile enmState;
/** The thread handle. */
/** The user parameter. */
/** Data specific to the kind of thread.
* This should really be in PDMTHREADINT, but is placed here because of the
* function pointer typedefs. So, don't touch these, please.
*/
union
{
/** PDMTHREADTYPE_DEVICE data. */
struct
{
/** The device instance. */
/** The thread function. */
/** Thread. */
} Dev;
/** PDMTHREADTYPE_USB data. */
struct
{
/** The device instance. */
/** The thread function. */
/** Thread. */
} Usb;
/** PDMTHREADTYPE_DRIVER data. */
struct
{
/** The driver instance. */
/** The thread function. */
/** Thread. */
} Drv;
/** PDMTHREADTYPE_INTERNAL data. */
struct
{
/** The thread function. */
/** Thread. */
} Int;
/** PDMTHREADTYPE_EXTERNAL data. */
struct
{
/** The thread function. */
/** Thread. */
} Ext;
} u;
/** Internal data. */
union
{
#ifdef PDMTHREADINT_DECLARED
PDMTHREADINT s;
#endif
} Internal;
} PDMTHREAD;
/** PDMTHREAD::u32Version value. */
#ifdef IN_RING3
VMMR3DECL(int) PDMR3ThreadCreate(PVM pVM, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADINT pfnThread,
VMMR3DECL(int) PDMR3ThreadCreateExternal(PVM pVM, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADEXT pfnThread,
#endif /* IN_RING3 */
/** @} */
#endif