[comp.os.minix] SCSI-disk-device-driver-kit for PC-MINIX-1.5 1/2 Document

nemossan@uitec.ac.jp (Sakurao NEMOTO) (12/19/90)

The followings are originated by k.h@mix.  Mix is a commercail-BBS in  Japan
and it's sister-BBS of BIX, in the US.  Original author has difficulties  to
post here, comp.os.minix,  thus,  I'll post.   If  you  have  any  comments/
questions, please post here or e-mail me, nemossan@uitec.ac.jp.   Please NOT
use kdd-labs path, "nemossan@uitec.ac.jp" is enough.

----------------------------------------------------------------------------
SCSI-disk-driver-kit for Minix-1.5-PC

    This is a document for  Direct-Access-SCSI-Device Driver  and Minix-1.5.
Modification/addition  are  necessary  for  such a device as Magnetic-tapes.

    This is originally made to be used in J3100/J3300, but is also usable in
IBM-PC, PC-AT  and  its compatibles  or  AX-machines in Japan (which is IBM-
compatible and supports Japanese-KANJI).   Usage in a different architecured
machines, such as NEC-PC9801,  needs modification  of  the sources  "scsi.c"
and "sdisk.c".  The utility program  "sdisk.c"  is concerned to be usable in
MS-DOS, too.

	------------------------------------------------------------------
	You can freely use this, if NOT COMMERCIAL and PRIVATE-USAGE only.
	 I disclaim all warranties in these NEWSes, try by your own rsik.
	------------------------------------------------------------------

[0] contents of this kit
1)  readme	this file
2)  scsi.c	source code for SCSI-driver (kernel/scsi.c or kernel/wini.c)
3)  sdisk.c	source code for operation tool for SCSI-disk
			(usable under MINIX or MS-DOS)
4)  minix.cdif	context-diffs for include/minix
			(unnecessary if replace wini.c)
5)  fs.cdif	context-diffs for fs	(unnecessary if replace wini.c)
6)  kernel.cdif context-diffs for kernel



[1] supported hardware
    This is designed to be used with the following hardwares.
1)  Builtin SCSI-interface for Toshiba-J3300-Desktops.
2)  Combination  of  SCSI-interface-board  by  Toshiba  and   Toshiba-J3100-
    Laptops.
3)  Combination of "SPC-card" (see later) and J3100.
4)  Combination  of  hand-made-SCSI-board    (see  circuit  diagram   below)
    and J3100.

    Both 3) and 4) resemble eachgether,   but  3)  means  "made according to
the document of  SPC-card"   and   4)  means "made according to the circuit-
diagram in this kit".

    "SPC-card" is originally made by  "TSURUZO"  at Japanese commercial BBS,
Nifty, which is sister-BBS of  compuserve.  And  SPC is a kit for SCSI-disks
under MS-DOS,  and  it provides circuit-diagram  for hand-made interface and
source code of device driver, formatter  and  partition-maker under  MS-DOS.
This kit,  I have designed to be usable  _ALSO_ in the SPC-board.  This SPC-
board lacks DMA  and  interruput,  which is necessary for  multi-process OSs
like MINIX, but it will be rather easily added by jumpering, as follows;

	/DACK (46) of MB89352  <-->  -DACK3 (56) of PJ1
	DREQ  (45) of MB89352  <-->  DREQ3  (55) of PJ1
	INTR  (46) of MB89352  <-->  IRQ11   (5) of PJ1.

    If jumpering is difficult, compile as NOT use DMA/Interrupt, then it can
be usable.  I/O-port address of this board should be set 0x300.

    If you want to make hardware by yourselves, refer to the circuit diagram
of this kit, it is almost the same as "SPC-card".

    J31SCSI1 board  made by Toshiba  is  one for  adding functions  same  as
builtin  SCSI-interface  of  J-3300 desktops,  and  it  provides  additional
buffers, DIP-switches for selection of channels for  interrupt and DMA, etc,
etc, in short, more flexible design.  If you want to use this board with the
software in this kit, set as follows;

a)  Setting of SW1: I/O ports

	 -----------------
	| o o o o     o o | ON		Thus I/O port is set at 0x300.
	|         o o     | OFF
	 -----------------
	  1 2 3 4 5 6 7 8

