brintos

brintos / linux-shallow public Read only

0
0
Text · 4.2 KiB · 5040c7e Raw
130 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * IBM/3270 Driver4 *5 * Author(s):6 *   Original 3270 Code for 2.4 written by Richard Hitt (UTS Global)7 *   Rewritten for 2.5 by Martin Schwidefsky <schwidefsky@de.ibm.com>8 *     Copyright IBM Corp. 2003, 20099 */10 11#include <uapi/asm/raw3270.h>12#include <asm/idals.h>13#include <asm/ioctl.h>14 15struct raw3270;16struct raw3270_view;17extern const struct class class3270;18 19/* 3270 CCW request */20struct raw3270_request {21	struct list_head list;		/* list head for request queueing. */22	struct raw3270_view *view;	/* view of this request */23	struct ccw1 ccw;		/* single ccw. */24	void *buffer;			/* output buffer. */25	size_t size;			/* size of output buffer. */26	int rescnt;			/* residual count from devstat. */27	int rc;				/* return code for this request. */28 29	/* Callback for delivering final status. */30	void (*callback)(struct raw3270_request *rq, void *data);31	void *callback_data;32};33 34struct raw3270_request *raw3270_request_alloc(size_t size);35void raw3270_request_free(struct raw3270_request *rq);36int raw3270_request_reset(struct raw3270_request *rq);37void raw3270_request_set_cmd(struct raw3270_request *rq, u8 cmd);38int  raw3270_request_add_data(struct raw3270_request *rq, void *data, size_t size);39void raw3270_request_set_data(struct raw3270_request *rq, void *data, size_t size);40void raw3270_request_set_idal(struct raw3270_request *rq, struct idal_buffer *ib);41 42static inline int43raw3270_request_final(struct raw3270_request *rq)44{45	return list_empty(&rq->list);46}47 48void raw3270_buffer_address(struct raw3270 *, char *, int, int);49 50/*51 * Functions of a 3270 view.52 */53struct raw3270_fn {54	int  (*activate)(struct raw3270_view *rq);55	void (*deactivate)(struct raw3270_view *rq);56	void (*intv)(struct raw3270_view *view,57		     struct raw3270_request *rq, struct irb *ib);58	void (*release)(struct raw3270_view *view);59	void (*free)(struct raw3270_view *view);60	void (*resize)(struct raw3270_view *view,61		       int new_model, int new_cols, int new_rows,62		       int old_model, int old_cols, int old_rows);63};64 65/*66 * View structure chaining. The raw3270_view structure is meant to67 * be embedded at the start of the real view data structure, e.g.:68 *   struct example {69 *     struct raw3270_view view;70 *     ...71 *   };72 */73struct raw3270_view {74	struct list_head list;75	spinlock_t lock; /* protects members of view */76#define RAW3270_VIEW_LOCK_IRQ	077#define RAW3270_VIEW_LOCK_BH	178	atomic_t ref_count;79	struct raw3270 *dev;80	struct raw3270_fn *fn;81	unsigned int model;82	unsigned int rows, cols;	/* # of rows & colums of the view */83	unsigned char *ascebc;		/* ascii -> ebcdic table */84};85 86int raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor, int subclass);87int raw3270_view_lock_unavailable(struct raw3270_view *view);88int raw3270_activate_view(struct raw3270_view *view);89void raw3270_del_view(struct raw3270_view *view);90void raw3270_deactivate_view(struct raw3270_view *view);91struct raw3270_view *raw3270_find_view(struct raw3270_fn *fn, int minor);92int raw3270_start(struct raw3270_view *view, struct raw3270_request *rq);93int raw3270_start_locked(struct raw3270_view *view, struct raw3270_request *rq);94int raw3270_start_irq(struct raw3270_view *view, struct raw3270_request *rq);95int raw3270_reset(struct raw3270_view *view);96struct raw3270_view *raw3270_view(struct raw3270_view *view);97int raw3270_view_active(struct raw3270_view *view);98int raw3270_start_request(struct raw3270_view *view, struct raw3270_request *rq,99			  int cmd, void *data, size_t len);100void raw3270_read_modified_cb(struct raw3270_request *rq, void *data);101 102/* Reference count inliner for view structures. */103static inline void104raw3270_get_view(struct raw3270_view *view)105{106	atomic_inc(&view->ref_count);107}108 109extern wait_queue_head_t raw3270_wait_queue;110 111static inline void112raw3270_put_view(struct raw3270_view *view)113{114	if (atomic_dec_return(&view->ref_count) == 0)115		wake_up(&raw3270_wait_queue);116}117 118struct raw3270 *raw3270_setup_console(void);119void raw3270_wait_cons_dev(struct raw3270 *rp);120 121/* Notifier for device addition/removal */122struct raw3270_notifier {123	struct list_head list;124	void (*create)(int minor);125	void (*destroy)(int minor);126};127 128int raw3270_register_notifier(struct raw3270_notifier *notifier);129void raw3270_unregister_notifier(struct raw3270_notifier *notifier);130