Scsi - Index of
Scsi - Index of Scsi - Index of
195 * pick up from where this one left off. */ 196 197 unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, 198 unsigned int buflen, struct scsi_cmnd *srb, unsigned int *index, 199 unsigned int *offset, enum xfer_buf_dir dir) 200 { 201 unsigned int cnt; 202 203 /* If not using scatter-gather, just transfer the data directly. 204 * Make certain it will fit in the available buffer space. */ 205 if (srb->use_sg == 0) { 206 if (*offset >= srb->request_bufflen) 207 return 0; 208 cnt = min(buflen, srb->request_bufflen - *offset); 209 if (dir == TO_XFER_BUF) 210 memcpy((unsigned char *) srb->request_buffer + *offset, 211 buffer, cnt); 212 else 213 memcpy(buffer, (unsigned char *) srb->request_buffer + 214 *offset, cnt); 215 *offset += cnt; 216 217 /* Using scatter-gather. We have to go through the list one entry 218 * at a time. Each s-g entry contains some number of pages, and 219 * each page has to be kmap()'ed separately. If the page is already 220 * in kernel-addressable memory then kmap() will return its address. 221 * If the page is not directly accessible -- such as a user buffer 222 * located in high memory -- then kmap() will map it to a temporary 223 * position in the kernel's virtual address space. */ 224 } else { 225 struct scatterlist *sg = 226 (struct scatterlist *) srb->request_buffer 227 + *index; 228 229 /* This loop handles a single s-g list entry, which may 230 * include multiple pages. Find the initial page structure 133 231 * and the starting offset within the page, and update 232 * the *offset and *index values for the next loop. */ 233 cnt = 0; 234 while (cnt < buflen && *index < srb->use_sg) { 235 struct page *page = sg->page + 236 ((sg->offset + *offset) >> PAGE_SHIFT); 237 unsigned int poff =
238 (sg->offset + *offset) & (PAGE_SIZE-1); 239 unsigned int sglen = sg->length - *offset; 240 241 if (sglen > buflen - cnt) { 242 243 /* Transfer ends within this s-g entry */ 244 sglen = buflen - cnt; 245 *offset += sglen; 246 } else { 247 248 /* Transfer continues to next s-g entry */ 249 *offset = 0; 250 ++*index; 251 ++sg; 252 } 253 254 /* Transfer the data for all the pages in this 255 * s-g entry. For each page: call kmap(), do the 256 * transfer, and call kunmap() immediately after. */ 257 while (sglen > 0) { 258 unsigned int plen = min(sglen, (unsigned int) 259 PAGE_SIZE - poff); 260 unsigned char *ptr = kmap(page); 261 262 if (dir == TO_XFER_BUF) 263 memcpy(ptr + poff, buffer + cnt, plen); 264 else 265 memcpy(buffer + cnt, ptr + poff, plen); 266 kunmap(page); 267 268 /* Start at the beginning of the next page */ 269 poff = 0; 270 ++page; 271 cnt += plen; 272 sglen -= plen; 273 } 274 } 134 275 } 276 277 /* Return the amount actually transferred */ 278 return cnt; 279 } 风,总是在最温柔的时候醉人;
- Page 83 and 84: 25 { 26 x->done = 0; 27 init_waitqu
- Page 85 and 86: 都会过期,我开始怀疑,在这
- Page 87 and 88: 是实际长度,要么就是不成
- Page 89 and 90: 87 258 行,usb_pipeendpoint,定义
- Page 91 and 92: 对爱你的人掘了一条无法
- Page 93 and 94: Type: Direct-Access ANSI SCSI revis
- Page 95 and 96: 416 /* 417 * this defines our host
- Page 97 and 98: 69 * Ioctl interface 70 * 71 * Stat
- Page 99 and 100: 155 * "is this a new device" checks
- Page 101 and 102: 241 char *proc_name; 242 243 /* 244
- Page 103 and 104: 328 * True if the low-level driver
- Page 105 and 106: 可以看到这个函数的参数
- Page 107 and 108: 451 short unsigned int max_sectors;
- Page 109 and 110: 地 说明了为啥咱们要显式
- Page 111 and 112: usb_stor_acquire_resources()函数
- Page 113 and 114: 341 } 342 343 /* reject if target !
- Page 115 and 116: 内核的核心位置,kernel/exit.c
- Page 117 and 118: 1023 dissociate_dev(us); 1024 retur
- Page 119 and 120: 917 行,再次判断设备有没有
- Page 121 and 122: 181 182 /* fail the command if we a
- Page 123 and 124: 83 struct timer_list eh_timeout; /*
- Page 125 and 126: 123 两个scsi_done,一个是struct
- Page 127 and 128: 56 jiffie count on our counter, the
- Page 129 and 130: 中 看到如下的定义: UNUSUAL_
- Page 131 and 132: 269 memcpy(data+16, us->unusual_dev
- Page 133: 一切准备好了之后,我们就
- Page 137 and 138: 所以对于那些不能相应INQUI
- Page 139 and 140: 239 行对unsigned int sglen 赋值
- Page 141 and 142: 请求,所以这里就判断abort
- Page 143 and 144: 112 case GPCMD_READ_HEADER: what =
- Page 145 and 146: 到北京,每每只有在夜深人
- Page 147 and 148: 580 /* 581 * If we have a failure,
- Page 149 and 150: 666 memcpy(srb->cmnd, old_cmnd, MAX
- Page 151 and 152: 950 struct bulk_cb_wrap *bcb = (str
- Page 153 and 154: 1034 /* get the status again */ 103
- Page 155 and 156: 426 /* store the actual length of t
- Page 157 and 158: 后她会给host 返回一个CSW.CB
- Page 159 and 160: 296 } 297 298 US_DEBUGP("-- transfe
- Page 161 and 162: 491 * scatter-gather or not, and ac
- Page 163 and 164: 迷雾重重的 Bulk 传输(五) us
- Page 165 and 166: 然后把她赋给了result.而us->
- Page 167 and 168: 而bcs->Status,标志命令执行
- Page 169 and 170: 就必须设置US_FL_IGNORE_RESIDUE
- Page 171 and 172: 485 }; 486 这是一个字符数组
- Page 173 and 174: srb->sense_buffer 里边的东西.S
- Page 175 and 176: 一个类似的函数,名叫usb_sto
- Page 177 and 178: 这种命令应该由mid level 来
- Page 179 and 180: Disk /dev/sda: 146.1 GB, 1461631057
- Page 181 and 182: through to the most significant bit
- Page 183 and 184: 1192 USB_TYPE_CLASS | USB_RECIP_INT
238 (sg-><strong>of</strong>fset + *<strong>of</strong>fset) & (PAGE_SIZE-1);<br />
239 unsigned int sglen = sg->length - *<strong>of</strong>fset;<br />
240<br />
241 if (sglen > buflen - cnt) {<br />
242<br />
243 /* Transfer ends within this s-g entry */<br />
244 sglen = buflen - cnt;<br />
245 *<strong>of</strong>fset += sglen;<br />
246 } else {<br />
247<br />
248 /* Transfer continues to next s-g entry */<br />
249 *<strong>of</strong>fset = 0;<br />
250 ++*index;<br />
251 ++sg;<br />
252 }<br />
253<br />
254 /* Transfer the data for all the pages in this<br />
255 * s-g entry. For each page: call kmap(), do the<br />
256 * transfer, and call kunmap() immediately after. */<br />
257 while (sglen > 0) {<br />
258 unsigned int plen = min(sglen, (unsigned int)<br />
259 PAGE_SIZE - p<strong>of</strong>f);<br />
260 unsigned char *ptr = kmap(page);<br />
261<br />
262 if (dir == TO_XFER_BUF)<br />
263 memcpy(ptr + p<strong>of</strong>f, buffer + cnt, plen);<br />
264 else<br />
265 memcpy(buffer + cnt, ptr + p<strong>of</strong>f, plen);<br />
266 kunmap(page);<br />
267<br />
268 /* Start at the beginning <strong>of</strong> the next page */<br />
269 p<strong>of</strong>f = 0;<br />
270 ++page;<br />
271 cnt += plen;<br />
272 sglen -= plen;<br />
273 }<br />
274 }<br />
134<br />
275 }<br />
276<br />
277 /* Return the amount actually transferred */<br />
278 return cnt;<br />
279 }<br />
风,总是在最温柔的时候醉人;