=============================================================================
      MOXA PC/104 Communication Module Device Driver Installation Guide
		    	    for FreeBSD 4.x 
	       Copyright (C) 2003, 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 PC/104 Communication Module driver supports following multiport 
   boards.

   PC/104 Communication Module
	CA-104, CA-132, CA-132I 

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

   In addition to device driver, useful utilities are also provided in this
   version. They are
    - mpdiag     Diagnostic program for displaying installed Moxa 
                 PC/104 Communication Modules.

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

   In Moxa's ftp sites, you may always find latest driver at
   ftp://ftp.moxa.com  or ftp://ftp.moxa.com.tw.

   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 
   - 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 is only one type of bus, PC/104 Bus, for PC/104 Communication 
       Module.

       You'll have to configure CAP address(I/O address), Interrupt Vector
       and IRQ before installing this driver. Please refer to hardware
       installation procedure in User's Manual before proceed any further.

   3.2 Driver files

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

       <copy mxpcbsd.tgz into /moxa>
       # cd /moxa 
       # tar xvfz mxpcbsd.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 "ttyNxx". For callout port, the naming convention
       is "cunxx".

       Device naming when more than 2 boards installed
       -----------------------------------------------
       Naming convention for each PC/104 Communication Module is 
       pre-defined as below.

       Board Num.	 Dial-in Port	      Callout port
       1st board	ttyN0  - ttyN7	      cun0  - cun7
       2nd board	ttyN8  - ttyN15       cun8  - cun15
       3rd board	ttyN16 - ttyN23       cun16 - cun23
       4th board	ttyN24 - ttyN31       cun24 - cun31

   3.4 Module driver configuration
   
       ------------- Prepare to use the MOXA driver--------------------  
       3.4.1 Create tty device with correct major number
          Before using MOXA driver, your system must have the tty devices 
          which are created with driver's major number. We offer one shell
          script "mpmknod" 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 "mpmknod"

          The procedure is:
	  # cd /moxa/driver
	  # sh mpmknod

          Mpmknod will delete any special files occupying the same device 
          naming.
          
       3.4.2 You have to add parameter to specify CAP address, Interrupt Vector
	  and IRQ of given module in file config.h. 
	  a. # cd /moxa/driver
	     # vi config.h
	  b. Find the three arrays as below.

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

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

	     static int mxpcdrvBoardIRQ[]
	     = {0, 0, 0, 0};

	  c. Change the address within this array using vi. For
	     example, to driver 2 PC/104 Modules with CAP address
	     0x280 and 0x180 as 1st and 2nd board, Interrupt
	     Vector 0x2C0 and 0x1C0 ,and IRQ 11 and 10. Just to change
	     the source code as follows.

	     static int mxpcdrvBoardCAP[]
	     = {0x280, 0x180, 0x00, 0x00};

	     static int mxpcdrvBoardVECT[]
	     = {0x2C0, 0x1C0, 0x00, 0x00};

	     static int mxpcdrvBoardIRQ[]
	     = {11, 10, 0, 0};
          
       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/mxpcbsd, then run

	  # make clean; make install

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

	  # kldload mxpcdrv.ko

	  will activate the module driver. You may run "kldstat" to check
	  if "mxpcdrv.ko" is activated. 
	  
       ------------- Load MOXA driver on boot --------------------  
       3.4.5 For the above description, you may manually execute 

	  # kldload mxpcdrv.ko 

          to activate this driver and run 

	  # kldunload mxpcdrv.ko 

	  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:
	  mxpcdrv_load="YES"

          Reboot and check if mxpcdrv.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 34 had been occupied, you may have to select
       1 free major number for this driver. There are 3 steps to change
       major numbers.

       3.7.1 Find free major numbers
	  In /usr/src/sys/conf/majors, you may find all the major numbers 
	  occupied in the system. Please select 1 major number that is 
	  available. e.g. 35.
       3.7.2 Create special files
	  Run /moxa/mxpcbsd/driver/mpmknod to create special files with
	  specified major numbers.
       3.7.3 Modify driver with new major number
	  Run vi to open /moxa/mxpcbsd/driver/mxpcdrv.c. Locate the line
	  contains "CDEV_MAJOR". Change the content as below.
	  #define CDEV_MAJOR	33
       3.7.4 Run "make clean; make install" in /moxa/mxpcbsd/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 "mpmknod" utility.

   mpdiag - Diagnostic
   --------------------
   This utility provides the function to display what Moxa PC/104 
   Communication Module found by driver in the system. 

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