Subversion Repositories HelenOS

Rev

Rev 3674 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3674 Rev 4338
1
/*
1
/*
2
 * Copyright (c) 2006 Josef Cejka
2
 * Copyright (c) 2006 Josef Cejka
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup kbdmips32 mips32
29
/** @addtogroup kbdmips32 mips32
30
 * @brief   HelenOS mips32 arch dependent parts of uspace keyboard handler.
30
 * @brief   HelenOS mips32 arch dependent parts of uspace keyboard handler.
31
 * @ingroup  kbd
31
 * @ingroup  kbd
32
 * @{
32
 * @{
33
 */
33
 */
34
 
34
 
35
/** @file
35
/** @file
36
 */
36
 */
37
 
37
 
38
#include <genarch/nofb.h>
38
#include <genarch/nofb.h>
39
#include <stdio.h> // DELETE!!!
39
#include <stdio.h> // DELETE!!!
40
 
40
 
41
#define KEY_F1 0x504f1bL
41
#define KEY_F1 0x504f1bL
42
#define KEY_F2 0x514f1bL
42
#define KEY_F2 0x514f1bL
43
#define KEY_F3 0x524f1bL
43
#define KEY_F3 0x524f1bL
44
#define KEY_F4 0x534f1bL
44
#define KEY_F4 0x534f1bL
45
#define KEY_F5 0x35315b1bL
45
#define KEY_F5 0x35315b1bL
46
#define KEY_F6 0x37315b1bL
46
#define KEY_F6 0x37315b1bL
47
#define KEY_F7 0x38315b1bL
47
#define KEY_F7 0x38315b1bL
48
#define KEY_F8 0x39315b1bL
48
#define KEY_F8 0x39315b1bL
49
#define KEY_F9 0x30325b1bL
49
#define KEY_F9 0x30325b1bL
50
#define KEY_F10 0x31325b1bL
50
#define KEY_F10 0x31325b1bL
51
#define KEY_F11 0x33325b1bL
51
#define KEY_F11 0x33325b1bL
52
#define KEY_F12 0x34325b1bL
52
#define KEY_F12 0x34325b1bL
53
 
53
 
54
/**
54
/**
55
 * Processes the key pressed - pushes the key code into the key buffer.
55
 * Processes the key pressed - pushes the key code into the key buffer.
56
 * Used in MSIM and Serengeti, i.e. non-framebuffer consoles.
56
 * Used in MSIM and Serengeti, i.e. non-framebuffer consoles.
57
 */
57
 */
