EmbLogic's Blog

Avtar Singh E-30.01.30

RCS file: new_lkm.c,v
Working file: new_lkm.c
head: 1.29
branch:
locks: strict
root: 1.29
access list:
symbolic names:
keyword substitution: kv
total revisions: 30;    selected revisions: 30
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.29    locked by: root;
date: 2013/07/29 12:20:41;  author: root;  state: Exp;  lines: +31 -10
used create_proc_read_entry successfully.
write the information of the device when we open the /proc entry of device.
used off variable to print the data on page.
—————————-
revision 1.28
date: 2013/07/28 18:02:06;  author: root;  state: Exp;  lines: +17 -5
implemented create_read_proc_entry successfully.
now device entry in /proc mapped with the my function named read_proc in the driver(new_lkm.c).
it provide the information about the attributes of the sculldev or device like device name,device size,etc..
some questions is still in mind
—————————-
revision 1.27
date: 2013/07/28 16:14:45;  author: root;  state: Exp;  lines: +43 -6
implemented create_proc_read_entry() in very simple way.
able to print any string to the page in read_proc function using sprintf().
till now working.
—————————-
revision 1.26
date: 2013/07/26 06:54:01;  author: root;  state: Exp;  lines: +14 -10
implemented the driver using one semaphore and one completion.
it can handle many writers as well as many readers .
it will accept first writer then accept one reader now again accept one writer and then again one reader and so on.
still now it is working properly.
—————————-
revision 1.25
date: 2013/07/24 18:58:42;  author: root;  state: Exp;  lines: +53 -18
implemented completion for one writer and many reader.
using init_completion() in O_WRONLY condition of open function.
waiting by wait_for_completion() in read function for putting readers in a small driver’s queue.
used complete once at the bottom of write and then afterward at the bottom of read call to allow other readers to read.
working successfully till now.
—————————-
revision 1.24
date: 2013/07/23 12:40:18;  author: root;  state: Exp;  lines: +35 -9
using two semaphores ,one to control read and secound to control writing over the scull.
in this in starting one writer is essential and after writing one reader is essential to proceed.
tested for two writing apps and two reading applications .
till now it is working successfully.
—————————-
revision 1.23
date: 2013/07/23 06:26:06;  author: root;  state: Exp;  lines: +4 -10
move sem_init() from open_file() to the function setup_struct_cdev().
here semaphore will initialize for each & every device at the starting.
—————————-
revision 1.22
date: 2013/07/22 17:17:13;  author: root;  state: Exp;  lines: +8 -2
implemented semaphore in kernel level.
using sema_init(),down() in open function,it will make down to semaphore only in O_WRONLY because i am recently controlling the write calls from two diffrent applications.
making up() after performing write function in scull_write().
working properly till now.
—————————-
revision 1.21
date: 2013/07/22 07:55:54;  author: root;  state: Exp;  lines: +2 -2
checked new version to read and trim.
it is working successfully.
i checked it upto 27 quantums to read and trim quantum by quantum.
—————————-
revision 1.20
date: 2013/07/22 07:23:59;  author: root;  state: Exp;  lines: +230 -28
this is successfully trimming all the allocated space to the device when we open it for writing next time.
i have also written a new version of read which will read and trim only quantums one by one.
read trim is not tested yet.
—————————-
revision 1.19
date: 2013/07/19 11:07:56;  author: root;  state: Exp;  lines: +115 -8
implemented scull_trim function properly.
when we open same file in the write mode again then it trim all the data.
means in this i deallocated the memory of quantums,qsets & scullqsets.
it is working successfully.
—————————-
revision 1.18
date: 2013/07/17 13:59:24;  author: root;  state: Exp;  lines: +0 -3
three waste lines deleted .
checked also to add many scullqsets with the previously allocated memory,that was less to write the new request by application.
working successfully.
—————————-
revision 1.17
date: 2013/07/17 13:05:14;  author: root;  state: Exp;  lines: +54 -7
successfully adding some memory when application gives more no. of characters than previously write call after g some positions.
can add some quantums in the previously allocated memory.
till now wprking successfully.
—————————-
revision 1.16
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.
=============================================================================

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>