ReactOS  0.4.14-dev-838-g99f979d
profil.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS HAL
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: hal/halx86/generic/profil.c
5  * PURPOSE: System Profiling
6  * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7  * Eric Kohl
8  */
9 
10 /* INCLUDES ******************************************************************/
11 
12 #include <hal.h>
13 #define NDEBUG
14 #include <debug.h>
15 
16 /* GLOBALS *******************************************************************/
17 
20 
21 /* FUNCTIONS *****************************************************************/
22 
23 /*
24  * @implemented
25  */
26 VOID
27 NTAPI
29 {
30  UCHAR StatusB;
31 
32  UNREFERENCED_PARAMETER(ProfileSource);
33 
34  /* Acquire the CMOS lock */
36 
37  /* Read Status Register B */
38  StatusB = HalpReadCmos(RTC_REGISTER_B);
39 
40  /* Disable periodic interrupts */
41  StatusB = StatusB & ~RTC_REG_B_PI;
42 
43  /* Write new value into Status Register B */
44  HalpWriteCmos(RTC_REGISTER_B, StatusB);
45 
47 
48  /* Release the CMOS lock */
50 }
51 
52 /*
53  * @unimplemented
54  */
55 VOID
56 NTAPI
58 {
59  UCHAR StatusA, StatusB;
60 
61  UNREFERENCED_PARAMETER(ProfileSource);
62 
64 
65  /* Acquire the CMOS lock */
67 
68  /* Set the interval in Status Register A */
69  StatusA = HalpReadCmos(RTC_REGISTER_A);
70  StatusA = (StatusA & 0xF0) | HalpProfileRate;
71  HalpWriteCmos(RTC_REGISTER_A, StatusA);
72 
73  /* Enable periodic interrupts in Status Register B */
74  StatusB = HalpReadCmos(RTC_REGISTER_B);
75  StatusB = StatusB | RTC_REG_B_PI;
76  HalpWriteCmos(RTC_REGISTER_B, StatusB);
77 
78  /* Release the CMOS lock */
80 }
81 
82 /*
83  * @unimplemented
84  */
86 NTAPI
88 {
89  ULONG_PTR CurrentValue, NextValue;
90  UCHAR i;
91 
92  /* Normalize interval. 122100 ns is the smallest supported */
93  Interval &= ~(1 << 31);
94  if (Interval < 1221)
95  Interval = 1221;
96 
97  /* Highest rate value of 15 means 500 ms */
98  CurrentValue = 5000000;
99  for (i = 15; ; i--)
100  {
101  NextValue = (CurrentValue + 1) / 2;
102  if (Interval > CurrentValue - NextValue / 2)
103  break;
104  CurrentValue = NextValue;
105  }
106 
107  /* Interval as needed by RTC */
108  HalpProfileRate = i;
109 
110  /* Reset the */
112  {
114  }
115 
116  return CurrentValue;
117 }
BOOLEAN HalpProfilingStopped
Definition: profil.c:18
#define IN
Definition: typedefs.h:38
ULONG_PTR NTAPI HalSetProfileInterval(IN ULONG_PTR Interval)
Definition: profil.c:44
enum _KPROFILE_SOURCE KPROFILE_SOURCE
VOID FORCEINLINE HalpWriteCmos(IN UCHAR Reg, IN UCHAR Value)
Definition: cmos.c:35
#define TRUE
Definition: types.h:120
UCHAR HalpProfileRate
Definition: profil.c:19
#define RTC_REG_B_PI
Definition: halp.h:55
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
VOID NTAPI HalStartProfileInterrupt(IN KPROFILE_SOURCE ProfileSource)
Definition: profil.c:33
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
VOID NTAPI HalpReleaseCmosSpinLock(VOID)
Definition: spinlock.c:244
unsigned char BOOLEAN
UCHAR FORCEINLINE HalpReadCmos(IN UCHAR Reg)
Definition: cmos.c:24
DWORD Interval
Definition: netstat.c:33
VOID NTAPI HalpAcquireCmosSpinLock(VOID)
Definition: spinlock.c:227
#define RTC_REGISTER_B
Definition: halp.h:17
unsigned char UCHAR
Definition: xmlstorage.h:181
#define RTC_REGISTER_A
Definition: xboxrtc.c:21
VOID NTAPI HalStopProfileInterrupt(IN KPROFILE_SOURCE ProfileSource)
Definition: profil.c:22