b)  Setting of SW1: DMA-channels and interrupt

	 -----------------
	|   o         o   | ON		Thus, IRQ11 and DMA-channel 3.
	| o   o o o o   o | OFF
	 -----------------
	  1 2 3 4 5 6 7 8



[2]  Type of installation
1)  Machine is J-3300 or J-3100?
    Hardware  construction  differ each  other,  for  builtin-SCSI-interface
of  J-3300,  J31SCSI1 I/F-board by Toshiba  and the circuit provided by this
kit.  When using this software in  builtin-SCSI-I/F of J-3300-desktops,  use
the following compile-flag

	#define J3300


1.2  Dependents on usage of the disk.
2)  additional-drive or first-drive? ---- replace kernel/wini.c or not?
    This is the selection of  (a)  use as additional disk or  (b) usage only
SCSI-disk.   The former case,  both builtin SASI  and  additional SCSI disks
can be accessed  at the same time,  because  we use  adding  scsi.c  as well
as conventional  kernel/wini.c.  In this case,  we are  necessary  to modify
files in  include, kernel, fs  directories, because number of devices, which
can be accessed by MINIX  increases.  This kit  provides  CDIFFs  to achieve
these modifications easily.  It will be  a good example  for  adding  device
drivers different from SCSI, where usually manual modifications are necesary.

    In the latter case,  replacement of  kernel/wini.c by scsi.c and several
minor patchs for kernel-stuff are enough. This is applicable for the case of
installing hard-disk-less J3100  or  builtin disk is reserved only to MS-DOS
and not to use in MINIX.  In this case,  copy scsi.c  as  wini.c and use the
following compiler flag

	#define REPLACE


1.3  Dependents on interface (board)
3)  use DMA or not? --- mainly for SPC-card
    This is the selection between usage of DMA or program-I/O.   In the case
of MINIX, DMA should be used because this is multitask OS, but original SPC-
card cannot handle DMA,while DMA can be used only jumpering mentioned above.
    In case of J31SCSI-card by Toshiba, DMA can be selected by DIP-switchs.

    When you use DMA, define the following at the compile time;

	#define DMA

    DMA-channel is defined as 3, but you can modify the #define statement in
scsi.c

	#define DMA_CHANNEL	3

    It should be  noticed  that  hardware of IBM-PC or PC-AT  cannot  access
beyond 64 KB boundary  of memory,  otherwise  system hangs up.   In  such  a
case,  we should decide  not to use DMA  or  move buffer cashe address,  but
I have  no such experience.   Program  is  coded  to cause  system-halt when
occurred DMA-access beyond 64 KB boundary displaying occurrence of it.


4)  use interrupt or not? ---- mainly for SPC-card
    In Multitask OSs as MINIX, DMA and interrupt should be used, but in case
of SPC-card, initially designed for MS-DOS,  has  no interrupt, and even the
hardware can treat interrupt,sometimes it is not usable because of collision
with another hardware.

    If you use interrupt, define the following flag at the compile time,

	#define INTERRUPT

otherwise  input/output  will be done by  busy-wait.   Interrupt channel  is
defined as its default value 11 in the following  #define in  kernel/const.h

	#define SCSI_IRQ	11

    You   can  removed  _scsi_int()   of   kernel/mpx.x   or  _cim_scsi() of
kernel/klib.x  if you don't  use  interrupt,   but  waste of memory  amounts
little, even they exist.


1.4  Dependents of SCSI-drives.
    The followings are  normally need not to specify.  When you met trouble,
it may be useful.

5)  available "READ CAPACITY" command or not?
    At compile time of scsi.c, if you specify

	#define USE_MODESENSE

then program gets  information about blocksize and  disk-capacity  utilizing
"MODE SENCE" command of SCSI.

    If not,  it uses  "READ CAPACITY"  commands.   If  you are using  a disk
which has no "READ CAPACITY" command, specify this flag, otherwise it is not
necesarry.


6)  available "GROUP0" command or not?
    At the compile time of scsi.c, if you define

	#define GROUP0

program uses "GROUP 0" command  instead of "GROUP 1" command  to  read/write
the disk.
    This is usually unnecessary, but if you use small capacity drive and has
