EmbLogic's Blog

Character Driver: lseek complete

RCS file: ./lseek.c,v
Working file: ./lseek.c
head: 1.3
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
lseek operation done.

revision 1.3
date: 2014/02/27 18:30:59; author: root; state: Exp; lines: +7 -0
at last new file position recevied for read operation.
————————

revision 1.3
date: 2014/02/27 18:30:59; author: root; state: Exp; lines: +7 -0
in lseek function use cases for SEEK_SET(0),SEEK_CURR(1),SEEK_END(2).
—————————-

revision 1.2

date: 2014/02/27 18:30:59; author: root; state: Exp; lines: +7 -0

declared loff_t nfpos .
—————————-
revision 1.1
date: 2014/02/27 18:28:22; author: root; state: Exp;
Initial revision

Posted in Uncategorized | Leave a comment

Multiple Data Compression

This is very impressive project, i have ever done.

As decompression is the reverse process of compression i.e. whatever be the procedure we follow during the compression, the reverse procedure will be follows during the decompression. During this projects i have read many aspects related to C programming and familiar the concept used in fseek() and lseek() function.

Posted in Project 2: Multiple Data Compression and Encryption | Leave a comment

Implemented stack using push and pop functions

RCS file: stack.c,v
Working file: stack.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
created a stack and implemented push statemnet.
—————————-
revision 1.2    locked by: root;
date: 2014/03/03 05:02:31;  author: root;  state: Exp;  lines: +20 -5
implemented pop statement.
—————————-
revision 1.1
date: 2014/03/03 04:53:59;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Data Structures with C, Uncategorized | Leave a comment

creation of stack using Functions and pushing and popping operation.

RCS file: stack.c,v
Working file: stack.c
head: 1.4
branch:
locks: strict
	root: 1.4
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;	selected revisions: 4
description:
created stack for 10 elements.
save address of stack into stackstart.
----------------------------
revision 1.4	locked by: root;
date: 2014/03/03 16:46:37;  author: root;  state: Exp;  lines: +7 -1
changes in pop function and decremented of value top.
empty the stack and goto stack top position.
----------------------------
revision 1.3
date: 2014/03/03 03:59:24;  author: root;  state: Exp;  lines: +42 -21
implemented stack pop operation and displaying contents of stack.
----------------------------
revision 1.2
date: 2014/03/02 10:20:25;  author: root;  state: Exp;  lines: +7 -8
changing int* into void*.
----------------------------
revision 1.1
date: 2014/03/02 08:10:27;  author: root;  state: Exp;
Initial revision
=============================================================================
Posted in Data Structures with C | Tagged | Leave a comment

Writing Character Device Driver

Following are the important points to note while writing data from user space to kernel space

1. The memory we allocate for creating qsets are architecture dependent, because qsets are the array of pointers which points to quantums i.e. they store the address of quantums.

2. so , for creating 8qsets in 32bit system we need to allocate 32 bytes of memory while in 64 bit system we need to allocate 64bytes of memory

 

Posted in Uncategorized | Leave a comment

User Interface to Character Device Driver

RCS file: writef.c,v
Working file: writef.c
head: 1.15
branch:
locks: strict
root: 1.15
access list:
symbolic names:
keyword substitution: kv
total revisions: 15;    selected revisions: 15
description:
chardev_write() function reside here.
—————————-
revision 1.15    locked by: root;
date: 2014/03/01 11:19:07;  author: root;  state: Exp;  lines: +5 -0.
Testing……….
—————————-
revision 1.14
date: 2014/03/01 11:13:18;  author: root;  state: Exp;  lines: +15 -7
The copy_from_user() function is used to copy a block of data from user space into the kernel buffer.copy_from_user() function contains 3 arguments:
1.A destination buffer,
2.A source buffer,and
3.length in bytes.
—————————-
revision 1.13
date: 2014/03/01 11:06:21;  author: root;  state: Exp;  lines: +2 -1
Done memset().
Testing the code…..
—————————-
revision 1.12
date: 2014/03/01 11:01:16;  author: root;  state: Exp;  lines: +54 -5
create_quantums() function that will create the required number of quantums.
Kmalloc() is used to allocate memory for each quantum. No. of quantums are dependent on how many number of bytes we are writing from user space.
Filling the memory allocated using kmalloc() with memset() so that it does not contain any garbage.
—————————-
revision 1.11
date: 2014/03/01 10:39:39;  author: root;  state: Exp;  lines: +1 -0
memset() function is used to fill the memory allocated for the qset array to ”.
—————————-
revision 1.10
date: 2014/03/01 10:36:59;  author: root;  state: Exp;  lines: +14 -4
Using kmalloc() memory is allocated to the required number of qsets , The memory allocated for qset depends upon the architecture of the OS, if the architecture is of 64 bytes then each qset required 8 byte of memory . and 4 bytes for 32 bit OS.Checking whether it is working fine or not.
—————————-
revision 1.9
date: 2014/03/01 10:26:27;  author: root;  state: Exp;  lines: +36 -2
Implemented create_scullqset() function.Now checking the number of qsets that needs to created by using the size argument of the chardev_write().After determining the number of qsets that needs to be created create_qset() function is called.
—————————-
revision 1.8
date: 2014/03/01 10:07:44;  author: root;  state: Exp;  lines: +2 -1
memset() function to clear the garbage ” .
—————————-
revision 1.7
date: 2014/03/01 10:04:21;  author: root;  state: Exp;  lines: +10 -0
Allocating memory for 1 scullqset using kmalloc
—————————-
revision 1.6
date: 2014/03/01 09:56:22;  author: root;  state: Exp;  lines: +22 -2
After finding out the number of scullqsets,create_scullqset() function is called to create the specified number of scullqsets.
Checking whether the function calling is taking place or not……
—————————-
revision 1.5
date: 2014/03/01 09:47:56;  author: root;  state: Exp;  lines: +19 -0
The size argument that specifies the size of the buffer pointed to by ubuff is used to find the number of scullqsets that needs to be created.
After finding out the exact number of scullqsets that needs to be created,the number of scullqsets are printed.
Creating scullqsets…….
—————————-
revision 1.4
date: 2014/03/01 09:32:34;  author: root;  state: Exp;  lines: +1 -1
Checking whether the ubuff pointer is actually pointing to the buffer in the application.Also checking the size field inside the 3rd argument of chardev_write().
—————————-
revision 1.3
date: 2014/03/01 09:28:31;  author: root;  state: Exp;  lines: +6 -1

Testing….
—————————-
revision 1.2
date: 2014/03/01 09:20:00;  author: root;  state: Exp;  lines: +9 -1
Printing the address inside filep->private_data to check whether it matches with the address returned by container_of() macro.
A local variable of type Sculldev is declared which will store the address that is present inside filep->private_data.
—————————-
revision 1.1
date: 2014/02/28 21:33:05;  author: root;  state: Exp;
Initial revision

Posted in Uncategorized | Leave a comment

BLOG

ARM architecture

ARM is a family of instruction set architectures for computer processors based on a reduced instruction set computing (RISC) architecture developed by British company ARM Holdings.

A RISC-based computer design approach means ARM processors require significantly fewer transistors than typical processors in average computers. This approach reduces costs, heat and power use. These are desirable traits for light, portable, battery-powered devices—including smartphones, laptops, tablet and notepad computers, and other embedded systems. A simpler design facilitates more efficient multi-core CPUs and higher core counts at lower cost, providing higher processing power and improved energy efficiency for servers and supercomputers.

