Logo Search packages:      
Sourcecode: virtualbox-ose version File versions  Download package

types.h

Go to the documentation of this file.
/** @file
 * VirtualBox - Types.
 */

/*
 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * 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.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
 * Clara, CA 95054 USA or visit http://www.sun.com if you need
 * additional information or have any questions.
 */

#ifndef ___VBox_types_h
#define ___VBox_types_h

#include <VBox/cdefs.h>
#include <iprt/types.h>


/** @defgroup grp_types     Basic VBox Types
 * @{
 */


/** @defgroup grp_types_both  Common Guest and Host Context Basic Types
 * @ingroup grp_types
 * @{
 */


/** @defgroup grp_types_hc  Host Context Basic Types
 * @ingroup grp_types_both
 * @{
 */

/** @} */


/** @defgroup grp_types_gc  Guest Context Basic Types
 * @ingroup grp_types_both
 * @{
 */

/** @} */


/** Pointer to per support driver session data.
 * (The data is a R0 entity and private to the the R0 SUP part. All
 * other should consider this a sort of handle.) */
typedef R0PTRTYPE(struct SUPDRVSESSION *) PSUPDRVSESSION;

/** Pointer to a VM. */
00070 typedef struct VM              *PVM;
/** Pointer to a VM - Ring-0 Ptr. */
typedef R0PTRTYPE(struct VM *)  PVMR0;
/** Pointer to a VM - Ring-3 Ptr. */
typedef R3PTRTYPE(struct VM *)  PVMR3;
/** Pointer to a VM - RC Ptr. */
typedef RCPTRTYPE(struct VM *)  PVMRC;

/** Pointer to a ring-0 (global) VM structure. */
typedef R0PTRTYPE(struct GVM *) PGVM;

/** Pointer to a ring-3 (user mode) VM structure. */
typedef R3PTRTYPE(struct UVM *) PUVM;


/** VM State
 */
00087 typedef enum VMSTATE
{
    /** The VM is being created. */
00090     VMSTATE_CREATING = 0,
    /** The VM is created. */
00092     VMSTATE_CREATED,
    /** The VM is runnning. */
00094     VMSTATE_RUNNING,
    /** The VM state is being loaded from file. */
00096     VMSTATE_LOADING,
    /** The VM is screwed because of a failed state loading. */
00098     VMSTATE_LOAD_FAILURE,
    /** The VM state is being saved to file. */
00100     VMSTATE_SAVING,
    /** The VM is suspended. */
00102     VMSTATE_SUSPENDED,
    /** The VM is being reset. */
00104     VMSTATE_RESETTING,
    /** The VM is in guru meditation over a fatal failure. */
00106     VMSTATE_GURU_MEDITATION,
    /** The VM is switched off, awaiting destruction. */
00108     VMSTATE_OFF,
    /** The VM is being destroyed. */
00110     VMSTATE_DESTROYING,
    /** Terminated. */
00112     VMSTATE_TERMINATED,
    /** hack forcing the size of the enum to 32-bits. */
00114     VMSTATE_MAKE_32BIT_HACK = 0x7fffffff
} VMSTATE;


/** Pointer to a PDM Driver Base Interface. */
00119 typedef struct PDMIBASE *PPDMIBASE;
/** Pointer to a pointer to a PDM Driver Base Interface. */
00121 typedef PPDMIBASE *PPPDMIBASE;

/** Pointer to a PDM Device Instance. */
00124 typedef struct PDMDEVINS *PPDMDEVINS;
/** Pointer to a pointer to a PDM Device Instance. */
00126 typedef PPDMDEVINS *PPPDMDEVINS;
/** R3 pointer to a PDM Device Instance. */
typedef R3PTRTYPE(PPDMDEVINS) PPDMDEVINSR3;
/** R0 pointer to a PDM Device Instance. */
typedef R0PTRTYPE(PPDMDEVINS) PPDMDEVINSR0;
/** RC pointer to a PDM Device Instance. */
typedef RCPTRTYPE(PPDMDEVINS) PPDMDEVINSRC;

