--- src/sys/dev/disk/aic7xxx/aic7xxx_osm.h 2007/07/07 01:09:42 1.12 +++ src/sys/dev/disk/aic7xxx/aic7xxx_osm.h 2008/02/09 18:13:13 1.13 @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: aic7xxx_osm.h,v 1.12 2007/07/07 01:09:42 pavalos Exp $ + * $Id: aic7xxx_osm.h,v 1.13 2008/02/09 18:13:13 pavalos Exp $ * * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx_osm.h,v 1.30 2005/12/05 11:58:32 ru Exp $ * $DragonFly$ @@ -126,6 +126,17 @@ extern devclass_t ahc_devclass; /* This driver supports target mode */ #define AHC_TARGET_MODE 1 +/***************************** Core Includes **********************************/ +#ifdef AHC_REG_PRETTY_PRINT +#define AIC_DEBUG_REGISTERS 1 +#else +#define AIC_DEBUG_REGISTERS 0 +#endif +#define AIC_CORE_INCLUDE "aic7xxx.h" +#define AIC_LIB_PREFIX ahc +#define AIC_CONST_PREFIX AHC +#include "aic_osm_lib.h" + /************************** Softc/SCB Platform Data ***************************/ struct ahc_platform_data { /* @@ -144,22 +155,12 @@ struct ahc_platform_data { void *ih; eventhandler_tag eh; struct thread *recovery_thread; + struct lock lock; }; struct scb_platform_data { }; -/***************************** Core Includes **********************************/ -#ifdef AHC_REG_PRETTY_PRINT -#define AIC_DEBUG_REGISTERS 1 -#else -#define AIC_DEBUG_REGISTERS 0 -#endif -#define AIC_CORE_INCLUDE "aic7xxx.h" -#define AIC_LIB_PREFIX ahc -#define AIC_CONST_PREFIX AHC -#include "aic_osm_lib.h" - /*************************** Device Access ************************************/ #define ahc_inb(ahc, port) \ bus_space_read_1((ahc)->tag, (ahc)->bsh, port) @@ -184,19 +185,26 @@ ahc_flush_device_writes(struct ahc_softc /**************************** Locking Primitives ******************************/ /* Lock protecting internal data structures */ -static __inline void ahc_lock(void); -static __inline void ahc_unlock(void); +static __inline void ahc_lockinit(struct ahc_softc *); +static __inline void ahc_lock(struct ahc_softc *); +static __inline void ahc_unlock(struct ahc_softc *); + +static __inline void +ahc_lockinit(struct ahc_softc *ahc) +{ + lockinit(&ahc->platform_data->lock, "ahc_lock", 0, LK_EXCLUSIVE|LK_CANRECURSE); +} static __inline void -ahc_lock(void) +ahc_lock(struct ahc_softc *ahc) { - crit_enter_id("ahc"); + lockmgr(&ahc->platform_data->lock, LK_EXCLUSIVE); } static __inline void -ahc_unlock(void) +ahc_unlock(struct ahc_softc *ahc) { - crit_exit_id("ahc"); + lockmgr(&ahc->platform_data->lock, LK_RELEASE); } /************************* Initialization/Teardown ****************************/