SUPR0IdcClientComponent.c revision 8e496a172b2000333186e5c1be75a50f398ed830
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync/* $Id$ */
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync/** @file
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * VirtualBox Support Driver - IDC Client Lib, Component APIs.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync */
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync/*
a2828f06a7a97fd85445ed5b2c5cb6a12a185d1dvboxsync * Copyright (C) 2008 Sun Microsystems, Inc.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync *
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * available from http://www.virtualbox.org. This file is free software;
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * you can redistribute it and/or modify it under the terms of the GNU
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * General Public License (GPL) as published by the Free Software
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync *
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * The contents of this file may alternatively be used under the terms
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * of the Common Development and Distribution License Version 1.0
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * VirtualBox OSE distribution, in which case the provisions of the
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * CDDL are applicable instead of those of the GPL.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync *
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * You may elect to license modified versions of this file under the
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * terms and conditions of either the GPL or the CDDL or both.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync *
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * additional information or have any questions.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync */
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync/*******************************************************************************
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync* Header Files *
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync*******************************************************************************/
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync#include "SUPR0IdcClientInternal.h"
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync#include <VBox/err.h>
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync/**
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * Registers a component factory with SUPDRV.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync *
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * @returns VBox status code.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * @param pHandle The IDC handle.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * @param pFactory The factory to register.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync */
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsyncSUPR0DECL(int) SUPR0IdcComponentRegisterFactory(PSUPDRVIDCHANDLE pHandle, PCSUPDRVFACTORY pFactory)
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync{
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync SUPDRVIDCREQCOMPREGFACTORY Req;
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync /*
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * Validate the handle before we access it.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync */
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync AssertPtrReturn(pHandle, VERR_INVALID_HANDLE);
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync AssertPtrReturn(pHandle->s.pSession, VERR_INVALID_HANDLE);
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync /*
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * Construct and fire off the request.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync */
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync Req.Hdr.cb = sizeof(Req);
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync Req.Hdr.rc = VERR_WRONG_ORDER;
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync Req.Hdr.pSession = pHandle->s.pSession;
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync Req.u.In.pFactory = pFactory;
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync return supR0IdcNativeCall(pHandle, SUPDRV_IDC_REQ_COMPONENT_REGISTER_FACTORY, &Req.Hdr);
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync}
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync/**
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * Deregisters a component factory with SUPDRV.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync *
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * @returns VBox status code.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * @param pHandle The IDC handle.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * @param pFactory The factory to register.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync */
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsyncSUPR0DECL(int) SUPR0IdcComponentDeregisterFactory(PSUPDRVIDCHANDLE pHandle, PCSUPDRVFACTORY pFactory)
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync{
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync SUPDRVIDCREQCOMPDEREGFACTORY Req;
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync /*
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * Validate the handle before we access it.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync */
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync AssertPtrReturn(pHandle, VERR_INVALID_HANDLE);
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync AssertPtrReturn(pHandle->s.pSession, VERR_INVALID_HANDLE);
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync /*
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync * Construct and fire off the request.
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync */
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync Req.Hdr.cb = sizeof(Req);
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync Req.Hdr.rc = VERR_WRONG_ORDER;
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync Req.Hdr.pSession = pHandle->s.pSession;
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync Req.u.In.pFactory = pFactory;
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync return supR0IdcNativeCall(pHandle, SUPDRV_IDC_REQ_COMPONENT_DEREGISTER_FACTORY, &Req.Hdr);
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync}
ba8183e1a0c699f5b5131a03e157fc7e39ed3009vboxsync
9d4498106267e3834edc3a37bca5ca660153525cvboxsync