1 | /* $Id: STAMInternal.h 6796 2008-02-04 18:19:58Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * STAM Internal Header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ___STAMInternal_h
|
---|
19 | #define ___STAMInternal_h
|
---|
20 |
|
---|
21 | #include <VBox/cdefs.h>
|
---|
22 | #include <VBox/types.h>
|
---|
23 | #include <VBox/stam.h>
|
---|
24 | #include <VBox/gvmm.h>
|
---|
25 | #include <iprt/semaphore.h>
|
---|
26 |
|
---|
27 | #if !defined(IN_STAM_R3) && !defined(IN_STAM_R0) && !defined(IN_STAM_GC)
|
---|
28 | # error "Not in STAM! This is an internal header!"
|
---|
29 | #endif
|
---|
30 |
|
---|
31 |
|
---|
32 | __BEGIN_DECLS
|
---|
33 |
|
---|
34 | /** @defgroup grp_stam_int Internals
|
---|
35 | * @ingroup grp_stam
|
---|
36 | * @internal
|
---|
37 | * @{
|
---|
38 | */
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * Sample descriptor.
|
---|
42 | */
|
---|
43 | typedef struct STAMDESC
|
---|
44 | {
|
---|
45 | /** Pointer to the next sample. */
|
---|
46 | struct STAMDESC *pNext;
|
---|
47 | /** Sample name. */
|
---|
48 | const char *pszName;
|
---|
49 | /** Sample type. */
|
---|
50 | STAMTYPE enmType;
|
---|
51 | /** Visibility type. */
|
---|
52 | STAMVISIBILITY enmVisibility;
|
---|
53 | /** Pointer to the sample data. */
|
---|
54 | union STAMDESCSAMPLEDATA
|
---|
55 | {
|
---|
56 | /** Counter. */
|
---|
57 | PSTAMCOUNTER pCounter;
|
---|
58 | /** Profile. */
|
---|
59 | PSTAMPROFILE pProfile;
|
---|
60 | /** Advanced profile. */
|
---|
61 | PSTAMPROFILEADV pProfileAdv;
|
---|
62 | /** Ratio, unsigned 32-bit. */
|
---|
63 | PSTAMRATIOU32 pRatioU32;
|
---|
64 | /** unsigned 8-bit. */
|
---|
65 | uint8_t *pu8;
|
---|
66 | /** unsigned 16-bit. */
|
---|
67 | uint16_t *pu16;
|
---|
68 | /** unsigned 32-bit. */
|
---|
69 | uint32_t *pu32;
|
---|
70 | /** unsigned 64-bit. */
|
---|
71 | uint64_t *pu64;
|
---|
72 | /** Simple void pointer. */
|
---|
73 | void *pv;
|
---|
74 | /** */
|
---|
75 | struct STAMDESCSAMPLEDATACALLBACKS
|
---|
76 | {
|
---|
77 | /** The same pointer. */
|
---|
78 | void *pvSample;
|
---|
79 | /** Pointer to the reset callback. */
|
---|
80 | PFNSTAMR3CALLBACKRESET pfnReset;
|
---|
81 | /** Pointer to the print callback. */
|
---|
82 | PFNSTAMR3CALLBACKPRINT pfnPrint;
|
---|
83 | } Callback;
|
---|
84 | } u;
|
---|
85 | /** Unit. */
|
---|
86 | STAMUNIT enmUnit;
|
---|
87 | /** Description. */
|
---|
88 | const char *pszDesc;
|
---|
89 | } STAMDESC;
|
---|
90 | /** Pointer to sample descriptor. */
|
---|
91 | typedef STAMDESC *PSTAMDESC;
|
---|
92 | /** Pointer to const sample descriptor. */
|
---|
93 | typedef const STAMDESC *PCSTAMDESC;
|
---|
94 |
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * STAM data kept in the UVM.
|
---|
98 | */
|
---|
99 | typedef struct STAMUSERPERVM
|
---|
100 | {
|
---|
101 | /** Pointer to the first sample. */
|
---|
102 | R3PTRTYPE(PSTAMDESC) pHead;
|
---|
103 | /** RW Lock for the list. */
|
---|
104 | RTSEMRW RWSem;
|
---|
105 |
|
---|
106 | /** The copy of the GVMM statistics. */
|
---|
107 | GVMMSTATS GVMMStats;
|
---|
108 | } STAMUSERPERVM;
|
---|
109 | /** Pointer to the STAM data kept in the UVM. */
|
---|
110 | typedef STAMUSERPERVM *PSTAMUSERPERVM;
|
---|
111 |
|
---|
112 |
|
---|
113 | /** Locks the sample descriptors for reading. */
|
---|
114 | #define STAM_LOCK_RD(pUVM) do { int rcSem = RTSemRWRequestRead(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
|
---|
115 | /** Locks the sample descriptors for writing. */
|
---|
116 | #define STAM_LOCK_WR(pUVM) do { int rcSem = RTSemRWRequestWrite(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
|
---|
117 | /** UnLocks the sample descriptors after reading. */
|
---|
118 | #define STAM_UNLOCK_RD(pUVM) do { int rcSem = RTSemRWReleaseRead(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
|
---|
119 | /** UnLocks the sample descriptors after writing. */
|
---|
120 | #define STAM_UNLOCK_WR(pUVM) do { int rcSem = RTSemRWReleaseWrite(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
|
---|
121 |
|
---|
122 | /** @} */
|
---|
123 |
|
---|
124 | __END_DECLS
|
---|
125 |
|
---|
126 | #endif
|
---|