SUPR0IdcClient.c revision 8e496a172b2000333186e5c1be75a50f398ed830
/* $Id$ */
/** @file
* VirtualBox Support Driver - IDC Client Lib, Core.
*/
/*
* Copyright (C) 2008 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "SUPR0IdcClientInternal.h"
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/**
* Opens the IDC interface of the support driver.
*
* This will perform basic version negotiations and fail if the
* minmum requirements aren't met.
*
* @returns VBox status code.
* @param pHandle The handle structure (output).
* @param uReqVersion The requested version. Pass 0 for default.
* @param uMinVersion The minimum required version. Pass 0 for default.
* @param puVersion Where to store the version of the IDC interface. Optional.
*/
SUPR0DECL(int) SUPR0IdcOpen(PSUPDRVIDCHANDLE pHandle, uint32_t uReqVersion, uint32_t uMinVersion, uint32_t *puVersion)
{
unsigned uDefaultMinVersion;
int rc;
/*
* Validate and set failure return values.
*/
if (puVersion)
*puVersion = 0;
AssertReturn(!uMinVersion || (uMinVersion & UINT32_C(0xffff0000)) == (SUPDRV_IDC_VERSION & UINT32_C(0xffff0000)), VERR_INVALID_PARAMETER);
AssertReturn(!uReqVersion || (uReqVersion & UINT32_C(0xffff0000)) == (SUPDRV_IDC_VERSION & UINT32_C(0xffff0000)), VERR_INVALID_PARAMETER);
/*
* Handle default version input and enforce minimum requirements made
* by this library.
*
* The clients will pass defaults (0), and only in the case that some
* special API feature was just added will they set an actual version.
* So, this is the place where can easily enforce a minimum IDC version
* on bugs and similar. It corresponds a bit to what SUPInit is
* responsible for.
*/
/*
* Setup the connect request packet and call the OS specific function.
*/
if (RT_SUCCESS(rc))
{
if (puVersion)
/*
* We don't really trust anyone, make sure the returned
* session and version values actually makes sense.
*/
{
return rc;
}
}
return rc;
}
/**
* Closes a IDC connection established by SUPR0IdcOpen.
*
* @returns VBox status code.
* @param pHandle The IDC handle.
*/
{
int rc;
/*
* Catch closed handles and check that the session is valid.
*/
return VERR_INVALID_HANDLE;
/*
* Create the request and hand it to the OS specific code.
*/
if (RT_SUCCESS(rc))
{
}
return rc;
}
/**
* Get the SUPDRV session for the IDC connection.
*
* This is for use with SUPDRV and component APIs that requires a valid
* session handle.
*
* @returns The session handle on success, NULL if the IDC handle is invalid.
*
* @param pHandle The IDC handle.
*/
{
return pSession;
}
/**
* Looks up a IDC handle by session.
*
* @returns The IDC handle on success, NULL on failure.
* @param pSession The session to lookup.
*
* @internal
*/
{
return pHandle;
return NULL;
}