Rev 4629 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4629 | Rev 4632 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2001-2004 Jakub Jermar |
2 | * Copyright (c) 2001-2004 Jakub Jermar |
3 | * Copyright (c) 2006 Josef Cejka |
3 | * Copyright (c) 2006 Josef Cejka |
4 | * Copyright (c) 2009 Vineeth Pillai |
4 | * Copyright (c) 2009 Vineeth Pillai |
5 | * All rights reserved. |
5 | * All rights reserved. |
6 | * |
6 | * |
7 | * Redistribution and use in source and binary forms, with or without |
7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions |
8 | * modification, are permitted provided that the following conditions |
9 | * are met: |
9 | * are met: |
10 | * |
10 | * |
11 | * - Redistributions of source code must retain the above copyright |
11 | * - Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. |
12 | * notice, this list of conditions and the following disclaimer. |
13 | * - Redistributions in binary form must reproduce the above copyright |
13 | * - Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the |
14 | * notice, this list of conditions and the following disclaimer in the |
15 | * documentation and/or other materials provided with the distribution. |
15 | * documentation and/or other materials provided with the distribution. |
16 | * - The name of the author may not be used to endorse or promote products |
16 | * - The name of the author may not be used to endorse or promote products |
17 | * derived from this software without specific prior written permission. |
17 | * derived from this software without specific prior written permission. |
18 | * |
18 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ |
29 | */ |
30 | 30 | ||
31 | /** @addtogroup kbdarm32 arm32 |
31 | /** @addtogroup kbdarm32 arm32 |
32 | * @brief HelenOS arm32/integratorcp arch dependent parts of uspace keyboard handler. |
32 | * @brief HelenOS arm32/integratorcp arch dependent parts of uspace keyboard handler. |
33 | * @ingroup kbd |
33 | * @ingroup kbd |
34 | * @{ |
34 | * @{ |
35 | */ |
35 | */ |
36 | /** @file |
36 | /** @file |
37 | * @ingroup kbdarm32 |
37 | * @ingroup kbdarm32 |
38 | */ |
38 | */ |
39 | #include <stdio.h> |
39 | #include <stdio.h> |
40 | #include <arch/kbd.h> |
40 | #include <arch/kbd.h> |
41 | #include <ipc/ipc.h> |
41 | #include <ipc/ipc.h> |
42 | #include <unistd.h> |
42 | #include <unistd.h> |
43 | #include <kbd.h> |
43 | #include <kbd.h> |
44 | #include <arch/pl050.h> |
44 | #include <arch/pl050.h> |
45 | #include <keys.h> |
45 | #include <keys.h> |
46 | #include <genarch/kbd.h> |
46 | #include <genarch/kbd.h> |
47 | #include <sysinfo.h> |
47 | #include <sysinfo.h> |
48 | #include <as.h> |
48 | #include <as.h> |
49 | #include <ipc/ipc.h> |
49 | #include <ipc/ipc.h> |
50 | #include <ipc/ns.h> |
50 | #include <ipc/ns.h> |
51 | #include <ipc/services.h> |
51 | #include <ipc/services.h> |
52 | #include <ddi.h> |
52 | #include <ddi.h> |
53 | #include <align.h> |
53 | #include <align.h> |
54 | 54 | ||
55 | #define PL050_KEY_RELEASE 0xF0 |
55 | #define PL050_KEY_RELEASE 0xF0 |
56 | #define PL050_ESC_KEY 0xE0 |
56 | #define PL050_ESC_KEY 0xE0 |
57 | 57 | ||
58 | irq_cmd_t pl050_cmds[] = { |
58 | irq_cmd_t pl050_cmds[] = { |
59 | { CMD_MEM_READ_1, (void *) 0, 0, 1 }, |
59 | { CMD_MEM_READ_1, (void *) 0, 0, 1 }, |
60 | { CMD_MEM_READ_1, (void *) 0, 0, 2} |
60 | { CMD_MEM_READ_1, (void *) 0, 0, 2} |
61 | }; |
61 | }; |
62 | 62 | ||
63 | irq_code_t pl050_kbd = { |
63 | irq_code_t pl050_kbd = { |
64 | 2, |
64 | 2, |
65 | pl050_cmds |
65 | pl050_cmds |
66 | }; |
66 | }; |
67 | 67 | ||
68 | 68 | ||
69 | static void *kbd_physaddr; |
69 | static void *kbd_physaddr; |
70 | static void *kbd_addr; |
70 | static void *kbd_addr; |
71 | 71 | ||
72 | /** Register uspace irq handler |
72 | /** Register uspace irq handler |
73 | * @return |
73 | * @return |
74 | */ |
74 | */ |
75 | int kbd_arch_init(void) |
75 | int kbd_arch_init(void) |
76 | { |
76 | { |
77 | kbd_physaddr = (void *)sysinfo_value("kbd.pbase"); |
77 | kbd_physaddr = (void *)sysinfo_value("kbd.pbase"); |
78 | 78 | ||
79 | kbd_addr = (void*)sysinfo_value("kbd.vbase"); |
79 | kbd_addr = (void*)sysinfo_value("kbd.vbase"); |
80 | 80 | ||
81 | pl050_cmds[0].addr = (void *)(kbd_addr+PL050_DATA); |
81 | pl050_cmds[0].addr = (void *)(kbd_addr+PL050_DATA); |
82 | pl050_cmds[1].addr = (void *)(kbd_addr+PL050_STAT); |
82 | pl050_cmds[1].addr = (void *)(kbd_addr+PL050_STAT); |
83 | 83 | ||
84 | /* Enable kbd */ |
84 | /* Enable kbd */ |
85 | ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &pl050_kbd); |
85 | ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &pl050_kbd); |
86 | 86 | ||
87 | return 0; |
87 | return 0; |
88 | } |
88 | } |
89 | 89 | ||
90 | /** Process keyboard & mouse events */ |
90 | /** Process keyboard & mouse events */ |
91 | int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) |
91 | int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) |
92 | { |
92 | { |
93 | static int key_released_flag = 0; |
93 | static int key_released_flag = 0; |
94 | static uint8_t prev_char = 0xFF; |
94 | static int caps_count = 0; |
95 | 95 | ||
96 | int scan_code = IPC_GET_ARG1(*call); |
96 | int scan_code = IPC_GET_ARG1(*call); |
97 | 97 | ||
- | 98 | if (scan_code == 0x58) { |
|
- | 99 | if (caps_count == 2) { |
|
- | 100 | caps_count = 0; |
|
- | 101 | return 1; |
|
- | 102 | } else if (key_released_flag && !caps_count) { |
|
- | 103 | key_released_flag = 0; |
|
- | 104 | return 1; |
|
- | 105 | } |
|
- | 106 | caps_count++; |
|
- | 107 | } |
|
- | 108 | ||
- | 109 | ||
98 | if (scan_code == PL050_KEY_RELEASE) { |
110 | if (scan_code == PL050_KEY_RELEASE) { |
99 | key_released_flag = 1; |
111 | key_released_flag = 1; |
100 | } else { |
112 | } else { |
101 | if (key_released_flag && prev_char == scan_code) { |
113 | if (key_released_flag) { |
102 | prev_char = 0xFF; |
- | |
103 | key_released(keybuffer, scan_code); |
114 | key_released(keybuffer, scan_code); |
104 | } else { |
115 | } else { |
105 | key_pressed(keybuffer, scan_code); |
116 | key_pressed(keybuffer, scan_code); |
106 | prev_char = scan_code; |
- | |
107 | } |
117 | } |
108 | key_released_flag = 0; |
118 | key_released_flag = 0; |
109 | } |
119 | } |
110 | 120 | ||
111 | return 1; |
121 | return 1; |
112 | } |
122 | } |
113 | 123 | ||
114 | /** |
124 | /** |
115 | * @} |
125 | * @} |
116 | */ |
126 | */ |
117 | 127 |