Subversion Repositories HelenOS-historic

Rev

Rev 1649 | Go to most recent revision | 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 Josef Cejka
2
 * Copyright (C) 2006 Josef Cejka
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 kbdia64 ia64
29
/** @addtogroup kbdia64 ia64
30
 * @brief   HelenOS ia64 arch dependent parts of uspace keyboard handler.
30
 * @brief   HelenOS ia64 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
#define KEY_F1 0x504f1b
43
#define KEY_F1 0x504f1b
42
#define KEY_F2 0x514f1b
44
#define KEY_F2 0x514f1b
43
#define KEY_F3 0x524f1b
45
#define KEY_F3 0x524f1b
44
#define KEY_F4 0x534f1b
46
#define KEY_F4 0x534f1b
45
#define KEY_F5 0x7e35315b1b
47
#define KEY_F5 0x7e35315b1b
46
#define KEY_F6 0x7e37315b1b
48
#define KEY_F6 0x7e37315b1b
47
#define KEY_F7 0x7e38315b1b
49
#define KEY_F7 0x7e38315b1b
48
#define KEY_F8 0x7e39315b1b
50
#define KEY_F8 0x7e39315b1b
49
#define KEY_F9 0x7e30325b1b
51
#define KEY_F9 0x7e30325b1b
50
#define KEY_F10 0x7e31325b1b
52
#define KEY_F10 0x7e31325b1b
51
#define KEY_F11 0x7e33325b1b
53
#define KEY_F11 0x7e33325b1b
52
#define KEY_F12 0x7e34325b1b
54
#define KEY_F12 0x7e34325b1b
53
 
55
 
54
 
56
 
55
#define FUNCTION_KEYS 0x100
57
#define FUNCTION_KEYS 0x100
56
 
58
 
57
irq_cmd_t ski_cmds[1] = {
59
irq_cmd_t ski_cmds[1] = {
58
    { CMD_IA64_GETCHAR, 0, 0 }
60
    { CMD_IA64_GETCHAR, 0, 0, 2 }
59
};
61
};
60
 
62
 
61
irq_code_t ski_kbd = {
63
irq_code_t ski_kbd = {
62
    1,
64
    1,
63
    ski_cmds
65
    ski_cmds
64
};
66
};
65
 
67
 
66
int kbd_arch_init(void)
68
int kbd_arch_init(void)
67
{
69
{
68
    if(sysinfo_value("kbd")) {
70
    if(sysinfo_value("kbd")) {
69
        ipc_register_irq(sysinfo_value("kbd.irq"), &ski_kbd);
71
        ipc_register_irq(sysinfo_value("kbd.irq"), &ski_kbd);
70
        return 1;
72
        return 0;
71
    }  
73
    }  
72
   
74
    return 1;
73
}
75
}
74
 
76
 
75
/*
77
/*
76
* Please preserve this code (it can be used to determine scancodes)
78
* Please preserve this code (it can be used to determine scancodes)
77
*
79
*
78
int to_hex(int v)
80
int to_hex(int v)
79
{
81
{
80
    return "0123456789ABCDEF"[v];
82
    return "0123456789ABCDEF"[v];
81
}
83
}
82
*/
84
*/
83
 
85
 
84
int kbd_arch_process(keybuffer_t *keybuffer, int scan_code)
86
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
85
{
87
{
86
    static unsigned long long buf=0;
88
    static unsigned long long buf=0;
87
    static int count=0;
89
    static int count=0;
88
    static int esc_count=0;
90
    static int esc_count=0;
-
 
91
    int scan_code = IPC_GET_ARG2(*call);
89
 
92
 
90
 
93
 
91
    /*
94
    /*
92
    * Please preserve this code (it can be used to determine scancodes)
95
    * Please preserve this code (it can be used to determine scancodes)
93
    */
96
    */
94
    //keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf));
97
    //keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf));
95
    //keybuffer_push(keybuffer, to_hex(scan_code&0xf));
98
    //keybuffer_push(keybuffer, to_hex(scan_code&0xf));
96
    //keybuffer_push(keybuffer, ' ');
99
    //keybuffer_push(keybuffer, ' ');
97
    //keybuffer_push(keybuffer, ' ');
100
    //keybuffer_push(keybuffer, ' ');
98
    //*/
101
    //*/
99
   
102
   
100
   
103
   
101
    if (scan_code){
104
    if (scan_code){
102
        buf|=(unsigned long long) scan_code<<(8*(count++));
105
        buf|=(unsigned long long) scan_code<<(8*(count++));
103
    } else {
106
    } else {
104
       
107
       
105
 
108
 
106
        if ( buf == 0x1b ) {
109
        if ( buf == 0x1b ) {
107
            esc_count++;
110
            esc_count++;
108
            if ( esc_count == 3 ) {
111
            if ( esc_count == 3 ) {
109
            __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE);
112
            __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE);
110
            }  
113
            }  
111
        } else {
114
        } else {
112
            esc_count=0;
115
            esc_count=0;
113
        }
116
        }
114
   
117
   
115
        if ( ! ( buf & 0xff00 ))
118
        if ( ! ( buf & 0xff00 ))
116
            keybuffer_push(keybuffer, buf);
119
            keybuffer_push(keybuffer, buf);
117
        else {
120
        else {
118
            switch (buf){
121
            switch (buf){
119
                case KEY_F1:
122
                case KEY_F1:
120
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 1 );
123
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 1 );
121
                    break;
124
                    break;
122
                case KEY_F2:
125
                case KEY_F2:
123
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 2 );
126
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 2 );
124
                    break;
127
                    break;
125
                case KEY_F3:
128
                case KEY_F3:
126
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 3 );
129
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 3 );
127
                    break;
130
                    break;
128
                case KEY_F4:
131
                case KEY_F4:
129
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 4 );
132
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 4 );
130
                    break;
133
                    break;
131
                case KEY_F5:
134
                case KEY_F5:
132
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 5 );
135
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 5 );
133
                    break;
136
                    break;
134
                case KEY_F6:
137
                case KEY_F6:
135
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 6 );
138
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 6 );
136
                    break;
139
                    break;
137
                case KEY_F7:
140
                case KEY_F7:
138
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 7 );
141
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 7 );
139
                    break;
142
                    break;
140
                case KEY_F8:
143
                case KEY_F8:
141
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 8 );
144
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 8 );
142
                    break;
145
                    break;
143
 
146
 
144
                case KEY_F9:
147
                case KEY_F9:
145
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 9 );
148
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 9 );
146
                    break;
149
                    break;
147
                case KEY_F10:
150
                case KEY_F10:
148
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 10 );
151
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 10 );
149
                    break;
152
                    break;
150
 
153
 
151
                case KEY_F11:
154
                case KEY_F11:
152
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 11 );
155
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 11 );
153
                    break;
156
                    break;
154
                case KEY_F12:
157
                case KEY_F12:
155
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 12 );
158
                    keybuffer_push(keybuffer,FUNCTION_KEYS | 12 );
156
                    break;
159
                    break;
157
 
160
 
158
 
161
 
159
            }
162
            }
160
        }
163
        }
161
        buf=count=0;
164
        buf=count=0;
162
    }
165
    }
163
 
166
 
164
    return  1;
167
    return  1;
165
}
168
}
166
 
169
 
167
/**
170
/**
168
 * @}
171
 * @}
169
 */
172
 */
170
 
173