EmbLogic's Blog

Category Archives: Uncategorized

Inside structure declaration of variable of same type is not allowed

struct node { struct node x; //not allowed struct node *head; //allowed }; Why does we can declare a pointer of same type but not a variable of same type?

Posted in Uncategorized | 1 Comment

Alternative method of newline

Q. How to print output in multiple line without using \n character? Ans. printf(“\x0a”);

Posted in Uncategorized | Leave a comment

character driver -> scull open ->container_of

the prototype for container_of is as follows: container_of(pointer,container_type,container_field) so what exactly does this return? considering an example, ptr=container_of(inode->i_cdev,struct scull_dev,cdev) here the pointer ‘inode->i_cdev’ has a field cdev.’cdev’ is CONTAINED IN struct scull_dev. so ultimately,’container_of’ takes pointer ‘inode->i_cdev’ to struct scull_dev … Continue reading →

Posted in Uncategorized | Leave a comment

partial write

can any bdy tell me …how to accomplish partial write in scull…???….when i call write cmd from d application,it jst fill only 1 quantum.But when i try to call write cmd multiple times ,it fills a few quantum with d … Continue reading →

Posted in Uncategorized | Leave a comment

The Algorithm to trim.

int scull_trim(struct scull_dev *dev) -> Iterate through scull_qsets -> for(*s_q=s_d->data;s_q;s_q=next) -> In every iteration -> Free the quantums -> Finaly free the qset array -> Make pointer to qset as NULL -> Free scull_qset -> Finally initialize the default values

Posted in Uncategorized | Leave a comment

The Macro “container_of”

#define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr – offsetof(type,member) );})

Posted in Uncategorized | Leave a comment

Regarding Char Device Registration

When we used : register_chrdev(unsigned int major, const char *name, struct file_operations *fops); We never initialized struct cdev. Still we were very much able to call all the functions mapped in the file_operatins structure using fop. Why we have to … Continue reading →

Posted in Uncategorized | 3 Comments

Registering the chr device

In int register_chrdev_region(dev_t first, unsigned int count,char *name); if we make count large what can go wrong.

Posted in Uncategorized | Leave a comment

Makefile

INSTALL_DIR=modules ifneq (${KERNELRELEASE},) obj-m := new.o new_mod-objs := new.o else KERNELDIR ?= /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) default: $(MAKE)  -C $(KERNELDIR) M=$(PWD) modules @rm -rf ${INSTALL_DIR} @mkdir ${INSTALL_DIR} @mv -f *.o *.ko *.mod.c .*.cmd ${INSTALL_DIR} clean: rm -rf … Continue reading →

Posted in Uncategorized | 1 Comment

Facing Problem in Write()

I’m trying to update the struct file -> f_pos with count number of bytes in my write function, but everytime i call write(), it will display the value of f_pos = 0. and i call 5 times write() in my … Continue reading →

Posted in Uncategorized | 1 Comment

Algo for Write operation

* Define Local Device. *Fetch device from local device. *Allocate space for buffer,pointed to by dev->data. *Check for error ,clear the allocated space using memset. *Check if the fpos is beyond the device size. *Check for errors. *Check if the … Continue reading →

Posted in Uncategorized | Leave a comment

Allocation Test Function.

// Function To allocate bytes . // Test function for writing write operation. #include<stdio.h> #include<stdlib.h> #define SIZE 1000 char arr[SIZE]; char *p=arr; char * allocate(unsigned char  ); char * allocate(unsigned char j) { if(arr+SIZE-p>j) { p=p+j; return p-j; } else … Continue reading →

Posted in Uncategorized | Leave a comment

Memory Management Strategies.

# The memory management algos vary from primitive bare-machine to paging and segmentation strategies. # Memory contains large array of words and bytes each having its own address. # The computer fetches the instructions from the cpu , according to … Continue reading →

Posted in Uncategorized | Leave a comment

device driver

today i have done initialising the driver in device driver then i faced a problem in that. in the init_module ,i had not returnned the value beacuse of this on inserting using insmod it will be hanged and the kernel … Continue reading →

Posted in Uncategorized | Leave a comment

scull

structure of scull is complete.. trying to work on the function recursion part.

Posted in Uncategorized | Leave a comment