OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [s390/] [char/] [ctrlchar.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 *  drivers/s390/char/ctrlchar.c
3
 *  Unified handling of special chars.
4
 *
5
 *    Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
6
 *    Author(s): Fritz Elfert <felfert@millenux.com> <elfert@de.ibm.com>
7
 *
8
 */
9
 
10
#include <linux/config.h>
11
#include <linux/stddef.h>
12
#include <linux/sysrq.h>
13
#include <linux/ctype.h>
14
#include <linux/interrupt.h>
15
 
16
#include "ctrlchar.h"
17
 
18
#ifdef CONFIG_MAGIC_SYSRQ
19
static int ctrlchar_sysrq_key;
20
static struct tq_struct ctrlchar_tq;
21
 
22
static void
23
ctrlchar_handle_sysrq(void *tty)
24
{
25
        handle_sysrq(ctrlchar_sysrq_key, NULL, NULL, (struct tty_struct*) tty);
26
}
27
#endif
28
 
29
void
30
ctrlchar_init(void)
31
{
32
#ifdef CONFIG_MAGIC_SYSRQ
33
        static int init_done = 0;
34
 
35
        if (init_done++)
36
                return;
37
        INIT_LIST_HEAD(&ctrlchar_tq.list);
38
        ctrlchar_tq.sync = 0;
39
        ctrlchar_tq.routine = (void (*)(void *)) ctrlchar_handle_sysrq;
40
#endif
41
}
42
 
43
/**
44
 * Check for special chars at start of input.
45
 *
46
 * @param buf Console input buffer.
47
 * @param len Length of valid data in buffer.
48
 * @param tty The tty struct for this console.
49
 * @return CTRLCHAR_NONE, if nothing matched,
50
 *         CTRLCHAR_SYSRQ, if sysrq was encountered
51
 *         otherwise char to be inserted logically or'ed
52
 *         with CTRLCHAR_CTRL
53
 */
54
unsigned int
55
ctrlchar_handle(const unsigned char *buf, int len, struct tty_struct *tty)
56
{
57
        if ((len < 2) || (len > 3))
58
                return CTRLCHAR_NONE;
59
 
60
        /* hat is 0xb1 in codepage 037 (US etc.) and thus */
61
        /* converted to 0x5e in ascii ('^') */
62
        if ((buf[0] != '^') && (buf[0] != '\252'))
63
                return CTRLCHAR_NONE;
64
 
65
#ifdef CONFIG_MAGIC_SYSRQ
66
        /* racy */
67
        if (len == 3 && buf[1] == '-') {
68
                ctrlchar_sysrq_key = buf[2];
69
                ctrlchar_tq.data = tty;
70
                queue_task(&ctrlchar_tq, &tq_immediate);
71
                mark_bh(IMMEDIATE_BH);
72
                return CTRLCHAR_SYSRQ;
73
        }
74
#endif
75
 
76
        if (len != 2)
77
                return CTRLCHAR_NONE;
78
 
79
        switch (tolower(buf[1])) {
80
        case 'c':
81
                return INTR_CHAR(tty) | CTRLCHAR_CTRL;
82
        case 'd':
83
                return EOF_CHAR(tty)  | CTRLCHAR_CTRL;
84
        case 'z':
85
                return SUSP_CHAR(tty) | CTRLCHAR_CTRL;
86
        }
87
        return CTRLCHAR_NONE;
88
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.