From: kdarling@garfield.catt.ncsu.edu (Kevin Darling)
Subject: Re: OSK 2.4 ROM->RAM module copy
Keywords: mvme147 ironics 3234 help modules
Organization: North Carolina State University
Date: Tue, 29 Sep 1992 03:57:57 GMT

trn@warper.jhuapl.edu (Tony Nardo) writes:
>On one of my projects, we are attempting to create a turnkey, ROM-based
>system.  We've noticed, however, that the applications we've written run
>significantly slower out of ROM than out of DRAM.
>
>Is is possible to copy a module from ROM to DRAM, then force the module
>directory to use the RAM-based version of the executable image?  Does
>anyone know of a utility for doing so under OSK 2.4?

Here's some source posted on CIS a couple of years ago:

* The intended use for this program is to transfer an existing ROM
* memory module to RAM for faster execution.
*
* syntax: ramit modulename
*
* The need for this results from the following facts:
* ROM frequently has lower access times than RAM,
* ROM is sometimes only 16 bits wide, while RAM is usually 32 bits wide,
* hardware cache is frequently disabled for 16 bit wide ROM space.
*
* e.g on 20MHz Motorola VME147 68030 board the dhrystone benchmark performs
* as follows:
*
* From ROM: (16 bit wide, 250ns access, cache is off) 1041 dhrystones/sec
* From RAM: (32 bit wide, cache is on) 2500 dhrystones/sec
*
* T.J. Martin Argonne National Laboratory 708-972-8708
* DELPHI username TJMARTIN,  CIS 71541,3611
* 2-JUN-90
*
* NOTE THAT THIS PROGRAM USES THE SYSTEM STATE CALLS: F$Move and F$VModul
* AND HAS THEREFORE BEEN MADE TO BE SYSTEM STATE, AND ONLY EXECUTABLE BY 
* THE SUPER USER.
*
* The memory used by the old module is not released since it appears 
* that releasing ROM to system memory seems to cause problems.
* In addition, the newly established RAM module will not unlink from memory.
* I do not pretend to be some guru about these matters, and have only put
* together something that seems to work.  I would appreciate any comments.
* 
* I have chosen not to perform any I/O for syntax help, prompts, etc. since 
* this is a system state module.
*
* The general approach is:
* 1 - Link to module to transfer
* 2 - Allocate enough system memory for the module
* 3 - Move module to new system memory
* 4 - increment revision level of new module image
* 5 - correct header parity and CRC of new module image
* 6 - verify/make known new module image using F$VModul.
*
 nam transfer a memory module to system RAM
 ttl RAMIT module transfer to RAM

 use             <defsfile>

Edition         equ 1
Revision        equ 0
StackSize       equ 512
Typ_Lang        equ (Prgrm<<8)+Objct
Attr_Rev        equ (ReEnt<<8)+(SupStat<<8)+Revision

 psect   ramit,Typ_Lang,Attr_Rev,Edition,StackSize,Start

Start:
 movem.l d0-d7/a0-a6,-(sp)
 move.w  #0,d0           set module type any
 movea.l a5,a0           point to module name in command line
 OS9     F$Link          link to it
 bcs.s   getout
* Note, we are not checking CRC of old module, will use it regardless
 movea.l a2,a3           save original module pointer in a3
 move.l  M$Size(a3),d0   get module size
 OS9     F$SRqMem        request that much system memory
 bcs.s   unlink
* a2 now points to area for new module
 movea.l a2,a4           save new module start in a4
 movea.l a3,a0           put old module start in a0
 move.l  M$Size(a3),d2   set number of bytes to move
 OS9     F$Move          move module to new area
 bcs.s   badnew
 movea.l a4,a0           put new module pointer in a0
 addq.b  #1,M$Revs(a0)   bump up rev level of new module
 OS9     F$SetCRC        fixup header parity and module CRC
 bcs.s   badnew
 move.l  M$Size(a4),d1   get module size
 move.l  #0,d0           beginning of module ID?
 OS9     F$VModul        verify module, make it known
 bcc.s   unlink
* unlink from the replaced module, not sure what this really does
badnew
 movea.l a4,a0           put new module ptr into a0
 move.l  M$Size(a0),d0   get number of bytes in module
* memory allocated in system state is not returned at exit, we must do it
 OS9     F$SRtMem        return new memory since we have failed
unlink
 movea.l a3,a2           set pointer to old module
 OS9     F$UnLink        unlink from old module
getout
 movem.l (sp)+,d0-d7/a0-a6
 OS9    F$Exit
*
 ends