Subversion Repositories HelenOS

Rev

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

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