OpenSS7
SS7 for the
Common Man

© Copyright 1997-2004,OpenSS7 Corporation, All Rights Reserved.
Last modified:

Home Overview Status News Documentation Resources About
   
 Overview
 Status
 News
 Documentation
 Resources
 About

   
Home Index Prev Next More Download Info FAQ Mail   Home -> Resources -> Browse Source -> strss7/drivers/lmi/lm.h


File /code/strss7/drivers/lmi/lm.h



#ifndef __LMI_LM_H__
#define __LMI_LM_H__

#ident "@(#) $RCSfile: lm.h,v $ $Name:  $($Revision: 0.8.2.4 $) $Date: 2003/03/25 11:50:28 $"

struct lmi;

typedef struct lmi_devops {
	struct lmi *(*attach) (dev_t);
	int (*open) (struct lmi *);
	int (*close) (struct lmi *);
} lmi_devops_t;

typedef struct lmi_lmiops {
	int (*info) (struct lmi *, void **, int *);
	int (*attach) (struct lmi *, void *, int);
	int (*detach) (struct lmi *);
	int (*enable) (struct lmi *);
	int (*disable) (struct lmi *);
	int (*ioctl) (struct lmi *, int, void *);
} lmi_lmiops_t;

typedef struct lmi_ops {
	lmi_devops_t dev;		/* device management */
	lmi_lmiops_t lmi;		/* local management calls */
} lmi_ops_t;

typedef struct lmi_driver {
	struct lmi_driver *next;	/* next driver structure */
	int cmajor;			/* major device number */
	int nminor;			/* number of minor devices */
	struct lmi *list;		/* list of device structures */
	struct streamtab *info;		/* streamtab for this driver */
	struct lmi_ops ops;		/* device operations */
	void *dcalls;			/* module calling driver */
	void *ucalls;			/* driver calling module */
} lmi_driver_t;

typedef struct lmi {
	struct lmi *next;		/* next device in device list */
	struct lmi *module;		/* upper for dev/mux, other for mod */
	void *ucalls;			/* upper module calls */
	void *dcalls;			/* lower device calls */
	struct lmi *device;		/* driver device (lower for mux) */
	lmi_driver_t *driver;		/* driver struct for driver */
	dev_t devnum;			/* driver device (null for module) */
	struct queue *rq;		/* read queue */
	struct queue *wq;		/* write queue */
	lis_spin_lock_t lock;		/* spin lock for SMP */
	void *user;			/* user of this structure */
	uint nest;			/* nested locks */
	lmi_ulong state;		/* LM interface state */
	lmi_ulong flags;		/* LM interface flags */
	lmi_ulong ids[0];		/* Protocol structure follows */
} lmi_t;

#define LMI_PRIV(__q) ((lmi_t *)(__q)->q_ptr)
#define lmi_init_lock(__lmi) lis_spin_lock_init(&(__lmi)->lock,"lmi-private")
#define lmi_locked(__lmi) ((__lmi)->user)

static inline int lmi_trylock(lmi_t * lmi)
{
	lis_spin_lock_t *lock = &lmi->lock;
	lis_spin_lock(lock);
	if (lmi->user && lmi->user != current) {
		lis_spin_unlock(lock);
		return (1);
	}
	lmi->user = current;
	lmi->next++;
	lis_spin_unlock(lock);
	return (0);
}

static inline void lmi_unlock(lmi_t * lmi)
{
	lis_spin_lock_t *lock = &lmi->lock;
	lis_spin_lock(lock);
	if (lmi->nest && lmi->user == current) {
		if (!--lmi->nest)
			lmi->user = NULL;
	} else {
		ptrace(("LMI: ERROR: Double unlock, nest = %d\n", lmi->nest));
		lmi->user = NULL;
		lmi->nest = 0;
	}
	lis_spin_unlock(lock);
}

extern int lmi_info(struct lmi *, void **, int *);
extern int lmi_attach(struct lmi *, void *, int);
extern int lmi_detach(struct lmi *);
extern int lmi_enable(struct lmi *);
extern int lmi_disable(struct lmi *);

extern int (*lmi_lmi_ops[5]) (lmi_t *, mblk_t *);

extern lmi_t *lmi_drv_attach(dev_t, lmi_driver_t *, size_t);
extern int lmi_drv_open(lmi_t * lmi);
extern int lmi_drv_close(lmi_t * lmi, lmi_ulong * tids, int ntids, lmi_ulong * bids, int nbids);

extern int lmi_mux_open(queue_t * q, dev_t * devp, int flag, int sflag,
			cred_t * crp, lmi_driver_t * list, size_t size);
extern int lmi_mux_close(queue_t * q, int flag, cred_t * crp,
			 lmi_ulong * tids, int ntids, lmi_ulong * bids, int nbids);

extern int lmi_open(queue_t * q, dev_t * devp, int flag, int sflag,
		    cred_t * crp, lmi_driver_t * list, size_t size);
extern int lmi_close(queue_t * q, int flag, cred_t * crp,
		     lmi_ulong * tids, int ntids, lmi_ulong * bids, int nbids);

extern int lmi_register_driver(lmi_driver_t ** list, major_t cmajor,
			       struct streamtab *strtab, int nminor, char *name,
			       lmi_ops_t * ops, void *dcalls, void *ucalls);
extern int lmi_unregister_driver(lmi_driver_t **, major_t);

#endif				/* __LMI_LM_H__ */


Home Index Prev Next More Download Info FAQ Mail   Home -> Resources -> Browse Source -> strss7/drivers/lmi/lm.h

OpenSS7
SS7 for the
Common Man
Home Overview Status News Documentation Resources About

© Copyright 1997-2004,OpenSS7 Corporation, All Rights Reserved.
Last modified: