1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox host drivers - Ring-0 support drivers - Testcases:
|
---|
4 | * Test the Global Info Page interface
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2007 innotek 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 |
|
---|
19 | /*******************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *******************************************************************************/
|
---|
22 | #include <VBox/sup.h>
|
---|
23 | #include <VBox/err.h>
|
---|
24 | #include <VBox/param.h>
|
---|
25 | #include <iprt/asm.h>
|
---|
26 | #include <iprt/assert.h>
|
---|
27 | #include <iprt/alloc.h>
|
---|
28 | #include <iprt/thread.h>
|
---|
29 | #include <iprt/stream.h>
|
---|
30 | #include <iprt/runtime.h>
|
---|
31 |
|
---|
32 |
|
---|
33 | int main(void)
|
---|
34 | {
|
---|
35 | RTR3Init();
|
---|
36 |
|
---|
37 | /*
|
---|
38 | * Init
|
---|
39 | */
|
---|
40 | PSUPDRVSESSION pSession = NIL_RTR0PTR;
|
---|
41 | int rc = SUPInit(&pSession);
|
---|
42 | if (VBOX_SUCCESS(rc))
|
---|
43 | {
|
---|
44 | if (g_pSUPGlobalInfoPage)
|
---|
45 | {
|
---|
46 | RTPrintf("tstGIP-2: u32UpdateHz=%RU32 u32UpdateIntervalNS=%RU32 u64NanoTSLastUpdateHz=%RX64 u32Mode=%d (%s) u32Version=%#x\n"
|
---|
47 | "tstGIP-2: it: u64NanoTS u64TSC UpIntTSC H TransId CpuHz TSC Interval History...\n",
|
---|
48 | g_pSUPGlobalInfoPage->u32UpdateHz,
|
---|
49 | g_pSUPGlobalInfoPage->u32UpdateIntervalNS,
|
---|
50 | g_pSUPGlobalInfoPage->u64NanoTSLastUpdateHz,
|
---|
51 | g_pSUPGlobalInfoPage->u32Mode,
|
---|
52 | g_pSUPGlobalInfoPage->u32Mode == SUPGIPMODE_SYNC_TSC ? "sync"
|
---|
53 | : g_pSUPGlobalInfoPage->u32Mode == SUPGIPMODE_ASYNC_TSC ? "async"
|
---|
54 | : "???",
|
---|
55 | g_pSUPGlobalInfoPage->u32Version);
|
---|
56 | for (int i = 0; i < 80; i++)
|
---|
57 | {
|
---|
58 | for (unsigned iCpu = 0; iCpu < RT_ELEMENTS(g_pSUPGlobalInfoPage->aCPUs); iCpu++)
|
---|
59 | if ( g_pSUPGlobalInfoPage->aCPUs[iCpu].u64CpuHz > 0
|
---|
60 | && g_pSUPGlobalInfoPage->aCPUs[iCpu].u64CpuHz != _4G + 1)
|
---|
61 | RTPrintf("tstGIP-2: %2d/%d: %016llx %016llx %08x %d %08x %15llu %08x %08x %08x %08x %08x %08x %08x %08x (%d)\n",
|
---|
62 | i, iCpu,
|
---|
63 | g_pSUPGlobalInfoPage->aCPUs[iCpu].u64NanoTS,
|
---|
64 | g_pSUPGlobalInfoPage->aCPUs[iCpu].u64TSC,
|
---|
65 | g_pSUPGlobalInfoPage->aCPUs[iCpu].u32UpdateIntervalTSC,
|
---|
66 | g_pSUPGlobalInfoPage->aCPUs[iCpu].iTSCHistoryHead,
|
---|
67 | g_pSUPGlobalInfoPage->aCPUs[iCpu].u32TransactionId,
|
---|
68 | g_pSUPGlobalInfoPage->aCPUs[iCpu].u64CpuHz,
|
---|
69 | g_pSUPGlobalInfoPage->aCPUs[iCpu].au32TSCHistory[0],
|
---|
70 | g_pSUPGlobalInfoPage->aCPUs[iCpu].au32TSCHistory[1],
|
---|
71 | g_pSUPGlobalInfoPage->aCPUs[iCpu].au32TSCHistory[2],
|
---|
72 | g_pSUPGlobalInfoPage->aCPUs[iCpu].au32TSCHistory[3],
|
---|
73 | g_pSUPGlobalInfoPage->aCPUs[iCpu].au32TSCHistory[4],
|
---|
74 | g_pSUPGlobalInfoPage->aCPUs[iCpu].au32TSCHistory[5],
|
---|
75 | g_pSUPGlobalInfoPage->aCPUs[iCpu].au32TSCHistory[6],
|
---|
76 | g_pSUPGlobalInfoPage->aCPUs[iCpu].au32TSCHistory[7],
|
---|
77 | g_pSUPGlobalInfoPage->aCPUs[iCpu].cErrors);
|
---|
78 | RTThreadSleep(9);
|
---|
79 | }
|
---|
80 | }
|
---|
81 | else
|
---|
82 | {
|
---|
83 | RTPrintf("tstGIP-2: g_pSUPGlobalInfoPage is NULL\n");
|
---|
84 | rc = -1;
|
---|
85 | }
|
---|
86 |
|
---|
87 | SUPTerm();
|
---|
88 | }
|
---|
89 | else
|
---|
90 | RTPrintf("tstGIP-2: SUPInit failed: %Vrc\n", rc);
|
---|
91 | return !!rc;
|
---|
92 | }
|
---|