1 /* $OpenBSD: aic79xx_openbsd.c,v 1.57 2020/07/20 14:41:13 krw Exp $ */ 2 3 /* 4 * Copyright (c) 2004 Milos Urbanek, Kenneth R. Westerback & Marco Peereboom 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR 20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 */ 29 30 /* 31 * Bus independent OpenBSD shim for the aic79xx based Adaptec SCSI controllers 32 * 33 * Copyright (c) 1994-2002 Justin T. Gibbs. 34 * Copyright (c) 2001-2002 Adaptec Inc. 35 * All rights reserved. 36 * 37 * Redistribution and use in source and binary forms, with or without 38 * modification, are permitted provided that the following conditions 39 * are met: 40 * 1. Redistributions of source code must retain the above copyright 41 * notice, this list of conditions, and the following disclaimer, 42 * without modification. 43 * 2. The name of the author may not be used to endorse or promote products 44 * derived from this software without specific prior written permission. 45 * 46 * Alternatively, this software may be distributed under the terms of the 47 * GNU Public License ("GPL"). 48 * 49 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 50 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 51 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 52 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 53 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 59 * SUCH DAMAGE. 60 * 61 */ 62 63 #include <dev/ic/aic79xx_openbsd.h> 64 #include <dev/ic/aic79xx_inline.h> 65 #include <dev/ic/aic79xx.h> 66 67 #ifndef AHD_TMODE_ENABLE 68 #define AHD_TMODE_ENABLE 0 69 #endif 70 71 /* XXX milos add ahd_ioctl */ 72 void ahd_action(struct scsi_xfer *); 73 void ahd_execute_scb(void *, bus_dma_segment_t *, int); 74 int ahd_poll(struct ahd_softc *, int); 75 void ahd_setup_data(struct ahd_softc *, struct scsi_xfer *, 76 struct scb *); 77 78 void ahd_adapter_req_set_xfer_mode(struct ahd_softc *, struct scb *); 79 80 struct cfdriver ahd_cd = { 81 NULL, "ahd", DV_DULL 82 }; 83 84 static struct scsi_adapter ahd_switch = { 85 ahd_action, NULL, NULL, NULL, NULL 86 }; 87 88 /* 89 * Attach all the sub-devices we can find 90 */ 91 int 92 ahd_attach(struct ahd_softc *ahd) 93 { 94 struct scsibus_attach_args saa; 95 char ahd_info[256]; 96 int s; 97 98 ahd_controller_info(ahd, ahd_info, sizeof ahd_info); 99 printf("%s\n", ahd_info); 100 ahd_lock(ahd, &s); 101 102 if (bootverbose) { 103 ahd_controller_info(ahd, ahd_info, sizeof ahd_info); 104 printf("%s: %s\n", ahd->sc_dev.dv_xname, ahd_info); 105 } 106 107 ahd_intr_enable(ahd, TRUE); 108 109 if (ahd->flags & AHD_RESET_BUS_A) 110 ahd_reset_channel(ahd, 'A', TRUE); 111 112 saa.saa_adapter_target = ahd->our_id; 113 saa.saa_adapter_buswidth = (ahd->features & AHD_WIDE) ? 16 : 8; 114 saa.saa_adapter_softc = ahd; 115 saa.saa_adapter = &ahd_switch; 116 saa.saa_luns = 8; 117 saa.saa_openings = 16; /* Must ALWAYS be < 256!! */ 118 saa.saa_pool = &ahd->sc_iopool; 119 saa.saa_quirks = saa.saa_flags = 0; 120 saa.saa_wwpn = saa.saa_wwnn = 0; 121 122 ahd->sc_child = config_found((void *)&ahd->sc_dev, &saa, scsiprint); 123 124 ahd_unlock(ahd, &s); 125 126 return (1); 127 128 } 129 130 /* 131 * Catch an interrupt from the adapter 132 */ 133 int 134 ahd_platform_intr(void *arg) 135 { 136 struct ahd_softc *ahd; 137 138 /* XXX in ahc there is some bus_dmamap_sync(PREREAD|PREWRITE); */ 139 140 ahd = (struct ahd_softc *)arg; 141 return ahd_intr(ahd); 142 } 143 144 /* 145 * We have an scb which has been processed by the 146 * adaptor, now we look to see how the operation 147 * went. 148 */ 149 void 150 ahd_done(struct ahd_softc *ahd, struct scb *scb) 151 { 152 struct scsi_xfer *xs = scb->xs; 153 154 /* XXX in ahc there is some bus_dmamap_sync(PREREAD|PREWRITE); */ 155 156 TAILQ_REMOVE(&ahd->pending_scbs, scb, next); 157 158 timeout_del(&xs->stimeout); 159 160 if (xs->datalen) { 161 int op; 162 163 if ((xs->flags & SCSI_DATA_IN) != 0) 164 op = BUS_DMASYNC_POSTREAD; 165 else 166 op = BUS_DMASYNC_POSTWRITE; 167 bus_dmamap_sync(ahd->parent_dmat, scb->dmamap, 0, 168 scb->dmamap->dm_mapsize, op); 169 bus_dmamap_unload(ahd->parent_dmat, scb->dmamap); 170 } 171 172 /* Translate the CAM status code to a SCSI error code. */ 173 switch (xs->error) { 174 case CAM_SCSI_STATUS_ERROR: 175 case CAM_REQ_INPROG: 176 case CAM_REQ_CMP: 177 switch (xs->status) { 178 case SCSI_TASKSET_FULL: 179 case SCSI_BUSY: 180 xs->error = XS_BUSY; 181 break; 182 case SCSI_CHECK: 183 case SCSI_TERMINATED: 184 if ((scb->flags & SCB_SENSE) == 0) { 185 /* CHECK on CHECK? */ 186 xs->error = XS_DRIVER_STUFFUP; 187 } else 188 xs->error = XS_NOERROR; 189 break; 190 default: 191 xs->error = XS_NOERROR; 192 break; 193 } 194 break; 195 case CAM_BUSY: 196 case CAM_REQUEUE_REQ: 197 xs->error = XS_BUSY; 198 break; 199 case CAM_CMD_TIMEOUT: 200 xs->error = XS_TIMEOUT; 201 break; 202 case CAM_BDR_SENT: 203 case CAM_SCSI_BUS_RESET: 204 xs->error = XS_RESET; 205 break; 206 case CAM_SEL_TIMEOUT: 207 xs->error = XS_SELTIMEOUT; 208 break; 209 default: 210 xs->error = XS_DRIVER_STUFFUP; 211 break; 212 } 213 214 if (xs->error != XS_NOERROR) { 215 /* Don't clobber any existing error state */ 216 } else if ((scb->flags & SCB_SENSE) != 0) { 217 /* 218 * We performed autosense retrieval. 219 * 220 * Zero any sense not transferred by the 221 * device. The SCSI spec mandates that any 222 * untransferred data should be assumed to be 223 * zero. Complete the 'bounce' of sense information 224 * through buffers accessible via bus-space by 225 * copying it into the clients csio. 226 */ 227 memset(&xs->sense, 0, sizeof(struct scsi_sense_data)); 228 memcpy(&xs->sense, ahd_get_sense_buf(ahd, scb), 229 sizeof(struct scsi_sense_data)); 230 xs->error = XS_SENSE; 231 } else if ((scb->flags & SCB_PKT_SENSE) != 0) { 232 struct scsi_status_iu_header *siu; 233 u_int32_t len; 234 235 siu = (struct scsi_status_iu_header *)scb->sense_data; 236 len = SIU_SENSE_LENGTH(siu); 237 memset(&xs->sense, 0, sizeof(xs->sense)); 238 memcpy(&xs->sense, SIU_SENSE_DATA(siu), 239 ulmin(len, sizeof(xs->sense))); 240 xs->error = XS_SENSE; 241 } 242 243 scsi_done(xs); 244 } 245 246 void 247 ahd_action(struct scsi_xfer *xs) 248 { 249 struct ahd_softc *ahd; 250 struct scb *scb; 251 struct hardware_scb *hscb; 252 u_int target_id; 253 u_int our_id; 254 int s; 255 struct ahd_initiator_tinfo *tinfo; 256 struct ahd_tmode_tstate *tstate; 257 u_int16_t quirks; 258 259 SC_DEBUG(xs->sc_link, SDEV_DB3, ("ahd_action\n")); 260 ahd = xs->sc_link->bus->sb_adapter_softc; 261 262 target_id = xs->sc_link->target; 263 our_id = SCSI_SCSI_ID(ahd, xs->sc_link); 264 265 ahd_lock(ahd, &s); 266 if ((ahd->flags & AHD_INITIATORROLE) == 0) { 267 xs->error = XS_DRIVER_STUFFUP; 268 scsi_done(xs); 269 ahd_unlock(ahd, &s); 270 return; 271 } 272 /* 273 * get an scb to use. 274 */ 275 tinfo = ahd_fetch_transinfo(ahd, 'A', our_id, target_id, &tstate); 276 277 quirks = xs->sc_link->quirks; 278 279 ahd_unlock(ahd, &s); 280 281 scb = xs->io; 282 hscb = scb->hscb; 283 scb->flags = SCB_FLAG_NONE; 284 scb->hscb->control = 0; 285 ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = NULL; 286 287 SC_DEBUG(xs->sc_link, SDEV_DB3, ("start scb(%p)\n", scb)); 288 289 scb->xs = xs; 290 timeout_set(&xs->stimeout, ahd_timeout, scb); 291 292 /* 293 * Put all the arguments for the xfer in the scb 294 */ 295 hscb->control = 0; 296 hscb->scsiid = BUILD_SCSIID(ahd, xs->sc_link, target_id, our_id); 297 hscb->lun = xs->sc_link->lun; 298 if (xs->xs_control & XS_CTL_RESET) { 299 hscb->cdb_len = 0; 300 scb->flags |= SCB_DEVICE_RESET; 301 hscb->control |= MK_MESSAGE; 302 hscb->task_management = SIU_TASKMGMT_LUN_RESET; 303 ahd_execute_scb(scb, NULL, 0); 304 } else { 305 hscb->task_management = 0; 306 ahd_setup_data(ahd, xs, scb); 307 } 308 } 309 310 void 311 ahd_execute_scb(void *arg, bus_dma_segment_t *dm_segs, int nsegments) 312 { 313 struct scb *scb; 314 struct scsi_xfer *xs; 315 struct ahd_softc *ahd; 316 struct ahd_initiator_tinfo *tinfo; 317 struct ahd_tmode_tstate *tstate; 318 u_int mask; 319 int s; 320 321 scb = (struct scb *)arg; 322 xs = scb->xs; 323 xs->error = CAM_REQ_INPROG; 324 xs->status = 0; 325 ahd = xs->sc_link->bus->sb_adapter_softc; 326 327 if (nsegments != 0) { 328 void *sg; 329 int op; 330 u_int i; 331 332 ahd_setup_data_scb(ahd, scb); 333 334 /* Copy the segments into our SG list */ 335 for (i = nsegments, sg = scb->sg_list; i > 0; i--) { 336 337 sg = ahd_sg_setup(ahd, scb, sg, dm_segs->ds_addr, 338 dm_segs->ds_len, 339 /*last*/i == 1); 340 dm_segs++; 341 } 342 343 if ((xs->flags & SCSI_DATA_IN) != 0) 344 op = BUS_DMASYNC_PREREAD; 345 else 346 op = BUS_DMASYNC_PREWRITE; 347 348 bus_dmamap_sync(ahd->parent_dmat, scb->dmamap, 0, 349 scb->dmamap->dm_mapsize, op); 350 351 } 352 353 ahd_lock(ahd, &s); 354 355 /* 356 * Last time we need to check if this SCB needs to 357 * be aborted. 358 */ 359 if (xs->flags & ITSDONE) { 360 if (nsegments != 0) 361 bus_dmamap_unload(ahd->parent_dmat, 362 scb->dmamap); 363 ahd_unlock(ahd, &s); 364 return; 365 } 366 367 tinfo = ahd_fetch_transinfo(ahd, SCSIID_CHANNEL(ahd, scb->hscb->scsiid), 368 SCSIID_OUR_ID(scb->hscb->scsiid), 369 SCSIID_TARGET(ahd, scb->hscb->scsiid), 370 &tstate); 371 372 mask = SCB_GET_TARGET_MASK(ahd, scb); 373 374 if ((tstate->discenable & mask) != 0) 375 scb->hscb->control |= DISCENB; 376 377 if ((tstate->tagenable & mask) != 0) 378 scb->hscb->control |= TAG_ENB; 379 380 if ((tinfo->curr.ppr_options & MSG_EXT_PPR_PROT_IUS) != 0) { 381 scb->flags |= SCB_PACKETIZED; 382 if (scb->hscb->task_management != 0) 383 scb->hscb->control &= ~MK_MESSAGE; 384 } 385 386 if ((tstate->auto_negotiate & mask) != 0) { 387 scb->flags |= SCB_AUTO_NEGOTIATE; 388 scb->hscb->control |= MK_MESSAGE; 389 } 390 391 /* XXX with ahc there was some bus_dmamap_sync(PREREAD|PREWRITE); */ 392 393 TAILQ_INSERT_HEAD(&ahd->pending_scbs, scb, next); 394 395 if (!(xs->flags & SCSI_POLL)) 396 timeout_add_msec(&xs->stimeout, xs->timeout); 397 398 scb->flags |= SCB_ACTIVE; 399 400 if ((scb->flags & SCB_TARGET_IMMEDIATE) != 0) { 401 /* Define a mapping from our tag to the SCB. */ 402 ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = scb; 403 ahd_pause(ahd); 404 ahd_set_scbptr(ahd, SCB_GET_TAG(scb)); 405 ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_TARG); 406 ahd_unpause(ahd); 407 } else { 408 ahd_queue_scb(ahd, scb); 409 } 410 411 if (!(xs->flags & SCSI_POLL)) { 412 int target = xs->sc_link->target; 413 int lun = SCB_GET_LUN(scb); 414 415 if (ahd->inited_target[target] == 0) { 416 struct ahd_devinfo devinfo; 417 418 ahd_adapter_req_set_xfer_mode(ahd, scb); 419 ahd_compile_devinfo(&devinfo, ahd->our_id, target, lun, 420 'A', /*XXX milos*/ROLE_UNKNOWN); 421 ahd_scb_devinfo(ahd, &devinfo, scb); 422 ahd_update_neg_request(ahd, &devinfo, tstate, tinfo, 423 AHD_NEG_IF_NON_ASYNC); 424 ahd->inited_target[target] = 1; 425 } 426 427 ahd_unlock(ahd, &s); 428 return; 429 } 430 431 /* 432 * If we can't use interrupts, poll for completion 433 */ 434 SC_DEBUG(xs->sc_link, SDEV_DB3, ("cmd_poll\n")); 435 436 do { 437 if (ahd_poll(ahd, xs->timeout)) { 438 if (!(xs->flags & SCSI_SILENT)) 439 printf("cmd fail\n"); 440 ahd_timeout(scb); 441 break; 442 } 443 } while (!(xs->flags & ITSDONE)); 444 445 ahd_unlock(ahd, &s); 446 } 447 448 int 449 ahd_poll(struct ahd_softc *ahd, int wait) 450 { 451 while (--wait) { 452 DELAY(1000); 453 if (ahd_inb(ahd, INTSTAT) & INT_PEND) 454 break; 455 } 456 457 if (wait == 0) { 458 printf("%s: board is not responding\n", ahd_name(ahd)); 459 return (EIO); 460 } 461 462 ahd_intr((void *)ahd); 463 return (0); 464 } 465 466 void 467 ahd_setup_data(struct ahd_softc *ahd, struct scsi_xfer *xs, 468 struct scb *scb) 469 { 470 struct hardware_scb *hscb; 471 472 hscb = scb->hscb; 473 xs->resid = xs->status = 0; 474 xs->error = CAM_REQ_INPROG; 475 476 hscb->cdb_len = xs->cmdlen; 477 if (hscb->cdb_len > MAX_CDB_LEN) { 478 xs->error = XS_DRIVER_STUFFUP; 479 scsi_done(xs); 480 return; 481 } 482 483 memcpy(hscb->shared_data.idata.cdb, xs->cmd, hscb->cdb_len); 484 485 /* Only use S/G if there is a transfer */ 486 if (xs->datalen) { 487 int error; 488 489 error = bus_dmamap_load(ahd->parent_dmat, 490 scb->dmamap, xs->data, 491 xs->datalen, NULL, 492 ((xs->flags & SCSI_NOSLEEP) ? 493 BUS_DMA_NOWAIT : BUS_DMA_WAITOK) | 494 BUS_DMA_STREAMING | 495 ((xs->flags & XS_CTL_DATA_IN) ? 496 BUS_DMA_READ : BUS_DMA_WRITE)); 497 if (error) { 498 #ifdef AHD_DEBUG 499 printf("%s: in ahd_setup_data(): bus_dmamap_load() " 500 "= %d\n", ahd_name(ahd), error); 501 #endif 502 xs->error = XS_DRIVER_STUFFUP; 503 scsi_done(xs); 504 return; 505 } 506 ahd_execute_scb(scb, scb->dmamap->dm_segs, 507 scb->dmamap->dm_nsegs); 508 } else { 509 ahd_execute_scb(scb, NULL, 0); 510 } 511 } 512 513 void 514 ahd_platform_set_tags(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, 515 ahd_queue_alg alg) 516 { 517 struct ahd_tmode_tstate *tstate; 518 519 ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid, 520 devinfo->target, &tstate); 521 522 if (alg != AHD_QUEUE_NONE) 523 tstate->tagenable |= devinfo->target_mask; 524 else 525 tstate->tagenable &= ~devinfo->target_mask; 526 } 527 528 int 529 ahd_softc_comp(struct ahd_softc *lahd, struct ahd_softc *rahd) 530 { 531 /* We don't sort softcs under OpenBSD so report equal always */ 532 return (0); 533 } 534 535 int 536 ahd_detach(struct device *self, int flags) 537 { 538 int rv = 0; 539 540 struct ahd_softc *ahd = (struct ahd_softc*)self; 541 542 if (ahd->sc_child != NULL) 543 rv = config_detach((void *)ahd->sc_child, flags); 544 545 ahd_free(ahd); 546 547 return rv; 548 } 549 550 void 551 ahd_adapter_req_set_xfer_mode(struct ahd_softc *ahd, struct scb *scb) 552 { 553 struct ahd_initiator_tinfo *tinfo; 554 struct ahd_tmode_tstate *tstate; 555 int target_id, our_id; 556 struct ahd_devinfo devinfo; 557 u_int16_t quirks; 558 u_int width, ppr_options, period, offset; 559 int s; 560 561 target_id = scb->xs->sc_link->target; 562 our_id = SCSI_SCSI_ID(ahd, scb->xs->sc_link); 563 564 s = splbio(); 565 566 quirks = scb->xs->sc_link->quirks; 567 tinfo = ahd_fetch_transinfo(ahd, 'A', our_id, target_id, &tstate); 568 ahd_compile_devinfo(&devinfo, our_id, target_id, 0, 'A', 569 ROLE_INITIATOR); 570 571 tstate->discenable |= (ahd->user_discenable & devinfo.target_mask); 572 573 if (quirks & SDEV_NOTAGS) 574 tstate->tagenable &= ~devinfo.target_mask; 575 else if (ahd->user_tagenable & devinfo.target_mask) 576 tstate->tagenable |= devinfo.target_mask; 577 578 if (quirks & SDEV_NOWIDE) 579 width = MSG_EXT_WDTR_BUS_8_BIT; 580 else 581 width = MSG_EXT_WDTR_BUS_16_BIT; 582 583 ahd_validate_width(ahd, NULL, &width, ROLE_UNKNOWN); 584 if (width > tinfo->user.width) 585 width = tinfo->user.width; 586 ahd_set_width(ahd, &devinfo, width, AHD_TRANS_GOAL, FALSE); 587 588 if (quirks & SDEV_NOSYNC) { 589 period = 0; 590 offset = 0; 591 } else { 592 period = tinfo->user.period; 593 offset = tinfo->user.offset; 594 } 595 596 /* XXX Look at saved INQUIRY flags for PPR capabilities XXX */ 597 ppr_options = tinfo->user.ppr_options; 598 /* XXX Other reasons to avoid ppr? XXX */ 599 if (width < MSG_EXT_WDTR_BUS_16_BIT) 600 ppr_options = 0; 601 602 if ((tstate->discenable & devinfo.target_mask) == 0 || 603 (tstate->tagenable & devinfo.target_mask) == 0) 604 ppr_options &= ~MSG_EXT_PPR_PROT_IUS; 605 606 ahd_find_syncrate(ahd, &period, &ppr_options, AHD_SYNCRATE_MAX); 607 ahd_validate_offset(ahd, NULL, period, &offset, width, ROLE_UNKNOWN); 608 609 if (offset == 0) { 610 period = 0; 611 ppr_options = 0; 612 } 613 614 if (ppr_options != 0 && tinfo->user.transport_version >= 3) { 615 tinfo->goal.transport_version = tinfo->user.transport_version; 616 tinfo->curr.transport_version = tinfo->user.transport_version; 617 } 618 619 ahd_set_syncrate(ahd, &devinfo, period, offset, ppr_options, 620 AHD_TRANS_GOAL, FALSE); 621 622 splx(s); 623 } 624 625 void 626 aic_timer_reset(aic_timer_t *timer, u_int msec, ahd_callback_t *func, 627 void *arg) 628 { 629 uint64_t nticks; 630 631 nticks = msec; 632 nticks *= hz; 633 nticks /= 1000; 634 callout_reset(timer, nticks, func, arg); 635 } 636 637 void 638 aic_scb_timer_reset(struct scb *scb, u_int msec) 639 { 640 uint64_t nticks; 641 642 nticks = msec; 643 nticks *= hz; 644 nticks /= 1000; 645 if (!(scb->xs->xs_control & XS_CTL_POLL)) 646 callout_reset(&scb->xs->xs_callout, nticks, ahd_timeout, scb); 647 } 648 649 void 650 ahd_flush_device_writes(struct ahd_softc *ahd) 651 { 652 /* XXX Is this sufficient for all architectures??? */ 653 ahd_inb(ahd, INTSTAT); 654 } 655 656 void 657 aic_platform_scb_free(struct ahd_softc *ahd, struct scb *scb) 658 { 659 int s; 660 661 ahd_lock(ahd, &s); 662 663 if ((ahd->flags & AHD_RESOURCE_SHORTAGE) != 0) { 664 ahd->flags &= ~AHD_RESOURCE_SHORTAGE; 665 } 666 667 if (!cold) { 668 /* we are no longer in autoconf */ 669 timeout_del(&scb->xs->stimeout); 670 } 671 672 ahd_unlock(ahd, &s); 673 } 674 675 void 676 ahd_print_path(struct ahd_softc *ahd, struct scb *scb) 677 { 678 sc_print_addr(scb->xs->sc_link); 679 } 680 681 void 682 ahd_platform_dump_card_state(struct ahd_softc *ahd) 683 { 684 /* Nothing to do here for OpenBSD */ 685 printf("FEATURES = 0x%x, FLAGS = 0x%x, CHIP = 0x%x BUGS =0x%x\n", 686 ahd->features, ahd->flags, ahd->chip, ahd->bugs); 687 } 688 689