only "GROUP 0" command, it is necessary to specify it.


7)  necessary to specify block (sector) size or not?
    At the compile time of scsi.c, if you specify

	#define BLOCKSIZE	512

or

	#define BLOCKSIZE	256

then program treats as if block (sector) size is that value.

    Normally,  blocksize  (sector size)  is  obtained by  "READ CAPACITY" or
"MODE SENCE" command,  thus it is not necessary.   But  if you use primitive
drives which can handle only  read/write of SCSI interface,  it is nenessary
to specify it.  In such a case, you are necessary to modify sdisk.c, too.


1.5  Options to debugging
    Scsi.c has further flags for debuggings or studyings as follows.

8)  #define C_DRIVER
    If you specify this flag, I/O access of SCSI-disks are made only scsi.c.
It is  slower  than assembler routine  added to kernel/klib.x,  but  if  you
specify this,  kernel/klib.x can be left unchanged, thus checking algorithms
or developing/studying becomes easier.

    If not specify this,  input/output  will be done by Direct-Memory-Access
through DMA controller or busy wait via _scsi_read()/_scsi_write() in kernel
/klib.x.


9) #define DEBUG
    This is the flag for debugging informations and tracing.



[3]  outline of installing processes
1)  making kernel
    First step is making a boot-disk which contains kernel with SCSI-driver.
    This process is  different  from the condition mentioned above, first is
the one  where SCSI-drivers only  is used  and the other  is the  one  where
coventional Hard-drive and the SCSI-drive are  used at  the same time.   The
former is more simple.


2)  Formatting and patitioing of SCSI-disk
    Normal MINIX-1.5  permits  upto 64 MB of  one file system,  thus  larger
disk drive more than it should be divided into partitions.   Partitioning is
made by sdisk, which resembles to fdisk-program of MINIX-1.5 and it performs
physical-formatting,  media checking  of  SCSI-disk  and  making/displaying/
changing of partitions.  If you use small sized disk and total area of it is
assigned to one file system (mount as /dev/sd0, sd1 etc), partition table is
unnecessary.


3)  Making device file
    Make  device file  of  SCSI-drives  using  mknod or mkfs.  Will be shown
later.



    Followings are the more detailed procedures of installation.

[4] In case where _ONLY_ SCSI-drive is used
    In case of  no builtin hard-disk  or  not use  hard disk  as  MINIX-file
system,   replace   kernel/wini.c  by  scsi.c,  and  patch  by  kernel.cdif.
"kernel.cdiff"  of  this kit  contains  CDIFFs  for  "Makefile",  "const.h",
"floppy.c",   "klib.x",   "main.c",   "mpx.x",  "protect.c",  "proto.h"  and
"table.c".  When  you use  these codes  in  8086-CPUs,  such as  J3100-SS or
J3100-SL, and with SPC-card neither DMA nor interrupt, patches for

	klib.x, sconst.h, floppy.c

are  enough.  In case of  80286/80386-CPUs,  all  of  the patches  should be
applied.   In  case  of  J3100-SS/J3100-SL,   2HC-formatted   (PC-AT-format,
1185.5 kB) floppies can't be read  unless  usage of  already patched  kernel
to floppy.c,  thus, this process  should be made by  other machines.   While
in case of 286/386-CPUed J3100/J3300 machines,  patching to  floppy.c is not
necessary, and even patch is done no harm will occur.

    Example of patching is as follows;

	# cd kernel
	# patch <kernel.cdif
	# cp scsi.c wini.c

Then, make active #defines of wini.c copied from scsi.c as

	#define REPLACE

and according to your environment make active several flags as

	#define J3300		/* make active if J-3300 DeskTops*/
	#define DMA		/* make active if DMA is available */
	#defile INTERRUPT	/* make active if interrupt available */

then make new kernel as

	# make kernel


    In case of  SPC-card,  let inactive  "#define J3300",  "#define DMA" and
"#define INTERRUPT" flags.  If you have jumpered mentioned above, the latter
two-flags can be  active,  but  in this case  patching to  "mpx.x"  is  also
necessary.

    In case of J-3300, J31SCSI1-board and the circuit-diagram of this kit, I
