tstPin.cpp revision a466f24ecf94b453750f9791ad1140556114711b
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * VBox host drivers - Ring-0 support drivers - Testcases:
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * Test the memory locking interface
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * Copyright (C) 2006 InnoTek Systemberatung GmbH
452fd0f33b11dc60aad994e3001c74415179d401vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
452fd0f33b11dc60aad994e3001c74415179d401vboxsync * available from http://www.virtualbox.org. This file is free software;
452fd0f33b11dc60aad994e3001c74415179d401vboxsync * you can redistribute it and/or modify it under the terms of the GNU
452fd0f33b11dc60aad994e3001c74415179d401vboxsync * General Public License as published by the Free Software Foundation,
452fd0f33b11dc60aad994e3001c74415179d401vboxsync * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
452fd0f33b11dc60aad994e3001c74415179d401vboxsync * distribution. VirtualBox OSE is distributed in the hope that it will
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * be useful, but WITHOUT ANY WARRANTY of any kind.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * If you received this file as part of a commercial VirtualBox
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * distribution, then only the terms of your commercial VirtualBox
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * license agreement apply instead of the previous paragraph.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync/*******************************************************************************
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* Header Files *
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync*******************************************************************************/
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync static struct
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync for (unsigned i = 0; i < sizeof(aPinnings) / sizeof(aPinnings[0]); i++)
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync SUPPageAlloc(0x10000 >> PAGE_SHIFT, &aPinnings[i].pv);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync aPinnings[i].pvAligned = ALIGNP(aPinnings[i].pv, PAGE_SIZE);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync rc = SUPPageLock(aPinnings[i].pvAligned, 0xf000 >> PAGE_SHIFT, &aPinnings[i].aPages[0]);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync RTPrintf("i=%d: pvAligned=%p pv=%p:\n", i, aPinnings[i].pvAligned, aPinnings[i].pv);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync unsigned c4GPluss = 0;
214ccb21af5d26cadb50ca7a9ecf9a85dfb2cf57vboxsync for (unsigned j = 0; j < (0xf000 >> PAGE_SHIFT); j++)
6378fc9dbcca8bb2bdd10916afbc30702193f178vboxsync RTPrintf("%2d: vrt=%p phys=%VHp\n", j, (char *)aPinnings[i].pvAligned + (j << PAGE_SHIFT), aPinnings[i].aPages[j].Phys);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync SUPPageFree(aPinnings[i].pv, 0x10000 >> PAGE_SHIFT);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync for (unsigned i = 0; i < sizeof(aPinnings) / sizeof(aPinnings[0]); i += 2)
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync RTPrintf("SUPPageUnlock(%p) -> rc=%d\n", aPinnings[i].pvAligned, rc);
6728a36898fd2be125a28e84d2115d19aa4923edvboxsync for (unsigned i = 0; i < sizeof(aPinnings) / sizeof(aPinnings[0]); i += 2)
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync SUPPageFree(aPinnings[i].pv, 0x10000 >> PAGE_SHIFT);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * Allocate a bit of contiguous memory.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync pv = SUPContAlloc(RT_ALIGN_Z(15003, PAGE_SIZE) >> PAGE_SHIFT, &HCPhys);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync RTPrintf("SUPContAlloc(15003) -> HCPhys=%llx pv=%p\n", HCPhys, pv);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync pv = SUPContAlloc(RT_ALIGN_Z(12999, PAGE_SIZE) >> PAGE_SHIFT, &HCPhys);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync RTPrintf("SUPContAlloc(12999) -> HCPhys=%llx pv=%p\n", HCPhys, pv);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync rc = SUPContFree(pv, RT_ALIGN_Z(12999, PAGE_SIZE) >> PAGE_SHIFT);
0b80b22020c2d2c55a20d2a73023f17214e5d6bavboxsync /* pv0 is intentionally not freed! */
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * Allocate a big chunk of virtual memory and then lock it.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync rc = SUPPageLock(pvAligned, BIG_SIZE >> PAGE_SHIFT, &aPages[0]);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync RTPrintf("SUPPageLock(%p,%d,) succeeded!\n", pvAligned, BIG_SIZE);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync for (unsigned j = 0; j < (BIG_SIZE >> PAGE_SHIFT); j++)
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync RTPrintf("%2d: vrt=%p phys=%08x\n", j, (char *)pvAligned + (j << PAGE_SHIFT), (uintptr_t)aPages[j].pvPhys);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync /* unlock */
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync RTPrintf("SUPPageUnlock(%p) -> rc=%d\n", pvAligned, rc);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync RTPrintf("SUPPageLock(%p) -> rc=%d\n", pvAligned, rc);