SUPDrv-os2.cpp revision d32ac60a720a1c5c75d73073d5b9affef33bee7a
/* $Id$ */
/** @file
* VBoxDrv - The VirtualBox Support Driver - OS/2 specifics.
*/
/*
* Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_SUP_DRV
#define __STDC_CONSTANT_MACROS
#define __STDC_LIMIT_MACROS
#include "SUPDrvInternal.h"
#include <iprt/initterm.h>
#include <iprt/spinlock.h>
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/**
* Device extention & session data association structure.
*/
static SUPDRVDEVEXT g_DevExt;
/** Spinlock protecting g_apSessionHashTab. */
/** Hash table */
/** Calculates the index into g_apSessionHashTab.*/
/* Defined in SUPDrvA-os2.asm */
extern uint16_t g_offLogHead;
extern uint16_t volatile g_offLogTail;
extern uint16_t const g_cchLogMax;
extern char g_szLog[];
/* (init only:) */
extern char g_szInitText[];
extern uint16_t g_cchInitText;
extern uint16_t g_cchInitTextMax;
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
/**
* 32-bit Ring-0 initialization.
*
* @returns 0 on success, non-zero on failure.
* @param pszArgs Pointer to the device arguments.
*/
{
/*
* Initialize the runtime.
*/
if (RT_SUCCESS(rc))
{
/*
* Initialize the device extension.
*/
if (RT_SUCCESS(rc))
{
/*
* Initialize the session hash table.
*/
if (RT_SUCCESS(rc))
{
/*
* Process the commandline. Later.
*/
bool fVerbose = true;
/*
* Success
*/
if (fVerbose)
{
strcpy(&g_szInitText[0],
"\r\n"
"Copyright (C) 2007 Knut St. Osmundsen\r\n"
"Copyright (C) 2007 Oracle Corporation\r\n");
}
return VINF_SUCCESS;
}
g_cchInitText = RTStrPrintf(&g_szInitText[0], g_cchInitTextMax, "VBoxDrv.sys: RTSpinlockCreate failed, rc=%Rrc\n", rc);
}
else
g_cchInitText = RTStrPrintf(&g_szInitText[0], g_cchInitTextMax, "VBoxDrv.sys: supdrvInitDevExt failed, rc=%Rrc\n", rc);
RTR0Term();
}
else
g_cchInitText = RTStrPrintf(&g_szInitText[0], g_cchInitTextMax, "VBoxDrv.sys: RTR0Init failed, rc=%Rrc\n", rc);
return rc;
}
{
int rc;
/*
* Create a new session.
*/
if (RT_SUCCESS(rc))
{
/*
* Insert it into the hash table.
*/
}
Log(("VBoxDrvOpen: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf()));
return rc;
}
{
/*
* Remove from the hash table.
*/
if (pSession)
{
{
}
else
{
while (pSession)
{
{
break;
}
/* next */
}
}
}
if (!pSession)
{
OSDBGPRINT(("VBoxDrvIoctl: WHUT?!? pSession == NULL! This must be a mistake... pid=%d sfn=%d\n", (int)Process, sfn));
return VERR_INVALID_PARAMETER;
}
/*
* Close the session.
*/
return 0;
}
{
/*
* Find the session.
*/
{
while ( pSession
}
if (RT_UNLIKELY(!pSession))
{
OSDBGPRINT(("VBoxDrvIoctl: WHUT?!? pSession == NULL! This must be a mistake... pid=%d\n", (int)Process));
return VERR_INVALID_PARAMETER;
}
/*
* Dispatch the fast IOCtl.
*/
return 0;
}
DECLASM(int) VBoxDrvIOCtl(uint16_t sfn, uint8_t iCat, uint8_t iFunction, void *pvParm, void *pvData, uint16_t *pcbParm, uint16_t *pcbData)
{
/*
* Find the session.
*/
{
while ( pSession
}
if (!pSession)
{
OSDBGPRINT(("VBoxDrvIoctl: WHUT?!? pSession == NULL! This must be a mistake... pid=%d\n", (int)Process));
return VERR_INVALID_PARAMETER;
}
/*
* Verify the category and dispatch the IOCtl.
*/
{
Log(("VBoxDrvIOCtl: pSession=%p iFunction=%#x pvParm=%p pvData=%p *pcbParm=%d *pcbData=%d\n", pSession, iFunction, pvParm, pvData, *pcbParm, *pcbData));
/*
* Lock the header.
*/
AssertMsgReturn(!rc, ("KernVMLock(VMDHL_WRITE, %p, %#x, &p, NULL, NULL) -> %d\n", pHdr, *pcbParm, &Lock, rc), VERR_LOCK_FAILED);
/*
* Validate the header.
*/
{
{
/*
* Lock the rest of the buffer if necessary.
*/
{
AssertMsgReturn(!rc, ("KernVMLock(VMDHL_WRITE, %p, %#x, &p, NULL, NULL) -> %d\n", pHdr, cbReq, &Lock, rc), VERR_LOCK_FAILED);
}
/*
* Process the IOCtl.
*/
}
else
{
}
}
else
{
}
/*
* Unlock and return.
*/
}
else
return rc;
}
{
}
void VBOXCALL supdrvOSSessionHashTabInserted(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, void *pvUser)
{
}
void VBOXCALL supdrvOSSessionHashTabRemoved(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, void *pvUser)
{
}
{
}
bool VBOXCALL supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc)
{
return false;
}
{
return false;
}
bool VBOXCALL supdrvOSAreTscDeltasInSync(void)
{
return false;
}
int VBOXCALL supdrvOSLdrOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename)
{
return VERR_NOT_SUPPORTED;
}
{
}
int VBOXCALL supdrvOSLdrValidatePointer(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, void *pv, const uint8_t *pbImageBits)
{
return VERR_NOT_SUPPORTED;
}
int VBOXCALL supdrvOSLdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const uint8_t *pbImageBits, PSUPLDRLOAD pReq)
{
return VERR_NOT_SUPPORTED;
}
{
}
#ifdef SUPDRV_WITH_MSR_PROBER
{
return VERR_NOT_SUPPORTED;
}
{
return VERR_NOT_SUPPORTED;
}
{
return VERR_NOT_SUPPORTED;
}
#endif /* SUPDRV_WITH_MSR_PROBER */
/**
* Callback for writing to the log buffer.
*
* @returns number of bytes written.
* @param pvArg Unused.
* @param pachChars Pointer to an array of utf-8 characters.
* @param cbChars Number of bytes in the character array pointed to by pachChars.
*/
{
size_t cchWritten = 0;
while (cbChars-- > 0)
{
if (offLogHeadNext == g_offLogTail)
break; /* no */
cchWritten++;
}
return cchWritten;
}
{
#if 0 //def DEBUG_bird
#endif
return cch;
}
/**
* Returns configuration flags of the host kernel.
*/
{
return 0;
}