#include <IOKit/IOLib.h>
#include "dtrace_dof.h"
extern "C" {
#include <pexpert/pexpert.h> //This is for debugging purposes ONLY
}
extern "C" {
kern_return_t _dtrace_register_anon_DOF(char *, unsigned char *, unsigned int);
}
#define super IOService
OSDefineMetaClassAndStructors(com_apple_driver_dtraceDOF, IOService)
#if defined(__BIG_ENDIAN__)
#define BYTE_CODE_CONTAINER "Anonymous DOF"
#else
#define BYTE_CODE_CONTAINER "DOF Anonymous"
#endif
bool com_apple_driver_dtraceDOF::init(OSDictionary *dict)
{
bool res = super::init(dict);
OSDictionary *AnonymousDOF = OSDynamicCast(OSDictionary, dict->getObject(BYTE_CODE_CONTAINER));
if (AnonymousDOF) {
OSCollectionIterator *keyIterator = OSCollectionIterator::withCollection(AnonymousDOF); OSString *key = NULL;
while ((key = OSDynamicCast(OSString, keyIterator->getNextObject()))) {
OSData *dof = NULL;
dof = OSDynamicCast(OSData, AnonymousDOF->getObject(key));
if (dof) {
const char *name = key->getCStringNoCopy();
int len = dof->getLength();
IOLog("com_apple_driver_dtraceDOF getLength(%s) = %d\n", name, len);
if (len > 0) {
kern_return_t ret =
_dtrace_register_anon_DOF((char *)name, (unsigned char *)(dof->getBytesNoCopy()), len);
if (KERN_SUCCESS != ret)
IOLog("com_apple_driver_dtraceDOF FAILED to register %s!\n", name);
}
}
}
keyIterator->release();
}
return res;
}
void com_apple_driver_dtraceDOF::free(void)
{
super::free();
}
IOService *com_apple_driver_dtraceDOF::probe(IOService *provider, SInt32 *score)
{
IOService *res = super::probe(provider, score);
return res;
}
bool com_apple_driver_dtraceDOF::start(IOService *provider)
{
bool res = super::start(provider);
return res;
}
void com_apple_driver_dtraceDOF::stop(IOService *provider)
{
super::stop(provider);
}