EmbLogic's Blog

CHARACTER DRIVER

i have done llseek successffully for write and read and now back to assignment sir gave us…

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
total revisions: 13; selected revisions: 13
description:
added function of copy from user
printk the no of byte writen successfully for one quantum
—————————-
revision 1.13 locked by: amitdalal;
date: 2013/07/17 00:08:24; author: amitdalal; state: Exp; lines: +0 -1
added some variable for write using llseek
added bpos for position update in copy from user
define bpos flag
—————————-
revision 1.12
date: 2013/07/17 00:07:11; author: amitdalal; state: Exp; lines: +0 -1
added variable bpos for position
use flag and j
—————————-
revision 1.11
date: 2013/07/17 00:02:29; author: amitdalal; state: Exp; lines: +0 -2
added some variable for reading using llseek
fix the problem related with left out of some first character
—————————-
revision 1.10
date: 2013/07/16 23:37:14; author: amitdalal; state: Exp; lines: +244 -194
give call to llseek
define function llseek
—————————-
revision 1.9
date: 2013/07/15 21:52:06; author: amitdalal; state: Exp; lines: +67 -41
added loff_t function to .c file
use f_pos for storing the value of pos
—————————-
revision 1.8
date: 2013/07/11 17:37:19; author: amitdalal; state: Exp; lines: +53 -38
modified code for write to get required no of qset
add lnoq variable
—————————-
revision 1.7
date: 2013/07/11 06:05:24; author: amitdalal; state: Exp; lines: +0 -1
add loop variable in loop for reading
remove some bug in reading loop
—————————-
revision 1.6
date: 2013/07/11 05:37:03; author: amitdalal; state: Exp; lines: +4 -4
remove some bug from write function
added loop variable to specify no of quantum in 2nd qset
—————————-
revision 1.5
date: 2013/07/11 05:18:10; author: amitdalal; state: Exp; lines: +76 -16
creating read function
use copy to user function
modifing the copy to user function
—————————-
revision 1.4
date: 2013/07/11 00:41:53; author: amitdalal; state: Exp; lines: +1 -0
debbuging problem causing kernel crash
—————————-
revision 1.3
date: 2013/07/11 00:19:58; author: amitdalal; state: Exp; lines: +11 -7
added variable loop
use while loop for creating multiple qset
—————————-
revision 1.2
date: 2013/07/11 00:00:36; author: amitdalal; state: Exp; lines: +25 -4
added the function of quantum written for 8 byte
debugging the problem related to writting of data not 8 byte
fix problem successfully related to written
—————————-
revision 1.1
date: 2013/07/10 21:22:34; author: amitdalal; state: Exp;
Initial revision
=============================================================================
header.h

RCS file: header.h,v
Working file: header.h
head: 1.4
branch:
locks: strict
amitdalal: 1.4
access list:
symbolic names:
keyword substitution: kv
total revisions: 4; selected revisions: 4
description:
added asm header .h for copy from user
—————————-
revision 1.4 locked by: amitdalal;
date: 2013/07/16 23:38:48; author: amitdalal; state: Exp; lines: +7 -7
include prototype of llseek
define llseek in file operation
—————————-
revision 1.3
date: 2013/07/15 21:53:32; author: amitdalal; state: Exp; lines: +5 -2
give prototype of llseek
define it in file operation
—————————-
revision 1.2
date: 2013/07/11 17:39:26; author: amitdalal; state: Exp; lines: +5 -5
remove init and cleanup prototype
—————————-
revision 1.1
date: 2013/07/10 21:25:25; author: amitdalal; state: Exp;
Initial revision
=============================================================================

app.c

RCS file: app.c,v
Working file: app.c
head: 1.5
branch:
locks: strict
amitdalal: 1.5
access list:
symbolic names:
keyword substitution: kv
total revisions: 5; selected revisions: 5
description:
extended the message in buff
—————————-
revision 1.5 locked by: amitdalal;
date: 2013/07/17 00:11:50; author: amitdalal; state: Exp; lines: +0 -1
added variable
use lseek
update write
printk offset value
—————————-
revision 1.4
date: 2013/07/16 23:40:05; author: amitdalal; state: Exp; lines: +71 -68
include header file for lseek
set the offset
printf the value of offset
—————————-
revision 1.3
date: 2013/07/15 21:56:21; author: amitdalal; state: Exp; lines: +52 -15
added lseek for f_pos
printf the newpos
—————————-
revision 1.2
date: 2013/07/11 00:32:38; author: amitdalal; state: Exp; lines: +1 -1
extended the message to check whether my multiple qset is working or not for above 64 byte
—————————-
revision 1.1
date: 2013/07/11 00:04:48; author: amitdalal; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Tagged | Leave a comment

Char Driver Logfile

RCS file: first_driver.c,v
Working file: first_driver.c
head: 2.12
branch:
locks: strict
rahul: 2.12
access list:
symbolic names:
keyword substitution: kv
total revisions: 22; selected revisions: 22
description:
base prog.
able to register the device through old method.
—————————-
revision 2.12 locked by: rahul;
date: 2013/07/14 06:21:44; author: rahul; state: Exp; lines: +57 -19
added information of the read function.
—————————-
revision 2.11
date: 2013/07/13 11:36:53; author: rahul; state: Exp; lines: +24 -29
done with read & write.
—————————-
revision 2.10
date: 2013/07/13 08:15:40; author: rahul; state: Exp; lines: +132 -29
m happy now…… after 24 hours i am able debug my program….. now it is able to write & read even for more then 64 bytes…
bug was with memory allocation….
—————————-
revision 2.9
date: 2013/07/11 12:59:35; author: rahul; state: Exp; lines: +30 -20
done with multiple qset entry.
added while loop along with the if ele condition.
—————————-
revision 2.8
date: 2013/07/11 11:15:03; author: rahul; state: Exp; lines: +21 -6
done with multiple quantums.
—————————-
revision 2.7
date: 2013/07/11 08:14:55; author: rahul; state: Exp; lines: +9 -4
able to write from user buffer to quantum. but only for 1 quantum.
now tring for multiple quantums.
—————————-
revision 2.6
date: 2013/07/11 07:54:58; author: rahul; state: Exp; lines: +66 -31
able to create quantum.
—————————-
revision 2.5
date: 2013/07/10 09:34:52; author: rahul; state: Exp; lines: +52 -8
created function for quantum creation.
testing ok.
—————————-
revision 2.4
date: 2013/07/09 11:51:18; author: rahul; state: Exp; lines: +54 -6
created scullqset function.
allocated memory for sculqset using kmalloc.
—————————-
revision 2.3
date: 2013/07/08 11:48:32; author: rahul; state: Exp; lines: +25 -3
mapped scull_read & scull_wrrite function with open call.
—————————-
revision 2.2
date: 2013/07/08 08:33:04; author: rahul; state: Exp; lines: +11 -10
initialises the value of open count in struct scull dev.
—————————-
revision 2.1
date: 2013/07/05 07:23:17; author: rahul; state: Exp; lines: +12 -11
done with looping also.
dev value at unregistration should be major no and 0.
—————————-
revision 2.0
date: 2013/07/04 11:50:08; author: rahul; state: Exp; lines: +4 -4
*** empty log message ***
—————————-
revision 1.9
date: 2013/07/04 11:41:53; author: rahul; state: Exp; lines: +31 -12
done for single device again
—————————-
revision 1.8
date: 2013/07/04 08:24:47; author: rahul; state: Exp; lines: +49 -20
inserted function for scull_trim.
done preservation of private data in struct file.
—————————-
revision 1.7
date: 2013/07/02 13:49:48; author: rahul; state: Exp; lines: +23 -24
done for 10 devices
—————————-
revision 1.6
date: 2013/07/02 13:10:25; author: rahul; state: Exp; lines: +2 -2
*** empty log message ***
—————————-
revision 1.5
date: 2013/07/02 13:09:23; author: rahul; state: Exp; lines: +5 -4
final with single devices.
—————————-
revision 1.4
date: 2013/07/02 12:40:45; author: rahul; state: Exp; lines: +14 -14
done for one number of device.
—————————-
revision 1.3
date: 2013/07/02 08:58:15; author: rahul; state: Exp; lines: +65 -8
done with scull initialisation scull_init().
—————————-
revision 1.2
date: 2013/07/01 11:10:21; author: rahul; state: Exp; lines: +32 -5
inserted for loop for calculating diffrnt minor numbers against one major numbr.
otherwise it is working fine.
—————————-
revision 1.1
date: 2013/07/01 07:24:56; author: rahul; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

30.01.30 : Taruna

RCS file: lkm.c,v
Working file: lkm.c
head: 1.18
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 18; selected revisions: 18
description:
Created the base module.
Used alloc_chrdev_region and register_chrdev_region to register the driver and unregistered it using unregister_chrdev_region.
—————————-
revision 1.18
date: 2013/07/17 08:03:34; author: taruna; state: Exp; lines: +62 -18
Did lseek successfully in reading for offset less than 8.
—————————-
revision 1.17
date: 2013/07/16 10:18:27; author: taruna; state: Exp; lines: +34 -11
Implemented lseek for offset less than 8.
Gave this lseek in reading.
—————————-
revision 1.16
date: 2013/07/16 06:00:14; author: taruna; state: Exp; lines: +74 -19
Declared the scull_lseek().
And tracked the offset position in filep->f_pos where filep is a pointer to struct file.
Printed the offset position.
Did this in scull_read().
—————————-
revision 1.15
date: 2013/07/15 04:58:39; author: taruna; state: Exp; lines: +101 -3
Able to read upto the user defined no. of characters successfully.
—————————-
date: 2013/07/11 10:12:48; author: taruna; state: Exp; lines: +45 -15
Implemented writing to multiple quantums of multiple qsets successfully.
Calculated lnoq i.e, local no. of quantums for using in the inner loop so that it never runs for more than 8 bytes which is the size of one quantum.
for moving to the next scullqset , preserved the size of bytes to be written in fnobtw and updated fnobtw and fnobsw.
Also initialised nobsw to 0 after every completion of inner loop.
—————————-
revision 1.13
date: 2013/07/11 06:39:16; author: taruna; state: Exp; lines: +14 -8
Implemented writing into multiple quantums using copy_from-user.
—————————-
revision 1.12
date: 2013/07/11 06:10:40; author: taruna; state: Exp; lines: +69 -5
Implemented writing to quantums using copy_from_user() for 1 quantum.
—————————-
revision 1.11
date: 2013/07/09 10:18:35; author: taruna; state: Exp; lines: +53 -5
Implemented creat_qset for any no. of qsets.
—————————-
revision 1.10
date: 2013/07/09 07:34:31; author: taruna; state: Exp; lines: +26 -8
Implemented the creat_scullqset() for any no. of scullqsets.
—————————-
revision 1.9
date: 2013/07/09 07:18:51; author: taruna; state: Exp; lines: +59 -2
Calculated the no. of scullqsets and no. of quantums.
Implemented creat_scullqset for creating one scullqset.
—————————-
revision 1.8
date: 2013/07/08 08:31:39; author: taruna; state: Exp; lines: +29 -0
Mapped the read and write to scull_read and scull_write() respectively.
—————————-
revision 1.7
date: 2013/07/08 07:32:41; author: taruna; state: Exp; lines: +20 -1
Initialised opencount in the scull_init function.
Declared the scull_trim().
—————————-
revision 1.6
date: 2013/07/04 06:51:22; author: taruna; state: Exp; lines: +42 -0
Declared lsculldev in scull_open() , got a local device.
Then got the cdev structure contained in ScullDev structure.
Saved the lsculldev to preserve the device in private_data of struct file.

