=============================================================================
          MOXA Smartio/Industio Family Device Driver Installation Guide
		    for FreeBSD 4.x/5.x
	       Copyright (C) 2005, Moxa Technologies Co, Ltd.
=============================================================================
Date: 

Content

0. Note
1. Introduction
2. System Requirement
3. Installation
   3.1 Hardware installation
   3.2 Driver files   
   3.3 Device naming convention
   3.4 Module driver configuration   
   3.7 Custom configuration
   3.8 Verify driver installation
4. Utilities
5. Setserial
6. Troubleshooting

-----------------------------------------------------------------------------
0. Note
      
   0.1 Installation step summary.   
   
      Hardware installation:
      	Refer to the "3.1 Hardware installation".
      	
      Software/driver installation:	   	
        0.2.1 Extract the Moxa driver: Refer to the "3.2 Driver files".
-----------------------------------------------------------------------------
1. Introduction

   The Smartio/Industio family FreeBSD driver supports following multiport 
   boards.

   Smatio:
	C104H, C104HS, C104H/PCI, C104HS/PCI, 
	C168H, C168HS, C168H/PCI, C168P, 
	CI-104J, CI-104JS
	CP-104UL, CP-104JU,	CP-168U,
	CP-118U, CP-102U, CP-102UL,
	CP-118EL, CP-168EL, CP-104EL

   Industio:
	CI-132, CI-132I, CI-123IS, 
	CI-134, CI-134I, CI-134IS, 
	CP-132, CP-132I, CP132S, CP-132IS, 
	CP-114, CP-114I, CP-114S, CP-114IS,
	CP-132U-I, CP-132UL,
	CP-134U, CP-134U-II
	CT-114I,

   This driver and installation procedure have been developed upon FreeBSD
   4.6/5.3 and compatible to all 4.x/5.x. This driver supports Intel x86 
   hardware platform. However, if compatibility problem occurs, please contact
   Moxa at support@moxa.com.

   In addition to device driver, useful utilities are also provided in this
   version. They are
    - msdiag     Diagnostic program for displaying installed Moxa 
                 Smartio/Industio boards.
    - io-irq.exe Configuration program to setup ISA boards. Please note that
                 this program can only be executed under DOS.

   All the drivers and utilities are published in form of source code under
   BSD License in this version. Please refer to BSD License announcement 
   in each source code file for more detail.

   This version of driver can be installed as Loadable Module (Module driver).
   You may refer to following installation procedure. Before you install 
   the driver, please refer to hardware installation procedure in the 
   User's Manual.

-----------------------------------------------------------------------------
2. System Requirement
   - Hardware platform: Intel x86 machine
   - FreeBSD version: 4.x/5.x
   - Package Requirement: gcc, kernel source
   - Maximum 4 boards can be installed in combination

