1 /* $FreeBSD$ */ 2 /*- 3 * Qlogic ISP SCSI Host Adapter FreeBSD Wrapper Definitions 4 * 5 * Copyright (c) 1997-2006 by Matthew Jacob 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice immediately at the beginning of the file, without modification, 13 * this list of conditions, and the following disclaimer. 14 * 2. The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 #ifndef _ISP_FREEBSD_H 30 #define _ISP_FREEBSD_H 31 32 #include <sys/param.h> 33 #include <sys/systm.h> 34 #include <sys/endian.h> 35 #if __FreeBSD_version < 500000 36 #include <sys/kernel.h> 37 #include <sys/queue.h> 38 #include <sys/malloc.h> 39 #else 40 #include <sys/lock.h> 41 #include <sys/kernel.h> 42 #include <sys/queue.h> 43 #include <sys/malloc.h> 44 #include <sys/mutex.h> 45 #include <sys/condvar.h> 46 #endif 47 48 #include <sys/proc.h> 49 #include <sys/bus.h> 50 51 #include <machine/bus.h> 52 #if __FreeBSD_version < 500000 53 #include <machine/clock.h> 54 #endif 55 #include <machine/cpu.h> 56 57 #include <cam/cam.h> 58 #include <cam/cam_debug.h> 59 #include <cam/cam_ccb.h> 60 #include <cam/cam_sim.h> 61 #include <cam/cam_xpt.h> 62 #include <cam/cam_xpt_sim.h> 63 #include <cam/cam_debug.h> 64 #include <cam/scsi/scsi_all.h> 65 #include <cam/scsi/scsi_message.h> 66 67 #include "opt_ddb.h" 68 #include "opt_isp.h" 69 70 #if __FreeBSD_version < 500000 71 #define ISP_PLATFORM_VERSION_MAJOR 4 72 #define ISP_PLATFORM_VERSION_MINOR 17 73 #else 74 #define ISP_PLATFORM_VERSION_MAJOR 5 75 #define ISP_PLATFORM_VERSION_MINOR 9 76 #endif 77 78 /* 79 * Efficiency- get rid of SBus code && tests unless we need them. 80 */ 81 #ifdef __sparc64__ 82 #define ISP_SBUS_SUPPORTED 1 83 #else 84 #define ISP_SBUS_SUPPORTED 0 85 #endif 86 87 #define HANDLE_LOOPSTATE_IN_OUTER_LAYERS 1 88 /* #define ISP_SMPLOCK 1 */ 89 90 #if __FreeBSD_version < 500000 91 #define ISP_IFLAGS INTR_TYPE_CAM 92 #else 93 #ifdef ISP_SMPLOCK 94 #define ISP_IFLAGS INTR_TYPE_CAM | INTR_ENTROPY | INTR_MPSAFE 95 #else 96 #define ISP_IFLAGS INTR_TYPE_CAM | INTR_ENTROPY 97 #endif 98 #endif 99 100 #if __FreeBSD_version < 700000 101 typedef void ispfwfunc(int, int, int, uint16_t **); 102 #endif 103 104 #ifdef ISP_TARGET_MODE 105 #define ISP_TARGET_FUNCTIONS 1 106 #define ATPDPSIZE 256 107 typedef struct { 108 uint32_t orig_datalen; 109 uint32_t bytes_xfered; 110 uint32_t last_xframt; 111 uint32_t tag : 16, 112 lun : 13, /* not enough */ 113 state : 3; 114 } atio_private_data_t; 115 #define ATPD_STATE_FREE 0 116 #define ATPD_STATE_ATIO 1 117 #define ATPD_STATE_CAM 2 118 #define ATPD_STATE_CTIO 3 119 #define ATPD_STATE_LAST_CTIO 4 120 #define ATPD_STATE_PDON 5 121 122 typedef struct tstate { 123 struct tstate *next; 124 struct cam_path *owner; 125 struct ccb_hdr_slist atios; 126 struct ccb_hdr_slist inots; 127 lun_id_t lun; 128 int bus; 129 uint32_t hold; 130 int atio_count; 131 int inot_count; 132 } tstate_t; 133 134 #define LUN_HASH_SIZE 32 135 #define LUN_HASH_FUNC(isp, port, lun) \ 136 ((IS_DUALBUS(isp)) ? \ 137 (((lun) & ((LUN_HASH_SIZE >> 1) - 1)) << (port)) : \ 138 ((lun) & (LUN_HASH_SIZE - 1))) 139 #endif 140 141 struct isposinfo { 142 struct ispsoftc * next; 143 uint64_t default_port_wwn; 144 uint64_t default_node_wwn; 145 uint32_t default_id; 146 device_t dev; 147 struct cam_sim *sim; 148 struct cam_path *path; 149 struct cam_sim *sim2; 150 struct cam_path *path2; 151 struct intr_config_hook ehook; 152 uint16_t loop_down_time; 153 uint16_t loop_down_limit; 154 uint32_t : 5, 155 simqfrozen : 3, 156 hysteresis : 8, 157 : 4, 158 disabled : 1, 159 fcbsy : 1, 160 mboxcmd_done : 1, 161 mboxbsy : 1; 162 #if __FreeBSD_version >= 500000 163 struct firmware * fw; 164 struct mtx lock; 165 struct cv kthread_cv; 166 union { 167 struct { 168 char wwnn[17]; 169 char wwpn[17]; 170 } fc; 171 struct { 172 int iid; 173 } spi; 174 } sysctl_info; 175 #endif 176 struct proc *kproc; 177 bus_dma_tag_t cdmat; 178 bus_dmamap_t cdmap; 179 #define isp_cdmat isp_osinfo.cdmat 180 #define isp_cdmap isp_osinfo.cdmap 181 #ifdef ISP_TARGET_MODE 182 #define TM_WILDCARD_ENABLED 0x02 183 #define TM_TMODE_ENABLED 0x01 184 uint8_t tmflags[2]; /* two busses */ 185 #define NLEACT 4 186 union ccb * leact[NLEACT]; 187 tstate_t tsdflt[2]; /* two busses */ 188 tstate_t *lun_hash[LUN_HASH_SIZE]; 189 atio_private_data_t atpdp[ATPDPSIZE]; 190 #endif 191 }; 192 193 #define isp_lock isp_osinfo.lock 194 195 /* 196 * Locking macros... 197 */ 198 199 #ifdef ISP_SMPLOCK 200 #define ISP_LOCK(x) mtx_lock(&(x)->isp_lock) 201 #define ISP_UNLOCK(x) mtx_unlock(&(x)->isp_lock) 202 #define ISPLOCK_2_CAMLOCK(isp) \ 203 mtx_unlock(&(isp)->isp_lock); mtx_lock(&Giant) 204 #define CAMLOCK_2_ISPLOCK(isp) \ 205 mtx_unlock(&Giant); mtx_lock(&(isp)->isp_lock) 206 #else 207 #define ISP_LOCK(x) do { } while (0) 208 #define ISP_UNLOCK(x) do { } while (0) 209 #define ISPLOCK_2_CAMLOCK(isp) do { } while (0) 210 #define CAMLOCK_2_ISPLOCK(isp) do { } while (0) 211 #endif 212 213 /* 214 * Required Macros/Defines 215 */ 216 217 #define ISP2100_SCRLEN 0x1000 218 219 #define MEMZERO(a, b) memset(a, 0, b) 220 #define MEMCPY memcpy 221 #define SNPRINTF snprintf 222 #define USEC_DELAY DELAY 223 #define USEC_SLEEP(isp, x) DELAY(x) 224 225 #define NANOTIME_T struct timespec 226 #define GET_NANOTIME nanotime 227 #define GET_NANOSEC(x) ((x)->tv_sec * 1000000000 + (x)->tv_nsec) 228 #define NANOTIME_SUB nanotime_sub 229 230 #define MAXISPREQUEST(isp) ((IS_FC(isp) || IS_ULTRA2(isp))? 1024 : 256) 231 232 #define MEMORYBARRIER(isp, type, offset, size) \ 233 switch (type) { \ 234 case SYNC_SFORDEV: \ 235 case SYNC_REQUEST: \ 236 bus_dmamap_sync(isp->isp_cdmat, isp->isp_cdmap, \ 237 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); \ 238 break; \ 239 case SYNC_SFORCPU: \ 240 case SYNC_RESULT: \ 241 bus_dmamap_sync(isp->isp_cdmat, isp->isp_cdmap, \ 242 BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); \ 243 break; \ 244 default: \ 245 break; \ 246 } 247 248 #define MBOX_ACQUIRE isp_mbox_acquire 249 #define MBOX_WAIT_COMPLETE isp_mbox_wait_complete 250 #define MBOX_NOTIFY_COMPLETE(isp) isp->isp_osinfo.mboxcmd_done = 1 251 #define MBOX_RELEASE isp_mbox_release 252 253 #define FC_SCRATCH_ACQUIRE(isp) \ 254 if (isp->isp_osinfo.fcbsy) { \ 255 isp_prt(isp, ISP_LOGWARN, \ 256 "FC scratch area busy (line %d)!", __LINE__); \ 257 } else \ 258 isp->isp_osinfo.fcbsy = 1 259 #define FC_SCRATCH_RELEASE(isp) isp->isp_osinfo.fcbsy = 0 260 261 #ifndef SCSI_GOOD 262 #define SCSI_GOOD SCSI_STATUS_OK 263 #endif 264 #ifndef SCSI_CHECK 265 #define SCSI_CHECK SCSI_STATUS_CHECK_COND 266 #endif 267 #ifndef SCSI_BUSY 268 #define SCSI_BUSY SCSI_STATUS_BUSY 269 #endif 270 #ifndef SCSI_QFULL 271 #define SCSI_QFULL SCSI_STATUS_QUEUE_FULL 272 #endif 273 274 #define XS_T struct ccb_scsiio 275 #define XS_DMA_ADDR_T bus_addr_t 276 #define XS_ISP(ccb) ((ispsoftc_t *) (ccb)->ccb_h.spriv_ptr1) 277 #define XS_CHANNEL(ccb) cam_sim_bus(xpt_path_sim((ccb)->ccb_h.path)) 278 #define XS_TGT(ccb) (ccb)->ccb_h.target_id 279 #define XS_LUN(ccb) (ccb)->ccb_h.target_lun 280 281 #define XS_CDBP(ccb) \ 282 (((ccb)->ccb_h.flags & CAM_CDB_POINTER)? \ 283 (ccb)->cdb_io.cdb_ptr : (ccb)->cdb_io.cdb_bytes) 284 285 #define XS_CDBLEN(ccb) (ccb)->cdb_len 286 #define XS_XFRLEN(ccb) (ccb)->dxfer_len 287 #define XS_TIME(ccb) (ccb)->ccb_h.timeout 288 #define XS_RESID(ccb) (ccb)->resid 289 #define XS_STSP(ccb) (&(ccb)->scsi_status) 290 #define XS_SNSP(ccb) (&(ccb)->sense_data) 291 292 #define XS_SNSLEN(ccb) \ 293 imin((sizeof((ccb)->sense_data)), ccb->sense_len) 294 295 #define XS_SNSKEY(ccb) ((ccb)->sense_data.flags & 0xf) 296 #define XS_TAG_P(ccb) \ 297 (((ccb)->ccb_h.flags & CAM_TAG_ACTION_VALID) && \ 298 (ccb)->tag_action != CAM_TAG_ACTION_NONE) 299 300 #define XS_TAG_TYPE(ccb) \ 301 ((ccb->tag_action == MSG_SIMPLE_Q_TAG)? REQFLAG_STAG : \ 302 ((ccb->tag_action == MSG_HEAD_OF_Q_TAG)? REQFLAG_HTAG : REQFLAG_OTAG)) 303 304 305 #define XS_SETERR(ccb, v) (ccb)->ccb_h.status &= ~CAM_STATUS_MASK, \ 306 (ccb)->ccb_h.status |= v, \ 307 (ccb)->ccb_h.spriv_field0 |= ISP_SPRIV_ERRSET 308 309 # define HBA_NOERROR CAM_REQ_INPROG 310 # define HBA_BOTCH CAM_UNREC_HBA_ERROR 311 # define HBA_CMDTIMEOUT CAM_CMD_TIMEOUT 312 # define HBA_SELTIMEOUT CAM_SEL_TIMEOUT 313 # define HBA_TGTBSY CAM_SCSI_STATUS_ERROR 314 # define HBA_BUSRESET CAM_SCSI_BUS_RESET 315 # define HBA_ABORTED CAM_REQ_ABORTED 316 # define HBA_DATAOVR CAM_DATA_RUN_ERR 317 # define HBA_ARQFAIL CAM_AUTOSENSE_FAIL 318 319 320 #define XS_ERR(ccb) ((ccb)->ccb_h.status & CAM_STATUS_MASK) 321 322 #define XS_NOERR(ccb) \ 323 (((ccb)->ccb_h.spriv_field0 & ISP_SPRIV_ERRSET) == 0 || \ 324 ((ccb)->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INPROG) 325 326 #define XS_INITERR(ccb) \ 327 XS_SETERR(ccb, CAM_REQ_INPROG), (ccb)->ccb_h.spriv_field0 = 0 328 329 #define XS_SAVE_SENSE(xs, sp) \ 330 (xs)->ccb_h.status |= CAM_AUTOSNS_VALID, \ 331 memcpy(&(xs)->sense_data, sp->req_sense_data, \ 332 imin(XS_SNSLEN(xs), sp->req_sense_len)) 333 334 #define XS_SET_STATE_STAT(a, b, c) 335 336 #define DEFAULT_IID(x) (isp)->isp_osinfo.default_id 337 #define DEFAULT_LOOPID(x) (isp)->isp_osinfo.default_id 338 #define DEFAULT_NODEWWN(isp) (isp)->isp_osinfo.default_node_wwn 339 #define DEFAULT_PORTWWN(isp) (isp)->isp_osinfo.default_port_wwn 340 #define ISP_NODEWWN(isp) FCPARAM(isp)->isp_nodewwn 341 #define ISP_PORTWWN(isp) FCPARAM(isp)->isp_portwwn 342 343 #if BYTE_ORDER == BIG_ENDIAN 344 #ifdef ISP_SBUS_SUPPORTED 345 #define ISP_IOXPUT_8(isp, s, d) *(d) = s 346 #define ISP_IOXPUT_16(isp, s, d) \ 347 *(d) = (isp->isp_bustype == ISP_BT_SBUS)? s : bswap16(s) 348 #define ISP_IOXPUT_32(isp, s, d) \ 349 *(d) = (isp->isp_bustype == ISP_BT_SBUS)? s : bswap32(s) 350 #define ISP_IOXGET_8(isp, s, d) d = (*((uint8_t *)s)) 351 #define ISP_IOXGET_16(isp, s, d) \ 352 d = (isp->isp_bustype == ISP_BT_SBUS)? \ 353 *((uint16_t *)s) : bswap16(*((uint16_t *)s)) 354 #define ISP_IOXGET_32(isp, s, d) \ 355 d = (isp->isp_bustype == ISP_BT_SBUS)? \ 356 *((uint32_t *)s) : bswap32(*((uint32_t *)s)) 357 358 #else /* ISP_SBUS_SUPPORTED */ 359 #define ISP_IOXPUT_8(isp, s, d) *(d) = s 360 #define ISP_IOXPUT_16(isp, s, d) *(d) = bswap16(s) 361 #define ISP_IOXPUT_32(isp, s, d) *(d) = bswap32(s) 362 #define ISP_IOXGET_8(isp, s, d) d = (*((uint8_t *)s)) 363 #define ISP_IOXGET_16(isp, s, d) d = bswap16(*((uint16_t *)s)) 364 #define ISP_IOXGET_32(isp, s, d) d = bswap32(*((uint32_t *)s)) 365 #endif 366 #define ISP_SWIZZLE_NVRAM_WORD(isp, rp) *rp = bswap16(*rp) 367 368 #define ISP_IOZGET_8(isp, s, d) d = (*((uint8_t *)s)) 369 #define ISP_IOZGET_16(isp, s, d) d = (*((uint16_t *)s)) 370 #define ISP_IOZGET_32(isp, s, d) d = (*((uint32_t *)s)) 371 #define ISP_IOZPUT_8(isp, s, d) *(d) = s 372 #define ISP_IOZPUT_16(isp, s, d) *(d) = s 373 #define ISP_IOZPUT_32(isp, s, d) *(d) = s 374 375 376 #else 377 #define ISP_IOXPUT_8(isp, s, d) *(d) = s 378 #define ISP_IOXPUT_16(isp, s, d) *(d) = s 379 #define ISP_IOXPUT_32(isp, s, d) *(d) = s 380 #define ISP_IOXGET_8(isp, s, d) d = *(s) 381 #define ISP_IOXGET_16(isp, s, d) d = *(s) 382 #define ISP_IOXGET_32(isp, s, d) d = *(s) 383 #define ISP_SWIZZLE_NVRAM_WORD(isp, rp) 384 385 #define ISP_IOZPUT_8(isp, s, d) *(d) = s 386 #define ISP_IOZPUT_16(isp, s, d) *(d) = bswap16(s) 387 #define ISP_IOZPUT_32(isp, s, d) *(d) = bswap32(s) 388 389 #define ISP_IOZGET_8(isp, s, d) d = (*((uint8_t *)(s))) 390 #define ISP_IOZGET_16(isp, s, d) d = bswap16(*((uint16_t *)(s))) 391 #define ISP_IOZGET_32(isp, s, d) d = bswap32(*((uint32_t *)(s))) 392 393 #endif 394 395 /* 396 * Includes of common header files 397 */ 398 399 #include <dev/isp/ispreg.h> 400 #include <dev/isp/ispvar.h> 401 #include <dev/isp/ispmbox.h> 402 403 #ifdef ISP_TARGET_MODE 404 #include <dev/isp/isp_tpublic.h> 405 #endif 406 407 void isp_prt(ispsoftc_t *, int level, const char *, ...) 408 __printflike(3, 4); 409 /* 410 * isp_osinfo definiitions && shorthand 411 */ 412 #define SIMQFRZ_RESOURCE 0x1 413 #define SIMQFRZ_LOOPDOWN 0x2 414 #define SIMQFRZ_TIMED 0x4 415 416 #define isp_sim isp_osinfo.sim 417 #define isp_path isp_osinfo.path 418 #define isp_sim2 isp_osinfo.sim2 419 #define isp_path2 isp_osinfo.path2 420 #define isp_dev isp_osinfo.dev 421 422 /* 423 * prototypes for isp_pci && isp_freebsd to share 424 */ 425 extern void isp_attach(ispsoftc_t *); 426 extern void isp_uninit(ispsoftc_t *); 427 428 /* 429 * driver global data 430 */ 431 extern int isp_announced; 432 extern int isp_fabric_hysteresis; 433 extern int isp_loop_down_limit; 434 extern int isp_quickboot_time; 435 436 /* 437 * Platform private flags 438 */ 439 #define ISP_SPRIV_ERRSET 0x1 440 #define ISP_SPRIV_INWDOG 0x2 441 #define ISP_SPRIV_GRACE 0x4 442 #define ISP_SPRIV_DONE 0x8 443 444 #define XS_CMD_S_WDOG(sccb) (sccb)->ccb_h.spriv_field0 |= ISP_SPRIV_INWDOG 445 #define XS_CMD_C_WDOG(sccb) (sccb)->ccb_h.spriv_field0 &= ~ISP_SPRIV_INWDOG 446 #define XS_CMD_WDOG_P(sccb) ((sccb)->ccb_h.spriv_field0 & ISP_SPRIV_INWDOG) 447 448 #define XS_CMD_S_GRACE(sccb) (sccb)->ccb_h.spriv_field0 |= ISP_SPRIV_GRACE 449 #define XS_CMD_C_GRACE(sccb) (sccb)->ccb_h.spriv_field0 &= ~ISP_SPRIV_GRACE 450 #define XS_CMD_GRACE_P(sccb) ((sccb)->ccb_h.spriv_field0 & ISP_SPRIV_GRACE) 451 452 #define XS_CMD_S_DONE(sccb) (sccb)->ccb_h.spriv_field0 |= ISP_SPRIV_DONE 453 #define XS_CMD_C_DONE(sccb) (sccb)->ccb_h.spriv_field0 &= ~ISP_SPRIV_DONE 454 #define XS_CMD_DONE_P(sccb) ((sccb)->ccb_h.spriv_field0 & ISP_SPRIV_DONE) 455 456 #define XS_CMD_S_CLEAR(sccb) (sccb)->ccb_h.spriv_field0 = 0 457 458 /* 459 * Platform specific inline functions 460 */ 461 462 static __inline int isp_mbox_acquire(ispsoftc_t *); 463 static __inline void isp_mbox_wait_complete(ispsoftc_t *, mbreg_t *); 464 static __inline void isp_mbox_release(ispsoftc_t *); 465 466 static __inline int 467 isp_mbox_acquire(ispsoftc_t *isp) 468 { 469 if (isp->isp_osinfo.mboxbsy) { 470 return (1); 471 } else { 472 isp->isp_osinfo.mboxcmd_done = 0; 473 isp->isp_osinfo.mboxbsy = 1; 474 return (0); 475 } 476 } 477 478 static __inline void 479 isp_mbox_wait_complete(ispsoftc_t *isp, mbreg_t *mbp) 480 { 481 int lim = mbp->timeout; 482 int j; 483 484 if (lim == 0) { 485 lim = MBCMD_DEFAULT_TIMEOUT; 486 } 487 if (isp->isp_mbxwrk0) { 488 lim *= isp->isp_mbxwrk0; 489 } 490 for (j = 0; j < lim; j += 100) { 491 uint32_t isr; 492 uint16_t sema, mbox; 493 if (isp->isp_osinfo.mboxcmd_done) { 494 break; 495 } 496 if (ISP_READ_ISR(isp, &isr, &sema, &mbox)) { 497 isp_intr(isp, isr, sema, mbox); 498 if (isp->isp_osinfo.mboxcmd_done) { 499 break; 500 } 501 } 502 USEC_DELAY(100); 503 } 504 if (isp->isp_osinfo.mboxcmd_done == 0) { 505 isp_prt(isp, ISP_LOGWARN, 506 "Polled Mailbox Command (0x%x) Timeout", 507 isp->isp_lastmbxcmd); 508 mbp->param[0] = MBOX_TIMEOUT; 509 isp->isp_osinfo.mboxcmd_done = 1; 510 } 511 } 512 513 static __inline void 514 isp_mbox_release(ispsoftc_t *isp) 515 { 516 isp->isp_osinfo.mboxbsy = 0; 517 } 518 519 static __inline uint64_t nanotime_sub(struct timespec *, struct timespec *); 520 static __inline uint64_t 521 nanotime_sub(struct timespec *b, struct timespec *a) 522 { 523 uint64_t elapsed; 524 struct timespec x = *b; 525 timespecsub(&x, a); 526 elapsed = GET_NANOSEC(&x); 527 if (elapsed == 0) 528 elapsed++; 529 return (elapsed); 530 } 531 532 static __inline char *strncat(char *, const char *, size_t); 533 static __inline char * 534 strncat(char *d, const char *s, size_t c) 535 { 536 char *t = d; 537 538 if (c) { 539 while (*d) 540 d++; 541 while ((*d++ = *s++)) { 542 if (--c == 0) { 543 *d = '\0'; 544 break; 545 } 546 } 547 } 548 return (t); 549 } 550 551 /* 552 * ISP Library functions 553 */ 554 555 #include <dev/isp/isp_library.h> 556 557 #endif /* _ISP_FREEBSD_H */ 558