Checked the access mode and called the function scull_trim to trim the device.
—————————-
revision 1.5
date: 2013/07/03 09:27:15; author: taruna; state: Exp; lines: +54 -2
Wrote the functions : init_scull , scull_open and scull_release.
—————————-
revision 1.4
date: 2013/07/03 07:43:05; author: taruna; state: Exp; lines: +35 -27
Used loop to add nod no. of devices in scull_setup() function.
Stored the major and minor number from alloc_chrdev_region in variable tmp using MKDEV and passed this tmp in unregister_chrdev_region in the cleanup function.
—————————-
revision 1.3
date: 2013/07/03 06:56:13; author: taruna; state: Exp; lines: +51 -0
Initialized the struct cdev through function scull_setup.
Initializeed the owner , operations and dev of struct cdev.

used cdev_init and cdev_add in scull_setup function and cdev_del in the cleanup function.
—————————-
revision 1.2
date: 2013/07/03 05:59:03; author: taruna; state: Exp; lines: +18 -2
Allocated memory for struct Sculldev using kmalloc and freed that memory using kfree in cleanup function.
—————————-
revision 1.1
date: 2013/07/03 05:35:59; author: taruna; state: Exp;
Initial revision
102,1 98%
=============================================================================
103,1 Bot

Posted in Character Driver, Device Drivers, Uncategorized | Tagged | Leave a comment

Char Driver Logfile

charlogfilepresently working on lseek implementation in write trying to rectify the problems in write operation using lseek.

Posted in Uncategorized | Leave a comment

E30.01.30 Om Parkash

RCS file: chard.c,v
Working file: chard.c
head: 1.6
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 6;     selected revisions: 6
description:
registered and unregistered devices using alloc_chrdev_region and unregis_chrdev_region.
implemented scull_setup function.
implemented scull_open routine.
started scull_trim,scull_release,scull_write and scull_read routines.
working well till now.
—————————-
revision 1.6
date: 2013/07/16 17:56:34;  author: emblogic;  state: Exp;  lines: +235 -65
Implemented lseek using scull_lseek.
new quantums get created when needed.
working well.
—————————-
revision 1.5
date: 2013/07/11 08:48:05;  author: emblogic;  state: Exp;  lines: +19 -47
implemented read and write successfully for any no. of bytes.
checked for upto 1000 bytes .successfully written to scull Quantums and read from the quantums as well.
—————————-
revision 1.4
date: 2013/07/10 11:43:39;  author: emblogic;  state: Exp;  lines: +89 -8
read successfully .
—————————-
revision 1.3
date: 2013/07/10 06:02:17;  author: emblogic;  state: Exp;  lines: +58 -4
written to scull successfully using write2scull function.
working well.
but printing garbage due to absence of NULL.
—————————-
revision 1.2
date: 2013/07/09 12:03:54;  author: emblogic;  state: Exp;  lines: +170 -5
implemented creat_scullqset,creat_qset and creat_quantums….aloocated memory to write to scull.
quantums created successfully .
working well till now.
—————————-
revision 1.1
date: 2013/07/08 11:03:54;  author: emblogic;  state: Exp;
Initial revision
=============================================================================
~

Posted in Character Driver, Device Drivers | Tagged | Leave a comment

Avtar Singh E-30.01.30