recommend to specify  "#define DMA"  and  "#define INTERRUPT", but they will
work even not specified these flags.


    Next step is  "make image"  to get "BOOT DISK", refer to the document of
MINIX-1.5.



[5] Addition of SCSI-disk
    To add SCSI-disk besides builtin-hard-disk  requires many changes.
    Processes of adding SCSI-drivers according to this kit is as follows;

1)  Patch "include/minix/config.h", "const.h" and "com.h" by "minix.cdif".
2)  Patch "fs/const.h" and "table.c" by "fs.cdif".
3)  Patch by "kernel.cdif" to
	kernel/Makefile, kernel/const.h, kernel/floppy.c, kernel/klib.x, 
	kernel/main.c, kernel/mpx.x, kernel/protec.c, kernel/proto.h, 
	kernel/sconst.h.

    After patches mentioned above,  copy  "scsi.c"  to  kernel-directory and
compile _ALL_ of fs, kernel and mm.



[6] Making device file
    Major/minor numbers of the device files are as follows;

1)  Major number
    Major number  is  decided  by "include/com.h", "kernel/table.c" and "fs/
table.c".  In this kit, numbers are as follows;

	in case replace wini.c by scsi.c		3
	in case adding SCSI besides builtin drive(s)	7.

    I've adopted 7 in latter case, because as usual I think net* device will
not be used.  If you need net*-device the number should be changed.


2)  Minor number
    Minor number is decided by "scsi.c", SCSI-driver.  Now, it is set as

	MSB                       LSB
	x   x   x   x   x   x   x   x		bit
	|       |   |   |   |       |
	+---+---+   +-+-+   +---+---+
	    |         |         |
	    |         |         +--- partition: 0 - 7
	    |         +--- LUN: Logical Unit Number of SCSI device (0 - 3)
	    +--- ID: ID of SCSI device (0 - 7)

    "ID" is a number to distinguish every  SCSI-device, and usually set from
0 to 7 by builtin DIP-switches of the apparatus. In many cases 7 is assinged
to computer and peripheral devices are assigned to  0, 1, 2...   This device
driver also  assings  7 to SCSI-ID of the computer, so assign from 0 to 6 to
the disks.   If you have more than one drives, assign independent numbers to
the different drives.

    LUN (Logical Unit Number) is  a  number to  identify sub-device of every
SCSI-device and cotrolled by SCSI-controller,  and it can be assigned from 0
to 7.   But in this device driver,  number of it  is restricted from 0 to 3.
Almost all of SCSI-interfaced builtin drives  only 0  is available.

    Partition number  can be used  from  0 to 7,  but in this device-driver,
number 0 is reserved as "whole device"  to access  whole part  of  the disk.
This system  is  convenient  to operate  partition-table  within  MINIX,  or
rewriting boot-sectors, but on the other hand, damage on disk will happen by
careless access to it.


    Making of  device file will be done by mknod or mkfs.  In case of mknod,
for examples, following operation may be necessary to use partition 0, 1, 2,
3 and 4 in case of replacing wini.c by scsi.c (major number is 3),

	# mknod /dev/sd0 b 3 0 0
	# mknod /dev/sd0a b 3 1 0
	# mknod /dev/sd0b b 3 2 0
	# mknod /dev/sd0c b 3 3 0
	# mknod /dev/sd0d b 3 4 0

    "0" in last column  is peculiar to MINIX and specifies blockcount of the
device, and to specify "0" means infinite.  If you want to precisely define,
set appropriate number of them.

    If you want two disk-drives, following specification may be better;

	# mknod /dev/sd0 b 3 0 0
	# mknod /dev/sd0a b 3 1 0
	# mknod /dev/sd0b b 3 2 0
	# mknod /dev/sd0c b 3 3 0
	# mknod /dev/sd0d b 3 4 0
	# mknod /dev/sd1 b 3 32 0
	# mknod /dev/sd1a b 3 33 0
	# mknod /dev/sd1b b 3 34 0
	# mknod /dev/sd1c b 3 35 0
	# mknod /dev/sd1d b 3 36 0

    This rule of naming  specifies  the string  "sd"  as SCSI-disk,  and the
