2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* drivers/s390/char/con3215.c
|
|
|
|
* 3215 line mode terminal driver.
|
|
|
|
*
|
|
|
|
* S390 version
|
|
|
|
* Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
|
|
|
|
* Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
|
|
|
|
*
|
|
|
|
* Updated:
|
|
|
|
* Aug-2000: Added tab support
|
|
|
|
* Dan Morrison, IBM Corporation (dmorriso@cse.buffalo.edu)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/kdev_t.h>
|
|
|
|
#include <linux/tty.h>
|
[PATCH] TTY layer buffering revamp
The API and code have been through various bits of initial review by
serial driver people but they definitely need to live somewhere for a
while so the unconverted drivers can get knocked into shape, existing
drivers that have been updated can be better tuned and bugs whacked out.
This replaces the tty flip buffers with kmalloc objects in rings. In the
normal situation for an IRQ driven serial port at typical speeds the
behaviour is pretty much the same, two buffers end up allocated and the
kernel cycles between them as before.
When there are delays or at high speed we now behave far better as the
buffer pool can grow a bit rather than lose characters. This also means
that we can operate at higher speeds reliably.
For drivers that receive characters in blocks (DMA based, USB and
especially virtualisation) the layer allows a lot of driver specific
code that works around the tty layer with private secondary queues to be
removed. The IBM folks need this sort of layer, the smart serial port
people do, the virtualisers do (because a virtualised tty typically
operates at infinite speed rather than emulating 9600 baud).
Finally many drivers had invalid and unsafe attempts to avoid buffer
overflows by directly invoking tty methods extracted out of the innards
of work queue structs. These are no longer needed and all go away. That
fixes various random hangs with serial ports on overflow.
The other change in here is to optimise the receive_room path that is
used by some callers. It turns out that only one ldisc uses receive room
except asa constant and it updates it far far less than the value is
read. We thus make it a variable not a function call.
I expect the code to contain bugs due to the size alone but I'll be
watching and squashing them and feeding out new patches as it goes.
Because the buffers now dynamically expand you should only run out of
buffering when the kernel runs out of memory for real. That means a lot of
the horrible hacks high performance drivers used to do just aren't needed any
more.
Description:
tty_insert_flip_char is an old API and continues to work as before, as does
tty_flip_buffer_push() [this is why many drivers dont need modification]. It
does now also return the number of chars inserted
There are also
tty_buffer_request_room(tty, len)
which asks for a buffer block of the length requested and returns the space
found. This improves efficiency with hardware that knows how much to
transfer.
and tty_insert_flip_string_flags(tty, str, flags, len)
to insert a string of characters and flags
For a smart interface the usual code is
len = tty_request_buffer_room(tty, amount_hardware_says);
tty_insert_flip_string(tty, buffer_from_card, len);
More description!
At the moment tty buffers are attached directly to the tty. This is causing a
lot of the problems related to tty layer locking, also problems at high speed
and also with bursty data (such as occurs in virtualised environments)
I'm working on ripping out the flip buffers and replacing them with a pool of
dynamically allocated buffers. This allows both for old style "byte I/O"
devices and also helps virtualisation and smart devices where large blocks of
data suddenely materialise and need storing.
So far so good. Lots of drivers reference tty->flip.*. Several of them also
call directly and unsafely into function pointers it provides. This will all
break. Most drivers can use tty_insert_flip_char which can be kept as an API
but others need more.
At the moment I've added the following interfaces, if people think more will
be needed now is a good time to say
int tty_buffer_request_room(tty, size)
Try and ensure at least size bytes are available, returns actual room (may be
zero). At the moment it just uses the flipbuf space but that will change.
Repeated calls without characters being added are not cumulative. (ie if you
call it with 1, 1, 1, and then 4 you'll have four characters of space. The
other functions will also try and grow buffers in future but this will be a
more efficient way when you know block sizes.
int tty_insert_flip_char(tty, ch, flag)
As before insert a character if there is room. Now returns 1 for success, 0
for failure.
int tty_insert_flip_string(tty, str, len)
Insert a block of non error characters. Returns the number inserted.
int tty_prepare_flip_string(tty, strptr, len)
Adjust the buffer to allow len characters to be added. Returns a buffer
pointer in strptr and the length available. This allows for hardware that
needs to use functions like insl or mencpy_fromio.
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-09 21:54:13 -07:00
|
|
|
#include <linux/tty_flip.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <linux/vt_kern.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/console.h>
|
|
|
|
#include <linux/interrupt.h>
|
2006-02-01 04:06:35 -07:00
|
|
|
#include <linux/err.h>
|
2008-10-10 13:33:27 -06:00
|
|
|
#include <linux/reboot.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/bootmem.h>
|
|
|
|
|
|
|
|
#include <asm/ccwdev.h>
|
|
|
|
#include <asm/cio.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/ebcdic.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <asm/delay.h>
|
|
|
|
#include <asm/cpcmd.h>
|
|
|
|
#include <asm/setup.h>
|
|
|
|
|
|
|
|
#include "ctrlchar.h"
|
|
|
|
|
|
|
|
#define NR_3215 1
|
|
|
|
#define NR_3215_REQ (4*NR_3215)
|
|
|
|
#define RAW3215_BUFFER_SIZE 65536 /* output buffer size */
|
|
|
|
#define RAW3215_INBUF_SIZE 256 /* input buffer size */
|
|
|
|
#define RAW3215_MIN_SPACE 128 /* minimum free space for wakeup */
|
|
|
|
#define RAW3215_MIN_WRITE 1024 /* min. length for immediate output */
|
|
|
|
#define RAW3215_MAX_BYTES 3968 /* max. bytes to write with one ssch */
|
|
|
|
#define RAW3215_MAX_NEWLINE 50 /* max. lines to write with one ssch */
|
|
|
|
#define RAW3215_NR_CCWS 3
|
|
|
|
#define RAW3215_TIMEOUT HZ/10 /* time for delayed output */
|
|
|
|
|
|
|
|
#define RAW3215_FIXED 1 /* 3215 console device is not be freed */
|
|
|
|
#define RAW3215_ACTIVE 2 /* set if the device is in use */
|
|
|
|
#define RAW3215_WORKING 4 /* set if a request is being worked on */
|
|
|
|
#define RAW3215_THROTTLED 8 /* set if reading is disabled */
|
|
|
|
#define RAW3215_STOPPED 16 /* set if writing is disabled */
|
|
|
|
#define RAW3215_CLOSING 32 /* set while in close process */
|
|
|
|
#define RAW3215_TIMER_RUNS 64 /* set if the output delay timer is on */
|
|
|
|
#define RAW3215_FLUSHING 128 /* set to flush buffer (no delay) */
|
|
|
|
|
|
|
|
#define TAB_STOP_SIZE 8 /* tab stop size */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Request types for a 3215 device
|
|
|
|
*/
|
|
|
|
enum raw3215_type {
|
|
|
|
RAW3215_FREE, RAW3215_READ, RAW3215_WRITE
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Request structure for a 3215 device
|
|
|
|
*/
|
|
|
|
struct raw3215_req {
|
|
|
|
enum raw3215_type type; /* type of the request */
|
|
|
|
int start, len; /* start index & len in output buffer */
|
|
|
|
int delayable; /* indication to wait for more data */
|
|
|
|
int residual; /* residual count for read request */
|
|
|
|
struct ccw1 ccws[RAW3215_NR_CCWS]; /* space for the channel program */
|
|
|
|
struct raw3215_info *info; /* pointer to main structure */
|
|
|
|
struct raw3215_req *next; /* pointer to next request */
|
|
|
|
} __attribute__ ((aligned(8)));
|
|
|
|
|
|
|
|
struct raw3215_info {
|
|
|
|
struct ccw_device *cdev; /* device for tty driver */
|
|
|
|
spinlock_t *lock; /* pointer to irq lock */
|
|
|
|
int flags; /* state flags */
|
|
|
|
char *buffer; /* pointer to output buffer */
|
|
|
|
char *inbuf; /* pointer to input buffer */
|
|
|
|
int head; /* first free byte in output buffer */
|
|
|
|
int count; /* number of bytes in output buffer */
|
|
|
|
int written; /* number of bytes in write requests */
|
|
|
|
struct tty_struct *tty; /* pointer to tty structure if present */
|
|
|
|
struct raw3215_req *queued_read; /* pointer to queued read requests */
|
|
|
|
struct raw3215_req *queued_write;/* pointer to queued write requests */
|
|
|
|
wait_queue_head_t empty_wait; /* wait queue for flushing */
|
|
|
|
struct timer_list timer; /* timer for delayed output */
|
|
|
|
int line_pos; /* position on the line (for tabs) */
|
|
|
|
char ubuffer[80]; /* copy_from_user buffer */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* array of 3215 devices structures */
|
|
|
|
static struct raw3215_info *raw3215[NR_3215];
|
|
|
|
/* spinlock to protect the raw3215 array */
|
|
|
|
static DEFINE_SPINLOCK(raw3215_device_lock);
|
|
|
|
/* list of free request structures */
|
|
|
|
static struct raw3215_req *raw3215_freelist;
|
|
|
|
/* spinlock to protect free list */
|
|
|
|
static spinlock_t raw3215_freelist_lock;
|
|
|
|
|
|
|
|
static struct tty_driver *tty3215_driver;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get a request structure from the free list
|
|
|
|
*/
|
|
|
|
static inline struct raw3215_req *
|
|
|
|
raw3215_alloc_req(void) {
|
|
|
|
struct raw3215_req *req;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&raw3215_freelist_lock, flags);
|
|
|
|
req = raw3215_freelist;
|
|
|
|
raw3215_freelist = req->next;
|
|
|
|
spin_unlock_irqrestore(&raw3215_freelist_lock, flags);
|
|
|
|
return req;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Put a request structure back to the free list
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
raw3215_free_req(struct raw3215_req *req) {
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (req->type == RAW3215_FREE)
|
|
|
|
return; /* don't free a free request */
|
|
|
|
req->type = RAW3215_FREE;
|
|
|
|
spin_lock_irqsave(&raw3215_freelist_lock, flags);
|
|
|
|
req->next = raw3215_freelist;
|
|
|
|
raw3215_freelist = req;
|
|
|
|
spin_unlock_irqrestore(&raw3215_freelist_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up a read request that reads up to 160 byte from the 3215 device.
|
|
|
|
* If there is a queued read request it is used, but that shouldn't happen
|
|
|
|
* because a 3215 terminal won't accept a new read before the old one is
|
|
|
|
* completed.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
raw3215_mk_read_req(struct raw3215_info *raw)
|
|
|
|
{
|
|
|
|
struct raw3215_req *req;
|
|
|
|
struct ccw1 *ccw;
|
|
|
|
|
|
|
|
/* there can only be ONE read request at a time */
|
|
|
|
req = raw->queued_read;
|
|
|
|
if (req == NULL) {
|
|
|
|
/* no queued read request, use new req structure */
|
|
|
|
req = raw3215_alloc_req();
|
|
|
|
req->type = RAW3215_READ;
|
|
|
|
req->info = raw;
|
|
|
|
raw->queued_read = req;
|
|
|
|
}
|
|
|
|
|
|
|
|
ccw = req->ccws;
|
|
|
|
ccw->cmd_code = 0x0A; /* read inquiry */
|
|
|
|
ccw->flags = 0x20; /* ignore incorrect length */
|
|
|
|
ccw->count = 160;
|
|
|
|
ccw->cda = (__u32) __pa(raw->inbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up a write request with the information from the main structure.
|
|
|
|
* A ccw chain is created that writes as much as possible from the output
|
|
|
|
* buffer to the 3215 device. If a queued write exists it is replaced by
|
|
|
|
* the new, probably lengthened request.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
raw3215_mk_write_req(struct raw3215_info *raw)
|
|
|
|
{
|
|
|
|
struct raw3215_req *req;
|
|
|
|
struct ccw1 *ccw;
|
|
|
|
int len, count, ix, lines;
|
|
|
|
|
|
|
|
if (raw->count <= raw->written)
|
|
|
|
return;
|
|
|
|
/* check if there is a queued write request */
|
|
|
|
req = raw->queued_write;
|
|
|
|
if (req == NULL) {
|
|
|
|
/* no queued write request, use new req structure */
|
|
|
|
req = raw3215_alloc_req();
|
|
|
|
req->type = RAW3215_WRITE;
|
|
|
|
req->info = raw;
|
|
|
|
raw->queued_write = req;
|
|
|
|
} else {
|
|
|
|
raw->written -= req->len;
|
|
|
|
}
|
|
|
|
|
|
|
|
ccw = req->ccws;
|
|
|
|
req->start = (raw->head - raw->count + raw->written) &
|
|
|
|
(RAW3215_BUFFER_SIZE - 1);
|
|
|
|
/*
|
|
|
|
* now we have to count newlines. We can at max accept
|
|
|
|
* RAW3215_MAX_NEWLINE newlines in a single ssch due to
|
|
|
|
* a restriction in VM
|
|
|
|
*/
|
|
|
|
lines = 0;
|
|
|
|
ix = req->start;
|
|
|
|
while (lines < RAW3215_MAX_NEWLINE && ix != raw->head) {
|
|
|
|
if (raw->buffer[ix] == 0x15)
|
|
|
|
lines++;
|
|
|
|
ix = (ix + 1) & (RAW3215_BUFFER_SIZE - 1);
|
|
|
|
}
|
|
|
|
len = ((ix - 1 - req->start) & (RAW3215_BUFFER_SIZE - 1)) + 1;
|
|
|
|
if (len > RAW3215_MAX_BYTES)
|
|
|
|
len = RAW3215_MAX_BYTES;
|
|
|
|
req->len = len;
|
|
|
|
raw->written += len;
|
|
|
|
|
|
|
|
/* set the indication if we should try to enlarge this request */
|
|
|
|
req->delayable = (ix == raw->head) && (len < RAW3215_MIN_WRITE);
|
|
|
|
|
|
|
|
ix = req->start;
|
|
|
|
while (len > 0) {
|
|
|
|
if (ccw > req->ccws)
|
|
|
|
ccw[-1].flags |= 0x40; /* use command chaining */
|
|
|
|
ccw->cmd_code = 0x01; /* write, auto carrier return */
|
|
|
|
ccw->flags = 0x20; /* ignore incorrect length ind. */
|
|
|
|
ccw->cda =
|
|
|
|
(__u32) __pa(raw->buffer + ix);
|
|
|
|
count = len;
|
|
|
|
if (ix + count > RAW3215_BUFFER_SIZE)
|
|
|
|
count = RAW3215_BUFFER_SIZE - ix;
|
|
|
|
ccw->count = count;
|
|
|
|
len -= count;
|
|
|
|
ix = (ix + count) & (RAW3215_BUFFER_SIZE - 1);
|
|
|
|
ccw++;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Add a NOP to the channel program. 3215 devices are purely
|
|
|
|
* emulated and its much better to avoid the channel end
|
|
|
|
* interrupt in this case.
|
|
|
|
*/
|
|
|
|
if (ccw > req->ccws)
|
|
|
|
ccw[-1].flags |= 0x40; /* use command chaining */
|
|
|
|
ccw->cmd_code = 0x03; /* NOP */
|
|
|
|
ccw->flags = 0;
|
|
|
|
ccw->cda = 0;
|
|
|
|
ccw->count = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start a read or a write request
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
raw3215_start_io(struct raw3215_info *raw)
|
|
|
|
{
|
|
|
|
struct raw3215_req *req;
|
|
|
|
int res;
|
|
|
|
|
|
|
|
req = raw->queued_read;
|
|
|
|
if (req != NULL &&
|
|
|
|
!(raw->flags & (RAW3215_WORKING | RAW3215_THROTTLED))) {
|
|
|
|
/* dequeue request */
|
|
|
|
raw->queued_read = NULL;
|
|
|
|
res = ccw_device_start(raw->cdev, req->ccws,
|
|
|
|
(unsigned long) req, 0, 0);
|
|
|
|
if (res != 0) {
|
|
|
|
/* do_IO failed, put request back to queue */
|
|
|
|
raw->queued_read = req;
|
|
|
|
} else {
|
|
|
|
raw->flags |= RAW3215_WORKING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
req = raw->queued_write;
|
|
|
|
if (req != NULL &&
|
|
|
|
!(raw->flags & (RAW3215_WORKING | RAW3215_STOPPED))) {
|
|
|
|
/* dequeue request */
|
|
|
|
raw->queued_write = NULL;
|
|
|
|
res = ccw_device_start(raw->cdev, req->ccws,
|
|
|
|
(unsigned long) req, 0, 0);
|
|
|
|
if (res != 0) {
|
|
|
|
/* do_IO failed, put request back to queue */
|
|
|
|
raw->queued_write = req;
|
|
|
|
} else {
|
|
|
|
raw->flags |= RAW3215_WORKING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function to start a delayed output after RAW3215_TIMEOUT seconds
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
raw3215_timeout(unsigned long __data)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw = (struct raw3215_info *) __data;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (raw->flags & RAW3215_TIMER_RUNS) {
|
|
|
|
del_timer(&raw->timer);
|
|
|
|
raw->flags &= ~RAW3215_TIMER_RUNS;
|
|
|
|
raw3215_mk_write_req(raw);
|
|
|
|
raw3215_start_io(raw);
|
|
|
|
}
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function to conditionally start an IO. A read is started immediately,
|
|
|
|
* a write is only started immediately if the flush flag is on or the
|
|
|
|
* amount of data is bigger than RAW3215_MIN_WRITE. If a write is not
|
|
|
|
* done immediately a timer is started with a delay of RAW3215_TIMEOUT.
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
raw3215_try_io(struct raw3215_info *raw)
|
|
|
|
{
|
|
|
|
if (!(raw->flags & RAW3215_ACTIVE))
|
|
|
|
return;
|
|
|
|
if (raw->queued_read != NULL)
|
|
|
|
raw3215_start_io(raw);
|
|
|
|
else if (raw->queued_write != NULL) {
|
|
|
|
if ((raw->queued_write->delayable == 0) ||
|
|
|
|
(raw->flags & RAW3215_FLUSHING)) {
|
|
|
|
/* execute write requests bigger than minimum size */
|
|
|
|
raw3215_start_io(raw);
|
|
|
|
if (raw->flags & RAW3215_TIMER_RUNS) {
|
|
|
|
del_timer(&raw->timer);
|
|
|
|
raw->flags &= ~RAW3215_TIMER_RUNS;
|
|
|
|
}
|
|
|
|
} else if (!(raw->flags & RAW3215_TIMER_RUNS)) {
|
|
|
|
/* delay small writes */
|
|
|
|
init_timer(&raw->timer);
|
|
|
|
raw->timer.expires = RAW3215_TIMEOUT + jiffies;
|
|
|
|
raw->timer.data = (unsigned long) raw;
|
|
|
|
raw->timer.function = raw3215_timeout;
|
|
|
|
add_timer(&raw->timer);
|
|
|
|
raw->flags |= RAW3215_TIMER_RUNS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-10-10 13:33:28 -06:00
|
|
|
* Try to start the next IO and wake up processes waiting on the tty.
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2008-10-10 13:33:28 -06:00
|
|
|
static void raw3215_next_io(struct raw3215_info *raw)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
struct tty_struct *tty;
|
|
|
|
|
|
|
|
raw3215_mk_write_req(raw);
|
|
|
|
raw3215_try_io(raw);
|
|
|
|
tty = raw->tty;
|
|
|
|
if (tty != NULL &&
|
|
|
|
RAW3215_BUFFER_SIZE - raw->count >= RAW3215_MIN_SPACE) {
|
|
|
|
tty_wakeup(tty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interrupt routine, called from common io layer
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
raw3215_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
struct raw3215_req *req;
|
|
|
|
struct tty_struct *tty;
|
|
|
|
int cstat, dstat;
|
2008-07-14 01:59:44 -06:00
|
|
|
int count;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
raw = cdev->dev.driver_data;
|
|
|
|
req = (struct raw3215_req *) intparm;
|
2008-07-14 01:58:50 -06:00
|
|
|
cstat = irb->scsw.cmd.cstat;
|
|
|
|
dstat = irb->scsw.cmd.dstat;
|
2008-07-14 01:59:26 -06:00
|
|
|
if (cstat != 0)
|
2008-10-10 13:33:28 -06:00
|
|
|
raw3215_next_io(raw);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (dstat & 0x01) { /* we got a unit exception */
|
|
|
|
dstat &= ~0x01; /* we can ignore it */
|
|
|
|
}
|
|
|
|
switch (dstat) {
|
|
|
|
case 0x80:
|
|
|
|
if (cstat != 0)
|
|
|
|
break;
|
|
|
|
/* Attention interrupt, someone hit the enter key */
|
|
|
|
raw3215_mk_read_req(raw);
|
2008-10-10 13:33:28 -06:00
|
|
|
raw3215_next_io(raw);
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
case 0x08:
|
|
|
|
case 0x0C:
|
|
|
|
/* Channel end interrupt. */
|
|
|
|
if ((raw = req->info) == NULL)
|
|
|
|
return; /* That shouldn't happen ... */
|
|
|
|
if (req->type == RAW3215_READ) {
|
|
|
|
/* store residual count, then wait for device end */
|
2008-07-14 01:58:50 -06:00
|
|
|
req->residual = irb->scsw.cmd.count;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
if (dstat == 0x08)
|
|
|
|
break;
|
|
|
|
case 0x04:
|
|
|
|
/* Device end interrupt. */
|
|
|
|
if ((raw = req->info) == NULL)
|
|
|
|
return; /* That shouldn't happen ... */
|
|
|
|
if (req->type == RAW3215_READ && raw->tty != NULL) {
|
|
|
|
unsigned int cchar;
|
|
|
|
|
|
|
|
tty = raw->tty;
|
|
|
|
count = 160 - req->residual;
|
|
|
|
EBCASC(raw->inbuf, count);
|
|
|
|
cchar = ctrlchar_handle(raw->inbuf, count, tty);
|
|
|
|
switch (cchar & CTRLCHAR_MASK) {
|
|
|
|
case CTRLCHAR_SYSRQ:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CTRLCHAR_CTRL:
|
[PATCH] TTY layer buffering revamp
The API and code have been through various bits of initial review by
serial driver people but they definitely need to live somewhere for a
while so the unconverted drivers can get knocked into shape, existing
drivers that have been updated can be better tuned and bugs whacked out.
This replaces the tty flip buffers with kmalloc objects in rings. In the
normal situation for an IRQ driven serial port at typical speeds the
behaviour is pretty much the same, two buffers end up allocated and the
kernel cycles between them as before.
When there are delays or at high speed we now behave far better as the
buffer pool can grow a bit rather than lose characters. This also means
that we can operate at higher speeds reliably.
For drivers that receive characters in blocks (DMA based, USB and
especially virtualisation) the layer allows a lot of driver specific
code that works around the tty layer with private secondary queues to be
removed. The IBM folks need this sort of layer, the smart serial port
people do, the virtualisers do (because a virtualised tty typically
operates at infinite speed rather than emulating 9600 baud).
Finally many drivers had invalid and unsafe attempts to avoid buffer
overflows by directly invoking tty methods extracted out of the innards
of work queue structs. These are no longer needed and all go away. That
fixes various random hangs with serial ports on overflow.
The other change in here is to optimise the receive_room path that is
used by some callers. It turns out that only one ldisc uses receive room
except asa constant and it updates it far far less than the value is
read. We thus make it a variable not a function call.
I expect the code to contain bugs due to the size alone but I'll be
watching and squashing them and feeding out new patches as it goes.
Because the buffers now dynamically expand you should only run out of
buffering when the kernel runs out of memory for real. That means a lot of
the horrible hacks high performance drivers used to do just aren't needed any
more.
Description:
tty_insert_flip_char is an old API and continues to work as before, as does
tty_flip_buffer_push() [this is why many drivers dont need modification]. It
does now also return the number of chars inserted
There are also
tty_buffer_request_room(tty, len)
which asks for a buffer block of the length requested and returns the space
found. This improves efficiency with hardware that knows how much to
transfer.
and tty_insert_flip_string_flags(tty, str, flags, len)
to insert a string of characters and flags
For a smart interface the usual code is
len = tty_request_buffer_room(tty, amount_hardware_says);
tty_insert_flip_string(tty, buffer_from_card, len);
More description!
At the moment tty buffers are attached directly to the tty. This is causing a
lot of the problems related to tty layer locking, also problems at high speed
and also with bursty data (such as occurs in virtualised environments)
I'm working on ripping out the flip buffers and replacing them with a pool of
dynamically allocated buffers. This allows both for old style "byte I/O"
devices and also helps virtualisation and smart devices where large blocks of
data suddenely materialise and need storing.
So far so good. Lots of drivers reference tty->flip.*. Several of them also
call directly and unsafely into function pointers it provides. This will all
break. Most drivers can use tty_insert_flip_char which can be kept as an API
but others need more.
At the moment I've added the following interfaces, if people think more will
be needed now is a good time to say
int tty_buffer_request_room(tty, size)
Try and ensure at least size bytes are available, returns actual room (may be
zero). At the moment it just uses the flipbuf space but that will change.
Repeated calls without characters being added are not cumulative. (ie if you
call it with 1, 1, 1, and then 4 you'll have four characters of space. The
other functions will also try and grow buffers in future but this will be a
more efficient way when you know block sizes.
int tty_insert_flip_char(tty, ch, flag)
As before insert a character if there is room. Now returns 1 for success, 0
for failure.
int tty_insert_flip_string(tty, str, len)
Insert a block of non error characters. Returns the number inserted.
int tty_prepare_flip_string(tty, strptr, len)
Adjust the buffer to allow len characters to be added. Returns a buffer
pointer in strptr and the length available. This allows for hardware that
needs to use functions like insl or mencpy_fromio.
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-09 21:54:13 -07:00
|
|
|
tty_insert_flip_char(tty, cchar, TTY_NORMAL);
|
2005-04-16 16:20:36 -06:00
|
|
|
tty_flip_buffer_push(raw->tty);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CTRLCHAR_NONE:
|
|
|
|
if (count < 2 ||
|
[PATCH] TTY layer buffering revamp
The API and code have been through various bits of initial review by
serial driver people but they definitely need to live somewhere for a
while so the unconverted drivers can get knocked into shape, existing
drivers that have been updated can be better tuned and bugs whacked out.
This replaces the tty flip buffers with kmalloc objects in rings. In the
normal situation for an IRQ driven serial port at typical speeds the
behaviour is pretty much the same, two buffers end up allocated and the
kernel cycles between them as before.
When there are delays or at high speed we now behave far better as the
buffer pool can grow a bit rather than lose characters. This also means
that we can operate at higher speeds reliably.
For drivers that receive characters in blocks (DMA based, USB and
especially virtualisation) the layer allows a lot of driver specific
code that works around the tty layer with private secondary queues to be
removed. The IBM folks need this sort of layer, the smart serial port
people do, the virtualisers do (because a virtualised tty typically
operates at infinite speed rather than emulating 9600 baud).
Finally many drivers had invalid and unsafe attempts to avoid buffer
overflows by directly invoking tty methods extracted out of the innards
of work queue structs. These are no longer needed and all go away. That
fixes various random hangs with serial ports on overflow.
The other change in here is to optimise the receive_room path that is
used by some callers. It turns out that only one ldisc uses receive room
except asa constant and it updates it far far less than the value is
read. We thus make it a variable not a function call.
I expect the code to contain bugs due to the size alone but I'll be
watching and squashing them and feeding out new patches as it goes.
Because the buffers now dynamically expand you should only run out of
buffering when the kernel runs out of memory for real. That means a lot of
the horrible hacks high performance drivers used to do just aren't needed any
more.
Description:
tty_insert_flip_char is an old API and continues to work as before, as does
tty_flip_buffer_push() [this is why many drivers dont need modification]. It
does now also return the number of chars inserted
There are also
tty_buffer_request_room(tty, len)
which asks for a buffer block of the length requested and returns the space
found. This improves efficiency with hardware that knows how much to
transfer.
and tty_insert_flip_string_flags(tty, str, flags, len)
to insert a string of characters and flags
For a smart interface the usual code is
len = tty_request_buffer_room(tty, amount_hardware_says);
tty_insert_flip_string(tty, buffer_from_card, len);
More description!
At the moment tty buffers are attached directly to the tty. This is causing a
lot of the problems related to tty layer locking, also problems at high speed
and also with bursty data (such as occurs in virtualised environments)
I'm working on ripping out the flip buffers and replacing them with a pool of
dynamically allocated buffers. This allows both for old style "byte I/O"
devices and also helps virtualisation and smart devices where large blocks of
data suddenely materialise and need storing.
So far so good. Lots of drivers reference tty->flip.*. Several of them also
call directly and unsafely into function pointers it provides. This will all
break. Most drivers can use tty_insert_flip_char which can be kept as an API
but others need more.
At the moment I've added the following interfaces, if people think more will
be needed now is a good time to say
int tty_buffer_request_room(tty, size)
Try and ensure at least size bytes are available, returns actual room (may be
zero). At the moment it just uses the flipbuf space but that will change.
Repeated calls without characters being added are not cumulative. (ie if you
call it with 1, 1, 1, and then 4 you'll have four characters of space. The
other functions will also try and grow buffers in future but this will be a
more efficient way when you know block sizes.
int tty_insert_flip_char(tty, ch, flag)
As before insert a character if there is room. Now returns 1 for success, 0
for failure.
int tty_insert_flip_string(tty, str, len)
Insert a block of non error characters. Returns the number inserted.
int tty_prepare_flip_string(tty, strptr, len)
Adjust the buffer to allow len characters to be added. Returns a buffer
pointer in strptr and the length available. This allows for hardware that
needs to use functions like insl or mencpy_fromio.
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-09 21:54:13 -07:00
|
|
|
(strncmp(raw->inbuf+count-2, "\252n", 2) &&
|
|
|
|
strncmp(raw->inbuf+count-2, "^n", 2)) ) {
|
|
|
|
/* add the auto \n */
|
|
|
|
raw->inbuf[count] = '\n';
|
2005-04-16 16:20:36 -06:00
|
|
|
count++;
|
|
|
|
} else
|
[PATCH] TTY layer buffering revamp
The API and code have been through various bits of initial review by
serial driver people but they definitely need to live somewhere for a
while so the unconverted drivers can get knocked into shape, existing
drivers that have been updated can be better tuned and bugs whacked out.
This replaces the tty flip buffers with kmalloc objects in rings. In the
normal situation for an IRQ driven serial port at typical speeds the
behaviour is pretty much the same, two buffers end up allocated and the
kernel cycles between them as before.
When there are delays or at high speed we now behave far better as the
buffer pool can grow a bit rather than lose characters. This also means
that we can operate at higher speeds reliably.
For drivers that receive characters in blocks (DMA based, USB and
especially virtualisation) the layer allows a lot of driver specific
code that works around the tty layer with private secondary queues to be
removed. The IBM folks need this sort of layer, the smart serial port
people do, the virtualisers do (because a virtualised tty typically
operates at infinite speed rather than emulating 9600 baud).
Finally many drivers had invalid and unsafe attempts to avoid buffer
overflows by directly invoking tty methods extracted out of the innards
of work queue structs. These are no longer needed and all go away. That
fixes various random hangs with serial ports on overflow.
The other change in here is to optimise the receive_room path that is
used by some callers. It turns out that only one ldisc uses receive room
except asa constant and it updates it far far less than the value is
read. We thus make it a variable not a function call.
I expect the code to contain bugs due to the size alone but I'll be
watching and squashing them and feeding out new patches as it goes.
Because the buffers now dynamically expand you should only run out of
buffering when the kernel runs out of memory for real. That means a lot of
the horrible hacks high performance drivers used to do just aren't needed any
more.
Description:
tty_insert_flip_char is an old API and continues to work as before, as does
tty_flip_buffer_push() [this is why many drivers dont need modification]. It
does now also return the number of chars inserted
There are also
tty_buffer_request_room(tty, len)
which asks for a buffer block of the length requested and returns the space
found. This improves efficiency with hardware that knows how much to
transfer.
and tty_insert_flip_string_flags(tty, str, flags, len)
to insert a string of characters and flags
For a smart interface the usual code is
len = tty_request_buffer_room(tty, amount_hardware_says);
tty_insert_flip_string(tty, buffer_from_card, len);
More description!
At the moment tty buffers are attached directly to the tty. This is causing a
lot of the problems related to tty layer locking, also problems at high speed
and also with bursty data (such as occurs in virtualised environments)
I'm working on ripping out the flip buffers and replacing them with a pool of
dynamically allocated buffers. This allows both for old style "byte I/O"
devices and also helps virtualisation and smart devices where large blocks of
data suddenely materialise and need storing.
So far so good. Lots of drivers reference tty->flip.*. Several of them also
call directly and unsafely into function pointers it provides. This will all
break. Most drivers can use tty_insert_flip_char which can be kept as an API
but others need more.
At the moment I've added the following interfaces, if people think more will
be needed now is a good time to say
int tty_buffer_request_room(tty, size)
Try and ensure at least size bytes are available, returns actual room (may be
zero). At the moment it just uses the flipbuf space but that will change.
Repeated calls without characters being added are not cumulative. (ie if you
call it with 1, 1, 1, and then 4 you'll have four characters of space. The
other functions will also try and grow buffers in future but this will be a
more efficient way when you know block sizes.
int tty_insert_flip_char(tty, ch, flag)
As before insert a character if there is room. Now returns 1 for success, 0
for failure.
int tty_insert_flip_string(tty, str, len)
Insert a block of non error characters. Returns the number inserted.
int tty_prepare_flip_string(tty, strptr, len)
Adjust the buffer to allow len characters to be added. Returns a buffer
pointer in strptr and the length available. This allows for hardware that
needs to use functions like insl or mencpy_fromio.
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-09 21:54:13 -07:00
|
|
|
count -= 2;
|
|
|
|
tty_insert_flip_string(tty, raw->inbuf, count);
|
2005-04-16 16:20:36 -06:00
|
|
|
tty_flip_buffer_push(raw->tty);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (req->type == RAW3215_WRITE) {
|
|
|
|
raw->count -= req->len;
|
|
|
|
raw->written -= req->len;
|
|
|
|
}
|
|
|
|
raw->flags &= ~RAW3215_WORKING;
|
|
|
|
raw3215_free_req(req);
|
|
|
|
/* check for empty wait */
|
|
|
|
if (waitqueue_active(&raw->empty_wait) &&
|
|
|
|
raw->queued_write == NULL &&
|
|
|
|
raw->queued_read == NULL) {
|
|
|
|
wake_up_interruptible(&raw->empty_wait);
|
|
|
|
}
|
2008-10-10 13:33:28 -06:00
|
|
|
raw3215_next_io(raw);
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Strange interrupt, I'll do my best to clean up */
|
|
|
|
if (req != NULL && req->type != RAW3215_FREE) {
|
|
|
|
if (req->type == RAW3215_WRITE) {
|
|
|
|
raw->count -= req->len;
|
|
|
|
raw->written -= req->len;
|
|
|
|
}
|
|
|
|
raw->flags &= ~RAW3215_WORKING;
|
|
|
|
raw3215_free_req(req);
|
|
|
|
}
|
2008-10-10 13:33:28 -06:00
|
|
|
raw3215_next_io(raw);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait until length bytes are available int the output buffer.
|
|
|
|
* Has to be called with the s390irq lock held. Can be called
|
|
|
|
* disabled.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
raw3215_make_room(struct raw3215_info *raw, unsigned int length)
|
|
|
|
{
|
|
|
|
while (RAW3215_BUFFER_SIZE - raw->count < length) {
|
|
|
|
/* there might be a request pending */
|
|
|
|
raw->flags |= RAW3215_FLUSHING;
|
|
|
|
raw3215_mk_write_req(raw);
|
|
|
|
raw3215_try_io(raw);
|
|
|
|
raw->flags &= ~RAW3215_FLUSHING;
|
|
|
|
#ifdef CONFIG_TN3215_CONSOLE
|
|
|
|
wait_cons_dev();
|
|
|
|
#endif
|
|
|
|
/* Enough room freed up ? */
|
|
|
|
if (RAW3215_BUFFER_SIZE - raw->count >= length)
|
|
|
|
break;
|
|
|
|
/* there might be another cpu waiting for the lock */
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_unlock(get_ccwdev_lock(raw->cdev));
|
2005-04-16 16:20:36 -06:00
|
|
|
udelay(100);
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_lock(get_ccwdev_lock(raw->cdev));
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* String write routine for 3215 devices
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
raw3215_write(struct raw3215_info *raw, const char *str, unsigned int length)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int c, count;
|
|
|
|
|
|
|
|
while (length > 0) {
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
count = (length > RAW3215_BUFFER_SIZE) ?
|
|
|
|
RAW3215_BUFFER_SIZE : length;
|
|
|
|
length -= count;
|
|
|
|
|
|
|
|
raw3215_make_room(raw, count);
|
|
|
|
|
|
|
|
/* copy string to output buffer and convert it to EBCDIC */
|
|
|
|
while (1) {
|
|
|
|
c = min_t(int, count,
|
|
|
|
min(RAW3215_BUFFER_SIZE - raw->count,
|
|
|
|
RAW3215_BUFFER_SIZE - raw->head));
|
|
|
|
if (c <= 0)
|
|
|
|
break;
|
|
|
|
memcpy(raw->buffer + raw->head, str, c);
|
|
|
|
ASCEBC(raw->buffer + raw->head, c);
|
|
|
|
raw->head = (raw->head + c) & (RAW3215_BUFFER_SIZE - 1);
|
|
|
|
raw->count += c;
|
|
|
|
raw->line_pos += c;
|
|
|
|
str += c;
|
|
|
|
count -= c;
|
|
|
|
}
|
|
|
|
if (!(raw->flags & RAW3215_WORKING)) {
|
|
|
|
raw3215_mk_write_req(raw);
|
|
|
|
/* start or queue request */
|
|
|
|
raw3215_try_io(raw);
|
|
|
|
}
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Put character routine for 3215 devices
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
raw3215_putchar(struct raw3215_info *raw, unsigned char ch)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned int length, i;
|
|
|
|
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (ch == '\t') {
|
|
|
|
length = TAB_STOP_SIZE - (raw->line_pos%TAB_STOP_SIZE);
|
|
|
|
raw->line_pos += length;
|
|
|
|
ch = ' ';
|
|
|
|
} else if (ch == '\n') {
|
|
|
|
length = 1;
|
|
|
|
raw->line_pos = 0;
|
|
|
|
} else {
|
|
|
|
length = 1;
|
|
|
|
raw->line_pos++;
|
|
|
|
}
|
|
|
|
raw3215_make_room(raw, length);
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
raw->buffer[raw->head] = (char) _ascebc[(int) ch];
|
|
|
|
raw->head = (raw->head + 1) & (RAW3215_BUFFER_SIZE - 1);
|
|
|
|
raw->count++;
|
|
|
|
}
|
|
|
|
if (!(raw->flags & RAW3215_WORKING)) {
|
|
|
|
raw3215_mk_write_req(raw);
|
|
|
|
/* start or queue request */
|
|
|
|
raw3215_try_io(raw);
|
|
|
|
}
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Flush routine, it simply sets the flush flag and tries to start
|
|
|
|
* pending IO.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
raw3215_flush_buffer(struct raw3215_info *raw)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (raw->count > 0) {
|
|
|
|
raw->flags |= RAW3215_FLUSHING;
|
|
|
|
raw3215_try_io(raw);
|
|
|
|
raw->flags &= ~RAW3215_FLUSHING;
|
|
|
|
}
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fire up a 3215 device.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
raw3215_startup(struct raw3215_info *raw)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (raw->flags & RAW3215_ACTIVE)
|
|
|
|
return 0;
|
|
|
|
raw->line_pos = 0;
|
|
|
|
raw->flags |= RAW3215_ACTIVE;
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
raw3215_try_io(raw);
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Shutdown a 3215 device.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
raw3215_shutdown(struct raw3215_info *raw)
|
|
|
|
{
|
|
|
|
DECLARE_WAITQUEUE(wait, current);
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (!(raw->flags & RAW3215_ACTIVE) || (raw->flags & RAW3215_FIXED))
|
|
|
|
return;
|
|
|
|
/* Wait for outstanding requests, then free irq */
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
if ((raw->flags & RAW3215_WORKING) ||
|
|
|
|
raw->queued_write != NULL ||
|
|
|
|
raw->queued_read != NULL) {
|
|
|
|
raw->flags |= RAW3215_CLOSING;
|
|
|
|
add_wait_queue(&raw->empty_wait, &wait);
|
|
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
schedule();
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
remove_wait_queue(&raw->empty_wait, &wait);
|
|
|
|
set_current_state(TASK_RUNNING);
|
|
|
|
raw->flags &= ~(RAW3215_ACTIVE | RAW3215_CLOSING);
|
|
|
|
}
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
raw3215_probe (struct ccw_device *cdev)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
int line;
|
|
|
|
|
2007-10-12 08:11:52 -06:00
|
|
|
/* Console is special. */
|
|
|
|
if (raw3215[0] && (cdev->dev.driver_data == raw3215[0]))
|
|
|
|
return 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
raw = kmalloc(sizeof(struct raw3215_info) +
|
|
|
|
RAW3215_INBUF_SIZE, GFP_KERNEL|GFP_DMA);
|
|
|
|
if (raw == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
spin_lock(&raw3215_device_lock);
|
|
|
|
for (line = 0; line < NR_3215; line++) {
|
|
|
|
if (!raw3215[line]) {
|
|
|
|
raw3215[line] = raw;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock(&raw3215_device_lock);
|
|
|
|
if (line == NR_3215) {
|
|
|
|
kfree(raw);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
raw->cdev = cdev;
|
|
|
|
raw->inbuf = (char *) raw + sizeof(struct raw3215_info);
|
|
|
|
memset(raw, 0, sizeof(struct raw3215_info));
|
2006-12-13 01:35:56 -07:00
|
|
|
raw->buffer = kmalloc(RAW3215_BUFFER_SIZE,
|
2005-04-16 16:20:36 -06:00
|
|
|
GFP_KERNEL|GFP_DMA);
|
|
|
|
if (raw->buffer == NULL) {
|
|
|
|
spin_lock(&raw3215_device_lock);
|
2006-07-12 08:41:55 -06:00
|
|
|
raw3215[line] = NULL;
|
2005-04-16 16:20:36 -06:00
|
|
|
spin_unlock(&raw3215_device_lock);
|
|
|
|
kfree(raw);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
init_waitqueue_head(&raw->empty_wait);
|
|
|
|
|
|
|
|
cdev->dev.driver_data = raw;
|
|
|
|
cdev->handler = raw3215_irq;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
raw3215_remove (struct ccw_device *cdev)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
|
|
|
|
ccw_device_set_offline(cdev);
|
|
|
|
raw = cdev->dev.driver_data;
|
|
|
|
if (raw) {
|
|
|
|
cdev->dev.driver_data = NULL;
|
2005-11-07 02:01:30 -07:00
|
|
|
kfree(raw->buffer);
|
2005-04-16 16:20:36 -06:00
|
|
|
kfree(raw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
raw3215_set_online (struct ccw_device *cdev)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
|
|
|
|
raw = cdev->dev.driver_data;
|
|
|
|
if (!raw)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
return raw3215_startup(raw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
raw3215_set_offline (struct ccw_device *cdev)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
|
|
|
|
raw = cdev->dev.driver_data;
|
|
|
|
if (!raw)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
raw3215_shutdown(raw);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ccw_device_id raw3215_id[] = {
|
|
|
|
{ CCW_DEVICE(0x3215, 0) },
|
|
|
|
{ /* end of list */ },
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ccw_driver raw3215_ccw_driver = {
|
|
|
|
.name = "3215",
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.ids = raw3215_id,
|
|
|
|
.probe = &raw3215_probe,
|
|
|
|
.remove = &raw3215_remove,
|
|
|
|
.set_online = &raw3215_set_online,
|
|
|
|
.set_offline = &raw3215_set_offline,
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_TN3215_CONSOLE
|
|
|
|
/*
|
|
|
|
* Write a string to the 3215 console
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
con3215_write(struct console *co, const char *str, unsigned int count)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (count <= 0)
|
|
|
|
return;
|
|
|
|
raw = raw3215[0]; /* console 3215 is the first one */
|
|
|
|
while (count > 0) {
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
if (str[i] == '\t' || str[i] == '\n')
|
|
|
|
break;
|
|
|
|
raw3215_write(raw, str, i);
|
|
|
|
count -= i;
|
|
|
|
str += i;
|
|
|
|
if (count > 0) {
|
|
|
|
raw3215_putchar(raw, *str);
|
|
|
|
count--;
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct tty_driver *con3215_device(struct console *c, int *index)
|
|
|
|
{
|
|
|
|
*index = c->index;
|
|
|
|
return tty3215_driver;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-10-10 13:33:27 -06:00
|
|
|
* panic() calls con3215_flush through a panic_notifier
|
|
|
|
* before the system enters a disabled, endless loop.
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
|
|
|
static void
|
2008-10-10 13:33:27 -06:00
|
|
|
con3215_flush(void)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
raw = raw3215[0]; /* console 3215 is the first one */
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
raw3215_make_room(raw, RAW3215_BUFFER_SIZE);
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2008-10-10 13:33:27 -06:00
|
|
|
static int con3215_notify(struct notifier_block *self,
|
|
|
|
unsigned long event, void *data)
|
|
|
|
{
|
|
|
|
con3215_flush();
|
|
|
|
return NOTIFY_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct notifier_block on_panic_nb = {
|
|
|
|
.notifier_call = con3215_notify,
|
|
|
|
.priority = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct notifier_block on_reboot_nb = {
|
|
|
|
.notifier_call = con3215_notify,
|
|
|
|
.priority = 0,
|
|
|
|
};
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* The console structure for the 3215 console
|
|
|
|
*/
|
|
|
|
static struct console con3215 = {
|
|
|
|
.name = "ttyS",
|
|
|
|
.write = con3215_write,
|
|
|
|
.device = con3215_device,
|
|
|
|
.flags = CON_PRINTBUFFER,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 3215 console initialization code called from console_init().
|
|
|
|
* NOTE: This is called before kmalloc is available.
|
|
|
|
*/
|
|
|
|
static int __init
|
|
|
|
con3215_init(void)
|
|
|
|
{
|
|
|
|
struct ccw_device *cdev;
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
struct raw3215_req *req;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Check if 3215 is to be the console */
|
|
|
|
if (!CONSOLE_IS_3215)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
/* Set the console mode for VM */
|
|
|
|
if (MACHINE_IS_VM) {
|
2005-06-25 15:55:32 -06:00
|
|
|
cpcmd("TERM CONMODE 3215", NULL, 0, NULL);
|
|
|
|
cpcmd("TERM AUTOCR OFF", NULL, 0, NULL);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate 3215 request structures */
|
|
|
|
raw3215_freelist = NULL;
|
|
|
|
spin_lock_init(&raw3215_freelist_lock);
|
|
|
|
for (i = 0; i < NR_3215_REQ; i++) {
|
|
|
|
req = (struct raw3215_req *) alloc_bootmem_low(sizeof(struct raw3215_req));
|
|
|
|
req->next = raw3215_freelist;
|
|
|
|
raw3215_freelist = req;
|
|
|
|
}
|
|
|
|
|
|
|
|
cdev = ccw_device_probe_console();
|
2006-02-01 04:06:35 -07:00
|
|
|
if (IS_ERR(cdev))
|
2005-04-16 16:20:36 -06:00
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
raw3215[0] = raw = (struct raw3215_info *)
|
|
|
|
alloc_bootmem_low(sizeof(struct raw3215_info));
|
|
|
|
memset(raw, 0, sizeof(struct raw3215_info));
|
|
|
|
raw->buffer = (char *) alloc_bootmem_low(RAW3215_BUFFER_SIZE);
|
|
|
|
raw->inbuf = (char *) alloc_bootmem_low(RAW3215_INBUF_SIZE);
|
|
|
|
raw->cdev = cdev;
|
|
|
|
cdev->dev.driver_data = raw;
|
|
|
|
cdev->handler = raw3215_irq;
|
|
|
|
|
|
|
|
raw->flags |= RAW3215_FIXED;
|
|
|
|
init_waitqueue_head(&raw->empty_wait);
|
|
|
|
|
|
|
|
/* Request the console irq */
|
|
|
|
if (raw3215_startup(raw) != 0) {
|
|
|
|
free_bootmem((unsigned long) raw->inbuf, RAW3215_INBUF_SIZE);
|
|
|
|
free_bootmem((unsigned long) raw->buffer, RAW3215_BUFFER_SIZE);
|
|
|
|
free_bootmem((unsigned long) raw, sizeof(struct raw3215_info));
|
|
|
|
raw3215[0] = NULL;
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2008-10-10 13:33:27 -06:00
|
|
|
atomic_notifier_chain_register(&panic_notifier_list, &on_panic_nb);
|
|
|
|
register_reboot_notifier(&on_reboot_nb);
|
2005-04-16 16:20:36 -06:00
|
|
|
register_console(&con3215);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
console_initcall(con3215_init);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* tty3215_open
|
|
|
|
*
|
|
|
|
* This routine is called whenever a 3215 tty is opened.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
tty3215_open(struct tty_struct *tty, struct file * filp)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
int retval, line;
|
|
|
|
|
|
|
|
line = tty->index;
|
|
|
|
if ((line < 0) || (line >= NR_3215))
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
raw = raw3215[line];
|
|
|
|
if (raw == NULL)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
tty->driver_data = raw;
|
|
|
|
raw->tty = tty;
|
|
|
|
|
|
|
|
tty->low_latency = 0; /* don't use bottom half for pushing chars */
|
|
|
|
/*
|
|
|
|
* Start up 3215 device
|
|
|
|
*/
|
|
|
|
retval = raw3215_startup(raw);
|
|
|
|
if (retval)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* tty3215_close()
|
|
|
|
*
|
|
|
|
* This routine is called when the 3215 tty is closed. We wait
|
|
|
|
* for the remaining request to be completed. Then we clean up.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
tty3215_close(struct tty_struct *tty, struct file * filp)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
|
|
|
|
raw = (struct raw3215_info *) tty->driver_data;
|
|
|
|
if (raw == NULL || tty->count > 1)
|
|
|
|
return;
|
|
|
|
tty->closing = 1;
|
|
|
|
/* Shutdown the terminal */
|
|
|
|
raw3215_shutdown(raw);
|
|
|
|
tty->closing = 0;
|
|
|
|
raw->tty = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns the amount of free space in the output buffer.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
tty3215_write_room(struct tty_struct *tty)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
|
|
|
|
raw = (struct raw3215_info *) tty->driver_data;
|
|
|
|
|
|
|
|
/* Subtract TAB_STOP_SIZE to allow for a tab, 8 <<< 64K */
|
|
|
|
if ((RAW3215_BUFFER_SIZE - raw->count - TAB_STOP_SIZE) >= 0)
|
|
|
|
return RAW3215_BUFFER_SIZE - raw->count - TAB_STOP_SIZE;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* String write routine for 3215 ttys
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
tty3215_write(struct tty_struct * tty,
|
|
|
|
const unsigned char *buf, int count)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
|
|
|
|
if (!tty)
|
|
|
|
return 0;
|
|
|
|
raw = (struct raw3215_info *) tty->driver_data;
|
|
|
|
raw3215_write(raw, buf, count);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Put character routine for 3215 ttys
|
|
|
|
*/
|
2008-04-30 01:54:00 -06:00
|
|
|
static int
|
2005-04-16 16:20:36 -06:00
|
|
|
tty3215_put_char(struct tty_struct *tty, unsigned char ch)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
|
|
|
|
if (!tty)
|
2008-04-30 01:54:00 -06:00
|
|
|
return 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
raw = (struct raw3215_info *) tty->driver_data;
|
|
|
|
raw3215_putchar(raw, ch);
|
2008-04-30 01:54:00 -06:00
|
|
|
return 1;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tty3215_flush_chars(struct tty_struct *tty)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns the number of characters in the output buffer
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
tty3215_chars_in_buffer(struct tty_struct *tty)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
|
|
|
|
raw = (struct raw3215_info *) tty->driver_data;
|
|
|
|
return raw->count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tty3215_flush_buffer(struct tty_struct *tty)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
|
|
|
|
raw = (struct raw3215_info *) tty->driver_data;
|
|
|
|
raw3215_flush_buffer(raw);
|
|
|
|
tty_wakeup(tty);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Currently we don't have any io controls for 3215 ttys
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
tty3215_ioctl(struct tty_struct *tty, struct file * file,
|
|
|
|
unsigned int cmd, unsigned long arg)
|
|
|
|
{
|
|
|
|
if (tty->flags & (1 << TTY_IO_ERROR))
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
default:
|
|
|
|
return -ENOIOCTLCMD;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable reading from a 3215 tty
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
tty3215_throttle(struct tty_struct * tty)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
|
|
|
|
raw = (struct raw3215_info *) tty->driver_data;
|
|
|
|
raw->flags |= RAW3215_THROTTLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable reading from a 3215 tty
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
tty3215_unthrottle(struct tty_struct * tty)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
raw = (struct raw3215_info *) tty->driver_data;
|
|
|
|
if (raw->flags & RAW3215_THROTTLED) {
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
raw->flags &= ~RAW3215_THROTTLED;
|
|
|
|
raw3215_try_io(raw);
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable writing to a 3215 tty
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
tty3215_stop(struct tty_struct *tty)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
|
|
|
|
raw = (struct raw3215_info *) tty->driver_data;
|
|
|
|
raw->flags |= RAW3215_STOPPED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable writing to a 3215 tty
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
tty3215_start(struct tty_struct *tty)
|
|
|
|
{
|
|
|
|
struct raw3215_info *raw;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
raw = (struct raw3215_info *) tty->driver_data;
|
|
|
|
if (raw->flags & RAW3215_STOPPED) {
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
raw->flags &= ~RAW3215_STOPPED;
|
|
|
|
raw3215_try_io(raw);
|
2006-12-04 07:40:07 -07:00
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-02 03:17:18 -06:00
|
|
|
static const struct tty_operations tty3215_ops = {
|
2005-04-16 16:20:36 -06:00
|
|
|
.open = tty3215_open,
|
|
|
|
.close = tty3215_close,
|
|
|
|
.write = tty3215_write,
|
|
|
|
.put_char = tty3215_put_char,
|
|
|
|
.flush_chars = tty3215_flush_chars,
|
|
|
|
.write_room = tty3215_write_room,
|
|
|
|
.chars_in_buffer = tty3215_chars_in_buffer,
|
|
|
|
.flush_buffer = tty3215_flush_buffer,
|
|
|
|
.ioctl = tty3215_ioctl,
|
|
|
|
.throttle = tty3215_throttle,
|
|
|
|
.unthrottle = tty3215_unthrottle,
|
|
|
|
.stop = tty3215_stop,
|
|
|
|
.start = tty3215_start,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 3215 tty registration code called from tty_init().
|
|
|
|
* Most kernel services (incl. kmalloc) are available at this poimt.
|
|
|
|
*/
|
2007-02-05 13:16:47 -07:00
|
|
|
static int __init
|
2005-04-16 16:20:36 -06:00
|
|
|
tty3215_init(void)
|
|
|
|
{
|
|
|
|
struct tty_driver *driver;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!CONSOLE_IS_3215)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
driver = alloc_tty_driver(NR_3215);
|
|
|
|
if (!driver)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
ret = ccw_driver_register(&raw3215_ccw_driver);
|
|
|
|
if (ret) {
|
|
|
|
put_tty_driver(driver);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Initialize the tty_driver structure
|
|
|
|
* Entries in tty3215_driver that are NOT initialized:
|
|
|
|
* proc_entry, set_termios, flush_buffer, set_ldisc, write_proc
|
|
|
|
*/
|
|
|
|
|
|
|
|
driver->owner = THIS_MODULE;
|
|
|
|
driver->driver_name = "tty3215";
|
|
|
|
driver->name = "ttyS";
|
|
|
|
driver->major = TTY_MAJOR;
|
|
|
|
driver->minor_start = 64;
|
|
|
|
driver->type = TTY_DRIVER_TYPE_SYSTEM;
|
|
|
|
driver->subtype = SYSTEM_TYPE_TTY;
|
|
|
|
driver->init_termios = tty_std_termios;
|
|
|
|
driver->init_termios.c_iflag = IGNBRK | IGNPAR;
|
|
|
|
driver->init_termios.c_oflag = ONLCR | XTABS;
|
|
|
|
driver->init_termios.c_lflag = ISIG;
|
|
|
|
driver->flags = TTY_DRIVER_REAL_RAW;
|
|
|
|
tty_set_operations(driver, &tty3215_ops);
|
|
|
|
ret = tty_register_driver(driver);
|
|
|
|
if (ret) {
|
|
|
|
put_tty_driver(driver);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
tty3215_driver = driver;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit
|
|
|
|
tty3215_exit(void)
|
|
|
|
{
|
|
|
|
tty_unregister_driver(tty3215_driver);
|
|
|
|
put_tty_driver(tty3215_driver);
|
|
|
|
ccw_driver_unregister(&raw3215_ccw_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(tty3215_init);
|
|
|
|
module_exit(tty3215_exit);
|