Date: Sun, 22 Jan 2012 13:57:03 +0100 From: Patrick Lamaiziere <patfbsd@davenulle.org> To: Gerhard Strangar <g.s@arcor.de> Cc: freebsd-drivers@freebsd.org Subject: Re: Introduction to writing kernel modules Message-ID: <20120122135703.15810f3f@davenulle.org> In-Reply-To: <4F1BEE87.6080303@arcor.de> References: <4F1BEE87.6080303@arcor.de>
next in thread | previous in thread | raw e-mail | index | archive | help
Le Sun, 22 Jan 2012 12:09:59 +0100, Gerhard Strangar <g.s@arcor.de> a écrit : > Hello, 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? The softc is used to store private informations (but I guess you can store public information too). Each instance of the driver owns its softc. I mean that if you have two network cards like "em0, em1" there will be two softc allocated, one for each. > 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? There is a facility for watchdogs, you should use it. You only have to register you watchdog in the kernel and watchdogd(8) is used to control the watchdog from userland. introduction: http://web.archive.org/web/20040629062401/http://ezine.daemonnews.org/200406/watchdog.html also see man 9 watchdog. > 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"? It is looking for two cards. Few docs / papers about the kernel are listed here : http://forums.freebsd.org/showthread.php?t=1566 And you can use the kernel cross reference to dig into the code: http://fxr.watson.org/. You will find few examples of kernel watchdogs. Regards.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120122135703.15810f3f>