Posted in System Programming

Linux kernel development – part 1

I will provide a hands on guide on dissecting and learning the Linux kernel . But I am busy with work and so forth and It may not be able to post in regular way. I however will not spoon feed and I will just be providing general guidelines. Also I will covering the linux kernel specific to the ia-32 platform .

Getting Started — Compiling the Linux Kernel

Download the newest linux kernel from http://www.kernel.org.make sure that you have newer version of gcc. To find out the current gcc version ,type
gcc --version.
To extract do ,
gunzip linux-2.6.xxx.tar.gz
tar -xvf linux-2.6xx.tar

and make your choices and save and exit.

If do not have ncurses library installed
type
make config

if present type
make menuconfig

For a qt based utility type
make xconfig

for gtk based type
make gconfig

if(kernel series is 2.4 )
make depend

Now finally build the kernel
make
make modules (for building modules)

Thus your kernel is made.Installation of newer kernel is bootloader specific grub has a different way,lilo has a different way.But the basic idea is same.For older kernel’s 2.2 vesrions etc we can put this kernel image directly into floppy for testing

Files and Directories to peek at

After extracting and compiling the kernel code, it’s time to peek at the different directories.
Lets discuss them
1)arch -Architecture dependent code
2)cryto -crypto API
3)Documentation-Docs
4)fs -The Virtual File System Implementation
5)init -the boot process and initialization
6)ipc-Inter process Communication
7)lib -Routines..
8)kernel -core systems
9)mm-Memory management
10)net-networking
11)Scripts
12)Security
13)Sound
14)user

Brief on gcc inline assembly

The basic gcc inline assembly format is as follows

asm  (
<IA 32 instructions >:
<output > :
<input >:
<clobbered>
);

you can search the net in detail on how to use inline assembly with gcc.

Frequently used data structures in kernel

  • Linked Lists   :-  See  /include/linux/list.h.The C language does not enforce type safety, Linux kernel provides set of macros for CRUD operations on a linked list
  • Trees             :-    Linux kernel uses balanced trees  ( RED BLACK TREE) in memory management . We will see this later

In Part2 we will focus more on the x86 architecture

Advertisements

2 thoughts on “Linux kernel development – part 1

  1. Put some more details about Linux kernel compilation with examples. Current explanantion is not enough for begginners :). A little more description on file structure will also help readers.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s