<?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>EmbLogic &#187; pravjot sir</title>
	<atom:link href="https://www.emblogic.com/blog/tag/pravjot-sir/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.emblogic.com/blog</link>
	<description>Embedded System and ARM Training</description>
	<lastBuildDate>Tue, 03 Mar 2020 13:00:06 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
	<item>
		<title>DEVICE DRIVER</title>
		<link>https://www.emblogic.com/blog/01/device-driver-10/</link>
		<comments>https://www.emblogic.com/blog/01/device-driver-10/#comments</comments>
		<pubDate>Mon, 06 Jan 2014 12:24:14 +0000</pubDate>
		<dc:creator><![CDATA[u.sravan]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[pravjot sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=8044</guid>
		<description><![CDATA[head    1.3; access; symbols; locks root:1.3; strict; comment @ * @; 1.3 date    2014.01.07.05.55.57;    author root;    state Exp; branches; next    1.2; 1.2 date    2014.01.07.04.44.27;    author root;    state Exp; branches; next    1.1; 1.1 date    2014.01.07.03.22.24;    author root;    state Exp; branches; next    &#8230; <a href="https://www.emblogic.com/blog/01/device-driver-10/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>head    1.3;<br />
access;<br />
symbols;<br />
locks<br />
root:1.3; strict;<br />
comment @ * @;</p>
<p>1.3<br />
date    2014.01.07.05.55.57;    author root;    state Exp;<br />
branches;<br />
next    1.2;</p>
<p>1.2<br />
date    2014.01.07.04.44.27;    author root;    state Exp;<br />
branches;<br />
next    1.1;</p>
<p>1.1<br />
date    2014.01.07.03.22.24;    author root;    state Exp;<br />
branches;<br />
next    ;</p>
<p>desc<br />
@device driver registerd using alloc_chrdev_region<br />
@</p>
<p>1.3<br />
log<br />
@device structure cdev initialized and cdev is added to device table<br />
@</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/01/device-driver-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DEVICE DRIVER SCULLDEV ALLOCATION &amp; DEALLOCATION</title>
		<link>https://www.emblogic.com/blog/01/device-driver-sculldev-allocation-deallocation/</link>
		<comments>https://www.emblogic.com/blog/01/device-driver-sculldev-allocation-deallocation/#comments</comments>
		<pubDate>Mon, 06 Jan 2014 11:15:26 +0000</pubDate>
		<dc:creator><![CDATA[u.sravan]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[pravjot sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=8033</guid>
		<description><![CDATA[module initialization log_file head    1.2; access; symbols; locks root:1.2; strict; comment @ * @; 1.2 date    2014.01.07.04.44.27;    author root;    state Exp; branches; next    1.1; 1.1 date    2014.01.07.03.22.24;    author root;    state Exp; branches; next    ; desc @device driver registerd using alloc_chrdev_region &#8230; <a href="https://www.emblogic.com/blog/01/device-driver-sculldev-allocation-deallocation/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>module initialization log_file</p>
<p>head    1.2;<br />
access;<br />
symbols;<br />
locks<br />
root:1.2; strict;<br />
comment @ * @;</p>
<p>1.2<br />
date    2014.01.07.04.44.27;    author root;    state Exp;<br />
branches;<br />
next    1.1;</p>
<p>1.1<br />
date    2014.01.07.03.22.24;    author root;    state Exp;<br />
branches;<br />
next    ;</p>
<p>desc<br />
@device driver registerd using alloc_chrdev_region<br />
@</p>
<p>1.2<br />
log<br />
@device driver structure(Sculldev) represented &amp; memory allocated using kmalloc<br />
@<br />
_______________________________________________________________________________________________________</p>
<p>module clean_up log_file</p>
<p>head    1.2;<br />
access;<br />
symbols;<br />
locks; strict;<br />
comment @ * @;</p>
<p>1.2<br />
date    2014.01.07.04.46.28;    author root;    state Exp;<br />
branches;<br />
next    1.1;</p>
<p>1.1<br />
date    2014.01.07.03.26.40;    author root;    state Exp;<br />
branches;<br />
next    ;</p>
<p>desc<br />
@device driver unregisterd using unregister_chrdev_region<br />
@</p>
<p>1.2<br />
log<br />
@device driver structure(Sculldev) deallocated using kfree &amp; device driver unregistered<br />
@</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/01/device-driver-sculldev-allocation-deallocation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>device driver module registration</title>
		<link>https://www.emblogic.com/blog/01/device-driver-module-registration/</link>
		<comments>https://www.emblogic.com/blog/01/device-driver-module-registration/#comments</comments>
		<pubDate>Mon, 06 Jan 2014 09:50:06 +0000</pubDate>
		<dc:creator><![CDATA[u.sravan]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[pravjot sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=8016</guid>
		<description><![CDATA[module initialization log_file head    1.1; access; symbols; locks root:1.1; strict; comment @ * @; 1.1 date    2014.01.07.03.22.24;    author root;    state Exp; branches; next    ; desc @device driver registerd using alloc_chrdev_region @ 1.1 log @Initial revision @ ______________________________________________________________________________________________________________________________________________________________________ module clean_up log_file &#8230; <a href="https://www.emblogic.com/blog/01/device-driver-module-registration/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>module initialization log_file</p>
<p>head    1.1;<br />
access;<br />
symbols;<br />
locks<br />
root:1.1; strict;<br />
comment @ * @;</p>
<p>1.1<br />
date    2014.01.07.03.22.24;    author root;    state Exp;<br />
branches;<br />
next    ;</p>
<p>desc<br />
@device driver registerd using alloc_chrdev_region<br />
@</p>
<p>1.1<br />
log<br />
@Initial revision<br />
@</p>
<p>______________________________________________________________________________________________________________________________________________________________________</p>
<p>module clean_up log_file</p>
<p>head    1.1;<br />
access;<br />
symbols;<br />
locks<br />
root:1.1; strict;<br />
comment @ * @;</p>
<p>1.1<br />
date    2014.01.07.03.26.40;    author root;    state Exp;<br />
branches;<br />
next    ;</p>
<p>desc<br />
@device driver unregisterd using unregister_chrdev_region<br />
@</p>
<p>1.1<br />
log<br />
@Initial revision<br />
@</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/01/device-driver-module-registration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bizarre condition</title>
		<link>https://www.emblogic.com/blog/10/bizarre-condition/</link>
		<comments>https://www.emblogic.com/blog/10/bizarre-condition/#comments</comments>
		<pubDate>Fri, 18 Oct 2013 15:41:03 +0000</pubDate>
		<dc:creator><![CDATA[Himalaya Batra]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Dheeraj sir]]></category>
		<category><![CDATA[Harpreet sir]]></category>
		<category><![CDATA[Jasmeen ma'am]]></category>
		<category><![CDATA[pravjot sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7353</guid>
		<description><![CDATA[whenever i open terminal, this ~~ automatically starts printing on my screen continuously&#8230;&#8230; it also create very much problem while typing&#8230;.. and main thing is this is not a hardware problem of my laptop&#8230; because this problem was not there &#8230; <a href="https://www.emblogic.com/blog/10/bizarre-condition/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>whenever i open terminal, this ~~ automatically starts printing on my screen continuously&#8230;&#8230; it also create very much problem while typing&#8230;.. and main thing is this is not a hardware problem of my laptop&#8230; because this problem was not there in windows 7 but this problem came in to notice after installing fedora 17. please suggest me what to do ???</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/10/bizarre-condition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Olinuxino:</title>
		<link>https://www.emblogic.com/blog/10/olinuxino/</link>
		<comments>https://www.emblogic.com/blog/10/olinuxino/#comments</comments>
		<pubDate>Sat, 12 Oct 2013 06:29:59 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[pravjot sir]]></category>
		<category><![CDATA[Siddharth Sir. Varun sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7318</guid>
		<description><![CDATA[How can i install flex2bin in my host? I tried but getting error in installiation of the this tooll.]]></description>
				<content:encoded><![CDATA[<p>How can i install flex2bin in my host? I tried but getting error in installiation of the this tooll. </p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/10/olinuxino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jatinder Kumar : Porting</title>
		<link>https://www.emblogic.com/blog/10/jatinder-kumar-porting/</link>
		<comments>https://www.emblogic.com/blog/10/jatinder-kumar-porting/#comments</comments>
		<pubDate>Thu, 10 Oct 2013 06:00:32 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Project 9: Embedded Linux on ARM]]></category>
		<category><![CDATA[pravjot sir]]></category>
		<category><![CDATA[Siddharth Sir. Varun sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7266</guid>
		<description><![CDATA[can anyone tell me how can i set console during loading rootfile system via NFS . I compiled my kernel and set the commandline string as root=/dev/nfs rootwait console=ttyS0,115200n8 and i also try bootargs environment varible of u boot but &#8230; <a href="https://www.emblogic.com/blog/10/jatinder-kumar-porting/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>can anyone tell me how can i set console during loading rootfile system via NFS . I compiled my kernel and set the commandline string  as root=/dev/nfs rootwait console=ttyS0,115200n8<br />
and i also try bootargs environment varible of u boot<br />
but i am still struck in the same problem.<br />
i know the kernel is booting but i can&#8217;t see the output on my console.<br />
I tried to understand JTAG but still confused that if i need extra hardware for it or not</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/10/jatinder-kumar-porting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Taruna : Porting Linux</title>
		<link>https://www.emblogic.com/blog/10/taruna-porting-linux/</link>
		<comments>https://www.emblogic.com/blog/10/taruna-porting-linux/#comments</comments>
		<pubDate>Mon, 07 Oct 2013 05:06:11 +0000</pubDate>
		<dc:creator><![CDATA[taruna]]></dc:creator>
				<category><![CDATA[Project 9: Embedded Linux on ARM]]></category>
		<category><![CDATA[pravjot sir]]></category>
		<category><![CDATA[Siddharth sir]]></category>
		<category><![CDATA[To : Varun Sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7294</guid>
		<description><![CDATA[I am porting linux on beaglebone and booting it via network.. I am able to get the uImage via tftp successfully , but when I fetch the rootfs through nfs , I am unable to get the output on the &#8230; <a href="https://www.emblogic.com/blog/10/taruna-porting-linux/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I am porting linux on beaglebone and booting it via network.. I am able to get the uImage via tftp successfully , but when I fetch the rootfs through nfs , I am unable to get the output on the console.. How to set the console for this?</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/10/taruna-porting-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Taruna</title>
		<link>https://www.emblogic.com/blog/10/taruna/</link>
		<comments>https://www.emblogic.com/blog/10/taruna/#comments</comments>
		<pubDate>Tue, 01 Oct 2013 05:39:31 +0000</pubDate>
		<dc:creator><![CDATA[taruna]]></dc:creator>
				<category><![CDATA[Project 9: Embedded Linux on ARM]]></category>
		<category><![CDATA[pravjot sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7204</guid>
		<description><![CDATA[Able to fetch the uImage using tftp on beaglebone&#8230; and boot it finally]]></description>
				<content:encoded><![CDATA[<p>Able to fetch the uImage using tftp on beaglebone&#8230; and boot it finally</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/10/taruna/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Character Driver Article</title>
		<link>https://www.emblogic.com/blog/07/character-driver-article/</link>
		<comments>https://www.emblogic.com/blog/07/character-driver-article/#comments</comments>
		<pubDate>Sun, 21 Jul 2013 05:18:28 +0000</pubDate>
		<dc:creator><![CDATA[ashish.verma]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[pravjot sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6791</guid>
		<description><![CDATA[Article On Character Driver This Article is based on how I implemented character driver till now. First of all we have to know actually what a driver Is. Let take a example in real world we have a man who &#8230; <a href="https://www.emblogic.com/blog/07/character-driver-article/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>                                        Article On Character Driver<br />
This Article is based on how I implemented character driver till now. First of all we have to know actually what a driver Is. Let take a example in real world we have a man who can drive a bike but can’t run car so we need a driver who can run a car .in the similar way there are some specific hardware devices  which can’t be run on simple program for that we need a special program. This program load in the kernel as a part of our operating system ,run and remove when it need is ended. They are used to<br />
1.To allow interaction with hardware devices<br />
2.Black boxes to hide details of hardware devices<br />
3.Use standardized calls<br />
4.Map standard calls to device-specific operations</p>
<p>So device drivers  are that loadable kernel modules which insert in kernel ,work as part of kernel and removes as the need is ended.<br />
Now there are Basically three types of drivers:<br />
1.Character Driver<br />
2.Block Driver<br />
3.Network Driver<br />
Character Driver:- First of all in driver we have to know that we are legally hack the kernel so we cant user level commands here for example we can’t use printf ,we use printk instead of that.<br />
In kernel level there are two main functions which are module_init (arg) and Module_exit (arg).Here arguments is our start and exit functions. This is the two main micros of a driver. That mean a driver perform Module_init at starting and Module_exit on exit.<br />
module_init (fn name):In module _init we register our driver by using<br />
alloc_chrdev_region(&amp;dev, minorno, nod, DRIVER_NAME);</p>
<p>in this dev id dev_t type and minor no is device no and nod Is number of devices .<br />
now we get a a combination of major and minor no in dev which is of 32 byte in which 20 byte is of minor no and 12 byte is for major no. we can get our major no. by using micros major(dev) and minor(dev) this will give major and  minor no.<br />
We make our user defined function sculldev which have all the information about the device and allocate memory for it using Kmalloc. Which return a pointer which points to it starting address.<br />
Now initialize our C_dev which is points to struct cdev and fops.<br />
cdev_init (&amp;sculldev-&gt;c_dev, &amp;fop);<br />
we can inform the kernel about this c dev structure using the cdev_add call.<br />
int cdev_add(struct sculldev -&gt;c_dev, dev_t dev, unsigned int count);<br />
 this is our start function. Now we proceeed to exit one.<br />
In exit function we do nothing  but to unregister device and free the memory allocatd to sculldev.<br />
Now we go to our header file and define our sculldev structure and assign its members that are our quantum_size ,qset size,device size.and struct cdev type c_dev and struct scullaset *scullqs.et which points to our structure  ScullQset which contains  two things which are first our next pointer which points to out next scullqset structure and second is  data pointer which contains qset which actually an array of pointer.It contains starting address of quantums.Ultimately our data is going to store in the quantums.<br />
The whole structure of ScullQset is known as Item.We can relate it as our linked list which has next pointer and an info part.<br />
This is our scullqset structure.</p>
<p>struct ScullQset<br />
{<br />
	struct ScullQset *next;<br />
	void **data;<br />
};<br />
 .<br />
Now as we know that every device has its own set of open,close etc fn. So we have to map it using a structure names file_operations.<br />
const struct file_operations fop=<br />
{<br />
	open:scull_open,<br />
        write:scull_write,<br />
        read:scull_read,<br />
        release:scull_release<br />
};</p>
<p>Here we map open call by scull_open means whenever a open call is make the command goes to scull open and perform scull_open.Simiarly we can map any no. of  user level command.<br />
Now we are defining prototypes of mapped command which are given in fs.h libraray which can accessible in kernel file.<br />
int scull_open(struct inode *, struct file * );<br />
int scull_release(struct inode *, struct file * );<br />
ssize_t scull_read (struct file *, char __user *, size_t, loff_t *);<br />
ssize_t scull_write(struct file *, const char __user *, size_t, loff_t *);</p>
<p>Now after that I write our open function in which I use Container_of which is used to map scull memory on device.<br />
I preserve starting point pointer i.e sculldev in filep-&gt;private data.<br />
Now In read fn . I get data from application and perform some calculation which give me idea on how many no. of quantum’s I needed to write this data .After that I write the data in Quantums by using the micro copy_from_user(destination,source,len)<br />
Now I mapped the read function also so I read this data and show it in application by micro copy_to_user (destination, source, len)<br />
Now I make a simple application and test it .I pass the data by using file descriptors.<br />
I make a node which connect device driver to application.<br />
I connect the application with device driver code by writing a command in script as<br />
./ appl node.<br />
 Loadable Moduler kernel can be inserted and removed from the running kernel(using kernel utilities insmod and rmmod respectively);<br />
Successfully worked till this. Working on lseek now.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/character-driver-article/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>30.1.30: Jatinder Kumar</title>
		<link>https://www.emblogic.com/blog/07/30-1-30-jatinder-kmau/</link>
		<comments>https://www.emblogic.com/blog/07/30-1-30-jatinder-kmau/#comments</comments>
		<pubDate>Sat, 20 Jul 2013 16:26:46 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[Device Drivers]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[pravjot sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6879</guid>
		<description><![CDATA[From last two weeks i am working on Character Driver. What is device driver and need of driver? From my knowledge device driver is nothing but piece of code that runs the device . Every device need that code to &#8230; <a href="https://www.emblogic.com/blog/07/30-1-30-jatinder-kmau/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>From last two weeks i am working on Character Driver.</p>
<p>What is  device driver and need of driver?<br />
From my knowledge device driver is nothing but piece of code that runs the device . Every device need that code to run ,without driver device is dead, to make device alive we have to provide that code.<br />
This code is nothing but the driver.<br />
When the driver sit in the hardware permanently that that driver is called firmware , when this driver set the rule how the system boot up then this driver know as BIOS.<br />
So i can conclude that every device need a piece of software to run the device. Driver not also run the device but it also decide that what will do i the device is on ,running and shutdown. From booting of the device to shutdown device need the support of the driver.</p>
<p>Types of device driver:<br />
1. Character driver<br />
2.  block driver<br />
3. Network driver/pipe driver</p>
<p>In this article i will talk about character driver.  Character-driven drivers are device drivers that operate on characters (bytes) as the basic unit of input and<br />
 output. They are accessed in a sequential, nonrandom manner.<br />
 We can access the device as the file and operation of file like read, write ,open close and lseek.</p>
<p>Linux kernel have feature that we can add functionality when the system is being running and similarly we can remove some functionality. We can add or remove functionality by mean of piece of code and that piece of code is nothing but the module. When the module is inserted then it works as the part of the Linux kernel. </p>
<p>In short we can add or remove the module. For adding the module i used insmod command and for removing it i used rmmod command.<br />
By doing insmode we can see our module is inserted in the kernel to cross check i used lsmod command and i saw that my module was i the list. As soon as i do rmmod i saw that my module was not there.</p>
<p>Now question comes what is moudle?<br />
As i already told that module in nothing but the piece of code. Every module as at-least two function initialization function and cleanup function.<br />
When the module is inserted by insmode the initialization function does it work and this function is initialized by a macro module_init().<br />
And when we do rmmode the cleanup function does its job and this function is invoked by the module_exit() function .<br />
And one thing we should keep in mind that what we have did in the initialization function we have do remove that in revere order int the cleanup function.<br />
After inserted the module in the kernel i register the my module first by older way register_chrdev(), this function takes three argument major no, driver_name, and a pointer to struct file operations . By giving major number as 0 we do let the kernel to choose the lowest available major number  and for unregistering  the  module i used unregister_chrdev(). It takes two argumnet major number and same device_name.<br />
This method is now obsolete. Now a days developer used new method for registration and unregistration. But if we dig out the code of the old driver we still found that this method is being used.</p>
<p>The newer function to registering the device is alloc_chrdev_region and register_chrdev_region.<br />
The alloc_chardev_region register the module by taking three argument first one is a pointer of dev_t and first minor no which is always 0 third argument is integer number and fourth is the deive name. By using this function we let the kernel to choice available major number.<br />
Same thing is done by register_chrdev_region function  but in this we have to provide the major number. It is always advisable that not to choose the major number statically because that major may also be used by the some other driver so a good developer pick the major number dynamically by using alloc_chrdev_region() for very first time . I also used alloc_chredv_region() for the first time and when i get the major number i used that major number in the second function  and the number of node (ie how many i want to register the device for that particular driver/module  ). The second one also prevent the registration of the same module in the kernel .</p>
<p>Then i declared a user defined structure struct ScullDev{}; this structure has initially it has two member  first is pointer to struct scullqset and a varible of type struct cdec.</p>
<p>And the struct ScullQset has the the various member like a void pointer , a pointer itself and lot more like device size,qset size ,quantum size. The void pointer has the that address where our data actually reside.</p>
<p>Next i used cdev_init() and cdev_add() functionn. By using cdev_intit function i initialized the chracter device and by using cdev_add() i inform the kernel.<br />
Before going on this step i understand the some structure  like file structure , inode structure, file_operations structure and relation between them. </p>
<p>Then i made a simple application for testing the driver. In which i simply used open ,write,read and close command.</p>
<p>In my driver i mapped the open command to my own open routine same i did for read,write ,close and lseek . And made nod by using mknod of type c and provide this mode major and minor number which i got for the alloc_chrdev_region. By doing this when i run my application using this node and when my application try to open the device it open the device according to my routine. </p>
<p>I made my open routine  , close routine and  read and write . In this routine i used my own algorithm  to read and write and trim .<br />
In write function and also used kmallc function to allocate the memory from kernel space  which is physical memory and cop_from_user macro. </p>
<p>And in read routine i track the quantum which is created and used copy_to_user macro.</p>
<p>In open routine i used container_of macro .</p>
<p>Until now i successfully implemented open ,write,read,release ,lseek<br />
 and application open the device in write only mode it first to trim. And open the driver after writing some data it will trim all the data and also implemented the driver for other version of read in which it free that quantum that  is read. </p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/30-1-30-jatinder-kmau/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>30.01.30 : Taruna</title>
		<link>https://www.emblogic.com/blog/07/30-01-30-taruna-3/</link>
		<comments>https://www.emblogic.com/blog/07/30-01-30-taruna-3/#comments</comments>
		<pubDate>Sat, 20 Jul 2013 04:18:51 +0000</pubDate>
		<dc:creator><![CDATA[taruna]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[pravjot sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6866</guid>
		<description><![CDATA[Character-driven drivers are device drivers that operate on characters (bytes) as the basic unit of input and output. They are accessed in a sequential, non-random manner. &#160; I started writing my first character driver by writing the simplest module – &#8230; <a href="https://www.emblogic.com/blog/07/30-01-30-taruna-3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">Character-driven drivers are device drivers that operate on characters (bytes) as the basic unit of input and output. They are accessed in a sequential, non-random manner. </span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">I started writing my first character driver by writing the simplest module – hello world module.</span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">Character devices have to register themselves with the kernel and provide it with the information that enables the kernel to invoke the correct functions when applications wish to interact with the device. I registered my driver using alloc_chrdev_region() and register_chrdev_region(). When we register our driver for the first time , we use the former method and to prevent its re-registeration when a new device is connected , we use the latter&#8230; The older method of registering a driver i the kernel is : register_chrdev().</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">The syntax of these are as follows:</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium"> int alloc_chrdev_region(dev_t * , unsigned , unsigned , const char *);</span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium"> int register_chrdev_region(dev_t , unsigned , const char *);</span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">We also need to include the required libraries in our header file.These are &lt;linux/init.h&gt; , &lt;linux/module.h&gt; , &lt;linux/fs.h&gt; , and others will be mentioned as per requirement. In our module we require two functions : module_init and module_exit.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">module_init is used for calling the initialization function while module_exit is needed for the cleanup function. I also used a special macro MODULE_LICENSE() to tell the kernel that my module bears a free license.</span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">To unregister the driver we use unregister_chrdev_region() in our cleanup function. The syntax of unregister_chrdev_region is:</span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium"> unregister_chrdev_region(dev_t , unsigned);</span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium"><span style="text-decoration: underline">Loading and unloading the driver</span></span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">To load and unload our driver we need special utilities / commands. These are insmod and rmmod.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">To insert my driver into the kernel I used insmod and to unload it I used rmmod. Also we can pass parameters while doing insmode. For that we use macro: module_param and include the header file moduleparam.h.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">module_param uses three parameters : name of the variable to be passed , its type and permissions. For eg: I used it as:</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">module_param(nod , int , S_IRUGO). Here nod stands for number of devices which is of integer type.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">After inserting our driver , we can perform various tasks like open , read , write and close. Rmmod simply tells the kernel that the driver is not there and it cannot perform these tasks.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium"><span style="text-decoration: underline">Getting memory for Scull Device</span></span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">The very next thing we need to do is to create the scull.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">This is done using kmalloc in the following manner:</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">kmalloc(size_t , gfp_t flags);</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">The flag that we used is GFP_KERNEL.</span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">The header file for kmalloc is &lt;linux/slab.h&gt;. This is done in the initialization function.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">In our cleanup function we need to undo everything we do in initialization function in the reverse order. So to free this allocated memory we use kfree().</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">Also its better to memset this allocated memory using memset.</span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium"><span style="text-decoration: underline">Major and Minor numbers</span></span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">We know that in linux everything is a file. Even the device is a file. The character devices are accessed through names in file system. We call them nodes.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">The major number identifies the driver for the device while the minor number is used by the kernel to determine exactly which device is being referred to.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">The device is internally referred by device numbers.dev_t is used to hold these device numbers. To get the major and minor numbers we use special macros:</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium"> MAJOR(dev_t);</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium"> MINOR(dev_t);</span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">To convert the major and minor numbers into device numbers , we use MKNOD.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium"> MKNOD(majorno , minorno);</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">So the device number is a 32 bit combination of major and minor numbers.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">12 bits are for major number and 20 bits for minor number.</span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">The alloc_chrdev_region() and register_chrdev_region() are used by the kernel to allocate device numbers for our driver.</span></span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium"><span style="text-decoration: underline">Initializing the cdev structure</span></span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">The cdev structure is used to represent our char device internally.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">I used cdev_init () to initialize the struct cdev. In this function , I initialized all the members of this structure:</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium"> set cdev.owner to THIS_MODULE</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium"> set cdev.dev to dev</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium"> set fileoperations to fops.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">After these initializations we need to tell the kernel about the cdev structure . To do so , I used cdev_add(). In my cleanup function I used cdev_del() .</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">The syntax of these functios are as follows:</span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium"> void cdev_init(struct cdev *, const struct file_operations *); </span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium"> int cdev_add(struct cdev *, dev_t, unsigned);</span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium"> void cdev_del(struct cdev *);</span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium"><span style="text-decoration: underline">Initializing the struct ScullDev</span></span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">The struct ScullDev is a user defined structure to represent the device.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">We need to initialize the members of struct ScullDev also.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">The members are : qset size , quantum size , device size and data size.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">I used my own function init_scull() to make these initializations.</span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">After doing upto this , our device is ready to be opened and we can perform read write operations on it. These operations are performed through an application that uses system calls: open , write , read and close.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">We then map these system calls to our own routines and use struct file_operations to do the mapping.</span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">I made an application and made it to interact with my driver to perform the read write and open close operations through a script.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">Apart from this we need to trim our device when we open it in write only mode. For this i made a scull_trim() function.</span></span></p>
<p><span style="font-family: DejaVu Sans Condensed,sans-serif"><span style="font-size: medium">I am able to perform writing and reading and also lseek.</span></span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/30-01-30-taruna-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>30.01.30 : Taruna</title>
		<link>https://www.emblogic.com/blog/07/30-01-30-taruna-2/</link>
		<comments>https://www.emblogic.com/blog/07/30-01-30-taruna-2/#comments</comments>
		<pubDate>Wed, 17 Jul 2013 08:09:21 +0000</pubDate>
		<dc:creator><![CDATA[taruna]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[Device Drivers]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[pravjot sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6824</guid>
		<description><![CDATA[RCS file: lkm.c,v Working file: lkm.c head: 1.18 branch: locks: strict access list: symbolic names: keyword substitution: kv total revisions: 18; selected revisions: 18 description: Created the base module. Used alloc_chrdev_region and register_chrdev_region to register the driver and unregistered it &#8230; <a href="https://www.emblogic.com/blog/07/30-01-30-taruna-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>RCS file: lkm.c,v<br />
Working file: lkm.c<br />
head: 1.18<br />
branch:<br />
locks: strict<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 18; selected revisions: 18<br />
description:<br />
Created the base module.<br />
Used alloc_chrdev_region and register_chrdev_region to register the driver and unregistered it using unregister_chrdev_region.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.18<br />
date: 2013/07/17 08:03:34; author: taruna; state: Exp; lines: +62 -18<br />
Did lseek successfully in reading for offset less than 8.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.17<br />
date: 2013/07/16 10:18:27; author: taruna; state: Exp; lines: +34 -11<br />
Implemented lseek for offset less than 8.<br />
Gave this lseek in reading.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.16<br />
date: 2013/07/16 06:00:14; author: taruna; state: Exp; lines: +74 -19<br />
Declared the scull_lseek().<br />
And tracked the offset position in filep-&gt;f_pos where filep is a pointer to struct file.<br />
Printed the offset position.<br />
Did this in scull_read().<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.15<br />
date: 2013/07/15 04:58:39; author: taruna; state: Exp; lines: +101 -3<br />
Able to read upto the user defined no. of characters successfully.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
date: 2013/07/11 10:12:48; author: taruna; state: Exp; lines: +45 -15<br />
Implemented writing to multiple quantums of multiple qsets successfully.<br />
Calculated lnoq i.e, local no. of quantums for using in the inner loop so that it never runs for more than 8 bytes which is the size of one quantum.<br />
for moving to the next scullqset , preserved the size of bytes to be written in fnobtw and updated fnobtw and fnobsw.<br />
Also initialised nobsw to 0 after every completion of inner loop.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.13<br />
date: 2013/07/11 06:39:16; author: taruna; state: Exp; lines: +14 -8<br />
Implemented writing into multiple quantums using copy_from-user.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.12<br />
date: 2013/07/11 06:10:40; author: taruna; state: Exp; lines: +69 -5<br />
Implemented writing to quantums using copy_from_user() for 1 quantum.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.11<br />
date: 2013/07/09 10:18:35; author: taruna; state: Exp; lines: +53 -5<br />
Implemented creat_qset for any no. of qsets.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10<br />
date: 2013/07/09 07:34:31; author: taruna; state: Exp; lines: +26 -8<br />
Implemented the creat_scullqset() for any no. of scullqsets.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/09 07:18:51; author: taruna; state: Exp; lines: +59 -2<br />
Calculated the no. of scullqsets and no. of quantums.<br />
Implemented creat_scullqset for creating one scullqset.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/08 08:31:39; author: taruna; state: Exp; lines: +29 -0<br />
Mapped the read and write to scull_read and scull_write() respectively.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/08 07:32:41; author: taruna; state: Exp; lines: +20 -1<br />
Initialised opencount in the scull_init function.<br />
Declared the scull_trim().<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/04 06:51:22; author: taruna; state: Exp; lines: +42 -0<br />
Declared lsculldev in scull_open() , got a local device.<br />
Then got the cdev structure contained in ScullDev structure.<br />
Saved the lsculldev to preserve the device in private_data of struct file.</p>
<p>Checked the access mode and called the function scull_trim to trim the device.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/03 09:27:15; author: taruna; state: Exp; lines: +54 -2<br />
Wrote the functions : init_scull , scull_open and scull_release.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/03 07:43:05; author: taruna; state: Exp; lines: +35 -27<br />
Used loop to add nod no. of devices in scull_setup() function.<br />
Stored the major and minor number from alloc_chrdev_region in variable tmp using MKDEV and passed this tmp in unregister_chrdev_region in the cleanup function.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/03 06:56:13; author: taruna; state: Exp; lines: +51 -0<br />
Initialized the struct cdev through function scull_setup.<br />
Initializeed the owner , operations and dev of struct cdev.</p>
<p>used cdev_init and cdev_add in scull_setup function and cdev_del in the cleanup function.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/03 05:59:03; author: taruna; state: Exp; lines: +18 -2<br />
Allocated memory for struct Sculldev using kmalloc and freed that memory using kfree in cleanup function.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/03 05:35:59; author: taruna; state: Exp;<br />
Initial revision<br />
102,1 98%<br />
=============================================================================<br />
103,1 Bot</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/30-01-30-taruna-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Character Driver</title>
		<link>https://www.emblogic.com/blog/07/character-driver-14/</link>
		<comments>https://www.emblogic.com/blog/07/character-driver-14/#comments</comments>
		<pubDate>Mon, 15 Jul 2013 11:39:31 +0000</pubDate>
		<dc:creator><![CDATA[ashish.verma]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[pravjot sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6735</guid>
		<description><![CDATA[Done with write call RCS File head 1.8; access; symbols; locks; strict; comment @ * @; 1.8 date 2013.07.14.10.18.16; author Ashish; state Exp; branches; next 1.7; 1.7 date 2013.07.13.07.47.07; author Ashish; state Exp; branches; next 1.6; 1.6 date 2013.07.11.08.29.33; author &#8230; <a href="https://www.emblogic.com/blog/07/character-driver-14/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Done with write call</p>
<p>RCS File</p>
<p>head 1.8;<br />
access;<br />
symbols;<br />
locks; strict;<br />
comment @ * @;<br />
1.8<br />
date 2013.07.14.10.18.16; author Ashish; state Exp;<br />
branches;<br />
next 1.7;</p>
<p>1.7<br />
date 2013.07.13.07.47.07; author Ashish; state Exp;<br />
branches;<br />
next 1.6;</p>
<p>1.6<br />
date 2013.07.11.08.29.33; author Ashish; state Exp;<br />
branches;<br />
next 1.5;</p>
<p>1.5<br />
date 2013.07.11.05.31.28; author Ashish; state Exp;<br />
branches;<br />
next 1.4;</p>
<p>1.4<br />
date 2013.07.09.10.25.39; author Ashish; state Exp;<br />
branches;<br />
next 1.3;</p>
<p>1.3<br />
date 2013.07.09.10.15.33; author Ashish; state Exp;<br />
branches;<br />
next 1.2;</p>
<p>1.2<br />
date 2013.07.09.08.29.36; author Ashish; state Exp;<br />
branches;<br />
next 1.1;</p>
<p>1.1<br />
date 2013.07.08.09.52.37; author Ashish; state Exp;<br />
branches;<br />
next ;<br />
desc<br />
@Done with tri<br />
trim.<br />
@<br />
1.8<br />
log<br />
@Some modification with refrence to maximum no. of bytes written in a particular scull<br />
Write fn is already done.<br />
moving to read fn.<br />
@<br />
text<br />
@#include&#8221;header.h&#8221;</p>
<p>MODULE_LICENSE(&#8220;GPL&#8221;);<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;trim Fn&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//<br />
int scull_trim(struct Sculldev *fsculldev)<br />
{<br />
if(!fsculldev)<br />
{<br />
printk(KERN_ERR&#8221;Error:No Sculldev\n&#8221;);<br />
}<br />
printk(&#8220;No error &#8220;);<br />
return 0;<br />
}</p>
<p>//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-SCULL OPEN&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
int scull_open(struct inode *inodep,struct file *filep)<br />
{<br />
struct Sculldev *pdev;</p>
<p>printk(&#8220;\nScull open function start\n&#8221;);<br />
pdev=container_of(inodep-&gt;i_cdev,struct Sculldev,c_dev); //mapping RAM memory on Device:Sculldev<br />
filep-&gt;private_data=pdev; //preserving it on file as lsculldev is lost<br />
if((filep-&gt;f_flags &amp; O_ACCMODE)==O_WRONLY)<br />
{<br />
printk(KERN_ALERT &#8220;FILE OPEN &#8220;);<br />
scull_trim(pdev);<br />
}<br />
printk(&#8220;Scull open function complete\n&#8221;);<br />
return 0;<br />
}</p>
<p>//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;Scull realease&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
int scull_release(struct inode *node,struct file *filep)<br />
{</p>
<p>printk(&#8220;Scull release function start\n&#8221;);<br />
printk(&#8220;Scull release function complete\n&#8221;);<br />
return 0;<br />
}<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;Scull Write&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
ssize_t scull_write(struct file *filep,const char __user *ubuff,size_t size,loff_t *loff )<br />
{<br />
struct Sculldev *lsculldev;<br />
struct ScullQset *lscullqset;<br />
int lv,mnobps,nobpq,noq; //nobps=no.of bytes per scull //noq is no. of quantums required.<br />
int ret=noq=0;<br />
int ls=nobpq=mnobps=0; //no. of bytes per quantum<br />
int nobns=0; //no. if byte in next scull<br />
int nobtw=size; //no. of bytes to write<br />
int nobsw=0;int sno=1; //sno is scull no<br />
int nosqs=0; // no. of scull<br />
mnobps=quantum_size * qset_size; //maximum no. of byteis scull<br />
printk(&#8220;\nStarting %s&#8221;,__func__);<br />
lsculldev=filep-&gt;private_data;<br />
if(!lsculldev)<br />
{<br />
printk(KERN_ALERT &#8220;ERROR lsculldev Not declared \n &#8220;);<br />
}<br />
noq=size/quantum_size; //no of quantum<br />
if(size % quantum_size)<br />
{<br />
noq++;<br />
}<br />
printk(&#8220;no of Quantums are %d&#8221;,noq);</p>
<p>nosqs=size/(quantum_size * qset_size); //////this is no. of item required<br />
if(size%(quantum_size * qset_size))<br />
{<br />
nosqs++;<br />
}<br />
printk(&#8220;No of SQSET require is %d &#8220;,nosqs); //finding how much Qset requires<br />
lsculldev-&gt;scullqset=create_sqset(nosqs); //creating ScullQset in lsculldc which point to ScullQset<br />
lscullqset=lsculldev-&gt;scullqset; //passing whole ScullQset structure<br />
create_qset(lscullqset,nosqs); //passing whole Scullqset structure and no scull qset require<br />
create_quantum(lscullqset,noq);<br />
nobtw=size;<br />
printk(&#8220;\n NO of bytes per quantum is %d &#8220;,nobpq);</p>
<p>// ret=copy_from_user(lscullqset-&gt;data[lv],ubuff,size);<br />
//printk(&#8220;\n quantum no is and data : %s&#8221;,(char *)lscullqset-&gt;data[lv]);<br />
printk(&#8220;\n NO of bytes to write is %d &#8220;,nobtw);</p>
<p>while(nosqs!=0)<br />
{</p>
<p>if(nobtw&gt;mnobps)<br />
{<br />
nobns=nobtw-mnobps; //no. of byte to write in next shell<br />
nobtw=mnobps;<br />
ls=noq-quantum_size; //in ls we store no. of quantums want in next shell<br />
noq=quantum_size;<br />
}<br />
for(lv=0;lv&lt;noq;lv++)</p>
<p>{<br />
if(nobtw&gt;quantum_size)<br />
{<br />
nobpq=quantum_size;<br />
}<br />
else<br />
{<br />
nobpq=nobtw;<br />
}<br />
ret=copy_from_user(lscullqset-&gt;data[lv],ubuff+nobsw,nobpq);//writing 8 bytes in a quantum<br />
printk(&#8220;\nScull is %d quantum no is %d and data : %s&#8221;,sno,lv,(char *)lscullqset-&gt;data[lv]);<br />
nobsw=nobsw+(nobpq-ret); //no of Bytes Sucessfull Written<br />
nobtw=nobtw+(nobpq-ret);<br />
}<br />
noq=ls;<br />
nobtw=nobns;<br />
nosqs&#8211;;<br />
sno++;</p>
<p>}<br />
return size-ret ;</p>
<p>printk(&#8220;\nLO JI HOGAYA End %s&#8221;,__func__);</p>
<p>}<br />
//==========================Creating ScullQset==========================================================<br />
struct ScullQset *create_sqset(int fnosqs) //we use pointer here becaz it returns a an address &#8230;pointer<br />
{<br />
struct ScullQset *lscullqset;<br />
struct ScullQset *start;<br />
int flag=0;<br />
int lv;<br />
int count=0;<br />
printk(&#8220;\n WE ARE In CREATE SCullQSET &#8220;);</p>
<p>for(lv=0;lv&lt;fnosqs;lv++)<br />
{<br />
if(flag==0)<br />
{<br />
lscullqset=start=(struct ScullQset *)kmalloc(sizeof(struct ScullQset),GFP_KERNEL);//as in linklist we preserve first nodee and allocating memory to first node<br />
flag++;<br />
}<br />
else<br />
{<br />
lscullqset-&gt;next=(struct ScullQset *)kmalloc(sizeof(struct ScullQset ),GFP_KERNEL);<br />
lscullqset=lscullqset-&gt;next;<br />
}<br />
count++;<br />
}<br />
printk(&#8220;\nNo. of ScullQset created is %d&#8221;,count);<br />
return start;<br />
}</p>
<p>//===================================Creating Qset======================================&gt;&gt;&gt;&gt;&gt;&gt;.&gt;<br />
int create_qset(struct ScullQset *fscullqset,int fnosqs)<br />
{<br />
int lv;<br />
printk(&#8220;\n We are in %s\n&#8221;,__func__);<br />
for(lv=0;lv&lt;fnosqs;lv++) //it make qset in more than one scull<br />
{<br />
fscullqset-&gt;data=kmalloc(sizeof(int *)*qset_size,GFP_KERNEL); //allocating memory to the data pointer of qset data<br />
fscullqset=fscullqset-&gt;next; //pointing to next scullqset &#8230;<br />
}<br />
printk(&#8220;Success fully Ended %s&#8221;,__func__);<br />
return 0;<br />
}</p>
<p>//++++++++++++++++++++++++++++++Creating Quantum+++++++++++++++++++++++++++++++++++++++++++</p>
<p>int create_quantum(struct ScullQset *fscullqset,int fnoq)<br />
{<br />
int lv;int lnoq;int count=0;<br />
printk(&#8220;Enter in %s&#8221;,__func__);<br />
while(fscullqset!=NULL)<br />
{ if(fnoq&gt;quantum_size)<br />
lnoq=quantum_size;<br />
else<br />
lnoq=fnoq;<br />
for(lv=0;lv&lt;lnoq;lv++)<br />
{<br />
fscullqset-&gt;data[lv]=kmalloc(quantum_size,GFP_KERNEL); //we are allocating memory in qset ke data me of quantum_size<br />
count++; // no of quantum created<br />
// printk(KERN_ALERT&#8221;quantum number=%u&#8221;,&amp;fscullqset-&gt;data[lv]);<br />
}<br />
fnoq=fnoq-quantum_size;<br />
fscullqset=fscullqset-&gt;next;;<br />
}<br />
printk(&#8220;\n no of quantum created %d&#8221;,count);</p>
<p>printk(&#8220;\n Exiting from %s&#8221;,__func__);<br />
return 0;</p>
<p>}</p>
<p>&nbsp;</p>
<p>//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;Read Function&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
ssize_t scull_read(struct file *filep,char __user *ubuff,size_t size,loff_t *loff )<br />
{<br />
//int ret;<br />
printk(&#8220;\n Starting %s &#8220;,__func__);<br />
//ret=copy_from_user(lscullqset-&gt;data[],ubuff,size);<br />
printk(&#8220;\nEnd %s&#8221;,__func__);<br />
return 0;<br />
}</p>
<p>//=====================================Scull init========================================================<br />
void scull_init(void)<br />
{<br />
printk(&#8220;starting__func_\n&#8221;);<br />
sculldev-&gt;quantum_size=QUANTUM_SIZE;<br />
sculldev-&gt;qset_size=QSET_SIZE;<br />
sculldev-&gt;data_size=DATA_SIZE;<br />
sculldev-&gt;device_size=DEVICE_SIZE;<br />
printk(&#8220;Quantum Size is %d &#8220;,sculldev-&gt;quantum_size);<br />
printk(&#8220;\n %s&#8221;,__func__);<br />
}</p>
<p>//======================================start=======================================================<br />
static int start(void)<br />
{<br />
printk(KERN_ALERT &#8220;WELCOME TO DEVICE DRIVER\n&#8221;);<br />
if(!majorno)<br />
{<br />
ret = alloc_chrdev_region(&amp;dev, minorno, nod, DRIVER_NAME);<br />
if(ret==0)<br />
printk(KERN_ALERT &#8220;Registration done\n&#8221;);<br />
else<br />
printk(&#8220;Registration failure\n&#8221;);<br />
majorno = MAJOR(dev); //MAJOR Is A Micro to fetch Major no. stored in dev //DEV has major +minor no. =20 bit (major no 12 + minor no 20 )<br />
minorno = MINOR(dev);<br />
}<br />
printk(&#8220;Major number assigned is___ %d\n&#8221;,majorno);<br />
printk(&#8220;Minor number assigned is___ %d\n&#8221;,minorno);<br />
sculldev= kmalloc(sizeof(struct Sculldev) * nod, GFP_KERNEL);<br />
memset(sculldev, &#8221;,sizeof(sculldev)*nod);<br />
dev=MKDEV(majorno,minorno);<br />
cdev_init(&amp;sculldev-&gt;c_dev, &amp;fop);<br />
sculldev-&gt;c_dev.owner=THIS_MODULE; //we goto c_dev owner through sculldec<br />
sculldev-&gt;c_dev.ops=&amp;fop;<br />
sculldev-&gt;c_dev.count=nod;<br />
cdev_add(&amp;sculldev-&gt;c_dev, dev, nod); //c_dev main dev ka add<br />
minorno = MAJOR(sculldev-&gt;c_dev.dev);<br />
majorno = MINOR(sculldev-&gt;c_dev.dev);<br />
printk(&#8220;SEC MINOR value____ %d\n&#8221;,minorno);<br />
printk(&#8220;SEC MAJOR value____ %d\n&#8221;,majorno);<br />
scull_init();<br />
printk(KERN_ALERT &#8220;Ho gaya Ji&#8221;);<br />
return 0;<br />
}<br />
//=====================================Exit===================================================<br />
static void end(void)<br />
{<br />
printk(KERN_ALERT &#8220;bye\n&#8221;);<br />
unregister_chrdev_region(dev, nod);<br />
printk(&#8220;Unregistration done\n&#8221;);<br />
}</p>
<p>module_init(start);<br />
module_exit(end);<br />
@<br />
1.7<br />
log<br />
@Completed Writing in diffrent Quantums as well as in diffrent Scullqset<br />
@<br />
text<br />
@d47 8<br />
a54 9<br />
int noq=0;int nobw=0; //nobw =no. of bytes wrriten<br />
int ret=0;<br />
int lv,ls; //noq is no. of quantums required.<br />
int nobpq=0;<br />
int nobns=0; //no. if byte in next scull<br />
int nobtw=size;<br />
int nobsw=0;int sno=1; //sno is scull no</p>
<p>int nosqs=0; // no. of scull<br />
d88 1<br />
a88 1<br />
if(nobtw&gt;64)<br />
d90 3<br />
a92 5<br />
nobns=nobtw-64; //no. of byte to write in next shell<br />
nobtw=64;<br />
// printk(&#8220;\n no. of byte to write in first shell : %d&#8221;,nobtw);<br />
// printk(&#8220;\n no. of byte to write in first shell : %d&#8221;,nobtw);<br />
ls=noq-quantum_size;<br />
d96 1<br />
a96 1<br />
// ret=copy_from_user(scullqset-&gt;data[lv],ubuff+nobsw,nobpq); //for writing everytjing in a single quantum<br />
d99 2<br />
a100 1<br />
{ nobpq=quantum_size;<br />
d107 2<br />
a108 2<br />
printk(&#8220;\nScull is %d quantum no is %d and data : %s&#8221;,sno,lv,(char *)lscullqset-&gt;data[lv]);<br />
nobsw=nobsw+(nobpq-ret);<br />
d111 3<br />
a113 5</p>
<p>// printk(&#8220;\n no. of byte to write in next shell : %d&#8221;,nobns);<br />
noq=ls;<br />
nobtw=nobns;<br />
nosqs&#8211;;<br />
@<br />
1.6<br />
log<br />
@maked Qset<br />
@<br />
text<br />
@d47 9<br />
a55 3<br />
int noq=0;<br />
// int ret; //noq is no. of quantums required.<br />
int nosqs=0; // no. of scull<br />
d77 47<br />
a123 1<br />
create_qset(lscullqset,nosqs); //passing whole Scullqset structure and no scull qset require<br />
d125 1<br />
a125 3<br />
printk(&#8220;\nLO JI HOGAYA End %s&#8221;,__func__);<br />
return 0;<br />
}<br />
d129 1<br />
a129 1<br />
struct ScullQset *lsculldev;<br />
d132 2<br />
d135 4<br />
a138 1<br />
if(flag==0)<br />
d140 1<br />
a140 1<br />
lsculldev=start=(struct ScullQset *)kmalloc(sizeof(struct ScullQset *),GFP_KERNEL);//as in linklist we preserve first nodee and allocating memory to first node<br />
d144 3<br />
a146 3<br />
{<br />
lsculldev-&gt;next=(struct ScullQset *)kmalloc(sizeof(struct ScullQset *),GFP_KERNEL);<br />
lsculldev=lsculldev-&gt;next;<br />
d148 3<br />
d159 1<br />
a159 1<br />
for(lv=0;lv&lt;fnosqs;lv++)<br />
d162 1<br />
a162 1<br />
fscullqset=fscullqset-&gt;next;<br />
d168 29<br />
d203 1<br />
a203 10</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;<br />
printk(&#8220;\nEnd %s&#8221;,__func__);<br />
@<br />
1.5<br />
log<br />
@done with finding quantum size<br />
\.<br />
@<br />
text<br />
@d4 1<br />
a4 1</p>
<p>d15 1<br />
a15 1</p>
<p>d32 1<br />
d42 1<br />
a42 1</p>
<p>d46 3<br />
a48 1<br />
int noq=0; //noq is no. of quantums required.<br />
d68 4<br />
a71 3</p>
<p>lsculldev-&gt;scullqset=create_sqset(nosqs);</p>
<p>d73 1<br />
a73 1<br />
printk(&#8220;\nLO JI HOGAYA End %s&#8221;,__func__);<br />
d76 19<br />
d96 2<br />
a97 1<br />
struct ScullQset *create_sqset(int fnosqs) //we use pointer here becaz it returns a an address &#8230;pointer<br />
d99 19<br />
a117 2<br />
struct ScullQset *lsculldev;<br />
struct ScullQset *start;<br />
a118 1<br />
int flag=0;<br />
a119 1<br />
printk(&#8220;\n WE ARE In CREATE SQSET &#8220;);<br />
a121 10<br />
if(flag==0)<br />
{<br />
lsculldev=start=(struct ScullQset *)kmalloc(sizeof(struct ScullQset *),GFP_KERNEL);<br />
return start;<br />
}<br />
else<br />
{<br />
lsculldev=(struct ScullQset *)kmalloc(sizeof(struct ScullQset *),GFP_KERNEL);<br />
return lsculldev;<br />
}<br />
a123 1<br />
}<br />
a124 3<br />
ssize_t scull_read(struct file *filep,char __user *ubuff,size_t size,loff_t *loff )<br />
{<br />
printk(&#8220;\n Starting %s &#8220;,__func__);<br />
d129 1<br />
d140 2<br />
d173 1<br />
a173 1</p>
<p>@<br />
1.4<br />
log<br />
@in write define lsculldev<br />
@<br />
text<br />
@d45 2<br />
d53 17<br />
a69 1<br />
printk(&#8220;\nEnd %s&#8221;,__func__);<br />
d72 24<br />
@<br />
1.3<br />
log<br />
@finally witth trim<br />
@<br />
text<br />
@d44 8<br />
a51 2<br />
printk(&#8220;\nStarting %s&#8221;,__func__);<br />
printk(&#8220;\nEnd %s&#8221;,__func__);<br />
@<br />
1.2<br />
log<br />
@./<br />
/<br />
@<br />
text<br />
@d7 3<br />
a9 3<br />
if(!fsculldev)<br />
{<br />
printk(KERN_ERR&#8221;Error:No Sculldev\n&#8221;);<br />
d11 1<br />
d18 10<br />
a27 13<br />
// struct Sculldev *lsculldev;</p>
<p>printk(&#8220;\nScull open function start\n&#8221;);<br />
// container_of(inodep-&gt;i_cdev,struct Sculldev,c_dev); //mapping RAM memory on Device:Sculldev<br />
// filep-&gt;private_data=lsculldev; //preserving it on file as lsculldev is lost<br />
// if((filep-&gt;f_flags &amp;&amp; O_ACCMODE)==O_WRONLY)<br />
// {<br />
// printk(KERN_ALERT &#8220;FILE OPEN &#8220;);<br />
// scull_trim(lsculldev);<br />
// }</p>
<p>&nbsp;</p>
<p>d45 1<br />
d52 1<br />
d68 5<br />
a72 6<br />
printk(KERN_ALERT &#8220;WELCOME TO DEVICE DRIVER\n&#8221;);</p>
<p>if(!majorno)<br />
{<br />
ret = alloc_chrdev_region(&amp;dev, minorno, nod, DRIVER_NAME);<br />
if(ret==0)<br />
d79 2<br />
a80 9<br />
// else if(majorno==0)<br />
// {<br />
// dev=MKDEV(majorno,minorno+1);<br />
// ret=register_chrdev_region(dev,nod,DRIVER_NAME);<br />
// }</p>
<p>printk(&#8220;Major number assigned is___ %d\n&#8221;,majorno);<br />
printk(&#8220;Minor number assigned is___ %d\n&#8221;,minorno);</p>
<p>a82 1</p>
<p>d85 1<br />
a85 1<br />
sculldev-&gt;c_dev.owner=&#8221;Ashish&#8221;; //we goto c_dev owner through sculldec<br />
a92 1</p>
<p>a94 17</p>
<p>//scull_open();</p>
<p>/* dev= MKDEV(majorno,i);<br />
cdev_init(&amp;sculldev-&gt;c_dev, &amp;fop);<br />
sculldev-&gt;c_dev.owner=&#8221;Ashish&#8221;; //we goto c_dev owner through sculldec<br />
sculldev-&gt;c_dev.ops=&amp;fop;<br />
sculldev-&gt;c_dev.count=nod;<br />
cdev_add(&amp;sculldev-&gt;c_dev, dev, nod); //c_dev main dev ka add<br />
majorno = MAJOR(sculldev-&gt;c_dev.dev);<br />
minorno = MINOR(sculldev-&gt;c_dev.dev);</p>
<p>printk(&#8221; MAJOR value____ %d\n&#8221;,majorno);<br />
printk(&#8221; MINOR value____ %d\n&#8221;,minorno);<br />
*/<br />
a97 1</p>
<p>a100 2</p>
<p>a101 1</p>
<p>@<br />
1.1<br />
log<br />
@Initial revision<br />
@<br />
text<br />
@d17 1<br />
a17 1<br />
struct Sculldev *lsculldev;<br />
d20 7<br />
a26 7<br />
container_of(inodep-&gt;i_cdev,struct Sculldev,c_dev); //mapping RAM memory on Device:Sculldev<br />
filep-&gt;private_data=lsculldev; //preserving it on file as lsculldev is lost<br />
if((filep-&gt;f_flags &amp;&amp; O_ACCMODE)==O_WRONLY)<br />
{<br />
printk(KERN_ALERT &#8220;FILE OPEN &#8220;);<br />
scull_trim(lsculldev);<br />
}<br />
@</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/character-driver-14/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Character Driver</title>
		<link>https://www.emblogic.com/blog/07/character-driver-11/</link>
		<comments>https://www.emblogic.com/blog/07/character-driver-11/#comments</comments>
		<pubDate>Thu, 11 Jul 2013 09:36:57 +0000</pubDate>
		<dc:creator><![CDATA[Om Parkash]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[pravjot sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6697</guid>
		<description><![CDATA[RCS file: chard.c,v Working file: chard.c head: 1.5 branch: locks: strict access list: symbolic names: keyword substitution: kv total revisions: 5;     selected revisions: 5 description: registered and unregistered devices using alloc_chrdev_region and unregis_chrdev_region. implemented scull_setup function. implemented scull_open routine. started &#8230; <a href="https://www.emblogic.com/blog/07/character-driver-11/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>RCS file: chard.c,v<br />
Working file: chard.c<br />
head: 1.5<br />
branch:<br />
locks: strict<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 5;     selected revisions: 5<br />
description:<br />
registered and unregistered devices using alloc_chrdev_region and unregis_chrdev_region.<br />
implemented scull_setup function.<br />
implemented scull_open routine.<br />
started scull_trim,scull_release,scull_write and scull_read routines.<br />
working well till now.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/11 08:48:05;  author: emblogic;  state: Exp;  lines: +19 -47<br />
implemented read and write successfully for any no. of bytes.<br />
checked for upto 1000 bytes .successfully written to scull Quantums and read from the quantums as well.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/10 11:43:39;  author: emblogic;  state: Exp;  lines: +89 -8<br />
read successfully .<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/10 06:02:17;  author: emblogic;  state: Exp;  lines: +58 -4<br />
written to scull successfully using write2scull function.<br />
working well.<br />
but printing garbage due to absence of NULL.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/09 12:03:54;  author: emblogic;  state: Exp;  lines: +170 -5<br />
implemented creat_scullqset,creat_qset and creat_quantums&#8230;.aloocated memory to write to scull.<br />
quantums created successfully .<br />
working well till now.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/08 11:03:54;  author: emblogic;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/character-driver-11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ranjeet Singh</title>
		<link>https://www.emblogic.com/blog/07/ranjeet-singh-4/</link>
		<comments>https://www.emblogic.com/blog/07/ranjeet-singh-4/#comments</comments>
		<pubDate>Mon, 08 Jul 2013 12:32:24 +0000</pubDate>
		<dc:creator><![CDATA[pratap.ashish]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[pravjot sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6683</guid>
		<description><![CDATA[RCS file: header2.h,v Working file: header2.h head: 1.9 branch: locks: strict access list: symbolic names: keyword substitution: kv total revisions: 9; selected revisions: 9 description: This is the header file for loadable kernel module. &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- revision 1.9 date: 2013/07/09 18:01:36; &#8230; <a href="https://www.emblogic.com/blog/07/ranjeet-singh-4/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>RCS file: header2.h,v<br />
Working file: header2.h<br />
head: 1.9<br />
branch:<br />
locks: strict<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 9;	selected revisions: 9<br />
description:<br />
This is the header file for loadable kernel module.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/09 18:01:36;  author: root;  state: Exp;  lines: +1 -0<br />
gave prototype to scull_trim function.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/04 11:43:22;  author: root;  state: Exp;  lines: +10 -1<br />
declare functions &#8220;scull_open&#8221; and &#8220;scull_release&#8221;.<br />
gave two file operations in struct fileoperations.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/04 07:53:59;  author: root;  state: Exp;  lines: +3 -0<br />
Gave prototype to functions &#8220;scull_dev&#8221; and &#8220;cdevinit&#8221;.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/03 06:53:31;  author: root;  state: Exp;  lines: +1 -0<br />
include linux/moduleparam.h.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/03 06:35:46;  author: root;  state: Exp;  lines: +20 -0<br />
declare variables in the data structure &#8220;struct ScullDev&#8221;: qset_size, quantum_size, data size, device_size.<br />
Also define Macros:QSET_SIZE, QUANTUM_SIZE, DATA_SIZE, DEVICE_SIZE and initialize them.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/02 11:31:50;  author: root;  state: Exp;  lines: +2 -0<br />
add data structure &#8220;struct file_operations fops&#8221;.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/02 10:49:46;  author: root;  state: Exp;  lines: +13 -0<br />
added header files :cdev.h , slab.h<br />
define data structure &#8220;struct ScullDev&#8221; and also define pointer to that structure.<br />
also define data structure &#8220;struct scullQset&#8221;.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/02 09:38:19;  author: root;  state: Exp;  lines: +14 -1<br />
adding header file fs.h.<br />
define macros DEV_NAME as device name, MAJORNO as major number, MINORNO as minor number for device.<br />
define variables : dev, majorno for MAJORNO, minorno for MINORNO, nod for NOD.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/02 07:30:51;  author: root;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/ranjeet-singh-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
