<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2567861330953913013</id><updated>2024-11-05T19:06:09.035-08:00</updated><category term="LDD"/><category term="Linux Device Drivers"/><category term="Linux"/><category term="Kernel Symbol Table"/><category term="Linux Drivers"/><category term="Linux Kernel Symbol Table"/><category term="Device Drivers"/><category term="Linux Device Driver Tutorial"/><category term="Linux Device Drivers Part-8"/><category term="Symbol Table"/><category term="Symbol in Linux"/><category term="Device Numbers"/><category term="Dynamic Modules"/><category term="Kernel Space"/><category term="Linux Device"/><category term="Linux Device Control"/><category term="Linux Kernel"/><category term="Linux on Windows"/><category term="Major Numbers"/><category term="Minor Numbers"/><category term="Oracle Virtual Machine"/><category term="Oracle virtual Box"/><category term="Static Modules"/><category term="User Space"/><category term="Virtual Linux"/><category term="BIOS"/><category term="Base Kernel"/><category term="Device Driver Programming"/><category term="Device Drivers Part-5"/><category term="Education"/><category term="First Stage Boot Loader"/><category term="How Linux Boots"/><category term="Installing Linux on Windows 7"/><category term="Kernel"/><category term="Kernel Loader"/><category term="Kernel Modules"/><category term="Kernel Space and User spaceInteraction"/><category term="Kernel applications"/><category term="Kernel module"/><category term="Linux Applications"/><category term="Linux Boot Procedure"/><category term="Linux Boot Process"/><category term="Linux Device Driver Part 9"/><category term="Linux Device Drivers 7"/><category term="Linux Device Drivers Part - 4"/><category term="Linux Device Drivers Part -6"/><category term="Linux Device Drivers Part-13"/><category term="Linux Device Drivers Part-5"/><category term="Linux Filesystems"/><category term="Linux Kernel Role"/><category term="Linux Kernel programming"/><category term="Linux Memory Management"/><category term="Linux Networking"/><category term="Linux Process Management"/><category term="Linux Tutorials"/><category term="Loading Listing and Unloading Kernel Moduels"/><category term="MBR"/><category term="Part 4 of Linux Device Drivers"/><category term="Part 5 of Linux Device Drivers"/><category term="Role of Device Drivers"/><category term="Second Stage Boot loader"/><category term="System Calls"/><category term="Tutorials"/><category term="User space and Kernel space"/><category term="Virtual Machine"/><category term="Windows"/><category term="insmod a module"/><category term="link stage"/><category term="unload a module"/><title type='text'>MrTechpathi Tutorials</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://mrtechpathi-tutorials.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>MrTechpathi</name><uri>http://www.blogger.com/profile/17144890590324530224</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>16</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2567861330953913013.post-9212756909774212008</id><published>2015-08-01T08:42:00.000-07:00</published><updated>2020-05-22T22:34:36.615-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Device Driver Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Device Numbers"/><category scheme="http://www.blogger.com/atom/ns#" term="LDD"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Drivers Part-13"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Kernel programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Major Numbers"/><category scheme="http://www.blogger.com/atom/ns#" term="Minor Numbers"/><title type='text'> Linux Device Drivers - Part 13 : More on Device Numbers</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
In this session, we are going to discuss following topics&lt;br /&gt;
&amp;nbsp; &amp;nbsp; 1. Allocating and freeing Device Numbers&lt;br /&gt;
&amp;nbsp; &amp;nbsp; 2. Best way to allocate Device Numbers &lt;br /&gt;
&amp;nbsp; &amp;nbsp; 3. Disadvantage of dynamic assignment of device numbers&lt;br /&gt;
&amp;nbsp; &amp;nbsp; 4. Allocating device numbers to scull device driver&lt;br /&gt;
&lt;br /&gt;
Source code of Linux Device Driver examples of O&#39;reilly can be downloaded from below link&lt;br /&gt;
&lt;br /&gt;
http://examples.oreilly.com/linuxdrive3/&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU1nxr21itPLWYMBGY-XAG927hPuttAuNKIUkjpTIH0BQRL8pPwYR6-dJam-Uf9TZUKokPcMSgIBijwXDeyYqcXQKcZfyuafazwSrDcek9qOLJ2P0I7h3syy8-2tW6H9djSl40oKpKtCY/s1600/mrtechpathi_linux_Device_drivers_part_13.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;484&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU1nxr21itPLWYMBGY-XAG927hPuttAuNKIUkjpTIH0BQRL8pPwYR6-dJam-Uf9TZUKokPcMSgIBijwXDeyYqcXQKcZfyuafazwSrDcek9qOLJ2P0I7h3syy8-2tW6H9djSl40oKpKtCY/s640/mrtechpathi_linux_Device_drivers_part_13.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Watch video here:&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/UztjkDcECkw&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://mrtechpathi-tutorials.blogspot.com/feeds/9212756909774212008/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2015/08/linux-device-drivers-part-13-more-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/9212756909774212008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/9212756909774212008'/><link rel='alternate' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2015/08/linux-device-drivers-part-13-more-on.html' title=' Linux Device Drivers - Part 13 : More on Device Numbers'/><author><name>MrTechpathi</name><uri>http://www.blogger.com/profile/17144890590324530224</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU1nxr21itPLWYMBGY-XAG927hPuttAuNKIUkjpTIH0BQRL8pPwYR6-dJam-Uf9TZUKokPcMSgIBijwXDeyYqcXQKcZfyuafazwSrDcek9qOLJ2P0I7h3syy8-2tW6H9djSl40oKpKtCY/s72-c/mrtechpathi_linux_Device_drivers_part_13.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2567861330953913013.post-6797118766528612162</id><published>2015-08-01T08:38:00.001-07:00</published><updated>2015-08-01T08:38:19.648-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Device Numbers"/><category scheme="http://www.blogger.com/atom/ns#" term="Kernel Symbol Table"/><category scheme="http://www.blogger.com/atom/ns#" term="LDD"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Drivers Part-8"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Kernel Symbol Table"/><category scheme="http://www.blogger.com/atom/ns#" term="Major Numbers"/><category scheme="http://www.blogger.com/atom/ns#" term="Minor Numbers"/><category scheme="http://www.blogger.com/atom/ns#" term="Symbol in Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Symbol Table"/><title type='text'>Linux Device Drivers Part - 12 : Major and Minor Numbers in Linux Device Driver Programming</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; margin: 0px; padding: 0px;&quot;&gt;
&lt;span style=&quot;color: #383838;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21.9999923706055px;&quot;&gt;In this session we will discuss following topics&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; margin: 0px; padding: 0px;&quot;&gt;
&lt;span style=&quot;color: #383838;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21.9999923706055px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; margin: 0px; padding: 0px;&quot;&gt;
&lt;span style=&quot;color: #383838;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21.9999923706055px;&quot;&gt;1. Books to refer for Linux Device Driver Programming&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; margin: 0px; padding: 0px;&quot;&gt;
&lt;span style=&quot;color: #383838;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21.9999923706055px;&quot;&gt;2. Our mail Goal to achieve in up coming sessions&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; margin: 0px; padding: 0px;&quot;&gt;
&lt;span style=&quot;color: #383838;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21.9999923706055px;&quot;&gt;3. Steps to follow while Linux Device Driver Programming&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; margin: 0px; padding: 0px;&quot;&gt;
&lt;span style=&quot;color: #383838;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21.9999923706055px;&quot;&gt;Under this particular topic we will learn about&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; margin: 0px; padding: 0px;&quot;&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;color: #383838; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21.9999923706055px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Gathering information about a Linux Device Driver&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: #383838; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21.9999923706055px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Gathering information of SCULL Device Driver&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: #383838; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21.9999923706055px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Identifying and defining Major and Minor Number&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: #383838; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21.9999923706055px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Representation of Device numbers&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzvV1wM5VNuMbzxrN-0JnpVONw5EJovS-ZnqDXkQWN98MJxOPo4NEIZbmSPPEuCan1rs1V0KSNm0UTkF0PNFBrMgulahkq7-DfEk9-ys8YEzKA4SspTvQTzq8HKmy_s4bu3sDRXwNCafQ/s1600/mrtechpathi_linux_device_drivers_part_12.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzvV1wM5VNuMbzxrN-0JnpVONw5EJovS-ZnqDXkQWN98MJxOPo4NEIZbmSPPEuCan1rs1V0KSNm0UTkF0PNFBrMgulahkq7-DfEk9-ys8YEzKA4SspTvQTzq8HKmy_s4bu3sDRXwNCafQ/s400/mrtechpathi_linux_device_drivers_part_12.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #383838; font-family: gotham, helvetica, arial, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 21.9999923706055px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; margin: 0px; padding: 0px;&quot;&gt;
&lt;span style=&quot;color: #383838; font-family: gotham, helvetica, arial, sans-serif; font-size: 14px; line-height: 21.9999923706055px;&quot;&gt;You can download a softcopy of LDD http://www.oreilly.com/openbook/linuxdrive3/book/&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; margin: 0px; padding: 0px;&quot;&gt;
&lt;br /&gt;
Watch video here :&lt;/div&gt;
&lt;/div&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/deOZGzIOlPI&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://mrtechpathi-tutorials.blogspot.com/feeds/6797118766528612162/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2015/08/linux-device-drivers-part-12-major-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/6797118766528612162'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/6797118766528612162'/><link rel='alternate' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2015/08/linux-device-drivers-part-12-major-and.html' title='Linux Device Drivers Part - 12 : Major and Minor Numbers in Linux Device Driver Programming'/><author><name>MrTechpathi</name><uri>http://www.blogger.com/profile/17144890590324530224</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzvV1wM5VNuMbzxrN-0JnpVONw5EJovS-ZnqDXkQWN98MJxOPo4NEIZbmSPPEuCan1rs1V0KSNm0UTkF0PNFBrMgulahkq7-DfEk9-ys8YEzKA4SspTvQTzq8HKmy_s4bu3sDRXwNCafQ/s72-c/mrtechpathi_linux_device_drivers_part_12.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2567861330953913013.post-1562087605670341096</id><published>2015-07-02T22:46:00.003-07:00</published><updated>2015-07-02T22:47:31.549-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Kernel Symbol Table"/><category scheme="http://www.blogger.com/atom/ns#" term="LDD"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Drivers Part-8"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Kernel Symbol Table"/><category scheme="http://www.blogger.com/atom/ns#" term="Symbol in Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Symbol Table"/><title type='text'>Linux Device Drivers Part 11: Device Driver Types</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In this video session, we will discuss about&lt;br /&gt;
1. /dev directory
Device Driver types (Character Devices, Block devices and Network Devices)&lt;br /&gt;
Practical session included at the end.&lt;br /&gt;
Please subscribe for more videos. &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjO4_9EeD7qhhGEDcvoGkcypH6c3kC9pv4zfH17ZyVEevnGlrJ321zmbhZu8HNOdBpsl0dCq40dy259MMqPsyXYeWhebyBh1Lxsb10niBaKvOpp55oqG_PfEp8moTPo0shfvZGsq8aO_rQ/s1600/mrtechpathi_linux_device_driver_Part_11.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;238&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjO4_9EeD7qhhGEDcvoGkcypH6c3kC9pv4zfH17ZyVEevnGlrJ321zmbhZu8HNOdBpsl0dCq40dy259MMqPsyXYeWhebyBh1Lxsb10niBaKvOpp55oqG_PfEp8moTPo0shfvZGsq8aO_rQ/s320/mrtechpathi_linux_device_driver_Part_11.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/jP9mLe2nAN4&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://mrtechpathi-tutorials.blogspot.com/feeds/1562087605670341096/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2015/07/linux-device-drivers-part-11-device.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/1562087605670341096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/1562087605670341096'/><link rel='alternate' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2015/07/linux-device-drivers-part-11-device.html' title='Linux Device Drivers Part 11: Device Driver Types'/><author><name>MrTechpathi</name><uri>http://www.blogger.com/profile/17144890590324530224</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjO4_9EeD7qhhGEDcvoGkcypH6c3kC9pv4zfH17ZyVEevnGlrJ321zmbhZu8HNOdBpsl0dCq40dy259MMqPsyXYeWhebyBh1Lxsb10niBaKvOpp55oqG_PfEp8moTPo0shfvZGsq8aO_rQ/s72-c/mrtechpathi_linux_device_driver_Part_11.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2567861330953913013.post-4742688956204231572</id><published>2015-07-02T22:46:00.002-07:00</published><updated>2015-07-02T22:47:56.459-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Kernel Symbol Table"/><category scheme="http://www.blogger.com/atom/ns#" term="LDD"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Drivers Part-8"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Kernel Symbol Table"/><category scheme="http://www.blogger.com/atom/ns#" term="Symbol in Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Symbol Table"/><title type='text'>Linux Device Drivers Part 10: Module Parameters</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In this video session we will discuss following topics&lt;br /&gt;
&lt;br /&gt;
1.What are Module parameters ?&lt;br /&gt;
2.Ways to change these module parameters?&lt;br /&gt;
3.Module_param macro&lt;br /&gt;
4.Array Module parameters&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7nT_XZrLaaDS-QeE34CVhGXU_w4wj6JcFl_Hvdcfi9LEAUK7sHysGA4kjeU7XSdwfZ9dAyl4SN42SGnL9v7HtTlGnY7HYxduFJNmIiA3UDoxv81JSf2Twpoo_OXwftcW7URg55aGsxd0/s1600/thumbnail_Linux_device_drivers_part_10.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;238&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7nT_XZrLaaDS-QeE34CVhGXU_w4wj6JcFl_Hvdcfi9LEAUK7sHysGA4kjeU7XSdwfZ9dAyl4SN42SGnL9v7HtTlGnY7HYxduFJNmIiA3UDoxv81JSf2Twpoo_OXwftcW7URg55aGsxd0/s320/thumbnail_Linux_device_drivers_part_10.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/3ccMOOLS6xY&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://mrtechpathi-tutorials.blogspot.com/feeds/4742688956204231572/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2015/07/linux-device-drivers-part-10-module.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/4742688956204231572'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/4742688956204231572'/><link rel='alternate' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2015/07/linux-device-drivers-part-10-module.html' title='Linux Device Drivers Part 10: Module Parameters'/><author><name>MrTechpathi</name><uri>http://www.blogger.com/profile/17144890590324530224</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7nT_XZrLaaDS-QeE34CVhGXU_w4wj6JcFl_Hvdcfi9LEAUK7sHysGA4kjeU7XSdwfZ9dAyl4SN42SGnL9v7HtTlGnY7HYxduFJNmIiA3UDoxv81JSf2Twpoo_OXwftcW7URg55aGsxd0/s72-c/thumbnail_Linux_device_drivers_part_10.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2567861330953913013.post-3294190587482784734</id><published>2015-06-15T15:34:00.000-07:00</published><updated>2015-06-15T15:34:24.535-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Device Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Kernel Symbol Table"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Driver Part 9"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Kernel Symbol Table"/><title type='text'>Linux Device Drivers Part 9 - More about Symbol tables</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;In this part we will discuss about following topics&lt;/span&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;About undefined symbol error and steps to solve it&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Is it mandatory to export the symbols ?&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Location of symbol table&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;About system.map file in Linux&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3vyxJUq47CS7em-qDfAhOwZt_nB7RvojD3KsqpbUC1Qz_oDoXFYBtKIWDwwEB9cKMyucnTt4EYWHRgt6i-TcmTnC8WYrQpNMjTyiQk9BspFdA_Vp3x1SUWOhQI8wfe4_Wi164zTeyMvo/s1600/mrtechpathi_LDD_Part_9.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;450&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3vyxJUq47CS7em-qDfAhOwZt_nB7RvojD3KsqpbUC1Qz_oDoXFYBtKIWDwwEB9cKMyucnTt4EYWHRgt6i-TcmTnC8WYrQpNMjTyiQk9BspFdA_Vp3x1SUWOhQI8wfe4_Wi164zTeyMvo/s640/mrtechpathi_LDD_Part_9.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1. About undefined symbol error and steps to solve it&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;The most common and most frustrating failure in loading an LKM is unresolved symbol, like this:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt; insmod: error inserting &#39;helloworld.ko&#39;: -1 Unknown symbol in module  
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;To debug this error,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1. Use nm utility&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;2. Know symbol definitions (in next slide)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Lets say my module is helloworld.ko&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;In order to display symbol table, we use following command.&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt; $nm helloworld.ko.  
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Output of this command is&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt; 00000000 r ____versions  
 0000002c r __mod_author22  
 00000000 r __mod_description24  
 00000020 r __mod_license23  
 00000040 r __mod_srcversion30  
 00000080 r __mod_vermagic5  
 00000063 r __module_depends  
 00000000 D __this_module  
 00000000 r _rheldata  
 00000000 T cleanup_module  
 &lt;b&gt;00000000 B g_value  &lt;/b&gt;
 00000000 t hello_exit  
 00000000 t hello_init  
 00000000 T init_module  
      &lt;b&gt;U printk &lt;/b&gt; 
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;In this list, try to find the Undefined symbol tag / Unknown symbol tag (in second column of symbol table).&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Once Symbol table is handy, we need to know about &amp;nbsp;symbol types.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Some of these types are:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;A for absolute&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;B or b for uninitialized data section (called BSS)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;D or d for initialized data section&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;G or g for initialized data section for small objects (global)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;i for sections specific to DLLs&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;N for debugging symbol&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;p for stack unwind section&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;R or r for read only data section&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;S or s for uninitialized data section for small objects&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;T or t for text (code) section&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;U for undefined&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;V or v for weak object&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;W or w for weak objects which have not been tagged so&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;- for stabs symbol in an a.out object file&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;2. Is it mandatory to export the symbols ?&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Now with symbol table and symbol types in hand, &amp;nbsp;we need to check which symbol type is relevant to our error. From above symbol types, &quot;U for undefined&quot; is relevant &quot;Unknown symbol in module&quot;.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;So, the symbols which are having U in the symbol table (second column) displayed are g_value and printk. printk will be resolved by Kernel while loading the module because relevant header files are included. So, we need to concentrate on g_value and why its displayed.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;In order to resolve this, you need to either export this in any other module where the definition exists or you need to make this local to this module.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;To know answer for this question, you can think of kernel symbols as being visible at three different levels in the Kernel source code:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&quot;static&quot;, - &amp;nbsp;visible only within their own source file (just like standard user space programming),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&quot;external&quot; - potentially visible to any other code built into the kernel itself, and&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&quot;exported - &amp;nbsp;visible and available to any loadable module&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;From above statement it’s obvious that if you are writing a Linux Kernel Module, it’s mandatory to export your module symbols if you want other module to benefit using them.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;3. Location of Symbol tables&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;The symbol exported by the statically Linked kernel and all linked-in modules can be retrieved by reading the /proc/kallsyms file or &amp;nbsp;using the query_modue() system call.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Take a look at /proc/kallsyms entry by typing following command in your terminal.&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt; cat /proc/kallsyms  
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Every entry in this file represents an exported (public) kernel symbol, which can be accessed by a Linux Kernel Module.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;If you would like to get symbol table of a particular module or kernel object, you can use “nm” command&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; width: 646.440979003906px;&quot;&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt; $nm KernelModule.ko.  
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div&gt;
&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;4.About System.map file in Linux&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Every kernel image that you build has a symbol table with it . The linux kernel symbol table contains names and addresses of all the kernel symbols.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;In Linux, the System.map file is a symbol table used by the kernel.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Because addresses may change from one build to the next, a new System.map is generated for each build of the kernel.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;The System.map is required when the address of a symbol name, or the symbol name of an address, is needed. It is especially useful for debugging kernel panics and kernel oopses.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;After building the Linux kernel, System.map is located in the root of the source directory. &amp;nbsp;Try typing “locate System.map” command in terminal.&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt; locate System.map  
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;These topics are also explained in detail with practical session in below video.&lt;br /&gt;
If you like it, please do subscribe and shed your comments.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/_k6zg5mLDXk&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://mrtechpathi-tutorials.blogspot.com/feeds/3294190587482784734/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2015/06/linux-device-drivers-part-9-more-about_15.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/3294190587482784734'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/3294190587482784734'/><link rel='alternate' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2015/06/linux-device-drivers-part-9-more-about_15.html' title='Linux Device Drivers Part 9 - More about Symbol tables'/><author><name>MrTechpathi</name><uri>http://www.blogger.com/profile/17144890590324530224</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3vyxJUq47CS7em-qDfAhOwZt_nB7RvojD3KsqpbUC1Qz_oDoXFYBtKIWDwwEB9cKMyucnTt4EYWHRgt6i-TcmTnC8WYrQpNMjTyiQk9BspFdA_Vp3x1SUWOhQI8wfe4_Wi164zTeyMvo/s72-c/mrtechpathi_LDD_Part_9.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2567861330953913013.post-3427933320076740540</id><published>2015-06-07T08:28:00.000-07:00</published><updated>2015-06-07T08:28:10.437-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Kernel Symbol Table"/><category scheme="http://www.blogger.com/atom/ns#" term="LDD"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Drivers Part-8"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Kernel Symbol Table"/><category scheme="http://www.blogger.com/atom/ns#" term="Symbol in Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Symbol Table"/><title type='text'>Linux Device Drivers - Part 8 :  Kernel Symbol Tables</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In this session we learn about&lt;br /&gt;
1. A symbol in Linux&lt;br /&gt;
2. How it is exported ?&lt;br /&gt;
3. Symbol and Symbol Table relationship&lt;br /&gt;
4. Idea behind exporting a Symbol&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjxQEX6SG11mYhelju9r8sPqQhYiST9Tn4C2FkBg0QzyyX9COEdt_blzJViE2e4QJi49iG2XNaLiDvHzWyE0thH2iPmRYDtN6iLe1h9wz6y7-4h_ww4LOiruxjoUEQ5WUqeWeSVoE8O5Q/s1600/mrtechpathi_tutorails_linux_device_drivers_part_8_kernel_Symbol_tables.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;443&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjxQEX6SG11mYhelju9r8sPqQhYiST9Tn4C2FkBg0QzyyX9COEdt_blzJViE2e4QJi49iG2XNaLiDvHzWyE0thH2iPmRYDtN6iLe1h9wz6y7-4h_ww4LOiruxjoUEQ5WUqeWeSVoE8O5Q/s640/mrtechpathi_tutorails_linux_device_drivers_part_8_kernel_Symbol_tables.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;1. A Symbol in Linux&lt;/b&gt;&lt;br /&gt;
In Linux, symbols are nothing but variables and functions that are needed to implement modularised drivers. Note that each and every symbol has its address in the memory.&lt;br /&gt;
&lt;br /&gt;
To make our understanding clear, lets draw a small diagram which shows a Linux Kernel Module with symbols ( Variables and functions ) in it.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIqBINm05nVx7eaXDFO5RqaU3Nwg8mt_SlTkEnmxt2YODH1tTxv2yC2p6HusACKRQVBpXP3rIYj76FCS1zUoYqP0wjwenVc4VmVQaTUD88w41uDydAIcHbNOCzO2h4nMJJ10I8dZn7EC0/s1600/mrtechpathi_tutorails_linux_device_drivers_part_7_kernel_Symbol_tables.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;171&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIqBINm05nVx7eaXDFO5RqaU3Nwg8mt_SlTkEnmxt2YODH1tTxv2yC2p6HusACKRQVBpXP3rIYj76FCS1zUoYqP0wjwenVc4VmVQaTUD88w41uDydAIcHbNOCzO2h4nMJJ10I8dZn7EC0/s400/mrtechpathi_tutorails_linux_device_drivers_part_7_kernel_Symbol_tables.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
So in short, symbol is nothing but a variable or function in LKM&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b&gt;How Symbols are Exported ?&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
Exporting Kernel Symbols is typically done with&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;EXPORT_SYMBOL()&lt;/li&gt;
&lt;li&gt;EXPORT_SYMBOL_GPL()&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
EXPORT_SYMBOL(), which exports a given symbol to all loadable modules&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
EXPORT_SYMBOL_GPL(), which exports a given symbol to only those modules that have a GPL-compatible license. (The first variation is far more common).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
GPL here is General Public License is widely used for free software license.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
EXPORT_SYMBOL_GPL functionality is same as EXPORT_SYMBOL, but it marks the exported symbol as usable only in modules licensed through either the General public License or a compatible one.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
So, whenever you write a driver, it should be GPL licensed. That will be a great facility in case your module wants to use any other module’s functions that are already exported using GPL.&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b&gt;3.Symbol and Symbol Table relation&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
Now we know about a symbol and how it is exported in Linux Kernel module. Lets learn about Kernel Symbol Table (also called Symbol Table in short).&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Kernel symbol table is nothing but a look-up table between symbol names and their addresses in memory.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
When a module is loaded into Kernel memory using insmod or modprobe utility, any symbol exported by the module becomes part of the Kernel symbol table. Exported symbols will become public Kernel symbols.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI4HRcegDX6zFIEOvFu3zTjfQxc34UX9pU4PO1JRG6V4oW1S7Nndoxg7cXypQXxklTsSdQNAkZzbCpHkF4kXOLFrDB-CZsrlf4cPLNLFhOQguHuH51-G6tXmgvrttHi_7ISttcenMuYs4/s1600/mrtechpathi_tutorials_linux_device_drivers_part7_kernel_symbol_table_1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;168&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI4HRcegDX6zFIEOvFu3zTjfQxc34UX9pU4PO1JRG6V4oW1S7Nndoxg7cXypQXxklTsSdQNAkZzbCpHkF4kXOLFrDB-CZsrlf4cPLNLFhOQguHuH51-G6tXmgvrttHi_7ISttcenMuYs4/s640/mrtechpathi_tutorials_linux_device_drivers_part7_kernel_symbol_table_1.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
While insmoding, the insmod utility resolves undefined symbols against the table of public Kernel symbols.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Kernel Symbol tables hold all the information needed to find program symbols, assign value to them, and relocate them.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Primary task of symbol is to associate a string with a value. For ex, printk symbol represents the address of the printk function in virtual address space where the function machine code resides.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This Kernel symbol table is loaded into memory as part of the Kernel boot process.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
We will be learning more about Kernel Symbol Tables in coming Sessions.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;4. Idea behind Exporting a Symbol&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Whole idea of exporting a symbol is to make other modules benefit using them.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
New modules can use symbols exported by your module, and you can stack new modules on top of other modules. &amp;nbsp;This concept is called Module stacking.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXEAOZk67kcMiCVu3OiO5Ek4_5YTHy4XhOLReogXIZzBrfWa0nb4qdP6RwKUB4oElcQIpMZckGueg-Cz2eNiXxJY0SfMcPaxEg6WcilLze85J2qrETeXYz5Soi9hbjGXW1wctzxdWlnn8/s1600/mrtechpathi_tutorials_linux_device_drivers_part_8_kernel_symbol_table.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;85&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXEAOZk67kcMiCVu3OiO5Ek4_5YTHy4XhOLReogXIZzBrfWa0nb4qdP6RwKUB4oElcQIpMZckGueg-Cz2eNiXxJY0SfMcPaxEg6WcilLze85J2qrETeXYz5Soi9hbjGXW1wctzxdWlnn8/s320/mrtechpathi_tutorials_linux_device_drivers_part_8_kernel_symbol_table.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Module stacking is implemented in the mainstream kernel sources as well: like each input USB device module stacks on the usbcore and input modules.&lt;/div&gt;
&lt;div&gt;
Module loading order can be important, particularly if they are stacked (dependent on the symbols defined in other modules)&lt;/div&gt;
&lt;div&gt;
This mechanism help reduce development time by simplifying each layer&lt;br /&gt;
&lt;br /&gt;
Check out video on this topi in my youtube channel. Don&#39;t forget to subscribe.&lt;/div&gt;
&lt;/div&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/sen-FlxJu_M&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;

