^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) =====================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) Amiga Buddha and Catweasel IDE Driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) =====================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) The Amiga Buddha and Catweasel IDE Driver (part of ide.c) was written by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) Geert Uytterhoeven based on the following specifications:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) ------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) Register map of the Buddha IDE controller and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) Buddha-part of the Catweasel Zorro-II version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) The Autoconfiguration has been implemented just as Commodore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) described in their manuals, no tricks have been used (for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) example leaving some address lines out of the equations...).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) If you want to configure the board yourself (for example let
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) a Linux kernel configure the card), look at the Commodore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) Docs. Reading the nibbles should give this information::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) Vendor number: 4626 ($1212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) product number: 0 (42 for Catweasel Z-II)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) Serial number: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) Rom-vector: $1000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) The card should be a Z-II board, size 64K, not for freemem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) list, Rom-Vektor is valid, no second Autoconfig-board on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) same card, no space preference, supports "Shutup_forever".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) Setting the base address should be done in two steps, just
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) as the Amiga Kickstart does: The lower nibble of the 8-Bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) address is written to $4a, then the whole Byte is written to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) $48, while it doesn't matter how often you're writing to $4a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) as long as $48 is not touched. After $48 has been written,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) the whole card disappears from $e8 and is mapped to the new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) address just written. Make sure $4a is written before $48,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) otherwise your chance is only 1:16 to find the board :-).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) The local memory-map is even active when mapped to $e8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) ============== ===========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) $0-$7e Autokonfig-space, see Z-II docs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) $80-$7fd reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) $7fe Speed-select Register: Read & Write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) (description see further down)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) $800-$8ff IDE-Select 0 (Port 0, Register set 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) $900-$9ff IDE-Select 1 (Port 0, Register set 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) $a00-$aff IDE-Select 2 (Port 1, Register set 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) $b00-$bff IDE-Select 3 (Port 1, Register set 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) $c00-$cff IDE-Select 4 (Port 2, Register set 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) Catweasel only!)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) $d00-$dff IDE-Select 5 (Port 3, Register set 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) Catweasel only!)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) $e00-$eff local expansion port, on Catweasel Z-II the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) Catweasel registers are also mapped here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) Never touch, use multidisk.device!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) $f00 read only, Byte-access: Bit 7 shows the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) level of the IRQ-line of IDE port 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) $f01-$f3f mirror of $f00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) $f40 read only, Byte-access: Bit 7 shows the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) level of the IRQ-line of IDE port 1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) $f41-$f7f mirror of $f40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) $f80 read only, Byte-access: Bit 7 shows the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) level of the IRQ-line of IDE port 2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) (Catweasel only!)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) $f81-$fbf mirror of $f80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) $fc0 write-only: Writing any value to this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) register enables IRQs to be passed from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) IDE ports to the Zorro bus. This mechanism
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) has been implemented to be compatible with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) harddisks that are either defective or have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) a buggy firmware and pull the IRQ line up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) while starting up. If interrupts would
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) always be passed to the bus, the computer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) might not start up. Once enabled, this flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) can not be disabled again. The level of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) flag can not be determined by software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) (what for? Write to me if it's necessary!).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) $fc1-$fff mirror of $fc0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) $1000-$ffff Buddha-Rom with offset $1000 in the rom
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) chip. The addresses $0 to $fff of the rom
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) chip cannot be read. Rom is Byte-wide and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) mapped to even addresses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) ============== ===========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) The IDE ports issue an INT2. You can read the level of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) IRQ-lines of the IDE-ports by reading from the three (two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) for Buddha-only) registers $f00, $f40 and $f80. This way
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) more than one I/O request can be handled and you can easily
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) determine what driver has to serve the INT2. Buddha and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) Catweasel expansion boards can issue an INT6. A separate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) memory map is available for the I/O module and the sysop's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) I/O module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) The IDE ports are fed by the address lines A2 to A4, just as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) the Amiga 1200 and Amiga 4000 IDE ports are. This way
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) existing drivers can be easily ported to Buddha. A move.l
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) polls two words out of the same address of IDE port since
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) every word is mirrored once. movem is not possible, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) it's not necessary either, because you can only speedup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 68000 systems with this technique. A 68020 system with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) fastmem is faster with move.l.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) If you're using the mirrored registers of the IDE-ports with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) A6=1, the Buddha doesn't care about the speed that you have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) selected in the speed register (see further down). With
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) A6=1 (for example $840 for port 0, register set 0), a 780ns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) access is being made. These registers should be used for a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) command access to the harddisk/CD-Rom, since command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) accesses are Byte-wide and have to be made slower according
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) to the ATA-X3T9 manual.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) Now for the speed-register: The register is byte-wide, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) only the upper three bits are used (Bits 7 to 5). Bit 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) must always be set to 1 to be compatible with later Buddha
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) versions (if I'll ever update this one). I presume that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) I'll never use the lower four bits, but they have to be set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) to 1 by definition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) The values in this table have to be shifted 5 bits to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) left and or'd with $1f (this sets the lower 5 bits).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) All the timings have in common: Select and IOR/IOW rise at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) the same time. IOR and IOW have a propagation delay of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) about 30ns to the clocks on the Zorro bus, that's why the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) values are no multiple of 71. One clock-cycle is 71ns long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) (exactly 70,5 at 14,18 Mhz on PAL systems).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) value 0 (Default after reset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 497ns Select (7 clock cycles) , IOR/IOW after 172ns (2 clock cycles)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) (same timing as the Amiga 1200 does on it's IDE port without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) accelerator card)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) value 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 639ns Select (9 clock cycles), IOR/IOW after 243ns (3 clock cycles)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) value 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 781ns Select (11 clock cycles), IOR/IOW after 314ns (4 clock cycles)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) value 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 355ns Select (5 clock cycles), IOR/IOW after 101ns (1 clock cycle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) value 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 355ns Select (5 clock cycles), IOR/IOW after 172ns (2 clock cycles)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) value 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 355ns Select (5 clock cycles), IOR/IOW after 243ns (3 clock cycles)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) value 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 1065ns Select (15 clock cycles), IOR/IOW after 314ns (4 clock cycles)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) value 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 355ns Select, (5 clock cycles), IOR/IOW after 101ns (1 clock cycle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) When accessing IDE registers with A6=1 (for example $84x),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) the timing will always be mode 0 8-bit compatible, no matter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) what you have selected in the speed register:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 781ns select, IOR/IOW after 4 clock cycles (=314ns) aktive.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) All the timings with a very short select-signal (the 355ns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) fast accesses) depend on the accelerator card used in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) system: Sometimes two more clock cycles are inserted by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) bus interface, making the whole access 497ns long. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) doesn't affect the reliability of the controller nor the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) performance of the card, since this doesn't happen very
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) often.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) All the timings are calculated and only confirmed by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) measurements that allowed me to count the clock cycles. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) the system is clocked by an oscillator other than 28,37516
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) Mhz (for example the NTSC-frequency 28,63636 Mhz), each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) clock cycle is shortened to a bit less than 70ns (not worth
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) mentioning). You could think of a small performance boost
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) by overclocking the system, but you would either need a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) multisync monitor, or a graphics card, and your internal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) diskdrive would go crazy, that's why you shouldn't tune your
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) Amiga this way.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) Giving you the possibility to write software that is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) compatible with both the Buddha and the Catweasel Z-II, The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) Buddha acts just like a Catweasel Z-II with no device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) connected to the third IDE-port. The IRQ-register $f80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) always shows a "no IRQ here" on the Buddha, and accesses to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) the third IDE port are going into data's Nirwana on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) Buddha.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) Jens Schönfeld february 19th, 1997
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) updated may 27th, 1997
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) eMail: sysop@nostlgic.tng.oche.de