Subversion Repositories HelenOS

Rev

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

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