/
Boot3.a
3323 lines (2635 loc) · 129 KB
/
Boot3.a
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
;
; File: Boot3.a (formerly BootCode.a)
;
; Contains: boot code for the Macintosh system
;
; This code lives in the 'boot' 3 resource in the System file.
;
; This code takes over the boot process from Boot2.a, and takes it
; up to the launch of the Process Manager. This code used to be in
; Boot2.a itself but was split off during the implementation of the
; CPU Gibbly mechanism. All code which handles booting should be added to
; this file; Boot2.a doesnÕt do much beyond finding a CPU Gibbly with
; this code and passing on the boot baton. This code, unlike Boot2.a,
; can be in ROM if we so choose.
;
; This contains all the code necessary to get from boot to the Process Mgr.
; It also contains the code that was formerly in INIT 31 that loads INIT resources
; from INIT, RDEV, and cdev files.
;
; Written by: Darin Adler, based on old boot blocks and StartBoot.a
;
; Copyright: © 1990-1993 by Apple Computer, Inc. All rights reserved.
;
; Change History (most recent first):
;
; <SM30> 11/7/93 SAM Roll in <MC2> from mc900ftjesus.
; <MC2> 11/7/93 SAM Sync-in this file with CPUBootcode.a from the gibbly sources.
; <SM29> 7/21/93 RC Changed RegisterROMComponent to selector 42 instead of 27
; <SM28> 7/20/93 SAM Cleaned up more stuff. Moved the processmgr 'proc' resource
; loading code *way* forward in the boot. The scod's end up being
; the very first resources in the heap. The "Welcome dialog is
; displayed after the scods are loaded. Removed a couple of 24
; bit routines. Redid the old installmgr code (which is now
; called InitSys7ToolBox). See the comment block around that
; change for details. Made QuickTime components not load on
; 68010s. Added labels to the ROM header references.
; <SM27> 6/17/93 rab Removed the GetGibbly and CanThisGibblyBootThisMachine routines
; and the code that calls them. This code was inadvertantly rolled
; in during the Ludwig sync up.
; <SM26> 6/15/93 SAM Undid change <LW2> for PDM. We dont need a gibbly to boot
; (we're actually turning the ROM you see...)
; <SM25> 6/14/93 kc Roll in Ludwig.
; <LW2> 3/25/93 GS Added GetGibbly and CanthisGibblyBootThisMachine routines to put
; up the proper Alert when booting a 7.1 System without a Gibbly.
; <SM24> 4/20/93 SAM Removed a call to _InitFonts, cuz _InitGraf calls it.
; <SM23> 2/12/93 PN Add forROM condition for the previous change
; <SM22> 02/11/93 HY Fix problem in routine DetachAndExecute. If a particular resource
; is not found in either the ROM or system file then you crash.
; <SM21> 02/10/93 HY Enable Appletalk on LCR/LC930 again. Revert <SM18> changes.
; <SM20> 2/5/93 SAM Removed the code that was unimplementing MemoryDispatch based on
; MMUtype. Removed the CPU/MMU checks before calling VM. VM
; knows if it can run.
; <SM19> 01/11/93 jmp Updated various BoxFlag names.
; <SM18> 12/16/92 HY Disable Appletalk on LCR/LC930.
; <SM17> 12/7/92 GMA We now call RegisterRomComponents directly from Boot3 instead of
; through the Manager InstallationVector(in ROM). Rom Components
; are registered (through ComponentDispatch) after making the
; Cyclone Gibbly Resident. This allows the Components in ROM to
; use Localized Strings in the Gibbly without referenceing the
; gibbly file directly.
; <SM16> 12/1/92 RB Added a call to MakeOverrideMap so that the 'rovm' resource is
; used to override some system resources.
; <SM15> 11/20/92 GS Added the EnablePDMsgs for the Quadra 900/950 . This was
; originally in a linked patch routine to avoid a problem with the
; KeySw handler early in the boot process.
; <SM14> 11/18/92 RB Finally, the Disk Cache code is in ROM so we don't need to
; install ptch 41 (the only one in SuperMario ROMs) anymore.
; <SM13> 11/3/92 RB Use ROMBase to check for VM being in ROM or not, and call
; StripAddress on the resource pointer before checkin it, just in
; case we are in 24 bit mode.
; <SM12> 11/3/92 fau Corrected a dereference in DetachandExecute.
; <SM11> 11/01/92 HY Conditionalize changes in <SM10> for LC930 because we don't have
; VM in ROM.
; <SM10> 10/30/92 RB Give VM in ROM a chance to load when this file is being used as
; a ROM Gibbly. VM in ROM is newer than the one in the system and
; it behaves correctly in SuperMario based ROMs.
; <SM9> 10/29/92 SWC Changed ShutdownEqu.a->Shutdown.a.
; <SM8> 10/22/92 CSS Change short branches to word branches.
; <41> 8/13/92 JDR Offset to CloseTheFile was out of range in ForTheFuture.
; <40> 8/13/92 DTY #1039434 <BBM>: DonÕt register components from QuickTime if
; weÕre booting on a 68000.
; <39> 7/22/92 csd #1018711: If script extensions canÕt be found in the Extensions
; folder, change <26> added a check for the System Folder. On
; Install 1 disks, though, we donÕt even have that; everything is
; at the root. So weÕll also check there. This is required so WSI
; and WSII systems can have Install 1 disks.
; <38> 6/27/92 DTY #1033818: We decided to leave the Gibbly the current resource
; map after all, so CurMap needs to be changed to SysMap before
; LoadDSAT can be called.
; <37> 6/24/92 DTY #1033818 <csd>: Undo <17> since 'boot' 2 now puts the Gibbly
; underneath the system resource map before heading into 'boot' 3
; so that the system will now always be the top resource map.
; <36> 6/15/92 csd #1032429 <gbm>: Added the file type 'vbnd' to the list of types
; from which INITs are run. These are Telephone Tools from the
; Comm Toolbox Telephone Manager.
; <35> 5/28/92 DTY #1030972: After 'DSAT' 0 is set up, look at a bit in low memory
; to see if 'boot' 2 could find a Gibbly or not. If it couldnÕt,
; the bit is set, which means that this code should bring up the
; error alert saying that the disk is too old.
; <34> 4/29/92 DTY #1027105: Roll out changes from <27>. The script extensions were
; being loaded, but seconary inits, like Akiko and
; InputBackSupport were still being disabled since theyÕre just
; normal INITs. Making them work would take a lot of hacking
; around, and that doesnÕt give us a nice general solution anyway,
; so just donÕt try to fix the problem at all.
; <33> 4/23/92 DTY Fix a bug in the linked patch extension mechanism. (I TOLD you
; it wasnÕt tested.) Set up D5 with a pointer to the linked patch
; loader so that linked patch extensions will work.
; <32> 4/20/92 DTY #1024149: DonÕt prevent DAL from loading if AppleTalk is off.
; <31> 4/20/92 JSM Moved this file from BootCode.a to Boot3.a, keeping all
; revisions.
; <30> 4/17/92 DTY Add mechanism to load linked patch files from the Extensions
; folder. Conditionalized for theFuture. No, I didnÕt test this
; change. I donÕt have an 'lpch' file to test with. And itÕs not
; theFuture yet.
; <29> 4/16/92 DTY Always include ResourceMgrPriv.a (in case this file is used for
; a Gibbly), and donÕt include LAPEqu.a any more, since the dummy
; LAP routine went away.
; <28> 4/15/92 JSM Roll-in changes from SuperMario to support their ROM gibbly,
; should not change System build. Take out some leftover revision
; <28> comments from when part of this file lived in
; StartSystem.a.
; <27> 4/13/92 DTY #1027105,<csd>: Script extensions should be considered part of
; required system software, and should not be disabled when the
; shift key is held down if Roman is not the primary script.
; Also, removed changes from revision <12>, AppleTalk does the
; right thing now.
; <26> 4/2/92 csd #1018711,<FM>: Change the LoadINITFilesInFolder routine to look
; in the System Folder if thereÕs an error trying to get the
; Extensions Folder when loading script extensions.
; <25> 4/2/92 DTY #1025555,<BBM>: When this file was part of StartSystem.a,
; MakeSysHeapGrowable was done way early in the boot process. It
; even does it twice. My worries about doing this so early in the
; last change are therefore unfounded. Move the first call to
; MakeSystemHeapGrowable back to StartSystem.a so that Gibblies do
; not get closed out. Get rid of the check around the second
; MakeSystemHeapGrowable.
; <24> 4/1/92 DTY #1025555,<FM>: Add A/UX support.
; <23> 3/27/92 DTY #1025567: Call _RsrcZoneInit before growing the system heap for
; the Process Manager to blow away any resources in the
; application heap that will get trashed by the call to
; _SetAppBase.
; <22> 3/26/92 DTY #1024282,<gbm>: I took the MoveHHi out of LinkedPatchLoader, so
; we donÕt need to keep so much stack space in memory all the
; time. Go back to the way it was before <19>.
; <21> 3/25/92 FM last checkin was #1025326
; <20> 3/25/92 FM Rolled in code from StartSystem.a. Now StartSystem.a only
; contains code to load a gibbly. BootCode.a (the gibbly) now
; takes care of all startup initialization.
; <19> 3/20/92 DTY BLT: Since the linked patch loader now calls _MoveHHi, VM is
; hanging with a double bus fault because the stack pointer is
; being moved to a paged out page again. Bump up the stack size
; needed for boot.
; <18> 3/16/92 DTY #1024540: Load 'pext' (El Kabong printing extensions) files from
; our special folders.
; <17> 3/3/92 DTY #1023670: The system 'boot' 3 needs to call _UseResFile before
; loading linked patches. This is because MacsBug resets CurMap to
; be the reference number of TopMapHndl, which could be a Gibbly
; calling the systemÕs boot code. This causes the linked patch
; loader to fail since it might not find any 'lpch' resources in
; the Gibbly.
; <16> 2/18/92 DTY Use d5 as a flag meaning that we had to implement StripAddress
; ourselves. If we had to relocate the boot code, check this flag
; to determine if we patched StripAddress. This lets Scruffy
; work.
; <15> 2/11/92 DTY Release the 'lodr' resource after linked patches have been
; loaded. This frees up about 2K in the system heap.
; <14> 2/11/92 DCL Changed the name of include file TSMEqu.[aph] to
; TextServices.[aph] for better read-ability.
; <13> 1/23/92 csd Make sure that enough pages are in memory before we move the
; supervisor stack pointer when relocating the boot world. If a
; stack operation causes a page fault, it creates a double bus
; fault, guaranteed.
; <12> 1/19/92 DTY Add a bunch of skanky code to prevent network code from being
; loaded if AppleTalk is turned off: Set up a fake LAP manager,
; and donÕt load DAL, AppleShare, or FileShare. (And just think
; about how 7 Up had to do this without changing the boot code!)
; Also get rid of NewROMCheck since this is done implicitly by the
; Gibblies.
; <11> 1/17/92 DTY DonÕt set up StkLowPt when relocating the boot world. Setting it
; causes the stack sniffer to fire.
; <10> 1/14/92 csd If VM adds memory the machine, relocate the boot world (code,
; stack, globals) to the new MemTop/2 area. This is because the VM
; code costs memory in the System heap, and CubeE no longer has
; room to boot on a 2 megabyte machine. Also, move the BootGlobals
; record and other equates to BootEqu.a so we donÕt have to keep
; the StartSystem.a and BootCode.a versions in sync.
; <9> 12/12/91 csd #1017421: with bal, loading the components from the QuickTime
; init because it wonÕt since the Component Manager is implemented
; already. Load components from the System file before we load
; init files. This doesnÕt work yet because the component manager
; canÕt handle 'thng' resources which come from a resource file
; with the refnum 0, which is what HomeResFile returns for the
; System.
; <8> 12/10/91 JH Oops, forgot to fill out the script language record before
; sending it to SetTextServiceLanguage.
; <7> 12/9/91 JH Added a little subroutine called TellTSMScriptAndLanguage. It
; gets called right after _AddScriptFonts and its purpose is to
; tell the text service manager what the system script and
; language is.
; <6> 11/23/91 YK Removed RegisterComponetFile calls. Added ComponentSearch at the
; end of LoadINITFiles.
; <5> 11/15/91 DTY Change the resource ID of the 'lodr' resource to match the ones
; in the Gibbly ERS.
; <4> 11/12/91 DTY Pass off a pointer to the 'ptbl' resource to the linked patch
; loader. Change type of linked patch load resource to 'lodr'.
; <3> 11/11/91 DTY The linked patch loader has been moved to the 'pldr' 0 resource
; for CPU Gibblies. Get this resource and jump to it instead of
; importing the label and jsrÕing.
; <2> 11/8/91 DTY Adding a comment describing why this file is here.
; <1> 11/8/91 DTY first checked in
;
; Change history from StartSystem.a:
;
; <56> 11/4/91 YK Register components in the INIT loading loop.
; <55> 11/4/91 JSM Take out SysPrivateEqu.a again.
; <54> 10/28/91 SAM Added a default define of false to has3rdFloppy.
; <53> 10/28/91 SAM/KSM Rolled in Regatta file:
; On Spike with caches diabled, we patch the MFM WrData vector of
; the Sony driver so we can use an updated timing constant in the
; Write code. The original constant is *barely* within spec and
; with caches disable it is no longer even close.
; Changed CheckFor040CacheInhibit to use the hwPriv call to push
; the caches, added a clock rate calculation to determine the
; amount of adjustment TimeDBRA will require with the caches off
; on the differently clocked 040s. Added a Terror2 (ROM minor
; version 17) check to the Zap PRAM routine so it will work on
; Zydeco.
; Updated the kNo040CacheTimeDBRA value.
; Slam a slower/lower TimeDBRA when the 040 caches are inhibited.
; (jmp) Make the System cmd-opt-r-p PRAM Reset work on TERROR
; machines to fix a TERROR bug.
; Changed HighestSupportedBoxFlag to Eclipse33.
; Added code to inhibit the 68040 caches if the high bit of the
; MMFlags byte is set (PRAM 8A).
; Add back the check for Gestalt after loading VM cuz if VM does
; not load, Gestalt is not yet implemented on non IIci ROM
; machines.
; Adding free memory checks after VM loads.
; Removed the previous revision -- Macsbug has been fixed to load
; in copyback!
; Inhibited all 040 caches while loading Macsbug cuz its too
; brain-damaged to load in copyback.
; <52> 9/16/91 JSM Cleanup header, donÕt include SysPrivateEqu.a (already in dump
; file).
; <51> 7/2/91 JSM Remove obsolete 7.0 related SysVers conditionals.
; <50> 6/12/91 LN added #include 'InternalOnlyEqu.a'
; <49> 6/11/91 gbm Take out conditional for Regatta
; <48> 4/13/91 stb dty, BRC#86692: Replace WhichCPU (borrowed from ROM) with
; HandleMacIIWith030. Now handle exactly one case where we help
; accelerators be VM-capable.
; <47> 4/2/91 SAM Bumping HighestSupportedBoxFlag for Regatta build.
; <46> 3/31/91 csd dba: Changed the test for 040 in the WhichCPU routine so that it
; doesnÕt jam 0 into the CACR, thereby possibly nuking any data
; which has not been flushed out of the cache.
; <45> 3/13/91 stb bbm, #83253: setup and use new ExpandMem global
; emMinSysHeapFreeSpace which specifies how much elbow room to
; leave in the system/process mgr heaps.
; <44> 2/19/91 gbm csd, #Go5 approved: Make sure _MemoryDispatch is NOT implemented
; on machines without PMMUs. Also fix the related bug in the ci
; ROM that sets MMUType wrong.
; <43> 2/15/91 gbm stb & dba, BRC # 82829: Fix the WhichCPU routine so that is
; stops turning off data cache and data bursting on '030s
; <42> 2/11/91 stb gbm, WS #stb211: change BSR.S back to BSR so MacsBug wonÕt die
; if you bail during install (by holding down the mouse button).
; Disassembler, too.
; <41> 2/11/91 stb gbm, BRC # 82423: implement StripAddress early enough to use
; when installing VM
; <40> 1/29/91 csd stb, Whiteboard Bug: Moved the SetDefaults code to an earlier
; position so that it executes before code that uses the
; variables.
; <39> 1/23/91 stb TED,81551: test a result code before BCCÕing.
; <38> 1/19/91 stb & DC (& dfh for some of it) change 'dbex' id; adjust file cache
; allowance; coordinate upward and downward growth limits.
; <37> 1/14/91 stb & mda; more net booting stuff; disable extension disabling if
; desired; do DoWeHaveEnoughRAMToBoot earlier; give file cache a
; little less BufPtr room. add culprit names for VM, Debugger,
; Disassembler; jam CPUflag to support 3rd-party processors for
; VM.
; <36> 12/18/90 stb & JDR; add error check after _MemoryDispatch.
; fix infinite loop in MakeSysFree if couldnÕt get desired amount.
; <35> 12/15/90 stb & KSM; move the currently-executing filename to avoid conflict
; with INITs which check CurApName to see if itÕs post-boot time.
; Replace error 106 with 25. Remove _MemoryDispatch declaration.
; <34> 12/13/90 stb & gbm; no longer load AppleTalk from a file.
; Use source to GetDefaultStartup to avoid problem on Plus.
; Reserve 100K for post-boot allocations by Process Mgr & Finder.
; <33> 12/12/90 stb & gbm; pass bufPtrLimit to LoadFileSystemCache code
; & dba; added 'appe' (background app) to the list of boot-executables.
; & bbm; add Cmd-Option-pr to reset PRAM on Plus, SE, II, Portable
; & k s; add net booting hooks
; <32> 11/15/90 stb & JDR; move dsBufPtrTooLow to SysErr.a
; <31> 11/9/90 dba & JSM; move 8¥24 GC loading before script system loading
; <30> 11/1/90 dba & stb; some misc. cleanup; fix bug where we were checking
; against the wrong value for the barrier; fix obscure error
; handling bug in NewPtrStartup; add NewPtrStartup for post-boot
; that returns an error; add an ellipsis on the end of long file
; names, instead of relying on smart code in the DSAT; put in the
; file name for all files opened outside the system file, not just
; for files with INIT resources
; <29> 10/31/90 dba & csd; add code to load the 8¥24 GC support code
; <28> 10/30/90 stb & BBM; make booting safer and more predictable in low-memory
; conditions.
; <27> 10/22/90 JJ Rex V8: Change all box flag references to use boxMacLC. Get rid
; of boxElsie and boxElsieV8.
; <26> 10/1/90 dba add innocuous value for location 0
; <25> 9/25/90 SAM Bumped highestBoxFlag to ElsieV8.
; <24> 9/22/90 gbm (with dba) change the routines that could kill ApplZone so that
; they do InitApplZone to get rid of the old contents
; <23> 9/16/90 gbm Fix detatching of system INITs. I don't think it ever worked...
; <22> 9/10/90 dba fix name copy bug
; <21> 8/27/90 VL (actually dba) set TheZone to SysZone when doing
; MakeSystemHeapGrowable since the application heap goes away.
; <20> 8/10/90 dba load A/ROSE and AppleTalk; this obsoletes INIT 18 and prevents
; the need for INIT 16
; <19> 8/6/90 stb add test for at least 1.5MB to make sure we can boot 7.0
; <18> 7/20/90 dba get rid of PTCH -1
; <17> 6/22/90 dba (with emt) move this code onto the stack to avoid fragmenting
; the system heap
; <16> 6/11/90 EMT Moved alternate trap dispatcher loading from patch files.
; <15> 5/29/90 DDG NEEDED FOR SIXPACK: Changed all the sixpack conditionals from
; six-point-oh-seven to six-point-oh-six.
; <14> 5/11/90 PKE NEEDED FOR SIXPACK: if this file is used for 6.0.6:
; Conditionalized early loading of script systems (see <9> and
; <13>) on SysVers >= $700. ALSO (for 7.0 only): Added call to new
; Script Mgr _AddScriptFonts routine after all INITs.
; <13> 5/5/90 PKE Added call to Script Mgr _InitScripts (new) after script system
; installation.
; <12> 4/25/90 dba change MMU check in LoadVM section (also add feature to load
; MacsBug before VM)
; <11> 4/20/90 dba check to see that the Shift key is the only key held down for
; Extensions Disabled
; <10> 4/20/90 dba close QD port much earlier; it isnÕt doing anyone any good; do
; InitApplZone for each INIT file; rely on patch to SetAppBase to
; do InitApplZones
; <9> 4/19/90 dba add support for Script Systems; increase system heap size
; <8> 4/19/90 dba make StartupScreens and Disable Extensions work
; <7> 4/18/90 dba change bsr.s to bsr (I will never check in w/o building)
; <6> 4/18/90 dba change branch from pl to mi to fix MakeSysFree bug (INITs were
; not being loaded); restuff dirID to make setting of the noINITs
; bit work right
; <5> 4/17/90 dba fix bug with InitApplZone stuff
; <4> 4/16/90 csd save registers around calls to ptch and PTCH resources since
; they donÕt obey the register saving conventions.
; <3> 4/11/90 dba put dynamic system heap size code for the Plus and SE back here;
; do InitApplZone before each INIT, instead of after each
; MakeSysFree; detach ourselves so we can support remote booting
; closing the System file and opening a new one
; <2> 4/10/90 dba fix bugs in MakeSysFree (wrong register d2 vs. d0 and possible
; error where size is odd)
; <1> 4/9/90 dba new today
;
; Change History from data fork of System file:
;
; <5> 3/22/90 dba change name of LoadPatch to LoadLinkedPatches
; <4> 3/21/90 dba take out the lingering Debugger statement
; <3> 3/21/90 dba change to work with new boot blocks for 7.0
; <2> 12/28/89 dba use MAIN instead of PROC to get dead code stripping; also get
; rid of wierd header that was required by a strange build rule in
; the old Make file; a corresponding change was made in
; SysObj.Make
; <1.5> 11/17/89 dba got rid of checks for 64K ROMs
; <1.4> 10/14/89 EMT Always load in RAM cache in system 7.
; <1.3> 6/5/89 EMT One more try.
; <1.2> 6/2/89 EMT Fixed coding errors in 1.1.
; <1.1> 6/1/89 EMT Removed ROM69 stuff. Bootstrap StripAddress if it doesnÕt exist.
; Use StripAddress before executing 'PTCH's.
; <1.0> 11/16/88 CCH Added to EASE.
; <S174> 4/10/87 bbm Save off the A5 world for the inits. (Some inits relied on
; CurrentA5 to be set up.)
; <S145> 3/27/87 bbm The algorithm that S115 used to grow the heap was to enlarge the
; heap by 16k or the size of the patch - whichever was bigger.
; What you really want is 16k free in addition to the size of the
; patch.
; <S128> 3/23/87 JTC On 64K ROMs be sure not to use nonexistent traps (such as
; SizeRsrc) or resize heap (since boot blocks are loaded at 64K).
; <S115> 3/19/87 JTC Ensure sufficient sys heap space before loading patches, using
; SizeResource to figure the local min. Then guarantee MinSysExtra
; space after loading last one. Code borrowed from INIT=31.
; <S109> 3/18/87 bbm Added the code for ÔPTCH $FFFFÕ. This enables general patches
; for all machines before the patches are read in by ÔPTCH 0Õ and
; general patches after the patches are read in by ÔPTCH $FFFFÕ.
; <S108> 3/17/87 bbm For system heaps larger than 58k, rom69patch needed to move the
; boot code (the boot code is loaded in at $10000). Since the boot
; code has moved, the return address on the stack should be
; modified. If you change the nature of the stack Ñ which rom69fix
; depends on - you must also modify rom69fix.a.
; <P029> 1/22/87 JTC JTC The above dates should surely be Ô86 and the res type is now
; 'PTCH', despite the above comments. This change is to
; accommodate the new PTCH=0 patch file for all systems.
; 11/20/86 BB Changed resource type for patch files from 'PTCH' to 'ptch'.
; 11/15/86 BB New today.
;
; Change History from INIT 31:
;
; <2> 2/19/90 sad <version 5>
; look into Extensions and Control Panels folders using Folder
; Mgr; use 1-deep resource calls instead of 64K ROM-compatible
; hacks; got rid of d7 hack for 64K ROMs; assures MinSysFree after
; last INIT file instead of before first
; <1.4> 11/17/89 dba got rid of checks for 64K ROMs
; <1.3> 6/19/89 CCH Removed check for files of type 'mntr' from version 1.2.
; <1.2> 2/21/89 CCH Added 'mntr' type to list of files that contain INITs.
; <1.1> 1/17/89 CCH Merged changes from 6.0.3.
; <1.0> 11/16/88 CCH Added to EASE.
; <S424> 3/15/88 DBG Prevent invisible INIT files from running
; <S393> 2/12/88 JRM Use fndrInfo bit to eliminate extra OpenResFiles. Set the bit if
; no INIT resources are found for a file. Check the bit before
; calling OpenResFile
; <SB293> 10/2/87 DAF Added an InitGraf before the InitPalettes so that all gDevices
; will be active.
; <S285> 9/21/87 DAF Changed the ROM85 test in s277 to test MacII or greater, rather
; than equal.
; <S277> 9/16/87 DAF Added InitPalettes here before INIT files are loaded. This
; causes the data structures to be allocated early rather than
; during the first init that calls _InitWindows.
; <S173> 4/10/87 JTC Fix CDEV to be cdev.
; <S114> 3/19/87 JTC Fix to get 16K min in sys heap even if no RDEV,INIT,CDEV files.
; Also, look for CDEV files too.
; <S9> 2/14/87 JTC Call InitApplZone after SetApplBase to get initialation
; attendant thereto.
; <S6> 1/5/87 JTC Add new resource 'sysz' comprising just one long word to request
; said amount of system heap space. Put code into inner loop of
; loading and executing INITs below to guarantee #MinSysExtra
; (borrowed from start code) free space at every execution.
; 8/4/86 DLD Converted source to MPW.
;
; System 3.1
;
; 2/8/86 JTC&LAK Fixed bug in patching return address into boot blocks after the
; boot blocks have been moved. Also added a BCLR to assure that
; the half-way point in memory is even after the DIV by 2.
; 2/5/86 LAK Fixed bug for Shuffle: return address needs to be updated after
; stack move.
;
; for InfoSphere
;
; 1/7/86 LAK On old ROMs: if not called from $10000 space or BufPtr has been
; moved below MemTop/2 + 1K already then punt the normalization.
; Someone has probably already 'normalized' the world, hopefully
; correctly.
;
; System Tools Disk for Plus
;
; 12/10/85 LAK Modified to look for files of both INIT and RDEV types.
; 12/6/85 ELR New Today
;
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
; equates
supportsMFM equ 1
If &type('has3rdFloppy') = 'UNDEFINED' Then
has3rdFloppy: equ 0
EndIf
load 'StandardEqu.d'
include 'MMUEqu.a'
include 'BootEqu.a'
include 'EgretEqu.a' ; <15>
include 'Folders.a'
include 'GestaltEqu.a' ; <33>
include 'HardwarePrivateEqu.a' ; just for hwCbAUX
include 'LinkedPatchMacros.a' ; For kROMVersion equates <10>
include 'ReliabilityEqu.a' ; just for RelPRAM <33>
include 'ResourceMgrPriv.a' ; for SetupResourceFileAttributes & Resource Override traps <28> <29>
include 'ScriptPriv.a' ; <13>
include 'ShutDown.a' ; just for _SDRestart <33><SM9>
include 'SonyEqu.a' ; <11>
include 'TextServices.a' ; so we have SetTextServiceLanguage <14>
include 'UniversalEqu.a' ; <15>
MACHINE MC68020 ; <SM28>
_AUXDispatch opword $ABF9 ; <24> A/UXÕs trap dispatch *** move to Traps.a
auxSecondaryInit equ 36 ; <24> Parameter for _AUXDispatch
auxExtraDebuggerSize equ $1c00-debuggerGlobalSize ; <24> Amount of additional storage space required by A/UX for MacsBug
bFInvisible equ 7 ; bit in ilFlUsrWds+fdFlags which means an invisible file
bFNoINIT equ 7 ; bit in ilFlUsrWds+fdFlags+1 which means no INIT resources
vmDebugSignature equ 'JB' ; magic number to debug VM
bbVMDebugSignature equ bbPageFlags ; boot blocks offset of magic word to debug VM
kNo040CacheTimeDBRA25MHz equ 1560 ; # of DBRA's per ms with 25MHz 040 caches inhibited <8>
kNo040CacheTimeDBRA33MHz equ 1513 ; # of DBRA's per ms with 33MHz 040 caches inhibited <9>
k040CyclesPerDBRA equ 4 ; # of cycles it takes an 040 to execute a DBRA <9>
kNoCacheWriteAdj equ $30EA ; No Caches Write Delay constant <11>
kBootStackSizeNeeded equ $2000 ; this many bytes of stack should be in physical memory <12> <19> <22>
kNetBootNameID equ -16507 ; name of NetBoot file <33>
kNetBootProcID equ -16507 ; id of the net boot proc resource <33>
kNetBootDriverRefNum equ -50 ; refnum if we are to load the net booter <33>
kAROSENameID equ -16501 ; name of A/ROSE file
kAppleTalkNameID equ -16500 ; name of AppleTalk file
k8Dot24GCNameID equ -16454 ; name of 8¥24 GC file <29>
kLinkedPatchFileID equ 'lpch' ; <30> File type containing a bunch of 'lpch' resources.
kPatchLoaderResourceType equ 'lodr' ; Resource type containing linked patch loader
kPatchLoaderResourceID equ -16385 ; Resource ID of resource containing linked patch loader
kPatchTableResourceType equ 'ptbl' ; Resource type containing patch table ranges
kFileShareCreator equ 'hhgg' ; <12>
kAppleShareCreator equ 'afps' ; <12>
kDALCreator equ 'dald' ; <12>
IF forROM THEN ; <28>
SysVersForROM equ $0710 ; <28> jam Cube-E system version into SysVersion lowmem for now
kROMVersionPlus equ $0075 ; <28>
kROMVersionSE equ $0276 ; <28>
kROMVersionII equ $0178 ; <28>
kROMVersionPortable equ $037A ; <28>
kROMVersionIIci equ $067C ; <28>
kROMVersionSuperMario EQU $077D ; <28>
ENDIF ; <28>
BootCode MAIN
; Registers passed in from boot blocks:
; A3 = handle to this resource
; A4 = dirID of the startup application (for pre-7.0 systems; used by the remote booting INIT)
; A5 = pointer to globals (SP + 400)
; A6 = pointer to boot blocks (used by the remote booting INIT)
move.l a3,a0 ; get the size of this boot code
_GetHandleSize
lea @continue,a0 ; copy from @continue to the end of the boot code
lea BootCode,a1
sub.l a0,a1 ; get BootCode-@continue
add.l a1,d0 ; fix up size
sub.l d0,sp ; make room on the stack
move.l sp,a1 ; copy onto the stack
_BlockMove ; move it up
jmp (a1) ; pass control there
@continue
move.l a3,-(sp) ; get rid of the resource
_ReleaseResource ; and continue with booting as normal
move.l ROMBase,a0 ; point into a safe place in ROM
add.l #$10000,a0 ; 64K into the ROM is always safe
move.l a0,0 ; jam this nice value into location 0
move.l sp,CurStackBase ; MacsBug works better if CurStackBase is set up
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
SetUpStartupScreen
; Load everything we need for ÒWelcome to MacintoshÓ or a startup screen.
move.w SysMap,CurMap ; <38> Make the System the current map so the DSAT will load.
moveq #0,d0 ; load DSAT 0
bsr LoadDSAT ; get the handle
move.l d0,d6 ; stash this away to dispose later
;____________________________________________________________________________________
; Process Manager segment tweaks.
;
; Load these 'scod' resource as low as possible in the system heap to reduce
; system heap fragmentation.
;
; Moved this code here so the 'scod's are THE first resources in the heap. Reduces
; fragmentation (7/20/93) SAM <SM28>
kProcessManagerSegmentType equ 'scod' ; Process Manager segment resource type <28>
subq #2,sp ; make room in stack for old resfile id <28>
_CurResFile ; Remember the current resource file, in case weÕre booting from a gibbly <28>
clr.w -(sp) ; id zero is always the system file <28>
_UseResFile ; Work on the System file <28>
lea ProcessManagerSegmentTable,a1 ; Table of Process Manager segments to load low <28>
@loadSegmentLoop ; <28>
move.w (a1)+,d1 ; Get a segment number <28>
bz.s DoneWithSegments ; Been there, done that. <28>
subq #4,sp ; room for handle result <28>
move.l #kProcessManagerSegmentType,-(sp) ; push res type <28>
move.w d1,-(sp) ; push id <28>
_Get1Resource ; Load it in <28>
addq #4,sp ; We donÕt really care about the resource <28>
bra.s @loadSegmentLoop ; go for the next one <28>
ProcessManagerSegmentTable ; <28>
dc.w $BFAC ; MiscSeg <28>
dc.w $BFB0 ; KernelSeg <28>
dc.w $BFB2 ; EPPCSeg <28>
dc.w 0 ; End of table <28>
DoneWithSegments ; <28>
_UseResFile ; The current resource file is on the stack <28>
bsr EraseMyIcon ; Erase the happy Mac a little later (after the processmgr loads) <SM28>
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
ShowStartupScreen
; First, open the resource fork of the startup screen file to look for a 'PICT' (0) resource.
moveq #1,d7 ; no startup screen is up yet
subq #2,sp ; make room for refNum
pea BootGlobals.bootBlocks+bbScreenName(a5)
_OpenResFile ; open the file
move.w (sp)+,d0 ; get the refnum
bmi.s @noResourceFork
move.w d0,-(sp) ; push back the refNum for later closing
subq #4,sp ; make room for handle
clr.w -(sp)
_GetPicture
move.l (sp)+,d0 ; check handle
bz.s @noPICTResource
move.l d0,a2 ; save the handle for later
move.l (a2),a0 ; dereference it
move.l picFrame+botRight(a0),-(sp) ; push the pictureÕs bounds rect
move.l picFrame+topLeft(a0),-(sp)
bsr CenterOnMainScreen ; center a rectangle on the screen
move.l a2,-(sp) ; get the picture handle
pea 4(sp) ; pass the centered rectangle
_DrawPicture
addq #8,sp ; get rid of the rectangle on the stack
moveq #0,d7 ; a startup screen has been displayed
@noPICTResource
_CloseResFile ; close the file (refNum left on stack from above)
@noResourceFork
tst.b d7 ; did we put something up there?
bz.s @done ; yes, we are done
; Now, try the data fork of the startup screen file to look for something to display on the screen.
lea BootGlobals.bootBlocks+bbScreenName(a5),a1
bsr LoadBelowBufPtr
bnz.s @noDataFork
cmp.l #342*512/8,d2 ; is the whole thing there?
blo.s @noDataFork
move.l #((342<<16)+512),-(sp) ; put a rect the size of the original Mac screen
clr.l -(sp) ; on the stack (0,0,342,512) as bounds for a bitMap
bsr CenterOnMainScreen ; center a rectangle on the screen
move.w #512/8,-(sp) ; now push the rowBytes of the bitMap
move.l a2,-(sp) ; and push the base address of the bitMap
move.l sp,-(sp) ; srcBits is here
pea BootGlobals.port+portBits(a5) ; dstBits is the screen
pea 8+bounds(sp) ; srcRect and dstRect is the one we computed
move.l (sp),-(sp)
clr.w -(sp) ; srcCopy mode
clr.l -(sp) ; no maskRgn
_CopyBits
lea bitMapRec(sp),sp ; get rid of our bitMap on the stack
moveq #0,d7 ; a startup screen has been displayed
bra.s @done
@noDataFork
; Now, do the welcome screen.
moveq #dsGreeting,d0 ; put up the greeting
_SysError
@done
IF NOT forROM THEN
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
UnimplementedTrap EQU $9F
MemoryDispatchTrap EQU $5C
SetUpCPUFlag
; HandleMacIIWith030 decides whether the processor is an 030 with MacII ROMs.
; We put it here so that 030 accelerator boards can work where the
; ROM doesn't know how to check for them. We ignore 040's because either the ROM must know about
; them or the vendor is doing some hardware magic to make it work without our help.
bsr HandleMacIIWith030 ; <48>
FixMMUTypeAndKillMemoryDispatch
; The ci ROM has a bug in 32-bit mode which causes MMUType to be set to $FF. So, if MMUType
; is $FF, we set it to the right thing. _MemoryDispatch is mistakenly implemented
; in 32-bit mode on machines where there is no MMU (because of the previous bug....).
; So, for machines without an MMU, weÕll unimplement the call.
; NOTE: The MMUType that we set here is a "best guess", since checking for PMMU vs. HMMU at
; this point is hard to do. We're assuming that accelerator makers will either:
; have this set up correctly before we get here, or set it up correctly later on.
tst.b MMUType ; check if MMUType has been setup
bpl.s @keepAGoin ; if it's positive, it has been
clr.l d0 ; <48>
move.b CPUFlag,d0 ; <48>
lea @DefaultMMUTypes, a0 ; point to our table of defaults
move.b (a0, d0.w), MMUType ; get the default type of MMU
cmp.b #cpu68030, d0 ; are we at least on an '030?
bge.s @keepAGoin ; yes, then assume MemoryDispatch is okay to have around
move.w #UnimplementedTrap, d0 ; no, then set MemoryDispatch be the same as
_GetTrapAddress ; the Unimplemented trap.
move.w #MemoryDispatchTrap, d0
_SetTrapAddress newOS
bra.s @keepAGoin
@DefaultMMUTypes
dc.b NoMMU ; 68000 - no MMU
dc.b NoMMU ; 68010 - no MMU
dc.b HMMU ; 68020 - HMMU (but could be 68851... oh well)
dc.b PMMU030 ; 68030 - '030 MMU
dc.b PMMU040 ; 68040 - '040 MMU
align
@keepAGoin
ENDIF ; NOT forROM
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
; CheckFor040CacheInhibit - If we're on an 040 machine and bit 7 of MMFlags (PRAM byte 8A) is set
; then inhibit the caches (can you say sssloooowwww?) and update TimeDBRA
; according to a calculated Clock rate (25 or 33Mhz currently). <SAM>
CheckFor040CacheInhibit ; <5> SAM
CMPI.B #cpu68040,cpuFlag ; Are we on an 040?
BNE.S @Continue ; -> Nope, do nothing
BTST.B #7,MMFlags ; Check the inhibit all caches bit in MMFlags
BEQ.S @Continue ; -> Leave them enabled
_FlushInstructionCache ; Push both caches back to RAM (FlushICache will do both caches) <10>
MACHINE MC68040 ; Generate 040 MOVEC instructions... <SM28>
MOVEC CACR,D0 ; Get the CAcheControlRegister
AND.L #~((1<<CACR_DE_040)|(1<<CACR_IE_040)),D0 ; Create a mask excluding the DE & IE bits
MOVEC D0,CACR ; Clear DE & IE in the CACR (caches are now inhibited)
MACHINE MC68020
MOVEQ #0,D0 ; Clear D0 <10>
MOVE.W TimeDBRA,D0 ; Get TimeDBRA <10>
DIVU.W #(1000/k040CyclesPerDBRA),D0 ; Compute the clock rate based on TimeDBRA & k040CyclesPerDBRA <10>
CMPI.W #28,D0 ; Pick a value between 25 & 33 <10>
BLS.S @Slam25 ; -> 25 MHz <10>
@Slam33 MOVE.W #kNo040CacheTimeDBRA33MHz,D0 ; Get the 33Mhz constant <10>
BRA.S @SetIt ; -> Set it
@Slam25 MOVE.W #kNo040CacheTimeDBRA25MHz,D0 ; Get the 25Mhz constant <10>
@SetIt MOVE.W D0,TimeDBRA ; Stuff the value
IF NOT forROM THEN ; Do not install this patch when this file is being <28>
; built as a ROM gibbly, the ROM is fixed. <28>
CMPI.B #boxQuadra700,boxFlag ; Are we on a Spike? (Quadra 700) <11><61>
BNE.S @Continue ; -> No. Do not install patch to MFMWrData <11>
LEA EndCachesOffMFMPatch,A0 ; Point to the end of the Patch <11>
LEA CachesOffMFMPatch,A1 ; Load the "Caches are off, fix the floppy MFM write code" patch <11>
MOVE.L A0,D0 ; Make a copy of the patch's starting address <11>
SUB.L A1,D0 ; Calc the size of the Floppy patch <11>
MOVE.L D0,D3 ; Copy the size to D3 <11>
_NewPtr ,Sys ; Get a block of Sys Heap memory <11>
BNE.S @Continue ; -> No mem. Exit <11>
EXG.L A0,A1 ; Swap src w/dest
MOVE.L D3,D0 ; Size
_BlockMove
MOVE.L A1,jMWrData ; Install the patch in the sony Write Data vector <11>
ENDIF ; <28>
@Continue
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
; Install the new dispatcher for systems that need it.
import InstallDispatch
jsr InstallDispatch
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
CheckForExtensionsDisabled
; If the Shift key is held down, disable loading of all Extensions, including VM and INITs,
; and background applications, and Finder Startup Folder.
; Do not allow disabling if a 'dbex' resource is not present. This allows users to ensure that
; their INITs will run (e.g. security packages). <37>
clr.b ResLoad ; no preloads please
subq #4,sp ; make room for function result
move.l #'dbex',-(sp) ; if present, allow user to Disable Extensions
move.w #-16385,-(sp) ; 'dbex' (-16385)
_GetResource
st ResLoad ; restore resLoad to proper state
move.l (sp)+,d0 ; did we get a handle?
bz.s @dontDisable ; no, user wonÕt get to disable
move.l d0,-(sp) ; get rid of the empty handle
_ReleaseResource
movem.l KeyMap,d0-d3 ; get four words worth of keys
bclr #7,d3 ; clear off the power key
bclr #1,d1 ; clear off the Caps Lock key
bclr #0,d1 ; clear off and test the Shift key
bz.s @dontDisable ; Shift key not held down, donÕt disable extensions
or.l d1,d0 ; stray keys held down?
or.l d2,d0
or.l d3,d0
bnz.s @dontDisable ; yes, donÕt disable extensions
bclr #extensionsEnabledBit,ExtensionsEnabledByte ; disable extensions
moveq #dsExtensionsDisabled,d0
bsr BootAlert ; put up an alert if we should
@dontDisable
;___________________________________________________________________________
ResetPRAM
; CheckForResetPRAM: Checks for the Cmd-Option-R-P keys down, and Resets PRAM <33>
; if they are down.
;
; Only do this if weÕre on a Plus ($0075), SE ($0276), II ($0178), or Portable ($037A).
; Reset the extended parameter RAM by invalidating the validity longword.
;
; TERROR ROM note: There is a bug in the TERROR ROM where the cmd-opt-r-p sequence <7> jmp
; sometimes doesnÕt work (a register is being trashed). So, to rectify this problem,
; we go ahead and let the reset fly on TERROR ROM machines even though they are
; IIci overpatches. This problem seems to be most accute on Spikes, so we may
; be able to restrict this code to Spikes only. Still investigating.
;
; *** TO DO:
; reset mouse speed in original PRAM to medium speed on all machines
; KeymapÕs locations for Cmd-Opt-P-R
; Cmd = $37 => bit .15 of D1
; Opt = $3A => bit .2 of D1
; P = $23 => bit .27 of D1
; R = $F => bit .23 of D0
clr.w BootGlobals.resetFlag(a5) ; by default, donÕt reboot
movem.l KeyMap,d0-d3 ; get four words worth of keys
; clear off keys which might be down but we donÕt care about
bclr.l #7,d3 ; clear off the power key
bclr.l #1,d1 ; clear off the Caps Lock key
; test for the keys we do care about, clearing them as we test
; test for only Cmd, Option, and P, taking care of all tests on D1.
eori.l #(1<<15)+(1<<2)+(1<<27),d1
bne @noReset
; the only bit left set should be the R bit, so weÕll change it,
; and then OR everything together, and reset PRAM only if
; everything is clear.
bchg.l #23,d0 ; change the R key bit
or.l d2,d0 ; OR together everything thatÕs left
or.l d3,d0
bnz.s @noReset ; something else is down, donÕt reset PRAM
; now check to see if weÕre on a ROM which needs resetting help
movea.l ROMBase,a0
move.w 8(a0),d2
cmp.w #kROMVersionPlus,d2
beq.s @resetPRAM
cmp.w #kROMVersionSE,d2
beq.s @resetPRAM
cmp.w #kROMVersionII,d2
beq.s @resetPRAM
cmp.w #kROMVersionPortable,d2
beq.s @resetPRAM ; <7> jmp
cmp.w #kROMVersionIIci,d2 ; <7> jmp
beq.s @chkMinorVers ; <7> jmp
bra.s @noReset ; <7> jmp
@chkMinorVers ; <7> jmp
move.b 18(A0),d2 ; <7> jmp
cmp.b #kROMMinorTERROR,d2 ; <7> jmp
beq.s @resetPRAM ; <7> jmp
cmp.b #kROMMinorTERROR2,d2 ; <9> SAM
beq.s @resetPRAM ; <9> SAM
bra.s @noReset ; <7> jmp
@resetPRAM ; stolen from StartInit.a
lea @stuff,a1 ; stuff to write into PRAM
subq.w #RelPram>>16,sp ; allocate buffer on stack
movea.l sp,a0 ; get buffer ptr
move.l #RelPram,d0 ; get #, addr PRAM bytes
_ReadXPram ; read the reliability MGR info
movea.l a1,a0 ; point to table data
move.l (a0)+,d0 ; get PRAM len/addr, point to data
_WriteXPRam ; kill the extended PRAM signature
lea SysParam,a0 ; standard PRAM buffer address
moveq.l #-1,d0 ; mask/data to write
move.b d0,(a0) ; kill the signature in the buffer
_WriteParam ; write the buffer to PRAM
_InitUtil ; Init PRAM
movea.l sp,a0 ; get buffer ptr
move.l #RelPram,d0 ; get #, addr PRAM bytes
_WriteXPram ; restore the reliability MGR info
move.w #-1,BootGlobals.resetFlag(a5)
bra.s @continue
@stuff
dc.l $0004000C ; XPRAM signature len/addr
dc.l 'Gone' ; invalidate XPRam signature with this
@noReset
@continue
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
RememberPhysicalMemTop
; Prior to loading VM, MemTop holds the top of physical memory.
; WeÕll use this later for our reality checking.
move.l MemTop,BootGlobals.physicalMemTop(a5)
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
DoWeHaveEnoughRAMToBoot
; WeÕve got to have at least minRAMNeeded to get 7.0 on its feet. minRAMNeeded was chosen
; for just enough to get Finder up with room for one control panel. Moved earlier in <37> to crash
; before VM or MacsBug soaks up too much memory.
cmpi.l #minRAMNeededToBoot,BootGlobals.physicalMemTop(a5) ; is RAM big enough?
bhs.s @weHaveEnough
moveq #dsNotEnoughRAMToBoot,d0
_SysError
@weHaveEnough
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
IF NOT forROM THEN ; <SM28>
LoadTemporaryStripAddress
; Patch loading depends on StripAddress, so install a temporary version for the time before loading.
; moved earlier in <41>
; This must get stomped by anyone who installs a _real_ StripAddress later.
moveq #0,d5 ; <16> Assume we donÕt patch _StripAddress
moveq #$55,d0 ; check if StripAddress is already implemented
_GetTrapAddress newOS
MOVE.L A0,D1 ; save its address
MOVE.W #$9F,D0 ; get unimplemented trap address
_GetTrapAddress newTool
CMP.L A0,D1 ; are they the same?
BNE.S @done ; yes, it already is implemented
moveq #$55,d0
LEA TemporaryStripAddress,a0
_SetTrapAddress newOS ; StripAddress doesnÕt exist, use mine as a bootstrap
moveq #1,d5 ; <16> Use D5 to mean we patched _StripAddress. Any number will doÉ
@done
ENDIF
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
LoadVMAndDebugger
; Load VM and MacsBug, but do it in a different order if JoeÕs debugging signature is found.
btst #extensionsEnabledBit,ExtensionsEnabledByte
bz.s @done ; extensions disabled means VM and MacsBug are disabled
cmp.w #vmDebugSignature,BootGlobals.bootBlocks+bbVMDebugSignature(a5)
beq.s @forDebugging ; if it is set right, do debugging
@normal
bsr LoadVM ; VM first
bsr LoadDebugger
bra.s @done