ARM Holdings develops the instruction set and architecture for ARM-based products, but does not manufacture products. The company periodically releases updates to its cores. Current cores from ARM Holdings support a 32-bit address space and 32-bit arithmetic,the recently introduced ARMv8-A architecture adds support for a 64-bit address space and 64-bit arithmetic. Instructions for ARM Holdings’ cores have 32-bit-wide fixed-length instructions, but later versions of the architecture also support a variable-length instruction set that provides both 32-bit and 16-bit-wide instructions for improved code density. Some cores can also provide hardware execution of Java byte codes.

ARM Holdings licenses the chip designs and the ARM instruction set architectures to third-parties, who design their own products that implement one of those architectures—including systems-on-chips (SoC) that incorporate memory, interfaces, radios, etc. Currently, the widely used Cortex cores, older “classic” cores, and specialized SecurCore cores variants are available for each of these to include or exclude optional capabilities. Companies that produce ARM products include Apple, Nvidia, Qualcomm, Rockchip, Samsung Electronics, and Texas Instruments. Apple first implemented the ARMv8-A architecture in the Apple A7 chip in the iPhone 5S.

In 2005, about 98% of all mobile phones sold used at least one ARM processor. The low power consumption of ARM processors has made them very popular: 37 billion ARM processors have been produced as of 2013, up from 10 billion in 2008. The ARM architecture (32-bit) is the most widely used architecture in mobile devices, and most popular 32-bit one in embedded systems.

According to ARM Holdings, in 2010 alone, producers of chips based on ARM architectures reported shipments of 6.1 billion ARM-based processors, representing 95% of smartphones, 35% of digital televisions and set-top boxes and 10% of mobile computers. It is the most widely used 32-bit instruction set architecture in terms of quantity produced.

History

The British computer manufacturer Acorn Computers first developed ARM in the 1980s to use in its personal computers. Its first ARM-based products were coprocessor modules for the BBC Micro series of computers. After the successful BBC Micro computer, Acorn Computers considered how to move on from the relatively simple MOS Technology 6502 processor to address business markets like the one that was soon dominated by the IBM PC, launched in 1981. The Acorn Business Computer (ABC) plan required that a number of second processors be made to work with the BBC Micro platform, but processors such as the Motorola 68000 and National Semiconductor 32016 were considered unsuitable, and the 6502 was not powerful enough for a graphics based user interface.

After testing all available processors and finding them lacking, Acorn decided it needed a new architecture. Inspired by white papers on the Berkeley RISC project, Acorn considered designing its own processor. A visit to the Western Design Center in Phoenix, where the 6502 was being updated by what was effectively a single-person company, showed Acorn engineers Steve Furber and Sophie Wilson they did not need massive resources and state-of-the-art research and development facilities.

Wilson developed the instruction set, writing a simulation of the processor in BBC Basic that ran on a BBC Micro with a second 6502 processor. This convinced Acorn engineers they were on the right track. Wilson approached Acorn’s CEO, Hermann Hauser, and requested more resources. Once he had approval, he assembled a small team to implement Wilson’s model in hardware.

Posted in Uncategorized | Tagged | Leave a comment

Module code to show how to perform “trim” operation by calling chardev_trim() before the device is opened for writing.

RCS file: openf.c,v
Working file: openf.c
head: 1.14
branch:
locks: strict
root: 1.14
access list:
symbolic names:
keyword substitution: kv
total revisions: 14;    selected revisions: 14
description:
The functionality of chardev_open() is implemented here inside this file.Whenever the application calls the open function,this is always the first operation performed on the device file.
—————————-
revision 1.14    locked by: root;
date: 2014/03/02 13:54:57;  author: root;  state: Exp;  lines: +0 -8
Status : chardev_trim() is working fine.

The chardev_trim() function is called to perform an operation of truncating the device to a length of 0 when the device is opened for writing.
For checking purposes,chardev_trim() function is called twice.One inside the chardev_open() and one inside the chardev_release().
—————————-
revision 1.13
date: 2014/03/01 20:24:26;  author: root;  state: Exp;  lines: +12 -4
Compilation successfull and chardev_trim() function is working fine.
Issue:Trying the free the memory that is not allocated in case of quantum.
Logical error fixed.
—————————-
revision 1.12
date: 2014/03/01 19:41:54;  author: root;  state: Exp;  lines: +4 -0
kernel crash taking place inside chardev_trim() function.
Issue inside chardev_trim() function.
Debugging……………………………
—————————-
revision 1.11
date: 2014/03/01 19:38:30;  author: root;  state: Exp;  lines: +1 -1
Syntax error fixed.
Issue:Missing semicolon.
—————————-
revision 1.10
date: 2014/03/01 19:37:04;  author: root;  state: Exp;  lines: +12 -4
One bug fixed.
Issue:qset_size variable is included using extern.
Debugging…..
—————————-
revision 1.9
date: 2014/03/01 13:09:52;  author: root;  state: Exp;  lines: +49 -3
Implementing chardev_trim() function.Inside this function,firstly certain checks are made to make sure that Sculldec , scullqset , qset and quantums exist or not.
If any of such things do not exist an error message is reported.Now performing trimming………..
—————————-
revision 1.8
date: 2014/03/01 12:08:22;  author: root;  state: Exp;  lines: +23 -1
Two printk statements are added inside the chardev_trim() function to mark its beginning and end.
Checking……….
—————————-
revision 1.7
date: 2014/03/01 11:57:45;  author: root;  state: Exp;  lines: +5 -0
O_ACCMODE is a macro that stands for a mask that can be bitwise-ANDed with the file status flag value to produce a value representing the file access mode.The mode will be O_WRONLY,O_RDONLY or O_RDWR.
The O_ACCMODE macro is used inside the chardev_open() function to find out the file access mode.
—————————-
revision 1.6
date: 2014/03/01 08:45:54;  author: root;  state: Exp;  lines: +5 -1
Printing the address stored inside the lsculldev to check whether it matches with the filep->private data address printed inside the chardev_release() function.
—————————-
revision 1.5
date: 2014/03/01 08:33:40;  author: root;  state: Exp;  lines: +1 -0
Once the Sculldev structure is found by the container_of() macro,a pointer to the scull is stored in the private_data field of the file structure for easier access    .
—————————-
revision 1.4
date: 2014/03/01 08:25:52;  author: root;  state: Exp;  lines: +11 -4
A local variable of type struct Sculldev is declared.
Used container_of() inside the open function.This macro has 3 arguments:
1.A pointer to a field named container_field.
2.This container field within a structure of type container_type,and
3.ccontainer field.
On success it returns a pointer to the containing structure.
—————————-
revision 1.3
date: 2014/02/28 18:51:08;  author: root;  state: Exp;  lines: +2 -0
Included the prototype of chardev_open() using extern.
—————————-
revision 1.2
date: 2014/02/28 18:42:56;  author: root;  state: Exp;  lines: +15 -0
Two printk statements are used to test that whether the open function is actually begin and ended.\
—————————-
revision 1.1
date: 2014/02/28 18:33:28;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: initial.c,v
Working file: initial.c
head: 1.13
branch:
locks: strict
root: 1.13
access list:
symbolic names:
keyword substitution: kv
total revisions: 13;    selected revisions: 13
description:
File containing the module’s initialization function that is called at module insertion time.
—————————-
revision 1.13    locked by: root;
date: 2014/02/28 18:56:45;  author: root;  state: Exp;  lines: +1 -1
Fixed the warning by giving void as an argument inside the initialize_parameters() function.
Compilation is successfull.
Checking the functionality by calling application……….
—————————-
revision 1.12
date: 2014/02/28 17:59:59;  author: root;  state: Exp;  lines: +1 -0
Header file:”file_opr.h” is added to include the file_operations structure.The file_operations structure is used to access the driver’s functions.
—————————-
revision 1.11
date: 2014/02/28 17:49:26;  author: root;  state: Exp;  lines: +15 -4
After a device number range has been obtained,the device needs to be activated by adding it to the character device database.This requires initializing an instance of cdev_init() followed by a call to cdev_add().cdev_add() tells te kernel about the cdev data structure.
—————————-
revision 1.10
date: 2014/02/28 17:16:31;  author: root;  state: Exp;  lines: +16 -0
Both the major and minor numbers are initialized to 0 inside the initialize_parameters() function.Macros like MAJOR() and MINOR() are used to extract the major and minor number from dev type variable.Another macro called MKDEV is used to create the device number.
Checking……
—————————-
revision 1.9
date: 2014/02/28 16:50:22;  author: root;  state: Exp;  lines: +25 -0
From the initialization function,another function is called to initialize the parameters such as device size, quantum_size ,qset_size and data_size.