&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://mrtechpathi-tutorials.blogspot.com/feeds/3427933320076740540/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2015/06/linux-device-drivers-part-8-kernel_7.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/3427933320076740540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/3427933320076740540'/><link rel='alternate' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2015/06/linux-device-drivers-part-8-kernel_7.html' title='Linux Device Drivers - Part 8 :  Kernel Symbol Tables'/><author><name>MrTechpathi</name><uri>http://www.blogger.com/profile/17144890590324530224</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjxQEX6SG11mYhelju9r8sPqQhYiST9Tn4C2FkBg0QzyyX9COEdt_blzJViE2e4QJi49iG2XNaLiDvHzWyE0thH2iPmRYDtN6iLe1h9wz6y7-4h_ww4LOiruxjoUEQ5WUqeWeSVoE8O5Q/s72-c/mrtechpathi_tutorails_linux_device_drivers_part_8_kernel_Symbol_tables.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2567861330953913013.post-8118582920330286728</id><published>2015-06-06T06:27:00.001-07:00</published><updated>2015-06-07T02:27:43.003-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="insmod a module"/><category scheme="http://www.blogger.com/atom/ns#" term="Kernel applications"/><category scheme="http://www.blogger.com/atom/ns#" term="Kernel module"/><category scheme="http://www.blogger.com/atom/ns#" term="Kernel Space"/><category scheme="http://www.blogger.com/atom/ns#" term="LDD"/><category scheme="http://www.blogger.com/atom/ns#" term="link stage"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Drivers 7"/><category scheme="http://www.blogger.com/atom/ns#" term="unload a module"/><category scheme="http://www.blogger.com/atom/ns#" term="User Space"/><title type='text'>Linux Device Drivers Part -7 : Kernel Modules vs Applications</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;In this part, we are going to discus about ,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;The difference between Kernel Modules (KM) and Applications (APs) &lt;b&gt;in brief&lt;/b&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Before proceeding further, I strongly recommend to watch my earlier videos from &quot;Linux Device Drivers Part -1 to Part 6&quot;.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9wJoRoAWP9hHsJTSAYlaClH5iihjJy78RpTZgBwJdg-nghzwqDrkWtBcg59kGRRhcFB0Yb4fFFF3bwZFHlx3hi3radAKSndz-sFnH0Luls6iQIyRBooXmn6dmQn7LgbzAuc28ZMmy1z8/s1600/mrtechpathi_Linux_Device_Drivers_Part-7.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;484&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9wJoRoAWP9hHsJTSAYlaClH5iihjJy78RpTZgBwJdg-nghzwqDrkWtBcg59kGRRhcFB0Yb4fFFF3bwZFHlx3hi3radAKSndz-sFnH0Luls6iQIyRBooXmn6dmQn7LgbzAuc28ZMmy1z8/s640/mrtechpathi_Linux_Device_Drivers_Part-7.jpg&quot; width=&quot;640&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Though there are many differences, to keep it simple and to explain in brief , I have hand picked few differences and listed them as topics form, which can be easily remembered and recollected when required &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;We compare below 6 topics between Kernel Modules (KM) and Applications (APs)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1. Initialisation&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;2. Which are Event Driven KM&#39;s or AP’s&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;3. About Exit Procedure in &amp;nbsp;KM&#39;s or AP’s &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;4. Ability to unload a module &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;5. Linking stage &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;6. Handling faults&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;This tutorial covers only brief description of all topics listed. This will help us to understand upcoming sessions with ease&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Lets start with our first topic, &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1. Initialisation&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;When we invoke a application, it starts and proceed ahead till end .&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Most small and medium sized application programs perform a single task from beginning to end. Take any application in your PC, they start and run till you end them&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Whereas every Kernel module registers itself with Kernel in order to serve future requests, and its initialisation function terminates immediately.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;In other words, the task of the module&#39;s initialisation function is to prepare for later invocation of the module&#39;s functions when required.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;2. Which are Event Driven KMs or APs&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;To understand in simple way, say if something happens, an event is raised and that should be served. So, with our current understanding, do you think Kernel is event driven ?&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Yes, when a Kernel module is loaded, it invokes init function (hello_init) which conveys Kernel “Here I am, and this is what I can do”. &amp;nbsp; Its conveying kernel, if some events occurs, just let me know i will serve&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;When &amp;nbsp;Kernel module is unloaded, it invokes exit (hello_exit) which conveys &amp;nbsp;Kernel “I am not there anymore; don’t ask me to do anything else”.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;This kind of approach to programming is similar to event-driven programming, but while &lt;b&gt;not all applications are event-driven&lt;/b&gt;, each and every Kernel module is even driven.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;3. About Exit Procedure in &amp;nbsp;KM or AP’s&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp;I have mentioned earlier, not all applications are event-driven . Imagine we have event driven application &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Major difference between event-driven applications and Kernel code is in the exit function.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;When an application terminates, it can be lazy in releasing resources or avoids clean up altogether, the exit function of a module must carefully undo everything the init function built up, or the pieces remain around until the system is rebooted. &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Sometimes , we end out of memory situations and system may totally crash. Note when application crashes, system can run without any issue, if kernel module crashes, it will kill the process or whole system needs to be rebooted&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;4. Ability to unload a module&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Incidentally, the ability to unload a module is one of the features of modularisation that you&#39;ll most appreciate, because it helps cut down development time; you can test successive versions of your new driver without going through the lengthy shutdown/reboot cycle each time.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;If you have driver programming experience, you will really appreciate this feature. It save lot of time and effort&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;With application, you need to either exit it completely and rerun the application. You will not be sure if the memory allocated is dealloated or the task initiated is exited cleanly. It all depends on how you implement the application.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;5. Linking Stage&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;An application can call functions it doesn&#39;t define: the linking stage resolves external references using the appropriate library of functions.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;printf is one of those callable functions and is defined in libc.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;A module, on the other hand, is linked only to the Kernel, and the only functions it can call are the ones exported by the Kernel; there are no libraries to link to. This point is very important. Keep in mind that there are no libraries for kernel modules to link to&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;The printk function used in hello.c earlier, for example, is the version of printf defined within the kernel and exported to modules. It behaves similarly to the original function, with a few minor differences.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Because no library is linked to kernel modules, source files should never include the usual header files. There are special exceptions like &amp;lt;stdarg.h&amp;gt; .&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Only functions that are actually part of the Kernel itself may be used in Kernel modules. Anything related to the Kernel is declared in headers found in the Kernel source tree had to be set up and configured.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Most of the relevant headers live in &quot;include/linux&quot; and &quot;include/asm&quot;, but other sub directories of include have been added to host material associated to specific Kernel subsystems.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;b&gt;6. Handling Faults&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Another important difference between kernel programming and application programming is in how each environment handles faults.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;As briefed earlier , Segmentation fault is harmless during application development and a debugger can always be used to trace the error to the problem in the source code, a kernel fault kills the current process at least, if not the whole system. &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Hey don&#39;t forget to check out youtube version of this article here.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;If you like, please dont forget to give a thumbsup :)
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/Sp0vfWll7H8&quot; width=&quot;420&quot;&gt;&lt;/iframe&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://mrtechpathi-tutorials.blogspot.com/feeds/8118582920330286728/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2015/06/linux-device-drivers-part-7-kernel.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/8118582920330286728'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/8118582920330286728'/><link rel='alternate' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2015/06/linux-device-drivers-part-7-kernel.html' title='Linux Device Drivers Part -7 : Kernel Modules vs Applications'/><author><name>MrTechpathi</name><uri>http://www.blogger.com/profile/17144890590324530224</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9wJoRoAWP9hHsJTSAYlaClH5iihjJy78RpTZgBwJdg-nghzwqDrkWtBcg59kGRRhcFB0Yb4fFFF3bwZFHlx3hi3radAKSndz-sFnH0Luls6iQIyRBooXmn6dmQn7LgbzAuc28ZMmy1z8/s72-c/mrtechpathi_Linux_Device_Drivers_Part-7.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2567861330953913013.post-5465037177016338896</id><published>2015-06-06T06:26:00.000-07:00</published><updated>2015-06-06T06:26:44.751-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="LDD"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Control"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Driver Tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Drivers Part -6"/><category scheme="http://www.blogger.com/atom/ns#" term="Loading Listing and Unloading Kernel Moduels"/><title type='text'>Linux Device Drivers Part - 6 : Loading Listing and Unloading Kernel Modules</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;In this part , we are going to discuss about&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1. Loading Kernel modules&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;2. Listing &amp;nbsp;kernel modules&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;3. Unloading kernel modules&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Before going ahead with these topics, I strongly recommend you to watch my earlier videos on Linux Device Driver Part 1 to 5.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXzmcmhYHZURMAunq3bJB8iPR1xGJf53lV9rKrxx8lfbZIFwqCdIkptWaDQE86gkAitDj-w3nlpP_-aSZw4MNVNnYEHGdE0z0UnVFNYCLt4ZUED0ocBYM16abm3Bjz6YUk8WiJOT4lst8/s1600/Linux_Device_Drivers_Part_6.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;450&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXzmcmhYHZURMAunq3bJB8iPR1xGJf53lV9rKrxx8lfbZIFwqCdIkptWaDQE86gkAitDj-w3nlpP_-aSZw4MNVNnYEHGdE0z0UnVFNYCLt4ZUED0ocBYM16abm3Bjz6YUk8WiJOT4lst8/s640/Linux_Device_Drivers_Part_6.jpg&quot; width=&quot;640&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Fine, lets start with our first topic&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1. Loading Kernel modules&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;In earlier session &quot;&lt;a href=&quot;http://www.mrtechpathi-tutorials.com/2014/08/linux-device-drivers-part-5.html&quot;&gt;Linux Device Drivers Part-5&lt;/a&gt;&quot;, we learnt how to build a sample helloworld Linux Kernel module.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;In this session we will see how to load that sample module into the kernel.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;We have two kernel utilities which does the trick of loading modules into the kernel.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;We have two utilities to perform this task&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1. insmod&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;2. modprobe&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;In following slides we will discuss about these utilities, their syntax and usage &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;So,What is insmod and what does it do ?&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Insmod is a kernel utility that installs loadable Kernel modules into kernel. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;It actually loads the module code and data into the kernel land, it links any unresolved symbols in the module to the symbol table of the kernel.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Insmod accepts a number of command line options and it can assign a value to parameters in a module before linking it to the current kernel.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Note that if a module is correctly designed, it can be configured at load time by passing arguments to insmod.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Lets see syntax of insmod&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Syntax:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;insmod [filename]&amp;nbsp;&amp;nbsp;[module-options...]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;These module options are optional.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;For example:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;insmod my_module.ko &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;This command inserts a module named my_module &amp;nbsp;into kernel with no module option&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Take another example,&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt; insmod /path/to/my_module.ko param1=0x330  &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;This command inserts my_module into kernel, specifying the module options &quot;param1=330&quot; . Module-options are just like command line arguments to kernel object&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;We will discuss more about module options in upcoming sessions ===&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;One important point to note here is that insmod accepts only one module as input prameter&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;You can&#39;t load two loadable modules at a time using insmod utility.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Second utiltiy is &lt;b&gt;modproble&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;It’s a Linux utility which offers more features than basic insmod utility.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;When compared to insmod, modprobe has various advantages like&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;It has the ability to decide which modules to load. Modprobe checks a directory /lib/modules/$(uname -r) for modules. This way it knows what modules to load&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Also, Its aware of module dependencies.&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;To know details of module dependencies, Modprobe uses another configuration &amp;nbsp;file called &lt;b&gt;modules.dep&lt;/b&gt; which is generated by depmod program&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;It supports resolution of recursive module dependencies when required. &amp;nbsp;When requested to load a particular module say its name x, if it has dependency on another module say y which is again dependency on z, modprobe tries to find these &amp;nbsp;modules in the current path or standard lib path and loads these modules to resolve all the dependecy symbols.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;These features are not available with basic insmod command&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Coming to syntax of modprobe to install a module&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Its Basic syntax is&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; modprobe &amp;nbsp;[modulename...]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;command followed by optional module name&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;For Example :&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $sudo modprobe&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;When modeprobe is soley used, it intelligently adds or removes a module from /lib/modules/&#39;uname -r&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;$sudo modprobe my_module.&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvTueShU6Chp6CmCCqJP_TXQrn483Yjy6T0JAYk3AaLNmkkBAkHH9AcTZqCXx6pKNrl9jTT37vCDbe0gV5pAnJh_dDuyMJFForKg-fOIy9aN5lPGcWZabWu02IrKlQJdqXMViBlWHIJ-0j/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;  $sudo modprobe my_module.  
&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Note you should be a super user to execute modprobe.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Modprobe supports various options. Please refer modprobe man page for more details.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Lets learn the difference between insmod and modprobe &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;

