summaryrefslogtreecommitdiffstats
path: root/private/ntos/nthals/halsnip/mips/xxcache.c
blob: 69d72396f9d6fe6ff5d98e6d53e5c25c2636f8ac (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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
//#pragma comment(exestr, "$Header: /usr4/winnt/SOURCES/halpcims/src/hal/halsnipm/mips/RCS/xxcache.c,v 1.4 1996/03/04 13:27:00 pierre Exp $")
/*++

Copyright (c) 1993-94 Siemens Nixdorf Informationssysteme AG

Module Name:

    xxcache.c

Abstract:


    This module implements the functions necessesary to call the correct Cache routines
    depending on Uni- or MultiProcessor machine typ.

Environment:

    Kernel mode only.

Revision History:

--*/

#include "halp.h"
#include "mpagent.h"
#include "xxcache.h"

HalpProcessorType HalpProcessorId = UNKNOWN;



// Desktop : processor may be R4600 or R4700 both of them with or without SC
// Minitower : processors may be R4700 with or without SC or R4400 + MPAgent (1 or 2)

VOID
HalpProcessorConfig()
{
ULONG Proc, reg;

    Proc = HalpProcIdentify(); 
    HalpMainBoard = (MotherBoardType) READ_REGISTER_UCHAR(0xbff0002a);
    if (HalpMainBoard == M8150) HalpIsTowerPci = TRUE;

    switch (Proc) {	

    case HalpR4600:
    case HalpR4700:
        if (PCR->SecondLevelDcacheFillSize) HalpProcessorId = ORIONSC;  // ASIC driven SC
            else HalpProcessorId = R4x00;
        break;

    default:
        // RM200 and RM300 use the same bit but use the opposite value to determine the new ASIC revision...
        // ASIC rev 1.0    => cache replace memory (special area reserved by the firmware).
        // ASIC rev >= 1.1 => cache replace with the ASIC register value.
        if (HalpMainBoard == DesktopPCI) {
            UCHAR tmp;
            tmp = READ_REGISTER_UCHAR(PCI_MSR_ADDR);
            if (tmp & PCI_MSR_REV_ASIC) HalpMpaCacheReplace = RM300_RESERVED | KSEG0_BASE;  // rev 1.0
                else HalpMpaCacheReplace = MPAGENT_RESERVED | KSEG0_BASE;    // rev 1.1
        } else {
            if (HalpMainBoard == MinitowerPCI) {
                UCHAR tmp;
                tmp = READ_REGISTER_UCHAR(PCI_MSR_ADDR);
                if (tmp & PCI_MSR_REV_ASIC) HalpMpaCacheReplace = MPAGENT_RESERVED | KSEG0_BASE;   // rev 1.1
                    else HalpMpaCacheReplace = RM300_RESERVED | KSEG0_BASE;     // rev 1.0
            } else HalpMpaCacheReplace = MPAGENT_RESERVED | KSEG0_BASE;         // RM400 all ASIC
        }

        HalpProcessorId = MPAGENT; // R4x00 always with MPAgent on the PCI range.

        if (HalpMpaCacheReplace == MPAGENT_RESERVED | KSEG0_BASE) {
             reg  = ((MPAGENT_RESERVED &   // put the reserved physical address (4Mb long)
                      MPA_OP_ADDR_MASK) |
                      MPA_OP_ENABLE);       // enable the operator
        } else {
             reg = 0;
        }

        WRITE_REGISTER_ULONG(&(mpagent->mem_operator), reg);  // for all procs (done for proc 0 in xxcache)

    }

    return;
}

VOID
HalFlushDcachePage(
   IN PVOID Color,
   IN ULONG PageFrame,
   IN ULONG Length
   )
{

    switch (HalpProcessorId) {

    case MPAGENT:

        HalpFlushDcachePageMulti(
           Color,
           PageFrame,
           Length
           );
    break;

    case ORIONSC:

        HalSweepDcacheRange(
           Color,
           Length
           );
        HalpFlushDcachePageOrion(
           Color,
           PageFrame,
           Length
           );
    break;

    case R4x00:

        HalpFlushDcachePageUni(
           Color,
           PageFrame,
           Length
           );
    break;

    case UNKNOWN:

    HalpProcessorConfig();
        HalFlushDcachePage(Color, PageFrame, Length);
    
   }

}

VOID
HalPurgeDcachePage (
   IN PVOID Color,
   IN ULONG PageFrame,
   IN ULONG Length
   )
{

    switch (HalpProcessorId) {

    case MPAGENT:

        HalpFlushDcachePageMulti(
           Color,
           PageFrame,
           Length
           );
    break;

    case ORIONSC:

        HalSweepDcacheRange(
           Color,
           Length
           );
        HalpFlushDcachePageOrion(
           Color,
           PageFrame,
           Length
           );
    break;

    case R4x00:

        HalpPurgeDcachePageUni(
           Color,
           PageFrame,
           Length
           );
    break;

    case UNKNOWN:

    HalpProcessorConfig();
        HalPurgeDcachePage(Color, PageFrame, Length);
    
   }

}

VOID
HalPurgeIcachePage(
   IN PVOID Color,
   IN ULONG PageFrame,
   IN ULONG Length
   )
{

    switch (HalpProcessorId) {

    case MPAGENT:

        HalpPurgeIcachePageMulti(
           Color,
           PageFrame,
           Length
           );
    break;

    case ORIONSC:

        HalSweepIcacheRange(
           Color,
           Length
           );
        HalpPurgeIcachePageOrion(
           Color,
           PageFrame,
           Length
           );
    break;

    case R4x00:

        HalpPurgeIcachePageUni(
           Color,
           PageFrame,
           Length
           );
    break;

    case UNKNOWN:

    HalpProcessorConfig();
        HalPurgeIcachePage(Color, PageFrame, Length);
    
   }

}

VOID
HalSweepDcache(
   VOID
   )
{

    switch (HalpProcessorId) {

    case MPAGENT:

        HalpSweepDcacheMulti();
    break;

    case ORIONSC:

        HalpSweepDcacheOrion();
    break;

    case R4x00:

        HalpSweepDcacheUni();
    break;

    case UNKNOWN:

    HalpProcessorConfig();
        HalSweepDcache();
    
   }
   
}

VOID
HalSweepIcache (
    VOID
    )
{

    switch (HalpProcessorId) {

    case MPAGENT:

        HalpSweepIcacheMulti();
    break;

    case ORIONSC:

        HalpSweepIcacheOrion();
    break;

    case R4x00:

        HalpSweepIcacheUni();
    break;

    case UNKNOWN:

    HalpProcessorConfig();
        HalSweepIcache();
    
   }
   
}

VOID
HalZeroPage (
    IN PVOID NewColor,
    IN PVOID OldColor,
    IN ULONG PageFrame
    )
{

    switch (HalpProcessorId) {

    case MPAGENT:

        HalpZeroPageMulti(
           NewColor,
           OldColor,
           PageFrame
           );
    break;

    case ORIONSC:

        HalpZeroPageOrion(
           NewColor,
           OldColor,
           PageFrame
           );
    break;

    case R4x00:

        HalpZeroPageUni(
           NewColor,
           OldColor,
           PageFrame
           );
    break;

    case UNKNOWN:

    HalpProcessorConfig();
        HalZeroPage(NewColor, OldColor, PageFrame);
    
   }
    
}