58
int kbd_process_no_fb(keybuffer_t *keybuffer, int scan_code)
58
int kbd_process_no_fb(keybuffer_t *keybuffer, int scan_code)
59
{
59
{
60
    static unsigned long buf = 0;
60
    static unsigned long buf = 0;
61
    static int count = 0;  
61
    static int count = 0;  
-
 
62
 
-
 
63
    if (scan_code == '\r')
-
 
64
        scan_code = '\n';
62
   
65
 
63
    if(scan_code == 0x7e) {
66
    if (scan_code == 0x7e) {
64
        switch (buf) {
67
        switch (buf) {
65
        case KEY_F5:
68
        case KEY_F5:
66
            keybuffer_push(keybuffer,FUNCTION_KEYS | 5);
69
            keybuffer_push(keybuffer,FUNCTION_KEYS | 5);
67
            buf = count = 0;
70
            buf = count = 0;
68
            return 1;
71
            return 1;
69
        case KEY_F6:
72
        case KEY_F6:
70
            keybuffer_push(keybuffer,FUNCTION_KEYS | 6);
73
            keybuffer_push(keybuffer,FUNCTION_KEYS | 6);
71
            buf = count = 0;
74
            buf = count = 0;
72
            return 1;
75
            return 1;
73
        case KEY_F7:
76
        case KEY_F7:
74
            keybuffer_push(keybuffer,FUNCTION_KEYS | 7);
77
            keybuffer_push(keybuffer,FUNCTION_KEYS | 7);
75
            buf = count = 0;
78
            buf = count = 0;
76
            return 1;
79
            return 1;
77
        case KEY_F8:
80
        case KEY_F8:
78
            keybuffer_push(keybuffer,FUNCTION_KEYS | 8);
81
            keybuffer_push(keybuffer,FUNCTION_KEYS | 8);
79
            buf = count = 0;
82
            buf = count = 0;
80
            return 1;
83
            return 1;
81
        case KEY_F9:
84
        case KEY_F9:
82
            keybuffer_push(keybuffer,FUNCTION_KEYS | 9);
85
            keybuffer_push(keybuffer,FUNCTION_KEYS | 9);
83
            buf = count = 0;
86
            buf = count = 0;
84
            return 1;
87
            return 1;
85
        case KEY_F10:
88
        case KEY_F10:
86
            keybuffer_push(keybuffer,FUNCTION_KEYS | 10);
89
            keybuffer_push(keybuffer,FUNCTION_KEYS | 10);
87
            buf = count = 0;
90
            buf = count = 0;
88
            return 1;
91
            return 1;
89
        case KEY_F11:
92
        case KEY_F11:
90
            keybuffer_push(keybuffer,FUNCTION_KEYS | 11);
93
            keybuffer_push(keybuffer,FUNCTION_KEYS | 11);
91
            buf = count = 0;
94
            buf = count = 0;
92
            return 1;
95
            return 1;
93
        case KEY_F12:
96
        case KEY_F12:
94
            keybuffer_push(keybuffer,FUNCTION_KEYS | 12);
97
            keybuffer_push(keybuffer,FUNCTION_KEYS | 12);
95
            buf = count = 0;
98
            buf = count = 0;
96
            return 1;
99
            return 1;
97
        default:
100
        default:
98
            keybuffer_push(keybuffer, buf & 0xff);
101
            keybuffer_push(keybuffer, buf & 0xff);
99
            keybuffer_push(keybuffer, (buf >> 8) &0xff);
102
            keybuffer_push(keybuffer, (buf >> 8) &0xff);
100
            keybuffer_push(keybuffer, (buf >> 16) &0xff);
103
            keybuffer_push(keybuffer, (buf >> 16) &0xff);
101
            keybuffer_push(keybuffer, (buf >> 24) &0xff);
104
            keybuffer_push(keybuffer, (buf >> 24) &0xff);
102
            keybuffer_push(keybuffer, scan_code);
105
            keybuffer_push(keybuffer, scan_code);
103
            buf = count = 0;
106
            buf = count = 0;
104
            return 1;
107
            return 1;
105
        }
108
        }
106
    }
109
    }
107
 
110
 
108
    buf |= ((unsigned long) scan_code)<<(8*(count++));
111
    buf |= ((unsigned long) scan_code)<<(8*(count++));
109
   
112
   
110
    if((buf & 0xff) != (KEY_F1 & 0xff)) {
113
    if((buf & 0xff) != (KEY_F1 & 0xff)) {
111
        keybuffer_push(keybuffer, buf);
114
        keybuffer_push(keybuffer, buf);
112
        buf = count = 0;
115
        buf = count = 0;
113
        return 1;
116
        return 1;
114
    }
117
    }
115
 
118
 
116
    if (count <= 1)
119
    if (count <= 1)
117
        return 1;
120
        return 1;
118
 
121
 
119
    if ((buf & 0xffff) != (KEY_F1 & 0xffff)
122
    if ((buf & 0xffff) != (KEY_F1 & 0xffff)
120
        && (buf & 0xffff) != (KEY_F5 & 0xffff) ) {
123
        && (buf & 0xffff) != (KEY_F5 & 0xffff) ) {
121
 
124
 
122
        keybuffer_push(keybuffer, buf & 0xff);
125
        keybuffer_push(keybuffer, buf & 0xff);
123
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
126
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
124
        buf = count = 0;
127
        buf = count = 0;
125
        return 1;
128
        return 1;
126
    }
129
    }
127
 
130
 
128
    if (count <= 2)
131
    if (count <= 2)
129
        return 1;
132
        return 1;
130
 
133
 
131
    switch (buf) {
134
    switch (buf) {
132
    case KEY_F1:
135
    case KEY_F1:
133
        keybuffer_push(keybuffer,FUNCTION_KEYS | 1);
136
        keybuffer_push(keybuffer,FUNCTION_KEYS | 1);
134
        buf = count = 0;
137
        buf = count = 0;
135
        return 1;
138
        return 1;
136
    case KEY_F2:
139
    case KEY_F2:
137
        keybuffer_push(keybuffer,FUNCTION_KEYS | 2);
140
        keybuffer_push(keybuffer,FUNCTION_KEYS | 2);
138
        buf = count = 0;
141
        buf = count = 0;
139
        return 1;
142
        return 1;
140
    case KEY_F3:
143
    case KEY_F3:
141
        keybuffer_push(keybuffer,FUNCTION_KEYS | 3);
144
        keybuffer_push(keybuffer,FUNCTION_KEYS | 3);
142
        buf = count = 0;
145
        buf = count = 0;
143
        return 1;
146
        return 1;
144
    case KEY_F4:
147
    case KEY_F4:
145
        keybuffer_push(keybuffer,FUNCTION_KEYS | 4);
148
        keybuffer_push(keybuffer,FUNCTION_KEYS | 4);
146
        buf = count = 0;
149
        buf = count = 0;
147
        return 1;
150
        return 1;
148
    }
151
    }
149
 
152
 
150
 
153
 
151
    if((buf & 0xffffff) != (KEY_F5 & 0xffffff)
154
    if((buf & 0xffffff) != (KEY_F5 & 0xffffff)
152
        && (buf & 0xffffff) != (KEY_F9 & 0xffffff)) {
155
        && (buf & 0xffffff) != (KEY_F9 & 0xffffff)) {
153
 
156
 
154
        keybuffer_push(keybuffer, buf & 0xff);
157
        keybuffer_push(keybuffer, buf & 0xff);
155
        keybuffer_push(keybuffer, (buf >> 8) & 0xff);
158
        keybuffer_push(keybuffer, (buf >> 8) & 0xff);
156
        keybuffer_push(keybuffer, (buf >> 16) & 0xff);
159
        keybuffer_push(keybuffer, (buf >> 16) & 0xff);
157
        buf=count=0;
160
        buf=count=0;
158
        return 1;
161
        return 1;
159
    }
162
    }
160
 
163
 
161
    if (count <= 3)
164
    if (count <= 3)
162
        return 1;
165
        return 1;
163
   
166
   
164
    switch (buf) {
167
    switch (buf) {
165
    case KEY_F5:
168
    case KEY_F5:
166
    case KEY_F6:
169
    case KEY_F6:
167
    case KEY_F7:
170
    case KEY_F7:
168
    case KEY_F8:
171
    case KEY_F8:
169
    case KEY_F9:
172
    case KEY_F9:
170
    case KEY_F10:
173
    case KEY_F10:
171
    case KEY_F11:
174
    case KEY_F11:
172
    case KEY_F12:
175
    case KEY_F12:
173
        return 1;
176
        return 1;
174
    default:
177
    default:
175
        keybuffer_push(keybuffer, buf & 0xff);
178
        keybuffer_push(keybuffer, buf & 0xff);
176
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
179
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
177
        keybuffer_push(keybuffer, (buf >> 16) &0xff);
180
        keybuffer_push(keybuffer, (buf >> 16) &0xff);
178
        keybuffer_push(keybuffer, (buf >> 24) &0xff);
181
        keybuffer_push(keybuffer, (buf >> 24) &0xff);
179
        buf = count = 0;
182
        buf = count = 0;
180
        return 1;
183
        return 1;
181
    }
184
    }
182
 
185
 
183
    return 1;
186
    return 1;
184
}
187
}
185
 
188
 
186
/** @}
189
/** @}
187
 */
190
 */