<?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; prabjot</title>
	<atom:link href="https://www.emblogic.com/blog/tag/prabjot/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>character driver</title>
		<link>https://www.emblogic.com/blog/09/character-driver-12/</link>
		<comments>https://www.emblogic.com/blog/09/character-driver-12/#comments</comments>
		<pubDate>Fri, 27 Sep 2013 18:59:10 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[jasmeen]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7199</guid>
		<description><![CDATA[i have done timer with wait_event_interruptible successfully&#8230;&#8230;]]></description>
				<content:encoded><![CDATA[<p>i have done timer with wait_event_interruptible successfully&#8230;&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/09/character-driver-12/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Charecter Driver logfile</title>
		<link>https://www.emblogic.com/blog/08/charecter-driver-logfile-2/</link>
		<comments>https://www.emblogic.com/blog/08/charecter-driver-logfile-2/#comments</comments>
		<pubDate>Wed, 07 Aug 2013 12:23:45 +0000</pubDate>
		<dc:creator><![CDATA[sampath.kumar]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6983</guid>
		<description><![CDATA[revision 1.33 locked by: sampath; date: 2013/08/07 12:03:17; author: sampath; state: Exp; lines: +120 -12 Timers Implementation calculted number of jiffies for char driver operation, used macro time_after to compare jiffie values converted jiffies to seconds and nanoseconds using jiffies_to_timespec &#8230; <a href="https://www.emblogic.com/blog/08/charecter-driver-logfile-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>revision 1.33 locked by: sampath;<br />
date: 2013/08/07 12:03:17; author: sampath; state: Exp; lines: +120 -12<br />
Timers Implementation<br />
calculted number of jiffies for char driver operation, used macro time_after to compare jiffie values<br />
converted jiffies to seconds and nanoseconds using jiffies_to_timespec<br />
calculated TSC(cycles since reset) using rdtscl and caculated number of cycles for the char drive operation, also tested using get_cycles<br />
Implemented wallclock time using do_gettimeofday and time_to_tm, created a proc entry by name cureenttime<br />
Implemented a /proc entry for incorporating delay using cpu_relax and schedule by names jitbusy and jitsched respectively<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/08/charecter-driver-logfile-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CHARACTER DRIVER LOGFILE</title>
		<link>https://www.emblogic.com/blog/08/character-driver-logfile-2/</link>
		<comments>https://www.emblogic.com/blog/08/character-driver-logfile-2/#comments</comments>
		<pubDate>Thu, 01 Aug 2013 13:53:59 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6952</guid>
		<description><![CDATA[RCS file: app11.c,v Working file: app11.c head: 1.2 branch: locks: strict amitdalal: 1.2 access list: symbolic names: keyword substitution: kv total revisions: 2; selected revisions: 2 description: define set_sem_val function define semaphore_p and semaphore_v done this for all 5 applicatin &#8230; <a href="https://www.emblogic.com/blog/08/character-driver-logfile-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>RCS file: app11.c,v<br />
Working file: app11.c<br />
head: 1.2<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.2<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 2;	selected revisions: 2<br />
description:<br />
define set_sem_val function<br />
define semaphore_p and semaphore_v<br />
done this for all 5 applicatin<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2	locked by: amitdalal;<br />
date: 2013/08/01 01:05:28;  author: amitdalal;  state: Exp;  lines: +29 -1<br />
include some variable<br />
use cmd for resetting all the parameter<br />
use cmd for setting newquantum no.<br />
include header file<br />
use cmd for setting qset no.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/25 23:29:38;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: amit.c,v<br />
Working file: amit.c<br />
head: 1.21<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.21<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 21;	selected revisions: 21<br />
description:<br />
added function of copy from user<br />
printk the no of byte writen successfully for one quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.21	locked by: amitdalal;<br />
date: 2013/08/01 00:53:49;  author: amitdalal;  state: Exp;  lines: +71 -5<br />
define function for ioctl to control the operation<br />
use cmd SCULL_IOCRESET,SCULL_IOCSQUANTUM,SCULL_IOCQSET,SCULL_IOCDATA,SCULL_IOCDEVICE<br />
USE capability cmd for cheking capability<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.20<br />
date: 2013/07/28 00:07:05;  author: amitdalal;  state: Exp;  lines: +21 -7<br />
create proc_read_entry function inside sculldev loop<br />
define read_proc out side the sculldev  loop<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.19<br />
date: 2013/07/26 19:26:10;  author: amitdalal;  state: Exp;  lines: +4 -3<br />
use spin_lock_irq before raeding<br />
use spin_unlock_irq func. at the end off writing<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.18<br />
date: 2013/07/26 00:33:49;  author: amitdalal;  state: Exp;  lines: +9 -19<br />
use wait_for_complition in read<br />
use complete_all in write<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.17<br />
date: 2013/07/25 23:23:36;  author: amitdalal;  state: Exp;  lines: +9 -8<br />
initialise sem_init again<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.16<br />
date: 2013/07/25 23:02:12;  author: amitdalal;  state: Exp;  lines: +33 -11<br />
initialise two semaphore for read and write in sculldev initialisation<br />
down semaphore in write for write<br />
at the end up semaphore for read<br />
down semaphore in write for read<br />
at the end up semaphore for write<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.15<br />
date: 2013/07/22 22:47:17;  author: amitdalal;  state: Exp;  lines: +5 -5<br />
initialise the semaphore init in scull_open for kernel level synchronisation<br />
call down_interruptible in open<br />
call up in release function<br />
define trim function<br />
calculate nosqs and noq agin in trim function<br />
memset the quantum_size<br />
to free all quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.14<br />
date: 2013/07/22 22:07:46;  author: amitdalal;  state: Exp;  lines: +102 -40<br />
define fpos variable for  fetching file position in read<br />
add fpos to count to calculate the nosqs and noq<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.13<br />
date: 2013/07/17 00:08:24;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
added some variable for write using llseek<br />
added bpos for position update in copy from user<br />
define bpos flag<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.12<br />
date: 2013/07/17 00:07:11;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
added variable bpos for position<br />
use flag and j<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.11<br />
date: 2013/07/17 00:02:29;  author: amitdalal;  state: Exp;  lines: +0 -2<br />
added some variable for reading using llseek<br />
fix the problem related with left out of some first character<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10<br />
date: 2013/07/16 23:37:14;  author: amitdalal;  state: Exp;  lines: +244 -194<br />
give call to llseek<br />
define function llseek<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/15 21:52:06;  author: amitdalal;  state: Exp;  lines: +67 -41<br />
added loff_t function to .c file<br />
use f_pos for storing the value of pos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/11 17:37:19;  author: amitdalal;  state: Exp;  lines: +53 -38<br />
modified code for write to get required no of qset<br />
add lnoq variable<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/11 06:05:24;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
add loop variable in loop for reading<br />
remove some bug in reading loop<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/11 05:37:03;  author: amitdalal;  state: Exp;  lines: +4 -4<br />
remove some bug from write function<br />
added loop variable to specify no of quantum in 2nd qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/11 05:18:10;  author: amitdalal;  state: Exp;  lines: +76 -16<br />
creating read function<br />
use copy to user function<br />
modifing the copy to user function<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/11 00:41:53;  author: amitdalal;  state: Exp;  lines: +1 -0<br />
debbuging problem causing kernel crash<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/11 00:19:58;  author: amitdalal;  state: Exp;  lines: +11 -7<br />
added variable loop<br />
use while loop for creating multiple qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:00:36;  author: amitdalal;  state: Exp;  lines: +25 -4<br />
added the function of quantum written for 8 byte<br />
debugging the problem related to writting of data not 8 byte<br />
fix problem successfully related to written<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:22:34;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: header.h,v<br />
Working file: header.h<br />
head: 1.10<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.10<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 10;	selected revisions: 10<br />
description:<br />
added asm header .h for copy from user<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10	locked by: amitdalal;<br />
date: 2013/08/01 00:59:39;  author: amitdalal;  state: Exp;  lines: +9 -3<br />
include prototype of ioctl<br />
define ioctl in the file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/28 00:09:43;  author: amitdalal;  state: Exp;  lines: +1 -0<br />
include header file for proc<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/26 19:29:27;  author: amitdalal;  state: Exp;  lines: +3 -1<br />
initialise spinlock_t my_lock in header file<br />
./<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/26 00:38:59;  author: amitdalal;  state: Exp;  lines: +3 -3<br />
define macro for complition in header.h<br />
another way is to define the complition in sculldev<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/25 23:25:01;  author: amitdalal;  state: Exp;  lines: +9 -3<br />
include struct semaphore rsem and wsem in sculldev<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/22 22:12:52;  author: amitdalal;  state: Exp;  lines: +3 -1<br />
defined header file for semaphore in kernel level<br />
define semaphore in Sculldev structure<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/16 23:38:48;  author: amitdalal;  state: Exp;  lines: +7 -7<br />
include prototype of llseek<br />
define llseek in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:53:32;  author: amitdalal;  state: Exp;  lines: +5 -2<br />
give prototype of llseek<br />
define it in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 17:39:26;  author: amitdalal;  state: Exp;  lines: +5 -5<br />
remove init and cleanup prototype<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:25:25;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: ioctlheader.h,v<br />
Working file: ioctlheader.h<br />
head: 1.1<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.1<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 1;	selected revisions: 1<br />
description:<br />
include all the macro for reseting,setting quantum no.<br />
macro for setting qset no.<br />
macro for setting data no.<br />
macro for setting device no.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1	locked by: amitdalal;<br />
date: 2013/08/01 01:01:24;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: ioctlheader.h,v<br />
Working file: ioctlheader.h<br />
head: 1.1<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.1<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 1;	selected revisions: 1<br />
description:<br />
include all the macro for reseting,setting quantum no.<br />
macro for setting qset no.<br />
macro for setting data no.<br />
macro for setting device no.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1	locked by: amitdalal;<br />
date: 2013/08/01 01:01:24;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/08/character-driver-logfile-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Charecter Driver logfile</title>
		<link>https://www.emblogic.com/blog/07/charecter-driver-logfile/</link>
		<comments>https://www.emblogic.com/blog/07/charecter-driver-logfile/#comments</comments>
		<pubDate>Wed, 31 Jul 2013 13:53:39 +0000</pubDate>
		<dc:creator><![CDATA[sampath.kumar]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6949</guid>
		<description><![CDATA[RCS file: ./basicregister.c,v Working file: basicregister.c head: 1.32 branch: locks: strict sampath: 1.22 sampath: 1.32 access list: symbolic names: keyword substitution: kv total revisions: 32; selected revisions: 32 description: Base program for driver Registering the driver into the kernel using &#8230; <a href="https://www.emblogic.com/blog/07/charecter-driver-logfile/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>RCS file: ./basicregister.c,v<br />
Working file: basicregister.c<br />
head: 1.32<br />
branch:<br />
locks: strict<br />
sampath: 1.22<br />
sampath: 1.32<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 32; selected revisions: 32<br />
description:<br />
Base program for driver<br />
Registering the driver into the kernel using register_chrdev<br />
inserting the module using insmod<br />
unregistering using unregister_chrdev<br />
removing the module using rmmod<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.32 locked by: sampath;<br />
date: 2013/07/31 13:23:52; author: sampath; state: Exp; lines: +84 -22<br />
Implementation of IOCTL<br />
Able to map ioctl call mapping done through file_operations<br />
calling IOCTL from application for reseting the values using SCULL_IOC_RESET<br />
Able to reset to initial values<br />
calling IOCTL call from application for changing the quantum size using SCULL_IOC_SQUANTUM<br />
Able to chage quantum value and further write and read operations are performed accordind to the new quantum size<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.31<br />
date: 2013/07/28 12:22:25; author: sampath; state: Exp; lines: +43 -2<br />
Implementation of proc<br />
calling create_proc_read_entry<br />
mapping function which contain sculldev Information device name,major number allocated,quantum size, qset size, no of bytes written and read by application<br />
Able to access from proc directory<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.30<br />
date: 2013/07/28 06:42:14; author: sampath; state: Exp; lines: +16 -3<br />
Implementation of spinlock for synchronization<br />
initialized spin_lock_init and locking using spin_lock in open<br />
unlocking at the end of read using spin_unlock<br />
Also tested synchronization using spin_lock_irq and spin_unlock_irq<br />
spin_lock_irqsave and spin_lock_irqrestore<br />
synchronizing using spinlock and completion<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.29<br />
date: 2013/07/27 19:26:57; author: sampath; state: Exp; lines: +16 -8<br />
Initialized sema_init and init_completion in open within if condition if(opened in write only mode) as the application level has calling open twice once in write and second in read only mode<br />
removed declaring sem_post in close and declared at the end of read so as to allow another application to open afetr first application complete reading operation<br />
note: care should be taken as open and close are called twice from same application<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.28<br />
date: 2013/07/25 06:49:48; author: sampath; state: Exp; lines: +14 -6<br />
Implemented completion<br />
declared init_completion in open<br />
wait_for_completion in read<br />
completion in write<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.27<br />
date: 2013/07/24 15:45:58; author: sampath; state: Exp; lines: +51 -10<br />
Corrected memory allocation error for scull_Qset<br />
Initialised scull_dev[lv]-&gt;scull_Qset=NULL for all lv values<br />
Able to perform trimming operation correctly<br />
Implementation of sema_init is done<br />
Able to synchronize correctly for multi applications<br />
Tested for 3 applications<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.26<br />
date: 2013/07/22 14:05:23; author: sampath; state: Exp; lines: +7 -1<br />
done with implementation of semaphores sema_init<br />
using down and up<br />
able to synchronize correctly tested running 3 applications at once<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.25<br />
date: 2013/07/22 12:27:19; author: sampath; state: Exp; lines: +76 -8<br />
Scull trim Implementation done if application opens in write only mode<br />
sucessfully trimming required no of quantum upto required no of bytes<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.24<br />
date: 2013/07/19 07:23:36; author: sampath; state: Exp; lines: +35 -75<br />
Sucessfully tested driver using 3 multithreaded application one at a time<br />
Able to write and read data sucessfully<br />
Trying to synchronize multiple application running at ones<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.23<br />
date: 2013/07/17 05:19:21; author: sampath; state: Exp; lines: +75 -28<br />
Defined llseek function mapped from function call<br />
Able to read data from application according to lseek offset in application<br />
done with read operation using lseek<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.22 locked by: sampath;<br />
date: 2013/07/13 11:04:51; author: sampath; state: Exp; lines: +15 -54<br />
done with read and write operations for multiple scullqsets<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.21<br />
date: 2013/07/13 10:43:24; author: sampath; state: Exp; lines: +1 -1<br />
added ubuff+tnobsr in copy_to_user for cursor position<br />
able to read data at the application<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.20<br />
date: 2013/07/13 10:17:59; author: sampath; state: Exp; lines: +35 -26<br />
sucessfully Implemented reading operation for 98 bytes of data<br />
able to read tnobsr in application<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.19<br />
date: 2013/07/13 07:17:49; author: sampath; state: Exp; lines: +20 -13<br />
new<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.18<br />
date: 2013/07/13 04:52:08; author: sampath; state: Exp; lines: +49 -36<br />
Able to read 63 bytes of data from kernel to user buffer.<br />
verification done by returning tnobsr to user application.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.17<br />
date: 2013/07/12 08:12:41; author: sampath; state: Exp; lines: +80 -11<br />
Implemented read operation trying to read from kernel to user buffer using copy_to_user<br />
Able to read only 8bytes of data<br />
tryin g to implement for complete read operation for reading 100bytes<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.16<br />
date: 2013/07/11 20:56:23; author: sampath; state: Exp; lines: +5 -10<br />
Able to return 0 from read operation of kernel buffer to application<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.15<br />
date: 2013/07/11 20:10:35; author: sampath; state: Exp; lines: +34 -25<br />
Sucessfully implemented for multiple qsets<br />
Tested writing operation for 100 bytes of data<br />
no of scull qset are 2 and no of quantums created are 13<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.14<br />
date: 2013/07/11 11:12:47; author: sampath; state: Exp; lines: +33 -10<br />
sucessfully implemented write operation for multiple quantums<br />
able to automate correct no of quantums<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.13<br />
date: 2013/07/11 07:57:21; author: sampath; state: Exp; lines: +24 -7<br />
Sucessfully implemented write operation<br />
using kernel facility copy_from_user<br />
testing for only 4bytes of data for which one quantum is enough<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.12<br />
date: 2013/07/10 11:43:26; author: sampath; state: Exp; lines: +75 -21<br />
Implementation of scullqset, qset and quantum done<br />
automated number of scullqsets and quantums wrt the application<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.11<br />
date: 2013/07/10 03:53:40; author: sampath; state: Exp; lines: +120 -34<br />
Implemeenting write operation<br />
fetched private-&gt;data to sculldev<br />
Implemented auto calculation for number of scull_qset and number of quantums<br />
allocated memory for scull_qset qset and quantum calling their functions separately and trying to link them<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10<br />
date: 2013/07/09 07:28:58; author: sampath; state: Exp; lines: +22 -0<br />
Implemented basic write and read operations<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/08 07:27:12; author: sampath; state: Exp; lines: +39 -41<br />
Implementation of scull_trim for future use<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/05 04:53:38; author: sampath; state: Exp; lines: +1 -1<br />
Initialised cdev_del after completing the usage of cdev<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/05 04:51:02; author: sampath; state: Exp; lines: +9 -8<br />
Added ret_cdev to check the return value of cdev_add<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/04 13:07:35; author: sampath; state: Exp; lines: +17 -7<br />
Initialising multiple devices<br />
assining dev using MKDEV<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/04 11:03:31; author: sampath; state: Exp; lines: +23 -10<br />
memory mapping through container_of<br />
pointing scull through inode<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/03 10:49:38; author: sampath; state: Exp; lines: +19 -2<br />
Assigning values to members of sculldev in scullinit and printing<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/02 13:40:19; author: sampath; state: Exp; lines: +17 -2<br />
Initialised function for scull_open<br />
and scull close<br />
calling open function from application<br />
communicating from user spaceapplication to kernelspace driver<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/02 10:34:24; author: sampath; state: Exp; lines: +44 -4<br />
Implemented struct scull<br />
registering the device in device table<br />
Initialized cdev_init<br />
pointing to dev through cdev<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/01 07:16:06; author: sampath; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/charecter-driver-logfile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CHARACTER DRIVER</title>
		<link>https://www.emblogic.com/blog/07/character-driver-18/</link>
		<comments>https://www.emblogic.com/blog/07/character-driver-18/#comments</comments>
		<pubDate>Sun, 28 Jul 2013 13:04:06 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6946</guid>
		<description><![CDATA[successfully done proc implimentation&#8230;.. RCS file: amit.c,v Working file: amit.c head: 1.20 branch: locks: strict amitdalal: 1.20 access list: symbolic names: keyword substitution: kv total revisions: 20; selected revisions: 20 description: added function of copy from user printk the no &#8230; <a href="https://www.emblogic.com/blog/07/character-driver-18/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>successfully done proc implimentation&#8230;..</p>
<p>RCS file: amit.c,v<br />
Working file: amit.c<br />
head: 1.20<br />
branch:<br />
locks: strict<br />
amitdalal: 1.20<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 20; selected revisions: 20<br />
description:<br />
added function of copy from user<br />
printk the no of byte writen successfully for one quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.20 locked by: amitdalal;<br />
date: 2013/07/28 00:07:05; author: amitdalal; state: Exp; lines: +21 -7<br />
create proc_read_entry function inside sculldev loop<br />
define read_proc out side the sculldev loop<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.19<br />
date: 2013/07/26 19:26:10; author: amitdalal; state: Exp; lines: +4 -3<br />
use spin_lock_irq before raeding<br />
use spin_unlock_irq func. at the end off writing<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.18<br />
date: 2013/07/26 00:33:49; author: amitdalal; state: Exp; lines: +9 -19<br />
use wait_for_complition in read<br />
use complete_all in write<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.17<br />
date: 2013/07/25 23:23:36; author: amitdalal; state: Exp; lines: +9 -8<br />
initialise sem_init again<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.16<br />
date: 2013/07/25 23:02:12; author: amitdalal; state: Exp; lines: +33 -11<br />
initialise two semaphore for read and write in sculldev initialisation<br />
down semaphore in write for write<br />
at the end up semaphore for read<br />
down semaphore in write for read<br />
at the end up semaphore for write<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.15<br />
date: 2013/07/22 22:47:17; author: amitdalal; state: Exp; lines: +5 -5<br />
initialise the semaphore init in scull_open for kernel level synchronisation<br />
call down_interruptible in open<br />
call up in release function<br />
define trim function<br />
calculate nosqs and noq agin in trim function<br />
memset the quantum_size<br />
to free all quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.14<br />
date: 2013/07/22 22:07:46; author: amitdalal; state: Exp; lines: +102 -40<br />
define fpos variable for fetching file position in read<br />
add fpos to count to calculate the nosqs and noq<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.13<br />
date: 2013/07/17 00:08:24; author: amitdalal; state: Exp; lines: +0 -1<br />
added some variable for write using llseek<br />
added bpos for position update in copy from user<br />
define bpos flag<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.12<br />
date: 2013/07/17 00:07:11; author: amitdalal; state: Exp; lines: +0 -1<br />
added variable bpos for position<br />
use flag and j<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.11<br />
date: 2013/07/17 00:02:29; author: amitdalal; state: Exp; lines: +0 -2<br />
added some variable for reading using llseek<br />
fix the problem related with left out of some first character<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10<br />
date: 2013/07/16 23:37:14; author: amitdalal; state: Exp; lines: +244 -194<br />
give call to llseek<br />
define function llseek<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/15 21:52:06; author: amitdalal; state: Exp; lines: +67 -41<br />
added loff_t function to .c file<br />
use f_pos for storing the value of pos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/11 17:37:19; author: amitdalal; state: Exp; lines: +53 -38<br />
modified code for write to get required no of qset<br />
add lnoq variable<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/11 06:05:24; author: amitdalal; state: Exp; lines: +0 -1<br />
add loop variable in loop for reading<br />
remove some bug in reading loop<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/11 05:37:03; author: amitdalal; state: Exp; lines: +4 -4<br />
remove some bug from write function<br />
added loop variable to specify no of quantum in 2nd qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/11 05:18:10; author: amitdalal; state: Exp; lines: +76 -16<br />
creating read function<br />
use copy to user function<br />
modifing the copy to user function<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/11 00:41:53; author: amitdalal; state: Exp; lines: +1 -0<br />
debbuging problem causing kernel crash<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/11 00:19:58; author: amitdalal; state: Exp; lines: +11 -7<br />
added variable loop<br />
use while loop for creating multiple qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:00:36; author: amitdalal; state: Exp; lines: +25 -4<br />
added the function of quantum written for 8 byte<br />
debugging the problem related to writting of data not 8 byte<br />
fix problem successfully related to written<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:22:34; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: header.h,v<br />
Working file: header.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 />
added asm header .h for copy from user<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/28 00:09:43; author: amitdalal; state: Exp; lines: +1 -0<br />
include header file for proc<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/26 19:29:27; author: amitdalal; state: Exp; lines: +3 -1<br />
initialise spinlock_t my_lock in header file<br />
./<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/26 00:38:59; author: amitdalal; state: Exp; lines: +3 -3<br />
define macro for complition in header.h<br />
another way is to define the complition in sculldev<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/25 23:25:01; author: amitdalal; state: Exp; lines: +9 -3<br />
include struct semaphore rsem and wsem in sculldev<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/22 22:12:52; author: amitdalal; state: Exp; lines: +3 -1<br />
defined header file for semaphore in kernel level<br />
define semaphore in Sculldev structure<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/16 23:38:48; author: amitdalal; state: Exp; lines: +7 -7<br />
include prototype of llseek<br />
define llseek in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:53:32; author: amitdalal; state: Exp; lines: +5 -2<br />
give prototype of llseek<br />
define it in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 17:39:26; author: amitdalal; state: Exp; lines: +5 -5<br />
remove init and cleanup prototype<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:25:25; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/character-driver-18/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Charecter Driver log file</title>
		<link>https://www.emblogic.com/blog/07/charecter-log-file/</link>
		<comments>https://www.emblogic.com/blog/07/charecter-log-file/#comments</comments>
		<pubDate>Sun, 28 Jul 2013 12:34:09 +0000</pubDate>
		<dc:creator><![CDATA[sampath.kumar]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6937</guid>
		<description><![CDATA[RCS file: ./basicregister.c,v Working file: basicregister.c head: 1.31 branch: locks: strict sampath: 1.22 sampath: 1.31 access list: symbolic names: keyword substitution: kv total revisions: 31; selected revisions: 31 description: Base program for driver Registering the driver into the kernel using &#8230; <a href="https://www.emblogic.com/blog/07/charecter-log-file/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>RCS file: ./basicregister.c,v<br />
Working file: basicregister.c<br />
head: 1.31<br />
branch:<br />
locks: strict<br />
sampath: 1.22<br />
sampath: 1.31<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 31; selected revisions: 31<br />
description:<br />
Base program for driver<br />
Registering the driver into the kernel using register_chrdev<br />
inserting the module using insmod<br />
unregistering using unregister_chrdev<br />
removing the module using rmmod<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.31 locked by: sampath;<br />
date: 2013/07/28 12:22:25; author: sampath; state: Exp; lines: +43 -2<br />
Implementation of proc<br />
calling create_proc_read_entry<br />
mapping function which contain sculldev Information device name,major number allocated,quantum size, qset size, no of bytes written and read by application<br />
Able to access from proc directory<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.30<br />
date: 2013/07/28 06:42:14; author: sampath; state: Exp; lines: +16 -3<br />
Implementation of spinlock for synchronization<br />
initialized spin_lock_init and locking using spin_lock in open<br />
unlocking at the end of read using spin_unlock<br />
Also tested synchronization using spin_lock_irq and spin_unlock_irq<br />
spin_lock_irqsave and spin_lock_irqrestore<br />
synchronizing using spinlock and completion<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.29<br />
date: 2013/07/27 19:26:57; author: sampath; state: Exp; lines: +16 -8<br />
Initialized sema_init and init_completion in open within if condition if(opened in write only mode) as the application level has calling open twice once in write and second in read only mode<br />
removed declaring sem_post in close and declared at the end of read so as to allow another application to open afetr first application complete reading operation<br />
note: care should be taken as open and close are called twice from same application<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.28<br />
date: 2013/07/25 06:49:48; author: sampath; state: Exp; lines: +14 -6<br />
Implemented completion<br />
declared init_completion in open<br />
wait_for_completion in read<br />
completion in write<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.27<br />
date: 2013/07/24 15:45:58; author: sampath; state: Exp; lines: +51 -10<br />
Corrected memory allocation error for scull_Qset<br />
Initialised scull_dev[lv]-&gt;scull_Qset=NULL for all lv values<br />
Able to perform trimming operation correctly<br />
Implementation of sema_init is done<br />
Able to synchronize correctly for multi applications<br />
Tested for 3 applications<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.26<br />
date: 2013/07/22 14:05:23; author: sampath; state: Exp; lines: +7 -1<br />
done with implementation of semaphores sema_init<br />
using down and up<br />
able to synchronize correctly tested running 3 applications at once<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.25<br />
date: 2013/07/22 12:27:19; author: sampath; state: Exp; lines: +76 -8<br />
Scull trim Implementation done if application opens in write only mode<br />
sucessfully trimming required no of quantum upto required no of bytes<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.24<br />
date: 2013/07/19 07:23:36; author: sampath; state: Exp; lines: +35 -75<br />
Sucessfully tested driver using 3 multithreaded application one at a time<br />
Able to write and read data sucessfully<br />
Trying to synchronize multiple application running at ones<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.23<br />
date: 2013/07/17 05:19:21; author: sampath; state: Exp; lines: +75 -28<br />
Defined llseek function mapped from function call<br />
Able to read data from application according to lseek offset in application<br />
done with read operation using lseek<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.22 locked by: sampath;<br />
date: 2013/07/13 11:04:51; author: sampath; state: Exp; lines: +15 -54<br />
done with read and write operations for multiple scullqsets<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.21<br />
date: 2013/07/13 10:43:24; author: sampath; state: Exp; lines: +1 -1<br />
added ubuff+tnobsr in copy_to_user for cursor position<br />
able to read data at the application<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.20<br />
date: 2013/07/13 10:17:59; author: sampath; state: Exp; lines: +35 -26<br />
sucessfully Implemented reading operation for 98 bytes of data<br />
able to read tnobsr in application<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.19<br />
date: 2013/07/13 07:17:49; author: sampath; state: Exp; lines: +20 -13<br />
new<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.18<br />
date: 2013/07/13 04:52:08; author: sampath; state: Exp; lines: +49 -36<br />
Able to read 63 bytes of data from kernel to user buffer.<br />
verification done by returning tnobsr to user application.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.17<br />
date: 2013/07/12 08:12:41; author: sampath; state: Exp; lines: +80 -11<br />
Implemented read operation trying to read from kernel to user buffer using copy_to_user<br />
Able to read only 8bytes of data<br />
tryin g to implement for complete read operation for reading 100bytes<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.16<br />
date: 2013/07/11 20:56:23; author: sampath; state: Exp; lines: +5 -10<br />
Able to return 0 from read operation of kernel buffer to application<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.15<br />
date: 2013/07/11 20:10:35; author: sampath; state: Exp; lines: +34 -25<br />
Sucessfully implemented for multiple qsets<br />
Tested writing operation for 100 bytes of data<br />
no of scull qset are 2 and no of quantums created are 13<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.14<br />
date: 2013/07/11 11:12:47; author: sampath; state: Exp; lines: +33 -10<br />
sucessfully implemented write operation for multiple quantums<br />
able to automate correct no of quantums<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.13<br />
date: 2013/07/11 07:57:21; author: sampath; state: Exp; lines: +24 -7<br />
Sucessfully implemented write operation<br />
using kernel facility copy_from_user<br />
testing for only 4bytes of data for which one quantum is enough<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.12<br />
date: 2013/07/10 11:43:26; author: sampath; state: Exp; lines: +75 -21<br />
Implementation of scullqset, qset and quantum done<br />
automated number of scullqsets and quantums wrt the application<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.11<br />
date: 2013/07/10 03:53:40; author: sampath; state: Exp; lines: +120 -34<br />
Implemeenting write operation<br />
fetched private-&gt;data to sculldev<br />
Implemented auto calculation for number of scull_qset and number of quantums<br />
allocated memory for scull_qset qset and quantum calling their functions separately and trying to link them<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10<br />
date: 2013/07/09 07:28:58; author: sampath; state: Exp; lines: +22 -0<br />
Implemented basic write and read operations<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/08 07:27:12; author: sampath; state: Exp; lines: +39 -41<br />
Implementation of scull_trim for future use<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/05 04:53:38; author: sampath; state: Exp; lines: +1 -1<br />
Initialised cdev_del after completing the usage of cdev<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/05 04:51:02; author: sampath; state: Exp; lines: +9 -8<br />
Added ret_cdev to check the return value of cdev_add<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/04 13:07:35; author: sampath; state: Exp; lines: +17 -7<br />
Initialising multiple devices<br />
assining dev using MKDEV<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/04 11:03:31; author: sampath; state: Exp; lines: +23 -10<br />
memory mapping through container_of<br />
pointing scull through inode<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/03 10:49:38; author: sampath; state: Exp; lines: +19 -2<br />
Assigning values to members of sculldev in scullinit and printing<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/02 13:40:19; author: sampath; state: Exp; lines: +17 -2<br />
Initialised function for scull_open<br />
and scull close<br />
calling open function from application<br />
communicating from user spaceapplication to kernelspace driver<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/02 10:34:24; author: sampath; state: Exp; lines: +44 -4<br />
Implemented struct scull<br />
registering the device in device table<br />
Initialized cdev_init<br />
pointing to dev through cdev<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/01 07:16:06; author: sampath; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/charecter-log-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CHARACTER DEVICE DRIVER</title>
		<link>https://www.emblogic.com/blog/07/character-device-driver-2/</link>
		<comments>https://www.emblogic.com/blog/07/character-device-driver-2/#comments</comments>
		<pubDate>Fri, 26 Jul 2013 13:56:18 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6935</guid>
		<description><![CDATA[i have successfully implimented the semaphore in kernel level and complition in kernel level RCS file: app11.c,v Working file: app11.c head: 1.1 branch: locks: strict amitdalal: 1.1 access list: symbolic names: keyword substitution: kv total revisions: 1; selected revisions: 1 &#8230; <a href="https://www.emblogic.com/blog/07/character-device-driver-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>i have successfully implimented the semaphore in kernel level and complition in kernel level</p>
<p>RCS file: app11.c,v<br />
Working file: app11.c<br />
head: 1.1<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.1<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 1;	selected revisions: 1<br />
description:<br />
define set_sem_val function<br />
define semaphore_p and semaphore_v<br />
done this for all 5 applicatin<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1	locked by: amitdalal;<br />
date: 2013/07/25 23:29:38;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: amit.c,v<br />
Working file: amit.c<br />
head: 1.18<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.18<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 18;	selected revisions: 18<br />
description:<br />
added function of copy from user<br />
printk the no of byte writen successfully for one quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.18	locked by: amitdalal;<br />
date: 2013/07/26 00:33:49;  author: amitdalal;  state: Exp;  lines: +9 -19<br />
use wait_for_complition in read<br />
use complete_all in write<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.17<br />
date: 2013/07/25 23:23:36;  author: amitdalal;  state: Exp;  lines: +9 -8<br />
initialise sem_init again<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.16<br />
date: 2013/07/25 23:02:12;  author: amitdalal;  state: Exp;  lines: +33 -11<br />
initialise two semaphore for read and write in sculldev initialisation<br />
down semaphore in write for write<br />
at the end up semaphore for read<br />
down semaphore in write for read<br />
at the end up semaphore for write<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.15<br />
date: 2013/07/22 22:47:17;  author: amitdalal;  state: Exp;  lines: +5 -5<br />
initialise the semaphore init in scull_open for kernel level synchronisation<br />
call down_interruptible in open<br />
call up in release function<br />
define trim function<br />
calculate nosqs and noq agin in trim function<br />
memset the quantum_size<br />
to free all quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.14<br />
date: 2013/07/22 22:07:46;  author: amitdalal;  state: Exp;  lines: +102 -40<br />
define fpos variable for  fetching file position in read<br />
add fpos to count to calculate the nosqs and noq<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.13<br />
date: 2013/07/17 00:08:24;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
added some variable for write using llseek<br />
added bpos for position update in copy from user<br />
define bpos flag<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.12<br />
date: 2013/07/17 00:07:11;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
added variable bpos for position<br />
use flag and j<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.11<br />
date: 2013/07/17 00:02:29;  author: amitdalal;  state: Exp;  lines: +0 -2<br />
added some variable for reading using llseek<br />
fix the problem related with left out of some first character<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10<br />
date: 2013/07/16 23:37:14;  author: amitdalal;  state: Exp;  lines: +244 -194<br />
give call to llseek<br />
define function llseek<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/15 21:52:06;  author: amitdalal;  state: Exp;  lines: +67 -41<br />
added loff_t function to .c file<br />
use f_pos for storing the value of pos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/11 17:37:19;  author: amitdalal;  state: Exp;  lines: +53 -38<br />
modified code for write to get required no of qset<br />
add lnoq variable<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/11 06:05:24;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
add loop variable in loop for reading<br />
remove some bug in reading loop<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/11 05:37:03;  author: amitdalal;  state: Exp;  lines: +4 -4<br />
remove some bug from write function<br />
added loop variable to specify no of quantum in 2nd qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/11 05:18:10;  author: amitdalal;  state: Exp;  lines: +76 -16<br />
creating read function<br />
use copy to user function<br />
modifing the copy to user function<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/11 00:41:53;  author: amitdalal;  state: Exp;  lines: +1 -0<br />
debbuging problem causing kernel crash<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/11 00:19:58;  author: amitdalal;  state: Exp;  lines: +11 -7<br />
added variable loop<br />
use while loop for creating multiple qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:00:36;  author: amitdalal;  state: Exp;  lines: +25 -4<br />
added the function of quantum written for 8 byte<br />
debugging the problem related to writting of data not 8 byte<br />
fix problem successfully related to written<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:22:34;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: dd1,v<br />
Working file: dd1<br />
head: 1.5<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.5<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 5;	selected revisions: 5<br />
description:<br />
adding compilation command for reading in script<br />
gcc<br />
./app1<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5	locked by: amitdalal;<br />
date: 2013/07/25 23:26:50;  author: amitdalal;  state: Exp;  lines: +16 -2<br />
run the 5 application simutanously<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/18 21:17:28;  author: amitdalal;  state: Exp;  lines: +1 -1<br />
added -lpthread for compilation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:55:17;  author: amitdalal;  state: Exp;  lines: +4 -3<br />
add unlink node<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 06:00:23;  author: amitdalal;  state: Exp;  lines: +2 -2<br />
make another node for reading<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/11 05:16:48;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: header.h,v<br />
Working file: header.h<br />
head: 1.7<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.7<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 7;	selected revisions: 7<br />
description:<br />
added asm header .h for copy from user<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7	locked by: amitdalal;<br />
date: 2013/07/26 00:38:59;  author: amitdalal;  state: Exp;  lines: +3 -3<br />
define macro for complition in header.h<br />
another way is to define the complition in sculldev<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/25 23:25:01;  author: amitdalal;  state: Exp;  lines: +9 -3<br />
include struct semaphore rsem and wsem in sculldev<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/22 22:12:52;  author: amitdalal;  state: Exp;  lines: +3 -1<br />
defined header file for semaphore in kernel level<br />
define semaphore in Sculldev structure<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/16 23:38:48;  author: amitdalal;  state: Exp;  lines: +7 -7<br />
include prototype of llseek<br />
define llseek in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:53:32;  author: amitdalal;  state: Exp;  lines: +5 -2<br />
give prototype of llseek<br />
define it in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 17:39:26;  author: amitdalal;  state: Exp;  lines: +5 -5<br />
remove init and cleanup prototype<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:25:25;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/character-device-driver-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CHARACTER DRIVER</title>
		<link>https://www.emblogic.com/blog/07/character-driver-17/</link>
		<comments>https://www.emblogic.com/blog/07/character-driver-17/#comments</comments>
		<pubDate>Tue, 23 Jul 2013 12:18:05 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6930</guid>
		<description><![CDATA[i have successfully implimented the mutex with in the 1 application and semaphore with in the thread for 4 application and done semaphore within the kernel level it is suceesssfully running RCS file: app11.c,v Working file: app11.c head: 1.1 branch: &#8230; <a href="https://www.emblogic.com/blog/07/character-driver-17/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>i have successfully implimented the mutex with in the 1 application and semaphore with in the thread for 4 application and done semaphore within the kernel level it is suceesssfully running</p>
<p>RCS file: app11.c,v<br />
Working file: app11.c<br />
head: 1.1<br />
branch:<br />
locks: strict<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 1;	selected revisions: 1<br />
description:<br />
use mutex for inter thread communication<br />
initialise mutex in main app11 function<br />
use mutex_lock<br />
use mutex_unlock for one application app11<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/22 22:16:09;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: amit.c,v<br />
Working file: amit.c<br />
head: 1.15<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.15<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 15;	selected revisions: 15<br />
description:<br />
added function of copy from user<br />
printk the no of byte writen successfully for one quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.15	locked by: amitdalal;<br />
date: 2013/07/22 22:47:17;  author: amitdalal;  state: Exp;  lines: +5 -5<br />
initialise the semaphore init in scull_open for kernel level synchronisation<br />
call down_interruptible in open<br />
call up in release function<br />
define trim function<br />
calculate nosqs and noq agin in trim function<br />
memset the quantum_size<br />
to free all quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.14<br />
date: 2013/07/22 22:07:46;  author: amitdalal;  state: Exp;  lines: +102 -40<br />
define fpos variable for  fetching file position in read<br />
add fpos to count to calculate the nosqs and noq<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.13<br />
date: 2013/07/17 00:08:24;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
added some variable for write using llseek<br />
added bpos for position update in copy from user<br />
define bpos flag<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.12<br />
date: 2013/07/17 00:07:11;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
added variable bpos for position<br />
use flag and j<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.11<br />
date: 2013/07/17 00:02:29;  author: amitdalal;  state: Exp;  lines: +0 -2<br />
added some variable for reading using llseek<br />
fix the problem related with left out of some first character<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10<br />
date: 2013/07/16 23:37:14;  author: amitdalal;  state: Exp;  lines: +244 -194<br />
give call to llseek<br />
define function llseek<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/15 21:52:06;  author: amitdalal;  state: Exp;  lines: +67 -41<br />
added loff_t function to .c file<br />
use f_pos for storing the value of pos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/11 17:37:19;  author: amitdalal;  state: Exp;  lines: +53 -38<br />
modified code for write to get required no of qset<br />
add lnoq variable<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/11 06:05:24;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
add loop variable in loop for reading<br />
remove some bug in reading loop<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/11 05:37:03;  author: amitdalal;  state: Exp;  lines: +4 -4<br />
remove some bug from write function<br />
added loop variable to specify no of quantum in 2nd qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/11 05:18:10;  author: amitdalal;  state: Exp;  lines: +76 -16<br />
creating read function<br />
use copy to user function<br />
modifing the copy to user function<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/11 00:41:53;  author: amitdalal;  state: Exp;  lines: +1 -0<br />
debbuging problem causing kernel crash<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/11 00:19:58;  author: amitdalal;  state: Exp;  lines: +11 -7<br />
added variable loop<br />
use while loop for creating multiple qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:00:36;  author: amitdalal;  state: Exp;  lines: +25 -4<br />
added the function of quantum written for 8 byte<br />
debugging the problem related to writting of data not 8 byte<br />
fix problem successfully related to written<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:22:34;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: dd1,v<br />
Working file: dd1<br />
head: 1.9<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.9<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 5;	selected revisions: 5<br />
description:<br />
adding compilation command for reading in script<br />
gcc<br />
./app1<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9	locked by: amitdalal;<br />
date: 2013/07/21 22:56:36;  author: amitdalal;  state: Exp;  lines: +8 -0<br />
added gcc command for 5 application<br />
added executable command for all the 5 application<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/18 21:17:28;  author: amitdalal;  state: Exp;  lines: +1 -1<br />
added -lpthread for compilation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/15 21:55:17;  author: amitdalal;  state: Exp;  lines: +4 -3<br />
add unlink node<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/11 06:00:23;  author: amitdalal;  state: Exp;  lines: +2 -2<br />
make another node for reading<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/11 05:16:48;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================<br />
RCS file: dd1,v<br />
Working file: dd1<br />
head: 1.4<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.4<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 4;	selected revisions: 4<br />
description:<br />
adding compilation command for reading in script<br />
gcc<br />
./app1<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4	locked by: amitdalal;<br />
date: 2013/07/19 21:17:28;  author: amitdalal;  state: Exp;  lines: +1 -1<br />
added -lpthread for compilation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:55:17;  author: amitdalal;  state: Exp;  lines: +4 -3<br />
add unlink node<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 06:00:23;  author: amitdalal;  state: Exp;  lines: +2 -2<br />
make another node for reading<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/11 05:16:48;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================<br />
:<br />
RCS file: header.h,v<br />
Working file: header.h<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 />
added asm header .h for copy from user<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/22 22:12:52;  author: amitdalal;  state: Exp;  lines: +3 -1<br />
defined header file for semaphore in kernel level<br />
define semaphore in Sculldev structure<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/16 23:38:48;  author: amitdalal;  state: Exp;  lines: +7 -7<br />
include prototype of llseek<br />
define llseek in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:53:32;  author: amitdalal;  state: Exp;  lines: +5 -2<br />
give prototype of llseek<br />
define it in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 17:39:26;  author: amitdalal;  state: Exp;  lines: +5 -5<br />
remove init and cleanup prototype<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:25:25;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/character-driver-17/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CHARACTER DEVICE DRIVER</title>
		<link>https://www.emblogic.com/blog/07/character-device-driver/</link>
		<comments>https://www.emblogic.com/blog/07/character-device-driver/#comments</comments>
		<pubDate>Mon, 22 Jul 2013 11:45:33 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6921</guid>
		<description><![CDATA[i have implimented the read write close open for 5 application in multithread using semaphore successfully.now i am going to do trim function&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.. &#160; RCS file: app.c,v Working file: app.c head: 1.9 branch: locks: strict amitdalal: 1.9 access list: symbolic &#8230; <a href="https://www.emblogic.com/blog/07/character-device-driver/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>i have implimented the read write close open for 5 application in multithread using semaphore successfully.now i am going to do trim function&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..</p>
<p>&nbsp;</p>
<p>RCS file: app.c,v<br />
Working file: app.c<br />
head: 1.9<br />
branch:<br />
locks: strict<br />
amitdalal: 1.9<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 9; selected revisions: 9<br />
description:<br />
extended the message in buff<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9 locked by: amitdalal;<br />
date: 2013/07/21 22:38:57; author: amitdalal; state: Exp; lines: +127 -73<br />
include some header file for ipc semaphore and thread semaphore<br />
give the prototype of set sem_value<br />
give prototype for semaphore_p and semaphore_v<br />
defined union semun structure<br />
created ipc semaphore for ist application<br />
call the function set_sem_value<br />
call the function semaphore _p<br />
call the function semaphore_v at te end of main finction<br />
defined semaphor_p,semaphore_v and set_sem_val function<br />
same step are done for 5 application except calling set_value function<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/18 21:16:18; author: amitdalal; state: Exp; lines: +0 -1<br />
added pthread join function<br />
added pthread exit<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/18 21:08:19; author: amitdalal; state: Exp; lines: +94 -41<br />
define the function for open<br />
4 thread created<br />
define the function for write<br />
lssek function after write<br />
define function for read<br />
define function for close<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/17 21:37:34; author: amitdalal; state: Exp; lines: +8 -5<br />
added variable len0,count0 for lseek after write<br />
added lseek after write<br />
again use the write function to append<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/17 00:11:50; author: amitdalal; state: Exp; lines: +0 -1<br />
added variable<br />
use lseek<br />
update write<br />
printk offset value<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/16 23:40:05; author: amitdalal; state: Exp; lines: +71 -68<br />
include header file for lseek<br />
set the offset<br />
printf the value of offset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:56:21; author: amitdalal; state: Exp; lines: +52 -15<br />
added lseek for f_pos<br />
printf the newpos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:32:38; author: amitdalal; state: Exp; lines: +1 -1<br />
extended the message to check whether my multiple qset is working or not for above 64 byte<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/11 00:04:48; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================<br />
RCS file: dd1,v<br />
Working file: dd1<br />
head: 1.5<br />
branch:<br />
locks: strict<br />
amitdalal: 1.5<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 5; selected revisions: 5<br />
description:<br />
adding compilation command for reading in script<br />
gcc<br />
./app1<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5 locked by: amitdalal;<br />
date: 2013/07/21 22:56:36; author: amitdalal; state: Exp; lines: +8 -0<br />
added gcc command for 5 application<br />
added executable command for all the 5 application<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/18 21:17:28; author: amitdalal; state: Exp; lines: +1 -1<br />
added -lpthread for compilation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:55:17; author: amitdalal; state: Exp; lines: +4 -3<br />
add unlink node<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 06:00:23; author: amitdalal; state: Exp; lines: +2 -2<br />
make another node for reading<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/11 05:16:48; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/character-device-driver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CHARACTER DEVICE DRIVER(ARTICLE)</title>
		<link>https://www.emblogic.com/blog/07/character-device-driverarticle/</link>
		<comments>https://www.emblogic.com/blog/07/character-device-driverarticle/#comments</comments>
		<pubDate>Sun, 21 Jul 2013 20:47:29 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6851</guid>
		<description><![CDATA[ARTICLE ON CHARACTER DRIVER I have been working on character device driver since last two to three weeks and here I am giving you the concept and idea I am using in character driver till now. Let us start with &#8230; <a href="https://www.emblogic.com/blog/07/character-device-driverarticle/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>ARTICLE<br />
ON<br />
CHARACTER DRIVER</p>
<p>I have been working on character device driver since last two to three weeks and here I am<br />
giving you the concept and idea I am  using in character driver till now.</p>
<p>Let us start with the basic idea about character driver before moving on what is happening in architecture which help me to create my device driver.<br />
DEVICE DRIVER  -&gt;  These are loadable kernel modules that can be inserted in kernel at the run time and they provide a well defined interface for hardware to respond to a specific application code that want to communicate with the hardware . user at user level gives some specific code through application and the role of these device driver is to make these command work for hardware.</p>
<p>CHARACTER DRIVER  -&gt; Character driver is driver that access the device character by character  i.e a stream of bytes as in files.</p>
<p>MODULE  -&gt; It is piece of code that is used for communication b/w hardware and software</p>
<p>Device driver concept divided into two basic part.<br />
1.	user level       -&gt;    where your application  reside<br />
2.	kernel level   -&gt;    where your modules and drivers  reside<br />
now question arise how link is created b/w user level and kernel level.<br />
NODE  -&gt;  node created the link b/w user level and kernel level<br />
			                USER SPACE(APPLICATION)<br />
                   					|</p>
<p>			    KERNEL SPACE(MODULES AND DRIVERS)</p>
<p>						|<br />
			 			HARDWARE</p>
<p>There are few structures which were defind in kernel and user space through which we can defined functionality of our device driver<br />
KERNEL DEFINED STRUCTURE :<br />
1.	STRUCT FILE<br />
2.	STRUCT Inode<br />
3.	Cdev<br />
USER DEFINED STRUCTURE:<br />
1.	Struct Sculldev<br />
2.	Struct Scull_qset<br />
3.	Struct file operations</p>
<p>Scull  -&gt;  Scull is a memory space which is allocated in machine memory to your device. in scull we have two vital structure know as struct Sculldev and struct Scull_qset. The former one is the starting point of scull as well as contains data about all the scullqset present in your scull in a way it contains metadata. its member are as fallow-<br />
1.	*scull_qset<br />
2.	Scull qset_size<br />
3.	data_size<br />
4.	quantum_size<br />
5.	device_size.<br />
6.	struct cdev.<br />
struct Sculldev                 		//user defined structure Sculldev<br />
{<br />
	struct Scull_qset *scull_qset;	//pointing to 1st quantum set(Scull_qset structure)<br />
	int quantum_size;				//current quantum size<br />
	int qset_size;				//current array size<br />
	int data_size;				//amount of data stored here<br />
	int device_size;<br />
	int open_count;<br />
	struct cdev var_dev;   //cdev structure defined in  cdev header file<br />
}*sculldev;      			//used for pointing Sculldev</p>
<p>Scull_qset is a structure which store data or information. it mainly has two member:<br />
1.	*next -&gt;   pointer to next scull_qset<br />
2.	**data -&gt; double pointer to your data, means first it will point to an array of pointer known as qset , contains quantum where actually our data is kept.<br />
struct Scull_qset<br />
{<br />
	struct Scull_qset *next;<br />
	void **data;<br />
};</p>
<p>Struct file operations -&gt; It generally defines the behavior of our device. It is used here to map the user level system calls to programmer defined system call.<br />
Some defined system call:<br />
1.	OPEN<br />
2.	CLOSE(RELEASE)<br />
3.	WRITE<br />
4.	READ<br />
5.	LLSEEK<br />
struct file_operations fops=<br />
{<br />
	open:scull_open,<br />
	read:scull_read,<br />
	write:scull_write,<br />
	llseek:scull_llseek,<br />
	release:scull_release</p>
<p>};</p>
<p>Now comes kernel level structures into picture.<br />
 STRUCT INODE -&gt; as we all know that in linux everything is file either it is a text file, some kind of code or any device with each and every file there is an associated inode structure , here we will mainly concentrate and concerned about which is particularly represents our device. “inode” is the only way through which we can or its better to say our application can interact with our device.<br />
main member are:<br />
1.	 i_cev  -&gt;which points to your struct cdev. pointer to file operations.<br />
2.<br />
Struct file -&gt; Members are:<br />
1.	*f_pos :- which takes the account of the cursor in your file. pointer to file operations<br />
2.	*private data :- which will help us to do mapping from your user level to kernal level as its stores the address of your SCULL so we can access all the data which we have stored in quantum part of scullqset from user level. </p>
<p>Struct Cdev—&gt; It mainly has three member:<br />
1.	owner :- which specifies about its owner name<br />
2.	pointer to file operation<br />
3.	 dev which contains major and minor no.</p>
<p>void Sculldev_initialisation(void)<br />
		{<br />
			int a,lv;<br />
	for(lv=0;lv Major no. is a number which is given to each and every device driver we have in our machine<br />
Minor no -&gt; Minor no. is the number which represents your the device associated with that particular device driver. </p>
<p>majorno=MAJOR(dev);	//extract major no.from device number<br />
minorno=MINOR(dev);	//extract minor no.from device number</p>
<p>This is all about the architecture now lets have  look on the operations or working.</p>
<p>STEPS USED IN IMPLIMENTATION OF CHARACTER DRIVER</p>
<p>1.	Insmod -&gt; which will load our module, module is a source code which is loaded on demand.<br />
insmod ./modules/amit.ko </p>
<p>2.	Registration -&gt; register our device driver and device so that DD will get a major number and device gets its own minor number.<br />
ret=alloc_chrdev_region(&amp;dev,minorno,nod,DRIVER_NAME);	//when we are registering one device (for dynamic allocation)</p>
<p>3.Allocation -&gt; Allocate space to Scull in machine memory.<br />
sculldev=kmalloc(sizeof(struct Sculldev)*nod , GFP_KERNEL);	//allocate memory to Sculldev</p>
<p>4.Initialize Scull	–&gt; cdev_init— create link between struct inode and struct cdev… define owner.. cdev_add make attribute of device available to our kernel.<br />
void Sculldev_initialisation(void)<br />
		{<br />
			int a,lv;<br />
	for(lv=0;lv flash data if present in the memory space which is assigned to scull</p>
<p>7.Open -&gt; define open system call.<br />
int scull_open(struct inode *inodep, struct file *filep)<br />
{</p>
<p>	struct Sculldev* pdev;<br />
	printk(KERN_ALERT&#8221;BEGIN:open SUCCESSFULLY :%s\n&#8221;,__func__);</p>
<p>pdev=(struct Sculldev *)container_of(inodep-&gt;i_cdev, struct Sculldev, var_dev);  // map the memeory allocated to Sculldev to VFS which is going to return pointer(A convenience macro that may be used to obtain a pointer to a structure from a pointer to some other structure contained within it.)</p>
<p>filep-&gt;private_data =pdev;	//all information stored in pdev pointer conatining address</p>
<p>	if((filep-&gt;f_flags &amp;&amp; O_ACCMODE) == O_WRONLY)<br />
		{</p>
<p>			printk(KERN_ALERT&#8221;FILE OPEN\n&#8221;);<br />
			scull_trim(pdev);<br />
		}</p>
<p>	printk(KERN_ALERT&#8221;END:open close SUCCESSFULLY: %s\n&#8221;,__func__);<br />
	return 0;<br />
}</p>
<p>8.	Write -&gt;before doing that allocate space to Scullqset then to qset and at last to quantum now we can write data to our quantum, LSEEK if needed.<br />
ssize_t scull_write(struct file *filep,const char __user *buff,size_t count, loff_t *f_pos)<br />
{<br />
struct Sculldev *pdev;<br />
	struct Scull_qset *qset;<br />
	int noq,nosqs,i,j,ret=0,loop=0;			//noq=no.of quantum,nosqs=no. of scull_qset,<br />
	int nobpq,noctw,nocsw,flag=0,bpos=0;		//nocsw=no. of character successfully write<br />
	noq=nosqs=nobpq=noctw=nocsw=0;<br />
	pdev=filep-&gt;private_data;			//fetch the device</p>
<p>	printk(KERN_ALERT&#8221;BEGIN:write open SUCCESSFULLY: %s\n&#8221;,__func__);<br />
	if(!pdev)<br />
		{<br />
			printk(&#8220;no private data&#8221;);<br />
		}</p>
<p>	nosqs=count/(quantum_size*qset_size);	//finding no. of scull_qset required<br />
	if(count % (quantum_size*qset_size))<br />
	nosqs++;<br />
	pdev-&gt;scull_qset=create_scull_qset(nosqs);	//creating scull_qset(Sculldev *pdev pointing towards *scull_qset)<br />
	if(!pdev-&gt;scull_qset)<br />
		{<br />
			printk(&#8220;no scull_qset found\n&#8221;);<br />
		}<br />
	noq=count/quantum_size;<br />
	if(count%quantum_size)<br />
	noq++;</p>
<p>	qset=pdev-&gt;scull_qset;<br />
	create_qset(qset,nosqs);	//creating _qset<br />
	create_quantum(qset,noq);	//creating _quantum<br />
	nobpq=quantum_size;<br />
	nocsw=0;<br />
	noctw=count;<br />
 	int offset=filep-&gt;f_pos;<br />
	printk(KERN_ALERT&#8221;offset=%d\n&#8221;,(int)filep-&gt;f_pos);	//data write in quantum</p>
<p>	while(nosqs)<br />
		{<br />
			if(noq&gt;quantum_size)<br />
				{<br />
					loop=quantum_size;<br />
				}<br />
			else<br />
				{<br />
					loop=noq;<br />
				}<br />
	if(flag==0)<br />
		{<br />
			if(offset&gt;quantum_size)<br />
				{<br />
					j=offset/quantum_size;<br />
					bpos=offset%quantum_size;<br />
					nobpq=quantum_size-bpos;<br />
				}<br />
			else<br />
				{<br />
					j=0;<br />
					nobpq=quantum_size-offset;<br />
					bpos=offset;<br />
				}<br />
	flag=1;<br />
		}<br />
	else<br />
		{<br />
			j=0;<br />
			loop=noq;<br />
			bpos=0;<br />
		}<br />
	for(i=j;idata[i]+bpos,buff+nocsw,nobpq);			//copy data from user space<br />
			printk(KERN_ALERT&#8221;quantum=%d-&gt;write=%s\n&#8221;,i,(char *)qset-&gt;data[i]+bpos);	//data write in quantum<br />
			nocsw=nocsw+(nobpq-ret);<br />
			noctw=noctw-(nobpq-ret);<br />
			if(noctw&gt;quantum_size)<br />
				{<br />
					nobpq=quantum_size;<br />
				}<br />
			else<br />
				{<br />
					nobpq=noctw;<br />
				}<br />
			printk(KERN_ALERT&#8221;no. of byte successfully write=%d\n&#8221;,nocsw);<br />
			printk(KERN_ALERT&#8221;no. of byte not write=%d\n&#8221;,ret);<br />
			bpos=0;<br />
		}<br />
			nosqs&#8211;;<br />
			qset=qset-&gt;next;<br />
			noq=noq-quantum_size;<br />
		}<br />
	printk(KERN_ALERT&#8221;no.of qset=%d\n&#8221;,loop);</p>
<p>	printk(KERN_ALERT&#8221;END:write close SUCCESSFULLY : %s\n&#8221;,__func__);<br />
	return count-ret;<br />
}</p>
<p>9. Read -&gt; read whatever you have written to quantum.<br />
ssize_t scull_read(struct file *filep,char __user *buff,size_t count, loff_t *f_pos)</p>
<p>ret=copy_to_user(buff+nocsr,qset-&gt;data[i]+bpos,nobpq);                     //copy data from user space<br />
10. Release-&gt; de-allocate all the space, unregister your device and DD, remove your module.<br />
int scull_release(struct inode *inodep, struct file *filep)<br />
{<br />
	printk(KERN_ALERT&#8221;BEGIN:OPEN SUCCESSFULLY release: %s\n&#8221;,__func__);<br />
	printk(KERN_ALERT&#8221;END:close SUCCESSFULLY release: %s\n&#8221;,__func__);<br />
	return 0;<br />
}</p>
<p>For unregistering :</p>
<p>static void cleanup(void)<br />
{<br />
	int lv;<br />
	printk(KERN_ALERT &#8220;BEGIN: %s\n&#8221;,__func__);<br />
	printk(KERN_ALERT&#8221;\ngood bye\n&#8221;);<br />
	for(lv=0;lv make<br />
For making node -&gt; mknod node c 249 0</p>
<p>TO remove the driver -&gt; rmmod amit</p>
<p>HERE I AM GIVING YOU THE IMPLIMENTATION PROCEDURE TO CLEARIFY THE ALL  STEP:-</p>
<p>Initialization of driver -&gt; Mapping of system calls from application to the driver -&gt; open call -&gt; Mapping of memory on to the device (including trim function) -&gt; Write call -&gt; Read call -&gt; Seek call -&gt;use of multi threaded application.</p>
<p>We have used command “insmod” to call the initialization macro i.e. module_init() which will insert the driver into the list of modules &amp; “rmmod” to call the cleanup macro i.e. module_exit() which will remove the driver from the list.</p>
<p> Driver starts with the registration using alloc_chrdev_region(). This registration (using alloc_chrdev_region()) is done so as to get the major number dynamically for the driver. Correspondingly a minor number is generated for the first device.<br />
We can also use register_chrdev() to register the driver if we want to assign the user defined major number.</p>
<p>After registration we got a 32 bit number stored in “dev” which is of “dev_t” type. First 12 bits will give major number by using macro “MAJOR” &amp; remaining 20 bits will give the minor number by using macro “MINOR”. </p>
<p>After getting the major &amp; minor number, now its time to initialize the SCULL i.e. Simple character utility for loading localities. SCULL is a char driver that acts on the memory area as though it was a device. This SCULL is defined by a structure “Sculldev” contains blocks of memory called scullqsets which are also called as items and each item contains qsets which are nothing but array of pointers pointing to specific locations known as quantums. The scullqset or item can handle data maximum upto the data equal to product of qset_size and quantum size. Further each quantum can store maximum of bytes equal to quantum_size defined by the developer. We can calculate the number of scullqsets and number of quantums required for storing given number of bytes. One thing which is very important that these “items” or we can say that “scullqsets” should be linked like “link list” so as to store the data in quantums of different scullqsets.</p>
<p>After initializing the structure Sculldev, now we have to initialize the structure C_dev which will give the information of our device i.e. Owner of the device, Major &amp; Minor numbers, operations that our device can perform etc. After this its time to map the system calls to the corresponding functions defined in the driver.</p>
<p> As the mapping is done so now from the application end we will call the open system call which will call our defined function in driver. In normal routine open call creates a stream and after handing over of the stream this call terminates. For our driver we have written our own routines. In our open function we have used a macro “container_of” to map the memory allocated for scull from RAM to the device &amp; along with the link of “Structure inode” with “Structure C_dev &amp; SCULL. This mapping will return the starting address of the SCULL which we will store into the “private data” of the “Structure file”. When ever &amp; where ever if we want to access the sculldev we will fetch the private data. After sending the address of Sculldev we will call the trim function. </p>
<p>If we want to write on to the device, we have to check whether the device is having something onto its memory or not. If we found anything in quantums, we first trim the data nothing but flushing out the previously written bytes.</p>
<p>After trimming we will call write from the application. This write system call will call the write function which we have in our driver as we have already mapped all the operations to be performed by the applications in “Structure file_operations”. Writing here means getting the data from the user buffer &amp; writing it on the quantums present in the SCULL i.e. Memory of device. In the starting of write function we will fetch the private data so as to get the address of SCULL. For writing we will use “Copy_from_user()”. Before writing we will calculate the number of items (scullqsets) to be created along with the number of quantums. Now we want to read what we have written earlier in the quantums. For this we will call the read function. This means reading the data from the quantums &amp; passing it to the user buffer which we will receive in our application. For this we will use “Copy_to_user()”.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/character-device-driverarticle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DEVICE DRIVER</title>
		<link>https://www.emblogic.com/blog/07/device-driver-7/</link>
		<comments>https://www.emblogic.com/blog/07/device-driver-7/#comments</comments>
		<pubDate>Fri, 19 Jul 2013 10:26:10 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6832</guid>
		<description><![CDATA[MULTI THREAD(open,write,read,close) amit.c RCS file: amit.c,v Working file: amit.c head: 1.13 branch: locks: strict amitdalal: 1.13 access list: symbolic names: keyword substitution: kv total revisions: 13; selected revisions: 13 description: added function of copy from user printk the no of &#8230; <a href="https://www.emblogic.com/blog/07/device-driver-7/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>MULTI THREAD(open,write,read,close)</p>
<p>amit.c</p>
<p>RCS file: amit.c,v<br />
Working file: amit.c<br />
head: 1.13<br />
branch:<br />
locks: strict<br />
amitdalal: 1.13<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 13; selected revisions: 13<br />
description:<br />
added function of copy from user<br />
printk the no of byte writen successfully for one quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.13 locked by: amitdalal;<br />
date: 2013/07/17 00:08:24; author: amitdalal; state: Exp; lines: +0 -1<br />
added some variable for write using llseek<br />
added bpos for position update in copy from user<br />
define bpos flag<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.12<br />
date: 2013/07/17 00:07:11; author: amitdalal; state: Exp; lines: +0 -1<br />
added variable bpos for position<br />
use flag and j<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.11<br />
date: 2013/07/17 00:02:29; author: amitdalal; state: Exp; lines: +0 -2<br />
added some variable for reading using llseek<br />
fix the problem related with left out of some first character<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10<br />
date: 2013/07/16 23:37:14; author: amitdalal; state: Exp; lines: +244 -194<br />
give call to llseek<br />
define function llseek<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/15 21:52:06; author: amitdalal; state: Exp; lines: +67 -41<br />
added loff_t function to .c file<br />
use f_pos for storing the value of pos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/11 17:37:19; author: amitdalal; state: Exp; lines: +53 -38<br />
modified code for write to get required no of qset<br />
add lnoq variable<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/11 06:05:24; author: amitdalal; state: Exp; lines: +0 -1<br />
add loop variable in loop for reading<br />
remove some bug in reading loop<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/11 05:37:03; author: amitdalal; state: Exp; lines: +4 -4<br />
remove some bug from write function<br />
added loop variable to specify no of quantum in 2nd qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/11 05:18:10; author: amitdalal; state: Exp; lines: +76 -16<br />
creating read function<br />
use copy to user function<br />
modifing the copy to user function<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/11 00:41:53; author: amitdalal; state: Exp; lines: +1 -0<br />
debbuging problem causing kernel crash<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/11 00:19:58; author: amitdalal; state: Exp; lines: +11 -7<br />
added variable loop<br />
use while loop for creating multiple qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:00:36; author: amitdalal; state: Exp; lines: +25 -4<br />
added the function of quantum written for 8 byte<br />
debugging the problem related to writting of data not 8 byte<br />
fix problem successfully related to written<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:22:34; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>app.c</p>
<p>RCS file: app.c,v<br />
Working file: app.c<br />
head: 1.8<br />
branch:<br />
locks: strict<br />
amitdalal: 1.8<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 8; selected revisions: 8<br />
description:<br />
extended the message in buff<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8 locked by: amitdalal;<br />
date: 2013/07/19 21:16:18; author: amitdalal; state: Exp; lines: +0 -1<br />
added pthread join function<br />
added pthread exit<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/19 21:08:19; author: amitdalal; state: Exp; lines: +94 -41<br />
define the function for open<br />
4 thread created<br />
define the function for write<br />
lssek function after write<br />
define function for read<br />
define function for close<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/18 21:37:34; author: amitdalal; state: Exp; lines: +8 -5<br />
added variable len0,count0 for lseek after write<br />
added lseek after write<br />
again use the write function to append<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/17 00:11:50; author: amitdalal; state: Exp; lines: +0 -1<br />
added variable<br />
use lseek<br />
update write<br />
printk offset value<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/16 23:40:05; author: amitdalal; state: Exp; lines: +71 -68<br />
include header file for lseek<br />
set the offset<br />
printf the value of offset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:56:21; author: amitdalal; state: Exp; lines: +52 -15<br />
added lseek for f_pos<br />
printf the newpos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:32:38; author: amitdalal; state: Exp; lines: +1 -1<br />
extended the message to check whether my multiple qset is working or not for above 64 byte<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/11 00:04:48; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>script</p>
<p>RCS file: dd1,v<br />
Working file: dd1<br />
head: 1.4<br />
branch:<br />
locks: strict<br />
amitdalal: 1.4<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 4; selected revisions: 4<br />
description:<br />
adding compilation command for reading in script<br />
gcc<br />
./app1<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4 locked by: amitdalal;<br />
date: 2013/07/19 21:17:28; author: amitdalal; state: Exp; lines: +1 -1<br />
added -lpthread for compilation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:55:17; author: amitdalal; state: Exp; lines: +4 -3<br />
add unlink node<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 06:00:23; author: amitdalal; state: Exp; lines: +2 -2<br />
make another node for reading<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/11 05:16:48; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/device-driver-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CHARACTER DRIVER</title>
		<link>https://www.emblogic.com/blog/07/character-driver-15/</link>
		<comments>https://www.emblogic.com/blog/07/character-driver-15/#comments</comments>
		<pubDate>Wed, 17 Jul 2013 12:59:06 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6734</guid>
		<description><![CDATA[i have done llseek successffully for write and read and now back to assignment sir gave us&#8230; rcs file amit.c RCS file: amit.c,v Working file: amit.c head: 1.13 branch: locks: strict amitdalal: 1.13 access list: symbolic names: keyword substitution: kv &#8230; <a href="https://www.emblogic.com/blog/07/character-driver-15/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>i have done llseek successffully for write and read and now back to assignment sir gave us&#8230;</p>
<p>rcs file</p>
<p>amit.c<br />
RCS file: amit.c,v<br />
Working file: amit.c<br />
head: 1.13<br />
branch:<br />
locks: strict<br />
amitdalal: 1.13<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 13; selected revisions: 13<br />
description:<br />
added function of copy from user<br />
printk the no of byte writen successfully for one quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.13 locked by: amitdalal;<br />
date: 2013/07/17 00:08:24; author: amitdalal; state: Exp; lines: +0 -1<br />
added some variable for write using llseek<br />
added bpos for position update in copy from user<br />
define bpos flag<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.12<br />
date: 2013/07/17 00:07:11; author: amitdalal; state: Exp; lines: +0 -1<br />
added variable bpos for position<br />
use flag and j<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.11<br />
date: 2013/07/17 00:02:29; author: amitdalal; state: Exp; lines: +0 -2<br />
added some variable for reading using llseek<br />
fix the problem related with left out of some first character<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10<br />
date: 2013/07/16 23:37:14; author: amitdalal; state: Exp; lines: +244 -194<br />
give call to llseek<br />
define function llseek<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/15 21:52:06; author: amitdalal; state: Exp; lines: +67 -41<br />
added loff_t function to .c file<br />
use f_pos for storing the value of pos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/11 17:37:19; author: amitdalal; state: Exp; lines: +53 -38<br />
modified code for write to get required no of qset<br />
add lnoq variable<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/11 06:05:24; author: amitdalal; state: Exp; lines: +0 -1<br />
add loop variable in loop for reading<br />
remove some bug in reading loop<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/11 05:37:03; author: amitdalal; state: Exp; lines: +4 -4<br />
remove some bug from write function<br />
added loop variable to specify no of quantum in 2nd qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/11 05:18:10; author: amitdalal; state: Exp; lines: +76 -16<br />
creating read function<br />
use copy to user function<br />
modifing the copy to user function<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/11 00:41:53; author: amitdalal; state: Exp; lines: +1 -0<br />
debbuging problem causing kernel crash<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/11 00:19:58; author: amitdalal; state: Exp; lines: +11 -7<br />
added variable loop<br />
use while loop for creating multiple qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:00:36; author: amitdalal; state: Exp; lines: +25 -4<br />
added the function of quantum written for 8 byte<br />
debugging the problem related to writting of data not 8 byte<br />
fix problem successfully related to written<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:22:34; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================<br />
header.h</p>
<p>RCS file: header.h,v<br />
Working file: header.h<br />
head: 1.4<br />
branch:<br />
locks: strict<br />
amitdalal: 1.4<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 4; selected revisions: 4<br />
description:<br />
added asm header .h for copy from user<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4 locked by: amitdalal;<br />
date: 2013/07/16 23:38:48; author: amitdalal; state: Exp; lines: +7 -7<br />
include prototype of llseek<br />
define llseek in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:53:32; author: amitdalal; state: Exp; lines: +5 -2<br />
give prototype of llseek<br />
define it in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 17:39:26; author: amitdalal; state: Exp; lines: +5 -5<br />
remove init and cleanup prototype<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:25:25; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>app.c</p>
<p>RCS file: app.c,v<br />
Working file: app.c<br />
head: 1.5<br />
branch:<br />
locks: strict<br />
amitdalal: 1.5<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 5; selected revisions: 5<br />
description:<br />
extended the message in buff<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5 locked by: amitdalal;<br />
date: 2013/07/17 00:11:50; author: amitdalal; state: Exp; lines: +0 -1<br />
added variable<br />
use lseek<br />
update write<br />
printk offset value<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/16 23:40:05; author: amitdalal; state: Exp; lines: +71 -68<br />
include header file for lseek<br />
set the offset<br />
printf the value of offset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:56:21; author: amitdalal; state: Exp; lines: +52 -15<br />
added lseek for f_pos<br />
printf the newpos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:32:38; author: amitdalal; state: Exp; lines: +1 -1<br />
extended the message to check whether my multiple qset is working or not for above 64 byte<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/11 00:04:48; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/character-driver-15/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DEVICE DRIVER</title>
		<link>https://www.emblogic.com/blog/07/device-driver-6/</link>
		<comments>https://www.emblogic.com/blog/07/device-driver-6/#comments</comments>
		<pubDate>Fri, 12 Jul 2013 06:19:47 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6680</guid>
		<description><![CDATA[successfully done write and read for multiple qset and multiple quantum and for single qset here is rcs file amit.c head 1.8; access; symbols; locks amitdalal:1.8; strict; comment @ * @; 1.8 date 2013.07.11.17.37.19; author amitdalal; state Exp; branches; next &#8230; <a href="https://www.emblogic.com/blog/07/device-driver-6/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>successfully done write and read for multiple qset and multiple quantum and for single qset here is rcs file</p>
<p>amit.c<br />
head	1.8;<br />
access;<br />
symbols;<br />
locks<br />
	amitdalal:1.8; strict;<br />
comment	@ * @;</p>
<p>1.8<br />
date	2013.07.11.17.37.19;	author amitdalal;	state Exp;<br />
branches;<br />
next	1.7;</p>
<p>1.7<br />
date	2013.07.11.06.05.24;	author amitdalal;	state Exp;<br />
branches;<br />
next	1.6;</p>
<p>1.6<br />
date	2013.07.11.05.37.03;	author amitdalal;	state Exp;<br />
branches;<br />
next	1.5;</p>
<p>1.5<br />
date	2013.07.11.05.18.10;	author amitdalal;	state Exp;<br />
branches;<br />
next	1.4;</p>
<p>1.4<br />
date	2013.07.11.00.41.53;	author amitdalal;	state Exp;<br />
branches;<br />
next	1.3;</p>
<p>1.3<br />
date	2013.07.11.00.19.58;	author amitdalal;	state Exp;<br />
branches;<br />
next	1.2;</p>
<p>1.2<br />
date	2013.07.11.00.00.36;	author amitdalal;	state Exp;<br />
branches;<br />
next	1.1;</p>
<p>1.1<br />
date	2013.07.10.21.22.34;	author amitdalal;	state Exp;<br />
branches;<br />
next	;</p>
<p>desc<br />
@added function of copy from user<br />
printk the no of byte writen successfully for one quantum<br />
@</p>
<p>1.8<br />
log<br />
@modified code for write to get required no of qset<br />
add lnoq variable<br />
@<br />
text<br />
@#include&#8221;header.h&#8221;<br />
int create_qset(struct Scull_qset *qset,int nosqs)	//creating qset and allocating memory to qset(64 bytes)<br />
{<br />
	int lv;<br />
	printk(KERN_ALERT&#8221;BEGIN:SUCCESSFULLY : %s\n&#8221;,__func__);</p>
<p>if(!qset)<br />
	printk(KERN_ERR &#8220;error in creatin qset\n&#8221;);<br />
for(lv=0;lvdata=kmalloc(sizeof(int *)*qset_size,GFP_KERNEL);	//allocating memory to the *qset_size<br />
	qset=qset-&gt;next;<br />
}<br />
	printk(KERN_ALERT&#8221;END:SUCCESSFULLY : %s\n&#8221;,__func__);<br />
	return 0;<br />
}</p>
<p>int create_quantum(struct Scull_qset *qset,int noq)		//creating quantum and locating memory to quantum(8 quantum per qset)<br />
{<br />
	int i,count=0,lnoq=0;</p>
<p>	printk(KERN_ALERT&#8221;BEGIN:SUCCESSFULLY : %s\n&#8221;,__func__);<br />
if(!qset)<br />
	printk(KERN_ERR &#8220;error in creating quantum\n&#8221;);</p>
<p>while(qset!=NULL)<br />
{<br />
if(noq&gt;quantum_size)<br />
lnoq=quantum_size;<br />
else<br />
lnoq=noq;<br />
for(i=0;idata[i]=kmalloc(quantum_size,GFP_KERNEL);	//allocate memory to quantum<br />
	printk(KERN_ALERT&#8221;quantum number=%p&#8221;,&amp;qset-&gt;data[i]);<br />
	count++;<br />
	}</p>
<p>noq=noq-quantum_size;<br />
qset=qset-&gt;next;<br />
}<br />
	printk(KERN_ALERT&#8221;quantum number=%d&#8221;,count);<br />
	printk(KERN_ALERT&#8221;END:SUCCESSFULLY : %s\n&#8221;,__func__);<br />
	return 0;<br />
}</p>
<p>struct Scull_qset* create_scull_qset(int fnosqs)	//creating scull_qset and allocating memory to it<br />
{</p>
<p>	struct Scull_qset *pdev,*start;	//taking two pointer<br />
	int flag=0,i=0;<br />
	start=NULL;<br />
	printk(KERN_ALERT&#8221;BEGIN:SUCCESSFULLY : %s\n&#8221;,__func__);<br />
for(i=0;inext=(struct Scull_qset *)(kmalloc(sizeof(struct Scull_qset),GFP_KERNEL));	//allocating memory to the next scull_qset<br />
	pdev=pdev-&gt;next;<br />
}<br />
}<br />
	printk(KERN_ALERT&#8221;END: SUCCESSFULLY: %s\n&#8221;,__func__);<br />
	return start;<br />
}</p>
<p>ssize_t scull_read(struct file *filep,char __user *buff,size_t count, loff_t *offp)<br />
{<br />
	struct Sculldev *pdev;<br />
        struct Scull_qset *qset;<br />
        int noq,nosqs,i,ret=0,loop=0;<br />
        int nobpq,noctr,nocsr;<br />
        noq=nosqs=nobpq=noctr=0;<br />
        nobpq=quantum_size;<br />
        nocsr=0;<br />
        noctr=count;</p>
<p>	printk(KERN_ALERT&#8221;read open SUCCESSFULLY : %s\n&#8221;,__func__);<br />
        pdev=filep-&gt;private_data;       //fetch the device<br />
        printk(KERN_ALERT&#8221;write open SUCCESSFULLY: %s\n&#8221;,__func__);<br />
        if(!pdev)<br />
{<br />
        printk(&#8220;no private data&#8221;);<br />
}<br />
        nosqs=count/(quantum_size*qset_size);   //finding no. of scull_qset required<br />
if(count%(quantum_size*qset_size))<br />
        nosqs++;<br />
if(!pdev-&gt;scull_qset)<br />
{<br />
        printk(&#8220;no scull_qset found\n&#8221;);<br />
}<br />
        noq=count/quantum_size;<br />
if(count%quantum_size);<br />
        noq++;<br />
        qset=pdev-&gt;scull_qset;</p>
<p>while(nosqs)<br />
        {<br />
         if(noq&gt;quantum_size)<br />
        {<br />
        loop=quantum_size;<br />
        }<br />
        else<br />
        {<br />
        loop=noq;<br />
        }<br />
for(i=0;iquantum_size)  //if noctw&gt;quantum_size ,nobpq is equql to the quantum_size that is 8<br />
        nobpq=quantum_size;<br />
        else<br />
        nobpq=noctr;            //else nobpq is equal to the noctw</p>
<p>        ret=copy_to_user(buff+nocsr,qset-&gt;data[i],nobpq);                     //copy data from user space<br />
        nocsr=nocsr+(nobpq-ret);<br />
        noctr=noctr-(nobpq-ret);<br />
        printk(KERN_ALERT&#8221;no. of byte successfully read=%d\n&#8221;,nocsr);<br />
        }<br />
        nosqs&#8211;;<br />
        qset=qset-&gt;next;<br />
        noq=noq-quantum_size;<br />
        }<br />
        printk(KERN_ALERT&#8221;no.of qset=%d\n&#8221;,loop);<br />
	printk(KERN_ALERT&#8221;END:read close SUCCESSFULLY: %s\n&#8221;,__func__);<br />
       return count-ret;</p>
<p>}</p>
<p>ssize_t scull_write(struct file *filep,const char __user *buff,size_t count, loff_t *offp)<br />
{</p>
<p>	struct Sculldev *pdev;<br />
	struct Scull_qset *qset;<br />
	int noq,nosqs,i,ret=0,loop=0;<br />
	int nobpq,noctw,nocsw;<br />
	noq=nosqs=nobpq=noctw=nocsw=0;</p>
<p>	pdev=filep-&gt;private_data;	//fetch the device<br />
	printk(KERN_ALERT&#8221;write open SUCCESSFULLY: %s\n&#8221;,__func__);<br />
	if(!pdev)<br />
{<br />
	printk(&#8220;no private data&#8221;);<br />
}<br />
	nosqs=count/(quantum_size*qset_size);	//finding no. of scull_qset required<br />
if(count % (quantum_size*qset_size))<br />
	nosqs++;<br />
	pdev-&gt;scull_qset=create_scull_qset(nosqs);	//creating scull_qset(Sculldev *pdev pointing towards *scull_qset)<br />
if(!pdev-&gt;scull_qset)<br />
{<br />
	printk(&#8220;no scull_qset found\n&#8221;);<br />
}<br />
	noq=count/quantum_size;<br />
if(count%quantum_size)<br />
	noq++;</p>
<p>	qset=pdev-&gt;scull_qset;<br />
	create_qset(qset,nosqs);	//creating _qset<br />
	create_quantum(qset,noq);	//creating _quantum<br />
	nobpq=quantum_size;<br />
	nocsw=0;<br />
	noctw=count;</p>
<p>while(nosqs)<br />
	{<br />
	if(noq&gt;quantum_size)<br />
	{<br />
	loop=quantum_size;<br />
	}<br />
	else<br />
	{<br />
	loop=noq;<br />
	}<br />
for(i=0;iquantum_size)	//if noctw&gt;quantum_size ,nobpq is equql to the quantum_size that is 8<br />
	nobpq=quantum_size;<br />
	else<br />
	nobpq=noctw;		//else nobpq is equal to the noctw</p>
<p>	ret=copy_from_user(qset-&gt;data[i],buff+nocsw,nobpq);			//copy data from user space<br />
	printk(KERN_ALERT&#8221;quantum=%d-&gt;write=%s\n&#8221;,i,(char *)qset-&gt;data[i]);	//data write in quantum<br />
	nocsw=nocsw+(nobpq-ret);<br />
	noctw=noctw-(nobpq-ret);<br />
	printk(KERN_ALERT&#8221;no. of byte successfully write=%d\n&#8221;,nocsw);<br />
	printk(KERN_ALERT&#8221;no. of byte not write=%d\n&#8221;,ret);<br />
	}<br />
	nosqs&#8211;;<br />
	qset=qset-&gt;next;<br />
	noq=noq-quantum_size;<br />
	}<br />
	printk(KERN_ALERT&#8221;no.of qset=%d\n&#8221;,loop);</p>
<p>	printk(KERN_ALERT&#8221;write close SUCCESSFULLY : %s\n&#8221;,__func__);<br />
	return count-ret;<br />
}</p>
<p>int scull_open(struct inode *inodep, struct file *filep)<br />
{</p>
<p>	struct Sculldev* pdev;<br />
	printk(KERN_ALERT&#8221;OPEN SUCCESSFULLY :%s\n&#8221;,__func__);<br />
        pdev=(struct Sculldev *)container_of(inodep-&gt;i_cdev, struct Sculldev, var_dev);// map the memeory allocated to Sculldev to VFS which is going to return pointer<br />
	filep-&gt;private_data =pdev;	//all information stored in pdev pointer conatining address</p>
<p>if((filep-&gt;f_flags &amp;&amp; O_ACCMODE) == O_WRONLY)<br />
{</p>
<p>	printk(KERN_ALERT&#8221;FILE OPEN\n&#8221;);<br />
	scull_trim(pdev);<br />
}</p>
<p>	printk(KERN_ALERT&#8221;close SUCCESSFULLY: %s\n&#8221;,__func__);<br />
	return 0;<br />
}</p>
<p>int scull_trim(struct Sculldev *fsculldev)<br />
{<br />
	printk(KERN_ALERT&#8221;BEGIN :%s\n&#8221;,__func__);<br />
if(!fsculldev)<br />
{<br />
	printk(KERN_ERR&#8221;no scull found\n&#8221;);<br />
}<br />
if(!fsculldev-&gt;scull_qset)<br />
{<br />
	printk(KERN_INFO&#8221;no scullqset found\n&#8221;);<br />
}<br />
	printk(KERN_ALERT&#8221;END: %s\n&#8221;,__func__);<br />
	return 0;<br />
}</p>
<p>int scull_release(struct inode *inodep, struct file *filep)<br />
{<br />
	printk(KERN_ALERT&#8221;OPEN SUCCESSFULLY release: %s\n&#8221;,__func__);<br />
	printk(KERN_ALERT&#8221;close SUCCESSFULLY release: %s\n&#8221;,__func__);<br />
	return 0;<br />
}<br />
void sculldev_initialisation(void)<br />
{<br />
int a,lv;<br />
for(lv=0;lv&lt;nod;lv++)<br />
{<br />
	dev=MKDEV(majorno,lv);	//lv=newminorno+1(allocating value of minorno and majorno to your dev)<br />
	printk(&quot;sculldev initialisation start :%s\n&quot;,__func__);<br />
	cdev_init(&amp;sculldev[lv].var_dev, &amp;fops);<br />
	sculldev[lv].var_dev.dev = dev;	//storing that value of dev into dev which is defined in cdev.. through sculldev<br />
	sculldev[lv].var_dev.owner=THIS_MODULE;<br />
	sculldev[lv].var_dev.ops=&amp;fops;<br />
	sculldev[lv].var_dev.count=nod;<br />
	sculldev[lv].open_count=0;</p>
<p>	a=cdev_add(&amp;sculldev[lv].var_dev,sculldev[lv].var_dev.dev, nod);</p>
<p>	sculldev[lv].quantum_size=quantum_size;<br />
	sculldev[lv].device_size=device_size;<br />
	sculldev[lv].data_size=data_size;<br />
	sculldev[lv].qset_size=qset_size;</p>
<p>	majorno=MAJOR(dev);<br />
	minorno=MINOR(dev);<br />
	printk(&quot;value of a is&#8212;&#8211;%d\n&quot;,a);<br />
	printk(&quot;majorno assigned is&#8212;&#8211;%d\n&quot;,majorno);<br />
	printk(&quot;minorno assigned is&#8212;&#8211;%d\n&quot;,minorno);<br />
	}<br />
	printk(&quot;quantum size&#8212;&#8211;%d\n&quot;,quantum_size);<br />
	printk(&quot;device size&#8212;&#8211;%d\n&quot;,device_size);<br />
	printk(&quot;data size&#8212;&#8211;%d\n&quot;,data_size);<br />
	printk(&quot;qset size&#8212;&#8211;%d\n&quot;,qset_size);<br />
	printk(&quot;scull initiallisation complete :%s\n&quot;,__func__);<br />
	}</p>
<p>static int entry_init(void)<br />
{<br />
	printk(KERN_ALERT &quot;BEGIN: %s\n&quot;,__func__);<br />
	if(!majorno)	//because majorno value is 0<br />
	{<br />
		ret=alloc_chrdev_region(&amp;dev,minorno,nod,DRIVER_NAME);	//when we are registering one device<br />
		if(ret==0)<br />
		{<br />
		 printk(&quot;allocation is ok\n&quot; );<br />
		}<br />
	}<br />
	else<br />
	{<br />
		register_chrdev_region(dev,nod,DRIVER_NAME);	//when we are registering more than 1 device<br />
		printk(&quot;\nIt is in else region\n&quot;);<br />
	}<br />
	minorno = MINOR(dev);<br />
	majorno = MAJOR(dev);<br />
	printk(KERN_ALERT &quot;END: %s\n&quot;,__func__);</p>
<p>memory();<br />
sculldev_initialisation();<br />
return 0;<br />
}</p>
<p>void memory(void)</p>
<p>	{<br />
	printk(KERN_ALERT &quot;BEGIN: %s\n&quot;,__func__);<br />
	sculldev=kmalloc(sizeof(struct Sculldev)*nod , GFP_KERNEL);	//allocate memory to Sculldev<br />
	memset(sculldev,&#039;&#039;,nod *sizeof(struct Sculldev));</p>
<p>	if(sculldev==0)<br />
	{<br />
		printk(&quot;memory allocation failed&quot;);<br />
	}<br />
	else<br />
	{<br />
		printk(&quot;memory allocation is done\n&quot;);<br />
	}<br />
	printk(KERN_ALERT &quot;END: %s\n&quot;,__func__);</p>
<p>}</p>
<p>static void cleanup(void)<br />
{<br />
	int lv;<br />
	printk(KERN_ALERT &quot;BEGIN: %s\n&quot;,__func__);<br />
	printk(KERN_ALERT&quot;\ngood bye\n&quot;);<br />
for(lv=0;lv&lt;nod;lv++)<br />
{<br />
	//dev=MKDEV(majorno,lv);<br />
	cdev_del(&amp;sculldev[lv].var_dev);<br />
	unregister_chrdev_region(sculldev[lv].var_dev.dev ,nod);<br />
	//unregister_chrdev_region(dev,nod);<br />
}<br />
kfree(sculldev);	//free allocated memory to Sculldev<br />
printk(KERN_ALERT&quot;END:%s\n&quot;,__func__);<br />
}<br />
module_init(entry_init);<br />
module_exit(cleanup);</p>
<p>@</p>
<p>1.7<br />
log<br />
@add loop variable in loop for reading<br />
remove some bug in reading loop<br />
@<br />
text<br />
@d2 1<br />
a2 1<br />
int create_qset(struct scull_qset *qset,int nosps)	//creating qset and allocating memory to qset(64 bytes)<br />
d9 1<br />
a9 1<br />
for(lv=0;lv&lt;qset;lv++)<br />
d18 1<br />
a18 1<br />
int create_quantum(struct scull_qset *qset,int noq)		//creating quantum and locating memory to quantum(8 quantum per qset)<br />
d20 1<br />
a20 1<br />
	int i,count;<br />
d25 8<br />
a32 1<br />
for(i=0;inext=(struct scull_qset *)(kmalloc(sizeof(struct scull_qset),GFP_KERNEL));	//allocating memory to the next scull_qset<br />
d66 1<br />
a72 1<br />
	printk(KERN_ALERT&#8221;read open SUCCESSFULLY : %s\n&#8221;,__func__);<br />
d74 4<br />
a77 4<br />
        struct scull_qset *qset;<br />
        int noq,nosqs,i,ret,loop;<br />
        int nobpq,noctw,nocsw;<br />
        noq=nosqs=nobpq=noctw=nocsw=0;<br />
d79 2<br />
a80 2<br />
        nocsw=0;<br />
        noctw=count;<br />
d82 1<br />
d90 1<br />
a90 1<br />
if(count%(quantum_size*qset_size));<br />
a91 1<br />
        pdev-&gt;scull_qset=create_scull_qset(nosqs);      //creating scull_qset(Sculldev *pdev pointing towards *scull_qset)<br />
d100 1<br />
a100 3<br />
        create_qset(qset,nosqs);        //creating _qset<br />
        create_quantum(qset,noq);       //creating _quantum</p>
<p>d111 1<br />
a111 1<br />
for(i=0;iquantum_size)  //if noctw&gt;quantum_size ,nobpq is equql to the quantum_size that is 8<br />
d116 1<br />
a116 1<br />
        nobpq=noctw;            //else nobpq is equal to the noctw<br />
d118 4<br />
a121 5<br />
        ret=copy_to_user(buff+nocsw,qset-&gt;data[i],nobpq);                     //copy data from user space<br />
        printk(KERN_ALERT&#8221;quantum=%d-&gt;read=%s\n&#8221;,i,qset-&gt;data[i]);     //data write in quantum<br />
        nocsw=nocsw+(nobpq-ret);<br />
        noctw=noctw-(nobpq-ret);<br />
        printk(KERN_ALERT&#8221;no. of byte successfully read=%d\n&#8221;,nocsw);<br />
d128 3<br />
a130 2<br />
	printk(KERN_ALERT&#8221;read close SUCCESSFULLY: %s\n&#8221;,__func__);<br />
        return count-ret;<br />
d134 1<br />
d139 2<br />
a140 2<br />
	struct scull_qset *qset;<br />
	int noq,nosqs,i,ret,loop;<br />
d151 1<br />
a151 1<br />
if(count%(quantum_size*qset_size));<br />
d159 1<br />
a159 1<br />
if(count%quantum_size);<br />
d161 1<br />
d191 1<br />
d328 1<br />
a328 1<br />
static void exit(void)<br />
d344 1<br />
a344 1<br />
module_exit(exit);<br />
@</p>
<p>1.6<br />
log<br />
@remove some bug from write function<br />
added loop variable to specify no of quantum in 2nd qset<br />
@<br />
text<br />
@a1 1</p>
<p>@</p>
<p>1.5<br />
log<br />
@creating read function<br />
use copy to user function<br />
modifing the copy to user function<br />
@<br />
text<br />
@a130 3<br />
	nobpq=quantum_size;<br />
	nocsw=0;<br />
	noctw=count;<br />
d152 3<br />
d166 1<br />
a166 1<br />
for(i=0;idata=kmalloc(sizeof(int *)*qset_size,GFP_KERNEL);	//allocating memory to the *qset_size<br />
qset=qset-&gt;next;<br />
d19 1<br />
a19 1<br />
int create_quantum(struct scull_qset *qset,int noq)<br />
d29 1<br />
a29 1<br />
	printk(KERN_ALERT&#8221;quantum number=%u&#8221;,&amp;qset-&gt;data[i]);<br />
d37 1<br />
a37 1<br />
struct scull_qset* create_scull_qset(int fnosqs)<br />
d60 58<br />
d119 1<br />
a119 1<br />
	return 0;<br />
d122 1<br />
d131 4<br />
d156 1<br />
a156 5<br />
	printk(KERN_ALERT&#8221;write SUCCESSFULLY : %d\n&#8221;,count);<br />
	nobpq=quantum_size;<br />
	nocsw=0;<br />
	noctw=count;<br />
	while(nosqs)<br />
d166 1<br />
a166 1<br />
	for(i=0;i)<br />
d100 1<br />
a100 1</p>
<p>d104 2<br />
a105 2</p>
<p>	}*/<br />
d117 5<br />
a122 1<br />
	printk(KERN_ALERT&#8221;no. of byte successfully write=%d\n&#8221;,nocsw);<br />
@</p>
<p>1.1<br />
log<br />
@Initial revision<br />
@<br />
text<br />
@d93 4<br />
a96 1<br />
	for(i=0;idata[i],buff,count);			//copy data from user space<br />
	printk(KERN_ALERT&#8221;write in quantum=%s\n&#8221;,(char *)qset-&gt;data[i]);	//data write in quantum<br />
d118 1<br />
d121 1<br />
a121 1<br />
	return count;<br />
@</p>
<p>header.h</p>
<p>head	1.2;<br />
access;<br />
symbols;<br />
locks<br />
	amitdalal:1.2; strict;<br />
comment	@ * @;</p>
<p>1.2<br />
date	2013.07.11.17.39.26;	author amitdalal;	state Exp;<br />
branches;<br />
next	1.1;</p>
<p>1.1<br />
date	2013.07.10.21.25.25;	author amitdalal;	state Exp;<br />
branches;<br />
next	;</p>
<p>desc<br />
@added asm header .h for copy from user<br />
@</p>
<p>1.2<br />
log<br />
@remove init and cleanup prototype<br />
@<br />
text<br />
@#include    //need for registring( for everything)<br />
#include<br />
#include        //needed for KERN_ALERT<br />
#include        //needed for kmalloc and flag of kmalloc<br />
#include        //needed cdev structure<br />
#include<br />
#include<br />
#include<br />
MODULE_LICENSE(&#8220;GPL&#8221;);<br />
MODULE_AUTHOR(&#8220;AMIT DALAL&#8221;);<br />
#define DRIVER_NAME &#8220;DALAL DRIVER&#8221;<br />
#ifndef DEBUG<br />
#define DEBUG<br />
#endif<br />
#define  QUANTUM_SIZE 8<br />
#define  DATA_SIZE 0<br />
#define  DEVICE_SIZE 4096<br />
#define  QSET_SIZE 8</p>
<p>#ifndef MAJORNO<br />
#define MAJORNO 0<br />
#endif</p>
<p>#ifndef MINORNO<br />
#define MINORNO 0<br />
#endif</p>
<p>#ifndef NOD<br />
#define NOD 10<br />
#endif<br />
dev_t dev;<br />
int ret;<br />
int minorno=MINORNO;<br />
int majorno=MAJORNO;<br />
int nod=NOD;<br />
int  quantum_size=QUANTUM_SIZE;<br />
 int qset_size=QSET_SIZE;<br />
 int data_size=DATA_SIZE;<br />
int device_size=DEVICE_SIZE;</p>
<p>int scull_release(struct inode *, struct file *);<br />
int scull_open(struct inode *, struct file *);<br />
void sculldev_initialisation(void);<br />
void memory(void);<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>struct Sculldev                 //user defined structure Sculldev<br />
{<br />
struct Scull_qset *scull_qset;	//pointing to 1st quqntum set<br />
int quantum_size;		//current quantum size<br />
int qset_size;			//current array size<br />
int data_size;		//amount of data stored here<br />
int device_size;<br />
int open_count;<br />
struct cdev var_dev;    	//cdev structure defined in  cdev header file<br />
}*sculldev;      //used for pointing Sculldev</p>
<p>int scull_trim(struct Sculldev *);<br />
struct Scull_qset<br />
{<br />
	struct Scull_qset *next;<br />
	void **data;<br />
};<br />
struct file_operations fops=<br />
{<br />
	open:scull_open,<br />
	read:scull_read,<br />
	write:scull_write,<br />
	release:scull_release</p>
<p>};<br />
struct Scull_qset* create_scull_qset(int);</p>
<p>@</p>
<p>1.1<br />
log<br />
@Initial revision<br />
@<br />
text<br />
@d39 1<br />
a39 1<br />
 int device_size=DEVICE_SIZE;<br />
d50 1<br />
a50 1<br />
struct scull_qset *scull_qset;	//pointing to 1st quqntum set<br />
d60 1<br />
a60 1<br />
struct scull_qset<br />
d62 1<br />
a62 1<br />
	struct scull_qset *next;<br />
d73 1<br />
a73 1<br />
struct scull_qset* create_scull_qset(int);<br />
@</p>
<p>app.c<br />
head	1.2;<br />
access;<br />
symbols;<br />
locks<br />
	amitdalal:1.2; strict;<br />
comment	@ * @;</p>
<p>1.2<br />
date	2013.07.11.00.32.38;	author amitdalal;	state Exp;<br />
branches;<br />
next	1.1;</p>
<p>1.1<br />
date	2013.07.11.00.04.48;	author amitdalal;	state Exp;<br />
branches;<br />
next	;</p>
<p>desc<br />
@extended the message in buff<br />
@</p>
<p>1.2<br />
log<br />
@extended the message to check whether my multiple qset is working or not for above 64 byte<br />
@<br />
text<br />
@#include<br />
#include<br />
#include<br />
int main(int argc , char *argv[])<br />
{<br />
int fd,count,len;<br />
char buff[]=&#8221;AMIT DALAL have great time in emblogic embedded technologies pvt ltd,noida,INDIA&#8221;;<br />
if(argc!= 2)<br />
{<br />
perror(&#8220;error\n&#8221;);<br />
}<br />
else<br />
{<br />
//fd=open(argv[1],O_RDONLY);<br />
fd=open(argv[1],O_WRONLY);<br />
if(fd&lt;0)<br />
{<br />
perror(&quot;error\n&quot;);<br />
}<br />
len=strlen(buff);<br />
//count=read(fd,buff,len);<br />
count=write(fd,buff,len);</p>
<p>if(count==len)<br />
{<br />
printf(&quot;successfully write\n&quot;);<br />
}<br />
if(count&lt;len)<br />
{<br />
printf(&quot;partially write\n&quot;);<br />
}<br />
if(count==-1)<br />
{<br />
printf(&quot;some error in writing\n&quot;);<br />
}<br />
if(count==0)<br />
{<br />
printf(&quot;nothing write\n&quot;);<br />
}<br />
printf(&quot;no of byte write successfully=%d\n&quot;,count);<br />
printf(&quot;fd open successfully=%d\n&quot;,fd);<br />
printf(&quot;length is=%d\n&quot;,len);<br />
close(fd);<br />
return 0;<br />
}</p>
<p>}<br />
@</p>
<p>1.1<br />
log<br />
@Initial revision<br />
@<br />
text<br />
@d7 1<br />
a7 1<br />
char buff[]=&quot;amit dalal have great time in emblogic pvt ltd,noida&quot;;<br />
@</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/device-driver-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DEVICE DRIVER</title>
		<link>https://www.emblogic.com/blog/07/device-driver-5/</link>
		<comments>https://www.emblogic.com/blog/07/device-driver-5/#comments</comments>
		<pubDate>Fri, 05 Jul 2013 06:58:05 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6666</guid>
		<description><![CDATA[i have done the open close call for 10 node and also done the container_of]]></description>
				<content:encoded><![CDATA[<p>i have done the open close call for 10 node and also done the container_of</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/device-driver-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DEVICE DRIVER</title>
		<link>https://www.emblogic.com/blog/07/device-driver-4/</link>
		<comments>https://www.emblogic.com/blog/07/device-driver-4/#comments</comments>
		<pubDate>Wed, 03 Jul 2013 08:54:23 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>
		<category><![CDATA[pravjot sir]]></category>
		<category><![CDATA[siddarth sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6668</guid>
		<description><![CDATA[I have done REGISTRATION, UNREGISTERED AND OPEN CLOSE in single node device driver but not able to unregister it for 10 node.. &#160;]]></description>
				<content:encoded><![CDATA[<p>I have done REGISTRATION, UNREGISTERED AND OPEN CLOSE in single node device driver but not able to unregister it for 10 node..</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/device-driver-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
