summaryrefslogtreecommitdiffstats
path: root/private/ntos/fw/alpha/jnsetset.c
blob: bc3ba1436fc08c8a625af77ea7e1dac90731fef5 (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
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
/*++

Copyright (c) 1991, 1992  Microsoft Corporation
Copyright (c) 1993  Digital Equipment Corporation

Module Name:

    jnsetset.c


Abstract:

    A firmware tool that allows the user to examine and
    modify the Alpha/Jensen PROM data.
    

Author:

    John DeRosa		31-July-1992.

    This module, and the entire setup program, was based on the jzsetup
    program written by David M. Robinson (davidro) of Microsoft, dated
    9-Aug-1991.
    

Revision History:

--*/

#include "fwp.h"
#include "jnsnvdeo.h"
#include "machdef.h"

#ifdef JENSEN
#include "jnsnrtc.h"
#else
#include "mrgnrtc.h"		// morgan
#endif

#include "string.h"
#include "iodevice.h"
#include "jnvendor.h"
#include "fwstring.h"
#include "xxstring.h"

//
// Routine prototypes.
//

VOID
FwOperatingSystemSwitch(
    VOID
    );

VOID
JzDumpBootSelections(
    VOID
    );

BOOLEAN
JzBootMenu(
    VOID
    );

VOID
JzEnvironmentMenu(
    VOID
    );

VOID
JzUpdateROMData(
    VOID
    );

//
// Static data.
//

ULONG ScsiHostId;
extern PCHAR FirmwareVersion;
extern PUCHAR ScreenBanner;

//
// This indicates whether the environment variables or configuration 
// information was changed while the user was in the setup program.
// If so, we update the ROM data block.
//
// A global static is used to minimize the amount of code, and function
// prototypes and definitions, that has to change.
//

BOOLEAN SetupROMPendingModified;

ULONG
JzGetSelection (
    IN PCHAR Menu[],
    IN ULONG NumberOfChoices,
    IN ULONG DefaultChoice,
    IN PCHAR MenuTitle,
    IN PCHAR BottomExtraLine1,
    IN PCHAR BottomExtraLine2,
    IN LONG AutobootValue,
    IN BOOLEAN ShowTheTime
    )

/*++

Routine Description:

    This routine gets a menu selection from the user.

Arguments:

    Menu		Supplies an array of pointers to menu character
	                strings.

    Selections		Supplies the number of menu selections.

    DefaultChoice	Supplies the current default choice.

    MenuTitle		Points to a string that is the name of this menu.

    BottomExtraLine1,	If non-NULL, points to strings that should be
    BottomExtraLine2    printed out below the "use arrow keys to select" line.

    AutobootValue	If zero, do not do an autoboot countdown.
	            	If nonzero, do an autoboot countdown with this value.

    ShowTheTime  	If true, show the time.  

Return Value:

    Returns the value selected, -1 if the escape key was pressed.

--*/
{
    ULONG Index;

    //
    // Clear screen and print banner.
    //

    FwSetScreenColor(ArcColorWhite, ArcColorBlue);
    FwSetScreenAttributes( TRUE, FALSE, FALSE);
    FwClearScreen();

    FwSetPosition( 0, 0);
    FwPrint(FW_ARC_MULTIBOOT_MSG, FirmwareVersion);
    FwPrint(FW_COPYRIGHT_MSG);
    FwPrint(SS_SELECTION_MENU_MSG, MenuTitle);

    FwSetPosition(NumberOfChoices + 8, 0);
    FwPrint(FW_USE_ARROW_AND_ENTER_MSG);
    if (BottomExtraLine1 != NULL) {
	FwSetPosition(NumberOfChoices + 9, 0);
	FwPrint(BottomExtraLine1);
    }
    if (BottomExtraLine2 != NULL) {
	FwSetPosition(NumberOfChoices + 10, 0);
	FwPrint(BottomExtraLine2);
    }

    if (AutobootValue != 0) {
	FwPrint(FW_AUTOBOOT_MSG);
    }

    //
    // Display the menu and the wait for an action to be selected.
    //

    DefaultChoice = JzDisplayMenu(Menu,
                                  NumberOfChoices,
                                  DefaultChoice,
                                  7,
				  AutobootValue,
                                  ShowTheTime);

    //
    // Clear the choices.
    //

    for (Index = 0; Index < NumberOfChoices ; Index++ ) {
        VenSetPosition( Index + 7, 5);
        VenPrint1("%cK", ASCII_CSI);
    }

    return(DefaultChoice);
}

ULONG
JzInitializeScsiHostId (
    VOID
    )

/*++

Routine Description:

    This routine gets the ScsiHostId from the configuration database if it
    exists.

Arguments:

    None.

Return Value:

    The ScsiHostId is read from the ScsiController configuration component
    if it exists.  If not, a value of 7 is returned.

--*/
{
    PCONFIGURATION_COMPONENT Component;
    PCM_SCSI_DEVICE_DATA ScsiDeviceData;
    UCHAR Buffer[sizeof(CM_PARTIAL_RESOURCE_LIST) +
                 (sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) * 5) +
                 sizeof(CM_SCSI_DEVICE_DATA)];
    PCM_PARTIAL_RESOURCE_LIST Descriptor = (PCM_PARTIAL_RESOURCE_LIST)&Buffer;
    ULONG Count;

    if (((Component = ArcGetComponent("scsi(0)")) != NULL) &&
        (Component->Class == AdapterClass) && (Component->Type == ScsiAdapter) &&
        (ArcGetConfigurationData((PVOID)Descriptor, Component) == ESUCCESS) &&
        ((Count = Descriptor->Count) < 6)) {

        ScsiDeviceData = (PCM_SCSI_DEVICE_DATA)&Descriptor->PartialDescriptors[Count];

        if (ScsiDeviceData->HostIdentifier > 7) {
            return(7);
        } else {
            return(ScsiDeviceData->HostIdentifier);
        }
    }

    return(7);

}


