VBoxDTraceTypes.h revision 0f35a0af8419a03d0f456ff4de479bb547425635
/* $Id$ */
/** @file
* VBoxDTraceTypes.h - Fake a bunch of Solaris types.
*
* Contributed by: bird
*/
/*
* Copyright (C) 2012-2015 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* Development and Distribution License Version 1.0 (CDDL) only, as it
* comes in the "COPYING.CDDL" 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.
*
*/
#ifndef ___VBoxDTraceTypes_h___
#define ___VBoxDTraceTypes_h___
#ifdef IN_RING0
#endif
#ifdef IN_RING3
# include <limits.h>
# if defined(_MSC_VER)
# include <stdio.h>
# endif
#endif
struct modctl;
typedef unsigned char uchar_t;
typedef unsigned short ushort_t;
typedef unsigned int uint_t;
typedef int64_t longlong_t;
typedef uint64_t u_longlong_t;
typedef RTCCINTREG greg_t;
typedef unsigned int model_t;
typedef RTCPUID processorid_t;
typedef char *caddr_t;
#endif
#define NANOSEC RT_NS_1SEC
#define MICROSEC RT_US_1SEC
#define MILLISEC RT_MS_1SEC
#define SEC (1)
#define MAXPATHLEN RTPATH_MAX
#define PATH_MAX RTPATH_MAX
#define NBBY (8)
#define NCPU RTCPUSET_MAX_CPUS
#define B_FALSE (0)
#define B_TRUE (1)
#if defined(RT_ARCH_X86)
# ifndef __i386
# define __i386 1
# endif
# ifndef __x86
# define __x86 1
# endif
# ifndef _IPL32
# define _IPL32 1
# endif
# define _LITTLE_ENDIAN 1
#elif defined(RT_ARCH_AMD64)
# ifndef __x86_64
# define __x86_64 1
# endif
# ifndef __x86
# define __x86 1
# endif
# ifndef _LP64
# define _LP64 1
# endif
# define _LITTLE_ENDIAN 1
#else
# error "unsupported arch!"
#endif
/** Mark a cast added when porting the code to VBox.
* Avoids lots of \#ifdef VBOX otherwise needed to mark up the changes. */
/** Mark a type change made when porting the code to VBox.
* This is usually signed -> unsigned type changes that avoids a whole lot of
* comparsion warnings. */
/** Mark missing void in a parameter list. */
#define VBDTVOID void
/** Mark missing static in a function definition. */
#define VBDTSTATIC static
/*
* string
*/
# define snprintf RTStrPrintf
# define vsnprintf RTStrPrintfV
#endif
/*
* Bitmap stuff.
*/
#if ARCH_BITS == 32
# define BT_NBIPUL 32
# define BT_ULMASK 0x1f
# define BT_NBIPUL 64
# define BT_ULMASK 0x3f
#else
#endif
#ifdef IN_RING0
/*
* Kernel stuff...
*/
#define CPU_ON_INTR(a_pCpu) (false)
#define KERNELBASE VBoxDtGetKernelBase()
uintptr_t VBoxDtGetKernelBase(void);
typedef struct VBoxDtCred
{
} cred_t;
#define priv_isequalset(a, b) (true)
#define crhold VBoxDtCredHold
#define crfree VBoxDtCredFree
typedef struct RTTIMER *cyclic_id_t;
typedef struct VBoxDtThread
{
/** The next thread with the same hash table entry.
* Or the next free thread. */
struct VBoxDtThread *pNext;
/** Age list node. */
/** The native thread handle. */
/** The process ID. */
} kthread_t;
struct VBoxDtThread *VBoxDtGetCurrentThread(void);
#define curthread (VBoxDtGetCurrentThread())
typedef struct VBoxDtProcess proc_t;
# if 0 /* not needed ? */
struct VBoxDtProcess proc_t;
{
/* uint32_t p_flag; - don't bother with this */
struct dtrace_helpers *p_dtrace_helpers;
}
proc_t *VBoxDtGetCurrentProc(void);
# define curproc (VBoxDtGetCurrentProc())
/*# define SNOCD RT_BIT(0) - don't bother with this */
# endif
typedef struct VBoxDtTaskQueue taskq_t;
typedef struct VBoxDtMutex
{
RTNATIVETHREAD volatile hOwner;
} kmutex_t;
#define mutex_enter VBoxDtMutexEnter
#define mutex_exit VBoxDtMutexExit
#define mod_lock g_DummyMtx
#define cpu_lock g_DummyMtx
extern struct VBoxDtMutex g_DummyMtx;
typedef struct VBoxDtCpuCore
{
uint16_t volatile cpuc_dtrace_flags;
} cpucore_t;
#define CPU_DTRACE_BADADDR RT_BIT(0)
#define cpu_core (g_aVBoxDtCpuCores)
struct VBoxDtCred *VBoxDtGetCurrentCreds(void);
#define CRED() VBoxDtGetCurrentCreds()
#define panic VBoxDtPanic
void VBoxDtPanic(const char *pszFormat, ...);
#define cmn_err VBoxDtCmnErr
#define CE_WARN 10
#define CE_NOTE 11
#define uprintf VBoxDtUPrintf
#define vuprintf VBoxDtUPrintfV
void VBoxDtUPrintf(const char *pszFormat, ...);
/*
* Memory allocation wrappers.
*/
#define kmem_alloc VBoxDtKMemAlloc
#define kmem_zalloc VBoxDtKMemAllocZ
#define kmem_free VBoxDtKMemFree
typedef struct VBoxDtMemCache kmem_cache_t;
#define kmem_cache_alloc VBoxDtKMemCacheAlloc
#define kmem_cache_free VBoxDtKMemCacheFree
typedef struct VBoxDtVMem vmem_t;
#define vmem_create VBoxDtVMemCreate
#define vmem_destroy VBoxDtVMemDestroy
#define vmem_alloc VBoxDtVMemAlloc
#define vmem_free VBoxDtVMemFree
/*
*/
#define copyin VBoxDtCopyIn
#define copyout VBoxDtCopyOut
/*
* Device numbers.
*/
/*
* DDI
*/
# define DDI_SUCCESS (0)
# define DDI_FAILURE (-1)
# if 0 /* not needed */
# define ddi_get_soft_state VBoxDtDdiSoftStateGet
int VBoxDtDdiSoftStateTerm(void **ppvSoftStates);
typedef enum { DDI_ATT_CMD_DUMMY } ddi_attach_cmd_t;
typedef struct VBoxDtDevInfo dev_info_t;
# define ddi_driver_major VBoxDtDdiDriverMajor
# define ddi_report_dev VBoxDtDdiReportDev
# endif
/*
* DTrace bits we've made external.
*/
extern int dtrace_attach(void);
extern int dtrace_detach(void);
struct dtrace_state;
#endif /* IN_RING0 */
#ifdef IN_RING3
/*
* Make life a little easier in ring-3.
*/
# include <stdlib.h>
# include <string.h>
# define gethrtime() RTTimeNanoTS()
/* This isn't necessarily making things easier at first, but allows EF and
such later on when things doesn't work right. */
/* Replacement for strndup(), requires editing the code unfortunately. */
do { \
} while (0)
/*
* gelf
*/
# include "../../../Runtime/include/internal/ldrELF64.h"
typedef Elf64_Half GElf_Half;
typedef Elf64_Xword GElf_Xword;
typedef Elf64_Shdr GElf_Shdr;
typedef Elf64_Ehdr GElf_Ehdr;
typedef Elf64_Addr GElf_Addr;
#define GELF_ST_INFO ELF64_ST_INFO
#define GELF_ST_TYPE ELF64_ST_TYPE
#define GELF_ST_BIND ELF64_ST_BIND
/*
* MSC stuff.
*/
# ifdef _MSC_VER
# ifndef SIZE_MAX
# if ARCH_BITS == 32
# define SIZE_MAX UINT32_MAX
# else
# define SIZE_MAX UINT64_MAX
# endif
# endif
# endif /* _MSC_VER */
#endif /* IN_RING3 */
#endif