From df9d46b6d9e77db555ba7246673787cd8e1d0e51 Mon Sep 17 00:00:00 2001 From: Matt Jacob Date: Tue, 4 Jul 2000 01:04:35 +0000 Subject: [PATCH] Add in isp_lock/isp_unlock inlines. Add in an islocked/intsok flag to isp_osinfo substructure (all in prep for SMP). Define MBOX_WAIT_COMPLETE and MBOX_NOTIFY_COMPLETE macros so that we can now (temp) use tsleep to wait for mailbox completion. Requires us to guess whether we're servicing an interrupt or not- will use intr_nesting_level. Add local strncat function. --- sys/dev/isp/isp_freebsd.h | 91 +++++++++++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 9 deletions(-) diff --git a/sys/dev/isp/isp_freebsd.h b/sys/dev/isp/isp_freebsd.h index 37f6c56c775b..159b82af068e 100644 --- a/sys/dev/isp/isp_freebsd.h +++ b/sys/dev/isp/isp_freebsd.h @@ -44,11 +44,13 @@ #include #include #include +#include #include #include #include #include +#include #include #include @@ -112,7 +114,13 @@ struct isposinfo { struct cam_path *path; struct cam_sim *sim2; struct cam_path *path2; - volatile char simqfrozen; + struct intr_config_hook ehook; + volatile u_int16_t : 14, + islocked : 1, + intsok : 1; + u_int8_t mboxwaiting; + u_int8_t simqfrozen; + int splsaved; #ifdef ISP_TARGET_MODE #define TM_WANTED 0x01 #define TM_BUSY 0x02 @@ -143,13 +151,60 @@ struct isposinfo { #define DFLT_DBLEVEL isp_debug extern int isp_debug; -#define ISP_LOCKVAL_DECL int isp_spl_save -#define ISP_ILOCKVAL_DECL ISP_LOCKVAL_DECL -#define ISP_UNLOCK(isp) (void) splx(isp_spl_save) -#define ISP_LOCK(isp) isp_spl_save = splcam() -#define ISP_ILOCK(isp) ISP_LOCK(isp) -#define ISP_IUNLOCK(isp) ISP_UNLOCK(isp) -#define IMASK cam_imask + +static __inline void isp_lock(struct ispsoftc *); +static __inline void isp_unlock(struct ispsoftc *); + +static __inline void +isp_lock(struct ispsoftc *isp) +{ + int s = splcam(); + if (isp->isp_osinfo.islocked == 0) { + isp->isp_osinfo.islocked = 1; + isp->isp_osinfo.splsaved = s; + } else { + splx(s); + } +} + +static __inline void +isp_unlock(struct ispsoftc *isp) +{ + if (isp->isp_osinfo.islocked) { + isp->isp_osinfo.islocked = 0; + splx(isp->isp_osinfo.splsaved); + } +} + +#define ISP_LOCK isp_lock +#define ISP_UNLOCK isp_unlock +#define SERVICING_INTERRUPT(isp) (intr_nesting_level != 0) + +#define MBOX_WAIT_COMPLETE(isp) \ + if (isp->isp_osinfo.intsok == 0 || SERVICING_INTERRUPT(isp)) { \ + int j; \ + for (j = 0; j < 60 * 2000; j++) { \ + if (isp_intr(isp) == 0) { \ + SYS_DELAY(500); \ + } \ + if (isp->isp_mboxbsy == 0) \ + break; \ + } \ + if (isp->isp_mboxbsy != 0) \ + printf("%s: mailbox timeout\n", isp->isp_name); \ + } else { \ + isp->isp_osinfo.mboxwaiting = 1; \ + while (isp->isp_mboxbsy != 0) \ + (void) tsleep(&isp->isp_osinfo.mboxwaiting, PRIBIO, \ + "isp_mailbox", 0);\ + } + +#define MBOX_NOTIFY_COMPLETE(isp) \ + if (isp->isp_osinfo.mboxwaiting) { \ + isp->isp_osinfo.mboxwaiting = 0; \ + wakeup(&isp->isp_osinfo.mboxwaiting); \ + } \ + isp->isp_mboxbsy = 0 #define XS_NULL(ccb) ccb == NULL #define XS_ISP(ccb) ((struct ispsoftc *) (ccb)->ccb_h.spriv_ptr1) @@ -266,6 +321,25 @@ extern void isp_uninit(struct ispsoftc *); #define IDPRINTF(lev, x) if (isp->isp_dblev >= (u_int8_t) lev) printf x #define PRINTF printf #define CFGPRINTF if (bootverbose || DFLT_DBLEVEL > 1) printf +#define STRNCAT strncat +static __inline char *strncat(char *, const char *, size_t); +static __inline char * +strncat(char *d, const char *s, size_t c) +{ + char *t = d; + + if (c) { + while (*d) + d++; + while ((*d++ = *s++)) { + if (--c == 0) { + *d = '\0'; + break; + } + } + } + return (t); +} #define SYS_DELAY(x) DELAY(x) @@ -276,4 +350,3 @@ extern void isp_uninit(struct ispsoftc *); #define INLINE __inline #include #endif /* _ISP_FREEBSD_H */ -