summaryrefslogtreecommitdiffstats
path: root/private/ntos/fw/ppc/fwp.h
blob: f7d09eb4ad3a3d7701fa1b42d3dd69bead2052bf (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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
/*++

Copyright (c) 1991  Microsoft Corporation

Module Name:

    fwp.h

Abstract:

    This module contains extensions to the firmware.h header file.

Author:

    David M. Robinson (davidro) 29-Aug-1991

Revision History:

--*/

#ifndef _FWP_
#define _FWP_

#include "bldr.h"
#include "firmware.h"
#include "kbdmouse.h"
#ifndef DUO
#include "jazzdef.h"
#include "jazzprom.h"
#ifndef _PPC_
#include "jazzdma.h"
#else
#include "ppcdef.h"
#endif
#else
#include "duodef.h"
#include "duoprom.h"
#include "duodma.h"
#endif


//
// TEMPTEMP Temporary defines.
//

#define SECONDARY_CACHE_SIZE (1 << 20)
#define SECONDARY_CACHE_INVALID 0x0
#define SECONDARY_CACHE_DIRTY_EXCLUSIVE 0x5
#define TAGLO_SSTATE 0xA

//
// Current version and revision numbers.
//

#define ARC_VERSION     1
#define ARC_REVISION    2


//
// Define the firmware vendor specific entry point numbers.
//

typedef enum _VENDOR_ENTRY {
    AllocatePoolRoutine,
    StallExecutionRoutine,
    PrintRoutine,
    SetDisplayAttributesRoutine,
    OutputCharacterRoutine,
    ScrollVideoRoutine,
    BootRestartRoutine,
    MaximumVendorRoutine
    } VENDOR_ENTRY;

//
// Define vendor specific routine types.
//

typedef
PVOID
(*PVEN_ALLOCATE_POOL_ROUTINE) (
    IN ULONG NumberOfBytes
    );

typedef
VOID
(*PVEN_STALL_EXECUTION_ROUTINE) (
    IN ULONG Microseconds
    );

typedef
ULONG
(*PVEN_PRINT_ROUTINE) (
    IN PCHAR Format,
    ...
    );

typedef
VOID
(*PVEN_SET_DISPLAY_ATTRIBUTES_ROUTINE) (
    IN ULONG ForegroundColor,
    IN ULONG BackgroundColor,
    IN BOOLEAN HighIntensity,
    IN BOOLEAN Underscored,
    IN BOOLEAN ReverseVideo,
    IN ULONG CharacterWidth,
    IN ULONG CharacterHeight
    );

typedef
VOID
(*PVEN_OUTPUT_CHARACTER_ROUTINE) (
    IN PVOID Character,
    IN ULONG Row,
    IN ULONG Column
    );

typedef
VOID
(*PVEN_SCROLL_VIDEO_ROUTINE) (
    VOID
    );

typedef
VOID
(*PVEN_BOOT_RESTART_ROUTINE) (
    IN PRESTART_BLOCK RestartBlock
    );

//
// Define vendor specific prototypes.
//

PVOID
FwAllocatePool (
    IN ULONG NumberOfBytes
    );

VOID
FwStallExecution (
    IN ULONG Microseconds
    );

ULONG
FwPrint (
    IN PCHAR Format,
    ...
    );

VOID
FwSetDisplayAttributes (
    IN ULONG ForegroundColor,
    IN ULONG BackgroundColor,
    IN BOOLEAN HighIntensity,
    IN BOOLEAN Underscored,
    IN BOOLEAN ReverseVideo,
    IN ULONG CharacterWidth,
    IN ULONG CharacterHeight
    );

VOID
FwOutputCharacter (
    IN PVOID Character,
    IN ULONG Row,
    IN ULONG Column
    );

VOID
FwScrollVideo (
    VOID
    );

//
// Define vendor specific functions.
//
#define VenRestartBlock(RestartBlock) \
    ((PVEN_BOOT_RESTART_ROUTINE)(SYSTEM_BLOCK->VendorVector[BootRestartRoutine])) \
        ((RestartBlock))

#define VenAllocatePool(NumberOfBytes) \
    ((PVEN_ALLOCATE_MEMORY_ROUTINE)(SYSTEM_BLOCK->VendorVector[AllocatePoolRoutine])) \
        ((NumberOfBytes))

#define VenStallExecution(Microseconds) \
    ((PVEN_STALL_EXECUTION_ROUTINE)(SYSTEM_BLOCK->VendorVector[StallExecutionRoutine])) \
        ((Microseconds))

#define VenPrint(x) \
    ((PVEN_PRINT_ROUTINE)(SYSTEM_BLOCK->VendorVector[PrintRoutine])) \
        ((x))

#define VenPrint1(x,y) \
    ((PVEN_PRINT_ROUTINE)(SYSTEM_BLOCK->VendorVector[PrintRoutine])) \
        ((x), (y))

#define VenPrint2(x,y,z) \
    ((PVEN_PRINT_ROUTINE)(SYSTEM_BLOCK->VendorVector[PrintRoutine])) \
        ((x), (y), (z))

#define VenSetDisplayAttributes(ForegroundColor, BackgroundColor, HighIntensity, Underscored, ReverseVideo, CharacterWidth, CharacterHeight) \
    ((PVEN_SET_DISPLAY_ATTRIBUTES_ROUTINE)(SYSTEM_BLOCK->VendorVector[SetDisplayAttributesRoutine])) \
        ((ForegroundColor), (BackgroundColor), (HighIntensity), \
        (Underscored), (ReverseVideo), (CharacterWidth), (CharacterHeight))

#define VenOutputCharacter(Character, Row, Column) \
    ((PVEN_OUTPUT_CHARACTER_ROUTINE)(SYSTEM_BLOCK->VendorVector[OutputCharacterRoutine])) \
        ((Character), (Row), (Column))

#define VenScrollVideo() \
    ((PVEN_SCROLL_VIDEO_ROUTINE)(SYSTEM_BLOCK->VendorVector[ScrollVideoRoutine])) ()


//
// Define the Lookup table. At initialization, the driver must fill this table
// with the device pathnames it can handle.
//

typedef struct _DRIVER_LOOKUP_ENTRY {
    PCHAR                    DevicePath;
    PBL_DEVICE_ENTRY_TABLE   DispatchTable;
} DRIVER_LOOKUP_ENTRY, *PDRIVER_LOOKUP_ENTRY;

#define SIZE_OF_LOOKUP_TABLE BL_FILE_TABLE_SIZE

extern DRIVER_LOOKUP_ENTRY DeviceLookupTable[SIZE_OF_LOOKUP_TABLE];

//
// Define the Device Pathname. This table is indexed with the FileId.
// FwOpen tries to match the OpenPath with the entries in this table, and
// if it finds a match it increments the reference counter.  If it doesn't
// find a match it tries to match an entry in the DRIVER_LOOKUP_TABLE
// and then calls the Open routine of that driver.
//

#define SIZE_OF_ARC_DEVICENAME  64

typedef struct _OPENED_PATHNAME_ENTRY {
    ULONG   ReferenceCounter;
    CHAR    DeviceName[SIZE_OF_ARC_DEVICENAME];
} OPENED_PATHNAME_ENTRY, *POPENED_PATHNAME_ENTRY;

#define SIZE_OF_OPENED_PATHNAME_TABLE BL_FILE_TABLE_SIZE

extern OPENED_PATHNAME_ENTRY OpenedPathTable[SIZE_OF_OPENED_PATHNAME_TABLE];

//
// Driver initialization routines.
//

VOID
FwInitializeMemory(
    IN VOID
    );

VOID
FwResetMemory(
    IN VOID
    );

VOID
DisplayInitialize(
    IN OUT PDRIVER_LOOKUP_ENTRY LookupTableEntry,
    IN ULONG Entries
    );

VOID
KeyboardInitialize(
    IN OUT PDRIVER_LOOKUP_ENTRY LookupTableEntry,
    IN ULONG Entries
    );

VOID
SerialInitialize(
    IN OUT PDRIVER_LOOKUP_ENTRY LookupTableEntry,
    IN ULONG Entries
    );

VOID
HardDiskInitialize(
    IN OUT PDRIVER_LOOKUP_ENTRY LookupTable,
    IN ULONG Entries
    );

VOID
FloppyInitialize(
    IN OUT PDRIVER_LOOKUP_ENTRY LookupTableEntry,
    IN ULONG Entries
    );



//
// Define the private configuration packet structure, which contains a
// configuration component as well as pointers to the component's parent,
// peer, child, and configuration data.
//

typedef struct _CONFIGURATION_PACKET {
    CONFIGURATION_COMPONENT Component;
    struct _CONFIGURATION_PACKET *Parent;
    struct _CONFIGURATION_PACKET *Peer;
    struct _CONFIGURATION_PACKET *Child;
    PVOID ConfigurationData;
} CONFIGURATION_PACKET, *PCONFIGURATION_PACKET;

//
// The compressed configuration packet structure used to store configuration
// data in NVRAM.
//

typedef struct _COMPRESSED_CONFIGURATION_PACKET {
    UCHAR Parent;
    UCHAR Class;
    UCHAR Type;
    UCHAR Flags;
    ULONG Key;
    UCHAR Version;
    UCHAR Revision;
    USHORT ConfigurationDataLength;
    USHORT Identifier;
    USHORT ConfigurationData;
} COMPRESSED_CONFIGURATION_PACKET, *PCOMPRESSED_CONFIGURATION_PACKET;

//
// Defines for Identifier index.
//

#define NO_CONFIGURATION_IDENTIFIER 0xFFFF

//
// Defines for the volatile and non-volatile configuration tables.
//

#define NUMBER_OF_ENTRIES 40
#define LENGTH_OF_IDENTIFIER (1024 - (40*16) - 8)
#define LENGTH_OF_DATA 2048
#define LENGTH_OF_ENVIRONMENT 1024
#define LENGTH_OF_EISA_DATA 2044

#define MAXIMUM_ENVIRONMENT_VALUE 256

//
// The volatile configuration table structure.
//

typedef struct _CONFIGURATION {
    CONFIGURATION_PACKET Packet[NUMBER_OF_ENTRIES];
    UCHAR Identifier[LENGTH_OF_IDENTIFIER];
    UCHAR Data[LENGTH_OF_DATA];
    UCHAR EisaData[LENGTH_OF_EISA_DATA];
} CONFIGURATION, *PCONFIGURATION;

//
// The non-volatile configuration table structure.
//

typedef struct _NV_CONFIGURATION {

    //
    // First Page
    //

    COMPRESSED_CONFIGURATION_PACKET Packet[NUMBER_OF_ENTRIES];
    UCHAR Identifier[LENGTH_OF_IDENTIFIER];
    UCHAR Data[LENGTH_OF_DATA];
    UCHAR Checksum1[4];
    UCHAR Environment[LENGTH_OF_ENVIRONMENT];
    UCHAR Checksum2[4];

    //
    // Second Page
    //

    UCHAR EisaData[LENGTH_OF_EISA_DATA];
    UCHAR Checksum3[4];

} NV_CONFIGURATION, *PNV_CONFIGURATION;

//
// Define identifier index, data index, pointer to configuration table.
//

extern ULONG IdentifierIndex;
extern ULONG DataIndex;
extern ULONG EisaDataIndex;
extern PCONFIGURATION Configuration;

//
// Non-volatile ram layout.
//

#define NVRAM_CONFIGURATION NVRAM_VIRTUAL_BASE
#define NVRAM_SYSTEM_ID (NVRAM_VIRTUAL_BASE + 0x00002000)

//
// Memory size.  The MctadrRev2 is used to interpret the memory size value
// in the configuration register.
//

extern ULONG MemorySize;
#define MEMORY_SIZE (MemorySize << 20)
extern BOOLEAN MctadrRev2;

//
// Memory layout.
//

#ifndef _PPC_
#define FW_POOL_BASE 0xa07ed000
#define FW_POOL_SIZE 0xf000
#else
#define FW_POOL_BASE 0xe80000
#define FW_POOL_SIZE 0x3000
#endif

//
// Define special character values. TEMPTEMP These should go somewhere else.
//

#define ASCII_NUL 0x00
#define ASCII_BEL 0x07
#define ASCII_BS  0x08
#define ASCII_HT  0x09
#define ASCII_LF  0x0A
#define ASCII_VT  0x0B
#define ASCII_FF  0x0C
#define ASCII_CR  0x0D
#define ASCII_CSI 0x9B
#define ASCII_ESC 0x1B
#define ASCII_SYSRQ 0x80

//
// Define screen colors.
//

typedef enum _ARC_SCREEN_COLOR {
    ArcColorBlack,
    ArcColorRed,
    ArcColorGreen,
    ArcColorYellow,
    ArcColorBlue,
    ArcColorMagenta,
    ArcColorCyan,
    ArcColorWhite,
    MaximumArcColor
    } ARC_SCREEN_COLOR;

//
// Define video board types for Jazz.
//

typedef enum _JAZZ_VIDEO_TYPE {
    JazzVideoG300,
    JazzVideoG364,
    JazzVideoVxl,
    Reserved3,
    Reserved4,
    Reserved5,
    Reserved6,
    Reserved7,
    Reserved8,
    Reserved9,
    ReservedA,
    ReservedB,
    ReservedC,
    ReservedD,
    ReservedE,
    ReservedF,
    MipsVideoG364,
    MaximumJazzVideo
    } JAZZ_VIDEO_TYPE, *PJAZZ_VIDEO_TYPE;



//
// Define firmware routine prototypes.
//

VOID
FwIoInitialize1 (
    VOID
    );

VOID
FwIoInitialize2 (
    VOID
    );

BOOLEAN
FwGetPathMnemonicKey(
    IN PCHAR OpenPath,
    IN PCHAR Mnemonic,
    OUT PULONG Key
    );

PCHAR
FwEnvironmentLoad(
    VOID
    );

VOID
FwPrintVersion (
    VOID
    );

ARC_STATUS
DisplayBootInitialize(
    VOID
    );

ARC_STATUS
FwGetVideoData (
    OUT PMONITOR_CONFIGURATION_DATA MonitorData
    );

VOID
FwSetVideoData (
    IN PMONITOR_CONFIGURATION_DATA MonitorData
    );

VOID
FwTerminationInitialize(
    IN VOID
    );

VOID
FwHalt(
    IN VOID
    );

VOID
FwMonitor(
    IN ULONG
    );

VOID
FwExceptionInitialize(
    IN VOID
    );

VOID
ResetSystem (
    IN VOID
    );


VOID
FwpFreeStub(
    IN PVOID Buffer
    );

typedef enum _GETSTRING_ACTION {
    GetStringSuccess,
    GetStringEscape,
    GetStringUpArrow,
    GetStringDownArrow,
    GetStringMaximum
} GETSTRING_ACTION, *PGETSTRING_ACTION;

GETSTRING_ACTION
FwGetString(
    OUT PCHAR String,
    IN ULONG StringLength,
    IN PCHAR InitialString OPTIONAL,
    IN ULONG CurrentRow,
    IN ULONG CurrentColumn
    );

ARC_STATUS
FwConfigurationCheckChecksum (
    VOID
    );

ARC_STATUS
FwEnvironmentCheckChecksum (
    VOID
    );

VOID
FwpReservedRoutine(
    VOID
    );

VOID
FwWaitForKeypress(
    VOID
    );

VOID
JzShowTime (
    BOOLEAN First
    );

VOID
JxBmp (
    VOID
    );

ULONG
JxDisplayMenu (
    IN PCHAR Choices[],
    IN ULONG NumberOfChoices,
    IN LONG DefaultChoice,
    IN ULONG CurrentLine
    );

BOOLEAN
FwGetVariableSegment (
    IN ULONG SegmentNumber,
    IN OUT PCHAR Segment
    );

ARC_STATUS
FwSetVariableSegment (
    IN ULONG SegmentNumber,
    IN PCHAR VariableName,
    IN OUT PCHAR Segment
    );

ARC_STATUS
JzAddProcessor (
    IN ULONG ProcessorNumber
    );

//
// Print macros.
//

extern BOOLEAN DisplayOutput;
extern BOOLEAN SerialOutput;
extern BOOLEAN FwConsoleInitialized;
extern BOOLEAN SetupIsRunning;

ULONG
FwPrint (
    PCHAR Format,
    ...
    );

#define FwClearScreen() \
    FwPrint("%c2J", ASCII_CSI)

#define FwSetScreenColor(FgColor, BgColor) \
    FwPrint("%c3%dm", ASCII_CSI, (UCHAR)FgColor); \
    FwPrint("%c4%dm", ASCII_CSI, (UCHAR)BgColor)

#define FwSetScreenAttributes( HighIntensity, Underscored, ReverseVideo ) \
    FwPrint("%c0m", ASCII_CSI); \
    if (HighIntensity) { \
        FwPrint("%c1m", ASCII_CSI); \
    } \
    if (Underscored) { \
        FwPrint("%c4m", ASCII_CSI); \
    } \
    if (ReverseVideo) { \
        FwPrint("%c7m", ASCII_CSI); \
    }

#define FwSetPosition( Row, Column ) \
    FwPrint("%c%d;%dH", ASCII_CSI, (Row + 1), (Column + 1))

#define FwMoveCursorLeft(Spaces) \
    FwPrint ("%c%dD", ASCII_CSI, Spaces)

#define FwMoveCursorToColumn(Spaces)               \
    FwPrint( "\r" );                               \
    if ( Spaces > 1 )                              \
        FwPrint( "%c%dC", ASCII_CSI, Spaces - 1)
#endif // _FWP_