<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Device Drivers &#8211; Harry Jackson</title>
	<atom:link href="http://127.0.0.1:8090/tag/device-drivers/feed" rel="self" type="application/rss+xml" />
	<link>http://127.0.0.1:8090</link>
	<description>Parent, Painter, Programmer</description>
	<lastBuildDate>Wed, 24 Nov 2004 06:14:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>
	<item>
		<title>Writing Linux Device Drivers</title>
		<link>http://127.0.0.1:8090/writing_linux_device_drivers.htm</link>
					<comments>http://127.0.0.1:8090/writing_linux_device_drivers.htm#respond</comments>
		
		<dc:creator><![CDATA[harry]]></dc:creator>
		<pubDate>Wed, 24 Nov 2004 06:14:22 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Device Drivers]]></category>
		<category><![CDATA[Kernel]]></category>
		<guid isPermaLink="false">http://www.hjackson.org/wp/?p=213</guid>

					<description><![CDATA[I lost my internet connection at the weekend and was at a bit of a loss as to what I could do so I decided to take a pop at writing a simple module for the Linux kernel. I have a copy of Beginning Linux Programming ISBN: 1861002971 Authors: Richard Stevens and Neil Matthew Ed: &#8230; <p class="link-more"><a href="http://127.0.0.1:8090/writing_linux_device_drivers.htm" class="more-link">Continue reading<span class="screen-reader-text"> "Writing Linux Device Drivers"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>I lost my internet connection at the weekend and was at a bit of a loss as to what I could do so I decided to take a pop at writing a simple module for the Linux kernel. I have a copy of<br />
Beginning Linux Programming<br />
ISBN: 1861002971<br />
Authors: Richard Stevens and Neil Matthew<br />
Ed: 2nd<br />
so I turned to the back of it and started my foray into the Kernel. Now you need to remember that I am not a C programmer by trade and turning to the back of this book was a keen reminder of just how rusty my C is getting, not that it was ever rust free.<br />
Luckily for me I have another book that is considered the C bible ie K&amp;R and it deserves its reputation, it is a classic and I would recommend any programmer regardless of language choice to have a flick through it. When I was looking at some odd construct that those pointy hats had invented I had a flick through K&amp;R  and soon sorted it out.<br />
Anyway back to the kernel. I was quick to discover that writing a module for the 2.6 kernel is not quite as straight forward as copying from the book and trying to understand what was going on. Things have been changing and I was getting all sorts of weird (or at least to me) and wonderful errors when trying to compile the kernel.<br />
I eventually started to have a read at the recent modules in the source for 2.6.5 which I am running on this box. I also have the source for a 2.4 kernel on here so I opened 2 character drivers and compared notes between them. This is where I started to notice things that had changed. I made the changes I thought where necessary and I managed to get most of the &#8220;Hello World&#8221; module compiling but I was still getting errors.<br />
I had a hunt around and I found a reference to some new build procedures for 2.6.5 so off I went in search of kbuild documentation and found some more stuff that had changed in the kernel. Namely the build procedure. This part was actually harder than the C that I had been struggling with.<br />
After much swearing (I hate Makefiles and adding some more sugar is a pain in the ass) I managed to get the module compiling and I was on my way.<br />
After a days work I now had a module that, on load would say<br />
&#8220;Hello World&#8221;<br />
and on removal<br />
&#8220;Goodbye World&#8221;<br />
time well spent or not? I haven&#8217;t decided yet. I wonder how often changes like this take place in the kernel and how much porting takes place because of it.<br />
Where to go from here. I asked a few friends who know more about this stuff than I do and I got mixed advice about continuing. Some of them think the kernel is a mess because they are always changing the driver API among other things. I cannot comment because my knowledge of the Linux kernel is limited to spelling it and I sometimes get that wrong.<br />
I did get some useful pointers though. The following is the best book I have found so far for someone like me who is just starting out in the kernel.<br />
<a href="http://www.xml.com/ldd/chapter/book/index.html">Linux Device Drivers, 2nd Edition</a><br />
It is written for the 2.4 kernel but has a wealth of information that is still valid today. I have started porting the scull drivers from this to the 2.6 kernel I am running and it is proving very interesting. I printed off chapter 2 and 3 yesterday and have have almost finished them (40 mins from Luton to London on the train each way helps). So far it seems to be moving along at a fair old pace, I am just hoping I can keep up.<br />
I could have done with the following at the weekend. This tells me what I needed to know about moving from 2.4 to 2.6. I can see myself using this a lot in the next few weeks.<br />
<a href="http://lwn.net/Articles/driver-porting/">Driver Porting</a></p>
]]></content:encoded>
					
					<wfw:commentRss>http://127.0.0.1:8090/writing_linux_device_drivers.htm/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
