[comp.sources.amiga] v90i061: cVBR - change vector base register, Part01/01

Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator) (02/10/90)

Submitted-by: mjl@alison.at (Martin J. Laubach)
Posting-number: Volume 90, Issue 061
Archive-name: kernel/cvbr

[ uuencoded executable included.  ...tad ]

This is a small tool that will move the exception vector table (on 68010
or higher).

	mjl

#!/bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 1)."
# Contents:  Vbr.Asm Vbr.uu vbr.doc
# Wrapped by tadguy@xanth on Fri Feb  9 15:27:53 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Vbr.Asm' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Vbr.Asm'\"
else
echo shar: Extracting \"'Vbr.Asm'\" \(2540 characters\)
sed "s/^X//" >'Vbr.Asm' <<'END_OF_FILE'
X*
X* Change the vector base register on 68010+
X*
X* by Martin J. Laubach
X*
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
X	incdir "inc:include.i"
X
X	include "exec/execbase.i"
X	include "exec/libraries.i"
X	include "exec/tasks.i"
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
X	xdef	main
X
X	xref	_AbsExecBase
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
Xcall	macro
X	xref	_LVO\1
X	jsr 	_LVO\1(a6)
X	endm
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
Xstdout	equr	d7
XDosBase	equr	a5
XTask	equr	a4
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
Xmain:	move.l	_AbsExecBase,a6
X	lea	DosName,a1
X	moveq	#0,d0
X	call	OpenLibrary		; Open DOSBase to chat with user
X	move.l	d0,DosBase
X	tst.l	d0
X	beq	exit
X
X	move.l	d0,a6
X	call	Output			; get stdout
X	move.l	d0,stdout
X
X	move.l	d0,d1
X	move.l	#SignOn,d2
X	moveq	#SignOnEnd-SignOn,d3
X	call	Write			; say hello
X
X	move.l	_AbsExecBase,a6
X	cmp.w	#33,LIB_VERSION(a6)
X	bls	noversion		; check for the right kickstart
X
X	btst.b	#AFB_68010,AttnFlags+1(a6)
X	beq	novbr			; and the right processor
X
X	move.l	a5,a0
X	lea	getvbr,a5
X	call	Supervisor		; become SUPERMAN!
X
X	tst.l	d4
X	bne.s	already			; vbr already set
X
X	move.l	#$400,d0
X	moveq	#0,d1
X	call	AllocMem		; get memory block for vectors
X	move.l	d0,Memory
X	beq.s	nomem
X
X	sub.l	a0,a0
X	move.l	Memory,a1
X	move.l	#$400,d0
X	call	CopyMem			; now copy the exception vectors
X
X	move.l	Memory,d4
X	move.l	a5,a0
X	lea	setvbr,a5
X	call	Supervisor
X
Xexit0:	move.l	DosBase,a1
X	move.l	_AbsExecBase,a6
X	call	CloseLibrary		; clean up
X
Xexit:	moveq	#0,d0
X	rts
X
Xgetvbr:	move.l	a0,a5
X	movec.l	vbr,d4
X	rte
X
Xsetvbr:	move.l	a0,a5
X	movec.l	d4,vbr
X	rte
X
Xalready:
X	move.l	d4,d5
X
X	moveq	#0,d4
X	move.l	a5,a0
X	lea	setvbr,a5
X	call	Supervisor
X
X	move.l	d5,a0
X	sub.l	a1,a1
X	move.l	#$400,d0
X	call	CopyMem
X
X	move.l	d5,a1
X	move.l	#$400,d0
X	call	FreeMem
X
X	move.l	#Already,d2
X	moveq	#AlreadyEnd-Already,d3
X	bra.s	Panic
X
Xnomem:	move.l	#NoMem,d2
X	moveq	#NoMemEnd-NoMem,d3
X	bra.s	Panic
X
Xnovbr:	move.l	#ProcErr,d2
X	moveq	#ProcErrEnd-ProcErr,d3
X	bra.s	Panic
X
Xnoversion:
X	move.l	#VerErr,d2
X	moveq	#VerErrEnd-VerErr,d3
XPanic:	move.l	DosBase,a6
X	move.l	stdout,d1
X	call	Write
X	bra.s	exit0
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
XMemory:		dc.l 0
XOldTrap:	dc.l 0
X
XDosName:	dc.b 'dos.library',0
XSignOn:		dc.b 'cVBR (c) Copyright 1989 by Martin J. Laubach',10
XSignOnEnd:
XVerErr:		dc.b '*** You need at least version 1.2 of the OS '
X		dc.b 'to use cVBR',10
XVerErrEnd:
XProcErr:	dc.b '*** You really should have an 68010 to run cVBR',10
XProcErrEnd:
XNoMem:		dc.b '*** You haven't got $400 more bytes...',10
XNoMemEnd:
XAlready:	dc.b '*** VBR already changed, reverting to normal',10
XAlreadyEnd:
END_OF_FILE
if test 2540 -ne `wc -c <'Vbr.Asm'`; then
    echo shar: \"'Vbr.Asm'\" unpacked with wrong size!
fi
# end of 'Vbr.Asm'
fi
if test -f 'Vbr.uu' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Vbr.uu'\"
else
echo shar: Extracting \"'Vbr.uu'\" \(912 characters\)
sed "s/^X//" >'Vbr.uu' <<'END_OF_FILE'
Xbegin 664 Vbr
XM```#\P`````````#``````````(```!\``````````````/I````?"QY````$
XM!$/Y```!%'``3J[]V"I`2H!G``"&+$!.KO_$+@`B`"0\```!('8M3J[_T"QY&
XM````!`QN`"$`%&,``+P(+@```2EG``"H($U+^0```*).KO_B2H1F6"`\```$=
XM`'(`3J[_.B/````!#&=XD<@B>0```0P@/```!`!.KOV0*#D```$,($U+^0``_
XM`*I.KO_B(DTL>0````1.KOYB<`!.=2I(3GI(`4YS*DA.>T@!3G,J!'@`($U+5
XM^0```*I.KO_B($63R2`\```$`$ZN_9`B12`\```$`$ZN_RXD/````<)V+6`<<
XM)#P```&U=@U@$B0\```!A78P8`@D/````4UV."Q-(@=.KO_08(8`````````N
XM`&1O<RYL:6)R87)Y`&-60E(@*&,I($-O<'ER:6=H="`Q.3@Y(&)Y($UA<G1IV
XM;B!*+B!,875B86-H"BHJ*B!9;W4@;F5E9"!A="!L96%S="!V97)S:6]N(#$N*
XM,B!O9B!T:&4@3U,@=&\@=7-E(&-60E(**BHJ(%EO=2!R96%L;'D@<VAO=6QDD
XM(&AA=F4@86X@-C@P,3`@=&\@<G5N(&-60E(**BHJ(%EO=2!H879E;BHJ*B!6"
XM0E(@86QR96%D>2!C:&%N9V5D+"!R979E<G1I;F<@=&\@;F]R;6%L"@````/L'
XM````#``````````(````)@```$X```!H````<@```((```"*````N@```-X`&
XK``#H````\@```/P````````#\@```^D````````#\@```^H````````#\MX`L
X``
Xend
Xsize 628
END_OF_FILE
if test 912 -ne `wc -c <'Vbr.uu'`; then
    echo shar: \"'Vbr.uu'\" unpacked with wrong size!
fi
# end of 'Vbr.uu'
fi
if test -f 'vbr.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vbr.doc'\"
else
echo shar: Extracting \"'vbr.doc'\" \(4210 characters\)
sed "s/^X//" >'vbr.doc' <<'END_OF_FILE'
X
X
X     Page 1                cVBR's Documentation                 Page 1
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X                                    RM
X                   (c) Copyright 1989 by Martin J. Laubach
X                            All rights reserved
X
X
X
X
X
X
X
X
X  1. Introduction      
X
X       cVBR is a small tool that will move the exception vector table
X     of the CPU somewhere else than it's supposed to be.  
X
X  2. How to     
X
X       Running vbr once will allocate some memory, copy the exception
X     and interrupt vector table, and then change the VBR to point
X     there.  
X
X       Running vbr a second time will copy the tables back where they
X     are supposed to be, and clear the VBR register.  
X
X  3. Advantages      
X
X       There are two advantages I can think of: first, any program
X     that accesses the exception and/or interrupt vectors directly
X     instead of using the exec functions will cease to work --
X     especially those dirty "hacker type" programs (sorry, folks).
X     This in my opinion, really *is* an advantage.  
X       Second, when fast RAM is available, the new vector tables are
X     allocated there. This should result in faster interrupt and
X     exception processing, especially when there is a lot of DMA to
X     chip memory going on (disk accesses, blitter blittings, overscan
X     screens).  
X
X
X
X
X     Advantages
X
X
X     Page 2                cVBR's Documentation                 Page 2
X
X
X  4. What      
X
X       In this archive, you should find the following files: 
X
X             vbr.doc .... What you are reading right now.
X             vbr.asm .... The source for rm.
X             vbr ........ The executable
X
X
X  5. Where      
X
X       If you have any comments, ideas what could or should be
X     improved, bug reports or just like to chat a bit, please feel
X     free to contact me at one of the following addresses... I just
X     *love* receiving mail! 
X
X       Usenet:  mjl@alison.at 
X                ..!uunet!mcsun!tuvie!alison!mjl 
X
X         or 
X
X       FidoNet: "Martin Laubach" at 2:310/3.14 
X
X
X       Looking forward to reading from you, 
X
X             mjl 
X
X
X
X  6. License      
X
X       This material is (c) Copyright 1989 by Martin J. Laubach -- All
X     rights reserved.  
X
X       It may be distributed freely as long as the following
X     restrictions are met: 
X
X       The distributor may charge a fee to recover distribution
X     costs. The fee for diskette distribution should not be more than
X     the cost to obtain the same diskette from Fred Fish.  
X
X       The distributor agrees to cease distributing the programs and
X     data involved if requested to do so by the author.  
X
X       You may copy and distribute verbatim copies of the program's
X     executable code and documentation as you receive it, in any
X     medium, provided that you conspicuously and appropriately
X     publish only the original, unmodified program, with all
X     copyright notices and disclaimers of warranty intact and
X     including all the accompanying documentation, example files and
X     anything else that came with the original.  
X
X       The author will not be liable for any damage arising from the
X
X
X     License
X
X
X     Page 3                cVBR's Documentation                 Page 3
X
X
X     failure of this program to perform as described, or any
X     destruction of other programs or data residing on a system
X     attempting to run the program.  While I know of no damaging
X     errors, the user of this program uses it at his or her own
X     risk.  
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X     License
X
X
X     Page 4                cVBR's Documentation                 Page 4
X
X
X  7. Road Map    
X
X
X
X        1. Introduction     ....................................    1
X        2. How to    ...........................................    1
X        3. Advantages     ......................................    1
X        4. What     ............................................    1
X        5. Where     ...........................................    2
X        6. License     .........................................    2
X        7. Road Map    .........................................    4
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X     Road Map
X
END_OF_FILE
if test 4210 -ne `wc -c <'vbr.doc'`; then
    echo shar: \"'vbr.doc'\" unpacked with wrong size!
fi
# end of 'vbr.doc'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have the archive.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
Mail comments to the moderator at <amiga-request@cs.odu.edu>.
Post requests for sources, and general dicussion to comp.sys.amiga.