2 * drivers/s390/char/sclp_vt220.c
3 * SCLP VT220 terminal driver.
6 * Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Author(s): Peter Oberparleiter <Peter.Oberparleiter@de.ibm.com>
10 #include <linux/config.h>
11 #include <linux/module.h>
12 #include <linux/spinlock.h>
13 #include <linux/list.h>
14 #include <linux/wait.h>
15 #include <linux/timer.h>
16 #include <linux/kernel.h>
17 #include <linux/tty.h>
18 #include <linux/tty_driver.h>
19 #include <linux/sched.h>
20 #include <linux/errno.h>
22 #include <linux/major.h>
23 #include <linux/console.h>
24 #include <linux/kdev_t.h>
25 #include <linux/bootmem.h>
26 #include <linux/interrupt.h>
27 #include <linux/init.h>
28 #include <asm/uaccess.h>
31 #define SCLP_VT220_PRINT_HEADER "sclp vt220 tty driver: "
32 #define SCLP_VT220_MAJOR TTY_MAJOR
33 #define SCLP_VT220_MINOR 65
34 #define SCLP_VT220_DRIVER_NAME "sclp_vt220"
35 #define SCLP_VT220_DEVICE_NAME "ttysclp"
36 #define SCLP_VT220_CONSOLE_NAME "ttyS"
37 #define SCLP_VT220_CONSOLE_INDEX 1 /* console=ttyS1 */
38 #define SCLP_VT220_BUF_SIZE 80
40 /* Representation of a single write request */
41 struct sclp_vt220_request
{
42 struct list_head list
;
43 struct sclp_req sclp_req
;
45 struct timer_list retry_timer
;
49 struct sclp_vt220_sccb
{
50 struct sccb_header header
;
51 struct evbuf_header evbuf
;
54 #define SCLP_VT220_MAX_CHARS_PER_BUFFER (PAGE_SIZE - \
55 sizeof(struct sclp_vt220_request) - \
56 sizeof(struct sclp_vt220_sccb))
58 /* Structures and data needed to register tty driver */
59 static struct tty_driver
*sclp_vt220_driver
;
61 /* The tty_struct that the kernel associated with us */
62 static struct tty_struct
*sclp_vt220_tty
;
64 /* Lock to protect internal data from concurrent access */
65 static spinlock_t sclp_vt220_lock
;
67 /* List of empty pages to be used as write request buffers */
68 static struct list_head sclp_vt220_empty
;
70 /* List of pending requests */
71 static struct list_head sclp_vt220_outqueue
;
73 /* Number of requests in outqueue */
74 static int sclp_vt220_outqueue_count
;
76 /* Wait queue used to delay write requests while we've run out of buffers */
77 static wait_queue_head_t sclp_vt220_waitq
;
79 /* Timer used for delaying write requests to merge subsequent messages into
81 static struct timer_list sclp_vt220_timer
;
83 /* Pointer to current request buffer which has been partially filled but not
85 static struct sclp_vt220_request
*sclp_vt220_current_request
;
87 /* Number of characters in current request buffer */
88 static int sclp_vt220_buffered_chars
;
90 /* Flag indicating whether this driver has already been initialized */
91 static int sclp_vt220_initialized
= 0;
93 /* Flag indicating that sclp_vt220_current_request should really
94 * have been already queued but wasn't because the SCLP was processing
96 static int sclp_vt220_flush_later
;
98 static void sclp_vt220_receiver_fn(struct evbuf_header
*evbuf
);
99 static void __sclp_vt220_emit(struct sclp_vt220_request
*request
);
100 static void sclp_vt220_emit_current(void);
102 /* Registration structure for our interest in SCLP event buffers */
103 static struct sclp_register sclp_vt220_register
= {
104 .send_mask
= EvTyp_VT220Msg_Mask
,
105 .receive_mask
= EvTyp_VT220Msg_Mask
,
106 .state_change_fn
= NULL
,
107 .receiver_fn
= sclp_vt220_receiver_fn
112 * Put provided request buffer back into queue and check emit pending
113 * buffers if necessary.
116 sclp_vt220_process_queue(struct sclp_vt220_request
*request
)
119 struct sclp_vt220_request
*next
;
122 /* Put buffer back to list of empty buffers */
123 page
= request
->sclp_req
.sccb
;
124 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
125 /* Move request from outqueue to empty queue */
126 list_del(&request
->list
);
127 sclp_vt220_outqueue_count
--;
128 list_add_tail((struct list_head
*) page
, &sclp_vt220_empty
);
129 /* Check if there is a pending buffer on the out queue. */
131 if (!list_empty(&sclp_vt220_outqueue
))
132 next
= list_entry(sclp_vt220_outqueue
.next
,
133 struct sclp_vt220_request
, list
);
134 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
136 __sclp_vt220_emit(next
);
137 else if (sclp_vt220_flush_later
)
138 sclp_vt220_emit_current();
139 wake_up(&sclp_vt220_waitq
);
140 /* Check if the tty needs a wake up call */
141 if (sclp_vt220_tty
!= NULL
) {
142 tty_wakeup(sclp_vt220_tty
);
147 * Retry sclp write request after waiting some time for an sclp equipment
151 sclp_vt220_retry(unsigned long data
)
153 struct sclp_vt220_request
*request
;
154 struct sclp_vt220_sccb
*sccb
;
156 request
= (struct sclp_vt220_request
*) data
;
157 request
->sclp_req
.status
= SCLP_REQ_FILLED
;
158 sccb
= (struct sclp_vt220_sccb
*) request
->sclp_req
.sccb
;
159 sccb
->header
.response_code
= 0x0000;
160 sclp_add_request(&request
->sclp_req
);
163 #define SCLP_BUFFER_MAX_RETRY 5
164 #define SCLP_BUFFER_RETRY_INTERVAL 2
167 * Callback through which the result of a write request is reported by the
171 sclp_vt220_callback(struct sclp_req
*request
, void *data
)
173 struct sclp_vt220_request
*vt220_request
;
174 struct sclp_vt220_sccb
*sccb
;
176 vt220_request
= (struct sclp_vt220_request
*) data
;
177 if (request
->status
== SCLP_REQ_FAILED
) {
178 sclp_vt220_process_queue(vt220_request
);
181 sccb
= (struct sclp_vt220_sccb
*) vt220_request
->sclp_req
.sccb
;
183 /* Check SCLP response code and choose suitable action */
184 switch (sccb
->header
.response_code
) {
188 case 0x05f0: /* Target resource in improper state */
191 case 0x0340: /* Contained SCLP equipment check */
192 if (vt220_request
->retry_count
++ > SCLP_BUFFER_MAX_RETRY
)
194 /* Remove processed buffers and requeue rest */
195 if (sclp_remove_processed((struct sccb_header
*) sccb
) > 0) {
196 /* Not all buffers were processed */
197 sccb
->header
.response_code
= 0x0000;
198 vt220_request
->sclp_req
.status
= SCLP_REQ_FILLED
;
199 sclp_add_request(request
);
204 case 0x0040: /* SCLP equipment check */
205 if (vt220_request
->retry_count
++ > SCLP_BUFFER_MAX_RETRY
)
207 /* Wait some time, then retry request */
208 vt220_request
->retry_timer
.function
= sclp_vt220_retry
;
209 vt220_request
->retry_timer
.data
=
210 (unsigned long) vt220_request
;
211 vt220_request
->retry_timer
.expires
=
212 jiffies
+ SCLP_BUFFER_RETRY_INTERVAL
*HZ
;
213 add_timer(&vt220_request
->retry_timer
);
219 sclp_vt220_process_queue(vt220_request
);
223 * Emit vt220 request buffer to SCLP.
226 __sclp_vt220_emit(struct sclp_vt220_request
*request
)
228 if (!(sclp_vt220_register
.sclp_send_mask
& EvTyp_VT220Msg_Mask
)) {
229 request
->sclp_req
.status
= SCLP_REQ_FAILED
;
230 sclp_vt220_callback(&request
->sclp_req
, (void *) request
);
233 request
->sclp_req
.command
= SCLP_CMDW_WRITEDATA
;
234 request
->sclp_req
.status
= SCLP_REQ_FILLED
;
235 request
->sclp_req
.callback
= sclp_vt220_callback
;
236 request
->sclp_req
.callback_data
= (void *) request
;
238 sclp_add_request(&request
->sclp_req
);
242 * Queue and emit given request.
245 sclp_vt220_emit(struct sclp_vt220_request
*request
)
250 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
251 list_add_tail(&request
->list
, &sclp_vt220_outqueue
);
252 count
= sclp_vt220_outqueue_count
++;
253 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
254 /* Emit only the first buffer immediately - callback takes care of
257 __sclp_vt220_emit(request
);
261 * Queue and emit current request.
264 sclp_vt220_emit_current(void)
267 struct sclp_vt220_request
*request
;
268 struct sclp_vt220_sccb
*sccb
;
270 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
272 if (sclp_vt220_current_request
!= NULL
) {
273 sccb
= (struct sclp_vt220_sccb
*)
274 sclp_vt220_current_request
->sclp_req
.sccb
;
275 /* Only emit buffers with content */
276 if (sccb
->header
.length
!= sizeof(struct sclp_vt220_sccb
)) {
277 request
= sclp_vt220_current_request
;
278 sclp_vt220_current_request
= NULL
;
279 if (timer_pending(&sclp_vt220_timer
))
280 del_timer(&sclp_vt220_timer
);
282 sclp_vt220_flush_later
= 0;
284 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
286 sclp_vt220_emit(request
);
289 #define SCLP_NORMAL_WRITE 0x00
292 * Helper function to initialize a page with the sclp request structure.
294 static struct sclp_vt220_request
*
295 sclp_vt220_initialize_page(void *page
)
297 struct sclp_vt220_request
*request
;
298 struct sclp_vt220_sccb
*sccb
;
300 /* Place request structure at end of page */
301 request
= ((struct sclp_vt220_request
*)
302 ((addr_t
) page
+ PAGE_SIZE
)) - 1;
303 init_timer(&request
->retry_timer
);
304 request
->retry_count
= 0;
305 request
->sclp_req
.sccb
= page
;
306 /* SCCB goes at start of page */
307 sccb
= (struct sclp_vt220_sccb
*) page
;
308 memset((void *) sccb
, 0, sizeof(struct sclp_vt220_sccb
));
309 sccb
->header
.length
= sizeof(struct sclp_vt220_sccb
);
310 sccb
->header
.function_code
= SCLP_NORMAL_WRITE
;
311 sccb
->header
.response_code
= 0x0000;
312 sccb
->evbuf
.type
= EvTyp_VT220Msg
;
313 sccb
->evbuf
.length
= sizeof(struct evbuf_header
);
318 static inline unsigned int
319 sclp_vt220_space_left(struct sclp_vt220_request
*request
)
321 struct sclp_vt220_sccb
*sccb
;
322 sccb
= (struct sclp_vt220_sccb
*) request
->sclp_req
.sccb
;
323 return PAGE_SIZE
- sizeof(struct sclp_vt220_request
) -
327 static inline unsigned int
328 sclp_vt220_chars_stored(struct sclp_vt220_request
*request
)
330 struct sclp_vt220_sccb
*sccb
;
331 sccb
= (struct sclp_vt220_sccb
*) request
->sclp_req
.sccb
;
332 return sccb
->evbuf
.length
- sizeof(struct evbuf_header
);
336 * Add msg to buffer associated with request. Return the number of characters
340 sclp_vt220_add_msg(struct sclp_vt220_request
*request
,
341 const unsigned char *msg
, int count
, int convertlf
)
343 struct sclp_vt220_sccb
*sccb
;
349 if (count
> sclp_vt220_space_left(request
))
350 count
= sclp_vt220_space_left(request
);
354 sccb
= (struct sclp_vt220_sccb
*) request
->sclp_req
.sccb
;
355 buffer
= (void *) ((addr_t
) sccb
+ sccb
->header
.length
);
358 /* Perform Linefeed conversion (0x0a -> 0x0a 0x0d)*/
360 (from
< count
) && (to
< sclp_vt220_space_left(request
));
362 /* Retrieve character */
364 /* Perform conversion */
366 if (to
+ 1 < sclp_vt220_space_left(request
)) {
367 ((unsigned char *) buffer
)[to
++] = c
;
368 ((unsigned char *) buffer
)[to
++] = 0x0d;
373 ((unsigned char *) buffer
)[to
++] = c
;
375 sccb
->header
.length
+= to
;
376 sccb
->evbuf
.length
+= to
;
379 memcpy(buffer
, (const void *) msg
, count
);
380 sccb
->header
.length
+= count
;
381 sccb
->evbuf
.length
+= count
;
387 * Emit buffer after having waited long enough for more data to arrive.
390 sclp_vt220_timeout(unsigned long data
)
392 sclp_vt220_emit_current();
395 #define BUFFER_MAX_DELAY HZ/2
398 * Internal implementation of the write function. Write COUNT bytes of data
400 * to the SCLP interface. In case that the data does not fit into the current
401 * write buffer, emit the current one and allocate a new one. If there are no
402 * more empty buffers available, wait until one gets emptied. If DO_SCHEDULE
403 * is non-zero, the buffer will be scheduled for emitting after a timeout -
404 * otherwise the user has to explicitly call the flush function.
405 * A non-zero CONVERTLF parameter indicates that 0x0a characters in the message
406 * buffer should be converted to 0x0a 0x0d. After completion, return the number
410 __sclp_vt220_write(const unsigned char *buf
, int count
, int do_schedule
,
421 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
423 /* Create a sclp output buffer if none exists yet */
424 if (sclp_vt220_current_request
== NULL
) {
425 while (list_empty(&sclp_vt220_empty
)) {
426 spin_unlock_irqrestore(&sclp_vt220_lock
,
431 wait_event(sclp_vt220_waitq
,
432 !list_empty(&sclp_vt220_empty
));
433 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
435 page
= (void *) sclp_vt220_empty
.next
;
436 list_del((struct list_head
*) page
);
437 sclp_vt220_current_request
=
438 sclp_vt220_initialize_page(page
);
440 /* Try to write the string to the current request buffer */
441 written
= sclp_vt220_add_msg(sclp_vt220_current_request
,
442 buf
, count
, convertlf
);
443 overall_written
+= written
;
444 if (written
== count
)
447 * Not all characters could be written to the current
448 * output buffer. Emit the buffer, create a new buffer
449 * and then output the rest of the string.
451 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
452 sclp_vt220_emit_current();
453 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
457 /* Setup timer to output current console buffer after some time */
458 if (sclp_vt220_current_request
!= NULL
&&
459 !timer_pending(&sclp_vt220_timer
) && do_schedule
) {
460 sclp_vt220_timer
.function
= sclp_vt220_timeout
;
461 sclp_vt220_timer
.data
= 0UL;
462 sclp_vt220_timer
.expires
= jiffies
+ BUFFER_MAX_DELAY
;
463 add_timer(&sclp_vt220_timer
);
465 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
466 return overall_written
;
470 * This routine is called by the kernel to write a series of
471 * characters to the tty device. The characters may come from
472 * user space or kernel space. This routine will return the
473 * number of characters actually accepted for writing.
476 sclp_vt220_write(struct tty_struct
*tty
, int from_user
,
477 const unsigned char *buf
, int count
)
483 return __sclp_vt220_write(buf
, count
, 1, 0);
484 /* Use intermediate buffer to prevent calling copy_from_user() while
488 length
= count
< SCLP_VT220_BUF_SIZE
?
489 count
: SCLP_VT220_BUF_SIZE
;
490 length
-= copy_from_user(tty
->driver_data
,
491 (const unsigned char __user
*)buf
, length
);
497 length
= __sclp_vt220_write(tty
->driver_data
, length
, 1, 0);
505 #define SCLP_VT220_SESSION_ENDED 0x01
506 #define SCLP_VT220_SESSION_STARTED 0x80
507 #define SCLP_VT220_SESSION_DATA 0x00
510 * Called by the SCLP to report incoming event buffers.
513 sclp_vt220_receiver_fn(struct evbuf_header
*evbuf
)
518 /* Ignore input if device is not open */
519 if (sclp_vt220_tty
== NULL
)
522 buffer
= (char *) ((addr_t
) evbuf
+ sizeof(struct evbuf_header
));
523 count
= evbuf
->length
- sizeof(struct evbuf_header
);
526 case SCLP_VT220_SESSION_ENDED
:
527 case SCLP_VT220_SESSION_STARTED
:
529 case SCLP_VT220_SESSION_DATA
:
530 /* Send input to line discipline */
533 /* Prevent buffer overrun by discarding input. Note that
534 * because buffer_push works asynchronously, we cannot wait
535 * for the buffer to be emptied. */
536 if (count
+ sclp_vt220_tty
->flip
.count
> TTY_FLIPBUF_SIZE
)
537 count
= TTY_FLIPBUF_SIZE
- sclp_vt220_tty
->flip
.count
;
538 memcpy(sclp_vt220_tty
->flip
.char_buf_ptr
, buffer
, count
);
539 memset(sclp_vt220_tty
->flip
.flag_buf_ptr
, TTY_NORMAL
, count
);
540 sclp_vt220_tty
->flip
.char_buf_ptr
+= count
;
541 sclp_vt220_tty
->flip
.flag_buf_ptr
+= count
;
542 sclp_vt220_tty
->flip
.count
+= count
;
543 tty_flip_buffer_push(sclp_vt220_tty
);
549 * This routine is called when a particular tty device is opened.
552 sclp_vt220_open(struct tty_struct
*tty
, struct file
*filp
)
554 if (tty
->count
== 1) {
555 sclp_vt220_tty
= tty
;
556 tty
->driver_data
= kmalloc(SCLP_VT220_BUF_SIZE
, GFP_KERNEL
);
557 if (tty
->driver_data
== NULL
)
559 tty
->low_latency
= 0;
565 * This routine is called when a particular tty device is closed.
568 sclp_vt220_close(struct tty_struct
*tty
, struct file
*filp
)
570 if (tty
->count
== 1) {
571 sclp_vt220_tty
= NULL
;
572 kfree(tty
->driver_data
);
573 tty
->driver_data
= NULL
;
578 * This routine is called by the kernel to write a single
579 * character to the tty device. If the kernel uses this routine,
580 * it must call the flush_chars() routine (if defined) when it is
581 * done stuffing characters into the driver.
583 * NOTE: include/linux/tty_driver.h specifies that a character should be
584 * ignored if there is no room in the queue. This driver implements a different
585 * semantic in that it will block when there is no more room left.
588 sclp_vt220_put_char(struct tty_struct
*tty
, unsigned char ch
)
590 __sclp_vt220_write(&ch
, 1, 0, 0);
594 * This routine is called by the kernel after it has written a
595 * series of characters to the tty device using put_char().
598 sclp_vt220_flush_chars(struct tty_struct
*tty
)
600 if (sclp_vt220_outqueue_count
== 0)
601 sclp_vt220_emit_current();
603 sclp_vt220_flush_later
= 1;
607 * This routine returns the numbers of characters the tty driver
608 * will accept for queuing to be written. This number is subject
609 * to change as output buffers get emptied, or if the output flow
613 sclp_vt220_write_room(struct tty_struct
*tty
)
619 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
621 if (sclp_vt220_current_request
!= NULL
)
622 count
= sclp_vt220_space_left(sclp_vt220_current_request
);
623 list_for_each(l
, &sclp_vt220_empty
)
624 count
+= SCLP_VT220_MAX_CHARS_PER_BUFFER
;
625 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
630 * Return number of buffered chars.
633 sclp_vt220_chars_in_buffer(struct tty_struct
*tty
)
637 struct sclp_vt220_request
*r
;
640 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
642 if (sclp_vt220_current_request
!= NULL
)
643 count
= sclp_vt220_chars_stored(sclp_vt220_current_request
);
644 list_for_each(l
, &sclp_vt220_outqueue
) {
645 r
= list_entry(l
, struct sclp_vt220_request
, list
);
646 count
+= sclp_vt220_chars_stored(r
);
648 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
653 __sclp_vt220_flush_buffer(void)
657 sclp_vt220_emit_current();
658 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
659 if (timer_pending(&sclp_vt220_timer
))
660 del_timer(&sclp_vt220_timer
);
661 while (sclp_vt220_outqueue_count
> 0) {
662 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
664 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
666 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
670 * Pass on all buffers to the hardware. Return only when there are no more
674 sclp_vt220_flush_buffer(struct tty_struct
*tty
)
676 sclp_vt220_emit_current();
680 * Initialize all relevant components and register driver with system.
683 __sclp_vt220_init(int early
)
688 if (sclp_vt220_initialized
)
690 sclp_vt220_initialized
= 1;
691 spin_lock_init(&sclp_vt220_lock
);
692 INIT_LIST_HEAD(&sclp_vt220_empty
);
693 INIT_LIST_HEAD(&sclp_vt220_outqueue
);
694 init_waitqueue_head(&sclp_vt220_waitq
);
695 init_timer(&sclp_vt220_timer
);
696 sclp_vt220_current_request
= NULL
;
697 sclp_vt220_buffered_chars
= 0;
698 sclp_vt220_outqueue_count
= 0;
699 sclp_vt220_tty
= NULL
;
700 sclp_vt220_flush_later
= 0;
702 /* Allocate pages for output buffering */
703 for (i
= 0; i
< (early
? MAX_CONSOLE_PAGES
: MAX_KMEM_PAGES
); i
++) {
705 page
= alloc_bootmem_low_pages(PAGE_SIZE
);
707 page
= (void *) get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
710 list_add_tail((struct list_head
*) page
, &sclp_vt220_empty
);
715 static struct tty_operations sclp_vt220_ops
= {
716 .open
= sclp_vt220_open
,
717 .close
= sclp_vt220_close
,
718 .write
= sclp_vt220_write
,
719 .put_char
= sclp_vt220_put_char
,
720 .flush_chars
= sclp_vt220_flush_chars
,
721 .write_room
= sclp_vt220_write_room
,
722 .chars_in_buffer
= sclp_vt220_chars_in_buffer
,
723 .flush_buffer
= sclp_vt220_flush_buffer
727 * Register driver with SCLP and Linux and initialize internal tty structures.
730 sclp_vt220_tty_init(void)
732 struct tty_driver
*driver
;
735 /* Note: we're not testing for CONSOLE_IS_SCLP here to preserve
736 * symmetry between VM and LPAR systems regarding ttyS1. */
737 driver
= alloc_tty_driver(1);
740 rc
= __sclp_vt220_init(0);
742 put_tty_driver(driver
);
745 rc
= sclp_register(&sclp_vt220_register
);
747 printk(KERN_ERR SCLP_VT220_PRINT_HEADER
748 "could not register tty - "
749 "sclp_register returned %d\n", rc
);
750 put_tty_driver(driver
);
754 driver
->owner
= THIS_MODULE
;
755 driver
->driver_name
= SCLP_VT220_DRIVER_NAME
;
756 driver
->name
= SCLP_VT220_DEVICE_NAME
;
757 driver
->major
= SCLP_VT220_MAJOR
;
758 driver
->minor_start
= SCLP_VT220_MINOR
;
759 driver
->type
= TTY_DRIVER_TYPE_SYSTEM
;
760 driver
->subtype
= SYSTEM_TYPE_TTY
;
761 driver
->init_termios
= tty_std_termios
;
762 driver
->flags
= TTY_DRIVER_REAL_RAW
;
763 tty_set_operations(driver
, &sclp_vt220_ops
);
765 rc
= tty_register_driver(driver
);
767 printk(KERN_ERR SCLP_VT220_PRINT_HEADER
768 "could not register tty - "
769 "tty_register_driver returned %d\n", rc
);
770 put_tty_driver(driver
);
773 sclp_vt220_driver
= driver
;
777 module_init(sclp_vt220_tty_init
);
779 #ifdef CONFIG_SCLP_VT220_CONSOLE
782 sclp_vt220_con_write(struct console
*con
, const char *buf
, unsigned int count
)
784 __sclp_vt220_write((const unsigned char *) buf
, count
, 1, 1);
787 static struct tty_driver
*
788 sclp_vt220_con_device(struct console
*c
, int *index
)
791 return sclp_vt220_driver
;
795 * This routine is called from panic when the kernel is going to give up.
796 * We have to make sure that all buffers will be flushed to the SCLP.
797 * Note that this function may be called from within an interrupt context.
800 sclp_vt220_con_unblank(void)
802 __sclp_vt220_flush_buffer();
805 /* Structure needed to register with printk */
806 static struct console sclp_vt220_console
=
808 .name
= SCLP_VT220_CONSOLE_NAME
,
809 .write
= sclp_vt220_con_write
,
810 .device
= sclp_vt220_con_device
,
811 .unblank
= sclp_vt220_con_unblank
,
812 .flags
= CON_PRINTBUFFER
,
813 .index
= SCLP_VT220_CONSOLE_INDEX
817 sclp_vt220_con_init(void)
821 if (!CONSOLE_IS_SCLP
)
823 rc
= __sclp_vt220_init(1);
826 /* Attach linux console */
827 register_console(&sclp_vt220_console
);
831 console_initcall(sclp_vt220_con_init
);
832 #endif /* CONFIG_SCLP_VT220_CONSOLE */