RCS file: new_lkm.c,v
Working file: new_lkm.c
head: 1.16
branch:
locks: strict
root: 1.16
access list:
symbolic names:
keyword substitution: kv
total revisions: 17;    selected revisions: 17
description:
in this i register many no. of devices that we can provide at the time of insmod as command line argument.
use setup_struct_cdev() function i.e user defined to setup of the struct cdev,in this we use cdev_init() & cdev_add().
in cleanup we use cdev_del to delete the cdev setup for all devices.
also used kmalloc() & kfree() to allocate & deallocate the memory to scull_dev (pointer of struct Sculldev).
—————————-
revision 1.16   locked by: root;
date: 2013/07/16 13:54:00;  author: root;  state: Exp;  lines: +2 -2
working for lseek of more than one quantums also .
till now driver can lseek before write after write .
results are comming correct.
—————————-
revision 1.15
date: 2013/07/16 13:03:18;  author: root;  state: Exp;  lines: +29 -25
working for write ,then again write some data after 5 positions.
reading the whole data after two write operations .
checked only for less than 8 bytes to append.
working successfully till now.
—————————-
revision 1.14
date: 2013/07/16 11:21:28;  author: root;  state: Exp;  lines: +72 -14
performing lseek by any no. of positions successfully.
written only for SEEK_SET.
performed lseek before write & at the time of read operations.
till now it is working properly.
—————————-
revision 1.13
date: 2013/07/16 05:17:19;  author: root;  state: Exp;  lines: +52 -25
implemented lseek when we read after writing to the quantums.
only SEEK_SET implemented in the scull_lseek.
it can seek within the quantum , inter quantum & inter scullqset.
till now it is working correctly.
—————————-
revision 1.12
date: 2013/07/15 07:39:03;  author: root;  state: Exp;  lines: +23 -4
coming in different case in scull_lseek according to the request of application.
defined variable new_position to return the value to application & to store the new position after lseek operation in scull_lseek.
—————————-
revision 1.11
date: 2013/07/15 06:28:03;  author: root;  state: Exp;  lines: +34 -15
add scull_lseek() to seek the cursor position according to the lseek call in the app.c.
printing offset position & offset type correctly.
working successfully till now.
—————————-
revision 1.10
date: 2013/07/11 15:05:36;  author: root;  state: Exp;  lines: +36 -8
gave response to read call of application.
scull_read() function is taking request of read call.
use copy_to_user() function to copy no. of bytes requested by application from kernel space i.e quantums to the user buffer.
rbuff is our user buffer in our case.
successfully jumping from one scullqset to another when one scullqset fills.
overall successfully writing to user buffer is performing.
—————————-
revision 1.9
date: 2013/07/11 12:09:24;  author: root;  state: Exp;  lines: +40 -2
to read call driver is comming in scull
scull_read().
here copy_to_user() is working properly only to write first quantum from kernel space to user buffer i.e rbuff in my case.
it is successfully writing upto this.
—————————-
revision 1.8
date: 2013/07/11 10:48:47;  author: root;  state: Exp;  lines: +47 -8
in scull_write(),use copy_from_user() to copy data from user buffer i.e wbuff in our case to the quantums that was allocated.
also after copying data from ubuff to kernel buffer i.e quantums i link the fscullqset with the scullqset of the sculldev that was stored in the filep->private_data .
till now it is successfully working.
it can also move from one scullqset to next when all the quantums of the present scullqset fills.
—————————-
revision 1.7
date: 2013/07/10 10:20:09;  author: root;  state: Exp;  lines: +11 -8
in create_scullqset(),make fscullqset->next = NULL.
sometimes without doing this result in kernel crash in create_quantum().
—————————-
revision 1.6
date: 2013/07/10 07:40:20;  author: root;  state: Exp;  lines: +215 -3
declaire variable noq & nosqs for no. of quantum & no. of scullqset respectively.
from the given info. in header ,found the value of noq & nosqs.
now to create nosqs called function create_scullqset(), &to create no. of qsets i called function create_qset() .
at last i called create_quantum() to create requirted no. of quantums.
value in size comes from application app.c ,i.e 3rd argument of write.
till now working successfully.
—————————-
revision 1.5
date: 2013/07/08 11:15:20;  author: emblogic;  state: Exp;  lines: +97 -18
defined read & write function for reading & writing to & from the kernel buffer to user space buffer.
only control is going to read & write when called by application .
noting is performing in the read & write function.
—————————-
revision 1.4
date: 2013/07/08 11:14:01;  author: emblogic;  state: Exp;  lines: +0 -3
2 lines deleted.
—————————-
revision 1.3
date: 2013/07/08 11:12:58;  author: emblogic;  state: Exp;  lines: +2 -0
2 lines added.
—————————-
revision 1.2
date: 2013/07/02 12:25:03;  author: root;  state: Exp;  lines: +57 -7
branches:  1.2.1;
driver comming in the open_file function after receiving the open call from the application ,app.c.
initialize struct Sculldev elements like qset_size,quantum_size,device_size & data_size.
added open_file() & close_file() function to give response yo the open & close call of app.c program.
in script ,we make node to interface b/w US & KS by using mknod command.
—————————-
revision 1.1
date: 2013/07/02 08:50:13;  author: root;  state: Exp;
Initial revision
—————————-
revision 1.2.1.1
date: 2013/07/05 06:49:09;  author: emblogic;  state: Exp;  lines: +48 -17
in open_file function i use container_of() function to map the machine memory & device memory.
this function return address of that mapped memory whis i am storing in the lsculldev i.e pointer to struct Sculldev.
now this address is put in the private data of struct file .
now i check the requested permission by anding the f_flags member of struct file with O_ACCMODE .
now accordingly control goes to the scull_trim function.
=============================================================================

Posted in Character Driver | Tagged | Leave a comment

E 30:01:30 Vikram Sharma

CS file: ./ch_d.c,v
Working file: ./ch_d.c
head: 1.15
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 15;    selected revisions: 15
description:
Basic Driver Arch. with cdev initionlized
—————————-
revision 1.15
date: 2013/07/16 23:23:14;  author: vikram;  state: Exp;  lines: +10 -1
Problem While reading second Qset…….
—————————-
revision 1.14
date: 2013/07/16 21:37:09;  author: vikram;  state: Exp;  lines: +54 -20
problem While Reading Multiple qsets.
—————————-
revision 1.13
date: 2013/07/16 16:27:32;  author: vikram;  state: Exp;  lines: +35 -16
lseek Implemented compltly on Write.
still have to implement for read.
—————————-
revision 1.12
date: 2013/07/15 21:47:38;  author: vikram;  state: Exp;  lines: +9 -5
lseek partially working.
—————————-
revision 1.11
date: 2013/07/15 19:55:12;  author: vikram;  state: Exp;  lines: +69 -5
partially implemented lseek.
—————————-
revision 1.10
date: 2013/07/13 17:56:16;  author: vikram;  state: Exp;  lines: +26 -12
read done for Now.
—————————-
revision 1.9
date: 2013/07/13 15:03:39;  author: vikram;  state: Exp;  lines: +56 -2
my_read mapped and implemented properly.
—————————-
revision 1.8
date: 2013/07/11 22:50:38;  author: vikram;  state: Exp;  lines: +62 -0
mapped my_read…..copy_to_user, still to be implemented.
—————————-
revision 1.7
date: 2013/07/11 18:14:14;  author: vikram;  state: Exp;  lines: +0 -1
Written 300+ Bytes in ScullDev.
—————————-
revision 1.6
date: 2013/07/11 17:46:13;  author: vikram;  state: Exp;  lines: +113 -7
Written Over Kernel Space.
for multiple quantums.
—————————-
revision 1.5
date: 2013/07/10 17:25:17;  author: vikram;  state: Exp;  lines: +1 -1
create_scullqset Implemented.
create_qset implimented.
create_quantum Implemented
—————————-
revision 1.4
date: 2013/07/10 15:41:12;  author: vikram;  state: Exp;  lines: +178 -3
create quantum done
—————————-
revision 1.3
date: 2013/07/08 20:24:35;  author: vikram;  state: Exp;  lines: +80 -3
my_write implemented.
scull_trim implemented.
—————————-
revision 1.2
date: 2013/07/05 22:13:30;  author: vikram;  state: Exp;  lines: +32 -2
maped open and release with my_open and my_close.
—————————-
revision 1.1
date: 2013/07/04 01:38:08;  author: vikram;  state: Exp;
Initial revision
=============================================================================

