doubts :To write a generic device driver for pci device.
PROJECT :To write a generic device driver for pci device.
SOURCES : pci.c & pci.h files in the linux source files.
/usr/src/linux/drivers/pci/pci.c
/usr/include/linux/pci.h
CURRENT STEP : To link the files My_prog.c and pci.c
PROBLEM_1 : Unable to form pci.o and to solve its dependencies. Trying to write makefile for it.
PROBLEM_2 : What all #define's and #include's to place in My_prog.c.
My_prog.c is written with just one function call from file pci.h.
Just to see if the whole thing compiles. But we are unable to suceed.
Unable to deal with
#define __KERNEL__. and
#include<modules.h>
#include<linux/config.h>
#include<pci.h>
Code:
//******************My_prog.c**********************
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
#include <linux/config.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/proc_fs.h>
#include <linux/pci.h>
int main()
{
struct pci_dev *dev=NULL;
dev = (struct pci_dev *)pci_find_device( 1 , 1 , dev);
if(!dev)
{
printf("\n\n\t\tNO DEVICE FOUND...!!!");
}
else
{
printf("\n\n\t\tDEVICE FOUND...!!!");
}
return 0;
}