2 * SCLP VT220 terminal driver.
4 * Copyright IBM Corp. 2003, 2009
6 * Author(s): Peter Oberparleiter <Peter.Oberparleiter@de.ibm.com>
9 #include <linux/module.h>
10 #include <linux/spinlock.h>
11 #include <linux/list.h>
12 #include <linux/wait.h>
13 #include <linux/timer.h>
14 #include <linux/kernel.h>
15 #include <linux/tty.h>
16 #include <linux/tty_driver.h>
17 #include <linux/tty_flip.h>
18 #include <linux/errno.h>
20 #include <linux/major.h>
21 #include <linux/console.h>
22 #include <linux/kdev_t.h>
23 #include <linux/interrupt.h>
24 #include <linux/init.h>
25 #include <linux/reboot.h>
26 #include <linux/slab.h>
28 #include <asm/uaccess.h>
31 #define SCLP_VT220_MAJOR TTY_MAJOR
32 #define SCLP_VT220_MINOR 65
33 #define SCLP_VT220_DRIVER_NAME "sclp_vt220"
34 #define SCLP_VT220_DEVICE_NAME "ttysclp"
35 #define SCLP_VT220_CONSOLE_NAME "ttyS"
36 #define SCLP_VT220_CONSOLE_INDEX 1 /* console=ttyS1 */
38 /* Representation of a single write request */
39 struct sclp_vt220_request
{
40 struct list_head list
;
41 struct sclp_req sclp_req
;
46 struct sclp_vt220_sccb
{
47 struct sccb_header header
;
48 struct evbuf_header evbuf
;
51 #define SCLP_VT220_MAX_CHARS_PER_BUFFER (PAGE_SIZE - \
52 sizeof(struct sclp_vt220_request) - \
53 sizeof(struct sclp_vt220_sccb))
55 /* Structures and data needed to register tty driver */
56 static struct tty_driver
*sclp_vt220_driver
;
58 static struct tty_port sclp_vt220_port
;
60 /* Lock to protect internal data from concurrent access */
61 static spinlock_t sclp_vt220_lock
;
63 /* List of empty pages to be used as write request buffers */
64 static struct list_head sclp_vt220_empty
;
66 /* List of pending requests */
67 static struct list_head sclp_vt220_outqueue
;
69 /* Suspend mode flag */
70 static int sclp_vt220_suspended
;
72 /* Flag that output queue is currently running */
73 static int sclp_vt220_queue_running
;
75 /* Timer used for delaying write requests to merge subsequent messages into
77 static struct timer_list sclp_vt220_timer
;
79 /* Pointer to current request buffer which has been partially filled but not
81 static struct sclp_vt220_request
*sclp_vt220_current_request
;
83 /* Number of characters in current request buffer */
84 static int sclp_vt220_buffered_chars
;
86 /* Counter controlling core driver initialization. */
87 static int __initdata sclp_vt220_init_count
;
89 /* Flag indicating that sclp_vt220_current_request should really
90 * have been already queued but wasn't because the SCLP was processing
92 static int sclp_vt220_flush_later
;
94 static void sclp_vt220_receiver_fn(struct evbuf_header
*evbuf
);
95 static void sclp_vt220_pm_event_fn(struct sclp_register
*reg
,
96 enum sclp_pm_event sclp_pm_event
);
97 static int __sclp_vt220_emit(struct sclp_vt220_request
*request
);
98 static void sclp_vt220_emit_current(void);
100 /* Registration structure for SCLP output event buffers */
101 static struct sclp_register sclp_vt220_register
= {
102 .send_mask
= EVTYP_VT220MSG_MASK
,
103 .pm_event_fn
= sclp_vt220_pm_event_fn
,
106 /* Registration structure for SCLP input event buffers */
107 static struct sclp_register sclp_vt220_register_input
= {
108 .receive_mask
= EVTYP_VT220MSG_MASK
,
109 .receiver_fn
= sclp_vt220_receiver_fn
,
114 * Put provided request buffer back into queue and check emit pending
115 * buffers if necessary.
118 sclp_vt220_process_queue(struct sclp_vt220_request
*request
)
124 /* Put buffer back to list of empty buffers */
125 page
= request
->sclp_req
.sccb
;
126 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
127 /* Move request from outqueue to empty queue */
128 list_del(&request
->list
);
129 list_add_tail((struct list_head
*) page
, &sclp_vt220_empty
);
130 /* Check if there is a pending buffer on the out queue. */
132 if (!list_empty(&sclp_vt220_outqueue
))
133 request
= list_entry(sclp_vt220_outqueue
.next
,
134 struct sclp_vt220_request
, list
);
135 if (!request
|| sclp_vt220_suspended
) {
136 sclp_vt220_queue_running
= 0;
137 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
140 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
141 } while (__sclp_vt220_emit(request
));
142 if (request
== NULL
&& sclp_vt220_flush_later
)
143 sclp_vt220_emit_current();
144 tty_port_tty_wakeup(&sclp_vt220_port
);
147 #define SCLP_BUFFER_MAX_RETRY 1
150 * Callback through which the result of a write request is reported by the
154 sclp_vt220_callback(struct sclp_req
*request
, void *data
)
156 struct sclp_vt220_request
*vt220_request
;
157 struct sclp_vt220_sccb
*sccb
;
159 vt220_request
= (struct sclp_vt220_request
*) data
;
160 if (request
->status
== SCLP_REQ_FAILED
) {
161 sclp_vt220_process_queue(vt220_request
);
164 sccb
= (struct sclp_vt220_sccb
*) vt220_request
->sclp_req
.sccb
;
166 /* Check SCLP response code and choose suitable action */
167 switch (sccb
->header
.response_code
) {
171 case 0x05f0: /* Target resource in improper state */
174 case 0x0340: /* Contained SCLP equipment check */
175 if (++vt220_request
->retry_count
> SCLP_BUFFER_MAX_RETRY
)
177 /* Remove processed buffers and requeue rest */
178 if (sclp_remove_processed((struct sccb_header
*) sccb
) > 0) {
179 /* Not all buffers were processed */
180 sccb
->header
.response_code
= 0x0000;
181 vt220_request
->sclp_req
.status
= SCLP_REQ_FILLED
;
182 if (sclp_add_request(request
) == 0)
187 case 0x0040: /* SCLP equipment check */
188 if (++vt220_request
->retry_count
> SCLP_BUFFER_MAX_RETRY
)
190 sccb
->header
.response_code
= 0x0000;
191 vt220_request
->sclp_req
.status
= SCLP_REQ_FILLED
;
192 if (sclp_add_request(request
) == 0)
199 sclp_vt220_process_queue(vt220_request
);
203 * Emit vt220 request buffer to SCLP. Return zero on success, non-zero
207 __sclp_vt220_emit(struct sclp_vt220_request
*request
)
209 request
->sclp_req
.command
= SCLP_CMDW_WRITE_EVENT_DATA
;
210 request
->sclp_req
.status
= SCLP_REQ_FILLED
;
211 request
->sclp_req
.callback
= sclp_vt220_callback
;
212 request
->sclp_req
.callback_data
= (void *) request
;
214 return sclp_add_request(&request
->sclp_req
);
218 * Queue and emit current request.
221 sclp_vt220_emit_current(void)
224 struct sclp_vt220_request
*request
;
225 struct sclp_vt220_sccb
*sccb
;
227 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
228 if (sclp_vt220_current_request
) {
229 sccb
= (struct sclp_vt220_sccb
*)
230 sclp_vt220_current_request
->sclp_req
.sccb
;
231 /* Only emit buffers with content */
232 if (sccb
->header
.length
!= sizeof(struct sclp_vt220_sccb
)) {
233 list_add_tail(&sclp_vt220_current_request
->list
,
234 &sclp_vt220_outqueue
);
235 sclp_vt220_current_request
= NULL
;
236 if (timer_pending(&sclp_vt220_timer
))
237 del_timer(&sclp_vt220_timer
);
239 sclp_vt220_flush_later
= 0;
241 if (sclp_vt220_queue_running
|| sclp_vt220_suspended
)
243 if (list_empty(&sclp_vt220_outqueue
))
245 request
= list_first_entry(&sclp_vt220_outqueue
,
246 struct sclp_vt220_request
, list
);
247 sclp_vt220_queue_running
= 1;
248 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
250 if (__sclp_vt220_emit(request
))
251 sclp_vt220_process_queue(request
);
254 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
257 #define SCLP_NORMAL_WRITE 0x00
260 * Helper function to initialize a page with the sclp request structure.
262 static struct sclp_vt220_request
*
263 sclp_vt220_initialize_page(void *page
)
265 struct sclp_vt220_request
*request
;
266 struct sclp_vt220_sccb
*sccb
;
268 /* Place request structure at end of page */
269 request
= ((struct sclp_vt220_request
*)
270 ((addr_t
) page
+ PAGE_SIZE
)) - 1;
271 request
->retry_count
= 0;
272 request
->sclp_req
.sccb
= page
;
273 /* SCCB goes at start of page */
274 sccb
= (struct sclp_vt220_sccb
*) page
;
275 memset((void *) sccb
, 0, sizeof(struct sclp_vt220_sccb
));
276 sccb
->header
.length
= sizeof(struct sclp_vt220_sccb
);
277 sccb
->header
.function_code
= SCLP_NORMAL_WRITE
;
278 sccb
->header
.response_code
= 0x0000;
279 sccb
->evbuf
.type
= EVTYP_VT220MSG
;
280 sccb
->evbuf
.length
= sizeof(struct evbuf_header
);
285 static inline unsigned int
286 sclp_vt220_space_left(struct sclp_vt220_request
*request
)
288 struct sclp_vt220_sccb
*sccb
;
289 sccb
= (struct sclp_vt220_sccb
*) request
->sclp_req
.sccb
;
290 return PAGE_SIZE
- sizeof(struct sclp_vt220_request
) -
294 static inline unsigned int
295 sclp_vt220_chars_stored(struct sclp_vt220_request
*request
)
297 struct sclp_vt220_sccb
*sccb
;
298 sccb
= (struct sclp_vt220_sccb
*) request
->sclp_req
.sccb
;
299 return sccb
->evbuf
.length
- sizeof(struct evbuf_header
);
303 * Add msg to buffer associated with request. Return the number of characters
307 sclp_vt220_add_msg(struct sclp_vt220_request
*request
,
308 const unsigned char *msg
, int count
, int convertlf
)
310 struct sclp_vt220_sccb
*sccb
;
316 if (count
> sclp_vt220_space_left(request
))
317 count
= sclp_vt220_space_left(request
);
321 sccb
= (struct sclp_vt220_sccb
*) request
->sclp_req
.sccb
;
322 buffer
= (void *) ((addr_t
) sccb
+ sccb
->header
.length
);
325 /* Perform Linefeed conversion (0x0a -> 0x0a 0x0d)*/
327 (from
< count
) && (to
< sclp_vt220_space_left(request
));
329 /* Retrieve character */
331 /* Perform conversion */
333 if (to
+ 1 < sclp_vt220_space_left(request
)) {
334 ((unsigned char *) buffer
)[to
++] = c
;
335 ((unsigned char *) buffer
)[to
++] = 0x0d;
340 ((unsigned char *) buffer
)[to
++] = c
;
342 sccb
->header
.length
+= to
;
343 sccb
->evbuf
.length
+= to
;
346 memcpy(buffer
, (const void *) msg
, count
);
347 sccb
->header
.length
+= count
;
348 sccb
->evbuf
.length
+= count
;
354 * Emit buffer after having waited long enough for more data to arrive.
357 sclp_vt220_timeout(unsigned long data
)
359 sclp_vt220_emit_current();
362 #define BUFFER_MAX_DELAY HZ/20
365 * Drop oldest console buffer if sclp_con_drop is set
368 sclp_vt220_drop_buffer(void)
370 struct list_head
*list
;
371 struct sclp_vt220_request
*request
;
374 if (!sclp_console_drop
)
376 list
= sclp_vt220_outqueue
.next
;
377 if (sclp_vt220_queue_running
)
378 /* The first element is in I/O */
380 if (list
== &sclp_vt220_outqueue
)
383 request
= list_entry(list
, struct sclp_vt220_request
, list
);
384 page
= request
->sclp_req
.sccb
;
385 list_add_tail((struct list_head
*) page
, &sclp_vt220_empty
);
390 * Internal implementation of the write function. Write COUNT bytes of data
392 * to the SCLP interface. In case that the data does not fit into the current
393 * write buffer, emit the current one and allocate a new one. If there are no
394 * more empty buffers available, wait until one gets emptied. If DO_SCHEDULE
395 * is non-zero, the buffer will be scheduled for emitting after a timeout -
396 * otherwise the user has to explicitly call the flush function.
397 * A non-zero CONVERTLF parameter indicates that 0x0a characters in the message
398 * buffer should be converted to 0x0a 0x0d. After completion, return the number
402 __sclp_vt220_write(const unsigned char *buf
, int count
, int do_schedule
,
403 int convertlf
, int may_fail
)
413 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
415 /* Create an sclp output buffer if none exists yet */
416 if (sclp_vt220_current_request
== NULL
) {
417 if (list_empty(&sclp_vt220_empty
))
419 while (list_empty(&sclp_vt220_empty
)) {
420 if (may_fail
|| sclp_vt220_suspended
)
422 if (sclp_vt220_drop_buffer())
424 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
427 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
429 page
= (void *) sclp_vt220_empty
.next
;
430 list_del((struct list_head
*) page
);
431 sclp_vt220_current_request
=
432 sclp_vt220_initialize_page(page
);
434 /* Try to write the string to the current request buffer */
435 written
= sclp_vt220_add_msg(sclp_vt220_current_request
,
436 buf
, count
, convertlf
);
437 overall_written
+= written
;
438 if (written
== count
)
441 * Not all characters could be written to the current
442 * output buffer. Emit the buffer, create a new buffer
443 * and then output the rest of the string.
445 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
446 sclp_vt220_emit_current();
447 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
451 /* Setup timer to output current console buffer after some time */
452 if (sclp_vt220_current_request
!= NULL
&&
453 !timer_pending(&sclp_vt220_timer
) && do_schedule
) {
454 sclp_vt220_timer
.function
= sclp_vt220_timeout
;
455 sclp_vt220_timer
.data
= 0UL;
456 sclp_vt220_timer
.expires
= jiffies
+ BUFFER_MAX_DELAY
;
457 add_timer(&sclp_vt220_timer
);
460 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
461 return overall_written
;
465 * This routine is called by the kernel to write a series of
466 * characters to the tty device. The characters may come from
467 * user space or kernel space. This routine will return the
468 * number of characters actually accepted for writing.
471 sclp_vt220_write(struct tty_struct
*tty
, const unsigned char *buf
, int count
)
473 return __sclp_vt220_write(buf
, count
, 1, 0, 1);
476 #define SCLP_VT220_SESSION_ENDED 0x01
477 #define SCLP_VT220_SESSION_STARTED 0x80
478 #define SCLP_VT220_SESSION_DATA 0x00
481 * Called by the SCLP to report incoming event buffers.
484 sclp_vt220_receiver_fn(struct evbuf_header
*evbuf
)
489 buffer
= (char *) ((addr_t
) evbuf
+ sizeof(struct evbuf_header
));
490 count
= evbuf
->length
- sizeof(struct evbuf_header
);
493 case SCLP_VT220_SESSION_ENDED
:
494 case SCLP_VT220_SESSION_STARTED
:
496 case SCLP_VT220_SESSION_DATA
:
497 /* Send input to line discipline */
500 tty_insert_flip_string(&sclp_vt220_port
, buffer
, count
);
501 tty_flip_buffer_push(&sclp_vt220_port
);
507 * This routine is called when a particular tty device is opened.
510 sclp_vt220_open(struct tty_struct
*tty
, struct file
*filp
)
512 if (tty
->count
== 1) {
513 tty_port_tty_set(&sclp_vt220_port
, tty
);
514 sclp_vt220_port
.low_latency
= 0;
515 if (!tty
->winsize
.ws_row
&& !tty
->winsize
.ws_col
) {
516 tty
->winsize
.ws_row
= 24;
517 tty
->winsize
.ws_col
= 80;
524 * This routine is called when a particular tty device is closed.
527 sclp_vt220_close(struct tty_struct
*tty
, struct file
*filp
)
530 tty_port_tty_set(&sclp_vt220_port
, NULL
);
534 * This routine is called by the kernel to write a single
535 * character to the tty device. If the kernel uses this routine,
536 * it must call the flush_chars() routine (if defined) when it is
537 * done stuffing characters into the driver.
540 sclp_vt220_put_char(struct tty_struct
*tty
, unsigned char ch
)
542 return __sclp_vt220_write(&ch
, 1, 0, 0, 1);
546 * This routine is called by the kernel after it has written a
547 * series of characters to the tty device using put_char().
550 sclp_vt220_flush_chars(struct tty_struct
*tty
)
552 if (!sclp_vt220_queue_running
)
553 sclp_vt220_emit_current();
555 sclp_vt220_flush_later
= 1;
559 * This routine returns the numbers of characters the tty driver
560 * will accept for queuing to be written. This number is subject
561 * to change as output buffers get emptied, or if the output flow
565 sclp_vt220_write_room(struct tty_struct
*tty
)
571 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
573 if (sclp_vt220_current_request
!= NULL
)
574 count
= sclp_vt220_space_left(sclp_vt220_current_request
);
575 list_for_each(l
, &sclp_vt220_empty
)
576 count
+= SCLP_VT220_MAX_CHARS_PER_BUFFER
;
577 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
582 * Return number of buffered chars.
585 sclp_vt220_chars_in_buffer(struct tty_struct
*tty
)
589 struct sclp_vt220_request
*r
;
592 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
594 if (sclp_vt220_current_request
!= NULL
)
595 count
= sclp_vt220_chars_stored(sclp_vt220_current_request
);
596 list_for_each(l
, &sclp_vt220_outqueue
) {
597 r
= list_entry(l
, struct sclp_vt220_request
, list
);
598 count
+= sclp_vt220_chars_stored(r
);
600 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
605 * Pass on all buffers to the hardware. Return only when there are no more
609 sclp_vt220_flush_buffer(struct tty_struct
*tty
)
611 sclp_vt220_emit_current();
614 /* Release allocated pages. */
615 static void __init
__sclp_vt220_free_pages(void)
617 struct list_head
*page
, *p
;
619 list_for_each_safe(page
, p
, &sclp_vt220_empty
) {
621 free_page((unsigned long) page
);
625 /* Release memory and unregister from sclp core. Controlled by init counting -
626 * only the last invoker will actually perform these actions. */
627 static void __init
__sclp_vt220_cleanup(void)
629 sclp_vt220_init_count
--;
630 if (sclp_vt220_init_count
!= 0)
632 sclp_unregister(&sclp_vt220_register
);
633 __sclp_vt220_free_pages();
634 tty_port_destroy(&sclp_vt220_port
);
637 /* Allocate buffer pages and register with sclp core. Controlled by init
638 * counting - only the first invoker will actually perform these actions. */
639 static int __init
__sclp_vt220_init(int num_pages
)
645 sclp_vt220_init_count
++;
646 if (sclp_vt220_init_count
!= 1)
648 spin_lock_init(&sclp_vt220_lock
);
649 INIT_LIST_HEAD(&sclp_vt220_empty
);
650 INIT_LIST_HEAD(&sclp_vt220_outqueue
);
651 init_timer(&sclp_vt220_timer
);
652 tty_port_init(&sclp_vt220_port
);
653 sclp_vt220_current_request
= NULL
;
654 sclp_vt220_buffered_chars
= 0;
655 sclp_vt220_flush_later
= 0;
657 /* Allocate pages for output buffering */
659 for (i
= 0; i
< num_pages
; i
++) {
660 page
= (void *) get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
663 list_add_tail(page
, &sclp_vt220_empty
);
665 rc
= sclp_register(&sclp_vt220_register
);
668 __sclp_vt220_free_pages();
669 sclp_vt220_init_count
--;
670 tty_port_destroy(&sclp_vt220_port
);
675 static const struct tty_operations sclp_vt220_ops
= {
676 .open
= sclp_vt220_open
,
677 .close
= sclp_vt220_close
,
678 .write
= sclp_vt220_write
,
679 .put_char
= sclp_vt220_put_char
,
680 .flush_chars
= sclp_vt220_flush_chars
,
681 .write_room
= sclp_vt220_write_room
,
682 .chars_in_buffer
= sclp_vt220_chars_in_buffer
,
683 .flush_buffer
= sclp_vt220_flush_buffer
,
687 * Register driver with SCLP and Linux and initialize internal tty structures.
689 static int __init
sclp_vt220_tty_init(void)
691 struct tty_driver
*driver
;
694 /* Note: we're not testing for CONSOLE_IS_SCLP here to preserve
695 * symmetry between VM and LPAR systems regarding ttyS1. */
696 driver
= alloc_tty_driver(1);
699 rc
= __sclp_vt220_init(MAX_KMEM_PAGES
);
703 driver
->driver_name
= SCLP_VT220_DRIVER_NAME
;
704 driver
->name
= SCLP_VT220_DEVICE_NAME
;
705 driver
->major
= SCLP_VT220_MAJOR
;
706 driver
->minor_start
= SCLP_VT220_MINOR
;
707 driver
->type
= TTY_DRIVER_TYPE_SYSTEM
;
708 driver
->subtype
= SYSTEM_TYPE_TTY
;
709 driver
->init_termios
= tty_std_termios
;
710 driver
->flags
= TTY_DRIVER_REAL_RAW
;
711 tty_set_operations(driver
, &sclp_vt220_ops
);
712 tty_port_link_device(&sclp_vt220_port
, driver
, 0);
714 rc
= tty_register_driver(driver
);
717 rc
= sclp_register(&sclp_vt220_register_input
);
720 sclp_vt220_driver
= driver
;
724 tty_unregister_driver(driver
);
726 __sclp_vt220_cleanup();
728 put_tty_driver(driver
);
731 __initcall(sclp_vt220_tty_init
);
733 static void __sclp_vt220_flush_buffer(void)
737 sclp_vt220_emit_current();
738 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
739 if (timer_pending(&sclp_vt220_timer
))
740 del_timer(&sclp_vt220_timer
);
741 while (sclp_vt220_queue_running
) {
742 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
744 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
746 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
750 * Resume console: If there are cached messages, emit them.
752 static void sclp_vt220_resume(void)
756 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
757 sclp_vt220_suspended
= 0;
758 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
759 sclp_vt220_emit_current();
763 * Suspend console: Set suspend flag and flush console
765 static void sclp_vt220_suspend(void)
769 spin_lock_irqsave(&sclp_vt220_lock
, flags
);
770 sclp_vt220_suspended
= 1;
771 spin_unlock_irqrestore(&sclp_vt220_lock
, flags
);
772 __sclp_vt220_flush_buffer();
775 static void sclp_vt220_pm_event_fn(struct sclp_register
*reg
,
776 enum sclp_pm_event sclp_pm_event
)
778 switch (sclp_pm_event
) {
779 case SCLP_PM_EVENT_FREEZE
:
780 sclp_vt220_suspend();
782 case SCLP_PM_EVENT_RESTORE
:
783 case SCLP_PM_EVENT_THAW
:
789 #ifdef CONFIG_SCLP_VT220_CONSOLE
792 sclp_vt220_con_write(struct console
*con
, const char *buf
, unsigned int count
)
794 __sclp_vt220_write((const unsigned char *) buf
, count
, 1, 1, 0);
797 static struct tty_driver
*
798 sclp_vt220_con_device(struct console
*c
, int *index
)
801 return sclp_vt220_driver
;
805 sclp_vt220_notify(struct notifier_block
*self
,
806 unsigned long event
, void *data
)
808 __sclp_vt220_flush_buffer();
812 static struct notifier_block on_panic_nb
= {
813 .notifier_call
= sclp_vt220_notify
,
817 static struct notifier_block on_reboot_nb
= {
818 .notifier_call
= sclp_vt220_notify
,
822 /* Structure needed to register with printk */
823 static struct console sclp_vt220_console
=
825 .name
= SCLP_VT220_CONSOLE_NAME
,
826 .write
= sclp_vt220_con_write
,
827 .device
= sclp_vt220_con_device
,
828 .flags
= CON_PRINTBUFFER
,
829 .index
= SCLP_VT220_CONSOLE_INDEX
833 sclp_vt220_con_init(void)
837 rc
= __sclp_vt220_init(sclp_console_pages
);
840 /* Attach linux console */
841 atomic_notifier_chain_register(&panic_notifier_list
, &on_panic_nb
);
842 register_reboot_notifier(&on_reboot_nb
);
843 register_console(&sclp_vt220_console
);
847 console_initcall(sclp_vt220_con_init
);
848 #endif /* CONFIG_SCLP_VT220_CONSOLE */