[comp.sys.amiga] FlushLibs, Now you can have your very own!

carl@umd5.umd.edu (Carl Symborski) (12/04/87)

  So like I finally got my A2000 and now its time to whip up yet another
working Workbench disk from the new masters.  While I was doing this
I did notice that some of the utilities in the Extras disk have been
upgraded since the enhancer release came out.  IconMerge for example can
now both merge and split icons apart.  (Used this to fix the TrashCan.)
Other things have changed as well so its a good bet to copy everything you
normally use inorder to get the latest versions.

  Anyway when upgrading my Startup-Sequence to read the clock I got to 
thinking why I was doing this "loadwb -debug" thing.  All I ever use the
debug menu is for the flushlibs feature.  Back when I had the A1000 I found
it really convenient to be able to toss any drivers I had loaded inorder
to make room for a compile.  Its good for a few other things so I decided
to do the obvious and scratch down my own "flushlibs" command and delete the
"-debug" that I was doing.

  So here they are: flushlibs.asm which can run from the CLI, and
flushlibswb.asm which is a CLI/Workbench combo version.  I started working
on a cute Icon for the WB version... looked like a toilet... but it started
taking more time than I put into writing the code in the first place, I
mean talk about over kill!  If you want to use the WB version, supply your
own Icon.
 
Enjoy!

Carl Symborski

#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar:    Shell Archiver
#	Run the following text with /bin/sh to create:
#	flushlibs.asm
#	flushlibs.uue
#	flushlibswb.asm
#	flushlibswb.uue
cat << \SHAR_EOF > flushlibs.asm
;
; FlushLibs  -  A CLI utility to free as much memory as possible
;
; by Carl Symborski, December 2, 1987;  for the Public Domain
;
; FlushLibs will make an unreasonable (too-big) memory request.
; This will cause AllocMem to kick out any devs/libs/fonts that 
; are just hanging around (hoping to free up enough ram to satisfy
; the request).
;
***************************
	NOLIST
	INCLUDE "exec/types.i"
	INCLUDE "exec/memory.i"
	LIST
        XREF _AbsExecBase
	XREF _LVOAllocMem
***************************
FlushLibs:
	MOVE.L   _AbsExecBase,a6

        MOVE.L   #MEMF_PUBLIC,d1
	MOVE.L   #$FFFFFFF,d0      ; Ask for *lots*
        JSR      _LVOAllocMem(a6)  ; No error checking..

        MOVEQ    #0,d0
        RTS
 	END
SHAR_EOF
cat << \SHAR_EOF > flushlibs.uue
begin 777 flushlibs
M   #\P         #          (    '              /I    !RQY    
M!"(\     2 \#____TZN_SIP $YU      /R   #Z0        /R   #Z@  
&      /R
 
end
SHAR_EOF
cat << \SHAR_EOF > flushlibswb.asm
;
; FlushLibsWb  -  A Workbench/CLI utility to free as much memory 
;                 as possible
;
; by Carl Symborski, December 2, 1987;  for the Public Domain
;
; FlushLibs will make an unreasonable (too-big) memory request.
; This will cause AllocMem to kick out any devs/libs/fonts that 
; are just hanging around (hoping to free up enough ram to satisfy
; the request).
;
***************************
	NOLIST
	INCLUDE  "exec/types.i"
	INCLUDE  "exec/memory.i"
 	INCLUDE  "exec/libraries.i"
 	INCLUDE  "exec/tasks.i"
 	INCLUDE  "libraries/dosextens.i"
	LIST
        XREF     _AbsExecBase
	XREF     _LVOAllocMem
****** WB stuff............
        XREF     _LVOFindTask
        XREF     _LVOWaitPort
        XREF     _LVOGetMsg
        XREF     _LVOForbid
        XREF     _LVOReplyMsg
***************************
FlushLibs:
	MOVE.L   _AbsExecBase,a6

        SUBA.L   a1,a1
        JSR      _LVOFindTask(a6)
        MOVE.L   d0,a4
        MOVEQ    #0,d0            ; flag=0, default, means CLI
        MOVE.L   pr_CLI(a4),d1    ; from CLI or what?
        BNE.S    FromCLI

FromWB: LEA      pr_MsgPort(a4),a0
        JSR	 _LVOWaitPort(a6)
        LEA      pr_MsgPort(a4),a0
        JSR	 _LVOGetMsg(a6)   ; WB message pointer in d0
FromCLI:
	MOVE.L   d0,-(a7)         ; Save message (or CLI flag) for exit...
*****
        MOVE.L   #MEMF_PUBLIC,d1  
	MOVE.L   #$FFFFFFF,d0     ; ask for *lots* of memory
        JSR      _LVOAllocMem(a6)
*****
        MOVE.L   (a7)+,d7         ; ...get saved pointer and
        BEQ.S    NotWB            ; if zero then started from CLI

        JSR      _LVOForbid(a6)
        MOVE.L   d7,a1
        JSR      _LVOReplyMsg(a6)

NotWB:  MOVEQ    #0,d0
        RTS
	END
SHAR_EOF
cat << \SHAR_EOF > flushlibswb.uue
begin 777 flushlibswb
M   #\P         #          (    3              /I    $RQY    
M!)/)3J[^VBA <  B+ "L9A!![ !<3J[^@$'L %Q.KOZ,+P B/     $@/ __
M__].KO\Z+A]G"DZN_WPB1TZN_H9P $YU      /R   #Z0        /R   #
)Z@        /R
 
end
SHAR_EOF
#	End of shell archive
exit 0

perry@well.UUCP (Perry S. Kivolowitz) (12/05/87)

Not that it matters much (well maybe it might) but your program
will cause FaccII to attempt evasive action if run while FaccII
is set to detect low memory situations.

Just something to be aware of.

Perry

joels@tekred.TEK.COM (Joel Swank) (12/08/87)

In article <4626@well.UUCP>, perry@well.UUCP (Perry S. Kivolowitz) writes:
> but your program [flushlibs]
> will cause FaccII to attempt evasive action if run while FaccII
                               ^^^^^^^^^^^^^^
> is set to detect low memory situations.

What does that mean?


Joel Swank
Tektronix, Redmond, Oregon
joels@tekred.TEK.COM