Posts

Showing posts with the label kernel programming

A series on kernel configuration and compilation.

Here is a series of posts on the very basics of how one can configure a kernel and then compile it and install it. If anything appears to be wrong or something more has to be added please feel free to add or comment .... http://220.225.214.101/forum/59

obj-m := $(TARGET)

now was wondering what was that supposed to mean , when i first saw the makefile for the sample driver module i had written , and now after having some personal time with the kernel documentation , i have found out that this stands for object module goals , i had suspected this already ..... so that gives me the reason why my module was compiled by make even though i didn't give the goal for the specific target object !!!

coding style !

ever taken time to go through the kernel documentation , well i have not till now , ..... and there i found this file which read as 'Coding Style ' and believe it is nothing like what i have read before , .... if u have kernel source code go into the source directory and look for a file 'coding style' in the Documentation directory or else here goes the file or rather a part of it ......... _______________________________________________________________________________________ Linux kernel coding style This is a short document describing the preferred coding style for the linux kernel. Coding style is very personal, and I won't _force_ my views on anybody, but this is what goes for anything that I have to be able to maintain, and I'd prefer it for most other things too. Please at least consider the points made here. First off, I'd suggest printing out a copy of the GNU coding standards, and NOT read it. Burn them, it's a great symbolic gesture. Anyway, h...

more on kbuild !!

this seems to be getting more and more interesting , ... there is a hell lot of information on 'kbuild' and using the same for developing the modules form outside the kernel ,..... if u have kernel source code then the following is a good place to search :: /[path to kernel source directory]/Documentation/kbuild/ check out all the text files in there !!

kbuild , that was the actual solution !

the content i posted just before , that is on compiling kernel modules , i have tried going through the contents of the makefile and found the following solution , the technique used was something called kbuild, it provides a standard method for building external modules from the kernel environment ,................. for the sample.c driver i wrote the contents of the corresponding makefile were : _____________________________________________________________________________ default : make -C /usr/src/kernels/$(shell uname -r)-i686/ SUBDIRS=$(PWD) modules obj-m :=sample.o clean : -rm *.o *.ko *.mod.c _____________________________________________________________________________ according to the kernel module programming guide this is a method provided by the 2.6x versions called kbuild a little more intorduction at the following link http://www.tldp.org/LDP/lkmpg/2.6/html/x181.html

my ordeal with module.h - SOLUTIONS !!

so here we go on with our story , the other day when i was working on CentOS i opened Kdevelop ( an IDE for programming ) , and started a new project under the 'C --> Kernel module ' and it gave me a sample kernel module , very similar to the one i had earlier written , i just executed the program ( in other words compiled it ) , it finished succesfully , i was confused at first , ...... then i looked at what was going on behind the curtains of Kdevelop , i jumped into the directory Kdevelop had created for the kernel module , btw make is a wondeerful utility which comes very handy when managing large projects ,...... and checked the 'Makefile '( the configuration file used by make ) that had been used to Kdevelop for compiling and installing the module , the makefile was using the includes from the kernel source directory and was starting a submake in that directory which was in turn compiling my module , ........ i will post the details of the 'Makefile' ...

my ordeal with module.h !!

i have had a tough time compiling kernel modules and then inserting them , and the reason , for me the very troublesome /linux/module.h , the most important of header files required when you are writing a kernel module , you can't write a kernel module without including this file , ....... my problem started here when i was writing a kernel module , a very basic hello world module , on Fedora 8 , when i tried compiling it , it showed a lot of errors ( obviously though ..) , later i realised that there was no file /usr/include/linux/module.h , and after some research found out that the kernel headers RPM provided with Fedora 8 doesn't have this file , so even on installing the kernel headers the file was missing , and then with some help from the posts on the Twincling Discussion list ( twincling is an open-source community based in hyderabad ) , i downloaded the kernel source RPMs and recompiled the kernel using the Kernel-spec files for generating the Kernel installation and ...