Device Driver Writing Red Hat 8 & 9
Hi!
I am having trouble with the first stage of my mission. I am trying to compile some code to make a beginners module. When I compile it I get some errors. 1) It doesn't know what KERN_INFO is I looked at the /usr/include/linux/kernel.h and it only has 1 sysinfo struct in there. I did a search on the kernel.h file and other ones I found had the #defines in them which is how I knew what to write. I added this line into my own source file which removed the error... $define KERN_INFO "<6>" 2) I now get a parse error before ';' in function 'init_module' I got this off here: lwn.net/Articles/21817 (need to be logged in to see it I think) I #define MODULE #include <linux/module.h> #include <linux/kernel.h> int init_module(void) { printk(KERN_INFO "Hello, world\n"); return 0; } void cleanup_module(void) { printk(KERN_INFO "Goodbye cruel world\n"); } I am running Redhat 8.0 with 2.4.20-24 kernel & Redhat 9 2.4.20-8 I should mention I am only typing 'gcc driver.c' to compile it. Has anyone tryed this before? |
ok, I go
gcc -c driver.c #and it happily creates a driver.o file I then go insmod -f ./driver.o I used -f to force load as I also get version errors (must be to do with using an updated kernel). ie Warning: kernel-module version mismatch ./driver.o was compiled for kernel version 2.4.9-9 while this kernel is version 2.4.20-24.8 |
ok, I go
gcc -c driver.c #and it happily creates a driver.o file I then go insmod -f ./driver.o I used -f to force load as I also get version errors (must be to do with using an updated kernel). ie Warning: kernel-module version mismatch ./driver.o was compiled for kernel version 2.4.9-9 while this kernel is version 2.4.20-24.8 |
All times are GMT -5. The time now is 04:55 PM. |