&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;While loading a module,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;insmod fails with &quot;Unresolved Symbol&quot; error when an unresolved symbol is present in the loading module.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Where as modprobe looks at the module to be loaded to see &amp;nbsp;whether it references any symbols that are not currently defined in the kernel. If any such references are found, modprobe looks for other modules in the current module search path that define the relevant symbols.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;When modprobe finds those modules which are needed by the module being loaded, it loads them into the kernel as well.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;In short, while loading a module into kernel, if that module has any dependency on another module, modprobe find those modules under current module search path, it loads them into the kernel.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Note modeprobe is aware of default location of modules and knows how to figure out the dependencies and load the modules in the right order.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;One more important point to note here is &amp;nbsp;we need to root permissions for executing both insmod and modporbe commands.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;When a module is loaded, any symbol exported by the module becomes part of kernel symbol table.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;So what exactly is kernel symbol table&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Kernel Symbol Table:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;In earlier slides we have discussed about insmod resolving undefined symbols by referring Kernel Symbol Table. The Kernel Symbol table contains the addresses of global kernel items, functions and variables that are needed to implement modularized drivers.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Now we know details of loading a kernel module using insmod and modprobe. Lets jump to our second topic,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;b&gt;2. Listing modules currently loaded in kernel&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;We use a Linux utility called “lsmod”&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Lsmod command lists the modules currently loaded in the kenrel. Lsmod works by reading the /proc/modules virtual file.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Information on currently loaded modules can also be found in the sysfs virtual filesystem under /sys/modules.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Syntax:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;$lsmod&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;b&gt;3. Unloading kernel modules &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Two Kernel Utilities to unload the modules are&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;$rmmod&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;$Modprobe&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Lets learn about rmmod&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;rmmod is a Linux utility which unloads the loadable module.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Module should be already loaded to execute rmmod command.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Module fails if the kernel believes that the module is still in use or if the kernel has been configured to disallow module removal.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Syntax of rmmod&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;rmmod [module name]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Example: $rmmod my_module&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Note name &quot;my_module&quot; doesnt have any extension like .ko here&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Note :We need to be a super user for executing this command.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Modprobe syntax&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Since we have already discussed about modprobe in earlier slides, lets learn the syntax for unloading a kernel module&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Syntax is&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;$modprobe –r &amp;nbsp;[module-name]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;For example:&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;  insmod my_module.ko    
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;$modprobe –r my_module&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Note : There is no ko extension here and We need to be a super user for executing this command.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Lets wind up this session with an important question asked in forums.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;