-----------------------------------------------------------------------------
3. Installation

   3.1 Hardware installation
   3.2 Driver files   
   3.3 Device naming convention
   3.4 Module driver configuration   
   3.7 Custom configuration
   3.8 Verify driver installation
       
             
   3.1 Hardware installation

       There are two types of buses, ISA and PCI, for Smartio/Industio 
       family multiport board.

       ISA board
       ---------
       You'll have to configure CAP address, I/O address, Interrupt Vector
       as well as IRQ before installing this driver. Please refer to hardware
       installation procedure in User's Manual before proceed any further.
       Please make sure the JP1 is open after the ISA board is set properly.

       PCI board
       ---------
       You may need to adjust IRQ usage in BIOS to avoid from IRQ conflict
       with other ISA devices. Please refer to hardware installation
       procedure in User's Manual in advance.

       PCI IRQ Sharing
       -----------
       Each port within the same multiport board shares the same IRQ. Up to
       4 Moxa Smartio/Industio PCI Family multiport boards can be installed 
       together on one system and they can share the same IRQ.


   3.2 Driver files

       The driver file may be obtained from CD-ROM or Web site. The
       first step, anyway, is to copy driver file "mxbsd_<version>.tgz" 
       into specified directory. e.g. /moxa. The execute commands as below.

       <copy mxbsd_<version>.tgz into /moxa directory>
       # cd /moxa
       # tar xvfz mxbsd_<version>.tgz 
       
   3.3 Device naming convention
   
       You may find all the driver and utilities files in ./moxa
       
       Dialin and callout port
       -----------------------
       This driver remains traditional serial device properties. There are
       two special file name for each serial port. One is dial-in port
       which is named "ttyMxx". For callout port, the naming convention
       is "cumxx".

       Device naming when more than 2 boards installed
       -----------------------------------------------
       Naming convention for each Smartio/Industio multiport board is 
       pre-defined as below.

       Board Num.	 Dial-in Port	      Callout port
       1st board	ttyM0  - ttyM7	      cum0  - cum7
       2nd board	ttyM8  - ttyM15       cum8  - cum15
       3rd board	ttyM16 - ttyM23       cum16 - cum23
       4th board	ttyM24 - ttym31       cum24 - cum31

   3.4 Module driver configuration
   
       ------------- Prepare to use the MOXA driver--------------------  
       3.4.1 Create tty device with correct major number
          ---------------NOTE----------------
	  This step is only for FreeBSD 4.x.
          -----------------------------------
          Before using MOXA driver, your system must have the tty devices 
          which are created with driver's major number. We offer one shell
          script "msmknod" to simplify the procedure. 
          This step is only needed to be executed once. But you still
          need to do this procedure when:
          a. Your total installed MOXA boards number is changed. Maybe you 
             add/delete one MOXA board.
          b. You want to change the tty name. This needs to modify the 
             shell script "msmknod"

          The procedure is:
	  # cd /moxa/mxser/driver
	  # ./msmknod

          Msmknod will delete any special files occupying the same device 
          naming.
          
       3.4.2 If you'd like to drive Smartio/Industio ISA boards in the system, 
          you'll have to add parameter to specify CAP address of given 
	  board in file config.h. 
	  a. # cd /moxa/mxser/driver
	     # vi config.h
	  b. Find the array mxserBoardCAP[] as below.

	     static int mxserBoardCAP[]
	     = {0x00, 0x00, 0x00, 0x00};

	  c. Change the address within this array using vi. For
	     example, to driver 2 ISA boards with CAP address
	     0x280 and 0x180 as 1st and 2nd board. Just to change
	     the source code as follows.

	     static int mxserBoardCAP[]
	     = {0x280, 0x180, 0x00, 0x00};
          
       3.4.3 Build the MOXA driver and utilities
          Before using the MOXA driver and utilities, you need compile the
          all the source code. This step is only need to be executed once.
                    
          Find "Makefile" in /moxa, then run

	  # make clean; make install

	  The driver files "mx.ko" and utilities will be properly compiled
	  and copied to system directories respectively. 
          
       ------------- Load MOXA driver--------------------  
       3.4.4 Load the MOXA driver  

	  # kldload mx

	  will activate the module driver. You may run "kldstat" to check
	  if "mx" is activated. 
	  
       ------------- Load MOXA driver on boot --------------------  
       3.4.5 For the above description, you may manually execute "kldload mx" 
          to activate this driver and run "kldunload mx" to remove it. 
          However, it's better to have a boot time configuration to 
          eliminate manual operation. Boot time configuration can be 
          achieved by loader.conf file. 
          
	  Run following command for setting loader.conf files.

	  # vi /boot/loader.conf
	  Add the following line to the file:
	  mx_load="YES"

          Reboot and check if mx.ko activated by "kldstat" command.

   3.7 Custom configuration
       Although this driver already provides you default configuration, you
       still can change the device name. The instruction to
       change these parameters are shown as below.

       Change Major number
       -------------------
       If major number 30 and 35 had been occupied, you may have to select
       2 free major numbers for this driver. There are 3 steps to change
       major numbers.

       3.7.1 Find free major numbers
	  Please select 2 major numbers that are available.
	  e.g. 40, 45.
       3.7.2 Create special files
          (This is only for FreeBSD 4.x)
	  Run /moxa/mxser/driver/msmknod to create special files with
	  specified major numbers.
       3.7.3 Modify driver with new major number
	  Run vi to open /moxa/mxser/driver/mx.c. Locate the line
	  contains "CDEV_MAJOR". Change the content as below.
	  #define CDEV_MAJOR	33
       3.7.4 Run "make install" in /moxa/mxser/driver.

-----------------------------------------------------------------------------
4. Utilities
   There are 1 utility contained in this driver. It is diag.
   The 1 utility is released in form of source code. They should
   be compiled into executable file and copied into /usr/bin.

   Before using these utilities, please load driver (refer 3.4) and
   make sure you had run the "msmknod" utility.

   msdiag - Diagnostic
   --------------------
   This utility provides the function to display what Moxa Smartio/Industio 
   board found by driver in the system.

-----------------------------------------------------------------------------
