gtpc2mj8C/C++ Language Support User's Guide

Adding a User-Defined Device Driver

To add a user-defined device driver to the system:

  1. Write the set of device driver functions (described in User-Defined Device Driver Functions) as required by the interface declared in c$spif.h. Define the device driver functions as non-exportable functions in the COMX library.
  2. Declare the user-defined device driver functions in a device driver header file. For examples of how to do this, see c$ddsm.h (for the sample input and output message drivers) or i$fsdd.h (for the IBM-supplied regular and null device drivers). The following is a template for this declaration:
    /**********************************************************************/
    /* Declare the functions for the user-defined device driver.          */
    /**********************************************************************/
    TPF_FSDD_APPEND     new_device_driver_append_function;
    TPF_FSDD_CLOSE      new_device driver_close_function;
    TPF_FSDD_GET        new_device_driver_get_function;
    TPF_FSDD_OPEN       new_device_driver_open_function;
    TPF_FSDD_PUT        new_device_driver_put_function;
    TPF_FSDD_RESIZE     new_device_driver_resize_function;
    TPF_FSDD_SIZE       new_device_driver_size_function;
    TPF_FSDD_POLL       new_device_driver_poll_function;
    TPF_FSDD_POLL_CLEAN new_device_driver_poll_clean_function;
     
    /**********************************************************************/
    /* The following macro defines the initializer for the new struct     */
    /* tpf_spif entry in the UDDTBL device driver table.                  */
    /**********************************************************************/
    #define NEW_DEVICE_DRIVER_TABLE_ENTRY {                                \
        new_device_driver_append_function,                                 \
        new_device driver_close_function,                                  \
        new_device_driver_get_function,                                    \
        new_device_driver_open_function,                                   \
        new_device_driver_put_function,                                    \
        new_device_driver_resize_function,                                 \
        new_device_driver_size_function                                    \
        new_device_driver_poll_function                                    \
        new_device_driver_poll_clean_function                              \
     
    }
    
  3. Using the new or updated header from the previous step, update segment UDDTBL:
    1. Add the new or updated header from the previous step to the list of #includes following the prolog.
    2. Define a new entry in the device driver interface table by adding the new initializer macro to the initializer list for the TPF_USRDDTAB array. The index of the new device driver element in the TPF_USRDDTAB array is the major device number for any special file that uses the new device driver.
      Note:
      Do not change or reorder any existing entries. If you do, you will have to delete and re-create all special files for which the major device number changed.
  4. Recompile UDDTBL.
  5. Rebuild the COMX library including the new object for UDDTBL (from step 3) and any user-defined device driver objects (from step 1).
  6. Load the rebuilt COMX library online.
  7. Enter the ZFILE mknod command to create the character special files that use the user-defined device driver by using the major device number from step 3b. See TPF Operations for more information about the ZFILE mknod command.

The device driver is now accessible to online load modules by opening the special files defined in step 7.