Posted in Character Driver, Device Drivers | Tagged | Leave a comment

Character Driver Logfile

Posted in Uncategorized | Leave a comment

Character Driver

Done with write call

RCS File

head 1.8;
access;
symbols;
locks; strict;
comment @ * @;
1.8
date 2013.07.14.10.18.16; author Ashish; state Exp;
branches;
next 1.7;

1.7
date 2013.07.13.07.47.07; author Ashish; state Exp;
branches;
next 1.6;

1.6
date 2013.07.11.08.29.33; author Ashish; state Exp;
branches;
next 1.5;

1.5
date 2013.07.11.05.31.28; author Ashish; state Exp;
branches;
next 1.4;

1.4
date 2013.07.09.10.25.39; author Ashish; state Exp;
branches;
next 1.3;

1.3
date 2013.07.09.10.15.33; author Ashish; state Exp;
branches;
next 1.2;

1.2
date 2013.07.09.08.29.36; author Ashish; state Exp;
branches;
next 1.1;

1.1
date 2013.07.08.09.52.37; author Ashish; state Exp;
branches;
next ;
desc
@Done with tri
trim.
@
1.8
log
@Some modification with refrence to maximum no. of bytes written in a particular scull
Write fn is already done.
moving to read fn.
@
text
@#include”header.h”

MODULE_LICENSE(“GPL”);
//—————————trim Fn————————————————//
int scull_trim(struct Sculldev *fsculldev)
{
if(!fsculldev)
{
printk(KERN_ERR”Error:No Sculldev\n”);
}
printk(“No error “);
return 0;
}

//————————————-SCULL OPEN———————————
int scull_open(struct inode *inodep,struct file *filep)
{
struct Sculldev *pdev;

printk(“\nScull open function start\n”);
pdev=container_of(inodep->i_cdev,struct Sculldev,c_dev); //mapping RAM memory on Device:Sculldev
filep->private_data=pdev; //preserving it on file as lsculldev is lost
if((filep->f_flags & O_ACCMODE)==O_WRONLY)
{
printk(KERN_ALERT “FILE OPEN “);
scull_trim(pdev);
}
printk(“Scull open function complete\n”);
return 0;
}

//—————————Scull realease———————————————
int scull_release(struct inode *node,struct file *filep)
{

printk(“Scull release function start\n”);
printk(“Scull release function complete\n”);
return 0;
}
//——————————Scull Write———————————————–
ssize_t scull_write(struct file *filep,const char __user *ubuff,size_t size,loff_t *loff )
{
struct Sculldev *lsculldev;
struct ScullQset *lscullqset;
int lv,mnobps,nobpq,noq; //nobps=no.of bytes per scull //noq is no. of quantums required.
int ret=noq=0;
int ls=nobpq=mnobps=0; //no. of bytes per quantum
int nobns=0; //no. if byte in next scull
int nobtw=size; //no. of bytes to write
int nobsw=0;int sno=1; //sno is scull no
int nosqs=0; // no. of scull
mnobps=quantum_size * qset_size; //maximum no. of byteis scull
printk(“\nStarting %s”,__func__);
lsculldev=filep->private_data;
if(!lsculldev)
{
printk(KERN_ALERT “ERROR lsculldev Not declared \n “);
}
noq=size/quantum_size; //no of quantum
if(size % quantum_size)
{
noq++;
}
printk(“no of Quantums are %d”,noq);

nosqs=size/(quantum_size * qset_size); //////this is no. of item required
if(size%(quantum_size * qset_size))
{
nosqs++;
}
printk(“No of SQSET require is %d “,nosqs); //finding how much Qset requires
lsculldev->scullqset=create_sqset(nosqs); //creating ScullQset in lsculldc which point to ScullQset
lscullqset=lsculldev->scullqset; //passing whole ScullQset structure
create_qset(lscullqset,nosqs); //passing whole Scullqset structure and no scull qset require
create_quantum(lscullqset,noq);
nobtw=size;
printk(“\n NO of bytes per quantum is %d “,nobpq);

// ret=copy_from_user(lscullqset->data[lv],ubuff,size);
//printk(“\n quantum no is and data : %s”,(char *)lscullqset->data[lv]);
printk(“\n NO of bytes to write is %d “,nobtw);

while(nosqs!=0)
{

if(nobtw>mnobps)
{
nobns=nobtw-mnobps; //no. of byte to write in next shell
nobtw=mnobps;
ls=noq-quantum_size; //in ls we store no. of quantums want in next shell
noq=quantum_size;
}
for(lv=0;lv<noq;lv++)

{
if(nobtw>quantum_size)
{
nobpq=quantum_size;
}
else
{
nobpq=nobtw;
}
ret=copy_from_user(lscullqset->data[lv],ubuff+nobsw,nobpq);//writing 8 bytes in a quantum
printk(“\nScull is %d quantum no is %d and data : %s”,sno,lv,(char *)lscullqset->data[lv]);
nobsw=nobsw+(nobpq-ret); //no of Bytes Sucessfull Written
nobtw=nobtw+(nobpq-ret);
}
noq=ls;
nobtw=nobns;
nosqs–;
sno++;

}
return size-ret ;

printk(“\nLO JI HOGAYA End %s”,__func__);

}
//==========================Creating ScullQset==========================================================
struct ScullQset *create_sqset(int fnosqs) //we use pointer here becaz it returns a an address …pointer
{
struct ScullQset *lscullqset;
struct ScullQset *start;
int flag=0;
int lv;
int count=0;
printk(“\n WE ARE In CREATE SCullQSET “);

for(lv=0;lv<fnosqs;lv++)
{
if(flag==0)
{
lscullqset=start=(struct ScullQset *)kmalloc(sizeof(struct ScullQset),GFP_KERNEL);//as in linklist we preserve first nodee and allocating memory to first node
flag++;
}
else
{
lscullqset->next=(struct ScullQset *)kmalloc(sizeof(struct ScullQset ),GFP_KERNEL);
lscullqset=lscullqset->next;
}
count++;
}
printk(“\nNo. of ScullQset created is %d”,count);
return start;
}

