$Id: README,v 1.8 1993/10/14 00:44:22 delman Exp delman $

This is release 0.7 of atdisk2 patch for Linux. It contains diffs
against Linux 0.99.13 & 0.99.14. Files in this package: README,
0.99.13-diffs, 0.99.14-diffs & makehd1.

!BEWARE! This is BETA code. Use code and instructions at your OWN
risk! THE CODE AND HARDWARE MODIFICATION NOTES IN THIS PACKAGE ARE
PROVIDED "AS IS" WITH NO WARRANTY WHATSOEVER.

[1-Dec-93 Delman Lee <delman@mipg.upenn.edu>]


Introduction
------------

The patch in this package enables Linux to use a second AT-type
(16-bit) hard disk controller with 2 drives maximum attached to it. 

In mid-February 1993, Muhammad Saggaf announced patches for using a
second AT-type HD controller. It turned out that there were others
also working on the same idea. This package merges the efforts into
one. Most of the codes in the patch are done by Muhammand Saggaf
<alsaggaf@Athena.MIT.EDU> and Joel Baldwin <qumqats@citrus.SAC.CA.US>,
I am only the "gift wrapper"! A similar patch was done by Neville
Chandler <nhc@mtdcr.att.com> around 0.95, however it never made it to
the public.

MS-DOS won't be able to recognise the drives on the secondary
controller unless there is on-board BIOS. However, some on-board BIOS
(e.g. Seagate ST-21M) will not handle more than two drives maximum on
the *system*, not on the controller. You will need some driver like
3drvs110.zip for MS-DOS to recognise drives on a 2nd controller
without BIOS. 3drvs110.zip is available on major MS-DOS archive sites.
I myself have not tested 3drvs110.zip out.


Preparation
-----------

1) It is a good idea to low-level format your drives, if required,
BEFORE going onto the hardware modifications in step (2). MFM & RLL
drives require low-level formatting, IDE drives do not.

Remove your primary controller card and drives from the system and
treat your secondary controller and drives as primary as far as
low-level formatting is concerned.

This patch does not use any controller on-board BIOS. So if you are
going to enable the BIOS on your secondary controller for MS-DOS sake,
then low-level format using the controller's BIOS.  Otherwise disable
the BIOS on the controller card, and low-level format the drives with
utilities in, say, the motherboard ROM BIOS.
 
2) You need a controller card that can:
   (i) run at the secondary hard disk I/O ports (0x170-0x177,
       0x376-0x377), and 
   (ii) run on a different IRQ line from your primary controller card.

One should be able to achieve (i) with appropriate jumper settings on
most controller cards. If yours doesn't, get another card that does.

To achieve (ii), some cards have jumpers to change the IRQ line from 14
(the default) to another line. If so, you are in luck; otherwise you
need to do some hardware modification to your controller card. 

--- Hardware Modification ---

This sub-section describes a hardware modification procedure, which
works on my system. I of course cannot guarantee that it will work on
your system, nor can I guarantee that it will not damage your
controller or system. THE CODE AND HARDWARE MODIFICATION NTOES IN
THIS PACKAGE ARE PROVIDED "AS IS" WITH NO WARRANTY WHATSOEVER. Use at
your OWN risk!

If you are not familiar with hardware modification or using a
soldering gun, you should find a hardware "guru" to assist you.

The following is a diagram of the "back" of a 16-bit ISA card. The
back being the side of the board with no chips and components on it
(well not much anyway).


  |                                                          |
  |               side with no components on it              |
  |                                                          |
  |                                      _____               |
  |           B edge connector           |   |       D       | 
  |                                      |   |1            18| 
  ----------------------------------------   -----------------


At the bottom of the card you will see two sets of metal contacts. The
longer set is referred to as the B edge connector and the shorter set
as the D edge connector. XT (8-bit) cards only have the longer B edge
connector. The metal contacts on the controller are called "fingers".

Fingers may only exist at places where an electrical signal actually
reaches there. Because you will be diverting the IRQ signal from one
finger to another contact, it's a good idea to have a controller card
that has fingers even at places where no electrical signals get there.
In particular there would be 18 fingers on the D edge connector.

The fingers on the D edge connector are labelled D1 to D18 from left
to right as shown in the diagram above.  The ones of interest to us
are:

        Finger   IRQ line
          D3        10
          D4        11
          D5        12  
          D6        15   [It is not a typo, D6 is IRQ 15]
          D7        14

Your controller card should have a track going to D7/IRQ14, the
default AT hard disk IRQ line. 

Decide on which IRQ line you want your secondary controller to work
on. Make sure no other cards are using it. [I use IRQ15, Muhammad uses
IRQ10.] 



  |                                                |-..      |
  |                                         ..-----|         |
  |                                                |         |
  |                                                |         |
  |                                                |         |
  |                                      _____     |         |
  |            B edge connector          |   |   I I         | 
  |                                      |   |   I I         |
  ----------------------------------------   -----------------
                                                 D D
                                                 6 7