/** Pointer to a PDM USB Device Instance. */
00135 typedef struct PDMUSBINS *PPDMUSBINS;
/** Pointer to a pointer to a PDM USB Device Instance. */
00137 typedef PPDMUSBINS *PPPDMUSBINS;

/** Pointer to a PDM Driver Instance. */
00140 typedef struct PDMDRVINS *PPDMDRVINS;
/** Pointer to a pointer to a PDM Driver Instance. */
00142 typedef PPDMDRVINS *PPPDMDRVINS;

/** Pointer to a PDM Service Instance. */
00145 typedef struct PDMSRVINS *PPDMSRVINS;
/** Pointer to a pointer to a PDM Service Instance. */
00147 typedef PPDMSRVINS *PPPDMSRVINS;

/** R3 pointer to a timer. */
typedef R3PTRTYPE(struct TMTIMER *) PTMTIMERR3;
/** Pointer to a R3 pointer to a timer. */
00152 typedef PTMTIMERR3 *PPTMTIMERR3;

/** R0 pointer to a timer. */
typedef R0PTRTYPE(struct TMTIMER *) PTMTIMERR0;
/** Pointer to a R3 pointer to a timer. */
00157 typedef PTMTIMERR0 *PPTMTIMERR0;

/** RC pointer to a timer. */
typedef RCPTRTYPE(struct TMTIMER *) PTMTIMERRC;
/** Pointer to a RC pointer to a timer. */
00162 typedef PTMTIMERRC *PPTMTIMERRC;

/** Pointer to a timer. */
typedef CTX_SUFF(PTMTIMER)     PTMTIMER;
/** Pointer to a pointer to a timer. */
00167 typedef PTMTIMER              *PPTMTIMER;

/** SSM Operation handle. */
00170 typedef struct SSMHANDLE *PSSMHANDLE;

/** Pointer to a CPUMCTX. */
00173 typedef struct CPUMCTX *PCPUMCTX;
/** Pointer to a const CPUMCTX. */
00175 typedef const struct CPUMCTX *PCCPUMCTX;

/** Pointer to a CPU context core. */
00178 typedef struct CPUMCTXCORE *PCPUMCTXCORE;
/** Pointer to a const CPU context core. */
00180 typedef const struct CPUMCTXCORE *PCCPUMCTXCORE;

/** Pointer to selector hidden registers. */
00183 typedef struct CPUMSELREGHID *PCPUMSELREGHID;
/** Pointer to const selector hidden registers. */
00185 typedef const struct CPUMSELREGHID *PCCPUMSELREGHID;

/** @} */


/** @defgroup grp_types_idt     Interrupt Descriptor Table Entry.
 * @ingroup grp_types
 * @todo This all belongs in x86.h!
 * @{ */

/** @todo VBOXIDT -> VBOXDESCIDT, skip the complex variations. We'll never use them. */

/** IDT Entry, Task Gate view. */
#pragma pack(1)                         /* paranoia */
00199 typedef struct VBOXIDTE_TASKGATE
{
    /** Reserved. */
00202     unsigned    u16Reserved1 : 16;
    /** Task Segment Selector. */
00204     unsigned    u16TSS : 16;
    /** More reserved. */
00206     unsigned    u8Reserved2 : 8;
    /** Fixed value bit 0 - Set to 1. */
00208     unsigned    u1Fixed0 : 1;
    /** Busy bit. */
00210     unsigned    u1Busy : 1;
    /** Fixed value bit 2 - Set to 1. */
00212     unsigned    u1Fixed1 : 1;
    /** Fixed value bit 3 - Set to 0. */
00214     unsigned    u1Fixed2: 1;
    /** Fixed value bit 4 - Set to 0. */
00216     unsigned    u1Fixed3 : 1;
    /** Descriptor Privilege level. */
00218     unsigned    u2DPL : 2;
    /** Present flag. */
00220     unsigned    u1Present : 1;
    /** Reserved. */
00222     unsigned    u16Reserved3 : 16;
} VBOXIDTE_TASKGATE;
#pragma pack()
/** Pointer to IDT Entry, Task gate view. */
00226 typedef VBOXIDTE_TASKGATE *PVBOXIDTE_TASKGATE;


