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