Status:The parameters are initialized successfully.
Now before the kernel calls the device’s operations,a cdev structure must be initialized with cdev_init() and the kernel is being told about the initialization with cdev_add().Implementing this task….
—————————-
revision 1.8
date: 2014/02/28 15:46:09;  author: root;  state: Exp;  lines: +1 -1
Inside the alloc_chrdev_region(),the fourth argument is changed from DEVICE_NAME to DRIVER_NAME.
—————————-
revision 1.7
date: 2014/02/28 15:32:31;  author: root;  state: Exp;  lines: +1 -0
memset() is used to fill the memory allocated using kmalloc() function with ”.
—————————-
revision 1.6
date: 2014/02/28 15:26:38;  author: root;  state: Exp;  lines: +12 -1
kmalloc() function is used to allocate memory.kmalloc() function takes two arguments:
1.size ,and
2.set of flags.
On success,kmalloc returns a pointer to the allocated memory otherwise it returns NULL.
In the flag field,GFP_KERNEL is used.
—————————-
revision 1.5
date: 2014/02/27 20:12:29;  author: root;  state: Exp;  lines: +7 -1
module_param() macro is used.With the help of this macro parameters can be passed to the module while loading it,when using “insmod”.
module_param() macro takes three arguments:
1.The name of the variable,
2.The type of the variable,
3.Permissions.
—————————-
revision 1.4
date: 2014/02/27 19:58:09;  author: root;  state: Exp;  lines: +1 -1
alloc_chrdev_region() function is used to allocate dynamically a major number.On success,the first parameter of this function stores the first device number.
—————————-
revision 1.3
date: 2014/02/27 19:31:39;  author: root;  state: Exp;  lines: +11 -0
Header file: “decleration.h” is added to include all the variable declerations.
—————————-
revision 1.2
date: 2014/02/27 18:50:37;  author: root;  state: Exp;  lines: +7 -0
module_init() macro is used to define which function is called during module’s insertion time.
__init token hints to the kernel that the function is used only at the initialization time.
The function specified by the module_init() macro is declared static because it is not meant to be visible outside the file.
—————————-
revision 1.1
date: 2014/02/27 18:49:06;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: closef.c,v
Working file: closef.c
head: 1.3
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
chardev_release() function live here.
—————————-
revision 1.3
date: 2014/03/02 14:08:43;  author: root;  state: Exp;  lines: +9 -1
chardev_trim() function is called to truncate the device to a length 0 and also it is called here to check whether trimming is working properly or not.
—————————-
revision 1.2
date: 2014/02/28 20:37:55;  author: root;  state: Exp;  lines: +2 -2
chardev_release() function is called when the application calls close() system call.
Two printk statements are used as debug statements to find out whether this function is called or not.
—————————-
revision 1.1
date: 2014/02/28 20:37:08;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: header.h,v
Working file: header.h
head: 1.17
branch:
locks: strict
root: 1.17
access list:
symbolic names:
keyword substitution: kv
total revisions: 17;    selected revisions: 17
description:
Base header file that includes the definitions of all the macros,structures and contains the necessary header files required by the module code.
—————————-
revision 1.17    locked by: root;
date: 2014/03/01 11:21:47;  author: root;  state: Exp;  lines: +1 -0
Header file:<asm/uaccess.h> is added to support copy_from_user() function.
—————————-
revision 1.16
date: 2014/02/28 17:13:48;  author: root;  state: Exp;  lines: +2 -0
Header file:<linux/types.h> is added to support dev_t type.
—————————-
revision 1.15
date: 2014/02/28 16:58:15;  author: root;  state: Exp;  lines: +6 -0
Two macros are defined called MAJOR_NO and MINOR_NO.
—————————-
revision 1.14
date: 2014/02/28 15:44:56;  author: root;  state: Exp;  lines: +2 -2
The macro DEVICE_NAME is changed to DRIVER_NAME and the header file:<string.h> is removed.
—————————-
revision 1.13
date: 2014/02/28 15:41:31;  author: root;  state: Exp;  lines: +1 -1
Header file:<linux/cdev.h> is added to support a cdev structure.The cdev structure is used to register the driver with the kernel.
—————————-
revision 1.12
date: 2014/02/28 15:33:59;  author: root;  state: Exp;  lines: +1 -0
Header file:<string.h> is added to support memset() function.
—————————-
revision 1.11
date: 2014/02/28 15:18:15;  author: root;  state: Exp;  lines: +16 -0
Four macros are defined namely:DEVICE_SIZE , DATA_SIZE , QUANTUM and QSET.
These macros are used to initialize the fields inside the Scull_Dev structure.
—————————-
revision 1.10
date: 2014/02/28 15:10:35;  author: root;  state: Exp;  lines: +16 -0
Two structures are defined of type Sculldev and Scullqset.Sculldev is a structure that is used to hold device information.Scullqset is a structure that holds a pointer to the qset array and another pointer to a structure of Scullqset type.
—————————-
revision 1.9
date: 2014/02/27 21:07:42;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/slab.h> is added to support kmalloc() and kfree() functions.
—————————-
revision 1.8
date: 2014/02/27 20:02:53;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/moduleparam.h> is added to support the module_param() macro.With the help of this macro parameters can be passed to a module while loading it.
—————————-
revision 1.7
date: 2014/02/27 19:28:38;  author: root;  state: Exp;  lines: +4 -0
A macro called DEVICE_NAME is defined using #define.
—————————-
revision 1.6
date: 2014/02/27 19:20:01;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/fs.h> is added to the base header file to support various functions like alloc_chrdev_region(),unregister_chrdev_region(),etc.
—————————-
revision 1.5
date: 2014/02/27 18:44:36;  author: root;  state: Exp;  lines: +4 -0
A macro called DEBUG is defined using #define.
—————————-
revision 1.4
date: 2014/02/27 18:41:13;  author: root;  state: Exp;  lines: +2 -0
A special macro called MODULE_LICENSE is used to tell the kernel that the module bears a free license without such a decleration the kernel complains.
—————————-
revision 1.3
date: 2014/02/27 18:38:11;  author: root;  state: Exp;  lines: +1 -1
Header file:<linux/module.h> is added to the base header file to provide support for a great many number of macros like:MODULE_LICENSE , MODULE_AUTHOR,etc.
—————————-
revision 1.2
date: 2014/02/27 18:36:07;  author: root;  state: Exp;  lines: +2 -0
Header file:<linux/init.h> is added to the base header file to provide support for module_init() and module_exit() macros.
—————————-
revision 1.1
date: 2014/02/27 18:35:18;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Character Driver, Device Drivers | Leave a comment

Fibonacci Using Recursion

RCS file: ques1.c,v
Working file: ques1.c
head: 1.3
branch:
locks: strict
akshat: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
fibonaci using function calling.
recursion concept.
—————————-
revision 1.3    locked by: akshat;
date: 2014/02/26 14:24:40;  author: akshat;  state: Exp;  lines: +4 -1
its working perfectly.
done.
—————————-
revision 1.2
date: 2014/02/26 14:15:28;  author: akshat;  state: Exp;  lines: +3 -2
errors eliminated.
—————————-
revision 1.1
date: 2014/02/26 14:12:48;  author: akshat;  state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

Project 1-MDC

RCS file: mdc.c,v
Working file: mdc.c
head: 1.42
branch:
locks: strict
akshat: 1.42
access list:
symbolic names:
keyword substitution: kv
total revisions: 42;    selected revisions: 42
description:
implementation of MULTIPLE DATA COMPRESSION AND ENCRYPTION USING ITERATIVE TECHNIQUES.
Opening and reading from file.
—————————-
revision 1.42    locked by: akshat;
date: 2014/03/02 01:29:53;  author: akshat;  state: Exp;  lines: +17 -12
exact compressed file is retrieved.
MDC for 4bit code length performed.
—————————-
revision 1.41
date: 2014/03/02 01:20:06;  author: akshat;  state: Exp;  lines: +15 -21
finally file is compressed and decompressed.
—————————-
revision 1.40
date: 2014/03/01 22:38:54;  author: akshat;  state: Exp;  lines: +29 -7
Decompression done.
,
—————————-
revision 1.39
date: 2014/03/01 22:03:53;  author: akshat;  state: Exp;  lines: +2 -2
Completed compression with 50%.
—————————-
revision 1.38
date: 2014/03/01 21:50:17;  author: akshat;  state: Exp;  lines: +15 -12
Compression done.
4 bit compression.
—————————-
revision 1.37
date: 2014/03/01 21:34:42;  author: akshat;  state: Exp;  lines: +1 -1
Compressing the file.
—————————-
revision 1.36
date: 2014/03/01 21:32:44;  author: akshat;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.35
date: 2014/03/01 21:32:17;  author: akshat;  state: Exp;  lines: +1 -1
infinite loop omitted.
—————————-
revision 1.34
date: 2014/03/01 21:31:19;  author: akshat;  state: Exp;  lines: +1 -1
Error check.
—————————-
revision 1.33
date: 2014/03/01 21:30:46;  author: akshat;  state: Exp;  lines: +3 -2
Function declaration done.
—————————-
revision 1.32
date: 2014/03/01 21:27:42;  author: akshat;  state: Exp;  lines: +3 -5
Corrections made.
Debugging tool used.
Use of scripting techniques.
—————————-
revision 1.31
date: 2014/03/01 21:26:34;  author: akshat;  state: Exp;  lines: +33 -23
Encryption function formed.
—————————-
revision 1.30
date: 2014/03/01 19:31:32;  author: akshat;  state: Exp;  lines: +4 -1
*** empty log message ***
—————————-
revision 1.29
date: 2014/03/01 19:13:19;  author: akshat;  state: Exp;  lines: +3 -11
Index found.
—————————-
revision 1.28
date: 2014/03/01 18:26:37;  author: akshat;  state: Exp;  lines: +2 -7
*** empty log message ***
—————————-
revision 1.27
date: 2014/03/01 18:25:41;  author: akshat;  state: Exp;  lines: +6 -6
*** empty log message ***
—————————-
revision 1.26
date: 2014/03/01 18:25:04;  author: akshat;  state: Exp;  lines: +4 -2
*** empty log message ***
—————————-
revision 1.25
date: 2014/03/01 18:23:19;  author: akshat;  state: Exp;  lines: +1 -1
Implemented count for counting no of distinct charcters.
—————————-
revision 1.24
date: 2014/03/01 18:23:03;  author: akshat;  state: Exp;  lines: +3 -3
*** empty log message ***
—————————-
revision 1.23
date: 2014/03/01 18:22:18;  author: akshat;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.22
date: 2014/03/01 18:21:55;  author: akshat;  state: Exp;  lines: +2 -1
Corrected.
—————————-
revision 1.21
date: 2014/03/01 18:19:48;  author: akshat;  state: Exp;  lines: +1 -0
*** empty log message ***
—————————-
revision 1.20
date: 2014/03/01 18:19:21;  author: akshat;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.19
date: 2014/03/01 18:16:51;  author: akshat;  state: Exp;  lines: +4 -4
done.
—————————-
revision 1.18
date: 2014/03/01 18:13:15;  author: akshat;  state: Exp;  lines: +1 -0
*** empty log message ***
—————————-
revision 1.17
date: 2014/03/01 18:11:54;  author: akshat;  state: Exp;  lines: +2 -1
*** empty log message ***
—————————-
revision 1.16
date: 2014/03/01 18:09:24;  author: akshat;  state: Exp;  lines: +3 -3
*** empty log message ***
—————————-
revision 1.15
date: 2014/03/01 18:00:12;  author: akshat;  state: Exp;  lines: +3 -2
Function convert omitted.
—————————-
revision 1.14
date: 2014/03/01 17:58:28;  author: akshat;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.13
date: 2014/03/01 17:53:39;  author: akshat;  state: Exp;  lines: +1 -1
checking for correct type of ind.
—————————-
revision 1.12
date: 2014/03/01 17:52:17;  author: akshat;  state: Exp;  lines: +2 -2
Type of index was wrong.
—————————-
revision 1.11
date: 2014/03/01 17:49:25;  author: akshat;  state: Exp;  lines: +1 -1
CONFLICTING TYPES.
CHECKING.
—————————-
revision 1.10
date: 2014/03/01 17:48:57;  author: akshat;  state: Exp;  lines: +1 -1
YES, got the error.
—————————-
revision 1.9
date: 2014/03/01 17:47:37;  author: akshat;  state: Exp;  lines: +8 -5
conflicting types for convert found.
checking.
—————————-
revision 1.8
date: 2014/03/01 17:45:07;  author: akshat;  state: Exp;  lines: +30 -7
Created various functions.
checking for errors.
—————————-
revision 1.7
date: 2014/03/01 17:31:58;  author: akshat;  state: Exp;  lines: +3 -3
GENERAL error found.
GDB working.
Scripting working.
—————————-
revision 1.6
date: 2014/03/01 17:29:53;  author: akshat;  state: Exp;  lines: +1 -0
Checking for few more errors.
—————————-
revision 1.5
date: 2014/03/01 17:27:09;  author: akshat;  state: Exp;  lines: +3 -3
GDB understanding is intersting.
—————————-
revision 1.4
date: 2014/03/01 17:24:35;  author: akshat;  state: Exp;  lines: +39 -11
errors, lets use GDB(DEBUGGING TOOL).
GRADUAL DEBUGGER
USE OF DEBUGGING TOOLS.
—————————-
revision 1.3
date: 2014/03/01 17:14:18;  author: akshat;  state: Exp;  lines: +7 -0
implemented use of SHELL SCRIPTING in the project MDC.
its done using BASH script in bin.
—————————-
revision 1.2
date: 2014/03/01 17:08:02;  author: akshat;  state: Exp;  lines: +11 -5
array containing text file elements is created.
using scripts now.
—————————-
revision 1.1
date: 2014/03/01 16:35:53;  author: akshat;  state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

Character_driver :read operation

I am implemented successfully read operation from kernel space to user space with and without using lseek machanism.

Posted in Uncategorized | Leave a comment

Module code to show how to write data in a single quantum using copy_from_user() function.

RCS file: writef.c,v
Working file: writef.c
head: 1.15
branch:
locks: strict
root: 1.15
access list:
symbolic names:
keyword substitution: kv
total revisions: 15;    selected revisions: 15
description:
chardev_write() function reside here.
—————————-
revision 1.15    locked by: root;
date: 2014/03/01 11:19:07;  author: root;  state: Exp;  lines: +5 -0
One printk statement is added to test whether the data is actually copied into the kernel buffer or not.
Testing……….
—————————-
revision 1.14
date: 2014/03/01 11:13:18;  author: root;  state: Exp;  lines: +15 -7
The copy_from_user() function is used to copy a block of data from user space into the kernel buffer.copy_from_user() function contains 3 arguments:
1.A destination buffer,
2.A source buffer,and
3.length in bytes.
—————————-
revision 1.13
date: 2014/03/01 11:06:21;  author: root;  state: Exp;  lines: +2 -1
Done memset().
Testing the code…..
—————————-
revision 1.12
date: 2014/03/01 11:01:16;  author: root;  state: Exp;  lines: +54 -5
Implemented the create_quantums() function that will create the required number of quantums.
Kmalloc() is used to allocate memory for each quantum.
Filling the memory allocated using kmalloc() with memset() so that it does not contain any garbage.
—————————-
revision 1.11
date: 2014/03/01 10:39:39;  author: root;  state: Exp;  lines: +1 -0
memset() function is used to fill the memory allocated for the qset array to ”.
—————————-
revision 1.10
date: 2014/03/01 10:36:59;  author: root;  state: Exp;  lines: +14 -4
Using kmalloc() memory is allocated to the required number of qsets.
Checking whether it is working fine or not.
—————————-
revision 1.9
date: 2014/03/01 10:26:27;  author: root;  state: Exp;  lines: +36 -2
Implemented create_scullqset() function.Now checking the number of qsets that needs to created by using the size argument of the chardev_write().After determining the number of qsets that needs to be created create_qset() function is called.
—————————-
revision 1.8
date: 2014/03/01 10:07:44;  author: root;  state: Exp;  lines: +2 -1
memset() function is used to fill the memory allocated using kmalloc() with ” .
—————————-
revision 1.7
date: 2014/03/01 10:04:21;  author: root;  state: Exp;  lines: +10 -0
Allocating memory for 1 scullqset to check whether the create_scullqset() function is working properly or not.
—————————-
revision 1.6
date: 2014/03/01 09:56:22;  author: root;  state: Exp;  lines: +22 -2
After finding out the number of scullqsets,create_scullqset() function is called to create the specified number of scullqsets.
Checking whether the function calling is taking place or not……
—————————-
revision 1.5
date: 2014/03/01 09:47:56;  author: root;  state: Exp;  lines: +19 -0
The size argument that specifies the size of the buffer pointed to by ubuff is used to find the number of scullqsets that needs to be created.
After finding out the exact number of scullqsets that needs to be created,the number of scullqsets are printed.
Creating scullqsets…….
—————————-
revision 1.4
date: 2014/03/01 09:32:34;  author: root;  state: Exp;  lines: +1 -1
Fixed the warning by type-casting size_t to int.
—————————-
revision 1.3
date: 2014/03/01 09:28:31;  author: root;  state: Exp;  lines: +6 -1
Checking whether the ubuff pointer is actually pointing to the buffer in the application.Also checking the size field inside the 3rd argument of chardev_write().
—————————-
revision 1.2
date: 2014/03/01 09:20:00;  author: root;  state: Exp;  lines: +9 -1
Printing the address inside filep->private_data to check whether it matches with the address returned by container_of() macro.
A local variable of type Sculldev is declared which will store the address that is present inside filep->private_data.
—————————-
revision 1.1
date: 2014/02/28 21:33:05;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: openf.c,v
Working file: openf.c
head: 1.6
branch:
locks: strict
root: 1.6
access list:
symbolic names:
keyword substitution: kv
total revisions: 6;    selected revisions: 6
description:
The functionality of chardev_open() is implemented here inside this file.Whenever the application calls the open function,this is always the first operation performed on the device file.
—————————-
revision 1.6    locked by: root;
date: 2014/03/01 08:45:54;  author: root;  state: Exp;  lines: +5 -1
Printing the address stored inside the lsculldev to check whether it matches with the filep->private data address printed inside the chardev_release() function.
—————————-
revision 1.5
date: 2014/03/01 08:33:40;  author: root;  state: Exp;  lines: +1 -0
Once the Sculldev structure is found by the container_of() macro,a pointer to the scull is stored in the private_data field of the file structure for easier access    .
—————————-
revision 1.4
date: 2014/03/01 08:25:52;  author: root;  state: Exp;  lines: +11 -4
A local variable of type struct Sculldev is declared.
Used container_of() inside the open function.This macro has 3 arguments:
1.A pointer to a field named container_field.
2.This container field within a structure of type container_type,and
3.ccontainer field.
On success it returns a pointer to the containing structure.
—————————-
revision 1.3
date: 2014/02/28 18:51:08;  author: root;  state: Exp;  lines: +2 -0
Included the prototype of chardev_open() using extern.
—————————-
revision 1.2
date: 2014/02/28 18:42:56;  author: root;  state: Exp;  lines: +15 -0
Two printk statements are used to test that whether the open function is actually begin and ended.\
—————————-
revision 1.1
date: 2014/02/28 18:33:28;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: header.h,v
Working file: header.h
head: 1.17
branch:
locks: strict
root: 1.17
access list:
symbolic names:
keyword substitution: kv
total revisions: 17;    selected revisions: 17
description:
Base header file that includes the definitions of all the macros,structures and contains the necessary header files required by the module code.
—————————-
revision 1.17    locked by: root;
date: 2014/03/01 11:21:47;  author: root;  state: Exp;  lines: +1 -0
Header file:<asm/uaccess.h> is added to support copy_from_user() function.
—————————-
revision 1.16
date: 2014/02/28 17:13:48;  author: root;  state: Exp;  lines: +2 -0
Header file:<linux/types.h> is added to support dev_t type.
—————————-
revision 1.15
date: 2014/02/28 16:58:15;  author: root;  state: Exp;  lines: +6 -0
Two macros are defined called MAJOR_NO and MINOR_NO.
—————————-
revision 1.14
date: 2014/02/28 15:44:56;  author: root;  state: Exp;  lines: +2 -2
The macro DEVICE_NAME is changed to DRIVER_NAME and the header file:<string.h> is removed.
—————————-
revision 1.13
date: 2014/02/28 15:41:31;  author: root;  state: Exp;  lines: +1 -1
Header file:<linux/cdev.h> is added to support a cdev structure.The cdev structure is used to register the driver with the kernel.
—————————-
revision 1.12
date: 2014/02/28 15:33:59;  author: root;  state: Exp;  lines: +1 -0
Header file:<string.h> is added to support memset() function.
—————————-
revision 1.11
date: 2014/02/28 15:18:15;  author: root;  state: Exp;  lines: +16 -0
Four macros are defined namely:DEVICE_SIZE , DATA_SIZE , QUANTUM and QSET.
These macros are used to initialize the fields inside the Scull_Dev structure.
—————————-
revision 1.10
date: 2014/02/28 15:10:35;  author: root;  state: Exp;  lines: +16 -0
Two structures are defined of type Sculldev and Scullqset.Sculldev is a structure that is used to hold device information.Scullqset is a structure that holds a pointer to the qset array and another pointer to a structure of Scullqset type.
—————————-
revision 1.9
date: 2014/02/27 21:07:42;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/slab.h> is added to support kmalloc() and kfree() functions.
—————————-
revision 1.8
date: 2014/02/27 20:02:53;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/moduleparam.h> is added to support the module_param() macro.With the help of this macro parameters can be passed to a module while loading it.
—————————-
revision 1.7
date: 2014/02/27 19:28:38;  author: root;  state: Exp;  lines: +4 -0
A macro called DEVICE_NAME is defined using #define.
—————————-
revision 1.6
date: 2014/02/27 19:20:01;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/fs.h> is added to the base header file to support various functions like alloc_chrdev_region(),unregister_chrdev_region(),etc.
—————————-
revision 1.5
date: 2014/02/27 18:44:36;  author: root;  state: Exp;  lines: +4 -0
A macro called DEBUG is defined using #define.
—————————-
revision 1.4
date: 2014/02/27 18:41:13;  author: root;  state: Exp;  lines: +2 -0
A special macro called MODULE_LICENSE is used to tell the kernel that the module bears a free license without such a decleration the kernel complains.
—————————-
revision 1.3
date: 2014/02/27 18:38:11;  author: root;  state: Exp;  lines: +1 -1
Header file:<linux/module.h> is added to the base header file to provide support for a great many number of macros like:MODULE_LICENSE , MODULE_AUTHOR,etc.
—————————-
revision 1.2
date: 2014/02/27 18:36:07;  author: root;  state: Exp;  lines: +2 -0
Header file:<linux/init.h> is added to the base header file to provide support for module_init() and module_exit() macros.
—————————-
revision 1.1
date: 2014/02/27 18:35:18;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: closef.c,v
Working file: closef.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
chardev_release() function live here.
—————————-
revision 1.2    locked by: root;
date: 2014/02/28 20:37:55;  author: root;  state: Exp;  lines: +2 -2
chardev_release() function is called when the application calls close() system call.
Two printk statements are used as debug statements to find out whether this function is called or not.
—————————-
revision 1.1
date: 2014/02/28 20:37:08;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: cleanup.c,v
Working file: cleanup.c
head: 1.6
branch:
locks: strict
root: 1.6
access list:
symbolic names:
keyword substitution: kv
total revisions: 6;    selected revisions: 6
description:
File that contains the cleanup function which returns all the resources back to the system.
—————————-
revision 1.6    locked by: root;
date: 2014/02/28 15:35:01;  author: root;  state: Exp;  lines: +1 -0
kfree() function is used for freeing the memory.
—————————-
revision 1.5
date: 2014/02/27 20:15:39;  author: root;  state: Exp;  lines: +3 -1
A variable of type int representing the number of devices is included here using extern.
—————————-
revision 1.4
date: 2014/02/27 19:36:03;  author: root;  state: Exp;  lines: +1 -0
A variable dev of type dev_t storing the device number is included here using extern.
—————————-
revision 1.3
date: 2014/02/27 19:33:49;  author: root;  state: Exp;  lines: +3 -1
Called unregister_chrdev_region() which is having 2 arguments: device number and the total number of device numbers to unregister.
—————————-
revision 1.2
date: 2014/02/27 18:58:02;  author: root;  state: Exp;  lines: +14 -0
module_exit() macro is used to define which function is to be called at module removal time.\
The function specified by the module_exit() macro is declared static because it is not meant to be visible outside the file.
—————————-
revision 1.1
date: 2014/02/27 18:55:42;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Character Driver, Device Drivers | Leave a comment

Module code to show how to use container_of() macro inside driver’s open function and storing the return value of container_of() inside filep->private_data.

RCS file: openf.c,v
Working file: openf.c
head: 1.6
branch:
locks: strict
root: 1.6
access list:
symbolic names:
keyword substitution: kv
total revisions: 6;    selected revisions: 6
description:
The functionality of chardev_open() is implemented here inside this file.Whenever the application calls the open function,this is always the first operation performed on the device file.
—————————-
revision 1.6    locked by: root;
date: 2014/03/01 08:45:54;  author: root;  state: Exp;  lines: +5 -1
Printing the address stored inside the lsculldev to check whether it matches with the filep->private data address printed inside the chardev_release() function.
—————————-
revision 1.5
date: 2014/03/01 08:33:40;  author: root;  state: Exp;  lines: +1 -0
Once the Sculldev structure is found by the container_of() macro,a pointer to the scull is stored in the private_data field of the file structure for easier access    .
—————————-
revision 1.4
date: 2014/03/01 08:25:52;  author: root;  state: Exp;  lines: +11 -4
A local variable of type struct Sculldev is declared.
Used container_of() inside the open function.This macro has 3 arguments:
1.A pointer to a field named container_field.
2.This container field within a structure of type container_type,and
3.ccontainer field.
On success it returns a pointer to the containing structure.
—————————-
revision 1.3
date: 2014/02/28 18:51:08;  author: root;  state: Exp;  lines: +2 -0
Included the prototype of chardev_open() using extern.
—————————-
revision 1.2
date: 2014/02/28 18:42:56;  author: root;  state: Exp;  lines: +15 -0
Two printk statements are used to test that whether the open function is actually begin and ended.\
—————————-
revision 1.1
date: 2014/02/28 18:33:28;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: cleanup.c,v
Working file: cleanup.c
head: 1.6
branch:
locks: strict
root: 1.6
access list:
symbolic names:
keyword substitution: kv
total revisions: 6;    selected revisions: 6
description:
File that contains the cleanup function which returns all the resources back to the system.
—————————-
revision 1.6    locked by: root;
date: 2014/02/28 15:35:01;  author: root;  state: Exp;  lines: +1 -0
kfree() function is used for freeing the memory.
—————————-
revision 1.5
date: 2014/02/27 20:15:39;  author: root;  state: Exp;  lines: +3 -1
A variable of type int representing the number of devices is included here using extern.
—————————-
revision 1.4
date: 2014/02/27 19:36:03;  author: root;  state: Exp;  lines: +1 -0
A variable dev of type dev_t storing the device number is included here using extern.
—————————-
revision 1.3
date: 2014/02/27 19:33:49;  author: root;  state: Exp;  lines: +3 -1
Called unregister_chrdev_region() which is having 2 arguments: device number and the total number of device numbers to unregister.
—————————-
revision 1.2
date: 2014/02/27 18:58:02;  author: root;  state: Exp;  lines: +14 -0
module_exit() macro is used to define which function is to be called at module removal time.\
The function specified by the module_exit() macro is declared static because it is not meant to be visible outside the file.
—————————-
revision 1.1
date: 2014/02/27 18:55:42;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: closef.c,v
Working file: closef.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
chardev_release() function live here.
—————————-
revision 1.3    locked by: root;
date: 2014/03/01 08:42:45;  author: root;  state: Exp;  lines: +5 -1
Making a check by printing the address stored inside the filep->private_data matches with the lsculldev value returned by the container_of() macro.
—————————-
revision 1.2
date: 2014/02/28 20:37:55;  author: root;  state: Exp;  lines: +2 -2
chardev_release() function is called when the application calls close() system call.
Two printk statements are used as debug statements to find out whether this function is called or not.
—————————-
revision 1.1
date: 2014/02/28 20:37:08;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: header.h,v
Working file: header.h
head: 1.16
branch:
locks: strict
root: 1.16
access list:
symbolic names:
keyword substitution: kv
total revisions: 16;    selected revisions: 16
description:
Base header file that includes the definitions of all the macros,structures and contains the necessary header files required by the module code.
—————————-
revision 1.16    locked by: root;
date: 2014/02/28 17:13:48;  author: root;  state: Exp;  lines: +2 -0
Header file:<linux/types.h> is added to support dev_t type.
—————————-
revision 1.15
date: 2014/02/28 16:58:15;  author: root;  state: Exp;  lines: +6 -0
Two macros are defined called MAJOR_NO and MINOR_NO.
—————————-
revision 1.14
date: 2014/02/28 15:44:56;  author: root;  state: Exp;  lines: +2 -2
The macro DEVICE_NAME is changed to DRIVER_NAME and the header file:<string.h> is removed.
—————————-
revision 1.13
date: 2014/02/28 15:41:31;  author: root;  state: Exp;  lines: +1 -1
Header file:<linux/cdev.h> is added to support a cdev structure.The cdev structure is used to register the driver with the kernel.
—————————-
revision 1.12
date: 2014/02/28 15:33:59;  author: root;  state: Exp;  lines: +1 -0
Header file:<string.h> is added to support memset() function.
—————————-
revision 1.11
date: 2014/02/28 15:18:15;  author: root;  state: Exp;  lines: +16 -0
Four macros are defined namely:DEVICE_SIZE , DATA_SIZE , QUANTUM and QSET.
These macros are used to initialize the fields inside the Scull_Dev structure.
—————————-
revision 1.10
date: 2014/02/28 15:10:35;  author: root;  state: Exp;  lines: +16 -0
Two structures are defined of type Sculldev and Scullqset.Sculldev is a structure that is used to hold device information.Scullqset is a structure that holds a pointer to the qset array and another pointer to a structure of Scullqset type.
—————————-
revision 1.9
date: 2014/02/27 21:07:42;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/slab.h> is added to support kmalloc() and kfree() functions.
—————————-
revision 1.8
date: 2014/02/27 20:02:53;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/moduleparam.h> is added to support the module_param() macro.With the help of this macro parameters can be passed to a module while loading it.
—————————-
revision 1.7
date: 2014/02/27 19:28:38;  author: root;  state: Exp;  lines: +4 -0
A macro called DEVICE_NAME is defined using #define.
—————————-
revision 1.6
date: 2014/02/27 19:20:01;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/fs.h> is added to the base header file to support various functions like alloc_chrdev_region(),unregister_chrdev_region(),etc.
—————————-
revision 1.5
date: 2014/02/27 18:44:36;  author: root;  state: Exp;  lines: +4 -0
A macro called DEBUG is defined using #define.
—————————-
revision 1.4
date: 2014/02/27 18:41:13;  author: root;  state: Exp;  lines: +2 -0
A special macro called MODULE_LICENSE is used to tell the kernel that the module bears a free license without such a decleration the kernel complains.
—————————-
revision 1.3
date: 2014/02/27 18:38:11;  author: root;  state: Exp;  lines: +1 -1
Header file:<linux/module.h> is added to the base header file to provide support for a great many number of macros like:MODULE_LICENSE , MODULE_AUTHOR,etc.
—————————-
revision 1.2
date: 2014/02/27 18:36:07;  author: root;  state: Exp;  lines: +2 -0
Header file:<linux/init.h> is added to the base header file to provide support for module_init() and module_exit() macros.
—————————-
revision 1.1
date: 2014/02/27 18:35:18;  author: root;  state: Exp;
Initial revision
=============================================================================

 

Posted in Character Driver, Device Drivers | Leave a comment

Vim editor

If any one of you want to get auto indenting while writing code in vim editor and if you are fed up of giving command again and again in every page go to

/etc

and than open

file named vimrc using vim editor by command

vim vimrc

shown in images file before change and after change is shown below.

Posted in Uncategorized | Leave a comment

module code to show how to perform an open and release operation, when an application issues open() and close() system call.

RCS file: header.h,v
Working file: header.h
head: 1.16
branch:
locks: strict
root: 1.16
access list:
symbolic names:
keyword substitution: kv
total revisions: 16;    selected revisions: 16
description:
Base header file that includes the definitions of all the macros,structures and contains the necessary header files required by the module code.
—————————-
revision 1.16    locked by: root;
date: 2014/02/28 17:13:48;  author: root;  state: Exp;  lines: +2 -0
Header file:<linux/types.h> is added to support dev_t type.
—————————-
revision 1.15
date: 2014/02/28 16:58:15;  author: root;  state: Exp;  lines: +6 -0
Two macros are defined called MAJOR_NO and MINOR_NO.
—————————-
revision 1.14
date: 2014/02/28 15:44:56;  author: root;  state: Exp;  lines: +2 -2
The macro DEVICE_NAME is changed to DRIVER_NAME and the header file:<string.h> is removed.
—————————-
revision 1.13
date: 2014/02/28 15:41:31;  author: root;  state: Exp;  lines: +1 -1
Header file:<linux/cdev.h> is added to support a cdev structure.The cdev structure is used to register the driver with the kernel.
—————————-
revision 1.12
date: 2014/02/28 15:33:59;  author: root;  state: Exp;  lines: +1 -0
Header file:<string.h> is added to support memset() function.
—————————-
revision 1.11
date: 2014/02/28 15:18:15;  author: root;  state: Exp;  lines: +16 -0
Four macros are defined namely:DEVICE_SIZE , DATA_SIZE , QUANTUM and QSET.
These macros are used to initialize the fields inside the Scull_Dev structure.
—————————-
revision 1.10
date: 2014/02/28 15:10:35;  author: root;  state: Exp;  lines: +16 -0
Two structures are defined of type Sculldev and Scullqset.Sculldev is a structure that is used to hold device information.Scullqset is a structure that holds a pointer to the qset array and another pointer to a structure of Scullqset type.
—————————-
revision 1.9
date: 2014/02/27 21:07:42;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/slab.h> is added to support kmalloc() and kfree() functions.
—————————-
revision 1.8
date: 2014/02/27 20:02:53;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/moduleparam.h> is added to support the module_param() macro.With the help of this macro parameters can be passed to a module while loading it.
—————————-
revision 1.7
date: 2014/02/27 19:28:38;  author: root;  state: Exp;  lines: +4 -0
A macro called DEVICE_NAME is defined using #define.
—————————-
revision 1.6
date: 2014/02/27 19:20:01;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/fs.h> is added to the base header file to support various functions like alloc_chrdev_region(),unregister_chrdev_region(),etc.
—————————-
revision 1.5
date: 2014/02/27 18:44:36;  author: root;  state: Exp;  lines: +4 -0
A macro called DEBUG is defined using #define.
—————————-
revision 1.4
date: 2014/02/27 18:41:13;  author: root;  state: Exp;  lines: +2 -0
A special macro called MODULE_LICENSE is used to tell the kernel that the module bears a free license without such a decleration the kernel complains.
—————————-
revision 1.3
date: 2014/02/27 18:38:11;  author: root;  state: Exp;  lines: +1 -1
Header file:<linux/module.h> is added to the base header file to provide support for a great many number of macros like:MODULE_LICENSE , MODULE_AUTHOR,etc.
—————————-
revision 1.2
date: 2014/02/27 18:36:07;  author: root;  state: Exp;  lines: +2 -0
Header file:<linux/init.h> is added to the base header file to provide support for module_init() and module_exit() macros.
—————————-
revision 1.1
date: 2014/02/27 18:35:18;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: initial.c,v
Working file: initial.c
head: 1.13
branch:
locks: strict
root: 1.13
access list:
symbolic names:
keyword substitution: kv
total revisions: 13;    selected revisions: 13
description:
File containing the module’s initialization function that is called at module insertion time.
—————————-
revision 1.13    locked by: root;
date: 2014/02/28 18:56:45;  author: root;  state: Exp;  lines: +1 -1
Fixed the warning by giving void as an argument inside the initialize_parameters() function.
Compilation is successfull.
Checking the functionality by calling application……….
—————————-
revision 1.12
date: 2014/02/28 17:59:59;  author: root;  state: Exp;  lines: +1 -0
Header file:”file_opr.h” is added to include the file_operations structure.The file_operations structure is used to access the driver’s functions.
—————————-
revision 1.11
date: 2014/02/28 17:49:26;  author: root;  state: Exp;  lines: +15 -4
After a device number range has been obtained,the device needs to be activated by adding it to the character device database.This requires initializing an instance of cdev_init() followed by a call to cdev_add().cdev_add() tells te kernel about the cdev data structure.
—————————-
revision 1.10
date: 2014/02/28 17:16:31;  author: root;  state: Exp;  lines: +16 -0
Both the major and minor numbers are initialized to 0 inside the initialize_parameters() function.Macros like MAJOR() and MINOR() are used to extract the major and minor number from dev type variable.Another macro called MKDEV is used to create the device number.
Checking……
—————————-
revision 1.9
date: 2014/02/28 16:50:22;  author: root;  state: Exp;  lines: +25 -0
From the initialization function,another function is called to initialize the parameters such as device size, quantum_size ,qset_size and data_size.

Status:The parameters are initialized successfully.
Now before the kernel calls the device’s operations,a cdev structure must be initialized with cdev_init() and the kernel is being told about the initialization with cdev_add().Implementing this task….
—————————-
revision 1.8
date: 2014/02/28 15:46:09;  author: root;  state: Exp;  lines: +1 -1
Inside the alloc_chrdev_region(),the fourth argument is changed from DEVICE_NAME to DRIVER_NAME.
—————————-
revision 1.7
date: 2014/02/28 15:32:31;  author: root;  state: Exp;  lines: +1 -0
memset() is used to fill the memory allocated using kmalloc() function with ”.
—————————-
revision 1.6
date: 2014/02/28 15:26:38;  author: root;  state: Exp;  lines: +12 -1
kmalloc() function is used to allocate memory.kmalloc() function takes two arguments:
1.size ,and
2.set of flags.
On success,kmalloc returns a pointer to the allocated memory otherwise it returns NULL.
In the flag field,GFP_KERNEL is used.
—————————-
revision 1.5
date: 2014/02/27 20:12:29;  author: root;  state: Exp;  lines: +7 -1
module_param() macro is used.With the help of this macro parameters can be passed to the module while loading it,when using “insmod”.
module_param() macro takes three arguments:
1.The name of the variable,
2.The type of the variable,
3.Permissions.
—————————-
revision 1.4
date: 2014/02/27 19:58:09;  author: root;  state: Exp;  lines: +1 -1
alloc_chrdev_region() function is used to allocate dynamically a major number.On success,the first parameter of this function stores the first device number.
—————————-
revision 1.3
date: 2014/02/27 19:31:39;  author: root;  state: Exp;  lines: +11 -0
Header file: “decleration.h” is added to include all the variable declerations.
—————————-
revision 1.2
date: 2014/02/27 18:50:37;  author: root;  state: Exp;  lines: +7 -0
module_init() macro is used to define which function is called during module’s insertion time.
__init token hints to the kernel that the function is used only at the initialization time.
The function specified by the module_init() macro is declared static because it is not meant to be visible outside the file.
—————————-
revision 1.1
date: 2014/02/27 18:49:06;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: cleanup.c,v
Working file: cleanup.c
head: 1.6
branch:
locks: strict
root: 1.6
access list:
symbolic names:
keyword substitution: kv
total revisions: 6;    selected revisions: 6
description:
File that contains the cleanup function which returns all the resources back to the system.
—————————-
revision 1.6    locked by: root;
date: 2014/02/28 15:35:01;  author: root;  state: Exp;  lines: +1 -0
kfree() function is used for freeing the memory.
—————————-
revision 1.5
date: 2014/02/27 20:15:39;  author: root;  state: Exp;  lines: +3 -1
A variable of type int representing the number of devices is included here using extern.
—————————-
revision 1.4
date: 2014/02/27 19:36:03;  author: root;  state: Exp;  lines: +1 -0
A variable dev of type dev_t storing the device number is included here using extern.
—————————-
revision 1.3
date: 2014/02/27 19:33:49;  author: root;  state: Exp;  lines: +3 -1
Called unregister_chrdev_region() which is having 2 arguments: device number and the total number of device numbers to unregister.
—————————-
revision 1.2
date: 2014/02/27 18:58:02;  author: root;  state: Exp;  lines: +14 -0
module_exit() macro is used to define which function is to be called at module removal time.\
The function specified by the module_exit() macro is declared static because it is not meant to be visible outside the file.
—————————-
revision 1.1
date: 2014/02/27 18:55:42;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: closef.c,v
Working file: closef.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
chardev_release() function live here.
—————————-
revision 1.2    locked by: root;
date: 2014/02/28 20:37:55;  author: root;  state: Exp;  lines: +2 -2
chardev_release() function is called when the application calls close() system call.
Two printk statements are used as debug statements to find out whether this function is called or not.
—————————-
revision 1.1
date: 2014/02/28 20:37:08;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: decleration.h,v
Working file: decleration.h
head: 1.8
branch:
locks: strict
root: 1.8
access list:
symbolic names:
keyword substitution: kv
total revisions: 8;    selected revisions: 8
description:
All the variable declerations are done inside this header file.
—————————-
revision 1.8    locked by: root;
date: 2014/02/28 20:28:24;  author: root;  state: Exp;  lines: +1 -0
Gave prototype for chardev_release() function.
—————————-
revision 1.7
date: 2014/02/28 18:48:17;  author: root;  state: Exp;  lines: +2 -0
Gave prototype of chardev_open() function.
—————————-
revision 1.6
date: 2014/02/28 17:05:32;  author: root;  state: Exp;  lines: +1 -0
A variable of type dev_t is declared that is used to store the updated device number obtained from mkdev.
—————————-
revision 1.5
date: 2014/02/28 16:59:40;  author: root;  state: Exp;  lines: +3 -0
Two variables are declared inside this file that will hold the information about major and minor numbers.
—————————-
revision 1.4
date: 2014/02/28 16:39:07;  author: root;  state: Exp;  lines: +4 -0
Variables quantum_size,qset_size,data_size and device_size are declared that will get initialized by the macros defined in header.h.
—————————-
revision 1.3
date: 2014/02/28 15:30:46;  author: root;  state: Exp;  lines: +1 -0
A variable of type Sculldev is declared in this file.
—————————-
revision 1.2
date: 2014/02/27 20:06:26;  author: root;  state: Exp;  lines: +1 -0
A variable of type int is declared representing the number of devices.
—————————-
revision 1.1
date: 2014/02/27 19:30:54;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: openf.c,v
Working file: openf.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
The functionality of chardev_open() is implemented here inside this file.Whenever the application calls the open function,this is always the first operation performed on the device file.
—————————-
revision 1.3    locked by: root;
date: 2014/02/28 18:51:08;  author: root;  state: Exp;  lines: +2 -0
Included the prototype of chardev_open() using extern.
—————————-
revision 1.2
date: 2014/02/28 18:42:56;  author: root;  state: Exp;  lines: +15 -0
Two printk statements are used to test that whether the open function is actually begin and ended.
—————————-
revision 1.1
date: 2014/02/28 18:33:28;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Character Driver, Device Drivers | Leave a comment