CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Linux/Unix社区 >  内核及驱动程序研究区

关于编译pci设备驱动程序出现的问题

楼主goodmouse1(goodmouse)2005-04-19 22:18:29 在 Linux/Unix社区 / 内核及驱动程序研究区 提问

我的代码源程序如下:  
  #ifndef   _PCI_H  
  #define   _PCI_H  
   
  #include   <linux/types.h>  
  #include   <linux/fs.h>  
  #include   <linux/mm.h>  
  #include   <linux/errno.h>  
  #include   <asm/segment.h>  
  #include   <linux/module.h>  
  #include   <linux/kernel.h>  
  #include   <linux/pci.h>  
   
   
  #define   PCI_VENDOR_ID_netb     0x10ee  
  #define   PCI_DEVICE_ID_netb 0x1000  
   
  unsigned   int   pci_major   =   250;  
   
   
   
  static   ssize_t   read_pci(struct   file   *file,char   *buf,ssize_t   count,loff_t   *ppos)    
  {    
  int   left;  
   
  // if   ((verify_area(VERIFY_WRITE,buf,count)   ==   -EFAULT   )    
  // return   -EFAULT;    
   
  for(left   =   count   ;   left   >   0   ;   left--)    
  {    
  __put_user(1,buf,1);    
  buf++;    
  }    
  return   count;    
  }    
   
  static   ssize_t   write_pci(struct   file   *file,char   *buf,ssize_t   count,loff_t   *ppos)    
  {    
  return   count;  
  }    
   
  static   int   ioctl_pci(struct   inode   *inode,   struct   file   *   file,   unsigned   int   count,   unsigned   long   count1)  
  {  
  return   0;  
  }  
   
  static   int   open_pci(struct   inode   *inode,struct   file   *file   )    
  {    
  //MOD_INC_USE_COUNT;    
  return   0;    
  }    
   
  static   void   release_pci(struct   inode   *inode,struct   file   *file   )    
  {    
  //MOD_DEC_USE_COUNT;    
  return;  
  }  
   
   
  static   struct   file_operations   pci_fops   ={  
          owner:THIS_MODULE,  
          NULL,  
          read:read_pci,  
          write:write_pci,  
          NULL,  
          NULL,  
          ioctl:ioctl_pci,  
          NULL,  
          open:open_pci,  
          NULL,  
          release:release_pci,  
          NULL,  
          NULL,  
          NULL,  
          NULL,  
          NULL,  
          NULL,  
          NULL  
  };  
   
   
  static   int   init_module(struct   pci_dev   *dev){  
  /*找这块设备是否存在*/  
  dev   =   pci_find_device(PCI_VENDOR_ID_netb,  
  PCI_DEVICE_ID_netb,dev);  
  if(dev==0){  
  //printk(KERN_INFO   "pci:   can't   get   major   number\n");    
  return   -1;  
  };  
   
   
  /*启动pci设备*/  
  if(pci_enable_device(dev))   {;}  
   
  /*注册设备*/  
  register_chrdev(pci_major,"pci",&pci_fops);  
   
   
  }  
   
  void   cleanup_module(void)    
  {    
  unregister_chrdev(pci_major,"pci");    
  }    
   
   
   
  #endif  
   
   
   
   
  程序使用gcc   -DMODULE   -D__KERNEL__   -DLINUX   pci.c编译  
  出现了如下错误信息:  
  cpci.c:   At   top   level:  
  cpci.c:21:   warning:   `struct   file'   declared   inside   parameter   list  
  cpci.c:21:   warning:   its   scope   is   only   this   definition   or   declaration,   which   is   probably   not   what   you   want  
  cpci.c:36:   warning:   `struct   file'   declared   inside   parameter   list  
  cpci.c:41:   warning:   `struct   file'   declared   inside   parameter   list  
  cpci.c:41:   warning:   `struct   inode'   declared   inside   parameter   list  
  cpci.c:46:   warning:   `struct   file'   declared   inside   parameter   list  
  cpci.c:46:   warning:   `struct   inode'   declared   inside   parameter   list  
  cpci.c:52:   warning:   `struct   file'   declared   inside   parameter   list  
  cpci.c:52:   warning:   `struct   inode'   declared   inside   parameter   list  
  cpci.c:59:   variable   `cpci_fops'   has   initializer   but   incomplete   type  
  cpci.c:60:   unknown   field   `owner'   specified   in   initializer  
  cpci.c:60:   warning:   excess   elements   in   struct   initializer  
  cpci.c:60:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:61:   warning:   excess   elements   in   struct   initializer  
  cpci.c:61:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:62:   unknown   field   `read'   specified   in   initializer  
  cpci.c:62:   warning:   excess   elements   in   struct   initializer  
  cpci.c:62:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:63:   unknown   field   `write'   specified   in   initializer  
  cpci.c:63:   warning:   excess   elements   in   struct   initializer  
  cpci.c:63:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:64:   warning:   excess   elements   in   struct   initializer  
  cpci.c:64:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:65:   warning:   excess   elements   in   struct   initializer  
  cpci.c:65:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:66:   unknown   field   `ioctl'   specified   in   initializer  
  cpci.c:66:   warning:   excess   elements   in   struct   initializer  
  cpci.c:66:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:67:   warning:   excess   elements   in   struct   initializer  
  cpci.c:67:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:68:   unknown   field   `open'   specified   in   initializer  
  cpci.c:68:   warning:   excess   elements   in   struct   initializer  
  cpci.c:68:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:69:   warning:   excess   elements   in   struct   initializer  
  cpci.c:69:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:70:   unknown   field   `release'   specified   in   initializer  
  cpci.c:70:   warning:   excess   elements   in   struct   initializer  
  cpci.c:70:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:71:   warning:   excess   elements   in   struct   initializer  
  cpci.c:71:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:72:   warning:   excess   elements   in   struct   initializer  
  cpci.c:72:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:73:   warning:   excess   elements   in   struct   initializer  
  cpci.c:73:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:74:   warning:   excess   elements   in   struct   initializer  
  cpci.c:74:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:75:   warning:   excess   elements   in   struct   initializer  
  cpci.c:75:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:76:   warning:   excess   elements   in   struct   initializer  
  cpci.c:76:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:78:   warning:   excess   elements   in   struct   initializer  
  cpci.c:78:   warning:   (near   initialization   for   `cpci_fops')  
  cpci.c:81:   warning:   `struct   pci_dev'   declared   inside   parameter   list  
  cpci.c:   In   function   `init_module':  
  cpci.c:84:   warning:   assignment   makes   pointer   from   integer   without   a   cast  
  cpci.c:   At   top   level:  
  cpci.c:59:   storage   size   of   `cpci_fops'   isn't   known  
  make:   ***   [cpci]   Error   1  
   
  如何改进呢? 问题点数:50、回复次数:2Top

1 楼hs_guanqi(关七)回复于 2005-04-20 00:21:22 得分 30

老问题了,要加上-I/usr/src/linux/include,  
  头文件要使用kernel的Top

2 楼gettext(冰雪之崖)回复于 2005-04-20 07:44:52 得分 20

or   -I   /usr/src/linux-2.4/include/Top

相关问题

  • vc中怎样编译驱动程序
  • 程序编译
  • 编译程序
  • 请问有没有人会使用vc1.52编译驱动程序呢?怎么编译?
  • 怎么样编译驱动程序(vc++ 6.0 + ddk2000)或者(vc++ 6.0 + ddk98)?
  • 有人知道如何连接用Tasm5编译的OBJ驱动WDM程序吗?
  • <<linux设备驱动程序>>中的一个关于编译内核问题
  • !请问,新下载的驱动程序该如何编译进内核呢?
  • vc编译 程序
  • foxbase的反编译程序

关键词

  • null
  • pci
  • ssize
  • inode
  • count
  • ioctl
  • struct
  • buf
  • left
  • include

得分解答快速导航

  • 帖主:goodmouse1
  • hs_guanqi
  • gettext

相关链接

  • CSDN Blog
  • 技术文档
  • 代码下载
  • 第二书店
  • 读书频道

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo