tstLow.cpp revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/** @file
*
* VBox host drivers - Ring-0 support drivers - Testcases:
* Test allocating physical memory below 4G
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* 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 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.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <string.h>
{
int rc;
int rcRet = 0;
RTR3Init(false);
RTPrintf("tstLow: TESTING...\n");
if (VBOX_SUCCESS(rc))
{
/*
* Allocate a bit of contiguous memory.
*/
void *pvPages0 = (void *)0x77777777;
if (VBOX_SUCCESS(rc))
{
/* check that the pages are below 4GB and valid. */
{
{
rcRet++;
RTPrintf("tstLow: error: aPages0[%d].uReserved=%#x expected 0!\n", iPage, aPages0[iPage].uReserved);
}
{
rcRet++;
}
}
if (!rcRet)
{
for (uint8_t *pu8 = (uint8_t *)pvPages0 + iPage * PAGE_SIZE, *pu8End = pu8 + PAGE_SIZE; pu8 < pu8End; pu8++)
{
RTPrintf("tstLow: error: invalid page content %02x != %02x. iPage=%p off=%#x\n",
rcRet++;
}
}
}
else
{
rcRet++;
}
/*
* Allocate odd amounts in from 1 to 127.
*/
{
void *pvPages1 = (void *)0x77777777;
if (VBOX_SUCCESS(rc))
{
/* check that the pages are below 4GB and valid. */
{
RTPrintf("%-4d::%-4d: Phys=%VHp Reserved=%p\n", cPages, iPage, aPages1[iPage].Phys, aPages1[iPage].uReserved);
{
rcRet++;
RTPrintf("tstLow: error: aPages1[%d].uReserved=%#x expected 0!\n", iPage, aPages1[iPage].uReserved);
}
{
rcRet++;
}
}
if (!rcRet)
{
for (uint8_t *pu8 = (uint8_t *)pvPages1 + iPage * PAGE_SIZE, *pu8End = pu8 + PAGE_SIZE; pu8 < pu8End; pu8++)
{
RTPrintf("tstLow: error: invalid page content %02x != %02x. iPage=%p off=%#x\n",
rcRet++;
}
}
}
else
{
rcRet++;
}
}
}
else
{
rcRet++;
}
return rcRet;
}