/********************************************************* ** ScanToConfig ** ** ** ** Builds the MMU-Configuration file automatically ** ** from the MuScan output, including kludges for ** ** bad or mis-designed hardware ** ** Version 1.04 © 2000 THOR-Software, Thomas Richter ** ** 13.04.2000 ** *********************************************************/ PARSE ARG destination p5disable acadisable . if (destination = '') then destination = '*' p5 = 1; if (upper(p5disable) = 'NOP5') then p5 = 0; aca = 1; if (upper(acadisable) = 'NOACA') then aca = 0; rec = 25; if (OPEN(.out,destination,'W')) THEN; DO rv=WRITELN(.out,";*************************************************************************"); rv=WRITELN(.out,";** MMU Configuration file **"); rv=WRITELN(.out,";** **"); rv=WRITELN(.out,";** this file is read on startup by the mmu.library and used to modify **"); rv=WRITELN(.out,";** the pre-calculated or scanned MMU table **"); rv=WRITELN(.out,";** **"); rv=WRITELN(.out,";** © 1999,2000 THOR Software, Thomas Richter **"); rv=WRITELN(.out,";*************************************************************************"); rv=WRITELN(.out,""); rv=WRITELN(.out,""); rv=WRITELN(.out,""); rv=WRITELN(.out,"; the current version of the MMU library knows four commands that can"); rv=WRITELN(.out,"; be used in this file:"); rv=WRITELN(.out,"; CLEARTTX clears all or parts of the transparent translation registers"); rv=WRITELN(.out,"; ADDMEM adds memory to the exec free list pool. BE WARNED, this command"); rv=WRITELN(.out,"; does NOT modify the MMU tables, this must be done manually with"); rv=WRITELN(.out,"; SETCACHEMODE"); rv=WRITELN(.out,"; SETCACHEMODE defines the MMU tables."); rv=WRITELN(.out,"; DESCRIPTORCACHEINHIBIT defines whether the data cache should be disabled"); rv=WRITELN(.out,"; for the MMU descriptors. It's usually OFF meaning the cache will remain"); rv=WRITELN(.out,"; enabled. This is fine for the mmu.library, but certain hacks might require"); rv=WRITELN(.out,"; an ON argument here. Note that this means more work for the library."); rv=WRITELN(.out,""); rv=WRITELN(.out,""); rv=WRITELN(.out,"ClearTTx ;ignore all TTX registers if any. We don't need them"); rv=WRITELN(.out,""); rv=WRITELN(.out,";DescriptorCacheInhibit ON ;make access to MMU descriptors cache inhibited"); rv=WRITELN(.out,""); rv=WRITELN(.out,""); rv=WRITELN(.out,";Board specific setup follows here,"); rv=WRITELN(.out,";generated by ScanToConfig 1.04 © 14.04.2000 THOR-Software"); rv=WRITELN(.out,""); rv=WRITELN(.out,";General memory setup follows."); rv=WRITELN(.out,";The following lines are a compatibility kludge for some P5 boards"); rv=WRITELN(.out,";which enable the MMU prior to the 68040/68060 library and leave"); rv=WRITELN(.out,";the memory in CACHEINHIBIT state. You may remove the following"); rv=WRITELN(.out,";lines on all other machines most likely."); rv=WRITELN(.out,""); ADDRESS COMMAND "MemModes >T:MemInfo"; IF (OPEN(.meminfo,"T:MemInfo",'R')) THEN; DO DO UNTIL EOF(.meminfo) line = READLN(.meminfo); WRITELN(.out,line); END; rv=CLOSE(.meminfo); END; rv=WRITELN(.out,";Memory setup end."); rv=WRITELN(.out,""); rv=WRITELN(.out,""); ADDRESS COMMAND 'FindPort "BOOT-MMU-Port"' portmode = RC; ADDRESS COMMAND "ShowBoards to T:BoardInfo"; boards = 0; if (OPEN(.boardinfo,"T:BoardInfo",'R')) then; do DO UNTIL EOF(.boardinfo) line = READLN(.boardinfo) IF line ~= '' THEN; DO PARSE VAR line 'Type:' type 'Product:' product 'Manufacturer:' mf 'Serial#:' id 'BoardAddr:' from 'BoardSize:' size; boards = boards + 1; type.boards=X2D(type); product.boards=X2D(product); mf.boards=X2D(mf); id.boards=X2D(id); base.boards=X2D(SUBSTR(from,2,6)); end.boards=X2D(SUBSTR(size,2,6))+base.boards; END END rv=CLOSE(.boardinfo); END ADDRESS COMMAND "MuScan to T:BoardInfo"; if (OPEN(.boardinfo,"T:BoardInfo",'R')) then; do rec = 0; scan = 0; portwarn = 0; ppcwarn = 0; DO UNTIL EOF(.boardinfo) line = READLN(.boardinfo) IF scan = 0 THEN; DO IF line = 'Memory map:' THEN; DO scan = 1; END; END; ELSE; DO IF line ~= '' THEN; DO base = SUBWORD(line,1,1); end = SUBWORD(line,3,1); mode = SUBWORD(line,4); rv = ScanEntry(base,end,mode); END; END END rv=CLOSE(.boardinfo); END /* P5 setup kludges follow here..... Sigh */ romlibs = 0; /* libs in ROM? */ p5init = 0; romlibs = 0; ppccheck = 0; acainit = 0; IF aca THEN; DO ADDRESS COMMAND 'ACAIdentify' acamode = RC; /* Possibly ACA board? */ IF acamode ~= 0 THEN; DO acainit = 1 END; END; IF p5 THEN; DO ADDRESS COMMAND 'P5Identify' p5mode = RC; /* Possibly P5 board? */ ADDRESS COMMAND 'FindPort "BOOT-MMU-Port"' portmode = RC; /* MMU setup kludge? */ ADDRESS COMMAND 'FindResident "ppc.library"' ppclibmode = RC; /* PPCLib in ROM? */ ADDRESS COMMAND 'FindResident "68060quick.library"' quicklibmode = RC; /* quick lib in ROM? */ ADDRESS COMMAND 'FindResident "68060.library"' libmode = RC; /* 060 lib in ROM? */ ADDRESS COMMAND 'FindResident "68040.library"' lib4mode = RC; /* 040 lib in ROM? */ IF p5mode ~= 0 THEN; DO p5init = 1 ppccheck = 1 END; IF ppclibmode = 0 THEN; DO ppccheck = 1 END; IF portmode = 0 THEN; DO ppccheck = 1 p5init = 1 END; IF (quicklibmode = 0) | (libmode = 0) | (lib4mode = 0) | (ppclibmode = 0) THEN; DO p5init = 1 romlibs = 1 ppccheck = 1 END; END; IF p5init = 1 THEN;DO rv=WRITELN(.out,""); rv=WRITELN(.out,";P5 fixes follow here:"); rv=WRITELN(.out,";If you do not own a P5 board, you may remove the following lines"); rv=WRITELN(.out,";"); rv=WRITELN(.out,";Several P5 boards build a private MMU setup on boot"); rv=WRITELN(.out,";using a kludge called the BOOT-MMU-Port. To run this"); rv=WRITELN(.out,";kludge, the following external command is run from"); rv=WRITELN(.out,";LIBS:mmu/ as all other external commands"); rv=WRITELN(.out,";"); rv=WRITELN(.out,";This command installs also other P5 relevant MMU settings"); rv=WRITELN(.out,";Hence, for P5 boards, please keep it in place even if"); rv=WRITELN(.out,";you *DO NOT* see the BOOT-MMU-Port."); rv=WRITELN(.out,";"); IF ~EXISTS("LIBS:mmu") THEN; DO OPTIONS FAILAT 15 ADDRESS COMMAND 'MakeDir >NIL: LIBS:MMU' OPTIONS FAILAT 10 END; IF ~EXISTS("LIBS:mmu/P5Init") THEN; DO ADDRESS COMMAND 'Copy >NIL: P5Init to LIBS:MMU/P5Init' END; rv=WRITELN(.out,"P5Init"); rv=WRITELN(.out,""); rv=WRITELN(.out,""); END; IF acainit = 1 THEN;DO rv=WRITELN(.out,""); rv=WRITELN(.out,";ACA fixes follow here:"); rv=WRITELN(.out,";If you do not own an ACA board, you may remove the following lines"); rv=WRITELN(.out,";"); rv=WRITELN(.out,";This command installs also ACA relevant MMU settings"); rv=WRITELN(.out,";Hence, for older ACA boards, please keep it in place."); rv=WRITELN(.out,";"); IF ~EXISTS("LIBS:mmu") THEN; DO OPTIONS FAILAT 15 ADDRESS COMMAND 'MakeDir >NIL: LIBS:MMU' OPTIONS FAILAT 10 END; IF ~EXISTS("LIBS:mmu/ACAInit") THEN; DO ADDRESS COMMAND 'Copy >NIL: ACAInit to LIBS:MMU/ACAInit' END; rv=WRITELN(.out,"ACAInit"); rv=WRITELN(.out,""); rv=WRITELN(.out,""); END; IF ppccheck = 1 THEN; DO ADDRESS COMMAND 'PPCIdentify' ppccheck = RC; END; IF ppccheck = 1 THEN; DO SAY "The setup script found a P5 board with PPC processor."; SAY "While not a problem in general, please note that you"; SAY "absolutely *MUST NOT* use the ppc.library together"; SAY "with the mmu.library. This won't work."; END; IF romlibs = 1 THEN; DO rv=WRITELN(.out,""); rv=WRITELN(.out,";This board has some processor libs resident"); rv=WRITELN(.out,";BPPCFix should be run to remove it."); rv=WRITELN(.out,";This command has been installed into C:"); rv=WRITELN(.out,";by the setup script."); SAY "The setup script found some processor libraries resident in ROM"; SAY "You will not be able to use the MuLib specific processor"; SAY "libraries unless you run BPPCFix in your startup-sequence."; SAY "Please study the BPPCFix manual for details on how to run"; SAY "this program to replace the ROM-based libraries." SAY ""; SAY "Note further that you *DO NOT* need the ENVARC:MMU-Configuration" SAY "file if you continue to use the ROM resident libraries."; SAY ""; IF ~EXISTS("C:BPPCFix") THEN; DO ADDRESS COMMAND 'Copy >NIL: BPPCFix to C:BPPCFix' SAY "Copied BPPCFix to C: for convenience..."; END; END; rv=WRITELN(.out,""); rv=CLOSE(.out); ADDRESS COMMAND 'Delete T:BoardInfo QUIET' END RETURN 0 ScanEntry: PARSE ARG base,end,mode base = X2D(SUBSTR(base,3,6)) end = X2D(SUBSTR(end,3,6))+1 copyback = INDEX(mode,'CopyBack')>0; cacheinhibit = INDEX(mode,'CacheInhibit')>0; invalid = INDEX(mode,'Blank')>0 | INDEX(mode,'Invalid')>0; remapped = INDEX(mode,'Remapped')>0; speedup = INDEX(mode,'NonSerial')>0 | INDEX(mode,'Imprecise')>0; iomark = 0; board = 0; DO i=1 TO boards IF basebase.i THEN; DO iomark = 1; END; END; cachemodes = "WriteThrough"; iomodes = ""; IF copyback THEN cachemodes="CopyBack"; IF cacheinhibit THEN cachemodes="CacheInhibit"; IF speedup THEN cachemodes="CacheInhibit Imprecise NonSerial"; IF iomark THEN iomodes="IOSpace"; memrange = "SetCacheMode 0x"D2X(base)"00 Size 0x"D2X(end-base)"00"; zeropage = 0; chipmem = 0; zorro2 = 0; iospace = 0; mother = 0; rangermem = 0; p5space = 0; ppcspace = 0; mem = 0; rom = 0; IF end<=X2D('80') THEN zeropage = 1; IF end<=X2D('2000') THEN chipmem = 1; IF base>=X2D('2000') & end<=X2D('A000') THEN zorro2 = 1; IF base>=X2D('A000') & end<=X2D('B800') THEN iospace = 1; IF base>=X2D('B800') & end<=X2D('C000') THEN mother = 1; IF base>=X2D('C000') & end<=X2D('D800') THEN rangermem = 1; IF base>=X2D('DA00') & end<=X2D('E000') THEN mother = 1; IF base>=X2D('E800') & end<=X2D('F000') THEN iospace = 1; IF base>=X2D('F000') & end<=X2D('F800') THEN p5space = 1; IF base>=X2D('F800') & end<=X2D('10000') THEN rom = 1; IF base>=X2D('10000') & end<=X2D('100000') THEN mem = 1; IF base>=X2D('80000') & end<=X2D('100000') THEN ppcspace = 1; IF base>=X2D('100000') & end<=X2D('800000') THEN iospace = 1; IF base>=X2D('400000') & end<=X2D('C00000') THEN ppcspace = 1; IF base>=X2D('E00000') & end<=X2D('1000000') THEN p5space = 1; IF base>=X2D('FF0000') & end<=X2D('FF1000') THEN iospace = 1; IF iomark THEN iospace = 1; /* found remapped chip memory */ IF zeropage & remapped THEN; DO SAY 'Found a remapped ZeroPage, it might be a good idea to run MuFastZero.'; SAY 'If MuFastZero fails with "Zero page already remapped", please add the'; SAY 'FORCENATIVE command line option.'; END; /* found fast chip. This can be turned on in either case */ IF chipmem & (~remapped) & (~invalid) THEN; DO rv=WRITELN(.out,";In case you don't run the V40 68040 resp. 68060.library"); rv=WRITELN(.out,";the following line will speed up the chip memory. It is"); rv=WRITELN(.out,";not required otherwise."); rv=WRITELN(.out,memrange "CacheInhibit Imprecise NonSerial"); rv=WRITELN(.out,""); END; /* found slow zorro II or gfx mem? */ IF zorro2 & (~copyback) & (~invalid) & (~iomark) THEN; DO rv=WRITELN(.out,";Found slow Zorro-II memory. Keeping the caches disabled."); rv=WRITELN(.out,memrange "CacheInhibit Imprecise NonSerial Valid"); rv=WRITELN(.out,""); END; /* copy attributes for the IO space */ IF iospace & (~invalid) & (~remapped) THEN; DO rv=WRITELN(.out,memrange cachemodes "Valid IOSpace"); rv=WRITELN(.out,""); END; /* setup ranger memory */ IF rangermem & (~invalid) & (~remapped) THEN; DO rv=WRITELN(.out,memrange "CacheInhibit Imprecise NonSerial Valid"); rv=WRITELN(.out,""); END; /* setup P5 uglyness */ IF p5space & (~invalid) & (~remapped) & (~iospace) THEN; DO rv=WRITELN(.out,";The following memory region should be left blank"); rv=WRITELN(.out,";according to the CBM design rules. It isn't..."); rv=WRITELN(.out,memrange cachemodes "Valid IOSpace"); rv=WRITELN(.out,""); END; /* found remapped ROM? */ IF rom & remapped THEN; DO SAY 'Found a remapped ROM, running MuFastRom might be a good idea,'; SAY 'but make sure you disable other ROM remappers before trying'; SAY 'to use the MMU.library setup.'; END; /* strange caching modes in RAM? */ IF mem THEN; DO IF ~copyback THEN; DO IF ~portwarn THEN; DO SAY 'WARNING! Found non-copyback memory regions.'; SAY 'This could mean that either the ppc.library is running'; SAY 'or P5 I/O hardware is active.'; SAY 'For the time being, I do nothing about it, but you should'; SAY 'check the MMU-Configuration file manually and follow the'; SAY 'notes in this file for further testing.'; rv=WRITELN(.out,"WARNING! Found non-copyback memory regions."); rv=WRITELN(.out,"This could mean that either the ppc.library is running"); rv=WRITELN(.out,"or P5 I/O hardware is active."); rv=WRITELN(.out,"For the time being, I do nothing about it, but you could"); rv=WRITELN(.out,"try to remove the semi-colon for the following lines:"); portwarn = 1; END; rv=WRITELN(.out,";"memrange cachemodes "Valid"); END; END; /* PPC memory area marked as valid? */ IF ppcspace & (~invalid) & (~remapped) THEN; DO IF ~ppcwarn THEN; DO SAY 'WARNING! Found possible PPC memory regions.'; SAY 'DO NOT RUN THE ppc.library or you get problems.'; ppcwarn = 1; END; rv=WRITELN(.out,";If you don't own a PPC, you may remove the next line:"); rv=WRITELN(.out,memrange cachemodes iomodes "Valid"); rv=WRITELN(.out,""); END; RETURN 0