EmbLogic's Blog

Character Driver(IOCTL for the set quantum)

#apply the ioctl in the kernel layer and get quantum and set quantum is work fine....and after changing the quantum size we are able to write according to that but we are not able to read when we are changing the quantum size....

RCS file: application.c,v
Working file: application.c
head: 1.34
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 34;	selected revisions: 34
description:
this is the application program in the user space
open write and close is used
----------------------------
revision 1.34
date: 2014/06/08 10:27:10;  author: root;  state: Exp;  lines: +3 -3
*** empty log message ***
----------------------------
revision 1.33
date: 2014/06/08 10:17:20;  author: root;  state: Exp;  lines: +4 -0
*** empty log message ***
----------------------------
revision 1.32
date: 2014/06/08 10:13:33;  author: root;  state: Exp;  lines: +2 -0
*** empty log message ***
----------------------------
revision 1.31
date: 2014/06/08 10:03:52;  author: root;  state: Exp;  lines: +1 -1
make arg instead of &arg
----------------------------
revision 1.30
date: 2014/06/08 07:10:04;  author: root;  state: Exp;  lines: +2 -1
*** empty log message ***
----------------------------
revision 1.29
date: 2014/06/08 05:14:38;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.28
date: 2014/06/07 12:59:04;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.27
date: 2014/06/07 12:57:58;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.26
date: 2014/06/07 12:45:21;  author: root;  state: Exp;  lines: +3 -3
*** empty log message ***
----------------------------
revision 1.25
date: 2014/06/07 12:42:55;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.24
date: 2014/06/07 12:42:03;  author: root;  state: Exp;  lines: +2 -1
*** empty log message ***
----------------------------
revision 1.23
date: 2014/06/07 12:37:56;  author: root;  state: Exp;  lines: +6 -2
call a system call for the SCULL_SQUANTUM
----------------------------
revision 1.22
date: 2014/06/07 12:31:14;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.21
date: 2014/06/07 10:20:19;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.20
date: 2014/06/07 10:11:16;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.19
date: 2014/06/07 09:55:19;  author: root;  state: Exp;  lines: +3 -1
make a call for the othe macro i.e for the SCUlL_GQUANTUM
----------------------------
revision 1.18
date: 2014/06/07 09:35:52;  author: root;  state: Exp;  lines: +5 -1
make a application call for the ioctl
----------------------------
revision 1.17
date: 2014/06/02 12:09:20;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.16
date: 2014/05/30 07:19:57;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.15
date: 2014/05/30 07:09:07;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.14
date: 2014/05/29 06:06:43;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.13
date: 2014/05/29 06:05:10;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.12
date: 2014/05/29 05:44:00;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.11
date: 2014/05/29 05:43:01;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.10
date: 2014/05/29 05:38:44;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.9
date: 2014/05/29 05:37:02;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.8
date: 2014/05/26 11:19:01;  author: root;  state: Exp;  lines: +2 -2
seeking operation applied
apply SEEK_SET. and call lseek in application layer
----------------------------
revision 1.7
date: 2014/05/26 06:00:53;  author: root;  state: Exp;  lines: +10 -4
not open the node in RDWR mode because the node either open in the WR mode or in RD mode because its tbecause if we make it fullduplex then data get mingle.
----------------------------
revision 1.6
date: 2014/05/25 11:29:25;  author: root;  state: Exp;  lines: +11 -7
open the file in the O_RDWR mode then its capable to read and write from the files.
----------------------------
revision 1.5
date: 2014/05/24 11:49:01;  author: root;  state: Exp;  lines: +9 -9
*** empty log message ***
----------------------------
revision 1.4
date: 2014/05/24 11:35:56;  author: root;  state: Exp;  lines: +12 -12
close the fd for the writing then open it again in the read mode.
----------------------------
revision 1.3
date: 2014/05/24 09:07:54;  author: root;  state: Exp;  lines: +16 -2
close the fd for the write operation(important to close the fd otherwise use lseek)
then open in the read mode then read while using its file descriptor.
----------------------------
revision 1.2
date: 2014/05/24 07:49:26;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.1
date: 2014/05/24 07:17:20;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: devopen.c,v
Working file: devopen.c
head: 1.3
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;	selected revisions: 3
description:
open the module in the kernel layer by passing the argument from the application layer of the open system call.
here we are not using the trim funciton.
----------------------------
revision 1.3
date: 2014/06/02 11:43:23;  author: root;  state: Exp;  lines: +5 -5
*** empty log message ***
----------------------------
revision 1.2
date: 2014/06/02 11:38:54;  author: root;  state: Exp;  lines: +7 -3
*** empty log message ***
----------------------------
revision 1.1
date: 2014/05/24 07:15:18;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: ioctl.c,v
Working file: ioctl.c
head: 1.22
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 22;	selected revisions: 22
description:
the file corresponds to unlocked_ioctl...
----------------------------
revision 1.22
date: 2014/06/08 08:09:38;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.21
date: 2014/06/08 08:09:05;  author: root;  state: Exp;  lines: +2 -0
*** empty log message ***
----------------------------
revision 1.20
date: 2014/06/08 05:36:29;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.19
date: 2014/06/08 05:23:12;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.18
date: 2014/06/08 05:15:34;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.17
date: 2014/06/08 05:14:39;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.16
date: 2014/06/07 13:09:16;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.15
date: 2014/06/07 13:08:24;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.14
date: 2014/06/07 13:07:43;  author: root;  state: Exp;  lines: +2 -0
*** empty log message ***
----------------------------
revision 1.13
date: 2014/06/07 12:48:51;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.12
date: 2014/06/07 12:44:11;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.11
date: 2014/06/07 12:40:50;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.10
date: 2014/06/07 12:38:55;  author: root;  state: Exp;  lines: +5 -0
make the defination for the SULL_SQUANTUM
----------------------------
revision 1.9
date: 2014/06/07 12:31:19;  author: root;  state: Exp;  lines: +4 -3
*** empty log message ***
----------------------------
revision 1.8
date: 2014/06/07 10:21:43;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.7
date: 2014/06/07 10:21:08;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.6
date: 2014/06/07 10:12:39;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.5
date: 2014/06/07 10:10:06;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.4
date: 2014/06/07 09:55:55;  author: root;  state: Exp;  lines: +1 -0
use put_user
use put_user() to written in the application layer.
----------------------------
revision 1.3
date: 2014/06/07 09:47:26;  author: root;  state: Exp;  lines: +9 -1
making the switch for the different MACRO of IOCTL
----------------------------
revision 1.2
date: 2014/06/07 09:43:12;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.1
date: 2014/06/07 09:30:35;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: cleanup.c,v
Working file: cleanup.c
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;	selected revisions: 1
description:
this is used to remove and unregistered the module from the /proc/devices table.
----------------------------
revision 1.1
date: 2014/05/24 07:13:18;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: devread.c,v
Working file: devread.c
head: 1.29
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 29;	selected revisions: 29
description:
write the fuction for the read which is work in the kernel layer.
----------------------------
revision 1.29
date: 2014/06/08 10:29:24;  author: root;  state: Exp;  lines: +5 -5
*** empty log message ***
----------------------------
revision 1.28
date: 2014/06/08 10:26:24;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.27
date: 2014/06/08 10:21:43;  author: root;  state: Exp;  lines: +5 -5
*** empty log message ***
----------------------------
revision 1.26
date: 2014/06/05 06:54:23;  author: root;  state: Exp;  lines: +4 -2
*** empty log message ***
----------------------------
revision 1.25
date: 2014/06/05 06:29:11;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.24
date: 2014/06/05 06:02:00;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.23
date: 2014/06/05 05:56:16;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.22
date: 2014/06/05 05:07:23;  author: root;  state: Exp;  lines: +6 -3
use the spin_lock and the spin_unlock...
----------------------------
revision 1.21
date: 2014/06/03 12:48:40;  author: root;  state: Exp;  lines: +1 -0
give the wait_for_completion in the start...
and complete in the last....
work fine....in the different application accesing the same node....
----------------------------
revision 1.20
date: 2014/06/03 05:00:49;  author: root;  state: Exp;  lines: +3 -2
apply the completion in the devread.
----------------------------
revision 1.19
date: 2014/06/03 04:58:08;  author: root;  state: Exp;  lines: +2 -2
remove the semaphore...
----------------------------
revision 1.18
date: 2014/06/03 04:29:10;  author: root;  state: Exp;  lines: +1 -1
making up the semaphore above the returing...
----------------------------
revision 1.17
date: 2014/06/03 04:23:54;  author: root;  state: Exp;  lines: +3 -1
*** empty log message ***
----------------------------
revision 1.16
date: 2014/06/02 12:00:36;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.15
date: 2014/06/02 11:45:09;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.14
date: 2014/06/02 05:14:57;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.13
date: 2014/06/02 05:08:38;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.12
date: 2014/06/02 04:52:46;  author: root;  state: Exp;  lines: +6 -0
making down and up the semaphore by using the down_interruptible() and up() respectively.
----------------------------
revision 1.11
date: 2014/05/30 11:03:46;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.10
date: 2014/05/30 07:09:09;  author: root;  state: Exp;  lines: +13 -8
implement the SEEK_SET again.
and it work file
----------------------------
revision 1.9
date: 2014/05/26 11:19:45;  author: root;  state: Exp;  lines: +28 -9
draw logic for the seek operation.
----------------------------
revision 1.8
date: 2014/05/24 11:40:26;  author: root;  state: Exp;  lines: +9 -5
give the defination for the read function.
----------------------------
revision 1.7
date: 2014/05/24 10:34:09;  author: root;  state: Exp;  lines: +7 -2
*** empty log message ***
----------------------------
revision 1.6
date: 2014/05/24 09:28:15;  author: root;  state: Exp;  lines: +5 -5
*** empty log message ***
----------------------------
revision 1.5
date: 2014/05/24 09:26:24;  author: root;  state: Exp;  lines: +7 -7
*** empty log message ***
----------------------------
revision 1.4
date: 2014/05/24 09:21:09;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.3
date: 2014/05/24 09:19:17;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.2
date: 2014/05/24 09:16:07;  author: root;  state: Exp;  lines: +1 -0
make a access to the private data to the sculldev
----------------------------
revision 1.1
date: 2014/05/24 09:09:26;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: fileopr.h,v
Working file: fileopr.h
head: 1.4
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;	selected revisions: 4
description:
used for the mapping purpose.
----------------------------
revision 1.4
date: 2014/06/07 09:36:06;  author: root;  state: Exp;  lines: +2 -1
mapp the unlocked_ioctl with the scull_ioctl
----------------------------
revision 1.3
date: 2014/05/25 11:30:20;  author: root;  state: Exp;  lines: +2 -1
*** empty log message ***
----------------------------
revision 1.2
date: 2014/05/24 09:09:56;  author: root;  state: Exp;  lines: +2 -1
do the mapping of read
----------------------------
revision 1.1
date: 2014/05/24 07:18:55;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: ioctl.h,v
Working file: ioctl.h
head: 1.4
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;	selected revisions: 4
description:
make the header file for the ioctl this is the user define header file...
----------------------------
revision 1.4
date: 2014/06/07 13:05:20;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.3
date: 2014/06/07 12:38:17;  author: root;  state: Exp;  lines: +1 -0
include the micro SCULL_SQUANTUM to set the new quantum size.
----------------------------
revision 1.2
date: 2014/06/07 09:36:38;  author: root;  state: Exp;  lines: +1 -1
make the user define header file for the ioctl
----------------------------
revision 1.1
date: 2014/06/07 09:30:35;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: declaration.h,v
Working file: declaration.h
head: 1.4
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;	selected revisions: 4
description:
define some macros which are freq	uently used in our program.
----------------------------
revision 1.4
date: 2014/06/05 06:54:21;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.3
date: 2014/06/05 05:56:14;  author: root;  state: Exp;  lines: +2 -1
*** empty log message ***
----------------------------
revision 1.2
date: 2014/06/05 05:06:10;  author: root;  state: Exp;  lines: +1 -0
make the extern variable spinlock_t lock
----------------------------
revision 1.1
date: 2014/05/24 07:14:06;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: devrelease.c,v
Working file: devrelease.c
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;	selected revisions: 1
description:
for closeing the module
----------------------------
revision 1.1
date: 2014/05/24 07:16:45;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: header.h,v
Working file: header.h
head: 1.5
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 5;	selected revisions: 5
description:
define macros and include header file in this and make a ScullDev and ScullQset structure in this.
----------------------------
revision 1.5
date: 2014/06/07 09:29:12;  author: root;  state: Exp;  lines: +3 -0
here we include the header file <asm-generic/ioctl.h>
here we also include the user define ioctl.h header file.
----------------------------
revision 1.4
date: 2014/06/05 05:05:01;  author: root;  state: Exp;  lines: +2 -0
include the header file for the spinlock....i.e spinlock.h
----------------------------
revision 1.3
date: 2014/06/03 04:56:00;  author: root;  state: Exp;  lines: +2 -0
include the header file <linux.completion.h> for the completion...
----------------------------
revision 1.2
date: 2014/06/02 04:49:56;  author: root;  state: Exp;  lines: +3 -1
include the linux/semaphore.h header file for the semaphores.
----------------------------
revision 1.1
date: 2014/05/24 07:11:00;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: devlseek.c,v
Working file: devlseek.c
head: 1.3
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;	selected revisions: 3
description:
----------------------------
revision 1.3
date: 2014/06/02 07:22:38;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.2
date: 2014/05/30 07:09:37;  author: root;  state: Exp;  lines: +4 -2
*** empty log message ***
----------------------------
revision 1.1
date: 2014/05/25 11:30:12;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: devwrite.c,v
Working file: devwrite.c
head: 1.15
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 15;	selected revisions: 15
description:
used to write in the multiple quantum
multiple qset
then use copy_from_user.
very important file and hard too.
----------------------------
revision 1.15
date: 2014/06/05 06:54:22;  author: root;  state: Exp;  lines: +4 -2
*** empty log message ***
----------------------------
revision 1.14
date: 2014/06/05 05:56:16;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.13
date: 2014/06/05 05:07:03;  author: root;  state: Exp;  lines: +5 -3
use the spin_lock and spin_unlock
----------------------------
revision 1.12
date: 2014/06/03 12:48:15;  author: root;  state: Exp;  lines: +1 -0
given the complete call in the last...
----------------------------
revision 1.11
date: 2014/06/03 12:44:22;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.10
date: 2014/06/03 04:57:08;  author: root;  state: Exp;  lines: +4 -3
apply the wait_for_completion() same as the downing the semaphore...
apply the complete() same as the uping the semaphore...
----------------------------
revision 1.9
date: 2014/06/03 04:28:45;  author: root;  state: Exp;  lines: +2 -1
making up the semaphore above the returing.....
----------------------------
revision 1.8
date: 2014/06/03 04:21:25;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.7
date: 2014/06/02 12:11:54;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.6
date: 2014/06/02 11:45:08;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.5
date: 2014/06/02 05:14:55;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.4
date: 2014/06/02 04:51:17;  author: root;  state: Exp;  lines: +5 -0
making down and up the semaphore by using down_interruptible() and up() respectively
----------------------------
revision 1.3
date: 2014/05/25 09:31:31;  author: root;  state: Exp;  lines: +11 -4
use the loff and filep->f_pos to see the position of the pointer.
this loff and filep->f_pos could not be updated automatically so we make the updation.
----------------------------
revision 1.2
date: 2014/05/24 07:47:23;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.1
date: 2014/05/24 07:17:56;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: init.c,v
Working file: init.c
head: 1.7
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 7;	selected revisions: 7
description:
this is used to insert the module the register the module.
in this i dont use trim function.
----------------------------
revision 1.7
date: 2014/06/05 06:54:20;  author: root;  state: Exp;  lines: +4 -4
*** empty log message ***
----------------------------
revision 1.6
date: 2014/06/05 05:55:48;  author: root;  state: Exp;  lines: +4 -2
use the rwlock_t
----------------------------
revision 1.5
date: 2014/06/05 05:05:37;  author: root;  state: Exp;  lines: +3 -1
make the init
init_apin_lock is applied here....
----------------------------
revision 1.4
date: 2014/06/03 04:56:36;  author: root;  state: Exp;  lines: +2 -1
initilize the completion by init_completion above the cdev_add...
----------------------------
revision 1.3
date: 2014/06/02 11:38:52;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.2
date: 2014/06/02 04:50:25;  author: root;  state: Exp;  lines: +1 -0
initilize the binary semaphore before the cdev_add using the sema_init()
----------------------------
revision 1.1
date: 2014/05/24 07:12:20;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: prototype.h,v
Working file: prototype.h
head: 1.4
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;	selected revisions: 4
description:
declare the prototype.
----------------------------
revision 1.4
date: 2014/06/07 09:35:22;  author: root;  state: Exp;  lines: +2 -0
write the prototype for the scullioctl
----------------------------
revision 1.3
date: 2014/05/25 11:29:17;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.2
date: 2014/05/24 09:07:02;  author: root;  state: Exp;  lines: +2 -0
mention the prototype of the read call which is is fs.h header file and is in the struct file_operations {
----------------------------
revision 1.1
date: 2014/05/24 07:14:52;  author: root;  state: Exp;
Initial revision
=============================================================================
Posted in Uncategorized | Leave a comment

created a thread

RCS file: thread2.c,v
Working file: thread2.c
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
create a thread
—————————-
revision 1.1
date: 2014/06/08 08:18:53; author: root; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

Phony Targets, Macros and Special Characters in MAKEFILES

Sometimes a target does not mean a file but it might represent an action to be performed. When a target  is not related to a file it is called phony target.

For instance:

getobj:
	mv obj/*.o .  2>/dev/null

getobj target move all files with .o extension from obj directory to current directory — not a big deal. However, you should be asking yourself: “What if there is no file in obj ?” That is a good question. In that case, the mv command would return an error that would be passed to the make command.

Note: make command default behavior is to abort the processing when an error is detected while executing commands in rules.

Of course, there will be situations that the obj directory will be empty. How will you avoid the make command from aborting when an error happens?

You can use a special character - (minus) preceding the mv command. Thus:

getobj:
	-mv obj/*.o .  2>/dev/null

- Tells the make to ignore errors. There is another special character: @ – Tells make not to print the command to standard output before executing. You can combine both always preceding the command:

getobj:
	-@mv obj/*.o .  2>/dev/null

There is a special phony target called all where you can group several main targets and phony targets. all phony target  is often used to lead make command while reading makefile.

For instance:

all: getobj app install putobj

The make command will execute the targets in sequence: getobj, app, install and putobj.

Another interesting feature, make command supports is the concept of MACRO in makefiles. We can define a MACRO by writing:

MACRONAME=value

and access the value of MACRONAME by writing either $(MACRONAME) or ${MACRONAME}.

For instance:

EXECPATH=./bin

INCPATH=./include

OBJPATH=./obj

CC=cc

CFLAGS=-g -Wall -I$(INCPATH)

While executing, make replaces $(MACRONAME) with the appropriated definition. Now we know what phony targets and macros are we can move to the next sample.

Posted in Data Structures with C | Leave a comment

a program of function with argument passinng using shell script

RCS file: fun1,v
Working file: fun1
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
a program of function with argument passing using shell script
—————————-
revision 1.1
date: 2014/06/07 10:38:19; author: root; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

fibonacci series using pointer

1 #include
2 #include
3 int main()
4 {
5 int a,b,c,i,n;
6 b=0;
7 c=1;
8 printf(“enter the value \n”);
9 scanf(“%d”,&a);
10 int *d;
11 d=(int*)malloc(sizeof(a));
12 *(d+0)=0;
13 *(d+1)=1;
14 i=2;
15 while(i<a)
16 {
17 *(d+i)=b+c;b=c;c=*(d+i);
18 i++;
19 }
20 for(i=0;i<a;i++)
21 printf("%d\n",*(d+i));
22 }

Posted in Uncategorized | Leave a comment

registering character driver

head 1.15;
access;
symbols;
locks
root:1.15; strict;
comment @ * @;

1.15
date 2014.05.11.08.48.49; author root; state Exp;
branches;
next 1.14;

1.14
date 2014.05.10.07.23.56; author root; state Exp;
branches;
next 1.13;

1.13
date 2014.05.10.07.17.59; author root; state Exp;
branches;
next 1.12;

1.12
date 2014.05.09.10.22.15; author root; state Exp;
branches;
next 1.11;

1.11
date 2014.05.09.10.20.37; author root; state Exp;
branches;
next 1.10;

1.10
date 2014.05.09.07.45.13; author root; state Exp;
branches;
next 1.9;

1.9
date 2014.05.09.07.43.59; author root; state Exp;
branches;
next 1.8;

1.8
date 2014.05.09.07.39.00; author root; state Exp;
branches;
next 1.7;

1.7
date 2014.05.09.07.36.42; author root; state Exp;
branches;
next 1.6;

1.6
date 2014.05.09.07.35.17; author root; state Exp;
branches;
next 1.5;

1.5
date 2014.05.09.07.21.24; author root; state Exp;
branches;
next 1.4;

1.4
date 2014.05.08.11.42.32; author root; state Exp;
branches;
next 1.3;

1.3
date 2014.05.08.07.09.50; author root; state Exp;
branches;
next 1.2;

1.2
date 2014.05.06.11.48.01; author root; state Exp;
branches;
next 1.1;

1.1
date 2014.05.06.11.22.20; author root; state Exp;
branches;
next ;

desc
@initialization done.
@

1.15
log
@aloocated memory using kmalloc.
@
text
@#include”header.h”
#include”declration.c”
//#include”file_op.c”
unsigned int major_no,minor_no,nod;
dev_t dev;
struct sculldev *scull_dev;
module_param(nod,uint,S_IRUGO);
static int __init init_func(void)
{ int ret;
major_no= MAJORNO;
minor_no= MINORNO;
//nod= NOD;
//struct file_operations fops;
printk(KERN_INFO “we are in kernel”);
ret = alloc_chrdev_region(&dev,minor_no,nod,”poonam”);
if(ret<0)
{
printk(KERN_ERR"failed\n");
}
major_no=MAJOR(dev);
minor_no=MINOR(dev);
printk(KERN_INFO"sucessful registration major no =%d\n",major_no);
printk(KERN_INFO"sucessful registration minor no =%d\n",minor_no);
printk(KERN_INFO"nod is =%d\n",nod);
scull_dev = kmalloc((sizeof( struct sculldev)*nod), GFP_KERNEL);
if(!scull_dev)
{
printk(KERN_ERR"kmalloc failure\n");
return -1;
}

printk(KERN_INFO"kmalloc successfull\n");

return 0;
}

module_init(init_func);
@

1.14
log
@*** empty log message ***
@
text
@d6 1
d15 1
a15 1
ret = alloc_chrdev_region(&dev,minor_no,nod,"arjun");
d25 9
@

1.13
log
@add module_param macro
before initilaization function defination
@
text
@d6 1
a6 1
module_param(nod,unsigned int,S_IRUGO);
@

1.12
log
@*** empty log message ***
@
text
@d6 1
d11 1
a11 1
nod= NOD;
d23 1
@

1.11
log
@*** empty log message ***
@
text
@d11 1
a11 1
struct file_operations fops;
d18 2
a19 2
major_no=MAJORNO(dev);
minor_no=MINORNO(dev);
@

1.10
log
@*** empty log message ***
@
text
@d6 3
a8 3
static int init_func(void)
int ret;
{ major_no= MAJORNO;
@

1.9
log
@*** empty log message ***
@
text
@d18 1
a18 1
majro_no=MAJORNO(dev);
@

1.8
log
@*** empty log message ***
@
text
@d7 1
a10 1
int ret;
@

1.7
log
@*** empty log message ***
@
text
@d7 2
a8 2
{ major_no= MAJOR_NO;
minor_no= MINOR_NO;
d18 2
a19 2
majro_no=MAJOR_NO(dev);
minor_no=MINOR_NO(dev);
@

1.6
log
@*** empty log message ***
@
text
@d9 1
a9 1
NOD=nod;
@

1.5
log
@using alloc function
@
text
@d5 1
@

1.4
log
@used file operation variable.
@
text
@d2 1
d4 1
d6 3
a8 1
{
d12 1
a12 1
ret = register_chrdev(0,"mychardevice",&fops);
d17 5
a21 1
printk(KERN_INFO"sucessful registration %d\n",ret);
@

1.3
log
@included file operations in init function.
@
text
@d2 1
a2 1
#include"file_op.c"
d6 1
@

1.2
log
@register my char device.
@
text
@d7 6
a12 1
ret = register(0,"mychardevice",&fops);
@

1.1
log
@Initial revision
@
text
@d2 1
d4 2
a5 1
{
d7 1
@

Posted in Uncategorized | Leave a comment

character driver registration

Posted in Uncategorized | Leave a comment

algorithm to write initialization function for character deriver

follow these simple steps to initialize your character driver….
1. use module __init(initialization_function_name)
this is a micro which takes function name as argument.
2. static int initialization_function_name(void)
this is the defination of micro…
in this defination follow following steps..
a. register your char device using register_chardev_region().
b. allocate memory for the sculldev.
c. initialize your device using cdev_init() and add your device using cdev_add() functions.

Posted in Uncategorized | Leave a comment

information about kernel symbol table

We’ve seen how insmod resolves undefined symbols against the table of public kernel symbols. The table contains the addresses of global kernel items—functions and variables—that are needed to implement modularized drivers. When a module is loaded, any symbol exported by the module becomes part of the kernel symbol table. In the usual case, a module implements its own functionality without the need to export any symbols at all. You need to export symbols, however, whenever other modules may benefit from using them.

New modules can use symbols exported by your module, and you can stack new modules on top of other modules. Module stacking is implemented in the mainstream kernel sources as well: the msdos filesystem relies on symbols exported by the fat module, and each input USB device module stacks on the usbcore and input modules.

Module stacking is useful in complex projects. If a new abstraction is implemented in the form of a device driver, it might offer a plug for hardware-specific implementations. For example, the video-for-linux set of drivers is split into a generic module that exports symbols used by lower-level device drivers for specific hardware. According to your setup, you load the generic video module and the specific module for your installed hardware. Support for parallel ports and the wide variety of attachable devices is handled in the same way, as is the USB kernel subsystem. Stacking in the parallel port subsystem is shown in Figure 2-2; the arrows show the communications between the modules and with the kernel programming interface.

When using stacked modules, it is helpful to be aware of the modprobe utility. As we described earlier, modprobe functions in much the same way as insmod, but it also loads any other modules that are required by the module you want to load. Thus, one modprobe command can sometimes replace several invocations of insmod (although you’ll still need insmod when loading your own modules from the current directory, because modprobe looks only in the standard installed module directories).

Using stacking to split modules into multiple layers can help reduce development time by simplifying each layer. This is similar to the separation between mechanism and policy that we discussed in Chapter 1.

The Linux kernel header files provide a convenient way to manage the visibility of your symbols, thus reducing namespace pollution (filling the namespace with names that may conflict with those defined elsewhere in the kernel) and promoting proper information hiding. If your module needs to export symbols for other modules to use, the following macros should be used.

EXPORT_SYMBOL(name);
EXPORT_SYMBOL_GPL(name);

Either of the above macros makes the given symbol available outside the module. The _GPL version makes the symbol available to GPL-licensed modules only. Symbols must be exported in the global part of the module’s file, outside of any function, because the macros expand to the declaration of a special-purpose variable that is expected to be accessible globally. This variable is stored in a special part of the module executible (an “ELF section”) that is used by the kernel at load time to find the variables exported by the module.

Posted in Uncategorized | Leave a comment

register your charcter deriver

Posted in Uncategorized | Leave a comment

register of character deriver

Posted in Uncategorized | Leave a comment

fibonacci series using array

1 #include
2 int main()
3 {
4 int a,b,c,i,n;
5 b=0;
6 c=1;
7 printf(“enter the value \n”);
8 scanf(“%d”,&a);
9 int d[a];
10 d[0]=0;
11 d[1]=1;
12 i=2;
13 printf(“%d”,d[0]);
14 while(i<a)
15 {
16 d[i]=b+c;b=c;c=d[i];
17 i++;
18 }for(i=0;i<a;i++)
20 printf("%d\n",d[i]);
21 }

19 for(i=0;i<a;i++)
20 printf("%d\n",d[i]);
21 }
22

Posted in Uncategorized | Leave a comment

fibonnacci series using pointers

#include
2 #include
3 #include
4 int main()
5
6 {
7 int a,b,c,n,t,i;
8 int *ptr;
9
10 i =2;
11 /* a=0;
12 b=1;*/
13 printf(“enter the max range for fibonacci”);
14 scanf(“%d”,&n);
ptr = (int *)malloc(sizeof(n));
17 *(ptr+0)=0;
18 *(ptr+1)=1;
19 while(n>i)
{

15

Posted in Uncategorized | Leave a comment

program of thread and checking load of processor

head    1.1;
access;
symbols;
locks
root:1.1; strict;
comment    @ * @;

1.1
date    2014.06.07.07.30.30;    author root;    state Exp;
branches;
next    ;

desc
@simple program of thread.
@

1.1
log
@Initial revision
@

Posted in Uncategorized | Leave a comment

a program of function using shell scripting

RCS file: fun,v
Working file: fun
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
a program of function using shell scripting
—————————-
revision 1.1
date: 2014/06/07 10:05:25; author: root; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment