/* $Id$ */
/** @file
* VirtualBox Guest Additions - Virtio Driver for Solaris.
*/
/*
* Copyright (C) 2010-2011 Oracle Corporation
*
* 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 (GPL) 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.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#ifdef DEBUG_ramshankar
#endif
#include "Virtio-solaris.h"
/**
* 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;
}
{
{
{
/*
* 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.
*/
{
}