summaryrefslogtreecommitdiffstats
path: root/private/ntos/fw/alpha/stubs.c
blob: c64c8626665d471fde1e2cf7795b31e3021a13f9 (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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
/*++

Copyright (c) 1990  Microsoft Corporation
Copyright (c) 1993  Digital Equipment Corporation

Module Name:

    stubs.c

Abstract:

    This module implements stub routines for the firmware, FailSafe
    Booter, and the Alpha AXP/Jensen ROM update tool (JNUPDATE.EXE).

Author:

    Lluia Abello (lluis) 3-Oct-1991

Environment:

    Kernel mode only.

Revision History:

    John DeRosa [DEC]	11-May-1993

        Made Alpha AXP modification.

--*/

#include "ntos.h"
#include "fwp.h"
#include "fwstring.h"

LONG
DebugPrint(
    IN PSTRING Output
    );


#if defined(MORGAN)
#include "ex.h"

PVOID
ExAllocatePool(
    IN POOL_TYPE PoolType,
    IN ULONG NumberOfBytes
    )
{
    return((PVOID)NULL);
}



VOID
KeRaiseIrql (
   KIRQL NewIrql,
   PKIRQL OldIrql
   )
{
    return;
}



VOID
KeLowerIrql (
   KIRQL NewIrql
   )
{
    return;
}


#endif           // MORGAN



#ifndef JNUPDATE

VOID
FwpFreeStub(
    IN PVOID Buffer
    )
{
}

VOID
FwpReservedRoutine(
    VOID
    )
{
    FwPrint(ST_RESERVED_ROUTINE_MSG);
    return;
}

#endif



//
// This is defined in ntos\rtl\imagedir.c.  This is linked in unnecessarily
// on a normal build, and is needed on a kd build.  The problem is that the
// rtl copy has an try/except block, which causes SEH code to be pulled into
// the link, which we are not prepared for.  So, this copy is identical to
// the rtl copy except it has no try/except form.
//

PIMAGE_NT_HEADERS
RtlImageNtHeader (
    IN PVOID Base
    )

/*++

Routine Description:

    This function returns the address of the NT Header.

Arguments:

    Base - Supplies the base of the image.

Return Value:

    Returns the address of the NT Header.

--*/

{

    PIMAGE_NT_HEADERS NtHeaders;

    if (Base != NULL &&
        Base != (PVOID)-1
       ) {
//        try {
            if (((PIMAGE_DOS_HEADER)Base)->e_magic == IMAGE_DOS_SIGNATURE) {
                NtHeaders = (PIMAGE_NT_HEADERS)((PCHAR)Base + ((PIMAGE_DOS_HEADER)Base)->e_lfanew);
                if (NtHeaders->Signature == IMAGE_NT_SIGNATURE) {
                    return NtHeaders;
                }
            }

//        } except(EXCEPTION_EXECUTE_HANDLER) {
//            return NULL;
//        }

    }

    return NULL;
}




#ifndef JNUPDATE

#ifndef ALPHA_FW_KDHOOKS

//
// This must not be defined for kd link.
//

LONG
DebugPrint(
    IN PSTRING Output
    )

/*++

Routine Description:

    This function is defined in rtl\alpha\debugstb.s.  There, it calls
    BREAK_DEBUG_PRINT, which is defined in public\sdk\inc\kxalpha.h to
    do a call_pal callkd, which in the NT PALcode will invoke the
    AlphaKd link.

    The normal firmware PALcode has no AlphaKd support, so DebugPrint is
    stubbed off here.  There are references to DebugPrint in the bldr
    directory and some fw files.
    
Arguments:


Return Value:

--*/

{
    return (0);
}

#endif

#endif


#ifndef JNUPDATE

VOID
RtlInitString(
    OUT PSTRING DestinationString,
    IN PCSZ SourceString OPTIONAL
    )

/*++

Routine Description:

    The RtlInitString function initializes an NT counted string.
    The DestinationString is initialized to point to the SourceString
    and the Length and MaximumLength fields of DestinationString are
    initialized to the length of the SourceString, which is zero if
    SourceString is not specified.

    This is a copy of the same function in \nt\private\ntos\rtl\string.c.
    It is here to minimize what the linker drags into the image.
    
Arguments:

    DestinationString - Pointer to the counted string to initialize

    SourceString - Optional pointer to a null terminated string that
        the counted string is to point to.


Return Value:

    None.

--*/

{
    DestinationString->Length = 0;
    DestinationString->Buffer = (PCHAR)SourceString;
    if (ARGUMENT_PRESENT( SourceString )) {
        while (*SourceString++) {
            DestinationString->Length++;
            }

        DestinationString->MaximumLength = (SHORT)(DestinationString->Length+1);
        }
    else {
        DestinationString->MaximumLength = 0;
        }
}

#endif

#if (!defined FAILSAFE_BOOTER) && (!defined JNUPDATE)


//
// This stub is needed by some function in the rtl library.
//

NTSTATUS
ZwQuerySystemInformation (
    IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
    OUT PVOID SystemInformation,
    IN ULONG SystemInformationLength,
    OUT PULONG ReturnLength OPTIONAL
    )

{
    return;
}

#endif


VOID
FwErrorStackUnderflow (
    IN ULONG Caller,
    IN ULONG CallerOfTheCaller,
    IN ULONG CallerRequestedStackArea
    )

/*++

Routine Description:

    A function was called that requested a stack area too large for
    the current Firmware stack.  The firmware _RtlCheckStack function
    (see fwchkstk.s) calls this function to print out the fatal error
    message.

    The 64KB underneath the Firmware stack is used as a panic stack.

Arguments:

    Caller			The address of the function that tried to
                                allocate the stack space.

    CallerOfTheCaller		The address of the function that called the
                                function held in "Caller".

    CallerRequestedStackArea	The amount of stack space requested by
                                "Caller".

Return Value:

    This never returns.

--*/

{
    VenSetScreenColor(ArcColorRed, ArcColorWhite);
    VenPrint(ST_STACK_UNDERFLOW_1_MSG);
    VenPrint2(ST_STACK_UNDERFLOW_2_MSG, Caller, CallerOfTheCaller);
    VenPrint2(ST_STACK_UNDERFLOW_3_MSG,
	      CallerRequestedStackArea,
	      FW_STACK_LOWER_BOUND);

#if (!defined FAILSAFE_BOOTER) && (!defined JNUPDATE)

    VenPrint(ST_HIT_KEY_FOR_MONITOR_MSG);
    VenSetScreenColor(ArcColorWhite, ArcColorBlue);

    FwWaitForKeypress(TRUE);

    FwMonitor(0);		// Should never return.

#endif

    while (TRUE) {
    }
}


#ifndef JNUPDATE

VOID
KeFlushIoBuffers (
    IN PMDL Mdl,
    IN BOOLEAN ReadOperation,
    IN BOOLEAN DmaOperation
    )

/*++

Routine Description:

    This function flushes the I/O buffer specified by the memory descriptor
    list from the data cache on the current processor.

Arguments:

    Mdl - Supplies a pointer to a memory descriptor list that describes the
        I/O buffer location.

    ReadOperation - Supplies a boolean value that describes whether the I/O
        operation is a read into memory.

    DmaOperation - Supplies a boolean value that describes whether the I/O
        operation is a DMA operation.

Return Value:

    None.

--*/
{

    //
    // temptemp
    //
    // This function must distribute the flush in an MP system.
    //

    HalFlushIoBuffers( Mdl, ReadOperation, DmaOperation );
    return;
}

#endif