/** IDT Entry, Intertupt gate view. */
#pragma pack(1)                         /* paranoia */
00231 typedef struct VBOXIDTE_INTERRUPTGATE
{
    /** Low offset word. */
00234     unsigned    u16OffsetLow : 16;
    /** Segment Selector. */
00236     unsigned    u16SegSel : 16;
    /** Reserved. */
00238     unsigned    u5Reserved2 : 5;
    /** Fixed value bit 0 - Set to 0. */
00240     unsigned    u1Fixed0 : 1;
    /** Fixed value bit 1 - Set to 0. */
00242     unsigned    u1Fixed1 : 1;
    /** Fixed value bit 2 - Set to 0. */
00244     unsigned    u1Fixed2 : 1;
    /** Fixed value bit 3 - Set to 0. */
00246     unsigned    u1Fixed3: 1;
    /** Fixed value bit 4 - Set to 1. */
00248     unsigned    u1Fixed4 : 1;
    /** Fixed value bit 5 - Set to 1. */
00250     unsigned    u1Fixed5 : 1;
    /** Gate size, 1 = 32 bits, 0 = 16 bits. */
00252     unsigned    u132BitGate : 1;
    /** Fixed value bit 5 - Set to 0. */
00254     unsigned    u1Fixed6 : 1;
    /** Descriptor Privilege level. */
00256     unsigned    u2DPL : 2;
    /** Present flag. */
00258     unsigned    u1Present : 1;
    /** High offset word. */
00260     unsigned    u16OffsetHigh : 16;
} VBOXIDTE_INTERRUPTGATE;
#pragma pack()
/** Pointer to IDT Entry, Interrupt gate view. */
00264 typedef  VBOXIDTE_INTERRUPTGATE *PVBOXIDTE_INTERRUPTGATE;

/** IDT Entry, Trap Gate view. */
#pragma pack(1)                         /* paranoia */
00268 typedef struct VBOXIDTE_TRAPGATE
{
    /** Low offset word. */
00271     unsigned    u16OffsetLow : 16;
    /** Segment Selector. */
00273     unsigned    u16SegSel : 16;
    /** Reserved. */
00275     unsigned    u5Reserved2 : 5;
    /** Fixed value bit 0 - Set to 0. */
00277     unsigned    u1Fixed0 : 1;
    /** Fixed value bit 1 - Set to 0. */
00279     unsigned    u1Fixed1 : 1;
    /** Fixed value bit 2 - Set to 0. */
00281     unsigned    u1Fixed2 : 1;
    /** Fixed value bit 3 - Set to 1. */
00283     unsigned    u1Fixed3: 1;
    /** Fixed value bit 4 - Set to 1. */
00285     unsigned    u1Fixed4 : 1;
    /** Fixed value bit 5 - Set to 1. */
00287     unsigned    u1Fixed5 : 1;
    /** Gate size, 1 = 32 bits, 0 = 16 bits. */
00289     unsigned    u132BitGate : 1;
    /** Fixed value bit 5 - Set to 0. */
00291     unsigned    u1Fixed6 : 1;
    /** Descriptor Privilege level. */
00293     unsigned    u2DPL : 2;
    /** Present flag. */
00295     unsigned    u1Present : 1;
    /** High offset word. */
00297     unsigned    u16OffsetHigh : 16;
} VBOXIDTE_TRAPGATE;
#pragma pack()
/** Pointer to IDT Entry, Trap Gate view. */
00301 typedef VBOXIDTE_TRAPGATE *PVBOXIDTE_TRAPGATE;

