VirtualBox

source: vbox/trunk/src/VBox/VMM/STAMInternal.h@ 5429

Last change on this file since 5429 was 5211, checked in by vboxsync, 17 years ago

GVMM statistics.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
1/* $Id: STAMInternal.h 5211 2007-10-09 18:16:08Z 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 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
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 */
43typedef 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. */
91typedef STAMDESC *PSTAMDESC;
92/** Pointer to const sample descriptor. */
93typedef const STAMDESC *PCSTAMDESC;
94
95
96/**
97 * Converts a STAM pointer into a VM pointer.
98 * @returns Pointer to the VM structure the STAM is part of.
99 * @param pSTAM Pointer to STAM instance data.
100 */
101#define STAM2VM(pSTAM) ( (PVM)((char*)pSTAM - pSTAM->offVM) )
102
103
104/**
105 * The stam data in the VM.
106 */
107struct STAM
108{
109 /** Offset to the VM structure.
110 * See STAM2VM(). */
111 RTINT offVM;
112 /** Alignment padding. */
113 RTUINT uPadding;
114 /** Pointer to the first sample. */
115 R3PTRTYPE(PSTAMDESC) pHead;
116 /** RW Lock for the list. */
117 RTSEMRW RWSem;
118
119 /** The copy of the GVMM statistics. */
120 GVMMSTATS GVMMStats;
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
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