Changes made to the kernel file structures to support CAPI
==========================================================

The following notes are a very short summary of all actions necessary to
incorporate CAPI for BSD into the FreeBSD operating system. These
modifications are only valid (or verified) for version 4.6-RELEASE,
4.7-RELEASE, 5.0-RELEASE and 5.1-RELEASE. Other versions may need other
modifications or C4B will even not work with them.

This list is a list for the author of C4B to summarize all necessary changes to
incorporate C4B into the main FreeBSD, NetBSD or OpenBSD source tree. See
README for a list of tasks to execute if You want to link C4B into Your own
system.



Modifications under /usr/src/lib and /usr/src/include
-----------------------------------------------------

Files added to source tree:

   /sys/c4b/include/capi20.h
   /sys/c4b/include/capidef.h
   /sys/c4b/include/capi_pack_on.h
   /sys/c4b/include/capi_pack_off.h
   /sys/c4b/include/capi_result.h
   /sys/c4b/include/capi_supplsvc.h
   /sys/c4b/include/capi_echoc.h
   /sys/c4b/include/capi_li.h
   /sys/c4b/include/capi_bsd.h
   /sys/c4b/include/capi_bsdtrc.h

   /usr/src/lib/libcapi20/Makefile
   /usr/src/lib/libcapi20/capilib.cc
   /usr/src/lib/libcapi20/capi20.3
   /usr/src/lib/libcapi20/capi-trc.7

Modified /usr/src/include/Makefile to install the CAPI header files from
/sys/c4b/include to /usr/include.

Modify usr/src/lib/Makefile to build "libcapi20" if NO_C4B is not defined.



Files modified to enter CAPI support into the kernel
----------------------------------------------------

For 5.1-RELEASE: Patch /sys/sys/endian.h to compile (will be installed to
/usr/include/sys/endian.h when doing "make install" in /usr/src/include). In
most inline functions a cast is necessary in the assignment to the local
pointer variable.



Changes to /sys/i386/include/i4b_ioctl.h:

added controller type CTRL_CAPIMGR "CAPIMGR driven controllers",
CTRL_NUMTYPES incremented:

   #define CTRL_CAPIMGR    6               /* boards accessed through the CAPI manager */
   #define CTRL_NUMTYPES   7               /* number of controller types   */



Changes to /sys/i4b/layer4/i4b_l4mgmt.c:

Functions "i4b_l4_daemon_attached" and "i4b_l4_daemon_detached":
   management commands are also sent to CAPIMGR controllers

/*XXX*/         if(*ctrl_desc[i].N_MGMT_COMMAND &&
                   (ctrl_desc[i].ctrl_type == CTRL_PASSIVE ||
                    ctrl_desc[i].ctrl_type == CTRL_CAPIMGR))



Files added to the source tree:

   /sys/c4b/kcapimgr/kcapimgr.c
   /sys/c4b/kcapimgr/kcapimgr_global.h
   /sys/c4b/kcapimgr/kcapi_appl.c
   /sys/c4b/kcapimgr/kcapi_appl.h
   /sys/c4b/kcapimgr/kcapi_ctlr.c
   /sys/c4b/kcapimgr/kcapi_ctlr.h
   /sys/c4b/kcapimgr/kcapi_trace.c
   /sys/c4b/kcapimgr/kcapi_trace.h
   /sys/c4b/kcapimgr/capi_drv.h

   /sys/c4b/capidev/capidev.c

   /sys/c4b/driver/avmaic/avmaic.c
   /sys/c4b/driver/avmaic/avmaic_global.h
   /sys/c4b/driver/avmaic/avmaic_misc.h
   /sys/c4b/driver/avmaic/avmaic_misc.c
   /sys/c4b/driver/avmaic/avmlli.h
   /sys/c4b/driver/avmaic/avmb1.h
   /sys/c4b/driver/avmaic/avmb1.c
   /sys/c4b/driver/avmaic/avmarm.h
   /sys/c4b/driver/avmaic/avmarm.c
   /sys/c4b/driver/avmaic/avmdma.h
   /sys/c4b/driver/avmaic/avmdma.c
   /sys/c4b/driver/avmaic/avmio.h
   /sys/c4b/driver/avmaic/avmio.c
   /sys/c4b/driver/avmaic/avmt1.h
   /sys/c4b/driver/avmaic/avmt1.c
   
   /sys/c4b/driver/daic/daic.c
   /sys/c4b/driver/daic/daic_bootstrap.c
   /sys/c4b/driver/daic/daic_bootstrap.h
   /sys/c4b/driver/daic/daic_dispatch.c
   /sys/c4b/driver/daic/daic_dispatch.h
   /sys/c4b/driver/daic/daic_global.h
   /sys/c4b/driver/daic/daic_globalid.c
   /sys/c4b/driver/daic/daic_globalid.h
   /sys/c4b/driver/daic/daic_hw.c
   /sys/c4b/driver/daic/daic_hw.h
   /sys/c4b/driver/daic/daic_hwdefs.h
   /sys/c4b/driver/daic/daic_misc.c
   /sys/c4b/driver/daic/daic_misc.h
   /sys/c4b/driver/daic/daic_ncci.c
   /sys/c4b/driver/daic/daic_ncci.h
   /sys/c4b/driver/daic/daic_plci.c
   /sys/c4b/driver/daic/daic_plci.h

   /sys/i4b/i4bcapimgr/i4bcapimgr.c
   /sys/i4b/i4bcapimgr/i4bcmgr_capiutil.c
   /sys/i4b/i4bcapimgr/i4bcmgr_capiutil.h
   /sys/i4b/i4bcapimgr/i4bcmgr_global.h
   /sys/i4b/i4bcapimgr/i4bcmgr_l4if.c
   /sys/i4b/i4bcapimgr/i4bcmgr_nccism.c
   /sys/i4b/i4bcapimgr/i4bcmgr_nccism.h
   /sys/i4b/i4bcapimgr/i4bcmgr_plcism.c
   /sys/i4b/i4bcapimgr/i4bcmgr_plcism.h