/** IDT Entry Generic view. */
#pragma pack(1)                         /* paranoia */
00305 typedef struct VBOXIDTE_GENERIC
{
    /** Low offset word. */
00308     unsigned    u16OffsetLow : 16;
    /** Segment Selector. */
00310     unsigned    u16SegSel : 16;
    /** Reserved. */
00312     unsigned    u5Reserved : 5;
    /** IDT Type part one (not used for task gate). */
00314     unsigned    u3Type1 : 3;
    /** IDT Type part two. */
00316     unsigned    u5Type2 : 5;
    /** Descriptor Privilege level. */
00318     unsigned    u2DPL : 2;
    /** Present flag. */
00320     unsigned    u1Present : 1;
    /** High offset word. */
00322     unsigned    u16OffsetHigh : 16;
} VBOXIDTE_GENERIC;
#pragma pack()
/** Pointer to IDT Entry Generic view. */
00326 typedef VBOXIDTE_GENERIC *PVBOXIDTE_GENERIC;

/** IDT Type1 value. (Reserved for task gate!) */
00329 #define VBOX_IDTE_TYPE1             0
/** IDT Type2 value - Task gate. */
00331 #define VBOX_IDTE_TYPE2_TASK        0x5
/** IDT Type2 value - 16 bit interrupt gate. */
00333 #define VBOX_IDTE_TYPE2_INT_16      0x6
/** IDT Type2 value - 32 bit interrupt gate. */
00335 #define VBOX_IDTE_TYPE2_INT_32      0xe
/** IDT Type2 value - 16 bit trap gate. */
00337 #define VBOX_IDTE_TYPE2_TRAP_16     0x7
/** IDT Type2 value - 32 bit trap gate. */
00339 #define VBOX_IDTE_TYPE2_TRAP_32     0xf

/** IDT Entry. */
#pragma pack(1)                         /* paranoia */
00343 typedef union VBOXIDTE
{
    /** Task gate view. */
00346     VBOXIDTE_TASKGATE       Task;
    /** Trap gate view. */
00348     VBOXIDTE_TRAPGATE       Trap;
    /** Interrupt gate view. */
00350     VBOXIDTE_INTERRUPTGATE  Int;
    /** Generic IDT view. */
00352     VBOXIDTE_GENERIC        Gen;

    /** 8 bit unsigned integer view. */
00355     uint8_t     au8[8];
    /** 16 bit unsigned integer view. */
00357     uint16_t    au16[4];
    /** 32 bit unsigned integer view. */
00359     uint32_t    au32[2];
    /** 64 bit unsigned integer view. */
00361     uint64_t    au64;
} VBOXIDTE;
#pragma pack()
/** Pointer to IDT Entry. */
00365 typedef VBOXIDTE *PVBOXIDTE;

#pragma pack(1)
/** IDTR */
00369 typedef struct VBOXIDTR
{
    /** Size of the IDT. */
00372     uint16_t    cbIdt;
    /** Address of the IDT. */
00374     uint64_t     pIdt;
} VBOXIDTR, *PVBOXIDTR;
#pragma pack()

#pragma pack(1)
/** IDTR from version 1.6 */
00380 typedef struct VBOXIDTR_VER1_6
{
    /** Size of the IDT. */
00383     uint16_t    cbIdt;
    /** Address of the IDT. */
00385     uint32_t     pIdt;
} VBOXIDTR_VER1_6, *PVBOXIDTR_VER1_6;
#pragma pack()

/** @} */


/** @def VBOXIDTE_OFFSET
 * Return the offset of an IDT entry.
 */
00395 #define VBOXIDTE_OFFSET(desc) \
        (  ((uint32_t)((desc).Gen.u16OffsetHigh) << 16) \
         | (           (desc).Gen.u16OffsetLow        ) )

#pragma pack(1)
/** GDTR */
00401 typedef struct VBOXGDTR
{
    /** Size of the GDT. */
00404     uint16_t    cbGdt;
    /** Address of the GDT. */
00406     uint64_t    pGdt;
} VBOXGDTR;
#pragma pack()
/** Pointer to GDTR. */
00410 typedef VBOXGDTR *PVBOXGDTR;

#pragma pack(1)
/** GDTR from version 1.6 */
00414 typedef struct VBOXGDTR_VER1_6
{
    /** Size of the GDT. */
00417     uint16_t    cbGdt;
    /** Address of the GDT. */
00419     uint32_t    pGdt;
} VBOXGDTR_VER1_6;
#pragma pack()

/** @} */


/**
 * Task Segment
 */
#pragma pack(1)
00430 typedef struct VBOXTSS
{
    /** Back link to previous task. (static) */
00433     RTSEL       selPrev;
    uint16_t    padding1;
    /** Ring-0 stack pointer. (static) */
00436     uint32_t    esp0;
    /** Ring-0 stack segment. (static) */
00438     RTSEL       ss0;
    uint16_t    padding_ss0;
    /** Ring-1 stack pointer. (static) */
00441     uint32_t    esp1;
    /** Ring-1 stack segment. (static) */
00443     RTSEL       ss1;
    uint16_t    padding_ss1;
    /** Ring-2 stack pointer. (static) */
00446     uint32_t    esp2;
    /** Ring-2 stack segment. (static) */
00448     RTSEL       ss2;
    uint16_t    padding_ss2;
    /** Page directory for the task. (static) */
00451     uint32_t    cr3;
    /** EIP before task switch. */
00453     uint32_t    eip;
    /** EFLAGS before task switch. */
00455     uint32_t    eflags;
    /** EAX before task switch. */
00457     uint32_t    eax;
    /** ECX before task switch. */
00459     uint32_t    ecx;
    /** EDX before task switch. */
00461     uint32_t    edx;
    /** EBX before task switch. */
00463     uint32_t    ebx;
    /** ESP before task switch. */
00465     uint32_t    esp;
    /** EBP before task switch. */
00467     uint32_t    ebp;
    /** ESI before task switch. */
00469     uint32_t    esi;
    /** EDI before task switch. */
00471     uint32_t    edi;
    /** ES before task switch. */
00473     RTSEL       es;
    uint16_t    padding_es;
    /** CS before task switch. */
00476     RTSEL       cs;
    uint16_t    padding_cs;
    /** SS before task switch. */
00479     RTSEL       ss;
    uint16_t    padding_ss;
    /** DS before task switch. */
00482     RTSEL       ds;
    uint16_t    padding_ds;
    /** FS before task switch. */
00485     RTSEL       fs;
    uint16_t    padding_fs;
    /** GS before task switch. */
00488     RTSEL       gs;
    uint16_t    padding_gs;
    /** LDTR before task switch. */
00491     RTSEL       selLdt;
    uint16_t    padding_ldt;
    /** Debug trap flag */
00494     uint16_t    fDebugTrap;
    /** Offset relative to the TSS of the start of the I/O Bitmap
     * and the end of the interrupt redirection bitmap. */
00497     uint16_t    offIoBitmap;
    /** 32 bytes for the virtual interrupt redirection bitmap. (VME) */
00499     uint8_t     IntRedirBitmap[32];
} VBOXTSS;
#pragma pack()
/** Pointer to task segment. */
00503 typedef VBOXTSS *PVBOXTSS;
/** Pointer to const task segment. */
00505 typedef const VBOXTSS *PCVBOXTSS;


/**
 * Data transport buffer (scatter/gather)
 */
00511 typedef struct PDMDATASEG
{
    /** Length of buffer in entry. */
00514     size_t  cbSeg;
    /** Pointer to the start of the buffer. */
00516     void   *pvSeg;
} PDMDATASEG;
/** Pointer to a data transport segment. */
00519 typedef PDMDATASEG *PPDMDATASEG;
/** Pointer to a const data transport segment. */
00521 typedef PDMDATASEG const *PCPDMDATASEG;

/** @} */

#endif

Generated by  Doxygen 1.6.0   Back to index