//===================================Creating Qset======================================>>>>>>.>
int create_qset(struct ScullQset *fscullqset,int fnosqs)
{
int lv;
printk(“\n We are in %s\n”,__func__);
for(lv=0;lv<fnosqs;lv++) //it make qset in more than one scull
{
fscullqset->data=kmalloc(sizeof(int *)*qset_size,GFP_KERNEL); //allocating memory to the data pointer of qset data
fscullqset=fscullqset->next; //pointing to next scullqset …
}
printk(“Success fully Ended %s”,__func__);
return 0;
}

//++++++++++++++++++++++++++++++Creating Quantum+++++++++++++++++++++++++++++++++++++++++++

int create_quantum(struct ScullQset *fscullqset,int fnoq)
{
int lv;int lnoq;int count=0;
printk(“Enter in %s”,__func__);
while(fscullqset!=NULL)
{ if(fnoq>quantum_size)
lnoq=quantum_size;
else
lnoq=fnoq;
for(lv=0;lv<lnoq;lv++)
{
fscullqset->data[lv]=kmalloc(quantum_size,GFP_KERNEL); //we are allocating memory in qset ke data me of quantum_size
count++; // no of quantum created
// printk(KERN_ALERT”quantum number=%u”,&fscullqset->data[lv]);
}
fnoq=fnoq-quantum_size;
fscullqset=fscullqset->next;;
}
printk(“\n no of quantum created %d”,count);

printk(“\n Exiting from %s”,__func__);
return 0;

}

 

//—————————Read Function——————————————————————
ssize_t scull_read(struct file *filep,char __user *ubuff,size_t size,loff_t *loff )
{
//int ret;
printk(“\n Starting %s “,__func__);
//ret=copy_from_user(lscullqset->data[],ubuff,size);
printk(“\nEnd %s”,__func__);
return 0;
}

//=====================================Scull init========================================================
void scull_init(void)
{
printk(“starting__func_\n”);
sculldev->quantum_size=QUANTUM_SIZE;
sculldev->qset_size=QSET_SIZE;
sculldev->data_size=DATA_SIZE;
sculldev->device_size=DEVICE_SIZE;
printk(“Quantum Size is %d “,sculldev->quantum_size);
printk(“\n %s”,__func__);
}

//======================================start=======================================================
static int start(void)
{
printk(KERN_ALERT “WELCOME TO DEVICE DRIVER\n”);
if(!majorno)
{
ret = alloc_chrdev_region(&dev, minorno, nod, DRIVER_NAME);
if(ret==0)
printk(KERN_ALERT “Registration done\n”);
else
printk(“Registration failure\n”);
majorno = MAJOR(dev); //MAJOR Is A Micro to fetch Major no. stored in dev //DEV has major +minor no. =20 bit (major no 12 + minor no 20 )
minorno = MINOR(dev);
}
printk(“Major number assigned is___ %d\n”,majorno);
printk(“Minor number assigned is___ %d\n”,minorno);
sculldev= kmalloc(sizeof(struct Sculldev) * nod, GFP_KERNEL);
memset(sculldev, ”,sizeof(sculldev)*nod);
dev=MKDEV(majorno,minorno);
cdev_init(&sculldev->c_dev, &fop);
sculldev->c_dev.owner=THIS_MODULE; //we goto c_dev owner through sculldec
sculldev->c_dev.ops=&fop;
sculldev->c_dev.count=nod;
cdev_add(&sculldev->c_dev, dev, nod); //c_dev main dev ka add
minorno = MAJOR(sculldev->c_dev.dev);
majorno = MINOR(sculldev->c_dev.dev);
printk(“SEC MINOR value____ %d\n”,minorno);
printk(“SEC MAJOR value____ %d\n”,majorno);
scull_init();
printk(KERN_ALERT “Ho gaya Ji”);
return 0;
}
//=====================================Exit===================================================
static void end(void)
{
printk(KERN_ALERT “bye\n”);
unregister_chrdev_region(dev, nod);
printk(“Unregistration done\n”);
}

module_init(start);
module_exit(end);
@
1.7
log
@Completed Writing in diffrent Quantums as well as in diffrent Scullqset
@
text
@d47 8
a54 9
int noq=0;int nobw=0; //nobw =no. of bytes wrriten
int ret=0;
int lv,ls; //noq is no. of quantums required.
int nobpq=0;
int nobns=0; //no. if byte in next scull
int nobtw=size;
int nobsw=0;int sno=1; //sno is scull no

