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

📄 ips.c

📁 linux和2410结合开发 用他可以生成2410所需的zImage文件
💻 C
📖 第 1 页 / 共 5 页
字号:
            if (IPS_USE_I2O_DELIVER(ha))               ha->func.issue = ips_issue_i2o;            else               ha->func.issue = ips_issue_copperhead;         }         /*          * Initialize the card if it isn't already          */         if (!(*ha->func.isinit)(ha)) {            if (!(*ha->func.init)(ha)) {               /*                * Initialization failed                */               printk(KERN_WARNING "(%s%d) unable to initialize controller - skipping controller\n",                      ips_name, ips_next_controller);               ha->active = 0;               ips_free(ha);               scsi_unregister(sh);               ips_ha[ips_next_controller] = 0;               ips_sh[ips_next_controller] = 0;               ips_next_controller++;               ips_num_controllers--;               continue;            }         }         /* install the interrupt handler */         if (request_irq(irq, do_ipsintr, SA_SHIRQ, ips_name, ha)) {            printk(KERN_WARNING "(%s%d) unable to install interrupt handler - skipping controller\n",                   ips_name, ips_next_controller);            ha->active = 0;            ips_free(ha);            scsi_unregister(sh);            ips_ha[ips_next_controller] = 0;            ips_sh[ips_next_controller] = 0;            ips_next_controller++;            ips_num_controllers--;            continue;         }         /*          * Allocate a temporary SCB for initialization          */         ha->scbs = (ips_scb_t *) kmalloc(sizeof(ips_scb_t), GFP_KERNEL);         if (!ha->scbs) {            /* couldn't allocate a temp SCB */            printk(KERN_WARNING "(%s%d) unable to allocate CCBs - skipping contoller\n",                   ips_name, ips_next_controller);            ha->active = 0;            ips_free(ha);            scsi_unregister(sh);            ips_ha[ips_next_controller] = 0;            ips_sh[ips_next_controller] = 0;            free_irq(ha->irq, ha);            ips_next_controller++;            ips_num_controllers--;            continue;         }         memset(ha->scbs, 0, sizeof(ips_scb_t));         ha->scbs->sg_list = (IPS_SG_LIST *) kmalloc(sizeof(IPS_SG_LIST) * IPS_MAX_SG, GFP_KERNEL);         if (!ha->scbs->sg_list) {            /* couldn't allocate a temp SCB S/G list */            printk(KERN_WARNING "(%s%d) unable to allocate CCBs - skipping contoller\n",                   ips_name, ips_next_controller);            ha->active = 0;            ips_free(ha);            scsi_unregister(sh);            ips_ha[ips_next_controller] = 0;            ips_sh[ips_next_controller] = 0;            free_irq(ha->irq, ha);            ips_next_controller++;            ips_num_controllers--;            continue;         }         ha->max_cmds = 1;         ips_next_controller++;      } while ((dev[i] = pci_find_device(IPS_VENDORID, deviceID[i], dev[i])));   }   /*    * Do Phase 2 Initialization    * Controller init    */   for (i = 0; i < ips_next_controller; i++) {      if (ips_ha[i] == 0) {         printk(KERN_WARNING "(%s%d) ignoring bad controller\n",                ips_name, i);         continue;      }      ha = ips_ha[i];      sh = ips_sh[i];      if (!ha->active) {         scsi_unregister(sh);         ips_ha[i] = NULL;         ips_sh[i] = NULL;         continue;      }      if (!ips_hainit(ha)) {         printk(KERN_WARNING "(%s%d) unable to initialize controller - skipping\n",                ips_name, i);         ha->active = 0;         ips_free(ha);         free_irq(ha->irq, ha);         scsi_unregister(sh);         ips_ha[i] = NULL;         ips_sh[i] = NULL;         ips_num_controllers--;         continue;      }      /*       * Free the temporary SCB       */      kfree(ha->scbs->sg_list);      kfree(ha->scbs);      ha->scbs = NULL;      /* allocate CCBs */      if (!ips_allocatescbs(ha)) {         printk(KERN_WARNING "(%s%d) unable to allocate CCBs - skipping contoller\n",                ips_name, i);         ha->active = 0;         ips_free(ha);         free_irq(ha->irq, ha);         scsi_unregister(sh);         ips_ha[i] = NULL;         ips_sh[i] = NULL;         ips_num_controllers--;         continue;      }      /* finish setting values */      sh->max_id = ha->ntargets;      sh->max_lun = ha->nlun;      sh->max_channel = ha->nbus - 1;      sh->can_queue = ha->max_cmds-1;   }   if (ips_num_controllers > 0)      register_reboot_notifier(&ips_notifier);   return (ips_num_controllers);#else   /* No PCI -- No ServeRAID */   return (0);#endif /* CONFIG_PCI */}/****************************************************************************//*                                                                          *//* Routine Name: ips_release                                                *//*                                                                          *//* Routine Description:                                                     *//*                                                                          *//*   Remove a driver                                                        *//*                                                                          *//****************************************************************************/intips_release(struct Scsi_Host *sh) {   ips_scb_t *scb;   ips_ha_t  *ha;   int        i;   METHOD_TRACE("ips_release", 1);   for (i = 0; i < IPS_MAX_ADAPTERS && ips_sh[i] != sh; i++);   if (i == IPS_MAX_ADAPTERS) {      printk(KERN_WARNING "(%s) release, invalid Scsi_Host pointer.\n",            ips_name);#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0)      BUG();#endif      return (FALSE);   }   ha = IPS_HA(sh);   if (!ha)      return (FALSE);   /* flush the cache on the controller */   scb = &ha->scbs[ha->max_cmds-1];   ips_init_scb(ha, scb);   scb->timeout = ips_cmd_timeout;   scb->cdb[0] = IPS_CMD_FLUSH;   scb->cmd.flush_cache.op_code = IPS_CMD_FLUSH;   scb->cmd.flush_cache.command_id = IPS_COMMAND_ID(ha, scb);   scb->cmd.flush_cache.state = IPS_NORM_STATE;   scb->cmd.flush_cache.reserved = 0;   scb->cmd.flush_cache.reserved2 = 0;   scb->cmd.flush_cache.reserved3 = 0;   scb->cmd.flush_cache.reserved4 = 0;   printk(KERN_NOTICE "(%s%d) Flushing Cache.\n", ips_name, ha->host_num);   /* send command */   if (ips_send_wait(ha, scb, ips_cmd_timeout, IPS_INTR_ON) == IPS_FAILURE)      printk(KERN_NOTICE "(%s%d) Incomplete Flush.\n", ips_name, ha->host_num);   printk(KERN_NOTICE "(%s%d) Flushing Complete.\n", ips_name, ha->host_num);   ips_sh[i] = NULL;   ips_ha[i] = NULL;   /* free extra memory */   ips_free(ha);   /* Free I/O Region */   if (ha->io_addr)      release_region(ha->io_addr, ha->io_len);   /* free IRQ */   free_irq(ha->irq, ha);   scsi_unregister(sh);   ips_released_controllers++;   if (ips_num_controllers == ips_released_controllers)      unregister_reboot_notifier(&ips_notifier);   return (FALSE);}/****************************************************************************//*                                                                          *//* Routine Name: ips_halt                                                   *//*                                                                          *//* Routine Description:                                                     *//*                                                                          *//*   Perform cleanup when the system reboots                                *//*                                                                          *//****************************************************************************/static intips_halt(struct notifier_block *nb, ulong event, void *buf) {   ips_scb_t *scb;   ips_ha_t  *ha;   int        i;   if ((event != SYS_RESTART) && (event != SYS_HALT) &&       (event != SYS_POWER_OFF))      return (NOTIFY_DONE);   for (i = 0; i < ips_next_controller; i++) {      ha = (ips_ha_t *) ips_ha[i];      if (!ha)         continue;      if (!ha->active)         continue;      /* flush the cache on the controller */      scb = &ha->scbs[ha->max_cmds-1];      ips_init_scb(ha, scb);      scb->timeout = ips_cmd_timeout;      scb->cdb[0] = IPS_CMD_FLUSH;      scb->cmd.flush_cache.op_code = IPS_CMD_FLUSH;      scb->cmd.flush_cache.command_id = IPS_COMMAND_ID(ha, scb);      scb->cmd.flush_cache.state = IPS_NORM_STATE;      scb->cmd.flush_cache.reserved = 0;      scb->cmd.flush_cache.reserved2 = 0;      scb->cmd.flush_cache.reserved3 = 0;      scb->cmd.flush_cache.reserved4 = 0;      printk(KERN_NOTICE "(%s%d) Flushing Cache.\n", ips_name, ha->host_num);      /* send command */      if (ips_send_wait(ha, scb, ips_cmd_timeout, IPS_INTR_ON) == IPS_FAILURE)         printk(KERN_NOTICE "(%s%d) Incomplete Flush.\n", ips_name, ha->host_num);      else         printk(KERN_NOTICE "(%s%d) Flushing Complete.\n", ips_name, ha->host_num);   }   return (NOTIFY_OK);}/****************************************************************************//*                                                                          *//* Routine Name: ips_eh_abort                                               *//*                                                                          *//* Routine Description:                                                     *//*                                                                          *//*   Abort a command (using the new error code stuff)                       *//*                                                                          *//****************************************************************************/intips_eh_abort(Scsi_Cmnd *SC) {   ips_ha_t         *ha;   ips_copp_wait_item_t *item;   METHOD_TRACE("ips_eh_abort", 1);   if (!SC)      return (FAILED);   ha = (ips_ha_t *) SC->host->hostdata;   if (!ha)      return (FAILED);   if (!ha->active)      return (FAILED);   if (SC->serial_number != SC->serial_number_at_timeout) {      /* HMM, looks like a bogus command */      DEBUG(1, "Abort called with bogus scsi command");      return (FAILED);   }   if (test_and_set_bit(IPS_IN_ABORT, &ha->flags))      return (FAILED);   /* See if the command is on the copp queue */   IPS_QUEUE_LOCK(&ha->copp_waitlist);   item = ha->copp_waitlist.head;   while ((item) && (item->scsi_cmd != SC))      item = item->next;   IPS_QUEUE_UNLOCK(&ha->copp_waitlist);   if (item) {      /* Found it */      ips_removeq_copp(&ha->copp_waitlist, item);      clear_bit(IPS_IN_ABORT, &ha->flags);      return (SUCCESS);

⌨️ 快捷键说明

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