SUPDRVIOC.h revision c11eaae90d06d3740db0cfc969cc426b75dc7d73
/** @file
*
* VBox host drivers - Ring-0 support drivers - Shared code:
* IOCtl definitions
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* 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 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.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
#ifndef __SUPDRVIOC_h__
#define __SUPDRVIOC_h__
/*
* Basic types.
*/
/*
* IOCtl numbers.
* We're using the Win32 type of numbers here, thus the macros below.
* The SUP_IOCTL_FLAG macro is used to separate requests from 32-bit
* and 64-bit processes.
*/
#ifdef __AMD64__
# define SUP_IOCTL_FLAG 128
# define SUP_IOCTL_FLAG 0
#else
# error "dunno which arch this is!"
#endif
#ifdef __WIN__
# define SUP_CTL_CODE(Function) CTL_CODE(FILE_DEVICE_UNKNOWN, (Function) | SUP_IOCTL_FLAG, METHOD_BUFFERED, FILE_WRITE_ACCESS)
# define SUP_CTL_CODE_FAST(Function) CTL_CODE(FILE_DEVICE_UNKNOWN, (Function) | SUP_IOCTL_FLAG, METHOD_NEITHER, FILE_WRITE_ACCESS)
/** @todo get rid of this duplication of window header #defines! */
# ifndef CTL_CODE
# endif
# ifndef METHOD_BUFFERED
# define METHOD_BUFFERED 0
# endif
# ifndef METHOD_NEITHER
# define METHOD_NEITHER 3
# endif
# ifndef FILE_WRITE_ACCESS
# define FILE_WRITE_ACCESS 0x0002
# endif
# ifndef FILE_DEVICE_UNKNOWN
# define FILE_DEVICE_UNKNOWN 0x00000022
# endif
# define SUP_CTL_CATEGORY 0xc0
# define SUP_CTL_CATEGORY_FAST 0xc1
# ifdef __X86__ /** @todo With the next major version change, drop this branch. */
# define SUP_CTL_CODE(Function) \
# define SUP_CTL_CODE_FAST(Function) \
# else
# if 1 /* figure out when this changed. */
# else /* now: _IO_BAD and _IOWR_BAD */
# endif
# endif
#else /* BSD */
#endif
/** Negotiate cookie. */
/** Query SUPR0 functions. */
/** Install IDT patch for calling processor. */
/** Remove IDT patch for calling processor. */
/** Pin down physical pages. */
/** Unpin physical pages. */
/** Allocate contious memory. */
/** Free contious memory. */
/** Open an image. */
/** Upload the image bits. */
/** Free an image. */
/** Get address of a symbol within an image. */
/** Call the R0 VMM Entry point. */
/** Get the host paging mode. */
/** Allocate memory below 4GB (physically). */
/** Free low memory. */
/** Map the GIP into user space. */
/** Unmap the GIP. */
/** Set the VM handle for doing fast call ioctl calls. */
/** Fast path IOCtl: VMMR0_DO_RAW_RUN */
/** Fast path IOCtl: VMMR0_DO_HWACC_RUN */
/** Just a NOP call for profiling the latency of a fast ioctl call to VMMR0. */
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
#ifdef __AMD64__
#else
#endif
#ifndef __WIN__
/**
* Structure used by OSes with less advanced ioctl interfaces, i.e. most
* Unix like OSes :-)
*/
typedef struct SUPDRVIOCTLDATA
{
void *pvIn;
unsigned long cbIn;
void *pvOut;
unsigned long cbOut;
#ifdef __OS2__
int rc;
#endif
#endif
/** SUPCOOKIE_IN magic word. */
#define SUPCOOKIE_MAGIC "The Magic Word!"
/** Current interface version.
* The upper 16-bit is the major version, the the lower the minor version.
* When incompatible changes are made, the upper major number has to be changed. */
#define SUPDRVIOC_VERSION 0x00040004
/** SUP_IOCTL_COOKIE Input. */
typedef struct SUPCOOKIE_IN
{
/** Magic word. */
char szMagic[16];
/** The requested interface version number. */
/** The minimum interface version number. */
/** SUP_IOCTL_COOKIE Output. */
typedef struct SUPCOOKIE_OUT
{
/** Cookie. */
/** Session cookie. */
/** Interface version for this session. */
/** The actual interface version in the driver. */
/** Number of functions available for the SUP_IOCTL_QUERY_FUNCS request. */
/** Session handle. */
/** SUP_IOCTL_QUERY_FUNCS Input. */
typedef struct SUPQUERYFUNCS_IN
{
/** Cookie. */
/** Session cookie. */
/** Function. */
typedef struct SUPFUNC
{
/** Name - mangled. */
char szName[32];
/** Address. */
/** SUP_IOCTL_QUERY_FUNCS Output. */
typedef struct SUPQUERYFUNCS_OUT
{
/** Number of functions returned. */
/** Array of functions. */
/** SUP_IOCTL_IDT_INSTALL Input. */
typedef struct SUPIDTINSTALL_IN
{
/** Cookie. */
/** Session cookie. */
/** SUP_IOCTL_IDT_INSTALL Output. */
typedef struct SUPIDTINSTALL_OUT
{
/** Cookie. */
/** SUP_IOCTL_IDT_REMOVE Input. */
typedef struct SUPIDTREMOVE_IN
{
/** Cookie. */
/** Session cookie. */
/** SUP_IOCTL_PINPAGES Input. */
typedef struct SUPPINPAGES_IN
{
/** Cookie. */
/** Session cookie. */
/** Start of page range. Must be PAGE aligned. */
/** Size of the range. Must be PAGE aligned. */
/** SUP_IOCTL_PINPAGES Output. */
typedef struct SUPPINPAGES_OUT
{
/** Array of pages. */
/** SUP_IOCTL_UNPINPAGES Input. */
typedef struct SUPUNPINPAGES_IN
{
/** Cookie. */
/** Session cookie. */
/** Start of page range of a range previuosly pinned. */
/** SUP_IOCTL_CONT_ALLOC Input. */
typedef struct SUPCONTALLOC_IN
{
/** Cookie. */
/** Session cookie. */
/** Number of bytes to allocate. */
/** SUP_IOCTL_CONT_ALLOC Output. */
typedef struct SUPCONTALLOC_OUT
{
/** The address of the ring-0 mapping of the allocated memory. */
/** The address of the ring-3 mapping of the allocated memory. */
/** The physical address of the allocation. */
/** SUP_IOCTL_CONT_FREE Input. */
typedef struct SUPCONTFREE_IN
{
/** Cookie. */
/** Session cookie. */
/** The ring-3 address of the memory to free. */
/** SUP_IOCTL_LDR_OPEN Input. */
typedef struct SUPLDROPEN_IN
{
/** Cookie. */
/** Session cookie. */
/** Size of the image we'll be loading. */
/** Image name.
* This is the NAME of the image, not the file name. It is used
* to share code with other processes. (Max len is 32 chars!) */
char szName[32];
/** SUP_IOCTL_LDR_OPEN Output. */
typedef struct SUPLDROPEN_OUT
{
/** The base address of the image. */
/** Indicate whether or not the image requires loading. */
bool fNeedsLoading;
/**
* Module initialization callback function.
* This is called once after the module has been loaded.
*
* @returns 0 on success.
* @returns Appropriate error code on failure.
*/
typedef DECLCALLBACK(int) FNR0MODULEINIT(void);
/** Pointer to a FNR0MODULEINIT(). */
/**
* Module termination callback function.
* This is called once right before the module is being unloaded.
*/
typedef DECLCALLBACK(void) FNR0MODULETERM(void);
/** Pointer to a FNR0MODULETERM(). */
/**
* Symbol table entry.
*/
typedef struct SUPLDRSYM
{
/** Offset into of the string table. */
/** Offset of the symbol relative to the image load address. */
} SUPLDRSYM, *PSUPLDRSYM;
/** SUP_IOCTL_LDR_LOAD Input. */
typedef struct SUPLDRLOAD_IN
{
/** Cookie. */
/** Session cookie. */
/** The address of module initialization function. Similar to _DLL_InitTerm(hmod, 0). */
/** The address of module termination function. Similar to _DLL_InitTerm(hmod, 1). */
/** Special entry points. */
union
{
struct
{
/** The module handle (i.e. address). */
/** Address of VMMR0Entry function. */
} VMMR0;
} EP;
/** Address. */
/** Entry point type. */
enum { EP_NOTHING, EP_VMMR0 }
/** The offset of the symbol table. */
/** The number of entries in the symbol table. */
/** The offset of the string table. */
/** Size of the string table. */
/** Size of image (including string and symbol tables). */
/** The image data. */
char achImage[1];
/** SUP_IOCTL_LDR_FREE Input. */
typedef struct SUPLDRFREE_IN
{
/** Cookie. */
/** Session cookie. */
/** Address. */
/** SUP_IOCTL_LDR_GET_SYMBOL Input. */
typedef struct SUPLDRGETSYMBOL_IN
{
/** Cookie. */
/** Session cookie. */
/** Address. */
/** The symbol name (variable length). */
char szSymbol[1];
/** SUP_IOCTL_LDR_GET_SYMBOL Output. */
typedef struct SUPLDRGETSYMBOL_OUT
{
/** The symbol address. */
/** SUP_IOCTL_CALL_VMMR0 Input. */
typedef struct SUPCALLVMMR0_IN
{
/** Cookie. */
/** Session cookie. */
/** The VM handle. */
/** Which operation to execute. */
/** The size of the buffer pointed to by pvArg. */
/** Argument to that operation. */
/** SUP_IOCTL_CALL_VMMR0 Output. */
typedef struct SUPCALLVMMR0_OUT
{
/** The VBox status code for the operation. */
/** SUP_IOCTL_GET_PAGING_MODE Input. */
typedef struct SUPGETPAGINGMODE_IN
{
/** Cookie. */
/** Session cookie. */
/** SUP_IOCTL_GET_PAGING_MODE Output. */
typedef struct SUPGETPAGINGMODE_OUT
{
/** The paging mode. */
/** SUP_IOCTL_LOW_ALLOC Input. */
typedef struct SUPLOWALLOC_IN
{
/** Cookie. */
/** Session cookie. */
/** Number of pages to allocate. */
/** SUP_IOCTL_LOW_ALLOC Output. */
typedef struct SUPLOWALLOC_OUT
{
/** The ring-3 address of the allocated memory. */
/** The ring-0 address of the allocated memory. */
/** Array of pages. */
/** SUP_IOCTL_LOW_FREE Input. */
typedef struct SUPLOWFREE_IN
{
/** Cookie. */
/** Session cookie. */
/** The ring-3 address of the memory to free. */
/** SUP_IOCTL_GIP_MAP Input. */
typedef struct SUPGIPMAP_IN
{
/** Cookie. */
/** Session cookie. */
/** SUP_IOCTL_GIP_MAP Output. */
typedef struct SUPGIPMAP_OUT
{
/** Pointer to the read-only usermode GIP mapping for this session. */
/** Pointer to the supervisor mode GIP mapping. */
/** The physical address of the GIP. */
/** SUP_IOCTL_GIP_UNMAP Input. */
typedef struct SUPGIPUNMAP_IN
{
/** Cookie. */
/** Session cookie. */
/** SUP_IOCTL_SET_VM_FOR_FAST Input. */
typedef struct SUPSETVMFORFAST_IN
{
/** Cookie. */
/** Session cookie. */
/** The ring-0 VM handle (pointer). */
#pragma pack() /* paranoia */
#endif