tstPin.cpp revision cca8c8c55206ccd60f1b32843a67ce737447ac60
/** @file
*
* VBox host drivers - Ring-0 support drivers - Testcases:
* Test the memory locking interface
*/
/*
* Copyright (C) 2006-2007 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 <stdlib.h>
#include <string.h>
{
int rc;
int rcRet = 0;
if (!rc)
{
/*
* Simple test.
*/
void *pv;
RTThreadSleep(1500);
#if 0
RTPrintf("Unlocking...\n");
RTThreadSleep(250);
RTThreadSleep(1500);
#endif
/*
* More extensive.
*/
static struct
{
void *pv;
void *pvAligned;
} aPinnings[500];
{
if (!rc)
{
unsigned c4GPluss = 0;
for (unsigned j = 0; j < (0xf000 >> PAGE_SHIFT); j++)
{
RTPrintf("%2d: vrt=%p phys=%RHp\n", j, (char *)aPinnings[i].pvAligned + (j << PAGE_SHIFT), aPinnings[i].aPages[j].Phys);
c4GPluss++;
}
}
else
{
rcRet++;
break;
}
}
{
{
if (rc)
{
rcRet++;
}
}
}
{
{
}
}
/*
* Allocate a bit of contiguous memory.
*/
{
{
if (rc)
}
else
RTPrintf("SUPContAlloc (2nd) failed!\n");
/* pv0 is intentionally not freed! */
}
else
RTPrintf("SUPContAlloc failed!\n");
/*
* Allocate a big chunk of virtual memory and then lock it.
*/
if (pv)
{
if (!rc)
{
/* dump */
#if 0
for (unsigned j = 0; j < (BIG_SIZE >> PAGE_SHIFT); j++)
RTPrintf("%2d: vrt=%p phys=%08x\n", j, (char *)pvAligned + (j << PAGE_SHIFT), (uintptr_t)aPages[j].pvPhys);
#endif
/* unlock */
if (rc)
{
rcRet++;
}
}
else
{
rcRet++;
}
}
}
return rcRet;
}