Completed till arrays and 4 questions of pointers…
Completed till arrays and 4 questions of pointers…
Done first 56 questions of C assignments….
Kindly help me to understand the below question –
“write a program to printa cycle of cosine, sine wave”….
completed mdc of code lenght 4 now going ahead for next code lenght.
Logic- when u convert a decimal number to its binary number then u get series of 1 and 0 ,Now if a number is power of two then u will observe it has only one (bit 1) and if you perform binary and operation of it with just a number previous to it ,then u will get Zeros.
For example
8=1000(binary form ) here u can see only one (bit 1) is there rest are zeros,
Now the number just previous to 8 is 7
so, 7=0111 and if u perform binary and operation on it as
1000(8)
(AND) 0111(7)
———
0000(0)
———
So if we perform AND operation between the number (which we want to check is a power of two or not) and the number just previous to it and result comes as zeros then its power of two otherwise it is not.
so here is the one line expression
if(!(num & (num-1))&&num)
if the above condition true then the number is of power of two otherwise it is not.
Implemented timer in character driver by using timespec and timevalue structure ..
done first 9 assignments with some problems.
main problem is coming in low level file input-output operations.
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
—————————-
revision 1.2 locked by: amitdalal;
date: 2013/08/01 01:05:28; author: amitdalal; state: Exp; lines: +29 -1
include some variable
use cmd for resetting all the parameter
use cmd for setting newquantum no.
include header file
use cmd for setting qset no.
—————————-
revision 1.1
date: 2013/07/25 23:29:38; author: amitdalal; state: Exp;
Initial revision
=============================================================================
RCS file: amit.c,v
Working file: amit.c
head: 1.21
branch:
locks: strict
amitdalal: 1.21
access list:
symbolic names:
keyword substitution: kv
total revisions: 21; selected revisions: 21
description:
added function of copy from user
printk the no of byte writen successfully for one quantum
—————————-
revision 1.21 locked by: amitdalal;
date: 2013/08/01 00:53:49; author: amitdalal; state: Exp; lines: +71 -5
define function for ioctl to control the operation
use cmd SCULL_IOCRESET,SCULL_IOCSQUANTUM,SCULL_IOCQSET,SCULL_IOCDATA,SCULL_IOCDEVICE
USE capability cmd for cheking capability
—————————-
revision 1.20
date: 2013/07/28 00:07:05; author: amitdalal; state: Exp; lines: +21 -7
create proc_read_entry function inside sculldev loop
define read_proc out side the sculldev loop
—————————-
revision 1.19
date: 2013/07/26 19:26:10; author: amitdalal; state: Exp; lines: +4 -3
use spin_lock_irq before raeding
use spin_unlock_irq func. at the end off writing
—————————-
revision 1.18
date: 2013/07/26 00:33:49; author: amitdalal; state: Exp; lines: +9 -19
use wait_for_complition in read
use complete_all in write
—————————-
revision 1.17
date: 2013/07/25 23:23:36; author: amitdalal; state: Exp; lines: +9 -8
initialise sem_init again
—————————-
revision 1.16
date: 2013/07/25 23:02:12; author: amitdalal; state: Exp; lines: +33 -11
initialise two semaphore for read and write in sculldev initialisation
down semaphore in write for write
at the end up semaphore for read
down semaphore in write for read
at the end up semaphore for write
—————————-
revision 1.15
date: 2013/07/22 22:47:17; author: amitdalal; state: Exp; lines: +5 -5
initialise the semaphore init in scull_open for kernel level synchronisation
call down_interruptible in open
call up in release function
define trim function
calculate nosqs and noq agin in trim function
memset the quantum_size
to free all quantum
—————————-
revision 1.14
date: 2013/07/22 22:07:46; author: amitdalal; state: Exp; lines: +102 -40
define fpos variable for fetching file position in read
add fpos to count to calculate the nosqs and noq
—————————-
revision 1.13
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
=============================================================================
RCS file: header.h,v
Working file: header.h
head: 1.10
branch:
locks: strict
amitdalal: 1.10
access list:
symbolic names:
keyword substitution: kv
total revisions: 10; selected revisions: 10
description:
added asm header .h for copy from user
—————————-
revision 1.10 locked by: amitdalal;
date: 2013/08/01 00:59:39; author: amitdalal; state: Exp; lines: +9 -3
include prototype of ioctl
define ioctl in the file operation
—————————-
revision 1.9
date: 2013/07/28 00:09:43; author: amitdalal; state: Exp; lines: +1 -0
include header file for proc
—————————-
revision 1.8
date: 2013/07/26 19:29:27; author: amitdalal; state: Exp; lines: +3 -1
initialise spinlock_t my_lock in header file
./
—————————-
revision 1.7
date: 2013/07/26 00:38:59; author: amitdalal; state: Exp; lines: +3 -3
define macro for complition in header.h
another way is to define the complition in sculldev
—————————-
revision 1.6
date: 2013/07/25 23:25:01; author: amitdalal; state: Exp; lines: +9 -3
include struct semaphore rsem and wsem in sculldev
—————————-
revision 1.5
date: 2013/07/22 22:12:52; author: amitdalal; state: Exp; lines: +3 -1
defined header file for semaphore in kernel level
define semaphore in Sculldev structure
—————————-
revision 1.4
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
=============================================================================
RCS file: ioctlheader.h,v
Working file: ioctlheader.h
head: 1.1
branch:
locks: strict
amitdalal: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
include all the macro for reseting,setting quantum no.
macro for setting qset no.
macro for setting data no.
macro for setting device no.
—————————-
revision 1.1 locked by: amitdalal;
date: 2013/08/01 01:01:24; author: amitdalal; state: Exp;
Initial revision
=============================================================================
RCS file: ioctlheader.h,v
Working file: ioctlheader.h
head: 1.1
branch:
locks: strict
amitdalal: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
include all the macro for reseting,setting quantum no.
macro for setting qset no.
macro for setting data no.
macro for setting device no.
—————————-
revision 1.1 locked by: amitdalal;
date: 2013/08/01 01:01:24; author: amitdalal; state: Exp;
Initial revision
=============================================================================
RCS file: first_driver.c,v
Working file: first_driver.c
head: 2.23
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 33; selected revisions: 33
description:
base prog.
able to register the device through old method.
—————————-
revision 2.23
date: 2013/08/01 11:53:49; author: rahul; state: Exp; lines: +7 -6
done with proc
able to creat pages.
—————————-
revision 2.22
date: 2013/08/01 11:00:22; author: rahul; state: Exp; lines: +78 -35
done with ioctl command
created scull_ioctl function.
able to change the quantum size.
—————————-
revision 2.21
date: 2013/07/26 11:08:11; author: rahul; state: Exp; lines: +108 -11
implemented spin_lock()
implemented completion()
but to implement syncro between writes of two diffrent applications & reads of two diffrent applications, we have to use semaphore between application.
—————————-
revision 2.20
date: 2013/07/22 14:04:17; author: rahul; state: Exp; lines: +26 -26
faced problem with trim function again.
previous ligic was not correct.
used data_size which was declared in struct sculldev.
working fine
—————————-
revision 2.19
date: 2013/07/22 12:22:22; author: rahul; state: Exp; lines: +57 -9
done with semaphores in device driver.
used call sema_init().
—————————-
revision 2.18
date: 2013/07/21 20:05:01; author: rahul; state: Exp; lines: +40 -13
done with multi thread 5 applications
.syncro done with the help of semaphores.
—————————-
revision 2.17
date: 2013/07/20 13:24:29; author: rahul; state: Exp; lines: +173 -104
done with lseek.
first write then lseek then write.
done for within one quantum.
—————————-
revision 2.16
date: 2013/07/19 06:54:18; author: rahul; state: Exp; lines: +4 -3
able to use multi thread application.
—————————-
revision 2.15
date: 2013/07/18 10:09:58; author: rahul; state: Exp; lines: +1 -1
ok for lseek before write.
—————————-
revision 2.14
date: 2013/07/17 10:03:13; author: rahul; state: Exp; lines: +40 -26
done with lseek before write & after write.
complete for seek till 8 bytes only.
now working with multiple quantums.
—————————-
revision 2.13
date: 2013/07/16 12:31:05; author: rahul; state: Exp; lines: +75 -7
inserted function for llseek.
able to seek before write operation.
next step to use lseek after the write operation.
—————————-
revision 2.12
date: 2013/07/14 06:21:44; author: rahul; state: Exp; lines: +57 -19
added informations 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 ir 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
=============================================================================
RCS file: new_lkm.c,v
Working file: new_lkm.c
head: 1.30
branch:
locks: strict
root: 1.30
access list:
symbolic names:
keyword substitution: kv
total revisions: 31; selected revisions: 31
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.30 locked by: root;
date: 2013/08/01 12:32:18; author: root; state: Exp; lines: +31 -0
implemented capability also in my ioctl function.
done some basic checking in program.
added more command operations also .
working successfully.
—————————-
revision 1.29
date: 2013/08/01 11:09:10; author: root; state: Exp; lines: +112 -10
implemented basic ioctl.
in this i have made some basic commands like IOCMD_RESET,IOCMD_SQUANTUM,etc..
made a new header file named ioctl_header.h,included in driver source code as well as in the application.
so that commands become visible to the driver and applications.
driver giving response to the requested commands by app.
every operations of ioctl is mapped with the function named ioctl().
working successfully.
—————————-
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.
=============================================================================
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 register_chrdev
inserting the module using insmod
unregistering using unregister_chrdev
removing the module using rmmod
—————————-
revision 1.32 locked by: sampath;
date: 2013/07/31 13:23:52; author: sampath; state: Exp; lines: +84 -22
Implementation of IOCTL
Able to map ioctl call mapping done through file_operations
calling IOCTL from application for reseting the values using SCULL_IOC_RESET
Able to reset to initial values
calling IOCTL call from application for changing the quantum size using SCULL_IOC_SQUANTUM
Able to chage quantum value and further write and read operations are performed accordind to the new quantum size
—————————-
revision 1.31
date: 2013/07/28 12:22:25; author: sampath; state: Exp; lines: +43 -2
Implementation of proc
calling create_proc_read_entry
mapping function which contain sculldev Information device name,major number allocated,quantum size, qset size, no of bytes written and read by application
Able to access from proc directory
—————————-
revision 1.30
date: 2013/07/28 06:42:14; author: sampath; state: Exp; lines: +16 -3
Implementation of spinlock for synchronization
initialized spin_lock_init and locking using spin_lock in open
unlocking at the end of read using spin_unlock
Also tested synchronization using spin_lock_irq and spin_unlock_irq
spin_lock_irqsave and spin_lock_irqrestore
synchronizing using spinlock and completion
—————————-
revision 1.29
date: 2013/07/27 19:26:57; author: sampath; state: Exp; lines: +16 -8
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
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
note: care should be taken as open and close are called twice from same application
—————————-
revision 1.28
date: 2013/07/25 06:49:48; author: sampath; state: Exp; lines: +14 -6
Implemented completion
declared init_completion in open
wait_for_completion in read
completion in write
—————————-
revision 1.27
date: 2013/07/24 15:45:58; author: sampath; state: Exp; lines: +51 -10
Corrected memory allocation error for scull_Qset
Initialised scull_dev[lv]->scull_Qset=NULL for all lv values
Able to perform trimming operation correctly
Implementation of sema_init is done
Able to synchronize correctly for multi applications
Tested for 3 applications
—————————-
revision 1.26
date: 2013/07/22 14:05:23; author: sampath; state: Exp; lines: +7 -1
done with implementation of semaphores sema_init
using down and up
able to synchronize correctly tested running 3 applications at once
—————————-
revision 1.25
date: 2013/07/22 12:27:19; author: sampath; state: Exp; lines: +76 -8
Scull trim Implementation done if application opens in write only mode
sucessfully trimming required no of quantum upto required no of bytes
—————————-
revision 1.24
date: 2013/07/19 07:23:36; author: sampath; state: Exp; lines: +35 -75
Sucessfully tested driver using 3 multithreaded application one at a time
Able to write and read data sucessfully
Trying to synchronize multiple application running at ones
—————————-
revision 1.23
date: 2013/07/17 05:19:21; author: sampath; state: Exp; lines: +75 -28
Defined llseek function mapped from function call
Able to read data from application according to lseek offset in application
done with read operation using lseek
—————————-
revision 1.22 locked by: sampath;
date: 2013/07/13 11:04:51; author: sampath; state: Exp; lines: +15 -54
done with read and write operations for multiple scullqsets
—————————-
revision 1.21
date: 2013/07/13 10:43:24; author: sampath; state: Exp; lines: +1 -1
added ubuff+tnobsr in copy_to_user for cursor position
able to read data at the application
—————————-
revision 1.20
date: 2013/07/13 10:17:59; author: sampath; state: Exp; lines: +35 -26
sucessfully Implemented reading operation for 98 bytes of data
able to read tnobsr in application
—————————-
revision 1.19
date: 2013/07/13 07:17:49; author: sampath; state: Exp; lines: +20 -13
new
—————————-
revision 1.18
date: 2013/07/13 04:52:08; author: sampath; state: Exp; lines: +49 -36
Able to read 63 bytes of data from kernel to user buffer.
verification done by returning tnobsr to user application.
—————————-
revision 1.17
date: 2013/07/12 08:12:41; author: sampath; state: Exp; lines: +80 -11
Implemented read operation trying to read from kernel to user buffer using copy_to_user
Able to read only 8bytes of data
tryin g to implement for complete read operation for reading 100bytes
—————————-
revision 1.16
date: 2013/07/11 20:56:23; author: sampath; state: Exp; lines: +5 -10
Able to return 0 from read operation of kernel buffer to application
—————————-
revision 1.15
date: 2013/07/11 20:10:35; author: sampath; state: Exp; lines: +34 -25
Sucessfully implemented for multiple qsets
Tested writing operation for 100 bytes of data
no of scull qset are 2 and no of quantums created are 13
—————————-
revision 1.14
date: 2013/07/11 11:12:47; author: sampath; state: Exp; lines: +33 -10
sucessfully implemented write operation for multiple quantums
able to automate correct no of quantums
—————————-
revision 1.13
date: 2013/07/11 07:57:21; author: sampath; state: Exp; lines: +24 -7
Sucessfully implemented write operation
using kernel facility copy_from_user
testing for only 4bytes of data for which one quantum is enough
—————————-
revision 1.12
date: 2013/07/10 11:43:26; author: sampath; state: Exp; lines: +75 -21
Implementation of scullqset, qset and quantum done
automated number of scullqsets and quantums wrt the application
—————————-
revision 1.11
date: 2013/07/10 03:53:40; author: sampath; state: Exp; lines: +120 -34
Implemeenting write operation
fetched private->data to sculldev
Implemented auto calculation for number of scull_qset and number of quantums
allocated memory for scull_qset qset and quantum calling their functions separately and trying to link them
—————————-
revision 1.10
date: 2013/07/09 07:28:58; author: sampath; state: Exp; lines: +22 -0
Implemented basic write and read operations
—————————-
revision 1.9
date: 2013/07/08 07:27:12; author: sampath; state: Exp; lines: +39 -41
Implementation of scull_trim for future use
—————————-
revision 1.8
date: 2013/07/05 04:53:38; author: sampath; state: Exp; lines: +1 -1
Initialised cdev_del after completing the usage of cdev
—————————-
revision 1.7
date: 2013/07/05 04:51:02; author: sampath; state: Exp; lines: +9 -8
Added ret_cdev to check the return value of cdev_add
—————————-
revision 1.6
date: 2013/07/04 13:07:35; author: sampath; state: Exp; lines: +17 -7
Initialising multiple devices
assining dev using MKDEV
—————————-
revision 1.5
date: 2013/07/04 11:03:31; author: sampath; state: Exp; lines: +23 -10
memory mapping through container_of
pointing scull through inode
—————————-
revision 1.4
date: 2013/07/03 10:49:38; author: sampath; state: Exp; lines: +19 -2
Assigning values to members of sculldev in scullinit and printing
—————————-
revision 1.3
date: 2013/07/02 13:40:19; author: sampath; state: Exp; lines: +17 -2
Initialised function for scull_open
and scull close
calling open function from application
communicating from user spaceapplication to kernelspace driver
—————————-
revision 1.2
date: 2013/07/02 10:34:24; author: sampath; state: Exp; lines: +44 -4
Implemented struct scull
registering the device in device table
Initialized cdev_init
pointing to dev through cdev
—————————-
revision 1.1
date: 2013/07/01 07:16:06; author: sampath; state: Exp;
Initial revision
=============================================================================
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.
=============================================================================
successfully done proc implimentation…..
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 of byte writen successfully for one quantum
—————————-
revision 1.20 locked by: amitdalal;
date: 2013/07/28 00:07:05; author: amitdalal; state: Exp; lines: +21 -7
create proc_read_entry function inside sculldev loop
define read_proc out side the sculldev loop
—————————-
revision 1.19
date: 2013/07/26 19:26:10; author: amitdalal; state: Exp; lines: +4 -3
use spin_lock_irq before raeding
use spin_unlock_irq func. at the end off writing
—————————-
revision 1.18
date: 2013/07/26 00:33:49; author: amitdalal; state: Exp; lines: +9 -19
use wait_for_complition in read
use complete_all in write
—————————-
revision 1.17
date: 2013/07/25 23:23:36; author: amitdalal; state: Exp; lines: +9 -8
initialise sem_init again
—————————-
revision 1.16
date: 2013/07/25 23:02:12; author: amitdalal; state: Exp; lines: +33 -11
initialise two semaphore for read and write in sculldev initialisation
down semaphore in write for write
at the end up semaphore for read
down semaphore in write for read
at the end up semaphore for write
—————————-
revision 1.15
date: 2013/07/22 22:47:17; author: amitdalal; state: Exp; lines: +5 -5
initialise the semaphore init in scull_open for kernel level synchronisation
call down_interruptible in open
call up in release function
define trim function
calculate nosqs and noq agin in trim function
memset the quantum_size
to free all quantum
—————————-
revision 1.14
date: 2013/07/22 22:07:46; author: amitdalal; state: Exp; lines: +102 -40
define fpos variable for fetching file position in read
add fpos to count to calculate the nosqs and noq
—————————-
revision 1.13
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
=============================================================================
RCS file: header.h,v
Working file: header.h
head: 1.9
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 9; selected revisions: 9
description:
added asm header .h for copy from user
—————————-
revision 1.9
date: 2013/07/28 00:09:43; author: amitdalal; state: Exp; lines: +1 -0
include header file for proc
—————————-
revision 1.8
date: 2013/07/26 19:29:27; author: amitdalal; state: Exp; lines: +3 -1
initialise spinlock_t my_lock in header file
./
—————————-
revision 1.7
date: 2013/07/26 00:38:59; author: amitdalal; state: Exp; lines: +3 -3
define macro for complition in header.h
another way is to define the complition in sculldev
—————————-
revision 1.6
date: 2013/07/25 23:25:01; author: amitdalal; state: Exp; lines: +9 -3
include struct semaphore rsem and wsem in sculldev
—————————-
revision 1.5
date: 2013/07/22 22:12:52; author: amitdalal; state: Exp; lines: +3 -1
defined header file for semaphore in kernel level
define semaphore in Sculldev structure
—————————-
revision 1.4
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
=============================================================================