gigaset.h

来自「LINUX 2.6.17.4的源码」· C头文件 代码 · 共 906 行 · 第 1/2 页

H
906
字号
	atomic_t mode;			/* see M_XXXX */	atomic_t mstate;		/* Modem state: see MS_XXXX */					/* only changed by the event layer */	int cmd_result;	int channels;	struct bc_state *bcs;		/* Array of struct bc_state */	int onechannel;			/* data and commands transmitted in one					   stream (M10x) */	spinlock_t lock;	struct at_state_t at_state;	/* at_state_t for cid == 0 */	struct list_head temp_at_states;/* list of temporary "struct					   at_state_t"s without B channel */	struct inbuf_t *inbuf;	struct cmdbuf_t *cmdbuf, *lastcmdbuf;	spinlock_t cmdlock;	unsigned curlen, cmdbytes;	unsigned open_count;	struct tty_struct *tty;	struct tasklet_struct if_wake_tasklet;	unsigned control_state;	unsigned fwver[4];	int gotfwver;	unsigned running;		/* !=0 if events are handled */	unsigned connected;		/* !=0 if hardware is connected */	unsigned isdn_up;		/* !=0 after ISDN_STAT_RUN */	unsigned cidmode;	int myid;			/* id for communication with LL */	isdn_if iif;	struct reply_t *tabnocid;	struct reply_t *tabcid;	int cs_init;	int ignoreframes;		/* frames to ignore after setting up the					   B channel */	struct mutex mutex;		/* locks this structure:					 *   connected is not changed,					 *   hardware_up is not changed,					 *   MState is not changed to or from					 *   MS_LOCKED */	struct timer_list timer;	int retry_count;	int dle;			/* !=0 if modem commands/responses are					   dle encoded */	int cur_at_seq;			/* sequence of AT commands being					   processed */	int curchannel;			/* channel those commands are meant					   for */	atomic_t commands_pending;	/* flag(s) in xxx.commands_pending have					   been set */	struct tasklet_struct event_tasklet;					/* tasklet for serializing AT commands.					 * Scheduled					 *   -> for modem reponses (and					 *      incoming data for M10x)					 *   -> on timeout					 *   -> after setting bits in					 *      xxx.at_state.pending_command					 *      (e.g. command from LL) */	struct tasklet_struct write_tasklet;					/* tasklet for serial output					 * (not used in base driver) */	/* event queue */	struct event_t events[MAX_EVENTS];	unsigned ev_tail, ev_head;	spinlock_t ev_lock;	/* current modem response */	unsigned char respdata[MAX_RESP_SIZE];	unsigned cbytes;	/* private data of hardware drivers */	union {		struct usb_cardstate *usb; /* USB hardware driver (m105) */		struct ser_cardstate *ser; /* serial hardware driver */		struct bas_cardstate *bas; /* USB hardware driver (base) */	} hw;};struct gigaset_driver {	struct list_head list;	spinlock_t lock;		/* locks minor tables and blocked */	struct tty_driver *tty;	unsigned have_tty;	unsigned minor;	unsigned minors;	struct cardstate *cs;	unsigned *flags;	int blocked;	const struct gigaset_ops *ops;	struct module *owner;};struct cmdbuf_t {	struct cmdbuf_t *next, *prev;	int len, offset;	struct tasklet_struct *wake_tasklet;	unsigned char buf[0];};struct bas_bc_state {	/* isochronous output state */	atomic_t	running;	atomic_t	corrbytes;	spinlock_t	isooutlock;	struct isow_urbctx_t	isoouturbs[BAS_OUTURBS];	struct isow_urbctx_t	*isooutdone, *isooutfree, *isooutovfl;	struct isowbuf_t	*isooutbuf;	unsigned numsub;		/* submitted URB counter					   (for diagnostic messages only) */	struct tasklet_struct	sent_tasklet;	/* isochronous input state */	spinlock_t isoinlock;	struct urb *isoinurbs[BAS_INURBS];	unsigned char isoinbuf[BAS_INBUFSIZE * BAS_INURBS];	struct urb *isoindone;		/* completed isoc read URB */	int loststatus;			/* status of dropped URB */	unsigned isoinlost;		/* number of bytes lost */	/* state of bit unstuffing algorithm	   (in addition to BC_state.inputstate) */	unsigned seqlen;		/* number of '1' bits not yet					   unstuffed */	unsigned inbyte, inbits;	/* collected bits for next byte */	/* statistics */	unsigned goodbytes;		/* bytes correctly received */	unsigned alignerrs;		/* frames with incomplete byte at end */	unsigned fcserrs;		/* FCS errors */	unsigned frameerrs;		/* framing errors */	unsigned giants;		/* long frames */	unsigned runts;			/* short frames */	unsigned aborts;		/* HDLC aborts */	unsigned shared0s;		/* '0' bits shared between flags */	unsigned stolen0s;		/* '0' stuff bits also serving as					   leading flag bits */	struct tasklet_struct rcvd_tasklet;};struct gigaset_ops {	/* Called from ev-layer.c/interface.c for sending AT commands to the	   device */	int (*write_cmd)(struct cardstate *cs,			 const unsigned char *buf, int len,			 struct tasklet_struct *wake_tasklet);	/* Called from interface.c for additional device control */	int (*write_room)(struct cardstate *cs);	int (*chars_in_buffer)(struct cardstate *cs);	int (*brkchars)(struct cardstate *cs, const unsigned char buf[6]);	/* Called from ev-layer.c after setting up connection	 * Should call gigaset_bchannel_up(), when finished. */	int (*init_bchannel)(struct bc_state *bcs);	/* Called from ev-layer.c after hanging up	 * Should call gigaset_bchannel_down(), when finished. */	int (*close_bchannel)(struct bc_state *bcs);	/* Called by gigaset_initcs() for setting up bcs->hw.xxx */	int (*initbcshw)(struct bc_state *bcs);	/* Called by gigaset_freecs() for freeing bcs->hw.xxx */	int (*freebcshw)(struct bc_state *bcs);	/* Called by gigaset_bchannel_down() for resetting bcs->hw.xxx */	void (*reinitbcshw)(struct bc_state *bcs);	/* Called by gigaset_initcs() for setting up cs->hw.xxx */	int (*initcshw)(struct cardstate *cs);	/* Called by gigaset_freecs() for freeing cs->hw.xxx */	void (*freecshw)(struct cardstate *cs);	/* Called from common.c/interface.c for additional serial port	   control */	int (*set_modem_ctrl)(struct cardstate *cs, unsigned old_state,			      unsigned new_state);	int (*baud_rate)(struct cardstate *cs, unsigned cflag);	int (*set_line_ctrl)(struct cardstate *cs, unsigned cflag);	/* Called from i4l.c to put an skb into the send-queue. */	int (*send_skb)(struct bc_state *bcs, struct sk_buff *skb);	/* Called from ev-layer.c to process a block of data	 * received through the common/control channel. */	void (*handle_input)(struct inbuf_t *inbuf);};/* = Common structures and definitions ======================================= *//* Parser states for DLE-Event: * <DLE-EVENT>: <DLE_FLAG> "X" <EVENT> <DLE_FLAG> "." * <DLE_FLAG>:  0x10 * <EVENT>:     ((a-z)* | (A-Z)* | (0-10)*)+ */#define DLE_FLAG	0x10/* =========================================================================== *  Functions implemented in asyncdata.c *//* Called from i4l.c to put an skb into the send-queue. * After sending gigaset_skb_sent() should be called. */int gigaset_m10x_send_skb(struct bc_state *bcs, struct sk_buff *skb);/* Called from ev-layer.c to process a block of data * received through the common/control channel. */void gigaset_m10x_input(struct inbuf_t *inbuf);/* =========================================================================== *  Functions implemented in isocdata.c *//* Called from i4l.c to put an skb into the send-queue. * After sending gigaset_skb_sent() should be called. */int gigaset_isoc_send_skb(struct bc_state *bcs, struct sk_buff *skb);/* Called from ev-layer.c to process a block of data * received through the common/control channel. */void gigaset_isoc_input(struct inbuf_t *inbuf);/* Called from bas-gigaset.c to process a block of data * received through the isochronous channel */void gigaset_isoc_receive(unsigned char *src, unsigned count,			  struct bc_state *bcs);/* Called from bas-gigaset.c to put a block of data * into the isochronous output buffer */int gigaset_isoc_buildframe(struct bc_state *bcs, unsigned char *in, int len);/* Called from bas-gigaset.c to initialize the isochronous output buffer */void gigaset_isowbuf_init(struct isowbuf_t *iwb, unsigned char idle);/* Called from bas-gigaset.c to retrieve a block of bytes for sending */int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size);/* =========================================================================== *  Functions implemented in i4l.c/gigaset.h *//* Called by gigaset_initcs() for setting up with the isdn4linux subsystem */int gigaset_register_to_LL(struct cardstate *cs, const char *isdnid);/* Called from xxx-gigaset.c to indicate completion of sending an skb */void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb);/* Called from common.c/ev-layer.c to indicate events relevant to the LL */int gigaset_isdn_icall(struct at_state_t *at_state);int gigaset_isdn_setup_accept(struct at_state_t *at_state);int gigaset_isdn_setup_dial(struct at_state_t *at_state, void *data);void gigaset_i4l_cmd(struct cardstate *cs, int cmd);void gigaset_i4l_channel_cmd(struct bc_state *bcs, int cmd);static inline void gigaset_isdn_rcv_err(struct bc_state *bcs){	isdn_ctrl response;	/* error -> LL */	gig_dbg(DEBUG_CMD, "sending L1ERR");	response.driver = bcs->cs->myid;	response.command = ISDN_STAT_L1ERR;	response.arg = bcs->channel;	response.parm.errcode = ISDN_STAT_L1ERR_RECV;	bcs->cs->iif.statcallb(&response);}/* =========================================================================== *  Functions implemented in ev-layer.c *//* tasklet called from common.c to process queued events */void gigaset_handle_event(unsigned long data);/* called from isocdata.c / asyncdata.c * when a complete modem response line has been received */void gigaset_handle_modem_response(struct cardstate *cs);/* =========================================================================== *  Functions implemented in proc.c *//* initialize sysfs for device */void gigaset_init_dev_sysfs(struct cardstate *cs);void gigaset_free_dev_sysfs(struct cardstate *cs);/* =========================================================================== *  Functions implemented in common.c/gigaset.h */void gigaset_bcs_reinit(struct bc_state *bcs);void gigaset_at_init(struct at_state_t *at_state, struct bc_state *bcs,		     struct cardstate *cs, int cid);int gigaset_get_channel(struct bc_state *bcs);void gigaset_free_channel(struct bc_state *bcs);int gigaset_get_channels(struct cardstate *cs);void gigaset_free_channels(struct cardstate *cs);void gigaset_block_channels(struct cardstate *cs);/* Allocate and initialize driver structure. */struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,					  const char *procname,					  const char *devname,					  const char *devfsname,					  const struct gigaset_ops *ops,					  struct module *owner);/* Deallocate driver structure. */void gigaset_freedriver(struct gigaset_driver *drv);void gigaset_debugdrivers(void);struct cardstate *gigaset_get_cs_by_tty(struct tty_struct *tty);struct cardstate *gigaset_get_cs_by_id(int id);/* For drivers without fixed assignment device<->cardstate (usb) */struct cardstate *gigaset_getunassignedcs(struct gigaset_driver *drv);void gigaset_unassign(struct cardstate *cs);void gigaset_blockdriver(struct gigaset_driver *drv);/* Allocate and initialize card state. Calls hardware dependent   gigaset_init[b]cs(). */struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,				 int onechannel, int ignoreframes,				 int cidmode, const char *modulename);/* Free card state. Calls hardware dependent gigaset_free[b]cs(). */void gigaset_freecs(struct cardstate *cs);/* Tell common.c that hardware and driver are ready. */int gigaset_start(struct cardstate *cs);/* Tell common.c that the device is not present any more. */void gigaset_stop(struct cardstate *cs);/* Tell common.c that the driver is being unloaded. */void gigaset_shutdown(struct cardstate *cs);/* Tell common.c that an skb has been sent. */void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb);/* Append event to the queue. * Returns NULL on failure or a pointer to the event on success. * ptr must be kmalloc()ed (and not be freed by the caller). */struct event_t *gigaset_add_event(struct cardstate *cs,				  struct at_state_t *at_state, int type,				  void *ptr, int parameter, void *arg);/* Called on CONFIG1 command from frontend. */int gigaset_enterconfigmode(struct cardstate *cs); //0: success <0: errorcode/* cs->lock must not be locked */static inline void gigaset_schedule_event(struct cardstate *cs){	unsigned long flags;	spin_lock_irqsave(&cs->lock, flags);	if (cs->running)		tasklet_schedule(&cs->event_tasklet);	spin_unlock_irqrestore(&cs->lock, flags);}/* Tell common.c that B channel has been closed. *//* cs->lock must not be locked */static inline void gigaset_bchannel_down(struct bc_state *bcs){	gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_CLOSED, NULL, 0, NULL);	gig_dbg(DEBUG_CMD, "scheduling BC_CLOSED");	gigaset_schedule_event(bcs->cs);}/* Tell common.c that B channel has been opened. *//* cs->lock must not be locked */static inline void gigaset_bchannel_up(struct bc_state *bcs){	gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_OPEN, NULL, 0, NULL);	gig_dbg(DEBUG_CMD, "scheduling BC_OPEN");	gigaset_schedule_event(bcs->cs);}/* handling routines for sk_buff *//* ============================= *//* pass received skb to LL * Warning: skb must not be accessed anymore! */static inline void gigaset_rcv_skb(struct sk_buff *skb,				   struct cardstate *cs,				   struct bc_state *bcs){	cs->iif.rcvcallb_skb(cs->myid, bcs->channel, skb);	bcs->trans_down++;}/* handle reception of corrupted skb * Warning: skb must not be accessed anymore! */static inline void gigaset_rcv_error(struct sk_buff *procskb,				     struct cardstate *cs,				     struct bc_state *bcs){	if (procskb)		dev_kfree_skb(procskb);	if (bcs->ignore)		--bcs->ignore;	else {		++bcs->corrupted;		gigaset_isdn_rcv_err(bcs);	}}/* bitwise byte inversion table */extern __u8 gigaset_invtab[];	/* in common.c *//* append received bytes to inbuf */int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src,		       unsigned numbytes);/* =========================================================================== *  Functions implemented in interface.c *//* initialize interface */void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,			   const char *devname, const char *devfsname);/* release interface */void gigaset_if_freedriver(struct gigaset_driver *drv);/* add minor */void gigaset_if_init(struct cardstate *cs);/* remove minor */void gigaset_if_free(struct cardstate *cs);/* device received data */void gigaset_if_receive(struct cardstate *cs,			unsigned char *buffer, size_t len);#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?