machine 68020 ****************************************************************************** * VBR2FAST v1.0 (9.2.1999) - © 1999 Simone Bevilacqua ****************************************************************************** * INFO moves the VBR to FAST memory; * if VBR has already been moved with VBR2FAST itself, the old * VBR is restored * NOTE cli only ****************************************************************************** KWD0 = "vBr2" KWD1 = "fAsT" start when Init[] ;init when #-1<>GetVBR[] ;get VBR move.l d0,CurrVBR ;store it when ChkPatch[d0] ;chk if already VBR2FASTed RestoreVBR[CurrVBR] ;if so, restore prev VBR Print[#TxtTitle] Print[#TxtSuccess1] owhen MkVecTab[CurrVBR] ;else build new tab Print[#TxtTitle] Print[#TxtSuccess0] othw ;if not enough mem Print[#TxtTitle] Print[#TxtNoMem] ;show err msg ewhen othw ;if 68000 Print[#TxtTitle] Print[#Txt68000] ;show err msg ewhen ewhen end rts ****************************************************************************** * ChkPatch v1.0.0 ****************************************************************************** * INFO checks if the VBR has already been VBR2FASTed * SYN V2Fed = ChkPatch[CurrVBR] * d0.l a0.l * IN CurrVBR current value of VBR * OUT V2Fed 0=not patched; ~0=patched ****************************************************************************** function ChkPatch[a0],a0:d0 moveq.l #0,d0 when.s #KWD0=-(a0) & #KWD1=-(a0) moveq.l #1,d0 ewhen efunc ****************************************************************************** * RestoreVBR v1.0.0 ****************************************************************************** * INFO restores the VBR previously patched by VBR2FAST * SYN RestoreVBR[CurrVBR] * a0.l * IN CurrVBR current value of VBR * NOTE when calling this proc be sure CurrVBR has really been output * by VBR2FAST, otherwise... GURU!!! ****************************************************************************** procedure RestoreVBR[a0],d0-d1/a0-a1/a6 clr.l -(a0) ;clr kwd clr.l -(a0) ;clr kwd ChgVBR[-(a0)] ;restore prev VBR movea.l -(a0),a1 ;buf act adr move.l #256*4+20,d0 movea.l 4.w,a6 jsr (-210,a6) ;FreeMem() eproc ****************************************************************************** * MkVecTab v1.0.0 ****************************************************************************** * INFO build the new table of vectors and changes the VBR * SYN ErrCode = MkVecTab[CurrVBR] * d0.l d0.l * IN CurrVBR current VBR * OUT ErrCode 0=ERROR (not enough mem); ~0=OK * NOTE - the new VBR is always longword aligned * - the new vector table has an header of this kind: * VBR-16: actual buffer adr (may not be longword aligned) * VBR-12: CurrVBR passed in input * VBR -8: KWD1 part1 of security keyword * VBR -4: KWD0 part0 of security keyword ****************************************************************************** function MkVecTab[d0],d1-d7/a0-a6:d0.l movea.l d0,a2 ;keep CurrVBR move.l #256*4+20,d0 ;room for 256 vectors+header+algn moveq.l #4,d1 ;FAST only movea.l 4.w,a6 jsr (-198,a6) ;AllocMem() move.l d0,d1 ;buf act adr when ne addq.l #3,d0 ;align at andi.l #$fffffffc,d0 ;longword movea.l d0,a0 move.l d1,(a0)+ ;store act adr move.l a2,(a0)+ ;store CurrVBR move.l #KWD1,(a0)+ ;write security move.l #KWD0,(a0)+ ;kwd move.l a0,d0 ;new VBR expire d1=#255 move.l (a2)+,(a0)+ ;copy all vectors nexp ChgVBR[d0] ;update VBR moveq.l #1,d0 ;OK othw moveq.l #0,d0 ;ERROR ewhen efunc ***************************************************************************** * Init v1.0.0 ***************************************************************************** * INFO just some sys inits... * SYN ErrCode = Init[] * d0.l * OUT ErrCode 0=ERROR; ~0=OK * MOD DOSBase dos.library base ptr * StdOut output handle assigned by OS ***************************************************************************** function Init[],d1-d2/a0-a1/a6:d0.l moveq.l #0,d2 ;ERROR lea.l (DosName,pc),a1 moveq.l #36,d0 ;at least KS 2.0 movea.l 4.w,a6 jsr (-552,a6) ;OpenLibrary() move.l d0,DOSBase when.s ne movea.l d0,a6 jsr (-60,a6) ;OutPut() move.l d0,StdOut moveq.l #1,d2 ;OK ewhen efunc,d2 ***************************************************************************** * GetVBR v1.0.3 ***************************************************************************** * INFO gets the current value of the Vector Base Register * SYN VBR = GetVBR[] * d0.l * OUT VBR current VBR * NOTE OldVBR = -1 if the CPU is a 68000 ***************************************************************************** function GetVBR[],a5-a6:d0.l movea.l 4.w,a6 btst.b #0,($129,a6) when.s ne ;if not 68000 lea.l (.excp,pc),a5 jsr (-30,a6) ;Supervisor() othw ;else if 68000 moveq.l #-1,d0 ;ERROR ewhen pop.s ;don't execute movec!!! .excp movec.l VBR,d0 rte efunc ***************************************************************************** * ChgVBR v1.0.0 ***************************************************************************** * INFO changes the value of the Vector Base Register * SYN GetVBR[NewVBR] * d0.l * IN NewVBR value to write to the VBR * NOTE no check on 68k type ***************************************************************************** procedure ChgVBR[d0],a5-a6 movea.l 4.w,a6 lea.l (.excp,pc),a5 jsr (-30,a6) ;Supervisor() pop.s ;don't execute movec!!! .excp movec.l d0,VBR ;write NewVBR rte eproc ******************************************************************************* * Print v1.0.0 ******************************************************************************* * INFO prints a text to the standard output * SYN Print[TxtPtr] * d2 * IN TxtPtr ptr to NULL-terminated text string * REQ DOSBase dos.library ptr * StdOut standard output handle ******************************************************************************* procedure Print[d2],d0-d3/a0-a1/a6 movea.l d2,a0 .findend tst.b (a0)+ bne.s .findend ;find end of string move.l a0,d3 sub.l d2,d3 ;length movea.l DOSBase,a6 move.l StdOut,d1 jsr (-48,a6) ;Write() eproc ****************************************************************************** * data cnop 0,4 DOSBase dc.l 0 StdOut dc.l 0 CurrVBR dc.l 0 DosName dc.b "dos.library",0 TxtTitle dc.b 10,"›1mVBR2FAST v1.0›0m (9.2.1999) - © 1999 Simone Bevilacqua",10,0 Txt68000 dc.b "ERROR: MC68000s don't have the VBR!",10,10,0 TxtNoMem dc.b "ERROR: not enough memory",10,10,0 TxtSuccess0 dc.b "VBR successfully moved!",10,10,0 TxtSuccess1 dc.b "VBR successfully restored!",10,10,0