; ; File: MiscPatches.a ; ; Contains: Miscellaneous patches that don't fit anyplace else. Currently contains the following patches: ; ; Patch to _SynchIdleTime to handle idling for File Manager, Edition Manager, Data Access ; Manager, and PPC Toolbox. ; ; InitApplication and CleanupApplication. ; ; Gestalt function for Data Access Manager, Edition Manager, ; Standard File, and AppleEvent Manager. ; ; Copyright: © 1989-1992 by Apple Computer, Inc. All rights reserved. ; ; Change History (most recent first): ; ; 11/3/92 SWC Changed SlotEqu.a->Slots.a and removed INCLUDE of Traps.a. ; 9/3/92 PN Nuke the check for IIci because this is SuperMario. ; 7/14/92 PN Use the real name for PPCTrap ; 5/20/92 TN Moved entry points for Packs 8 ,9, 11, 13, 15 to new files in ; the folder with the corresponding Pack sources. ; 5/16/92 kc Remove PowerPrivEqu.a include. ; 4/15/92 kc Change bsr to jsr. ; 4/13/92 JSM Roll-in changes from Reality: (note: still need to merge in revision <55>) ; <56> 4/7/92 JSM Use more specific equates in place of emPackGlobals everywhere. ; <54> 12/31/91 RB Removed _PowerDispatch trap definition. It is now in Traps.a ; <53> 12/6/91 YK Added _CleanUpApplicationComponents to CleanupApplication. ; (Deja VuÉ) ; <52> 11/21/91 YK Removed _InputUtilsDispatch. ; <51> 10/28/91 SAM/KSM Rolled in Regatta changes. ; <3> 6/14/91 SAM (HJR) Using new PowerMgr record names. ; <1> 5/15/91 SAM Split off from 7.0 GM sources. Added support for power cycling ; at every few SynchIdle calls (for TIM). ; <50> 10/23/91 DTY _CleanUpApplication now calls _GetOverrideMap to determine when ; to stop closing files instead of blindly going on through to the ; System file. ; <49> 10/23/91 YK Added _InputUtilsDispatch for the Input Utilities. ; <48> 10/18/91 JH Fixed dumb error accessing DictionaryMgr handle in ; DictionaryDispatch ; <47> 10/17/91 JH Added _DictionaryDispatch for the dictionary manager. ; <46> 10/17/91 JSM DonÕt use hasPPC conditional. ; <45> 9/19/91 JSM DonÕt use forNuFinder conditional (this was the only file that ; used it). ; <44> 9/18/91 JSM Cleanup header, remove references to hasSplineFonts. ; <43> 6/12/91 LN removed #include 'HardwareEqu.a' ; <42> 2/25/91 dnf dfh, #80720,#82672: Give the File Manager some idle time so it ; can make sure there are enough FCBs available. ; <41> 2/4/91 CL (MR)Moving the cleanup of TrueTypeª caches into cleanup app from ; BassPatches for 7.0. ; <40> 12/14/90 DFH (ksm) DoSevenOhIdle was a head patch to SystemTask. Now it is ; its own trap, SynchIdleTime, and is called by the Process Mgr at ; SystemTask and in idle scheduling time. ; <39> 10/15/90 JSM Use ppcIdleCmd. ; <38> 9/21/90 DDG Added a package handler for picture utilities. ; <37> 9/5/90 ngk Add AppleEventMgr stuff and conditionalizing code more ; <36> 8/17/90 gbm stop using myHasEditionMgr, since the build system now has its ; act together ; <35> 8/6/90 BBH add CommToolbox cleanup code to CleanupApplication as a JSR ; instead of a patch ; <34> 7/31/90 DFH Fixed typos in new CleanupApplication code. ; <33> 7/31/90 DFH Put CleanupApplication's calls in proper sequence. Added Sound ; Mgr and Resource Mgr cleanups. ; <32> 7/25/90 PKE In CleanupApplication, call to CleanupScriptApp replaces code ; that disposed of application itl cache. In InitApplication, add ; InitScriptApp call to set up application-specific Script Mgr ; globals (including itl cache). Include ScriptPriv.a. ; <31> 7/25/90 DFH Include MFPrivate.a to get InitApplication and ; CleanupApplication. ; <30> 7/12/90 STB Moved _DispatchHelper & _ProcHelper patch installation code to ; DispatchHelper.a ; <29> 7/8/90 JSM Pass in pointer to use count instead of offset when calling ; _ProcHelper. ; <28> 7/7/90 JSM Split DispatchHelper and ProcHelper off to {OS}DispatchHelper.a ; so SixPack can use them, general format cleanup. ; <27> 7/2/90 PKE Added code to CleanupApplication that disposes of applicationÕs ; itl2/itl4 cache. ; <26> 6/20/90 DTY Removed ShutdownMgr.a from MiscPatches and made it a stand-alone ; 'lpch' ; <25> 6/19/90 VL Convert various routines for linked patches. ; <24> 6/13/90 JSM Add include of SlotEqu.a and ROMEqu.a to fix BigBang build after ; ShutDownMgr.a changes. ; <23> 6/8/90 ngk Fix bug in PACKHelper, It was trashing A2. ; <22> 5/31/90 ngk Add gestault selector for StandardFile. Changed PACKHelper to ; not need a exit proc. ; <21> 5/2/90 PKE Included 'GestaltPrivateEqu.a' to fix the build. It is now ; needed for ShutDownMgr.a, which is included here. ; <20> 4/24/90 S To Include a Call to PPC at System Task Time. ; <19> 4/20/90 KSM DispatchHelper used to assume that there were no ÒholesÓ in the ; table, even if they were between the first and last selectors. ; With a simple branch (I hope), we can keep this from being a ; problem. ; <18> 3/20/90 EMT Used smaller (and faster) color quickdraw test. ; <17> 3/15/90 JSM Do a JMP instead of RTS from PACKHelper to DispatchHelper. ; <16> 3/10/90 ngk Change Pack11 (Editions Mgr) to use new package dispatcher. ; Added bit to dispatch flags that means selectors are even ; numbers. ; <15> 3/5/90 DVB Only PMgrExit on color machines ha ha ; <14> 2/26/90 JSM Fix Pack13Entry to check for globals. ; <13> 2/26/90 JSM Database Access Manager (PACK 13) now uses PACKHelper. ; <12> 2/24/90 JSM Add support for reentrant locking to PACKHelper. ; <11> 2/21/90 JSM Tighten up DispatchHelper. ; <10> 2/20/90 JSM Change DispatchTable format for DispatchHelper, tweak ; PACKHelper. ; <9> 2/19/90 JSM Add generic package dispatcher PACKHelper, add PPC Browser as ; PACK 9. ; <8> 2/16/90 DVB Add PMgrExit ; <7> 2/15/90 JSM Add generic dispatcher DispatchHelper. ; <6> 2/4/90 DNF Add include of FileMgrPrivate.a ; <5> 1/21/90 ngk Changed gestaltEditionMgr to gestaltEditionMgrAttr ; <4> 1/12/90 CCH Added include of ÒHardwarePrivateEqu.aÓ. ; <3> 1/6/90 ngk Use symbolic names for Edition manager calls ; <2> 1/4/90 JSM Add Gestalt function for 7.0 features. ; <2.4> 12/11/89 GMR Pulled Sony driver Format patch from this file, now in separate ; patch file (FormatPatch.a). ; <2.3> 12/8/89 dnf Reorder equates to make things work ; <2.2> 11/6/89 csd changed ShutDown Manager trap to point to the ShutDown Manager ; dispatcher, instead of the ShutDown Manager init code. ; <2.1> 11/4/89 ngk Added call to DataPublication Quit in _CleanupApp ; <2.0> 11/2/89 dba fixed ShutDown Manager initialization; I am a bad doggie! ; <1.9> 10/31/89 dba moved ShutDown Manager here ; <1.8> 10/16/89 KST Added two traps: InitApplication and CleanUpApplication. ; <1.7> 10/16/89 CCH Commented out EntryTable entries for InitApplication and ; CleanupApplication until the extended trap dispatcher is rolled ; into the big bang build. ; <1.6> 10/11/89 CCH Added _InitApplication and _CleanupApplication. ; <1.5> 10/6/89 JSM Patch SystemTask and _Pack13 for SnarfMan. ; <1.4> 10/1/89 ngk Added DataPublications Idle call to SytemTask chain. ; <1.3> 8/18/89 CCH Removed definition of onMac32. ; <1.2> 8/9/89 ngk Added new safer dispatcher for PACK=11 (DataPublications) ; <1.1> 8/8/89 GMR Fixed conditional testing for new sony driver. ; <1.0> 8/7/89 GMR Adding for first time to EASE. ; PRINT PUSH,OFF LOAD 'StandardEqu.d' INCLUDE 'LinkedPatchMacros.a' INCLUDE 'BTreeEqu.a' include 'MMUEqu.a' include 'BootEqu.a' include 'HardwareEqu.a' include 'FileMgrPrivate.a' include 'GestaltEqu.a' include 'GestaltPrivateEqu.a' ; <21> include 'Slots.a' ; <24> include 'ROMEqu.a' ; <24> include 'EditionsPrivate.a' include 'DatabaseAccess.a' include 'DispatchHelperPriv.a' include 'MFPrivate.a' include 'ScriptPriv.a' ; <32> include 'ResourceMgrPriv.a' include 'PPCPriv.a' ; <39> include 'fontPrivate.a' ; include 'universalEqu.a' include 'PowerPrivEqu.a' include 'Processes.a' include 'TextServices.a' PwrCycCount EQU $AA ; <1> PRINT POP ; ; These patches are installed on all ROM families ; ROMs Plus,SE,II,Portable,IIci ;___________________________________________________________________________________ ; ; Routine: SynchIdleTime bcc0 ; ; Inputs: none ; ; Outputs: none ; ; Can destroy: D0-D2,A0-A1 ; ; Function: Gets called at synchronous idlish time by Process Mgr ; ; Calls FileManagerIdleProc to check FCB allocation. ; ; Calls _EditionBackGroundTask only if the package is loaded ; and some edition files are in use. ; ; Calls DBIdle only if the Data Access manager globals are allocated. ; ; Calls idle routine for PPC Toolbox. ; ;___________________________________________________________________________________ SynchIdleTimeProc PatchProc _SynchIdleTime import FileManagerIdleProc jsr FileManagerIdleProc ; <42> IF hasEditionMgr THEN ; ; Check if we need to call _EditionBackGroundTask ; MOVE.L ExpandMem, A0 ; get expanded memory area LEA ExpandMemRec.emDataPub(A0),A0 ; get em globals location MOVE.L (A0),D0 ; test if allocated BEQ.S @emIdleDone ; if not, no need to do idle MOVE.L D0,A1 MOVE.L EdtnMgrGlobals.firstPubCB(A1),D0 CMP.L D0,A0 ; if no pub control blocks BEQ.S @emIdleDone ; then done MOVE.L EdtnMgrGlobals.nextPollTime(A1),D0 ; if timer has not expired CMP.L Ticks,D0 ; then check for DBIdle BHI.S @emIdleDone SUBQ #2,SP ; place holder for result _EditionBackGroundTask ; call dpBackGroundTask TST.W (SP)+ ; ignore result @emIdleDone ENDIF IF hasDataAccessMgr THEN ; ; Check if we need to call DBIdle ; MOVE.L ExpandMem, A0 ; get expanded memory area MOVE.L ExpandMemRec.emSnarfGlobals(A0), D0 ; get Snarf globals BEQ.S @doneDBIdle ; if not allocated no need to do idle SUBQ #2,SP ; place holder for result MOVE.W #$00FF,D0 ; actually call DBIdle _Pack13 TST.W (SP)+ ; ignore result @doneDBIdle ENDIF ; ; always do PPC idle routine ; MOVEQ #ppcIdleCmd,D0 ; <39> call PPC idle routine _PPC ; PPC trap WITH PMgrRec,PowerDispRec ; BTST.B #0,$DD5 BEQ.S @Done ; no power cycling MOVEQ #IdleMindDisp,D0 ; Set the selector to IdleMind _PowerDispatch @Done BTst.B #$1, ($2409) BEQ.B @skipDriverCall IMPORT PMIdleRelatedDriverCall MACHINE MC68030 Bsr.L PMIdleRelatedDriverCall @skipDriverCall MoveA.L ([$2B6],$288), A0 Move.L A0, D0 BEQ.B @return MoveM.L D1-D3/A1-A2, -(A7) Move $6(A0), D1 MoveQ.L #$0, D2 @loop MoveA.L $14(A0,D2.L), A1 Move.L A1, D0 BEQ.B @continue Move $C8(A1), D0 Clr D3 Cmp D3, D0 BEQ.B @continue MoveA.L $C4(A1), A2 Move.L A2, D0 BEQ.B @continue Jsr (A2) Bra.B @exit @continue AddQ #$4, D2 SubQ #$1, D1 BNE.B @loop @exit MoveM.L (A7)+, D1-D3/A1-A2 @return Rts ENDPROC ; SynchIdleTimeProc ;___________________________________________________________________________________ ; ; Routine: InitApplication bd40 <1.6> ; ; Inputs: none ; ; Outputs: status flag ? (currently unused) in D0 ; ; Can destroy: D0-D2,A0-A1 ; ; Function: Gets called at application launch by Multifinder to set up the world. ; ;___________________________________________________________________________________ InitApp PatchProc _InitApplication ; ; Set up application-specific Script Mgr globals <32> ; SUBQ #2,SP ; space for OSErr result _InitScriptApp ; go set up appÕs script globals ADDQ #2,SP ; always returns NoErr, ignore ; ; All done, return status flag in D0 ; MOVEQ #-1,D0 RTS ; big routine ENDPROC ; InitApp ;___________________________________________________________________________________ ; ; Routine: CleanupApplication <1.6> ; Inputs: none ; Outputs: none ; Destroys: D0/A0-A1 ; Gets called by the Process Mgr's ExitToShell code. The current low memory, traps, ; VBLs, etc. are for the dying application. This is the chance for OS and ToolBox to ; tidy up things that were given to the application. ; BEWARE! The order of operations here is VERY important. This is why you add code ; here, rather than patching this or some other trap. In general, we want to cleanup ; from the top down. For example, since closing the resource files nukes any custom ; code provided by the app (e.g. WDEFs), we must cleanup parts that use the custom code ; (e.g. the Palette Mgr) BEFORE closing the resource files. Similarly, CloseResFiles and ; _BTCleanUp are called before _FSCleanup so _FSCleanup doesn't close the files out from ; under the Btree or Resource Mgrs. ; ;___________________________________________________________________________________ CleanupApp PatchProc _CleanupApplication CLR.L -(SP) ; room for result MOVE.L applZone,A0 ; point to zone hdr MOVE.L A0,-(SP) ; push start ptr MOVE.L (A0),-(SP) ; push zone trailer MOVE.W #sbKillSomeCaches,D0 _SplineMgr ; like _sbKillSomeCaches but with non-quick move ADDQ #4,SP ; ignore result MoveA.L ExpandMem, A0 MoveA.L $64(A0), A0 Tst.L $70(A0) BEQ.B @skipAll SubQ #$8, SP Clr -(SP) Pea.L $2(SP) _GetCurrentProcess Tst (SP)+ BNE.B @dont Clr -(SP) Pea.L $2(SP) Clr -(SP) _InlineAware Tst.B (SP)+ BEQ.B @dont Clr -(SP) Move #$2, -(SP) Pea.L $4(SP) Move #$16, D0 _TSMDispatch AddQ #$2, SP @dont AddQ #$8, SP @skipAll ; ; Clean up Compoents and Component insetances belong to this app. ; _CleanUpApplicationComponents <53> ; ; Clean up the Palette Manager if there is one. ; MOVE.W #selectPMgrExit,D0 ; _PMgrExit _PaletteDispatch ; ; Clean up Sound Manager ; _SndAppDead ; ; Clean up application-specific Script Mgr globals (incl itl2/4 cache) <27><32> ; SUBQ #2,SP ; space for OSErr result _CleanupScriptApp ; go clean up appÕs script globals ADDQ #2,SP ; always returns NoErr, ignore ; ; Clean up Resource Manager. Close resource files from the top of the ; chain down to, but not including, the system file. After this, defprocs ; and any other "system" code from the application chain are suspect. ; NOTE: Could be using ROM routine CloseFiles in ResourceMgr.a. ; @CloseResFiles move.l TopMapHndl, a1 ; start at the top subq #4,sp move.l SysMapHndl,-(sp) ; <50> _GetOverrideMap ; <50> Stop at the first system override file cmpa.l (sp)+, a1 ; down to the system file? beq.s @DoneResMgr ; stop at the system file move.l (a1), a1 ; deref handle to get map move.w MRefNum(a1), -(sp) ; get file refnum from map _CloseResFile ; close said file (sets new TopMapHndl) bra.s @CloseResFiles ; and try again @DoneResMgr ; ; Do BTree Manager clean up ; suba #fscpbLen,sp ; allocate ioPB movea.l sp,a0 ; a0=ioPB moveq #(fscpbLen/4)-1,d0 ; d0=size in long movea.l a0,a1 @BTClear clr.l (a1)+ dbra d0,@BTClear _BTCleanUp ; clean up B*tree ; ; Do File System clean up ; moveq #(fscpbLen/4)-1,d0 ; d0=size in long movea.l a0,a1 @FSClear clr.l (a1)+ dbra d0,@FSClear _FSCleanUp ; cleanup FS adda.L #fscpbLen,sp ; deallocate space rts ENDPROC ; CleanupApp END ; of file