1/* $FreeBSD: head/sys/dev/iir/iir.c 114001 2003-04-25 05:37:04Z scottl $ */ |
2/* |
3 * Copyright (c) 2000-03 Intel Corporation |
4 * All Rights Reserved 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions, and the following disclaimer, 11 * without modification, immediately at the beginning of the file. --- 24 unchanged lines hidden (view full) --- 36 * 37 * credits: Niklas Hallqvist; OpenBSD driver for the ICP Controllers. 38 * Mike Smith; Some driver source code. 39 * FreeBSD.ORG; Great O/S to work on and for. 40 * 41 * TODO: 42 */ 43 |
44#ident "$Id: iir.c 1.3 2003/03/21 16:28:32 achim Exp $" |
45 46#define _IIR_C_ 47 48/* #include "opt_iir.h" */ 49#include <sys/param.h> 50#include <sys/systm.h> 51#include <sys/endian.h> 52#include <sys/eventhandler.h> --- 148 unchanged lines hidden (view full) --- 201 SLIST_INIT(&gdt->sc_free_gccb); 202 SLIST_INIT(&gdt->sc_pending_gccb); 203 TAILQ_INIT(&gdt->sc_ccb_queue); 204 TAILQ_INIT(&gdt->sc_ucmd_queue); 205 TAILQ_INSERT_TAIL(&gdt_softcs, gdt, links); 206 207 /* DMA tag for mapping buffers into device visible space. */ 208 if (bus_dma_tag_create(gdt->sc_parent_dmat, /*alignment*/1, /*boundary*/0, |
209 /*lowaddr*/BUS_SPACE_MAXADDR_32BIT, |
210 /*highaddr*/BUS_SPACE_MAXADDR, 211 /*filter*/NULL, /*filterarg*/NULL, 212 /*maxsize*/MAXBSIZE, /*nsegments*/GDT_MAXSG, 213 /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT, 214 /*flags*/BUS_DMA_ALLOCNOW, 215 &gdt->sc_buffer_dmat) != 0) { 216 printf("iir%d: bus_dma_tag_create(...,gdt->sc_buffer_dmat) failed\n", 217 gdt->sc_hanum); 218 return (1); 219 } 220 gdt->sc_init_level++; 221 222 /* DMA tag for our ccb structures */ |
223 if (bus_dma_tag_create(gdt->sc_parent_dmat, 224 /*alignment*/1, 225 /*boundary*/0, 226 /*lowaddr*/BUS_SPACE_MAXADDR_32BIT, |
227 /*highaddr*/BUS_SPACE_MAXADDR, |
228 /*filter*/NULL, 229 /*filterarg*/NULL, 230 GDT_MAXCMDS * sizeof(struct gdt_ccb), /* maxsize */ |
231 /*nsegments*/1, 232 /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT, 233 /*flags*/0, &gdt->sc_gccb_dmat) != 0) { 234 printf("iir%d: bus_dma_tag_create(...,gdt->sc_gccb_dmat) failed\n", 235 gdt->sc_hanum); 236 return (1); 237 } 238 gdt->sc_init_level++; --- 152 unchanged lines hidden (view full) --- 391 panic("iir%d: Scatter/Gather Cache Service " 392 "required but not supported!\n", gdt->sc_hanum); 393 gdt_free_ccb(gdt, gccb); 394 return (1); 395 } 396 } 397 } 398 |
399 /* OEM */ 400 gdt_enc32(gccb->gc_scratch + GDT_OEM_VERSION, 0x01); 401 gdt_enc32(gccb->gc_scratch + GDT_OEM_BUFSIZE, sizeof(gdt_oem_record_t)); 402 if (gdt_internal_cmd(gdt, gccb, GDT_CACHESERVICE, GDT_IOCTL, 403 GDT_OEM_STR_RECORD, GDT_INVALID_CHANNEL, 404 sizeof(gdt_oem_str_record_t))) { 405 strncpy(gdt->oem_name, ((gdt_oem_str_record_t *) 406 gccb->gc_scratch)->text.scsi_host_drive_inquiry_vendor_id, 7); 407 gdt->oem_name[7]='\0'; 408 } else { 409 /* Old method, based on PCI ID */ 410 if (gdt->sc_vendor == INTEL_VENDOR_ID) 411 strcpy(gdt->oem_name,"Intel "); 412 else 413 strcpy(gdt->oem_name,"ICP "); 414 } 415 |
416 /* Scan for cache devices */ 417 for (i = 0; i < cdev_cnt && i < GDT_MAX_HDRIVES; i++) { 418 if (gdt_internal_cmd(gdt, gccb, GDT_CACHESERVICE, GDT_INFO, 419 i, 0, 0)) { 420 gdt->sc_hdr[i].hd_present = 1; 421 gdt->sc_hdr[i].hd_size = gdt->sc_info; 422 423 /* --- 339 unchanged lines hidden (view full) --- 763 sim_links.tqe); 764 ++gdt_stat.req_queue_act; 765 if (gdt_stat.req_queue_act > gdt_stat.req_queue_max) 766 gdt_stat.req_queue_max = gdt_stat.req_queue_act; 767 next_cmd = FALSE; 768 } 769 } else if (target >= GDT_MAX_HDRIVES || 770 !gdt->sc_hdr[target].hd_present || lun != 0) { |
771 ccbh->status = CAM_DEV_NOT_THERE; |
772 --gdt_stat.io_count_act; 773 xpt_done(ccb); 774 } else { 775 /* cache service command */ 776 if (cmd == READ_6 || cmd == WRITE_6 || 777 cmd == READ_10 || cmd == WRITE_10) { 778 if ((gccb = gdt_cache_cmd(gdt, ccb, &lock)) == NULL) { 779 TAILQ_INSERT_HEAD(&gdt->sc_ccb_queue, &ccb->ccb_h, --- 415 unchanged lines hidden (view full) --- 1195 bzero(inq, sizeof(struct scsi_inquiry_data)); 1196 inq->device = (gdt->sc_hdr[t].hd_devtype & 4) ? 1197 T_CDROM : T_DIRECT; 1198 inq->dev_qual2 = (gdt->sc_hdr[t].hd_devtype & 1) ? 0x80 : 0; 1199 inq->version = SCSI_REV_2; 1200 inq->response_format = 2; 1201 inq->additional_length = 32; 1202 inq->flags = SID_CmdQue | SID_Sync; |
1203 strcpy(inq->vendor, gdt->oem_name); |
1204 sprintf(inq->product, "Host Drive #%02d", t); 1205 strcpy(inq->revision, " "); 1206 break; 1207 } 1208 case MODE_SENSE_6: 1209 { 1210 struct mpd_data { 1211 struct scsi_mode_hdr_6 hd; --- 97 unchanged lines hidden (view full) --- 1309 gdt_enc32(gdt->sc_cmd + GDT_CMD_UNION + GDT_RAW_SDATA, 1310 0xffffffffUL); 1311 1312 gdt->sc_cmd_len = roundup(GDT_CMD_UNION + GDT_RAW_SG_LST + 1313 nseg * GDT_SG_SZ, sizeof(u_int32_t)); 1314 } 1315 1316 if (nseg != 0) { |
1317 bus_dmamap_sync(gdt->sc_buffer_dmat, gccb->gc_dmamap, 1318 (ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN ? 1319 BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE); |
1320 } 1321 1322 /* We must NOT abort the command here if CAM_REQ_INPROG is not set, 1323 * because command semaphore is already set! 1324 */ 1325 1326 ccb->ccb_h.status |= CAM_SIM_QUEUED; 1327 /* timeout handling */ --- 365 unchanged lines hidden (view full) --- 1693 gdt_sync_event(gdt, ctx.service, ctx.istatus, gccb); 1694 if (!(gdt->sc_state & GDT_POLLING)) 1695 splx(lock); 1696 gdt_next(gdt); 1697 break; 1698 } 1699} 1700 |
1701int |
1702gdt_async_event(struct gdt_softc *gdt, int service) 1703{ 1704 struct gdt_ccb *gccb; 1705 1706 GDT_DPRINTF(GDT_D_INTR, ("gdt_async_event(%p, %d)\n", gdt, service)); 1707 1708 if (service == GDT_SCREENSERVICE) { 1709 if (gdt->sc_status == GDT_MSG_REQUEST) { --- 43 unchanged lines hidden (view full) --- 1753 } 1754 gdt_store_event(GDT_ES_ASYNC, service, &gdt->sc_dvr); 1755 printf("iir%d: %s\n", gdt->sc_hanum, gdt->sc_dvr.event_string); 1756 } 1757 1758 return (0); 1759} 1760 |
1761int |
1762gdt_sync_event(struct gdt_softc *gdt, int service, 1763 u_int8_t index, struct gdt_ccb *gccb) 1764{ 1765 union ccb *ccb; |
1766 1767 GDT_DPRINTF(GDT_D_INTR, 1768 ("gdt_sync_event(%p, %d, %d, %p)\n", gdt,service,index,gccb)); 1769 1770 ccb = gccb->gc_ccb; 1771 1772 if (service == GDT_SCREENSERVICE) { 1773 u_int32_t msg_len; --- 90 unchanged lines hidden (view full) --- 1864 gdt, gccb)); 1865 TAILQ_INSERT_HEAD(&gdt->sc_ccb_queue, &ccb->ccb_h, sim_links.tqe); 1866 ++gdt_stat.req_queue_act; 1867 if (gdt_stat.req_queue_act > gdt_stat.req_queue_max) 1868 gdt_stat.req_queue_max = gdt_stat.req_queue_act; 1869 return (2); 1870 } 1871 |
1872 bus_dmamap_sync(gdt->sc_buffer_dmat, gccb->gc_dmamap, 1873 (ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN ? 1874 BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE); |
1875 1876 ccb->csio.resid = 0; 1877 if (gdt->sc_status == GDT_S_OK) { 1878 ccb->ccb_h.status = CAM_REQ_CMP; 1879 } else { 1880 /* error */ 1881 if (gccb->gc_service == GDT_CACHESERVICE) { 1882 ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR | CAM_AUTOSNS_VALID; --- 11 unchanged lines hidden (view full) --- 1894 gdt->sc_dvr.eu.sync.hostdrive = ccb->ccb_h.target_id; 1895 if (gdt->sc_status >= 0x8000) 1896 gdt_store_event(GDT_ES_SYNC, 0, &gdt->sc_dvr); 1897 else 1898 gdt_store_event(GDT_ES_SYNC, service, &gdt->sc_dvr); 1899 } else { 1900 /* raw service */ 1901 if (gdt->sc_status != GDT_S_RAW_SCSI || gdt->sc_info >= 0x100) { |
1902 ccb->ccb_h.status = CAM_DEV_NOT_THERE; |
1903 } else { 1904 ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR|CAM_AUTOSNS_VALID; 1905 ccb->csio.scsi_status = gdt->sc_info; 1906 bcopy(gccb->gc_scratch, &ccb->csio.sense_data, 1907 ccb->csio.sense_len); 1908 } 1909 } 1910 } --- 120 unchanged lines hidden --- |