Virtio-solaris.c revision 38b0f04a36431d57eed1de01653dd0a015eae4c3
/* $Id$ */
/** @file
* VirtualBox Guest Additions: Virtio Driver for Solaris.
*/
/*
* Copyright (C) 2010 Oracle Corporation
*
* Oracle Corporation confidential
* All rights reserved
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "Virtio-solaris.h"
#if defined(DEBUG_ramshankar)
# define LogFlowFunc LogRel
#endif
/**
* Virtio Attach routine that should be called from all Virtio drivers' attach
* routines.
*
* @param pDip The module structure instance.
* @param pDeviceOps Pointer to device ops structure.
* @param pHyperOps Pointer to hypervisor ops structure.
*
* @return Solaris DDI error code. DDI_SUCCESS or DDI_FAILURE.
*/
int VirtioAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd, PVIRTIODEVICEOPS pDeviceOps, PVIRTIOHYPEROPS pHyperOps)
{
LogFlowFunc((VIRTIOLOGNAME ":VirtioAttach: pDip=%p enmCmd=%d pDeviceOps=%p pHyperOps=%p\n", pDip, enmCmd, pDeviceOps, pHyperOps));
if (enmCmd != DDI_ATTACH)
{
return DDI_FAILURE;
}
int rc = DDI_FAILURE;
{
{
{
/*
* Attach hypervisor interface and obtain features supported by host.
*/
if (rc == DDI_SUCCESS)
{
/*
* Attach the device type interface.
*/
if (rc == DDI_SUCCESS)
{
return DDI_SUCCESS;
}
else
}
else
}
else
}
else
}
else
LogRel((VIRTIOLOGNAME ":VirtioAttach: failed to alloc %u bytes for device structure.\n", sizeof(VIRTIODEVICE)));
return DDI_FAILURE;
}
/**
* Virtio Detach routine that should be called from all Virtio drivers' detach
* routines.
*
* @param pDip The module structure instance.
*
* @return Solaris DDI error code. DDI_SUCCESS or DDI_FAILURE.
*/
{
if (RT_UNLIKELY(!pDevice))
return DDI_FAILURE;
if (enmCmd != DDI_DETACH)
{
return DDI_FAILURE;
}
if (rc == DDI_SUCCESS)
{
return DDI_SUCCESS;
}
else
return DDI_FAILURE;
}
/**
* Allocates a Virtio Queue object and assigns it an index.
*
* @param pDevice Pointer to the Virtio device instance.
*
* @return A pointer to a Virtio Queue instance.
*/
{
if (RT_UNLIKELY(!pQueue))
{
LogRel((VIRTIOLOGNAME ":VirtioGetQueue: failed to alloc memory for %u bytes.\n", sizeof(VIRTIOQUEUE)));
return NULL;
}
{
return NULL;
}
/* @todo enable interrupt. */
return pQueue;
}
/**
* Puts a queue and destroys the instance.
*
* @param pDevice Pointer to the Virtio device instance.
* @param pQueue Pointer to the Virtio queue.
*/
{
}