&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Is it possible to forcibly remove the kernel modules when the are in use ?&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Yes, its possible to configure the kernel to allow forced removal of modules, even when they appear to be busy. &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Commands normally used are&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;rmmod -f yourmodule&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;modprobe -rf yourmodule&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;These commands only work when you enable the kernel configuration CONFIG_MODULE_FORCE_UNLOAD.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Hey don&#39;t forget to check out youtube version of this article here.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;If you like, please don&#39;t forget to give a thumbsup :)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/zTTzIc1zJ3s&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://mrtechpathi-tutorials.blogspot.com/feeds/5465037177016338896/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2015/06/linux-device-drivers-part-6-loading.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/5465037177016338896'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/5465037177016338896'/><link rel='alternate' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2015/06/linux-device-drivers-part-6-loading.html' title='Linux Device Drivers Part - 6 : Loading Listing and Unloading Kernel Modules'/><author><name>MrTechpathi</name><uri>http://www.blogger.com/profile/17144890590324530224</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXzmcmhYHZURMAunq3bJB8iPR1xGJf53lV9rKrxx8lfbZIFwqCdIkptWaDQE86gkAitDj-w3nlpP_-aSZw4MNVNnYEHGdE0z0UnVFNYCLt4ZUED0ocBYM16abm3Bjz6YUk8WiJOT4lst8/s72-c/Linux_Device_Drivers_Part_6.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2567861330953913013.post-1636820865471845116</id><published>2014-08-11T14:34:00.001-07:00</published><updated>2015-06-06T07:00:46.289-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Device Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Device Drivers Part-5"/><category scheme="http://www.blogger.com/atom/ns#" term="LDD"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Drivers Part-5"/><category scheme="http://www.blogger.com/atom/ns#" term="Part 5 of Linux Device Drivers"/><title type='text'>Linux Device Drivers Part - 5 : Building and Compiling Kernel Moduels</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;In this part, we will discuss about 5 topics&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Linux Device Driver Example References&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Setting up Environment for compiling Kernel modules.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Implementing Helloworld Kernel module and Macros used in it.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Creating Makefile to compile Helloworld Kernel module&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Compilation and Kernel object generation of Helloworld Kernel module&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf4pWNwntO5vWpLAk6RTAPhCdrIqhMr8_OMZ8N-_9FfWptr1YLNN8lav1OBhPHO3i556oOHZyv75Ns4Gj0L9u02S_VsmeolBfx4myFcqgeza93NTwgBItuU8VycxPX8NanFCsr5ov0YAw/s1600/mrtechpathi_Title_Page_Linux_Device_Drivers_5.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;mrtechpathi_Title_Page_Linux_Device_Drivers_5&quot; border=&quot;0&quot; height=&quot;470&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf4pWNwntO5vWpLAk6RTAPhCdrIqhMr8_OMZ8N-_9FfWptr1YLNN8lav1OBhPHO3i556oOHZyv75Ns4Gj0L9u02S_VsmeolBfx4myFcqgeza93NTwgBItuU8VycxPX8NanFCsr5ov0YAw/s640/mrtechpathi_Title_Page_Linux_Device_Drivers_5.jpg&quot; title=&quot;mrtechpathi_Title_Page_Linux_Device_Drivers_5&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1. Linux Device Driver Example references&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Before proceeding further, make sure you have watched my earlier videos &amp;nbsp;on &quot;Linux Device drivers&quot; &amp;nbsp;Part 1 to Part 4.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;As mentioned in my earlier videos, most of the concepts &amp;nbsp;discussed in these sessions are &amp;nbsp;derived from famous O&#39;Rielly Linux Device Drivers &amp;nbsp;3rd edition.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;To demonstrate Kernel programming concepts, I will be using the O&#39;Reilly &amp;nbsp;sample programs which are available on below site to download.&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;      http://examples.oreilly.com/linuxdrive3  
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Download these files and save it to your harddrive. Compiling, loading and modifying these examples are good way to improve your understanding of how Linux Device drivers work and interact with Kernel. &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;All examples work with any 2.6.x Kernel. You need to install Kernel headers before Building and running your modules.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;2. Setting up Environment for compiling Kernel modules.&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
I am using a Virtual Linux system in Windows 7. To know how to install Linux on Windows 7 Pc, please watch my earlier video on &quot;&lt;a href=&quot;https://www.youtube.com/watch?v=R3Eaz3ztspI&quot;&gt;Installing Linux in windows 7 PC using Oracle VM Machine&quot;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Now we will install the necessary packages required for compiling Compiling a Kernel module.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;In order to install any package you should be a super user (from here on we will address it as root).&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Login as root by typing &quot;su&quot; command in the terminal.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Enter the root password.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Its always safe and good practise to login as user and then switch to root when &amp;nbsp;required.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Type below command to install Kernel headers and other basic packages required for compiling kernel modules.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;$sudo yum install vim gcc kernel-devel kernel-headers dkms make bzip2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Lets see more about the packages which we are going to install&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;b&gt;Vim &amp;nbsp;&lt;/b&gt;– Popular Linux Editor&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;b&gt;gcc &amp;nbsp;&lt;/b&gt;– C Compiler&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;b&gt;Kernel-devel&lt;/b&gt; – are the files that are required for compiling kernel code that will run as part of the kernel, such as kernel modules.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;b&gt;Kernel-headers&amp;nbsp;&lt;/b&gt;- contains files that describe the system environment and are used for compiling normal programs that run in userspace.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;b&gt;dkms&lt;/b&gt; - Dynamic kernel module support package&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;b&gt;make&lt;/b&gt; - make file tool necessary for Kernel code buildsystem.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;b&gt;bzip2&lt;/b&gt; - zipping tool&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;While installation kernel may ask &quot;Is this ok Y/N&quot;. Type Y and complete the installation.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;At the end, you will observe kernel source installed under /usr/src/kernels/2.6.xx&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Once the installation is done, reboot your Linux Machine. &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Once your virtual box is rebooted, login with user credentials.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;We have completed the setting up environment.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;3. Implementing Helloworld Kernel module and Macros used in it.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Now lets begin with Hello world Module&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Log into your Virtual machines as a user.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Open a terminal window&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Create a directory with name LDD-3 (Its your choice) anywhere preferably in your home directory (like /home/mrtechpathi)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Change directory to it&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;cd LDD3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Create your first helloworld module. So how do you do that ?&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;For this we will use vim editor. Which is very popular and used by many Linux programmers all over the world. Though novice programmers may face issues but will be wonderful editor to work with.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Now lets type hello world program. I will name it as hello.c&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt; #include &amp;lt;linux/init.h&amp;gt;  
 #include &amp;lt;linux/module.h&amp;gt;  
 MODULE_LICENSE(&quot;Dual BSD/GPL&quot;);  
 static int hello_init(void)  
 {  
   printk(KERN_ALERT &quot;Hello, world\n&quot;);  
   return 0;  
 }  
 static void hello_exit(void)  
 {  
   printk(KERN_ALERT &quot;Goodbye, cruel world\n&quot;);  
 }  
 module_init(hello_init);  
 module_exit(hello_exit);  
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Instead of copy pasting this program, I would recommend to type program yourself which makes you understand each and every line of it.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Great you have coded your first Hello world kernel module.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Lets understand more about the helloworld kernel module&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Kernel headers used in Module&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;#include &amp;lt;linux/init.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;This header contains the definition of the functions used in this module.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Module_init() and Module_exit() are defined in this file.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Module_init() is a macro which defines the function to be called at module&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;insertion time or at system boot time.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Module_exit() is a macro which defines the function to be called at module removal time. This function is also called Celan up function.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Kernel modules must always contain these two functions, init_module and cleanup_module.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;If you clearly observe in helloworld kernel module code (above) , we have used a two kernel headers and special kernel macros.&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt; 1.MODULE_LICENsE  
 2.printk  
 3.KERN_ALERT  
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp;Lets see whats significance of these Kernel headers.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1. MODULE_LICENSE&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;This macro is used to tell the kernel that this module bears a free license; without such a declaration, the kernel complains when the module is loaded.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;2. Printk function&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;This function is similar to printf in standard C. This is implemented to make kernel have its own print function instead of having dependency on C library.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;3.KERN_ALERT&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;This string is the &amp;nbsp;priority of message. KERN_ALERT is the highest priority set to specify kernel to print the message immediately.We will discuss more about this macro in up coming sessions.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Coming to the functions used in this Helloworld kernel module,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;There are two main functions.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;hello_init and hello_exit&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Function 1: hello_init()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;This particular function is called when the module is loaded&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Function 2: hello_exit()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;This particular function is called when module is removed.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;We will see more about loading and removing kernel modules in coming session&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Now we have our hello.c module implemented. Its time to compile&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;To compile this Kernel modules, we need to create a Makefile.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;I am in LDD-3 directory where my hello.c is present.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Before creating a makefile for our helloworld module, we need to know the &lt;b&gt;path of kernel build directory&lt;/b&gt;. For this first we need to know the kernel version.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;To know the kernel version used in your PC, type &quot;&lt;i&gt;&lt;b&gt;uname -a&quot;&lt;/b&gt;&lt;/i&gt;command in the terminal.&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt; [root@localhost LDD]# uname -a  
 Linux localhost.localdomain 2.6.32-431.20.5.el6.i686 #1 SMP Fri Jul 25 05:42:52 UTC 2014 i686 i686 i386 GNU/Linux  
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;This command displays the current linux version. &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Make a note of this name &amp;nbsp;for example, 2.6.32-431.20.5.el6.i686.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;With this information, we will try creating a makefile for our helloworld module.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;4. Creating Makefile to compile Helloworld Kernel module&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Open a vim editor and type these couple of lines.&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt; obj-m := hello.o  
 KDIR := /lib/modules/2.6.32-431.20.5.el6.i686/build  
 PWD := $(shell pwd)  
 default:  
     $(MAKE) -C $(KDIR) SUBDIRS=$(PWD)  
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;obj-m:=hello.o&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;This assignment states that there &amp;nbsp;is one module to be built from object file hello.o.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Some may wonder how this single line does whole job.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;The kernel build system in Linux 2.6 Kernel is designed in&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;such &amp;nbsp;a way to handler the rest of the parameters.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;KDIR := /lib/modules/2.6.32-431.20.5.el6.i686/build&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Its Kernel build directory. The director which starts with 2.6.32 here is the one which we noted down before creating this Makefile. We got this by executing &#39;uname -a&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;PWD := $(shell pwd)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Current directory path. It shows the kernel about the current location of our kernel module. Since we are creating makefile in the same directory, we will read current path to PWD variable.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Now the last line&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;default:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $(MAKE) -C $(KDIR) SUBDIRS=$(PWD)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;This is the main make command which switches to your Kernel build directory and invokes the make command to compile helloworld kernel module present in the sub-directory.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;-C option tells make command to switch to kernel build directory. directory.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;5. Compilation and Kernel object generation of Helloworld Kernel module&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Now we have Makefile and hello.c file in our LDD-3 directory.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Lets execute the program. Executing program is very simple now.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Just type ‘make’ command in the directory where your Kernel module and Makefile are present.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;make will compile the helloworld program and generates the kernel object of helloworld module.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;We can find kernel object hello.ko in the same directory.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;In next session we will see how to load and remove this kernel module.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Hey dont forget to watch Linux Device Part -5 in youtube. I am sure you will like it and give a thumbs-up.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/RwRje_Vy2u4&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://mrtechpathi-tutorials.blogspot.com/feeds/1636820865471845116/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2014/08/linux-device-drivers-part-5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/1636820865471845116'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/1636820865471845116'/><link rel='alternate' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2014/08/linux-device-drivers-part-5.html' title='Linux Device Drivers Part - 5 : Building and Compiling Kernel Moduels'/><author><name>MrTechpathi</name><uri>http://www.blogger.com/profile/17144890590324530224</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf4pWNwntO5vWpLAk6RTAPhCdrIqhMr8_OMZ8N-_9FfWptr1YLNN8lav1OBhPHO3i556oOHZyv75Ns4Gj0L9u02S_VsmeolBfx4myFcqgeza93NTwgBItuU8VycxPX8NanFCsr5ov0YAw/s72-c/mrtechpathi_Title_Page_Linux_Device_Drivers_5.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2567861330953913013.post-4783749093490706227</id><published>2013-06-23T06:45:00.000-07:00</published><updated>2015-06-06T07:06:33.155-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Base Kernel"/><category scheme="http://www.blogger.com/atom/ns#" term="Device Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Dynamic Modules"/><category scheme="http://www.blogger.com/atom/ns#" term="LDD"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Drivers Part - 4"/><category scheme="http://www.blogger.com/atom/ns#" term="Part 4 of Linux Device Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Static Modules"/><category scheme="http://www.blogger.com/atom/ns#" term="User space and Kernel space"/><title type='text'>Linux Device Drivers - Part 4 : Linux Kernel Moduels (LKM)  and types of LKM&#39;s</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In this sesssion, we will discuss about&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Linux Kernel Modules&lt;/li&gt;
&lt;li&gt;Base Kernel,&lt;/li&gt;
&lt;li&gt;User Space and Kernel Space&lt;/li&gt;
&lt;li&gt;Types of Linux Kernel Modules,&lt;/li&gt;
&lt;li&gt;Which module type to choose while Kernel Programming ?&lt;/li&gt;
&lt;li&gt;Location of Linux Kernel Modules in a linux PC.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLpRCycSZ1jux1PRWGWox4Q_oBfewS1oS2D9Lseb_GHr0BvK_zC8lJZ-kU2mBxUkwXHGiB2GdP5Mp_evc7FlAjqRIuUD0ZHvBXVycpBhjBkfqnPMVi666X9dIxK7uB_9AMhKs67s_cCEg/s1600/mrtechpathi_linux_device_drivers_part4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;mrtechpathi_tutorials_linux_device_drivers_4&quot; border=&quot;0&quot; height=&quot;475&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLpRCycSZ1jux1PRWGWox4Q_oBfewS1oS2D9Lseb_GHr0BvK_zC8lJZ-kU2mBxUkwXHGiB2GdP5Mp_evc7FlAjqRIuUD0ZHvBXVycpBhjBkfqnPMVi666X9dIxK7uB_9AMhKs67s_cCEg/s640/mrtechpathi_linux_device_drivers_part4.jpg&quot; title=&quot;mrtechpathi_tutorials_linux_device_drivers_4&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;What exactly is a module in Linux ?&lt;/b&gt;&lt;br /&gt;
Its a piece of code that can be added to the Base Kernel. We will be discussing about Base kernel in coming slides.&lt;br /&gt;
&lt;br /&gt;
If you are planning to add some code to kernel, then it means you are adding a module to Linux Kernel.We can&#39;t just add code to Linux without any purpose. &amp;nbsp;We add code to make a device (like printer,bluetooth dongle etc) to work.We call this piece of code as device drivers in Windows.&lt;br /&gt;
&lt;br /&gt;
Assuming many are familiar with Windows, we can draw one conclusion.As we have device drivers in Windows Operating system, we have modules in Linux Operating system.In short, Devices Drivers are called modules in Linux Operating system. Both terms can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
Before knowing about Module types, we need to know about Base Kenel, User Space and Kernel Space.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;What is a Base Kernel:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Kernel code which is compiled and loaded along with basic device drivers as a single entity is called Base Kernel.Note that all parts of base kernel will be loaded all the time.Once you have a working base kernel,it is good to leave it untouched as long as possible.&lt;br /&gt;
&lt;br /&gt;
Next we will discuss about User space and Kernel space in Linux.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm-K4Gu_RVro_mwYpO45DvD7x08GTWvjHtqfqExQx1eGbQYnSWxFE87O8-9xD0LD-egNvKPRH8PSV96gUep8ZauidtruTdiEYBE7dGYhMpE1vxWSX2USdH2XLr_aGr01PmQbt0ueOhoXA/s1600/linux_device_drivers_4_userspace_and_kernelspace.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;mrtechpathi_tutorials_linux_device_drivers_4&quot; border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm-K4Gu_RVro_mwYpO45DvD7x08GTWvjHtqfqExQx1eGbQYnSWxFE87O8-9xD0LD-egNvKPRH8PSV96gUep8ZauidtruTdiEYBE7dGYhMpE1vxWSX2USdH2XLr_aGr01PmQbt0ueOhoXA/s320/linux_device_drivers_4_userspace_and_kernelspace.jpg&quot; title=&quot;mrtechpathi_tutorials_linux_device_drivers_4&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
From this diagaram, Base Kernel along with Kernel modules (KM1 and KM10) fall under Kernel space. User applications fall under user space.&lt;br /&gt;
&lt;br /&gt;
What are User Space and Kernel Space ?&lt;br /&gt;
&lt;br /&gt;
Simplified answer is that the kernel runs in kernel space, and normal programs run in user space.&lt;br /&gt;
&lt;br /&gt;
Normal programs in user space can&#39;t mess with memory (and other resources) owned by other programs or by the Linux kernel. This limits their ability to do corrupt things like crashing the machine.&lt;br /&gt;
&lt;br /&gt;
The kernel is the core of the operating system. It normally has full access to all memory and machine hardware (and everything else on the machine. To keep the machine as stable as possible, you normally want only the most trusted, well-tested code to run in kernel mode/kernel space.&lt;br /&gt;
&lt;br /&gt;
Modules in Linux are of two types.&lt;br /&gt;
&lt;br /&gt;
1. Static Modules&lt;br /&gt;
2. Dynamic Modules&lt;br /&gt;
&lt;br /&gt;
What is a static module ?&lt;br /&gt;
&lt;br /&gt;
Static modules are those which are compiled as a part of the base kernel and is available at anytime.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsrt4PuMJjp2_ljBdfhGTycXMKNKGhv26svj59JbPGp1x2B0p2aSpen9qULpk59vAbZdrTpPjzoDUPRmmRzi2ly-zYJiome5yedrna3MV6XcevMWjnwGpYEqkLr6xAUQJEbi4PdpCALBg/s1600/static_modules.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;mrtechpathi_tutorials_linux_device_drivers_4&quot; border=&quot;0&quot; height=&quot;168&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsrt4PuMJjp2_ljBdfhGTycXMKNKGhv26svj59JbPGp1x2B0p2aSpen9qULpk59vAbZdrTpPjzoDUPRmmRzi2ly-zYJiome5yedrna3MV6XcevMWjnwGpYEqkLr6xAUQJEbi4PdpCALBg/s320/static_modules.jpg&quot; title=&quot;mrtechpathi_tutorials_linux_device_drivers_4&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
From this diagram you can see the static modules are part of Kernel image. They are compiled and loaded as a part of base kernel image.&lt;br /&gt;
&lt;br /&gt;
What is dynamic module ?&lt;br /&gt;
&lt;br /&gt;
Dynamic modules are compiled as modules separately and loaded as and when required.&lt;br /&gt;
&lt;br /&gt;
These are also called Loadable Kernel Modules. In short we call them as LKM from now on.&lt;br /&gt;
&lt;br /&gt;
Every Kernel Programmer should clearly understand about dynamic modules and how they work.&lt;br /&gt;
&lt;br /&gt;
From this diagram, we see the dynamic modules are compiled separtely. They are not part of basic kernel image.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzNW2tuRb4q78jyFlRmVDauJqv8YsdFGu0fCHxVYEwsPCGOGUxgLElqipEUrt-EvamB73_ThloHqI7_0ynGCgAg6wXb8VSPj6zN2g4fVDbbxsd8kM1T9z6hUE8dlljhToe6hEnu1gj59E/s1600/dynamic_modules.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;mrtechpathi_tutorials_linux_device_drivers_4&quot; border=&quot;0&quot; height=&quot;228&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzNW2tuRb4q78jyFlRmVDauJqv8YsdFGu0fCHxVYEwsPCGOGUxgLElqipEUrt-EvamB73_ThloHqI7_0ynGCgAg6wXb8VSPj6zN2g4fVDbbxsd8kM1T9z6hUE8dlljhToe6hEnu1gj59E/s400/dynamic_modules.jpg&quot; title=&quot;mrtechpathi_tutorials_linux_device_drivers_4&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
To know how exactly dynamic module is loaded, we need to know 4 important steps.&lt;br /&gt;
&lt;br /&gt;
Step 1: From this diagram, assume you have written a dynamic module xyz. You will also write an application which tries to access xyz functionalities.&lt;br /&gt;
&lt;br /&gt;
Step 2: Once Linux is up on running on your PC or device, you will dynamically insmod your xyz module using &quot;insmod&quot; command to RAM. We will discuss about insmod in later sessions.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhE6j_izIXt3RvPV5LBdwWy_ERjloSCkuUCXzxh0yJhvZGPQIyIYBZos_z8ggA0MWbmnUnIUNT6lHEc7wgfh1juz6nBNqAvYERSG11MqlRYLbNlpXzKYGikl-Q0rDT3_2-iRgIpe7WfGQg/s1600/dynamic_modules_step1_and_step2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;363&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhE6j_izIXt3RvPV5LBdwWy_ERjloSCkuUCXzxh0yJhvZGPQIyIYBZos_z8ggA0MWbmnUnIUNT6lHEc7wgfh1juz6nBNqAvYERSG11MqlRYLbNlpXzKYGikl-Q0rDT3_2-iRgIpe7WfGQg/s640/dynamic_modules_step1_and_step2.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Step 3: You application in userspace xyz will try to access functionalities of your hardware through xyz module by calling Linux provided system calls. Normally they are called ioctl calls. We will discuss about ioctl calls later.&lt;br /&gt;
&lt;br /&gt;
Step 4: Once the required hardware functionality is retrieved by the user application, when xyz module is no more needed, we can request kernel to remove xyz module using rmmod command.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEOdIh7t17MkutKlnLqXSnKLKvV55HD6a8uyh2npQ5MiqFa3QuhLbs_xr7TwTILWU8rS0pb3z79AFpFqQ5WUvXz72VsC08vCGPaIf7zU1Kv8p9gaNm-MBfKeZH6N2In29vuy5wZm4ZIbQ/s1600/dynamic_modules_step3_and_step4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;mrtechpathi_tutorials_linux_device_drivers_4&quot; border=&quot;0&quot; height=&quot;324&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEOdIh7t17MkutKlnLqXSnKLKvV55HD6a8uyh2npQ5MiqFa3QuhLbs_xr7TwTILWU8rS0pb3z79AFpFqQ5WUvXz72VsC08vCGPaIf7zU1Kv8p9gaNm-MBfKeZH6N2In29vuy5wZm4ZIbQ/s640/dynamic_modules_step3_and_step4.jpg&quot; title=&quot;mrtechpathi_tutorials_linux_device_drivers_4&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
These are 4 simple steps how a dynamic module is loaded, functionality of hardware is retrieved and dynamic module is removed.&lt;br /&gt;
&lt;br /&gt;
Once after discussing about static and dynamic modules, we have a common question, which one to use ? which is the best ?&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
Yes ,always a device driver programmer has a choice between building his module as static module or dynamic module. &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
To decide on this, we need to first know few things.&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Disadvantages of building your module as static.&lt;/li&gt;
&lt;li&gt;Advantages of building your module as dynamic (as LKM).&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;Disadvantages of building your module as static:&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;
Lets say you have written a static module &quot;xyz&quot; for a device driver.&lt;br /&gt;
When you compile this as static module along with kernel, you will be adding extra size to the kernel image permanently. This the first major disadvantage. As the kernel size grows, the time taken to load the kernel and size occupied by the kernel image in the memory.increases.&lt;br /&gt;
&lt;br /&gt;
Whenever you modify your &quot;xyz&quot; device driver, you need to recompile your entire kernel to build it.&lt;br /&gt;
Also machine need to be rebooted for the changes to take effect.&lt;br /&gt;
&lt;br /&gt;
One more important drawback is While you device driver is not stable, when you build it as static module, you will face issues which takes more time to debug.&lt;br /&gt;
&lt;br /&gt;
Take scenario when there is a memory overflow bug in your &quot;xyz&quot; static module. Once it is statically compiled and the kernel is loaded, at some point of time, the kernel may crash.&lt;br /&gt;
&lt;br /&gt;
In order to debug it people may take hours or days to fix it. Also your kernel which includes this &quot;xyz&quot; as part of it will be useless till you fix the crash issue.&lt;br /&gt;
&lt;br /&gt;
This doesn&#39;t happen when you build you &quot;xyz&quot; as dynamic module. We will see how in a short while.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Advantages of building your module as dynamic (as LKM):&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Lets say you built your xyz module as dynamic (LKM) now.&lt;br /&gt;
&lt;br /&gt;
With this you don&#39;t have to rebuild your kernel as often. It can be compiled separately.&lt;br /&gt;
&lt;br /&gt;
It saves you time and spares you the possiblity of introducing an error in rebuilding and reinstalling the base kernel.&lt;br /&gt;
&lt;br /&gt;
It can be loaded onto kernel at run time without having the machine to reboot.&lt;br /&gt;
&lt;br /&gt;
It saves you memory beacause you load them when you are actually using them.&lt;br /&gt;
&lt;br /&gt;
It can be unloaded anytime and hence no permanent affect on kernel size.&lt;br /&gt;
&lt;br /&gt;
Since these are compiled and built serpately from kernel, they are much faster to maintain and debug.&lt;br /&gt;
&lt;br /&gt;
Each dynamic module is made up of object code that can be dynamically linked to the running kernel by the insmod program and can be unlinked by the rmmod program.&lt;br /&gt;
&lt;br /&gt;
Many have a misconception that dynamci modules are bit slower than Static modules. I totally disagree with them because, loading either one is simply a brach to the memory location where it resides.&lt;br /&gt;
&lt;br /&gt;
With information known till now, lets see the example which we discussed earlier about a overflow bug in your module. Assume this bug is present in your &quot;xyz&quot; module which is built as dyanmic module.&lt;br /&gt;
&lt;br /&gt;
Once you boot-up your Linux on your Embedded device or PC, load your LKM&#39;s along with your “xyz” dynamic module, after a while when your system crashes because of overflow bug, to know if your &quot;xyz&quot; module is causing the issue, you can discard loading your &quot;xyz&quot; module after next boot up and just load the base kernel along with other dynamic modules and see if the system crash.&lt;br /&gt;
&lt;br /&gt;
If it doesnt, then it clearly shows that your &quot;xyz&quot; module is the culprit and you can debug and fix the bug without any much headache.&lt;br /&gt;
&lt;br /&gt;
Remember, you can even use your base kernel and other LKM&#39;s till you fix this overflow bug in your &quot;xyz&quot; dynamic module.&lt;br /&gt;
&lt;br /&gt;
Hope everyone are clear with this explanation. If youare not clear, please drop a comment.&lt;br /&gt;
&lt;br /&gt;
ok,Now if we repeate our earlier question as a kernel programmer, which one do you prefer static module or dynamic module ?&lt;br /&gt;
&lt;br /&gt;
As a good kernel programmer, one should prefer building their module as dynamic module.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;So when to use Static modules ?&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
There are times where one have to build something into the base kernel instead of making it a dynamic module.&lt;br /&gt;
&lt;br /&gt;
Anything that is necessary to get the system up far enough to load dynamic modules must obviously be built into the base kernel.&lt;br /&gt;
&lt;br /&gt;
For example, the driver for the disk drive that contains the root filesystem must be built into the base kernel&lt;br /&gt;
&lt;br /&gt;
Final topic of this session,&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Location of linux kernel modules in linux device or PC:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Usually, all Linux kernel modules (drivers) are stored in the module directory located that /lib/modules/$(uname -r) directory.&lt;br /&gt;
&lt;br /&gt;
To see current modules, type:&lt;br /&gt;
$ ls /lib/modules/$(uname -r)&lt;br /&gt;
&lt;br /&gt;
Use the following command to list all drivers for various devices:&lt;br /&gt;
$ ls /lib/modules/$(uname -r)/kernel/drivers/&lt;br /&gt;
&lt;br /&gt;
Thats all for this session. If you have any doubts, dont hesitate to drop a comment or a mail.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
For more explanation, please watch this video.&lt;/div&gt;
&lt;div&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;480&quot; src=&quot;http://www.youtube.com/embed/kpKZPBUepxo&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://mrtechpathi-tutorials.blogspot.com/feeds/4783749093490706227/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2013/06/linux-device-drivers-part-4.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/4783749093490706227'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/4783749093490706227'/><link rel='alternate' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2013/06/linux-device-drivers-part-4.html' title='Linux Device Drivers - Part 4 : Linux Kernel Moduels (LKM)  and types of LKM&#39;s'/><author><name>MrTechpathi</name><uri>http://www.blogger.com/profile/17144890590324530224</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLpRCycSZ1jux1PRWGWox4Q_oBfewS1oS2D9Lseb_GHr0BvK_zC8lJZ-kU2mBxUkwXHGiB2GdP5Mp_evc7FlAjqRIuUD0ZHvBXVycpBhjBkfqnPMVi666X9dIxK7uB_9AMhKs67s_cCEg/s72-c/mrtechpathi_linux_device_drivers_part4.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2567861330953913013.post-4420537338435172705</id><published>2013-06-09T11:38:00.000-07:00</published><updated>2013-06-09T11:38:09.827-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Installing Linux on Windows 7"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux on Windows"/><category scheme="http://www.blogger.com/atom/ns#" term="Oracle virtual Box"/><category scheme="http://www.blogger.com/atom/ns#" term="Oracle Virtual Machine"/><category scheme="http://www.blogger.com/atom/ns#" term="Virtual Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Virtual Machine"/><title type='text'>Installing Linux on Windows 7 PC using Oracle VM Virtual Box</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In previous session, we learnt about a Windows 7 application &quot;&lt;a href=&quot;http://mrtechpathi-tutorials.blogspot.co.uk/2013/05/installing-oracle-virtualbox.html&quot;&gt;Oracle VM VirtualBox&lt;/a&gt;&quot;. Please view previous session before proceeding further.&lt;br /&gt;
&lt;br /&gt;
Right, once you are done installing with &quot;Oracle VM VirtualBox&quot;, you need to first choose the flavour of Linux you are going to install using VirtualBox.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6MCvcVHDXmVPw5Uh4FUC8cTnYm_C_e73a5oulLhqwEqomkMxF3dUXD7eNiVCQ79EvgYqgOYIi4gZj9PRzZHFSAnUdsVvO2_M7RPaDUJKCC2P8aO9QD3-HsiJnl54-c0XjCxgfHECnL3s/s1600/installing_virtual_linux_in_windows_7_PC.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6MCvcVHDXmVPw5Uh4FUC8cTnYm_C_e73a5oulLhqwEqomkMxF3dUXD7eNiVCQ79EvgYqgOYIi4gZj9PRzZHFSAnUdsVvO2_M7RPaDUJKCC2P8aO9QD3-HsiJnl54-c0XjCxgfHECnL3s/s400/installing_virtual_linux_in_windows_7_PC.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
I will go ahead and download Centos OS Linux Flavour.&lt;br /&gt;
&lt;br /&gt;
To download this iso image, open a separate tab and type this address in address bar.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvTueShU6Chp6CmCCqJP_TXQrn483Yjy6T0JAYk3AaLNmkkBAkHH9AcTZqCXx6pKNrl9jTT37vCDbe0gV5pAnJh_dDuyMJFForKg-fOIy9aN5lPGcWZabWu02IrKlQJdqXMViBlWHIJ-0j/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; http://centos.linuxfreedom.com/download.html  &lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
In this website, scroll down and download the first one. Since its 690Meg, it takes time to download. So, wait till the download gets completed.&lt;br /&gt;
&lt;br /&gt;
Since, I have already downloaded this image to a particular location, I will go ahead with our tutorial.&lt;br /&gt;
&lt;br /&gt;
Start VirtualBox application in windows.Best way is to click here on startup menu and search for virtualbox. Click on it to open.&lt;br /&gt;
&lt;br /&gt;
This is very simple interface and easy to install Linux using this application.&lt;br /&gt;
&lt;br /&gt;
Using this application you can create n number of virtual machines depending on your requirement. For today&#39;s tutorial, we will create Centos Linux Virtual machine.77&lt;br /&gt;
&lt;br /&gt;
So lets see how to do it.&lt;br /&gt;
&lt;br /&gt;
First select New.&lt;br /&gt;
&lt;br /&gt;
Type Name as you wish. I am going to type &quot;MrTechpathi_Centos&quot;&lt;br /&gt;
&lt;br /&gt;
Based on your name, the type and verison will get updated automatically. If not, select the type as &quot;Linux&quot; and version as &quot;Red Hat&quot;.&lt;br /&gt;
&lt;br /&gt;
Click on &quot;Next&quot;.&lt;br /&gt;
&lt;br /&gt;
Now, we need to select the memory size.You should be very careful in choosing the amount of memory here because its allocated to virtual Machine from your existing Ram memory.&lt;br /&gt;
&lt;br /&gt;
I am having 3Gig of RAM so, I will go ahead with 1.4GB. VirtualBox actually shows green and pink color in order to show the best and worst case scenarios. So, choose wisely.&lt;br /&gt;
&lt;br /&gt;
Click on &quot;Next&quot;&lt;br /&gt;
&lt;br /&gt;
Here, you need to create a hard driver for your virtual machine. So, you need to&lt;br /&gt;
&lt;br /&gt;
Select option &quot;Create a virtual hard drive now&quot;0. Click on &quot;Create&quot;&lt;br /&gt;
&lt;br /&gt;
Now, select default options from here on. Select VDI (VirtualBox Disk Image) as type of your hard drive and click on &quot;Next&quot;.&lt;br /&gt;
&lt;br /&gt;
Select &quot;Dynamically allocated&quot; option and click on &quot;next&quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the location of virtual harddrive and also size of the harddrive. I will leave the default location unchanged and change the Harddisk size from 8Gig to 32Gig. Choosing Harddisk size again depends on the size of free space available in your Windows 7 harddrive.&lt;br /&gt;
&lt;br /&gt;
Click on &quot;create&quot;.&lt;br /&gt;
&lt;br /&gt;
Now we are ready with a virutal machine skeleton.&lt;br /&gt;
&lt;br /&gt;
We need to add iso image to it. Lets do it now.&lt;br /&gt;
&lt;br /&gt;
When you click on &quot;storage&quot;, you can see two entries. One IDE and SATA.&lt;br /&gt;
&lt;br /&gt;
Under IDE, you will find Empty entry.Select Empty and &amp;nbsp;On the right hand side, under attributes, choose a virtual CD or disk file option.&lt;br /&gt;
&lt;br /&gt;
Here you need to select your centos iso image downloaded during initial stages of this tutorial.&lt;br /&gt;
&lt;br /&gt;
Once selected, click on ok.&lt;br /&gt;
&lt;br /&gt;
So, till now, we have created Harddrive for virutal machine and added centos iso image as controller IDE.&lt;br /&gt;
&lt;br /&gt;
Now its time to start the centos virtual machine and install iso image to virtually created harddisk.&lt;br /&gt;
&lt;br /&gt;
Select your virtual machine and click &quot;start&quot;.&lt;br /&gt;
&lt;br /&gt;
Please read this message on all pop up messages from here on and press ok.&lt;br /&gt;
&lt;br /&gt;
I would like to mention one important thing here. In order to switch between your virtual machine and Windows 7 PC, you need to press &quot;RightCtrl&quot; button on your keyboard. To make it easier to remember, VirtualBox displays &quot;RightCtrl&quot; at the bottom of virtual machine.&lt;br /&gt;
&lt;br /&gt;
Wait till Linux boots up.&lt;br /&gt;
&lt;br /&gt;
Click on &quot;Login&quot;.&lt;br /&gt;
&lt;br /&gt;
Now you have standalone virual centos Linux operating system running on your Windows 7 PC.&lt;br /&gt;
&lt;br /&gt;
To install Centos to your virtual harddrive, select &quot;Install to HardDrive&quot; option on the desktop.&lt;br /&gt;
&lt;br /&gt;
This will start CentOS installer.&lt;br /&gt;
&lt;br /&gt;
From here on its normal installation procedure.&lt;br /&gt;
&lt;br /&gt;
Click on &quot;Next&quot;&lt;br /&gt;
&lt;br /&gt;
Select your preferred country. I will select mine as &quot;United Kingdom&quot;.&lt;br /&gt;
&lt;br /&gt;
Select &quot;Basic Storage Devices&quot; and click &quot;Next&quot;.&lt;br /&gt;
&lt;br /&gt;
Since we have allocated 32Gig from Windows 7 free space for our virtual harddrive, select &quot;Yes,discard any data&quot;.&lt;br /&gt;
&lt;br /&gt;
Name your computer. I will name mine as mrtechpathi and click next.&lt;br /&gt;
&lt;br /&gt;
Select the timezone accordingly.&lt;br /&gt;
&lt;br /&gt;
Mine I have selected as London. Click on &quot;Next&quot;&lt;br /&gt;
&lt;br /&gt;
Enter root password and confirm. Click on &quot;Next&quot;.&lt;br /&gt;
&lt;br /&gt;
To use 32Gig virutal harddisk, select &quot;Use all space&quot; and click &quot;Next&quot;.&lt;br /&gt;
&lt;br /&gt;
Select &quot;write changes to disk&quot; option to write storage configuration to disk.&lt;br /&gt;
&lt;br /&gt;
Now relax and wait for few minutes for the installation to complete.&lt;br /&gt;
&lt;br /&gt;
So, after few minutes, the installation is done.&lt;br /&gt;
&lt;br /&gt;
Click on Close and proceed.&lt;br /&gt;
&lt;br /&gt;
Now poweroff the virtual machine and restart by pressing Start.&lt;br /&gt;
&lt;br /&gt;
Wait till the Linux Boots-up. Once after the bootup you need to do initial setup. For more details please watch this video.&lt;br /&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/R3Eaz3ztspI&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://mrtechpathi-tutorials.blogspot.com/feeds/4420537338435172705/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2013/06/installing-linux-on-windows-7-pc-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/4420537338435172705'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/4420537338435172705'/><link rel='alternate' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2013/06/installing-linux-on-windows-7-pc-using.html' title='Installing Linux on Windows 7 PC using Oracle VM Virtual Box'/><author><name>MrTechpathi</name><uri>http://www.blogger.com/profile/17144890590324530224</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6MCvcVHDXmVPw5Uh4FUC8cTnYm_C_e73a5oulLhqwEqomkMxF3dUXD7eNiVCQ79EvgYqgOYIi4gZj9PRzZHFSAnUdsVvO2_M7RPaDUJKCC2P8aO9QD3-HsiJnl54-c0XjCxgfHECnL3s/s72-c/installing_virtual_linux_in_windows_7_PC.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2567861330953913013.post-4542122852626793076</id><published>2013-06-07T08:09:00.002-07:00</published><updated>2013-06-07T13:46:26.628-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BIOS"/><category scheme="http://www.blogger.com/atom/ns#" term="First Stage Boot Loader"/><category scheme="http://www.blogger.com/atom/ns#" term="How Linux Boots"/><category scheme="http://www.blogger.com/atom/ns#" term="Kernel"/><category scheme="http://www.blogger.com/atom/ns#" term="Kernel Loader"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Boot Procedure"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Boot Process"/><category scheme="http://www.blogger.com/atom/ns#" term="MBR"/><category scheme="http://www.blogger.com/atom/ns#" term="Second Stage Boot loader"/><title type='text'>How Linux Boots ? Linux Boot-up procedure made easy.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
If you are new to Linux and interested in Linux Boot process, you have reached the correct web-page.This article is for you.&lt;br /&gt;
&lt;br /&gt;
Linux is a Open Source Operating System&amp;nbsp; developed by many programmers around the clock. Its a dynamically evolving Operating system used in various devices like Mobiles, Personal computers, Laptops, tablets etc. &lt;br /&gt;
&lt;br /&gt;
If you are using a Linux PC (or a device)&amp;nbsp; in your daily life, it’s important to know how it boots and what steps are involved in its boot up process. &lt;br /&gt;
&lt;br /&gt;
The moment you switch on a Linux device, you may notice various screen displayed during the initial stage of Linux Boot-up. Finally you will end up with a log-in prompt.&lt;br /&gt;
&lt;br /&gt;
Are you curious to know what exactly happens between the power-up and the display of Login prompt ?&amp;nbsp; If you are, then lets see how Linux boots.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Linux Boot-up process involves mainly 4 steps:&lt;/b&gt;&lt;br /&gt;
1.&amp;nbsp;&amp;nbsp;&amp;nbsp; BIOS&lt;br /&gt;
2.&amp;nbsp;&amp;nbsp;&amp;nbsp; MBR (First Stage Bootloader)&lt;br /&gt;
3.&amp;nbsp;&amp;nbsp;&amp;nbsp; Kernel Loader (Second Stage Boot loader)&lt;br /&gt;
4.&amp;nbsp;&amp;nbsp;&amp;nbsp; Kernel&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;1. BIOS (Basic Input/Output System) :&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Resides at the end of flash memory. This is a well- known location to a processor when the system is reset.&lt;/li&gt;
&lt;li&gt;BIOS program is written into permanent read-only memory and is always available to use. &lt;/li&gt;
&lt;li&gt;It provides the lowest level interface to peripheral devices and controls the first step of the boot process.&lt;/li&gt;
&lt;li&gt;It performs a &lt;b&gt;P&lt;/b&gt;ower &lt;b&gt;O&lt;/b&gt;n &lt;b&gt;S&lt;/b&gt;elf-&lt;b&gt;T&lt;/b&gt;est (POST) for all the hardware components in the system to make sure that all hardware’s are functional.&lt;/li&gt;
&lt;li&gt;It checks if the computer is being started from a cool boot (off position) or from a warm boot (restarted).&lt;/li&gt;
&lt;li&gt;It retrieves the information from CMOS (&lt;b&gt;C&lt;/b&gt;omplementary &lt;b&gt;M&lt;/b&gt;etal &lt;b&gt;O&lt;/b&gt;xide &lt;b&gt;S&lt;/b&gt;emiconductor) a batter operated memory chip on the motherboard that sotres time, data, and critical information of the computer.&lt;/li&gt;
&lt;li&gt;Once&amp;nbsp; above steps are successful, based on the order of the bootable media selected in the BIOS, it boots up the Linux.&lt;/li&gt;
&lt;li&gt;If Linux is installed in Hard-drive, it looks at the first sector of the Hard-disk for (MBR)&amp;nbsp; &lt;b&gt;M&lt;/b&gt;aster &lt;b&gt;B&lt;/b&gt;oot &lt;b&gt;R&lt;/b&gt;ecord. It loads MBR to memory and passes control to it.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;u&gt;&lt;b&gt;2. MBR (First stage Boot Loader):&lt;/b&gt;&lt;/u&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRr9uQBf2P4RHTfZSboaW5Our4qxkBbnjzZzVIXIsn4z-WLYam_B-EE6PR0swd9jO3cRINUf7VErjXGCFbLz5676eBwPRv8rBBg3dipQVr3fLZrHCF194DQSm4X1SHVldgnKTg_AoZ4qo/s1600/Master_boot_record.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;262&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRr9uQBf2P4RHTfZSboaW5Our4qxkBbnjzZzVIXIsn4z-WLYam_B-EE6PR0swd9jO3cRINUf7VErjXGCFbLz5676eBwPRv8rBBg3dipQVr3fLZrHCF194DQSm4X1SHVldgnKTg_AoZ4qo/s320/Master_boot_record.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;MBR is the first stage boot loader which is loaded into the RAM and executed. This boot loader is less than 512 bytes in length (a single sector) .&lt;/li&gt;
&lt;li&gt;First 416 bytes is the Boot loader, the next 64 bytes is the partition table and 2 bytes of magic number.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Job of boot loader is to load the second stage boot loader.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;It does this by looking through the partition table for an active partition. When active partition is found, it scans the remaining partition in the partition table and make sure that they are all inactive. When this is verified, the active partition is loaded into the RAM and executed.&lt;/li&gt;
&lt;li&gt;From there on, second stage boot loader passes control to the kernel image and the kernel is decompressed and initialized. &lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;u&gt;&lt;b&gt;3. Kernel Loader (Second stage Boot loader):&lt;/b&gt;&lt;/u&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Once control reaches kernel loaders , its task is to load the Linux Kernel and optional initial RAM disk (initrd kernel).&lt;/li&gt;
&lt;li&gt;This also checks the system hardware, enumerates the attached hardware devices, mounts the root device, and then loads the necessary kernel modules.&lt;/li&gt;
&lt;li&gt;On success, it starts the first user-space program (init) and performs high level system initialization.&lt;/li&gt;
&lt;li&gt;The first and second stage boot loader combined together are called LILO (Linux Loader) or GRUB (Grand Unified Boot loader) in X86 PC environment.&lt;/li&gt;
&lt;li&gt;GRUB is superior to LILO. So, let’s know about GRUB.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;b&gt;GRUB:&lt;/b&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;GRUB includes knowledge of Linux File systems.&lt;/li&gt;
&lt;li&gt;It can load a Linux Kernel from an ext2 or ext3 system.&lt;/li&gt;
&lt;li&gt;Its loads Linux Kernel in three stage boot loader instead of above discussed two stage boot loaders.&lt;/li&gt;
&lt;li&gt;Stage 1: Boots a stage 1.5 boot loader that understands the particular file system containing the Linux Kernel Image.&lt;/li&gt;
&lt;li&gt;Once Stage 1.5 boot loader is up and running, stage 2 boot loader can be loaded.&lt;/li&gt;
&lt;li&gt;With Stage 2 boot loader loaded, GRUB displays list of available kernels (as in /etc/grub.conf). It allows you to select a kernel and even amend it with additional kernel parameters.&lt;/li&gt;
&lt;li&gt;Till here, with second stage boot loader in memory, the file system is verified, and default kernel image and initrd image are loaded into memory. With the image ready, the stage 2 boot loader invokes the kernel image.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4. Kernel:&lt;/b&gt;&lt;/u&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Once kernel is loaded into the memory, it finds init in sbin and executes it.&lt;/li&gt;
&lt;li&gt;Init is the parent or grandparent of&amp;nbsp; all the processes that start up automatically in Linux system.&lt;/li&gt;
&lt;li&gt;Init reads the initialization file “/etc/inittab”. This instructs init to read an initial configuration script for the environment, which sets the path, starts swapping, checks the file systems , sets the clock , initializes serial ports etc.&lt;/li&gt;
&lt;li&gt;Init continues to read /etc/inittab file, which describes how the system should be set up in each run level and sets the default run level.&lt;/li&gt;
&lt;li&gt;Available run levels are generally described in /etc/inittab, which is partially shown below:&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvTueShU6Chp6CmCCqJP_TXQrn483Yjy6T0JAYk3AaLNmkkBAkHH9AcTZqCXx6pKNrl9jTT37vCDbe0gV5pAnJh_dDuyMJFForKg-fOIy9aN5lPGcWZabWu02IrKlQJdqXMViBlWHIJ-0j/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; #  
 # inittab  This file describes how the INIT process should set up  
 #      the system in a certain run-level.  
 # Default run level. The run levels are:  
 #  0 - halt (Do NOT set initdefault to this)  
 #  1 - Single user mode  
 #  2 - Multiuser, without NFS  
 #  (The same as 3, if you do not have networking)  
 #  3 - Full multiuser mode  
 #  4 - unused  
 #  5 - X11  
 #  6 - reboot (Do NOT set initdefault to this)  
 #   
&lt;/code&gt;&lt;/pre&gt;
Runlevel selection can be done in /etc/inittab file.&lt;br /&gt;
&lt;br /&gt;
Now based on run level selection, the Linux Kernel boots up and finishes the boot process and displays the login prompt for the user to input. &lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Note :&lt;/b&gt;&lt;/u&gt; System boot up process depends on the hardware that Linux is being booted on.&lt;br /&gt;
Please note that in this article we discussed about the boot process of Linux on X86 platforms. &lt;br /&gt;
This process may change for other platforms.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://mrtechpathi-tutorials.blogspot.com/feeds/4542122852626793076/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2013/06/how-linux-boots-linux-boot-up-procedure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/4542122852626793076'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/4542122852626793076'/><link rel='alternate' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2013/06/how-linux-boots-linux-boot-up-procedure.html' title='How Linux Boots ? Linux Boot-up procedure made easy.'/><author><name>MrTechpathi</name><uri>http://www.blogger.com/profile/17144890590324530224</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRr9uQBf2P4RHTfZSboaW5Our4qxkBbnjzZzVIXIsn4z-WLYam_B-EE6PR0swd9jO3cRINUf7VErjXGCFbLz5676eBwPRv8rBBg3dipQVr3fLZrHCF194DQSm4X1SHVldgnKTg_AoZ4qo/s72-c/Master_boot_record.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2567861330953913013.post-3302010123708745732</id><published>2013-05-31T15:47:00.000-07:00</published><updated>2013-06-07T13:36:15.537-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux on Windows"/><category scheme="http://www.blogger.com/atom/ns#" term="Oracle virtual Box"/><category scheme="http://www.blogger.com/atom/ns#" term="Oracle Virtual Machine"/><category scheme="http://www.blogger.com/atom/ns#" term="Virtual Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows"/><title type='text'>Installing Oracle VirtualBox Applicaiton on Windows 7</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Before starting this tutorial, please take backup of your valuable data. MrTechpathi-Tutorials takes no repsonsibility for any damage or loss of your valuable data.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeGr-5RDuG6bArMThHzmVdBoyGiRPUjkhHS6O5F58hMHk8mO2gLB48_l2ZMLY-6EcXLeNhBcb4D8bxp4C8-1xxGe0F2foNCH2NHaJAZrFWeqBrBe0IYOZLiZgPvuk9tt7ctp5c0-uUuH0/s1600/Installing_Linux_in_Windows_Using_Oracle_VM_Machine.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;mrtechpathi_tutorials_installing_oracle_virtualbox_applications_on_windows7&quot; border=&quot;0&quot; height=&quot;227&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeGr-5RDuG6bArMThHzmVdBoyGiRPUjkhHS6O5F58hMHk8mO2gLB48_l2ZMLY-6EcXLeNhBcb4D8bxp4C8-1xxGe0F2foNCH2NHaJAZrFWeqBrBe0IYOZLiZgPvuk9tt7ctp5c0-uUuH0/s400/Installing_Linux_in_Windows_Using_Oracle_VM_Machine.jpg&quot; title=&quot;mrtechpathi_tutorials_installing_oracle_virtualbox_applications_on_windows7&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Many wish to install Linux operating system on PC or laptop. First we think about installing as a secondary operating system along with Windows 7.&lt;br /&gt;
&lt;br /&gt;
Later, we feel difficult to switch between Linux and Windows because we need to reboot PC for doing this.&lt;br /&gt;
&lt;br /&gt;
How to overcome this issue ? Cant we install Linux in Windows 7 ?&lt;br /&gt;
&lt;br /&gt;
Yes we can. But we need an application which will allow us to complete this task.&lt;br /&gt;
&lt;br /&gt;
There are many such applications available in market. I have chosen Oracle VM VirtualBox Manager.&lt;br /&gt;
&lt;br /&gt;
What exactly is a VirtualBox ?&lt;br /&gt;
VirtualBox is a general-purpose full virtualizer for x86 hardware, targeted at server, desktop and embedded use.&lt;br /&gt;
&lt;br /&gt;
Lets see how to install ..&lt;br /&gt;
&lt;br /&gt;
First,open your favourite web-brower and copy past this &lt;a href=&quot;https://www.virtualbox.org/wiki/Downloads&quot;&gt;url &lt;/a&gt;in address bar of your web-browser.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvTueShU6Chp6CmCCqJP_TXQrn483Yjy6T0JAYk3AaLNmkkBAkHH9AcTZqCXx6pKNrl9jTT37vCDbe0gV5pAnJh_dDuyMJFForKg-fOIy9aN5lPGcWZabWu02IrKlQJdqXMViBlWHIJ-0j/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; https://www.virtualbox.org/wiki/Downloads   
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
You will find &amp;nbsp;various virtualBox binaries for various platforms. Since we are installing VirtualBox in Windows 7 PC, choose the first one and save it to a particular location in your hard-drive.&lt;br /&gt;
&lt;br /&gt;
Once the binary is downloaded, double click on it.&lt;br /&gt;
&lt;br /&gt;
Select Run to the pass the security warning.&lt;br /&gt;
&lt;br /&gt;
Select Next to pass the welcome screen.&lt;br /&gt;
&lt;br /&gt;
Select the location where the installation should take place. Simply select the defaults and press Next.&lt;br /&gt;
&lt;br /&gt;
Select Yes for passing this warning.&lt;br /&gt;
&lt;br /&gt;
Next select install to proceed ahead with installation.&lt;br /&gt;
&lt;br /&gt;
This may take some time. &lt;br /&gt;
&lt;br /&gt;
Finally, Oracle VM VirtualBox is successfully installed.&lt;br /&gt;
&lt;br /&gt;
Leave default check box selection to start Oracle VM VirtualBox&quot; and select Finish.&lt;br /&gt;
&lt;br /&gt;
So, this is the oracle VM VirutalBox Manager applicaiton using which we will be installing &amp;nbsp;a Linux Virtual Machine in Windows 7.&lt;br /&gt;
&lt;br /&gt;
For more details, please check this video:&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/LNAMWYRQQWM&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://mrtechpathi-tutorials.blogspot.com/feeds/3302010123708745732/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2013/05/installing-oracle-virtualbox.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/3302010123708745732'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/3302010123708745732'/><link rel='alternate' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2013/05/installing-oracle-virtualbox.html' title='Installing Oracle VirtualBox Applicaiton on Windows 7'/><author><name>MrTechpathi</name><uri>http://www.blogger.com/profile/17144890590324530224</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeGr-5RDuG6bArMThHzmVdBoyGiRPUjkhHS6O5F58hMHk8mO2gLB48_l2ZMLY-6EcXLeNhBcb4D8bxp4C8-1xxGe0F2foNCH2NHaJAZrFWeqBrBe0IYOZLiZgPvuk9tt7ctp5c0-uUuH0/s72-c/Installing_Linux_in_Windows_Using_Oracle_VM_Machine.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2567861330953913013.post-6705723934338475671</id><published>2012-10-24T14:06:00.001-07:00</published><updated>2015-06-06T07:03:53.672-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Control"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Driver Tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Filesystems"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Kernel Role"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Memory Management"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Networking"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Process Management"/><title type='text'>Linux Device Drivers Part - 3 : Role of Linux Kernel</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
As a prerequisite, I strongly recommend you to watch &lt;a href=&quot;https://www.youtube.com/watch?v=U7QFcpVh248&quot;&gt;Part-1&lt;/a&gt; and &lt;a href=&quot;https://www.youtube.com/watch?v=VXIFibjNLhU&quot;&gt;Part-2&lt;/a&gt; of Linux Device Drivers from &lt;a href=&quot;http://mrtechpathi-tutorials.blogspot.co.uk/&quot;&gt;MrTechpathi Tutorials&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ04_tezdpWHZfGSynOJc0m8TA4fMuIoP5E3716kQa_bAHrezSkvdq8UH1spF1fh0-sshsYfgjXIz6i0lU5C2wj_FjnjS1KLqvlQINiYjVMelUU_UkjCE2zAmJyQjLFRgDe6BJQ6fa3M0/s1600/Linux_Device_Drivers_3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;mrtechpathi_tutorials_linux_device_drivers_part_3&quot; border=&quot;0&quot; height=&quot;483&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ04_tezdpWHZfGSynOJc0m8TA4fMuIoP5E3716kQa_bAHrezSkvdq8UH1spF1fh0-sshsYfgjXIz6i0lU5C2wj_FjnjS1KLqvlQINiYjVMelUU_UkjCE2zAmJyQjLFRgDe6BJQ6fa3M0/s640/Linux_Device_Drivers_3.jpg&quot; title=&quot;mrtechpathi_tutorials_linux_device_drivers_part_3&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
In this part we will learn about&amp;nbsp;Role of Linux Kernel.&lt;br /&gt;
&lt;br /&gt;
Why this topic is choosen ?&lt;br /&gt;
&lt;br /&gt;
This topic is choosen to understand the exact role played by Kernel to provide various services. In this part, I will just brief about kernel roles, &amp;nbsp; &amp;nbsp; eventually we will be discussing them in detail in upcoming parts.&lt;br /&gt;
&lt;br /&gt;
In a Linux system, several concurrent processes attend to different tasks. Each process asks for system resources like computing power, memory, &quot;network connectivity&quot;, or some other resource.&lt;br /&gt;
&lt;br /&gt;
Who will be serving these resources ? &amp;nbsp;Yes its the Kernel.&lt;br /&gt;
&lt;br /&gt;
Kernel &amp;nbsp;is the big chunk of executable code in charge of handling all these requests.&lt;br /&gt;
&lt;br /&gt;
Although distinction between the different kernel tasks isn&#39;t always clearly marked, the kernel&#39;s role can be split into the following parts.&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Process management&lt;/li&gt;
&lt;li&gt;Memory management&lt;/li&gt;
&lt;li&gt;File Systems&lt;/li&gt;
&lt;li&gt;Device control&lt;/li&gt;
&lt;li&gt;Networking&lt;/li&gt;
&lt;/ol&gt;
&lt;b&gt;1. Process managament&lt;/b&gt;&lt;br /&gt;
As a part of process management, kernel is in charge of creating and destroying processes and handling input and output operations.&lt;br /&gt;
&lt;br /&gt;
Communication amoung different proceess happens through various mechanims called Inter process communication mechanisms. We will discuss about various interprocesss mechanisms like signals,pipes,shared memory in upcoming topics.&lt;br /&gt;
&lt;br /&gt;
In addition, the scheduler, which controls how processes share the CPU, is part of process management. More generally, the kernel&#39;s process management activity runs several processes on top of a single CPU or on multiple CPUs.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2. Memory Management&lt;/b&gt;&lt;br /&gt;
Memory management looks at how the kernel manages physical &amp;nbsp;memory.&lt;br /&gt;
&lt;br /&gt;
Memory is a major resource, and the policy used to deal with it is a critical one for system performance. The kernel builds up a virtual addressing space for any and all processes on top of the limited available resources.&lt;br /&gt;
&lt;br /&gt;
We will be discussing about virtual address space in upcoming topics.&lt;br /&gt;
&lt;br /&gt;
The different parts of the kernel interact with the memory-management subsystem through a set of function calls, ranging from the simple malloc/free pair to much more complex functionalities.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&amp;nbsp;3. File Systems&lt;/b&gt;&lt;br /&gt;
Almost everything in Linux can be treated as a file. Linux is heavily based on the filesystem concept.&lt;br /&gt;
&lt;br /&gt;
The kernel builds a structured filesystem on top of unstructured hardware, and the resulting file concept is heavily used throughout the whole system.&lt;br /&gt;
&lt;br /&gt;
In addition, Linux also supports multiple filesystem types, that is, different ways of organizing data on the physical medium. For example, disks may be formatted with the Linux-standard ext3 filesystem... the commonly used FAT filesystem or several others.&lt;br /&gt;
&lt;br /&gt;
Key point to remember here is &quot;almost everything in Linux can be treated as a file&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;4. Device Control&lt;/b&gt;&lt;br /&gt;
Almost every system operation eventually maps to a physical device.All device control operations are performed by code that is specific to the device being addressed. Only the exception entitites are processor, memory, and a very few other entities.&lt;br /&gt;
&lt;br /&gt;
What does this mean ? It means in Linux every physical device is controlled by specific code called Device Driver.&lt;br /&gt;
&lt;br /&gt;
The kernel must have embedded in it a device driver for every peripheral present on a system, from the hard drive to the keyboard and the tape drive. This aspect of the kernel&#39;s functions is our primary interest in this tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;5. Networking&lt;/b&gt;&lt;br /&gt;
Networking must be managed by the operating system, because most network operations like asychronous incoming packets &amp;nbsp;are not specific to a process. The packets must be collected, identified, and dispatched before a process takes care of them.&lt;br /&gt;
&lt;br /&gt;
The system is in charge of delivering data packets across program and network interfaces, and it must control the execution of programs according to their network activity. Additionally, all the routing and address resolution issues are implemented within the kernel.&lt;br /&gt;
&lt;br /&gt;
Networking service from the kernel is the one which helps the programmer to explore and access various devices by accessing them remotely.&lt;br /&gt;
&lt;br /&gt;
This is end of Part-3 Linux &amp;nbsp;Device Drivers.&lt;br /&gt;
&lt;br /&gt;
We will continue our next topic in &amp;nbsp;Linux Device Drivers Part-4. Till then stay tuned ....&lt;br /&gt;
&lt;br /&gt;
To know more in detail, watch below video.&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;allowfullscreen&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/1v_ALs6zuRw&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;

&lt;br /&gt;
&lt;br /&gt;
Please feel free to comment and query.&lt;br /&gt;
&lt;br /&gt;
Don’t forget to subscribe &amp;nbsp;mrtechpathi videos in youtube.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://mrtechpathi-tutorials.blogspot.com/feeds/6705723934338475671/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2012/10/linux-device-drivers-part-3.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/6705723934338475671'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/6705723934338475671'/><link rel='alternate' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2012/10/linux-device-drivers-part-3.html' title='Linux Device Drivers Part - 3 : Role of Linux Kernel'/><author><name>MrTechpathi</name><uri>http://www.blogger.com/profile/17144890590324530224</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ04_tezdpWHZfGSynOJc0m8TA4fMuIoP5E3716kQa_bAHrezSkvdq8UH1spF1fh0-sshsYfgjXIz6i0lU5C2wj_FjnjS1KLqvlQINiYjVMelUU_UkjCE2zAmJyQjLFRgDe6BJQ6fa3M0/s72-c/Linux_Device_Drivers_3.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2567861330953913013.post-7449316140695596359</id><published>2012-10-21T03:43:00.000-07:00</published><updated>2015-06-06T07:05:38.417-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Dynamic Modules"/><category scheme="http://www.blogger.com/atom/ns#" term="Kernel Modules"/><category scheme="http://www.blogger.com/atom/ns#" term="Kernel Space"/><category scheme="http://www.blogger.com/atom/ns#" term="Kernel Space and User spaceInteraction"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Driver Tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Kernel"/><category scheme="http://www.blogger.com/atom/ns#" term="Static Modules"/><category scheme="http://www.blogger.com/atom/ns#" term="System Calls"/><category scheme="http://www.blogger.com/atom/ns#" term="User Space"/><title type='text'>Linux Device Drivers Part - 2 : System Memory, Static Modules and Dynamic Modules</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Before proceeding further, I strongly recommend you to watch &lt;a href=&quot;https://www.youtube.com/watch?v=U7QFcpVh248&quot;&gt;Part-1 of Linux Device Drivers&lt;/a&gt; from &lt;a href=&quot;http://mrtechpathi-tutorials.blogspot.co.uk/&quot;&gt;MrTechpathi tutorials&lt;/a&gt;.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEid904M0xzTiuq1SgLxZeUsedsw-baZfGgEMO6OEnzA2-YxLHlDyGxCBQaXF2Tiu47eCpj8We2bf2kGU8Lfg23bBEw9nSfESN3mCAOj0kDRLEAIVdNxILLG8AOWXSPoEqJZ7X7a5SHg0mo/s1600/Linux_Device_Drivers_2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;mrtechpathi_tutorials_linux_device_drivers_part_1&quot; border=&quot;0&quot; height=&quot;484&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEid904M0xzTiuq1SgLxZeUsedsw-baZfGgEMO6OEnzA2-YxLHlDyGxCBQaXF2Tiu47eCpj8We2bf2kGU8Lfg23bBEw9nSfESN3mCAOj0kDRLEAIVdNxILLG8AOWXSPoEqJZ7X7a5SHg0mo/s640/Linux_Device_Drivers_2.jpg&quot; title=&quot;mrtechpathi_tutorials_linux_device_drivers_part_1&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
In this part we will learn about following topics.&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;System Memory&lt;/li&gt;
&lt;li&gt;Kernel Space and User Space&lt;/li&gt;
&lt;li&gt;Kernel Modules : Static Modules and Dynamic Modules&lt;/li&gt;
&lt;/ol&gt;
So lets start with our first topic&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;1. System Memory&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
This topic is choosen to completely understand user space and kernel space.&lt;br /&gt;
&lt;br /&gt;
Every system has certain amount of memory.&lt;br /&gt;
&lt;br /&gt;
This memory consists of RAM (Random Access Memory) cells, whose contents can be accessed (i.e., read and written to) at extremely high speeds but are retained only temporarily (i.e., while in use or, at most, while the power supply remains on).&lt;br /&gt;
&lt;br /&gt;
Coming to the purpose of memory, it holds programs and data that are currently in use and thereby serve as a high speed mediumbetween the CPU (central processing unit) and the much slower storages like hard disk drives (HDDs).&lt;br /&gt;
&lt;br /&gt;
This System memory in Linux can be divided into two distinct regions: Kernel space and User space.&lt;br /&gt;
&lt;br /&gt;
Hope you understood how system memory, user space and kernel space are correlated.&lt;br /&gt;
&lt;br /&gt;
Now, lets move to our next topic.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;2. Kernel Space and User space&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
So, what is a kernel space ?&lt;br /&gt;
&lt;br /&gt;
Kernel space is where the &amp;nbsp;core of the operating system runs and provides its services.&lt;br /&gt;
&lt;br /&gt;
The left paritition is the kernel space where the operating system runs and provides services.&lt;br /&gt;
&lt;br /&gt;
The right partition is the user space where user processes run.&lt;br /&gt;
&lt;br /&gt;
What is a user space ?&lt;br /&gt;
&lt;br /&gt;
User space is that set of memory locations in which user processes run. A process is an executing instance of a program. One of the roles of the kernel is to manage individual user processes within this space and to prevent them from interfering with each other.&lt;br /&gt;
&lt;br /&gt;
Note that Device Driver runs in Kernel space and not in user space. All applications run in User space.These are very important points to be remembred by every device programmer.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;3. Kernel Space and User space &amp;nbsp;Interaction&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
How does this interaction happens ?&lt;br /&gt;
&lt;br /&gt;
To answer this quesion in short, it happens only through system calls.&lt;br /&gt;
&lt;br /&gt;
In detail, Kernel space can be accessed by user processes only through the use of system calls.System calls are requests in a Unix-like operating system by an active process for a service provided by the kernel, such as input/output (I/O) or process creation.&lt;br /&gt;
&lt;br /&gt;
In this what exactly we mean by Active process ?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;An active process is a process that is currently progressing in the CPU. Whereas, process is the one which is waiting for its next turn in the CPU. I/O is any program, operation or device that transfers data to or from a CPU and to or from a peripheral device (such as disk drives, keyboards, mice and printers).&lt;br /&gt;
&lt;br /&gt;
Please note that user space processes can&#39;t access the hardware directly. They need to use system calls for accessing certain functionality of hardware. These system calls are implemented by a driver and runs in kernel space to provide functionaliy of hardware to user.&lt;br /&gt;
&lt;br /&gt;
All these interactions are managed by the core kernel.&lt;br /&gt;
&lt;br /&gt;
If we go one step further and relate the previous &quot;User space and Kernel Space&quot; diagram with our program, kernel and hardware, it will resemble as this figure.&lt;br /&gt;
&lt;br /&gt;
Our application program will reside in user space and driver will reside in Kernel space. System calls are the only way for a user space program to access kernel space Device Drivers.&lt;br /&gt;
&lt;br /&gt;
Hope all are clear with Kernel space , User space and their interaction using system calls.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Kernel Modules&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Kernel Modules can be classified into two types&lt;br /&gt;
&lt;br /&gt;
Static modules&lt;br /&gt;
Dynamic modules&lt;br /&gt;
&lt;br /&gt;
What is a static module ?&lt;br /&gt;
&lt;br /&gt;
Static modules are compiled as a part of the kernel and are available at anytime. These make the kernel larger and has the disadvantage of requiring us to rebuild and reboot the kernel every time we want new functionality.&lt;br /&gt;
&lt;br /&gt;
Is there any better way than static modules ? Yes they are dynamic modules.&lt;br /&gt;
&lt;br /&gt;
What is a dynamic module ?&lt;br /&gt;
&lt;br /&gt;
Dynamic modules are pieces of code that can be loaded and unloaded into the kernel upon demand. They extend the functionality of the kernel without the need to reboot the system. &amp;nbsp;After loading the kernel, we can load this modules using insmod and unload using rmmod. We will be discussing about insmod and rmmod in upcoming tutorials.&lt;br /&gt;
&lt;br /&gt;
Dynamic Modules have the advantage that it uses the Memory more efficiently than the Statically linked drivers.&lt;br /&gt;
&lt;br /&gt;
Hope you are clear about Static modules which will be part of the kernel and dynamic modules which can be loaded into kernel based on our requirement.&lt;br /&gt;
&lt;br /&gt;
This is end of part-2 of Linux Device Drivers.&lt;br /&gt;
&lt;br /&gt;
If you are not clear on any topic discussed till now, please watch&lt;a href=&quot;https://www.youtube.com/watch?v=U7QFcpVh248&quot;&gt; part-1 &lt;/a&gt;and &lt;a href=&quot;https://www.youtube.com/watch?v=VXIFibjNLhU&quot;&gt;part-2&lt;/a&gt; couple of times without missing a single point. This will help in upcoming tutorials.&lt;br /&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;allowfullscreen&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/VXIFibjNLhU&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;


&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://mrtechpathi-tutorials.blogspot.com/feeds/7449316140695596359/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2012/10/linux-device-drivers-part-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/7449316140695596359'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/7449316140695596359'/><link rel='alternate' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2012/10/linux-device-drivers-part-2.html' title='Linux Device Drivers Part - 2 : System Memory, Static Modules and Dynamic Modules'/><author><name>MrTechpathi</name><uri>http://www.blogger.com/profile/17144890590324530224</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEid904M0xzTiuq1SgLxZeUsedsw-baZfGgEMO6OEnzA2-YxLHlDyGxCBQaXF2Tiu47eCpj8We2bf2kGU8Lfg23bBEw9nSfESN3mCAOj0kDRLEAIVdNxILLG8AOWXSPoEqJZ7X7a5SHg0mo/s72-c/Linux_Device_Drivers_2.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2567861330953913013.post-7800598324699786239</id><published>2012-10-07T04:32:00.000-07:00</published><updated>2015-06-06T07:07:49.211-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Device Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Education"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Applications"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Driver Tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Device Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Kernel"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Tutorials"/><category scheme="http://www.blogger.com/atom/ns#" term="Role of Device Drivers"/><category scheme="http://www.blogger.com/atom/ns#" term="Tutorials"/><title type='text'>Linux Device Drivers Part - 1 : What is Linux Device Driver ?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
From today, we &amp;nbsp;will be discussing about Linux Device Drivers which are very useful for Device Driver programmers.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSery7xY7SM4GMDCF-BTCblYtpBzuLyW5rE8Au5HTkyHTIqeiiZE_fwk6thNy5SD-a4Gnbxg_MlWGYlfDDTfchYvwJ4log-gJgzr7HuygYzGOYnos5A22qmMMeDK-NdnMOR4Z4k8VcHls/s1600/Linux_Device_Drivers_1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;mrtechpathi_tutorials_linux_device_drivers_part_1&quot; border=&quot;0&quot; height=&quot;488&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSery7xY7SM4GMDCF-BTCblYtpBzuLyW5rE8Au5HTkyHTIqeiiZE_fwk6thNy5SD-a4Gnbxg_MlWGYlfDDTfchYvwJ4log-gJgzr7HuygYzGOYnos5A22qmMMeDK-NdnMOR4Z4k8VcHls/s640/Linux_Device_Drivers_1.jpg&quot; title=&quot;mrtechpathi_tutorials_linux_device_drivers_part_1&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Linux has more future and those who learn more on Linux Kernel and Device drivers will benefit a lot. Linux is one of the best open source operating system which is available to everyone. It is majorly used operating system in smart phones and Embedded Systems these days. Yes all, Android phones have Open source Linux Operating system in it which is customized according to Smartphone vendor needs.&lt;br /&gt;
&lt;br /&gt;
So, lets start with Linux Device Driver Programming..&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Scope of this Tutorial&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
To gain in depth knowledge on Linux Device Driver.&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;From now on, for your convenience, we will be discussing this topic part by part.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;b&gt;&lt;u&gt;In this part we will know about&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
What is a Linux Device Driver ?&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;b&gt;&lt;u&gt;So&amp;nbsp;What is a Linux Device Driver ?&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
Linux Device drivers are distinct “black boxes” that make a particular piece of hardware respond to a well-defined internal programming interface.They completely &amp;nbsp;hide the details of how the device works.&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;b&gt;&lt;u&gt;Points to note while writing a device driver&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;While writing a driver to a specific device, remember that each driver is different; as a driver writer, you need to understand your specific device well.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;You need to gather all information like datasheets, design documents and schematics of your device from device vendor.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Please note that its very difficult to teach about a specific device in this tutorial. Instead, we will teach you how to build the background required to make your device work.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;&lt;u&gt;Role of Device driver&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
As stated earlier, User activities are performed by means of a set of standardized calls that are independent of the specific driver; mapping those calls to device-specific operations that act on real hardware is then the role of the device driver.&lt;br /&gt;
&lt;br /&gt;
That&#39;s &amp;nbsp;it for today, for your convenience, we will be discussing Linux Device drivers part by part.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
For more pictorial description, watch below video and shed your comments and queries.&lt;/div&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;allowfullscreen&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/U7QFcpVh248&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://mrtechpathi-tutorials.blogspot.com/feeds/7800598324699786239/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2012/10/linux-device-drivers-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/7800598324699786239'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2567861330953913013/posts/default/7800598324699786239'/><link rel='alternate' type='text/html' href='http://mrtechpathi-tutorials.blogspot.com/2012/10/linux-device-drivers-part-1.html' title='Linux Device Drivers Part - 1 : What is Linux Device Driver ?'/><author><name>MrTechpathi</name><uri>http://www.blogger.com/profile/17144890590324530224</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSery7xY7SM4GMDCF-BTCblYtpBzuLyW5rE8Au5HTkyHTIqeiiZE_fwk6thNy5SD-a4Gnbxg_MlWGYlfDDTfchYvwJ4log-gJgzr7HuygYzGOYnos5A22qmMMeDK-NdnMOR4Z4k8VcHls/s72-c/Linux_Device_Drivers_1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry></feed>