18c2ecf20Sopenharmony_ci===================================== 28c2ecf20Sopenharmony_ciAmiga Buddha and Catweasel IDE Driver 38c2ecf20Sopenharmony_ci===================================== 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ciThe Amiga Buddha and Catweasel IDE Driver (part of ide.c) was written by 68c2ecf20Sopenharmony_ciGeert Uytterhoeven based on the following specifications: 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci------------------------------------------------------------------------ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciRegister map of the Buddha IDE controller and the 118c2ecf20Sopenharmony_ciBuddha-part of the Catweasel Zorro-II version 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ciThe Autoconfiguration has been implemented just as Commodore 148c2ecf20Sopenharmony_cidescribed in their manuals, no tricks have been used (for 158c2ecf20Sopenharmony_ciexample leaving some address lines out of the equations...). 168c2ecf20Sopenharmony_ciIf you want to configure the board yourself (for example let 178c2ecf20Sopenharmony_cia Linux kernel configure the card), look at the Commodore 188c2ecf20Sopenharmony_ciDocs. Reading the nibbles should give this information:: 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci Vendor number: 4626 ($1212) 218c2ecf20Sopenharmony_ci product number: 0 (42 for Catweasel Z-II) 228c2ecf20Sopenharmony_ci Serial number: 0 238c2ecf20Sopenharmony_ci Rom-vector: $1000 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ciThe card should be a Z-II board, size 64K, not for freemem 268c2ecf20Sopenharmony_cilist, Rom-Vektor is valid, no second Autoconfig-board on the 278c2ecf20Sopenharmony_cisame card, no space preference, supports "Shutup_forever". 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ciSetting the base address should be done in two steps, just 308c2ecf20Sopenharmony_cias the Amiga Kickstart does: The lower nibble of the 8-Bit 318c2ecf20Sopenharmony_ciaddress is written to $4a, then the whole Byte is written to 328c2ecf20Sopenharmony_ci$48, while it doesn't matter how often you're writing to $4a 338c2ecf20Sopenharmony_cias long as $48 is not touched. After $48 has been written, 348c2ecf20Sopenharmony_cithe whole card disappears from $e8 and is mapped to the new 358c2ecf20Sopenharmony_ciaddress just written. Make sure $4a is written before $48, 368c2ecf20Sopenharmony_ciotherwise your chance is only 1:16 to find the board :-). 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ciThe local memory-map is even active when mapped to $e8: 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci============== =========================================== 418c2ecf20Sopenharmony_ci$0-$7e Autokonfig-space, see Z-II docs. 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci$80-$7fd reserved 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci$7fe Speed-select Register: Read & Write 468c2ecf20Sopenharmony_ci (description see further down) 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci$800-$8ff IDE-Select 0 (Port 0, Register set 0) 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci$900-$9ff IDE-Select 1 (Port 0, Register set 1) 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci$a00-$aff IDE-Select 2 (Port 1, Register set 0) 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci$b00-$bff IDE-Select 3 (Port 1, Register set 1) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci$c00-$cff IDE-Select 4 (Port 2, Register set 0, 578c2ecf20Sopenharmony_ci Catweasel only!) 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci$d00-$dff IDE-Select 5 (Port 3, Register set 1, 608c2ecf20Sopenharmony_ci Catweasel only!) 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci$e00-$eff local expansion port, on Catweasel Z-II the 638c2ecf20Sopenharmony_ci Catweasel registers are also mapped here. 648c2ecf20Sopenharmony_ci Never touch, use multidisk.device! 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci$f00 read only, Byte-access: Bit 7 shows the 678c2ecf20Sopenharmony_ci level of the IRQ-line of IDE port 0. 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci$f01-$f3f mirror of $f00 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci$f40 read only, Byte-access: Bit 7 shows the 728c2ecf20Sopenharmony_ci level of the IRQ-line of IDE port 1. 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci$f41-$f7f mirror of $f40 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci$f80 read only, Byte-access: Bit 7 shows the 778c2ecf20Sopenharmony_ci level of the IRQ-line of IDE port 2. 788c2ecf20Sopenharmony_ci (Catweasel only!) 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci$f81-$fbf mirror of $f80 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci$fc0 write-only: Writing any value to this 838c2ecf20Sopenharmony_ci register enables IRQs to be passed from the 848c2ecf20Sopenharmony_ci IDE ports to the Zorro bus. This mechanism 858c2ecf20Sopenharmony_ci has been implemented to be compatible with 868c2ecf20Sopenharmony_ci harddisks that are either defective or have 878c2ecf20Sopenharmony_ci a buggy firmware and pull the IRQ line up 888c2ecf20Sopenharmony_ci while starting up. If interrupts would 898c2ecf20Sopenharmony_ci always be passed to the bus, the computer 908c2ecf20Sopenharmony_ci might not start up. Once enabled, this flag 918c2ecf20Sopenharmony_ci can not be disabled again. The level of the 928c2ecf20Sopenharmony_ci flag can not be determined by software 938c2ecf20Sopenharmony_ci (what for? Write to me if it's necessary!). 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci$fc1-$fff mirror of $fc0 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci$1000-$ffff Buddha-Rom with offset $1000 in the rom 988c2ecf20Sopenharmony_ci chip. The addresses $0 to $fff of the rom 998c2ecf20Sopenharmony_ci chip cannot be read. Rom is Byte-wide and 1008c2ecf20Sopenharmony_ci mapped to even addresses. 1018c2ecf20Sopenharmony_ci============== =========================================== 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ciThe IDE ports issue an INT2. You can read the level of the 1048c2ecf20Sopenharmony_ciIRQ-lines of the IDE-ports by reading from the three (two 1058c2ecf20Sopenharmony_cifor Buddha-only) registers $f00, $f40 and $f80. This way 1068c2ecf20Sopenharmony_cimore than one I/O request can be handled and you can easily 1078c2ecf20Sopenharmony_cidetermine what driver has to serve the INT2. Buddha and 1088c2ecf20Sopenharmony_ciCatweasel expansion boards can issue an INT6. A separate 1098c2ecf20Sopenharmony_cimemory map is available for the I/O module and the sysop's 1108c2ecf20Sopenharmony_ciI/O module. 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ciThe IDE ports are fed by the address lines A2 to A4, just as 1138c2ecf20Sopenharmony_cithe Amiga 1200 and Amiga 4000 IDE ports are. This way 1148c2ecf20Sopenharmony_ciexisting drivers can be easily ported to Buddha. A move.l 1158c2ecf20Sopenharmony_cipolls two words out of the same address of IDE port since 1168c2ecf20Sopenharmony_cievery word is mirrored once. movem is not possible, but 1178c2ecf20Sopenharmony_ciit's not necessary either, because you can only speedup 1188c2ecf20Sopenharmony_ci68000 systems with this technique. A 68020 system with 1198c2ecf20Sopenharmony_cifastmem is faster with move.l. 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ciIf you're using the mirrored registers of the IDE-ports with 1228c2ecf20Sopenharmony_ciA6=1, the Buddha doesn't care about the speed that you have 1238c2ecf20Sopenharmony_ciselected in the speed register (see further down). With 1248c2ecf20Sopenharmony_ciA6=1 (for example $840 for port 0, register set 0), a 780ns 1258c2ecf20Sopenharmony_ciaccess is being made. These registers should be used for a 1268c2ecf20Sopenharmony_cicommand access to the harddisk/CD-Rom, since command 1278c2ecf20Sopenharmony_ciaccesses are Byte-wide and have to be made slower according 1288c2ecf20Sopenharmony_cito the ATA-X3T9 manual. 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ciNow for the speed-register: The register is byte-wide, and 1318c2ecf20Sopenharmony_cionly the upper three bits are used (Bits 7 to 5). Bit 4 1328c2ecf20Sopenharmony_cimust always be set to 1 to be compatible with later Buddha 1338c2ecf20Sopenharmony_civersions (if I'll ever update this one). I presume that 1348c2ecf20Sopenharmony_ciI'll never use the lower four bits, but they have to be set 1358c2ecf20Sopenharmony_cito 1 by definition. 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ciThe values in this table have to be shifted 5 bits to the 1388c2ecf20Sopenharmony_cileft and or'd with $1f (this sets the lower 5 bits). 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ciAll the timings have in common: Select and IOR/IOW rise at 1418c2ecf20Sopenharmony_cithe same time. IOR and IOW have a propagation delay of 1428c2ecf20Sopenharmony_ciabout 30ns to the clocks on the Zorro bus, that's why the 1438c2ecf20Sopenharmony_civalues are no multiple of 71. One clock-cycle is 71ns long 1448c2ecf20Sopenharmony_ci(exactly 70,5 at 14,18 Mhz on PAL systems). 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_civalue 0 (Default after reset) 1478c2ecf20Sopenharmony_ci 497ns Select (7 clock cycles) , IOR/IOW after 172ns (2 clock cycles) 1488c2ecf20Sopenharmony_ci (same timing as the Amiga 1200 does on it's IDE port without 1498c2ecf20Sopenharmony_ci accelerator card) 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_civalue 1 1528c2ecf20Sopenharmony_ci 639ns Select (9 clock cycles), IOR/IOW after 243ns (3 clock cycles) 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_civalue 2 1558c2ecf20Sopenharmony_ci 781ns Select (11 clock cycles), IOR/IOW after 314ns (4 clock cycles) 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_civalue 3 1588c2ecf20Sopenharmony_ci 355ns Select (5 clock cycles), IOR/IOW after 101ns (1 clock cycle) 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_civalue 4 1618c2ecf20Sopenharmony_ci 355ns Select (5 clock cycles), IOR/IOW after 172ns (2 clock cycles) 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_civalue 5 1648c2ecf20Sopenharmony_ci 355ns Select (5 clock cycles), IOR/IOW after 243ns (3 clock cycles) 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_civalue 6 1678c2ecf20Sopenharmony_ci 1065ns Select (15 clock cycles), IOR/IOW after 314ns (4 clock cycles) 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_civalue 7 1708c2ecf20Sopenharmony_ci 355ns Select, (5 clock cycles), IOR/IOW after 101ns (1 clock cycle) 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ciWhen accessing IDE registers with A6=1 (for example $84x), 1738c2ecf20Sopenharmony_cithe timing will always be mode 0 8-bit compatible, no matter 1748c2ecf20Sopenharmony_ciwhat you have selected in the speed register: 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci781ns select, IOR/IOW after 4 clock cycles (=314ns) aktive. 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ciAll the timings with a very short select-signal (the 355ns 1798c2ecf20Sopenharmony_cifast accesses) depend on the accelerator card used in the 1808c2ecf20Sopenharmony_cisystem: Sometimes two more clock cycles are inserted by the 1818c2ecf20Sopenharmony_cibus interface, making the whole access 497ns long. This 1828c2ecf20Sopenharmony_cidoesn't affect the reliability of the controller nor the 1838c2ecf20Sopenharmony_ciperformance of the card, since this doesn't happen very 1848c2ecf20Sopenharmony_cioften. 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ciAll the timings are calculated and only confirmed by 1878c2ecf20Sopenharmony_cimeasurements that allowed me to count the clock cycles. If 1888c2ecf20Sopenharmony_cithe system is clocked by an oscillator other than 28,37516 1898c2ecf20Sopenharmony_ciMhz (for example the NTSC-frequency 28,63636 Mhz), each 1908c2ecf20Sopenharmony_ciclock cycle is shortened to a bit less than 70ns (not worth 1918c2ecf20Sopenharmony_cimentioning). You could think of a small performance boost 1928c2ecf20Sopenharmony_ciby overclocking the system, but you would either need a 1938c2ecf20Sopenharmony_cimultisync monitor, or a graphics card, and your internal 1948c2ecf20Sopenharmony_cidiskdrive would go crazy, that's why you shouldn't tune your 1958c2ecf20Sopenharmony_ciAmiga this way. 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ciGiving you the possibility to write software that is 1988c2ecf20Sopenharmony_cicompatible with both the Buddha and the Catweasel Z-II, The 1998c2ecf20Sopenharmony_ciBuddha acts just like a Catweasel Z-II with no device 2008c2ecf20Sopenharmony_ciconnected to the third IDE-port. The IRQ-register $f80 2018c2ecf20Sopenharmony_cialways shows a "no IRQ here" on the Buddha, and accesses to 2028c2ecf20Sopenharmony_cithe third IDE port are going into data's Nirwana on the 2038c2ecf20Sopenharmony_ciBuddha. 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ciJens Schönfeld february 19th, 1997 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ciupdated may 27th, 1997 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_cieMail: sysop@nostlgic.tng.oche.de 210