summaryrefslogtreecommitdiffstats
path: root/private/ntos/nthals/halr98b/mips/xxclock.c
blob: 4f953ab8dc967fca9db31fb378a6f9613522b473 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/*++

Copyright (c) 1994  Microsoft Corporation

Module Name:

    xxclock.c

Abstract:


    This module implements the function necesssary to change the clock
    interrupt rate.

Environment:

    Kernel mode only.

Revision History:

--*/

/*
 *	Original source: Build Number 1.612
 *
 *	Modify for R98(MIPS/R4400)
 *
 ***********************************************************************
 *
 * K001		95.11.24	M.Kusano
 *	Add	for WDT
 */


#include "halp.h"

//
// Define global data used to communicate new clock rates to the clock
// interrupt service routine.
//

ULONG HalpCurrentTimeIncrement;
ULONG HalpNextIntervalCount;
ULONG HalpNextTimeIncrement;
ULONG HalpNewTimeIncrement;
//K001
ULONG HalpStartWDTFlag[R98B_MAX_CPU];
ULONG HalpStopWDTFlag[R98B_MAX_CPU];
ULONG HalpSetWDTFlag[R98B_MAX_CPU];
ULONG HalpSetWDTCount[R98B_MAX_CPU];

VOID
HalStartWDT(
    IN ULONG   Count
    ); 

VOID
HalStopWDT(
    VOID
    );

VOID
HalSetWDTCounter(
    VOID
    );

ULONG
HalSetTimeIncrement (
    IN ULONG DesiredIncrement
    ) 
/*++

Routine Description:

     This function is called to set the clock interrupt rate to the frequency
     required by the specified time increment value.

     N.B. This function is only executed on the processor that keeps the
         system time.

Arguments:

    DesiredIncrement - Supplies desired number of 100ns units between clock
        interrupts.

Return Value:

    The actual time increment in 100ns units.

--*/

{

    ULONG NewTimeIncrement;
    ULONG NextIntervalCount;
    KIRQL OldIrql;

    //
    // If the specified time increment value is less that the minimum value
    // or greater than the maximum value ,then set the time increment value
    // to the minimum or maximum as appropriate.
    //

    if (DesiredIncrement < MINIMUM_INCREMENT) {
        DesiredIncrement = MINIMUM_INCREMENT;

    } else if (DesiredIncrement > MAXIMUM_INCREMENT) {
        DesiredIncrement = MAXIMUM_INCREMENT;
    }

    //
    // Raise IRQL to the highest level, set the new clock interrupt
    // parameters, lower IRQl, and return the new time increment value.
    //

    // Adjust clock values to the Columbus clock frequency
    //

    KeRaiseIrql(HIGH_LEVEL, &OldIrql);
    NextIntervalCount = ((DesiredIncrement * COLUMBUS_CLOCK_FREQUENCY) / 1000) / 10;
    NewTimeIncrement = (NextIntervalCount * 1000 * 10) / COLUMBUS_CLOCK_FREQUENCY;
    HalpNextIntervalCount = NextIntervalCount;
    HalpNewTimeIncrement = NewTimeIncrement;
    KeLowerIrql(OldIrql);
    return NewTimeIncrement;
}

//K001
VOID	HalStartWDT(
	IN ULONG   Count
)
/*++
Routine Description:
 
 This function is called to start WDT. 

Arguments:

 Count - Counter value for WDT.

Return Value:

    NONE
--*/
{
	ULONG NumCPU,i;

	NumCPU=**((PULONG *)(&KeNumberProcessors));
	NumCPU--;

	for(i=0;i<=NumCPU;i++){
		HalpStartWDTFlag[i]=1;
		HalpSetWDTCount[i]=Count;
	}
}		

VOID	HalStopWDT(
)
/*++
Routine Description:
 
 This function is called to stop WDT. 

Arguments:

   NONE

Return Value:

    NONE
--*/
{
	ULONG NumCPU,i;

	NumCPU=**((PULONG *)(&KeNumberProcessors));
	NumCPU--;

	for(i=0;i<=NumCPU;i++){
		HalpStopWDTFlag[i]=1;
	}
}		

VOID	HalSetWDTCounter(
)
/*++
Routine Description:
 
 This function is called to stop WDT. 

Arguments:

   NONE

Return Value:

    NONE
--*/
{
	ULONG NumCPU,i;

	NumCPU=**((PULONG *)(&KeNumberProcessors));
	NumCPU--;

	for(i=0;i<=NumCPU;i++){
		HalpSetWDTFlag[i]=1;
	}
}