number follows for ID, final "a", "b", "c" ... specifies paritions.    Names
of the devices  can be allocated  freely, but the more the number of devices
or partitions the more difficult to decide the names of them.


    In the case of adding SCSI-disk (major number is 7) and use partition 0,
1, 2, 3, 4, make device file as

	# mknod /dev/sd0 b 7 0 0
	# mknod /dev/sd0a b 7 1 0
	# mknod /dev/sd0b b 7 2 0
	# mknod /dev/sd0c b 7 3 0
	# mknod /dev/sd0d b 7 4 0

If you are using  the "ROOT FILE SYSTEM"  copied  from floppy disk  in  boot
time, you must also copy back or make these device files to floppy ROOT file
system.  Or you will lose these special files at next boot time.

    If you make device file by mkfs, at first make "protofile", refer to the
Minix-1.5 manual.  This is a very useful way to make a new file system.


    Thus you can use SCSI-disk.  Booting up the system, and try

	# dd if=/dev/sd0 of=/dev/null count=1000

and if access-lamp makes ON and  command nomally terminates,  almost all  of
the steps successfully made.

    If you have missed "mknod"ing of sd0 or setting ID of SCSI-disk or power
of the drive is OFF, the system will be hung up.   This is the same  for the
commands mkfs, mount, ..., which access the disk.  To avoid this hanging up,
insertion of "timeout" function to scsi.c is necessary.  I've decided not to
install this function  because  memory is precious in  MINIX.  I  don't know
this is the best choice or not.

    If  we specify a name which does not exist in  /dev  in  "mkfs"ing,  the
curious file will be made at /dev.  This, I think, is from bug of "mkfs".



[8] making partition-table -- sdisk
    If you are necessary making partition-table, compile sdisk.c and exec

	sdisk [-r] [id [lun]]

where
	-r:	replace bad blocks at the time of "verify"
	id:	ID of SCSI-device (0--7)		default:0
	lun:	Logical Unit Number of the SCSI-device	default:0.

In case of normal external adding drive, specify as

	sdisk

or

	sdisk 0

In MINIX,  I/O access of sdisk is made through /dev/mem, thus speed is slow,
be patient.  And you can not use this program in this way on the _SAME_ SCSI
disk in current use.  You can execute this operation only on another disk or
floppy file system,  or  in MS-DOS.   Otherwise  it causes  system  clush by
collision  between  device driver (scsi.c)  and  sdisk.c. On the _SAME_ SCSI
disk you can only use the type of format

	sdisk /dev/sd0

which enables you only to read and modify patition table but not to physical
format.

    Changing sdisk.c  by "completed"  SCSI-driver in  /dev/sd*,  access will
be rather speed up and  avoid this problem.  But we will not be able to pre-
pare SCSI drives without SCSI driver.

    Starting "sdisk",  it will show, at first, total number of blocks of the
disk and its block size, then the following menu will be shown

	1 show partition table
	2 change partition table
	3 format disk
	4 verify disk
	q quit

select  appropriate number.  Usually  SCSI-disks  are shipped after physical
formatting,  thus  item-3 or 4  is  unnecessary.  Installation  of "4 verify
disk", here, is not good one,  it performs  block after block, thus too slow
in speed.  Modification of it to do several blocks  at once,  speed up  will
be easily obtained.

    Usually  item-1, 2 and q  are used.  If you specify item-2, program asks
you block-count or number of starting/ending-blocks, for every partition.

Thus specify

	number_of_blocks<Enter>

or

	number_of_starting_block  number_of_ending_block<Enter>.

Pressing only <Enter> will make every 32 MB sized partiton from the start.

    Final partition contains several informations currently not used as well
as  its  check-sum.  These  may be useful if you make primitively interfaced
board which can handle only Read/Write of SCSI.


    This program  is  prepared as  Xmas-present 1990,  so time is limited to
deliver, thus  I have remained  many things to implement or to improve,  for
example ability of sharing Hard-disk with other OSs.

    "sdisk.c" can be used in MS-DOS environment  if  compiled with the -DDOS
flag.  It contains several functions convenient to make experiments in MINIX
or MS-DOS, thus it will be useful for experiments or understanding SCSIs.



[9] Structure of partition-table
    Structure of partition-table  is  system-dependent.   The  structure  of