VOID
JensenSetupProgram(
    OUT PBOOLEAN RunAProgram,
    OUT PCHAR PathName
    )

/*++

Routine Description:

    This routine is the top level of the setup utility.

Arguments:

    RunAProgram  -	A pointer to a boolean that will be set to TRUE
                        if the user wants to run a program.

    PathName	-	A pointer to a string area for program names.
                        If asked to run a program, this will be loaded with
			the name of the program to run.  For now, this
			program will be assumed to be run without any
			arguments.

Return Value:

    None.

--*/
{
    BOOLEAN Reboot;
    BOOLEAN AlreadyFoundAFatalProblem;
    BOOLEAN DisableChoice[NUMBER_OF_SETUP_MENU_CHOICES];
    LONG DefaultChoice = 0;
    ULONG ProblemAreas;
    ULONG TempX;
    ULONG Index;
    ULONG CurrentLine;
    UCHAR Character;
    UCHAR YellowString[10];
    PCHAR AdvisoryString;
    PCHAR ErrorString = NULL;

    //
    // The ROM has not been modified yet by the user.
    //

    SetupROMPendingModified = FALSE;

    //
    // Initialize the ScsiHostId Value.
    //

    ScsiHostId = JzInitializeScsiHostId();

    //
    // Loop on choices until exit is selected.
    //

    *RunAProgram = FALSE;

    Reboot = FALSE;

    while (TRUE) {

	//
	// Reset the setup menu by clearing the marker area and resetting the
	// foreground color at the beginning of each line to white, and reset
	// the choice-disable array.
	//

	sprintf(YellowString, "%c3%dm  ", ASCII_CSI, ArcColorWhite);

	for (Index = 0; Index < NUMBER_OF_SETUP_MENU_CHOICES; Index++) {

	    DisableChoice[Index] = FALSE;

	    if (SetupMenuChoices[Index] != NULL) {
		// Be careful not to copy the \0.
		strncpy(SetupMenuChoices[Index], YellowString, 6);
	    }
	}

	AdvisoryString = NULL;

	//
	// Now the setup menu is in its initial default state.  Get the
	// system problem areas.
	//

	FwSystemConsistencyCheck(TRUE, &ProblemAreas);

	//
	// Intializing the ROM data has to be done in a particular order.  So,
	// we now cycle through the problem bits and put a colored arrow
	// next to each area that needs fixing, and at the same time load
	// the array that tells us which ones are not allowed yet.
	//
	// This code is not general-purpose.  It knows about the order of
	// SetupMenuChoices and the desired order of problem repair.
	//

	sprintf(YellowString, "%c3%dm->", ASCII_CSI, ArcColorYellow);

	AlreadyFoundAFatalProblem = FALSE;
	TempX = ProblemAreas;
	Index = 0;

	while (TempX != 0) {

	    //
	    // There is at least one more system problem.
	    //

	    if (((TempX & 1) != 0) || ((TempX & 0x10000) != 0)) {

		//
		// There is a problem in the area that we are now pointing at,
		// so make this a yellow line.
		//

		strncpy (SetupMenuChoices[Index], YellowString, 6);
		AdvisoryString = SS_YELLOW_MEANS_FIX_THIS_MSG;

		//
		// Since managing the boot selections is a "yellow" error,
		// they are orthogonal to fixing fatal ("red") problems.
		//

		if (Index != SETUP_MENU_BOOT_SELECTION_LINE) {


		    if (AlreadyFoundAFatalProblem == FALSE) {

			//
			// Remember that we have found the first fatal
			// problem already.
			//

			AlreadyFoundAFatalProblem = TRUE;
		    
		    } else {

			//
			// There is a problem in the area we are now pointing
			// at, and it is not the first problem found, and this
			// is not a "Manage boot selections" problem.  So,
			// mark this problem as one which is temporarily
			// disabled until the more serious problem(s) are
			// fixed.
			//

			DisableChoice[Index] = TRUE;
		    }
		}
	    }		

	    //
	    // Shift the red and yellow halves right one bit.
	    //

	    TempX = ((TempX & FWP_MACHINE_PROBLEMS_RED) >> 1) |
	            (((TempX & FWP_MACHINE_PROBLEMS_YELLOW) >> 17) << 16);
	    Index++;
	}

	//
	// Now get the users selection.  The last selection is offerred only
	// if a change is pending.  The system time is displayed only if there
	// are no problems with the system time.  We do this until the user
	// makes an allowed selection.
	//

	do {
	    DefaultChoice = JzGetSelection(SetupMenuChoices,
					   (SetupROMPendingModified ?
					    NUMBER_OF_SETUP_MENU_CHOICES :
					    NUMBER_OF_SETUP_MENU_CHOICES - 1),
					   DefaultChoice,
					   FW_MENU_SETUP_MSG,
					   AdvisoryString,
					   ErrorString,
					   0,
					   (ProblemAreas & FWP_MACHINE_PROBLEMS_TIME) ? FALSE : TRUE);

	    
	    if ((DefaultChoice >= 0) &&
		(DefaultChoice <= (NUMBER_OF_SETUP_MENU_CHOICES - 1)) &&
		(DisableChoice[DefaultChoice] == TRUE)) {

		ErrorString = SS_CHOOSE_ANOTHER_ITEM_MSG;

	    } else {

		ErrorString = NULL;
	    }

	} while (ErrorString != NULL);

	FwClearScreen();

        //
        // Switch based on the action.
        //

        switch (DefaultChoice) {

	    //
	    // Set system time
	    //

	    case 0:

	      JzSetTime();
  	      break;


	    //
	    // Set default environment variables
	    //

	    case 1:

	      JzMakeDefaultEnvironment(FALSE);
              break;


	    //
	    // Set default configuration
	    //

	    case 2:

	      Reboot = JzMakeDefaultConfiguration(FALSE) || Reboot;
              break;


	    //
	    // Manage boot selections
	    //

	    case 3:

	      JzBootMenu();
              break;


	    //
	    // Setup autoboot
	    //

	    case 4:

	      JzSetupAutoboot(FALSE);
              break;


	    //
	    // Menu spacer selections
	    //

	    case 5:
	    case 9:

	      break;


	    //
	    // Run EISA configuration utility from a floppy.  If a
	    // reboot is pending, we reboot after setting the auto-run
	    // NVRAM flag.  If a ROM update is pending, do the update first.
	    //

	    case 6:

#ifdef ISA_PLATFORM

	      break;

#else

	      if (SetupROMPendingModified) {
		  JzUpdateROMData();
	      }

              if (Reboot) {

		  FwpWriteIOChip(RTC_APORT, RTC_RAM_NT_FLAGS0);
		  Character = FwpReadIOChip(RTC_DPORT);
		  ((PRTC_RAM_NT_FLAGS_0)(&Character))->AutoRunECU = 1;
		  FwpWriteIOChip(RTC_APORT, RTC_RAM_NT_FLAGS0);
		  FwpWriteIOChip(RTC_DPORT, Character);

		  FwPrint(SS_ECU_WILL_NOW_REBOOT_MSG);
		  FwStallExecution(3 * 1000 * 1000);
		  ArcReboot();
	      }

	      *RunAProgram = TRUE;
	      strcpy(PathName, FW_ECU_LOCATION);
	      return;

#endif

	    //
	    // Edit environment variables
	    //

	    case 7:

	      JzEditVariable();
              break;


	    //
	    // Reset to factory defaults
	    //

	    case 8:

	      FwSetPosition(3, 0);
	      FwPrint(SS_RESET_TO_FACTORY_DEFAULTS_WARNING_MSG);
	      CurrentLine = 7;
	      CurrentLine = JzGetYesNo(&CurrentLine, SS_ARE_YOU_SURE_MSG, TRUE);

	      if (CurrentLine == 0) {
		  JzMakeDefaultEnvironment(TRUE);
		  Reboot = JzMakeDefaultConfiguration(TRUE);
		  JzAddBootSelection(TRUE);
		  JzSetupAutoboot(TRUE);
	      }

              break;
            
	    //
	    // Help
	    //

	    case 10:

	      FwSetPosition(3,0);
	      for (Index = 0; Index < SETUP_HELP_TABLE_SIZE; Index++) {
		  if (SETUP_HELP_TABLE[Index] != NULL) {
		      FwPrint(SETUP_HELP_TABLE[Index]);
		  }
		  FwPrint(SS_CRLF_MSG);
	      }

	      FwWaitForKeypress(TRUE);
	      break;


	    //
	    // Switch to OpenVMS or OSF
	    //

	    case 11:

	      FwOperatingSystemSwitch();
	      break;

	    //
	    // Quit.
	    //

	    case 12:

	      FwEnvironmentLoad();
	      FwRestoreConfiguration();
	      return;

	    //
	    // Exit, and escape key
	    //

	    case -1:
	    case 13:
	    default:

	      //
	      // If the escape key was pressed, or something bad happened
	      // in the menu subroutine, ask the user for a confirmation.
	      //

	      if ((DefaultChoice != 13) && SetupROMPendingModified) {

		  FwSetPosition(3, 0);
		  FwPrint(SS_ESCAPE_FROM_SETUP_MSG);

		  while (ArcGetReadStatus(ARC_CONSOLE_INPUT) != ESUCCESS) {
		      JzShowTime(FALSE);
		  }

		  ArcRead(ARC_CONSOLE_INPUT, &Character, 1, &Index);

		  if (Character == ASCII_ESC) {
		      FwEnvironmentLoad();
		      FwRestoreConfiguration();
		      return;
		  }
	      }

	      if (SetupROMPendingModified) {
		  JzUpdateROMData();
	      }

              if (Reboot) {
		  ArcReboot();
	      }
              return;

        }
    }
}


BOOLEAN
JzBootMenu(
    VOID
    )
/*++

Routine Description:

    This routine displays the boot menu.

Arguments:

    None.

Return Value:

    Returns TRUE if something was probably changed, and FALSE if nothing
    was changed.

--*/
{
    BOOLEAN FoundProblems;
    BOOLEAN PreviousROMPending;
    LONG DefaultChoice = 0;

    //
    // Loop on choices until exit is selected.
    //
    // Right now, the test for a pending ROM change is to look for a change
    // in the global SetupROMPendingModified.  This test is too pessimistic,
    // and could be made more discriminating.
    //

    PreviousROMPending = SetupROMPendingModified;
    SetupROMPendingModified = FALSE;
    
    while (TRUE) {

        DefaultChoice = JzGetSelection(ManageBootSelectionChoices,
                                       NUMBER_OF_SS_MANAGE_BOOT_CHOICES,
                                       DefaultChoice,
				       FW_MENU_BOOT_SELECTIONS_MSG,
				       NULL,
				       NULL,
	                               0,
	                               TRUE);

        //
        // Switch based on the action.
        //

        switch (DefaultChoice) {

        //
        // Add boot selection
        //

        case 0:
            JzAddBootSelection(FALSE);
            break;

        //
        // Change a boot selection
        //

        case 1:
            JzEditBootSelection();
            break;

        //
        // Check boot selections
        //

        case 2:
            JzCheckBootSelections(FALSE, &FoundProblems);
            break;

        //
        // Delete a boot selection
        //

        case 3:
            JzDeleteBootSelection();
            break;

	//
	// Dump boot selections
	//

	case 4:
	    JzDumpBootSelections();
	    break;

        //
        // Rearrange boot selections
        //

        case 5:
            JzRearrangeBootSelections();
            break;

        //
        // Escape Key, or Exit.
        //

	case -1:
        default:

	  //
	  // Check if a change happened, and restore previous global TRUEness
	  // if necessary.
	  //
	    if (SetupROMPendingModified) {
		return (TRUE);
	    } else {
		SetupROMPendingModified = PreviousROMPending;
		return (FALSE);
	    }
        }
    }
}

