LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 12-14-2003, 12:26 AM   #1
unicorn21
LQ Newbie
 
Registered: Dec 2003
Location: Brisbane
Posts: 5

Rep: Reputation: 0
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?

Last edited by unicorn21; 12-14-2003 at 12:34 AM.
 
Old 12-14-2003, 01:25 AM   #2
unicorn21
LQ Newbie
 
Registered: Dec 2003
Location: Brisbane
Posts: 5

Original Poster
Rep: Reputation: 0
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
 
Old 12-14-2003, 03:01 AM   #3
unicorn21
LQ Newbie
 
Registered: Dec 2003
Location: Brisbane
Posts: 5

Original Poster
Rep: Reputation: 0
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing Device Driver... okeyla Programming 3 05-18-2005 07:41 AM
Device driver for a USB to RS-232 Serial DB9 Adapter for red Hat 8 or 9 sp022 Linux - Hardware 1 04-18-2005 09:39 AM
Red Hat Enterpraise 3 & driver emulex facs Linux - Enterprise 2 02-01-2005 02:08 AM
Need help in writing device driver eshwar_ind Programming 1 02-07-2004 03:46 PM
Red Hat 7.2... & a modem with Red Hat 7.1 driver support rahduku Linux - Distributions 1 02-14-2002 11:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 06:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration