1 | /* $Id: STAMInternal.h 23 2007-01-15 14:08:28Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * STAM Internal Header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006 InnoTek Systemberatung 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 as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef __STAMInternal_h__
|
---|
23 | #define __STAMInternal_h__
|
---|
24 |
|
---|
25 | #include <VBox/cdefs.h>
|
---|
26 | #include <VBox/types.h>
|
---|
27 | #include <VBox/stam.h>
|
---|
28 | #include <iprt/semaphore.h>
|
---|
29 |
|
---|
30 | #if !defined(IN_STAM_R3) && !defined(IN_STAM_R0) && !defined(IN_STAM_GC)
|
---|
31 | # error "Not in STAM! This is an internal header!"
|
---|
32 | #endif
|
---|
33 |
|
---|
34 |
|
---|
35 | __BEGIN_DECLS
|
---|
36 |
|
---|
37 | /** @defgroup grp_stam_int Internals
|
---|
38 | * @ingroup grp_stam
|
---|
39 | * @internal
|
---|
40 | * @{
|
---|
41 | */
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Sample descriptor.
|
---|
45 | */
|
---|
46 | typedef struct STAMDESC
|
---|
47 | {
|
---|
48 | /** Pointer to the next sample. */
|
---|
49 | struct STAMDESC *pNext;
|
---|
50 | /** Sample name. */
|
---|
51 | const char *pszName;
|
---|
52 | /** Sample type. */
|
---|
53 | STAMTYPE enmType;
|
---|
54 | /** Visibility type. */
|
---|
55 | STAMVISIBILITY enmVisibility;
|
---|
56 | /** Pointer to the sample data. */
|
---|
57 | union STAMDESCSAMPLEDATA
|
---|
58 | {
|
---|
59 | /** Counter. */
|
---|
60 | PSTAMCOUNTER pCounter;
|
---|
61 | /** Profile. */
|
---|
62 | PSTAMPROFILE pProfile;
|
---|
63 | /** Advanced profile. */
|
---|
64 | PSTAMPROFILEADV pProfileAdv;
|
---|
65 | /** Ratio, unsigned 32-bit. */
|
---|
66 | PSTAMRATIOU32 pRatioU32;
|
---|
67 | /** unsigned 8-bit. */
|
---|
68 | uint8_t *pu8;
|
---|
69 | /** unsigned 16-bit. */
|
---|
70 | uint16_t *pu16;
|
---|
71 | /** unsigned 32-bit. */
|
---|
72 | uint32_t *pu32;
|
---|
73 | /** unsigned 64-bit. */
|
---|
74 | uint64_t *pu64;
|
---|
75 | /** Simple void pointer. */
|
---|
76 | void *pv;
|
---|
77 | /** */
|
---|
78 | struct STAMDESCSAMPLEDATACALLBACKS
|
---|
79 | {
|
---|
80 | /** The same pointer. */
|
---|
81 | void *pvSample;
|
---|
82 | /** Pointer to the reset callback. */
|
---|
83 | PFNSTAMR3CALLBACKRESET pfnReset;
|
---|
84 | /** Pointer to the print callback. */
|
---|
85 | PFNSTAMR3CALLBACKPRINT pfnPrint;
|
---|
86 | } Callback;
|
---|
87 | } u;
|
---|
88 | /** Unit. */
|
---|
89 | STAMUNIT enmUnit;
|
---|
90 | /** Description. */
|
---|
91 | const char *pszDesc;
|
---|
92 | } STAMDESC;
|
---|
93 | /** Pointer to sample descriptor. */
|
---|
94 | typedef STAMDESC *PSTAMDESC;
|
---|
95 | /** Pointer to const sample descriptor. */
|
---|
96 | typedef const STAMDESC *PCSTAMDESC;
|
---|
97 |
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * Converts a STAM pointer into a VM pointer.
|
---|
101 | * @returns Pointer to the VM structure the STAM is part of.
|
---|
102 | * @param pSTAM Pointer to STAM instance data.
|
---|
103 | */
|
---|
104 | #define STAM2VM(pSTAM) ( (PVM)((char*)pSTAM - pSTAM->offVM) )
|
---|
105 |
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * The stam data in the VM.
|
---|
109 | */
|
---|
110 | struct STAM
|
---|
111 | {
|
---|
112 | /** Offset to the VM structure.
|
---|
113 | * See STAM2VM(). */
|
---|
114 | RTINT offVM;
|
---|
115 | /** Alignment padding. */
|
---|
116 | RTUINT uPadding;
|
---|
117 | /** Pointer to the first sample. */
|
---|
118 | HCPTRTYPE(PSTAMDESC) pHead;
|
---|
119 | /** RW Lock for the list. */
|
---|
120 | RTSEMRW RWSem;
|
---|
121 | };
|
---|
122 |
|
---|
123 | /** Locks the sample descriptors for reading. */
|
---|
124 | #define STAM_LOCK_RD(pVM) do { int rcSem = RTSemRWRequestRead(pVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
|
---|
125 | /** Locks the sample descriptors for writing. */
|
---|
126 | #define STAM_LOCK_WR(pVM) do { int rcSem = RTSemRWRequestWrite(pVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
|
---|
127 | /** UnLocks the sample descriptors after reading. */
|
---|
128 | #define STAM_UNLOCK_RD(pVM) do { int rcSem = RTSemRWReleaseRead(pVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
|
---|
129 | /** UnLocks the sample descriptors after writing. */
|
---|
130 | #define STAM_UNLOCK_WR(pVM) do { int rcSem = RTSemRWReleaseWrite(pVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
|
---|
131 |
|
---|
132 | /** @} */
|
---|
133 |
|
---|
134 | __END_DECLS
|
---|
135 |
|
---|
136 | #endif
|
---|