int nosqs=0; // no. of scull
d88 1
a88 1
if(nobtw>64)
d90 3
a92 5
nobns=nobtw-64; //no. of byte to write in next shell
nobtw=64;
// printk(“\n no. of byte to write in first shell : %d”,nobtw);
// printk(“\n no. of byte to write in first shell : %d”,nobtw);
ls=noq-quantum_size;
d96 1
a96 1
// ret=copy_from_user(scullqset->data[lv],ubuff+nobsw,nobpq); //for writing everytjing in a single quantum
d99 2
a100 1
{ nobpq=quantum_size;
d107 2
a108 2
printk(“\nScull is %d quantum no is %d and data : %s”,sno,lv,(char *)lscullqset->data[lv]);
nobsw=nobsw+(nobpq-ret);
d111 3
a113 5

// printk(“\n no. of byte to write in next shell : %d”,nobns);
noq=ls;
nobtw=nobns;
nosqs–;
@
1.6
log
@maked Qset
@
text
@d47 9
a55 3
int noq=0;
// int ret; //noq is no. of quantums required.
int nosqs=0; // no. of scull
d77 47
a123 1
create_qset(lscullqset,nosqs); //passing whole Scullqset structure and no scull qset require
d125 1
a125 3
printk(“\nLO JI HOGAYA End %s”,__func__);
return 0;
}
d129 1
a129 1
struct ScullQset *lsculldev;
d132 2
d135 4
a138 1
if(flag==0)
d140 1
a140 1
lsculldev=start=(struct ScullQset *)kmalloc(sizeof(struct ScullQset *),GFP_KERNEL);//as in linklist we preserve first nodee and allocating memory to first node
d144 3
a146 3
{
lsculldev->next=(struct ScullQset *)kmalloc(sizeof(struct ScullQset *),GFP_KERNEL);
lsculldev=lsculldev->next;
d148 3
d159 1
a159 1
for(lv=0;lv<fnosqs;lv++)
d162 1
a162 1
fscullqset=fscullqset->next;
d168 29
d203 1
a203 10

 

 

 
printk(“\nEnd %s”,__func__);
@
1.5
log
@done with finding quantum size
\.
@
text
@d4 1
a4 1

d15 1
a15 1

d32 1
d42 1
a42 1

d46 3
a48 1
int noq=0; //noq is no. of quantums required.
d68 4
a71 3

lsculldev->scullqset=create_sqset(nosqs);

d73 1
a73 1
printk(“\nLO JI HOGAYA End %s”,__func__);
d76 19
d96 2
a97 1
struct ScullQset *create_sqset(int fnosqs) //we use pointer here becaz it returns a an address …pointer
d99 19
a117 2
struct ScullQset *lsculldev;
struct ScullQset *start;
a118 1
int flag=0;
a119 1
printk(“\n WE ARE In CREATE SQSET “);
a121 10
if(flag==0)
{
lsculldev=start=(struct ScullQset *)kmalloc(sizeof(struct ScullQset *),GFP_KERNEL);
return start;
}
else
{
lsculldev=(struct ScullQset *)kmalloc(sizeof(struct ScullQset *),GFP_KERNEL);
return lsculldev;
}
a123 1
}
a124 3
ssize_t scull_read(struct file *filep,char __user *ubuff,size_t size,loff_t *loff )
{
printk(“\n Starting %s “,__func__);
d129 1
d140 2
d173 1
a173 1

@
1.4
log
@in write define lsculldev
@
text
@d45 2
d53 17
a69 1
printk(“\nEnd %s”,__func__);
d72 24
@
1.3
log
@finally witth trim
@
text
@d44 8
a51 2
printk(“\nStarting %s”,__func__);
printk(“\nEnd %s”,__func__);
@
1.2
log
@./
/
@
text
@d7 3
a9 3
if(!fsculldev)
{
printk(KERN_ERR”Error:No Sculldev\n”);
d11 1
d18 10
a27 13
// struct Sculldev *lsculldev;

printk(“\nScull open function start\n”);
// container_of(inodep->i_cdev,struct Sculldev,c_dev); //mapping RAM memory on Device:Sculldev
// filep->private_data=lsculldev; //preserving it on file as lsculldev is lost
// if((filep->f_flags && O_ACCMODE)==O_WRONLY)
// {
// printk(KERN_ALERT “FILE OPEN “);
// scull_trim(lsculldev);
// }

 

d45 1
d52 1
d68 5
a72 6
printk(KERN_ALERT “WELCOME TO DEVICE DRIVER\n”);

if(!majorno)
{
ret = alloc_chrdev_region(&dev, minorno, nod, DRIVER_NAME);
if(ret==0)
d79 2
a80 9
// else if(majorno==0)
// {
// dev=MKDEV(majorno,minorno+1);
// ret=register_chrdev_region(dev,nod,DRIVER_NAME);
// }

printk(“Major number assigned is___ %d\n”,majorno);
printk(“Minor number assigned is___ %d\n”,minorno);

a82 1

d85 1
a85 1
sculldev->c_dev.owner=”Ashish”; //we goto c_dev owner through sculldec
a92 1

a94 17

//scull_open();

/* dev= MKDEV(majorno,i);
cdev_init(&sculldev->c_dev, &fop);
sculldev->c_dev.owner=”Ashish”; //we goto c_dev owner through sculldec
sculldev->c_dev.ops=&fop;
sculldev->c_dev.count=nod;
cdev_add(&sculldev->c_dev, dev, nod); //c_dev main dev ka add
majorno = MAJOR(sculldev->c_dev.dev);
minorno = MINOR(sculldev->c_dev.dev);

printk(” MAJOR value____ %d\n”,majorno);
printk(” MINOR value____ %d\n”,minorno);
*/
a97 1

a100 2

a101 1

@
1.1
log
@Initial revision
@
text
@d17 1
a17 1
struct Sculldev *lsculldev;
d20 7
a26 7
container_of(inodep->i_cdev,struct Sculldev,c_dev); //mapping RAM memory on Device:Sculldev
filep->private_data=lsculldev; //preserving it on file as lsculldev is lost
if((filep->f_flags && O_ACCMODE)==O_WRONLY)
{
printk(KERN_ALERT “FILE OPEN “);
scull_trim(lsculldev);
}
@

Posted in Uncategorized | Tagged | Leave a comment

30.01.30 : Monika – Char Driver

RCS file: hello.c,v
Working file: hello.c
head: 1.17
branch:
access list:
symbolic names:
keyword substitution: kv
total revisions: 17;    selected revisions: 17
description:
Base module.
—————————-
revision 1.17
date: 2013/07/12 07:02:51;  author: user1;  state: Exp;  lines: +35 -6
Modified read() function to check for no. of bytes requested for reading to be not greater than bytes actually written
But it is actually checking for no. of quantums not to be greater than no.of quantums actually written.
—————————-
revision 1.16   locked by: user1;
date: 2013/07/11 08:09:20;  author: user1;  state: Exp;  lines: +73 -5
Implemented successfully read() function for any number of bytes using copy_to_user().
—————————-
revision 1.15
date: 2013/07/11 07:00:44;  author: user1;  state: Exp;  lines: +30 -7
Modified write() function to write in quantums from user buffer.
Implemented for any number of bytes to be written.
—————————-
revision 1.14   locked by: user1;
date: 2013/07/09 09:07:19;  author: user1;  state: Exp;  lines: +61 -21
Added creat_quantums() function.
Working fine till now.
—————————-
revision 1.13
date: 2013/07/09 08:11:40;  author: user1;  state: Exp;  lines: +56 -3
Modified the creat_qset() function to make required no. of qsets.
—————————-
revision 1.12
date: 2013/07/09 07:49:02;  author: user1;  state: Exp;  lines: +168 -1
Calculated no. of quantums, qsets, struct scullqset.
Added creat_scullqset() function.
Added creat_qset() function.
—————————-
revision 1.11
date: 2013/07/08 06:54:49;  author: user1;  state: Exp;  lines: +39 -3
Added opencount to struct sculldev.
Mapped scull_read() and scull_read().
Scull_trim function modified.
—————————-
revision 1.10
date: 2013/07/04 06:31:35;  author: user1;  state: Exp;  lines: +23 -0
Used macro container_of for mapping memory of device.
Preserved the mapping using private_data field of struct file.
Added scull_trim function for devices opened with write only.
—————————-
revision 1.9
date: 2013/07/02 07:24:47;  author: user1;  state: Exp;  lines: +1 -0
Used memset for sculldev after kmalloc.
—————————-
revision 1.8
date: 2013/07/02 07:05:06;  author: user1;  state: Exp;  lines: +14 -0
Declared scull_open() , scull_release() functions.
—————————-
revision 1.7
date: 2013/07/02 06:23:12;  author: user1;  state: Exp;  lines: +55 -24
Added definition of scull_init function for initialisation of struct sculldev.
Added scull_setup_cdev for cdev_add function.
—————————-
revision 1.6
date: 2013/07/02 05:57:06;  author: user1;  state: Exp;  lines: +15 -17
Edited major no. value and scull pointer double pointer to single pointer.
—————————-
revision 1.5
date: 2013/07/01 10:38:35;  author: user1;  state: Exp;  lines: +32 -2
Used kalloc to allocate memory to sculldev pointer variable.
Added the number of devices to the kernel device table using cdev_init,cdev_add.
Deleted them using cdev_del in cleanup code.
Free the memory using kfree.
—————————-
revision 1.4
date: 2013/07/01 08:36:32;  author: user1;  state: Exp;  lines: +23 -26
Registered device driver using alloc_chrdev_region and register_chrdev_region for 1 device.
Unregistered the driver in cleanup code using unregister_chrdev_region.
Used MAJOR , MINOR , MKDEV macros for major no. and minor no.
—————————-
revision 1.3
date: 2013/06/30 06:23:26;  author: user1;  state: Exp;  lines: +12 -1
Added register_chrdev function in initialisation_code function to register the driver.
Added unregister_chrdev in cleanup_code to unregister the driver.
—————————-
revision 1.2
date: 2013/06/30 06:08:23;  author: user1;  state: Exp;  lines: +8 -7
Added header.h file.
—————————-
revision 1.1
date: 2013/06/29 09:53:23;  author: user1;  state: Exp;
Initial revision
=============================================================================

Posted in Character Driver, Device Drivers | Leave a comment

Implemented lseek in character driver (project 05)

RCS file: chard.c,v
Working file: chard.c
head: 1.6
branch:
locks: strict
emblogic: 1.6
access list:
symbolic names:
keyword substitution: kv
total revisions: 6;     selected revisions: 6
description:
registered and unregistered devices using alloc_chrdev_region and unregis_chrdev_region.
implemented scull_setup function.
implemented scull_open routine.
started scull_trim,scull_release,scull_write and scull_read routines.
working well till now.
—————————-
revision 1.6    locked by: emblogic;
date: 2013/07/14 10:32:08;  author: emblogic;  state: Exp;  lines: +169 -50
implemented lseek using scull_lseek.
created new quantums when needed.
read and written successfully after seeking.
—————————-
revision 1.5
date: 2013/07/11 08:48:05;  author: emblogic;  state: Exp;  lines: +19 -47
implemented read and write successfully for any no. of bytes.
checked for upto 1000 bytes .successfully written to scull Quantums and read from the quantums as well.
—————————-
revision 1.4
date: 2013/07/10 11:43:39;  author: emblogic;  state: Exp;  lines: +89 -8
read successfully .
—————————-
revision 1.3
date: 2013/07/10 06:02:17;  author: emblogic;  state: Exp;  lines: +58 -4
written to scull successfully using write2scull function.
working well.
but printing garbage due to absence of NULL.
—————————-
revision 1.2
date: 2013/07/09 12:03:54;  author: emblogic;  state: Exp;  lines: +170 -5
implemented creat_scullqset,creat_qset and creat_quantums….aloocated memory to write to scull.
quantums created successfully .
working well till now.
—————————-
revision 1.1
date: 2013/07/08 11:03:54;  author: emblogic;  state: Exp;
Initial revision
=============================================================================

Posted in Character Driver | Tagged | Leave a comment

jai ho prameet baba ki

barabar wala pc chal rha h kya tera

Posted in Uncategorized | Tagged | Leave a comment

mdc

project name-mdc

Posted in Uncategorized | Leave a comment

helloo.!!!

started project on multiple data compression and encryption using iterative technique…

Posted in Uncategorized | Leave a comment

started mdc.c

project has start ed today…n pravjot sir told us if v dont complete our project ..then we wont get certificates……luks..lyk hv to complete my project..

Posted in Uncategorized | 2 Comments