summaryrefslogtreecommitdiffstats
path: root/private/ntos/nthals/halsni4x/mips/jxreturn.c
blob: 7999a2690fc012fdcf3b5af1fd03da62041b7e2d (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
//#pragma comment(exestr, "$Header: /usr4/winnt/SOURCES/ddk35/src/hal/halsni/mips/RCS/jxreturn.c,v 1.3 1995/02/13 12:49:56 flo Exp $")

/*++


Copyright (c) 1993-94 Siemens Nixdorf Informationssysteme AG
Copyright (c) 1991  Microsoft Corporation

Module Name:

    jxreturn.c

Abstract:

    This module implements the HAL return to firmware function.


--*/

#include "halp.h"
#include "eisa.h"
#include "SNIregs.h"
#include "mpagent.h"

VOID
HalpBootCpuRestart(
	VOID
	);

VOID
HalReturnToFirmware(
    IN FIRMWARE_REENTRY Routine
    )

/*++

Routine Description:

    This function returns control to the specified firmware routine.
    In most cases it generates a soft reset.

Arguments:

    Routine - Supplies a value indicating which firmware routine to invoke.

Return Value:

    Does not return.

--*/

{
    KIRQL OldIrql;
    UCHAR DataByte;
    PUCHAR MachineControlRegister = (HalpIsRM200) ?
                                       (PUCHAR) RM200_MCR_ADDR :
                                       (PUCHAR) RM400_MCR_ADDR;

    //
    // Disable Interrupts.
    //
    KeRaiseIrql(HIGH_LEVEL, &OldIrql);

    //
    // Case on the type of return.
    //

    switch (Routine) {
    case HalHaltRoutine:

        //
        // Hang looping.
        //
        for (;;) {}

    case HalPowerDownRoutine:

        //
        // PowerOff is done by the SNI machines by writing the Power_Off bit to the machine control register ...
        //

        WRITE_REGISTER_UCHAR(MachineControlRegister, MCR_POWER_OFF);
        for (;;) {}  // hang looping


    case HalRestartRoutine:
    case HalRebootRoutine:
    case HalInteractiveModeRoutine:


	if (HalpIsMulti) {
                ULONG Mask;

		Mask = HalpActiveProcessors & ~(PCR->SetMember);
#if DBG
		DbgPrint("Send message RESTART to maskcpu = %x \n",Mask);
#endif

                HalpSendIpi(Mask,MPA_RESTART_MESSAGE);
                //
                // if this is not the Boot CPU, we call a special Firmware entry to stop it
                //

		if (PCR->Number ) {
                        //
                        // remove this processor from the list of active processors
                        //
                   	HalpActiveProcessors &= (~(PCR->SetMember));

                        HalSweepDcache();	// this should run only local ...
#if DBG
 			DbgPrint(" Reinit slave %x \n", ((SNI_PRIVATE_VECTOR *)(SYSTEM_BLOCK->VendorVector))->reinit_slave);	
#endif
			((SNI_PRIVATE_VECTOR *)(SYSTEM_BLOCK->VendorVector))->reinit_slave();

		} else HalpBootCpuRestart();
	}


        DataByte = READ_REGISTER_UCHAR(
                      &((PEISA_CONTROL) HalpOnboardControlBase)->ExtendedNmiResetControl);

        ((PNMI_EXTENDED_CONTROL) &DataByte)->BusReset = 1;

        WRITE_REGISTER_UCHAR(
            &((PEISA_CONTROL) HalpOnboardControlBase)->ExtendedNmiResetControl,
            DataByte
            );

        KeStallExecutionProcessor(10000);

        ((PNMI_EXTENDED_CONTROL) &DataByte)->BusReset = 0;

        WRITE_REGISTER_UCHAR(
            &((PEISA_CONTROL) HalpOnboardControlBase)->ExtendedNmiResetControl,
            DataByte
            );

        if (HalpIsRM200) {

            //
            // Reset the SNI RM200 machines by writing the reset bit to the machine control register ...
            // ArcReboot does not work correctly on the RM200 (Reset of the Isa Bus)
            //

            WRITE_REGISTER_UCHAR(MachineControlRegister, (MCR_INRESET | MCR_PODD));

        } else {

            ArcReboot();
        }

        for (;;) ;

    default:
        DbgPrint("HalReturnToFirmware invalid argument\n");
        KeLowerIrql(OldIrql);
        DbgBreakPoint();
    }
}

VOID
HalpBootCpuRestart(
	VOID
	)

/*++

Routine Description:

    This function returns control to the firmware Arcreboot routine.
    it waits until all other cpu's have beet shut down.
    this code is executed only on the boot cpu

Arguments:

    None

Return Value:

    Does not return.

--*/
{
    UCHAR DataByte;
    ULONG cpt;

    cpt = 0;
    while(HalpActiveProcessors != PCR->SetMember) {
    	KeStallExecutionProcessor(500000);
	++cpt;if (cpt == 20) break;
    }	
    //
    // if there are still ssome processors active, we do a reset of the entire machine
    //
    if (HalpActiveProcessors != PCR->SetMember) {

#if DBG
	DbgPrint(" Some processors did not answer (%x). Reset machine started. \n", HalpActiveProcessors);
#endif
	WRITE_REGISTER_UCHAR((PUCHAR) RM400_MCR_ADDR, (MCR_INRESET | MCR_PODD));

    } else {

#if DBG
	DbgPrint("Reboot started \n");
#endif

    }

        DataByte = READ_REGISTER_UCHAR(
                      &((PEISA_CONTROL) HalpOnboardControlBase)->ExtendedNmiResetControl);

        ((PNMI_EXTENDED_CONTROL) &DataByte)->BusReset = 1;

        WRITE_REGISTER_UCHAR(
            &((PEISA_CONTROL) HalpOnboardControlBase)->ExtendedNmiResetControl,
            DataByte
            );

        KeStallExecutionProcessor(10000);

        ((PNMI_EXTENDED_CONTROL) &DataByte)->BusReset = 0;

        WRITE_REGISTER_UCHAR(
            &((PEISA_CONTROL) HalpOnboardControlBase)->ExtendedNmiResetControl,
            DataByte
            );


        ArcReboot();

        for (;;) ;
}