亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sd.c

?? <Linux1.0核心游記>電子書+書后源碼+Linux1.0源碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* *	sd.c Copyright (C) 1992 Drew Eckhardt  *	Linux scsi disk driver by *		Drew Eckhardt  * *	<drew@colorado.edu> * *       Modified by Eric Youngdale eric@tantalus.nrl.navy.mil to *       add scatter-gather, multiple outstanding request, and other *       enhancements. */#include <linux/fs.h>#include <linux/kernel.h>#include <linux/sched.h>#include <linux/string.h>#include <linux/errno.h>#include <asm/system.h>#define MAJOR_NR SCSI_DISK_MAJOR#include "../block/blk.h"#include "scsi.h"#include "hosts.h"#include "sd.h"#include "scsi_ioctl.h"#include "constants.h"#include <linux/genhd.h>/*static const char RCSid[] = "$Header:";*/#define MAX_RETRIES 5/* *	Time out in seconds */#define SD_TIMEOUT 300struct hd_struct * sd;int NR_SD=0;int MAX_SD=0;Scsi_Disk * rscsi_disks;static int * sd_sizes;static int * sd_blocksizes;extern int sd_ioctl(struct inode *, struct file *, unsigned int, unsigned long);static sd_init_onedisk(int);static void requeue_sd_request (Scsi_Cmnd * SCpnt);static int sd_open(struct inode * inode, struct file * filp){        int target;	target =  DEVICE_NR(MINOR(inode->i_rdev));	if(target >= NR_SD || !rscsi_disks[target].device)	  return -ENODEV;   /* No such device */	/* Make sure that only one process can do a check_change_disk at one time. This is also used to lock out further access when the partition table is being re-read. */	while (rscsi_disks[target].device->busy);	if(rscsi_disks[target].device->removable) {	  check_disk_change(inode->i_rdev);	  if(!rscsi_disks[target].device->access_count)	    sd_ioctl(inode, NULL, SCSI_IOCTL_DOORLOCK, 0);	};	rscsi_disks[target].device->access_count++;	return 0;}static void sd_release(struct inode * inode, struct file * file){        int target;	sync_dev(inode->i_rdev);	target =  DEVICE_NR(MINOR(inode->i_rdev));	rscsi_disks[target].device->access_count--;	if(rscsi_disks[target].device->removable) {	  if(!rscsi_disks[target].device->access_count)	    sd_ioctl(inode, NULL, SCSI_IOCTL_DOORUNLOCK, 0);	};}static void sd_geninit(void);static struct file_operations sd_fops = {	NULL,			/* lseek - default */	block_read,		/* read - general block-dev read */	block_write,		/* write - general block-dev write */	NULL,			/* readdir - bad */	NULL,			/* select */	sd_ioctl,		/* ioctl */	NULL,			/* mmap */	sd_open,		/* open code */	sd_release,		/* release */	block_fsync		/* fsync */};static struct gendisk sd_gendisk = {	MAJOR_NR,		/* Major number */	"sd",		/* Major name */	4,		/* Bits to shift to get real from partition */	1 << 4,		/* Number of partitions per real */	0,		/* maximum number of real */	sd_geninit,	/* init function */	NULL,		/* hd struct */	NULL,	/* block sizes */	0,		/* number */	NULL,	/* internal */	NULL		/* next */};static void sd_geninit (void){	int i;	for (i = 0; i < NR_SD; ++i)		sd[i << 4].nr_sects = rscsi_disks[i].capacity;	sd_gendisk.nr_real = NR_SD;}/*	rw_intr is the interrupt routine for the device driver.  It will	be notified on the end of a SCSI read / write, and	will take on of several actions based on success or failure.*/static void rw_intr (Scsi_Cmnd *SCpnt){  int result = SCpnt->result;  int this_count = SCpnt->bufflen >> 9;#ifdef DEBUG  printk("sd%d : rw_intr(%d, %d)\n", MINOR(SCpnt->request.dev), SCpnt->host->host_no, result);#endif/*  First case : we assume that the command succeeded.  One of two things will  happen here.  Either we will be finished, or there will be more  sectors that we were unable to read last time.*/  if (!result) {#ifdef DEBUG    printk("sd%d : %d sectors remain.\n", MINOR(SCpnt->request.dev), SCpnt->request.nr_sectors);    printk("use_sg is %d\n ",SCpnt->use_sg);#endif    if (SCpnt->use_sg) {      struct scatterlist * sgpnt;      int i;      sgpnt = (struct scatterlist *) SCpnt->buffer;      for(i=0; i<SCpnt->use_sg; i++) {#ifdef DEBUG	printk(":%x %x %d\n",sgpnt[i].alt_address, sgpnt[i].address, sgpnt[i].length);#endif	if (sgpnt[i].alt_address) {	  if (SCpnt->request.cmd == READ)	    memcpy(sgpnt[i].alt_address, sgpnt[i].address, sgpnt[i].length);	  scsi_free(sgpnt[i].address, sgpnt[i].length);	};      };      scsi_free(SCpnt->buffer, SCpnt->sglist_len);  /* Free list of scatter-gather pointers */    } else {      if (SCpnt->buffer != SCpnt->request.buffer) {#ifdef DEBUG	printk("nosg: %x %x %d\n",SCpnt->request.buffer, SCpnt->buffer,		   SCpnt->bufflen);#endif		  if (SCpnt->request.cmd == READ)	    memcpy(SCpnt->request.buffer, SCpnt->buffer,		   SCpnt->bufflen);	  scsi_free(SCpnt->buffer, SCpnt->bufflen);      };    };/* * 	If multiple sectors are requested in one buffer, then *	they will have been finished off by the first command.  If *	not, then we have a multi-buffer command. */    if (SCpnt->request.nr_sectors > this_count)      {	SCpnt->request.errors = 0;		if (!SCpnt->request.bh)	  {#ifdef DEBUG	    printk("sd%d : handling page request, no buffer\n",		   MINOR(SCpnt->request.dev));#endif/*  The SCpnt->request.nr_sectors field is always done in 512 byte sectors,  even if this really isn't the case.*/	    panic("sd.c: linked page request (%lx %x)",		  SCpnt->request.sector, this_count);	  }      }    end_scsi_request(SCpnt, 1, this_count);    requeue_sd_request(SCpnt);    return;  }/* Free up any indirection buffers we allocated for DMA purposes. */    if (SCpnt->use_sg) {      struct scatterlist * sgpnt;      int i;      sgpnt = (struct scatterlist *) SCpnt->buffer;      for(i=0; i<SCpnt->use_sg; i++) {#ifdef DEBUG	printk("err: %x %x %d\n",SCpnt->request.buffer, SCpnt->buffer,		   SCpnt->bufflen);#endif	if (sgpnt[i].alt_address) {	  scsi_free(sgpnt[i].address, sgpnt[i].length);	};      };      scsi_free(SCpnt->buffer, SCpnt->sglist_len);  /* Free list of scatter-gather pointers */    } else {#ifdef DEBUG      printk("nosgerr: %x %x %d\n",SCpnt->request.buffer, SCpnt->buffer,		   SCpnt->bufflen);#endif      if (SCpnt->buffer != SCpnt->request.buffer)	scsi_free(SCpnt->buffer, SCpnt->bufflen);    };/*	Now, if we were good little boys and girls, Santa left us a request	sense buffer.  We can extract information from this, so we	can choose a block to remap, etc.*/        if (driver_byte(result) != 0) {	  if (sugestion(result) == SUGGEST_REMAP) {#ifdef REMAP/*	Not yet implemented.  A read will fail after being remapped,	a write will call the strategy routine again.*/	    if rscsi_disks[DEVICE_NR(SCpnt->request.dev)].remap	      {		result = 0;	      }	    else	      #endif	    }	  if ((SCpnt->sense_buffer[0] & 0x7f) == 0x70) {	    if ((SCpnt->sense_buffer[2] & 0xf) == UNIT_ATTENTION) {	      if(rscsi_disks[DEVICE_NR(SCpnt->request.dev)].device->removable) {	      /* detected disc change.  set a bit and quietly refuse	*/	      /* further access.					*/	      		rscsi_disks[DEVICE_NR(SCpnt->request.dev)].device->changed = 1;		end_scsi_request(SCpnt, 0, this_count);		requeue_sd_request(SCpnt);		return;	      }	    }	  }	  /* 	If we had an ILLEGAL REQUEST returned, then we may haveperformed an unsupported command.  The only thing this should be wouldbe a ten byte read where only a six byte read was supportted.  Also,on a system where READ CAPACITY failed, we mave have read past the endof the 	disk. */	  if (SCpnt->sense_buffer[2] == ILLEGAL_REQUEST) {	    if (rscsi_disks[DEVICE_NR(SCpnt->request.dev)].ten) {	      rscsi_disks[DEVICE_NR(SCpnt->request.dev)].ten = 0;	      requeue_sd_request(SCpnt);	      result = 0;	    } else {	    }	  }	}  /* driver byte != 0 */	if (result) {		printk("SCSI disk error : host %d id %d lun %d return code = %x\n",		       rscsi_disks[DEVICE_NR(SCpnt->request.dev)].device->host->host_no,		       rscsi_disks[DEVICE_NR(SCpnt->request.dev)].device->id,		       rscsi_disks[DEVICE_NR(SCpnt->request.dev)].device->lun, result);		if (driver_byte(result) & DRIVER_SENSE)			print_sense("sd", SCpnt);		end_scsi_request(SCpnt, 0, SCpnt->request.current_nr_sectors);		requeue_sd_request(SCpnt);		return;	}}/*	requeue_sd_request() is the request handler function for the sd driver.	Its function in life is to take block device requests, and translate	them to SCSI commands.*/static void do_sd_request (void){  Scsi_Cmnd * SCpnt = NULL;  struct request * req = NULL;  int flag = 0;  while (1==1){    cli();    if (CURRENT != NULL && CURRENT->dev == -1) {      sti();      return;    };    INIT_SCSI_REQUEST;/* We have to be careful here.  allocate_device will get a free pointer, but   there is no guarantee that it is queueable.  In normal usage, we want to   call this, because other types of devices may have the host all tied up,   and we want to make sure that we have at least one request pending for this   type of device.   We can also come through here while servicing an   interrupt, because of the need to start another command.  If we call   allocate_device more than once, then the system can wedge if the command   is not queueable.  The request_queueable function is safe because it checks   to make sure that the host is able to take another command before it returns   a pointer.  */    if (flag++ == 0)      SCpnt = allocate_device(&CURRENT,			      rscsi_disks[DEVICE_NR(MINOR(CURRENT->dev))].device->index, 0);     else SCpnt = NULL;    sti();/* This is a performance enhancement.  We dig down into the request list and   try and find a queueable request (i.e. device not busy, and host able to   accept another command.  If we find one, then we queue it. This can   make a big difference on systems with more than one disk drive.  We want   to have the interrupts off when monkeying with the request list, because   otherwise the kernel might try and slip in a request inbetween somewhere. */    if (!SCpnt && NR_SD > 1){      struct request *req1;      req1 = NULL;      cli();      req = CURRENT;      while(req){	SCpnt = request_queueable(req,				  rscsi_disks[DEVICE_NR(MINOR(req->dev))].device->index);	if(SCpnt) break;	req1 = req;	req = req->next;      };      if (SCpnt && req->dev == -1) {	if (req == CURRENT) 	  CURRENT = CURRENT->next;	else	  req1->next = req->next;      };      sti();    };        if (!SCpnt) return; /* Could not find anything to do */        wake_up(&wait_for_request);        /* Queue command */    requeue_sd_request(SCpnt);  };  /* While */}    static void requeue_sd_request (Scsi_Cmnd * SCpnt){	int dev, block, this_count;	unsigned char cmd[10];	char * buff;repeat:	if(SCpnt->request.dev <= 0) {	  do_sd_request();	  return;	}	dev =  MINOR(SCpnt->request.dev);	block = SCpnt->request.sector;	this_count = 0;#ifdef DEBUG	printk("Doing sd request, dev = %d, block = %d\n", dev, block);#endif	if (dev >= (NR_SD << 4) || block + SCpnt->request.nr_sectors > sd[dev].nr_sects)		{		end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors);		goto repeat;		}	block += sd[dev].start_sect;	dev = DEVICE_NR(dev);	if (rscsi_disks[dev].device->changed)	        {/* * quietly refuse to do anything to a changed disc until the changed bit has been reset */		/* printk("SCSI disk has been changed.  Prohibiting further I/O.\n");	*/		end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors);		goto repeat;		}#ifdef DEBUG	printk("sd%d : real dev = /dev/sd%d, block = %d\n", MINOR(SCpnt->request.dev), dev, block);#endif	switch (SCpnt->request.cmd)		{		case WRITE :			if (!rscsi_disks[dev].device->writeable)				{				end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors);				goto repeat;				}			cmd[0] = WRITE_6;			break;		case READ :			cmd[0] = READ_6;			break;		default :			panic ("Unknown sd command %d\n", SCpnt->request.cmd);		      }	SCpnt->this_count = 0;	if (!SCpnt->request.bh || 	    (SCpnt->request.nr_sectors == SCpnt->request.current_nr_sectors)) {	  /* case of page request (i.e. raw device), or unlinked buffer */	  this_count = SCpnt->request.nr_sectors;	  buff = SCpnt->request.buffer;	  SCpnt->use_sg = 0;	} else if (SCpnt->host->sg_tablesize == 0 ||		   (need_isa_buffer && 		    dma_free_sectors < 10)) {	  /* Case of host adapter that cannot scatter-gather.  We also	   come here if we are running low on DMA buffer memory.  We set	   a threshold higher than that we would need for this request so	   we leave room for other requests.  Even though we would not need	   it all, we need to be conservative, because if we run low enough	   we have no choice but to panic. */	  if (SCpnt->host->sg_tablesize != 0 &&	      need_isa_buffer && 	      dma_free_sectors < 10)	    printk("Warning: SCSI DMA buffer space running low.  Using non scatter-gather I/O.\n");	  this_count = SCpnt->request.current_nr_sectors;	  buff = SCpnt->request.buffer;	  SCpnt->use_sg = 0;	} else {	  /* Scatter-gather capable host adapter */	  struct buffer_head * bh;	  struct scatterlist * sgpnt;	  int count, this_count_max;	  bh = SCpnt->request.bh;	  this_count = 0;	  this_count_max = (rscsi_disks[dev].ten ? 0xffff : 0xff);	  count = 0;	  while(bh && count < SCpnt->host->sg_tablesize) {	    if ((this_count + (bh->b_size >> 9)) > this_count_max) break;	    this_count += (bh->b_size >> 9);	    count++;	    bh = bh->b_reqnext;	  };

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91丨九色丨蝌蚪富婆spa| 国产一区 二区| 在线观看日韩av先锋影音电影院| 国产精品久久久久久妇女6080| 成人18视频在线播放| 亚洲视频免费在线观看| 91蜜桃在线免费视频| 亚洲国产综合人成综合网站| 91精品国产免费| 国产成人午夜电影网| 亚洲免费看黄网站| 欧美精品日日鲁夜夜添| 国内精品写真在线观看| 中文字幕欧美区| 欧美性色综合网| 精品一区二区久久| 中文字幕一区二区三区不卡 | 久久久www成人免费毛片麻豆| 高清成人免费视频| 亚洲一二三四区| 91精品免费在线观看| 国产成人在线观看| 五月开心婷婷久久| 欧美激情中文字幕一区二区| 欧美视频三区在线播放| 国内成+人亚洲+欧美+综合在线 | 久久久久国产免费免费| 一本色道久久综合狠狠躁的推荐| 免费人成网站在线观看欧美高清| 久久品道一品道久久精品| 91在线视频官网| 秋霞国产午夜精品免费视频| 国产精品久久久久一区二区三区共| 欧美色视频在线| 国产69精品久久久久777| 蜜桃视频第一区免费观看| 久久伊人蜜桃av一区二区| 91福利区一区二区三区| 国产在线精品一区二区不卡了| 中文字幕中文字幕一区| 日韩美女天天操| 91亚洲精品乱码久久久久久蜜桃 | 日本精品一级二级| 国产成人免费9x9x人网站视频| 亚洲丰满少妇videoshd| 国产精品免费观看视频| 日韩亚洲欧美中文三级| 91麻豆产精品久久久久久| 激情文学综合丁香| 免费在线观看一区| 一个色综合网站| 国产午夜精品一区二区三区嫩草| 欧美一区二区三区四区高清| 在线国产亚洲欧美| 一本色道综合亚洲| 波多野结衣精品在线| 国产一区二区成人久久免费影院| 日韩av电影免费观看高清完整版在线观看 | 色婷婷综合视频在线观看| 国产在线国偷精品产拍免费yy| 性久久久久久久久久久久 | 亚洲人成亚洲人成在线观看图片| 久久久精品影视| 最新欧美精品一区二区三区| 精品国产乱码久久久久久闺蜜| 欧美性高清videossexo| 色噜噜狠狠一区二区三区果冻| 成人高清av在线| 成人av在线一区二区| 国产精品1区2区3区在线观看| 久久97超碰色| 亚洲成人av一区二区三区| 樱桃国产成人精品视频| 一区二区三区中文在线| 一区二区三区中文在线| 亚洲自拍偷拍图区| 亚洲成a人片综合在线| 亚洲一区av在线| 日韩成人伦理电影在线观看| 日韩avvvv在线播放| 蜜乳av一区二区三区| 久久国产夜色精品鲁鲁99| 国产自产2019最新不卡| 亚洲综合在线视频| 五月天亚洲精品| 日本一区中文字幕| 捆绑调教一区二区三区| 精品亚洲porn| 国产成人av在线影院| 99综合电影在线视频| 日本高清不卡在线观看| 欧美军同video69gay| 日韩一级免费一区| 久久久777精品电影网影网 | 一区二区三区欧美日韩| 亚洲图片欧美色图| 麻豆视频观看网址久久| 国产成人av电影在线播放| 色哟哟欧美精品| 在线综合视频播放| 国产视频视频一区| 亚洲欧美日本韩国| 免费高清视频精品| 大胆亚洲人体视频| 欧美日韩国产影片| 精品免费日韩av| 亚洲三级电影全部在线观看高清| 午夜精品久久久| 东方aⅴ免费观看久久av| 91在线码无精品| 欧美电影免费提供在线观看| 国产欧美精品区一区二区三区 | www.成人网.com| 欧美人狂配大交3d怪物一区| 久久久亚洲精品石原莉奈| 综合自拍亚洲综合图不卡区| 奇米影视7777精品一区二区| 国产精品一卡二卡在线观看| 91蝌蚪porny| 久久久精品2019中文字幕之3| 尤物在线观看一区| 国产精品一二三四区| 在线这里只有精品| 久久久亚洲精品一区二区三区| 一区二区三区免费看视频| 国产一区二区三区黄视频 | 欧美性生活久久| 久久久精品国产免费观看同学| 亚洲午夜电影网| 成人一区二区视频| 日韩免费电影一区| 亚洲一级二级三级在线免费观看| 韩国av一区二区三区| 欧美调教femdomvk| 最近日韩中文字幕| 国产精品亚洲人在线观看| 91麻豆精品91久久久久久清纯| 中文字幕一区二区三区四区不卡 | 国产综合成人久久大片91| 欧美三级欧美一级| 成人免费小视频| 成人免费视频一区| 精品国产伦一区二区三区观看体验 | 国产传媒欧美日韩成人| 51精品视频一区二区三区| 亚洲色图视频网| 成人av在线播放网站| 久久蜜臀中文字幕| 久久精品国产亚洲高清剧情介绍| 欧美视频一二三区| 一区二区欧美国产| 日本精品视频一区二区三区| 国产精品久久久久久久午夜片| 国产乱国产乱300精品| 日韩欧美色电影| 人人精品人人爱| 3d成人动漫网站| 午夜久久久久久电影| 欧美日韩另类一区| 亚洲综合久久久| 欧美日韩一本到| 亚洲成人你懂的| 91麻豆精品国产91久久久资源速度 | 6080国产精品一区二区| 亚洲图片有声小说| 在线观看免费视频综合| 亚洲第一久久影院| 欧美群妇大交群的观看方式| 日本91福利区| 26uuu国产电影一区二区| 国产成人在线色| 日韩一区在线免费观看| 91高清视频在线| 午夜精品久久久久影视| 91精品国产高清一区二区三区| 日韩精品久久理论片| 欧美成人vps| 国产高清在线观看免费不卡| 国产精品久久久久久久久免费桃花| 不卡的av电影| 一区二区三区四区视频精品免费| 日本精品视频一区二区| 视频一区视频二区中文| 欧美成人video| 国产成人免费在线视频| 国产精品女同互慰在线看| 激情综合网av| 国产精品少妇自拍| proumb性欧美在线观看| 亚洲精品老司机| 3d动漫精品啪啪1区2区免费 | 中文字幕在线一区二区三区| 色婷婷精品久久二区二区蜜臀av | 欧美日韩成人一区二区| 亚洲成人午夜影院| 精品久久久久久久一区二区蜜臀| 国产精品一二三区在线| 国产精品久久777777| 欧美电影影音先锋| 国产在线精品一区在线观看麻豆|