fs3270.c (764a4a8e54cdd6efc5928f876aa9e35778f22377) fs3270.c (23d805b647db6c2063a13089497615efa9deacdd)
1/*
2 * drivers/s390/char/fs3270.c
3 * IBM/3270 Driver - fullscreen driver.
4 *
5 * Author(s):
6 * Original 3270 Code for 2.4 written by Richard Hitt (UTS Global)
7 * Rewritten for 2.5/2.6 by Martin Schwidefsky <schwidefsky@de.ibm.com>
8 * -- Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
9 */
10
11#include <linux/bootmem.h>
12#include <linux/console.h>
13#include <linux/init.h>
14#include <linux/interrupt.h>
15#include <linux/list.h>
16#include <linux/types.h>
1/*
2 * drivers/s390/char/fs3270.c
3 * IBM/3270 Driver - fullscreen driver.
4 *
5 * Author(s):
6 * Original 3270 Code for 2.4 written by Richard Hitt (UTS Global)
7 * Rewritten for 2.5/2.6 by Martin Schwidefsky <schwidefsky@de.ibm.com>
8 * -- Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
9 */
10
11#include <linux/bootmem.h>
12#include <linux/console.h>
13#include <linux/init.h>
14#include <linux/interrupt.h>
15#include <linux/list.h>
16#include <linux/types.h>
17#include <linux/smp_lock.h>
18
19#include <asm/ccwdev.h>
20#include <asm/cio.h>
21#include <asm/ebcdic.h>
22#include <asm/idals.h>
23
24#include "raw3270.h"
25#include "ctrlchar.h"

--- 186 unchanged lines hidden (view full) ---

212 if (fp->init->rc)
213 fp->init->callback(fp->init, NULL);
214}
215
216static int
217fs3270_irq(struct fs3270 *fp, struct raw3270_request *rq, struct irb *irb)
218{
219 /* Handle ATTN. Set indication and wake waiters for attention. */
17
18#include <asm/ccwdev.h>
19#include <asm/cio.h>
20#include <asm/ebcdic.h>
21#include <asm/idals.h>
22
23#include "raw3270.h"
24#include "ctrlchar.h"

--- 186 unchanged lines hidden (view full) ---

211 if (fp->init->rc)
212 fp->init->callback(fp->init, NULL);
213}
214
215static int
216fs3270_irq(struct fs3270 *fp, struct raw3270_request *rq, struct irb *irb)
217{
218 /* Handle ATTN. Set indication and wake waiters for attention. */
220 if (irb->scsw.dstat & DEV_STAT_ATTENTION) {
219 if (irb->scsw.cmd.dstat & DEV_STAT_ATTENTION) {
221 fp->attention = 1;
222 wake_up(&fp->wait);
223 }
224
225 if (rq) {
220 fp->attention = 1;
221 wake_up(&fp->wait);
222 }
223
224 if (rq) {
226 if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK)
225 if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK)
227 rq->rc = -EIO;
228 else
229 /* Normal end. Copy residual count. */
226 rq->rc = -EIO;
227 else
228 /* Normal end. Copy residual count. */
230 rq->rescnt = irb->scsw.count;
229 rq->rescnt = irb->scsw.cmd.count;
231 }
232 return RAW3270_IO_DONE;
233}
234
235/*
236 * Process reads from fullscreen 3270.
237 */
238static ssize_t

--- 178 unchanged lines hidden (view full) ---

417fs3270_open(struct inode *inode, struct file *filp)
418{
419 struct fs3270 *fp;
420 struct idal_buffer *ib;
421 int minor, rc;
422
423 if (imajor(filp->f_path.dentry->d_inode) != IBM_FS3270_MAJOR)
424 return -ENODEV;
230 }
231 return RAW3270_IO_DONE;
232}
233
234/*
235 * Process reads from fullscreen 3270.
236 */
237static ssize_t

--- 178 unchanged lines hidden (view full) ---

