Lines Matching refs:np

277 #define	INB(r) bus_space_read_1(np->bst, np->bsh, offsetof(struct ncr_reg, r))
278 #define INW(r) bus_space_read_2(np->bst, np->bsh, offsetof(struct ncr_reg, r))
279 #define INL(r) bus_space_read_4(np->bst, np->bsh, offsetof(struct ncr_reg, r))
281 #define OUTB(r, val) bus_space_write_1(np->bst, np->bsh, \
283 #define OUTW(r, val) bus_space_write_2(np->bst, np->bsh, \
285 #define OUTL(r, val) bus_space_write_4(np->bst, np->bsh, \
287 #define OUTL_OFF(o, val) bus_space_write_4(np->bst, np->bsh, o, val)
289 #define INB_OFF(o) bus_space_read_1(np->bst, np->bsh, o)
290 #define INW_OFF(o) bus_space_read_2(np->bst, np->bsh, o)
291 #define INL_OFF(o) bus_space_read_4(np->bst, np->bsh, o)
295 bus_space_read_4(np->bst2, np->bsh2, off))
303 bus_space_write_4(np->bst2, np->bsh2, off, val); \
307 READSCRIPT_OFF(np->script, offsetof(struct script, r))
310 WRITESCRIPT_OFF(np->script, offsetof(struct script, r), val)
1140 #define NCB_SCRIPT_PHYS(np,lbl) (np->p_script + offsetof (struct script, lbl))
1141 #define NCB_SCRIPTH_PHYS(np,lbl) (np->p_scripth + offsetof (struct scripth,lbl))
1250 static nccb_p ncr_alloc_nccb(ncb_p np, u_long target, u_long lun);
1251 static void ncr_complete(ncb_p np, nccb_p cp);
1253 static void ncr_exception(ncb_p np);
1254 static void ncr_free_nccb(ncb_p np, nccb_p cp);
1255 static void ncr_freeze_devq(ncb_p np, struct cam_path *path);
1256 static void ncr_selectclock(ncb_p np, u_char scntl3);
1257 static void ncr_getclock(ncb_p np, u_char multiplier);
1258 static nccb_p ncr_get_nccb(ncb_p np, u_long t,u_long l);
1262 static void ncr_init(ncb_p np, char * msg, u_long code);
1264 static void ncr_int_ma(ncb_p np, u_char dstat);
1265 static void ncr_int_sir(ncb_p np);
1266 static void ncr_int_sto(ncb_p np);
1271 static void ncb_profile(ncb_p np, nccb_p cp);
1272 static void ncr_script_copy_and_bind(ncb_p np, ncrcmd *src, ncrcmd *dst,
1277 static void ncr_getsync(ncb_p np, u_char sfac, u_char *fakp,
1279 static void ncr_setsync(ncb_p np, nccb_p cp,u_char scntl3,u_char sxfer,
1281 static void ncr_setwide(ncb_p np, nccb_p cp, u_char wide, u_char ack);
1283 static int ncr_snooptest(ncb_p np);
1286 static void ncr_wakeup(ncb_p np, u_long code);
1338 static char *ncr_name (ncb_p np)
1341 snprintf(name, sizeof(name), "ncr%d", np->unit);
2996 static void ncr_script_copy_and_bind (ncb_p np, ncrcmd *src, ncrcmd *dst, int len)
3021 ncr_name(np), (int) (src-start-1));
3047 ncr_name(np), (int) (src-start-1));
3054 if ((opcode & SCR_NO_FLUSH) && !(np->features&FE_PFEN))
3095 new = (old & ~RELOC_MASK) + rman_get_start(np->reg_res);
3098 new = (old & ~RELOC_MASK) + np->p_script;
3101 new = (old & ~RELOC_MASK) + np->p_scripth;
3104 new = (old & ~RELOC_MASK) + vtophys(np);
3330 ncr_init_burst(ncb_p np, u_char bc)
3332 np->rv_ctest4 &= ~0x80;
3333 np->rv_dmode &= ~(0x3 << 6);
3334 np->rv_ctest5 &= ~0x4;
3337 np->rv_ctest4 |= 0x80;
3341 np->rv_dmode |= ((bc & 0x3) << 6);
3342 np->rv_ctest5 |= (bc & 0x4);
3359 ncb_p np = (struct ncb*) device_get_softc(dev);
3371 np->unit = device_get_unit(dev);
3378 np->reg_rid = 0x14;
3379 np->reg_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
3380 &np->reg_rid, RF_ACTIVE);
3381 if (!np->reg_res) {
3392 np->bst = rman_get_bustag(np->reg_res);
3393 np->bsh = rman_get_bushandle(np->reg_res);
3401 if (!pci_map_port (config_id, 0x10, &np->port))
3410 np->rv_scntl3 = INB(nc_scntl3) & 0x77;
3411 np->rv_dmode = INB(nc_dmode) & 0xce;
3412 np->rv_dcntl = INB(nc_dcntl) & 0xa9;
3413 np->rv_ctest3 = INB(nc_ctest3) & 0x01;
3414 np->rv_ctest4 = INB(nc_ctest4) & 0x88;
3415 np->rv_ctest5 = INB(nc_ctest5) & 0x24;
3416 np->rv_gpcntl = INB(nc_gpcntl);
3417 np->rv_stest2 = INB(nc_stest2) & 0x20;
3421 np->rv_scntl3, np->rv_dmode, np->rv_dcntl);
3423 np->rv_ctest3, np->rv_ctest4, np->rv_ctest5);
3426 np->rv_dcntl |= NOCOM;
3440 np->maxburst = ncr_chip_table[i].maxburst;
3441 np->maxoffs = ncr_chip_table[i].maxoffs;
3442 np->clock_divn = ncr_chip_table[i].clock_divn;
3443 np->features = ncr_chip_table[i].features;
3445 np->maxburst = 4;
3446 np->maxoffs = 8;
3447 np->clock_divn = 4;
3448 np->features = FE_ERL;
3451 np->maxwide = np->features & FE_WIDE ? 1 : 0;
3452 np->clock_khz = np->features & FE_CLK80 ? 80000 : 40000;
3453 if (np->features & FE_QUAD) np->multiplier = 4;
3454 else if (np->features & FE_DBLR) np->multiplier = 2;
3455 else np->multiplier = 1;
3461 if (np->features & (FE_ULTRA|FE_ULTRA2))
3462 ncr_getclock(np, np->multiplier);
3467 ncr_name(np),
3468 read_tekram_eeprom (np, NULL) ?
3476 if (np->rv_scntl3)
3477 np->features |= FE_BIOS;
3482 i = np->clock_divn - 1;
3485 if (10ul * SCSI_NCR_MIN_ASYNC * np->clock_khz > div_10M[i]) {
3490 np->rv_scntl3 = i+1;
3497 period = (4 * div_10M[0] + np->clock_khz - 1) / np->clock_khz;
3498 if (period <= 250) np->minsync = 10;
3499 else if (period <= 303) np->minsync = 11;
3500 else if (period <= 500) np->minsync = 12;
3501 else np->minsync = (period + 40 - 1) / 40;
3507 if (np->minsync < 25 && !(np->features & (FE_ULTRA|FE_ULTRA2)))
3508 np->minsync = 25;
3509 else if (np->minsync < 12 && !(np->features & FE_ULTRA2))
3510 np->minsync = 12;
3516 period = (11 * div_10M[np->clock_divn - 1]) / (4 * np->clock_khz);
3517 np->maxsync = period > 2540 ? 254 : period / 10;
3525 if (!(np->rv_gpcntl & 0x01))
3526 np->features |= FE_LED0;
3529 np->features |= FE_DIFF;
3538 if (!(np->features & FE_BIOS)) {
3542 np->rv_dmode = 0;
3543 np->rv_dcntl = NOCOM;
3544 np->rv_ctest3 = 0;
3545 np->rv_ctest4 = MPEE;
3546 np->rv_ctest5 = 0;
3547 np->rv_stest2 = 0;
3549 if (np->features & FE_ERL)
3550 np->rv_dmode |= ERL; /* Enable Read Line */
3551 if (np->features & FE_BOF)
3552 np->rv_dmode |= BOF; /* Burst Opcode Fetch */
3553 if (np->features & FE_ERMP)
3554 np->rv_dmode |= ERMP; /* Enable Read Multiple */
3555 if (np->features & FE_CLSE)
3556 np->rv_dcntl |= CLSE; /* Cache Line Size Enable */
3557 if (np->features & FE_WRIE)
3558 np->rv_ctest3 |= WRIE; /* Write and Invalidate */
3559 if (np->features & FE_PFEN)
3560 np->rv_dcntl |= PFEN; /* Prefetch Enable */
3561 if (np->features & FE_DFS)
3562 np->rv_ctest5 |= DFS; /* Dma Fifo Size */
3563 if (np->features & FE_DIFF)
3564 np->rv_stest2 |= 0x20; /* Differential mode */
3565 ncr_init_burst(np, np->maxburst); /* Max dwords burst length */
3567 np->maxburst =
3568 burst_code(np->rv_dmode, np->rv_ctest4, np->rv_ctest5);
3574 if ((np->features & FE_RAM) && sizeof(struct script) <= 4096) {
3575 np->sram_rid = 0x18;
3576 np->sram_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
3577 &np->sram_rid,
3584 if (np->sram_res != NULL) {
3585 np->script = NULL;
3586 np->p_script = rman_get_start(np->sram_res);
3587 np->bst2 = rman_get_bustag(np->sram_res);
3588 np->bsh2 = rman_get_bushandle(np->sram_res);
3590 np->script = (struct script*) contigmalloc
3594 np->script = (struct script *)
3599 np->scripth = (struct scripth*) contigmalloc
3604 np->scripth = (struct scripth *)
3621 ncr_name(np), (int)cachelnsz);
3628 ncr_name(np));
3640 if (usrsync > np->maxsync)
3641 usrsync = np->maxsync;
3642 if (usrsync < np->minsync)
3643 usrsync = np->minsync;
3647 if (usrwide > np->maxwide) usrwide=np->maxwide;
3650 tcb_p tp = &np->target[i];
3653 tp->tinfo.user.offset = usrsync != 0 ? np->maxoffs : 0;
3666 ncr_name(np), np->minsync, np->maxsync, np->maxoffs,
3667 burst_length(np->maxburst),
3668 (np->rv_ctest5 & DFS) ? "large" : "normal");
3675 ncr_name(np),
3676 np->rv_stest2 & 0x20 ? "differential" : "single-ended",
3677 np->rv_dcntl & IRQM ? "totem pole" : "open drain",
3678 np->sram_res ? ", using on-chip SRAM" : "");
3685 if (np->script)
3686 np->p_script = vtophys(np->script);
3687 np->p_scripth = vtophys(np->scripth);
3689 ncr_script_copy_and_bind (np, (ncrcmd *) &script0,
3690 (ncrcmd *) np->script, sizeof(struct script));
3692 ncr_script_copy_and_bind (np, (ncrcmd *) &scripth0,
3693 (ncrcmd *) np->scripth, sizeof(struct scripth));
3699 if (np->features & FE_LED0) {
3709 np->jump_tcb.l_cmd = SCR_JUMP;
3710 np->jump_tcb.l_paddr = NCB_SCRIPTH_PHYS (np, abort);
3716 np->myaddr = INB(nc_scid) & 0x07;
3717 if (!np->myaddr) np->myaddr = SCSI_NCR_MYADDR;
3746 if (ncr_snooptest (np)) {
3756 np->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
3758 if (np->irq_res == NULL) {
3762 bus_setup_intr(dev, np->irq_res, INTR_TYPE_CAM | INTR_ENTROPY,
3763 NULL, ncr_intr, np, &np->irq_handle);
3779 np->sim = cam_sim_alloc(ncr_action, ncr_poll, "ncr", np, np->unit,
3781 if (np->sim == NULL) {
3787 if (xpt_bus_register(np->sim, dev, 0) != CAM_SUCCESS) {
3788 cam_sim_free(np->sim, /*free_devq*/ TRUE);
3792 if (xpt_create_path(&np->path, /*periph*/NULL,
3793 cam_sim_path(np->sim), CAM_TARGET_WILDCARD,
3795 xpt_bus_deregister(cam_sim_path(np->sim));
3796 cam_sim_free(np->sim, /*free_devq*/TRUE);
3803 ncr_timeout (np);
3804 np->lasttime=0;
3822 ncb_p np = vnp;
3832 ncr_exception (np);
3835 np->ticks = 100;
3856 ncb_p np;
3858 np = (ncb_p) cam_sim_softc(sim);
3877 tp = &np->target[ccb->ccb_h.target_id];
3899 cp = ncr_get_nccb (np, ccb->ccb_h.target_id,
4042 ncr_free_nccb(np, cp);
4048 cp->phys.header.savep = NCB_SCRIPT_PHYS (np, data_in);
4051 cp->phys.header.savep = NCB_SCRIPT_PHYS (np, data_out);
4055 cp->phys.header.savep = NCB_SCRIPT_PHYS (np, no_data);
4076 cp->phys.header.launch.l_paddr = NCB_SCRIPT_PHYS (np, select);
4148 qidx = np->squeueput + 1;
4151 np->squeue [qidx ] = NCB_SCRIPT_PHYS (np, idle);
4152 np->squeue [np->squeueput] = CCB_PHYS (cp, phys);
4153 np->squeueput = qidx;
4157 ncr_name (np), np->squeueput,
4159 (NCB_SCRIPTH_PHYS (np, tryloop))));
4201 tp = &np->target[ccb->ccb_h.target_id];
4238 if (spi->bus_width > np->maxwide)
4239 spi->bus_width = np->maxwide;
4246 && (spi->sync_period < np->minsync))
4247 spi->sync_period = np->minsync;
4252 if (spi->sync_offset > np->maxoffs)
4253 spi->sync_offset = np->maxoffs;
4284 tcb_p tp = &np->target[ccb->ccb_h.target_id];
4365 if ((np->features & FE_WIDE) != 0)
4370 cpi->max_target = (np->features & FE_WIDE) ? 15 : 7;
4372 cpi->initiator_id = np->myaddr;
4405 ncr_complete (ncb_p np, nccb_p cp)
4426 cp->phys.header.launch.l_paddr= NCB_SCRIPT_PHYS (np, idle);
4431 ncb_profile (np, cp);
4439 tp = &np->target[ccb->ccb_h.target_id];
4557 ncr_free_nccb (np, cp);
4575 ncr_wakeup (ncb_p np, u_long code)
4586 nccb_p cp = np->link_nccb;
4605 ncr_complete (np, cp);
4613 ncr_freeze_devq (ncb_p np, struct cam_path *path)
4625 cp = np->link_nccb;
4634 == NCB_SCRIPT_PHYS (np, select))
4641 idx = np->squeueput - i;
4645 if (np->squeue[idx]
4647 np->squeue[idx] =
4648 NCB_SCRIPT_PHYS (np, skip);
4655 ncr_complete (np, cp);
4671 bidx = np->squeueput;
4672 i = np->squeueput - firstskip;
4681 if (np->squeue[i] == NCB_SCRIPT_PHYS (np, skip)) {
4684 np->squeue[bidx] = np->squeue[i];
4685 if (np->squeue[bidx]
4686 == NCB_SCRIPT_PHYS(np, idle))
4691 np->squeueput = bidx;
4705 ncr_init(ncb_p np, char * msg, u_long code)
4721 if (msg) printf ("%s: restart (%s).\n", ncr_name (np), msg);
4728 np -> squeue [i] = NCB_SCRIPT_PHYS (np, idle);
4734 np->squeueput = 0;
4735 WRITESCRIPT(startpos[0], NCB_SCRIPTH_PHYS (np, tryloop));
4742 ncr_wakeup (np, code);
4751 ncr_selectclock(np, np->rv_scntl3); /* Select SCSI clock */
4752 OUTB (nc_scid , RRE|np->myaddr);/* host adapter SCSI address */
4753 OUTW (nc_respid, 1ul<<np->myaddr);/* id to respond to */
4755 OUTB (nc_dmode , np->rv_dmode); /* XXX modify burstlen ??? */
4756 OUTB (nc_dcntl , np->rv_dcntl);
4757 OUTB (nc_ctest3, np->rv_ctest3);
4758 OUTB (nc_ctest5, np->rv_ctest5);
4759 OUTB (nc_ctest4, np->rv_ctest4);/* enable master parity checking */
4760 OUTB (nc_stest2, np->rv_stest2|EXT); /* Extended Sreq/Sack filtering */
4766 np->rv_scntl3, np->rv_dmode, np->rv_dcntl);
4768 np->rv_ctest3, np->rv_ctest4, np->rv_ctest5);
4775 if (np->features & FE_LED0) {
4783 tcb_p tp = &np->target[i];
4786 tp->tinfo.wval = np->rv_scntl3;
4804 OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, start));
4810 xpt_async(AC_BUS_RESET, np->path, NULL);
4830 static void ncr_getsync(ncb_p np, u_char sfac, u_char *fakp, u_char *scntl3p)
4832 u_long clk = np->clock_khz; /* SCSI clock frequency in kHz */
4833 int div = np->clock_divn; /* Number of divisors supported */
4898 ncr_setsync(ncb_p np, nccb_p cp, u_char scntl3, u_char sxfer, u_char period)
4915 tp = &np->target[target];
4918 scntl3 = np->rv_scntl3;
4920 | (np->rv_scntl3 & 0x07);
4930 (((sxfer>>5)+4)*div_10M[div-1])/np->clock_khz;
4974 np->sync_st = sxfer;
4976 np->wide_st = scntl3;
4981 for (cp = np->link_nccb; cp; cp = cp->link_nccb) {
4999 static void ncr_setwide (ncb_p np, nccb_p cp, u_char wide, u_char ack)
5016 tp = &np->target[target];
5053 np->sync_st = sxfer;
5055 np->wide_st = scntl3;
5060 for (cp = np->link_nccb; cp; cp = cp->link_nccb) {
5085 ncb_p np = arg;
5087 ticks_t step = np->ticks;
5092 if (np->lasttime != thistime) {
5097 np->lasttime = thistime;
5110 t = thistime - np->heartbeat;
5112 if (t<2) np->latetime=0; else np->latetime++;
5114 if (np->latetime>2) {
5131 for (cp=np->link_nccb; cp; cp=cp->link_nccb) {
5145 NCB_SCRIPT_PHYS (np, select)) {
5147 ncr_name (np), cp);
5149 = NCB_SCRIPT_PHYS (np, skip);
5165 ncr_complete (np, cp);
5170 np->timeout_ch =
5171 timeout (ncr_timeout, (caddr_t) np, step ? step : 1);
5181 ncr_exception (np);
5217 static void ncr_log_hard_error(ncb_p np, u_short sist, u_char dstat)
5228 if (np->p_script < dsp &&
5229 dsp <= np->p_script + sizeof(struct script)) {
5230 script_ofs = dsp - np->p_script;
5232 script_base = (u_char *) np->script;
5235 else if (np->p_scripth < dsp &&
5236 dsp <= np->p_scripth + sizeof(struct scripth)) {
5237 script_ofs = dsp - np->p_scripth;
5239 script_base = (u_char *) np->scripth;
5249 ncr_name (np), (unsigned)INB (nc_sdid)&0x0f, dstat, sist,
5256 printf ("%s: script cmd = %08x\n", ncr_name(np),
5260 printf ("%s: regdump:", ncr_name(np));
5275 static void ncr_exception (ncb_p np)
5286 np->profile.num_fly++;
5287 ncr_wakeup (np, 0);
5300 np->profile.num_int++;
5322 ncr_init (np, bootverbose ? "scsi reset" : NULL, HS_RESET);
5337 ncr_int_sto (np);
5349 ncr_int_ma (np, dstat);
5366 OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, no_data));
5379 ncr_int_sir (np);
5388 ncr_log_hard_error(np, sist, dstat);
5395 if (time_second - np->regtime > 10) {
5397 np->regtime = time_second;
5398 for (i=0; i<sizeof(np->regdump); i++)
5399 ((volatile char*)&np->regdump)[i] = INB_OFF(i);
5400 np->regdump.nc_dstat = dstat;
5401 np->regdump.nc_sist = sist;
5414 printf ("%s: have to clear fifos.\n", ncr_name (np));
5416 OUTB (nc_ctest3, np->rv_ctest3 | CLF);
5426 printf ("%s: handshake timeout\n", ncr_name(np));
5431 OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, cleanup));
5444 OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, cleanup));
5465 OUTB (nc_dcntl, np->rv_dcntl | STD);
5470 ncr_name (np));
5474 ncr_name (np), INB (nc_sdid)&0x0f);
5490 OUTB (nc_dcntl, np->rv_dcntl | STD);
5504 OUTB (nc_ctest3, np->rv_ctest3 | CLF);
5519 ncr_name(np),i/16);
5527 val = bus_space_read_1(np->bst, np->bsh, i);
5532 untimeout (ncr_timeout, (caddr_t) np, np->timeout_ch);
5534 printf ("%s: halted!\n", ncr_name(np));
5555 ncr_init (np, "fatal error", HS_FAIL);
5574 static void ncr_int_sto (ncb_p np)
5585 cp = np->link_nccb;
5591 ncr_complete (np, cp);
5599 diff = scratcha - NCB_SCRIPTH_PHYS (np, tryloop);
5605 OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, start));
5608 ncr_init (np, "selection timeout", HS_FAIL);
5625 static void ncr_int_ma (ncb_p np, u_char dstat)
5650 ctest5 = (np->rv_ctest5 & DFS) ? INB (nc_ctest5) : 0;
5671 OUTB (nc_ctest3, np->rv_ctest3 | CLF); /* clear dma fifo */
5677 cp = np->link_nccb;
5683 ncr_name (np), (void *) np->header.cp);
5686 if (cp != np->header.cp) {
5688 "(%p != %p) np->nccb = %p\n",
5689 ncr_name (np), (void *)cp, (void *)np->header.cp,
5690 (void *)np->link_nccb);
5707 } else if (dsp > np->p_script &&
5708 dsp <= np->p_script + sizeof(struct script)) {
5709 vdsp_base = np->script;
5710 vdsp_off = dsp - np->p_script - 8;
5713 vdsp_base = np->scripth;
5714 vdsp_off = dsp - np->p_scripth - 8;
5728 cp, np->header.cp,
5774 OUTB (nc_dcntl, np->rv_dcntl | STD);
5808 np->profile.num_break++;
5811 OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, dispatch));
5813 OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, checkatn));
5842 static void ncr_int_sir (ncb_p np)
5850 tcb_p tp = &np->target[target];
5864 cp = np->link_nccb;
5871 assert (cp == np->header.cp);
5872 if (cp != np->header.cp)
5893 printf ("%s: int#%d",ncr_name (np),num);
5897 tp = &np->target[i];
5913 OUTL (nc_dsp, NCB_SCRIPTH_PHYS (np, getcc));
5942 np->target[cp->ccb->ccb_h.target_id].hold_cp = cp;
6044 ncr_setsync (np, cp, 0, 0xe0, 0);
6048 ncr_setwide (np, cp, 0, 0);
6052 np->msgin [0] = MSG_NOOP;
6053 np->msgout[0] = MSG_NOOP;
6055 OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, dispatch));
6066 (void) ncr_show_msg (np->msgin);
6075 per = np->msgin[3];
6076 ofs = np->msgin[4];
6082 if (per < np->minsync)
6083 {chg = 1; per = np->minsync;}
6096 ncr_getsync(np, per, &fak, &scntl3);
6126 ncr_setsync (np, cp, 0, 0xe0, 0);
6127 OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, msg_bad));
6132 ncr_setsync (np,cp,scntl3,(fak<<5)|ofs, per);
6133 OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, clrack));
6138 ncr_setwide (np, cp, 0, 0);
6148 ncr_setsync (np, cp, scntl3, (fak<<5)|ofs, per);
6150 np->msgout[0] = MSG_EXTENDED;
6151 np->msgout[1] = 3;
6152 np->msgout[2] = MSG_EXT_SDTR;
6153 np->msgout[3] = per;
6154 np->msgout[4] = ofs;
6161 (void) ncr_show_msg (np->msgout);
6166 OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, msg_bad));
6169 np->msgin [0] = MSG_NOOP;
6180 (void) ncr_show_msg (np->msgin);
6189 wide = np->msgin[3];
6215 ncr_setwide (np, cp, 0, 1);
6216 OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, msg_bad));
6221 ncr_setwide (np, cp, wide, 1);
6222 OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, clrack));
6227 ncr_setsync (np, cp, 0, 0xe0, 0);
6237 ncr_setwide (np, cp, wide, 1);
6239 np->msgout[0] = MSG_EXTENDED;
6240 np->msgout[1] = 2;
6241 np->msgout[2] = MSG_EXT_WDTR;
6242 np->msgout[3] = wide;
6244 np->msgin [0] = MSG_NOOP;
6251 (void) ncr_show_msg (np->msgout);
6273 (unsigned)np->lastmsg, np->msgout[0]);
6286 (void) ncr_show_msg (np->msgin);
6323 (unsigned) np->header.savep,
6324 (unsigned) np->header.goalp);
6343 ncr_freeze_devq(np, cp->ccb->ccb_h.path);
6344 ncr_complete(np, cp);
6359 cp = np->link_nccb;
6370 OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, reselect));
6378 printf ("%s: queue empty.\n", ncr_name (np));
6384 OUTB (nc_dcntl, np->rv_dcntl | STD);
6397 (ncb_p np, u_long target, u_long lun)
6410 lp = np->target[target].lp[lun];
6428 cp = ncr_alloc_nccb(np, target, lun);
6432 printf("%s: Bogus free cp found\n", ncr_name(np));
6451 static void ncr_free_nccb (ncb_p np, nccb_p cp)
6473 ncr_alloc_nccb (ncb_p np, u_long target, u_long lun)
6479 assert (np != NULL);
6484 tp=&np->target[target];
6492 tp->jump_tcb.l_paddr = np->jump_tcb.l_paddr;
6495 (np->features & FE_PFEN)? SCR_COPY(1) : SCR_COPY_F(1);
6497 tp->getscr[2] = rman_get_start(np->reg_res) + offsetof (struct ncr_reg, nc_sxfer);
6499 (np->features & FE_PFEN)? SCR_COPY(1) : SCR_COPY_F(1);
6501 tp->getscr[5] = rman_get_start(np->reg_res) + offsetof (struct ncr_reg, nc_scntl3);
6511 tp->call_lun.l_paddr = NCB_SCRIPT_PHYS (np, resel_lun);
6514 tp->jump_lcb.l_paddr = NCB_SCRIPTH_PHYS (np, abort);
6515 np->jump_tcb.l_paddr = vtophys (&tp->jump_tcb);
6537 lp->call_tag.l_paddr = NCB_SCRIPT_PHYS (np, resel_tag);
6540 lp->jump_nccb.l_paddr = NCB_SCRIPTH_PHYS (np, aborttag);
6577 cp->call_tmp.l_paddr = NCB_SCRIPT_PHYS (np, resel_tmp);
6582 cp->link_nccb = np->link_nccb;
6583 np->link_nccb = cp;
6718 static int ncr_regtest (struct ncb* np)
6742 static int ncr_snooptest (struct ncb* np)
6747 err |= ncr_regtest (np);
6753 pc = NCB_SCRIPTH_PHYS (np, snooptest);
6797 if (pc != NCB_SCRIPTH_PHYS (np, snoopend)+8) {
6800 (u_long) NCB_SCRIPTH_PHYS (np, snooptest), (u_long) pc,
6801 (u_long) NCB_SCRIPTH_PHYS (np, snoopend) +8);
6846 static void ncb_profile (ncb_p np, nccb_p cp)
6875 diff = (np->disc_phys - np->disc_ref) & 0xff;
6876 np->disc_ref += diff;
6878 np->profile.num_trans += 1;
6880 np->profile.num_bytes += cp->ccb->csio.dxfer_len;
6881 np->profile.num_disc += diff;
6882 np->profile.ms_setup += co;
6883 np->profile.ms_data += work;
6884 np->profile.ms_disc += disc;
6885 np->profile.ms_post += post;
6915 static void ncr_selectclock(ncb_p np, u_char scntl3)
6917 if (np->multiplier < 2) {
6923 printf ("%s: enabling clock multiplier\n", ncr_name(np));
6926 if (np->multiplier > 2) { /* Poll bit 5 of stest4 for quadrupler */
6931 printf("%s: the chip cannot lock the frequency\n", ncr_name(np));
6944 ncrgetfreq (ncb_p np, int gen)
6989 static void ncr_getclock (ncb_p np, u_char multiplier)
6996 np->multiplier = 1;
6999 np->multiplier = multiplier;
7000 np->clock_khz = 40000 * multiplier;
7005 (void) ncrgetfreq (np, 11);
7006 f1 = ncrgetfreq (np, 11);
7007 f2 = ncrgetfreq (np, 11);
7019 np->clock_khz = 80000; /* Probably a 875 rev. 1 ? */
7058 tekram_write_bit (ncb_p np, int bit)
7072 tekram_read_bit (ncb_p np)
7082 read_tekram_eeprom_reg (ncb_p np, int reg)
7090 tekram_write_bit (np, 1);
7093 tekram_write_bit (np, cmd >> bit);
7099 result |= tekram_read_bit (np);
7107 read_tekram_eeprom(ncb_p np, struct tekram_eeprom *buffer)
7121 val = read_tekram_eeprom_reg (np, i);