Let's say you have decided on IRQ15 -- finger D6. One needs to divert
the signal going to finger D7 to D6 as shown in the above diagram. 



  |                                                |-..      |
  |                                         ..-----|         |
  |                                                |x        |
  |                                                          |
  |                                                |x'       |
  |                                      _____   y |         |
  |            B edge connector          |   |   I I         | 
  |                                      |   |   I I         |
  ----------------------------------------   -----------------
                                                 D D
                                                 6 7


Cut the metal track going to the D7 finger with, for example, an
exacto knife. Make sure you cut the track going only to D7, and not
stop the signal going to other parts of the board. This is illustrated
in the above diagram, where the track is cut between points x and x'.

Make a connection from the termination of the track at point x (i.e.
not point x', the end leading to the D7 finger) to the D6 finger at
point y. The connection can be a piece of wire with ends soldered onto
points x and y. This is illustrated in the following diagram:



  |                                                |-..      |
  |                                         ..-----|         |
  |                                               _|x        |
  |                                              |           |
  |                                              | |x'       |
  |                                      _____  y| |         |
  |            B edge connector          |   |   I I         | 
  |                                      |   |   I I         |
  ----------------------------------------   -----------------
                                                 D D
                                                 6 7


If there isn't a finger at D6, then you will have to use your creative
mind to make a metal contact there!

Idea 1: You could take a wire connected to the termination of the
track and squeeze it into the corresponding D6 contact in the
motherboard socket when the board is in; but it's a bit dodgy. Because
there are fingers on both sides of the card, make sure that the wire
you squeezed in neither touch the contact on the other side nor its
adjacent contacts.

Idea 2: One could also use the edge connector of a prototype card sold
in many electronics stores. A prototype card is basically an empty
card with all the fingers on the edge connector. Connect a wire from
the termination of the track on the controller card (point x in
diagram) to the D6 finger of the prototype card, and plug the
prototype card in a free slot. 


Installation
------------

Now that the controller is ready, you can do the software
modification. Source of Linux is assumed to be in /usr/src/linux.

1) Type "cd /usr/src/linux/kernel/blk_drv ; cp hd.c hd1.c"

2) Type "cd /usr/src/linux ; patch < diffs_file", where
   'diffs_file' is the diffs file with full path specified.

3) Edit the line beginning '#define HD1_TYPE {' in
   /usr/src/linux/include/linux/config.h . Read the comments above that
   line to see how to enter your drive geometry. The comments are for
   defining HD_TYPE, define HD1_TYPE in a similar fashion.

   HD_TYPE is for geometries of drives on the primary controller. HD_TYPE
   is not normally required to be defined. Geometries for drives on the
   primary controller are read off the CMOS.

   HD1_TYPE is for geometries of drives on the secondary controller. It
   MUST be defined for this patch to work.

4) In /usr/src/linux/kernel/blk_drv/hd1.c, Edit the line '#define
   HD_IRQ 14' to an interrupt which you have chosen on your
   controller card that isn't being used by another device in the system.

5) (Edit /usr/src/linux/Makefile as per instruction in
    /usr/src/linux/README.) 
   Type "make config". Answer y to 
   'Harddisk on secondary AT-controller support'. 

6) Type "make dep ; make clean".

7) Type "make Image" .... and/or whatever you usually do to install a new
   kernel. 

8) Make the new devices with the 'makehd1' script provided. The naming
   scheme is the same as /dev/hd*, except we now have /dev/hd1*.

9) Reboot the system with the secondary controller and drives
   installed. (The partition check during bootup maybe incorrect for
   /dev/hd1*, since you haven't partitioned it yet.)

10) Partition your the drives on the secondary controller with
    something like "fdisk /dev/hd1a" and/or "fdisk /dev/hd1b".

11) Do something like 'mkfs -c /dev/hd1a?', where ? is the partition
    number [1-8], then everything should be fine!



Miscellaneous
-------------

--- Possible conflicts between controller cards with floppy support ---

There have been reports that: if you have two controller cards, both
with floppy disk support on them, then there *may* be conflicts
between the two cards. Some cards will work just fine together, others
will not. If you encounter floppy disk problems when the two cards
are plugged in, then it's likely to be this problem. Note that
conflict occurs regardless of whether the atdisk2 patches are applied
or not. 

The solution (thanks to Bas Laarhoven <bas@vimec.nl>) is to
disconnect/cut a couple of fingers on the card to which you will NOT
be attaching any floppy drives. The fingers concerned are B6(DRQ2),
B26(DACK2) and B22(IRQ6).

Please DO NOT cut/disconnect them straight away. Verify first that
they are actually the cause of the problem by, for example, sticking
some insulated tape on the above fingers. If the problem go away, then
you can safely cut the connections.


--- Final words ---

Bug reports to delman@mipg.upenn.edu, will try my best to get it fixed
but no guarantees.

The code in this package is due to:
Joel Baldwin <qumqats@citrus.SAC.CA.US>
Ian Justman <ianj@citrus.SAC.CA.US>
Delman Lee <delman@mipg.upenn.edu>
Muhammad Saggaf <alsaggaf@Athena.MIT.EDU>
and numerous people on the KERNEL channel.
