VBoxDTraceR0.cpp revision 8a93080e3d260d04962c3a5eb16fcd699a2364cf
/* $Id$ */
/** @file
* VBoxDTraceR0.
*/
/*
* Copyright (c) 2012 bird
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <iprt/asm-amd64-x86.h>
#include <sys/dtrace_impl.h>
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** Per CPU information */
/** Dummy mutex. */
struct VBoxDtMutex g_DummyMtx;
void (*dtrace_cpu_init)(processorid_t);
void (*dtrace_modload)(struct modctl *);
void (*dtrace_modunload)(struct modctl *);
void (*dtrace_helpers_cleanup)(void);
void (*dtrace_cpustart_init)(void);
void (*dtrace_cpustart_fini)(void);
void (*dtrace_cpc_fire)(uint64_t);
void (*dtrace_debugger_init)(void);
void (*dtrace_debugger_fini)(void);
{
/** @todo ? */
}
/**
* Dummy callback used by dtrace_sync.
*/
{
}
/**
* Synchronzie across all CPUs (expensive).
*/
void dtrace_sync(void)
{
}
/**
* Fetch a 8-bit "word" from userland.
*
* @return The byte value.
* @param pvUserAddr The userland address.
*/
{
if (RT_FAILURE(rc))
{
u8 = 0;
}
return u8;
}
/**
* Fetch a 16-bit word from userland.
*
* @return The word value.
* @param pvUserAddr The userland address.
*/
{
if (RT_FAILURE(rc))
{
u16 = 0;
}
return u16;
}
/**
* Fetch a 32-bit word from userland.
*
* @return The dword value.
* @param pvUserAddr The userland address.
*/
{
if (RT_FAILURE(rc))
{
u32 = 0;
}
return u32;
}
/**
* Fetch a 64-bit word from userland.
*
* @return The qword value.
* @param pvUserAddr The userland address.
*/
{
if (RT_FAILURE(rc))
{
u64 = 0;
}
return u64;
}
/** copyin implementation */
{
}
/** copyout implementation */
{
}
/**
* Copy data from userland into the kernel.
*
* @param uUserAddr The userland address.
* @param uKrnlAddr The kernel buffer address.
* @param cb The number of bytes to copy.
* @param pfFlags Pointer to the relevant cpuc_dtrace_flags.
*/
void dtrace_copyin( uintptr_t uUserAddr, uintptr_t uKrnlAddr, size_t cb, volatile uint16_t *pfFlags)
{
if (RT_FAILURE(rc))
{
}
}
/**
* Copy data from the kernel into userlad.
*
* @param uKrnlAddr The kernel buffer address.
* @param uUserAddr The userland address.
* @param cb The number of bytes to copy.
* @param pfFlags Pointer to the relevant cpuc_dtrace_flags.
*/
void dtrace_copyout( uintptr_t uKrnlAddr, uintptr_t uUserAddr, size_t cb, volatile uint16_t *pfFlags)
{
if (RT_FAILURE(rc))
{
}
}
/**
* Copy a string from userland into the kernel.
*
* @param uUserAddr The userland address.
* @param uKrnlAddr The kernel buffer address.
* @param cbMax The maximum number of bytes to copy. May stop
* earlier if zero byte is encountered.
* @param pfFlags Pointer to the relevant cpuc_dtrace_flags.
*/
void dtrace_copyinstr( uintptr_t uUserAddr, uintptr_t uKrnlAddr, size_t cbMax, volatile uint16_t *pfFlags)
{
if (!cbMax)
return;
if (RT_FAILURE(rc))
{
/* Byte by byte - lazy bird! */
{
if (RT_FAILURE(rc))
{
return;
}
return;
off++;
}
}
}
/**
* Copy a string from the kernel and into user land.
*
* @param uKrnlAddr The kernel string address.
* @param uUserAddr The userland address.
* @param cbMax The maximum number of bytes to copy. Will stop
* earlier if zero byte is encountered.
* @param pfFlags Pointer to the relevant cpuc_dtrace_flags.
*/
void dtrace_copyoutstr(uintptr_t uKrnlAddr, uintptr_t uUserAddr, size_t cbMax, volatile uint16_t *pfFlags)
{
}
/**
* Get the caller @a cCallFrames call frames up the stack.
*
* @returns The caller's return address or ~(uintptr_t)0.
* @param cCallFrames The number of frames.
*/
{
/** @todo Will fix dtrace_probe this so it won't be necessary. */
return (uintptr_t)~0;
}
/**
* Get argument number @a iArg @a cCallFrames call frames up the stack.
*
* @returns The caller's return address or ~(uintptr_t)0.
* @param iArg The argument to get.
* @param cCallFrames The number of frames.
*/
{
/** @todo Will fix dtrace_probe this so that this will be easier to do on all
* platforms (MSC sucks, no frames on AMD64). */
return 0xdeadbeef;
}
/**
* Produce a traceback of the kernel stack.
*
* @param paPcStack Where to return the program counters.
* @param cMaxFrames The maximum number of PCs to return.
* @param cSkipFrames The number of artificial callstack frames to
* skip at the top.
* @param pIntr Not sure what this is...
*/
{
int iFrame = 0;
while (iFrame < cMaxFrames)
{
iFrame++;
}
}
/**
* Get the number of call frames on the stack.
*
* @returns The stack depth.
* @param cSkipFrames The number of artificial callstack frames to
* skip at the top.
*/
int dtrace_getstackdepth(int cSkipFrames)
{
return 1;
}
/**
* Produce a traceback of the userland stack.
*
* @param paPcStack Where to return the program counters.
* @param paFpStack Where to return the frame pointers.
* @param cMaxFrames The maximum number of frames to return.
*/
{
int iFrame = 0;
while (iFrame < cMaxFrames)
{
iFrame++;
}
}
/**
* Produce a traceback of the userland stack.
*
* @param paPcStack Where to return the program counters.
* @param cMaxFrames The maximum number of frames to return.
*/
{
int iFrame = 0;
while (iFrame < cMaxFrames)
{
iFrame++;
}
}
/**
* Computes the depth of the userland stack.
*/
int dtrace_getustackdepth(void)
{
return 0;
}
/**
*
* @returns Current level.
*/
int dtrace_getipl(void)
{
#ifdef RT_ARCH_AMD64
/* CR8 is normally the same as IRQL / IPL on AMD64. */
return ASMGetCR8();
#else
/* Just fake it on x86. */
return !ASMIntAreEnabled();
#endif
}
/**
* Get current monotonic timestamp.
*
* @returns Timestamp, nano seconds.
*/
hrtime_t dtrace_gethrtime(void)
{
return RTTimeNanoTS();
}
/**
* Get current walltime.
*
* @returns Timestamp, nano seconds.
*/
hrtime_t dtrace_gethrestime(void)
{
/** @todo try get better resolution here somehow ... */
}
/**
* DTrace panic routine.
*
* @param pszFormat Panic message.
* @param va Arguments to the panic message.
*/
{
for (;;)
{
*pchCrash = '\0';
}
}
/**
* DTrace panic routine.
*
* @param pszFormat Panic message.
* @param ... Arguments to the panic message.
*/
void VBoxDtPanic(const char *pszFormat, ...)
{
}
/**
* DTrace kernel message routine.
*
* @param pszFormat Kernel message.
* @param ... Arguments to the panic message.
*/
{
}
/** uprintf implementation */
void VBoxDtUPrintf(const char *pszFormat, ...)
{
}
/** vuprintf implementation */
{
}
/* CRED implementation. */
cred_t *VBoxDtGetCurrentCreds(void)
{
if (!pThread)
return NULL;
}
/* crhold implementation */
{
}
/* crfree implementation */
{
if (!cRefs)
}
#if 0
#endif