summaryrefslogtreecommitdiffstats
path: root/private/ntos/nthals/halppc/ppc/pxreturn.c
blob: a59dd8087d509ddd24a3954a934419ebe698d402 (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
/*++

Copyright (c) 1991  Microsoft Corporation

Copyright (c) 1994 MOTOROLA, INC.  All Rights Reserved.  This file
contains copyrighted material.  Use of this file is restricted
by the provisions of a Motorola Software License Agreement.

Copyright (c) 1996  International Business Machines Corporation


Module Name:

    pxreturn.c

Abstract:

    This module implements the HAL return to firmware function.


Author:

    David N. Cutler (davec) 21-Aug-1991

Revision History:

    Jim Wooldridge (jimw@austin.vnet.ibm.com) Initial Power PC port

         Keyboard mapping code was ported to PPC.
         This function is currently a stub since our firmware is big endian

--*/

#include "halp.h"
#include "pci.h"
#include "pcip.h"
#include "eisa.h"

#if defined(VICTORY)

#include "ibmppc.h"

#endif

//
// Define keyboard registers structure.
//

typedef struct _KBD_REGISTERS {
    union {
        UCHAR Output;
        UCHAR Input;
    } Data;

    union {
        UCHAR Status;
        UCHAR Command;
    } Control;
} KBD_REGISTERS;

#define KBD_IBF_MASK 2                  // input buffer full mask

#define  KBD_DATA_PORT 0x60
#define  KBD_COMMAND_PORT 0x64
#define KbdGetStatus() (READ_REGISTER_UCHAR(&HalpIoControlBase + KBD_COMMAND_PORT))
#define KbdStoreCommand(Byte) WRITE_REGISTER_UCHAR(&HalpIoControlBase + KBD_COMMAND_PORT, Byte)
#define KbdStoreData(Byte) WRITE_REGISTER_UCHAR(&HalpIoControlBase + KBD_DATA_PORT, Byte)
#define KbdGetData() (READ_REGISTER_UCHAR(&HalpIoControlBase + KBD_DATA_PORT))

VOID
HalpPowerPcReset(
   VOID
   );

#if defined(VICTORY)

VOID
HalpResetUnion(
    VOID
    );

#endif

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 by asserting the reset line
    trough the keyboard controller.
    The Keyboard controller is mapped using the same virtual address
    and the same fixed entry as the DMA.

Arguments:

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

Return Value:

    Does not return.

--*/

{

    KIRQL OldIrql;

    ULONG               i;
    PCI_COMMON_CONFIG   PciData;
    PUCHAR              PIC_Address;
    UCHAR               PIC_Mask=0xFF;

#define ISA_CONTROL ((PEISA_CONTROL) HalpIoControlBase)

    HalpUpdateDecrementer(0x7FFFFFFF);

    //
    // Disable Interrupts.
    //

    KeRaiseIrql(HIGH_LEVEL, &OldIrql);

    //
    // Disable interrupt controller:
    //

    PIC_Address = &(ISA_CONTROL->Interrupt1ControlPort1);
    WRITE_REGISTER_UCHAR(PIC_Address, PIC_Mask);
    PIC_Address = &(ISA_CONTROL->Interrupt2ControlPort1);
    WRITE_REGISTER_UCHAR(PIC_Address, PIC_Mask);

#if defined(SOFT_HDD_LAMP)
    //
    // Turn off the HDD lamp.
    //

    *((PUCHAR)HalpIoControlBase + HDD_LAMP_PORT) = 0;

#endif

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

    switch (Routine) {
    case HalHaltRoutine:

        //
        // Hang looping.
        //

        for (;;) {
        }

    case HalPowerDownRoutine:
    case HalRestartRoutine:
    case HalRebootRoutine:
    case HalInteractiveModeRoutine:

#if defined(VICTORY)

        if ( HalpSystemType == IBM_DORAL ) {
            //
            // Poke the Union "Power On Reset" register.
            // (This should never return).
            //
            HalpResetUnion();
        }

#endif

        HalpPowerPcReset();

        for (;;) {
        }

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