the table  here mentioned  is  as follows,  and  its  original idea is after
takamiti@mix, installer MINIX-1.5 into NEC-PC9801.   This  intends to future
various expansions.

struct scsi {
  struct {
	unsigned char Mnt_Id;		/* currently unused */
	unsigned char Sys_Id;		/* system identifier*/
	unsigned char unused[2];	/* currently unused */
	unsigned long ipl;		/* IPL positon of sector - unused */
	unsigned long start;		/* start secter of this partition */
	unsigned long last;		/*  end  secter of this partition */
	unsigned char name[16];		/* system name */
  } part_info[15];
  char sc_unused[30];			/* currently unused */
  short sc_magic;			/* check sum */
} scsi[7];

    Total size of the table is 512-bytes, and in the first 480-bytes upto 15
partitions can be described.   But in "scsi.c", design of major/minor number
limits partition from 0 to 7,  and  partition-0 means whole disk, thus seven
partitions only are used.  If you want more, modify major/minor-related part
of "scsi.c" as well as

	#define MAX_PARTITION	8

    Mnt_Id and ipl fields  are  reserved  for future to boot from the ROM on
SCSI-board, and currently it is set to 0.

    Sys_Id field  is  used to  indentfy MINIX-system  from other OSs, and it
uses 0xc0 value for MINIX.  Sys_Id for unused partition table is set to 0.

    In sc_magic field at the final 2-bytes contains sum of former 510 bytes,
and they are used to check validity of partition-table at the initialization
of the driver.

    This partition table  is  placed on  the second block  of the disk,  and
first block  is  reserved to  future Initial Program Loader (IPL).   You may
allow  coexistence  of other OSs where partition table is placed here, first
block.



[10] circuit diagram for hand-made interface

	Here is a sample circuit to use this driver in J-3100 expansion slot.
This can also be usable in IBM-PC, XT, AT  by very minor changes.

Parts List:
Universal Board*	KEL BB07-15			1
60P Connector*		KEL 8801-060-170L		1
40P Connector*		KEL 8801-040-170L		1
SCSI CONNECTOR						1
LSI			Fujutsu MB89352			1
TTL			74LS688				1
TTL			74LS04				1
TTL			74LS125				1
Xtal oscilator		8MHz				1
Terminator		BECKMAN 898-5-R220/330		2
8P DIP Switch						1
Bypass capactor		tantalum or ceramic		6 or more

The parts marked by '*' are for J-3100 only. (see notes bellow)

Sample Layout:

    +------------------------+  +---------------------------------------+
    |          KEL           |  |                KEL                    |
+---+     8801-040-170L      +--+           8801-060-170L               +---+
|   |          PJ2           |  |                PJ1                    |   |
|   +------------------------+  +---------------------------------------+   |
|                                                                           |
|                                                                           |
|                                                                           |
|                                                                           |
|                                                  +------------------+     |
|                                                  |   8P DIP SWITCH  |     |
|                                                  +------------------+     |
|                                                                           |
|                                                                           |
|                                                                           |
|    +-------------+       +--------------+       +--------------------+    |
|    |   74LS125   |       |    74LS04    |       |       74LS688      |    |
|    +-------------+       +--------------+       +--------------------+    |
|        +--------------------------------------------------------+         |
|        |                                                        |         |
|        |                                                        |         |
|        |                       MB89352                          |         |
|        |                                                        |         |
|        |                                                        |         |
|        +--------------------------------------------------------+         |
|        +--------------+      +--------------+    +--------------+         |
|        |  8MHz Xtal   |      |  TERMINATOR  |    |  TERMINATOR  |         |
|        |  OSCILATOR   |      |  (REGISTOR)  |    |  (REGISTOR)  |         |
|        +--------------+      +--------------+    +--------------+         |
|    +-----------------------------------------------------------------+    |
|    |                                                                 |    |
+----+                    SCSI BUS CONNECTOR                           +----+
     |                           (CN1)                                 |
     +-----------------------------------------------------------------+



Circuit Diagram:

                            74LS688
                         +----------+   DIP-SW