VOID
JzDumpBootSelections(
    VOID
    )
/*++

Routine Description:

    This function gives a crude dump of the current boot selections.

Arguments:

    None.

Return Value:

    None.

--*/
{
    ULONG Count;
    ULONG IndentAmount;
    ULONG Index;
    ULONG Index2;
    ULONG Number;
    PCHAR Variable;

    VenClearScreen();
    VenSetPosition(3, 0);
    
    for (Number = 0; Number < 6 ; Number++ ) {
	switch (Number) {
	  case 0:
	    Variable = "LOADIDENTIFIER";
	    IndentAmount = sizeof("LOADIDENTIFIER");
	    break;
	  case 1:
	    Variable = "SYSTEMPARTITION";
	    IndentAmount = sizeof("SYSTEMPARTITION");
	    break;
	  case 2:
	    Variable = "OSLOADER";
	    IndentAmount = sizeof("OSLOADER");
	    break;
	  case 3:
	    Variable = "OSLOADPARTITION";
	    IndentAmount = sizeof("OSLOADPARTITION");
	    break;
	  case 4:
	    Variable = "OSLOADFILENAME";
	    IndentAmount = sizeof("OSLOADFILENAME");
	    break;
	  case 5:
	    Variable = "OSLOADOPTIONS";
	    IndentAmount = sizeof("OSLOADOPTIONS");
	    break;
	}
	
	VenPrint1("%s=",Variable);
	Variable = FwGetVolatileEnvironmentVariable(Variable);
	if (Variable != NULL) {

	    //
	    // If this variable will fit all on one line, print it as such.
	    // Otherwise, print one segment per line.
	    //

	    if ((IndentAmount + strlen(Variable)) < DisplayWidth) {
		VenPrint(Variable);
	    } else {
		while (strchr(Variable,';') != NULL) {
		    Index = strchr(Variable,';') - Variable + 1;
		    ArcWrite(ARC_CONSOLE_OUTPUT, Variable, Index, &Count);
		    VenPrint(SS_CRLF_MSG);
		    for (Index2 = 0; Index2 < IndentAmount; Index2++) {
			VenPrint(" ");
		    }
		    Variable += Index;
		}
		VenPrint(Variable);
	    }
	}
	VenPrint(SS_CRLF_MSG);
    }
    
    VenPrint(SS_CRLF_MSG);
    FwWaitForKeypress(TRUE);
}


