This particular real-time module flips the bits of the parallel port when it is scheduled. It can be found in the rt/parbit/ subdirectory of the kernel source (after the KURT patch is applied). We now explain the various portions of the source.

/*
 * KURT: KU Real Time Linux (v0.01)
 * --------------------------------
 *
 * File: rt/parbit/rt_parallel.c
 * Copyright (C) 1997 by the University of Kansas Center for Research,
 * Inc.  This software was developed by the Information and
 * Telecommunication Technology Center (ITTC) at the University of
 * Kansas.  Partial funding for this project was provided by Sprint. This
 * software may be used and distributed according to the terms of the GNU
 * Public License, incorporated herein by reference.  Neither ITTC nor
 * Sprint accept any liability whatsoever for this product.
 *
 * This project was developed under the direction of Dr. Douglas Niehaus.
 * 
 * Authors: Balaji S.
 *
 * Please send bug-reports/suggestions/comments to kurt@ittc.ku.edu
 * 
 * Further details about this project can be obtained at
 *    http://hegel.ittc.ku.edu/projects/kurt/ 
 *    or in the file Documentation/realtime.txt
 */

#include <linux/module.h>
#include <linux/rt.h>
#ifdef CONFIG_UTIME
#include <linux/mutime.h>
#endif
#include <asm/io.h>

This is the main event handling routine for this RTMod. This routine will be called by the KURT framework whenever an event of this type takes place.

static void output_val(unsigned long useless_data)
{
        static int i = 0;
        /* just set all the parallel ports to 1 or zero.
         */
        outb(i, 0x278);
        outb(i, 0x378);
        i = 1 - i;
        return;
}

This is the structure that is passed to the KURT framework when registering this module. The definition of this structure can be found in <linux/rt.h>.

struct rtmod_info {
        char *name;

        /* The following function would be called whenever an event of this 
         * RTMod is scheduled. This function would be passed a pointer to a 
         * struct timer_list for this event. This would be the event read
         * from the disk. This function should extract the data out of the 
         * timer list structure and pass it back. For example in the process 
         * module the rt_id of the process to be woken up on expiration of an 
         * event is stored in the function space of the timer_list structure.
         */
        unsigned long (*modify_timer_data) (struct timer_list *);

        /* the init and the cleanup is called for each module during switch
         * from normal to real-time and real-time to normal
         * These functions are for initializing any module-specific parameters
         * The init function is passed a command line that can be specified
         * in the switch_to_rt system call.
         */
        int (*init_rtmod) (const char *);
        int (*cleanup_rtmod) (void);

        void (*event_handler) (unsigned long);
        /* The following function is to be used by rt mods that need to give
         * additional interfaces to the user programs using this module.
         * The user programs can call the system call rtmod_cmd with the
         * the rt mod id and the appropriate command as well as a structure
         * that the rtmod knows.
         */
        void (*rtmod_cmd) (int, void *, unsigned long);
};

For our parbit module, there is no data for an event and the init and the cleanup functions are not necessary.

static struct rtmod_info parbit_rtmod_info =
{
        "parbit",
        NULL,
        NULL,
        NULL,
        output_val,
        NULL
};

This function registers the parbit RTMod with the real-time framework.

int init_parbit_rtmod(void)
{

        int status;

        if ((status = register_rtmod(&parbit_rtmod_info)) < 0) {
                return status;
        }
        return 0;
}

These functions are called when the parbit module is installed into the kernel (via insmod or modprobe).

#ifdef MODULE
int init_module(void)
{
        int status;

        if ((status = init_parbit_rtmod()) < 0) {
                return status;
        }
        return 0;
}

void cleanup_module(void)
{
        unregister_rtmod(parbit_rtmod_info.name);
}

#endif

KURT @ ITTC

Last modified: Fri Mar 24 13:08:04 CST 2000

Home Up