Directory /sys/i4b/i4bcapimgr and files are added to implement new controller
type CTRL_CAPIMGR.

The following files are taken from their respective Makefile.kernel variants
under .../c4b/modules/{kcapimgr|capidev} and .../c4b/modules/driver/*.

   /sys/modules/kcapimgr/Makefile
   /sys/modules/capidev/Makefile
   /sys/modules/avmaic/Makefile
   /sys/modules/daic/Makefile
   /sys/modules/i4bcapimgr/Makefile

Modified /sys/modules/Makefile to include the new modules directories above.



Added to /sys/conf/files:

   #
   # the CAPI manager with the kernel CAPI interface for drivers and applications
   #
   c4b/kcapimgr/kcapimgr.c         optional kcapimgr
   c4b/kcapimgr/kcapi_appl.c       optional kcapimgr
   c4b/kcapimgr/kcapi_ctlr.c       optional kcapimgr
   c4b/kcapimgr/kcapi_trace.c      optional kcapimgr
   #
   # the CAPI device for CAPI support for user space applications
   #
   c4b/capidev/capidev.c   optional capidev
   #



Added to /sys/conf/files.i386:

   #
   # the CAPI manager driver for AVM active ISDN controllers
   #
   c4b/driver/avmaic/avmaic.c      optional avmaic
   c4b/driver/avmaic/avmaic_misc.c optional avmaic
   c4b/driver/avmaic/avmb1.c       optional avmaic
   c4b/driver/avmaic/avmarm.c      optional avmaic
   c4b/driver/avmaic/avmdma.c      optional avmaic
   c4b/driver/avmaic/avmio.c       optional avmaic
   c4b/driver/avmaic/avmt1.c       optional avmaic
   #
   # the CAPI manager driver for legacy Diehl active ISDN controllers
   #
   c4b/driver/daic/daic.c          optional daic
   c4b/driver/daic/daic_bootstrap.c optional daic
   c4b/driver/daic/daic_dispatch.c optional daic
   c4b/driver/daic/daic_globalid.c optional daic
   c4b/driver/daic/daic_hw.c       optional daic
   c4b/driver/daic/daic_misc.c     optional daic
   c4b/driver/daic/daic_ncci.c     optional daic
   c4b/driver/daic/daic_plci.c     optional daic
   #

   #
   # i4b driver to support CAPIMGR controllers
   #
   i4b/i4bcapimgr/i4bcapimgr.c             optional i4bcapimgr
   i4b/i4bcapimgr/i4bcmgr_l4if.c           optional i4bcapimgr
   i4b/i4bcapimgr/i4bcmgr_plcism.c         optional i4bcapimgr
   i4b/i4bcapimgr/i4bcmgr_nccism.c         optional i4bcapimgr
   i4b/i4bcapimgr/i4bcmgr_capiutil.c       optional i4bcapimgr



Added to /sys/conf/options:

   #
   # options for the CAPI manager
   #
   KCAPIMGR_LOG_MASK       opt_kcapimgr.h
   #
   # options for the CAPI device to user land
   #
   CAPIDEV_LOG_MASK        opt_capidev.h
   #



Added to /sys/conf/options.i386:

Note: AVMAIC_IDENTIFY_B1ISA is only valid for 4.x.

   #
   # options for the CAPI driver for AVM active ISDN controllers
   #
   AVMAIC_LOG_MASK                 opt_avmaic.h
   AVMAIC_MAX_UNITS                opt_avmaic.h
   AVMAIC_MAX_APPLICATIONS         opt_avmaic.h
   AVMAIC_MAX_NCCI_PER_CHANNEL     opt_avmaic.h
   AVMAIC_IDENTIFY_B1ISA           opt_avmaic.h
   #
   # options for the CAPI driver for legacy Diehl active ISDN controllers
   #
   DAIC_LOG_MASK                   opt_daic.h
   DAIC_MAX_UNITS                  opt_daic.h
   DAIC_MAX_APPLICATIONS           opt_daic.h

   #
   # options for the i4b driver to support CAPIMGR controllers
   #
   I4BCAPIMGR_LOG_MASK                opt_i4bcapimgr.h
   I4BCAPIMGR_ALLOC_MAX_BDATA_SIZE    opt_i4bcapimgr.h



Added to /sys/conf/majors:

for 4.x-RELEASE:

   170     capi            CAPI interface for user space applications

for 5.0-RELEASE:

   226     capi            CAPI interface for user space applications

for 5.1-RELEASE and up: Not relevant any more.



5.1-RELEASE and up: Added to /sys/conf/NOTES:

   #
   # kernel and user space CAPI support
   #
   # supported options:
   #    KCAPIMGR_LOG_MASK          initializes the log mask for the CAPI manager,
   #                               integer value
   #    CAPIDEV_LOG_MASK           initialize the log mask for the CAPI device to
   #                               user space applications, integer value
   #
   pseudo-device   "kcapimgr"
   pseudo-device   "capidev"



5.1-RELEASE and up: Added to /sys/i386/conf/NOTES:

   #
   # CAPI manager driver for the AVM active ISDN adapters (B1, C2, C4, T1)
   #
   # supported flags:
   #    0x00 (or no flags) AVM-B1 ISA
   #    0x10 - 0x13        AVM-T1 ISA with board number 0 - 3 (low nibble of
   #                       flags)
   #
   # supported options:
   #    AVMAIC_LOG_MASK            initializes the log mask for the driver
   #    AVMAIC_MAX_UNITS           specifies the maximum no. supported boards,
   #                               default is 4
   #    AVMAIC_MAX_APPLICATIONS    specifies the maximum no. supported
   #                               simultaneously registered applications,
   #                               default is 30
   #    AVMAIC_MAX_NCCI_PER_CHANNEL
   #                               specifies the maximum no. possible B3
   #                               connections per channel and application,
   #                               default is 4
   #    AVMAIC_IDENTIFY_B1ISA="#"  toggles the identification of B1 ISA devices
   #                               when used as a kld module; "#" represents the
   #                               number of card devices to create (mainly useful
   #                               for debugging the device driver)
   #
   device avmaic
   # AVM-B1 ISA
   hint.avmaic.0.at="isa"
   hint.avmaic.0.port="0x150"
   hint.avmaic.0.irq="5"

   #
   # CAPI manager driver for the legacy Diehl active ISDN adapters (S, SX, SXn,
   # SCOM, Quattro, S2m)
   #
   # Note: The S2m board is currently not supported.
   #
   # supported options:
   #    DAIC_LOG_MASK              initializes the log mask for the driver
   #    DAIC_MAX_UNITS             specifies the maximum no. supported boards,
   #                               default is 4
   #    DAIC_MAX_APPLICATIONS      specifies the maximum no. supported
   #                               simultaneously registered applications,
   #                               default is 30
   #
   device daic
   # Diehl S, SX, SXn, SCOM (specifying the memory size is optional)
   hint.daic.0.at="isa"
   hint.daic.0.maddr="0xD0000"
   hint.daic.0.msize="0x800"
   hint.daic.0.irq="10"
   # Diehl Quattro (specifying the memory size is optional)
   hint.daic.0.at="isa"
   hint.daic.0.maddr="0xD0000"
   hint.daic.0.msize="0x2000"
   hint.daic.0.irq="10"
   # Diehl S2m (specifying the memory size is mandatory)
   hint.daic.0.at="isa"
   hint.daic.0.maddr="0xD0000"
   hint.daic.0.msize="0x4000"
   hint.daic.0.irq="10"

   #
   # i4b driver to support CAPI controllers
   #
   # supported options:
   #    I4BCAPIMGR_LOG_MASK        initializes the log mask for i4bcapimgr,
   #                               integer value
   #    I4BCAPIMGR_ALLOC_MAX_BDATA_SIZE
   #                               Normally incoming data blocks are forwarded to
   #                               the layer 4 drivers just as they are. But there
   #                               are situations (activated VJ compression and
   #                               uncompression is performed in the received
   #                               mbuf) where it is assumed that the received
   #                               mbuf is allocated with the maximum size of 2kB.
   #                               If this option is set, all incoming data blocks
   #                               are copied into new mbufs of maximum size, thus
   #                               wasting memory and computing time.
   #
   # Note: It is a better idea to load this as a kernel loadable module.
   pseudo-device   "i4bcapimgr"



5.0-RELEASE and earlier: Added to /sys/i386/conf/LINT and other kernel
configuration files:

Note: The option AVMAIC_IDENTIFY_B1ISA is only valid for 4.x.

   #
   # CAPI manager driver for the AVM active ISDN adapters (B1, C2, C4, T1)
   #
   # supported flags:
   #    0x00 (or no flags) AVM-B1 ISA
   #    0x10 - 0x13        AVM-T1 ISA with board number 0 - 3 (low nibble of
   #                       flags)
   #
   # supported options:
   #    AVMAIC_LOG_MASK            initializes the log mask for the driver
   #    AVMAIC_MAX_UNITS           specifies the maximum no. supported boards,
   #                               default is 4
   #    AVMAIC_MAX_APPLICATIONS    specifies the maximum no. supported
   #                               simultaneously registered applications,
   #                               default is 30
   #    AVMAIC_MAX_NCCI_PER_CHANNEL
   #                               specifies the maximum no. possible B3
   #                               connections per channel and application,
   #                               default is 4
   #    AVMAIC_IDENTIFY_B1ISA="#"  toggles the identification of B1 ISA devices
   #                               when used as a kld module; "#" represents the
   #                               number of card devices to create (mainly useful
   #                               for debugging the device driver)
   #
   # AVM-B1 ISA
   #device          avmaic0 at isa? port 0x150 irq 5
   # AVM-T1 ISA
   #device          avmaic0 at isa? port 0xXXX irq X flags 0x10
   # AVM-B1 PCI (v3 or v4), AVM-C2, AVM-C4, AVM-T1 PCI
   #device          avmaic

   #
   # CAPI manager driver for the legacy Diehl active ISDN adapters (S, SX, SXn,
   # SCOM, Quattro, S2m)
   #
   # Note: The S2m board is currently not supported.
   #
   # supported options:
   #    DAIC_LOG_MASK              initializes the log mask for the driver
   #    DAIC_MAX_UNITS             specifies the maximum no. supported boards,
   #                               default is 4
   #    DAIC_MAX_APPLICATIONS      specifies the maximum no. supported
   #                               simultaneously registered applications,
   #                               default is 30
   #
   # Diehl S, SX, SXn, SCOM (specifying the memory size is optional)
   #device          daic0 at isa? mem 0xD0000 size 0x800 irq 10
   # Diehl Quattro (specifying the memory size is optional)
   #device          daic0 at isa? mem 0xD0000 size 0x2000 irq 10
   # Diehl S2m (specifying the memory size is manadatory)
   #device          daic0 at isa? mem 0xD0000 size 0x4000 irq 10

   #
   # i4b driver to support CAPI controllers
   #
   # supported options:
   #    I4BCAPIMGR_LOG_MASK        initializes the log mask for i4bcapimgr,
   #                               integer value
   #    I4BCAPIMGR_ALLOC_MAX_BDATA_SIZE
   #                               Normally incoming data blocks are forwarded to
   #                               the layer 4 drivers just as they are. But there
   #                               are situations (activated VJ compression and
   #                               uncompression is performed in the received
   #                               mbuf) where it is assumed that the received
   #                               mbuf is allocated with the maximum size of 2kB.
   #                               If this option is set, all incoming data blocks
   #                               are copied into new mbufs of maximum size, thus
   #                               wasting memory and computing time.
   #
   # Note: It is a better idea to load this as a kernel loadable module.
   pseudo-device   "i4bcapimgr"



Files added and/or modified for user space CAPI support
-------------------------------------------------------

Changes to /dev/MAKEDEV:

Note: For 5.x-RELEASE this file does not exist any more.

In other releases modified to also create capi20 device for standard:

   # CAPI support:
   #       capi    device to support user land CAPI applications
   #

           sh MAKEDEV capi                                 # cdev, ISDN

   capi)
           mknod capi20 c 170 0
	   chmod 666 capi20
           ;;





Changes made to I4B user space applications to support CAPI controllers
=======================================================================

Changes to /usr/src/usr.sbin/i4b/isdnd/controller.c:

Function "name_of_controller": added support for controller type CTRL_CAPIMGR

        static char *capimgr_card[] = {
                "CAPI manager driven board"
        };

        else if(ctrl_type == CTRL_CAPIMGR)
        {
                return capimgr_card[0];
        }

Function "init_controller_state": added support for controller type
CTRL_CAPIMGR, be sure to set the state to "CTRL_UP" for there is no method for
the controller to tell isdnd that it is up

        case CTRL_CAPIMGR:
                isdn_ctrl_tab[controller].ctrl_type = ctrl_type;
                isdn_ctrl_tab[controller].card_type = card_type;
                isdn_ctrl_tab[controller].state = CTRL_UP;
                break;





Tools for C4B and management of the CAPI controller drivers
===========================================================

Copied the tools avmaicctl, daicctl, capitest and capitrace as well as the
manual file directory man to /usr/src/usr.sbin/c4b/. Modify
/usr/src/usr.sbin/Makefile to include the c4b subdirectory if NO_C4B is not
defined. Create /usr/src/usr.sbin/c4b/Makefile (from Makefile.tools) and
/usr/src/usr.sbin/c4b/Makefile.inc (from Makefile.tools.inc) to create all C4B
related tools and the manual files for the kernel modules.



/usr/src/share/capi/avmaic

Directory added, installed firmware files for all active AVM boards in
uuencoded form into it. A Readme file explaines what the files are, where they
are from and where to get current versions. A Makefile in this directory will
decode the binary files and install them to /usr/share/capi/avmaic.

/usr/src/share/capi/daic

Directory added, installed firmware files for all legacy Diehl active ISDN
boards in uuencoded form into it. A Readme file explaines what the files are,
where they are from and where to get current versions. A Makefile in this
directory will decode the binary files and install them to
/usr/share/capi/daic.

Modify /usr/src/share/Makefile to enter subdirectory capi if NO_C4B is not
defined.

Add the following note for NO_C4B to /usr/src/share/examples/etc/make.conf:

   #NO_C4B=        true    # do not build CAPI for BSD package





Registering new directories and the library to the source tree
==============================================================

Modify /usr/src/etc/mtree/BSD.usr.dist to include entries for the directories
.../capi, .../capi/avmaic and .../capi/daic, using default ownership and rights
mask. As mentioned int the file /usr/src/etc/mtree/README update
/usr/src/share/man/man.7 to include these three directories.

Modify /usr/src/share/mk/bsd.libnames.mk to include a line for libcapi20.a.





Integration of C4B into the system startup up to 5.0-RELEASE
============================================================

Add the following file from the c4b root directory:

/usr/src/etc/rc.capi

Modify /usr/src/etc/Makefile to include this file in case NO_C4B is not
defined.



Add the following text to /usr/src/etc/defaults/rc.conf just before the
settings for I4B:

### CAPI subsystem options: ###
capi_enable="NO"                # Enable the CAPI subsystem (YES or NO).
capi_load_ctlr_driver=""        # List of CAPI controller driver kernel modules
                                # to load on startup if not compiled into the
                                # kernel.
capi_download_commands=""       # List of short names for download operations
                                # to perform; for every <name> the variable
                                # ${capi_<name>_cmd} is looked up for the
                                # actual download command and
                                # ${capi_<name>_flags} contains its commands
                                # line arguments.



Modify /usr/src/etc/rc.network to include the following text just before the
startup of the ISDN subsystem:

        # CAPI subsystem startup
        # Note: Because I4B may use some CAPI driven ISDN controllers, CAPI
        #       must be started before.
        #
        case ${capi_enable} in
        [Yy][Ee][Ss])
                if [ -r /etc/rc.capi ]; then
                        . /etc/rc.capi
                fi
                ;;
        esac





Integration of C4B into the system startup for 5.1-RELEASE and up
=================================================================

Add the following file from the c4b root directory:

/usr/src/etc/rc.d/capi (from rc.d-capi)



Add the following text to /usr/src/etc/defaults/rc.conf just before the
settings for I4B:

### CAPI subsystem options: ###
capi_enable="NO"                # Enable the CAPI subsystem (YES or NO).
capi_load_ctlr_driver=""        # List of CAPI controller driver kernel modules
                                # to load on startup if not compiled into the
                                # kernel.
capi_download_commands=""       # List of short names for download operations
                                # to perform; for every <name> the variable
                                # ${capi_<name>_cmd} is looked up for the
                                # actual download command and
                                # ${capi_<name>_flags} contains its commands
                                # line arguments.
