Subversion Repositories HelenOS

Rev

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

Rev 1928 Rev 2071
1
/*
1
/*
2
 * Copyright (C) 2006 Martin Decky
2
 * Copyright (c) 2006 Martin Decky
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 kbdppc32 ppc32
29
/** @addtogroup kbdppc32 ppc32
30
 * @brief   HelenOS ppc32 arch dependent parts of uspace keyboard handler.
30
 * @brief   HelenOS ppc32 arch dependent parts of uspace keyboard handler.
31
 * @ingroup  kbd
31
 * @ingroup  kbd
32
 * @{
32
 * @{
33
 */
33
 */
34
/** @file
34
/** @file
35
 */
35
 */
36
 
36
 
37
#include <arch/kbd.h>
37
#include <arch/kbd.h>
38
#include <ipc/ipc.h>
38
#include <ipc/ipc.h>
39
#include <sysinfo.h>
39
#include <sysinfo.h>
40
#include <kbd.h>
40
#include <kbd.h>
41
#include <keys.h>
41
#include <keys.h>
42
 
42
 
43
irq_cmd_t cuda_cmds[1] = {
43
irq_cmd_t cuda_cmds[1] = {
44
    { CMD_PPC32_GETCHAR, 0, 0, 2 }
44
    { CMD_PPC32_GETCHAR, 0, 0, 2 }
45
};
45
};
46
 
46
 
47
irq_code_t cuda_kbd = {
47
irq_code_t cuda_kbd = {
48
    1,
48
    1,
49
    cuda_cmds
49
    cuda_cmds
50
};
50
};
51
 
51
 
52
 
52
 
53
#define SPECIAL     255
53
#define SPECIAL     255
54
#define FUNCTION_KEYS 0x100
54
#define FUNCTION_KEYS 0x100
55
 
55
 
56
 
56
 
57
static int lchars[0x80] = {
57
static int lchars[0x80] = {
58
    'a',
58
    'a',
59
    's',
59
    's',
60
    'd',
60
    'd',
61
    'f',
61
    'f',
62
    'h',
62
    'h',
63
    'g',
63
    'g',
64
    'z',
64
    'z',
65
    'x',
65
    'x',
66
    'c',
66
    'c',
67
    'v',
67
    'v',
68
    SPECIAL,
68
    SPECIAL,
69
    'b',
69
    'b',
70
    'q',
70
    'q',
71
    'w',
71
    'w',
72
    'e',
72
    'e',
73
    'r',
73
    'r',
74
    'y',
74
    'y',
75
    't',
75
    't',
76
    '1',
76
    '1',
77
    '2',
77
    '2',
78
    '3',
78
    '3',
79
    '4',
79
    '4',
80
    '6',
80
    '6',
81
    '5',
81
    '5',
82
    '=',
82
    '=',
83
    '9',
83
    '9',
84
    '7',
84
    '7',
85
    '-',
85
    '-',
86
    '8',
86
    '8',
87
    '0',
87
    '0',
88
    ']',
88
    ']',
89
    'o',
89
    'o',
90
    'u',
90
    'u',
91
    '[',
91
    '[',
92
    'i',
92
    'i',
93
    'p',
93
    'p',
94
    '\n',                 /* Enter */
94
    '\n',                 /* Enter */
95
    'l',
95
    'l',
96
    'j',
96
    'j',
97
    '\'',
97
    '\'',
98
    'k',
98
    'k',
99
    ';',
99
    ';',
100
    '\\',
100
    '\\',
101
    ',',
101
    ',',
102
    '/',
102
    '/',
103
    'n',
103
    'n',
104
    'm',
104
    'm',
105
    '.',
105
    '.',
106
    '\t',                 /* Tab */
106
    '\t',                 /* Tab */
107
    ' ',
107
    ' ',
108
    '`',
108
    '`',
109
    '\b',                 /* Backspace */
109
    '\b',                 /* Backspace */
110
    SPECIAL,
110
    SPECIAL,
111
    SPECIAL,              /* Escape */
111
    SPECIAL,              /* Escape */
112
    SPECIAL,              /* Ctrl */
112
    SPECIAL,              /* Ctrl */
113
    SPECIAL,              /* Alt */
113
    SPECIAL,              /* Alt */
114
    SPECIAL,              /* Shift */
114
    SPECIAL,              /* Shift */
115
    SPECIAL,              /* Caps-Lock */
115
    SPECIAL,              /* Caps-Lock */
116
    SPECIAL,              /* RAlt */
116
    SPECIAL,              /* RAlt */
117
    SPECIAL,              /* Left */
117
    SPECIAL,              /* Left */
118
    SPECIAL,              /* Right */
118
    SPECIAL,              /* Right */
119
    SPECIAL,              /* Down */
119
    SPECIAL,              /* Down */
120
    SPECIAL,              /* Up */
120
    SPECIAL,              /* Up */
121
    SPECIAL,
121
    SPECIAL,
122
    SPECIAL,
122
    SPECIAL,
123
    '.',                  /* Keypad . */
123
    '.',                  /* Keypad . */
124
    SPECIAL,
124
    SPECIAL,
125
    '*',                  /* Keypad * */
125
    '*',                  /* Keypad * */
126
    SPECIAL,
126
    SPECIAL,
127
    '+',                  /* Keypad + */
127
    '+',                  /* Keypad + */
128
    SPECIAL,
128
    SPECIAL,
129
    SPECIAL,              /* NumLock */
129
    SPECIAL,              /* NumLock */
130
    SPECIAL,
130
    SPECIAL,
131
    SPECIAL,
131
    SPECIAL,
132
    SPECIAL,
132
    SPECIAL,
133
    '/',                  /* Keypad / */
133
    '/',                  /* Keypad / */
134
    '\n',                 /* Keypad Enter */
134
    '\n',                 /* Keypad Enter */
135
    SPECIAL,
135
    SPECIAL,
136
    '-',                  /* Keypad - */
136
    '-',                  /* Keypad - */
137
    SPECIAL,
137
    SPECIAL,
138
    SPECIAL,
138
    SPECIAL,
139
    SPECIAL,
139
    SPECIAL,
140
    '0',                  /* Keypad 0 */
140
    '0',                  /* Keypad 0 */
141
    '1',                  /* Keypad 1 */
141
    '1',                  /* Keypad 1 */
142
    '2',                  /* Keypad 2 */
142
    '2',                  /* Keypad 2 */
143
    '3',                  /* Keypad 3 */
143
    '3',                  /* Keypad 3 */
144
    '4',                  /* Keypad 4 */
144
    '4',                  /* Keypad 4 */
145
    '5',                  /* Keypad 5 */
145
    '5',                  /* Keypad 5 */
146
    '6',                  /* Keypad 6 */
146
    '6',                  /* Keypad 6 */
147
    '7',                  /* Keypad 7 */
147
    '7',                  /* Keypad 7 */
148
    SPECIAL,
148
    SPECIAL,
149
    '8',                  /* Keypad 8 */
149
    '8',                  /* Keypad 8 */
150
    '9',                  /* Keypad 9 */
150
    '9',                  /* Keypad 9 */
151
    SPECIAL,
151
    SPECIAL,
152
    SPECIAL,
152
    SPECIAL,
153
    SPECIAL,
153
    SPECIAL,
154
    (FUNCTION_KEYS | 5),  /* F5 */
154
    (FUNCTION_KEYS | 5),  /* F5 */
155
    (FUNCTION_KEYS | 6),  /* F6 */
155
    (FUNCTION_KEYS | 6),  /* F6 */
156
    (FUNCTION_KEYS | 7),  /* F7 */
156
    (FUNCTION_KEYS | 7),  /* F7 */
157
    (FUNCTION_KEYS | 3),  /* F3 */
157
    (FUNCTION_KEYS | 3),  /* F3 */
158
    (FUNCTION_KEYS | 8),  /* F8 */
158
    (FUNCTION_KEYS | 8),  /* F8 */
159
    (FUNCTION_KEYS | 9),  /* F9 */
159
    (FUNCTION_KEYS | 9),  /* F9 */
160
    SPECIAL,
160
    SPECIAL,
161
    (FUNCTION_KEYS | 11), /* F11 */
161
    (FUNCTION_KEYS | 11), /* F11 */
162
    SPECIAL,
162
    SPECIAL,
163
    (FUNCTION_KEYS | 13), /* F13 */
163
    (FUNCTION_KEYS | 13), /* F13 */
164
    SPECIAL,
164
    SPECIAL,
165
    SPECIAL,              /* ScrollLock */
165
    SPECIAL,              /* ScrollLock */
166
    SPECIAL,
166
    SPECIAL,
167
    (FUNCTION_KEYS | 10), /* F10 */
167
    (FUNCTION_KEYS | 10), /* F10 */
168
    SPECIAL,
168
    SPECIAL,
169
    (FUNCTION_KEYS | 12), /* F12 */
169
    (FUNCTION_KEYS | 12), /* F12 */
170
    SPECIAL,
170
    SPECIAL,
171
    SPECIAL,              /* Pause */
171
    SPECIAL,              /* Pause */
172
    SPECIAL,              /* Insert */
172
    SPECIAL,              /* Insert */
173
    SPECIAL,              /* Home */
173
    SPECIAL,              /* Home */
174
    SPECIAL,              /* PageUp */
174
    SPECIAL,              /* PageUp */
175
    SPECIAL,              /* Delete */
175
    SPECIAL,              /* Delete */
176
    (FUNCTION_KEYS | 4),  /* F4 */
176
    (FUNCTION_KEYS | 4),  /* F4 */
177
    SPECIAL,              /* End */
177
    SPECIAL,              /* End */
178
    (FUNCTION_KEYS | 2),  /* F2 */
178
    (FUNCTION_KEYS | 2),  /* F2 */
179
    SPECIAL,              /* PageDown */
179
    SPECIAL,              /* PageDown */
180
    (FUNCTION_KEYS | 1)   /* F1 */
180
    (FUNCTION_KEYS | 1)   /* F1 */
181
};
181
};
182
 
182
 
183
 
183
 
184
int kbd_arch_init(void)
184
int kbd_arch_init(void)
185
{
185
{
186
    return ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &cuda_kbd);
186
    return ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &cuda_kbd);
187
}
187
}
188
 
188
 
189
 
189
 
190
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
190
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
191
{
191
{
192
    int param = IPC_GET_ARG2(*call);
192
    int param = IPC_GET_ARG2(*call);
193
 
193
 
194
    if (param != -1) {
194
    if (param != -1) {
195
        uint8_t scancode = (uint8_t) param;
195
        uint8_t scancode = (uint8_t) param;
196
   
196
   
197
        if ((scancode & 0x80) != 0x80) {
197
        if ((scancode & 0x80) != 0x80) {
198
            int key = lchars[scancode & 0x7f];
198
            int key = lchars[scancode & 0x7f];
199
           
199
           
200
            if (key != SPECIAL)
200
            if (key != SPECIAL)
201
                keybuffer_push(keybuffer, key);
201
                keybuffer_push(keybuffer, key);
202
        }
202
        }
203
    }
203
    }
204
   
204
   
205
    return 1;
205
    return 1;
206
}
206
}
207
 
207
 
208
/** @}
208
/** @}
209
 */
209
 */
210
 
210