⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iucv.c

📁 Linux内核源代码 为压缩文件 是<<Linux内核>>一书中的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
    dev_kfree_skb(skb);                               /* release it*/#ifdef DEBUG    printk(  "iucv:leaving iucv_tx, device %s\n",dev->name);#endif    return retval;              /* zero == done; nonzero == fail*/}   /* end  iucv_tx( struct sk_buff *skb, struct device *dev)  *//*---------------*//* iucv_release *//*---------------*/int iucv_release(net_device *dev){    int rc =0;    struct iucv_priv *privptr;    privptr = (struct iucv_priv *) (dev->priv);    netif_stop(dev);    netif_stop_queue(dev);           /* can't transmit any more*/    rc = iucv_sever(privptr->command_buffer);    if (rc!=0)    {       printk("iucv: %s: iucv_release pending...rc:%02x\n",dev->name,rc);    }#ifdef DEBUG      printk("iucv: iucv_sever ended with rc: %X\n",rc);#endif    return rc;} /* end  iucv_release() *//*-----------------------------------------------*//* Configuration changes (passed on by ifconfig) *//*-----------------------------------------------*/int iucv_config(net_device *dev, struct ifmap *map){   if (dev->flags & IFF_UP)        /* can't act on a running interface*/        return -EBUSY;   /* ignore other fields */   return 0;}/*  end  iucv_config()  *//*----------------*//* Ioctl commands *//*----------------*/int iucv_ioctl(net_device *dev, struct ifreq *rq, int cmd){#ifdef DEBUG    printk(  "iucv: device %s; iucv_ioctl\n",dev->name);#endif    return 0;}/*---------------------------------*//* Return statistics to the caller *//*---------------------------------*/struct net_device_stats *iucv_stats(net_device *dev){    struct iucv_priv *priv = (struct iucv_priv *)dev->priv;#ifdef DEBUG    printk(  "iucv: device %s; iucv_stats\n",dev->name);#endif    return &priv->stats;}/* * iucv_change_mtu      * IUCV can handle MTU sizes from 576 to approx. 32000     */static int iucv_change_mtu(net_device *dev, int new_mtu){#ifdef DEBUG    printk(  "iucv: device %s; iucv_change_mtu\n",dev->name);#endif       if ((new_mtu < 64) || (new_mtu > 32000))	 return -EINVAL;       dev->mtu = new_mtu;       return 0;}/*--------------------------------------------*//* The init function (sometimes called probe).*//* It is invoked by register_netdev()         *//*--------------------------------------------*/int iucv_init(net_device *dev){    int rc;    struct iucv_priv *privptr;#ifdef DEBUG    printk(  "iucv: iucv_init, device: %s\n",dev->name);#endif    dev->open            = iucv_open;    dev->stop            = iucv_release;    dev->set_config      = iucv_config;    dev->hard_start_xmit = iucv_tx;    dev->do_ioctl        = iucv_ioctl;    dev->get_stats       = iucv_stats;    dev->change_mtu      = iucv_change_mtu;    /* keep the default flags, just add NOARP */    dev->hard_header_len = 0;    dev->addr_len        = 0;    dev->type            = ARPHRD_SLIP;    dev->tx_queue_len    = 100;    dev->flags           = IFF_NOARP|IFF_POINTOPOINT;    dev->mtu    = 4092;    dev_init_buffers(dev);    /* Then, allocate the priv field. This encloses the statistics */    /* and a few private fields.*/    dev->priv = kmalloc(sizeof(struct iucv_priv), GFP_KERNEL);    if (dev->priv == NULL){       printk(  "iucv: no memory for dev->priv.\n");       return -ENOMEM;    }    memset(dev->priv, 0, sizeof(struct iucv_priv));    privptr = (struct iucv_priv *)(dev->priv);    privptr->send_buffer = (u8*) __get_free_pages(GFP_KERNEL+GFP_DMA,8);    if (privptr->send_buffer == NULL) {      printk(KERN_INFO "%s: could not get pages for send buffer\n",	     dev->name);      return -ENOMEM;    }    memset(privptr->send_buffer, 0, 8*PAGE_SIZE);    privptr->send_buffer_len=8*PAGE_SIZE;        privptr->receive_buffer = (u8*) __get_free_pages(GFP_KERNEL+GFP_DMA,8);    if (privptr->receive_buffer == NULL) {      printk(KERN_INFO "%s: could not get pages for receive buffer\n",	     dev->name);      return -ENOMEM;    }    memset(privptr->receive_buffer, 0, 8*PAGE_SIZE);    privptr->receive_buffer_len=8*PAGE_SIZE;    /* now use the private fields ... */    /* init pathid                    */    privptr->pathid = -1;    /* init private userid from global userid */    memcpy(privptr->userid,iucv_userid[dev-iucv_devs],8);    /* we can use only ONE buffer for external interrupt ! */    rc=iucv_declare_buffer(privptr->command_buffer,                           (DCLBFR_T *)iucv_ext_int_buffer);    if (rc!=0 && rc!=19)   /* ignore existing buffer */      {         printk(  "iucv:iucv_declare failed, rc: %X\n",rc);         return -ENODEV;      }    rc = iucv_enable(privptr->command_buffer);    if (rc!=0)    {            printk(  "iucv:iucv_enable failed, rc: %x\n",rc);            iucv_retrieve_buffer(privptr->command_buffer);            return -ENODEV;    }#ifdef DEBUG    printk(  "iucv: iucv_init endend OK for device %s.\n",dev->name);#endif    return 0;}/* * setup iucv devices *  * string passed: iucv=userid1,...,useridn  */#if LINUX_VERSION_CODE>=0x020300static int  __init iucv_setup(char *str)#else__initfunc(void iucv_setup(char *str,int *ints))#endif{    int result=0, i=0,j=0, k=0, device_present=0;    char *s = str;    net_device * dev ={0};#ifdef DEBUG    printk(  "iucv: start registering device(s)... \n");#endif    /*     * scan device userids     */    while(*s != 0x20 && *s != '\0'){       if(*s == ','){          /* fill userid up to 8 chars */          for(k=i;k<8;k++){             iucv_userid[j][k] = 0x40;          } /* end for */          /* new device  */          j++;          s++; /* ignore current char */          i=0;          if (j>MAX_DEVICES) {             printk("iucv: setup devices: max devices %d reached.\n",		    MAX_DEVICES);             break;          } /* end if */          continue;       } /* end if */       iucv_ascii_userid[j][i] = (int)*s;       iucv_userid[j][i] = _ascebc[(int)*s++];       i++;    } /* end while */    /*      * fill last userid up to 8 chars     */    for(k=i;k<8;k++) {      iucv_userid[j][k] = 0x40;    }    /*     * set device name and register     */    for (k=0;k<=j;k++) {      memcpy(iucv_devs[k].name, "iucv0", 4);      dev = &iucv_devs[k];      dev->name[4] = k + '0';#ifdef DEBUGX      printk("iucv: (ASCII- )Userid:%s\n",&iucv_ascii_userid[k][0]);      printk("iucv: (ASCII-)Userid: ");      for (i=0;i<8;i++) {        printk(  "%02X ",(int)iucv_ascii_userid[k][i]);      }      printk("\n");      printk("iucv: (EBCDIC-)Userid: ");      for (i=0;i<8;i++) {         printk(  "%02X ",(int)iucv_userid[k][i]);      }      printk("\n");      printk("iucv: device name :%s\n",iucv_devs[k].name);#endif      if ( (result = register_netdev(iucv_devs + k)) )          printk("iucv: error %i registering device \"%s\"\n",                 result, iucv_devs[k].name);      else      {              device_present++;      }    } /* end for */#ifdef DEBUG    printk(  "iucv: end register devices, %d devices present\n",device_present);#endif    /* return device_present ? 0 : -ENODEV; */#if LINUX_VERSION_CODE>=0x020300    return 1;#else    return;#endif}#if LINUX_VERSION_CODE>=0x020300__setup("iucv=", iucv_setup);#endif/*-------------*//* The devices *//*-------------*/char iucv_names[MAX_DEVICES*8]; /* MAX_DEVICES eight-byte buffers */net_device iucv_devs[MAX_DEVICES] = {    {        iucv_names, /* name -- set at load time */        0, 0, 0, 0,  /* shmem addresses */        0x000,       /* ioport */        0,           /* irq line */        0, 0, 0,     /* various flags: init to 0 */        NULL,        /* next ptr */        iucv_init,  /* init function, fill other fields with NULL's */    },    {        iucv_names+8,/* name -- set at load time */        0, 0, 0, 0,  /* shmem addresses */        0x000,       /* ioport */        0,           /* irq line */        0, 0, 0,     /* various flags: init to 0 */        NULL,        /* next ptr */        iucv_init,  /* init function, fill other fields with NULL's */    },    {        iucv_names+16,/* name -- set at load time */        0, 0, 0, 0,  /* shmem addresses */        0x000,       /* ioport */        0,           /* irq line */        0, 0, 0,     /* various flags: init to 0 */        NULL,        /* next ptr */        iucv_init,  /* init function, fill other fields with NULL's */    },    {        iucv_names+24,/* name -- set at load time */        0, 0, 0, 0,  /* shmem addresses */        0x000,       /* ioport */        0,           /* irq line */        0, 0, 0,     /* various flags: init to 0 */        NULL,        /* next ptr */        iucv_init,  /* init function, fill other fields with NULL's */    },    {        iucv_names+32,/* name -- set at load time */        0, 0, 0, 0,  /* shmem addresses */        0x000,       /* ioport */        0,           /* irq line */        0, 0, 0,     /* various flags: init to 0 */        NULL,        /* next ptr */        iucv_init,  /* init function, fill other fields with NULL's */    },    {        iucv_names+40,/* name -- set at load time */        0, 0, 0, 0,  /* shmem addresses */        0x000,       /* ioport */        0,           /* irq line */        0, 0, 0,     /* various flags: init to 0 */        NULL,        /* next ptr */        iucv_init,  /* init function, fill other fields with NULL's */    },    {        iucv_names+48,/* name -- set at load time */        0, 0, 0, 0,  /* shmem addresses */        0x000,       /* ioport */        0,           /* irq line */        0, 0, 0,     /* various flags: init to 0 */        NULL,        /* next ptr */        iucv_init,  /* init function, fill other fields with NULL's */    },    {        iucv_names+56,/* name -- set at load time */        0, 0, 0, 0,  /* shmem addresses */        0x000,       /* ioport */        0,           /* irq line */        0, 0, 0,     /* various flags: init to 0 */        NULL,        /* next ptr */        iucv_init,  /* init function, fill other fields with NULL's */    },    {        iucv_names+64,/* name -- set at load time */        0, 0, 0, 0,  /* shmem addresses */        0x000,       /* ioport */        0,           /* irq line */        0, 0, 0,     /* various flags: init to 0 */        NULL,        /* next ptr */        iucv_init,  /* init function, fill other fields with NULL's */    },    {        iucv_names+72,/* name -- set at load time */        0, 0, 0, 0,  /* shmem addresses */        0x000,       /* ioport */        0,           /* irq line */        0, 0, 0,     /* various flags: init to 0 */        NULL,        /* next ptr */        iucv_init,  /* init function, fill other fields with NULL's */    }};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -