Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Jan 2012 12:09:59 +0100
From:      Gerhard Strangar <g.s@arcor.de>
To:        freebsd-drivers@freebsd.org
Subject:   Introduction to writing kernel modules
Message-ID:  <4F1BEE87.6080303@arcor.de>

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

I'm trying to write a driver for my watchdog card. However I don't know
anything about kernel modules in FreeBSD. I'm running 8.2 Release and I
found /usr/src/share/examples/drivers/, but there are lines like

struct ${1}_softc {
[...]
 char    buffer[BUFFERSIZE];     /* If we need to buffer something. */
};

Does it mean that it's for internal use of the example module only or
does an other component use it?
My card is PCI-based and all I need to do is write a byte via port-based
IO, no Interrupts, no DMA or other stuff. I'm planning to use a
character device for triggering the timer reset or disabling the card.
But I don't need to copy the input to kernel space before checking if it
was 0 or 1, do I?

Later on, the example uses:
static struct _pcsid
{
        u_int32_t       type;
        const char      *desc;
} pci_ids[] = {
        { 0x1234abcd,   "ACME PCI Widgetplus"   },
        { 0x1243fedc,   "Happy moon brand RIPOFFplus"   },
        { 0x00000000,   NULL                                    }
};

What's the meaning of those? Is the driver looking for two cards and 0x0
and NULL terminate the list or is it looking for one card only and the
abcd matches the "class" of "pcilist -lv" and fedc matches "card"?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4F1BEE87.6080303>