{"id":95,"date":"2012-03-05T23:36:26","date_gmt":"2012-03-05T18:06:26","guid":{"rendered":"http:\/\/sandeepmathew.wordpress.com\/?p=95"},"modified":"2012-03-05T23:36:26","modified_gmt":"2012-03-05T18:06:26","slug":"linux-kernel-development-part-1","status":"publish","type":"post","link":"https:\/\/sandeepmathew.com\/index.php\/2012\/03\/05\/linux-kernel-development-part-1\/","title":{"rendered":"Linux kernel development &#8211; part 1"},"content":{"rendered":"<p>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 .<\/p>\n<h2>Getting Started \u2014 Compiling the Linux Kernel<\/h2>\n<p>Download the newest linux kernel from www.kernel.org.make sure that you have newer version of gcc. To find out the current gcc version ,type<br \/>\n<code> gcc --version. <\/code><br \/>\nTo extract do ,<br \/>\n<code>gunzip linux-2.6.xxx.tar.gz<br \/>\ntar -xvf linux-2.6xx.tar<\/code><br \/>\nand make your choices and save and exit.<\/p>\n<p>If do not have ncurses library installed<br \/>\n<code>type<br \/>\nmake config<br \/>\n<\/code><\/p>\n<p>if present type<br \/>\n<code>make menuconfig<\/code><\/p>\n<p>For a qt based utility type<br \/>\n<code>make xconfig<\/code><\/p>\n<p>for gtk based type<br \/>\n<code>make gconfig<\/code><\/p>\n<p>if(kernel series is 2.4 )<br \/>\n<code>make depend<\/code><\/p>\n<p>Now finally build the kernel<br \/>\n<code>make<br \/>\nmake modules (for building modules)<\/code><\/p>\n<p>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\u2019s 2.2 vesrions etc we can put this kernel image directly into floppy for testing<\/p>\n<h2>Files and Directories to peek at<\/h2>\n<p>After extracting and compiling the kernel code, it\u2019s time to peek at the different directories.<br \/>\nLets discuss them<br \/>\n1)arch -Architecture dependent code<br \/>\n2)cryto -crypto API<br \/>\n3)Documentation-Docs<br \/>\n4)fs -The Virtual File System Implementation<br \/>\n5)init -the boot process and initialization<br \/>\n6)ipc-Inter process Communication<br \/>\n7)lib -Routines..<br \/>\n8)kernel -core systems<br \/>\n9)mm-Memory management<br \/>\n10)net-networking<br \/>\n11)Scripts<br \/>\n12)Security<br \/>\n13)Sound<br \/>\n14)user<\/p>\n<h2>Brief on gcc inline assembly<\/h2>\n<p>The basic gcc inline assembly format is as follows<\/p>\n<p><code>asm\u00a0 (<br \/>\n&lt;IA 32 instructions &gt;:<br \/>\n&lt;output &gt; :<br \/>\n&lt;input &gt;:<br \/>\n&lt;clobbered&gt;<br \/>\n);<\/code><\/p>\n<p>you can search the net in detail on how to use inline assembly with gcc.<\/p>\n<h2>Frequently used data structures in kernel<\/h2>\n<ul>\n<li>Linked Lists\u00a0\u00a0 :-\u00a0 See\u00a0 \/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<\/li>\n<li>Trees\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 :-\u00a0\u00a0\u00a0 Linux kernel uses balanced trees\u00a0 ( RED BLACK TREE) in memory management . We will see this later<\/li>\n<\/ul>\n<p>In Part2 we will focus more on the x86 architecture<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/sandeepmathew.com\/index.php\/wp-json\/wp\/v2\/posts\/95"}],"collection":[{"href":"https:\/\/sandeepmathew.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sandeepmathew.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sandeepmathew.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sandeepmathew.com\/index.php\/wp-json\/wp\/v2\/comments?post=95"}],"version-history":[{"count":0,"href":"https:\/\/sandeepmathew.com\/index.php\/wp-json\/wp\/v2\/posts\/95\/revisions"}],"wp:attachment":[{"href":"https:\/\/sandeepmathew.com\/index.php\/wp-json\/wp\/v2\/media?parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sandeepmathew.com\/index.php\/wp-json\/wp\/v2\/categories?post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sandeepmathew.com\/index.php\/wp-json\/wp\/v2\/tags?post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}