I’m trying to get the examples from Linux Device Drivers, ed 3 (ldd3) working before I start working with the book so that I can have a set of working examples that I can use…. I’m getting the following errors (seeing error in Debian squeeze and also Crunchbang Linux):
inp.c:33:20: error: [u]asm/io.h:[/u] No such file or directory
when I looked at the makefile I found this (which I think is the problem):
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
INCLUDEDIR = $(KERNELDIR)/include
contents of /lib/modules/uname -r/build which is a link to /usr/src/linux-headers-2.6.39-bpo.2-486/
$ uname -r
2.6.39-bpo.2-486
$ ls /lib/modules/`uname -r`/build
arch include Makefile Module.symvers scripts
$ ls /lib/modules/`uname -r`/build/include
config generated linux
The directory that make is looking does not have the required files. I found the files required under /usr/src/linux-headers-2.6.39-bpo.2-common/ and the missing asm/io.h file @ /usr/src/linux-headers-2.6.39-bpo.2-common/include/asm-generic/
$ ls /usr/src/linux-headers-2.6.39-bpo.2-common/
arch include Kbuild Makefile scripts
$ ls /usr/src/linux-headers-2.6.39-bpo.2-common/include/
acpi crypto Kbuild linux media net rdma scsi staging trace xen
asm-generic drm keys math-emu mtd pcmcia rxrpc sound target video
Do I have to install any package to get the files in that directory… I’ve already installed linux-headers-uname -r package (in both Debian and Crunchbang)… In gnewsense I found the files in /lib/modules/$(shell uname -r)/build… but it was a older kernel… so not sure if the directory structure under linux change… or is it distro specific… please let me know how do I get the compilation going…. I’m not very good with Makefiles so how can I change the makefile so that it will look for the header files in the other directories….
Thanks,
asp5
First things first, LDD3 is quite old and I wouldn’t be surprised if header files might have moved around. Javier Martinez Canillas has updated the LDD3 sources for more modern kernels.
When investigating this a little further, I found that the
asmsymlink has been broken for a while. (io.happears to have stored inasm-generic/for some reason.) In case you’re curious, I filed a bug report at Ubuntu for the broken symlinks.For whatever it’s worth, I can build a module referencing either
<asm/io.h>or<asm-generic/io.h>(though as Hasturkun reminds me, you shouldn’t useasm-genericdirectly):