Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Nov 1997 19:10:05 +0100 (CET)
From:      J.Bredemeyer@tu-bs.de
To:        freebsd-hackers <freebsd-hackers@freebsd.org>
Cc:        Jochen Bredemeyer <dj5ba@amsat.org>
Subject:   LKM and interrupts: it works!
Message-ID:  <Pine.BSF.3.96.971115185200.3502B-100000@reb2.ivev.bau.tu-bs.de>

next in thread | raw e-mail | index | archive | help
Hello,

I recently posted a question concerning the usage of interrupts within
Loadable Kernel Modules (LKM).

After scanning several sources, especially "/sys/i386/isa/isa.c" and
its included files, I found a working solution - here is an extract of my
device driver:

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

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/kernel.h>
#include <i386/isa/isa.h>
#include <i386/isa/isa_device.h>
#include <i386/isa/icu.h>

#define _IRQ    IRQ12   /* Interrupt number */

[...]

/* not really necessary */
static struct isa_device dev =3D {0, &hexdriver, BASEADDR, 12, -1, (caddr_t)0,
                                  0,&hexintr, 0, 0, 0, 1, 0, 0, 1, 0, 0};

int hex_load (struct lkm_table *lkmtp, int cmd)
{
    if (!hexprobe(&dev))
    {
        uprintf ("Hexlink driver: probe failed\n");
        return 1;
    }
    /* register_intr() from "isa.c" */
    if(register_intr(ffs(_IRQ)-1,0,0,(inthand2_t *)hexintr,&tty_imask,0))
    {
        uprintf ("Hexlink driver: register_intr() failed\n");
        return 1;
    }
    INTREN(_IRQ);       /* Enable Interrupt, see "icu.h" */
    uprintf ("Hexlink driver loaded\n");
    hexattach(&dev);
    return 0;
}

int hex_unload (struct lkm_table *lkmtp, int cmd)
{
    INTRDIS(_IRQ); /* Disable IRQ */
    unregister_intr(ffs(_IRQ)-1,(inthand2_t *)hexintr); /* Release IRQ */
    uprintf ("Hexlink driver unloaded\n");
    return 0;
}

void hexintr (int unit)
{
    printf("\nInterrupt occured!\n");
}

[...]

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

I hope this helps!


Bye,

Jochen

DJ 5 BA
J.Bredemeyer@tu-bs.de
dj5ba@amsat.org




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.971115185200.3502B-100000>