VOID
JzUpdateROMData(
    VOID
    )
/*++

Routine Description:

    The user is exiting the setup utility after having changed something
    in the Configuration or Environment Variables.  This function updates
    the ROM from the volatile areas.

Arguments:

    None.

Return Value:

    None.

--*/
{
    ARC_STATUS Status;

    VenClearScreen();
    VenSetPosition(0,0);
    VenPrint(SS_ROM_UPDATE_IN_PROGRESS_MSG);
    if ((Status = FwSaveConfiguration()) != ESUCCESS) {
	VenPrint(SS_ROM_UPDATE_FAILED_MSG);
	ParseARCErrorStatus(Status);
    }

    return;
}

VOID
FwOperatingSystemSwitch(
    VOID
    )

/*++

Routine Description:

     This lets the user alter the console selection flag in the NVRAM.

Arguments:

     None.


Side Effects:

     The RTC_RAM_CONSOLE_SELECTION flag byte in the Jensen NVRAM
     may be modified.

Return Value:

     None.

--*/

{
    UCHAR Character;
    ULONG Count;
    BOOLEAN UserMadeAChange = FALSE;
    LONG Index;
    UCHAR PresentChoice;

    while (TRUE) {

        FwClearScreen();
	FwSetPosition(2, 0);
	FwPrint(SS_WHICH_OS_QUERY_MSG);

	//
	// Print out the current boot selection.  Although the operating
	// system selection encodings are hard-wired, the definitions are
	// also declared in \nt\private\ntos\inc\jnsnrtc.h.  The legal
	// values are 1 -- 3; any other value defaults to booting NT.
	//

	FwpWriteIOChip(RTC_APORT, RTC_RAM_CONSOLE_SELECTION);
	PresentChoice = FwpReadIOChip(RTC_DPORT);
	if ((PresentChoice == 0) || (PresentChoice > 3)) {
	    PresentChoice = RTC_RAM_CONSOLE_SELECTION_NT;
	}

	FwPrint(SS_BOOT_SELECTION_IS_MSG,
		OperatingSystemNames[PresentChoice - 1]);

	FwSetPosition((NUMBER_OF_OS_CHOICES + 7), 0);
        FwPrint(FW_USE_ARROW_AND_ENTER_MSG);

	//
	// JzDisplayMenu returns -1 or a 0-based menu selection.
	// The console selection flag is 1-based.
	//

	Index = JzDisplayMenu(OperatingSystemSwitchChoices,
			      NUMBER_OF_OS_CHOICES,
			      3,
			      6,
			      0,
			      FALSE)
	        + 1;

	if ((Index < 1) || (Index > 3)) {

	    //
	    // The user hit escape, selected Return to main menu, or something
	    // bad happened in JzDisplayMenu.  Exit this loop.
	    //

	    break;
	}

	//
	// Change the console selection flag.
	//

	FwpWriteIOChip(RTC_APORT, RTC_RAM_CONSOLE_SELECTION);
	FwpWriteIOChip(RTC_DPORT, Index);
	UserMadeAChange = TRUE;
    }


    //
    // If the user made a change, tell him to power-cycle.
    //

    if (UserMadeAChange) {
	FwSetPosition(2, 0);
	FwPrint("\x9bK");
	FwSetPosition(6, 0);
	FwPrint("%c0J", ASCII_CSI);
	FwPrint(SS_POWER_CYCLE_FOR_NEW_OS_MSG);
	FwPrint(SS_PRESS_KEY_MSG);
        FwRead(ARC_CONSOLE_INPUT, &Character, 1, &Count);
    }
}