AEN     (PJ1-57)---------+01        |  +-----+
SA11    (PJ1-22)---------+02      03+--+ o/o +--+ SW1-1 ON
SA10    (PJ1-21)---------+04      05+--+ o/o +--+ SW1-2 ON
SA9     (PJ1-20)---------+06      07+--+ o/o +--+ SW1-3 OFF Setup for
SA8     (PJ1-19)---------+08      09+--+ o/o +--+ SW1-4 OFF base address
SA7     (PJ1-17)---------+11      12+--+ o/o +--+ SW1-5 ON  to 0x300
SA6     (PJ1-16)---------+13      14+--+ o/o +--+ SW1-6 ON
SA5     (PJ1-15)---------+15      16+--+ o/o +--+ SW1-7 ON
SA4     (PJ1-14)---------+17  19  18+--+ o/o +--+ SW1-8 ON
                         +----+----+   +-----+  |
                              |           +5V --+--
                              |          --+--  GND
                              |            |
                    74LS04    |      +-----+------+
                    +----+    +------+02  48      | MB98352
RESET   (PJ1-48)----+1  2+-----------+01          |
                    +----+           |          17+----@----DB0 (CN1-02)
SA3     (PJ1-13)---------------------+06        15+----@----DB1 (CN1-04)
SA2     (PJ1-12)---------------------+05        14+----@----DB2 (CN1-06)
SA1     (PJ1-11)---------------------+04        13+----@----DB3 (CN1-08)
SA0     (PJ1-10)---------------------+03        11+----@----DB4 (CN1-10)
                                     |          10+----@----DB5 (CN1-12)
SD7     (PJ1-40)---------------------+29        08+----@----DB6 (CN1-14)
SD6     (PJ1-39)---------------------+28        07+----@----DB7 (CN1-16)
SD5     (PJ1-38)---------------------+27        18+----@----DBP (CN1-18)
SD4     (PJ1-37)---------------------+26          |
SD3     (PJ1-35)---------------------+25          |
SD2     (PJ1-34)---------------------+23        42+----@----ATN (CN1-32)
SD1     (PJ1-33)---------------------+22        32+----@----BSY (CN1-36)
SD0     (PJ1-32)---------------------+21        41+----@----ACK (CN1-38)
IRQ11   (PJ2- 5)---------------------+30        31+----@----SRST(CN1-40)
DREQ3   (PJ1-55)---------------------+45        38+----@----MSG (CN1-42)
-DACK3  (PJ1-56)---------------------+46        34+----@----SEL (CN1-44)
-IOR    (PJ1-45)---------------------+43        36+----@----C/D (CN1-46)
-IOW    (PJ1-44)-----------+---------+44        39+----@----REQ (CN1-48)
                           |         |          35+----@----I/O (CN1-50)
             +5V        +--+--+      |            |
           --+--        | 1  2+------+19          |    +----GND (CN1-20)
             |          +    3+------|20        09+----+----GND (CN1-22)
         +---+---+ 8MHz +-----+      |          16+----+----GND (CN1-24)
  8MHz   |VCC    |      74LS125      |          33+----+----GND (CN1-24)
  osc.   |GND OUT+-------------------+47  24    40+----+----GND (CN1-28)
         +---+---+                   +-----+------+    +----GND (CN1-30)
             |                             |           +----GND (CN1-34)
           --+-- GND                     --+--         +----GND (CN1-1)
                                          GND          +----GND (CN1-3)
                                                       +----GND (CN1-5)                                             +5V                +----GND (CN1-7)
+5V (PJ1-02)-------------------------+--               +----GND (CN1-9)
GND (PJ1-01)-+      '@' meants       |                 +----GND (CN1-11)
GND (PJ1-09)-+       pullup        220 ohm             +----GND (CN1-13)
GND (PJ1-18)-+                       |                 +----GND (CN1-15)
GND (PJ1-27)-+     ----@---  ==  ----+----             +----GND (CN1-17)
GND (PJ1-43)-+                       |                 +----GND (CN1-19)
GND (PJ1-51)-+       BECKMAN       330 ohm             +----GND (CN1-21)
GND (PJ1-69)-+    898-5-R220/330     |                 +----GND (CN1-23)
             |    or equivalent    --+--               |
           --+--                    GND              --+--
            GND                                       GND


Notes:

1) You can use this circuit on IBM-PC/AT by replacing PJ1 and PJ2 assignments
	as follows.

	AEN(A11)     SA11(A20)     SA10(A21)     SA9(A22)      SA8(A23)
	SA7(A24)     SA6(A25)      SA5(A26)      SA4(A27)      SA3(A28)
	SA2(A29)     SA1(A30)      SA0(A31)      -IOW(B13)     -IOR(B14)
	SD7(A2)      SD6(A3)       SD5(A4)       SD4(A5)       SD3(A6)
	SD2(A7)      SD1(A8)       SD0(A9)       RESET(B2)     IRQ11(D4)
	+5V(B3,B29,D16)		   GND(B1,B10,B31,D18)

2) You should use one tantalum or ceramic bypass capacitor for each IC's and
	terminator's +5V pin.

3) Connect No.3, 5, 9, 11, 13 of LS04 and No.4, 5, 9, 10, 12, 13 of LS125 to
	VCC (+5V).



[11] Introduction to SCSI
    SCSI  is  abbreviated from  "Small Computer System Interface"  and  this
is  the interface between  computer(s) and peripheral device(s). Each device
is assigned  an ID (identify) number from 0 to 7,  and this number is set by
builtin DIP-switches  or  software, not to  duplicated.   Up to 7 peripheral
devices can be  connected to  one or more computer(s) through  SCSI-cable in
runs as shown.

	 ----------   ----------   ----------            ----------
	| SCSI ID0 | | SCSI ID1 | | SCSI ID2 |   ...    | SCSI ID7 |
	 ----------   ----------   ----------            ----------
	      *|         |  |         |  |                  |*
	       +---------+  +---------+  +------     -------+
		SCSI cable   SCSI cable        SCSI cable

    At the  both ends  of the  cables  (shown as  "*"  in the figure), there
necessary  "terminator"  in  order to  avoid distortion  by  reflection   of
signals.  The terminator  has two types,  one is builtin-type, the other  is
connecter-type,  which is  used  in the  hard-disks  usualy  has  two  SCSI-
receptacles.  Maximum total length  of the SCSI cable is limited to 6 meters
in case of unbalanced type cable commonly used.

    Every device can contain upto 8 (from No.0 to 7) internal devices, which
are managed by its own controller of the device. Internal devices are called
Logical Unit Number (LUN),  and these  can be accessed from other devices in
the SCSI interface, thus maximum devices to be connected amounts upto 64.

    SCSI interface is a extension of SASI hard-disk interface of SUGART co.,
and standardized as  ANSI X.3.131-1986.   On  extension,  floppy-disks, mag-
netic-tapes, high-speed-printers,  Magneto-Optical-disks (MO-disk),  CD-ROMs
and other computers as well as hard-disk are taken into account and commands
for the following devices are standardized.

	1) Direct access devices:		floppy, hard-disk, MO-disk
	2) Sequential access devices:		Magnetic tape
	3) printers
	4) processers (computers)
	5) one-time write, multi-read devices:	Optical disk
	6) read only devices:			CD-ROM

    But standardization  of  command  is  not complete  and  there are  many
"vendor unique" commands  inherent  to devies, thus  limitting compatibility
between the same devices from other companies.

    In the SCSI-connected machines,  computers are called as "initiator" and
the others are called as "target". At first control is started by initiator,
then target, peripheral devices, obtain initiative.



[12] Literature
    The followings  are  the literatures  which I have bought at the time of
developing this device-driver.

1)	ANSI X3.131-1989
    After this standard, "Common Command Set" is released, thus expansion of
SCSI-standard has been done.

2)	User's manual of SCSI-protocol-controller MB89352, by Fujitsu
    This is  the document  for  main LSI  of  the hardware treated  in  this
document.   To   know  further hardware-level  information,  "DATA SHEET" is
necessary.  (I don't know if English-version of them are available or not.)

Further literatures are omitted, because it is written in Japanese Language.

If you know better literatures, please let me know them.


					k.h@NIKKEI-MIX, 1990-12-19

Partialy translated into broken :-) English by

		Dec 19 '90 (We) nemossan@mix,   nemossan@uitec.ac.jp
    (Description of HardWare circuit diagram is written by
     original author in English.)