VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/testcase/tstContiguous.cpp@ 2471

Last change on this file since 2471 was 2014, checked in by vboxsync, 18 years ago

r=bird: some cleanup of the cPages change.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1/** @file
2 *
3 * VBox host drivers - Ring-0 support drivers - Testcases:
4 * Test contiguous memory
5 */
6
7/*
8 * Copyright (C) 2006 InnoTek Systemberatung GmbH
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License as published by the Free Software Foundation,
14 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
15 * distribution. VirtualBox OSE is distributed in the hope that it will
16 * be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * If you received this file as part of a commercial VirtualBox
19 * distribution, then only the terms of your commercial VirtualBox
20 * license agreement apply instead of the previous paragraph.
21 */
22
23
24/*******************************************************************************
25* Header Files *
26*******************************************************************************/
27#include <VBox/sup.h>
28#include <VBox/param.h>
29#include <iprt/runtime.h>
30#include <iprt/stream.h>
31#include <stdlib.h>
32#include <string.h>
33
34
35
36int main(int argc, char **argv)
37{
38 int rc;
39 int rcRet = 0;
40
41 RTR3Init(false);
42 rc = SUPInit();
43 RTPrintf("tstContiguous: SUPInit -> rc=%Vrc\n", rc);
44 rcRet += rc != 0;
45 if (!rc)
46 {
47 /*
48 * Allocate a bit of contiguous memory.
49 */
50 RTHCPHYS HCPhys;
51 void *pv = SUPContAlloc(8, &HCPhys);
52 rcRet += pv == NULL || HCPhys == 0;
53 if (pv && HCPhys)
54 {
55 memset(pv, 0xff, PAGE_SIZE * 8);
56 pv = SUPContAlloc(5, &HCPhys);
57 rcRet += pv == NULL || HCPhys == 0;
58 if (pv && HCPhys)
59 {
60 memset(pv, 0x7f, PAGE_SIZE * 5);
61 rc = SUPContFree(pv, 5);
62 rcRet += rc != 0;
63 if (rc)
64 RTPrintf("tstContiguous: SUPContFree failed! rc=%Vrc\n", rc);
65 }
66 else
67 RTPrintf("tstContiguous: SUPContAlloc (2nd) failed!\n");
68 }
69 else
70 RTPrintf("tstContiguous: SUPContAlloc failed!\n");
71
72 rc = SUPTerm();
73 RTPrintf("tstContiguous: SUPTerm -> rc=%Vrc\n", rc);
74 rcRet += rc != 0;
75 }
76
77 return rcRet;
78}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette