EmbLogic's Blog

parmeet singh is funny lad

Posted in Uncategorized | Leave a comment

emblogic

we have started with Project 1

Posted in Uncategorized | Leave a comment

Hello

we started our project mdc.c

Posted in Uncategorized | Leave a comment

proj:1

starting project1 for data compression.

Posted in Uncategorized | Leave a comment

DEVICE DRIVER

successfully done write and read for multiple qset and multiple quantum and for single qset here is rcs file

amit.c
head 1.8;
access;
symbols;
locks
amitdalal:1.8; strict;
comment @ * @;

1.8
date 2013.07.11.17.37.19; author amitdalal; state Exp;
branches;
next 1.7;

1.7
date 2013.07.11.06.05.24; author amitdalal; state Exp;
branches;
next 1.6;

1.6
date 2013.07.11.05.37.03; author amitdalal; state Exp;
branches;
next 1.5;

1.5
date 2013.07.11.05.18.10; author amitdalal; state Exp;
branches;
next 1.4;

1.4
date 2013.07.11.00.41.53; author amitdalal; state Exp;
branches;
next 1.3;

1.3
date 2013.07.11.00.19.58; author amitdalal; state Exp;
branches;
next 1.2;

1.2
date 2013.07.11.00.00.36; author amitdalal; state Exp;
branches;
next 1.1;

1.1
date 2013.07.10.21.22.34; author amitdalal; state Exp;
branches;
next ;

desc
@added function of copy from user
printk the no of byte writen successfully for one quantum
@

1.8
log
@modified code for write to get required no of qset
add lnoq variable
@
text
@#include”header.h”
int create_qset(struct Scull_qset *qset,int nosqs) //creating qset and allocating memory to qset(64 bytes)
{
int lv;
printk(KERN_ALERT”BEGIN:SUCCESSFULLY : %s\n”,__func__);

if(!qset)
printk(KERN_ERR “error in creatin qset\n”);
for(lv=0;lvdata=kmalloc(sizeof(int *)*qset_size,GFP_KERNEL); //allocating memory to the *qset_size
qset=qset->next;
}
printk(KERN_ALERT”END:SUCCESSFULLY : %s\n”,__func__);
return 0;
}

int create_quantum(struct Scull_qset *qset,int noq) //creating quantum and locating memory to quantum(8 quantum per qset)
{
int i,count=0,lnoq=0;

printk(KERN_ALERT”BEGIN:SUCCESSFULLY : %s\n”,__func__);
if(!qset)
printk(KERN_ERR “error in creating quantum\n”);

while(qset!=NULL)
{
if(noq>quantum_size)
lnoq=quantum_size;
else
lnoq=noq;
for(i=0;idata[i]=kmalloc(quantum_size,GFP_KERNEL); //allocate memory to quantum
printk(KERN_ALERT”quantum number=%p”,&qset->data[i]);
count++;
}

noq=noq-quantum_size;
qset=qset->next;
}
printk(KERN_ALERT”quantum number=%d”,count);
printk(KERN_ALERT”END:SUCCESSFULLY : %s\n”,__func__);
return 0;
}

struct Scull_qset* create_scull_qset(int fnosqs) //creating scull_qset and allocating memory to it
{

struct Scull_qset *pdev,*start; //taking two pointer
int flag=0,i=0;
start=NULL;
printk(KERN_ALERT”BEGIN:SUCCESSFULLY : %s\n”,__func__);
for(i=0;inext=(struct Scull_qset *)(kmalloc(sizeof(struct Scull_qset),GFP_KERNEL)); //allocating memory to the next scull_qset
pdev=pdev->next;
}
}
printk(KERN_ALERT”END: SUCCESSFULLY: %s\n”,__func__);
return start;
}

ssize_t scull_read(struct file *filep,char __user *buff,size_t count, loff_t *offp)
{
struct Sculldev *pdev;
struct Scull_qset *qset;
int noq,nosqs,i,ret=0,loop=0;
int nobpq,noctr,nocsr;
noq=nosqs=nobpq=noctr=0;
nobpq=quantum_size;
nocsr=0;
noctr=count;

printk(KERN_ALERT”read open SUCCESSFULLY : %s\n”,__func__);
pdev=filep->private_data; //fetch the device
printk(KERN_ALERT”write open SUCCESSFULLY: %s\n”,__func__);
if(!pdev)
{
printk(“no private data”);
}
nosqs=count/(quantum_size*qset_size); //finding no. of scull_qset required
if(count%(quantum_size*qset_size))
nosqs++;
if(!pdev->scull_qset)
{
printk(“no scull_qset found\n”);
}
noq=count/quantum_size;
if(count%quantum_size);
noq++;
qset=pdev->scull_qset;

while(nosqs)
{
if(noq>quantum_size)
{
loop=quantum_size;
}
else
{
loop=noq;
}
for(i=0;iquantum_size) //if noctw>quantum_size ,nobpq is equql to the quantum_size that is 8
nobpq=quantum_size;
else
nobpq=noctr; //else nobpq is equal to the noctw

ret=copy_to_user(buff+nocsr,qset->data[i],nobpq); //copy data from user space
nocsr=nocsr+(nobpq-ret);
noctr=noctr-(nobpq-ret);
printk(KERN_ALERT”no. of byte successfully read=%d\n”,nocsr);
}
nosqs–;
qset=qset->next;
noq=noq-quantum_size;
}
printk(KERN_ALERT”no.of qset=%d\n”,loop);
printk(KERN_ALERT”END:read close SUCCESSFULLY: %s\n”,__func__);
return count-ret;

}

ssize_t scull_write(struct file *filep,const char __user *buff,size_t count, loff_t *offp)
{

struct Sculldev *pdev;
struct Scull_qset *qset;
int noq,nosqs,i,ret=0,loop=0;
int nobpq,noctw,nocsw;
noq=nosqs=nobpq=noctw=nocsw=0;

pdev=filep->private_data; //fetch the device
printk(KERN_ALERT”write open SUCCESSFULLY: %s\n”,__func__);
if(!pdev)
{
printk(“no private data”);
}
nosqs=count/(quantum_size*qset_size); //finding no. of scull_qset required
if(count % (quantum_size*qset_size))
nosqs++;
pdev->scull_qset=create_scull_qset(nosqs); //creating scull_qset(Sculldev *pdev pointing towards *scull_qset)
if(!pdev->scull_qset)
{
printk(“no scull_qset found\n”);
}
noq=count/quantum_size;
if(count%quantum_size)
noq++;

qset=pdev->scull_qset;
create_qset(qset,nosqs); //creating _qset
create_quantum(qset,noq); //creating _quantum
nobpq=quantum_size;
nocsw=0;
noctw=count;

while(nosqs)
{
if(noq>quantum_size)
{
loop=quantum_size;
}
else
{
loop=noq;
}
for(i=0;iquantum_size) //if noctw>quantum_size ,nobpq is equql to the quantum_size that is 8
nobpq=quantum_size;
else
nobpq=noctw; //else nobpq is equal to the noctw

ret=copy_from_user(qset->data[i],buff+nocsw,nobpq); //copy data from user space
printk(KERN_ALERT”quantum=%d->write=%s\n”,i,(char *)qset->data[i]); //data write in quantum
nocsw=nocsw+(nobpq-ret);
noctw=noctw-(nobpq-ret);
printk(KERN_ALERT”no. of byte successfully write=%d\n”,nocsw);
printk(KERN_ALERT”no. of byte not write=%d\n”,ret);
}
nosqs–;
qset=qset->next;
noq=noq-quantum_size;
}
printk(KERN_ALERT”no.of qset=%d\n”,loop);

printk(KERN_ALERT”write close SUCCESSFULLY : %s\n”,__func__);
return count-ret;
}

int scull_open(struct inode *inodep, struct file *filep)
{

struct Sculldev* pdev;
printk(KERN_ALERT”OPEN SUCCESSFULLY :%s\n”,__func__);
pdev=(struct Sculldev *)container_of(inodep->i_cdev, struct Sculldev, var_dev);// map the memeory allocated to Sculldev to VFS which is going to return pointer
filep->private_data =pdev; //all information stored in pdev pointer conatining address

if((filep->f_flags && O_ACCMODE) == O_WRONLY)
{

printk(KERN_ALERT”FILE OPEN\n”);
scull_trim(pdev);
}

printk(KERN_ALERT”close SUCCESSFULLY: %s\n”,__func__);
return 0;
}

int scull_trim(struct Sculldev *fsculldev)
{
printk(KERN_ALERT”BEGIN :%s\n”,__func__);
if(!fsculldev)
{
printk(KERN_ERR”no scull found\n”);
}
if(!fsculldev->scull_qset)
{
printk(KERN_INFO”no scullqset found\n”);
}
printk(KERN_ALERT”END: %s\n”,__func__);
return 0;
}

int scull_release(struct inode *inodep, struct file *filep)
{
printk(KERN_ALERT”OPEN SUCCESSFULLY release: %s\n”,__func__);
printk(KERN_ALERT”close SUCCESSFULLY release: %s\n”,__func__);
return 0;
}
void sculldev_initialisation(void)
{
int a,lv;
for(lv=0;lv<nod;lv++)
{
dev=MKDEV(majorno,lv); //lv=newminorno+1(allocating value of minorno and majorno to your dev)
printk("sculldev initialisation start :%s\n",__func__);
cdev_init(&sculldev[lv].var_dev, &fops);
sculldev[lv].var_dev.dev = dev; //storing that value of dev into dev which is defined in cdev.. through sculldev
sculldev[lv].var_dev.owner=THIS_MODULE;
sculldev[lv].var_dev.ops=&fops;
sculldev[lv].var_dev.count=nod;
sculldev[lv].open_count=0;

a=cdev_add(&sculldev[lv].var_dev,sculldev[lv].var_dev.dev, nod);

sculldev[lv].quantum_size=quantum_size;
sculldev[lv].device_size=device_size;
sculldev[lv].data_size=data_size;
sculldev[lv].qset_size=qset_size;

majorno=MAJOR(dev);
minorno=MINOR(dev);
printk("value of a is—–%d\n",a);
printk("majorno assigned is—–%d\n",majorno);
printk("minorno assigned is—–%d\n",minorno);
}
printk("quantum size—–%d\n",quantum_size);
printk("device size—–%d\n",device_size);
printk("data size—–%d\n",data_size);
printk("qset size—–%d\n",qset_size);
printk("scull initiallisation complete :%s\n",__func__);
}

static int entry_init(void)
{
printk(KERN_ALERT "BEGIN: %s\n",__func__);
if(!majorno) //because majorno value is 0
{
ret=alloc_chrdev_region(&dev,minorno,nod,DRIVER_NAME); //when we are registering one device
if(ret==0)
{
printk("allocation is ok\n" );
}
}
else
{
register_chrdev_region(dev,nod,DRIVER_NAME); //when we are registering more than 1 device
printk("\nIt is in else region\n");
}
minorno = MINOR(dev);
majorno = MAJOR(dev);
printk(KERN_ALERT "END: %s\n",__func__);

memory();
sculldev_initialisation();
return 0;
}

void memory(void)

{
printk(KERN_ALERT "BEGIN: %s\n",__func__);
sculldev=kmalloc(sizeof(struct Sculldev)*nod , GFP_KERNEL); //allocate memory to Sculldev
memset(sculldev,'',nod *sizeof(struct Sculldev));

if(sculldev==0)
{
printk("memory allocation failed");
}
else
{
printk("memory allocation is done\n");
}
printk(KERN_ALERT "END: %s\n",__func__);

}

static void cleanup(void)
{
int lv;
printk(KERN_ALERT "BEGIN: %s\n",__func__);
printk(KERN_ALERT"\ngood bye\n");
for(lv=0;lv<nod;lv++)
{
//dev=MKDEV(majorno,lv);
cdev_del(&sculldev[lv].var_dev);
unregister_chrdev_region(sculldev[lv].var_dev.dev ,nod);
//unregister_chrdev_region(dev,nod);
}
kfree(sculldev); //free allocated memory to Sculldev
printk(KERN_ALERT"END:%s\n",__func__);
}
module_init(entry_init);
module_exit(cleanup);

@

1.7
log
@add loop variable in loop for reading
remove some bug in reading loop
@
text
@d2 1
a2 1
int create_qset(struct scull_qset *qset,int nosps) //creating qset and allocating memory to qset(64 bytes)
d9 1
a9 1
for(lv=0;lv<qset;lv++)
d18 1
a18 1
int create_quantum(struct scull_qset *qset,int noq) //creating quantum and locating memory to quantum(8 quantum per qset)
d20 1
a20 1
int i,count;
d25 8
a32 1
for(i=0;inext=(struct scull_qset *)(kmalloc(sizeof(struct scull_qset),GFP_KERNEL)); //allocating memory to the next scull_qset
d66 1
a72 1
printk(KERN_ALERT”read open SUCCESSFULLY : %s\n”,__func__);
d74 4
a77 4
struct scull_qset *qset;
int noq,nosqs,i,ret,loop;
int nobpq,noctw,nocsw;
noq=nosqs=nobpq=noctw=nocsw=0;
d79 2
a80 2
nocsw=0;
noctw=count;
d82 1
d90 1
a90 1
if(count%(quantum_size*qset_size));
a91 1
pdev->scull_qset=create_scull_qset(nosqs); //creating scull_qset(Sculldev *pdev pointing towards *scull_qset)
d100 1
a100 3
create_qset(qset,nosqs); //creating _qset
create_quantum(qset,noq); //creating _quantum

d111 1
a111 1
for(i=0;iquantum_size) //if noctw>quantum_size ,nobpq is equql to the quantum_size that is 8
d116 1
a116 1
nobpq=noctw; //else nobpq is equal to the noctw
d118 4
a121 5
ret=copy_to_user(buff+nocsw,qset->data[i],nobpq); //copy data from user space
printk(KERN_ALERT”quantum=%d->read=%s\n”,i,qset->data[i]); //data write in quantum
nocsw=nocsw+(nobpq-ret);
noctw=noctw-(nobpq-ret);
printk(KERN_ALERT”no. of byte successfully read=%d\n”,nocsw);
d128 3
a130 2
printk(KERN_ALERT”read close SUCCESSFULLY: %s\n”,__func__);
return count-ret;
d134 1
d139 2
a140 2
struct scull_qset *qset;
int noq,nosqs,i,ret,loop;
d151 1
a151 1
if(count%(quantum_size*qset_size));
d159 1
a159 1
if(count%quantum_size);
d161 1
d191 1
d328 1
a328 1
static void exit(void)
d344 1
a344 1
module_exit(exit);
@

1.6
log
@remove some bug from write function
added loop variable to specify no of quantum in 2nd qset
@
text
@a1 1

@

1.5
log
@creating read function
use copy to user function
modifing the copy to user function
@
text
@a130 3
nobpq=quantum_size;
nocsw=0;
noctw=count;
d152 3
d166 1
a166 1
for(i=0;idata=kmalloc(sizeof(int *)*qset_size,GFP_KERNEL); //allocating memory to the *qset_size
qset=qset->next;
d19 1
a19 1
int create_quantum(struct scull_qset *qset,int noq)
d29 1
a29 1
printk(KERN_ALERT”quantum number=%u”,&qset->data[i]);
d37 1
a37 1
struct scull_qset* create_scull_qset(int fnosqs)
d60 58
d119 1
a119 1
return 0;
d122 1
d131 4
d156 1
a156 5
printk(KERN_ALERT”write SUCCESSFULLY : %d\n”,count);
nobpq=quantum_size;
nocsw=0;
noctw=count;
while(nosqs)
d166 1
a166 1
for(i=0;i)
d100 1
a100 1

d104 2
a105 2

}*/
d117 5
a122 1
printk(KERN_ALERT”no. of byte successfully write=%d\n”,nocsw);
@

1.1
log
@Initial revision
@
text
@d93 4
a96 1
for(i=0;idata[i],buff,count); //copy data from user space
printk(KERN_ALERT”write in quantum=%s\n”,(char *)qset->data[i]); //data write in quantum
d118 1
d121 1
a121 1
return count;
@

header.h

head 1.2;
access;
symbols;
locks
amitdalal:1.2; strict;
comment @ * @;

1.2
date 2013.07.11.17.39.26; author amitdalal; state Exp;
branches;
next 1.1;

1.1
date 2013.07.10.21.25.25; author amitdalal; state Exp;
branches;
next ;

desc
@added asm header .h for copy from user
@

1.2
log
@remove init and cleanup prototype
@
text
@#include //need for registring( for everything)
#include
#include //needed for KERN_ALERT
#include //needed for kmalloc and flag of kmalloc
#include //needed cdev structure
#include
#include
#include
MODULE_LICENSE(“GPL”);
MODULE_AUTHOR(“AMIT DALAL”);
#define DRIVER_NAME “DALAL DRIVER”
#ifndef DEBUG
#define DEBUG
#endif
#define QUANTUM_SIZE 8
#define DATA_SIZE 0
#define DEVICE_SIZE 4096
#define QSET_SIZE 8

#ifndef MAJORNO
#define MAJORNO 0
#endif

#ifndef MINORNO
#define MINORNO 0
#endif

#ifndef NOD
#define NOD 10
#endif
dev_t dev;
int ret;
int minorno=MINORNO;
int majorno=MAJORNO;
int nod=NOD;
int quantum_size=QUANTUM_SIZE;
int qset_size=QSET_SIZE;
int data_size=DATA_SIZE;
int device_size=DEVICE_SIZE;

int scull_release(struct inode *, struct file *);
int scull_open(struct inode *, struct file *);
void sculldev_initialisation(void);
void memory(void);
ssize_t scull_read(struct file *,char __user *,size_t , loff_t *);
ssize_t scull_write(struct file *,const char __user *,size_t , loff_t *);

struct Sculldev //user defined structure Sculldev
{
struct Scull_qset *scull_qset; //pointing to 1st quqntum set
int quantum_size; //current quantum size
int qset_size; //current array size
int data_size; //amount of data stored here
int device_size;
int open_count;
struct cdev var_dev; //cdev structure defined in cdev header file
}*sculldev; //used for pointing Sculldev

int scull_trim(struct Sculldev *);
struct Scull_qset
{
struct Scull_qset *next;
void **data;
};
struct file_operations fops=
{
open:scull_open,
read:scull_read,
write:scull_write,
release:scull_release

};
struct Scull_qset* create_scull_qset(int);

@

1.1
log
@Initial revision
@
text
@d39 1
a39 1
int device_size=DEVICE_SIZE;
d50 1
a50 1
struct scull_qset *scull_qset; //pointing to 1st quqntum set
d60 1
a60 1
struct scull_qset
d62 1
a62 1
struct scull_qset *next;
d73 1
a73 1
struct scull_qset* create_scull_qset(int);
@

app.c
head 1.2;
access;
symbols;
locks
amitdalal:1.2; strict;
comment @ * @;

1.2
date 2013.07.11.00.32.38; author amitdalal; state Exp;
branches;
next 1.1;

1.1
date 2013.07.11.00.04.48; author amitdalal; state Exp;
branches;
next ;

desc
@extended the message in buff
@

1.2
log
@extended the message to check whether my multiple qset is working or not for above 64 byte
@
text
@#include
#include
#include
int main(int argc , char *argv[])
{
int fd,count,len;
char buff[]=”AMIT DALAL have great time in emblogic embedded technologies pvt ltd,noida,INDIA”;
if(argc!= 2)
{
perror(“error\n”);
}
else
{
//fd=open(argv[1],O_RDONLY);
fd=open(argv[1],O_WRONLY);
if(fd<0)
{
perror("error\n");
}
len=strlen(buff);
//count=read(fd,buff,len);
count=write(fd,buff,len);

if(count==len)
{
printf("successfully write\n");
}
if(count<len)
{
printf("partially write\n");
}
if(count==-1)
{
printf("some error in writing\n");
}
if(count==0)
{
printf("nothing write\n");
}
printf("no of byte write successfully=%d\n",count);
printf("fd open successfully=%d\n",fd);
printf("length is=%d\n",len);
close(fd);
return 0;
}

}
@

1.1
log
@Initial revision
@
text
@d7 1
a7 1
char buff[]="amit dalal have great time in emblogic pvt ltd,noida";
@

Posted in Uncategorized | Tagged | Leave a comment

Prince Singla : E-30.01.30

RCS file: char_driver.c,v
Working file: char_driver.c
head: 1.6
branch:
locks: strict
emblogic: 1.6
access list:
symbolic names:
keyword substitution: kv
total revisions: 6; selected revisions: 6
description:
register using alloc.
successfullu implement sculldev
sucessfully implement cdev
—————————-
revision 1.6 locked by: emblogic;
date: 2013/07/12 19:04:31; author: emblogic; state: Exp; lines: +57 -11
scull_read working successfully for multiple no of scullqset.
used copy_to_user.
—————————-
revision 1.5
date: 2013/07/12 14:37:34; author: emblogic; state: Exp; lines: +4 -3
written to multiple scullqset.
declared nobws,lcount,lnoq
—————————-
revision 1.4
date: 2013/07/12 14:01:12; author: emblogic; state: Exp; lines: +29 -8
written n no of bytes to scull using copy_from_user.
—————————-
revision 1.3
date: 2013/07/12 12:18:38; author: emblogic; state: Exp; lines: +7 -3
written 8 bytes to scull using copy_from_user.
printed written data into the driver.
—————————-
revision 1.2
date: 2013/07/10 18:01:30; author: emblogic; state: Exp; lines: +319 -9
implemented sucllqset ().
implemented qset(),quantum(),
allocate memory to quantum and qset .
succesfully working .
—————————-
revision 1.1
date: 2013/07/02 10:35:38; author: emblogic; state: Exp;
Initial revision
=============================================================================

Posted in Character Driver | Leave a comment

Kushal Chugh : E-30.01.30

RCS file: lkm.c,v
Working file: lkm.c
head: 1.11
branch:
locks: strict
emblogic: 1.11
access list:
symbolic names:
keyword substitution: kv
total revisions: 11; selected revisions: 11
description:
—————————-
revision 1.11 locked by: emblogic;
date: 2013/07/11 12:37:36; author: emblogic; state: Exp; lines: +1 -1
slight addition in the printk ;ine of the read function.
—————————-
revision 1.10
date: 2013/07/11 12:32:53; author: emblogic; state: Exp; lines: +111 -10
Successfully Implemented he read function.
Able to read the data for muliple quantums.
Implemented reading for multiple qsets as well.
Succesfully done
—————————-
revision 1.9
date: 2013/07/11 08:37:45; author: emblogic; state: Exp; lines: +0 -2
So as Implemented Writing into multiple qsets as well.
Successfully written.
—————————-
revision 1.8
date: 2013/07/11 08:27:07; author: emblogic; state: Exp; lines: +67 -27
Implemented writting in Multiple quantums.
Successfully written.
—————————-
revision 1.7
date: 2013/07/11 06:21:43; author: emblogic; state: Exp; lines: +36 -10
Implemented writting for 1 Quantum.
Successfully.
—————————-
revision 1.6
date: 2013/07/09 12:11:32; author: emblogic; state: Exp; lines: +61 -3
Successfully implemented scullqset,qset & quantum function.
—————————-
revision 1.5
date: 2013/07/09 10:50:17; author: emblogic; state: Exp; lines: +128 -3
working on creat_qset.
created scullqset function
—————————-
revision 1.4
date: 2013/07/08 10:57:52; author: emblogic; state: Exp; lines: +43 -1
scull_read &scull_write function mapped.
—————————-
revision 1.3
date: 2013/07/08 06:31:57; author: emblogic; state: Exp; lines: +20 -1
scull_trim function called inside scull_open function.
—————————-
revision 1.2
date: 2013/07/08 06:20:02; author: emblogic; state: Exp; lines: +8 -5
open and release function implied
—————————-
revision 1.1
date: 2013/07/02 12:56:06; author: emblogic; state: Exp;
Initial revision
=============================================================================

Posted in Character Driver | Tagged | Leave a comment

Avtar Singh E- 30.01.30

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

Posted in Character Driver | Tagged | Leave a comment

30.1.30: JATINDER KUNAR

Implemented the driver fror n number of byte reading and n number of byte writing. Now going to sleep as provjot sir said today …. go to bed on time. good night.
RCS file: lkm.c,v
Working file: lkm.c
head: 1.17
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 17; selected revisions: 17
description:
—————————-
—————————-
revision 1.17
date: 2013/07/11 16:39:20; author: jatinder; state: Exp; lines: +44 -5
Ipmelemented Scull_read ().
Successfully aabled to read n bytes of data by my driver.
the read algo is same a that of in scull_write.
app successfully read and write via node to drive.
—————————-
revision 1.16
date: 2013/07/11 15:25:43; author: jatinder; state: Exp; lines: +49 -2
fial to open scull_read.
—————————-
revision 1.15
date: 2013/07/11 10:12:17; author: jatinder; state: Exp; lines: +44 -16
Implemented the write for multiple scullqset successfully.
counted lnoq for inner loop for according to remaining bytes.
SO that inner loop never run more then 8 bytes ie onlu for 1 scullqset.
for next scullqset i used my own alogrithim.
preserved size in fnobtw , updted fnobtm and fnobsw .
—————————-
revision 1.14
date: 2013/07/11 06:39:26; author: jatinder; state: Exp; lines: +11 -4
Implemented copy_from_user fro n number of quauntum .
for this we made our own algorithm.
/.
—————————-
revision 1.13
date: 2013/07/11 06:03:50; author: jatinder; state: Exp; lines: +64 -14
implemented copy_from_user for 1 quantum .
—————————-
revision 1.12
date: 2013/07/09 10:17:35; author: jatinder; state: Exp; lines: +66 -6
implemented the create_qset for n number of qsets.
—————————-
revision 1.11
date: 2013/07/09 07:34:52; author: jatinder; state: Exp; lines: +25 -11
Implemented create_scullqset() for nosqs .
—————————-
revision 1.10
date: 2013/07/09 07:18:15; author: jatinder; state: Exp; lines: +61 -0
calculated the no of quantum and no of scullqset.
implemented the create_scullqset() for creatinf 1 scullqset.
—————————-
revision 1.9
date: 2013/07/08 08:31:27; author: jatinder; state: Exp; lines: +28 -2
Gave the declartion of scull_read() and scull_write().
and in header mapped the read and write funtion to scull_read and sucll_write .
—————————-
revision 1.8
date: 2013/07/08 07:32:22; author: jatinder; state: Exp; lines: +19 -3
in sucll_trim function we checked for fsculldev and fscullded->sucllqet that is is NULL or have some value.
—————————-
revision 1.7
date: 2013/07/04 06:51:41; author: jatinder; state: Exp; lines: +61 -15
decaled lsculldev in open routine.
used container_of macro.
save the information given by container_of macro in struct inode’s private_data member.
call the scull_trim function
—————————-
revision 1.6

date: 2013/07/03 09:27:59; author: jatinder; state: Exp; lines: +57 -1
gave defination of sucll_open() and scull_realse() .
intialized variable od sculldev for number of nod.
scucessfully opend the file from my driver.
—————————-
revision 1.5
date: 2013/07/03 07:42:02; author: jatinder; state: Exp; lines: +32 -25
used loop scull_setupfunction to add nod number of device
in clenup_func() used nod number of time cdev_del().
and save the major and minor number in tmp.
pssed this tmp in unregister_chrdev_region for unregister the driver
—————————-
revision 1.4
date: 2013/07/03 06:57:12; author: jatinder; state: Exp; lines: +54 -0
declared scull_setup function.
used cdev_init and cdev_add() in this function.
initialized the members of struct cdev.
in cleanup routine used cdev_del() function .
in cleanup routine always do things in the reverse order wrt initialization routine.
—————————-
revision 1.3
date: 2013/07/03 06:02:39; author: jatinder; state: Exp; lines: +13 -0
used kmalloc for number of node.
and used kfree function in cleanup module.
—————————-
revision 1.2
date: 2013/07/03 05:30:46; author: jatinder; state: Exp; lines: +24 -9
used register_chrdev_region function.
call param_module
—————————-
revision 1.1
date: 2013/07/02 19:45:49; author: jatinder; state: Exp;
Initial revision
=============================================================================
105,1 Bot

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

Character Driver

Implemented character driver writing to kernel buffer for any number of bytes . Also implemented reading from kernel buffer for any number of bytes.

Posted in Uncategorized | Leave a comment

Character Driver

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

Posted in Character Driver | Tagged | Leave a comment

Ranjeet Singh

RCS file: header2.h,v
Working file: header2.h
head: 1.9
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 9; selected revisions: 9
description:
This is the header file for loadable kernel module.
—————————-
revision 1.9
date: 2013/07/09 18:01:36; author: root; state: Exp; lines: +1 -0
gave prototype to scull_trim function.
—————————-
revision 1.8
date: 2013/07/04 11:43:22; author: root; state: Exp; lines: +10 -1
declare functions “scull_open” and “scull_release”.
gave two file operations in struct fileoperations.
—————————-
revision 1.7
date: 2013/07/04 07:53:59; author: root; state: Exp; lines: +3 -0
Gave prototype to functions “scull_dev” and “cdevinit”.
—————————-
revision 1.6
date: 2013/07/03 06:53:31; author: root; state: Exp; lines: +1 -0
include linux/moduleparam.h.
—————————-
revision 1.5
date: 2013/07/03 06:35:46; author: root; state: Exp; lines: +20 -0
declare variables in the data structure “struct ScullDev”: qset_size, quantum_size, data size, device_size.
Also define Macros:QSET_SIZE, QUANTUM_SIZE, DATA_SIZE, DEVICE_SIZE and initialize them.
—————————-
revision 1.4
date: 2013/07/02 11:31:50; author: root; state: Exp; lines: +2 -0
add data structure “struct file_operations fops”.
—————————-
revision 1.3
date: 2013/07/02 10:49:46; author: root; state: Exp; lines: +13 -0
added header files :cdev.h , slab.h
define data structure “struct ScullDev” and also define pointer to that structure.
also define data structure “struct scullQset”.
—————————-
revision 1.2
date: 2013/07/02 09:38:19; author: root; state: Exp; lines: +14 -1
adding header file fs.h.
define macros DEV_NAME as device name, MAJORNO as major number, MINORNO as minor number for device.
define variables : dev, majorno for MAJORNO, minorno for MINORNO, nod for NOD.
—————————-
revision 1.1
date: 2013/07/02 07:30:51; author: root; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Tagged | Leave a comment

Ranjeet Singh

RCS file: lkm.c,v
Working file: lkm.c
head: 1.14
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 14; selected revisions: 14
description:
This is loadable kernel module.
—————————-
revision 1.14
date: 2013/07/09 18:00:30; author: root; state: Exp; lines: +34 -2
define scull_trim function.
—————————-
revision 1.13
date: 2013/07/09 17:42:14; author: root; state: Exp; lines: +1 -1
preserve the lsculldev variable in flip->private_data.
—————————-
revision 1.12
date: 2013/07/09 17:35:41; author: root; state: Exp; lines: +22 -6
Declare a variable lsculldev.
store the pointer return by the container_of in this lsculldev variable.
—————————-
revision 1.11
date: 2013/07/04 11:40:49; author: root; state: Exp; lines: +27 -2
define functions “scull_open” and “scull_release”.
also successfully create node and an application successfully make open call using that node.
—————————-
revision 1.10
date: 2013/07/04 11:15:06; author: root; state: Exp; lines: +5 -4
declare ret in function cdevinit.
kernel crashes many time because of nod.
gave runtime value to nod.
—————————-
revision 1.9
date: 2013/07/04 10:13:38; author: root; state: Exp; lines: +38 -14
initialize 20 nods successfully using for loop.
—————————-
revision 1.8
date: 2013/07/04 08:00:25; author: ranjeet; state: Exp; lines: +47 -13
initialize the values of struct ScullDev using function scull_init.
initialize the values struct cdev using function cdevinit.
—————————-
revision 1.7
date: 2013/07/03 06:54:15; author: root; state: Exp; lines: +2 -1
using function module_param.
—————————-
revision 1.6
date: 2013/07/03 06:42:07; author: root; state: Exp; lines: +8 -1
initialize values to struct i_cdev’s variables.
also initialize values to the variables declared in struct ScullDev.
—————————-
revision 1.5
date: 2013/07/02 11:30:00; author: root; state: Exp; lines: +12 -1
In function init : call functions cdev_init & cdev_add.
—————————-
revision 1.4
date: 2013/07/02 11:01:33; author: root; state: Exp; lines: +5 -2
In function init: using kmalloc function & flush the garbage using memset.
In function exit: free allocated memory using kfree.
—————————-
revision 1.3
date: 2013/07/02 10:04:08; author: root; state: Exp; lines: +30 -6
in init function: call register_chrdev_region.
also printed the values of majorno and minorno.
also call MKDEV function.
—————————-
revision 1.2
date: 2013/07/02 09:43:30; author: root; state: Exp; lines: +15 -3
call alloc function for registering the device.
in exit func: call unregister_chrdev_region function for unregistering the device.
—————————-
revision 1.1
date: 2013/07/02 07:35:12; author: root; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Tagged | Leave a comment

DEVICE DRIVER

i have done the open close call for 10 node and also done the container_of

Posted in Uncategorized | Tagged | Leave a comment

Character Driver

RCS file: car_dev.c,v
Working file: car_dev.c
head: 1.6
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 6;    selected revisions: 6
description:
registeration done using alloc_cardev_region.
unregistered using unregister_chardev_region.
—————————-
revision 1.6
date: 2013/07/03 05:39:57;  author: root;  state: Exp;  lines: +1 -0
added module_param().
—————————-
revision 1.5
date: 2013/07/03 05:15:28;  author: root;  state: Exp;  lines: +7 -2
given values to stuct sculldev and cdev.
—————————-
revision 1.4
date: 2013/07/01 22:51:08;  author: root;  state: Exp;  lines: +2 -0
intialize cdev using cdev_init.
added to the kernel using cdev_add.
—————————-
revision 1.3
date: 2013/07/01 22:13:39;  author: root;  state: Exp;  lines: +3 -0
added kmalloc & kfree.
used memset.
—————————-
revision 1.2
date: 2013/07/01 21:32:35;  author: root;  state: Exp;  lines: +21 -3
used register_chrdev_region.
printed the value of major & minor no.
—————————-
revision 1.1
date: 2013/07/01 19:43:38;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment