Deleted Added
sdiff udiff text old ( 113350 ) new ( 114001 )
full compact
1/* $FreeBSD: head/sys/dev/iir/iir.c 113350 2003-04-10 23:50:06Z mux $ */
2/*
3 * Copyright (c) 2000-01 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.2 2001/06/21 20: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,
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, /*alignment*/1, /*boundary*/0,
224 /*lowaddr*/BUS_SPACE_MAXADDR,
225 /*highaddr*/BUS_SPACE_MAXADDR,
226 /*filter*/NULL, /*filterarg*/NULL,
227 GDT_MAXCMDS * sizeof(struct gdt_ccb),
228 /*nsegments*/1,
229 /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
230 /*flags*/0, &gdt->sc_gccb_dmat) != 0) {
231 printf("iir%d: bus_dma_tag_create(...,gdt->sc_gccb_dmat) failed\n",
232 gdt->sc_hanum);
233 return (1);
234 }
235 gdt->sc_init_level++;

--- 152 unchanged lines hidden (view full) ---

388 panic("iir%d: Scatter/Gather Cache Service "
389 "required but not supported!\n", gdt->sc_hanum);
390 gdt_free_ccb(gdt, gccb);
391 return (1);
392 }
393 }
394 }
395
396 /* Scan for cache devices */
397 for (i = 0; i < cdev_cnt && i < GDT_MAX_HDRIVES; i++) {
398 if (gdt_internal_cmd(gdt, gccb, GDT_CACHESERVICE, GDT_INFO,
399 i, 0, 0)) {
400 gdt->sc_hdr[i].hd_present = 1;
401 gdt->sc_hdr[i].hd_size = gdt->sc_info;
402
403 /*

--- 339 unchanged lines hidden (view full) ---

743 sim_links.tqe);
744 ++gdt_stat.req_queue_act;
745 if (gdt_stat.req_queue_act > gdt_stat.req_queue_max)
746 gdt_stat.req_queue_max = gdt_stat.req_queue_act;
747 next_cmd = FALSE;
748 }
749 } else if (target >= GDT_MAX_HDRIVES ||
750 !gdt->sc_hdr[target].hd_present || lun != 0) {
751 ccbh->status = CAM_SEL_TIMEOUT;
752 --gdt_stat.io_count_act;
753 xpt_done(ccb);
754 } else {
755 /* cache service command */
756 if (cmd == READ_6 || cmd == WRITE_6 ||
757 cmd == READ_10 || cmd == WRITE_10) {
758 if ((gccb = gdt_cache_cmd(gdt, ccb, &lock)) == NULL) {
759 TAILQ_INSERT_HEAD(&gdt->sc_ccb_queue, &ccb->ccb_h,

--- 415 unchanged lines hidden (view full) ---

1175 bzero(inq, sizeof(struct scsi_inquiry_data));
1176 inq->device = (gdt->sc_hdr[t].hd_devtype & 4) ?
1177 T_CDROM : T_DIRECT;
1178 inq->dev_qual2 = (gdt->sc_hdr[t].hd_devtype & 1) ? 0x80 : 0;
1179 inq->version = SCSI_REV_2;
1180 inq->response_format = 2;
1181 inq->additional_length = 32;
1182 inq->flags = SID_CmdQue | SID_Sync;
1183 strcpy(inq->vendor, "IIR ");
1184 sprintf(inq->product, "Host Drive #%02d", t);
1185 strcpy(inq->revision, " ");
1186 break;
1187 }
1188 case MODE_SENSE_6:
1189 {
1190 struct mpd_data {
1191 struct scsi_mode_hdr_6 hd;

--- 97 unchanged lines hidden (view full) ---

1289 gdt_enc32(gdt->sc_cmd + GDT_CMD_UNION + GDT_RAW_SDATA,
1290 0xffffffffUL);
1291
1292 gdt->sc_cmd_len = roundup(GDT_CMD_UNION + GDT_RAW_SG_LST +
1293 nseg * GDT_SG_SZ, sizeof(u_int32_t));
1294 }
1295
1296 if (nseg != 0) {
1297 int op;
1298
1299 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)
1300 op = BUS_DMASYNC_PREREAD;
1301 else
1302 op = BUS_DMASYNC_PREWRITE;
1303 bus_dmamap_sync(gdt->sc_buffer_dmat, gccb->gc_dmamap, op);
1304 }
1305
1306 /* We must NOT abort the command here if CAM_REQ_INPROG is not set,
1307 * because command semaphore is already set!
1308 */
1309
1310 ccb->ccb_h.status |= CAM_SIM_QUEUED;
1311 /* timeout handling */

--- 365 unchanged lines hidden (view full) ---

1677 gdt_sync_event(gdt, ctx.service, ctx.istatus, gccb);
1678 if (!(gdt->sc_state & GDT_POLLING))
1679 splx(lock);
1680 gdt_next(gdt);
1681 break;
1682 }
1683}
1684
1685static int
1686gdt_async_event(struct gdt_softc *gdt, int service)
1687{
1688 struct gdt_ccb *gccb;
1689
1690 GDT_DPRINTF(GDT_D_INTR, ("gdt_async_event(%p, %d)\n", gdt, service));
1691
1692 if (service == GDT_SCREENSERVICE) {
1693 if (gdt->sc_status == GDT_MSG_REQUEST) {

--- 43 unchanged lines hidden (view full) ---

1737 }
1738 gdt_store_event(GDT_ES_ASYNC, service, &gdt->sc_dvr);
1739 printf("iir%d: %s\n", gdt->sc_hanum, gdt->sc_dvr.event_string);
1740 }
1741
1742 return (0);
1743}
1744
1745static int
1746gdt_sync_event(struct gdt_softc *gdt, int service,
1747 u_int8_t index, struct gdt_ccb *gccb)
1748{
1749 union ccb *ccb;
1750 int op;
1751
1752 GDT_DPRINTF(GDT_D_INTR,
1753 ("gdt_sync_event(%p, %d, %d, %p)\n", gdt,service,index,gccb));
1754
1755 ccb = gccb->gc_ccb;
1756
1757 if (service == GDT_SCREENSERVICE) {
1758 u_int32_t msg_len;

--- 90 unchanged lines hidden (view full) ---

1849 gdt, gccb));
1850 TAILQ_INSERT_HEAD(&gdt->sc_ccb_queue, &ccb->ccb_h, sim_links.tqe);
1851 ++gdt_stat.req_queue_act;
1852 if (gdt_stat.req_queue_act > gdt_stat.req_queue_max)
1853 gdt_stat.req_queue_max = gdt_stat.req_queue_act;
1854 return (2);
1855 }
1856
1857 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)
1858 op = BUS_DMASYNC_POSTREAD;
1859 else
1860 op = BUS_DMASYNC_POSTWRITE;
1861 bus_dmamap_sync(gdt->sc_buffer_dmat, gccb->gc_dmamap, op);
1862
1863 ccb->csio.resid = 0;
1864 if (gdt->sc_status == GDT_S_OK) {
1865 ccb->ccb_h.status = CAM_REQ_CMP;
1866 } else {
1867 /* error */
1868 if (gccb->gc_service == GDT_CACHESERVICE) {
1869 ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR | CAM_AUTOSNS_VALID;

--- 11 unchanged lines hidden (view full) ---

1881 gdt->sc_dvr.eu.sync.hostdrive = ccb->ccb_h.target_id;
1882 if (gdt->sc_status >= 0x8000)
1883 gdt_store_event(GDT_ES_SYNC, 0, &gdt->sc_dvr);
1884 else
1885 gdt_store_event(GDT_ES_SYNC, service, &gdt->sc_dvr);
1886 } else {
1887 /* raw service */
1888 if (gdt->sc_status != GDT_S_RAW_SCSI || gdt->sc_info >= 0x100) {
1889 ccb->ccb_h.status = CAM_SEL_TIMEOUT;
1890 } else {
1891 ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR|CAM_AUTOSNS_VALID;
1892 ccb->csio.scsi_status = gdt->sc_info;
1893 bcopy(gccb->gc_scratch, &ccb->csio.sense_data,
1894 ccb->csio.sense_len);
1895 }
1896 }
1897 }

--- 120 unchanged lines hidden ---