xref: /reactos/hal/halx86/pc98/profil.c (revision 98e8827a)
1 /*
2  * PROJECT:     NEC PC-98 series HAL
3  * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE:     System Profiling
5  * COPYRIGHT:   Copyright 2020 Dmitry Borisov (di.sean@protonmail.com)
6  */
7 
8 /* INCLUDES ******************************************************************/
9 
10 #include <hal.h>
11 
12 #define NDEBUG
13 #include <debug.h>
14 
15 /* GLOBALS *******************************************************************/
16 
17 BOOLEAN HalpProfilingStopped = TRUE;
18 UCHAR HalpProfileRate = 3;
19 
20 /* FUNCTIONS *****************************************************************/
21 
22 VOID
23 NTAPI
24 HalStopProfileInterrupt(
25     _In_ KPROFILE_SOURCE ProfileSource)
26 {
27     UNREFERENCED_PARAMETER(ProfileSource);
28 
29     HalpAcquireCmosSpinLock();
30 
31     /* Clear the interrupt flag */
32     (VOID)__inbyte(RTC_IO_i_INTERRUPT_RESET);
33 
34     HalpProfilingStopped = TRUE;
35 
36     HalpReleaseCmosSpinLock();
37 }
38 
39 VOID
40 NTAPI
41 HalStartProfileInterrupt(
42     _In_ KPROFILE_SOURCE ProfileSource)
43 {
44     UNREFERENCED_PARAMETER(ProfileSource);
45 
46     HalpProfilingStopped = FALSE;
47 
48     HalpAcquireCmosSpinLock();
49 
50     /* Configure the clock divisor for generating periodic interrupts */
51     __outbyte(RTC_IO_o_INT_CLOCK_DIVISOR, HalpProfileRate | 0x80);
52 
53     HalpReleaseCmosSpinLock();
54 }
55 
56 ULONG_PTR
57 NTAPI
58 HalSetProfileInterval(
59     _In_ ULONG_PTR Interval)
60 {
61     /*
62      * FIXME:
63      * 1) What is the maximum and minimum interrupt frequency for the RTC?
64      * 2) Find the maximum possible clock divisor value.
65      */
66     UNIMPLEMENTED;
67 
68     /* Update interval */
69     if (!HalpProfilingStopped)
70        HalStartProfileInterrupt(0);
71 
72     /* For now... */
73     return Interval;
74 }
75