Subversion Repositories HelenOS-historic

Rev

Rev 1634 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1608 decky 1
/*
1626 decky 2
 * Copyright (C) 2006 Martin Decky
1608 decky 3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 *
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
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
15
 *   derived from this software without specific prior written permission.
16
 *
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
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
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
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
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
28
 
1649 cejka 29
/** @addtogroup kbdppc32 ppc32
30
 * @brief   HelenOS ppc32 arch dependent parts of uspace keyboard handler.
31
 * @ingroup  kbd
32
 * @{
33
 */
34
/** @file
35
 */
36
 
1608 decky 37
#include <arch/kbd.h>
38
#include <ipc/ipc.h>
1626 decky 39
#include <sysinfo.h>
1608 decky 40
 
1626 decky 41
irq_cmd_t cuda_cmds[1] = {
42
    { CMD_PPC32_GETCHAR, 0, 0 }
43
};
44
 
45
irq_code_t cuda_kbd = {
46
    1,
47
    cuda_cmds
48
};
49
 
50
 
1634 decky 51
#define SPECIAL     255
52
#define FUNCTION_KEYS 0x100
53
 
54
 
55
static int lchars[0x80] = {
56
    'a',
57
    's',
58
    'd',
59
    'f',
60
    'h',
61
    'g',
62
    'z',
63
    'x',
64
    'c',
65
    'v',
66
    SPECIAL,
67
    'b',
68
    'q',
69
    'w',
70
    'e',
71
    'r',
72
    'y',
73
    't',
74
    '1',
75
    '2',
76
    '3',
77
    '4',
78
    '6',
79
    '5',
80
    '=',
81
    '9',
82
    '7',
83
    '-',
84
    '8',
85
    '0',
86
    ']',
87
    'o',
88
    'u',
89
    '[',
90
    'i',
91
    'p',
92
    '\n',                 /* Enter */
93
    'l',
94
    'j',
95
    '\'',
96
    'k',
97
    ';',
98
    '\\',
99
    ',',
100
    '/',
101
    'n',
102
    'm',
103
    '.',
104
    '\t',                 /* Tab */
105
    ' ',
106
    '`',
107
    '\b',                 /* Backspace */
108
    SPECIAL,
109
    SPECIAL,              /* Escape */
110
    SPECIAL,              /* Ctrl */
111
    SPECIAL,              /* Alt */
112
    SPECIAL,              /* Shift */
113
    SPECIAL,              /* Caps-Lock */
114
    SPECIAL,              /* RAlt */
115
    SPECIAL,              /* Left */
116
    SPECIAL,              /* Right */
117
    SPECIAL,              /* Down */
118
    SPECIAL,              /* Up */
119
    SPECIAL,
120
    SPECIAL,
121
    '.',                  /* Keypad . */
122
    SPECIAL,
123
    '*',                  /* Keypad * */
124
    SPECIAL,
125
    '+',                  /* Keypad + */
126
    SPECIAL,
127
    SPECIAL,              /* NumLock */
128
    SPECIAL,
129
    SPECIAL,
130
    SPECIAL,
131
    '/',                  /* Keypad / */
132
    '\n',                 /* Keypad Enter */
133
    SPECIAL,
134
    '-',                  /* Keypad - */
135
    SPECIAL,
136
    SPECIAL,
137
    SPECIAL,
138
    '0',                  /* Keypad 0 */
139
    '1',                  /* Keypad 1 */
140
    '2',                  /* Keypad 2 */
141
    '3',                  /* Keypad 3 */
142
    '4',                  /* Keypad 4 */
143
    '5',                  /* Keypad 5 */
144
    '6',                  /* Keypad 6 */
145
    '7',                  /* Keypad 7 */
146
    SPECIAL,
147
    '8',                  /* Keypad 8 */
148
    '9',                  /* Keypad 9 */
149
    SPECIAL,
150
    SPECIAL,
151
    SPECIAL,
152
    (FUNCTION_KEYS | 5),  /* F5 */
153
    (FUNCTION_KEYS | 6),  /* F6 */
154
    (FUNCTION_KEYS | 7),  /* F7 */
155
    (FUNCTION_KEYS | 3),  /* F3 */
156
    (FUNCTION_KEYS | 8),  /* F8 */
157
    (FUNCTION_KEYS | 9),  /* F9 */
158
    SPECIAL,
159
    (FUNCTION_KEYS | 11), /* F11 */
160
    SPECIAL,
161
    (FUNCTION_KEYS | 13), /* F13 */
162
    SPECIAL,
163
    SPECIAL,              /* ScrollLock */
164
    SPECIAL,
165
    (FUNCTION_KEYS | 10), /* F10 */
166
    SPECIAL,
167
    (FUNCTION_KEYS | 12), /* F12 */
168
    SPECIAL,
169
    SPECIAL,              /* Pause */
170
    SPECIAL,              /* Insert */
171
    SPECIAL,              /* Home */
172
    SPECIAL,              /* PageUp */
173
    SPECIAL,              /* Delete */
174
    (FUNCTION_KEYS | 4),  /* F4 */
175
    SPECIAL,              /* End */
176
    (FUNCTION_KEYS | 2),  /* F2 */
177
    SPECIAL,              /* PageDown */
178
    (FUNCTION_KEYS | 1)   /* F1 */
1629 decky 179
};
180
 
181
 
1608 decky 182
int kbd_arch_init(void)
183
{
1626 decky 184
    return (!ipc_register_irq(sysinfo_value("cuda.irq"), &cuda_kbd));
1608 decky 185
}
186
 
1626 decky 187
 
188
int kbd_arch_process(keybuffer_t *keybuffer, int scan_code)
1608 decky 189
{
1634 decky 190
    if (scan_code != -1) {
191
        uint8_t scancode = (uint8_t) scan_code;
1629 decky 192
 
1634 decky 193
        if ((scancode & 0x80) != 0x80) {
194
            int key = lchars[scancode & 0x7f];
195
 
196
            if (key != SPECIAL)
197
                keybuffer_push(keybuffer, key);
198
        }
199
    }
1629 decky 200
 
1608 decky 201
    return 1;
202
}
1649 cejka 203
 
204
/** @}
205
 */
206