public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: 'hello world' module
@ 2005-06-13 17:50 Nick Warne
  0 siblings, 0 replies; 12+ messages in thread
From: Nick Warne @ 2005-06-13 17:50 UTC (permalink / raw)
  To: linux-kernel

Jesper Juhl wrote:

> I don't have that book, so I can't really say, but here's an example
> from "Linux Kernel Development, 2ed" by rml
> (http://rlove.org/kernel_book/)

I bought this today!  If you are in UK, here is the best deal I could find - 
£22.00 + free delivery - I ordered this morning, it is dispatched already:

http://www.compman.co.uk/scripts/browse.asp?ref=706766

Why US on-line books are at least half the price of UK ones, I don't know., 
but of course then shipping costs/time buggers that up.
Rip-off UK, I suppose.

Thanks for the tip - I have been after a kernel book for ages, but wasn't sure 
what to get.

Nick
-- 
"When you're chewing on life's gristle,
Don't grumble, Give a whistle..."

^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: 'hello world' module
@ 2005-06-11 16:54 Nick Warne
  2005-06-11 17:06 ` Jan Engelhardt
  0 siblings, 1 reply; 12+ messages in thread
From: Nick Warne @ 2005-06-11 16:54 UTC (permalink / raw)
  To: linux-kernel

Robert Hancock wrote:

> Nick Warne wrote:
>> 2.4.31, GCC 3.4.4
>> 
>> Build like:
>> 
>> gcc -D__KERNEL__ -I/usr/src/linux/include -DMODULE -Wall -O2 -c hello.c
>> -o hello.o
> 
> That compilation method will not work on 2.6. You have to use the kernel
> makefiles to build the module. See:
> 
> http://linuxdevices.com/articles/AT4389927951.html

I see.  Sorry for the bum steer; I haven't messed about with 2.6.x much in 
development - I am still [trying to learn] learning 2.4.x.

How do you guys keep up with it all?

Great link, thanks.

Nick
-- 
"When you're chewing on life's gristle,
Don't grumble, Give a whistle..."

^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: 'hello world' module
@ 2005-06-11 15:53 Nick Warne
  0 siblings, 0 replies; 12+ messages in thread
From: Nick Warne @ 2005-06-11 15:53 UTC (permalink / raw)
  To: linux-kernel, ilan_sk

Hi Ilan,

I don't know about the Oh Really! version, but this one taken from 'Beginning 
Linux Programming' (forward by Alan Cox!) ISBN 1-861002-97-1 worked OK for 
me.

2.4.31, GCC 3.4.4

Build like:

gcc -D__KERNEL__ -I/usr/src/linux/include -DMODULE -Wall -O2 -c hello.c -o 
hello.o

Edit hello.c to suit:



#include <linux/module.h>

#if defined(CONFIG_SMP)
#define __SMP__
#endif

#if defined(CONFIG_MODVERSIONS)
#define MODVERSIONS
#include <linux/modversions.h>
#endif

#include <linux/kernel.h>

MODULE_AUTHOR ("Nick Warne <nick@linicks.net>");
MODULE_DESCRIPTION ("Hello Kernel! module");
MODULE_LICENSE("GPL");

int init_module(void)
{
        printk(KERN_DEBUG "Hello, kernel!\n");
        return 0;
}

void cleanup_module(void)
{
        printk(KERN_DEBUG "Good-bye, kernel!\n");
}



bash-2.05b# insmod hello.o
bash-2.05b# dmesg | tail -n1
Hello, kernel!

bash-2.05b# lsmod
Module                  Size  Used by    Tainted: P
hello                    320   0  (unused)

bash-2.05b# rmmod hello
bash-2.05b# dmesg | tail -n1
Good-bye, kernel!



Hope that helps.

Nick
-- 
"When you're chewing on life's gristle,
Don't grumble, Give a whistle..."

^ permalink raw reply	[flat|nested] 12+ messages in thread
* 'hello world' module
@ 2005-06-11 12:11 Ilan S.
  2005-06-11 18:17 ` Sam Ravnborg
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Ilan S. @ 2005-06-11 12:11 UTC (permalink / raw)
  To: linux-kernel

Hello dear professionals!

I would be very thankful if anybody prompt me what's wrong.
I'm trying to build the "Hello world" module from O'Reilly's "Linux device 
drivers" and that is what I get:

[ilanso@Netvision Kernel]$ make -C /home/ilanso/src/linux-2.6.11.11 M=`pwd`
make: Entering directory `/home/ilanso/src/linux-2.6.11.11'
  Building modules, stage 2.
  MODPOST
make: Leaving directory `/home/ilanso/src/linux-2.6.11.11'
[ilanso@Netvision Kernel]$ ls
hello.c  Makefile
[ilanso@Netvision Kernel]$  

Please email me to ilan_sk@netvision.net.il, because I'm not subscribed to 
this mailing list yet...
Thanks in advance...

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2005-06-13 20:10 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <4egz4-2tj-15@gated-at.bofh.it>
2005-06-11 16:25 ` 'hello world' module Robert Hancock
2005-06-11 16:31   ` Jan Engelhardt
2005-06-13 17:50 Nick Warne
  -- strict thread matches above, loose matches on Subject: below --
2005-06-11 16:54 Nick Warne
2005-06-11 17:06 ` Jan Engelhardt
2005-06-11 15:53 Nick Warne
2005-06-11 12:11 Ilan S.
2005-06-11 18:17 ` Sam Ravnborg
2005-06-11 20:25   ` Jan Engelhardt
2005-06-12 19:17     ` Sam Ravnborg
2005-06-11 19:43 ` Jesper Juhl
2005-06-13 20:09 ` Edward Macfarlane Smith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox