2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2009-06-16 16:30:47 +08:00
|
|
|
* IBM/3270 Driver - core functions.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2009-06-16 16:30:47 +08:00
|
|
|
* 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
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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>
|
2007-08-22 19:51:40 +08:00
|
|
|
#include <asm/diag.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include "raw3270.h"
|
|
|
|
|
2005-10-31 07:00:10 +08:00
|
|
|
#include <linux/major.h>
|
|
|
|
#include <linux/kdev_t.h>
|
|
|
|
#include <linux/device.h>
|
2006-03-26 17:37:14 +08:00
|
|
|
#include <linux/mutex.h>
|
2005-10-31 07:00:10 +08:00
|
|
|
|
2013-01-08 22:31:11 +08:00
|
|
|
struct class *class3270;
|
2005-10-31 07:00:10 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* The main 3270 data structure. */
|
|
|
|
struct raw3270 {
|
|
|
|
struct list_head list;
|
|
|
|
struct ccw_device *cdev;
|
|
|
|
int minor;
|
|
|
|
|
|
|
|
short model, rows, cols;
|
2013-01-04 21:55:13 +08:00
|
|
|
unsigned int state;
|
2005-04-17 06:20:36 +08:00
|
|
|
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 */
|
2006-06-29 20:57:39 +08:00
|
|
|
|
2013-01-04 21:55:13 +08:00
|
|
|
struct raw3270_view init_view;
|
|
|
|
struct raw3270_request init_reset;
|
|
|
|
struct raw3270_request init_readpart;
|
|
|
|
struct raw3270_request init_readmod;
|
2006-06-29 20:57:39 +08:00
|
|
|
unsigned char init_data[256];
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2013-01-04 21:55:13 +08:00
|
|
|
/* 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 */
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* raw3270->flags */
|
|
|
|
#define RAW3270_FLAGS_14BITADDR 0 /* 14-bit buffer addresses */
|
|
|
|
#define RAW3270_FLAGS_BUSY 1 /* Device busy, leave it alone */
|
2013-01-04 21:55:13 +08:00
|
|
|
#define RAW3270_FLAGS_CONSOLE 2 /* Device is the console. */
|
|
|
|
#define RAW3270_FLAGS_FROZEN 3 /* set if 3270 is frozen for suspend */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Semaphore to protect global data of raw3270 (devices, views, etc). */
|
2006-03-26 17:37:14 +08:00
|
|
|
static DEFINE_MUTEX(raw3270_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* List of 3270 devices. */
|
2008-01-26 21:11:13 +08:00
|
|
|
static LIST_HEAD(raw3270_devices);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 */
|
2012-01-13 07:02:20 +08:00
|
|
|
static bool tubxcorrect = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
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.
|
|
|
|
*/
|
2007-02-06 04:16:47 +08:00
|
|
|
static unsigned char raw3270_ebcgraf[64] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
0x40, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
|
|
|
|
0xc8, 0xc9, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
|
|
|
|
0x50, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
|
|
|
|
0xd8, 0xd9, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
|
|
|
0x60, 0x61, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
|
|
|
|
0xe8, 0xe9, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
|
|
|
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
|
|
|
|
0xf8, 0xf9, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f
|
|
|
|
};
|
|
|
|
|
2013-01-04 21:55:13 +08:00
|
|
|
static inline int raw3270_state_ready(struct raw3270 *rp)
|
|
|
|
{
|
|
|
|
return rp->state == RAW3270_STATE_READY;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int raw3270_state_final(struct raw3270 *rp)
|
|
|
|
{
|
|
|
|
return rp->state == RAW3270_STATE_INIT ||
|
|
|
|
rp->state == RAW3270_STATE_READY;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
void
|
|
|
|
raw3270_buffer_address(struct raw3270 *rp, char *cp, unsigned short addr)
|
|
|
|
{
|
|
|
|
if (test_bit(RAW3270_FLAGS_14BITADDR, &rp->flags)) {
|
|
|
|
cp[0] = (addr >> 8) & 0x3f;
|
|
|
|
cp[1] = addr & 0xff;
|
|
|
|
} else {
|
|
|
|
cp[0] = raw3270_ebcgraf[(addr >> 6) & 0x3f];
|
|
|
|
cp[1] = raw3270_ebcgraf[addr & 0x3f];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate a new 3270 ccw request
|
|
|
|
*/
|
|
|
|
struct raw3270_request *
|
|
|
|
raw3270_request_alloc(size_t size)
|
|
|
|
{
|
|
|
|
struct raw3270_request *rq;
|
|
|
|
|
|
|
|
/* Allocate request structure */
|
2006-03-24 19:15:31 +08:00
|
|
|
rq = kzalloc(sizeof(struct raw3270_request), GFP_KERNEL | GFP_DMA);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!rq)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
|
|
/* alloc output buffer. */
|
|
|
|
if (size > 0) {
|
|
|
|
rq->buffer = kmalloc(size, GFP_KERNEL | GFP_DMA);
|
|
|
|
if (!rq->buffer) {
|
|
|
|
kfree(rq);
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rq->size = size;
|
|
|
|
INIT_LIST_HEAD(&rq->list);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup ccw.
|
|
|
|
*/
|
|
|
|
rq->ccw.cda = __pa(rq->buffer);
|
|
|
|
rq->ccw.flags = CCW_FLAG_SLI;
|
|
|
|
|
|
|
|
return rq;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free 3270 ccw request
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
raw3270_request_free (struct raw3270_request *rq)
|
|
|
|
{
|
2005-11-07 17:01:30 +08:00
|
|
|
kfree(rq->buffer);
|
2005-04-17 06:20:36 +08:00
|
|
|
kfree(rq);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset request to initial state.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
raw3270_request_reset(struct raw3270_request *rq)
|
|
|
|
{
|
|
|
|
BUG_ON(!list_empty(&rq->list));
|
|
|
|
rq->ccw.cmd_code = 0;
|
|
|
|
rq->ccw.count = 0;
|
|
|
|
rq->ccw.cda = __pa(rq->buffer);
|
|
|
|
rq->ccw.flags = CCW_FLAG_SLI;
|
|
|
|
rq->rescnt = 0;
|
|
|
|
rq->rc = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set command code to ccw of a request.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
raw3270_request_set_cmd(struct raw3270_request *rq, u8 cmd)
|
|
|
|
{
|
|
|
|
rq->ccw.cmd_code = cmd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add data fragment to output buffer.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
raw3270_request_add_data(struct raw3270_request *rq, void *data, size_t size)
|
|
|
|
{
|
|
|
|
if (size + rq->ccw.count > rq->size)
|
|
|
|
return -E2BIG;
|
|
|
|
memcpy(rq->buffer + rq->ccw.count, data, size);
|
|
|
|
rq->ccw.count += size;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set address/length pair to ccw of a request.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
raw3270_request_set_data(struct raw3270_request *rq, void *data, size_t size)
|
|
|
|
{
|
|
|
|
rq->ccw.cda = __pa(data);
|
|
|
|
rq->ccw.count = size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set idal buffer to ccw of a request.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
raw3270_request_set_idal(struct raw3270_request *rq, struct idal_buffer *ib)
|
|
|
|
{
|
|
|
|
rq->ccw.cda = __pa(ib->data);
|
|
|
|
rq->ccw.count = ib->size;
|
|
|
|
rq->ccw.flags |= CCW_FLAG_IDA;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stop running ccw.
|
|
|
|
*/
|
|
|
|
static int
|
2013-01-04 21:55:13 +08:00
|
|
|
__raw3270_halt_io(struct raw3270 *rp, struct raw3270_request *rq)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int retries;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (raw3270_request_final(rq))
|
|
|
|
return 0;
|
|
|
|
/* Check if interrupt has already been processed */
|
|
|
|
for (retries = 0; retries < 5; retries++) {
|
|
|
|
if (retries < 2)
|
|
|
|
rc = ccw_device_halt(rp->cdev, (long) rq);
|
|
|
|
else
|
|
|
|
rc = ccw_device_clear(rp->cdev, (long) rq);
|
|
|
|
if (rc == 0)
|
|
|
|
break; /* termination successful */
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add the request to the request queue, try to start it if the
|
|
|
|
* 3270 device is idle. Return without waiting for end of i/o.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
__raw3270_start(struct raw3270 *rp, struct raw3270_view *view,
|
|
|
|
struct raw3270_request *rq)
|
|
|
|
{
|
|
|
|
rq->view = view;
|
|
|
|
raw3270_get_view(view);
|
|
|
|
if (list_empty(&rp->req_queue) &&
|
|
|
|
!test_bit(RAW3270_FLAGS_BUSY, &rp->flags)) {
|
|
|
|
/* No other requests are on the queue. Start this one. */
|
|
|
|
rq->rc = ccw_device_start(rp->cdev, &rq->ccw,
|
|
|
|
(unsigned long) rq, 0, 0);
|
|
|
|
if (rq->rc) {
|
|
|
|
raw3270_put_view(view);
|
|
|
|
return rq->rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
list_add_tail(&rq->list, &rp->req_queue);
|
|
|
|
return 0;
|
2014-03-21 16:25:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
raw3270_view_active(struct raw3270_view *view)
|
|
|
|
{
|
|
|
|
struct raw3270 *rp = view->dev;
|
|
|
|
|
|
|
|
return rp && rp->view == view &&
|
|
|
|
!test_bit(RAW3270_FLAGS_FROZEN, &rp->flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
raw3270_start(struct raw3270_view *view, struct raw3270_request *rq)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
struct raw3270 *rp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
spin_lock_irqsave(get_ccwdev_lock(view->dev->cdev), flags);
|
|
|
|
rp = view->dev;
|
2009-06-16 16:30:47 +08:00
|
|
|
if (!rp || rp->view != view ||
|
|
|
|
test_bit(RAW3270_FLAGS_FROZEN, &rp->flags))
|
2005-04-17 06:20:36 +08:00
|
|
|
rc = -EACCES;
|
2013-01-04 21:55:13 +08:00
|
|
|
else if (!raw3270_state_ready(rp))
|
|
|
|
rc = -EBUSY;
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
|
|
|
rc = __raw3270_start(rp, view, rq);
|
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(view->dev->cdev), flags);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2005-10-31 07:00:10 +08:00
|
|
|
int
|
|
|
|
raw3270_start_locked(struct raw3270_view *view, struct raw3270_request *rq)
|
|
|
|
{
|
|
|
|
struct raw3270 *rp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rp = view->dev;
|
2009-06-16 16:30:47 +08:00
|
|
|
if (!rp || rp->view != view ||
|
|
|
|
test_bit(RAW3270_FLAGS_FROZEN, &rp->flags))
|
2005-10-31 07:00:10 +08:00
|
|
|
rc = -EACCES;
|
2013-01-04 21:55:13 +08:00
|
|
|
else if (!raw3270_state_ready(rp))
|
|
|
|
rc = -EBUSY;
|
2005-10-31 07:00:10 +08:00
|
|
|
else
|
|
|
|
rc = __raw3270_start(rp, view, rq);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
int
|
|
|
|
raw3270_start_irq(struct raw3270_view *view, struct raw3270_request *rq)
|
|
|
|
{
|
|
|
|
struct raw3270 *rp;
|
|
|
|
|
|
|
|
rp = view->dev;
|
|
|
|
rq->view = view;
|
|
|
|
raw3270_get_view(view);
|
|
|
|
list_add_tail(&rq->list, &rp->req_queue);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 3270 interrupt routine, called from the ccw_device layer
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
raw3270_irq (struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
|
|
|
|
{
|
|
|
|
struct raw3270 *rp;
|
|
|
|
struct raw3270_view *view;
|
|
|
|
struct raw3270_request *rq;
|
|
|
|
int rc;
|
|
|
|
|
2009-05-05 03:40:54 +08:00
|
|
|
rp = dev_get_drvdata(&cdev->dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!rp)
|
|
|
|
return;
|
|
|
|
rq = (struct raw3270_request *) intparm;
|
|
|
|
view = rq ? rq->view : rp->view;
|
|
|
|
|
|
|
|
if (IS_ERR(irb))
|
|
|
|
rc = RAW3270_IO_RETRY;
|
2008-07-14 15:58:50 +08:00
|
|
|
else if (irb->scsw.cmd.fctl & SCSW_FCTL_HALT_FUNC) {
|
2005-04-17 06:20:36 +08:00
|
|
|
rq->rc = -EIO;
|
|
|
|
rc = RAW3270_IO_DONE;
|
2008-07-14 15:58:50 +08:00
|
|
|
} else if (irb->scsw.cmd.dstat == (DEV_STAT_CHN_END | DEV_STAT_DEV_END |
|
|
|
|
DEV_STAT_UNIT_EXCEP)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Handle CE-DE-UE and subsequent UDE */
|
|
|
|
set_bit(RAW3270_FLAGS_BUSY, &rp->flags);
|
|
|
|
rc = RAW3270_IO_BUSY;
|
|
|
|
} else if (test_bit(RAW3270_FLAGS_BUSY, &rp->flags)) {
|
|
|
|
/* Wait for UDE if busy flag is set. */
|
2008-07-14 15:58:50 +08:00
|
|
|
if (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) {
|
2005-04-17 06:20:36 +08:00
|
|
|
clear_bit(RAW3270_FLAGS_BUSY, &rp->flags);
|
|
|
|
/* Got it, now retry. */
|
|
|
|
rc = RAW3270_IO_RETRY;
|
|
|
|
} else
|
|
|
|
rc = RAW3270_IO_BUSY;
|
|
|
|
} else if (view)
|
|
|
|
rc = view->fn->intv(view, rq, irb);
|
|
|
|
else
|
|
|
|
rc = RAW3270_IO_DONE;
|
|
|
|
|
|
|
|
switch (rc) {
|
|
|
|
case RAW3270_IO_DONE:
|
|
|
|
break;
|
|
|
|
case RAW3270_IO_BUSY:
|
|
|
|
/*
|
|
|
|
* Intervention required by the operator. We have to wait
|
|
|
|
* for unsolicited device end.
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
case RAW3270_IO_RETRY:
|
|
|
|
if (!rq)
|
|
|
|
break;
|
|
|
|
rq->rc = ccw_device_start(rp->cdev, &rq->ccw,
|
|
|
|
(unsigned long) rq, 0, 0);
|
|
|
|
if (rq->rc == 0)
|
tree-wide: Assorted spelling fixes
In particular, several occurances of funny versions of 'success',
'unknown', 'therefore', 'acknowledge', 'argument', 'achieve', 'address',
'beginning', 'desirable', 'separate' and 'necessary' are fixed.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Joe Perches <joe@perches.com>
Cc: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-02-03 08:01:28 +08:00
|
|
|
return; /* Successfully restarted. */
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case RAW3270_IO_STOP:
|
|
|
|
if (!rq)
|
|
|
|
break;
|
2013-01-04 21:55:13 +08:00
|
|
|
__raw3270_halt_io(rp, rq);
|
2005-04-17 06:20:36 +08:00
|
|
|
rq->rc = -EIO;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
if (rq) {
|
|
|
|
BUG_ON(list_empty(&rq->list));
|
|
|
|
/* The request completed, remove from queue and do callback. */
|
|
|
|
list_del_init(&rq->list);
|
|
|
|
if (rq->callback)
|
|
|
|
rq->callback(rq, rq->callback_data);
|
|
|
|
/* Do put_device for get_device in raw3270_start. */
|
|
|
|
raw3270_put_view(view);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Try to start each request on request queue until one is
|
|
|
|
* started successful.
|
|
|
|
*/
|
|
|
|
while (!list_empty(&rp->req_queue)) {
|
|
|
|
rq = list_entry(rp->req_queue.next,struct raw3270_request,list);
|
|
|
|
rq->rc = ccw_device_start(rp->cdev, &rq->ccw,
|
|
|
|
(unsigned long) rq, 0, 0);
|
|
|
|
if (rq->rc == 0)
|
|
|
|
break;
|
|
|
|
/* Start failed. Remove request and do callback. */
|
|
|
|
list_del_init(&rq->list);
|
|
|
|
if (rq->callback)
|
|
|
|
rq->callback(rq, rq->callback_data);
|
|
|
|
/* Do put_device for get_device in raw3270_start. */
|
|
|
|
raw3270_put_view(view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-01-04 21:55:13 +08:00
|
|
|
* To determine the size of the 3270 device we need to do:
|
|
|
|
* 1) send a 'read partition' data stream to the device
|
|
|
|
* 2) wait for the attn interrupt that precedes the query reply
|
|
|
|
* 3) do a read modified to get the query reply
|
|
|
|
* To make things worse we have to cope with intervention
|
|
|
|
* required (3270 device switched to 'stand-by') and command
|
|
|
|
* rejects (old devices that can't do 'read partition').
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
struct raw3270_ua { /* Query Reply structure for Usable Area */
|
|
|
|
struct { /* Usable Area Query Reply Base */
|
|
|
|
short l; /* Length of this structured field */
|
|
|
|
char sfid; /* 0x81 if Query Reply */
|
|
|
|
char qcode; /* 0x81 if Usable Area */
|
|
|
|
char flags0;
|
|
|
|
char flags1;
|
|
|
|
short w; /* Width of usable area */
|
|
|
|
short h; /* Heigth of usavle area */
|
|
|
|
char units; /* 0x00:in; 0x01:mm */
|
|
|
|
int xr;
|
|
|
|
int yr;
|
|
|
|
char aw;
|
|
|
|
char ah;
|
|
|
|
short buffsz; /* Character buffer size, bytes */
|
|
|
|
char xmin;
|
|
|
|
char ymin;
|
|
|
|
char xmax;
|
|
|
|
char ymax;
|
|
|
|
} __attribute__ ((packed)) uab;
|
|
|
|
struct { /* Alternate Usable Area Self-Defining Parameter */
|
|
|
|
char l; /* Length of this Self-Defining Parm */
|
|
|
|
char sdpid; /* 0x02 if Alternate Usable Area */
|
|
|
|
char res;
|
|
|
|
char auaid; /* 0x01 is Id for the A U A */
|
|
|
|
short wauai; /* Width of AUAi */
|
|
|
|
short hauai; /* Height of AUAi */
|
|
|
|
char auaunits; /* 0x00:in, 0x01:mm */
|
|
|
|
int auaxr;
|
|
|
|
int auayr;
|
|
|
|
char awauai;
|
|
|
|
char ahauai;
|
|
|
|
} __attribute__ ((packed)) aua;
|
|
|
|
} __attribute__ ((packed));
|
|
|
|
|
|
|
|
static void
|
2013-01-04 21:55:13 +08:00
|
|
|
raw3270_size_device_vm(struct raw3270 *rp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int rc, model;
|
2007-05-10 21:45:42 +08:00
|
|
|
struct ccw_dev_id dev_id;
|
2013-01-04 21:55:13 +08:00
|
|
|
struct diag210 diag_data;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-05-10 21:45:42 +08:00
|
|
|
ccw_device_get_id(rp->cdev, &dev_id);
|
2013-01-04 21:55:13 +08:00
|
|
|
diag_data.vrdcdvno = dev_id.devno;
|
|
|
|
diag_data.vrdclen = sizeof(struct diag210);
|
|
|
|
rc = diag210(&diag_data);
|
|
|
|
model = diag_data.vrdccrmd;
|
|
|
|
/* Use default model 2 if the size could not be detected */
|
|
|
|
if (rc || model < 2 || model > 5)
|
|
|
|
model = 2;
|
2005-04-17 06:20:36 +08:00
|
|
|
switch (model) {
|
|
|
|
case 2:
|
|
|
|
rp->model = model;
|
|
|
|
rp->rows = 24;
|
|
|
|
rp->cols = 80;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
rp->model = model;
|
|
|
|
rp->rows = 32;
|
|
|
|
rp->cols = 80;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
rp->model = model;
|
|
|
|
rp->rows = 43;
|
|
|
|
rp->cols = 80;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
rp->model = model;
|
|
|
|
rp->rows = 27;
|
|
|
|
rp->cols = 132;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-04 21:55:13 +08:00
|
|
|
static void
|
|
|
|
raw3270_size_device(struct raw3270 *rp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct raw3270_ua *uap;
|
|
|
|
|
|
|
|
/* Got a Query Reply */
|
2006-06-29 20:57:39 +08:00
|
|
|
uap = (struct raw3270_ua *) (rp->init_data + 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Paranoia check. */
|
2013-01-04 21:55:13 +08:00
|
|
|
if (rp->init_readmod.rc || rp->init_data[0] != 0x88 ||
|
|
|
|
uap->uab.qcode != 0x81) {
|
|
|
|
/* Couldn't detect size. Use default model 2. */
|
|
|
|
rp->model = 2;
|
|
|
|
rp->rows = 24;
|
|
|
|
rp->cols = 80;
|
|
|
|
return;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Copy rows/columns of default Usable Area */
|
|
|
|
rp->rows = uap->uab.h;
|
|
|
|
rp->cols = uap->uab.w;
|
|
|
|
/* Check for 14 bit addressing */
|
|
|
|
if ((uap->uab.flags0 & 0x0d) == 0x01)
|
|
|
|
set_bit(RAW3270_FLAGS_14BITADDR, &rp->flags);
|
|
|
|
/* Check for Alternate Usable Area */
|
|
|
|
if (uap->uab.l == sizeof(struct raw3270_ua) &&
|
|
|
|
uap->aua.sdpid == 0x02) {
|
|
|
|
rp->rows = uap->aua.hauai;
|
|
|
|
rp->cols = uap->aua.wauai;
|
|
|
|
}
|
2013-01-04 21:55:13 +08:00
|
|
|
/* Try to find a model. */
|
|
|
|
rp->model = 0;
|
|
|
|
if (rp->rows == 24 && rp->cols == 80)
|
|
|
|
rp->model = 2;
|
|
|
|
if (rp->rows == 32 && rp->cols == 80)
|
|
|
|
rp->model = 3;
|
|
|
|
if (rp->rows == 43 && rp->cols == 80)
|
|
|
|
rp->model = 4;
|
|
|
|
if (rp->rows == 27 && rp->cols == 132)
|
|
|
|
rp->model = 5;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2013-01-04 21:55:13 +08:00
|
|
|
static void
|
|
|
|
raw3270_size_device_done(struct raw3270 *rp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2013-01-04 21:55:13 +08:00
|
|
|
struct raw3270_view *view;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-07-12 22:41:55 +08:00
|
|
|
rp->view = NULL;
|
2013-01-04 21:55:13 +08:00
|
|
|
rp->state = RAW3270_STATE_READY;
|
|
|
|
/* Notify views about new size */
|
|
|
|
list_for_each_entry(view, &rp->view_list, list)
|
|
|
|
if (view->fn->resize)
|
|
|
|
view->fn->resize(view, rp->model, rp->rows, rp->cols);
|
|
|
|
/* Setup processing done, now activate a view */
|
|
|
|
list_for_each_entry(view, &rp->view_list, list) {
|
|
|
|
rp->view = view;
|
|
|
|
if (view->fn->activate(view) == 0)
|
|
|
|
break;
|
|
|
|
rp->view = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2013-01-04 21:55:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
raw3270_read_modified_cb(struct raw3270_request *rq, void *data)
|
|
|
|
{
|
|
|
|
struct raw3270 *rp = rq->view->dev;
|
|
|
|
|
|
|
|
raw3270_size_device(rp);
|
|
|
|
raw3270_size_device_done(rp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
raw3270_read_modified(struct raw3270 *rp)
|
|
|
|
{
|
|
|
|
if (rp->state != RAW3270_STATE_W4ATTN)
|
|
|
|
return;
|
|
|
|
/* Use 'read modified' to get the result of a read partition. */
|
|
|
|
memset(&rp->init_readmod, 0, sizeof(rp->init_readmod));
|
|
|
|
memset(&rp->init_data, 0, sizeof(rp->init_data));
|
|
|
|
rp->init_readmod.ccw.cmd_code = TC_READMOD;
|
|
|
|
rp->init_readmod.ccw.flags = CCW_FLAG_SLI;
|
|
|
|
rp->init_readmod.ccw.count = sizeof(rp->init_data);
|
|
|
|
rp->init_readmod.ccw.cda = (__u32) __pa(rp->init_data);
|
|
|
|
rp->init_readmod.callback = raw3270_read_modified_cb;
|
|
|
|
rp->state = RAW3270_STATE_READMOD;
|
|
|
|
raw3270_start_irq(&rp->init_view, &rp->init_readmod);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
raw3270_writesf_readpart(struct raw3270 *rp)
|
|
|
|
{
|
|
|
|
static const unsigned char wbuf[] =
|
|
|
|
{ 0x00, 0x07, 0x01, 0xff, 0x03, 0x00, 0x81 };
|
|
|
|
|
|
|
|
/* Store 'read partition' data stream to init_data */
|
|
|
|
memset(&rp->init_readpart, 0, sizeof(rp->init_readpart));
|
|
|
|
memset(&rp->init_data, 0, sizeof(rp->init_data));
|
|
|
|
memcpy(&rp->init_data, wbuf, sizeof(wbuf));
|
|
|
|
rp->init_readpart.ccw.cmd_code = TC_WRITESF;
|
|
|
|
rp->init_readpart.ccw.flags = CCW_FLAG_SLI;
|
|
|
|
rp->init_readpart.ccw.count = sizeof(wbuf);
|
|
|
|
rp->init_readpart.ccw.cda = (__u32) __pa(&rp->init_data);
|
|
|
|
rp->state = RAW3270_STATE_W4ATTN;
|
|
|
|
raw3270_start_irq(&rp->init_view, &rp->init_readpart);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Device reset
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
raw3270_reset_device_cb(struct raw3270_request *rq, void *data)
|
|
|
|
{
|
|
|
|
struct raw3270 *rp = rq->view->dev;
|
|
|
|
|
|
|
|
if (rp->state != RAW3270_STATE_RESET)
|
|
|
|
return;
|
2013-10-14 22:48:29 +08:00
|
|
|
if (rq->rc) {
|
2013-01-04 21:55:13 +08:00
|
|
|
/* Reset command failed. */
|
|
|
|
rp->state = RAW3270_STATE_INIT;
|
2013-10-15 19:41:05 +08:00
|
|
|
} else if (MACHINE_IS_VM) {
|
2013-01-04 21:55:13 +08:00
|
|
|
raw3270_size_device_vm(rp);
|
|
|
|
raw3270_size_device_done(rp);
|
|
|
|
} else
|
|
|
|
raw3270_writesf_readpart(rp);
|
2014-03-21 22:24:27 +08:00
|
|
|
memset(&rp->init_reset, 0, sizeof(rp->init_reset));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-01-04 21:55:13 +08:00
|
|
|
__raw3270_reset_device(struct raw3270 *rp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2014-03-21 22:24:27 +08:00
|
|
|
/* Check if reset is already pending */
|
|
|
|
if (rp->init_reset.view)
|
|
|
|
return -EBUSY;
|
2013-01-04 21:55:13 +08:00
|
|
|
/* Store reset data stream to init_data/init_reset */
|
2006-06-29 20:57:39 +08:00
|
|
|
rp->init_data[0] = TW_KR;
|
2013-01-04 21:55:13 +08:00
|
|
|
rp->init_reset.ccw.cmd_code = TC_EWRITEA;
|
|
|
|
rp->init_reset.ccw.flags = CCW_FLAG_SLI;
|
|
|
|
rp->init_reset.ccw.count = 1;
|
|
|
|
rp->init_reset.ccw.cda = (__u32) __pa(rp->init_data);
|
|
|
|
rp->init_reset.callback = raw3270_reset_device_cb;
|
|
|
|
rc = __raw3270_start(rp, &rp->init_view, &rp->init_reset);
|
|
|
|
if (rc == 0 && rp->state == RAW3270_STATE_INIT)
|
|
|
|
rp->state = RAW3270_STATE_RESET;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
raw3270_reset_device(struct raw3270 *rp)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
|
|
|
|
rc = __raw3270_reset_device(rp);
|
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2005-10-31 07:00:10 +08:00
|
|
|
int
|
|
|
|
raw3270_reset(struct raw3270_view *view)
|
|
|
|
{
|
|
|
|
struct raw3270 *rp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rp = view->dev;
|
2009-06-16 16:30:47 +08:00
|
|
|
if (!rp || rp->view != view ||
|
|
|
|
test_bit(RAW3270_FLAGS_FROZEN, &rp->flags))
|
2005-10-31 07:00:10 +08:00
|
|
|
rc = -EACCES;
|
2013-01-04 21:55:13 +08:00
|
|
|
else if (!raw3270_state_ready(rp))
|
|
|
|
rc = -EBUSY;
|
2005-10-31 07:00:10 +08:00
|
|
|
else
|
|
|
|
rc = raw3270_reset_device(view->dev);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2013-01-04 21:55:13 +08:00
|
|
|
static int
|
|
|
|
raw3270_init_irq(struct raw3270_view *view, struct raw3270_request *rq,
|
|
|
|
struct irb *irb)
|
|
|
|
{
|
|
|
|
struct raw3270 *rp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Unit-Check Processing:
|
|
|
|
* Expect Command Reject or Intervention Required.
|
|
|
|
*/
|
|
|
|
if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) {
|
|
|
|
/* Request finished abnormally. */
|
|
|
|
if (irb->ecw[0] & SNS0_INTERVENTION_REQ) {
|
|
|
|
set_bit(RAW3270_FLAGS_BUSY, &view->dev->flags);
|
|
|
|
return RAW3270_IO_BUSY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (rq) {
|
|
|
|
if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) {
|
|
|
|
if (irb->ecw[0] & SNS0_CMD_REJECT)
|
|
|
|
rq->rc = -EOPNOTSUPP;
|
|
|
|
else
|
|
|
|
rq->rc = -EIO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (irb->scsw.cmd.dstat & DEV_STAT_ATTENTION) {
|
|
|
|
/* Queue read modified after attention interrupt */
|
|
|
|
rp = view->dev;
|
|
|
|
raw3270_read_modified(rp);
|
|
|
|
}
|
|
|
|
return RAW3270_IO_DONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct raw3270_fn raw3270_init_fn = {
|
|
|
|
.intv = raw3270_init_irq
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Setup new 3270 device.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
raw3270_setup_device(struct ccw_device *cdev, struct raw3270 *rp, char *ascebc)
|
|
|
|
{
|
|
|
|
struct list_head *l;
|
|
|
|
struct raw3270 *tmp;
|
|
|
|
int minor;
|
|
|
|
|
|
|
|
memset(rp, 0, sizeof(struct raw3270));
|
|
|
|
/* Copy ebcdic -> ascii translation table. */
|
|
|
|
memcpy(ascebc, _ascebc, 256);
|
|
|
|
if (tubxcorrect) {
|
|
|
|
/* correct brackets and circumflex */
|
|
|
|
ascebc['['] = 0xad;
|
|
|
|
ascebc[']'] = 0xbd;
|
|
|
|
ascebc['^'] = 0xb0;
|
|
|
|
}
|
|
|
|
rp->ascebc = ascebc;
|
|
|
|
|
|
|
|
/* Set defaults. */
|
|
|
|
rp->rows = 24;
|
|
|
|
rp->cols = 80;
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&rp->req_queue);
|
|
|
|
INIT_LIST_HEAD(&rp->view_list);
|
|
|
|
|
2013-01-04 21:55:13 +08:00
|
|
|
rp->init_view.dev = rp;
|
|
|
|
rp->init_view.fn = &raw3270_init_fn;
|
|
|
|
rp->view = &rp->init_view;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Add device to list and find the smallest unused minor
|
2005-10-31 07:00:10 +08:00
|
|
|
* number for it. Note: there is no device with minor 0,
|
|
|
|
* see special case for fs3270.c:fs3270_open().
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_lock(&raw3270_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Keep the list sorted. */
|
2005-10-31 07:00:10 +08:00
|
|
|
minor = RAW3270_FIRSTMINOR;
|
2005-04-17 06:20:36 +08:00
|
|
|
rp->minor = -1;
|
|
|
|
list_for_each(l, &raw3270_devices) {
|
|
|
|
tmp = list_entry(l, struct raw3270, list);
|
|
|
|
if (tmp->minor > minor) {
|
|
|
|
rp->minor = minor;
|
|
|
|
__list_add(&rp->list, l->prev, l);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
minor++;
|
|
|
|
}
|
2005-10-31 07:00:10 +08:00
|
|
|
if (rp->minor == -1 && minor < RAW3270_MAXDEVS + RAW3270_FIRSTMINOR) {
|
2005-04-17 06:20:36 +08:00
|
|
|
rp->minor = minor;
|
|
|
|
list_add_tail(&rp->list, &raw3270_devices);
|
|
|
|
}
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_unlock(&raw3270_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* No free minor number? Then give up. */
|
|
|
|
if (rp->minor == -1)
|
|
|
|
return -EUSERS;
|
|
|
|
rp->cdev = cdev;
|
2009-05-05 03:40:54 +08:00
|
|
|
dev_set_drvdata(&cdev->dev, rp);
|
2005-04-17 06:20:36 +08:00
|
|
|
cdev->handler = raw3270_irq;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_TN3270_CONSOLE
|
2014-01-27 20:26:10 +08:00
|
|
|
/* Tentative definition - see below for actual definition. */
|
|
|
|
static struct ccw_driver raw3270_ccw_driver;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Setup 3270 device configured as console.
|
|
|
|
*/
|
2014-01-27 20:26:10 +08:00
|
|
|
struct raw3270 __init *raw3270_setup_console(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2014-01-27 20:26:10 +08:00
|
|
|
struct ccw_device *cdev;
|
2013-01-04 21:55:13 +08:00
|
|
|
unsigned long flags;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct raw3270 *rp;
|
|
|
|
char *ascebc;
|
|
|
|
int rc;
|
|
|
|
|
2014-01-27 20:28:10 +08:00
|
|
|
cdev = ccw_device_create_console(&raw3270_ccw_driver);
|
2014-01-27 20:26:10 +08:00
|
|
|
if (IS_ERR(cdev))
|
|
|
|
return ERR_CAST(cdev);
|
|
|
|
|
2009-06-22 18:08:05 +08:00
|
|
|
rp = kzalloc(sizeof(struct raw3270), GFP_KERNEL | GFP_DMA);
|
|
|
|
ascebc = kzalloc(256, GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
rc = raw3270_setup_device(cdev, rp, ascebc);
|
|
|
|
if (rc)
|
|
|
|
return ERR_PTR(rc);
|
|
|
|
set_bit(RAW3270_FLAGS_CONSOLE, &rp->flags);
|
2014-01-27 20:28:10 +08:00
|
|
|
|
|
|
|
rc = ccw_device_enable_console(cdev);
|
|
|
|
if (rc) {
|
|
|
|
ccw_device_destroy_console(cdev);
|
|
|
|
return ERR_PTR(rc);
|
|
|
|
}
|
|
|
|
|
2013-01-04 21:55:13 +08:00
|
|
|
spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
|
|
|
|
do {
|
|
|
|
__raw3270_reset_device(rp);
|
|
|
|
while (!raw3270_state_final(rp)) {
|
2013-04-13 18:53:21 +08:00
|
|
|
ccw_device_wait_idle(rp->cdev);
|
2013-01-04 21:55:13 +08:00
|
|
|
barrier();
|
|
|
|
}
|
|
|
|
} while (rp->state != RAW3270_STATE_READY);
|
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
return rp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
raw3270_wait_cons_dev(struct raw3270 *rp)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
|
2013-04-13 18:53:21 +08:00
|
|
|
ccw_device_wait_idle(rp->cdev);
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a 3270 device structure.
|
|
|
|
*/
|
|
|
|
static struct raw3270 *
|
|
|
|
raw3270_create_device(struct ccw_device *cdev)
|
|
|
|
{
|
|
|
|
struct raw3270 *rp;
|
|
|
|
char *ascebc;
|
|
|
|
int rc;
|
|
|
|
|
2014-03-21 22:24:27 +08:00
|
|
|
rp = kzalloc(sizeof(struct raw3270), GFP_KERNEL | GFP_DMA);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!rp)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
ascebc = kmalloc(256, GFP_KERNEL);
|
|
|
|
if (!ascebc) {
|
|
|
|
kfree(rp);
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
}
|
|
|
|
rc = raw3270_setup_device(cdev, rp, ascebc);
|
|
|
|
if (rc) {
|
|
|
|
kfree(rp->ascebc);
|
|
|
|
kfree(rp);
|
|
|
|
rp = ERR_PTR(rc);
|
|
|
|
}
|
|
|
|
/* Get reference to ccw_device structure. */
|
|
|
|
get_device(&cdev->dev);
|
|
|
|
return rp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Activate a view.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
raw3270_activate_view(struct raw3270_view *view)
|
|
|
|
{
|
|
|
|
struct raw3270 *rp;
|
|
|
|
struct raw3270_view *oldview, *nv;
|
|
|
|
unsigned long flags;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rp = view->dev;
|
|
|
|
if (!rp)
|
|
|
|
return -ENODEV;
|
|
|
|
spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
|
|
|
|
if (rp->view == view)
|
|
|
|
rc = 0;
|
2013-01-04 21:55:13 +08:00
|
|
|
else if (!raw3270_state_ready(rp))
|
|
|
|
rc = -EBUSY;
|
2009-06-16 16:30:47 +08:00
|
|
|
else if (test_bit(RAW3270_FLAGS_FROZEN, &rp->flags))
|
|
|
|
rc = -EACCES;
|
2005-04-17 06:20:36 +08:00
|
|
|
else {
|
2006-07-12 22:41:55 +08:00
|
|
|
oldview = NULL;
|
2013-01-04 21:55:13 +08:00
|
|
|
if (rp->view && rp->view->fn->deactivate) {
|
2005-04-17 06:20:36 +08:00
|
|
|
oldview = rp->view;
|
|
|
|
oldview->fn->deactivate(oldview);
|
|
|
|
}
|
|
|
|
rp->view = view;
|
|
|
|
rc = view->fn->activate(view);
|
|
|
|
if (rc) {
|
|
|
|
/* Didn't work. Try to reactivate the old view. */
|
|
|
|
rp->view = oldview;
|
|
|
|
if (!oldview || oldview->fn->activate(oldview) != 0) {
|
|
|
|
/* Didn't work as well. Try any other view. */
|
|
|
|
list_for_each_entry(nv, &rp->view_list, list)
|
|
|
|
if (nv != view && nv != oldview) {
|
|
|
|
rp->view = nv;
|
|
|
|
if (nv->fn->activate(nv) == 0)
|
|
|
|
break;
|
2006-07-12 22:41:55 +08:00
|
|
|
rp->view = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Deactivate current view.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
raw3270_deactivate_view(struct raw3270_view *view)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
struct raw3270 *rp;
|
|
|
|
|
|
|
|
rp = view->dev;
|
|
|
|
if (!rp)
|
|
|
|
return;
|
|
|
|
spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
|
|
|
|
if (rp->view == view) {
|
|
|
|
view->fn->deactivate(view);
|
2006-07-12 22:41:55 +08:00
|
|
|
rp->view = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Move deactivated view to end of list. */
|
|
|
|
list_del_init(&view->list);
|
|
|
|
list_add_tail(&view->list, &rp->view_list);
|
|
|
|
/* Try to activate another view. */
|
2013-01-04 21:55:13 +08:00
|
|
|
if (raw3270_state_ready(rp) &&
|
2009-06-16 16:30:47 +08:00
|
|
|
!test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) {
|
2005-10-31 07:00:10 +08:00
|
|
|
list_for_each_entry(view, &rp->view_list, list) {
|
|
|
|
rp->view = view;
|
|
|
|
if (view->fn->activate(view) == 0)
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
2006-07-12 22:41:55 +08:00
|
|
|
rp->view = NULL;
|
2005-10-31 07:00:10 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add view to device with minor "minor".
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
struct raw3270 *rp;
|
|
|
|
int rc;
|
|
|
|
|
2005-10-31 07:00:10 +08:00
|
|
|
if (minor <= 0)
|
|
|
|
return -ENODEV;
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_lock(&raw3270_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
rc = -ENODEV;
|
|
|
|
list_for_each_entry(rp, &raw3270_devices, list) {
|
|
|
|
if (rp->minor != minor)
|
|
|
|
continue;
|
|
|
|
spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
|
2013-01-04 21:55:13 +08:00
|
|
|
atomic_set(&view->ref_count, 2);
|
|
|
|
view->dev = rp;
|
|
|
|
view->fn = fn;
|
|
|
|
view->model = rp->model;
|
|
|
|
view->rows = rp->rows;
|
|
|
|
view->cols = rp->cols;
|
|
|
|
view->ascebc = rp->ascebc;
|
|
|
|
spin_lock_init(&view->lock);
|
|
|
|
list_add(&view->list, &rp->view_list);
|
|
|
|
rc = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
|
|
|
|
break;
|
|
|
|
}
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_unlock(&raw3270_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find specific view of device with minor "minor".
|
|
|
|
*/
|
|
|
|
struct raw3270_view *
|
|
|
|
raw3270_find_view(struct raw3270_fn *fn, int minor)
|
|
|
|
{
|
|
|
|
struct raw3270 *rp;
|
|
|
|
struct raw3270_view *view, *tmp;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_lock(&raw3270_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
view = ERR_PTR(-ENODEV);
|
|
|
|
list_for_each_entry(rp, &raw3270_devices, list) {
|
|
|
|
if (rp->minor != minor)
|
|
|
|
continue;
|
|
|
|
spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
|
2013-01-04 21:55:13 +08:00
|
|
|
list_for_each_entry(tmp, &rp->view_list, list) {
|
|
|
|
if (tmp->fn == fn) {
|
|
|
|
raw3270_get_view(tmp);
|
|
|
|
view = tmp;
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
|
|
|
|
break;
|
|
|
|
}
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_unlock(&raw3270_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove view from device and free view structure via call to view->fn->free.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
raw3270_del_view(struct raw3270_view *view)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
struct raw3270 *rp;
|
|
|
|
struct raw3270_view *nv;
|
|
|
|
|
|
|
|
rp = view->dev;
|
|
|
|
spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
|
|
|
|
if (rp->view == view) {
|
|
|
|
view->fn->deactivate(view);
|
2006-07-12 22:41:55 +08:00
|
|
|
rp->view = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
list_del_init(&view->list);
|
2013-01-04 21:55:13 +08:00
|
|
|
if (!rp->view && raw3270_state_ready(rp) &&
|
2009-06-16 16:30:47 +08:00
|
|
|
!test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Try to activate another view. */
|
|
|
|
list_for_each_entry(nv, &rp->view_list, list) {
|
2005-10-31 07:00:10 +08:00
|
|
|
if (nv->fn->activate(nv) == 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
rp->view = nv;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
|
|
|
|
/* Wait for reference counter to drop to zero. */
|
|
|
|
atomic_dec(&view->ref_count);
|
|
|
|
wait_event(raw3270_wait_queue, atomic_read(&view->ref_count) == 0);
|
|
|
|
if (view->fn->free)
|
|
|
|
view->fn->free(view);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove a 3270 device structure.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
raw3270_delete_device(struct raw3270 *rp)
|
|
|
|
{
|
|
|
|
struct ccw_device *cdev;
|
|
|
|
|
|
|
|
/* Remove from device chain. */
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_lock(&raw3270_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
list_del_init(&rp->list);
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_unlock(&raw3270_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Disconnect from ccw_device. */
|
|
|
|
cdev = rp->cdev;
|
2006-07-12 22:41:55 +08:00
|
|
|
rp->cdev = NULL;
|
2009-05-05 03:40:54 +08:00
|
|
|
dev_set_drvdata(&cdev->dev, NULL);
|
2006-07-12 22:41:55 +08:00
|
|
|
cdev->handler = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Put ccw_device structure. */
|
|
|
|
put_device(&cdev->dev);
|
|
|
|
|
|
|
|
/* Now free raw3270 structure. */
|
|
|
|
kfree(rp->ascebc);
|
|
|
|
kfree(rp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
raw3270_probe (struct ccw_device *cdev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Additional attributes for a 3270 device
|
|
|
|
*/
|
|
|
|
static ssize_t
|
2005-05-17 18:43:27 +08:00
|
|
|
raw3270_model_show(struct device *dev, struct device_attribute *attr, char *buf)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%i\n",
|
2009-05-05 03:40:54 +08:00
|
|
|
((struct raw3270 *) dev_get_drvdata(dev))->model);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2006-07-12 22:41:55 +08:00
|
|
|
static DEVICE_ATTR(model, 0444, raw3270_model_show, NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static ssize_t
|
2005-05-17 18:43:27 +08:00
|
|
|
raw3270_rows_show(struct device *dev, struct device_attribute *attr, char *buf)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%i\n",
|
2009-05-05 03:40:54 +08:00
|
|
|
((struct raw3270 *) dev_get_drvdata(dev))->rows);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2006-07-12 22:41:55 +08:00
|
|
|
static DEVICE_ATTR(rows, 0444, raw3270_rows_show, NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static ssize_t
|
2005-05-17 18:43:27 +08:00
|
|
|
raw3270_columns_show(struct device *dev, struct device_attribute *attr, char *buf)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%i\n",
|
2009-05-05 03:40:54 +08:00
|
|
|
((struct raw3270 *) dev_get_drvdata(dev))->cols);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2006-07-12 22:41:55 +08:00
|
|
|
static DEVICE_ATTR(columns, 0444, raw3270_columns_show, NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static struct attribute * raw3270_attrs[] = {
|
|
|
|
&dev_attr_model.attr,
|
|
|
|
&dev_attr_rows.attr,
|
|
|
|
&dev_attr_columns.attr,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group raw3270_attr_group = {
|
|
|
|
.attrs = raw3270_attrs,
|
|
|
|
};
|
|
|
|
|
2006-07-18 19:46:58 +08:00
|
|
|
static int raw3270_create_attributes(struct raw3270 *rp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2013-01-08 22:31:11 +08:00
|
|
|
return sysfs_create_group(&rp->cdev->dev.kobj, &raw3270_attr_group);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Notifier for device addition/removal
|
|
|
|
*/
|
2008-01-26 21:11:13 +08:00
|
|
|
static LIST_HEAD(raw3270_notifier);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-01-08 22:31:11 +08:00
|
|
|
int raw3270_register_notifier(struct raw3270_notifier *notifier)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct raw3270 *rp;
|
|
|
|
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_lock(&raw3270_mutex);
|
2013-01-08 22:31:11 +08:00
|
|
|
list_add_tail(¬ifier->list, &raw3270_notifier);
|
|
|
|
list_for_each_entry(rp, &raw3270_devices, list)
|
|
|
|
notifier->create(rp->minor);
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_unlock(&raw3270_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-08 22:31:11 +08:00
|
|
|
void raw3270_unregister_notifier(struct raw3270_notifier *notifier)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2013-01-08 22:31:11 +08:00
|
|
|
struct raw3270 *rp;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_lock(&raw3270_mutex);
|
2013-01-08 22:31:11 +08:00
|
|
|
list_for_each_entry(rp, &raw3270_devices, list)
|
|
|
|
notifier->destroy(rp->minor);
|
|
|
|
list_del(¬ifier->list);
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_unlock(&raw3270_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set 3270 device online.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
raw3270_set_online (struct ccw_device *cdev)
|
|
|
|
{
|
|
|
|
struct raw3270_notifier *np;
|
2013-01-08 22:31:11 +08:00
|
|
|
struct raw3270 *rp;
|
2005-04-17 06:20:36 +08:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
rp = raw3270_create_device(cdev);
|
|
|
|
if (IS_ERR(rp))
|
|
|
|
return PTR_ERR(rp);
|
2006-07-18 19:46:58 +08:00
|
|
|
rc = raw3270_create_attributes(rp);
|
|
|
|
if (rc)
|
|
|
|
goto failure;
|
2013-01-04 21:55:13 +08:00
|
|
|
raw3270_reset_device(rp);
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_lock(&raw3270_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
list_for_each_entry(np, &raw3270_notifier, list)
|
2013-01-08 22:31:11 +08:00
|
|
|
np->create(rp->minor);
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_unlock(&raw3270_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
2005-10-31 07:00:10 +08:00
|
|
|
|
|
|
|
failure:
|
|
|
|
raw3270_delete_device(rp);
|
|
|
|
return rc;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove 3270 device structure.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
raw3270_remove (struct ccw_device *cdev)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
struct raw3270 *rp;
|
|
|
|
struct raw3270_view *v;
|
|
|
|
struct raw3270_notifier *np;
|
|
|
|
|
2009-05-05 03:40:54 +08:00
|
|
|
rp = dev_get_drvdata(&cdev->dev);
|
2005-10-31 07:00:10 +08:00
|
|
|
/*
|
|
|
|
* _remove is the opposite of _probe; it's probe that
|
|
|
|
* should set up rp. raw3270_remove gets entered for
|
|
|
|
* devices even if they haven't been varied online.
|
|
|
|
* Thus, rp may validly be NULL here.
|
|
|
|
*/
|
|
|
|
if (rp == NULL)
|
|
|
|
return;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
sysfs_remove_group(&cdev->dev.kobj, &raw3270_attr_group);
|
|
|
|
|
|
|
|
/* Deactivate current view and remove all views. */
|
|
|
|
spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
|
|
|
|
if (rp->view) {
|
2013-01-04 21:55:13 +08:00
|
|
|
if (rp->view->fn->deactivate)
|
|
|
|
rp->view->fn->deactivate(rp->view);
|
2006-07-12 22:41:55 +08:00
|
|
|
rp->view = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
while (!list_empty(&rp->view_list)) {
|
|
|
|
v = list_entry(rp->view_list.next, struct raw3270_view, list);
|
|
|
|
if (v->fn->release)
|
|
|
|
v->fn->release(v);
|
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
|
|
|
|
raw3270_del_view(v);
|
|
|
|
spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
|
|
|
|
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_lock(&raw3270_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
list_for_each_entry(np, &raw3270_notifier, list)
|
2013-01-08 22:31:11 +08:00
|
|
|
np->destroy(rp->minor);
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_unlock(&raw3270_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Reset 3270 device. */
|
|
|
|
raw3270_reset_device(rp);
|
|
|
|
/* And finally remove it. */
|
|
|
|
raw3270_delete_device(rp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set 3270 device offline.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
raw3270_set_offline (struct ccw_device *cdev)
|
|
|
|
{
|
|
|
|
struct raw3270 *rp;
|
|
|
|
|
2009-05-05 03:40:54 +08:00
|
|
|
rp = dev_get_drvdata(&cdev->dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (test_bit(RAW3270_FLAGS_CONSOLE, &rp->flags))
|
|
|
|
return -EBUSY;
|
|
|
|
raw3270_remove(cdev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-06-16 16:30:47 +08:00
|
|
|
static int raw3270_pm_stop(struct ccw_device *cdev)
|
|
|
|
{
|
|
|
|
struct raw3270 *rp;
|
|
|
|
struct raw3270_view *view;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2009-06-22 18:08:19 +08:00
|
|
|
rp = dev_get_drvdata(&cdev->dev);
|
2009-06-16 16:30:47 +08:00
|
|
|
if (!rp)
|
|
|
|
return 0;
|
|
|
|
spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
|
2013-01-04 21:55:13 +08:00
|
|
|
if (rp->view && rp->view->fn->deactivate)
|
2009-06-16 16:30:47 +08:00
|
|
|
rp->view->fn->deactivate(rp->view);
|
|
|
|
if (!test_bit(RAW3270_FLAGS_CONSOLE, &rp->flags)) {
|
|
|
|
/*
|
|
|
|
* Release tty and fullscreen for all non-console
|
|
|
|
* devices.
|
|
|
|
*/
|
|
|
|
list_for_each_entry(view, &rp->view_list, list) {
|
|
|
|
if (view->fn->release)
|
|
|
|
view->fn->release(view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set_bit(RAW3270_FLAGS_FROZEN, &rp->flags);
|
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int raw3270_pm_start(struct ccw_device *cdev)
|
|
|
|
{
|
|
|
|
struct raw3270 *rp;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2009-06-22 18:08:19 +08:00
|
|
|
rp = dev_get_drvdata(&cdev->dev);
|
2009-06-16 16:30:47 +08:00
|
|
|
if (!rp)
|
|
|
|
return 0;
|
|
|
|
spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
|
|
|
|
clear_bit(RAW3270_FLAGS_FROZEN, &rp->flags);
|
2013-01-04 21:55:13 +08:00
|
|
|
if (rp->view && rp->view->fn->activate)
|
2009-06-16 16:30:47 +08:00
|
|
|
rp->view->fn->activate(rp->view);
|
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void raw3270_pm_unfreeze(struct raw3270_view *view)
|
|
|
|
{
|
2009-10-06 16:33:56 +08:00
|
|
|
#ifdef CONFIG_TN3270_CONSOLE
|
2009-06-16 16:30:47 +08:00
|
|
|
struct raw3270 *rp;
|
|
|
|
|
|
|
|
rp = view->dev;
|
|
|
|
if (rp && test_bit(RAW3270_FLAGS_FROZEN, &rp->flags))
|
2013-04-13 18:56:51 +08:00
|
|
|
ccw_device_force_console(rp->cdev);
|
2009-10-06 16:33:56 +08:00
|
|
|
#endif
|
2009-06-16 16:30:47 +08:00
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static struct ccw_device_id raw3270_id[] = {
|
|
|
|
{ CCW_DEVICE(0x3270, 0) },
|
|
|
|
{ CCW_DEVICE(0x3271, 0) },
|
|
|
|
{ CCW_DEVICE(0x3272, 0) },
|
|
|
|
{ CCW_DEVICE(0x3273, 0) },
|
|
|
|
{ CCW_DEVICE(0x3274, 0) },
|
|
|
|
{ CCW_DEVICE(0x3275, 0) },
|
|
|
|
{ CCW_DEVICE(0x3276, 0) },
|
|
|
|
{ CCW_DEVICE(0x3277, 0) },
|
|
|
|
{ CCW_DEVICE(0x3278, 0) },
|
|
|
|
{ CCW_DEVICE(0x3279, 0) },
|
|
|
|
{ CCW_DEVICE(0x3174, 0) },
|
|
|
|
{ /* end of list */ },
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ccw_driver raw3270_ccw_driver = {
|
2011-03-23 17:16:02 +08:00
|
|
|
.driver = {
|
|
|
|
.name = "3270",
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
2005-04-17 06:20:36 +08:00
|
|
|
.ids = raw3270_id,
|
|
|
|
.probe = &raw3270_probe,
|
|
|
|
.remove = &raw3270_remove,
|
|
|
|
.set_online = &raw3270_set_online,
|
|
|
|
.set_offline = &raw3270_set_offline,
|
2009-06-16 16:30:47 +08:00
|
|
|
.freeze = &raw3270_pm_stop,
|
|
|
|
.thaw = &raw3270_pm_start,
|
|
|
|
.restore = &raw3270_pm_start,
|
2013-01-02 22:18:18 +08:00
|
|
|
.int_class = IRQIO_C70,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
raw3270_init(void)
|
|
|
|
{
|
|
|
|
struct raw3270 *rp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (raw3270_registered)
|
|
|
|
return 0;
|
|
|
|
raw3270_registered = 1;
|
|
|
|
rc = ccw_driver_register(&raw3270_ccw_driver);
|
|
|
|
if (rc == 0) {
|
|
|
|
/* Create attributes for early (= console) device. */
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_lock(&raw3270_mutex);
|
2005-10-31 07:00:10 +08:00
|
|
|
class3270 = class_create(THIS_MODULE, "3270");
|
2005-04-17 06:20:36 +08:00
|
|
|
list_for_each_entry(rp, &raw3270_devices, list) {
|
|
|
|
get_device(&rp->cdev->dev);
|
|
|
|
raw3270_create_attributes(rp);
|
|
|
|
}
|
2006-03-26 17:37:14 +08:00
|
|
|
mutex_unlock(&raw3270_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
raw3270_exit(void)
|
|
|
|
{
|
|
|
|
ccw_driver_unregister(&raw3270_ccw_driver);
|
2005-10-31 07:00:10 +08:00
|
|
|
class_destroy(class3270);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
module_init(raw3270_init);
|
|
|
|
module_exit(raw3270_exit);
|
|
|
|
|
2013-01-08 22:31:11 +08:00
|
|
|
EXPORT_SYMBOL(class3270);
|
2005-04-17 06:20:36 +08:00
|
|
|
EXPORT_SYMBOL(raw3270_request_alloc);
|
|
|
|
EXPORT_SYMBOL(raw3270_request_free);
|
|
|
|
EXPORT_SYMBOL(raw3270_request_reset);
|
|
|
|
EXPORT_SYMBOL(raw3270_request_set_cmd);
|
|
|
|
EXPORT_SYMBOL(raw3270_request_add_data);
|
|
|
|
EXPORT_SYMBOL(raw3270_request_set_data);
|
|
|
|
EXPORT_SYMBOL(raw3270_request_set_idal);
|
|
|
|
EXPORT_SYMBOL(raw3270_buffer_address);
|
|
|
|
EXPORT_SYMBOL(raw3270_add_view);
|
|
|
|
EXPORT_SYMBOL(raw3270_del_view);
|
|
|
|
EXPORT_SYMBOL(raw3270_find_view);
|
|
|
|
EXPORT_SYMBOL(raw3270_activate_view);
|
|
|
|
EXPORT_SYMBOL(raw3270_deactivate_view);
|
|
|
|
EXPORT_SYMBOL(raw3270_start);
|
2005-10-31 07:00:10 +08:00
|
|
|
EXPORT_SYMBOL(raw3270_start_locked);
|
2005-04-17 06:20:36 +08:00
|
|
|
EXPORT_SYMBOL(raw3270_start_irq);
|
2005-10-31 07:00:10 +08:00
|
|
|
EXPORT_SYMBOL(raw3270_reset);
|
2005-04-17 06:20:36 +08:00
|
|
|
EXPORT_SYMBOL(raw3270_register_notifier);
|
|
|
|
EXPORT_SYMBOL(raw3270_unregister_notifier);
|
|
|
|
EXPORT_SYMBOL(raw3270_wait_queue);
|