PROGRAM Set040 SOURCE Written in 100% assembler using Macro68 FUNCTION 1. To remap Kickstart V2.04 or greater from ROM into FAST RAM on an Amiga equipped with a 68040 CPU, using the MMU, with optional parameters for greater compatibility between various 68040 boards. An optional switch allows it to patch the Kickstart to stop drives from clicking. This patch will work on any version, including future versions, as it searches the trackdisk.device for the required instruction and changes this instructon before installing the remap. 2. To allow this FASTROM remap to be removed and all resources reclaimed. 3. To load a different Kickstart than the one currently in ROM, and use the MMU to boot into this Kickstart. 4. To manipulate both caches in the 68040 and the two Data Cache modes. 5. To display certain information regarding the setting of some 68040 registers and modes. 6. To switch between the 68040 and 68030 on a Progressive Peripherals & Software 68040 card in an Amiga A3000-25MHZ ACKNOWLEDGEMENTS Thank you to Dave Haynie and Michael Sinz for their answers to my questions regarding the 68040 many times over EMAIL. Thank you to Sean Moore at Progressive and Peripherals and Software for the 'special deal' on the 68040 card in return for distribution of my Sysinfo Program. Thank you to my friend Paul Coward (Digisoft) for a brilliant assembler, Macro68 V3.xxx. Thank you to Fred Fish for his continuing work in distribution of our programs. Without him, distribution would be much more difficult. DOCUMENT FILE The spelling in this document file is in Australian. Spelling in some Countries may vary, but this document is correct. AUTHOR Nic Wilson Nic Wilson Software 138d South Street TOOWOOMBA QUEENSLAND 4350 Australia EMAIL cbmvax!cbmaus!wilson!nic@uunet.uu.net or cbmehq!cbmaus!wilson!nic@cbmvax.commodore.com TELEPHONE +61 76 358539 After Hours Australian Time +61 76 358384 Work Hours Australian Time FAX Same as Work Telephone COPYRIGHT This program, and its source code & document files are Copyright (C) Nic Wilson Software 1991-1992. DISTRIBUTION The program is Shareware and may be freely distributed on the condition that no profit is gained from this distribution either directly or indirectly. A small copying fee, no more than the cost of 2 (two) average 3.5 inch blank disks, (including the supplied disk). Crunching of the executable file is considered a breach of this agreement, due to the fact all current crunchers I have tested fail on the 68040 processor. Archival in the form of 'lharc' type programs is permitted. Commercial companies may distribute this program as a part of a disk of utilities supplied with their 68040 boards without permission, on the condition that I am notified of your intention to distribute, and all documents files are included on disk or printed form exactly as written here. EXCEPTIONS Progressive Peripherals & Software are exempt from the above distribution conditions. Fred Fish is exempt from the above distribution conditions. ARCHIVE The following files are included in the Set040 archive. Set040 - executable Set040.doc - document file MMUSR - executable MMUSR.doc - document file kickspeed - executable kickspeed.doc - document file AddMem - executable DONATIONS All donations in the form of cash, money order, travellers cheques, bank draft (in AUS dollars), goods, software or hardware will be gratefully accepted, and ensure further shareware programs from me. Overseas users, please do not send personal cheques. It is very difficult to convert them into cash. I give my sincere thanks to all those users who have donated to my work in the past. It is with your continuing support to all programmers that the Amiga has such a vast amount of quality shareware programs available, and that I am able to continue work on shareware programs aswell as commercial ones. REQUIREMENTS Depending on the function the requirements are different and are as follows: FASTROM install - AmigaDOS V2.04 or greater, 68040 CPU, 1MB FAST RAM or more KICKROM install - AmigaDOS V2,04 or greater, 68040 CPU, 1MB CHIP RAM minimum CHIP to FASTROM - AmigaDOS V1.2 or greater, 68040 CPU, 1MB FAST RAM or more 68040 <-> 68030 - AmigaDOS V2.04 or greater, A3000 with PP&S 68040 board OTHER INFO This program was written and tested on an Amiga A3000 with a Progressive Peripherals & Software 68040 card. This is the only card it has been tested on. If it works on your card please let me know, if it doesn't let me know too and maybe we can rectify it for other 68040 cards. See below for more information on this. USAGE Set040 If no switch is supplied, Set040 will display information on cache settings, etc., unless Set040 finds a 'KICKROM' installation. In this case it will perform the 'KICKROM' to 'FASTROM' change before displaying the information. Because some switch arguments use upper case characters, the entire switch and argument characters are case sensitive and must be entered as shown here. Only one '-' switch is allowed. Any others will be ignored. The '-f' switch allows multiple arguments (EG. -fzwi). The '-k' takes one argument for path/filename. The '-c' switch allows multiple arguments (EG. -cIDc). The '-r' switch takes no arguments. The '-s' switch takes no arguments. ? = Displays a 'USAGE' string on the current CLI. ************** FASTROM OPTION ************** -f = Install FASTROM remap with optional parameters With no further arguments, -f will install a FASTROM remap, disable caching of ZorroII memory space. Mother board space & ZorroIII memory area will be set as Copyback cachable. Both the data and instruction caches will be enabled. Workbench screen title will be changed to "Amiga Fastbench". The FASTROM option is best placed in your startup-sequence so that the boot process can gain from the extra speed of Kickstart in ram. I recommend placing it as the very first line of the startup-sequence. z = Allow caching of ZorroII memory ($200000 - $A00000). Only give this argument if you have nothing but memory between these addresses. If you are not sure, you can use my SysInfo program to find out. w = Set addresses $1000000 - $3FFFFFF as WriteThrough (SEE NOTES). c = Set addresses $4000000 - $FFFFFFF as WriteThrough (SEE NOTES). d = Do not enable data cache. i = Do not enable instruction cache. These two may be required for special cases or if you normally operate with one or more of your caches disabled. n = Install patch to stop floppy drives clicking. t = Do not change the Workbench screen title. By default it will change it to "Amiga Fastbench" as an obvious sign that FASTROM is installed. This argument will overide this and leave the title unchanged. EXAMPLE ------- To install FASTROM and Click free drives -> Set040 -fn ************** KICKROM OPTION ************** -k = Install and boot different Kickstart than the one currently in ROM = Full path and filename to a Kickstart file, or, if using a Kickstart disk, must be a floppy drive (eg. DF0:) The Kickstart file can be a 256K file (1.2 or 1.3) or a 512k file (2.0x) as saved by the "Update2.x" or "Update1.3" program supplied with your A3000. The Kickstart disk can be either a standard A1000 Kickstart or an A3000 SuperKickstart disk. If a SuperKickstart is used a requester window will open and prompt you for the Kickstart version you require. These choices will be "V1.3" or "V2.0". If the drive you specified does not have a disk in it, you will be prompted for a disk with a requester. This function requires an Amiga with at least 1MB of chip memory for it to work. It will attempt to allocate around 576k of memory within the chip memory area as high as possible. The allocated chip memory from this allocated block to the end of the next one megabyte boundary will be hidden from exec after the reboot. When Set040 is run again and the CHIPROM to FASTROM conversion is done, this hidden memory will be added to the free pool. If your chip memory usage is large, Set040 may not be able to obtain the required memory. If this happens I suggest closing as many programs as possible or re-booting with a minimum set-up so that Set040 can allocate the ram it requires. Even though we are about to re-boot, into a new kickstart, Set040 will NOT just take the ram required, as this may cause an exception. If the memory allocated, falls within the first megabyte on an Amiga with two megabytes of chip ram, the second megabyte will be lost completely unless added in with the 'addmem' command. This should not happen under normal circumstances, as Exec normally allocates memory from lower addresses first. This means that the memory allocated by Set040 should always fall within the highest one megabyte block. A brief message will appear, informing you that the new kickstart is being patched to prevent the MMU from being disabled. After a short delay the new Kickstart will be booted. During this delay the power light will flash rapidly to let you know this function is operating successfully. KICKSTART 1.2 - 1.3 If the new Kickstart is 1.2 or 1.3, only the remaining chip memory will be available after booting. Any FASTRAM on the A3000 mother board will not be available. This memory must be added to the system with the supplied "addmem" command. It has been done this way incase the fast memory is not required for some reason. The usage for the 'addmem' command for different memory sizes is shown below. When the FASTRAM has been added, you may run Set040 again with no arguments. Set040 will recognise that the set-up is a CHIPRAM set-up and will move it to FASTRAM if there is sufficient available. The amount of CHIPRAM that was previously hidden will be added to the free pool. AddMem usage for A3000 32bit wide fast ram are as follows: A3000 4MB 32 bit ram = AddMem 7C00000 7FFFFFF A3000 8MB 32 bit ram = AddMem 7800000 7FFFFFF A3000 12MB 32 bit ram = AddMem 7400000 7FFFFFF A3000 16MB 32 bit ram = AddMem 7000000 7FFFFFF KICKSTART 2.0x If the new Kickstart is 2.0x (V37+)your FASTRAM will still be available and your hard disk would have booted. The addmem command will not be required. This set-up will still be in CHIPRAM though, and can be automatically moved to fast memory by running Set040 again without any arguments. This is the information only mode of Set040 but will recognise the Chip setup and move it and the MMU set-up to FASTRAM, then replace the previously hidden chip memory. EXAMPLE ------- To install a KICKROM setup from a file called "KICK" in "DEVS:" Set040 -k devs:kick To install a kickrom option from a kickstart disk in df1: Set040 -k df1: NOTE: ONCE THIS KICKSTART IS INSTALLED IT CANNOT BE REMOVED WITH THE '-r' FUNCTION. ANY ATTEMPT TO DO SO WILL GIVE AN ERROR. IF YOU WISH TO RETURN TO YOUR ROM BASED KICKSTART, ALL THE IS REQUIRED IS A HARDWARE RESET. (THERFORE THE KICKROM SETUP WILL NOT SURVIVE A HARDWARE RESET). FOR COMPATIBILITY REASONS, WHEN THE CHIPRAM to FASTRAM CHANGE IS PERFORMED, THE DATA CACHE WILL ONLY BE ENABLED FOR V2.0X KICKSTARTS, AND WILL BE DISABLED FOR OTHER KICKSTARTS. IF YOU WISH TO CHANGE THIS, OR MANIPULATE THE OTHER CACHES, USE THE '-c' SWITCH OPTIONS. ****************** CACHE MANIPULATION ****************** -c = Manipulate caches as per arguments. I = Enable Instruction cache. i = Disable Instruction cache. D = Enable Data cache. d = Disable Data cache. B = Enable both caches. b = Disable both caches. C = Enable Copyback for $4000000 - $FFFFFFF. c = Disable Copyback for $4000000 - $FFFFFFF. NOTE: Enabling instruction and data caches with -cID is exactly the same as using -cB. Likewise use -cb to disable both caches. It has been done this way so that each cache can be manipulated seperately or manipulated together easily. EXAMPLES -------- Disable both caches - Set040 -cb Enable both caches - Set040 -cB Disable Data Cache - Set040 -cd Enable Data Cache - Set040 -cD Enable Ins & Data Caches and disable Copyback - Set040 -cIDc Enable Ins & Data Caches and disable Copyback - Set040 -cBc ETC... **************** REMOVING FASTROM **************** -r = Remove the FASTROM remap and reclaim all resources. NOTE This function is not possible on a KICKROM setup. ************* CPU SWITCHING ************* -s = Switch between the 68040 and 68030 and vice-versa on a PP&S 68040 card in an Amiga A3000-25MHZ. The program automatically knows the current CPU and will prompt to switch to the opposite one. NOTE ON -s This is the only switch that is permitted on a 68030 CPU. All other switches will display an error. When this switch is given, a requester will open and will prompt you to either 'CHANGE' or 'ABORT' via two gadgets. If aborted, no further action takes place and the program will exit. If 'CHANGE' is selected, another requester will open and prompt you to reboot the computer. This requester will have a single 'ABORT' gadget, giving you a final chance to abort. The actual reboot must be done by hand, using the keyboard because the PP&S 68040 card requires a hardware reset to switch modes. This cannot be generated with software. (NO, the reset instruction will not work!) :-( IMPROVEMENTS All suggestions will be carefully considered. All bugs will be rectified A.S.A.P. I will attempt to overcome all incompatibilities if sufficient information on your particular board is supplied ie. amount of onboard ram, address of such ram, A3000 or A2000 board, full description of other hardware you use, full description of any plug in cards, full description of your Amiga, OS version numbers etc!! TECHNICAL NOTES The average user may not completely understand the following notes, suffice to say an understanding of how this program works is not required. Information given here is mainly for the benefit of the experienced user or programmer. These notes may be of some help if you experience problems with certain 68040 cards. I wrote this program for a few reasons. To gain knowledge in programming the 68040 processor in assembler and to discover the differences from its older brothers. I wanted to test Macro68 assembler in 68040 instructions. When I ran a test of the difference in speed between reading the ROMS and reading FAST RAM, I realized an assembler 68040 MMU program was a necessity. I found that while reading the ROMS the 68040 was only marginally faster than the 68030, yet in FAST RAM the 68040 leaves the 68030 standing. The MMU set-up remaps the kickstart ROMS to FAST RAM, and allows for instruction caching of the address areas the same as for the data areas mentioned below. This set-up protects the new kickstart by marking this area of memory as write-protected in the ATC table entries. Re-mapping kickstart to FAST RAM poses a few problems because of the design of the 68040 MMU. Most of the first 16MB of the Amiga memory map must be set for non-cachable serialized. The rest of the 4 Gigabyte space can be set for cachable copyback, but because of limitations of the 68040 MMU, programming this is not easy. The standard PP&S set-up manages this by using both of the Data Transparent Translation registers. This works fine but does not allow for re-mapping of the kickstart. The 68040 MMU looks at Transparent Translation registers first, and if an address matches, the ATC tables are not accessed. Therefore a remap of the kickstart would not be seen if we used the same values in the transparent registers as PP&S, or Commodore uses. The 68040 has a simple 3 level ATC table and page sizes of either 4k or 8k. Our set-up discussed here uses the 8k page size. If the ATC is used, each entry in the first table covers 32MB. This means that we must at least have entries in this table for that address space. If we want this entire 32MB to be valid we must have complete entries in the second and third tables to cater for it. This is not a large problem but does use around 17k of memory for each 32MB space covered in the table. The problem is enhanced due to the fact the 68040 does not support 'early termination descriptors' as the 68030 did. The next problem exists because, two of each data and instruction transparent translation registers are not enough to control the rest of the space. We could put all entries in the ATC tables, but this would mean rather large tables and make it difficult to control the copyback mode over a large area. This would also mean that the CPU040 program from PP&S, and possibly many more 68040 copyback manipulation programs would not be compatible. The set-up I have opted for, is to insert entire entries for the first 64MB of space. The first 16MB is set in the tables as non-cachable serialized. Copyback mode for the second, third and fourth 16MB spaces can be conrolled globally between copyback or writethrough at installation time by command line arguments. The address of this entire 48MB space is $1000000 - $3FFFFFF. The next 64MB address space ($4000000 - $7FFFFFF) is controlled by one each of the two data and instruction transparent translation registers for the data and instruction spaces respectively. The data registers are set for cachable copyback unless the 'w' argument of the '-f' switch is used at installation. This can be changed after installation with the '-c' switch. The instruction registers are set for cachable. The above caters for the first 16MB and the area defined as 'A3000 mother board space'. Above this area we have a 128MB space which is defined as "ZorroIII 32 bit memory expansion area". This is controlled by the second data and instruction transparent translation registers and can be optionally switched between copyback or writethrough after installation by command line arguments. This area will default to copyback at installation unless '-fc' command line argument is given. All these ATC entries except for the kickstart remap entries actually get transparently translated. The 68040 users guide states that if the physical address equals the logical address in a page entry, then that entry is transparently translated. Transparent translation means that there is no CPU overhead to do the translation. The kickstart remap routine makes use of the new 'MOVE16' instruction to copy the ROM into ram. This allows a very fast copy and saves having to call kickstart routines to flush the caches after the copy. A program of this kind written in C (with current C compilers) would have to use CopyMemQuick function call and then flush the caches, and this would be much slower, whereas my routine is instantaneous. When programming this set-up I attempted to keep it as compatible with the standard set-up from PP&S as possible. This allows their CPU040 program to still be used to manipulate the copyback mode. I tried also to keep it compatible with my own CPUSet program that I released at an earlier date. In doing this it I had to compromise the set-up even further than I would have normally done. The PP&S CPU040 program ,my CPUSet program and Commdore's new CPU program will only be able to switch copyback address areas that are controlled by the DTT1 register. This allows them to control memory addresses in the range of $4000000 - $7FFFFFF. This area covers the entire motherboard fast memory in the A3000. The '-c options have much greater control over all areas. The rest of the map has been set as invalid. The set-up I have opted for should allow for the greatest compatibility between different 68040 cards. I will change this set-up or supply more options in future versions if necessary. ZorroIII memory boards which are addressed within the range of $8000000 - $FFFFFFF should work as this is the area that has been assigned for such memory boards. Other ZorroIII boards that are addressed above this area will not work with the current set-up. I have no knowledge of such cards available at the time of writing. TRADEMARKS AmigaDOS, Amiga and Kickstart are trademarks of Commodore Amiga Inc. PP&S is an abbreviation for Progressive Peripherals and Software. MC68030, MC68040 and Motorola are trademarks of Motorola Inc. REFERENCES M68000PM/AD Programmers Reference Manual (inc. CPU32) Published by Motorola Literature Distribution USA. M68000UM/AD 8-/16-/32-Bit MicroProcessor User's Manual Eigth Edition. Published by PRENTICE HALL, Englewood Cliffs, N.J. 07632 MC68040UM/AD 32-Bit MicroProcessor User's Manual Published by Motorola Literature Distribution USA. MC68030UM/AD 32-Bit MicroProcessor User's Manual Published by Motorola Literature Distribution USA.