/*
* IBM/3270 Driver - core functions.
*
* Author(s):
* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global)
* Rewritten for 2.5 by Martin Schwidefsky <schwidefsky@de.ibm.com>
* Copyright IBM Corp. 2003, 2009
*/
#include <linux/module.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/wait.h>
#include <asm/ccwdev.h>
#include <asm/cio.h>
#include <asm/ebcdic.h>
#include <asm/diag.h>
#include "raw3270.h"
#include <linux/major.h>
#include <linux/kdev_t.h>
#include <linux/device.h>
#include <linux/mutex.h>
struct class *class3270;
/* The main 3270 data structure. */
struct raw3270 {
struct list_head list;
struct ccw_device *cdev;
int minor;
short model, rows, cols;
unsigned int state;
unsigned long flags;
struct list_head req_queue; /* Request queue. */
struct list_head view_list; /* List of available views. */
struct raw3270_view *view; /* Active view. */
struct timer_list timer; /* Device timer. */
unsigned char *ascebc; /* ascii -> ebcdic table */
struct raw3270_view init_view;
struct raw3270_request init_reset;
struct raw3270_request init_readpart;
struct raw3270_request init_readmod;
unsigned char init_data[256];
};
/* raw3270->state */
#define RAW3270_STATE_INIT 0 /* Initial state */
#define RAW3270_STATE_RESET 1 /* Reset command is pending */
#define RAW3270_STATE_W4ATTN 2 /* Wait for attention interrupt */
#define RAW3270_STATE_READMOD 3 /* Read partition is pending */
#define RAW3270_STATE_READY 4 /* Device is usable by views */
/* raw3270->flags */
#define RAW3270_FLAGS_14BITADDR 0 /* 14-bit buffer addresses */
#define RAW3270_FLAGS_BUSY 1 /* Device busy, leave it alone */
#define RAW3270_FLAGS_CONSOLE 2 /* Device is the console. */
#define RAW3270_FLAGS_FROZEN 3 /* set if 3270 is frozen for suspend */
/* Semaphore to protect global data of raw3270 (devices, views, etc). */
static DEFINE_MUTEX(raw3270_mutex);
/* List of 3270 devices. */
static LIST_HEAD(raw3270_devices);
/*
* Flag to indicate if the driver has been registered. Some operations
* like waiting for the end of i/o need to be done differently as long
* as the kernel is still starting up (console support).
*/
static int raw3270_registered;
/* Module parameters */
static bool tubxcorrect = 0;
module_param(tubxcorrect, bool, 0);
/*
* Wait queue for device init/delete, view delete.
*/
DECLARE_WAIT_QUEUE_HEAD(raw3270_wait_queue);
/*
* Encode array for 12 bit 3270 addresses.
*/
static unsigned char