`
highsky
  • 浏览: 269806 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Linux核心数据结构--device

阅读更多
系统中每个网络设备都用一个设备数据结构来表示。

struct device

{


  /*

   * This is the first field of the "visible" part of this structure

   * (i.e. as seen by users in the "Space.c" file).  It is the name

   * the interface.

   */

  char                    *name;


  /* I/O specific fields                                           */

  unsigned long           rmem_end;        /* shmem "recv" end     */

  unsigned long           rmem_start;      /* shmem "recv" start   */

  unsigned long           mem_end;         /* shared mem end       */

  unsigned long           mem_start;       /* shared mem start     */

  unsigned long           base_addr;       /* device I/O address   */

  unsigned char           irq;             /* device IRQ number    */



  /* Low-level status flags. */

  volatile unsigned char  start,           /* start an operation   */

                          interrupt;       /* interrupt arrived    */

  unsigned long           tbusy;           /* transmitter busy     */

  struct device           *next;



  /* The device initialization function. Called only once.         */

int                     (*init)(struct device *dev);



  /* Some hardware also needs these fields, but they are not part of

     the usual set specified in Space.c. */

  unsigned char           if_port;         /* Selectable AUI,TP,   */

  unsigned char           dma;             /* DMA channel          */



  struct enet_statistics* (*get_stats)(struct device *dev);



  /*

   * This marks the end of the "visible" part of the structure. All

   * fields hereafter are internal to the system, and may change at

   * will (read: may be cleaned up at will).

   */



  /* These may be needed for future network-power-down code.       */

  unsigned long           trans_start;     /* Time (jiffies) of

                                              last transmit        */

  unsigned long           last_rx;         /* Time of last Rx      */

unsigned short          flags;           /* interface flags (BSD)*/

  unsigned short          family;          /* address family ID    */

  unsigned short          metric;          /* routing metric       */

  unsigned short          mtu;             /* MTU value            */

  unsigned short          type;            /* hardware type        */

  unsigned short          hard_header_len; /* hardware hdr len     */

  void                    *priv;           /* private data         */



  /* Interface address info. */

  unsigned char           broadcast[MAX_ADDR_LEN];

  unsigned char           pad;              

  unsigned char           dev_addr[MAX_ADDR_LEN]; 

  unsigned char           addr_len;        /* hardware addr len    */

  unsigned long           pa_addr;         /* protocol address     */

  unsigned long           pa_brdaddr;      /* protocol broadcast addr*/

  unsigned long           pa_dstaddr;      /* protocol P-P other addr*/

  unsigned long           pa_mask;         /* protocol netmask     */

  unsigned short          pa_alen;         /* protocol address len */



  struct dev_mc_list      *mc_list;        /* M'cast mac addrs     */

  int                     mc_count;        /* No installed mcasts  */

 

  struct ip_mc_list       *ip_mc_list;     /* IP m'cast filter chain */

  __u32                   tx_queue_len;    /* Max frames per queue   */

   

  /* For load balancing driver pair support */

  unsigned long           pkt_queue;       /* Packets queued       */

  struct device           *slave;          /* Slave device         */

  struct net_alias_info   *alias_info;     /* main dev alias info  */

  struct net_alias        *my_alias;       /* alias devs           */

 

  /* Pointer to the interface buffers. */

  struct sk_buff_head     buffs[DEV_NUMBUFFS];


  /* Pointers to interface service routines. */

  int                     (*open)(struct device *dev);

  int                     (*stop)(struct device *dev);

  int                     (*hard_start_xmit) (struct sk_buff *skb,

                                              struct device *dev);

  int                     (*hard_header) (struct sk_buff *skb,

                                          struct device *dev,

                                          unsigned short type,

                                          void *daddr,

                                          void *saddr,

                                          unsigned len);

  int                     (*rebuild_header)(void *eth,

                                          struct device *dev,

                                          unsigned long raddr,

                                          struct sk_buff *skb);

  void                    (*set_multicast_list)(struct device *dev);

  int                     (*set_mac_address)(struct device *dev,

                                          void *addr);

  int                     (*do_ioctl)(struct device *dev,

                                          struct ifreq *ifr,

                                          int cmd);

  int                     (*set_config)(struct device *dev,

                                          struct ifmap *map);

  void                    (*header_cache_bind)(struct hh_cache **hhp,

                                          struct device *dev,

                                          unsigned short htype,

                                          __u32 daddr);

  void                    (*header_cache_update)(struct hh_cache *hh,

                                          struct device *dev,

                                          unsigned char *  haddr);

  int                     (*change_mtu)(struct device *dev,

                                          int new_mtu);

  struct iw_statistics*   (*get_wireless_stats)(struct device *dev);

};

分享到:
评论

相关推荐

    Linux DeviceDrivers 3rd Edition

    一些重要的数据结构 53 字符设备的注册 59 open和release 62 scull的内存使用 64 read和write 67 试试新设备 74 快速参考 74 第四章 调试技术 76 内核中的调试支持 76 通过打印调试 78 通过查询调试 85 ...

    《精通Linux 设备驱动程序开发》.(Sreekrishnan).pdf

    14.4 块驱动程序数据结构和方法296 14.5 设备实例:简单存储控制器298 14.5.1 初始化299 14.5.2 块设备操作301 14.5.3 磁盘访问302 14.6 高级主题304 14.7 调试306 14.8 查看源代码306 第15章 网络...

    Linux 蓝牙协议栈的USB+设备驱动

    给出实现蓝牙设备驱动的重要数据结构和流程,并总结Linux 下开发蓝牙USB 设备驱动的一般方法和关键技术。 关键词:Linux 系统;蓝牙协议栈;设备驱动 USB Device Driver for Linux Bluetooth Stack LIANG Jun-xue...

    libusb 源码(win32 & linux USB开发)

     打开要使用的设备,在对硬件进行操作前必须要调用usb_open 来打开设备,这里大家看到有两个结构体 usb_dev_handle 和 usb_device 是我们在开发中经常碰到的,有必要把它们的结构看一看。在libusb 中的usb.h和usbi....

    Linux-Insight:Linux内核源码认知层,承上启下的分析

    介绍核心数据结构 4.2内核线程 介绍内核线程的作用与相互作用(如果存在内核线程的话) 4.3 percpu percpu的逻辑,如hrtimer即每cpu一颗红黑树挂接定时器,runqueue即每CPU运行操作系统,挂接进程。 5界面 proc文件...

    精通LINUX设备驱动程序开发

    183 9.4 pcmcia核心 183 9.5 驱动程序服务 183 9.6 客户驱动程序 183 9.6.1 数据结构 184 9.6.2 设备实例:pcmcia卡 185 9.7 将零件组装在一起 188 9.8 pcmcia存储 189 9.9 串行pcmcia 189 9.10 调试 191 ...

    入门学习Linux常用必会60个命令实例详解doc/txt

    因为Linux与Windows不同,其后台运行着许多进程,所以强制关机可能会导致进程的数据丢失,使系统处于不稳定的状态,甚至在有的系统中会损坏硬件设备(硬盘)。在系统关机前使用 shutdown命令,系统管理员会通知所有...

    新版Android开发教程.rar

    ----------------------------------- Android 编程基础 1 封面----------------------------------- Android 编程基础 ...• SQLite SQLite SQLite SQLite 用作结构化的数据存储 • 多媒体支持 包括常见的音频、视频和...

    LINUX设备驱动第三版_588及代码.rar

    一些重要的数据结构 字符设备的注册 open和release scull的内存使用 read和write 试试新设备 快速参考 第四章 调试技术 内核中的调试支持 通过打印调试 通过查询调试 通过监视调试 调试系统故障 调试器...

    ARM_Linux启动分析.pdf

    核心数据结构初始化--内核引导第一部分 四.外设初始化--内核引导第二部分 五.init进程和inittab引导指令 六.rc启动脚本 七.getty和login 八.bash 附:XDM方式登录 本文以Redhat 6.0 Linux 2.2.19 for Alpha/AXP为...

    linux设备驱动程序

    一些重要的数据结构 字符设备的注册 open和release scull的内存使用 read和write 试试新设备 快速参考 ch04.第四章 调试技术 内核中的调试支持 通过打印调试 通过查询调试 通过监视调试 调试系统故障 调试器和相关...

    jsr80 java 访问 usb

    当前,该 API 可以在具有 Linux 2.4 核心或者以前的 2.2.18 核心的 GNU/Linux 版本上工作。因此可支持大多数最新的版本,例如,该 API 可以在没有任何补丁或者升级的 Red Hat 7.2 和 9.0 上工作。 jUSB API 包括以下...

    支持WinCE和Linux的FL2416开发板原理图/示例源码/数据手册等-电路方案

    FL2416开发板采用‘核心板+底板’结构,核心板实现了S3C2416的最小系统,只需要一个电源就可让CPU正常工作;FL2416开发板底板上配备了多种外设接口,包括:LCD接口、以太网接口、1路USB2.0Device、4路USB1.1HOST、SD...

    uboott移植实验手册及技术文档

    了解 U-Boot-1.3.1 的代码结构,掌握其移植方法。 【实验环境】 1、Ubuntu 7.0.4发行版 2、u-boot-1.3.1 3、FS2410平台 4、交叉编译器 arm-softfloat-linux-gnu-gcc-3.4.5 【实验步骤】 一、建立自己的平台...

    网管教程 从入门到精通软件篇.txt

    DTED:地面高度数字数据(图形的数据格式)文件 DTF:Symantec Q&A相关的数据库数据文件 DTM:DigiTrakker模块文件 DUN:Microsoft拔号网络导出文件 DV:数字视频文件(MIME) DWG:AutoCAD工程图文件;AutoCAD...

    嵌入式系统/ARM技术中的在嵌入式系统中实现对U盘的操作

    引 言 USB(通用串行总线)用于将适用USB的外围设备(device)连接到主机(host),实现二者之间数据传输的外部总线结构;是一种快速、灵活的总线接口。它最大的特点是易于使用,主要是用在中速和低速的外设。 随着USB...

    嵌入式红绿灯控制系统

    #define DEVICE_NAME "demo" #define led_MAJOR 212 #define led_MINOR 0 static int MAX_BUF_LEN=1024; static char drv_buf[1024]; static int WRI_LENGTH=0; static char combuf[2]; char base = 0x70; ...

    Ghost 8.3 系统备份软件

    同以前版本不同的是,Ghost 2001 加入了对 Linux EX2的支持(FIFO 文件存储格式),这也就意味着 Linux 的用户也可以用 Ghost 来备份系统了。 3.配套软件  A.Ghost 浏览器 在以前的 Ghost版本中,我们只能对...

Global site tag (gtag.js) - Google Analytics