416fs3270_open(struct inode *inode, struct file *filp)
417{
418 struct fs3270 *fp;
419 struct idal_buffer *ib;
420 int minor, rc;
421
422 if (imajor(filp->f_path.dentry->d_inode) != IBM_FS3270_MAJOR)
423 return -ENODEV;
425 lock_kernel();
426 minor = iminor(filp->f_path.dentry->d_inode);
427 /* Check for minor 0 multiplexer. */
428 if (minor == 0) {
429 struct tty_struct *tty;
430 mutex_lock(&tty_mutex);
431 tty = get_current_tty();
432 if (!tty || tty->driver->major != IBM_TTY3270_MAJOR) {
433 mutex_unlock(&tty_mutex);
424 minor = iminor(filp->f_path.dentry->d_inode);
425 /* Check for minor 0 multiplexer. */
426 if (minor == 0) {
427 struct tty_struct *tty;
428 mutex_lock(&tty_mutex);
429 tty = get_current_tty();
430 if (!tty || tty->driver->major != IBM_TTY3270_MAJOR) {
431 mutex_unlock(&tty_mutex);
434 rc = -ENODEV;
435 goto out;
432 return -ENODEV;
436 }
437 minor = tty->index + RAW3270_FIRSTMINOR;
438 mutex_unlock(&tty_mutex);
439 }
440 /* Check if some other program is already using fullscreen mode. */
441 fp = (struct fs3270 *) raw3270_find_view(&fs3270_fn, minor);
442 if (!IS_ERR(fp)) {
443 raw3270_put_view(&fp->view);
433 }
434 minor = tty->index + RAW3270_FIRSTMINOR;
435 mutex_unlock(&tty_mutex);
436 }
437 /* Check if some other program is already using fullscreen mode. */
438 fp = (struct fs3270 *) raw3270_find_view(&fs3270_fn, minor);
439 if (!IS_ERR(fp)) {
440 raw3270_put_view(&fp->view);
444 rc = -EBUSY;
445 goto out;
441 return -EBUSY;
446 }
447 /* Allocate fullscreen view structure. */
448 fp = fs3270_alloc_view();
442 }
443 /* Allocate fullscreen view structure. */
444 fp = fs3270_alloc_view();
449 if (IS_ERR(fp)) {
450 rc = PTR_ERR(fp);
451 goto out;
452 }
445 if (IS_ERR(fp))
446 return PTR_ERR(fp);
453
454 init_waitqueue_head(&fp->wait);
455 fp->fs_pid = get_pid(task_pid(current));
456 rc = raw3270_add_view(&fp->view, &fs3270_fn, minor);
457 if (rc) {
458 fs3270_free_view(&fp->view);
447
448 init_waitqueue_head(&fp->wait);
449 fp->fs_pid = get_pid(task_pid(current));
450 rc = raw3270_add_view(&fp->view, &fs3270_fn, minor);
451 if (rc) {
452 fs3270_free_view(&fp->view);
459 goto out;
453 return rc;
460 }
461
462 /* Allocate idal-buffer. */
463 ib = idal_buffer_alloc(2*fp->view.rows*fp->view.cols + 5, 0);
464 if (IS_ERR(ib)) {
465 raw3270_put_view(&fp->view);
466 raw3270_del_view(&fp->view);
454 }
455
456 /* Allocate idal-buffer. */
457 ib = idal_buffer_alloc(2*fp->view.rows*fp->view.cols + 5, 0);
458 if (IS_ERR(ib)) {
459 raw3270_put_view(&fp->view);
460 raw3270_del_view(&fp->view);
467 rc = PTR_ERR(fp);
468 goto out;
461 return PTR_ERR(fp);
469 }
470 fp->rdbuf = ib;
471
472 rc = raw3270_activate_view(&fp->view);
473 if (rc) {
474 raw3270_put_view(&fp->view);
475 raw3270_del_view(&fp->view);
462 }
463 fp->rdbuf = ib;
464
465 rc = raw3270_activate_view(&fp->view);
466 if (rc) {
467 raw3270_put_view(&fp->view);
468 raw3270_del_view(&fp->view);
476 goto out;
469 return rc;
477 }
478 filp->private_data = fp;
470 }
471 filp->private_data = fp;
479out:
480 unlock_kernel();
481 return 0;
482}
483
484/*
485 * This routine is called when the 3270 tty is closed. We wait
486 * for the remaining request to be completed. Then we clean up.
487 */
488static int

--- 54 unchanged lines hidden ---
472 return 0;
473}
474
475/*
476 * This routine is called when the 3270 tty is closed. We wait
477 * for the remaining request to be completed. Then we clean up.
478 */
479static int

--- 54 unchanged lines hidden ---