VBoxGuestIDC-unix.c.h revision 390677f7318c5f08f4d42c65ded68a93b45f7234
956a0e3c076406b83d635174a201fd8761ee5133vboxsync/* $Rev$ */
956a0e3c076406b83d635174a201fd8761ee5133vboxsync/** @file
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * VBoxGuest - Inter Driver Communcation, unix implementation.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync *
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * This file is included by the platform specific source file.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync */
956a0e3c076406b83d635174a201fd8761ee5133vboxsync
956a0e3c076406b83d635174a201fd8761ee5133vboxsync/*
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * Copyright (C) 2006-2009 Sun Microsystems, Inc.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync *
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * available from http://www.virtualbox.org. This file is free software;
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * you can redistribute it and/or modify it under the terms of the GNU
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * General Public License (GPL) as published by the Free Software
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync *
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * additional information or have any questions.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * Some lines of code to disable the local APIC on x86_64 machines taken
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * from a Mandriva patch by Gwenole Beauchesne <gbeauchesne@mandriva.com>.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync */
956a0e3c076406b83d635174a201fd8761ee5133vboxsync
956a0e3c076406b83d635174a201fd8761ee5133vboxsync
956a0e3c076406b83d635174a201fd8761ee5133vboxsync/**
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * Open a new IDC connection.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync *
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * @returns Opaque pointer to session object.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * @param pu32Version Where to store VMMDev version.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync */
956a0e3c076406b83d635174a201fd8761ee5133vboxsyncDECLVBGL(void *) VBoxGuestIDCOpen(uint32_t *pu32Version)
956a0e3c076406b83d635174a201fd8761ee5133vboxsync{
956a0e3c076406b83d635174a201fd8761ee5133vboxsync PVBOXGUESTSESSION pSession;
956a0e3c076406b83d635174a201fd8761ee5133vboxsync int rc;
956a0e3c076406b83d635174a201fd8761ee5133vboxsync LogFlow(("VBoxGuestIDCOpen: Version=%#x\n", pu32Version ? *pu32Version : 0));
956a0e3c076406b83d635174a201fd8761ee5133vboxsync
956a0e3c076406b83d635174a201fd8761ee5133vboxsync AssertPtrReturn(pu32Version, NULL);
956a0e3c076406b83d635174a201fd8761ee5133vboxsync rc = VBoxGuestCreateKernelSession(&g_DevExt, &pSession);
956a0e3c076406b83d635174a201fd8761ee5133vboxsync if (RT_SUCCESS(rc))
956a0e3c076406b83d635174a201fd8761ee5133vboxsync {
956a0e3c076406b83d635174a201fd8761ee5133vboxsync *pu32Version = VMMDEV_VERSION;
956a0e3c076406b83d635174a201fd8761ee5133vboxsync return pSession;
956a0e3c076406b83d635174a201fd8761ee5133vboxsync }
956a0e3c076406b83d635174a201fd8761ee5133vboxsync LogRel(("VBoxGuestIDCOpen: VBoxGuestCreateKernelSession failed. rc=%d\n", rc));
956a0e3c076406b83d635174a201fd8761ee5133vboxsync return NULL;
956a0e3c076406b83d635174a201fd8761ee5133vboxsync}
956a0e3c076406b83d635174a201fd8761ee5133vboxsync
956a0e3c076406b83d635174a201fd8761ee5133vboxsync
956a0e3c076406b83d635174a201fd8761ee5133vboxsync/**
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * Close an IDC connection.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync *
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * @returns VBox error code.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * @param pvState Opaque pointer to the session object.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync */
956a0e3c076406b83d635174a201fd8761ee5133vboxsyncDECLVBGL(int) VBoxGuestIDCClose(void *pvSession)
956a0e3c076406b83d635174a201fd8761ee5133vboxsync{
956a0e3c076406b83d635174a201fd8761ee5133vboxsync PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pvSession;
956a0e3c076406b83d635174a201fd8761ee5133vboxsync LogFlow(("VBoxGuestIDCClose:\n"));
956a0e3c076406b83d635174a201fd8761ee5133vboxsync
956a0e3c076406b83d635174a201fd8761ee5133vboxsync AssertPtrReturn(pSession, VERR_INVALID_POINTER);
956a0e3c076406b83d635174a201fd8761ee5133vboxsync VBoxGuestCloseSession(&g_DevExt, pSession);
956a0e3c076406b83d635174a201fd8761ee5133vboxsync return VINF_SUCCESS;
956a0e3c076406b83d635174a201fd8761ee5133vboxsync}
956a0e3c076406b83d635174a201fd8761ee5133vboxsync
956a0e3c076406b83d635174a201fd8761ee5133vboxsync
956a0e3c076406b83d635174a201fd8761ee5133vboxsync/**
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * Perform an IDC call.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync *
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * @returns VBox error code.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * @param pvSession Opaque pointer to the session.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * @param iCmd Requested function.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * @param pvData IO data buffer.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * @param cbData Size of the data buffer.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync * @param pcbDataReturned Where to store the amount of returned data.
956a0e3c076406b83d635174a201fd8761ee5133vboxsync */
956a0e3c076406b83d635174a201fd8761ee5133vboxsyncDECLVBGL(int) VBoxGuestIDCCall(void *pvSession, unsigned iCmd, void *pvData, size_t cbData, size_t *pcbDataReturned)
956a0e3c076406b83d635174a201fd8761ee5133vboxsync{
956a0e3c076406b83d635174a201fd8761ee5133vboxsync PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pvSession;
956a0e3c076406b83d635174a201fd8761ee5133vboxsync LogFlow(("VBoxGuestIDCCall: %pvSesssion=%p Cmd=%u pvData=%p cbData=%d\n", pvSession, iCmd, pvData, cbData));
956a0e3c076406b83d635174a201fd8761ee5133vboxsync
956a0e3c076406b83d635174a201fd8761ee5133vboxsync AssertPtrReturn(pSession, VERR_INVALID_POINTER);
956a0e3c076406b83d635174a201fd8761ee5133vboxsync AssertMsgReturn(pSession->pDevExt == &g_DevExt,
956a0e3c076406b83d635174a201fd8761ee5133vboxsync ("SC: %p != %p\n", pSession->pDevExt, &g_DevExt), VERR_INVALID_HANDLE);
956a0e3c076406b83d635174a201fd8761ee5133vboxsync
956a0e3c076406b83d635174a201fd8761ee5133vboxsync return VBoxGuestCommonIOCtl(iCmd, &g_DevExt, pSession, pvData, cbData, pcbDataReturned);
956a0e3c076406b83d635174a201fd8761ee5133vboxsync}
956a0e3c076406b83d635174a201fd8761ee5133vboxsync
956a0e3c076406b83d635174a201fd8761ee5133vboxsync
956a0e3c076406b83d635174a201fd8761ee5133vboxsync